Skip to content

Instantly share code, notes, and snippets.

@erdemarslan
Forked from projetsdiy/micropython i2c scanner
Created November 6, 2021 18:19
Show Gist options
  • Save erdemarslan/f932e7f4beaa50c202c8ec4ed734f5d5 to your computer and use it in GitHub Desktop.
Save erdemarslan/f932e7f4beaa50c202c8ec4ed734f5d5 to your computer and use it in GitHub Desktop.
Micropython i2c scanner
# Scanner i2c en MicroPython | MicroPython i2c scanner
# Renvoi l'adresse en decimal et hexa de chaque device connecte sur le bus i2c
# Return decimal and hexa adress of each i2c device
# https://projetsdiy.fr - https://diyprojects.io (dec. 2017)
import machine
i2c = machine.I2C(scl=machine.Pin(5), sda=machine.Pin(4))
print('Scan i2c bus...')
devices = i2c.scan()
if len(devices) == 0:
print("No i2c device !")
else:
print('i2c devices found:',len(devices))
for device in devices:
print("Decimal address: ",device," | Hexa address: ",hex(device))
@erdemarslan
Copy link
Author

On Raspberry Pi Pico add 10K Pullup resistor between SCL-VCC and SDA-VCC

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment