• 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

🎓 [New Tutorial] Experimenting with ESP32 sleep modes

Q&A Forum › Category: ESP32 › 🎓 [New Tutorial] Experimenting with ESP32 sleep modes
3 Vote Up Vote Down
Steph asked 5 years ago

Hi everyone,

The other day, I was reading a discussion about ESP32 sleep modes. And it seemed to me that things were not very clear, especially about the light sleep mode. So I jumped at the opportunity to do some tests of my own, which I’m sharing with you today in the form of a comprehensive tutorial to try to clear up the fog.

Why Is This Tutorial Of Interest To You?

My initial intention was to do some experimentation with the different sleep modes of the ESP32. But while making the circuit that served as a support to illustrate my experiments, it appeared to me that I could take advantage of it to detail a lot of other things. And notably by taking care to address issues I’ve encountered in other RNT Lab posts over the last few weeks.

So I guess that even if you’re not primarily interested in sleep modes, you’ll find a lot of interesting things in this tutorial that you can use in many other applications. Take a look at it, I’m sure you’ll find something to suit your needs:

Experimenting with ESP32 sleep modes

To illustrate my point, I chose to implement a rather simple circuit:

Experimental support circuit

But through this relatively simple exercise, I propose to explore some programming techniques that you can reproduce in your own projects, to properly handle buttons, or to control the time flow and regulate the frequency of execution of the main loop, or make your microcontroller able to perform several tasks simultaneously. The ultimate goal of this tutorial will be to address what makes the big difference between the different ESP32 sleep modes.

As a result, this tutorial is finally quite dense, as I tried to detail all the points I covered to be as clear as possible. I hope that I succeeded and that you will be able to apply these concepts in your own projects.

I hope you’ll enjoy it, and that I didn’t make it too boring. I hope that I’ve gone into enough detail to make sure you understand it. If there are still some grey areas, I encourage you to come and discuss with me on this thread. I will be happy to answer your questions and help you resolve your issues.

Question Tags: Tutorial
9 Answers
1 Vote Up Vote Down
Rui Santos Staff answered 5 years ago

Thanks for sharing! It’s very detailed and helpful.
Regards,
Rui

1 Vote Up Vote Down
Sara Santos Staff answered 5 years ago

That’s great!
Thanks for sharing that!
I’ve read all parts of your tutorial and I’ve learned a lot of new stuff. Thank you.
I’ll try to come up with a summary of your tutorial to post on the Random Nerd Tutorials website.
Regards,
Sara

1 Vote Up Vote Down
Steph answered 5 years ago

@Rui: Thank you for your positive feedback.

@Sara
: I’m very happy that you could find some things to learn (I wonder which ones) 🙂
And thanks again for your upcoming post on RNT, which should give the turorial some visibility.

It makes me want to do more anyway 😉

Regards,
Steph

0 Vote Up Vote Down
Jean Pierre Daviau answered 5 years ago

Delightfull.

 

Great tutor.

0 Vote Up Vote Down
Steph answered 5 years ago

Thank you so much Jean-Pierre.
I’m trying to do my best…
But I’m not immune to making mistakes, like everyone else.
I’m like all of you: a learner.
I just try to take detailed notes on what I do 😉

0 Vote Up Vote Down
clark answered 4 years ago

Excellent, still trying to absorb it all.  🙂  On the https://m1cr0lab-esp32.github.io/sleep-modes/hibernation-mode/ page in setup() I added updateLED(); above flashActiveLED();  Coming out of sleep I was getting randomly the green light coming on.  It would instantly extinguish after pressing the shiftButton though.  I’m not sure why but this quick hack seemed to do the job.  I put a copy of the function prototype up by your one too, seeing as we were using it before it being defined: updateLED();

0 Vote Up Vote Down
Steph answered 4 years ago

That’s weird… you shouldn’t need to call updateLED().
Are you sure you got the ledIndex value at the right address?

ledIndex = EEPROM.read(0);

In the hibernate() function, are you sure you have done the commit so that the ledIndex backup is effective?

EEPROM.write(0, ledIndex);
EEPROM.commit();

Perhaps try writing to another address in the EEPROM (making sure to reserve enough area to reach that address).

Actually, it’s been a while since I wrote this tutorial… and on the ESP32, the EEPROM library (which was an emulation of what is found on Arduino boards) is deprecated. You can try to use the Preferences library which is now recommended. This library is provided with examples and is very easy to use.

Anyway, thanks for your feedback  🙂
It’s always nice to know that the tutorial is useful to some people.

Regards,
Steph

0 Vote Up Vote Down
Kent McNaughton answered 11 months ago

A truly great deep-dive into sleep with the ESP32. Thank you. 
I especially liked your notes and reference to the espressif site on the hibernation wakeup stub. I may want to use that method with the SignificationMotionDetected alert from a BNO085 IMU.

0 Vote Up Vote Down
Steph answered 11 months ago

Thanks for your feedback Kent.
I’m glad I could give you a few keys to better understand the ESP32 sleep modes.

Kind Regards,
Steph

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.