I'm not quite sure how to word this so I don't know how to search for it to see if there's already been an answer. I am an uber basic noob can't even draw out schematics, so sorry in advance.
I have a Raspberry Pi Zero w with a 5v relay board. Pi is supplied with 5v. The relay is connected with 5v and GND to the 5v and GND of the pi. I then have a lamp spliced into the relay to be turned on and off via the pi.
There is more to my setup. This is when the issue started happening. I put in a momentary push button. It seems like the input is extremely sensitive.
Here is my issue: If I turn on or off the exhaust fan in the bathroom (for example) or if I turn on a hair dryer or another fan, it will turn on the lamp. It doesn't happen all the time. I assume it is some kind of surge. I just can't quite figure out how to make sure that doesn't happen.
I've tried adding resistors, but that didn't. I'm not sure if this is a capacitor thing.. That's about the time I realized I have no idea what I'm doing and so I figured i'd ask!
EDIT 3 And fix*
I accidentally my raspberry pi and caused it unsafe power off which corrupted the SD card. I had an ESP8266 laying around that I decided to use instead. The issue was indeed a floating state as I had the same issue with the ESP. Using a 10k resistor to ground fixed the issue. Also, using the ESP8266 is MUCH better for this application than the rPi!!