DeepSleep trouble

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
bison00
New user
Posts: 3
Joined: 26 May 2021, 21:05

DeepSleep trouble

#1 Post by bison00 » 26 May 2021, 23:29

Hi all,

i have a problem with a very simple task. Send the ESP with the Config Weppage to maximum of sleeptime e.g. 12086 sec then Awake for 15 sec read the ADC Port and send it to Fhem. I can do what ever after 50 Minutes the ESP reboot and send the ADC Input to FHEM. I read many information about Deepsleep but I don't find a Solution.

Can you help me?

Thanks in Advanced

Bison

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

Re: DeepSleep trouble

#2 Post by TD-er » 27 May 2021, 08:52

What build are you using?
On older versions of the esp8266/Arduino library, the max sleep time was roughly 71 minutes.
On newer builds the max. sleeptime is slightly variable, depending on a few factors, but at least it should be in the order of 3 - 3.5 hours.
This should fit your example of 12086 seconds by the way.

N.B. there is some issue with some boards caused by a change made on 2020 Dec. 8. See https://github.com/letscontrolit/ESPEasy/issues/3638
So you might want to try a build from before that date.

bison00
New user
Posts: 3
Joined: 26 May 2021, 21:05

Re: DeepSleep trouble

#3 Post by bison00 » 27 May 2021, 12:20

Hi,

I use Build 20210114mega and check the with different Boards D1 mini, ESP 12F I see that the ESP Webpage/Config me offers different max Sleep time so I think the general Functions Work. But the Wake up to Check the Time for the Internal Timer with the NTP is like a Boot and so the advantage from saving Energy is lost. I only Work on Standard Sensor and with Rules.

For a better understanding I try to check the humidity of the plants 3 or 4 Times a Day. And the Deepsleep should save the battery.

Is there a Register I have to activate for DeepSleep max?

regards

Werner

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

Re: DeepSleep trouble

#4 Post by TD-er » 27 May 2021, 12:41

Can you please try a build from before the mentioned Dec. 8 2020?
It appears that specific change I mentioned does do some funky things to boards not needing that specific change. (as discussed in that issue I linked)

So it might very well be that your board also behaves strangely with the patch I added then.

As discussed in that issue, not only waking up too early (as you now experience) but also the much higher sleep current is bad for battery life, so please let me know if an older build also fixed your issue with waking too early.

