Rp2040 nano connect: weird values from accelerometer

Hi there,
i’m currently playing around with the accelerometer on my arduino nano rp2040 connect and don’t understand the values I get…
Basically, i’m trying to calculate the current speed in direction y without regarding that other axes would have any influence to that, too…

Well. in short, here’s my test code:

import time
from lsm6dsox import LSM6DSOX
from machine import Pin, I2C

# Initialize an I2C object.
i2c = I2C(0, scl=Pin(13), sda=Pin(12))

lsm = LSM6DSOX(i2c)

print("\n--------------------------------")
print("- Accel Monitoring Example -")
print("--------------------------------\n")

dy = 0
dt = 0.01

while (True):
    vals = lsm.read_accel()
    y = int(vals[1])

    # calculate current speed
    dy += y * dt
    print (f"speed:{dy}, acceleration:{vals}" )

    time.sleep(1 * dt)

However, while having the here on my desk without moving it I get strange values

import accel


  • Accel Monitoring Example -

speed:0.0, acceleration:(0.0, 0.0, 0.0)
speed:0.0, acceleration:(0.01013184, 0.2130127, 0.3861084)
speed:0.0, acceleration:(0.02087402, 0.4541016, 0.8231201)
speed:0.0, acceleration:(0.02026367, 0.4820557, 0.8759766)
speed:0.0, acceleration:(0.01599121, 0.480957, 0.8757324)
speed:0.0, acceleration:(0.01452637, 0.4807129, 0.8782959)
speed:0.0, acceleration:(0.01257324, 0.480957, 0.8765869)
speed:0.0, acceleration:(0.01098633, 0.4802246, 0.8776855)
speed:0.0, acceleration:(0.01147461, 0.480957, 0.8776855)
speed:0.0, acceleration:(0.01318359, 0.480835, 0.8776855)
speed:0.0, acceleration:(0.01489258, 0.4803467, 0.8763428)
speed:0.0, acceleration:(0.0168457, 0.4815674, 0.8775635)
speed:0.0, acceleration:(0.01818848, 0.4804688, 0.8778076)
speed:0.0, acceleration:(0.01806641, 0.4807129, 0.8773193)
speed:0.0, acceleration:(0.01904297, 0.480957, 0.8774414)
speed:0.0, acceleration:(0.01904297, 0.480835, 0.8775635)
speed:0.0, acceleration:(0.01879883, 0.4816895, 0.8770752)
speed:0.0, acceleration:(0.01782227, 0.4820557, 0.8778076)
speed:0.0, acceleration:(0.01623535, 0.4825439, 0.8779297)

Shouldn’t these all be zero? btw. the values don’t really change when I move the board around…
what am I doing wrong?

@iabdalkader

Which firmware version is that ? Is this MicroPython or OpenMV firmware ? If it’s our firmware, have you tried the development release ? I just ran your code seems to be working fine, even the stable release is working fine.

--------------------------------
- Accel Monitoring Example -
--------------------------------

speed:0.0, acceleration:(0.8200684, -0.2485352, -0.5213623)
speed:0.0, acceleration:(0.8249512, -0.2423096, -0.5324707)
speed:0.01, acceleration:(-0.3416748, 1.117188, 0.5230713)
speed:0.01, acceleration:(-0.2325439, 0.8411865, -0.5405273)
speed:0.01, acceleration:(-0.1154785, 0.005126953, 1.01709)
speed:0.01, acceleration:(-0.09777832, -0.0435791, 1.011597)

Traceback (most recent call last):
  File "<stdin>", line 25, in <module>
Exception: IDE interrupt
MPY: soft reboot
MicroPython: v1.18-omv-r13 OpenMV: v4.3.2 HAL: v1.3.0 BOARD: Arduino Nano RP2040 Connect-RP2040