Home / Learn Chip Programming / I2C Protocol in Depth
I2C Protocol in Depth
Two wires, many devices: how I2C addressing, ACK and clock stretching work.
Theory in plain words
What it is
I2C uses SDA (data) and SCL (clock) with open-drain lines and pull-up resistors. A master starts a transfer with START, sends a 7 bit address plus R/W bit, and each byte is acknowledged.
Why we use it
Most sensors, EEPROMs, RTCs and OLED displays use I2C. Wrong pull-ups or addresses are the usual reason a sensor is not found.
How it works
START (SDA falls while SCL high), address+W, ACK, data bytes with ACK, STOP (SDA rises while SCL high). Repeated START switches from write to read without releasing the bus.
Where it is used
- MPU6050, BMP280, SSD1306, DS3231, AT24C EEPROM
- Several sensors on two wires
- Bus scanner debugging
I2C bus simulator
Try address 0x49 (nobody home, NACK). Address conflict: two identical sensors need a different address pin or an I2C multiplexer (TCA9548A).
| Item | Value |
|---|---|
| Standard / Fast / Fast+ mode | 100 kHz / 400 kHz / 1 MHz |
| Pull-up resistors | 4.7 k (100 kHz, short wires) to 2.2 k (400 kHz) |
| Address | 7 bit (0x08..0x77); 8 bit form = address << 1 | R/W |
| Wires | SDA, SCL + GND (+ VCC) |
| Max devices | limited by addresses and bus capacitance 400 pF |
Quick quiz
1. I2C lines are...
Devices only pull low; resistors pull high.
2. What does NACK on the address mean?
Nobody pulled SDA low.