Page 1 of 1

Magnetic Switch is not stable

Posted: 08 Oct 2019, 18:20
by Koenig
I have a magnetic switch on the door, which I have connected via GPIO as a "normal switch". 1st problem: When the switch is open, it constantly sends alternating 0 and 1 signals. When closed, however, it reliably transmits the signal 1 (reversed logic). I have already put in a resistor in between, but that brings no improvement. 2nd question: Does such a normal switch actually constantly send its status? Is not it possible for it to send only state changes to the controller? If that works, what do I have to do? Is there possibly a solution over rules? I hope someone can help.

Re: Magnetic Switch is not stable

Posted: 08 Oct 2019, 18:50
by Patou
Please monitor the voltage on the gpio input pin to see if it is stable
Please check if the used gpio input has a pull up resistor if not put one around 10 k
Your switch should be connected between gpio input and gnd
You can add a capacitor of about 10 mf between input and gnd
On the input configuration you can add a digital filter by programming a debounce time 100 ... 200 msec
Hope this can help

Re: Magnetic Switch is not stable

Posted: 09 Oct 2019, 13:04
by TD-er
What is the configuration of the sensor plugin?
Does it have an interval set? Is that interval equal to the message interval?
Do you have a long cable between switch and ESP?
Does the reed switch (I assume you're using one of those) also trigger on vibrations?

If it is reacting to vibrations, you could add a small capacitor over it, to dampen the very short pulses. (also suggested by Patou)

Also what Patou suggests, enable filtering in the plugin settings.

Re: Magnetic Switch is not stable

Posted: 09 Oct 2019, 21:26
by Koenig
What is the configuration of the sensor plugin? -> Enclosed
Does it have an interval set? Is that interval equal to the message interval? -> The interval is 10 sec., but the messages are changing much more often
Do you have a long cable between switch and ESP? -> 2 meters
Does the reed switch (I assume you're using one of those) also trigger on vibrations? -> Officially not, but it's a cheap chinese reed switch. Perhaps this is the reason.

If it is reacting to vibrations, you could add a small capacitor over it, to dampen the very short pulses. (also suggested by Patou) -> i will try, thank you!

Also what Patou suggests, enable filtering in the plugin settings. -> where can I enable filtering?

Thank you in advance!

Re: Magnetic Switch is not stable

Posted: 09 Oct 2019, 21:27
by Koenig
Thank you! I will check it!

Re: Magnetic Switch is not stable

Posted: 09 Oct 2019, 22:53
by Patou
, enable filtering in the plugin settings. -> where can I enable filtering?
Answer : it is the denounce variable in the plugin

Re: Magnetic Switch is not stable

Posted: 09 Oct 2019, 23:12
by TD-er
A 2 meter long cable is quite long. It could act as an antenna.
You may want to experiment also with the pull-up resistor settings for that pin.
Sometimes twisting the cable may help reducing interference, but only if some source of noise is near.