⚡ New Power Usage Estimation feature!

Posted on
  • It's been a common issue that especially on battery powered devices like Puck.js and Bangle.js it's very difficult to know how long your device is going to last on a battery, or if you've got your device into a state where it's draining the battery fast. With Puck.js it is at least possible to attach a current meter to measure power consumption, but with Bangle.js you can't even do that.

    I've added a function called E.getPowerUsage() to the latest Cutting Edge that should go a long way towards helping with this (when 2v22 is released it'll be in there too). It's most useful on the Official Bluetooth Espruino devices.

    When called, it returns an object with a field called total which is the total estimated power usage in microamps. There's also an object called device which lists all devices Espruino thinks are drawing power:

    >E.getPowerUsage()
    ={
      device: { CPU: 295, polling: 187, BLE_periph: 665 },
      total: 1147 }
    

    On Bangle.js and Puck.js where the battery is about 200mAh (or 200,000uAh) you can do 200000/E.getPowerUsage().total to get the expected battery life in hours.

    Bear in mind this is very much an estimate - we are able to check average CPU usage and get a reasonably accurate figure, as well as for Bluetooth, but other sensors (GPS, accelerometer, etc) are estimated based on the current state... If you turn on GPS for a minute every hour and only check E.getPowerUsage() during that hour when the GPS is off, it will return 0 for GPS power usage.

    Even so, hopefully this will be a handy tool for Espruino users!

  • A Bangle.js app that inform about lasting high energy draw could certainly be useful. I recently left GPS on unwittingly for example.

  • There is already https://banglejs.com/apps/?id=powermanager which actually does a very similar thing (just using JS) - it's got various warnings you can enable - I'm not sure if one is for high power usage over a long time but I guess it could be added.

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

⚡ New Power Usage Estimation feature!

Posted by Avatar for Gordon @Gordon

Actions