How to control 4 channel relay with button and MQTT

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
ashfaaaa
New user
Posts: 4
Joined: 09 Feb 2017, 07:49

How to control 4 channel relay with button and MQTT

#1 Post by ashfaaaa » 09 Feb 2017, 08:13

Hello guys I'm new to Esp Easy is it possible to control 4 channel relay board with esp8266 esp(12F) control it with MQTT and add 4 physical buttons to control this relays.?

User avatar
toffel969
Normal user
Posts: 469
Joined: 03 Jan 2017, 10:58
Location: Germany

Re: How to control 4 channel relay with button and MQTT

#2 Post by toffel969 » 18 Feb 2017, 07:41

ashfaaaa wrote:Hello guys I'm new to Esp Easy is it possible to control 4 channel relay board with esp8266 esp(12F) control it with MQTT and add 4 physical buttons to control this relays.?
yes
Domoticz on Raspi 2 -- 14 ESP units (hacked Sonoff,NodeMCUs, Wemos, self-built units) running with RC140- Mega 2.0.0 dev8

guslinux
New user
Posts: 7
Joined: 24 Aug 2016, 16:33

Re: How to control 4 channel relay with button and MQTT

#3 Post by guslinux » 07 Jan 2018, 17:36

Hello,

How did you do to revert the GPIO state ?
Using the rules (EspEasyMega) I'm not able to read the GPIO state to revert the state of the relay... :oops:

In my case, I want to use the same ESP to read the input and control the relay using a specific rule.

Thanks !

User avatar
grovkillen
Core team member
Posts: 3621
Joined: 19 Jan 2017, 12:56
Location: Hudiksvall, Sweden
Contact:

Re: How to control 4 channel relay with button and MQTT

#4 Post by grovkillen » 07 Jan 2018, 17:45

Have you read the wiki tutorials regarding rules?
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you :idea: :idea: :idea:

guslinux
New user
Posts: 7
Joined: 24 Aug 2016, 16:33

Re: How to control 4 channel relay with button and MQTT

#5 Post by guslinux » 07 Jan 2018, 20:55

Yes, I have try reading the Rules Tutorial.

I want to do anything like that :

Code: Select all

on Button#State=1 do
  If GPIO14#State=1
  	gpio,14,0
  Else
  	gpio,14,1
  Endif
endon
But it seem not possible to read a GPIO used as output...

User avatar
grovkillen
Core team member
Posts: 3621
Joined: 19 Jan 2017, 12:56
Location: Hudiksvall, Sweden
Contact:

Re: How to control 4 channel relay with button and MQTT

#6 Post by grovkillen » 07 Jan 2018, 21:56

guslinux wrote: 07 Jan 2018, 20:55 Yes, I have try reading the Rules Tutorial.

I want to do anything like that :

Code: Select all

on Button#State=1 do
  If GPIO14#State=1
  	gpio,14,0
  Else
  	gpio,14,1
  Endif
endon
But it seem not possible to read a GPIO used as output...

Code: Select all

on Button#State do
  If [Button#State]=1
  	gpio,14,0
  Else
  	gpio,14,1
  Endif
endon
If you want to know the state of the GPIO you should have that hooked up as a device (switch) alongside the button. But if nothing can influence the GPIO from the outside (not controlled by the ESP) then you really don't need to know the state since it will be in direct connection to the button.
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you :idea: :idea: :idea:

guslinux
New user
Posts: 7
Joined: 24 Aug 2016, 16:33

Re: How to control 4 channel relay with button and MQTT

#7 Post by guslinux » 08 Jan 2018, 09:09

In my case,

I have 3 push button connected to the esp (on the same input), and I want also change the output state with a On/Off command using a domotic box (using MQTT).
I want to use rules to had more reactivity than using the domotic box to do that.

I want to use the less input possible on my esp (regarding your proposal to connect the relay output ton an input to monitor)...

User avatar
grovkillen
Core team member
Posts: 3621
Joined: 19 Jan 2017, 12:56
Location: Hudiksvall, Sweden
Contact:

Re: How to control 4 channel relay with button and MQTT

#8 Post by grovkillen » 08 Jan 2018, 09:20

So funnel all these inputs to the same event? You may use dummy devices to store the state.
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you :idea: :idea: :idea:

Post Reply

Who is online

Users browsing this forum: No registered users and 27 guests