Skip to content

Powersaving on companion when serial is off (ble/wifi)#34

Open
weebl2000 wants to merge 5 commits intodevfrom
powersaving-ble-companion
Open

Powersaving on companion when serial is off (ble/wifi)#34
weebl2000 wants to merge 5 commits intodevfrom
powersaving-ble-companion

Conversation

@weebl2000
Copy link
Owner

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)

  • Enters 30-minute light sleep cycles when serial_interface.isEnabled() is false and GPS is off
  • Wakes on: LoRa packet (ext1), timer (30min), or button press (GPIO wakeup)
  • Stays awake briefly after wake to process any pending work before sleeping again
  • Initial 2-minute delay before first sleep to allow setup/connection

WiFi radio actually turns off (src/helpers/esp32/SerialWifiInterface.cpp/h)

  • disable() now calls WiFi.disconnect(true) and WiFi.mode(WIFI_OFF) to power down the radio
  • enable() reconnects using stored SSID/password credentials
  • Previously disable() only set a flag — the WiFi radio stayed powered on

Button wakeup with correct polarity (src/helpers/ESP32Board.h)

  • enterLightSleep() accepts optional pin_wake_btn parameter (backward-compatible)
  • Uses GPIO wakeup (GPIO_INTR_LOW_LEVEL) for button — correct for active-LOW buttons
  • Keeps ext1 (ANY_HIGH) for LoRa DIO1 only — these can't share a mask since they need opposite trigger levels

Pending work detection (examples/companion_radio/MyMesh.cpp/h)

  • hasPendingWork() checks outbound packet queue to avoid sleeping while packets are queued

Notes

  • Only affects ESP32-S3 targets (gated by CONFIG_IDF_TARGET_ESP32S3)
  • Boards without PIN_USER_BTN gracefully skip button wakeup
  • GPS-enabled nodes skip sleep entirely (GPS needs continuous operation)
  • No changes to the repeater sleep path — sleep() still calls enterLightSleep(secs) without button

Mirror of meshcore-dev#1347

@weebl2000 weebl2000 force-pushed the powersaving-ble-companion branch from f4bf112 to c089637 Compare February 28, 2026 18:17
liamcottle and others added 4 commits March 4, 2026 01:39
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>
@weebl2000 weebl2000 force-pushed the powersaving-ble-companion branch from c089637 to ce18d1f Compare March 3, 2026 14:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants