[Feature Request] Generic nRF52 LPCOMP solar wake-up, strict external radio power management, and user-defined voltage thresholds
Platform
NRF52
Description
This is a feature request to implement a robust power management architecture for nRF52-based boards utilizing external LoRa modules (like the EBYTE E22P series) and solar harvesting. It aims to move away from hardcoded low-voltage thresholds to a fully dynamic approach applicable to any radio module with a sleep/enable pin.
- Strict External Radio Power Management: Currently, modules with active internal pull-ups (like the E22P) can suffer from backpowering or phantom boot-ups when the nRF52 enters SYSTEM_OFF if the enable pin is left floating (INPUT).
Proposal: Introduce a generic EXTERNAL_RADIO_ENABLE_PIN macro. Board designers/DIYers would simply wire their radio's EN/RXEN pin to a free GPIO and define this macro in their variant.h.
Modify cpuDeepSleep() to force this pin to OUTPUT and LOW, actively pulling it to GND during deep sleep to completely eliminate parasitic drain from external PA/LNA modules.
- Dynamic LPCOMP Solar Resurrection:
Proposal: Integrate the nRF52 LPCOMP hardware to wake the node from SYSTEM_OFF via the DETECT_UP event on a designated analog pin (e.g., BATTERY_LPCOMP_INPUT).
Include a helper function that dynamically maps a target mV wake threshold to the closest nrf_lpcomp_ref_t fraction (1/8 to 15/16) based on the specific board's resistor divider ratio (defined in variant.h).
- User-Defined Voltage Thresholds (App Integration):
Proposal: Replace the hardcoded OCV_ARRAY shutdown threshold with user-configurable values via the App: config.power.deep_sleep_voltage_mv and config.power.wake_voltage_mv (would require a PR in the protobufs repo).
The low_voltage_counter logic would evaluate against the user-defined deep_sleep_voltage_mv before triggering EVENT_LOW_BATTERY.
- Safe Regulatory Overrides for High-Power Modules:
Proposal: Allow boards with sensitive external PAs to securely define SX126X_MAX_POWER and LORA_DUTY_CYCLE_PERCENT in their variant.h to override regional defaults natively (e.g., EU_868) without breaking global compliance for other standard boards.
Motivation and Context: DIY and custom infrastructure nodes (like ProMicro/NiceNano + E22P + Solar) struggle with hardcoded sleep thresholds and backpowering issues, requiring external hardware watchdogs (like ATtiny13A or TLV840) to prevent deep-discharge bricking and bootloops. This software-native approach allows these boards to achieve near-zero quiescent current during SYSTEM_OFF and reliably wake up purely based on solar recovery, parameterized by the end-user depending on their specific Li-Ion/LiFePO4 chemistry.
Testing Proof of Concept: We have successfully tested this exact architecture on a custom branch.
Hardware: Faketec V5 (nRF52840 ProMicro base) with an EBYTE E22P (SX1262) module, and Seeed Studio XIAO nRF52840.
Results: Node configured with BATTERY_LPCOMP_INPUT_7 and a 1M/1M divider. Verified quiescent current drops to ~15µA plus extra hardware if are, during SYSTEM_OFF (radio EN actively grounded). Verified node autonomously boots when a variable bench supply crosses the calculated LPCOMP threshold (e.g., 3.71V).
Thanks for your work
A related request is described in Sleeping Beauty Mode https://github.com/meshtastic/firmware/issues/9911
Number 3 has been mentioned before, and I belive its a good idea. We still want to see the "true" % for the battery, but be able to shut down earlier. Mentioned in this issue: https://github.com/meshtastic/firmware/issues/9699#issuecomment-3973819176
This issue has not had any comment or update in the last month. If it is still relevant, please post update comments. If no comments are made, this issue will be closed automagically in 7 days.
This issue has not had any comment since the last notice. It has been closed automatically. If this is incorrect, or the issue becomes relevant again, please request that it is reopened.