The Wiki says that the deep sleep current of the XIAO ESP32C3 should be ‘about’ 43uA.
With the code below, which wakes up the XIAO, flashes an LED and goes back to sleep the deep sleep current is 115uA.
The line;
esp_sleep_pd_config(ESP_PD_DOMAIN_RTC_PERIPH, ESP_PD_OPTION_OFF);
Makes no difference to the deep sleep current, so why is the deep sleep current so high ?
/*******************************************************************************************************
Tested on Seeduino XIAO ESP32C3
Program Operation - This program is for the Seeeduino XIAO ESP32C3. The program is woken up by the RTC
timer after the configured number of seconds, flashes the LED for a while then goes back to sleep.
To use the sleep mode without the USB lead connected you need to comment out the #define DEBUG
line so that all the Serial operations are excluded from the program.
Sleep current using this mode of RTC wakeup was 115uA.
Serial monitor baud rate is set at 115200.
*******************************************************************************************************/
#define uS_TO_S_FACTOR 1000000ULL //Conversion factor for micro seconds to seconds
#define TIME_TO_SLEEP 15 //Time ESP32 will go to sleep (in seconds)
#define LED1 D6 //external LED on this pin
//#define DEBUG //enable this define to turn on Serial prints
void loop()
{
led_Flash(10, 500); //10 seconds slow LED flashes show wakeup from deep sleep
#ifdef DEBUG
Serial.println("Setup ESP32 to sleep for every " + String(TIME_TO_SLEEP) + " Seconds");
Serial.flush();
#endif
esp_sleep_enable_timer_wakeup(TIME_TO_SLEEP * uS_TO_S_FACTOR);
//The following command is intended to turn off all RTC peripherals in deep sleep.
esp_sleep_pd_config(ESP_PD_DOMAIN_RTC_PERIPH, ESP_PD_OPTION_OFF);
esp_deep_sleep_start();
#ifdef DEBUG
Serial.println("This will never be printed");
#endif
led_Flash(100, 25); //LED will (should) never flash
}
void led_Flash(uint16_t flashes, uint16_t delaymS)
{
uint16_t index;
for (index = 1; index <= flashes; index++)
{
digitalWrite(LED1, HIGH);
delay(delaymS);
digitalWrite(LED1, LOW);
delay(delaymS);
}
}
void setup()
{
pinMode(LED1, OUTPUT);
led_Flash(2, 125); //two quick LED flashes to indicate program start
#ifdef DEBUG
Serial.begin(115200);
Serial.println(F("7_Deep_Sleep_Timer_Wakeup Starting"));
#endif
}