include <Wire.h>
void setup() {
Serial.begin(115200);
Wire.begin();
}
void loop() {
Serial.begin(115200);
Wire.begin();
Serial.println("\nI2C Scanner");
for (byte address = 1; address < 127; address++) {
Wire.beginTransmission(address);
byte error = Wire.endTransmission();
if (error == 0) {
Serial.print("Device found at address 0x");
if (address < 16) {
Serial.print("0");
}
Serial.print(address, HEX);
Serial.println(" !");
}
else if (error == 4) {
Serial.print("Unknown error at address 0x");
if (address < 16) {
Serial.print("0");
}
Serial.println(address, HEX);
}
}
}