# How to properly clean up a noisy signal with a capacitor

I'm reading a pulse from a camera back to a raspberry pi and the noisy signal is causing the gpio pin to read too many inputs.

My signal is 3.3v. I'm currently using a 1uf Cap to try to clean up the signal but is that enough? I have the cap soldered to ground and then soldered in the middle of the 3.3v line which leads from the camera to my raspberry pi's gpio pin.

I'm more of a software guy rather than an electrical engineer. I appreciate any help/guidance!

simulate this circuit – Schematic created using CircuitLab

• Please post a schematic, you can draw one with the tool Feb 16 '17 at 23:41
• It depends what the pulse is used for and where it comes from. Contact closure? with Pull up R ? narrow pulse? data? using twisted pair wires? A large cap acts like a short circuit to a narrow pulse. Define pulse please! Feb 16 '17 at 23:50
• or at least define camera + port with www.links Feb 16 '17 at 23:58
• makezine.com/projects/raspberry-pi-point-and-shoot-camera Feb 17 '17 at 0:00
• Make sure the signal is stable. You may have to provide a pull-up resistor if the signal output is e.g. an open drain type. Check the spec/datasheet of the signal source. Feb 17 '17 at 12:50

If you're a software guy, then you can filter the noise in software, that's the cheapest option :)

But considering you do want to make a low-pass filter, you need a capacitor and a resistor.

simulate this circuit – Schematic created using CircuitLab

You can compute the RC constant as R*C, in the example that would be 100 * 0.000001 (because C is measured in Farads), or in this case 100 µs. Very crudely speaking (google around for more), fast signal changes that are quicker than the RC constant will get attenuated, slower ones will be passed through. You should decide whether those 100 µs are still too quick and increase the resistance (for example), should you require more filtering.

• I could but I prefer to take care of things at the source :). My software for it was working but this is how it should be done in my opinion. Thanks! I'll try that! Feb 16 '17 at 23:50
• why not increasing the capacitance instead of the resistance? Aug 23 '19 at 2:21
• @m4l490n, you could increase either one Aug 23 '19 at 9:15

Big capacitors demand enough charge to endanger the tiny on-chip transistors that attempt to instantaneously raise the cap voltage to 3.3volts. Hence some current-restricting resistance is needed, and perhaps a smaller capacitor.

If the GPIO is CMOS input (the datasheet will say "zero current" nominally, or much less than 1uA), you can use Rvalues of 100Kohm (brown-black-yellow) and let the ESD structures provide the capacitance.

However, what is the "noise" source? cellphones? battery chargers? electric mixers in the kitchen? You may find some twisted-pair between camera and raspberry [ use 2 colors, so your signal wire remains obvious ] is all you need.

I note you do not show a GND connection from Camera to Raspberry.

• This is all part of a much larger system. The ground from the camera is actually connected it's just far away so to speak. I pulled a ground from the camera and attached it to a ground on the pi and checked the signal on an oscilloscope and it's much cleaner. Testing today to see if it's good enough Feb 17 '17 at 13:53

This sounds like a problem that can be solved with an RC low pass filter but, also consider that a schmitt trigger input can provide decent protection against multiple counts because it works using two analogue thesholds. See the diagram below, left is simple threshold and right is schmitt double threshold: -

(source: howtomechatronics.com)

There are plenty of logic devices featuring schmitt trigger inputs so I'm not suggesting anything overly esoteric here.

You're looking for a debouncing circuit. The simplest hardware form for it is in the form of a low-pass RC filter, even though you may encounter some problems due to slow switching (remaining too much time in the "neither ON nor OFF" region of the input).

Here's the simplest circuit:

However, there are many other types of debouncers, both hardware and software ones, even some "what the hell is that?" ones.