Scans the given I2C pins for responsive device(s) and returns their respective addresses.

⚙ Hardware Needed


📚 External Libraries Needed


None

📑 Code


import time 
import board
import busio
 
i2c = busio.I2C(board.SCL, board.SDA)
 
while not i2c.try_lock():
    pass
 
while True:
    print("I2C addresses found:", [hex(device_address) for device_address in i2c.scan()])
    time.sleep(2)