Magnetometer drift

Hello,

First off, I have to say I am relatively new to magnetometers. I have been working in a project for the detection of magnets (they can be different sizes) in a three dimensional space around the sensor. The magnets and sensor positions are not strictly defined and they can be in any orientation in space.

I am able to use the software MotionCal to obtain relatively good values for calibration.

I then use the calibrated magnetometer output values to calculate the magnitude of the magnetic field.

By continuously reading the sensor, I check for the increase or decrease in the magnitude value which ocurr when a magnet aproaches from any direction.

The problem I have is that with time the sensor will experience drift in the measurements. This will cause the magnitude value, which before was relatively stable with no magnets around, to change a lot as I rotate the sensor.

Is there any way to combat this? I have by now done some research and have not reached any answer.

Any tips or knowledge would be apreciated.

Thank you

What magnetometer? What code?

Close to a magnet, the magnetic field strength and direction depends very strongly on position and orientation, so you should expect large changes when you rotate the sensor.