Skip to main content
Visitor II
June 9, 2021
Solved

IIS2MDC is it need to calibrate and how to calculate angle from raw data of the sensor?

  • June 9, 2021
  • 5 replies
  • 2614 views

Hi.

When i power my board and everything else i configure sensor in continous mode and succesfully getting data for each axis. Board is parallalel to the floor then it means that for getting angle i need sensor data from x axis and from y axis.

I tried with https:// blog.digilentinc.com/how-to-convert-magnetometer-data-into-compass-heading/ this approuch only difference is that i multiply data from axis with 1.5 ( i had read in aplication note that this is sensor constant to get mG) and for sensor in given web site is 0.48828125.

I want to ask is it needed to calibrate sensor every time when you power you entire board ( MCU and IIS2MDC) ?

Is that formula from given website good or not? Because i dont get good data when i compare with compass value from my smartphone even if i add declination angle for my geographical location to the calculated angle value which i got from the sensor.

    This topic has been closed for replies.
    Best answer by SimonF

    Please as I said, read this : https://arduino.stackexchange.com/questions/18625/converting-three-axis-magnetometer-to-degrees.

    There is not One formulas. There are several. It is depending the accuracy you want / need. Check with google : you can go from the simplest algo of Arduino to the hardest with integration, matrix and so on.

    Yes you will have to rotate the sensor like on smartphone, maybe several time to have something. If the values you get are not almost "perfect", the angle will be completly wrong.

    You can also read this paper : https://core.ac.uk/download/pdf/289945119.pdf.

    5 replies

    MKla.1Author
    Visitor II
    June 11, 2021

    Any suggestions?

    MKla.1Author
    Visitor II
    June 14, 2021

    ???

    MKla.1Author
    Visitor II
    June 15, 2021

    Can somebody answer ?

    Visitor II
    June 15, 2021

    Hello @Community member​ ,

    Your questions are not really clear.

    Yes you have to multiply data with 1.5. You should always prefer follow the application note of ST instead of following tutorial in which not explained values are used.

    You need to read more about hard-iron, soft-iron and offset calibration. For the hard-iron effect you don't need to redo the calibration at every reset if you keep the values you calculated. The soft-iron effect is a bit different. I suggest you to read more to understand every concept.

    You can also re-read my post it can give you some hints.

    Good luck.

    Simon

    MKla.1Author
    Visitor II
    June 15, 2021

    But which formula is ok for getting angle from mG values which you get from the sensor?

    Also is it need to rotate sensor like on smartphone to make calibration?

    SimonFAnswer
    Visitor II
    June 15, 2021

    Please as I said, read this : https://arduino.stackexchange.com/questions/18625/converting-three-axis-magnetometer-to-degrees.

    There is not One formulas. There are several. It is depending the accuracy you want / need. Check with google : you can go from the simplest algo of Arduino to the hardest with integration, matrix and so on.

    Yes you will have to rotate the sensor like on smartphone, maybe several time to have something. If the values you get are not almost "perfect", the angle will be completly wrong.

    You can also read this paper : https://core.ac.uk/download/pdf/289945119.pdf.