Toybox.BluetoothLowEnergy blows through battery

i've got a background watchface that uses BLE every 5 minutes to communicate with a pi-like device.  it works fine but i've noticed it uses the watch battery way faster than i think it should.

no matter whether i read 1 characteristic or 3 characteristics every 5 minutes, it uses about 3% battery per hour on a forerunner 645m (vs 0.4%/hour for a built-in basic watchface, or 1.5%/hour for a background watchface that uses communication webrequests every 5 minutes.) 

then i tried disabling everything except "Ble.setScanState(Ble.SCAN_STATE_SCANNING)" and had it disable scanning and exit the background process immediately after the first scan return (onScanResults) and it still uses 3% battery per hour!

i've also tested on an Epix2 and see 0.8% battery per hour which is better but still seems a lot for an Epix2 (i haven't compared to a communications bg wf on Epix yet.)

i guess connect iq is just doing something extremely inefficient like leaving BLE radio fully enabled whenever an app uses it at all...is there anything else I can try that might reduce battery use for BLE?

  • Are you always connecting to the same device?

    One thing that may help is after the first time you scan and pair, you can save the scan result in Storage.  After that, you can skip scanning, and use that saved scan result and go right to pairing.

    In my case, I have a pi that I use to open/close my garage door from CIQ, so after the first scan/pairing, I go right to pairing.  I did it more for speed (it's faster) than anything else..  I can skip scanning.  If you do this in a watch face, you probably want to have a setting so it will do the scan again (say you replaced the device)

  • Yes, same device and if they want to switch devices they can use a setting.. interesting, I'll have to try that, thanks.

  • Type checking may complain that you are trying to save a scan result.  Last I tried, that happened because type checking was checking Properties when saving to Storage, and you can't save scan results to Properties, only Storage.

  • results from saving/skipping the scanning is similar for the 645m, it uses more than 3% battery/hour for reading every 5 minutes, which is unusable. I am able to get that down to 2.5%/hour when only reading every 30 minutes, but that's still too much battery usage. I guess the 645m is just too old for this.

    i tested a little more with the Epix2 and it does seem useable:

    built-in wf (as a control): 0.49%/hour
    my CIQ webrequest-only app: 0.44%/hour
    my CIQ BLE-only app: 0.8%/hour
    (i suspect a longer test would have my webrequest app more in line with the built in wf test result.)

    i think at 0.8%/hour battery would last at least 3 days which is good enough. although the Epix isn't a good option for us, i may have to purchase another garmin to see if there are better options.  unless there is a Garmin program for sending out watches for testing?

  • With your sensor, do you have a way to see when something connects and for how long? With my pi apps, I log when something connects and when it disconnects.  I also have an option to turn on a led when something connects and off when it disconnects, as that's easier than watching a log file.

    With my watchface that has a background that does ble, scanning each time and reading 2 characteristics, I see the connection lasts 4-5 seconds.  What do you see?.

    The va5 isn't a bad low end device, but the BLE ranges is lower than other devices.  How far away from your sensor are you with your watch?

  • Yes, the fr645m takes about 14 seconds for just one characteristic with the saved scan result. The epix2 takes about 4 or 5 seconds.  I've been testing with them about 1.5 feet from the ble sensor.

  • Ok, 14 seconds is about half the max time a background can run.  The 645 is an old device and I doubt you can buy one today and probably wouldn't even worry about it, as I'm not sure the last time it got any kind of a FW update... 

    Depending on the pi I use, I see as low as about 3 seconds.(pi zero, pi zero 2, pi 4).

    With a va5 it's working within a couple meters, no problem....

  • Yeah i agree about the 645. But I won't buy another VA as the one I had the case crumbled apart. I was set to abandon Garmin until I found a use for the ble API, I don't know of another watch that allows that type of program... I'll probably try an instinct or fr x65 next.

  • Ok, with a va5, I charged it to 100%, and started my watch face that uses a background to read a pi every 5 minutes.  After 2 hours, it "dropped" to 100%.  But there's more.  I also have another app with a background that does makeWebRequests and  publishes complications that runs every 15 minutes

    Maybe I'll try my instict2 tomorrow.  When I get donations, that goes to help fund getting new devices for testing BTW... (but I might use part of the donations for a beer or two! Innocent)

  • Garmin is lucky to have you, their site even refers to your projects. They should be providing you samples!