Puck.JS draining battery

Posted on
  • Hi all,

    Has anyone had any issues with their Puck draining the battery super quickly? I have one that has been running for 2 weeks and is still on 100% and another that went flat in about 5 days? Both were running v200 and I have just put a cutting edge build on and noticed it has used 8% in the last hour an a half. The last three batteries have all been brand new from the packet. Same batch as the one in the unit still at 100%

    The code running isn't complicated. It's mostly just an IR remote I send commands too but get it to report temperature and battery voltage too. I have also checked D28 and D29 with .getMode() and they report input so I assume the serial port isn't on and keeping it awake?

    var tvOn = [1,1,1];
    var tvOff = [1,1,1];
    var tvToggle = [1,1,1];
    
    function onInit() {
        //start up and flash the lights in order...
        LED1.set();
        setTimeout(function() {
          LED1.reset();
          LED2.set();
          setTimeout(function() {
            LED2.reset();
            LED3.set();
            setTimeout(function() {
              LED3.reset();
            },300);
          },300);
        },300);
        setInterval(function() {
          NRF.setAdvertising({
            0x180F : [Puck.getBatteryPercentage()],
            0x1809 : [E.getTemperature()]
          },{interval:5000});
        },15*60*1000);
    }
    

    Cheers,
    Ryan

  • Wow, that is strange - your code looks absolutely fine.

    If there was other code that used digitalRead and then an input wasn't connected to anything, random electrical noise can keep waking the Puck up and can drain the battery quite quickly - but in the default state the inputs are set so that doesn't happen.

    Also the hardware serial should only initialise if D28 is actually pulled up to 3.3v at boot - having it just happening to 'float' at 3.3v wouldn't be enough.

    You could try using setSleepIndicator(LED1) to see if anything is waking the Puck up?

    Very early firmwares had an issue where NFC usage would cause a 1mA power draw, but that was fixed a year or more ago. It also used to be (pre 2.00) that keeping a connection open would draw a decent amount of power, but in v2.00 even that's changed and having a connection to whatever device controls the Puck won't draw much more power than having it just advertising.

    About the only other thing I can think of is whether a device is continually connecting/disconnecting to that Puck?

  • Honestly, I've been having a lot of battery issues too recently. I've been having to change them out every few days. Just connected via BLE - getting worse battery life than with v199. Let me know if you'd like me to start my own topic for this.

    E.on('init', function() {
      var debug_log = function debug_log(t) {
        console.log(t);
      };
    
      debug_log(NRF.getAddress());
      debug_log("Battery: " + E.getBattery() + " " + Puck.getBatteryPercentage());
    
      var kb = require("ble_hid_keyboard");
      NRF.setServices(undefined, { hid : kb.report });
    
      var sending = 0;
    
      var catchButton = function catchButton(e) {
        if(!sending) {
          var keyDown = e.state === true;
          var keyUp = e.state === false;
          var click = false;
    
          if(keyDown) {
            //digitalWrite(LED3,1);
          }
    
          if(keyUp) {
            triggerCommand();
          }
        }
      };
    
      var triggerCommand = function triggerCommand() {
        try {
          if(!sending) {
            sending = 1;
            //107 is f16
            NRF.sendHIDReport([0,0,107,0,0,0,0,0], function() {
              setTimeout(function() {
                NRF.sendHIDReport([0,0,0,0,0,0,0,0], function() {
                  setTimeout(function() {
                    debug_log("works");
                    sending = 0;
                  }, 250);
                });
              }, 100);
              //digitalWrite(LED3,0);
            });
          }
        } catch (e) {
          console.log("caught:" + JSON.stringify(e));
          //digitalWrite(LED3,0);
          digitalWrite(LED1,1);
          setTimeout(function() {
            digitalWrite(LED1,0);
            sending = 0;
          }, 100);
        }
      };
    
    
      setWatch(catchButton, BTN, {repeat:true, debounce:50, edge:'both' });
    });
    save();
    
  • Well, as ryan42 never responded I guess we might as well use this thread :)

    This is with Puck.js running version 2v00? Or the absolute latest builds? How often do you press the button?

    With 2v00, the connection changed a little:

    • pre-2v00 used 20ms connection intervals while connected
    • 2v00 and later use 7.5ms connection intervals when connected, but after ~2 minutes of idle they drop to 200ms so should be far better on a battery. For some reason it seems yours isn't idling.

    You could however try NRF.setConnectionInterval(100) : http://www.espruino.com/Reference#l_NRF_­setConnectionInterval

    In 1v00, setConnectionInterval only works when you're connected, but if you use a cutting edge build you could just shove it in your E.on('init'.

  • Sorry for the delay - yes, using 2v00, not cutting edge builds. Though, I tested them before and experienced the same issues. The button is used to trigger a recording (with the hotkey that's sent), so when testing the system we press it twice within 10 seconds to a minute. During actual recordings, we press it to twice: start and end within 5 minutes to an hour of recording.

    The button (sometimes) just fails at some point and doesn't reconnect until the battery is removed and put back in. Other times, the battery is completely dead.

    I left my puck at the office, which isn't open until January 2nd, but I'll be sure to test out the interval change when I'm back there.

  • Sorry @Gordon, has been a busy few weeks.

    I'll try with setSleepIndicator(LED1) and see if that can narrow it down a little bit. I'll try with the current build 2V00 first and then see if there is any difference with the cutting edge. Previously I was on 1V97 I think so I can also try rolling back to that.

    Cheers
    Ryan

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

Puck.JS draining battery

Posted by Avatar for ryan42 @ryan42

Actions