Skip to main content
Visitor II
May 29, 2023
Solved

Getting true north with the LIS2MDL and LSM6DSO sensors.

  • May 29, 2023
  • 2 replies
  • 1758 views

I use LIS2MDL and LSM6DSO sensors (with MotionMC and MotionEC libraries) for getting true north direction. I tested this configuration on IKS01A3 board and it works. But on my custom board, I'm having trouble with getting true north direction. After calibration the resulting azimuth differs from the true one by 70-150 degrees. Tilting the sensor plane by 5 degrees or more in the X or Y axes also affects the observed azimuth. Could this be due to incorrect routing of my custom board? I'm concerned about I2C line vias. Could vias be a source of parasitic magnetic induction? Power is also routing under the LIS2MDL (pic2). Any ideas are greatly appreciated.


_legacyfs_online_stmicro_images_0693W00000bl3Z1QAI.png
_legacyfs_online_stmicro_images_0693W00000bl3ZBQAY.png

    This topic has been closed for replies.
    Best answer by Federica Bossi

    Hi @ALT.1​ ,

    Looking at your layout I notice that you put traces under the device, this is not suggested by ST.

    Please follow the guidelines reported in TN0018 as reference material concerning PCB design.

    In addition, are you implementing both hard iron and soft iron compensation? We suggest you to do both.

    Then, please check that all the axes of both the devices are concordant and ENU (right-hand-rule).

    If these suggestions help you, please mark my answer as "Best Answer" by clicking on the "Select as Best" button, this can be helpful for Community users to find this solution faster :)

    2 replies

    Technical Moderator
    June 1, 2023

    Hi @ALT.1​ ,

    Looking at your layout I notice that you put traces under the device, this is not suggested by ST.

    Please follow the guidelines reported in TN0018 as reference material concerning PCB design.

    In addition, are you implementing both hard iron and soft iron compensation? We suggest you to do both.

    Then, please check that all the axes of both the devices are concordant and ENU (right-hand-rule).

    If these suggestions help you, please mark my answer as "Best Answer" by clicking on the "Select as Best" button, this can be helpful for Community users to find this solution faster :)

    Visitor II
    August 22, 2023

    I noticed you asked for True North.  If all you wanted was Magnetic North, you have your answers.

    But for True North, you will need to remove the Magnetic Declination for the position you are taking the Magnetic North reading at. 

    In short, you will need the latitude and longitude of where the reading is being taken.  Using that you will need to calculate the Magnetic Declination and subtract that from your Magnetic North reading to get True North.

    Magnetic Declination varies around the world and varies over time.  For example, the recent Magnetic Declination around Sao Paulo, Brazil is about -23 degrees.