I²C (Inter-Integrated Circuit) is a multi-drop serial bus invented by Philips (now NXP) for communication between ICs on the same PCB, i.e. short distance.
I2C uses a 2-wire bus to communicate between a bus master and 1 or more slave devices. The master is a microcontroller, the slave devices are often microcontroller peripherals, but can also be an other microcontroller. Typical slave devices include:
- RTCs (Real Time Clocks)
- Temperature sensors
- GPIO expanders
Communication goes over two wires: SDA (data) and SCL (clock). The lines are pull-up to high level by resistors, and the devices can make them low level with an open-drain NFET. A communication is initiated by a master which sends a start condition:
Start and stop conditions are easily detectable; they're the only situations where SDA can change while SCL is high. All other SDA changes should take place while SCL is low.
The master then sends the slave's 7-bit address followed by a R/W bit. After 8 bits have been received the slave replies with an ACK by pulling SDA low, which is read by the master at the 9th clock pulse. Successive byte may be written by the master or the slave as the master clock SCL. Each byte is to be acknowledged by the slave. The communication ends with the stop condition: SDA going high while SCL is high.
An I2C address is 7 bits long. Many devices have the highest bits of their address fixed, while the lowest bits can be selected using 1 or more inputs on the IC. The LM75B, for instance has the address range 1001xxx\$_2\$, where the 3 least significant bits can be set via 3 inputs on the device. This allows for up to 8 LM75Bs sharing the same I2C bus.