Skip to content

NRF52 - low voltage management, fixing data corruption - #8793

Closed
phaseloop wants to merge 17 commits into
meshtastic:developfrom
phaseloop:nrf52-voltage
Closed

NRF52 - low voltage management, fixing data corruption#8793
phaseloop wants to merge 17 commits into
meshtastic:developfrom
phaseloop:nrf52-voltage

Conversation

@phaseloop

@phaseloop phaseloop commented Nov 28, 2025

Copy link
Copy Markdown
Contributor

Draft - PR during testing and development.

Strayed a bit from original PR but in a good direction.

This PR solves various issues with NRF52 boards when voltage is below 3V - fixing some data corruption scenarios and making them less prone to boot loops and problems like power fail radio flood: #8763

While ESP32 boards die at around 3.0V, most NRF52 + LDO combinations easily allow to go down to 2.5V. Usually firmware will try to put device to sleep at around 3.1V but this often fails and it's a different story.

Introduced API will also make it possible to implement on other platforms in the future.

Changes:

  • implement isPowerLevelSafe() method to detect if current power state is safe for node to operate (driven by NRF52 POF power failure detection circuit). This will be especially important to prevent any NodeDB/config saving on power failure conditions to prevent flash corruption. Note that this does not use battery pin ADC but internal chip protection circuits.

  • prevent device boot when voltage is too low (boot will resume when voltage rises to safe level - for example on solar nodes). This will prevent bootloops. During waiting state - user led will flash in sequence to indicate device state.

  • move NRF52 power failure threshold from 2.4V to 2.7V which is above automatic cutoff value for li-ion battery protectors so we do not get unexpected power cutoff

TODO:

  • prevent any NodeDB saves during power failure condition. NRF52 automatically blocks flash writes - but Meshtastic interprets that as flash corruption and reboots and formats filesystem as soon as POF condition goes away. So we shoot ourselves in the foot with bazooka.

  • put device to deep sleep when power failure is detected without waiting for classic battery readings and ADC voltage detection because it may be already too late for that. One example is bad battery going from 3.2V to 2.5V in few seconds or powering boards from various external regulators (and countless unexpected failure modes).

@phaseloop
phaseloop marked this pull request as draft November 28, 2025 23:28
@CLAassistant

CLAassistant commented Nov 28, 2025

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@thebentern thebentern added the bugfix Pull request that fixes bugs label Nov 29, 2025
@phaseloop phaseloop changed the title Fix NRF52 memory corruption on low battery levels NRF52 - low power management, fixing data corruption Dec 1, 2025
@phaseloop phaseloop changed the title NRF52 - low power management, fixing data corruption NRF52 - low voltage management, fixing data corruption Dec 1, 2025
@phaseloop

Copy link
Copy Markdown
Contributor Author

closing, will reopen later as new PR

@phaseloop phaseloop closed this Jan 2, 2026
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.

3 participants