Deep sleep, button wake
Sleep at microamp current and wake on a button press. A boot counter survives in RTC memory.
ESP32
3V3
GND
EN
23
VP
22
VN
TX
34
RX
35
21
32
GND
33
19
25
18
26
5
27
17
14
16
12
4
GND
0
13
2
D2
15
D3
D1
CMD
D0
5V
CLK
Wiring
| From | To board | Note |
|---|---|---|
| Button, side A | 3V3 | |
| Button, side B | GPIO 33 | RTC pin, so it can wake the chip |
| 10 kΩ pull-down | GPIO 33 to GND | Holds the pin low while the button is open |
Tested on this board
Not run on this board yet. Treat the wiring and code as a first draft.
Firmware, Arduino sketch for ESP32 Dev Module
RTC_DATA_ATTR int boots = 0;
void setup() {
Serial.begin(115200);
delay(200);
boots++;
Serial.printf("Boot %d, wake cause %d\n", boots, (int)esp_sleep_get_wakeup_cause());
esp_sleep_enable_ext0_wakeup(GPIO_NUM_33, 1);
Serial.println("Sleeping. Press the button to wake.");
Serial.flush();
esp_deep_sleep_start();
}
void loop() {}Parts
| Quantity | Part | Where to buy |
|---|---|---|
| 1× | ESP32 dev board | Buy at Amazon |
| 1× | Push button | |
| 1× | 10 kΩ resistor | |
| 3× | Jumper wires |
Amazon buy links may include an Associates tag, and this site may earn a commission from qualifying Amazon purchases at no extra cost to you. Adafruit links are direct.
Libraries
None beyond the ESP32 Arduino core.
Load it
- In the Arduino IDE, install the esp32 board package and pick the board named above the sketch.
- Paste the sketch, choose the board's port and upload. Hold BOOT if the upload stalls at Connecting.
- Close the IDE's serial monitor, then open the bench here to watch the output.