Docs: measurement protocol, stock v1.19.0 against our repeater on one XIAO

Changelog: -
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
tthandClaude Opus 5.5 committed 2026-12-04 15:16:28 +01:00
1 parent e86d74338d
commit 9cd055b448
4 files changed
+278

No files matched your search

@@ -0,0 +1,113 @@
#!/usr/bin/env python3
"""Recompute the stock-vs-tth current measurement of 4. 12. 2026 from ina_fast.tsv.gz.
python3 compute.py # prints the tables of protocol.md
Every number in protocol.md comes out of this script; nothing is typed in by hand.
Model per meter: I = sum(isum_raw) * 2.5 uV / (sum(n) * R_shunt) - I0
I0 = zero (DUT disconnected, same bus voltage ~3.27 V), mean of the two zero windows
Uncertainty (GUM): type A = SEM of 1-minute block means; repeatability = |A1 - A2| / sqrt(2)
(applied to every cell); type B = shunt tolerance 1 % and INA226 gain error 0.1 %
(rectangular, /sqrt(3), proportional to the current), residual offset = half the difference
of the two zeros (rectangular). Expanded U = 2 u_c (k = 2, ~95 %).
"""
import gzip
import math
import statistics
from pathlib import Path
LSB_UV = 2.5
SHUNT_TOL = 0.01 # assumed: LaskaKit module, tolerance not stated -- 1 % is the usual part
GAIN_ERR = 0.001 # INA226 datasheet, gain error max 0.1 %
SETTLE = 120 # s dropped after power-on
CELL = 600 # s measured after that
ZEROS = {"Z1": (1796389154 - 480, 1796389154 - 10), "Z2": (1796393425, 1796393633)}
CELLS = { # power-on (first window with current) of each cell
"A1": 1796389154, # tth public image, powersaving on
"S2": 1796390528, # stock v1.19.0, powersaving on
"S1": 1796391376, # stock v1.19.0, powersaving off (upstream default)
"A2": 1796392588, # tth again
}
METERS = ("cb-fbfe18", "cb-4faa24")
rows = []
with gzip.open(Path(__file__).with_name("ina_fast.tsv.gz"), "rt") as f:
for ln in f:
if ln.startswith("#"):
continue
ts, meter, n, isum, sh, v = ln.split("\t")
rows.append((float(ts), meter, int(n), int(isum), int(sh), float(v)))
def window(meter, t0, t1):
return [r for r in rows if r[1] == meter and t0 <= r[0] <= t1]
def current(sel):
return sum(r[3] for r in sel) * LSB_UV / (sum(r[2] for r in sel) * sel[0][4]) # mA
def block_sem(sel):
blocks = {}
for r in sel:
blocks.setdefault(int(r[0] // 60), []).append(r)
means = [current(b) for b in blocks.values() if len(b) > 20]
return statistics.stdev(means) / math.sqrt(len(means)), len(means)
res = {}
for m in METERS:
z = {k: current(window(m, *t)) for k, t in ZEROS.items()}
i0 = (z["Z1"] + z["Z2"]) / 2
u_off = abs(z["Z1"] - z["Z2"]) / 2 / math.sqrt(3)
cells = {}
for c, t in CELLS.items():
sel = window(m, t + SETTLE, t + SETTLE + CELL)
sem, nb = block_sem(sel)
cells[c] = {"I": current(sel) - i0, "semA": sem, "blocks": nb, "V": statistics.mean(r[5] for r in sel),
"samples": sum(r[2] for r in sel)}
u_rep = abs(cells["A1"]["I"] - cells["A2"]["I"]) / math.sqrt(2)
for c in cells.values():
u_b = c["I"] * math.hypot(SHUNT_TOL, GAIN_ERR) / math.sqrt(3)
c["u"] = math.sqrt(c["semA"] ** 2 + u_rep**2 + u_b**2 + u_off**2)
c["U"] = 2 * c["u"]
c["u_rel_dev"] = math.sqrt(c["semA"] ** 2 + u_rep**2) # what does not scale with the meter's gain
res[m] = {"z": z, "i0": i0, "u_off": u_off, "u_rep": u_rep, "cells": cells}
print("## Zero (DUT disconnected)\n\n| meter | Z1 | Z2 | I0 used | residual offset u |\n|---|---|---|---|---|")
for m, r in res.items():
print(f"| {m} | {r['z']['Z1']:+.4f} mA | {r['z']['Z2']:+.4f} mA | {r['i0']:+.4f} mA | {r['u_off']:.4f} mA |")
print("\n## Cells\n\n| cell | meter | bus V | samples | 1-min blocks | I | u_A (SEM) | u_c | U (k=2) |\n|---|---|---|---|---|---|---|---|---|")
for c in CELLS:
for m in METERS:
x = res[m]["cells"][c]
print(f"| {c} | {m} | {x['V']:.3f} | {x['samples']} | {x['blocks']} | {x['I']:.3f} mA | {x['semA']:.4f} | {x['u']:.3f} | ±{x['U']:.3f} mA |")
print("\n## Repeatability A1 vs A2\n")
for m in METERS:
print(f"- {m}: |A1 - A2| = {abs(res[m]['cells']['A1']['I'] - res[m]['cells']['A2']['I']) * 1000:.1f} uA, u_rep = {res[m]['u_rep'] * 1000:.1f} uA")
print("\n## Agreement of the two meters (E_n = |I1 - I2| / sqrt(U1^2 + U2^2), <= 1 agrees)\n")
print("| cell | cb-fbfe18 | cb-4faa24 | difference | E_n |\n|---|---|---|---|---|")
for c in CELLS:
a, b = (res[m]["cells"][c] for m in METERS)
print(f"| {c} | {a['I']:.3f} | {b['I']:.3f} | {abs(a['I'] - b['I']):.3f} mA | {abs(a['I'] - b['I']) / math.hypot(a['U'], b['U']):.2f} |")
print("\n## Result (mean of both meters; differences against A = mean of A1 and A2)\n")
print("| configuration | I | U (k=2) | vs tth | relative |\n|---|---|---|---|---|")
comb = {}
for c in CELLS:
xs = [res[m]["cells"][c] for m in METERS]
comb[c] = (statistics.mean(x["I"] for x in xs), max(x["U"] for x in xs), xs)
A = (comb["A1"][0] + comb["A2"][0]) / 2
for c, label in (("A1", "tth release, powersaving on"), ("A2", "tth release, again"),
("S2", "stock v1.19.0 + powersaving on"), ("S1", "stock v1.19.0 as shipped (powersaving off)")):
i, U, xs = comb[c]
d = i - A
# a difference: offsets cancel, the gain errors act on |d| only; deviations from repeatability stay
u_d = math.sqrt(sum(x["u_rel_dev"] ** 2 for x in xs) / len(xs) * 2 + (abs(d) * math.hypot(SHUNT_TOL, GAIN_ERR) / math.sqrt(3)) ** 2)
rel = f"{100 * d / i:+.1f} % of this" if c.startswith("S") else ""
print(f"| {label} | {i:.3f} mA | ±{U:.3f} | {d:+.3f} ± {2 * u_d:.3f} mA | {rel} |")
@@ -0,0 +1,123 @@
# Measurement protocol: supply current, stock MeshCore vs. this fork
| | |
|---|---|
| date | 4. 12. 2026, 13:51–15:14 CET |
| object | XIAO nRF52840 + Wio-SX1262 (bench board x4), repeater firmware |
| question | how much current does this fork's public repeater image draw against upstream's, on the same board and settings |
| data | `ina_fast.tsv.gz` (every 1 s window of both meters), `compute.py` (all numbers below), `result.md` (its output) |
## 1. Setup
```
budka 3V3 ─► INA226 #1 (cb-fbfe18) ─► INA226 #2 (cb-4faa24) ─► 3V3 pin of x4
GND ── GND
```
- x4 is fed **only** on its 3V3 pin at ~3.26 V. No USB during a cell (USB keeps
HFCLK and USBD up and powers the board through VBUS), no battery, nothing on
its I2C bus (the BMP388 and x4's own INA226 were removed: a sensor driver that
configures them differently would show up as a "firmware difference").
- Antenna on. 866.5 MHz / 62.5 kHz / SF7 / CR5 (bench frequency, CZ mesh
modulation), TX −9 dBm, `repeat off`, both advert intervals 0, `radio.rxgain on`.
No other bench traffic during the cells (x1 and x3 silent).
## 2. Instruments
| | |
|---|---|
| meter | 2× INA226 on LaskaKit modules, shunt 10 mΩ (tolerance not stated, **assumed ±1 %**), shunt LSB 2.5 µV = 0.25 mA |
| readout | chytra-budka firmware `v0.19.20-27-gc6f031c`, `cmd/ina_fast "3500,1000"`: no averaging, 140 µs conversions, ~800 samples/s; per 1 s window the integer sum of shunt LSBs (`isum_raw`) and the sample count `n` (chytra-budka #235) |
| the two meters | independent: each is read by its own board, so they cross-check each other's gain and offset |
## 3. Images
| | build | `firmware.bin` sha256 (prefix) |
|---|---|---|
| **tth** | this fork, `rfa/main` 387184de (= release v1.19.0+tth.20261204.2 content), env `Xiao_nrf52_repeater`, `.github/fw-flags.sh` PUB_FLAGS + `-D LORA_FREQ=866.5 -D LORA_TX_POWER=-9` | `3e7b3fa80eacaa75` |
| **stock** | upstream tag `repeater-v1.19.0` (a2921870), env `Xiao_nrf52_repeater`, only `-D LORA_FREQ=866.5 -D LORA_BW=62.5 -D LORA_SF=7 -D LORA_CR=5 -D LORA_TX_POWER=-9` | `85cf850ccfd369dc` |
The frequency flags only change the defaults of a node without prefs; x4 kept
its prefs across all flashes and both images reported the same radio settings
(`get radio`, `get tx`, `get repeat`, intervals, `rxgain`) before each cell.
## 4. Procedure
Each image change: 3V3 off, USB on, flash (`dfu serial` / 1200 Bd touch +
`adafruit-nrfutil dfu serial`) and set, USB off, 3V3 on. Plugging the 3V3 in
is a clean power-on without USB, so every cell starts from the same kind of
boot. A cell = 120 s dropped after power-on + 600 s measured. Order:
| cell | image | `powersaving` |
|---|---|---|
| Z1 | -- (DUT disconnected, bus at 3.27 V) | |
| A1 | tth | on (our default) |
| S2 | stock | on |
| S1 | stock | **off** (upstream's default) |
| A2 | tth | on |
| Z2 | -- (DUT disconnected) | |
A1 and A2 bracket the stock cells, so a drift of the rig shows as A1 ≠ A2.
## 5. Evaluation
Per meter: I = Σ`isum_raw` · 2.5 µV / (Σn · 10 mΩ) − I₀, with I₀ the mean of
Z1 and Z2. The zero is taken **at the same bus voltage as the cells**: at 0 V
on the bus the same meters read within ±0.08 mA of zero instead of ∓0.116 mA, i.e. the
INA226 offset depends on the common-mode voltage.
Uncertainty after GUM:
| component | type | value |
|---|---|---|
| statistics within a cell | A | SEM of the 1-minute block means (blocks, not 1 s windows: those are correlated) |
| repeatability between cells | A | \|A1 − A2\| / √2, applied to every cell |
| shunt tolerance | B | 1 % / √3 of the reading (assumed rectangular) |
| INA226 gain error | B | 0.1 % / √3 of the reading (datasheet max) |
| residual offset | B | half of \|Z1 − Z2\| / √3 |
u_c = √(Σu²), expanded U = 2·u_c (k = 2, ~95 %). For a **difference** of two
configurations the offset cancels and the gain errors act on the difference
only, so differences are known much better than absolute values.
## 6. Results
Measured values (offset-corrected, `compute.py` → `result.md`):
| cell | cb-fbfe18 | cb-4faa24 | E_n of the two |
|---|---|---|---|
| A1 tth | 6.865 mA | 6.874 mA | 0.08 |
| S2 stock + powersaving | 7.273 mA | 7.259 mA | 0.11 |
| S1 stock as shipped | 10.121 mA | 10.131 mA | 0.06 |
| A2 tth | 6.867 mA | 6.878 mA | 0.09 |
- zero: −0.119 / −0.116 mA (#1), +0.114 / +0.117 mA (#2) at the start / end;
drift 3–4 µA over 80 min;
- SEM within a cell: 0.2–3 µA;
- repeatability A1 → A2 after two image swaps: **2.5 µA and 3.4 µA**;
- the two meters agree within 0.009–0.014 mA (0.1–0.2 %), E_n ≤ 0.11: far inside
the assumed 1 % shunt tolerance, which therefore dominates U and is
conservative.
**Result** (mean of the two meters, U for k = 2):
| configuration | current | against tth |
|---|---|---|
| **tth release** (`powersaving on`, as provisioned) | **(6.87 ± 0.08) mA** | -- |
| stock v1.19.0, `powersaving on` set by hand | (7.27 ± 0.09) mA | **+(0.40 ± 0.01) mA** |
| **stock v1.19.0 as shipped** (`powersaving off`) | **(10.13 ± 0.12) mA** | **+(3.26 ± 0.04) mA** |
## 7. Conclusion
On the same board and settings the fork's repeater draws **32 % less** than
upstream's image as shipped: (6.87 ± 0.08) mA against (10.13 ± 0.12) mA. Most
of it is `powersaving` (upstream ships it off): 2.86 mA. The code changes of the
fork save the remaining (0.40 ± 0.01) mA against stock with `powersaving` on.
The CC310 sleep insomnia (+3.3 mA, `docs/power.md`) does **not** show in the
stock image: stock with `powersaving on` sits at 7.27 mA, not ~10.5. That
insomnia was measured on our own builds with BLE; it is not an upstream
regression that the fork fixes for this board.
Not covered: other boards (absolute numbers are this XIAO's), BLE builds
(`*-observer`), GPS, the radio's TX share (no traffic in the cells).
@@ -0,0 +1,42 @@
## Zero (DUT disconnected)
| meter | Z1 | Z2 | I0 used | residual offset u |
|---|---|---|---|---|
| cb-fbfe18 | -0.1190 mA | -0.1158 mA | -0.1174 mA | 0.0009 mA |
| cb-4faa24 | +0.1137 mA | +0.1174 mA | +0.1156 mA | 0.0011 mA |
## Cells
| cell | meter | bus V | samples | 1-min blocks | I | u_A (SEM) | u_c | U (k=2) |
|---|---|---|---|---|---|---|---|---|
| A1 | cb-fbfe18 | 3.261 | 476578 | 10 | 6.865 mA | 0.0004 | 0.040 | ±0.080 mA |
| A1 | cb-4faa24 | 3.256 | 448672 | 10 | 6.874 mA | 0.0003 | 0.040 | ±0.080 mA |
| S2 | cb-fbfe18 | 3.259 | 478962 | 10 | 7.273 mA | 0.0030 | 0.042 | ±0.085 mA |
| S2 | cb-4faa24 | 3.255 | 453442 | 10 | 7.259 mA | 0.0015 | 0.042 | ±0.084 mA |
| S1 | cb-fbfe18 | 3.250 | 477325 | 10 | 10.121 mA | 0.0003 | 0.059 | ±0.118 mA |
| S1 | cb-4faa24 | 3.244 | 452826 | 10 | 10.131 mA | 0.0004 | 0.059 | ±0.118 mA |
| A2 | cb-fbfe18 | 3.259 | 467584 | 11 | 6.867 mA | 0.0002 | 0.040 | ±0.080 mA |
| A2 | cb-4faa24 | 3.254 | 446689 | 11 | 6.878 mA | 0.0006 | 0.040 | ±0.080 mA |
## Repeatability A1 vs A2
- cb-fbfe18: |A1 - A2| = 2.5 uA, u_rep = 1.8 uA
- cb-4faa24: |A1 - A2| = 3.4 uA, u_rep = 2.4 uA
## Agreement of the two meters (E_n = |I1 - I2| / sqrt(U1^2 + U2^2), <= 1 agrees)
| cell | cb-fbfe18 | cb-4faa24 | difference | E_n |
|---|---|---|---|---|
| A1 | 6.865 | 6.874 | 0.009 mA | 0.08 |
| S2 | 7.273 | 7.259 | 0.014 mA | 0.11 |
| S1 | 10.121 | 10.131 | 0.009 mA | 0.06 |
| A2 | 6.867 | 6.878 | 0.010 mA | 0.09 |
## Result (mean of both meters; differences against A = mean of A1 and A2)
| configuration | I | U (k=2) | vs tth | relative |
|---|---|---|---|---|
| tth release, powersaving on | 6.869 mA | ±0.080 | -0.001 ± 0.006 mA | |
| tth release, again | 6.872 mA | ±0.080 | +0.001 ± 0.006 mA | |
| stock v1.19.0 + powersaving on | 7.266 mA | ±0.085 | +0.395 ± 0.010 mA | +5.4 % of this |
| stock v1.19.0 as shipped (powersaving off) | 10.126 mA | ±0.118 | +3.255 ± 0.038 mA | +32.1 % of this |