Files
ESP32-S3-Touch-LCD-5B/wiki/pages/sleep-when-parked.md
T

32 lines
2.6 KiB
Markdown

---
type: concept
tags: [power, sleep, settings, verified]
updated: 2026-09-28
---
# Sleep when the car is off
User request 2026-09-28: both boards sit on permanent 12 V, so they must stop burning power when the CAN bus goes quiet. One switch, **Settings → System → "Sleep when the car is off"** (NVS `sleep_en`, default OFF), rules both controllers: the Main CTRL mirrors it into the CONFIG frame as `CFG_SLEEP_WHEN_SILENT` (bit 7 of `out_enable`, byte layout unchanged, `PACKET_VERSION` stays 2), and the Inst. Cluster caches CONFIG in NVS, so it knows the setting even after the Main CTRL has gone to sleep.
## Main CTRL (`src/modules/power_manager.cpp`)
Deep sleep when **all** of: switch on; CAN switched on but the bus quiet for 60 s (an ignition-on car never stops talking, so "quiet" = key off); nobody touched the screen for 60 s (`lv_disp_get_inactive_time`); no update running here or reported by the Inst. Cluster; up for at least 60 s. Sequence: `Tunables::flush()`, backlight off, `CANDriver::stop()` (frees GPIO 16 from TWAI), pull-up on GPIO 16, `esp_sleep_enable_ext0_wakeup(GPIO 16, low)`, `esp_deep_sleep_start()`. Wake = the first CAN frame pulls RX low → full reboot (~3 s to the Driveline); the boot log says `woke up: CAN bus activity`. Nothing else wakes it: with no bus (bench) only the reset button / a power cycle does, and the USB port is gone while asleep. Console: `sleep status | on | off | now`.
## Inst. Cluster (`src/modules/power_manager.cpp`)
Deep sleep when the bit is set, no DATA frame on any transport for 60 s, no update job, up ≥ 60 s. Gauges driven low and backlight off first. Two wake sources: **UART RX IO1 low** (the Main CTRL's first frame on the wire) and a **60 s timer**. A timer wake is a *probe boot*: setup skips its serial waits, the panel stays dark, and after 4 s without a frame the board sleeps again; if the Main CTRL is heard (ESP-NOW or wire) brightness is restored and the boot continues normally. This is what wakes a radio-only installation (no wire in the car).
## Verified 2026-09-28 (bench)
See the log entry of the day: switch → CONFIG → Inst. Cluster within a CONFIG period; `sleep now` on the Inst. Cluster and its wake.
## Not verified
- The Main CTRL's own sleep and CAN wake need the car (a quiet bus that later talks). Bench boards have no bus, so they would never wake.
- Deep-sleep current of either board (Waveshare boards keep their LDO/USB bridge powered).
- Whether the TJA1051's RXD idles high with the transceiver powered but the bus off (expected).
## Related
[[ota-updates]] · [[esp32-s3-touch-lcd-5b]] · (sibling wiki: controller-link, patrol-gauge-outputs)