Rules If & ON

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
gorogdaniel
Normal user
Posts: 15
Joined: 21 Feb 2020, 17:33

Rules If & ON

#1 Post by gorogdaniel » 03 Mar 2020, 10:40

Hi i have a project in the forest and the internet connection is very bad there. so i work out a new rule and only whant to know if this can work or not.

on System#Wake do
If %vcc% < 2.2
deepSleep,3600
else
on WiFi#Connected do
SendToHTTP,url.com,80,/up.php?s=%unit%&b=%ip%&ti=[t#t]&ta=[t2#t]&lu=[l#l]&h=[t2#h]&p=[t2#p]&g=[g#g]&u=[s#u]&r=[s#r]&v=%vcc%&lo=[s#l]
endon
endif
endon

The idee is if the Battery level is under 2.2 thath the esp go again sleep and dont send anything over internet. The battery is conected to a solar cell so the esp can wait until the cell is loaded.

Maybe is it possible to activate and deactivate WIFI in a rule?
It is important to save so much enery as possible.

Thank you very much

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

Re: Rules If & ON

#2 Post by TD-er » 03 Mar 2020, 10:46

2.2 Volt is too low, the ESP will not even boot, so this rule will never trigger.

Also it probably has already started to connect to WiFi, so if the battery is too low, it probably enters boot loop.

gorogdaniel
Normal user
Posts: 15
Joined: 21 Feb 2020, 17:33

Re: Rules If & ON

#3 Post by gorogdaniel » 03 Mar 2020, 11:13

ok thank you very much for the voltage i can set 3.0 to but the code is right? and i can place the same rule on boot to.

Code: Select all

on System#Boot do
If %vcc% < 3.0
deepSleep,3600
else
on WiFi#Connected do
SendToHTTP,url.com,80,/up.php?s=%unit%&b=%ip%&ti=[t#t]&ta=[t2#t]&lu=[l#l]&h=[t2#h]&p=[t2#p]&g=[g#g]&u=[s#u]&r=[s#r]&v=%vcc%&lo=[s#l]
deepSleep,3600
endon
endif
endon

on System#Wake do
If %vcc% < 3.0
deepSleep,3600
else
on WiFi#Connected do
SendToHTTP,url.com,80,/up.php?s=%unit%&b=%ip%&ti=[t#t]&ta=[t2#t]&lu=[l#l]&h=[t2#h]&p=[t2#p]&g=[g#g]&u=[s#u]&r=[s#r]&v=%vcc%&lo=[s#l]
deepSleep,3600
endon
endif
endon

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

Re: Rules If & ON

#4 Post by TD-er » 03 Mar 2020, 11:46

The "on <trigger> do" parts cannot be nested.
Those are the entry-points in the rules, as rules act on events (the trigger).

But you can refer to the event value if needed.

If you need to store a state for next rules calls, you can store them in variables.
See: https://espeasy.readthedocs.io/en/lates ... skvalueset

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

Re: Rules If & ON

#5 Post by Micha_he » 03 Mar 2020, 11:50

A tip from me: Maybe %vcc% has no valid value directly after booting. The AD-conversion takes a few seconds in my tests.

Wiki
Normal user
Posts: 413
Joined: 23 Apr 2018, 17:55
Location: Germany

Re: Rules If & ON

#6 Post by Wiki » 03 Mar 2020, 11:55

I don't think that nested ON will work as it is the reaction on an event.
Nevertheless, you should not connect the esp to a battery like this if it is a liion battery, which I suppose. If the voltag gets below 3.2 Volt it will drain the battery very fast because the voltage regulator will take too much current.
Better solution is to add a TP4056 circuit between solar panel, battery and esp to prevnt deep discharge. So then you are shure that the battery will not be discharged under 2.5V. And you will not need the nested ON.

Code: Select all

pi@raspberrypi:~ $ man woman
No manual entry for woman
pi@raspberrypi:~ $

Post Reply

Who is online

Users browsing this forum: No registered users and 18 guests