Different Deepsleeptimes by Clock?

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
Beliar_666
New user
Posts: 8
Joined: 11 Apr 2019, 00:08

Different Deepsleeptimes by Clock?

#1 Post by Beliar_666 » 09 Mar 2021, 23:56

Hello,
I want to use a D1Mini as a accupowered Weatherstation. It works with two 18650 Accus, a 5V Solarpanel and a TP4065. I Use Deepsleep and wake it up every 30 minutes. It works good this way.

Now i think why waking up at night every 30 minutes, at night no one looks for the temparature. So now is my question if it is possible to set up longer interval with a rule? Or set the whole Deepsleep with a ruleset? Between 4.30am and 11.45pm wake up every 30 mins and the other time sleep as long as possible.

Is there any way to do it, or is this impossible?

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

Re: Different Deepsleeptimes by Clock?

#2 Post by TD-er » 10 Mar 2021, 00:06

The max. deep sleep you can set is roughly 3h45.
And yes, you can call deepsleep from rules with a set duration in seconds.
See: https://espeasy.readthedocs.io/en/lates ... l-commands

Also, if the time was set (e.g. via NTP) and the unit remained powered, you still have some idea of time of day as the last timestamp is saved to RTC and restored when restarting (wake from deep sleep is the same as a restart only with a few flags set) (see system#wake https://espeasy.readthedocs.io/en/lates ... ore-events )
Just keep in mind the time will be off by the amount of sleep time just passed.
But you can also wait for NTP to complete as it will trigger an event which you can process in the rules and set the amount of sleep time. See: Time#Initialized and Time#Set
For example on the time#initialized event you check whether it is day or night (N.B. you can also check agains sunrise and sunset) and then set some amount of sleep time in a variable.
When done processing all you need to do, call deepsleep with the value set in the variable.

chemmex
Normal user
Posts: 92
Joined: 15 Feb 2019, 16:18

Re: Different Deepsleeptimes by Clock?

#3 Post by chemmex » 10 Jul 2021, 09:15

Just recently made a check if the clock can survive reboot and/or deepsleep. Conclusions: system re-reads last timestamp from RTC memory after software and hardware reboot. However, after waking up from deepsleep, no timestamp is read, and hence no system time recovered. Testing was done with manually set DateTime or NTP, then reboot or deepsleep without either wifi or internet connectivity, NTP on/off made no difference. Tested on latest codebase as well as 2020-05 build.

Code: Select all

81 : Info   : INIT : Free RAM:33808
82 : Info   : INIT : Soft Reboot #17 - Restart Reason: Software/System restart
83 : Info   : FS   : Mounting...
132 : Info   : FS   : Mount successful, used 80069 bytes of 1953282
164 : Info   : CRC  : SecuritySettings CRC   ...OK
167 : Info   : WiFi : Start network scan all channels
395 : Info   : INIT : Free RAM:30712
396 : Info   : INIT : I2C
396 : Info   : INIT : SPI not enabled
748 : Info   : INFO : Plugins: 23  (ESP82xx Core 2843a5ac, NONOS SDK 2.2.2-dev(38a443e), LWIP: 2.1.2 PUYA support)
749 : Info   : EVENT: System#Wake
768 : Info   : Webserver: start
769 : Info   : Time set to 1625864429.000
771 : Info   : Current Time Zone: STD time start: 2021-10-31 03:00:00 offset: 0 min
774 : Info   : Local time: 2021-07-09 21:00:29
775 : Info   : EVENT: System#Boot


77 : Info   : INIT : Free RAM:33808
79 : Info   : INIT : Deep Sleep #18 - Restart Reason: Deep-Sleep Wake
79 : Info   : FS   : Mounting...
129 : Info   : FS   : Mount successful, used 80320 bytes of 1953282
161 : Info   : CRC  : SecuritySettings CRC   ...OK
164 : Info   : WiFi : Start network scan all channels
393 : Info   : INIT : Free RAM:30552
394 : Info   : INIT : I2C
394 : Info   : INIT : SPI not enabled
499 : Info   : INFO : Plugins: 23  (ESP82xx Core 2843a5ac, NONOS SDK 2.2.2-dev(38a443e), LWIP: 2.1.2 PUYA support)
500 : Info   : EVENT: System#Wake
516 : Info   : Webserver: start
527 : Info   : EVENT: System#Boot

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

Re: Different Deepsleeptimes by Clock?

#4 Post by TD-er » 10 Jul 2021, 11:01

Not 100% sure I do understand it.
The log does show the reboot nr, so the RTC memory is OK.

Only thing I can imagine is that the RTC was saved somehow by storing the "unset" system time. -> bug
If you wait a bit longer before reboot, in the run which does restore the time from RTC, is it then restored at the next reboot?
RTC memory is saved when a call to PLUGIN_READ was successful.

chemmex
Normal user
Posts: 92
Joined: 15 Feb 2019, 16:18

Re: Different Deepsleeptimes by Clock?

#5 Post by chemmex » 10 Jul 2021, 13:23

RTC memory is definitely Ok as the dummy values are kept, etc. According to two startup logs below, it restores system time after any number of consequent reboots. Different story with deepsleep, it doesn't read timestamp after System#Wake event.

NTP was off, so time is just default.

Code: Select all

79 : Info   : INIT : Free RAM:33184
80 : Info   : INIT : Soft Reboot #26 - Restart Reason: Software/System restart
81 : Info   : FS   : Mounting...
130 : Info   : FS   : Mount successful, used 81575 bytes of 1953282
164 : Info   : CRC  : SecuritySettings CRC   ...OK
167 : Info   : WiFi : Start network scan all channels
395 : Info   : INIT : Free RAM:29912
396 : Info   : INIT : I2C
396 : Info   : INIT : SPI not enabled
503 : Info   : INFO : Plugins: 24  (ESP82xx Core 2843a5ac, NONOS SDK 2.2.2-dev(38a443e), LWIP: 2.1.2 PUYA support)
504 : Info   : EVENT: System#Wake
575 : Info   : Webserver: start
576 : Info   : Time set to 1625910028.000
578 : Info   : Current Time Zone: STD time start: 2021-10-31 03:00:00 offset: 0 min
581 : Info   : Local time: 2021-07-10 09:40:28
582 : Info   : EVENT: System#Boot
809 : Info   : EVENT: Time#Initialized



79 : Info   : INIT : Free RAM:33184
80 : Info   : INIT : Soft Reboot #27 - Restart Reason: External System
81 : Info   : FS   : Mounting...
130 : Info   : FS   : Mount successful, used 81826 bytes of 1953282
163 : Info   : CRC  : SecuritySettings CRC   ...OK
166 : Info   : WiFi : Start network scan all channels
395 : Info   : INIT : Free RAM:29824
396 : Info   : INIT : I2C
396 : Info   : INIT : SPI not enabled
501 : Info   : INFO : Plugins: 24  (ESP82xx Core 2843a5ac, NONOS SDK 2.2.2-dev(38a443e), LWIP: 2.1.2 PUYA support)
503 : Info   : EVENT: System#Wake
573 : Info   : Webserver: start
575 : Info   : Time set to 1625910131.000
576 : Info   : Current Time Zone: STD time start: 2021-10-31 03:00:00 offset: 0 min
580 : Info   : Local time: 2021-07-10 09:42:11
581 : Info   : EVENT: System#Boot
886 : Info   : EVENT: Time#Initialized

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

Re: Different Deepsleeptimes by Clock?

#6 Post by TD-er » 10 Jul 2021, 15:59

Hmm that's strange.
Can you make an issue for it on GitHub, or else it is impossible to find back.

chemmex
Normal user
Posts: 92
Joined: 15 Feb 2019, 16:18

Re: Different Deepsleeptimes by Clock?

#7 Post by chemmex » 12 Jul 2021, 13:19

Can you make an issue for it on GitHub, or else it is impossible to find back.
done

Post Reply

Who is online

Users browsing this forum: No registered users and 36 guests