I think the main thing here is that you have to find 'zero' for the magnetometer.
All kinds of things can effect the reading - for instance when I've been using a magnet, if I get too close it can presumably magnetise some part of the Puck, and that then changes the readings from then on.
But once you have the zero, you can subtract it from the magnetometer value and you should get a much cleaner reading.
Easiest way I'd say is to take 4 readings - one normally, one rotated 90 degrees, one 180, and one 270. Add the x, y and z's separately and divide by 4 - then always subtract that value from the magnetometer.
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
I think the main thing here is that you have to find 'zero' for the magnetometer.
All kinds of things can effect the reading - for instance when I've been using a magnet, if I get too close it can presumably magnetise some part of the Puck, and that then changes the readings from then on.
But once you have the zero, you can subtract it from the magnetometer value and you should get a much cleaner reading.
Easiest way I'd say is to take 4 readings - one normally, one rotated 90 degrees, one 180, and one 270. Add the x, y and z's separately and divide by 4 - then always subtract that value from the magnetometer.