I am trying to get the IMU unit to work on my Nano RP2040.
I get these same results on multiple Arduino Nano RP2040s
I installed the python library into the rp2040 using the command ./mpremote.exe mip install github:jposada202020/MicroPython_LSM6DSOX and ran the following code:
import time
from machine import Pin, I2C
from lib.micropython_lsm6dsox.lsm6dsox import LSM6DSOX
# from lsm6dsox import LSM6DSOX
i2c = I2C(1, sda=Pin(2), scl=Pin(3)) # Correct I2C pins for RP2040
print(str(i2c))
devices = i2c.scan()
print(str(devices))
if devices:
for d in devices:
print(hex(d))
time.sleep(1)
time.sleep(1)
lsm = LSM6DSOX(i2c)
while (True):
print('Accelerometer: x:{:>8.3f} y:{:>8.3f} z:{:>8.3f}'.format(*lsm.accel()))
print('Gyroscope: x:{:>8.3f} y:{:>8.3f} z:{:>8.3f}'.format(*lsm.gyro()))
print("")
time.sleep_ms(100)
and got:
MPY: soft reboot
I2C(1, freq=399361, scl=3, sda=2, timeout=50000)
[]
106 15 1 #this is coming from a debug line I wrote to print 'obj._address, self.register, self.lenght' in the 'RegisterStruct' class of i2c_helpers.py
Traceback (most recent call last):
File "<stdin>", line 14, in <module>
File "lib/micropython_lsm6dsox/lsm6dsox.py", line 159, in __init__
File "/lib/micropython_lsm6dsox/i2c_helpers.py", line 120, in __get__
OSError: [Errno 116] ETIMEDOUT
When I try the same thing using the following I2C config, I get:
i2c=I2C(0, scl=Pin(13), sda=Pin(12))
MPY: soft reboot
I2C(0, freq=399361, scl=13, sda=12, timeout=50000)
[106]
0x6a
106 15 1
Traceback (most recent call last):
File "<stdin>", line 16, in <module>
AttributeError: 'LSM6DSOX' object has no attribute 'accel'
I am trying to get the IMU unit to work on my Nano RP2040.
I get these same results on multiple Arduino Nano RP2040s
I installed the python library into the rp2040 using the command ./mpremote.exe mip install github:jposada202020/MicroPython_LSM6DSOX and ran the following code:
and got:
When I try the same thing using the following I2C config, I get:
i2c=I2C(0, scl=Pin(13), sda=Pin(12))