Merge feat/ina-coulomb into main

This commit is contained in:
tth committed 2026-12-04 19:18:14 +01:00
commit e987fc5566
18 files changed
+356 -6

No files matched your search

+23
View File
@@ -1428,6 +1428,29 @@ admin, and on a companion as the custom variable `ina.shunt`. With the wrong val
the current is off by the ratio -- LaskaKit's INA226 modules carry 10 mOhm, the
default assumes 100. Current is reported in steps of 1 mA (CayenneLPP).
#### Battery charge counter (INA226)
*meshcore-tth addition.*
**Usage:**
- `sensor get ina.coulomb`
- `sensor set ina.coulomb 1|0`
**Wiring:** the INA226 in series with the battery, IN+ on the cells and IN- on
the board, so current drawn from the battery reads positive and charging negative.
Set `ina.shunt` first (10 for LaskaKit modules).
**Note:** On, the INA226 converts continuously and averages in hardware without
gaps ((8.244 ms shunt + 0.14 ms bus) x 1024 = one result every ~8.6 s); the node
picks each result up and counts the charge drawn from and charged into the battery
since boot, separately. Telemetry then reports the latest ~8.6 s average instead of
a one-shot reading. The stats bundle carries the two counters (ids 22/23, uAh), the
exporter turns them into `meshcore_battery_charge_out_mah_total` and
`..._in_mah_total`; `rate()` of each is the consumption and the harvest. Off by
default: then the chip sleeps between telemetry reads. The only cost is the
INA226's own supply current (~0.33 mA, datasheet); the node reads it once per
result in a loop that wakes every 50 ms anyway. Listed only when an INA226 was
detected at boot; saved.
---
### Bridge (When bridge support is compiled in)
+2 -1
View File
@@ -86,7 +86,8 @@ reads past the data and fails the page.
| 17 / 18 | `direct_dups` / `flood_dups` | |
| 19 | `recv_errors` | |
| 20 / 21 | `tx_start_fail` / `tx_timeout` | |
| | *the fields of `RepeaterStats` plus telemetry; ids 1..21 are all a guest sees* | |
| 22 / 23 | `charge_out` / `charge_in` | uAh drawn from / charged into the battery since boot; only with `sensor set ina.coulomb 1` (an INA226 in the battery line) |
| | *the fields of `RepeaterStats` plus telemetry; ids 1..23 are all a guest sees* | |
| 24 | `fair_group` | FairnessLimiter drops, channel (group) bucket |
| 25 | `fair_sender` | sender bucket |
| 26 | `fair_advert` | advert bucket |
+1
View File
@@ -324,6 +324,7 @@ lost 16 % of its reception -- see cli_commands.md and [power.md](power.md).
| `sensor read` | the live telemetry decoded into one line (`sensor list` shows only settings) |
| `sensor get ina.shunt` | the shunt the current is computed with |
| `sensor set ina.shunt <mOhm>` | shunt resistance of an INA219, INA226 or INA3221 module (`10` for `R010`), saved; `0` = build default (100). The INA260 has its shunt inside and no setting |
| `sensor set ina.coulomb 1\|0` | an INA226 in the battery line as a charge counter: converts continuously (~8.6 s averages) and counts mAh drawn / charged since boot (stats bundle ids 22/23, exporter `meshcore_battery_charge_{out,in}_mah_total`). Saved; off by default. Costs the INA226's own ~0.33 mA |
## Build flags