• E.getBattery() is a useful finger in the air measure, but it's not super accurate because it uses voltage and the voltage of the cells doesn't vary that much with how depleted they are until right at the end. Maybe trust it within ~20%...

    You can use E.getPowerUsage() in 2v22 firmware to get an idea of instantaneous power draw.

    But just some notes:

    • If you want acceletometer once a second, use Puck.accelOn(1.6) and Puck.on('accel', fn) - that will be 1.6 times a second, but will be a lot more efficient keeping the accelerometer on than repeatedly turning on on and off like you were doing (even if you run it faster than than and throw readings away)
    • LED lights draw a lot of power 8mA vs 0.04mA for the accelerometer - try blinking them for ~100ms or so, or use pinMode(LED1,"input_pullup") to turn them on very dim rather than leaving them lit (if that's what you were doing)

    Also if you're staying connected to the Puck via Bluetooth consider using NRF.setConnectionInterval(100) - it slows down data transfer but forces the Puck to use a lower power bluetooth mode.

  • Thanks a lot!

    I checked with E.getPowerUsage() what my PowerUsage was, and BLE took around 600-700, while the cpu was around 100-200 or so. I have now set NRF.setConnectionInterval() to 50 - it is now slower for uploading code, but reduced the PowerUsage to only around 50-100~ compared with 600-700 it took before (i also implemented a "switching bluetooth off / on by pressing the button 15 seconds" to save battery even more if i don't actively need bluetooth).

    I also found out that the PMW was eating continous 200 Power, and it seems to go away if i reset each LED after using the LEDs. So i don't know if this added to the battery drain if it did run 24/7 all the time without me noticing (and even after setting the Leds brightness all to 0).

    Before i did this fixes, it was around 1000-1400 Power Useage overall. Now it's way way less.

    If you want acceletometer once a second, use Puck.accelOn(1.6) and Puck.on('accel', fn) - that will be 1.6 times a second, but will be a lot more efficient keeping the accelerometer on than repeatedly turning on on and off like you were doing (even if you run it faster than than and throw readings away)

    I assumed that just requesting one reading a second would be more performant than having the accelerometer readings run all the time. It's good to know that this is not the case and i can save more energy if i do it this way. Thanks for this tip!

    LED lights draw a lot of power 8mA vs 0.04mA for the accelerometer - try blinking them for ~100ms or so, or use pinMode(LED1,"input_pullup") to turn them on very dim rather than leaving them lit (if that's what you were doing)

    I have written me a function to switch on & off the leds like this:

    function SetLights(r, g, b)
    {
     //RED, GREEN, BLUE
     var LED_R   = LED1;
     var LED_G = LED2;
     var LED_B  = LED3;	
    	
     analogWrite(LED_R, r);
     analogWrite(LED_G, g);
     analogWrite(LED_B, b);
    }
    

    i use it normally by SetLights(1,0,0); as an example. But i also need a red light that adjusts in brightness to indicate the value of a variable as a visual feedback, so i also use SetLights(0.3,0,0); as an example. To reset the LEDs i did just set the value for the analogWrite() to 0. But it seems this did let the PMW run in background 24/7 from what i see in the E.PowerUseage. I have fixed this now thought by resetting the LEDs each time after i used the LEDs.

    The Battery which had yesterday 40-45% and then today only 15% left was completly drained after reach around 2volt. So seems E.getBattery() was accurate.

    Thanks again for the helpful advice!
    Cyyy

About

Avatar for Cyyyy @Cyyyy started