I noticed when testing similar code that the first reading after offsetting with zero = Puck.mag(); gives x, y and z values close to zero, as you'd expect, but second and subsequent jump to values that vary (+/-) quite a bit from zero, and actually found it better to do use a later reading as a zero/offset, making a couple of calibration passes as below
I doubt it matters much, as slight changes in orientation of Puck still move values considerably, regardless, but it seems the Puck.mag() reading doesn't quite do the zeroing/reset I expected.
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 noticed when testing similar code that the first reading after offsetting with
zero = Puck.mag();
givesx
,y
andz
values close to zero, as you'd expect, but second and subsequent jump to values that vary (+/-) quite a bit from zero, and actually found it better to do use a later reading as a zero/offset, making a couple of calibration passes as belowI doubt it matters much, as slight changes in orientation of Puck still move values considerably, regardless, but it seems the
Puck.mag()
reading doesn't quite do the zeroing/reset I expected.