Changelog: - Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
324 lines
18 KiB
Markdown
324 lines
18 KiB
Markdown
# Power saving on a solar repeater — what it costs, measured
|
||
|
||
Everything here was measured on the deployment hardware (SenseCAP Solar Node
|
||
P1-Pro, nRF52840 + SX1262 + L76K) on 2026-08-05/06 with `tools/power_ab.py`, not
|
||
taken from a datasheet. Numbers are input current on the 5 V USB side; the delta
|
||
between two states is what the paired design measures, and that is what these
|
||
figures are.
|
||
|
||
## The order that matters
|
||
|
||
| lever | measured | verdict |
|
||
|---|---|---|
|
||
| **GPS running continuously** | **46.0 mA** (spread 43.7-47.5) | `gps duty` recovers 42-45 of it |
|
||
| BLE advertising + Bluefruit's blinking LED | see below | defaults changed, LED off, 1 s interval |
|
||
| `powersaving on` (MCU light sleep) | **~1 mA** with USB, **2.7 mA** without (XIAO, 11/2026) | keep it on |
|
||
| CC310 IRQ cleared before sleep (nRF52) | **2.6 mA** after every boot | fixed in firmware, see below |
|
||
| RX duty cycle (`set radio.rxps`, from EasySkyMesh) | **~2.3 mA** at `max` (XIAO, 12. 11. 2026) | **no** on a live node: -16 % received and a TX stall on mast-three, see below |
|
||
| `radio.rxgain off` | ~0.7 mA | **no** — 1-3 dB of sensitivity is what a mast node is for |
|
||
| FEM LNA control | n/a | SenseCap has no FEM, only an RXEN switch |
|
||
|
||
A whole node in the shipping configuration, with the battery charged and GPS
|
||
duty-cycled, sits at **~24 mA**. Continuous GPS alone would nearly triple that.
|
||
|
||
## GPS is the whole game
|
||
|
||
The receiver on this board draws 46 mA, and a mast repeater runs GPS for one
|
||
reason only: the RTC is volatile, and a node whose clock is wrong has its
|
||
replies dropped by clients. It does not need a continuous fix — it needs the
|
||
clock set.
|
||
|
||
GPS is no longer the *only* way to get that (since 7. 8. 2026 a node starts at
|
||
its build epoch and any attached host sets it — see `docs/cli_commands.md` under
|
||
`time`). A reboot still throws the clock back to the build epoch: carrying it
|
||
across one in retained RAM was tried and measured not to work, because the
|
||
bootloader's stack owns the top of RAM. GPS is still
|
||
what makes a mast node's clock **absolutely** right months after the flash, with
|
||
nobody there to set it, so this reasoning stands for anything on a mast. What
|
||
changed is that a node without GPS is no longer stuck in 2024.
|
||
|
||
`gps duty` (`gps_enabled == 2`, so no prefs-layout change) powers the receiver
|
||
only around a sync, once a day (until 11/2026 every 30 minutes, the cadence
|
||
`gps on` re-syncs at). The LF crystal is ±20 ppm plus ~40 ppm at −10 °C, so a
|
||
day costs ~5 s of clock — far below what the mesh notices — and a reboot syncs
|
||
at once anyway. Verified on hardware in both paths (with the old 30 min / 1 h
|
||
timers):
|
||
|
||
- with sky (`mast-three`): `duty, asleep, fix, 7 sats` — got a fix, set the clock,
|
||
cut power to the receiver;
|
||
- without (indoors, `bench-rpt`): `awake` for exactly 300 s
|
||
(`GPS_DUTY_MAX_AWAKE_SECS`), then `asleep` with an hourly retry, so a blocked
|
||
sky cannot turn duty mode back into "always on".
|
||
|
||
Worst case (fix never obtained) still saves 42 mA; a normal 30 s fix saves 45.
|
||
Going from 30 min to 24 h saves another 0.25–0.75 mA (hot vs. warm start, not
|
||
measured per window), and the retry from 1 h to 6 h takes a node whose dome is
|
||
under snow from 3.8 mA (300 s at 46 mA hourly) to 0.64 mA.
|
||
Knobs: `GPS_DUTY_SYNC_INTERVAL_SECS` (86400), `GPS_DUTY_MAX_AWAKE_SECS` (300),
|
||
`GPS_DUTY_RETRY_SECS` (21600).
|
||
|
||
Upstream later (v1.18 dev, 11/2026) added its own `gps period <s>`. It is not a
|
||
replacement: a periodic acquisition has no timeout until the first fix ever, so
|
||
the indoor case above would stay at 46 mA for good. `gps duty` sets the period
|
||
to 0, and `gps on` / `gps off` leave duty mode.
|
||
|
||
**One visible side effect:** `querySensors()` only adds the GPS channel to
|
||
telemetry while the receiver is powered, so a duty-cycled node reports position
|
||
in telemetry only during its sync windows (well under 1 % of the time). What a repeater
|
||
*advertises* is unaffected — that comes from prefs via `set advert.loc prefs` (formerly `gps advert prefs`) — and
|
||
`node_lat/lon` keep the last fix. Confirmed in the field: `mast-three`'s scrape now
|
||
carries `voltage/temperature/humidity` and no `gps` field.
|
||
|
||
## BLE: two defaults that were quietly expensive
|
||
|
||
- **The blinking LED.** Bluefruit drives `LED_BLUE` while advertising and holds
|
||
it on while connected. On SenseCap Solar that pin is **12 — the same pin as
|
||
`P_LORA_TX_LED`**, so a sealed mast node spent solar charge blinking an LED
|
||
nobody can see, and the LoRa TX indicator lied as a bonus.
|
||
`RPT_BLE_CONN_LED` now defaults to 0.
|
||
- **The advertising rate.** Upstream leaves the slow interval at 244 units =
|
||
152.5 ms, i.e. three channels ~6.5 times a second, forever.
|
||
`RPT_BLE_ADV_SLOW` now defaults to 1600 = 1 s; the first
|
||
`RPT_BLE_ADV_FAST_SECS` (30) after boot or disconnect stay fast so discovery
|
||
is still immediate when someone is looking.
|
||
|
||
Bench boards keep both upstream behaviours (`-D RPT_BLE_CONN_LED=1`,
|
||
`-D RPT_BLE_ADV_SLOW=244` in `xiao_analyzer`): on a desk the blinking LED is the
|
||
"this thing is alive" indicator.
|
||
|
||
`ble off` remains the big BLE lever for a deployed node, but the deployment rule
|
||
stands: ship with BLE **on**, verify the node on site, and only then turn it off
|
||
over the mesh — otherwise a node that does not come up has no way in.
|
||
|
||
## RX duty cycle (rxps)
|
||
|
||
Ported from EasySkyMesh PowerSaving v18 behind `-D WITH_RX_POWERSAVING` (the
|
||
public releases have it), SX1262 only, **off until set**. The radio listens in
|
||
short windows and sleeps between them, staying awake through a packet once it
|
||
hears a preamble; after three failed arms it falls back to continuous RX by
|
||
itself. Commands: `docs/cli_commands.md`, `radio.rxps`.
|
||
|
||
Measured 12. 11. 2026 on a XIAO nRF52840 + Wio-SX1262 (not the SenseCAP of
|
||
the rest of this page), bench preset 866.5 MHz / SF8 / BW62.5, fed at 5 V
|
||
through an INA226 (10 mOhm) read every 5 s; the only other load was a UC96 on
|
||
the XIAO's USB port. A/B/A/B, 15 min cells, the first 2 min of each dropped:
|
||
|
||
| cell | rxps | mean | median |
|
||
|---|---|---|---|
|
||
| 1 | off | 33.84 mA | 32.2 mA |
|
||
| 2 | max | 31.31 mA | 30.5 mA |
|
||
| 3 | off | 33.53 mA | 32.5 mA |
|
||
| 4 | max | 31.36 mA | 30.3 mA |
|
||
|
||
`max` (level 8) against the mean of its neighbours: **-2.4 / -2.2 mA**, pooled
|
||
-2.35 mA (medians -1.95 mA); off vs off differs by 0.3 mA, max vs max by
|
||
0.05 mA. That is the radio's share, so it carries over to other SX1262 boards
|
||
in absolute terms; the 33 mA base is this bench (meter, BLE advertising), not
|
||
a node. Behind the XIAO's linear regulator the battery sees the same current:
|
||
~7-8 mW at 3.3 V.
|
||
|
||
Reception: a 3-board zero-hop matrix (x1, x3, x4; rxps switched on x1 and x4,
|
||
x3 the reference with rxps off; 20 rounds per phase, each link witnessed by
|
||
another board), run twice -- on the development build, then repeated on the
|
||
public release `v1.18.0+tth.20261112` (`ver` v1.18.0-tthd4afea1):
|
||
|
||
| phase | development build | public release | together |
|
||
|---|---|---|---|
|
||
| rxps off | 0/120 | 1/120 | 1/240 |
|
||
| `on` (level 3) | 1/120 | 2/120 | 3/240 |
|
||
| `max` (level 8) | 0/120 | 0/120 | **0/240** |
|
||
|
||
rxps stayed armed throughout, no error counts. Single losses happen with rxps
|
||
off as well, and of the three at level 3 one was on x3, which had rxps off: the
|
||
bench shows no degradation at any level. Not measured: mixed SF/preamble senders, a busy
|
||
live mesh. On a mast, where 2 mA of ~24 is not the problem, leave it off.
|
||
|
||
**On the live mesh it failed (mast-three, 14. 11. 2026, `max`).** Against ob1 as
|
||
the reference for the hour-to-hour traffic, the node received ~16 % fewer
|
||
packets (2.08 vs 2.47 per ob1 packet) with ~30 % more `recv_errors`, and within
|
||
two hours of switching it on it stopped transmitting altogether: `sent` frozen,
|
||
queue full (32), no `tx_start_fail`/`tx_timeout`, RX still counting -- so no
|
||
adverts and no replies to an admin login, for 6+ hours. `radiostat` showed
|
||
`irq=0x0014` (preamble + header valid, no RX done). `set radio.rxps off` did
|
||
NOT bring TX back; a reboot did. The mechanism is not proven, and the radio
|
||
silence watchdog cannot see it (it watches RX only). Do not enable rxps on a
|
||
node that has to answer.
|
||
|
||
## MCU sleep
|
||
|
||
`powersaving on` makes the nRF52 wait in WFE between events (it wakes on any
|
||
interrupt, including LoRa DIO1). Upstream ships it **off**, and it was missing
|
||
from our provisioning, so every node built from that file ran the core at 64 MHz
|
||
around the clock. It is now in our provisioning file.
|
||
|
||
**But it buys about 1 mA, not the 3-4 that seemed obvious.** Measured with GPS
|
||
held off so its sync windows could not pollute the cells: paired estimate
|
||
-0.96 mA over three pairs, spread -1.97 to +0.07, against a measured
|
||
cell-to-cell repeatability of 1.16 mA — i.e. the effect is the same size as this
|
||
rig's noise and cannot be told from zero. That fits the mechanism: the loop
|
||
still polls the SX1262 over SPI on every pass and the SoftDevice wakes the core
|
||
for each advertising event, so there is not much idle left to sleep through.
|
||
Keep it on (it is free and cannot hurt), but do not budget for it.
|
||
|
||
Blocking the loop task instead of waiting for an event (so that FreeRTOS can
|
||
sleep tickless) changes nothing either: `delay(10)` against `sd_app_evt_wait()`,
|
||
XIAO x4, A/B/A/B 30 min cells (14. 11. 2026): paired difference **0.04 mA**,
|
||
cell repeatability 0.1-0.4 mA. The tick wakeups are not where the current goes.
|
||
|
||
One fork-specific fix goes with it: the sleep is also held off while the BLE
|
||
console still has queued output (`bleTxPending()`), because on the observer node
|
||
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: 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 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`) 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:
|
||
|
||
| | 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 |
|
||
|
||
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`.
|
||
|
||
## nRF52 sleep & peripheral fixes
|
||
|
||
An audit of the nRF52840 firmware and the Adafruit core found several sources of
|
||
idle draw that apply to all nRF52 boards, not only SenseCAP Solar. They were
|
||
measured on 25./26. 11. 2026 on XIAO x4 (nRF52840 + Wio-SX1262, repeater build,
|
||
bench preset). Setup: no USB host, fed at 5 V through an INA226 read every
|
||
~1 s. Each cell was 10 min (20 min for rxps), 38 cells over two rounds. Every
|
||
knob was switched at runtime between two baseline cells. The baseline
|
||
repeatability was **0.05 mA**, so an effect counts only above 0.1 mA and with
|
||
the same sign in both rounds. The 5 V pin is VBUS, so USBD and HFXO stay up;
|
||
read the absolute numbers as this rig and the deltas as the result.
|
||
|
||
**The one that matters: `CRYPTOCELL_IRQn` sleep insomnia (+2.6 mA).**
|
||
`USE_CC310_HW_CRYPTO=1` runs CC310 in polling mode with `CRYPTOCELL_IRQn`
|
||
disabled in NVIC. A completed operation leaves the IRQ pending, and a pending
|
||
IRQ ends `sd_app_evt_wait()`/`__WFE()` immediately. `NRF52Board::sleep()` now
|
||
clears it before sleeping, as the Adafruit core's `wiring.c` does. Without the
|
||
clear, a node comes out of every boot stuck at **14.1 mA instead of 11.5**:
|
||
|
||
| boot with | before first BLE connection | after it |
|
||
|---|---|---|
|
||
| both fixes | 11.51 / 11.51 mA | 11.48 / 11.49 mA |
|
||
| no CC clear | **14.13 / 14.15 mA** | 11.38 / 11.52 mA |
|
||
| no CC clear, no late DC/DC (= old main) | **14.04 / 14.14 mA** | 11.50 / 11.55 mA |
|
||
| no late DC/DC | 11.43 / 11.53 mA | 11.51 / 11.53 mA |
|
||
|
||
Values are round 1 / round 2. In the stuck state the core wakes
|
||
~15 000 times a second, against ~990 for the 1024 Hz tick, and it is awake
|
||
for 80 % of the time. It is not an occasional spike either: 98–100 % of the
|
||
samples sit above 13 mA. Received LoRa packets do not end it (5 per window). The
|
||
first BLE connection does; the mechanism is not traced. A mast node that nobody
|
||
connects to over BLE stays in it. Toggling the clear at runtime
|
||
on an already clean node changes nothing (+0.01 / +0.02 mA), because the state
|
||
is decided at boot.
|
||
|
||
**Measured to make no difference, kept anyway** (each below 0.1 mA):
|
||
- **DC/DC re-enabled after SoftDevice start** (`onBootComplete()`):
|
||
+0.02 / −0.10 mA at runtime, and no difference as a boot flag. The premise
|
||
that S140 puts `NRF_POWER` back to LDO did not hold on this board.
|
||
`DCDCEN` read 1 after every boot, with or without the late enable. The
|
||
late enable is kept as a harmless safeguard.
|
||
- **Noise-floor calibration every 10 s instead of 2 s**
|
||
(`NOISE_FLOOR_CALIB_INTERVAL`): +0.08 mA, one pair.
|
||
|
||
**Not measured** (compile-time or other hardware):
|
||
- **Avoid `NRF_SPIM3` (Nordic Errata 195)**: `[nrf52_base]` sets
|
||
`-D SPI_32MHZ_INTERFACE=1`, which moves the SX1262 `SPI` bus from `NRF_SPIM3`
|
||
to `NRF_SPIM2`. `SPIClass::endTransaction()` disables `SPIM3` without the
|
||
errata workaround, which is worth ~1.2–2 mA idle per the errata. A clean
|
||
baseline of 11.5 mA on this board leaves little room for that.
|
||
- **GPS UART pins disconnected while the GPS is off**:
|
||
`NmeaGpsDriver::stopHardware()` resets TX/RX via `nrf_gpio_cfg_default()`
|
||
after `Uart::end()`, so the unpowered receiver is not back-powered.
|
||
- **Unused I2C bus switched off**: `EnvironmentSensorManager::begin()` calls
|
||
`Wire.end()` when the bus scan finds no device, and enables it again for the
|
||
`i2c` CLI command.
|
||
- **SenseCAP Solar battery divider (`VBAT_ENABLE`)**: held `HIGH` (off) at boot
|
||
and set back to `HIGH` right after `getBattMilliVolts()`, instead of staying
|
||
`LOW`. `initiateShutdown()` still drives it `LOW` when it arms the LPCOMP
|
||
wake. Open question: with the divider off, the ADC pin may sit near VDD +
|
||
0.3 V on a full cell. This is yet to be checked with a meter on the board.
|
||
|
||
**Runtime knobs from the same night**, for comparison (paired deltas):
|
||
|
||
| knob | round 1 | round 2 | reception (x1 witness) |
|
||
|---|---|---|---|
|
||
| `set radio.rxps max` | −2.47 mA | −2.33 mA | 20/21 |
|
||
| `set radio.rxps balanced` | −1.98 mA | −1.88 mA | 20/21 |
|
||
| `set radio.rxgain off` | −0.49 mA | −0.45 mA | 10/12 |
|
||
| `powersaving off` | +2.66 mA | (one pair) | 5/6 |
|
||
| baseline | | | 83/90 |
|
||
|
||
The x1 witness sends zero-hop adverts every ~130 s at 2 dBm. Reception counts
|
||
are approximate at cell edges, and no knob showed a gross loss. The bench
|
||
signal is strong, so this does not test sensitivity, and the rxps failure on
|
||
the live mesh (see above) still stands. `powersaving` is worth 2.7 mA here
|
||
without USB, much more than the ~1 mA measured with USB attached (USB keeps
|
||
HFCLK running).
|
||
|
||
Tools: `tools/power_ab.py --ina <url>` (INA226 of a solar controller as the
|
||
meter, raw samples saved), firmware bench knobs and the night driver are kept with
|
||
the run log, outside the repository.
|
||
|
||
## Measuring this yourself — two traps
|
||
|
||
1. **A solar node measured on its USB side measures the CHARGER.** With a
|
||
charging cell the meter reads 500-700 mA, pulsing, and the node's own tens of
|
||
mA ride on top of a drifting number. Wait for the charge to finish (it fell
|
||
0.71 → 0.53 → 0.22 → 0.05 A over about an hour here) or the numbers are
|
||
fiction. There is **no INA226 on this board** to cross-check with — the `i2c`
|
||
command reports nothing at all on the only bus the variant has — on three
|
||
separate P1-Pro units (`bench-rpt`, `mast-rpt-two`, `tth-mast-repeater-one`),
|
||
against a sensor table that expects `38 76 70 44 5C 42 40 41 5A 29 77`. So it
|
||
is the board, not one dead part, and the cross-check for a power measurement
|
||
has to be a second *board*.
|
||
2. **With `gps duty` enabled you cannot measure anything under ~5 mA.** A sync
|
||
window lands in a random cell and adds ~17 mA to a 10-minute average (seen:
|
||
40.9 mA against 24.1-24.5 in its neighbours). Put `gps off` in every cell of
|
||
such a run and restore `gps duty` afterwards.
|
||
|
||
See `tools/power_ab.py --help` for the alternating-cell design that makes
|
||
these deltas trustworthy in the first place.
|