Skip to content

Conversation

@weebl2000
Copy link
Contributor

@weebl2000 weebl2000 commented Jan 8, 2026

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

@weebl2000 weebl2000 changed the base branch from main to dev January 8, 2026 16:04
@weebl2000 weebl2000 changed the title Powersaving ble companion Powersaving on companion when serial is off (ble/wifi) Jan 8, 2026
@weebl2000 weebl2000 force-pushed the powersaving-ble-companion branch from 35fad46 to 69f1ad3 Compare January 8, 2026 23:01
@weebl2000
Copy link
Contributor Author

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).

@weebl2000
Copy link
Contributor Author

weebl2000 commented Jan 10, 2026

@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.

@weebl2000 weebl2000 force-pushed the powersaving-ble-companion branch from f090774 to 28773f8 Compare February 6, 2026 01:10
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>
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