Projects / I²C address explorer

I²C address explorer

Intermediate30 minGuided buildReviewed
ESP32 DevKitGPIO21GPIO223V3GNDBME2800x3C OLED0x76 BME2802 device(s)Scan result
0x3C OLED SSD1306

Tap a part to see what it does.

Tap the parts to see what each one does. A teaching simulation, not a circuit simulator.

Build it step by step

0 of 4 done
  1. ESP32

    Wire the bus

    SDA to GPIO21 and SCL to GPIO22 for every module.

  2. ESP32

    Upload

    Open the serial monitor at 115200.

  3. ESP32

    Add and remove

    Add a module, press EN, see the new address.

  4. ESP32

    Try a clash

    Two modules with the same address: note that only one line appears.

In short

How do you build an i²C address explorer?

A scanner sketch lists every I²C device it finds, names the common ones, and shows the result on an OLED: the first thing to run when a module will not respond. You need ESP32 DevKit V1, SSD1306 OLED Display, BME280 Environmental Sensor and Breadboard 830 Tie Points. It takes 4 steps and about 30 minutes.

Level
Intermediate
Time
About 30 min
Parts
4

Parts list

Tick what you already own. It saves to My Garage, so “Build with what I have” knows.

Wiring

FromToWhy
All SDAGPIO21Data
All SCLGPIO22Clock
All VCC / GND3V3 / GNDPower

Code

Library: Adafruit SSD1306 (the scan works without the OLED too). Press EN to rescan after changing modules.

Runs on a virtual ESP32 Dev Module in your browser, with sliders for the sensors. Happy with it? Verify and upload to your real board from the same page (Chrome or Edge on a computer).

#include <Wire.h>
#include <Adafruit_SSD1306.h>
Adafruit_SSD1306 oled(128, 64, &Wire, -1);

const char* nameOf(byte a) {
  switch (a) {
    case 0x3C: case 0x3D: return "OLED SSD1306";
    case 0x76: case 0x77: return "BME/BMP280";
    case 0x68: return "MPU6050 / DS3231";
    case 0x40: return "INA219";
    case 0x27: case 0x3F: return "LCD backpack";
    case 0x48: return "ADS1115";
    default: return "unknown";
  }
}

void setup() {
  Serial.begin(115200); Wire.begin(21, 22);
  bool oledOk = oled.begin(SSD1306_SWITCHCAPVCC, 0x3C);
  if (oledOk) { oled.clearDisplay(); oled.setTextColor(SSD1306_WHITE); oled.setCursor(0, 0); }
  int found = 0;
  for (byte a = 1; a < 127; a++) {
    Wire.beginTransmission(a);
    if (Wire.endTransmission() == 0) {
      found++;
      Serial.printf("0x%02X  %s\n", a, nameOf(a));
      if (oledOk) oled.printf("0x%02X %s\n", a, nameOf(a));
    }
  }
  Serial.printf("%d device(s)\n", found);
  if (oledOk) { oled.printf("%d device(s)", found); oled.display(); }
}

void loop() {}

What the serial monitor should show

Open the serial monitor at the baud rate in the code. This is what our simulator prints for a virtual ESP32 Dev Module with its sensors at their default values. Your numbers will follow your real readings, but the format should match.

0x3C  OLED SSD1306
0x76  BME/BMP280
2 device(s)

Test checklist

What you should see at each check. If a reading is far off, stop and use the troubleshooting list.

CheckExpected
OLED and BME280Lists 0x3C and 0x76
Unplug the BME280, press ENOnly 0x3C
Swap SDA and SCL0 devices, nothing breaks

If it does not work

0 devices

Swapped lines, missing ground, or a 5 V-only module.

Every address found

SDA or SCL shorted to ground.

Unknown address

Search the module's chip name; many have an address pin.

Still stuck? Find the fault step by step with your multimeter →

Ask Lark AI

Common questions

What parts do I need for the i²C address explorer?

ESP32 DevKit V1, SSD1306 OLED Display, BME280 Environmental Sensor and Breadboard 830 Tie Points.

How long does the i²C address explorer take to build?

About 30 minutes for a intermediate maker, in 4 steps.

How do I know the i²C address explorer works?

OLED and BME280: Lists 0x3C and 0x76. Unplug the BME280, press EN: Only 0x3C. Swap SDA and SCL: 0 devices, nothing breaks.

0 devices: what should I check?

Swapped lines, missing ground, or a 5 V-only module.

Every address found: what should I check?

SDA or SCL shorted to ground.

Unknown address: what should I check?

Search the module's chip name; many have an address pin.