I2C/Addresses/Two chips, one address

Two chips, one address

Two chips at one address both answer, at the same moment, on one wire. The scan shows one device, and every read returns a number built from both, with no error anywhere to say so.

Nothing stops two modules with the same address sharing a bus. Buy two LM75 boards and both arrive at 0x48; the ADS1115 analog converter's default is 0x48 too. Nothing on the bus reports the clash either.

Both chips acknowledge their address, on the same ninth clock, so a scan shows one square. Then, when the ESP32 reads, both send their bytes at once on SDA. Where one sends a 0 and the other a 1, the 0 wins: a chip can only pull the wire low, and one chip pulling is enough (lesson 9 has why). So the ESP32 reads the bitwise AND of the two answers.

At 25 °C and 22 °C, the first bytes are 0x19 and 0x16. Their AND is 0x10: 16 °C, a reading neither chip gave. Warm the first to 31 °C and the AND is 0x16, 22 °C, which is exactly the other chip's reading and looks perfectly normal. Nothing throws an error and nothing crashes. You get a wrong number that looks right.

Three fixes

  • Change an address. If the chip has address pins, set one of them on one module: A0 high moves an LM75 from 0x48 to 0x49.
  • Use the second bus. Where the pins are soldered to ground, as on our TK42, put the second module on its own pair of GPIOs. The ESP32 has two I2C controllers: Wire and Wire1.
  • Use a switch chip. A multiplexer such as TI's TCA9548A splits one bus into eight and connects one at a time; it has its own address, 0x70 to 0x77.

Edit this page — content/fundamentals/i2c/same-address.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 Fundamentals on the forum →