A proper Schmitt Trigger such as 74HC14 should do the job. On chip hysteresis is often tiny like 0.2V and more susceptible to noise pick up.
The 74HC14 has more like a volt of hysteresis.
Note the 0.8V / 2.0V levels are nothing to do with hysteresis, they just say the threshold is somewhere between those values, not that it has any hysteresis.
One thing to check is where that the 100nF cap is close to the GPIO pin itself directly to the nearest ground. 47k is a very weak pullup, try 10k / 4k7 or even 2k2.
One other thing, 20ms is very slow for a reed switch/relay, so a smaller R will help with that. A 100 ohm resistor in series with the reed switch will prevent arcing damage when the cap is shorted out.
The 74HC14 has more like a volt of hysteresis.
Note the 0.8V / 2.0V levels are nothing to do with hysteresis, they just say the threshold is somewhere between those values, not that it has any hysteresis.
One thing to check is where that the 100nF cap is close to the GPIO pin itself directly to the nearest ground. 47k is a very weak pullup, try 10k / 4k7 or even 2k2.
One other thing, 20ms is very slow for a reed switch/relay, so a smaller R will help with that. A 100 ohm resistor in series with the reed switch will prevent arcing damage when the cap is shorted out.
Statistics: Posted by Mark T — Fri Mar 01, 2024 10:52 pm