I2C stands for inter-integrated circuit, and is a 2-wire interface. These 2 wires are:

SDA - Serial data line SCL - Serial clock line

A typical I2C message might look like this: center Each peripheral has a 7-bit ID that is used to signify which peripheral a message is meant to be sent to. A two-byte I2C message might look like this:

Address Byteb7b6b5b4b3b2b1b0
read/writeID bit 6ID bit 5ID bit 4ID bit 3ID bit 2ID bit 1ID bit 0
Data Byteb7b6b5b4b3b2b1b0
data bit 7data bit 6data bit 5data bit 4data bit 3data bit 2data bit 1data bit 0
Like SPI, I2C has a number of configurations that are chip-dependent, and reconfiguring the driver may be necessary before sending a message to a peripheral. The core difference between the two is that SPI is roughly 10x faster than I2C, but I2C only requires 2 pins.

When wiring I2C, it’s important to remember pullup resistors on the line. It is standard for I2C pins on a device to be wired open-drain. Only one pullup resistor is necessary for a whole I2C line:

I2C wiring

⚠ Switch to EXCALIDRAW VIEW in the MORE OPTIONS menu of this document. ⚠ You can decompress Drawing data with the command palette: ‘Decompress current Excalidraw file’. For more info check in plugin settings under ‘Saving’

Excalidraw Data

Text Elements

Controller

SDA

SCL

Peripheral

SDA

SCL

Peripheral

SDA

SCL

Link to original