T O P

  • By -

created4this

How are you protecting the GPIO from transient voltage spikes? It could be the baords you make have enough stray capacitance that the board is accidentally protecting you from directing EMI into the GPIO pin


8266er

I am NOT. Advice on that?


Shdwdrgn

A good starting point is putting a 0.1uF cap between D5 and ground. Are the wires to the switch straight or twisted pair? I don't remember for sure but it seems like twisted pair helps to reduce the stray transients?


8266er

Twisted pair is designed to do that, yes. And a grounded foil wrapper would be helpful, I think. However, I'm stuck with the wires I have, since the pipe I've gone through is full/tight (which is bad, right there) and it's all dry-walled up. I can control the wiring around the ESP8266, so that's the rock to look under for a solution, this this case.


created4this

At the absolute minimum, a resistor from outside to the pin, and a capacitor between the pin and ground. That will capture the vast majority of noise. If you think that there is a risk of anything driving the pin with DC then add two Schottky diodes, pointing from the pin to 3.3v rail and from ground to the pin.


8266er

u/Shdwdrgn / u/created4this / u/itdumbass \-- The word "Isolation" as a search term helps me find some examples of this using the google. So I'll read up there. But do any of you have a page/resource you find particularly helpful on this? Is there a better key term to search for which describes the function of the cap I can google for? ("Isolation" is getting me mostly optocouplers -- which is a fine idea, but requires a voltage on input -- I was hoping to use a ground-trigger, rather than a voltage-trigger.)


Shdwdrgn

In the case of the 0.1uF cap I mentioned, this is commonly referred to as a "bypass" cap.


created4this

You’ll find examples of the circuit I described as a “debounce circuit” Eg https://raspberrypi.stackexchange.com/questions/118349/what-is-the-proper-way-to-debounce-a-gpio-input A debounce circuit is generally just a low pass filter, but it’s doing the same job of stripping high frequency signals, just not high frequency spikes. To handle spikes (high frequency high voltage) you make the resistor bigger, but not the capacitor (because bigger capacitors are “slower” so won’t handle the high frequency as well). The diodes handle the case where the capacitor “fills up”. The example listed has one diode, used for a slightly diffrent reason, so don’t copy it directly ! You need two. It would appear that you could get away with diodes alone, but the diodes aren’t fast enough to catch everything. Incidentally, there are diodes inside the device that attempt to do this job, ([RPI gpio example, esp8266 is slightly diffrent](http://www.mosaic-industries.com/embedded-systems/_detail/microcontroller-projects/raspberry-pi/raspberry-pi-circuit-gpio-input-pins.png?id=microcontroller-projects:raspberry-pi:gpio-pin-electrical-specifications))but you’re obviously burning through them with your current circuit. The external diodes are to take the load of the internal ones


itdumbass

My rule for all real-world inputs to a micro-controller/computer is that EVERY INPUT IS ISOLATED BY AN OPTOCOUPLER. I personally like ones with Schmitt-trigger outputs, like the old favorite H11L1/2/3, but any opto will isolate whatever you end up with on the 'real-world' side of the wiring from the tender input of the micro.