User Tools

Site Tools


check_device_i2c_address

This is an old revision of the document!


Check Device I2C Address

Aug 2026


Introduction


When you attach a device on the I2C bus, even though you might know it's address, it's a great idea to run a test to see if you can read it's actual address.

In this example, I have an LCD address on I2C bus zero, and I know it's address is 3C0 Hex, which in decimal is 60.


I2C Address Check


Below is the code we need to run to check for devices on the I2C.

download
from machine import Pin, I2C

i2c = I2C(0, scl=Pin(5), sda=Pin(4), freq=200000)
print("I2C addresses:", i2c.scan())

There are a couple of considerations around this code, and they are:

  • i2c = I2C(0 - The Zero is for Bus 0

The Pico has Bus 0 and Bus 1, and you should know which you used.

  • scl=Pin(5), sda=Pin(4)

These are the Pico pins your device is connected to, so scl(5) is Pico Pin 7 and sda(4) is Pico pin 6.

If you run the code above, you will see something similar to below:


check_device_i2c_address.1787090801.txt.gz · Last modified: by walkeradmin