RisalDash RisalDash

Guide · I²C · Troubleshooting

Your I²C sensor isn’t showing up? Here’s the fix, in order

You wired a BME280 (or an OLED, or an MPU6050), flashed your sketch, and got… nothing. The board can’t see the sensor. Nine times out of ten it’s one of four things — and they’re quick to check in the right order. Works the same on ESP32, ESP8266 and Arduino.

I²CTroubleshootingPull-upsESP32ESP8266Arduino

If you want the physical picture of what I²C actually does on the wire — START, ACK, clock stretching — see the interactive one-byte-six-buses explainer. This post is the practical counterpart: the bus is silent, now what?

ESP32 wired to a BME280 and an SSD1306 OLED on one I²C bus — SDA to GPIO21, SCL to GPIO22, sharing 3V3 and GND
A healthy I²C bus: a BME280 (0x76) and an SSD1306 (0x3C) share one SDA/SCL pair — different addresses, two wires. Built in BoardLab; drag the pins yourself and export the PNG.

Step 1 — Always scan the bus first

Never debug blind. Every I²C device answers on a 7-bit address, and you can ask the bus who’s home. Flash this and open the Serial Monitor at 115200:

#include <Wire.h>

void setup() {
  Serial.begin(115200);
  Wire.begin();               // ESP8266: D2/D1  ·  ESP32: 21/22  ·  Uno: A4/A5
}

void loop() {
  byte found = 0;
  Serial.println("Scanning I2C bus...");
  for (byte addr = 1; addr < 127; addr++) {
    Wire.beginTransmission(addr);
    if (Wire.endTransmission() == 0) {          // 0 = the device ACKed
      Serial.printf("  found device at 0x%02X\n", addr);
      found++;
    }
  }
  Serial.println(found ? "done." : "No devices found — check wiring & pull-ups.");
  delay(3000);
}

Three outcomes, three diagnoses:

Prefer a scanner on a web page instead of a serial cable? The RisalDash I2C-Scanner example lists every address with a best-guess of the chip, live in the browser.

Step 2 — Pull-up resistors (the #1 cause of a silent bus)

I²C outputs are open-drain: a device can only pull a line down to 0. What pulls it back up to logic high is a pair of pull-up resistors — one on SDA, one on SCL, to 3V3. Without them the lines float, nothing reads high, and the scan finds nothing at all.

The value is a trade-off: smaller resistance = crisper edges but more current; the datasheet limit is the bus capacitance (≤400 pF), which brings us to the next trap.

Step 3 — Long wires kill I²C

I²C was designed for chips on one board — centimetres, not metres. Every extra centimetre of wire adds capacitance, the rising edge rounds off, and past ~400 pF the master can’t tell a 1 from a 0. Symptoms: it works on the bench, then flakes out once you route the sensor across the room.

Step 4 — Two sensors, one address

The scan shows a device, but your second identical sensor is invisible — because they share the same fixed address. Two BME280s both answer on 0x76 and clobber each other. Fixes:

Still nothing? The usual last suspects

Work the list top to bottom — scan, pull-ups, wire length, addresses, then the stragglers — and a dead I²C bus almost always comes back to life within a few minutes.

Wire your own sensor and export a clean diagram — right in the browser, no Fritzing.