Find I2C devices
List the addresses of everything on the I2C bus.
A starter program from the MantisIDE Full IDE (Tools › Examples). Press Open in Full IDE to run it on your board, change it, and save it as your own.
# List the addresses of everything on the I2C bus.
from machine import Pin, I2C
i2c = I2C(0, scl=Pin(22), sda=Pin(21)) # Pico: I2C(0, scl=Pin(5), sda=Pin(4))
found = i2c.scan()
if found:
print("Found:", [hex(a) for a in found])
else:
print("Nothing found. Check wiring and pull-up resistors.")
Comments