How to Find and Use the Address of an I2C Device

Nucleo STM32F446 board



In this article, we explain how to find and use the address of an I2C device.

I2C is a commmunication protocol in which a master device such as an STM32 board or arduino communicates with a slave device such as an accelerometer or an RTC chip.

I2C can only have one master device but can have several slave devices on its bus.

The way it is able to uniquely identify any single slave device over any of the others is through the slave device's address.

Each slave device has its own assigned address and normally each device has an alternative address.

Why is this?

Even though I2C communication can only have one master device (such as a microcontroller such as an STM32 board or arduino), it can have multiple slave devices. If any of these slave devices have the same I2C address, this creates a conflict. Each slave device on an I2C bus must have its own unique address. Thus, if 2 slave devices on a bus have the same address, you must use the alternative address of one slave device.

Keep in mind that the I2C address is not one that you assign to the device; it is assigned by the manufacturer, and you can find this address, along with the alternative address, in the datasheet of the device.

Whether you use the original address or the alternative address, you must take account the ALT address pin of the chip.

The ALT address pin is the pin that determines whether you use the original address or the alternative address.

You can set the slave device to respond to either address by adjusting the logic state of the ALT address pin.

With the ADXL345 accelerometer device, having the ALT address pin in a HIGH state makes the slave have the original address. Having the ALT address pin in a LOW state makes the slave have the alternative address.

Below are the addresses of the ADXL345 accelerometer device.


ADXL345 accelerometer I2C addresses


If, for example, with the ADXL345 accelerometer chip, you are using the address of 0x1D followed by the R/W bit, the ALT address pin would need to be kept at a HIGH logic state. If you want to use the alternative address of 0x53 followed by the R/W bit, the ALT address pin would need to be kept in a LOW logic state (tied to GND) .

This is how the address and alternative addresses work.



Related Resources





HTML Comment Box is loading comments...