I2C.scan() returns nothing.
Posted: Wed Sep 22, 2021 9:16 pm
I'm trying to see the devices on the I2C bus on an AdaFruit QTPy RP2040. I know that there should be devices at 0x18 and 0x20:
Output is:
>>> %Run -c $EDITOR_CONTENT
hello
b'123'
[] 0
Thanks,
Dave
Code: Select all
#==========================================================
# i2c-scan.py
#
# Drive an i2c lcd display through an Adafruit MCP2040
# QT-PY 2040. This file uses the MicroPython tools and
# was created in Thonny.
#
# Created: 2021-09-15
#==========================================================
import rp2
import machine
lcdAddr = 0x72
# These all need to be used as a group or you get an error.
lcdBus0 = 0
sda0_pin = machine.Pin(8)
scl0_pin = machine.Pin(9)
# These all need to be used as a group or you get an error.
lcdBus1 = 1
sda1_pin = machine.Pin(6)
scl1_pin = machine.Pin(7)
print("hello")
i2c1 = machine.I2C(lcdBus1, scl=scl1_pin, sda=sda1_pin, freq=100000)
output = i2c1.scan()
print(output, len(output))
print("Done")
>>> %Run -c $EDITOR_CONTENT
hello
b'123'
[] 0
Thanks,
Dave