Matrix creator IMU issues

so I’m trying to make a balancing robot with the matrix creator at the top, using it’s IMU.
The IMU works and I get accurate readings, I however also get wrong outputs. for example:

right output (most of the time):
accel_x: -0.033000
accel_y: 0.379000
accel_z: 0.951000
gyro_x: 41.473000
gyro_y: 1.712000
gyro_z: 1.443000
yaw: 157.811295
pitch: 1.846277
roll: 21.728659
mag_x: 0.407000
mag_y: 0.166000
mag_z: -0.458000

wrong output (notice accel is wrong):
accel_x: 0.000000
accel_y: -0.224000
accel_z: 0.938000
gyro_x: 35.088001
gyro_y: 0.927000
gyro_z: 3.207000
yaw: 139.085617
pitch: 0.000000
roll: -13.431029
mag_x: 0.405000
mag_y: 0.351000
mag_z: -0.405000

this is a problem cause sometimes it’s just a random number, not an integer. So the robot thinks it’s e.g. on an angle of 53.4325 while in actuality it’s standing upright and tries to correct this.
Oh yeah, I use roll to get the current angle.

But any way of fixing this problem? Or do I have to write code that recognizes true outputs but then that means it would skip the wrong output and the robot could fall before it get’s the right command to stay upright

Hi @Pulviner,

Welcome to the community and apologies for the delayed response!

You could filter the noisy values out or maybe you could try to poll the sensors at a faster rate.

Here is the datasheet for the IMU, here is the MCU driver, and here is the thread polling the data. You should be able to use these resources to see if faster data acquisition rates are possible and implement it. If you chose to do so, you would need to flash the MCU with the new code following this guide.

Let me know if you have further questions!

Best,
Samreen