Micro:Bit (microbit) compass bug

Posted on
  • Hey,

    just received my microbit and while typing along (really easy espruino install, btw) I found that repetitively calling compass() creates nonsense result and soon gets stuck at

    { "x": 0, "y": 0, "z": 2 }
    

    like so:

    >compass()
    ={ "x": 29688, "y": -1537, "z": 32514 }
    >compass()
    ={ "x": -4214, "y": 24832, "z": 24834 }
    >compass()
    ={ "x": 24878, "y": -253, "z": 2 }
    

    Saw that too? Not sure if its some device data underflow or a missing reset, as I haven't looked at any internals so far.

    Cheers
    Stev

  • Hi - thanks for letting me know... so it just crashes on the 'compass' call?

    Does it return after a few seconds? It could be it's having some difficulty communicating over I2C, but it should time out.

    The micro:bit is a lot slower than normal Espruinos, so it could be that the timeouts are way longer than they should be and it could take up to a minute to return.

    It does seem like there's an issue with the code that reads from the compass though, even if it's only that it's giving dodgy values. I'll file an issue for it, but I'm a bit busy this week.

    If you desperately need it, you should be able to get the compass values directly:

    I2C1.writeTo(0x0E,1);
    var d = I2C1.readFrom(0x0E,6);
    // then data is in 6 bytes in d (i think)
    
  • I don't have a Micro:bit up to now but I've read that the magnetometer chip in the Micro:bit is the MAG3110 from Freescale. We have an Espruino module for the MAG3110 which supports all features of the sensor (e.g. different operation modes). It's fully tested with a MAG3110 evaluation board.

    @Stev
    If the Micro:bit has enough memory for using the MAG3110-module then you could experiment with this.

  • @luwar thanks! I'd totally forgotten about that!

  • Hey,

    @luwar
    good hint. I'll try that.

    @Gordon
    Just unpacked the thing and tested the few functions. And saw the compass call converging towards 0,0,2. Doesn't crash or block, just ends up there after a few calls. Just wanted to check whether a broken device or the code was the culprit.

  • Ahh, that makes sense then.

    I just fixed it, so any new builds (and 1v86 when released) will have it working.

  • Cool.
    Nice little BLE toy/tool.

  • Solved in 1.86. confirmed.

  • Great - thanks!

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

Micro:Bit (microbit) compass bug

Posted by Avatar for Stev @Stev

Actions