Skip to content

Conversation

@entr0p1
Copy link

@entr0p1 entr0p1 commented Jan 17, 2026

This PR implements initial stages of power management functionality for nRF52840 nodes to prevent lockups and flash corruption associated with low voltage. This is designed to be modular and enabled per-variant.

Phase 1 (this PR) includes:

  • Startup lockout - minimum voltage reading from VBAT is required in order to proceed with the boot. If voltage is deemed too low, the board will enter the shutdown state. This is gated if there is external power present (e.g. 5V, USB) to prevent erroneous lockouts if the board is charging.
  • LPCOMP wake - when voltage readings from the battery return to a healthy state (i.e. indicating charging), a board reset is issued and the board will boot back up without external intervention. This is enabled when shutdown is initiated from Startup lockout.

Added src/helpers/nrf52/Nrf52EarlyBoot.cpp:
- Early register capture before SystemInit()

Added src/helpers/nrf52/Nrf52PowerMgt.h:
- Phase 1 API (PowerMgtConfig, PowerMgtState, initState, checkBootVoltage, configureLpcompWake, enterSystemOff)

Added src/helpers/nrf52/Nrf52PowerMgt.cpp:
- Initial Implementation

Modified src/MeshCore.h:
- Added power management virtual methods to MainBoard

Added first supported board (Xiao nRF52840) for testing.
@entr0p1
Copy link
Author

entr0p1 commented Jan 17, 2026

Leaving this in a draft state so it can be tested as this is a major refactor to centralise more of the code away from individual variants, and tidy up general sloppiness/hacky code from the v1 implementation.

@mattzzw
Copy link
Contributor

mattzzw commented Jan 18, 2026

Would this work also e.g. with nfr52 based systems that do not have voltage divider resistors for the ADC port in place? (Thinking e.g. of ProMicro)

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants