Comments on: ESP32 Deep Sleep with Arduino IDE and Wake Up Sources https://randomnerdtutorials.com/esp32-deep-sleep-arduino-ide-wake-up-sources/ Learn ESP8266, ESP32, Arduino, and Raspberry Pi Sun, 10 May 2026 10:00:56 +0000 hourly 1 https://wordpress.org/?v=6.8.5 By: Bill https://randomnerdtutorials.com/esp32-deep-sleep-arduino-ide-wake-up-sources/#comment-1164001 Mon, 23 Feb 2026 22:05:47 +0000 https://randomnerdtutorials.com/?p=81663#comment-1164001 Hello

I used the first sketch: TimerWakeUp sketch.
I Powered the ESP32 with 3.3V on that pin. I measured 41mA during wake time and 4mA during sleep time. It’s not very useful for me as I want to run the ESP32 with a battery.

Any ideas are welcome!

]]>
By: Sara Santos https://randomnerdtutorials.com/esp32-deep-sleep-arduino-ide-wake-up-sources/#comment-1120794 Sat, 08 Nov 2025 15:57:10 +0000 https://randomnerdtutorials.com/?p=81663#comment-1120794 In reply to Philippe.

Yes.
That is true.
The reason we mention that for beginner programmers is that often they put all their working code on the loop(), and activate the wake-up sources in the setup(), so the loop() never runs.

But, yes, I should make things for clear in the tutorial.

Thanks for your comment.

Regards,
Sara

]]>
By: Philippe https://randomnerdtutorials.com/esp32-deep-sleep-arduino-ide-wake-up-sources/#comment-1120788 Sat, 08 Nov 2025 15:42:56 +0000 https://randomnerdtutorials.com/?p=81663#comment-1120788 Hi Sara and Rui,
My current project means that I spend a lot of time on your site, and each time I discover a little more about the scope of your work (and everything else that can be gained from reading the responses to the countless comments and questions !).
Today, I am posting a comment regarding deep sleep, not for intended publication but for your information, as I have just made a discovery (I doubt I am teaching you anything new, but one never know?).
You say, ‘you need to write all your tasks in the setup()’. Actually, no! An AI put me on the right track by helping me with some code using deep sleep (wake-up by watchdog). You can do lots of things in the loop(), provided that it is the loop() that triggers the sleep mode, as needed. This means that you can write code as normal. At least in the case of a watchdog wake-up, but I don’t see why it would be any different for other wake-up sources.

Here is an light example of what works for me. You will find lots of traces of your ESP-NOW tutorials, which have helped me immensely, so receive thousand thanks.
Philippe

#include <esp_now.h>
#include <WiFi.h>
#include “esp_sleep.h”

#define BOARD_ID 1
#define RX1_PIN 20
#define TX1_PIN 21

#define minDistance 10
#define maxDistance 700

#define uS_TO_S_FACTOR 1000000ULL /* Conversion factor for micro seconds to seconds /
#define SLEEP_DURATION 5 /
Deep sleep duration in seconds */

uint16_t measure = 999;
uint8_t broadcastAddress[] = {0xEC, 0x62, 0x60, 0x32, 0x65, 0x80};

typedef struct struct_message { int id; int measure; } struct_message;
struct_message LD2420;

esp_now_peer_info_t peerInfo;

unsigned long lastTime = 0;
const uint16_t updateTimer = 500;

volatile bool canSend = true;
uint16_t lastMeasureSent = 999;

void OnDataSent(const uint8_t *mac_addr, esp_now_send_status_t status) {
canSend = true;
}

void setup() {
Serial1.begin(115200, SERIAL_8N1, RX1_PIN, TX1_PIN);
WiFi.mode(WIFI_STA);
WiFi.disconnect();
esp_now_init();
esp_now_register_send_cb(OnDataSent);

memcpy(peerInfo.peer_addr, broadcastAddress, 6);
peerInfo.channel = 0;
peerInfo.encrypt = false;
esp_now_add_peer(&peerInfo);
delay(100);
}

