ESP32/Wires on the board/26. I2C addresses and conflicts
No board required

This one is about the wire, not the chip. Nothing below changes with the board you picked, which is why the chip and language switches are not on it. They come back on the ESP32 pages this one sits underneath.

Wires on the board · 26 of 81

I2C addresses and conflicts

An I2C address is seven bits, which is 128 seats, and almost every module you own was born in one of about twenty of them. Two devices in the same seat both answer, and the bus has no way to tell them apart.

/esp32/i2c-addresses-and-conflicts · any board · 8 min read

Switch modules on and watch where they land. The pair it opens with is the one that catches most people.

128 seats, and no reserved list
2 modules on two wires
grey = reserved by the standard111 seats free
Move one with its jumper
MPU6050 and DS3231 RTC are both at 0x68. They will answer the same address together and the bus reads the two replies mashed into one. Move whichever one can move — MPU6050: AD0 pin to 3V3; DS3231: fixed — no jumper exists.

Why the space is mostly empty and still crowded

Of the 128 addresses, the standard reserves sixteen — the lowest eight for general-call and bus commands, the highest eight for 10-bit addressing — which leaves 112 usable. Almost nothing uses most of them. Chip designers pick from the same handful of defaults, so displays cluster around 0x3C, pressure and humidity sensors around 0x76, real-time clocks and motion sensors around 0x68.

There is no registry and no negotiation. The address is a fact about the silicon, decided years before your project.

The three ways a device can move

A jumper or a solder blob. Most breakouts bring one or more address pins out. Tying one high moves the device by one: an MPU6050 with AD0 to 3V3 goes from 0x68 to 0x69. Expanders like the PCF8574 bring out three pins and give you eight consecutive slots.

Nothing. A DS3231 real-time clock is 0x68 and cannot be anything else. When a fixed device collides with a movable one, the movable one moves.

Neither can move. Two identical sensors, no address pins. Now you need either a second bus or a multiplexer.

The classic collision. A DS3231 clock and an MPU6050 motion sensor are both extremely common, both live at 0x68, and neither datasheet mentions the other. The clock is fixed, so the MPU moves — one wire from AD0 to 3V3 and both work.

Finding out, in ten seconds

Run the scanner from the previous page before you write any device code. Two things it tells you that nothing else will:

  • An address you did not expect is usually a module with its jumper already bridged, or a datasheet quoting the 8-bit form. 0x78 in the datasheet and 0x3C on the scan are the same device.
  • A collision often shows as one address that behaves erratically, not as an error. Both devices ACK, both start replying, and the wire ANDs the answers together into something plausible.

When nothing can move

A second bus. The ESP32 has two I2C peripherals, and on most Arduino cores you can put either on almost any pair of pins. Two identical sensors, two buses, two TwoWire objects. Cheapest fix by far when you have pins spare.

#include <Wire.h>

#define SDA_B 16
#define SCL_B 17

TwoWire busB = TwoWire(1);         // the second I2C peripheral

void setup() {
  Wire.begin();                    // default pins, sensor one
  busB.begin(SDA_B, SCL_B);        // any spare pair, sensor two, same address
}

A TCA9548A multiplexer. One chip at 0x70 with eight downstream buses. You write one byte to pick a channel, then talk to the device behind it as normal. Eight identical sensors, one pair of pins, and the only cost is a register write between reads.

The habit worth forming

Write the address next to the module in your notes, in 7-bit form, the day you wire it. Every hour lost to this is an hour spent assuming a library knows something it was never told.

Edit this page — content/esp32/i2c-addresses-and-conflicts.mdx

Discuss this article

Ask about this page. The answer stays here, on the page it belongs to, for whoever hits the same wall next.

Browse ESP32 on the forum