• Skip to main content
  • Skip to primary sidebar

RNTLab.com

The Ultimate Shortcut to Learn Electronics and Programming with Open Source Hardware and Software

  • Courses
  • Forum
    • Forum
    • Ask Question
  • Shop
  • Account
  • Blog
  • Login

Need to find elapsed time in Deep Sleep?

Q&A Forum › Need to find elapsed time in Deep Sleep?
0 Vote Up Vote Down
William Lucid asked 2 years ago

Sharing:  Sketch developed to find time spent in Deep Sleep:

Deep Sleep Elapsed Time Sketch

Regards,
William

Question Tags: Deep sleep, ESP32
5 Answers
0 Vote Up Vote Down
Sara Santos Staff answered 2 years ago

Thank you for sharing.
Simple code, but useful.
Regards,
Sara

0 Vote Up Vote Down
William Lucid answered 2 years ago

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

0 Vote Up Vote Down
Sara Santos Staff answered 2 years ago

I was asking about that.. How many off seconds?
Or does it depend on the length of time?

0 Vote Up Vote Down
William Lucid answered 2 years ago

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:

  1. 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.
  2. 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.
  3. 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. The 1ULL << 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. The ESP_EXT1_WAKEUP_ANY_HIGH parameter indicates that the wakeup can be triggered by any edge (rising or falling) of the pin voltage.

 

Regards,

William

0 Vote Up Vote Down
Sara Santos Staff answered 2 years ago

Thanks for the follow-up.
Regards,
Sara

Primary Sidebar

Login to Ask or Answer Questions

This Forum is private and it’s only available for members enrolled in our Courses.

Login »

Latest Course Updates

  • [New Edition] Build ESP32-CAM Projects eBook – 2nd Edition April 16, 2025
  • [eBook Updated] Learn ESP32 with Arduino IDE eBook – Version 3.2 April 16, 2025

You must be logged in to view this content.

Contact Support - Refunds - Privacy - Terms - MakerAdvisor.com - Member Login

Copyright © 2013-2025 · RandomNerdTutorials.com · All Rights Reserved

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.