How can I check the power draw of an application?

Posted on
  • I'm writing an application and need to check and record the watch's power draw while it runs.
    Is there any command I can run, or alternative method, to check the power draw?


  • No, there is no way to measure power draw (easily).

    When I asked that earlier Gordon said that he has has some setup where watch is opened and connected to external battery, with power meter, to measure power draw.

  • There is a list somewhere of the m/A draw per hardware element.

    GPS will flatten the battery in 6 hours.
    Leaving heart rate monitor on all the time will produce a big drawer.
    Writing to flash storage frequently will run the battery down.
    Keeping you backlight on for extended periods will drain the battery.

  • It's listed here:­r-consumption

    About all you can do without opening it is to look at the battery percentage change after a day of running it...

  • I'm writing an application and need to check and record the watch's power draw while it runs.

    If you mostly care only about CPU activity = your code running too long/too much/in busy loop, there is­obal_setBusyIndicator­obal_setSleepIndicator
    on some watches it helped me to set it to motor pin to feel how busy the device is. Ideally you don't feel anything most of the time. Did not try with Bangle 2 yet. vibration pin is D19 so setBusyIndicator(D19) could enable it. Also turning off normal vibration could be good idea. It will of course drain battery so it is just temporary test to be sure device is idling most of the time.

  • Actually a good one is setBusyIndicator(D8) which is the backlight. It'll then light the backlight whenever the Bangle is doing something.

    Generally if you actually see it flashing once a second on the clock, it's something that'll end up using a reasonable amount of power (so ~1 week battery rather than a month)

    edit: interestingly it is possible to look at SysTick (peek32(0xE000E018)) to keep an eye on CPU usage, but since CPU draws ~4mA, and the screen draws 60 (IIRC) even if you could get an accurate CPU usage percentage it's not the full story.

  • While trying things out for my current power manager app changes, I found this thread and was intrigued by @Gordon 's last edit. Some experimentation lead to:

    const systickMax = peek32(0xE000E014);
    print("Max:", systickMax);
    let t, systickNow, tLater, systickLater, systickDiff;
    setInterval(() => {
      tLater =;
      systickLater = peek32(0xE000E018);
      systickDiff = systickLater - systickNow;
      if (systickDiff < 0) systickDiff += systickMax;
      t =;
      systickNow = peek32(0xE000E018);
    }, systickMax/64000);
    setInterval(() => {
      let cpuPercentage = 100 - E.clip(systickDiff/systickMax*100,0,100)­;
      g.drawString("CPU used: " + cpuPercentage.toFixed(2) +"% " + systickDiff,0,0,true);
    }, 2000);

    Is this actually a valid way to guesstimate CPU-usage? On an bangle without boot code this shows 6-7% non-idle time while being connected to bluetooth. That drops down to 2.5% without bluetooth. Since there is a bit of stuff ongoing every 250/2000ms, that seems to be believable to me. Scrolling around in the launcher can get up to 100% as long I am actively scrolling.
    Am I correct in assuming that the systick overflows every 262ms? 16.7 million ticks at 64000 ticks every ms?

  • Wow, thanks for that experimentation! I'd say yes, that looks like it could be pretty good.

    Am I correct in assuming that the systick overflows every 262ms?

    That sounds about right, yes.

    Interestingly we do have a SysTick_Handler in jshardware.c which is called when SysTick overflows. I wonder if we could do this backwards - by checking the RTC in that systick we could see how much time we were asleep over those 16M ticks, without needing any extra wakeups.

  • It would be really handy to troubleshoot battery life issues, right now I'm struggling to keep it to last two days on a single charge, and I ran a calibration after charging it for three hours, the flattened the battery, recharged it for thee hours and the issue persists, so I don't think it's a calibration issue.

    I don't receive more notifications than usual either.

    Device Type	BANGLEJS2
    Firmware Version	2v16.183
    Apps Installed	launch (0.20), boot (0.56), widlock (0.08), widalarm (0.01), widmessages (0.04), messages (0.58), agenda (0.13), files (0.08), widbt_notify (0.17), calclock (0.06), widclk (0.07), mylocation (0.09), owmweather (0.02), widslimbat (0.01), weather (0.24), wid_edit (0.02), sched (0.21), qmsched (0.09), alarm (0.38), authentiwatch (0.07), android (0.23), astrocalc (0.04), quicklaunch (0.10), messageicons (0.05), messagegui (0.65), setting (0.58)

    1 Attachment

    • Screenshot_20230227-160039-138.png
  •­d=powermanager now has some logging capability for power use troubleshooting. It can show you code executed by timeouts and intervals and some estimation for hardware use.

  • Hmm so I enabled logging, the watch got really sluggish, and at some point frozen. I had to force it to reboot and it said

    Checking storage...
    Storage is corrupt.
    Erasing Storage Area...


  • :( that's not good. Sorry to hear that - however maybe if the storage had got corrupt, it was that which was causing your battery to run flat so fast?

  • That really should not happen. Did you use the detail logging? That can write a lot of data relatively fast into a storage file. Normal logging writes two files every 5 minutes and on reloads. Do you know how full the storage was?

  • Sadly I don't, I didn't get the chance to look at the logs before it happened. I've reconfigured my watch from scratch, keeping the apps and tweaks to a minimum. We'll see how it goes from there, and if the battery drain happens again I'll make sure to capture the logs often.

  • I switched back to 2v16 and the battery draw is back to normal. I'll have to dig deeper to find the source of the drain.

  • Two days later, the difference is quite drastic, with the same set of apps.

    1 Attachment

    • Screenshot_20230307-140552-617.png
  • Did you look at the logging of power manager by now?

  • Hi there

    I've been fighting battery drain issues on my kickstarter Bangle for the last couple of months. I've tried factory resetting multiple times and only installing a minimum amount of apps. But so far to avail. It's gotten so bad that the watch will lock up and drain the battery in a matter of hours.
    My storage got corrupted some months ago and I suspect that's when my issue started. I cannot upgrade firmware through Gadgetbridge as the upload always stops at 5-10%, so I use the DFU for upgrading.
    I've had to resurrect my old Pebble, as I've missed multiple important notifications.
    I will dive into some debugging when time allows it. Perhaps your work will help.
    Here's the battery graph from when I last used my Bangle.

    1 Attachment

    • Screenshot_20230309_130629_Banglejs Gadgetbridge.jpg
  • I cannot upgrade firmware through Gadgetbridge as the upload always stops at 5-10%

    I have the same issue with Banglejs Gadgetbridge (v0.71.2a-banglejs, from Google Play Store), so I usually disconnects from GB and do the update through using Chrome / Bromite.

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

How can I check the power draw of an application?

Posted by Avatar for Asynchronous @Asynchronous