cancel
Showing results for 
Search instead for 
Did you mean: 

LSM303AGR Magnetometer result is deviated when iron comes nearby

APate.19
Associate II

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.

6 REPLIES 6
Ozone
Lead

> 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/

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?

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

Absolute terms of both field measurments would be more descriptive.

The magnetic field of the earth is not constant.

See here, especially the "Geomagnetic Activity" diagram:

https://www.swpc.noaa.gov/communities/space-weather-enthusiasts

Thanks Ozone,

I am measuring my device(Door) position based on magnetometer readings. Is there any way to resolve issue of magnetometer readings changed after some days?

> I am measuring my device(Door) position based on magnetometer readings.

Not sure about the way you want to measure an object position with a magnetometer.

The manufacturing industry often uses magnetic position sensors which are threshold-based. Moving objects often have magnets of magnetic metal attached to aid detection. The gained information is binary (e.g. door closed or not).

For position measurement, distance sensors (optical or ultrasonic) might be a better choice, or rotary encoders.