Relay and internal timer

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
gian72
New user
Posts: 3
Joined: 29 Jul 2019, 13:04

Relay and internal timer

#1 Post by gian72 » 29 Jul 2019, 14:28

Hello.
I use and esp8266 vith espeasy 2.0 firmware to control a relay that does some plant irrigation.
The commands are sent via MQTT.
I had a problem: as the esp8266 is connected via internet: yesterday I sent a MQTT command to activate the relay ("gpio,12,0") but then the internet connection failed. So there was no way to interrupt the irrigation. The solution was to go there and pull the power cord :)
Now the question: Is there the possibility to have a timer so that if the esp receives "gpio,12,0" after say 15 minutes he will "gpio,12,2", so the relay will shut off even without internet connection. This will be a security...

Thanks for your help, ciao Gianluca

User avatar
dynamicdave
Normal user
Posts: 257
Joined: 30 Jan 2017, 20:25
Location: Hampshire, UK

Re: Relay and internal timer

#2 Post by dynamicdave » 29 Jul 2019, 18:30

First idea that springs to mind is to send an 'event-commnad' (via MQTT) to the Wemos.

Set-up a Rule-Set (in the Wemos) to listen for the event-command, and in the rule-set set the GPIO (gpio 12) and also trigger a timer for 15-minutes.

If your main server (or whatever is sending the MQTT commands) goes off-line and is unable to send the command to turn the GPIO off, then after 15-minutes the timer expires.

This will trigger another rule that will turn the GPIO off.

So one way or another the GPIO pin gets turned off.

When I have a few spare minutes I'll rough out a 'rule' for you.

Cheers from David.

User avatar
dynamicdave
Normal user
Posts: 257
Joined: 30 Jan 2017, 20:25
Location: Hampshire, UK

Re: Relay and internal timer

#3 Post by dynamicdave » 29 Jul 2019, 19:21

Something like this should work...

Code: Select all

On startWatering Do
   gpio,12,1          //Activate the relay
   TimerSet,1,900     //Start the timer for 15-mins
EndOn

On stopWatering Do
   gpio,12,0          //Deactivate the relay
   TimerSet,1,0       //Reset the timer
EndOn

On Rules#Timer=1 Do
   gpio,12,0          //Deactivate the relay
EndOn

HomeJCL
Normal user
Posts: 89
Joined: 03 Feb 2018, 10:42

Re: Relay and internal timer

#4 Post by HomeJCL » 29 Jul 2019, 20:42

Longpulse works also, you free a timer.
Belgium and land of ESP ... counting :D

gian72
New user
Posts: 3
Joined: 29 Jul 2019, 13:04

Re: Relay and internal timer

#5 Post by gian72 » 30 Jul 2019, 12:39

@dynamicdave thank you for helping me! :)
@HomeJCL how can I tell longpulse that I need the 0 and 2 values on the gpio and not 0 and 1 (to activate and deactivate)? Longpulse accepts only seconds and one value...

Gianluca

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 8 guests