You are reading a single comment by @Gordon and its replies. Click here to read the full conversation.
  • At the moment there's no 'built-in' calibration, so it all has to be done by your own code anyway.

    A lot of code does something like this:

    var zero = Puck.mag();
    var doorOpen = false;
    function onMag(p) {
      p.x -= zero.x;
      p.y -= zero.y;
      p.z -= zero.z;
      var s = Math.sqrt(p.x*p.x + p.y*p.y + p.z*p.z);
      var open = s<1000;
      if (open!=doorOpen) {
        doorOpen = open;
        digitalPulse(open ? LED1 : LED2, 1,1000);
      }
    }
    Puck.on('mag', onMag);
    Puck.magOn();
    

    So in that case, the calibration value is stored in the zero variable. If you want to reset the magnetometer value, all you have to do is run zero = Puck.mag(); again.

About

Avatar for Gordon @Gordon started