I will either revert that change, or add a flag to toggle its functionality in a new build. (which I hope to have in the next 5 - 7 days as I'm also working hard on the reported WiFi issues)

ezparce
Normal user
Posts: 12
Joined: 13 Jul 2020, 09:18

Re: DeepSleep trouble

#5 Post by ezparce » 16 Jun 2021, 08:04

Hi, I also find some problem with DeepSleep (ESPEasy_ESP82xx_mega-20210503.zip).
When I set Sleep awake time=20 and Sleep time= 7200, the real sleep time is always less than one hour (beetween 3128 and 3136 s).
I tried many values for sleep time beetween 7000 and 12000. No change. The max sleep time stays shorter than expected.
Any idea?

This behaviour is also true when I call DeepSleep from a rule (command).
When in deep sleep, power is 18 µA (normal).

Many thanks

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

Re: DeepSleep trouble

#6 Post by TD-er » 16 Jun 2021, 08:48

As I already reverted the DeepSleep code, can you try a build based on the latest code?

And while you're at it, you can even beta-test this new feature of web-flashing :)

https://td-er.nl/ESPEasy/
The builds there I made yesterday.

ezparce
Normal user
Posts: 12
Joined: 13 Jul 2020, 09:18

Re: DeepSleep trouble

#7 Post by ezparce » 16 Jun 2021, 10:32

I just tried web-flashing. It's GREAT! Very easy and straightforward.

Thanks for this new feature :P

I'll let you know if Deepsleep is correct now :)

ezparce
Normal user
Posts: 12
Joined: 13 Jul 2020, 09:18

Re: DeepSleep trouble

#8 Post by ezparce » 18 Jun 2021, 06:25

Unfortunately, the problem is stil there. Max DeepSleep time is around 3130 s whatever the value for sleeptime :(

Any idea?

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

Re: DeepSleep trouble

#9 Post by TD-er » 18 Jun 2021, 08:39

That's strange.

I just checked the WebUI value here on my breadboard (as "unit" next to the Sleep Time setting)
It states: [sec (max: 13713)]
This value is the value I let the SDK compute and may differ on each reload. I don't know the exact reason why it changes, but it is roughly 14000 +/- 300
This 10 minute difference does feel a bit strange, but ok...

Still the original max. deep sleep time was roughly 71 minutes (2^32 micro seconds)
But now you don't even seem to get to 1 hour.

Is the ESP still connected to the PC? Could it receive something from the PC via USB?
If so, can you power it via some external power supply, just to make sure there isn't some kind of power-save feature on the PC putting devices in some low power mode which does trigger something unintentionally to the ESP.

Edit:
Just read through this issue: https://github.com/esp8266/Arduino/issu ... -703259665
Seems like more people run into these issues.
Can you try 70 minutes to see if that does work if you actually set it to that value? (4200 sec)
I think the old max. you could set in ESPEasy was even slightly lower, so maybe also try 4100 sec.

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

Re: DeepSleep trouble

#10 Post by TD-er » 18 Jun 2021, 12:17

By browsing through those deep sleep issues on esp8266/Arduino I noticed a few recurring things in all comments:

- Max deep sleep time is unreliable and changes
- Instant deep sleep (which we call) does expect WiFi to be off
- deepSleep() does turn off WiFi safely. (whatever that means)

So I tried to mitigate these all by reducing the max. deep sleep time by roughly 5% and turn off WiFi ourselves and calling the deepSleep() function.

Can you perhaps try this PR: https://github.com/letscontrolit/ESPEasy/pull/3691

ezparce
Normal user
Posts: 12
Joined: 13 Jul 2020, 09:18

Re: DeepSleep trouble

#11 Post by ezparce » 19 Jun 2021, 11:10

Trying to understand the problem, I picked up a brand new ESP12F. I flash ESP_Easy_mega_20210503_normal_ESP8266_4M1M.bin.
No sensor, no controller. Only one rule for sending one field/value to Thingspeak.
GPIO16 connected to RST.
Powered by LiFe (3.3V) battery.

Using the same hardware and firmware, I try three different sleep time values: one hour, ten minutes and one minute.

Here is the test report:

1/ When Sleep Time is set to 3600 s:
Sleep time setting 3600s.jpg
Sleep time setting 3600s.jpg (12.67 KiB) Viewed 14327 times
Real time beetween wakeup is ~2870 s (~12% error). This value is stable over time.
Sleep time 3600s.jpg
Sleep time 3600s.jpg (32.55 KiB) Viewed 14327 times
2/ When Sleep Time is set to 600 s:
Sleep time setting 600s.jpg
Sleep time setting 600s.jpg (11.8 KiB) Viewed 14327 times
Real time beetween wakeup is 523 s (~13% error). This value is very stable over time.
Sleep time 600s.jpg
Sleep time 600s.jpg (92.04 KiB) Viewed 14327 times
3/ When Sleep Time is set to 60 s:
Sleep time setting 60s.jpg
Sleep time setting 60s.jpg (32.54 KiB) Viewed 14327 times
Real time beetween wakeup is ~54 s (~10% error).
Sleep time 60s.jpg
Sleep time 60s.jpg (40.49 KiB) Viewed 14327 times
My conclusion is whatever the sleep time value is, real sleep time is shorter than expected.
I'll let you know if I can reach more than one hour.

ezparce
Normal user
Posts: 12
Joined: 13 Jul 2020, 09:18

Re: DeepSleep trouble

#12 Post by ezparce » 20 Jun 2021, 11:55

My last tests shows that the abnormal behavior is due to the revision software of ESPEasy Mega.
When using ESP_Easy_mega_20210503_normal_ESP8266_4M1M.bin, the maximum sleep time is around 3160 s, whatever the sleep time is.
This is true on both ESP12F and Wemos boards.

As I remember that I used very long deep sleep last year, I decided to downgrade firmware to "Binary Filename: ESP_Easy_mega_20200608_normal_ESP8266_4M1M".
This time, both boards recovers a normal behavior. When sleep time value is set to 12.200, real sleep time is 10.735 s.

What do you think about this results?

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

Re: DeepSleep trouble

#13 Post by TD-er » 20 Jun 2021, 13:22

That's interesting to see the real sleep time is off by roughly 10%.
I do know that the sleep time does run at a different frequency compared to a normal run.
But I don't know if it also runs from a different oscillator.
The crystal (usually 26 MHz) must be quite stable to provide a stable WiFi connection. So if that oscillator is used the timer should not show such a large offset. More like 10 ppm instead of 10%.
So maybe the internal sleep timer clock is not using a crystal oscillator, but more like a ceramic oscillator.
Those show quite a large drift in frequency and are quite temperature dependent.

ezparce
Normal user
Posts: 12
Joined: 13 Jul 2020, 09:18

Re: DeepSleep trouble

#14 Post by ezparce » 21 Jun 2021, 07:29

Reading beetween the lines of the Expressif datasheet, the RTC of the ESP8266 is an RC oscillator (as many other processors). This kind of oscillator will never be accurate because thi is not a crystal. Resistors and Capacitors values are changing ovre time. They are subject to drift (temperature, power supply, etc.). That is why real RTC exist (DS1302 and so on).
But I consider that this lack of accuracy is not a big problem when I use deepsleep for IoT. 10% error is acceptable in most situations.

On the counterpart, the fact that the last release of ESPEasy does not handle sleeptime correctly is a problem. Do you think this issue will be fixed or is it necessary to open a case on githug?

In the meantime, I will use and old release (witch perfectly handle DeepSleep) :)

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

Re: DeepSleep trouble

#15 Post by TD-er » 21 Jun 2021, 08:19

I have made a PR, where I try to fix it: https://github.com/letscontrolit/ESPEasy/pull/3691
But have not received any reply on it.

bison00
New user
Posts: 3
Joined: 26 May 2021, 21:05

Re: DeepSleep trouble

#16 Post by bison00 » 20 Jan 2022, 23:38

Hi TD-er

your investigation helps me. Since 1 Year I try to Solve this Issue. When I downgrade to the Version you recommend it works. Why no one have the same Problem?

There is a bug in the Firmware an no one will solve it.

regards Bison

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

Re: DeepSleep trouble

#17 Post by TD-er » 21 Jan 2022, 00:21

Since it is quite an old topic you reply to, can you be a bit more elaborate?
What exact version is working well?

NickSaggy
New user
Posts: 1
Joined: 25 Jan 2022, 22:19

Re: DeepSleep trouble

#18 Post by NickSaggy » 26 Jan 2022, 11:50

The 2022 update is no different, there is no notable changes.

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

Re: DeepSleep trouble

#19 Post by TD-er » 26 Jan 2022, 13:36

NickSaggy wrote: 26 Jan 2022, 11:50 The 2022 update is no different, there is no notable changes.
Which exact build did you use?

TestGuest
New user
Posts: 1
Joined: 11 Feb 2022, 09:48

Re: DeepSleep trouble

#20 Post by TestGuest » 11 Feb 2022, 09:57

I also got this Problem (max. 2.7xx sec. even If I send others values above)

With actual release 20211224... the max now is about 10.800 seconds.

Post Reply

Who is online

Users browsing this forum: No registered users and 17 guests