Changelog: - Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
504 lines
30 KiB
Markdown
504 lines
30 KiB
Markdown
# Power saving on a solar repeater — what it costs, measured
|
||
|
||
Every number on this page was measured, none is from a datasheet unless it
|
||
says so. Two rigs: a **SenseCAP Solar P1-Pro** (nRF52840 + SX1262 + L76K GPS,
|
||
the mast board) on its 5 V USB side, August 2026; and a **XIAO nRF52840 +
|
||
Wio-SX1262** fed on its 3V3 pin at 3.25 V through an INA226, no USB -- the
|
||
closer match to a node on a cell -- in November and December 2026. Each figure
|
||
is a paired A/B delta (`tools/power_ab.py`); the absolute currents belong to the
|
||
rig, the deltas carry over to other nRF52840 + SX1262 boards.
|
||
|
||
## Summary: every option against stock firmware
|
||
|
||
"Stock" is upstream MeshCore with its defaults; "here" is this fork's public
|
||
release. Current is the paired delta of switching the option on (negative =
|
||
saves). Reception is what another board counted on the bench, or the live mesh
|
||
where it says so.
|
||
|
||
What it adds up to for your node (board, firmware, settings, traffic, battery,
|
||
panel): the [power calculator](power-calculator.md), which reads its numbers
|
||
from [`power-data.json`](power-data.json) -- update that file together with
|
||
this table.
|
||
|
||
| option | stock | here | current | reception / transmission | details |
|
||
|---|---|---|---|---|---|
|
||
| GPS `gps duty` (receiver powered only around a daily clock sync) | continuous (`gps on`) or `gps period` | `gps duty` on mast builds | **−42 to −45 mA** of 46 (P1-Pro) | no effect on the radio | [GPS](#gps-is-the-whole-game) |
|
||
| CC310 IRQ cleared before sleep | not needed: stock (no BLE) showed no insomnia, see the whole-node measurement | always (fix of our own BLE builds) | −3.3 mA at 3.3 V, −2.6 mA at 5 V, **against our earlier builds**, not against stock | none | [nRF52 fixes](#nrf52-sleep-and-peripheral-fixes) |
|
||
| `powersaving on` (MCU sleeps between events) | off | on (provisioning) | **−2.86 mA** on stock v1.19.0 (protocol below); −2.7 mA on ours; ~−1 mA with USB attached | no loss seen (5/6 witness, one pair); DIO1 wakes the core for every packet | [MCU sleep](#mcu-sleep) |
|
||
| RX duty cycle `set radio.rxps balanced` | not in upstream | built in, **off** | **−1.8 to −2.0 mA** | strong signal (SNR +11): 0 lost of 1200; **weak signal (SNR −2..−8): 13–28 % lost** against 0/450 without rxps, any sender preamble (4. 12. 2026, #46) | [rxps](#rx-duty-cycle-rxps) |
|
||
| RX duty cycle `set radio.rxps max` | not in upstream | built in, **off** | **−2.3 to −2.5 mA** | as `balanced` or worse; **live mast-three 14. 11.: −16 % received and a TX stall** (the stall is fixed, #46) | [rxps](#rx-duty-cycle-rxps) |
|
||
| tickless main loop (with `powersaving on`) | 1024 Hz tick | always | **−0.35 mA** | packets handled at once (DIO1 notifies the loop), 3/3 witness | [nRF52 fixes](#nrf52-sleep-and-peripheral-fixes) |
|
||
| SX1262 SPI on `NRF_SPIM2` (Errata 195) | `NRF_SPIM3` | always | **−0.47 mA** | none | [nRF52 fixes](#nrf52-sleep-and-peripheral-fixes) |
|
||
| `set radio.rxgain off` | on (boosted RX gain) | on | **−0.45 to −0.51 mA** | costs sensitivity (datasheet: ~1-3 dB); bench witness saw no gross loss, a strong bench signal cannot show the sensitivity | [nRF52 fixes](#nrf52-sleep-and-peripheral-fixes) |
|
||
| adaptive `set pwr.rxgain <mV>` / `set pwr.rxps <mV>` | not in upstream | built in, **off** | the two rows above, only while the battery is below the threshold | as the rows above, only then | [bootlock and cutoff](#a-mast-that-runs-flat-bootlock-and-cutoff) |
|
||
| BLE: LED off while connected/advertising, slow advertising 1 s | LED on, 152.5 ms | on mast builds | not measured separately | none (BLE only) | [BLE](#ble-two-defaults-that-were-quietly-expensive) |
|
||
| DC/DC regulator | on | on (re-enabled after SoftDevice, harmless) | switching it **off costs +0.6 mA** at 3.3 V | none | [nRF52 fixes](#nrf52-sleep-and-peripheral-fixes) |
|
||
| noise-floor calibration every 10 s instead of 2 s | 2 s | 2 s | ±0.08 mA (noise) | -- | [nRF52 fixes](#nrf52-sleep-and-peripheral-fixes) |
|
||
| idle I2C (`Wire.end()`), GPIOTE channel for DIO1 | -- | -- | ±0.00 mA | -- | [nRF52 fixes](#nrf52-sleep-and-peripheral-fixes) |
|
||
| `ble off` | on | on (a mast needs the way in) | ~1 mA of ~24 on the P1-Pro | -- | [BLE](#ble-two-defaults-that-were-quietly-expensive) |
|
||
|
||
**Whole node, measured against stock** ([protocol](measurements/2026-12-04-stock-vs-tth/protocol.md),
|
||
4. 12. 2026, XIAO on its 3V3 pin, two independent INA226 meters, the same
|
||
board and settings for both images):
|
||
|
||
| image | current (k = 2) |
|
||
|---|---|
|
||
| this fork's public repeater (`powersaving on`, as provisioned) | **(6.87 ± 0.08) mA** |
|
||
| upstream v1.19.0 with `powersaving on` set by hand | (7.27 ± 0.09) mA, +(0.40 ± 0.01) mA |
|
||
| **upstream v1.19.0 as shipped** (`powersaving off`) | **(10.13 ± 0.12) mA**, +(3.26 ± 0.04) mA |
|
||
|
||
The fork draws 32 % less than stock as shipped; 2.86 mA of that is
|
||
`powersaving`, the code changes save the remaining 0.40 mA. The per-option
|
||
deltas of the other rows were measured against our own builds and do not add up
|
||
to this (the CC310 one does not apply to stock at all); a re-measurement of every
|
||
row against this protocol's rig is planned. A P1-Pro in the mast configuration
|
||
(GPS duty, BLE on, charged cell) sits at **~24 mA**; continuous GPS alone would
|
||
nearly triple that.
|
||
|
||
**rxps costs reception.** On a strong signal the bench never lost a packet to
|
||
it, which is why it looked free (12. 11.: 0/240). On a weak one it does: with x4
|
||
receiving without antenna (RSSI −120..−126, SNR −2..−8, everyday traffic for a
|
||
mast) `balanced` lost 13–28 % against 0 of 450 without rxps, with 16- and
|
||
32-symbol senders alike, plus `recv_errors` from packets caught too late (#46,
|
||
4. 12. 2026). It explains mast-three's −16 % of 14. 11. and its lost admin replies
|
||
on 4. 12.; mast-three runs rxps **off** again since then. Use it only on a node
|
||
whose packets arrive strong (a short hop, a desk), never on a mast.
|
||
|
||
## 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.
|
||
|
||
Three state-machine bugs in the RXPS wrapper were subsequently fixed (#46):
|
||
`set radio.rxps off` no longer waits on a latched `isReceiving()` / `irq=0x0014`
|
||
and tears down duty cycling immediately; non-`RX_DONE` DIO1 events (`TIMEOUT` /
|
||
`HEADER_ERR`) clear latched IRQ flags and reset `CustomSX1262` receive state
|
||
before re-arming (preventing a concurrent noise-floor calibration window from
|
||
leaving the chip in `STBY_RC`); and `stopReceiveDutyCycle()` / `kickRx()` clear
|
||
both the IRQ latch and the stateful receiver latch (while keeping IRQ flags
|
||
intact across `readData()` on valid `RX_DONE` so `CRC_ERR` is still detected).
|
||
The TX stall watchdog log also records `err_flags`, `tx_budget_ms` and
|
||
`next_tx_ms` in case the 6-hour stall recurs. Until a soak test on the live mesh
|
||
confirms stability (prefer `balanced` over `max` for SNR margin), keep rxps off
|
||
on nodes that must 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.
|
||
|
||
### CPU time per received packet (`PWR_DUTY_INSTRUMENT`)
|
||
|
||
A bench build with `-D PWR_DUTY_INSTRUMENT` (nRF52 only, nothing changes
|
||
without the flag) prints one line to the USB console every ~10 s:
|
||
|
||
```
|
||
PWRDUTY awake_ms=… asleep_ms=… wakes=… duty_permille=… pkt_us=… pkt_n=…
|
||
```
|
||
|
||
- `awake_ms`, `asleep_ms` and `duty_permille` are the time between a return
|
||
from `NRF52Board::sleep()` and the next entry into it, against the WFE span
|
||
inside it. This needs `powersaving on`: without it `sleep()` is never called.
|
||
- `wakes` counts the passes through `sleep()`. BLE and USB events wake the
|
||
core too, so the duty is not packet cost alone.
|
||
- `pkt_us` and `pkt_n` are the CPU time spent in
|
||
`Dispatcher::processRecvPacket()` (dedup, crypto, routing) and the number of
|
||
packets. They do not depend on background wakes. This is the work a filter
|
||
on the radio side could skip for a packet that is dropped anyway.
|
||
|
||
All counters are cumulative since boot, so take the difference between two
|
||
lines.
|
||
|
||
Measured on the XIAO x4, 24. 11. 2026, live mesh, about 440 packets/h (all
|
||
flood adverts): about **6.8 ms CPU per received packet**, mostly the Ed25519
|
||
check of the advert signature. The duty went from 0.05 % at rest to 0.13 %.
|
||
The awake time is a small part of a node's current; the radio's RX and the
|
||
SoftDevice dominate.
|
||
|
||
## 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:
|
||
|
||
| command | default | what |
|
||
|---|---|---|
|
||
| `set pwr.bootlock <mV>` | 3300 mV (`variant.h`) | 3000..4200 or `off`; at boot, below it the node goes to SYSTEMOFF and the LPCOMP wakes it when the battery recovers |
|
||
| `set pwr.cutoff <mV>` | off | 3000..4200 or `off`; while running, three readings in a row (one a minute) below it switch the node off into the same SYSTEMOFF |
|
||
| `set pwr.rxgain <lo> [hi]\|off` | off | all boards: below `lo` mV (3 readings, 1/min) disables RX boosted gain (−0.48 mA); at `hi` mV (default `lo + 150`, min gap 50 mV) restores user's `radio.rxgain` |
|
||
| `set pwr.rxps <lo> [hi]\|off` | off | all boards with `WITH_RX_POWERSAVING`: below `lo` mV enables RXPS `balanced` (−1.9 mA); at `hi` mV restores continuous RX (ignored if `radio.rxps` is enabled manually) |
|
||
| `get pwr` | | thresholds, adaptive save state, battery now (and on `PWRMGT_RUNTIME`: bootlock, cutoff, boot voltage, last off) |
|
||
|
||
Adaptive power-saving thresholds live in `/pwr_save` (separate from `/pwr_guard`
|
||
and prefs) and never overwrite the user's `radio.rxgain` or `radio.rxps` prefs
|
||
(`get radio.rxgain` reports `> on (effective: off)` while throttled, and
|
||
`get radio.rxps` shows `effective=armed`). Readings under 2500 mV (ADC glitch or
|
||
a bench board powered on 3V3 with no cell, ~120–150 mV on XIAO) are ignored, and
|
||
USB power immediately releases both stages. For bench testing without a supply on
|
||
BAT pads, builds with `-D BENCH_BATT_OVERRIDE` expose local-only
|
||
`bench batt <mV|off|poll>`. Host tests: `test/test_battery_power_save`.
|
||
|
||
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 and 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.
|
||
|
||
**The same run again at 3.3 V without VBUS (27. 11. 2026).** Here x4 is fed on
|
||
its 3V3 pin at 3.25 V, so `bench duty` reads `vbus 0 usbd 0` and HFXO is
|
||
off. This is the closer match to a node on a cell. The setup was the same:
|
||
38 cells, two rounds, all of them valid. Baseline repeatability (detrended SD of
|
||
the base cells) was **0.009 / 0.015 mA**, so the threshold here is 0.03 mA.
|
||
The baseline is **6.90 mA** (22 mW, against 57 mW on the 5 V pin).
|
||
|
||
| boot with | before first BLE connection | after it |
|
||
|---|---|---|
|
||
| both fixes | 6.91 / 6.92 mA | 6.89 / 6.88 mA |
|
||
| no CC clear | **10.16 / 10.16 mA** | 6.91 / 6.89 mA |
|
||
| no CC clear, no late DC/DC (= old main) | **10.18 / 10.18 mA** | 6.89 / 6.94 mA |
|
||
| no late DC/DC | 6.90 / 6.91 mA | 6.93 / 6.92 mA |
|
||
|
||
The CC310 insomnia costs **+3.3 mA, almost half of the whole node**. Every
|
||
sample of those windows sits above 8.5 mA. The core wakes 14 900 times a
|
||
second, against 986, it is awake 79 % of the time, and `cc_pend` reads 1.
|
||
|
||
At this voltage **DC/DC is worth 0.6 mA**. `bench dcdc off` at runtime gives
|
||
+0.63 / +0.60 mA, and `A_like` (DC/DC off, CC clear off, nfcal 2 s) gives
|
||
+0.59 / +0.61 mA, the same thing. On the 5 V pin the same switch was below
|
||
resolution. The late re-enable still changes nothing, because `DCDCEN` reads 1
|
||
after every boot with or without it. So the regulator mode matters, and
|
||
SoftDevice simply does not turn it off.
|
||
|
||
| knob (3.3 V) | round 1 | round 2 |
|
||
|---|---|---|
|
||
| `bench dcdc off` | +0.63 mA | +0.60 mA |
|
||
| `bench cc off` (runtime) | +0.00 mA | −0.01 mA |
|
||
| `bench nfcal 2000` | −0.04 mA (one pair) | |
|
||
| `set radio.rxps max` | −2.30 mA | −2.30 mA |
|
||
| `set radio.rxps balanced` | −1.98 mA | −1.82 mA |
|
||
| `set radio.rxgain off` | −0.45 mA | −0.51 mA |
|
||
| `powersaving off` | +2.37 mA (one pair) | |
|
||
|
||
The rxps, rxgain and powersaving deltas match the 5 V run to within 0.3 mA.
|
||
In relative terms, rxps max now takes a third off the node. Reception from the
|
||
x1 witness matched what it sent in every cell (base 82 received for 72 sent;
|
||
x4 also hears other bench traffic). The witness again only detects a gross
|
||
loss, not a sensitivity loss.
|
||
|
||
**Two compile-time candidates, A/B/A/C/A at 3.3 V (3. 12. 2026).** Same rig
|
||
(x4 on its 3V3 pin at 3.25 V through the budka INA226, no USB), but the public
|
||
`Xiao_nrf52_repeater` env with `FW_OTA=1`, a BLE console and the bench preset,
|
||
and a BMP388 + INA226 asleep on the I2C bus. The five images were swapped with
|
||
OTA deltas over the BLE console (`ota_pack.py diff` + `ota_push.py --apply`,
|
||
~1.5 min each, the BLE link dropped before each cell), so nothing was
|
||
replugged. Cells of 10 min after 60 s of settling. The three baseline cells
|
||
read **7.06 / 7.07 / 7.06 mA** (fit), so the threshold is again ~0.03 mA.
|
||
|
||
| image | cell | vs. the surrounding baselines |
|
||
|---|---|---|
|
||
| `SPI_32MHZ_INTERFACE=0` (SX1262 back on `NRF_SPIM3`) | 7.53 mA | **+0.47 mA** |
|
||
| DIO1 interrupt detached (no GPIOTE IN channel at all) | 7.06 mA | **±0.00 mA** |
|
||
|
||
The SPIM2 move (`[nrf52_base]`, Errata 195) is thus worth 0.47 mA, less than
|
||
the 1.2–2 mA the errata suggests but well above resolution. Leaving the GPIOTE
|
||
IN channel for DIO1 costs nothing measurable: the C image is an upper bound
|
||
for any GPIOTE PORT rewrite (it removes the channel completely, so it would
|
||
also miss every packet), and it reads the same as the baseline. That rewrite
|
||
is therefore not worth doing.
|
||
|
||
**Two more, same rig and method (3. 12. 2026 evening):** baselines 7.08 / 7.08
|
||
/ 7.06 mA.
|
||
|
||
| image | cell | vs. the surrounding baselines |
|
||
|---|---|---|
|
||
| I2C bus ended at boot despite the sensors on it (`Wire.end()`, sensors dropped from the list) | 7.08 mA | **±0.00 mA** |
|
||
| FreeRTOS tick 100 Hz instead of 1024 Hz (`configTICK_RATE_HZ`) | 6.73 mA | **−0.34 mA** |
|
||
|
||
An idle TWIM costs nothing measurable, so `Wire.end()` on an empty bus is kept
|
||
only because it is harmless. The tick is worth about 0.34 mA (5 % of this node):
|
||
ten times fewer wake-ups. That is close to the ceiling of a tickless `loop()`
|
||
(issue tth #20), which would remove the remaining ~100 wakes a second too.
|
||
|
||
**Tickless loop, implemented (3. 12. 2026).** `NRF52Board::sleep()` now blocks
|
||
the loop task on a FreeRTOS task notification (at most 50 ms,
|
||
`NRF52_TICKLESS_MAX_MS`; 0 = the old `sd_app_evt_wait()`), so the idle task
|
||
runs and `configUSE_TICKLESS_IDLE` suppresses the tick; the DIO1 interrupt
|
||
gives the notification, so a received packet is handled at once, and a queued
|
||
TX keeps the loop awake (`hasPendingWork()`). Same rig, A/T/A/T/A, both images
|
||
from one tree: A 7.06 / 7.10 / 7.10 mA, T **6.73 / 6.74 mA**, i.e. **−0.35 mA**,
|
||
the whole ceiling of the 100 Hz test. Reception checked with x1 as the
|
||
sender (3 of 3 zero-hop adverts). Only nodes with `powersaving on` sleep at all.
|
||
A first try of this image hung: it ended the bus while sensors were still
|
||
listed, and the local framework (symlink, without the Wire timeout of PR #873)
|
||
waits forever on a disabled TWIM. A main loop that hangs still answers buttonless
|
||
BLE DFU, which brought x4 back without touching it.
|
||
|
||
**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 on the 5 V pin, and no difference as a boot flag
|
||
at either voltage. 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. DC/DC itself
|
||
does matter at 3.3 V (see above).
|
||
- **Noise-floor calibration every 10 s instead of 2 s**
|
||
(`NOISE_FLOOR_CALIB_INTERVAL`): +0.08 mA at 5 V and −0.04 mA at 3.3 V, one
|
||
pair each. That is at the edge of resolution and of no practical weight.
|
||
|
||
**Not measured** (compile-time or other hardware):
|
||
- **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.
|
||
- **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. It saves ~2.8 µA (4.2 V over 1.5 MOhm). With the old 10 ms settle the
|
||
reading came out 110-150 mV high (mast-three and second-mast after the OTA of
|
||
26.-27. 11. 2026, both at night, remote-mast without the change flat): the ADC
|
||
node starts high with the divider off. The settle is 100 ms now; still to be
|
||
checked against a meter, and whether the ADC pin sits near VDD + 0.3 V on a
|
||
full cell.
|
||
|
||
**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.
|