Hi all, I'm currently learning to use the ESP32 Cam board and have been trying to implement a deep sleep state for it. Whenever it goes into deep sleep, the LED light (GPIO 4 Pin) will become dimly lit until the deep sleep timer resets. This defeats the purpose of using a deep sleep because the LED is likely to draw more power over-time. I'm unsure of what's the cause of this issue after Googling for the past hour. Would appreciate some suggestions on what I can do to fix this issue. Please refer to the image and code snip below!
void goToDeepSleep() {
Serial.println("Going to sleep...");
digitalWrite(4, LOW); // Extra measure to turn the light off before going to sleep
// Deep sleep for x Minutes (LED starts to become dimly lit here)
esp_sleep_enable_timer_wakeup(PHOTO_INTERVAL * 60 * 1000000);
esp_deep_sleep_start();
}
Hi Idahowalker,
Thank you for the swift reply!
I've had a look at the resources you've provided but I'm still quite lost because I'm very new to Arduino and microcontrollers in general.
Would you mind going into more details about what you mean by setting the GPIO state, and the 2nd solution of setting an RTC pin?
Thanks again!
This is the right thing to do, but for some reason it is not working as expected.
digitalWrite(4, LOW); // Extra measure to turn the light off before going to sleep
If you look at the schematic for the ESP32-CAM, the LED is driven by a transistor, via GPIO4, which has a 47K pullup. That suggests that GPIO4 is going into a high impedance state (e.g. INPUT) during sleep, and the pullup resistor is enough to weakly activate the LED.
Hi jrmington,
Thank you for providing the schematic and talking about the GPIO04!
My solution was to input this line of code right before the sleep function and it worked flawlessly!
Appreciate the kind assistance!
rtc_gpio_isolate(GPIO_NUM_4);
Final code:
void goToDeepSleep() {
Serial.println("Going to sleep...");
digitalWrite(4, LOW); // Extra measure to turn the light off before going to sleep
rtc_gpio_isolate(GPIO_NUM_4); // <<<<<<<<<<< Added code
// Deep sleep for x Minutes (LED starts to become dimly lit here)
esp_sleep_enable_timer_wakeup(PHOTO_INTERVAL * 60 * 1000000);
esp_deep_sleep_start();
}
Evidently the "enable hold" operation of rtc_gpio_isolate() is the key:
Helper function to disconnect internal circuits from an RTC IO This function disables input, output, pullup, pulldown, and enables hold feature for an RTC IO.