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?
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)
-
1\$\begingroup\$ 50 seconds of bounce time? Are you breadboard ? \$\endgroup\$Curious KP– Curious KP2020年09月17日 17:43:08 +00:00Commented 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– SChand2020年09月17日 17:55:20 +00:00Commented 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\$Scott Seidman– Scott Seidman2020年09月17日 17:58:48 +00:00Commented 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– user308842020年09月17日 18:03:43 +00:00Commented 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– TonyM2020年09月17日 18:18:18 +00:00Commented Sep 17, 2020 at 18:18
1 Answer 1
R1 is not needed if you use the internal pull down resistor. But put a capcitor (~220nF) on the input side of the gpio.
-
\$\begingroup\$ what would the capacitor's function be? \$\endgroup\$SChand– SChand2020年10月27日 21:39:27 +00:00Commented Oct 27, 2020 at 21:39
-
1\$\begingroup\$ deglitching: The capacitor soaks up external electromagnetic interference. \$\endgroup\$Jasen Слава Україні– Jasen Слава Україні2020年10月28日 21:17:02 +00:00Commented 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– SChand2020年11月09日 19:22:44 +00:00Commented 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– Bill2020年11月11日 19:36:05 +00:00Commented Nov 11, 2020 at 19:36
-
\$\begingroup\$ The ground is used from the Raspberry Pi rail @Bill \$\endgroup\$SChand– SChand2020年11月12日 19:10:47 +00:00Commented Nov 12, 2020 at 19:10
Explore related questions
See similar questions with these tags.