Module 78 min

I2C: Two-Wire Addressable Bus

Two wires, many devices, built-in acknowledge

I2C, the Inter-Integrated Circuit bus, connects many devices using just two wires. It trades speed for wire count and addressing, which makes it ideal for sensors and small peripherals.

Just two wires

I2C uses SDA (serial data) and SCL (serial clock). Both are open-drain with pull-up resistors, meaning any device can pull a line low but none drives it high; the pull-ups do that. This shared-wire scheme is what lets many devices sit on the same two lines.

Addressing

Unlike SPI, there is no select wire. Instead each slave has an address (commonly 7 bits). The master sends a START, then the target address and a read/write bit, and only the matching slave responds. This is how one master reaches many devices over the same pair of wires.

START, STOP, and ACK

  1. START: SDA goes low while SCL is high, signalling the beginning of a transaction.
  2. Each byte is followed by an acknowledge: the receiver pulls SDA low for one clock to confirm it got the byte (ACK), or leaves it high to signal NACK.
  3. STOP: SDA goes high while SCL is high, ending the transaction.

The per-byte acknowledge is a real advantage over SPI: the sender knows whether each byte was received.

Speed and multi-master

I2C is slower than SPI (common speeds are 100 kHz standard and 400 kHz fast mode). It also supports multiple masters with an arbitration scheme, though most systems use a single master.

Watch out

I2C lines are open-drain and need pull-up resistors to work at all. Forgetting the pull-ups, or sizing them wrong for the bus capacitance, is the most common real-world I2C mistake. No pull-ups means the lines never go high and nothing communicates.