• I've been (unsuccessfully) trying to convert the magnetometer readings to a compass headings. I've been googling, and due to my maths education stopping at GCSE level, I don't understand most of the conversions. I tried following the adafruit guide but it's for a different magnetometer sensor, and the readings don't seem the same, Adafruit guide says the readings are in micro-Teslas and will be between 20 and 60 micro Teslas, and in the Puck guide it's saying a similar number, but that the increments are in 0.1 micro Teslas. I am getting readings of { "x": -3431, "y": 4167, "z": 508 } so even divided by 10 these are off.

    I thought that the following code might work:

    Puck.on('mag', function(xyz){
      console.log((Math.atan2(xyz.y/10,xyz.x/10) * 180) / Math.PI);
    });
    

    But I don't get the readings I would expect.

    Am I missing something or being a dope?

About

Avatar for Bennr @Bennr started