Ran into an issue (of course!) with the deep sleep not accepting a number large enough (would like to wake up once or twice a day only). Need to get creative
So the approach I was considering was to sleep for as long as it can and check and increment a persistent counter first-thing on wake up. It will serve as a multiplier to get us to a desired sleep duration without wasting energy on wifi connection and server comms.
Now, how to make this counter survive the reset. I found 2 options:
- Low-level EEPROM
- Write a small file on SPIFFS
With EEPROM it's nice and small, although a little low-level. I'd like to understand if I should avoid any specific memory segments on purpose? E.g. with the anticipation that I will also have a generic config file there in the future too, so they don't clash.
With SPIFFS it's operating with a higher level API and easy to use. Maybe an overkill (if EEPROM path is safe enough?)
An important consideration - need a way to reset a counter for the first-time deployment. Thought of:
- Wire a button (long-hold), or a (dip) switch which would be read and EEPROM/SPIFFS file erased if a condition detected.
- Any other nice trick maybe?
Someone did mention the max sleep they could get out of esp8266 was around half an hour only, suggesting it was a 31 bit integer or something only? Can someone share their experience with that?