Flexible programmable deep sleep possible?
(This is a rewrite of another post, which I now deleted, as I had not seen this collection list)
what I would like is the following: deep sleep from 07:00-23:00, active from 23:00 to 07:00 (of course time frame adjustable).
I want to use this for a PIR motion sensor system which shouldn't do anything during daytime. I can leave the ESP "on" during daytime but I prefer to have it to sleep to use as little energy as possible.
I have already found that deep sleep on the ESP is held by a uint32_t, with a max value of 4,294,967,295 microseconds which is slightly over 1 hour. Some people/posts report it sometimes doesn't work like a uint but like an int being 31 bits, so slightly over half an hour. I assume that's an error in software or hardware implementations, but actually I don't know.
So a direct option for "my demands" is not possible. I have seen posts on using an external RTC, or something like having the esp wake up every 60 minutes, update a counter, and go back to sleep.
What I am thinking off is more in the rules section.
There are time based rules so I wanted to know if something is possible like :
Code: Select all
On Clock#Time=All,07:00 do // every day at 07:00 hours do ...
"set esp easy to deep sleep and wake up every 30 minutes to check the time"
endon
On Clock#Time=All,23:00 do // every day at 23:00 hours do ...
"get esp easy from deep sleep and switch on necessary functions"
endon
But that would also require a flexible programmable deep sleep. Is that possible?
As a reference: Espimatic, another ESP8266 ino, uses a variable "backdoor" that can be checked and read/set. On every wakeup this value is checked/read in pimatic from a variable but could be initiated to other controllers using the protocols, or via rules on "this" or another espeasy. It will also help preventing you from "bricking" an espeasy: simply toggle the variable on your controller and the esp stays awake. This specific code can be found
here.