ESP-01 ≡ Detecting I2C Devices
ESP-01 I2C address detecting circuit
#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
  • How to Set Up Arduino IDE for ESP8266 Development
  • Blink the Built-in LED
  • Connecting the ESP8266 to Wi-Fi
  • Measuring Wi-Fi Signal Strength (RSSI) with ESP8266
  • ESP-01 ≡ How to program an ESP-01?
  • ESP-01 ≡ Detecting I2C Devices
  • ESP-01 ≡ TX button and an RX LED
  • ESP-01 ≡ Blink external LED on GPIO0
  • NodeMCU ≡ Blink external LED on D0
  • NodeMCU ≡ Detecting I2C Devices

  • Buy Me a Coffee