5v DI goes randomly on

Hi Guys

So I made a home assistant with the arduino mega and a raspberry pi.

I have 6 push buttons connected on 6 digital inputs. I use digital input to switch to ground.
I have already installed a 1K ohm resistor on digital input and 5V on every push button. But I see that my inputs randomly on different times switches on. This give the result that my lamps goes on and off randomly.

I have 4 push buttons on a distance of 4 meter and 2 push buttons on a distance of 18± meters. All of them goes randomly on and off. Approximately 4 times a day.

I don’t use shielded cables. I don’t have the option to replace them because they are already in the wall. But they are twisted.

What is the best solution for solving this problem?


With the switches at the ends of long wires you are probably picking up noise from the environment. Some times a cap from the input to ground will dump off the noise to ground. Start with 0.1uF.

How are your pull-ups wired?

Perhaps consider stronger ones.

Another possibility would be to see how long the phantom readings last. If they’re brief enough you could filter them out in your code.

I use now 1K ohm resistors, they are wired from the digital input to 5V.

What do you mean with consider stronger ones? To use example 10K ohm?

I have change the code, They must now be pressed 0.125 seconds. I will let it run 1 night and see what will be the result.

I will try it, I will let you know.

Thanks for the info!

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