LIS3MDL magnetometer output becomes noisy after a bit
Dear community,
I am trying to detect metalic objects (train axles) that are passing above two LIS3MDL sensors.
For this purpose I am using LIS3MDL breakout boards from Pololu
What I notice is that often, what seems randomly, the signal becomes noisy during the data gathering process.
To provide an example, I have plotted the sensor's X-axis output in a graph.
In the left half of the graph you can see that the signal is normal, and in the right half you can see the signal become noisy.
Nothing really seems to change in the external environment at the moment that this transition occurs.
We see this in multiple datasets.

Has such behavior been seen before with this sensor? If so, what could be the cause of this and can it be fixed?
I will give a few details about my setup below:
- LIS3MDL configuration:
- Ultra-high performance mode
- 155 Hz in continuous conversion mode.
- Scale: 4 gauss
- The VVD and Vin pins on the LIS3MDL are shorted together and connected to 3.3v.
- There are two LIS3MDL breakout boards on the same I2C bus
- For sensor A, the SDO pin is floating (for default I2C address)
- For sensor B, the SDO pin connected to GND (for the purpose of an unique I2C address)
- The breakout board has 1.5kOhm resistance/pull-up from SCL and SDA to VDD
- INT, CS, DRDY pins are floating and not used.
- The PCB is powered through 3x Saft LSH20 D lithium-thionyl chloride (Li-SOCl2), which are connected in parallel to increase battery capacity.
- I2C bus speed initialized by master at 400KHz, whereas the LIS3MDL sensors are the slaves.
- The master device logs the values to a SD card, which is how I gathered the data for plotting.
- Before/after each train, the sensor is automatically started/configured and stopped by writing the appropriate registers. During the data gathering, no registers are updated. Only the STATUS and OUT registers are being read.
- Sensor a is relatively close to the development board, only few centimeters away with on-PCB traces. The other one is connected via wires that are approx. 20cm long. At first I assumed the issue might be due to the long wires, but that does not explain why it occurs on the close sensor as well.
Here are some environmental details:
- The solution is outdoors in a waterproof enclosure (we have seen this issue occur both in summer and winter, so we dont assume outdoor temperature is the cause here)
- The enclosure is mounted on the rail with light pot magnets, that are approx 15cm distance from the sensors, and directed away from the sensors. This might still cause a bias in the magnetic offset, but this is not a problem for the solution as we are more interested in the change of magnetic field between consecutive measurements, rather than a biased absolute value.
- While the sensor is active, the sensor enclosure might vibrate a little bit.
I have tried to replicate this issue in the lab tests. But soo far without success.
Any assistance in this matter is highly appreciated.
Best regards,
Dirk
