Skip to content

Instantly share code, notes, and snippets.

@mattgaidica
Created October 10, 2024 14:14
Show Gist options
  • Save mattgaidica/b3fffc20bad6a1a91732f29b411f3009 to your computer and use it in GitHub Desktop.
Save mattgaidica/b3fffc20bad6a1a91732f29b411f3009 to your computer and use it in GitHub Desktop.
// Example to enter deep sleep after 10 seconds and wake up with a GPIO pin
void setup() {
// Initialize Serial for debugging
Serial.begin(115200);
delay(1000); // Wait for the serial to initialize
// Set GPIO pin for wakeup
esp_sleep_enable_ext0_wakeup(GPIO_NUM_0, 0); // Wake on low signal on GPIO 0
// Start deep sleep
Serial.println("Entering deep sleep mode in 10 seconds...");
delay(10000); // Wait 10 seconds
esp_deep_sleep_start(); // Enter deep sleep mode
}
void loop() {
// The device will never reach here as it goes into deep sleep
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment