Skip to menu

Robotics with Object Pascal

ESP32-S3 super mini experience

I2C Address Search

2025.04.25 14:06

me Views:500

// i2c Address search result : I found 0x1E,

// Line connected : SDA to 4, SCL to 5 (Connection is important since all pins can be used as I2C)
// for Compass HMC5883L on ESP32-S3 Supermini


#include "Wire.h"

void setup() {
  Serial.begin(115200);
  Wire.begin(4, 5); // SDA:4, SCL:5
  while (!Serial) {delay(100);};
}

void loop() {
  byte error, address;
  int nDevices = 0;

  delay(5000);
  Serial.println("Scanning for I2C devices ...");
  for (address = 0x01; address < 0x7f; address++) {
    Wire.beginTransmission(address);
    error = Wire.endTransmission();
    if (error == 0) {
      Serial.printf("I2C device found at address 0x%02X\n", address);
      nDevices++;
    } else if (error != 2) {
      Serial.printf("Error %d at address 0x%02X\n", error, address);
    }
  }
  if (nDevices == 0) {
    Serial.println("No I2C devices found\n");
  } else {
    Serial.println("done\n");
  }
}

 

I2C_Address_Search.png

 

 

No. Subject Author Date Views
Notice For the first time user of ESP32-S3 super mini users. me 2025.04.25 562
11 Object Pascal App getting data from ESP32-S3 (Parsing) file me 2025.04.29 474
10 Sound Sensor Test file me 2025.04.27 475
9 Laser distance sensor VL53L0X file me 2025.04.27 501
8 9DOF : Getting Pitch & Roll with ICM20948 v2 file me 2025.04.27 479
7 Formating output file me 2025.04.27 474
6 Blinking Built-in RGB without delay() me 2025.04.25 2362
5 Built-in RGB led Demo me 2025.04.25 496
4 Servo Demo me 2025.04.25 474
3 HMC5883L Compass demo file me 2025.04.25 490
» I2C Address Search file me 2025.04.25 500
1 Serial Sample (ASCII Table) me 2025.04.25 475