Skip to content

Stop preventing sleep on low battery for NRF52#7285

Closed
Joseph-DiGiovanni wants to merge 1 commit into
meshtastic:masterfrom
Joseph-DiGiovanni:nrf52-low-battery
Closed

Stop preventing sleep on low battery for NRF52#7285
Joseph-DiGiovanni wants to merge 1 commit into
meshtastic:masterfrom
Joseph-DiGiovanni:nrf52-low-battery

Conversation

@Joseph-DiGiovanni

@Joseph-DiGiovanni Joseph-DiGiovanni commented Jul 9, 2025

Copy link
Copy Markdown

This PR removes code that inhibits low battery sleep on NRF52-based nodes. The "freezing" noted in the comment when it was added in 2022 is not well documented, or explained anywhere else as far as I can find. More importantly, it doesn't appear to be happening anymore. It would seem to me that its not only safe, but necessary to remove this workaround and prevent batteries from over-discharging.

EDIT: I've updated the PR to only avoid low battery sleep when necessary. See my update comment for details.

Fixes #4378

🤝 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:
    • Heltec (Lora32) V3 N/A
    • LilyGo T-Deck N/A
    • LilyGo T-Beam N/A
    • RAK WisBlock 4631
    • Seeed Studio T-1000E tracker card

I've also tested this PR cherrypicked to the latest beta release (v2.6.11)

@CLAassistant

CLAassistant commented Jul 9, 2025

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@Joseph-DiGiovanni Joseph-DiGiovanni changed the title Allow sleep on low battery for NRF52 Stop preventing sleep on low battery for NRF52 Jul 13, 2025
@caveman99

Copy link
Copy Markdown
Member

What was happening is the node would not boot back up when sufficient power was applied, especially on a slowly rising level like you would get from a solar panel. Can you confirm this is not happening any more?

@Joseph-DiGiovanni

Joseph-DiGiovanni commented Jul 16, 2025

Copy link
Copy Markdown
Author

node would not boot back up when sufficient power was applied

@caveman99 This doesn't seem to be the expected behavior. The code tells the device to sleep for config.power.sds_secs which defaults to one day for routers and UINT32_MAX (effectively infinite time) otherwise.

If you've witnessed a node wake from the low battery state, it was likely a router that woke up the next day to check the battery level rather than waking because of the battery level. With that in mind, I can confirm my WisBlock mini does not correctly wake after config.power.sds_secs for unknown reasons, which is likely what they mean by "freezing".

Perhaps allowing super deep sleep when sds_secs is the UINT32_MAX default is a good compromise? That way nodes expecting to wake up regularly to recheck voltage (like routers) will not fall into this bugged infinite sleep while all other users that expect an infinite sleep will get exactly that :)

@Joseph-DiGiovanni

Copy link
Copy Markdown
Author

Now we'll only allow super deep sleep if "Super Deep Sleep Seconds" is set to the default of UINT32_MAX. Then it doesn't matter if the board freezes since it wouldn't be waking up for over 136 years anyway.

This avoids the known deep sleep bug on NRF52 while preserving the intended behavior for most users.

@garthvh

garthvh commented Jul 16, 2025

Copy link
Copy Markdown
Member

This was very problematic, can you verify this is not happening anymore?

@Joseph-DiGiovanni

Copy link
Copy Markdown
Author

Please read my previous comment. The latest version of this PR should make the board freezing issue irrelevant.

@vidplace7 vidplace7 added the bugfix Pull request that fixes bugs label Jul 18, 2025
@Kazagumo

Kazagumo commented Aug 5, 2025

Copy link
Copy Markdown

tested on my device,seems work

@Joseph-DiGiovanni

Copy link
Copy Markdown
Author

Can this be merged please? This simple fix is far overdue for something that could prevent battery damage. At this point I've shipped 80+ devices with this PR cherrypicked to 2.6.11 with no issue, so I'm fairly confident it works as intended.

@garthvh garthvh closed this Aug 6, 2025
@Joseph-DiGiovanni

Copy link
Copy Markdown
Author

@garthvh If you have an issue we can discuss it. Closing my PR without reading it is ridiculous.

@sachaw sachaw reopened this Aug 6, 2025
@jp-bennett

Copy link
Copy Markdown
Collaborator

I think the missing bit of information here is that RAK boards are intended to wake from deep sleep when the battery power exceeds 3.7v, regardless of what super deep sleep seconds is set to.

See https://forum.rakwireless.com/t/how-can-i-automatically-recovery-a-wisblock-box-from-a-low-battery-scenario/11352/3 for Bernd, a RAK engineer describing exactly the bug in question.

@Joseph-DiGiovanni

Joseph-DiGiovanni commented Aug 6, 2025

Copy link
Copy Markdown
Author

@jp-bennett reading that thread it seems to imply there is a hardware issue rather than software. The current expected behaviour is to sleep X seconds regardless of what board is in use. In the case of solar nodes just set SDS seconds to any non max value (or one day as is the current default for routers) and the low battery sleep is bypassed avoiding freezing.

On a side note, it seems strange to prioritize the uptime of solar nodes with undersized batteries/panels over the battery health and safety of all nodes.

@alexl83

alexl83 commented Aug 12, 2025

Copy link
Copy Markdown

I'm running this changes (cherry-picked) on 2.6.11 latest beta on my heltecs T114 and rak4631 and everything runs fine

alexl83 pushed a commit to alexl83/firmware that referenced this pull request Sep 1, 2025
…irmware into forkmaster

 Stop preventing sleep on low battery for NRF52 meshtastic#7285
@viric

viric commented Sep 6, 2025

Copy link
Copy Markdown
Contributor

I think that the hang you see not respecting SDS time is expected in a ROUTER node:
https://github.com/meshtastic/firmware/blob/develop/src/platform/nrf52/main-nrf52.cpp#L358

The device sleeps only if TRACKER/SENSOR. Otherwise it's powered off and will only be powered back on user button press.

@viric

viric commented Sep 11, 2025

Copy link
Copy Markdown
Contributor

@Joseph-DiGiovanni in this my PR (#7882) I do more than using the deep sleep, FYI.

alexl83 added a commit to alexl83/firmware that referenced this pull request Sep 20, 2025
…irmware into forkmaster

 Stop preventing sleep on low battery for NRF52 meshtastic#7285
@Joseph-DiGiovanni

Copy link
Copy Markdown
Author

Closing in favor of #7882. Thank you for the awesome work @viric

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugfix Pull request that fixes bugs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: nrf52 boards are not entering deep sleep when battery is critically low (make system_off mode work on nrf52)

10 participants