DeepSleep

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
kaju
New user
Posts: 4
Joined: 23 Feb 2021, 15:18

DeepSleep

#1 Post by kaju » 23 Feb 2021, 15:36

Hello everyone, I am new here and also new to the field ESPeasy. I have a Wemos d1 mini flashed with espeasy, connected to the wifi and tested the DeepSleep mode. First I would like to mention, I have nothing to do with computer science, I'm more of a hobbyist. What do I want to achieve? The wemos is connected to a powerbank - there is no other way. This should light up an LED in the evening and switch it off again at 9pm. Very important; during the day it should sleep, because of the power consumption. Since the Deepsleep is not definable in time, I would imagine it like this. The wemos is woken up every 60min for 15 sec, checks if a timer is to be processed, for example "LED on from 18 - 21 o'clock", processes this and at 21 o'clock it goes into DeepSleep again for 60 min each time. If the wemos now only wakes up at 18:30, this is also ok. Now I ask the question, does this work according to my imagination? And if so, I would ask further questions.

Thank you first of all.

Translated with www.DeepL.com/Translator (free version)

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

Re: DeepSleep

#2 Post by TD-er » 23 Feb 2021, 20:33

I don't think this is going to last long on a power bank.
The Wemos does take quite a bit of current in deep sleep, since there's a lot of other peripherals (e.g. the USB to serial chip) on board.
Also even if the Wemos was is in the deepest possible sleep, you would still consume rougly 100 uA of current.
When it is "on" it will consume roughly 100 mA (excl. the LED light).

So 15 sec 100 mA + 3585 sec 100 uA.
(15 * 100mA + 3585 * 0.1mA) / 3600 = 0.52 mA on average.
That's just assuming the unit can be put in deep sleep to consume only 100 uA.
But I think it will easily take a few mA due to all other parts on the board, so I think you will end up with something like 2 - 3 mA on average.

With a 1000 mAh power bank you can run roughly 300 hours on 3mA average (assuming the power bank can be discharged far enough)

Another thing with most power banks is that they detect when the current drops and then switch off.
So I would not be surprised your unit will never wake up from deep sleep when powered via a power bank.

N.B. I guess you also have to take the current of the LED into account, which is probably significant.

kaju
New user
Posts: 4
Joined: 23 Feb 2021, 15:18

Re: DeepSleep

#3 Post by kaju » 23 Feb 2021, 21:05

Thank you for, I allow myself to address you with Du,if it is allowed. I thank you for your calculation, yet I would like to correct and mention that I have a meter stuck in between and as soon as the Wemos goes into DeepSleep, almost no consumption is displayed. I try to attach pictures. That would be one thing. Nevertheless, I would like to go this way, as I have already mentioned, that the Wemos wakes up, checks whether a rule would be processed and after processing the rule, goes back to sleep. Whether it remains with the Powerbank, remains to be seen. I just have no plug in the place, otherwise I could save me all this. Of course I understand your concerns and I also have powerbanks, which switch off when there is no consumption. If it would work at all, I could always switch to another power supply.
I would just like to be shown the way how the rule has to look like, since I have no idea on this. Thanks

Translated with www.DeepL.com/Translator (free version)
Attachments
IMG_20210223_205315.jpg
IMG_20210223_205315.jpg (194.74 KiB) Viewed 5013 times
IMG_20210223_205241.jpg
IMG_20210223_205241.jpg (233.07 KiB) Viewed 5013 times

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

Re: DeepSleep

#4 Post by TD-er » 23 Feb 2021, 21:52

That power meter cannot display anything below 1 mA, but that doesn't mean the actual power consumption is less than 1 mA.
Most AD converters have a tolerance of some percent +/- 1 or more digits.
On top of that it is not uncommon an ADC is not entirely linear around 0 or maybe even made a bit "blind" around 0 to avoid recording a lot of noise.

About the rules.
Well they can be rather simple.
You have to take into account you may have 2 situations here.
Either you have a time set (via NTP for example) or you have not (right after a cold boot, no network connection yet).
Apart from those 2 situations you have another one, where you wake from deep sleep.
If the time was set in the last run and the unit remained powered, the time will be set to the last known system time.
However, if you just slept 1 hour, this time will be off for... 1 hour and some due to inaccuracy of the clock crystal.

So to start, I would think it is best to just trigger on the Time#Initialized event.

Code: Select all

on Time#Initialized do
  if %systime%>09:00:00 and %systime%<18:00:00
    // Turn off your light
  else
    // Turn on your light
  endif
  deepsleep,3600  // Go into deep sleep for 1 hour
endon
See also the sysvars page on the ESP node for more system variables and the documentation on rules: https://espeasy.readthedocs.io/en/lates ... Rules.html

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

Re: DeepSleep

#5 Post by Ath » 23 Feb 2021, 22:04

Another issue you'll be facing is how to keep the LED lit when the ESP is in deep sleep. And during the startup from sleep, the pins won't stay in their 'last set state', you can read here (bit of a long read, sorry) about the pin states during startup.
That means you'll have to keep the ESP active to keep the light on, as a LED won't be able to light up from the mentioned 2 micro ampere that can be pulled from a GPIO pin during deep sleep, further shortening the time it can run from the powerbank.
/Ton (PayPal.me)

kaju
New user
Posts: 4
Joined: 23 Feb 2021, 15:18

Re: DeepSleep

#6 Post by kaju » 24 Feb 2021, 11:39

In fact, I also wondered why the LED lights up despite deep sleep. And in addition a blue one, which by nature needs a higher voltage to light up. Anyway, I will run your example times and a big thanks for it. Then I will see how far I get. Ultimately it's a gimmick - so far I've been running this on a Christmas time circuit, these 18/6 circuits, powered by normal battery. But, I turn this on at 7pm, now that it is getting dark later and later, this continues to light for 6h, where I only need 2h. Maybe I explain this a little more. Grandpa has this candle in the hallway stand- at 9 pm he goes to bed, rather before, that's why the at 9 pm can go out. If the lights already at 17 o'clock, the question comes - can you not make it differently - 85 years old :-) . So I tried this solution, which I create, however, only through help. Therefore, again a big thank you.

Translated with www.DeepL.com/Translator (free version)

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

Re: DeepSleep

#7 Post by TD-er » 24 Feb 2021, 11:51

You can also compare the systime with %sunset% and %sunrise% and even apply an offset to it.
See the system variables page on your device for some examples.

kaju
New user
Posts: 4
Joined: 23 Feb 2021, 15:18

Re: DeepSleep

#8 Post by kaju » 24 Feb 2021, 11:56

I'll put some pictures of my previous and relatively ignorant settings in here.
Attachments
1614163993081.jpg
1614163993081.jpg (533.43 KiB) Viewed 4962 times
wemos4.jpg
wemos4.jpg (42.28 KiB) Viewed 4962 times
wemos3.jpg
wemos3.jpg (60 KiB) Viewed 4962 times
wemos2_2.jpg
wemos2_2.jpg (33.35 KiB) Viewed 4962 times
wemos2.jpg
wemos2.jpg (71.5 KiB) Viewed 4962 times
wemos1.jpg
wemos1.jpg (51.14 KiB) Viewed 4962 times

Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 18 guests