• 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

Deep Sleep Variables

Q&A Forum › Category: ESP32 › Deep Sleep Variables
0 Vote Up Vote Down
David A Fischer asked 5 years ago

I am working with some ESP32 deep sleep examples that show the use of — RTC_DATA_ATTR to save data in the RTC memory. 
What about #defines and #includes?  Why are they also not lost when the ESP goes to sleep? 
I want to connect for an HTTP GET to push some data every 30 min. or so and want to sleep to turn power off to the sensors in between (so a resistive soil sensor doesn’t fail early).  I need to know if everything needs to be in setup().
Thanks.

Question Tags: Deep sleep
2 Answers
0 Vote Up Vote Down
Steve Mercer answered 5 years ago

Only variables disappear (Well, reset). Defines are constants so the compiler just sets that value in code. includes just include the code at that point so the compiler compiles that in. So the code itself is there in non volatile memory (Flash). Variables are put into volatile (ie. changeable) memory. Volatile memory (RAM) is set to an unknown state when the ESP goes to sleep. If you need to know what the value was when the ESP went to sleep you need to save it in memory that won’t be wiped out (Like EEPROM or RTC memory)

0 Vote Up Vote Down
David A Fischer answered 5 years ago

Got it – thanks for explaining Steve.

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

  • [eBook Updated] Learn Raspberry Pi Pico/Pico W with MicroPython eBook – Version 1.2 May 26, 2025
  • [New Edition] Build ESP32-CAM Projects eBook – 2nd Edition 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.