Am I doing right for sensor fusion with Qwiic 9DoF - ISM330DHCX, MMC5983MA?

Hi, I am trying to get the orientation information from Qwiic 9DoF - ISM330DHCX, MMC5983MA, connecting them to ESP32 WROOM (USB-C). But there is no combined tutorial for both, like 9DOF_Razor_IMU; there are only the separated tutorials for each.:smiling_face_with_tear:

So I tried to figure out how to combine two tutorials with Gemini, and he told me to study the sensor fusion library, such as Madgwick. And my professor advised me to learn basic sensor fusion knowledge and quaternion from https://stanford.edu/class/ee267/notes/ee267_notes_imu.pdf and https://www.youtube.com/watch?si=rFtsTOHCuQdjpybt&v=6qV3YjFppuc&feature=youtu.be, and I completed them.

Now I am trying to do the sensor fusion with preprocessing(Convert Gyro units from dps to rad/s→Axis Alignment(by different z-axis)→Hard-Iron offset calibration for magnetometer)

Could anyone confirm if this workflow is appropriate for the Qwiic 9DoF board? Also, are there any specific issues or “gotchas” related to coordinate system alignment between the ISM330DHCX and MMC5983MA on this PCB that I should watch out for?

I’m still learning the fundamentals of sensor fusion, so I’d really appreciate your feedback. Thank you!

All sensor axes must be consistently aligned with respect to each other and form a right handed coordinate system. That may require you to reassign certain axis labels or signs in the code.

2 Likes

Thank you for your advice! Is there no reference or example code regarding that? I will try following your advice, but as a beginner, there’s a bit of a hurdle. I will try with Gemini even though there is nothing, but I want to avoid the black-box problem.

The data sheet shows how the sensor axes are oriented with the IC package, and inspection of the PCB shows how they are mounted. The PCB also has markings that inform you of the axial directions for each sensor. Every sensor manufacturer does it differently.

However, nothing beats running an example program to print out the raw data from each sensor, pointing the board in various directions, and making certain that YOU understand what the values and signs along X, Y and Z mean in terms of the real world directions of the gravitational and magnetic field vectors at your location.

For example, in the northern hemisphere at mid latitudes, the Earth’s magnetic field points strongly down, as well as to magnetic North (the vertical component is larger than the horizontal component).

If you don’t get this right, the resulting calculations will give meaningless results. Also, the magnetometer and gyro always require careful calibration.

You might find this AHRS example for a different sensor (ICM-20948) instructive, as two magnetometer axes need to be flipped to reconcile the coordinate systems: GitHub - jremington/ICM_20948-AHRS: Mahony Fusion Filter and Tilt compensated compass for ICM_20948

1 Like

Thank you! This is the one that I was looking for!