I’m accessing IMU data in ReachRS via Egor’s (@egor.fedorov) MPUtest library. Most sensor values are working as expected (accel_x, accel_y, accel_z, gyro_x, gyro_y, gyro_z, and temperature). However, magnetometer readings only work sporadically, mostly the values returned are zero for all three axes.
Restarting ReachRS sometimes results in good data but usually not.
I know that the IMU is not yet officially supported but I am asking for help on the small chance that somebody has already solved this issue.
@JR_MH I see you had a similar problem. Did you find a solution?
I will try disabling the first reset of the AK8963 magnetometer in the initialization routine tomorrow (MPU9250.cpp) (I don’t have access to the hardware right now).
//{0x80, MPUREG_PWR_MGMT_1}, // Reset Device - Disabled because it seems to corrupt initialisation of AK8963
i did use this with my arduino maybe someone can port this …
The calibration of the magnetometer is required to compensate for Magnetic Declination. The exact value of the correction depends on the location. There are two variables that have to calibrated: yaw and magbias.
i did use Permanent Calibration…
I now have IMU data streaming from ReachRS. The magnetometer passes the self-test but the values do not look right. I will implement the calibration procedure you have pointed me to and see it this improves things.
You need the formulas for a “tilt compensated compass”.
These links will get you started.
The tilt compensated compass only works while Reach is static. If you what the orientation of Reach while dynamic then you will need to use one of the more complicated sensor fusion libraries like this one (https://github.com/micropython-IMU/micropython-fusion).