I'm having trouble getting my ESP32-C6-Super Mini board to wake up from light sleep using a button (and even with a timer). My project works fine on an ESP32-WROOM board, but when I switch to the C6-Super Mini, it enters sleep correctly yet never wakes up.
Below are my two code examples and observations.
Working on ESP32-WROOM (using EXT0):
#include "esp_sleep.h"
#include <Arduino.h>
struct Button {
uint8_t pin;
bool pressed;
void init() {
pinMode(pin, INPUT_PULLUP);
pressed = false;
}
bool update() {
bool now = (digitalRead(pin) == LOW);
if (now && !pressed) {
pressed = true;
return true;
}
if (!now) {
pressed = false;
}
return false;
}
};
Button btn = {25, false};
enum State {
STATE_AWAKE,
STATE_WAIT_RELEASE,
STATE_ENTER_SLEEP,
STATE_SLEEPING,
STATE_WAKEUP
};
State currentState = STATE_AWAKE;
void setup() {
Serial.begin(115200);
delay(1000);
Serial.println("ESP32-C6 Light Sleep Toggle (EXT1 Wakeup)");
btn.init();
// Using EXT0 wakeup here on pin 25
esp_sleep_enable_ext0_wakeup((gpio_num_t)btn.pin, 0);
}
void loop() {
switch (currentState) {
case STATE_AWAKE:
if (btn.update()) {
Serial.println("Button pressed in awake state.");
currentState = STATE_WAIT_RELEASE;
}
break;
case STATE_WAIT_RELEASE:
if (digitalRead(btn.pin) == HIGH) {
Serial.println("Button released. Preparing to enter light sleep...");
currentState = STATE_ENTER_SLEEP;
}
break;
case STATE_ENTER_SLEEP:
Serial.println("Entering light sleep mode (EXT1)...");
currentState = STATE_SLEEPING;
esp_light_sleep_start();
currentState = STATE_WAKEUP;
break;
case STATE_WAKEUP:
Serial.println("Woke up from light sleep via EXT1!");
currentState = STATE_AWAKE;
break;
}
delay(10);
}
Serial Monitor Output on ESP32-WROOM:
Button pressed in awake state.
Button released. Preparing to enter light sleep...
Entering light sleep mode (EXT1)...
Woke up from light sleep via EXT1!
... I also measured the current: it drops from around 60mA to 20mA when in sleep, which seems normal.
Failing on ESP32-C6-Super Mini (using EXT1):
#include "esp_sleep.h"
#include <Arduino.h>
struct Button {
uint8_t pin;
bool pressed;
void init() {
pinMode(pin, INPUT_PULLUP);
pressed = false;
}
bool update() {
bool current = (digitalRead(pin) == LOW);
if (current && !pressed) {
pressed = true;
return true;
}
if (!current) {
pressed = false;
}
return false;
}
};
Button btn = {7, false}; // Using GPIO 7
enum State {
STATE_AWAKE,
STATE_WAIT_RELEASE,
STATE_ENTER_SLEEP,
STATE_SLEEPING,
STATE_WAKEUP
};
State currentState = STATE_AWAKE;
void setup() {
Serial.begin(115200);
delay(1000);
Serial.println("ESP32 Light Sleep Toggle Example");
btn.init();
// Keep RTC peripheral power on for internal pull-up stability
esp_sleep_pd_config(ESP_PD_DOMAIN_RTC_PERIPH, ESP_PD_OPTION_ON);
// EXT1 wakeup configuration: wake up when GPIO7 goes LOW
esp_sleep_enable_ext1_wakeup((1ULL << btn.pin), ESP_EXT1_WAKEUP_ANY_LOW);
}
void loop() {
switch (currentState) {
case STATE_AWAKE:
if (btn.update()) {
Serial.println("Button pressed in awake state.");
currentState = STATE_WAIT_RELEASE;
}
break;
case STATE_WAIT_RELEASE:
if (digitalRead(btn.pin) == HIGH) {
Serial.println("Button released. Preparing to enter light sleep...");
currentState = STATE_ENTER_SLEEP;
}
break;
case STATE_ENTER_SLEEP:
Serial.println("Entering light sleep mode...");
currentState = STATE_SLEEPING;
esp_light_sleep_start();
currentState = STATE_WAKEUP;
break;
case STATE_WAKEUP:
Serial.println("Woke up from light sleep!");
currentState = STATE_AWAKE;
break;
}
delay(10);
}
Serial Monitor Output on ESP32-C6-Super Mini:
mathematica
ESP32 Light Sleep Toggle Example
Button pressed in awake state.
Button released. Preparing to enter light sleep...
Now, entering sleep...
After entering sleep, the board never wakes up—even when I try pressing the button.
Additional Test with Timer Wakeup Only on ESP32-C6-Super Mini:
#include <Arduino.h>
#include "esp_sleep.h"
const int BUTTON_PIN = 7;
void setup() {
Serial.begin(115200);
delay(1000);
pinMode(BUTTON_PIN, INPUT_PULLUP); // Default HIGH
gpio_wakeup_enable((gpio_num_t)BUTTON_PIN, GPIO_INTR_LOW_LEVEL);
esp_sleep_enable_gpio_wakeup();
// Timer wakeup after 5 seconds
esp_sleep_enable_timer_wakeup(5000000ULL);
Serial.println("Entering Light Sleep in 3 seconds...");
delay(3000);
Serial.println("Now sleeping...");
esp_light_sleep_start();
Serial.println("Woke up!");
}
void loop() {
delay(1000);
Serial.println("Sleep again...");
esp_light_sleep_start();
Serial.println("Woke up again!");
}
Serial Output:
mathematica
Entering Light Sleep in 3 seconds...
Now sleeping...
After entering sleep, no wakeup occurs.
Summary of the Problem:
On the ESP32-WROOM board, my code works perfectly—the board sleeps and wakes via the button (or EXT0) as expected. On the ESP32-C6-Super Mini board, while sleep is successfully entered (confirmed by the current drop), the board never wakes up—neither with button wakeup (using EXT1) nor with a timer wakeup. Questions/Observations:
Could there be a bug or incomplete implementation in the Arduino core for ESP32-C6 affecting wakeup functions (esp_light_sleep_start(), EXT1, GPIO wakeup, timer wakeup)? Is it possible that the ESP32-C6-Super Mini board’s pin mapping or RTC configuration differs from what the code assumes? Any suggestions on debugging this or a workaround would be greatly appreciated. Please let me know if any part of this description seems off or if there are additional details I should include. Thanks in advance for your help!
Feel free to edit or add any hardware details (such as external pull-ups, wiring, etc.) to further clarify your setup. Good luck, and I hope this helps get to the bottom of the issue!
I tried light sleep mode in ESP32-WROOM and succeeded with it, but failed with it in ESP32-C6-Super Mini board.