Control of the relay when clicking the button (without network)
Moderators: grovkillen, Stuntteam, TD-er
Control of the relay when clicking the button (without network)
Hi, everybody!
My device - Sonoff from Itead
Pinouts:
gpio0 - Button
gpio12 - Relay
gpio13 - Led
How to me to make that when clicking the button the relay switched?
And that it worked only by means of the standard program in a firmware that it was possible to include or turn off manually the light in the absence of the Internet or Wi-Fi of a network in particular.
My device - Sonoff from Itead
Pinouts:
gpio0 - Button
gpio12 - Relay
gpio13 - Led
How to me to make that when clicking the button the relay switched?
And that it worked only by means of the standard program in a firmware that it was possible to include or turn off manually the light in the absence of the Internet or Wi-Fi of a network in particular.
- Attachments
-
- pic01.PNG (27.25 KiB) Viewed 12455 times
-
- pic02.PNG (39.79 KiB) Viewed 12455 times
Re: Control of the relay when clicking the button (without network)
If I understand well what you're trying to do, you need to set up a rule as detailed in this post:
viewtopic.php?f=2&t=1867&p=8627&hilit=s ... ules#p8627
viewtopic.php?f=2&t=1867&p=8627&hilit=s ... ules#p8627
Re: Control of the relay when clicking the button (without network)
Hi, kosta!
First go to Tools->Advanced and enable Rules (click on Rules checkbox).
Then go to Devices and cerate switch input like here:
Then go to Rules tab and paste this code:
on switchon do
gpio 12,1
gpio 13,0
inputswitchstate 0,1
endon
on switchoff do
gpio 12,0
gpio 13,1
inputswitchstate 0,0
endon
on Switch#switch do
if [Switch#switch]=1
event switchon
else
event switchoff
endif
endon
Submit and reboot!
Test. This setup works for me.
For more info about rules you can see the link which dlefol give you and this http://www.letscontrolit.com/wiki/index ... rial_Rules
First go to Tools->Advanced and enable Rules (click on Rules checkbox).
Then go to Devices and cerate switch input like here:
Then go to Rules tab and paste this code:
on switchon do
gpio 12,1
gpio 13,0
inputswitchstate 0,1
endon
on switchoff do
gpio 12,0
gpio 13,1
inputswitchstate 0,0
endon
on Switch#switch do
if [Switch#switch]=1
event switchon
else
event switchoff
endif
endon
Submit and reboot!
Test. This setup works for me.
For more info about rules you can see the link which dlefol give you and this http://www.letscontrolit.com/wiki/index ... rial_Rules
Regards from Bulgaria.
raptor
raptor
Re: Control of the relay when clicking the button (without network)
Many thanks! I understood everything.
Re: Control of the relay when clicking the button (without network)
Hi, i am a newbie with this and i am trying to do this same project to start. The button needs to be wired to gnd and the positive to gpio0? Thanks in advance!
Re: Control of the relay when clicking the button (without network)
Hi, javier77!
If your device is Sonoff you don't need to wire the button! The button is already connected to gpio0. You need to make the settings which you can see in my previous post.
If your device is Sonoff you don't need to wire the button! The button is already connected to gpio0. You need to make the settings which you can see in my previous post.
Regards from Bulgaria.
raptor
raptor
Re: Control of the relay when clicking the button (without network)
raptor wrote:Hi, javier77!
If your device is Sonoff you don't need to wire the button! The button is already connected to gpio0. You need to make the settings which you can see in my previous post.
I am trying this on a NodeMCU D1 mini using an arduino relay module and a push button.
Thanks in advance.
Javier
Re: Control of the relay when clicking the button (without network)
Unfortunately, I can't help you. I tried this only with Sonoff device.
Regards from Bulgaria.
raptor
raptor
Re: Control of the relay when clicking the button (without network)
raptor wrote:Hi, kosta!
First go to Tools->Advanced and enable Rules (click on Rules checkbox).
Then go to Devices and cerate switch input like here:
Untitled.png
Then go to Rules tab and paste this code:
on switchon do
gpio 12,1
gpio 13,0
inputswitchstate 0,1
endon
on switchoff do
gpio 12,0
gpio 13,1
inputswitchstate 0,0
endon
on Switch#switch do
if [Switch#switch]=1
event switchon
else
event switchoff
endif
endon
Submit and reboot!
Test. This setup works for me.
For more info about rules you can see the link which dlefol give you and this http://www.letscontrolit.com/wiki/index ... rial_Rules
Hello Raptor, button works without network ?
-
- Normal user
- Posts: 21
- Joined: 31 Oct 2016, 03:03
Re: Control of the relay when clicking the button (without network)
javier77
Yes
Positive to GPIO and gnd to ground
Yes
Positive to GPIO and gnd to ground
Re: Control of the relay when clicking the button (without network)
This is all I have for my sonoff's:
On button#switch do // when button is pressed, toggle the relay
if [button#switch]=1
gpio, 12, 1
else
gpio, 12, 0
endif
endon
---Device Settings---
Device: Switch input
Name: button
Delay: 0
IDX/Var: [what ever you need, I just use 1]
1st GPIO: GPIO-0
Switch Type: Switch
Switch Button Types: Push Button Active Low
Pull Up, Inversed, Send Boot State, Send Data - unchecked
Value Name 1: switch
On button#switch do // when button is pressed, toggle the relay
if [button#switch]=1
gpio, 12, 1
else
gpio, 12, 0
endif
endon
---Device Settings---
Device: Switch input
Name: button
Delay: 0
IDX/Var: [what ever you need, I just use 1]
1st GPIO: GPIO-0
Switch Type: Switch
Switch Button Types: Push Button Active Low
Pull Up, Inversed, Send Boot State, Send Data - unchecked
Value Name 1: switch
Re: Control of the relay when clicking the button (without network)
Hi
Only related , I set this configuration to be able to cycle the relay
Regards,
Only related , I set this configuration to be able to cycle the relay
Code: Select all
on System#Boot do / Set boot options
gpio,12,1
endon
on pushbutton#Switch=0 do / On push button call event/function cycle
event cycle
endon
On Clock#Time=MonTueFri,03:53 do / cron like job
event cycle
endon
on cycle do / set gpio, start timer
gpio,12,0
gpio,13,0
timerset,1,15
endon
on Rules#Timer=1 do / on time expire reset gpio
gpio,12,1
gpio,13,1
endon
Who is online
Users browsing this forum: No registered users and 0 guests