'I2C' object has no attribute 'try_lock' #12419
Replies: 2 comments 4 replies
-
You cannot directly use CircuitPython drivers with MicroPython. As analternative, you might try this driver for ADS1115: https://github.com/robert-hh/ads1x15 |
Beta Was this translation helpful? Give feedback.
-
Circuitpython uses the same I2C object, but requires an additional locking step in the setup of the I2C bus. Where we have in Micropython, e.g. on the RP2 Pico: from machine import I2C, Pin # Raspberry Pi Pico, Micropython
i2c = I2C(0, sda=Pin(0), scl=Pin(1), freq=100000) In Circuitpython the equivalent is: import board # Raspberry Pi Pico, Circuitpython
from busio import I2C
i2c = I2C(sda=board.GP0, scl=board.GP1)
while i2c.try_lock(): # CP requires I2C bus locking
pass Afterwards you may use the i2c object in similar way, i.e. with the same commands. So, if changing for an MP driver for the ads1x15 seems too complicated, you also might try to find the above locking statement in the Circuitpython driver and remove it for the MP setup. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I am encountering an issue while working with the I2C in MicroPython.
I am using a KY-039 heart beat sensor with a KY-053 Analog-Digital Converter but it throws me following error: 'I2C' object has no attribute 'try_lock'
Beta Was this translation helpful? Give feedback.
All reactions