Addresses
Every chip on an I2C bus has a seven-bit number, its address, and the controller puts it at the front of every message. The chip with that number answers and every other chip lets the message go by.
Every module on the bus hears every message, so each message has to say who it is for. It does that with the first thing the controller sends after the start: an address, seven bits long. Every chip compares it with its own and only the one that matches takes part. The rest ignore everything until the next start.
Addresses are written in hex. A few that turn up on modules, each from its chip's datasheet:
| Chip | Address |
|---|---|
| SSD1306 OLED | 0x3C (or 0x3D) |
| SHT31 humidity | 0x44 (or 0x45) |
| LM75 temperature | 0x48 to 0x4F |
| AT24C32 memory | 0x50 to 0x57 |
| DS3231 clock | 0x68 |
Choosing part of the address
The chip's maker fixes most of the address. Many chips let you set the last few bits with pins. The LM75 has three, A2, A1 and A0: tie each to ground for 0 or to the supply for 1, and the chip answers anywhere from 0x48 (all three low) to 0x4F (all three high). Many modules solder those pins to ground on the board, our TK42 among them, and then the address is fixed.
Send to an address nobody has and nothing happens: no module answers, and nothing on the bus complains. The next lesson is how the ESP32 notices.
128 numbers, 112 usable
Seven bits make 128 addresses. The specification reserves two groups of eight, 0x00 to 0x07 and 0x78 to 0x7F, for jobs such as calling every chip at once, which leaves 112 for modules. Version 1.0 in 1992 added ten-bit addresses for buses that run out; almost no module uses them.
Edit this page — content/fundamentals/i2c/addresses.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.