Powersaving on companion when serial is off (ble/wifi)#1347
Powersaving on companion when serial is off (ble/wifi)#1347weebl2000 wants to merge 3 commits intomeshcore-dev:devfrom
Conversation
35fad46 to
69f1ad3
Compare
|
Moved button handling logic to ESP32Board - this has the added benefit that repeaters will also wake up when you press the button (they do not currently). |
|
@fschrempf Actually basically all devices are low when pressed. Updated the code accordingly. On my Heltec v4 the screen turns off when I disable bluetooth. |
f090774 to
28773f8
Compare
28773f8 to
6e44a89
Compare
Use millisHasNowPassed() (2's complement safe) instead of direct comparison, consistent with the repeater's sleep timing logic. Co-Authored-By: Wessel <weebl@users.noreply.github.com>
|
I have confirmed this saves a bunch of milliamps when bluetooth is disabled, but even more so look at pr #1686. When bluetooth is enabled but phone isn't connected, we sleep for 3 seconds out of every and this saves about 80% power while still having bluetooth enabled. This PR works great but I'd suggest merging #1686 for even more power saving. |
Hi @weebl2000, How much is power consumption during sleep? Still 10mA as same as repeater. In my latest PR, I shifted from ext1 use GPIO wakeup instead of ext1 so the sleep is available to all esp32 boards. |
Build firmware: Build from this branch
Summary
Adds power saving to the companion radio when BLE/WiFi is disabled by the user. When the serial interface is off (and GPS is not enabled), the device enters ESP32-S3 light sleep for 30-minute intervals, significantly reducing power consumption for battery-powered companion nodes that are left running as pure relays.
Changes
Light sleep in companion radio (
examples/companion_radio/main.cpp)serial_interface.isEnabled()is false and GPS is offWiFi radio actually turns off (
src/helpers/esp32/SerialWifiInterface.cpp/h)disable()now callsWiFi.disconnect(true)andWiFi.mode(WIFI_OFF)to power down the radioenable()reconnects using stored SSID/password credentialsdisable()only set a flag — the WiFi radio stayed powered onButton wakeup with correct polarity (
src/helpers/ESP32Board.h)enterLightSleep()accepts optionalpin_wake_btnparameter (backward-compatible)GPIO_INTR_LOW_LEVEL) for button — correct for active-LOW buttonsANY_HIGH) for LoRa DIO1 only — these can't share a mask since they need opposite trigger levelsPending work detection (
examples/companion_radio/MyMesh.cpp/h)hasPendingWork()checks outbound packet queue to avoid sleeping while packets are queuedNotes
CONFIG_IDF_TARGET_ESP32S3)PIN_USER_BTNgracefully skip button wakeupsleep()still callsenterLightSleep(secs)without button