Skip to content

fix(power): latch low-battery decision in RTC memory and add recovery hysteresis#10440

Open
DatanoiseTV wants to merge 1 commit into
meshtastic:developfrom
DatanoiseTV:fix/power-low-battery-hysteresis
Open

fix(power): latch low-battery decision in RTC memory and add recovery hysteresis#10440
DatanoiseTV wants to merge 1 commit into
meshtastic:developfrom
DatanoiseTV:fix/power-low-battery-hysteresis

Conversation

@DatanoiseTV
Copy link
Copy Markdown
Contributor

The previous low-voltage handler counted 11 consecutive readings under
OCV[min] and triggered EVENT_LOW_BATTERY, but on SDS wake the counter
reset to 0. With the cell still flat, the count climbed back to 11 and
deep-slept again — wake-thrash burning boot energy each cycle. There
was also no recovery hysteresis: a brief spike across the threshold
would clear the count even with the battery still effectively flat.

Persist the latch in RTC memory so SDS doesn't lose it. Once latched,
clearing requires K consecutive readings above OCV[min] + 100 mV. If
the device wakes and is still latched-flat, immediately re-enter SDS
without running a normal boot.

Split out from #10425 — single-concern PR.

Build verification

pio run -e t-deck-tft succeeds, no new warnings.

Attestations

  • I have tested that my proposed changes behave as described — review/static-analysis only, not on-air.
  • On-hardware testing requested from community: build-verified t-deck-tft only.

…eresis

The previous low-voltage handler counted 11 consecutive readings under
OCV[min] and triggered EVENT_LOW_BATTERY, but on SDS wake the counter
reset to 0. With the cell still flat, the count climbed back to 11 and
deep-slept again — wake-thrash burning boot energy each cycle. There
was also no recovery hysteresis: a brief spike across the threshold
would clear the count even with the battery still effectively flat.

Persist the latch in RTC memory so SDS doesn't lose it. Once latched,
clearing requires K consecutive readings above OCV[min] + 100 mV. If
the device wakes and is still latched-flat, immediately re-enter SDS
without running a normal boot.
@github-actions github-actions Bot added the bugfix Pull request that fixes bugs label May 9, 2026
@thebentern thebentern requested a review from Copilot May 9, 2026 17:54
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR hardens low-battery handling to reduce boot-energy waste on flat cells by persisting a “low battery” decision across deep sleep and adding a recovery hysteresis requirement before clearing that decision.

Changes:

  • Add a persisted low-battery latch (RTC_DATA_ATTR on ESP32) so SDS wake-ups don’t lose the low-battery decision.
  • Add recovery hysteresis requiring multiple consecutive readings above OCV[min] + 100mV/cell before clearing the latch.
  • If still latched and below the recovery threshold, re-trigger low-battery sleep instead of proceeding normally.

Comment thread src/Power.cpp
Comment on lines +990 to +994
// OCV[] is per-cell; getBattVoltage() returns pack voltage. Scale by
// NUM_CELLS to keep the comparison consistent with the per-cell
// table on multi-cell variants (e.g. chatter2, station-g1).
constexpr int LOW_BATT_HYSTERESIS_MV_PER_CELL = 100;
const int v = batteryLevel->getBattVoltage();
Comment thread src/Power.cpp
Comment on lines +1006 to +1009
low_voltage_counter = 0;
LOG_INFO("Latched low-battery still flat at %dmV, re-enter deep sleep", v);
powerFSM.trigger(EVENT_LOW_BATTERY);
}
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.

2 participants