puck.js 2.1 as reed switch?

Posted on
  • Is it possible to somehow use a puck.js v2.1 as a reed switch?

    Documenation says that it is not possible with version 2.1: https://www.espruino.com/Puck.js#magneto­meter

    Puck.js v2 only You can use the puckjsv2-mag-level (About Modules) module to configure the Puck.js magnetometer for ultra low power mode (40uA) while acting like a reed switch (detecting when field strength is high or low). This will not currently work on Puck.js v2.1

    I tried it with my 2.1 puck.js and it indeed does not work:

    Uncaught Error: Puck.js v2 required for this module
    at line 1 col 78
    ...2 required for this module");var e;exports.on=function(c){c=...
    Uncaught TypeError: First argument to EventEmitter.on(..) must be a string
    at line 2 col 34
    require("puckjsv2-mag-level").on();

    Any way to get this working?

  • I just updated the modules so now it should work on any Puck.js (although the event name has now changed from mag to field).

    Puck.js v2.0 is the only one that does it in hardware, but on other Pucks it's trivial to implement in software, so the module now does that for you behind the scenes.

    It's still pretty power efficient.

  • Thanks for updating the module and the documentation! :)

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

puck.js 2.1 as reed switch?

Posted by Avatar for myxor @myxor

Actions