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.
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)