Problems with LSM303DLHC Compass


I’ve downloaded the latest Pololu Arduino library for the LSM303DLHC accelerometer and compass, calibrated it and fitted it into my project box. Sadly the project box is normally worn by a person and is subjected to a lot of movement. Because of this my compass readings are extremely unsteady when viewed within the serial monitor and extremely noisy when the data is plotted as a graph. Is there anything I can do (setup, etc) to stabilise the incoming data when the device constantly moving around?

Thanks in advance.


You might try taking an average of the reading in an attempt to help stabilize your data.

Alternatively, you might consider using an IMU, like the MinIMU-9 v2. The software is more complicated, but with the addition of a gyro you should be able to track rotation data better than with just a magnetometer and accelerometer alone.

Keep in mind that our software is meant to be a basic starting point, and it is possible that you might be able to find a way to get better results by rewriting it or using a different algorithm.


Thanks for the reply. I’m sort of a beginner so rewriting the initial algorithm will be a tad tough at this moment. But one thing I will try is creating a small function that will sample the data 10 times and report back the average each time it loops through the main loop to see if that helps, otherwise I will have to leave it out of my uni project which will be a real shame :frowning:

Your MiniMu-9 v2 looks interesting though, I will have to see if my usual UK suppliers stock this item and if so how much it will cost as I’ve not long just shelled out for the LSM303DLCH.