Cut NRF52 bluetooth power usage by 300% - testers needed!#8858
Conversation
|
@phaseloop are you on the discord? We can probably engage more testers there, |
|
@thebentern I joined discord now, I'll ping you there |
|
Would this be the fix to the drainage of phone battery some of us experienced? |
|
Can you share more specifics? Which phones and boards, etc? I would expect this to happen with esp32 because bluetooth timings set there are crazy and if phone stack does not support timing renegotiation I would pretty much expect it to drain battery fast. |
|
i think you mean -66%. you can't 'cut' 300% - you'll end up BLE generating us power for Lora :D. And .. this just refers to the power of BLE advertising - which is a cut from 100uA down to 33uA. Those Airtags and 'Faketecs' (which are flashed nRF52820 with coin battery) do this BLE advertising 24/7 ... for a year+. |
lmao, we don't need solar panels anymore! You're right - I should change it to "improve by" maybe. Yeah I thought description was clear that this BT subsystem power usage only. Funny enough much bigger power saving can be at the phone side as timing influences battery drain too. |
Can you expand on this and potentially create an issue in the app repos? |
|
Flashed to a t-echo and custom RAK4631 device, no noticeable changes in behavior yet |
|
Spoke too soon, I’m not able to change any settings from the Android app. Tried reset (rebooting) of the T114, clearing and re-pairing the BLE bonds. Android app gets stuck at 0% when opening any settings pane, and the T114 spams this to serial log: |
Posted this too soon… the page did eventually load, after about a minute of spamming the log. Going to flash without the change to confirm this PR caused the issue. Would appreciate if anyone else can confirm this PR makes configuration panes take much longer to load and spam the log too. |
|
Downgraded back to 2.7.16 tag, settings panes load instantly on Android, so this PR does cause a regression for my setup. |
While I did not check the log, the settings loaded instantly, and I was able to modify them without issue or delay Android app 2.7.8, on both devices I flashed |
|
@ndoo I have some suspicions what may be the issue. What phone is it? Does this happen only when trying to save settings? Can you try disabling BT on phone, waiting 15s and reconnecting again? @mdecourcy As for phone battery drain - there is BLE setting called connection interval which influences radio subsystem power usage and sleep modes (this is what is broken in esp32 ESP-IDF before v5.5, lmao). But when talking about that I forgot this is something I have in other PR not yet published as we need to sort out this one first. |
…htastic-firmware into nrf52-power-saving-1
|
I noticed the pushed commits involve the T114, do you still need me to make any changes to bisect the issue or do you wish me to just test the latest commit as-is? |
Sonim XP8800, Android 10, Qualcomm SDM630.
Yes, but not saving settings - just opening the settings pane where it tries to read settings.
Not tested yet. |
|
@ndoo - yes, please test the latest commits. There are confirmed issues that damaged/off spec LF crystals may throw off bluetooth timings when using slave latency settings. If this is XTAL issue - it may explain why it worked initially but stopped as the crystal heated a bit and deviated in freq |
|
I can't connect from MacBook Pro 13" 2017 (Bluetooth 4.2) to T1000-E with 2.7.16 and this patch applied. |
|
Android app settings loading and reading back are are snappy for me again on the latest commit, T114v2, Android 10, Qualcomm SDM630. Did not re-pair the node. |
|
@max-arnold @ndoo - I pushed another change. I got a Mac to test but I'll check if the same issue can be replicated here. Edit: works fine on Mac M3. I'll dig up some ancient Android. |
|
@phaseloop The last commit fixed the issue on MB Pro 2017 (Bluetooth 4.2). Also tested on iPhone XR (Bluetooth 5.0). |
|
@max-arnold awesome, thanks for testing! It seems that some devices ignore GAT preferred settings and need to be forced to renegotiate it. |
)" This reverts commit ae8d3fb.
|
@ponzano did you test the branch with the changes I implemented yesterday? Do you know what is overall power cost of having bluetooth enabled on NRF52? |
Uh no I didn’t notice it, I’ll have time to test again with this (and better) instrumentation on Friday morning so we’ll have to wait a couple of days. I’ll also compare power usage with and without Bluetooth enabled. |
|
Yeah, that patch fixed connectivity issues on MacOS so there is a big change it will fix your issue too :). The branch you mentioned is the one. Thanks for testing! @thebentern - is it possible to reopen this PR somehow? |
|
I did more tests with an iPhone XR (bluetooth 5.0) and after a couple of successful connects/disconnects (and maybe some idle time) the phone refuses to connect again. Rebooting the T1000-E usually helps. |
|
@phaseloop , need to make a new PR - but you can push to the same branch |
|
@max-arnold I've pushed a patch that may help. Please see if there is anything in debug log when the phone can't connect. Thanks! |
|
@phaseloop I do not see any new commits in your branch develop...phaseloop:meshtastic-firmware:nrf52-power-saving-1 (I did my last test using the "force BLE param negotiation" revision) |
|
I commited to wrong branch, should be ok now |
|
Here is the log when my phone fails to connect twice and then succeeds on the third attempt (all I did to reproduce the problem is just connecting and disconnecting multiple times): I'm testing against 2.7.16 with your branch applied on top. |
|
Another type of failure: ... at this point the app says "Too Many Retries" (No device connected, and my T1000-E is not in the list of available radios) However, the radio thinks it is connected and if I force close the app, radio prints the following lines: |
|
Thanks! That helped a lot. I pushed another fix. It seems some Apple products between iOS versions have conflicting BLE requirements. So we probably need to test few settings to check what makes it happy. I |
|
Unfortunately the problem is still there. Also found another way to reproduce it (not 100% reliably, sometimes it works just fine):
Without the patch the app always connects reliably. iOS version 18.7.2 (latest for an iPhone XR) |
|
Thanks! I pushed another change - this time disabled Slave Latency at all. I increased the connection interval a bit so we can offset energy saves there. Are you on discord? Maybe we can switch there. I hope disabling SL will work this time xD |
|
@ponzano thank you! That was helpful. Can you try the latest commit to check if iPhone issues were fixed? |
|
@phaseloop With the latest version of your branch both my phone and laptop reliably connect to T1000-E |
|
Perfect, thanks! If @ponzano confirms latest patch works for their iPhone as well, I'll reopen the PR and merge those changes. Thank you all for testing and helping! |
Yes seems to work correctly with iPhone as well! Nice job 👍 |
…#8858) * Improve NRF52 bluetooth power efficiency * test T114 bad LFXO * T1000 test * force BLE param negotiation --------- Co-authored-by: Ben Meadors <benmmeadors@gmail.com>
…shtastic#8858)" This reverts commit ae8d3fb.
…#8858) * Improve NRF52 bluetooth power efficiency * test T114 bad LFXO * T1000 test * force BLE param negotiation --------- Co-authored-by: Ben Meadors <benmmeadors@gmail.com>
…shtastic#8858)" This reverts commit f0557db.









According to Nordic online power profiler and general industry recommendation for low power BLE devices (see below), this change should reduce raw bluetooth subsystem power usage by at least 300%.
In advertisement mode (no phone connection) simulated current drop should be from 146 uA to 56 uA for the RF layer only.
When phone is connected to node (theoretical) yield should be around 400% as node is allowed to skip up to 5 extra interrogation/keep-alive frames longer if there is no data to send (so called slave latency).
Physics behind it:
https://docs.silabs.com/bluetooth/2.13/bluetooth-general-system-and-performance/optimizing-current-consumption-in-bluetooth-low-energy-devices
Changes introduced:
This change to be in effect was confirmed by nRF Connect logs. I don't see any visible impact on Meshtastic app connection/discovery times to node or general Android visibility of the device.
Screenshot by SiLabs from link above:
While this is a generic industry knowledge and we know power savings are there, it would be good if someone with a decent power profiler can check how theoretical yield looks in practice. It would be great if other people can test this change with their phones and nodes.
Those are still pretty conservative settings so we can have further fun once this is verified to be stable across general population.
I suppose similar change to ESP32 may bring much drastic power savings.
🤝 Attestations
I have tested that my proposed changes behave as described.
I have tested that my proposed changes do not cause any obvious regressions on the following devices: