Skip to main content
Visitor II
March 31, 2021
Solved

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

  • March 31, 2021
  • 1 reply
  • 2327 views

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.
    Best answer by Eleon BORLINI

    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

    1 reply

    ST Employee
    March 31, 2021

    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

    Visitor II
    March 31, 2021

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

    ST Employee
    March 31, 2021

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

    -Eleon