I noticed an interesting thing on a feather M0 express with nothing attached, if you scan for I2C devices you actually get random results. It's not necessarily a bug in CircuitPython but something worth noting that might trip folks up. Here's an example of scanning with nothing connected:
>>> import busio
>>> import board
>>> i2c = busio.I2C(board.SCL, board.SDA)
>>> while not i2c.try_lock():
... pass
...
>>> i2c.scan()
[65, 102]
>>> i2c.scan()
[33, 71]
>>> i2c.scan()
[]
>>> i2c.scan()
[65, 102]
>>> i2c.scan()
[]
Likely this is from the SCL and SDA pins not having internal pull-ups applied and floating to random high/low values. I wonder would it make sense to automatically turn these pull-ups on when I2C is initialized or even the board resets?
Impact-wise this isn't a huge issue. The only trouble it might cause is with drivers that validate the device exists by scanning for them first. In super rare cases they might get a false positive with nothing connected and interpret random noise as the expected I2C scan result. The driver will eventually fail when it tries to talk to the device, but it might be nice to catch it earlier if possible.
As far as I2C behavior goes it's all good once you plug in a device (which has its own pull-ups), I get a steady and expected I2C scan result:
>>> i2c.scan()
[116]
>>> i2c.scan()
[116]
>>> i2c.scan()
[116]
I noticed an interesting thing on a feather M0 express with nothing attached, if you scan for I2C devices you actually get random results. It's not necessarily a bug in CircuitPython but something worth noting that might trip folks up. Here's an example of scanning with nothing connected:
Likely this is from the SCL and SDA pins not having internal pull-ups applied and floating to random high/low values. I wonder would it make sense to automatically turn these pull-ups on when I2C is initialized or even the board resets?
Impact-wise this isn't a huge issue. The only trouble it might cause is with drivers that validate the device exists by scanning for them first. In super rare cases they might get a false positive with nothing connected and interpret random noise as the expected I2C scan result. The driver will eventually fail when it tries to talk to the device, but it might be nice to catch it earlier if possible.
As far as I2C behavior goes it's all good once you plug in a device (which has its own pull-ups), I get a steady and expected I2C scan result: