#include <Wire.h>
#define SDA_PIN 6 // Adjust if needed
#define SCL_PIN 7 // Adjust if needed
void setup() {
Serial.begin(115200);
Wire.begin(SDA_PIN, SCL_PIN);
Serial.println("\nI2C Scanner starting...");
}
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 address 0x");
if (address < 16) Serial.print("0");
Serial.print(address, HEX);
Serial.println(" !");
nDevices++;
}
}
if (nDevices == 0) {
Serial.println("No I2C devices found\n");
} else {
Serial.println("Scan complete\n");
}
delay(5000); // Wait 5 seconds before next scan
}
Loading
esp32-c3-devkitm-1
esp32-c3-devkitm-1
Loading
grove-oled-sh1107
grove-oled-sh1107