Sharing: Sketch developed to find time spent in Deep Sleep:
Deep Sleep Elapsed Time Sketch
Regards,
William
Good Morning Sara,
Are micros and millis effected by Deep Sleep? Used a stop watch on cellphone to time deep dleep; sleep_time is off a significant number of seconds. Not sure if it is my code or deep sleep shuts down micros and millis.
Regards,
William
I was asking about that.. How many off seconds?
Or does it depend on the length of time?
Sara,
My apologies for the very late response.
My reults were very inconsistant; off about every third button press more than 40,000 seconds for a deep sleep tme of less than 10 seconds. Have resolved the issue and updated the Github Gist
Other than switch bounce; I am at a loss to explain.
ChatGPT response to my prompt:
Please explain:
// Configure sleep mode esp_sleep_pd_config(ESP_PD_DOMAIN_RTC_PERIPH, ESP_PD_OPTION_ON); esp_sleep_pd_config(ESP_PD_DOMAIN_RTC_SLOW_MEM, ESP_PD_OPTION_ON); esp_sleep_enable_ext1_wakeup(1ULL << switchPin, ESP_EXT1_WAKEUP_ANY_HIGH);
The code snippet you provided is written in C/C++ and is configuring the sleep mode settings for an ESP32 microcontroller. Here’s what each line of code is doing:
esp_sleep_pd_config(ESP_PD_DOMAIN_RTC_PERIPH, ESP_PD_OPTION_ON);
This line of code configures the power domain settings for the RTC (Real-Time Clock) peripheral of the ESP32. It turns on the power domain for the RTC peripheral, which enables the RTC to continue running during the sleep mode.esp_sleep_pd_config(ESP_PD_DOMAIN_RTC_SLOW_MEM, ESP_PD_OPTION_ON);
This line of code configures the power domain settings for the RTC slow memory of the ESP32. It turns on the power domain for the RTC slow memory, which enables the memory to continue running during the sleep mode.esp_sleep_enable_ext1_wakeup(1ULL << switchPin, ESP_EXT1_WAKEUP_ANY_HIGH);
This line of code enables the external wakeup feature of the ESP32 using the switchPin as a trigger. It configures the switchPin to trigger the wakeup when the pin is pulled high. The1ULL << switchPin
part of the code shifts the binary value of 1 to the left by switchPin bits, which sets the corresponding bit in the register to enable the external wakeup. TheESP_EXT1_WAKEUP_ANY_HIGH
parameter indicates that the wakeup can be triggered by any edge (rising or falling) of the pin voltage.
Regards,
William