- #I2C Scanner
- # SDA Physical pin #1 - GP0
- # SCL Physical pin #2 - GP1
- # GND Physical pin #3 - GND
- # 3V3 Physical pin #36 - 3V3
- import time
- import board
- import busio
- i2c = busio.I2C(scl=board.GP1, sda=board.GP0)
- while not i2c.try_lock():
- pass
- chipCount = 0
- try:
- while True:
- print("Scanning....")
- theAddresses = [hex(device_address) for device_address in i2c.scan()]
- for i in theAddresses:
- chipCount += 1
- print("Chip",chipCount," = ",i)
- print("========================")
- time.sleep(4)
- chipCount = 0
- finally: # unlock the i2c bus when ctrl-c'ing out of the loop
- i2c.unlock()
I2C Scanner
Posted by Anonymous on Thu 26th Jan 2023 20:25
raw | new post
Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.