In this video we’re going to tackle Ghost Switching. That’s when your fancy cool DIY smart controller starts turning on and off on it’s own. It’s happened to me and i’m sure it’s happened to a lot of other people too. The good news is there’s a simple solution. Let me show ya.

 

Ghost Switching happens because of interference from nearby electrical systems getting picked up my the wires going between the GPIO pins and your switch or button.  The solution is simple. You put a resistor between the GPIO pin you’re using and a 3.3v pin.  And you put a capacitor between the GPIO pin and Ground.  

This setup with the resistor and capacitor is called a Low Pass Filter. It works because the capacitor allows higher frequency signals to pass through easily but it creates high resistance to low frequency signals. In our case the signal we want to pass through is just dc voltage, there’s no frequency at all. The interference that is causing our ghost switching is high frequency. The resistor is there to direct the load current through the capacitor.

The sizes of the resistor and the capacitor aren’t critical. The first person to tell me about this solution was Alex Gorgio.  He recommended using a 4.7k ohm resistor and a 33 nanofarad capacitor.  But if you don’t have those sizes you can use others. I found a website that lets you calculate the sizes of the R/C based on what frequency you want to filter out. Since we want just DC to pass and it has a frequency of zero, we can filter out everything else.  If you use the calculator just keep the frequency cap as low as you can so you don’t miss some of the interference.

Let’s go through the different kinds of Sonoffs and a couple ways you can connect the R/C.

Here’s a non-soldering solution too.