reading an input switch over mqtt
Posted: 05 Feb 2019, 22:08
All wright, been reading and fiddling for 3 days on how to use a normal switch to flip an input pin high and low and read the result on Node-Red via mqtt.
The goal is to monitor the state of switches in the field like i do with arduinos or pi's.
Hardware: gpio 12 as input
device: switch input, normal switch, input pullup inverse logic,
rules:
on sw1#switch=1 do
publish /wemos1/gpio/12,1
endon
on sw1#switch=0 do
publish /wemos1/gpio/12,0
endon
switch leg1------>grnd
leg2----->1k resistor---->3.3
leg2 ---- >gpio0
So when i close the switch i'm receiving a 1 in node red, so fine, but when i open it it toggles between 0 and 1 at the rate of the debounce field in the device menu.
This has to do with the rule set because without rule it behave ok in the log screen. I tried many examples and i can't make it work otherwise.
What i'm i doing wrong?
Thanks for your help, wonderfull project.
The goal is to monitor the state of switches in the field like i do with arduinos or pi's.
Hardware: gpio 12 as input
device: switch input, normal switch, input pullup inverse logic,
rules:
on sw1#switch=1 do
publish /wemos1/gpio/12,1
endon
on sw1#switch=0 do
publish /wemos1/gpio/12,0
endon
switch leg1------>grnd
leg2----->1k resistor---->3.3
leg2 ---- >gpio0
So when i close the switch i'm receiving a 1 in node red, so fine, but when i open it it toggles between 0 and 1 at the rate of the debounce field in the device menu.
This has to do with the rule set because without rule it behave ok in the log screen. I tried many examples and i can't make it work otherwise.
What i'm i doing wrong?
Thanks for your help, wonderfull project.