cancel
Showing results for 
Search instead for 
Did you mean: 

LIS3MDL Magnetometer Calibration

Pierre700
Associate

Hi,

From what I've been told, the LIS3MDL magnetometers self-calibrate upon turning on. I have taken some readings from 3 different LIS3MDL's and plotted the values in a similar way to the beginning of this tutorial:

https://thecavepearlproject.org/2015/05/22/calibrating-any-compass-or-accelerometer-for-arduino/

My plots, which I will include, show quite significant hard and soft iron distortions. So, it seems that the magnetometers are not correctly calibrating when powered on / are not calibrated.

How could I go about calibrating them?

The data points here I took by taking 750 readings with a 0.1 sec delay between each. I moved the magnetometer around in the air to trace a small sphere. Red = XY, Blue = XZ, Green = YZ. In the 3d plot, I projected the XY, XZ, and YZ points onto each axis (XY projected onto the Z axis, XZ projected onto the Y axis, YZ projected onto the X axis). While the black points are simply plotting the (X, Y, Z) into 3d space. From what I have read, if the magnetometer is calibrated correctly: for the 2d plot, each ellipse should be a circle and they should all be overlapping each other with the center at the origin; and for the 3d plot, each projection should be a circle and the black points a sphere - instead they are clearly ellipses & ellipsoid, and again should be centered on the origin.

0690X000008aEipQAE.pngEx.1A - Readings from magnetometer A in 2d0690X000008aEj4QAE.pngEx.2A - Readings from magnetometer A in 3d

0690X000008aEklQAE.pngEx. 1B - Readings from magnetometer B in 2d

0690X000008aEkqQAE.pngEx. 2B - Readings from magnetometer B in 3d

Plz let me know if i'm being stupid - i'm no expert in this stuff. Actually I was only introduced to this a few days ago, so I could very well be misunderstanding something.

Thanks

1 REPLY 1
Eleon BORLINI
ST Employee

Hi,

>> How could I go about calibrating them?

Did you already use the X-CUBE-MEMS1 eCompass calibration algorithm library? --> https://www.st.com/resource/en/user_manual/dm00396079.pdf

Regards