Repeater (SenseCAP Solar): battery thresholds settable at runtime, and a cutoff that switches a running node off before the cell runs flat
pub-release / release (push) Successful in 34m55s

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
tthandClaude Opus 5.5 committed 2026-11-23 13:22:24 +01:00
1 parent 0066d073db
commit be46cfa5fb
10 files changed
+392 -19

No files matched your search

+40 -16
View File
@@ -170,29 +170,53 @@ a half-drained `rxlog`/`pktlog` page would otherwise wait for the next
connection event — the bridge drains those on a 2-minute duty cycle, so a slower
drain directly costs collected frames.
## A mast that runs flat (boot protection)
## A mast that runs flat: bootlock and cutoff
A panel that gets no direct sun in winter (remote-mast faces east, 11/2026:
-50 mV a day from mid-November with consumption unchanged) eventually drains
the cell. Without protection the node then browns out, and every bit of
light restarts it on a cell that cannot hold it -- a boot loop at the edge.
the cell. Without protection the node runs until the brown-out, and every bit
of light then restarts it on a cell that cannot hold it -- a boot loop at the
edge, with the cell deep-discharged on the way.
`SenseCap_Solar_repeater` builds with `NRF52_POWER_MANAGEMENT` (upstream code,
wired in `variants/sensecap_solar`, only the switch was off): at boot the
node reads the battery and, below **3.3 V** (`PWRMGT_VOLTAGE_BOOTLOCK`), goes to
SYSTEMOFF with the LPCOMP armed on the battery input; it wakes when the
battery rises past the comparator threshold (3/8 VDD, ~3.4-3.7 V on the cell
per `variant.h`) and boots normally. USB power skips the check.
wired in `variants/sensecap_solar`) and `PWRMGT_RUNTIME` (ours), which gives
two thresholds, both saved on the node and settable from the console or as an
admin over the mesh:
What it does **not** do: switch off a running node as the battery falls --
nothing in the firmware calls the runtime low-voltage shutdown. It protects
the restart, not the discharge. The clock goes back to the build epoch after
such a restart, as after any power loss (`gps duty` resyncs it, `time` sets it).
| | default | |
|---|---|---|
| `set pwr.bootlock <mV>\|off` | 3300 mV (`variant.h`) | at boot, below it the node goes to SYSTEMOFF and the LPCOMP wakes it when the battery recovers |
| `set pwr.cutoff <mV>\|off` | off | while running, three readings in a row (one a minute) below it switch the node off into the same SYSTEMOFF |
| `get pwr` | | both, the battery now and at boot, USB, the reason of the last switch-off |
**Not yet verified on hardware**: the thresholds come from `variant.h`. Bench
test with an adjustable supply on the battery terminals: boot at 3.2 V must
stay dark, raising it to ~3.8 V must wake the node by itself; `get boot`
then shows `RESETREAS=0x00020000` (bit 17, wake from LPCOMP).
The cutoff must stay below the bootlock -- a node switched off at the cutoff
starts again only past the bootlock, which is the hysteresis (e.g. cutoff
3400, bootlock 3600). The node refuses a threshold above the battery voltage
at that moment (it would lock itself out of a mast), USB power disarms the
cutoff and skips the boot check, a reading under 1 V counts as an ADC glitch.
The values live in `/pwr_guard`, not in the prefs; without the file the build
defaults apply (`PWRMGT_BOOTLOCK_DEFAULT`, `PWRMGT_CUTOFF_DEFAULT`).
The wake level is not one of the thresholds: it is the LPCOMP comparing the
battery divider with 3/8 VDD, ~3.4-3.7 V on the cell per `variant.h`, fixed in
hardware steps. A bootlock above it means the node wakes, checks, and sleeps
again until the cell is past the bootlock -- harmless, each wake is a few ms.
The clock goes back to the build epoch after such a restart, as after any
power loss (`gps duty` resyncs it, `time` sets it).
Why upstream has it off: a fixed 3.3 V lock kept LiFePO4 and LTO nodes from
booting (#2377, v1.18.0); a chemistry-aware version is open as #2088 (FS read
before the check, per-chemistry thresholds). Ours is narrower -- one board
with a known Li-ion cell, two numbers, `off` for either -- and has to be
reconciled with #2088 if that lands.
**Not yet verified on hardware**: the logic has host tests
(`test/test_low_voltage_guard`), the thresholds and the wake level do not.
Bench test with an adjustable supply on the battery terminals: boot at 3.2 V
must stay dark; raising it to ~3.8 V must wake the node by itself (`get boot`
then shows `RESETREAS=0x00020000`, bit 17, wake from LPCOMP); with a cutoff
set, lowering the supply below it must switch the node off within ~3 minutes
and `get pwr` after the wake must say `last off: Low Voltage`.
## Measuring this yourself — two traps