Page 1 of 1

I2CDevice fails to probe device_address on Itsybitsy rp2040

Posted: Sat Mar 18, 2023 4:20 pm
by 2bndy5
I'm working on a lib that uses a sensor with no built-in pull-ups for the SDA and SCL lines. I've tried 4.7 kohm and 10 kohm resistors pulling up the SDA and SCL lines to 3v.

I noticed that my itsybitsy rp2040 fails to probe the specified address (0x2A) when instantiating an I2CDevice object. However, if I manually probe for the address using a busio.I2C.scan() first, then the I2CDevice object can correctly probe the device_address upon instantiation. I tried CirPy v8.0.4 and v7.3.3, and both exhibit the same behavior.

Code: Select all

import board
from adafruit_bus_device.i2c_device import I2CDevice

i2c = board.I2C()

while i2c.try_lock():
    pass
addrs = i2c.scan()  # needed on itsy rp2
i2c.unlock()
assert 0x2A in addrs,  "could not find device at address 0x2A"

device = I2CDevice(i2c, 0x2A)
I2CDevice instantiates fine without manual probing the address on my Itsybitsy M4 using either 4.7 kohm or 10 kohm resistors. So, now I'm wondering if this is still a wiring issue or an actual bug. I'm starting to suspect the later.

Code: Select all

import board
from adafruit_bus_device.i2c_device import I2CDevice

i2c = board.I2C()
device = I2CDevice(i2c, 0x2A)  # probes address correctly on itsy m4
Running the above code on itsybitsy rp2040 results in

Code: Select all

ValueError: No I2C device at address: 0x2a
However, if I run the last line again, then I2CDevice instantiates without error.

Re: I2CDevice fails to probe device_address on Itsybitsy rp2040

Posted: Sat Mar 18, 2023 5:00 pm
by 2bndy5
I'm now seeing a similar issue on github (https://github.com/adafruit/circuitpython/issues/5871), but it is related to using the pure python lib where my problem is with the builtin lib.