Monitor the XIAO's battery and make the XIAO the production board
The production OBU is now a Seeed XIAO ESP32-C5 (8 MB flash, one native USB-C port) on a LiPo with no protection board. The firmware reads the cell on GPIO6 (divider switched by GPIO26) every 5 s, sends it in STATUS (battery_mv and battery_flags, octets 103-105; decoders accept 103 or >= 106 octets), warns below 3.50 V and deep-sleeps below 3.30 V when no phone is on USB, waking every 5 min to check the cell again. Thresholds are in Kconfig; host test `make battery`. The app shows voltage, a rough percentage and the low/critical state on the ESP32-C5 card and in the top bar. With several bonded micrOBUs (a replaced board stays bonded), the BLE link tries the one that last connected first and moves on to the next after each failure. tools/station_status_watch.py reads STATUS from the native port.
This commit is contained in:
@@ -5,6 +5,43 @@ Engineering to-do list. The reviewer-facing open items live in
|
||||
|
||||
## Waiting on hardware
|
||||
|
||||
### XIAO ESP32-C5 battery: voltage, low-battery warning, shutdown (added 2026-10-05)
|
||||
|
||||
The production board is now a Seeed XIAO ESP32-C5 on COM10 (8 MB flash), on a LiPo with no protection
|
||||
board. Firmware reads the cell (GPIO6 behind the GPIO26 load switch) every 5 s, puts it in STATUS
|
||||
(octets 103-105), warns below 3.50 V and deep-sleeps below 3.30 V when no phone is on USB; the app shows
|
||||
voltage, percentage and the warning. Details: `obu-firmware/FLASHING.md`, "Battery and pins".
|
||||
Host tests (`make battery`, 6 groups) and the app's 116 unit tests pass; the production image was
|
||||
flashed to COM10 on 2026-10-05 and `tools/station_status_watch.py COM10` showed 106-octet STATUS with
|
||||
3998 mV, stable over 18 s. Backup of what COM10 held before: `firmware-backups/COM10-xiao-before-obu-firmware-2026-10-05.bin`.
|
||||
|
||||
Needs the XIAO, the cell and a multimeter (shutdown test: also the phone, or just the PC script):
|
||||
|
||||
- [ ] **Is the reading right?** (3998 mV before the cell was soldered, 4078 then 4104 mV after, rising as USB charges it.) Measure the cell at the BAT pads with the multimeter while the board runs and
|
||||
compare with `py -3.11 tools/station_status_watch.py COM10`. Off by more than ~2 %: set
|
||||
`CONFIG_MICROBU_BATTERY_SCALE_PERMILLE` = 1000 x multimeter / reading (the divider is 2 x 100 k into
|
||||
the ADC, so a high source impedance can read low). Unplug USB first to see the cell alone: with USB
|
||||
the charger holds the pin above the cell voltage.
|
||||
- [x] **Low-voltage shutdown and wake (done 2026-10-05 on COM10, cell soldered):** with the bench image the flags were 0x03 at once, the board stayed up for 85 s while the script talked, then slept 87 s after the script stopped (its port close resets the board, so that is 60 s grace + 30 s) and woke every 30 s, measured 4078 mV < 4100 and went straight back to sleep. A RESET press recovers it. Production image reflashed afterwards (c13c389-dirty, IDF v6.0.2, 4104 mV, flags 0). Original steps. Build with
|
||||
`CONFIG_MICROBU_BATTERY_WARN_MV=4150`, `SHUTDOWN_MV=4100`, `RESUME_MV=4100`, `SLEEP_S=30` (edit a
|
||||
copy of `sdkconfig`, `idf.py -B <dir> -DSDKCONFIG=<copy> build`), flash it, then expect:
|
||||
`station_status_watch.py` shows flags 0x01 (low) at once and 0x03 (critical); the board does NOT
|
||||
shut down while the script keeps talking; stop the script, wait about 2 minutes (60 s uptime + 30 s
|
||||
+ sampling): COM10 disappears (deep sleep); it reappears about every 30 s for a moment and goes
|
||||
away again while the cell reads below RESUME_MV. Then flash the production image again.
|
||||
- [ ] **App** (BLE checked 2026-10-05 on the Pixel: the card shows "Battery 4.12 V · about 90 %"; USB and the low/critical look still to do): with the phone on the XIAO (USB, then BLE), Settings > Connection > ESP32-C5 shows
|
||||
"Battery 3.xx V · about N %"; with a bench image whose WARN_MV is above the cell the card turns amber
|
||||
with "Low battery" and the top bar shows the battery-alert icon.
|
||||
- [ ] **Does the ADC read disturb the radio, or the radio the reading?** Connect the phone, transmit CAMs
|
||||
(radio on), and check the STATUS voltage does not jump by more than ~50 mV during TX bursts and
|
||||
that `radio_failed` stays 0 (the C5's ADC power is shared with the Wi-Fi PHY's power detector).
|
||||
- [ ] **Charge current and charge time.** The XIAO wiki gives no figure for the SGM40567. Measure the
|
||||
current into the cell with USB plugged in (multimeter in series in the cell's + wire), and note how
|
||||
the cell voltage rises. A 5000 mAh cell charged at ~100 mA takes days.
|
||||
- [ ] **Idle current from the cell** with the radio off (before Connect) and on, to estimate runtime.
|
||||
- [ ] Decide whether the cell needs a protection board before it goes anywhere but the bench: nothing
|
||||
protects it from a short, an over-current or a charge outside 0-45 degC.
|
||||
|
||||
### On-air check of the V2X data logger (added 2026-10-02)
|
||||
|
||||
Needs the phone, a second station sending (the simulated car works) and, for the CiT One part, the OBU.
|
||||
|
||||
Reference in New Issue
Block a user