Home / Learn Chip Programming / I2C Protocol in Depth

I2C Protocol in Depth

Two wires, many devices: how I2C addressing, ACK and clock stretching work.

In shortTwo wires, many devices: how I2C addressing, ACK and clock stretching work.

Theory in plain words

Read a registerSTARTaddr + Wregister numberrepeated STARTaddr + Rread data + NACKSTOP
Read a register

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

Scan the bus and read a sensorTry it Yourself

Try address 0x49 (nobody home, NACK). Address conflict: two identical sensors need a different address pin or an I2C multiplexer (TCA9548A).

ItemValue
Standard / Fast / Fast+ mode100 kHz / 400 kHz / 1 MHz
Pull-up resistors4.7 k (100 kHz, short wires) to 2.2 k (400 kHz)
Address7 bit (0x08..0x77); 8 bit form = address << 1 | R/W
WiresSDA, SCL + GND (+ VCC)
Max deviceslimited by addresses and bus capacitance 400 pF
Careful:Libraries differ: Arduino uses the 7 bit address (0x3C) while datasheets may show the 8 bit form (0x78). If the scanner finds nothing, check pull-ups, GND and voltage first.

Quick quiz

1. I2C lines are...

2. What does NACK on the address mean?