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:
@@ -36,4 +36,44 @@ config MICROBU_TX_LED_BLINK_MS
|
||||
config MICROBU_LED_INVERTED_RX
|
||||
bool "Inverted LED mode for receiver/bridge (normally ON, blink OFF on packet)"
|
||||
default n
|
||||
config MICROBU_BATTERY_ADC_GPIO
|
||||
int "Battery voltage ADC GPIO (-1: no battery monitoring)"
|
||||
range -1 6
|
||||
default 6
|
||||
help
|
||||
The XIAO ESP32-C5 reads its battery on GPIO6 (BAT_VOLT_PIN) through two 100 k resistors.
|
||||
config MICROBU_BATTERY_EN_GPIO
|
||||
int "Battery divider enable GPIO"
|
||||
range 0 28
|
||||
default 26
|
||||
help
|
||||
XIAO ESP32-C5: GPIO26 (BAT_VOLT_PIN_EN) switches the divider on for the reading.
|
||||
config MICROBU_BATTERY_SCALE_PERMILLE
|
||||
int "Battery reading trim (1000 = none)"
|
||||
range 800 1200
|
||||
default 1000
|
||||
help
|
||||
Multiplies the reading. Compare the STATUS battery voltage with a multimeter on the cell
|
||||
and set this to 1000 * multimeter / reading if the divider or ADC is off.
|
||||
config MICROBU_BATTERY_WARN_MV
|
||||
int "Low-battery warning below this cell voltage (mV)"
|
||||
range 3000 4200
|
||||
default 3500
|
||||
config MICROBU_BATTERY_SHUTDOWN_MV
|
||||
int "Shutdown below this cell voltage (mV), see battery_monitor.hpp"
|
||||
range 3000 4200
|
||||
default 3300
|
||||
help
|
||||
There is no protection board on the prototype cell, so this is the only guard against
|
||||
over-discharge. The board shuts down (deep sleep) once the smoothed voltage has stayed below
|
||||
this for 30 s and no phone is talking over USB; it checks the cell again every
|
||||
MICROBU_BATTERY_SLEEP_S and runs again from 3600 mV.
|
||||
config MICROBU_BATTERY_RESUME_MV
|
||||
int "After a shutdown, run again at or above this cell voltage (mV)"
|
||||
range 3300 4200
|
||||
default 3600
|
||||
config MICROBU_BATTERY_SLEEP_S
|
||||
int "Seconds between cell checks while shut down"
|
||||
range 30 3600
|
||||
default 300
|
||||
endmenu
|
||||
|
||||
Reference in New Issue
Block a user