• I want to make a beacon that uses as little power (last as long) as possible.
    Since puck has a button I thought I might get it to wake up on that and go into lowest power mode after a set period of advertising.

    Looking at the links at the end of "Getting started". I was hoping to find some stuff about puck platform-specifics that would help me code up the above. As it is the links that looked useful are broken.

  • Which links are broken? All the ones are the end of the Getting Started guide seem to work for me.

    You probably want:

    I'd hoped to have a few more tutorials up by now, but it's amazing what spending 6 hours a day answering emails does for your productivity :)

  • Thx Gordon,

    Those are the refs I needed. I'll post back here when I have tested code.

    BTW. The broken links are in the version that's in github. The ones on the puck-js website are OK.

    In terms of time for emails, I feel your pain :(

  • I think this is working OK. Is the advertising interval fixed at around 2 secs?

      function() {
        setTimeout(function() {
          setTimeout(function() {
          },60*1000); // 1 minute
        debounce: 50,
        repeat: true //??

    The button seems super-sensitive. I checked that the device is reassembled correctly. Picking it up appears to activate it.

  • :) Ahh, gotcha - yes, the Espruino site is the one to use. Some of the links and keywords are automatically tweaked when it goes online

  • Can I use sleep and wake often or is that not recommended to disable and enable Bluetooth multiple times?

  • Are you using the up to date firmware? There was some odd issue with the one that the devices came flashed with where occasionally using setWatch would disable the button's pullup resistor, making it trigger too often. pinMode(BTN,"input_pulldown") fixes it, but new firmware would be better.

    Advertising is ~700ms on 1v88 firmwares and ~350ms on 1v89 and later firmwares. BLE advertises on 3 separate frequency bands so if your phone/whatever is only listening on one it'd only pick a 1v88 firmware device up once every 2.1 seconds.

    @MobiTech it should be fine to keep using sleep and wake - I don't see that causing any big problems.

  • Thx Gordon,

    Adding that pinMode line caused it to stop waking up altogether (ie ignoring the button).
    My puck is on 1v88. I will look for how to upgrade it.

  • Sorry - I'm an idiot. It should have been pinMode(BTN,"input_pulldown") (the button pulls up to 3v when pressed).

    Firmware update info is here: http://www.espruino.com/Puck.js#firmware­-updates

  • figure this out: putting the line in and then taking it out again cleared the problem. No rush to explain that as I am up and running.

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

Power management/ puck's button?/ getting started links

Posted by Avatar for paul_tanner @paul_tanner