void processSensorLine() {
while (Serial1.available() > 0) {
String line = Serial1.readStringUntil(‘\n’);
line.trim();
if (line.startsWith(“Range “)) {
String distanceStr = line.substring(6);
int d = distanceStr.toInt();
if (d > minDistance && d < maxDistance) {
measure = d; // witness RED on peer
} else {
measure = 0; // witness GREEN
}
}
}
if(!Serial1.available()){
if (measure != 0 && (measure < minDistance || measure > maxDistance)) {
measure = 999; // invalid or transmission failure / witness ORANGE
}
}
}

void loop() {
if(millis() – lastTime >= updateTimer){
lastTime = currentMillis;

processSensorLine(); // reading LD2420

if ((measure != lastMeasureSent) && canSend) {
canSend = false;
LD2420.id = BOARD_ID;
LD2420.measure = measure;

esp_now_send(0, (uint8_t*)&LD2420, sizeof(LD2420));
lastMeasureSent = measure;
}

if(measure == 0){
while(Serial1.available()) Serial1.read();
esp_sleep_enable_timer_wakeup(SLEEP_DURATION * uS_TO_S_FACTOR);
esp_deep_sleep_start();
}

yield();

}
}

]]>
By: Sara Santos https://randomnerdtutorials.com/esp32-deep-sleep-arduino-ide-wake-up-sources/#comment-1085153 Sat, 23 Aug 2025 17:23:54 +0000 https://randomnerdtutorials.com/?p=81663#comment-1085153 In reply to Sergio83.

Great!
I’m glad it is working now!

]]>
By: Sergio83 https://randomnerdtutorials.com/esp32-deep-sleep-arduino-ide-wake-up-sources/#comment-1084129 Thu, 21 Aug 2025 12:55:36 +0000 https://randomnerdtutorials.com/?p=81663#comment-1084129 In reply to Sara Santos.

Ola Sara,
I’ve got it, was not so simple that only replace the statement, but you were of a very strong help!

Obrigadissimo …

]]>
By: Sara Santos https://randomnerdtutorials.com/esp32-deep-sleep-arduino-ide-wake-up-sources/#comment-1083699 Wed, 20 Aug 2025 10:53:44 +0000 https://randomnerdtutorials.com/?p=81663#comment-1083699 In reply to Sergio83.

Hi.
In case of the ESP32 C3 super mini, there are a few differences on the deep sleep functions you can use.
We cover that subject in our ESP32C3 guide: https://randomnerdtutorials.com/getting-started-esp32-c3-super-mini/
Scroll down to the section called: Sleep Modes with the ESP32-C3 Super Mini
Basically, for external wake-up with the ESP32-C3 super mini, you need to use this function instead: esp_deep_sleep_enable_gpio_wakeup()
More info here: docs.espressif.com/projects/esp-idf/en/v5.0/esp32c3/api-reference/system/sleep_modes.html#_CPPv433esp_deep_sleep_enable_gpio_wakeup8uint64_t33esp_deepsleep_gpio_wake_up_mode_t

I hope this helps.

Regards,
Sara

]]>
By: Sergio83 https://randomnerdtutorials.com/esp32-deep-sleep-arduino-ide-wake-up-sources/#comment-1083477 Tue, 19 Aug 2025 14:58:36 +0000 https://randomnerdtutorials.com/?p=81663#comment-1083477 Hello everyone,

I’m planning to use the ESP32 C3-based board with a 1.44″ TFT from Spotpear as a standalone device.
This board has a Lipo battery charging circuit, which is perfect for a standalone device. Since the battery capacity is limited, I want to implement the DeepSleep feature.

The only RTC GPIO available on the board’s connector is GPIO1.

After searching Google for miles to see if this GPIO can be used for this purpose on this board, I remain perplexed. Some sites say it’s possible, others say it’s not because it’s used internally for another device on the board.

So my first question is: with this board, can I use GPIO1 as an RTC?

