Getting FALSE positives with use of ESP8266 and magnet switch

Hi,
I'm pretty new to arduino but I am very interested in what it has to offer.
I made a simple project with a NC-switch installed on my garagedoor-opener. The intention was to log the status (open or closed) in an influxDB-database. This all works very well, the only problem I have is every day there are like 5 to 10 false positives which I like to get rid of. The wiring looks good and both switchparts are close enough to each other.
In attachment my sketch, the code and what the logging looks like in Grafana.

Any clues? Thanks in advance!

code_garage.txt (2.14 KB)

try a stronger pull-up resister on your input pin, 10K should work... and a 100nF capacitor to debounce the input, and/or a schmitt trigger. Also, share your code where it debounces the input.

Thx for this, been digging online based on your recommendations and it was learnful.
Also found out in this case the wall adapter was the cause. I tried a powerbank for 24 hours and there were no false triggers, now I replaced the cheap adapter with a more decent one and also having no false triggers.

Long wires, I'd optically isolate them.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.