#include <Wire.h>
#define SDA_PIN 6 // ESP32-C6 LP_I2C_SDA
#define SCL_PIN 7 // ESP32-C6 LP_I2C_SCL
void setup() {
Serial.begin(115200);
delay(2000);
Serial.printf("\nESP32-C6 I2C Scanner (SDA=%d, SCL=%d)\n", SDA_PIN, SCL_PIN);
Wire.begin(SDA_PIN, SCL_PIN, 100000); // 100kHz
}
void loop() {
byte error, address;
int nDevices = 0;
Serial.println("Scanning...");
for (address = 1; address < 127; address++) {
Wire.beginTransmission(address);
error = Wire.endTransmission();
if (error == 0) {
Serial.print("I2C device found at 0x");
if (address < 16) Serial.print("0");
Serial.println(address, HEX);
nDevices++;
}
else if (error == 4) {
Serial.print("Unknown error at 0x");
if (address < 16) Serial.print("0");
Serial.println(address, HEX);
}
}
if (nDevices == 0)
Serial.println("No I2C devices found\n");
delay(2000);
}
Loading
esp32-c6-devkitc-1
esp32-c6-devkitc-1