I2C looks simple with two wires, but because «1» comes from open-drain outputs and pull-ups, and devices are picked by address, a failure can come from several places. The steps below go from the least effort up. Figures follow NXP's I2C specification UM10204 Rev. 7.
| Symptom | Likely causes | Check first |
|---|---|---|
| Every device NACKs (no ACK after the address) | No pull-ups, address notation mix-up, missing power or GND | Steps 1–2 |
| One device NACKs | Address pin (A0, A1) wiring, two devices at one address, voltage levels | Steps 2–3 |
| Works, then hangs with SDA stuck at 0 | The master reset mid-read and a device still holds a 0 | Step 4 |
| Occasional errors after lengthening the wires | More bus capacitance slows the rising edge; noise | Steps 1, 5 |
1. Pull-up resistors
Devices only pull SCL and SDA down; the pull-ups make the 1 (UM10204 §3.1.1). Without them the lines never rise and no device answers. With power off, measuring SDA–VDD and SCL–VDD roughly shows the pull-up value. If every module carries its own pull-ups they add up in parallel and can get too small — check the combined value with the «Parallel Resistor Calculator».
Pick a value between two limits (UM10204 §7.1). Too small and devices cannot pull the line low; too large and the line's capacitance makes the rise slower than the specification allows.
Rp(min) = (VDD − VOL(max)) ÷ IOL VOL = 0.4 V, IOL = 3 mA (Standard, Fast) / 20 mA (Fast-mode Plus) Rp(max) = tr ÷ (0.8473 × Cb) tr = 1000 ns (100 kHz) / 300 ns (400 kHz) / 120 ns (1 MHz)
Example: at 3.3 V, 400 kHz and 100 pF of bus capacitance, Rp(min) = (3.3 − 0.4) ÷ 3 mA ≈ 967 Ω and Rp(max) = 300 ns ÷ (0.8473 × 100 pF) ≈ 3.54 kΩ, so use a value in between. At 100 kHz the maximum widens to about 11.8 kΩ. Cb is the sum of wire, connector and pin capacitance; if unsure, start toward the smaller (faster) value and check the waveform.
2. Address
- I2C addresses are 7 bits, and the first byte is «7-bit address + R/W bit» (§3.1.10). If a datasheet gives 8-bit values (write 0x90, read 0x91), the 7-bit address is 0x48. Check which form your library expects.
- A floating address pin (A0, A1, ADDR) has no defined value. Tie it to GND or VDD as the datasheet says.
- The two groups 0000 xxx and 1111 xxx (16 addresses) are reserved (§3.1.12). A first byte starting 1111 0xx is 10-bit addressing.
- Two devices at the same address both answer and the data collides. Remove them one at a time to find it.
3. Voltage levels
Inputs read below 0.3 × VDD as 0 and above 0.7 × VDD as 1 (table 10). A 5 V device on a bus pulled up to 3.3 V needs 3.5 V for a 1, so it may not see 3.3 V as 1. Pull up to 5 V instead and a 3.3 V device's input may be over its maximum. Separate devices with different supplies with a bidirectional I2C level shifter. Some legacy devices have fixed 1.5 V / 3.0 V thresholds; check the datasheet.
4. Clearing a stuck bus (SDA held at 0)
If the master resets while reading, the device keeps holding SDA low, waiting for the next clock while sending a 0 bit. The master then cannot create a start condition and the bus looks hung.
- If SDA is stuck low, the master sends nine SCL pulses; the device should release SDA within them (UM10204 §3.1.16). Then send a stop and start again.
- If the MCU's I2C peripheral refuses to clock because the bus is busy, switch the pins to GPIO briefly and toggle SCL by hand.
- If nine pulses do not help, or SCL is the one stuck low, use the device's hardware reset or cycle its power (§3.1.16).
- Doing this sequence at every firmware start-up removes many «only a reboot fixes it» field faults.
5. Wire length, capacitance, noise
- The bus capacitance limit is 400 pF at 100 and 400 kHz and 550 pF at 1 MHz (Fast-mode Plus) (table 11). The limit is capacitance, not length, so work it out from the cable's capacitance per metre (cable datasheet).
- Over the limit: lower the clock, split the bus with higher-drive (Fast-mode Plus) parts or bus buffers, or change the pull-ups (§7.2).
- For ribbon cable over 10 cm, order the wires SDA, VDD, VSS, SCL so a supply line sits between the signals. With twisted pairs, twist each signal with VSS (§7.5).
- If the bus must leave the box for several metres, look at a differential link (RS-485, CAN) or differential I2C buffer chips instead.
6. Checking with a logic analyzer
- Capture SCL and SDA and decode them as I2C in your logic analyzer software: start, repeated start, stop, address, R/W, ACK/NACK and data appear in a table.
- NACK right after the address → address, power, pull-ups. NACK in the middle of data → the device does not accept that register or length (see the datasheet's write sequence).
- Sample several times faster than SCL. If SCL and SDA change in the same sample, a start or stop can be missed.
- A logic analyzer cannot show a slow, rounded rising edge. Use an oscilloscope to see the rise time.
Sources
- NXP UM10204 I2C-bus specification and user manual Rev. 7.0 — §3.1.1 pull-ups, §3.1.10 address and R/W, §3.1.12 reserved addresses, §3.1.16 bus clear, tables 10–11, §7.1 pull-up equations, §7.2 above the capacitance limit, §7.5 wiring
Published 2026-11-01