New user with Envirophat stability query


I have a Pi0W with the envirophat attached.
I am successfully reading heading and inclination every second and logging.
My Pi is attached to a Lithium battery pack via a 50cm cable. So battery is 50cm away from Pi.
It is sat in a fixed position on a wooden table over 200cm away from any metal objects.
Over an hour period, I see a random variation of +/- 2 degrees in inclination and +/- 3 degrees in heading.
I see the same results when powered from my mains tower PC (via USB).
Is this variation to be expected?
Thanks for any help. Image shows heading variation at 1 second intervals over 2 consecutive minutes.


Both look pretty much as I would expect- the figures are certainly not going to be 100% accurate since the lsm303d is measuring magnetic fields which are rather unpredictable at best. If your graph was scaled to the full possible 360 degrees of orientation then this jitter would appear as fairly insignificant noise in the wider sweeps of orientation change.

You should at the very least run your numbers through a crude low-pass filter for display- by using a moving average of the last N values, rather than the raw data.

Most real-world applications of magnetometers and intertial measurement involve some calibration and then combination of sensor data to provide a more accurate estimation of orientation.