#include <Wire.h>
void setup() {
Wire.begin(0, 2);
Serial.begin(115200);
}
void loop() {
scanI2CDevices();
delay(5000);
}
void scanI2CDevices() {
for (byte address = 1; address < 127; ++address) {
Wire.beginTransmission(address);
if (Wire.endTransmission() == 0)
Serial.println("Device found at 0x" + String(address < 16 ? "0" : "") + String(address, HEX));
}
}
ESP-01 has no default pins for I2C communication, so we are forced to use GPIO0 for SDA and GPIO2 for SCL.
ESP-01 ESP-01S
19 Nov. 2024
|
Last Updated: 22 Nov. 2025
|
jaimedcsilva Related