I would like to use a push button to toggle a relay based on GPIO condition.
Could someone help me?
I am not sure the proper way in rules to check status of GPIO.
On Pushbutton=1 do
if GPIO13 is 1
then
set GPIO13=0
else
set GPIO13=1
Pushbutton toggle
Moderators: grovkillen, Stuntteam, TD-er
- grovkillen
- Core team member
- Posts: 3621
- Joined: 19 Jan 2017, 12:56
- Location: Hudiksvall, Sweden
- Contact:
Re: Pushbutton toggle
Please post your page with devices.
I suspect you need to do something like this:
Have you studied the wiki at all?
I suspect you need to do something like this:
Code: Select all
On pushbutton#state do
if pushbutton#state=1
GPIO,13,0
else
GPIO,13,1
endon
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
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you
Re: Pushbutton toggle
I have looked at the wiki, i think
.. could you send me link?
I am using a Nodemcu Wemos D1.
i have a pushbutton connected between - and D2
relay connected from D7 -> Led -> inputrelay
the code you suggested always just preforms the first part of the statement
I would like to push the button and if the relay is already high then send it low and vise versa.
.. could you send me link?
I am using a Nodemcu Wemos D1.
i have a pushbutton connected between - and D2
relay connected from D7 -> Led -> inputrelay
the code you suggested always just preforms the first part of the statement
I would like to push the button and if the relay is already high then send it low and vise versa.
-
- Normal user
- Posts: 33
- Joined: 05 Jun 2017, 05:32
it´s so easy
Hi,
in another Thread i find the solution, here are a rule for a modified (LED in red working on GPIO12) sonoff Basic:
Thing we should include it
(the choice =toggle) to the wiki
U had to create a device switch input with name Button, Valuename Switch on GPIO0 and
also one with name Steckdose, Valuename Switch on GPIO12.
best wishes
BerndJ
in another Thread i find the solution, here are a rule for a modified (LED in red working on GPIO12) sonoff Basic:
Code: Select all
On Button#Switch=toggle do
if [Steckdose#Switch]=0
gpio,12,1
else
gpio,12,0
endif
EndOn
(the choice =toggle) to the wiki
U had to create a device switch input with name Button, Valuename Switch on GPIO0 and
also one with name Steckdose, Valuename Switch on GPIO12.
best wishes
BerndJ
Last edited by BerndJ on 01 Aug 2017, 12:43, edited 1 time in total.
- grovkillen
- Core team member
- Posts: 3621
- Joined: 19 Jan 2017, 12:56
- Location: Hudiksvall, Sweden
- Contact:
Re: Pushbutton toggle
Then you need to create a device for the relay. You find more on the wiki for the Sonoff Touch (link below).
Code: Select all
On pushbutton#state do
if relay#state=1
GPIO,13,0
else
GPIO,13,1
endif
endon
PS. I forgot the "endif" in my first code.
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
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you
Who is online
Users browsing this forum: No registered users and 15 guests