I am having an issue that i am not sure what to do next, i am not a electronic guy just read a bunch so please bear with me. I am using an esp8266 that is connected to a simple push switch that when the switch is pushed it turns on some LED strips via a FET board that i found on Amazon. Everything works great. I have this setup turning the lights on in my workshop. however it does toggle my lights (on or off based on the state when the button is pushed.) when it is getting some type of noise. like when my heater kicks on or i have an old fluorescent lamp sometimes when i turn it on it will toggle the lights. What i have tried to do is:
1 added a 10k pull up resistor
2. powered everything from batteries
3. powered by a stronger power supply plugged into a UPS on battery side.
things i wonder about...
1 button is about 30 feet away so is the wire being that long an issue?
2 do i need to add a capacitor between pin and ground (read about this)
my code is pretty standard
in setup
attachInterrupt(digitalPinToInterrupt(buttonPin), InterruptHandler, FALLING);
if(interruptFlag > 0)
{
senddata(1,"Shop Lights has been toggled"); //send reading to my web services
toggle();
delay(2000);
interruptFlag = 0;
}
Outside setup
void toggle()
{
bool x = relaystate;
relaystate = !relaystate;
digitalWrite(relayPin, relaystate);
server.send(200, "text/plain", "Lights toggled");
if(x == LOW)
{
sendnotification("Shop Lights Toggled Off"); //send notifications to my mobile app
}
else
{
sendnotification("Shop Lights Toggled On"); //send notifications to my mobile app
}
}
image of my setup...
any ideas would be helpful
thanks tim