Skip to main content
jg_spitfire
Senior
Mar 31, 2021 10:58 AM UTC
Solved

LSM9DS1 - how to validate the data received from the magnetometer?

Hi, we have designed a custom PCB with the LSM9DS1 as IMU, we are receiving data from the accel, mag, and gyro, in the case of the accel I think is easier to know if the measure is ok (we must get 1G in the z-axis), but how could we validate if the data of the magnetometer is correct? , is there any expected value? we are not using an ST microcontroller to interface with the sensor.

Thanks

This topic has been closed for replies.
Eleon BORLINI
Eleon BORLINIBest answer
ST Employee
Mar 31, 2021 1:10 PM UTC

Hi @jg_spitfire​ ,

please consider first that the Earth magnetic field is about 0.5 gauss, so you should get this result calculating the magnetic field intensity from the 3-axis components.

For the conversion formula from LSB (digits) to physical quantities you can refer to the C drivers on Github for the LSM6DSM1 (lsm9ds1_reg.c).

Considering for example the default Full Scale of 4 gauss, the formula is:

float_t lsm9ds1_from_fs4gauss_to_mG(int16_t lsb)
{
 return ((float_t)lsb * 0.14f);
}

For a general check of the (correct) performances of the magnetic sensor, you can run the self test as reported in the lsm9ds1_self_test.c example.

If my reply answered your question, please click on Select as Best at the bottom of this post. This will help other users with the same issue to find the answer faster.

-Eleon

8 replies

Eleon BORLINI
Eleon BORLINIBest answer
ST Employee
Mar 31, 2021 1:10 PM UTC

Hi @jg_spitfire​ ,

please consider first that the Earth magnetic field is about 0.5 gauss, so you should get this result calculating the magnetic field intensity from the 3-axis components.

For the conversion formula from LSB (digits) to physical quantities you can refer to the C drivers on Github for the LSM6DSM1 (lsm9ds1_reg.c).

Considering for example the default Full Scale of 4 gauss, the formula is:

float_t lsm9ds1_from_fs4gauss_to_mG(int16_t lsb)
{
 return ((float_t)lsb * 0.14f);
}

For a general check of the (correct) performances of the magnetic sensor, you can run the self test as reported in the lsm9ds1_self_test.c example.

If my reply answered your question, please click on Select as Best at the bottom of this post. This will help other users with the same issue to find the answer faster.

-Eleon

jg_spitfire
Senior
Mar 31, 2021 1:31 PM UTC

Hi, so I should get 0.5 gauss in each axis?

Eleon BORLINI
ST Employee
Mar 31, 2021 1:33 PM UTC

No, only as vector sum of the 3 axis components, i.e. the sqrt(mag_x^2+mag_y^2+mag_z^2).

-Eleon