Short DeepSleep?

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
wiredcharlie
Normal user
Posts: 57
Joined: 28 Sep 2020, 13:58

Short DeepSleep?

#1 Post by wiredcharlie » 24 Oct 2020, 08:09

I'm using an IR LED / phototransistor to count dial rotations on my water meter. This is battery operated so I am keen to improve it's efficiency. I figured I could avoid having the IR LED on all the time and just check at intervals to see if the dial had moved. The real efficiency would come if I could DeepSleep ESP for about 300mS between checks, however it appears impossible to DeepSleep for less than a second. Is there a way to do a short DeepSleep? Or am I just barking up the wrong tree?

Tony

TD-er
Core team member
Posts: 8752
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Short DeepSleep?

#2 Post by TD-er » 24 Oct 2020, 12:33

Waking from deep sleep is effectively the same as pressing the reset button.
So it will boot and try to reconnect to WiFi.
The processing until WiFi connection is attempted is roughly 500 msec, and a WiFi reconnect does take roughly a second.

So sub-second deep sleep is kinda useless.

You could try to turn off the LED via a GPIO pin.

I think turning off the WiFi may save quite a bit more energy and enabling "eco" mode does even more.
So if you only turn on the WiFi when there is something to report, then you may save more energy compared to short power naps. (pun intended :) )

You can call "wifimode,off" and "wifimode,sta" from the rules to toggle WiFi state.
I have not tested it myself. It may not work as expected as the WiFi reconnect function may turn on the WiFi again.
If so, then a flag must be added in the source code to mark intentionally "not connected"

wiredcharlie
Normal user
Posts: 57
Joined: 28 Sep 2020, 13:58

Re: Short DeepSleep?

#3 Post by wiredcharlie » 24 Oct 2020, 19:36

Thanks!
But I couldn't get "wifimode,off" and "wifimode,sta" to work. Can't find any documentation on this feature either. Please could you point me towards the firmware / docs?

Cheers

Tony

User avatar
Ath
Normal user
Posts: 3517
Joined: 10 Jun 2018, 12:06
Location: NL

Re: Short DeepSleep?

#4 Post by Ath » 24 Oct 2020, 20:16

The actual commands are WiFiConnect and WiFiDisconnect, all commands can be found in the RTD documentation, over here: https://espeasy.readthedocs.io/en/lates ... mmand.html
/Ton (PayPal.me)

TD-er
Core team member
Posts: 8752
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Short DeepSleep?

#5 Post by TD-er » 24 Oct 2020, 20:29

Ath wrote: 24 Oct 2020, 20:16 The actual commands are WiFiConnect and WiFiDisconnect, all commands can be found in the RTD documentation, over here: https://espeasy.readthedocs.io/en/lates ... mmand.html
Well those commands I mentioned are indeed undocumented, but they are present in the code (this time I looked, promise :) )

But as I also have to look into the reconnect behavior, I will also keep this in mind to allow for running in "offline" mode.
Right now the ESP does try to reconnect quite quickly, causing a high CPU load when unable to connect to WiFi and also rather quickly increments the "failed connect attempt" counter, causing reboots on those units that are configured to reboot after N failed attempts.

Post Reply

Who is online

Users browsing this forum: Google [Bot] and 71 guests