Skip to main content

Does the Raspberry Pi 3 B+ support I2C?

Raspberry Pi GPIO
Raspberry Pi GPIO (Image credit: Jerry Hildenbrand / Android Central)

Best answer: Yes. The Raspberry Pi supports the I2C interface through its GPIO header. It's disabled by default so you'll need to enable the hardware and install some utilities before you can use it.

Amazon: Raspberry Pi 3 B+ (opens in new tab) ($40)

What's an I2C interface?

The I2C interface (it's actually I²C or I-squared-c but nobody wants to type that, hence the nickname) is the end point of an inter-integrated circuit serial bus that doesn't need high-speed communication. The transmission is synchronous and packet-switched and can host multiple masters and multiple slave devices on the same bus. You'll find it used anywhere. Simplicity is more important than speed and it's commonly used for attaching sensors or monitoring equipment.

For hobby applications, the I2C bus is commonly used to attach a PC board to an LCD. An I2C backpack board can trim the number of connections needed from 16 down to two, and with I/O pins always in short supply, that makes the I2C bus very valuable for many projects. To learn more about the I2C bus and Serial communications in general, Sparkfun has a great primer to get you started.

Using the I2C interface on the Raspberry Pi

By default, your Raspberry Pi has the I2C interface disabled. Don't worry, it's easy to enable it.

You'll use the same configuration tool you saw when you first turned on your Raspberry Pi. To bring it back, type sudo raspi-config from the command line. You'll find the option to enable the I2C option under Interfacing Options.

After a reboot, you can then install any utilities and debugging tools such as i2c-tools or the python-smbus libraries through the standard package manager using the apt-get command. Your project and the coding language you're using will determine exactly what extras you'll need to communicate over the I2C bus using the standard GPIO pins on your Raspberry Pi 3 B+.

Jerry Hildenbrand
Jerry Hildenbrand

Jerry is an amateur woodworker and struggling shade tree mechanic. There's nothing he can't take apart, but many things he can't reassemble. You'll find him writing and speaking his loud opinion on Android Central and occasionally on Twitter.