Going to deepsleep forever in rules

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
Flop
New user
Posts: 6
Joined: 23 Apr 2020, 20:07

Going to deepsleep forever in rules

#1 Post by Flop » 23 Apr 2020, 20:14

Hi,

I have an esp12 with espeasy firmware powered with lipo battery.
This esp is waking up each 10 minutes for 10 seconds and send temperature to an openhab server.
Is there a command that can be used in rules to put the esp in deepsleep forever ?

I check the battery voltage at startup, and I want to be able to put the esp in deepsleep forever if the battery level is to low to preserve the battery from overdischarge.


My settings :
Sleep awake time 10sec
Sleep time : 600sec

One device analog input internal Named Vcc with value Analog and formula is : %value%/1024*3.3

Rules :

On System#Boot do
delay 8000
if [Vcc#Analog]<2.5
deepSleep(0)
endif
endon

But it doesn't work.

thanks for your help.

Micha_he
Normal user
Posts: 372
Joined: 07 Feb 2018, 19:14
Location: Helmstedt, Germany

Re: Going to deepsleep forever in rules

#2 Post by Micha_he » 23 Apr 2020, 20:16

The correct command is 'deepsleep,0' !

Flop
New user
Posts: 6
Joined: 23 Apr 2020, 20:07

Re: Going to deepsleep forever in rules

#3 Post by Flop » 23 Apr 2020, 20:24

This does not work !

new rule :

On System#Boot do
delay 8000
if [Vcc#Analog]<2.5
deepSleep,0
endif
endon

log :

INIT : Booting version: mega-20190928 (ESP82xx Core 2_5_2, NONOS SDK 2.2.1(cfd48f3), LWIP: 2.1.2 PUYA support)
78 : INIT : Free RAM:33376
79 : INIT : Rebooted from deepsleep #31 Last Task: Background Task - Restart Reason: Deep-Sleep Wake
81 : FS : Mounting...
105 : FS : Mount successful, used 76053 bytes of 957314
496 : CRC : program checksum ...OK
526 : CRC : SecuritySettings CRC ...OK
614 : INIT : Free RAM:30232
616 : INIT : I2C
616 : INIT : SPI not enabled
618 : EVENT: System#NoSleep=10
650 : INFO : Plugins: 46 [Normal] (ESP82xx Core 2_5_2, NONOS SDK 2.2.1(cfd48f3), LWIP: 2.1.2 PUYA support)
652 : EVENT: System#Wake
772 : WIFI : Set WiFi to STA
805 : WIFI : Connecting Wifi attempt #0
808 : EVENT: System#Boot
820 : ACT : delay 8000
828 : Command: delay
8873 : ACT : deepSleep,0
8880 : Command: deepsleep
8987 : WIFI : Connected! AP: Wifi (04:18:D6:9F:F1:25) Ch: 1 Duration: 3771 ms
8988 : EVENT: WiFi#ChangedAccesspoint
8998 : EVENT: WiFi#ChangedWiFichannel
9006 : WIFI : DHCP IP: 192.168.1.112 (ESP-TEST-18650-64) GW: 192.168.1.1 SN: 255.255.255.0 duration: 2018 ms
9009 : EVENT: WiFi#Connected
9023 : Webserver: start
9024 : firstLoopConnectionsEstablished
9026 : EVENT: System#NoSleep=10
9042 : WD : Uptime 0 ConnectFailures 0 FreeMem 23840 WiFiStatus 3
9082 : DHT12: No reading!
9092 : ADC : Analog value: 81 = 81.000
9098 : EVENT: Vcc#Analog=0.26
9114 : ADC : Analog value: 81 = 81.000
9118 : EVENT: Vcc#Analog=0.26
9135 : ADC : Analog value: 81 = 81.000
9139 : EVENT: Vcc#Analog=0.26
9152 : ADC : Analog value: 82 = 82.000
9155 : EVENT: Vcc#Analog=0.26
9168 : ADC : Analog value: 81 = 81.000
9171 : EVENT: Vcc#Analog=0.26
9184 : ADC : Analog value: 81 = 81.000
9187 : EVENT: Vcc#Analog=0.26
9200 : ADC : Analog value: 81 = 81.000
9203 : EVENT: Vcc#Analog=0.26
9216 : ADC : Analog value: 81 = 81.000
9219 : EVENT: Vcc#Analog=0.26
9232 : ADC : Analog value: 82 = 82.000
9237 : EVENT: Vcc#Analog=0.26
9663 : ADC : Analog value: 81 = 81.000
9667 : EVENT: Vcc#Analog=0.26
10217 : WD : Uptime 1 ConnectFailures 0 FreeMem 23320 WiFiStatus 3
10665 : ADC : Analog value: 81 = 81.000
10670 : EVENT: Vcc#Analog=0.26
11663 : ADC : Analog value: 80 = 80.000
11667 : EVENT: Vcc#Analog=0.26
12665 : ADC : Analog value: 73 = 73.000
12668 : EVENT: Vcc#Analog=0.24
13663 : ADC : Analog value: 81 = 81.000
13667 : EVENT: Vcc#Analog=0.26
14665 : ADC : Analog value: 81 = 81.000
14669 : EVENT: Vcc#Analog=0.26
15663 : ADC : Analog value: 78 = 78.000
15667 : EVENT: Vcc#Analog=0.25
16665 : ADC : Analog value: 80 = 80.000
16668 : EVENT: Vcc#Analog=0.26
17663 : ADC : Analog value: 81 = 81.000
17667 : EVENT: Vcc#Analog=0.26
18665 : ADC : Analog value: 82 = 82.000
18669 : EVENT: Vcc#Analog=0.26
19026 : EVENT: System#Sleep
19035 : SLEEP: Powering down to deepsleep...

then esp goes to deepsleep for x sec and wake up !


Edit : i've tried this too

On System#Boot do
timerSet,1,8
end on

On Rules#Timer=1 do
if [Vcc#Analog]<2.5
deepsleep,0
endif
endon

Flop
New user
Posts: 6
Joined: 23 Apr 2020, 20:07

Re: Going to deepsleep forever in rules

#4 Post by Flop » 23 Apr 2020, 20:41

also tried to disable sleep awake time ( put 0 ) in config

and rules :

On System#Boot do
timerSet,1,8
timerSet,2,12
endon

On Rules#Timer=1 do
if [Vcc#Analog]<2.5
deepsleep,0
endif
endon

On Rules#Timer=2 do
deepsleep,30
endon

event #1 occurs but esp does not go to deepsleep:

9637 : EVENT: Rules#Timer=1
9690 : ACT : deepsleep,0

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

Re: Going to deepsleep forever in rules

#5 Post by TD-er » 23 Apr 2020, 21:24

This is not possible without an additional circuit.
The ESP itself cannot be in deep sleep mode for longer than the max deep sleep (which is roughly 3.5 hours)

Even if you disconnect the link between GPIO-16 and RST, it will try to fire the wake up signal and simply by doing that it will consume more power than in deep sleep.

I think the best you can do is to add some monitoring circuit that operates the EN pin on the ESP.
Such battery monitoring chips can be found for various voltages.
By disabling the EN pin of the ESP, you can prevent the ESP from booting.

There is only a small catch here.
The EN pin is usually pulled high via a resistor.
If you pull it low to disable booting, this pull up resistor will consume power from the battery.

Another option could be to add in ESPEasy a check to measure battery voltage on the ADC to see if it is safe to continue booting or else go to sleep immediately.
This should then be a configurable value in the settings and even be executed before starting the rules engine as that may also trigger other activities.

Flop
New user
Posts: 6
Joined: 23 Apr 2020, 20:07

Re: Going to deepsleep forever in rules

#6 Post by Flop » 23 Apr 2020, 22:02

TD-er wrote: 23 Apr 2020, 21:24 This is not possible without an additional circuit.
The ESP itself cannot be in deep sleep mode for longer than the max deep sleep (which is roughly 3.5 hours)

Even if you disconnect the link between GPIO-16 and RST, it will try to fire the wake up signal and simply by doing that it will consume more power than in deep sleep.

I think the best you can do is to add some monitoring circuit that operates the EN pin on the ESP.

Such battery monitoring chips can be found for various voltages.
By disabling the EN pin of the ESP, you can prevent the ESP from booting.


There is only a small catch here.
The EN pin is usually pulled high via a resistor.
If you pull it low to disable booting, this pull up resistor will consume power from the battery.
ok, now that i know it's not possible by software , I will think about that.
TD-er wrote: 23 Apr 2020, 21:24 Another option could be to add in ESPEasy a check to measure battery voltage on the ADC to see if it is safe to continue booting or else go to sleep immediately.
This should then be a configurable value in the settings and even be executed before starting the rules engine as that may also trigger other activities.
why not, but my dev skill are not as good as they were !

thanks, it's time for me to think about which way is the best for me.

Micha_he
Normal user
Posts: 372
Joined: 07 Feb 2018, 19:14
Location: Helmstedt, Germany

Re: Going to deepsleep forever in rules

#7 Post by Micha_he » 23 Apr 2020, 22:25

... and the 'deepsleep,0'-command only works in the firmware versions 04/10/2020 or later.

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Amazon [Bot] and 53 guests