From b5ae48e2e48d8f0318b4626407f5f1ebf60e43ee Mon Sep 17 00:00:00 2001 From: TeTeHacko Date: Tue, 24 Nov 2026 19:38:41 +0100 Subject: [PATCH 1/6] Repeater, room server, sensor, companion: fix nRF52 sleep wake-up loop and keep DC/DC enabled after BLE init --- docs/power.md | 15 +++++++++++++++ src/helpers/NRF52Board.cpp | 28 ++++++++++++++++++++++++---- src/helpers/NRF52Board.h | 1 + 3 files changed, 40 insertions(+), 4 deletions(-) diff --git a/docs/power.md b/docs/power.md index 53221290..f0773f99 100644 --- a/docs/power.md +++ b/docs/power.md @@ -218,6 +218,21 @@ 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 (bench verification pending) + +Audit of the nRF52840 firmware and Adafruit core identified several sources of +unnecessary idle draw that affect all nRF52 boards (not only SenseCAP Solar): + +- **`CRYPTOCELL_IRQn` sleep insomnia**: `USE_CC310_HW_CRYPTO=1` runs CC310 in + polling mode with `CRYPTOCELL_IRQn` disabled in NVIC; completed operations + leave it pending and immediately wake `sd_app_evt_wait()`/`__WFE()`. + `NRF52Board::sleep()` now clears `CRYPTOCELL_IRQn` before sleeping, matching + Adafruit core's `wiring.c`. +- **DC/DC regulator after SoftDevice start**: `NRF52BoardDCDC::begin()` runs + before `Bluefruit.begin()`, which enables SoftDevice S140 (defaulting + `NRF_POWER` to LDO). `NRF52BoardDCDC::onBootComplete()` now re-enables DC/DC + via `sd_power_dcdc_mode_set(NRF_POWER_DCDC_ENABLE)` once SoftDevice is active. + ## Measuring this yourself — two traps 1. **A solar node measured on its USB side measures the CHARGER.** With a diff --git a/src/helpers/NRF52Board.cpp b/src/helpers/NRF52Board.cpp index 618364c3..2268ec6d 100644 --- a/src/helpers/NRF52Board.cpp +++ b/src/helpers/NRF52Board.cpp @@ -288,10 +288,7 @@ void NRF52Board::pwrmgtWakeArmVbus() { } #endif -void NRF52BoardDCDC::begin() { - NRF52Board::begin(); - - // Enable DC/DC converter for improved power efficiency +static void enableNrf52Dcdc() { uint8_t sd_enabled = 0; sd_softdevice_is_enabled(&sd_enabled); if (sd_enabled) { @@ -301,6 +298,21 @@ void NRF52BoardDCDC::begin() { } } +void NRF52BoardDCDC::begin() { + NRF52Board::begin(); + + // Enable DC/DC converter for improved power efficiency + enableNrf52Dcdc(); +} + +void NRF52BoardDCDC::onBootComplete() { + NRF52Board::onBootComplete(); + + // SoftDevice (Bluefruit.begin()) starts after board.begin() and defaults + // NRF_POWER to LDO mode; re-enable DC/DC once SoftDevice owns NRF_POWER. + enableNrf52Dcdc(); +} + bool NRF52Board::isExternalPowered() { // Check if SoftDevice is enabled before using its API uint8_t sd_enabled = 0; @@ -324,6 +336,14 @@ void NRF52Board::sleep(uint32_t secs) { NVIC_ClearPendingIRQ(FPU_IRQn); #endif + // Clear pending CRYPTOCELL interrupt to avoid WFE/sd_app_evt_wait() insomnia. + // Adafruit_nRFCrypto polls CC310 with CRYPTOCELL_IRQn disabled in NVIC, so + // completed crypto/TRNG calls leave it pending (same workaround as Adafruit + // core wiring.c / port_cmsis_systick.c). + #ifdef NRF_CRYPTOCELL + NVIC_ClearPendingIRQ(CRYPTOCELL_IRQn); + #endif + // On nRF52, we use event-driven sleep instead of timed sleep // The 'secs' parameter is ignored - we wake on any interrupt uint8_t sd_enabled = 0; diff --git a/src/helpers/NRF52Board.h b/src/helpers/NRF52Board.h index c7644334..7c40d441 100644 --- a/src/helpers/NRF52Board.h +++ b/src/helpers/NRF52Board.h @@ -93,5 +93,6 @@ class NRF52BoardDCDC : virtual public NRF52Board { public: NRF52BoardDCDC() {} virtual void begin() override; + virtual void onBootComplete() override; }; #endif \ No newline at end of file From 2593015f4ac243470142ac9c3335ec29d2bf30ff Mon Sep 17 00:00:00 2001 From: TeTeHacko Date: Tue, 24 Nov 2026 19:43:09 +0100 Subject: [PATCH 2/6] Repeater, room server, sensor, companion: avoid nRF52840 SPIM3 Errata 195 idle current draw --- docs/power.md | 5 +++++ platformio.ini | 1 + 2 files changed, 6 insertions(+) diff --git a/docs/power.md b/docs/power.md index f0773f99..ea4da908 100644 --- a/docs/power.md +++ b/docs/power.md @@ -232,6 +232,11 @@ unnecessary idle draw that affect all nRF52 boards (not only SenseCAP Solar): before `Bluefruit.begin()`, which enables SoftDevice S140 (defaulting `NRF_POWER` to LDO). `NRF52BoardDCDC::onBootComplete()` now re-enables DC/DC via `sd_power_dcdc_mode_set(NRF_POWER_DCDC_ENABLE)` once SoftDevice is active. +- **Avoid `NRF_SPIM3` (Nordic Errata 195)**: `[nrf52_base]` now sets + `-D SPI_32MHZ_INTERFACE=1`, moving the primary `SPI` bus (used by SX1262 at + 2 MHz) from `NRF_SPIM3` to `NRF_SPIM2`. Adafruit `SPIClass::endTransaction()` + disables `SPIM3` without the Errata 195 workaround, leaving ~1.2-2 mA idle + draw after the first SPI transaction. ## Measuring this yourself — two traps diff --git a/platformio.ini b/platformio.ini index af3f8c2a..a779587d 100644 --- a/platformio.ini +++ b/platformio.ini @@ -142,6 +142,7 @@ build_flags = ${arduino_base.build_flags} -D EXTRAFS=1 -D FW_OTA_PUBKEY='"${ota.pubkey}"' -D USE_CC310_HW_CRYPTO=1 + -D SPI_32MHZ_INTERFACE=1 lib_deps = ${arduino_base.lib_deps} https://github.com/oltaco/CustomLFS#0.2.3 From a5bdc6db81d35b636c463ca8961f5c77c5a40c14 Mon Sep 17 00:00:00 2001 From: TeTeHacko Date: Tue, 24 Nov 2026 19:44:05 +0100 Subject: [PATCH 3/6] Repeater, room server, sensor, companion: disconnect GPS UART pins when GPS is powered off on nRF52 --- docs/power.md | 3 +++ src/helpers/sensors/NmeaGpsDriver.h | 8 +++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/docs/power.md b/docs/power.md index ea4da908..2cc5bf4f 100644 --- a/docs/power.md +++ b/docs/power.md @@ -237,6 +237,9 @@ unnecessary idle draw that affect all nRF52 boards (not only SenseCAP Solar): 2 MHz) from `NRF_SPIM3` to `NRF_SPIM2`. Adafruit `SPIClass::endTransaction()` disables `SPIM3` without the Errata 195 workaround, leaving ~1.2-2 mA idle draw after the first SPI transaction. +- **Disconnect GPS UART pins while GPS is off**: `NmeaGpsDriver::stopHardware()` + now resets the UART TX/RX pins via `nrf_gpio_cfg_default()` after `Uart::end()`, + preventing back-powering of the unpowered GPS receiver through GPIO/ESD paths. ## Measuring this yourself — two traps diff --git a/src/helpers/sensors/NmeaGpsDriver.h b/src/helpers/sensors/NmeaGpsDriver.h index baafc571..29da7fd5 100644 --- a/src/helpers/sensors/NmeaGpsDriver.h +++ b/src/helpers/sensors/NmeaGpsDriver.h @@ -204,7 +204,13 @@ class NmeaGpsDriver : public GpsDriver { // core's own Uart::end()) for all the hours `gps duty` keeps the GPS off, and // its idle-high TX line feeds the unpowered module. sendNmeaSentence() is // gated on _started: a write to a closed Uart takes a deleted semaphore. - if (_hardwareSerial != nullptr) _hardwareSerial->end(); + // Uart::end() clears PSEL but leaves GPIO PIN_CNF unchanged, so disconnect + // the pins explicitly to avoid back-powering the unpowered GPS module. + if (_hardwareSerial != nullptr) { + _hardwareSerial->end(); + if (_txPin != -1) nrf_gpio_cfg_default(g_ADigitalPinMap[_txPin]); + if (_rxPin != -1) nrf_gpio_cfg_default(g_ADigitalPinMap[_rxPin]); + } #endif _started = false; } From 76bf7afa1128129e9670d291430b05dbfe9a3591 Mon Sep 17 00:00:00 2001 From: TeTeHacko Date: Tue, 24 Nov 2026 19:47:03 +0100 Subject: [PATCH 4/6] Repeater, room server, sensor, companion: disable unused I2C on nRF52 and calibrate noise floor every 10 s --- docs/power.md | 5 +++ src/Dispatcher.cpp | 2 +- .../sensors/EnvironmentSensorManager.cpp | 32 +++++++++++++++++++ 3 files changed, 38 insertions(+), 1 deletion(-) diff --git a/docs/power.md b/docs/power.md index 2cc5bf4f..55990636 100644 --- a/docs/power.md +++ b/docs/power.md @@ -240,6 +240,11 @@ unnecessary idle draw that affect all nRF52 boards (not only SenseCAP Solar): - **Disconnect GPS UART pins while GPS is off**: `NmeaGpsDriver::stopHardware()` now resets the UART TX/RX pins via `nrf_gpio_cfg_default()` after `Uart::end()`, preventing back-powering of the unpowered GPS receiver through GPIO/ESD paths. +- **Disable unused I2C bus & lower noise-floor calibration rate**: on nRF52, + `EnvironmentSensorManager::begin()` calls `Wire.end()` when the I2C bus scan + finds zero devices (re-enabling temporarily for the `i2c` CLI command). + `NOISE_FLOOR_CALIB_INTERVAL` is raised from 2 s to 10 s to cut idle SPI + wake-ups 5x. ## Measuring this yourself — two traps diff --git a/src/Dispatcher.cpp b/src/Dispatcher.cpp index b3270d6a..14ad28d9 100644 --- a/src/Dispatcher.cpp +++ b/src/Dispatcher.cpp @@ -13,7 +13,7 @@ namespace mesh { #define MIN_TX_BUDGET_AIRTIME_DIV 2 // require at least 1/N of estimated airtime as budget before TX #ifndef NOISE_FLOOR_CALIB_INTERVAL - #define NOISE_FLOOR_CALIB_INTERVAL 2000 // 2 seconds + #define NOISE_FLOOR_CALIB_INTERVAL 10000 // 10 seconds #endif void Dispatcher::begin() { diff --git a/src/helpers/sensors/EnvironmentSensorManager.cpp b/src/helpers/sensors/EnvironmentSensorManager.cpp index 8d8b8dbe..950328e6 100644 --- a/src/helpers/sensors/EnvironmentSensorManager.cpp +++ b/src/helpers/sensors/EnvironmentSensorManager.cpp @@ -8,6 +8,10 @@ #define TELEM_WIRE &Wire // Use default I2C bus for Environment Sensors #endif +#ifdef NRF52_PLATFORM +static bool telem_wire_stopped = false; +#endif + // ============================================================ // Sensor library includes and static driver instances // ============================================================ @@ -715,6 +719,11 @@ bool EnvironmentSensorManager::begin() { bool detected[128] = {}; scanI2CBus(TELEM_WIRE, detected); + bool any_i2c_device = false; + for (uint8_t addr = 0x08; addr < 0x78; addr++) { + if (detected[addr]) { any_i2c_device = true; break; } + } + // Walk the sensor table and initialize only detected devices. _active_sensor_count = 0; for (size_t i = 0; i < SENSOR_TABLE_SIZE && _active_sensor_count < MAX_ACTIVE_SENSORS; i++) { @@ -741,6 +750,15 @@ bool EnvironmentSensorManager::begin() { } } +#ifdef NRF52_PLATFORM + if (!any_i2c_device) { + // No device ACKed anywhere on the bus (neither sensor nor RTC/display): + // disable TWIM to avoid idle peripheral/pull-up draw. + (TELEM_WIRE)->end(); + telem_wire_stopped = true; + } +#endif + return true; } @@ -765,6 +783,13 @@ static size_t appendWhole(char* dest, size_t used, size_t max_len, const char* s } int EnvironmentSensorManager::scanI2C(char* dest, size_t max_len) { +#ifdef NRF52_PLATFORM + bool restarted = telem_wire_stopped; + if (restarted) { + (TELEM_WIRE)->begin(); + telem_wire_stopped = false; + } +#endif bool found[128] = {}; scanI2CBus(TELEM_WIRE, found); @@ -790,6 +815,13 @@ int EnvironmentSensorManager::scanI2C(char* dest, size_t max_len) { n++; } +#ifdef NRF52_PLATFORM + if (restarted && n == 0) { + (TELEM_WIRE)->end(); + telem_wire_stopped = true; + } +#endif + if (n == 0) { used = appendWhole(dest, 0, max_len, "no I2C device answered"); } From 5c73a3b582537eb11db37fbe4e36740205908d7c Mon Sep 17 00:00:00 2001 From: TeTeHacko Date: Tue, 24 Nov 2026 19:55:11 +0100 Subject: [PATCH 5/6] Repeater, room server, companion: turn off SenseCAP Solar battery divider after reading voltage --- docs/power.md | 4 ++++ variants/sensecap_solar/SenseCapSolarBoard.cpp | 3 +-- variants/sensecap_solar/SenseCapSolarBoard.h | 1 + 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/docs/power.md b/docs/power.md index 55990636..33ba20d3 100644 --- a/docs/power.md +++ b/docs/power.md @@ -245,6 +245,10 @@ unnecessary idle draw that affect all nRF52 boards (not only SenseCAP Solar): finds zero devices (re-enabling temporarily for the `i2c` CLI command). `NOISE_FLOOR_CALIB_INTERVAL` is raised from 2 s to 10 s to cut idle SPI wake-ups 5x. +- **SenseCAP Solar battery divider (`VBAT_ENABLE`)**: held `HIGH` (off) at boot + and restored to `HIGH` immediately after `getBattMilliVolts()` instead of + staying continuously `LOW`. (`initiateShutdown()` still drives it `LOW` when + arming LPCOMP wake.) ## Measuring this yourself — two traps diff --git a/variants/sensecap_solar/SenseCapSolarBoard.cpp b/variants/sensecap_solar/SenseCapSolarBoard.cpp index 7414feb0..901b31af 100644 --- a/variants/sensecap_solar/SenseCapSolarBoard.cpp +++ b/variants/sensecap_solar/SenseCapSolarBoard.cpp @@ -31,10 +31,9 @@ void SenseCapSolarBoard::begin() { pinMode(BATTERY_PIN, INPUT); pinMode(VBAT_ENABLE, OUTPUT); - digitalWrite(VBAT_ENABLE, LOW); + digitalWrite(VBAT_ENABLE, HIGH); analogReadResolution(12); analogReference(AR_INTERNAL_3_0); - delay(50); #ifdef PIN_USER_BTN pinMode(PIN_USER_BTN, INPUT_PULLUP); diff --git a/variants/sensecap_solar/SenseCapSolarBoard.h b/variants/sensecap_solar/SenseCapSolarBoard.h index 1997d3b7..856349de 100644 --- a/variants/sensecap_solar/SenseCapSolarBoard.h +++ b/variants/sensecap_solar/SenseCapSolarBoard.h @@ -59,6 +59,7 @@ public: analogReference(AR_INTERNAL_3_0); delay(10); adcvalue = analogRead(BATTERY_PIN); + digitalWrite(VBAT_ENABLE, HIGH); return (adcvalue * ADC_MULTIPLIER * AREF_VOLTAGE) / 4.096; } From 137b9a9f05fcfe959958dc2ae9963caf2ab60d05 Mon Sep 17 00:00:00 2001 From: TeTeHacko Date: Thu, 26 Nov 2026 11:35:35 +0100 Subject: [PATCH 6/6] =?UTF-8?q?Docs:=20nRF52=20sleep=20fixes=20measured=20?= =?UTF-8?q?=E2=80=94=20CC310=20IRQ=20is=20the=202.6=20mA=20one,=20DC/DC=20?= =?UTF-8?q?and=20nfcal=20below=20resolution?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Changelog: - Co-Authored-By: Claude Opus 5.5 --- docs/power.md | 110 +++++++++++++++++++++++++++---------- src/helpers/NRF52Board.cpp | 5 +- 2 files changed, 84 insertions(+), 31 deletions(-) diff --git a/docs/power.md b/docs/power.md index 33ba20d3..0994352c 100644 --- a/docs/power.md +++ b/docs/power.md @@ -12,7 +12,8 @@ figures are. |---|---|---| | **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, not separable from zero** | keep it on (free), but it is not a lever | +| `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 | @@ -218,37 +219,88 @@ 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 (bench verification pending) +## nRF52 sleep & peripheral fixes -Audit of the nRF52840 firmware and Adafruit core identified several sources of -unnecessary idle draw that affect all nRF52 boards (not only SenseCAP Solar): +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. -- **`CRYPTOCELL_IRQn` sleep insomnia**: `USE_CC310_HW_CRYPTO=1` runs CC310 in - polling mode with `CRYPTOCELL_IRQn` disabled in NVIC; completed operations - leave it pending and immediately wake `sd_app_evt_wait()`/`__WFE()`. - `NRF52Board::sleep()` now clears `CRYPTOCELL_IRQn` before sleeping, matching - Adafruit core's `wiring.c`. -- **DC/DC regulator after SoftDevice start**: `NRF52BoardDCDC::begin()` runs - before `Bluefruit.begin()`, which enables SoftDevice S140 (defaulting - `NRF_POWER` to LDO). `NRF52BoardDCDC::onBootComplete()` now re-enables DC/DC - via `sd_power_dcdc_mode_set(NRF_POWER_DCDC_ENABLE)` once SoftDevice is active. -- **Avoid `NRF_SPIM3` (Nordic Errata 195)**: `[nrf52_base]` now sets - `-D SPI_32MHZ_INTERFACE=1`, moving the primary `SPI` bus (used by SX1262 at - 2 MHz) from `NRF_SPIM3` to `NRF_SPIM2`. Adafruit `SPIClass::endTransaction()` - disables `SPIM3` without the Errata 195 workaround, leaving ~1.2-2 mA idle - draw after the first SPI transaction. -- **Disconnect GPS UART pins while GPS is off**: `NmeaGpsDriver::stopHardware()` - now resets the UART TX/RX pins via `nrf_gpio_cfg_default()` after `Uart::end()`, - preventing back-powering of the unpowered GPS receiver through GPIO/ESD paths. -- **Disable unused I2C bus & lower noise-floor calibration rate**: on nRF52, - `EnvironmentSensorManager::begin()` calls `Wire.end()` when the I2C bus scan - finds zero devices (re-enabling temporarily for the `i2c` CLI command). - `NOISE_FLOOR_CALIB_INTERVAL` is raised from 2 s to 10 s to cut idle SPI - wake-ups 5x. +**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 restored to `HIGH` immediately after `getBattMilliVolts()` instead of - staying continuously `LOW`. (`initiateShutdown()` still drives it `LOW` when - arming LPCOMP wake.) + 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 ` (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 diff --git a/src/helpers/NRF52Board.cpp b/src/helpers/NRF52Board.cpp index 2268ec6d..bc817d67 100644 --- a/src/helpers/NRF52Board.cpp +++ b/src/helpers/NRF52Board.cpp @@ -308,8 +308,9 @@ void NRF52BoardDCDC::begin() { void NRF52BoardDCDC::onBootComplete() { NRF52Board::onBootComplete(); - // SoftDevice (Bluefruit.begin()) starts after board.begin() and defaults - // NRF_POWER to LDO mode; re-enable DC/DC once SoftDevice owns NRF_POWER. + // SoftDevice (Bluefruit.begin()) starts after board.begin(). On XIAO x4 + // (11/2026) DCDCEN read 1 after boot with or without this call, so it is a + // safeguard in case a SoftDevice/board combination resets NRF_POWER to LDO. enableNrf52Dcdc(); }