I2C Scanner example script (arduino.py) Lists the addresses of the I2C devices on SDA (D18) and SCL (D19), every 5 seconds, so a module can be plugged in while it runs.
Arduino's Wire has no match here, so this uses mcu.i2c() from phyduino.py.
- Wiring
- The board has no pull-up resistors on these pins. Most sensor modules include them; otherwise fit 4.7 kOhm resistors from SDA and SCL to 3.3 V. The on-board USB-PD controller is on a separate bus and does not appear.
- Output
from arduino import *
import phyduino as mcu
bus = None
def setup():
global bus
bus = mcu.i2c()
def loop():
found = bus.scan()
if found:
print("Found:", ", ".join("0x%02X" % address for address in found))
else:
print("No devices found. Check the wiring and the pull-up resistors.")
delay(5000)
def main():
setup()
while True:
loop()
if __name__ == "__main__":
main()