it wakes up the esp32-s3-zero from deep sleep by a low signal on pin 1 or 2 or 3 and lights up the led accordingly.
a high signal on the pin will switch off the led.
the signal duration required to activate the led is too long, approximately 200-500ms.
is there a way to make the wake up more rapid ? i consider to build a battery powered keyboard. the deep sleep mode was intended for energy saving. the large delay makes deep sleep useless if an action upon the pin signal is required after wake up.
here is the program:
#include "esp_sleep.h"
#include "driver/gpio.h"
#include "driver/rtc_io.h"
#define RGB_BRIGHTNESS 5 // Change white brightness (max 255)
#ifdef RGB_BUILTIN
#undef RGB_BUILTIN // Remove possible previous definition
#endif
#define RGB_BUILTIN 21
void setup() {
pinMode(GPIO_NUM_1, INPUT_PULLUP);
pinMode(GPIO_NUM_2, INPUT_PULLUP);
pinMode(GPIO_NUM_3, INPUT_PULLUP);
delay(4); // Give GPIOs a brief stabilization time
// Check pin states immediately
if (digitalRead(GPIO_NUM_1) == LOW) neopixelWrite(RGB_BUILTIN, RGB_BRIGHTNESS, 0, 0); // Red
if (digitalRead(GPIO_NUM_2) == LOW) neopixelWrite(RGB_BUILTIN, 0, RGB_BRIGHTNESS, 0); // Green
if (digitalRead(GPIO_NUM_3) == LOW) neopixelWrite(RGB_BUILTIN, 0, 0, RGB_BRIGHTNESS); // Blue
if (digitalRead(GPIO_NUM_1) == HIGH) neopixelWrite(RGB_BUILTIN, 0, 0, 0); // Red
if (digitalRead(GPIO_NUM_2) == HIGH) neopixelWrite(RGB_BUILTIN, 0, 0, 0); // Green
if (digitalRead(GPIO_NUM_3) == HIGH) neopixelWrite(RGB_BUILTIN, 0, 0, 0); // Blue
//rtc_gpio_hold_dis(GPIO_NUM_1); // Disable hold if enabled
//rtc_gpio_hold_dis(GPIO_NUM_2);
//rtc_gpio_hold_dis(GPIO_NUM_3);
// Configure wake-up source (EXT1 on multiple pins, any pin LOW)
uint64_t pinMask = (1ULL << GPIO_NUM_1) | (1ULL << GPIO_NUM_2) | (1ULL << GPIO_NUM_3);
esp_sleep_enable_ext1_wakeup_io(pinMask, ESP_EXT1_WAKEUP_ANY_LOW);
// Configure pins and enable deep sleep hold
for (int pin : {GPIO_NUM_1, GPIO_NUM_2, GPIO_NUM_3} ) {
//pinMode(pin, INPUT_PULLUP); // Set as input with pull-up
rtc_gpio_pullup_en((gpio_num_t)pin); // Enable pull-up resistor
rtc_gpio_pulldown_dis((gpio_num_t)pin); // Disable pull-down resistor
rtc_gpio_hold_en((gpio_num_t)pin); // Enable hold for this pin
}
// Enter deep sleep
esp_deep_sleep_start();
}
void loop() {
// This will not be executed
}