Documentation
Onboarding
Getting Started
Power & Battery
Hardware & Components
Build & Assembly
Radio & RF Design
Frequencies & Regulations
Firmware & Software
USB & Connectivity
GPS & Navigation
Morse & Communication
Modes & Operation
Field Operations & Rescue
Building Effectively
Build Variants
Project & Reference
Docs Firmware & Software Firmware Wake Sources

Firmware Wake Sources

Edit on GitHub

The ESP32 wake sources used by the beacon: RTC timer, GPIO buttons, and how the firmware distinguishes them.

Firmware Wake Sources

The ESP32 can wake from deep sleep in several ways. The beacon uses two of them, and the firmware must tell them apart at boot.

Wake sources in use

SourceHardwarePurpose
RTC timerInternalScheduled beacon burst
GPIOMODE buttonUser wakes the device to change settings

RTC timer wake

The timer is programmed before sleep with the duration of the sleep interval. It is the primary wake source during normal beacon operation. Accuracy is a few seconds over hours, which is fine for a beacon.

GPIO wake

The MODE button is wired to an RTC-capable GPIO. Pressing it while the device sleeps wakes it into CONFIG mode so the user can adjust settings without waiting for the next burst. The button must be wired with a pull resistor and connected to a pin the ESP32 allows for RTC GPIO wake (most boards: GPIO 0, 2, 4, 12-15, 25-27, 32-39).

Distinguishing wake causes

At boot, esp_sleep_get_wakeup_cause() returns the reason:

CauseAction
RTC timerResume the beacon cycle
GPIOEnter CONFIG mode
Power-on / resetFull boot sequence with splash screen

Debounce and re-sleep

A GPIO wake is debounced in firmware before the display turns on, because a glitch on the button line would otherwise light the OLED for no reason. If no button press is confirmed within 5 seconds, the device returns to deep sleep.