0
\$\begingroup\$

I have been using the circuit below. I have noticed there are times the circuit will trigger on its own without any button press. Sometimes it can trigger a few times within an hour. The components are soldered onto a PCB Board. I have my raspberry pi GPIO set as a pull down (GPIO.PUD_DOWN). The interrupt event is triggered on GPIO.RISING and I have a SW bouncetime of 50 seconds. The 3.3V source is connected to the 3.3V and GND rails on the Raspberry Pi. The Raspberry Pi is connected to a wall outlet using a 5V 3A adapter. The wires connecting the GPIO pin to the pushbutton are stranded copper. The distance between the GPIO pin to the pushbutton is about 3-5 inches. I have a PiCamera, 5V 0.5A Motorboard, 10mA Fan and 4 leds (<5mA total) connected to the Raspberry Pi as well in case load would be an issue. Power consumption is about 4 Watts on average.

Is my pull down resistor too low? Possibly a Raspberry Pi GPIO issue? Something else to look into or change circuit wise?

enter image description here

Interrupt Setup via Python:

GPIO.setup(button_gpio,GPIO.IN, pull_up_down=GPIO.PUD_DOWN)
GPIO.add_event_detect(button_gpio,GPIO.RISING, handler_funtion, bouncetime=50000)
\$\endgroup\$
20
  • 1
    \$\begingroup\$ 50 seconds of bounce time? Are you breadboard ? \$\endgroup\$
    – Curious KP
    Sep 17, 2020 at 17:43
  • 1
    \$\begingroup\$ @KiranPhalak I just overshot the number a lot to hopefully guarantee no bouncing signal. It was not the case. So I need to pinpoint the true cause here. I am using a PCB for my circuit. \$\endgroup\$
    – SChand
    Sep 17, 2020 at 17:55
  • 4
    \$\begingroup\$ Where does the 3.3V come from? The Pi? If not, do you have it grounded to the Pi correctly? \$\endgroup\$ Sep 17, 2020 at 17:58
  • 2
    \$\begingroup\$ Typically this circuit would have a capacitor across R1 to debounce environmental noise. 1uF, 0.1uF or 10nF. The capacitance value depends on what rise time can be tolerated for at the GPIO input. That would be my first try. \$\endgroup\$
    – user30884
    Sep 17, 2020 at 18:03
  • 2
    \$\begingroup\$ @user30884, switches don't typically have capacitors across them. It depends on the environment but there's almost always no need. A capacitor causes a slow rise and/or fall time and that's not helping a digital input, particularly if it's not a Schmitt trigger input. Do debouncing in digitally.and remove unnecessary capacitor part and cost. \$\endgroup\$
    – TonyM
    Sep 17, 2020 at 18:18

1 Answer 1

5
\$\begingroup\$

R1 is not needed if you use the internal pull down resistor. But put a capcitor (~220nF) on the input side of the gpio.

\$\endgroup\$
7
  • \$\begingroup\$ what would the capacitor's function be? \$\endgroup\$
    – SChand
    Oct 27, 2020 at 21:39
  • 1
    \$\begingroup\$ deglitching: The capacitor soaks up external electromagnetic interference. \$\endgroup\$ Oct 28, 2020 at 21:17
  • \$\begingroup\$ so in series with the 2.2k R1 I should add a 220nF capacitor? With the capacitor being in-between R1 and the GPIO input? Also, where does external EMI come from? the Pushbutton? Or is it possible the RPi has power fluctuations within it that trigger that GPIO interrupt event? \$\endgroup\$
    – SChand
    Nov 9, 2020 at 19:22
  • \$\begingroup\$ As Scott allready mensioned. Is the ground connected? If you use this input as interrupt input from a switch it can end in problems. Filter at least the input digital. \$\endgroup\$
    – Bill
    Nov 11, 2020 at 19:36
  • \$\begingroup\$ The ground is used from the Raspberry Pi rail @Bill \$\endgroup\$
    – SChand
    Nov 12, 2020 at 19:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.