• Basically what @Ollie says - you need to take a zero reading :)

    To use it as a compass you can maintain a min/max reading (http://www.espruino.com/modules/Vec3.js should make this easier) and then subtract the average of those 2 and then use the offset like a compass - so you'd have to upload the code, then rotate it every angle you can think of, and it should then be ok.

    Math.atan2 will save you a bunch of work too - unlike atan it can work over a whole 360 degrees, not just 90/180.

    But... Moving location, having magnets near, etc will all throw it off and it may need recalibrating.

    One thing you could do is make your own little jig/stand that has a magnet on it. That way it'll be powerful enough that the surrounding magnetic field won't be a big issue.

About

Avatar for Gordon @Gordon started