Skip to main content
Visitor II
May 30, 2019
Question

LIS3MDL Magnetometer Calibration

  • May 30, 2019
  • 1 reply
  • 1867 views

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

    This topic has been closed for replies.

    1 reply

    ST Employee
    June 7, 2019

    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