Inter-Integrated Circuit (I2C) is yet another serial communication capability, and is often called Two Wire Interface (TWI). It's synchronous like SPI; the master device generates and provides a clock. If you've worked with it you'll have noticed the clock (SCL) and data (SDA) lines. That's where the two-wire in the name comes from. Because there is only a single data line, I2C is half duplex, meaning that data can only go in one direction at a time.

One great advantage of I2C is that it is bus based, with each device having an address. The address of a specific device is included in the data in order to talk to that device. This is one of the primary differences from SPI: device addressing is part of the communication, not part of the hardware connection. This makes it far more flexible in terms of supporting many devices without additional hardware. The downside is that there's overhead in the communication itself, meaning that data can't be moved around as quickly. Another downside is that since device addresses are part of the communication, they have to be unique on the bus. If you need to use multiple copies of a device with the same address, you need to use an I2C multiplexer. Some devices offer an alternative: they have pins that are used to set their address. The 23017 is a prime example of this.

A great many of Adafruit's sensor breakouts are I2C based which makes putting together projects quick and easy, with just a few wires.

This guide was first published on May 29, 2018. It was last updated on May 29, 2018. This page (I2C) was last updated on May 19, 2019.