Magnetometer? IR Transmitter?

Posted on
  • Anyone have a working example of using the MAX3110 Magnetometer or the IR Transmitter?

    I didn't see an IR example.

    When I looked at the Espruino modules, I saw one for the MAX3110 from sparkfun..Yay! Paste the code in from the last example in the web page.

    The puck said:

    >
     _____                 _
    |   __|___ ___ ___ _ _|_|___ ___
    |   __|_ -| . |  _| | | |   | . |
    |_____|___|  _|_| |___|_|_|_|___|
              |_| http://espruino.com
     1v88 Copyright 2016 G.Williams
    >Uncaught ReferenceError: "B6" is not defined
     at line 1 col 20
    I2C1.setup( { scl: B6, sda: B7 } );
                       ^
    ERROR: Prompt not detected - upload failed. Trying to recover...
    ERROR: Prompt not detected - upload failed. Trying to recover...
    ERROR: Prompt not detected - upload failed. Trying to recover...
    ERROR: Prompt not detected - upload failed. Trying to recover...
    Disconnected
    Connected
    >
    
    

    Basically, I just had to open it up, push out the battery, and start again.

    Any thoughts anyone?

    -Ken

  • Yeah, sorry - this isn't documented well at the moment. The Puck specific things are already built in, in the Puck object. Info here: http://www.espruino.com/Reference#Puck

    Basically you can just do: Puck.mag() to get the magnetometer readings, or can set it up to run in the background:

    Puck.magOn();
    Puck.on('mag', function(xyz) {
      console.log(xyz);
    });
    // Turn events off with Puck.magOff();
    

    IR transmitter works with Puck.IR() as well - example of doing it from a website here: https://github.com/espruino/espruino.git­hub.io/blob/master/puck3.html

    But I'll do a tutorial on using it (and getting the IR signals to use) soon.

    The I2C crashing it is a strange one - it could be it was just waiting for a response. It might be next time you can just break out with Ctrl+C, but I'll look into it.

  • Just to add, I've put some more detailed info on the Puck page now: http://www.espruino.com/Puck.js

  • Spectacular! That's just the info I needed.

    Thanks Gordon.

    -Ken

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

Magnetometer? IR Transmitter?

Posted by Avatar for user70841 @user70841

Actions