I’ve been working in parallel to clear the ground with a test sketch. It’s the one from “Random Nerd Tutorials” for a wake-up with a single GPIO (Deep Sleep with External Wake-Up). So, with the EXT0 option.
After making a single modification: replacing the GPIO of the Wake Up pin from “33” to “1”, i.e.:
#define WAKEUP_GPIO GPIO_NUM_1 // Only RTC IO are allowed – ESP32 Pin example
I compiled with the board type ESP32C3 Dev Module (recommended by Spotpear).
I get the following compilation errors:

D:\MY ENVIRONMENT\DEVELOPMENTS\ARDUINO\PROJECTS in TESTING\DeepSleep\external_wakeup\external_wakeup.ino: In function ‘void setup()’:
D:\MY ENVIRONMENT\DEVELOPMENTS\ARDUINO\PROJECTS in TESTING\DeepSleep\external_wakeup\external_wakeup.ino:71:3: error: ‘esp_sleep_enable_ext0_wakeup’ was not declared in this scope; did you mean ‘esp_sleep_enable_bt_wakeup’?
71 | esp_sleep_enable_ext0_wakeup(WAKEUP_GPIO, 1); //1 = High, 0 = Low
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
| esp_sleep_enable_bt_wakeup
D:\MY ENVIRONMENT\DEVELOPMENTS\ARDUINO\PROJECTS in TESTING\DeepSleep\external_wakeup\external_wakeup.ino:75:3: error: ‘rtc_gpio_pullup_dis’ was not declared in this scope; did you mean ‘gpio_pullup_dis’?
75 | rtc_gpio_pullup_dis(WAKEUP_GPIO);
| ^~~~~~~~~~~~~~~~~~~
| gpio_pullup_dis
D:\MY ENVIRONMENT\DEVELOPMENTS\ARDUINO\PROJECTS in TESTING\DeepSleep\external_wakeup\external_wakeup.ino:76:3: error: ‘rtc_gpio_pulldown_en’ was not declared in this scope; Did you mean ‘gpio_pulldown_en’?
76 | rtc_gpio_pulldown_en(WAKEUP_GPIO);
| ^~~~~~~~~~~~~~~~~~~~
| gpio_pulldown_en
exit status 1

Compilation error: ‘esp_sleep_enable_ext0_wakeup’ was not declared in this scope; did you mean ‘esp_sleep_enable_bt_wakeup’?

After checking the include header code, these objects are indeed declared!

Can you shed some light on the origin of these compilation errors?
Thank you in advance for your help.

]]>
By: Sara Santos https://randomnerdtutorials.com/esp32-deep-sleep-arduino-ide-wake-up-sources/#comment-1076671 Thu, 31 Jul 2025 17:46:52 +0000 https://randomnerdtutorials.com/?p=81663#comment-1076671 In reply to Robert May.

Did you try adding the following line:
rtc_gpio_hold_en(4);

After setting the GPIO off, right before putting the board in deep sleep?

Regards,
Sara

]]>
By: Robert May https://randomnerdtutorials.com/esp32-deep-sleep-arduino-ide-wake-up-sources/#comment-1076617 Thu, 31 Jul 2025 15:25:11 +0000 https://randomnerdtutorials.com/?p=81663#comment-1076617 Hi Rui and Sara.
Thank you for your excellent tutorials.
I have combined 2 of your projects together (Time-lapse saved to SD card and Motion Detection using Deep Sleep. I now have a time-lapse camera that saves to an SD card and goes into deep sleep after a period of time. I would have thought that the flashlight led would shut down during deep sleep but it stays on and as I need to run this off batteries, I don’t want it running. I have tried using code with no effect. Any ideas please?

]]>
By: Sara Santos https://randomnerdtutorials.com/esp32-deep-sleep-arduino-ide-wake-up-sources/#comment-1058109 Mon, 16 Jun 2025 16:04:33 +0000 https://randomnerdtutorials.com/?p=81663#comment-1058109 In reply to WJCarpenter.

Hi
It is not necessary, but guarantees some stability.
Regards,
Sara

]]>