Skip to main content
Visitor II
January 30, 2020
Question

LSM303AGR Magnetometer result is deviated when iron comes nearby

  • January 30, 2020
  • 1 reply
  • 1693 views

Hi,

we have used LSM303AGR  magnetometer for cupboard Door Open/Close detection and it is working properly.

On door close position, i am getting ~0 of every direction as i have done hard iron compensation.

Issue i am getting in small cupboard is to open the door, door handle is required to rotate. when handle is rotated completely, Handle iron comes near magnetometer IC and due to that result is deviated.

Is there any solution for that?

Logic implemented to detect door Open/Close position:

  1. Calibration process:Close the door and calibrate it.at that position magnetometer gives ~0 value of each direction as i have done hard iron compensation.
  2. Door Open: when any magnetometer axis value is beyond 50 value.
  3. Door Close: when every magnetometer axis value is below 15 value.

    This topic has been closed for replies.

    1 reply

    Explorer
    January 30, 2020

    > Is there any solution for that?

    Depends on how you view the problem.

    The effect is intrinsic to magnetometers - they measure a magnetic field, wherever it comes from.

    But you can calibrate the sensor (search for "soft iron calibration"). Like e.g. here:

    https://www.instructables.com/id/Easy-hard-and-soft-iron-magnetometer-calibration/

    https://diydrones.com/profiles/blogs/advanced-hard-and-soft-iron-magnetometer-calibration-for-dummies

    https://pdocs.kauailabs.com/navx-mxp/guidance/magnetometer-calibration/

    APate.19Author
    Visitor II
    February 3, 2020

    Thanks Ozone,

    I observed another issue like magnetometer value changes after sometimes at same location.

    Initially:

    Fri 11/22/2019 18:27:54.801 : X : -4, Y : 0, Z : -3

    After:

    Thu 01/30/2020 18:58:06.330 : X : 18, Y : -5, Z : 31

    Can you please help what is going wrong?

    APate.19Author
    Visitor II
    March 2, 2020

    Can you please help what is going wrong in below mentioned case?

    magnetometer value changes after some days at same location and same position.

    Initially:

    Fri 11/22/2019 18:27:54.801 : X : -4, Y : 0, Z : -3

    After:

    Thu 01/30/2020 18:58:06.330 : X : 18, Y : -5, Z : 31