switch false positives

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
madmax
New user
Posts: 2
Joined: 16 Aug 2023, 11:18

switch false positives

#1 Post by madmax » 16 Aug 2023, 11:22

Hello,

I would like to use ESPEasy for a doorbell. Everything is working, but I'm experiencing quite a few false positives. I must mention that the cable from the switch to the ESPEasy is quite long, around 50 meters. Can I add a resistor or a capacitor to prevent or filter out this noise that might be causing the false positives? I have the cable connected to GPIO13 (D7) on a NodeMCU with the pull-up activated. Thanks for any ideas you might have

User avatar
Ath
Normal user
Posts: 3519
Joined: 10 Jun 2018, 12:06
Location: NL

Re: switch false positives

#2 Post by Ath » 16 Aug 2023, 12:37

For that kind of wire-length you'd need at max. a 4k7 pull-up resistor from gpio to 3.3V, and probably also a 10-100 nF capacitor from gpio to gnd, both at the NodeMCU side.
The built-in pull-up is around 80-100 kOhm, and that's way too weak to stabilize that kind of noisy signal. (Been there, done that :?)
In the Switch configuration the Debounce time should be set to 100 msec to make it more reliable/stable.

Another possibility would be to place the NodeMCU much closer to the button, and let the WiFi handle the distance, but that may be unpractical (long power lines etc.), though the pull-up should still be max. 10k, and the capacitor is also helpful.
/Ton (PayPal.me)

TD-er
Core team member
Posts: 8755
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: switch false positives

#3 Post by TD-er » 16 Aug 2023, 14:20

Hmm 50m cable is way too long.
You should for sure 'twist' the wires, but also make sure the wire ends have a very well defined state.
Depending on the switch type of the door bell, you can add some resistors.
I'll assume the switch of "NO" type (normally open, press to close)
So on the ESP side, you should pull the GPIO pin high using a rather strong pull-up resistor (e.g. 1k) and place a resistor of 10k over the door bell switch.
The ratio is still 10 : 1, so the logic level on the GPIO pin will be "high"

Code: Select all

3V3 
 |
 |
1k
 |
GPIO ----- 100 Ohm -----A
 |                      |
100nF                  10k
 |                      |
GND --------------------B
The switch and the 10k resistor will be connected to A and B
The long wires to A and B should be twisted, like the wires in UTP cable are.

By pressing the switch, the 10k resistor will be shorted and the capacitor between GPIO and GND will get discharged.
However since there is a 100 Ohm resistor in series with the switch, the capacitor will take some time to get discharged.

This will suppress noise picked up by the rather long antenna you created.
You can pick other resistor values, as long as the ratio of 1 : 10 : 100 is somewhat preserved. (ratio steps should be larger than 1 : 4)
And don't get too high resistance values, or else there won't hardly be any current flowing through the cable and thus less energetic noise can trigger false positives.

Still setting the debounce time, like Ton suggested, is needed.

madmax
New user
Posts: 2
Joined: 16 Aug 2023, 11:18

Re: switch false positives

#4 Post by madmax » 16 Aug 2023, 15:05

Okay, thank you for the information. I will give it a try.

Post Reply

Who is online

Users browsing this forum: No registered users and 32 guests