Terminology

Here we define some terms related to I2C.

  • SDA - Serial DAta line. This is the line the 1's and 0's go down to communicate data.
  • SCL - Serial CLock line. This is a square wave clock signal that is used to coordinate when to read the SDA line.
  • VCC - The supply voltage for power, typically 3.3V or 5V.
  • GND - Ground
  • Address - Each I2C device has a specific numerical address.
  • Pull Up Resistors - Resistors required between SCL and VCC as well as between SDA and VCC.

The I2C Bus

Here is a simple diagram showing the general arrangement of an I2C bus with several devices attached.

There are two main items that are important here:

  1. Pull up resistors between SCL/SDA and VCC
  2. Unique addresses for each device

Most I2C issues relate to something wrong with these two factors.

Pull Up Resistors

Only one set of pull up resistors are needed for the entire I2C bus. A stand alone device, like an iPhone, will have taken care of this internally. In that case, the microcontroller and all the I2C devices are self contained within the iPhone itself. But for maker applications, the microcontroller and I2C devices are typically provided as separate items. In that case, where are the pull up resistors? It depends, but in general:

  • Adafruit I2C breakouts include pull up resistors.
  • Mix mode breakouts may or may not include pull up resistors.
  • Raspberry Pi's include pull up resistors on their I2C pins.
Adafruit I2C breakouts include pull up resistors.

It's OK to have more than one pull up resistor. That would happen if you chained more than one Adafruit I2C breakout together, since each includes pull ups. The resistors will act in parallel and thus reduce the overall pull up resistance. But I2C can work with a range of pull up values, so this is generally not an issue.

Addresses

Each device on the I2C bus needs a unique address. How do you determine what the address is for any given breakout? The datasheet is the main source, but it can be a bit buried. Sometimes the address will be mentioned on the product page or in the associated learn guide. Some breakouts will print the address on the PCB itself. The source code for the sensor's library is another option, but again, can be a bit buried. That's why there's this convenient list of nothing but I2C addresses:

But it requires manually updating, so may not be 100% complete.

But also, don't worry - you don't need to know the address to perform an I2C scan. It just helps to know what to expect from the scan results.

Knowing your device I2C address is not required to perform a scan.
There are some devices that have more than one I2C address! Especially address 0x00 (which is special)

Hex Address Nomenclature

By convention, I2C addresses are reported in hexadecimal notation. That is what the leading 0x indicates. We won't discuss hex notation here, just keep in mind that when you see 0x77, it is not the same as 77.

While addresses are rarely referred in decimal, they are sometimes referenced in '8-bit' mode rather than 7-bit mode. In that case, a device with 7-bit address 0x39 would be referred to as 0x39 x 2 = 0x72

This guide was first published on Sep 16, 2021. It was last updated on Mar 27, 2024.

This page (I2C Basics) was last updated on Mar 08, 2024.

Text editor powered by tinymce.