I’m the author of this project, an automated feeding device controlled by a custom 4-button keypad.The device is in use 24/7, since over a year. In rare cases I‘ve noticed fake button events.To be more precise, whenever this happened it was precisely the moment the cat touched the casing with his nose. So I am wondering if it is possible that the cat acts as a capacitor, giving a slight shock to the GPIOs?
I suspect that the problem is the PULL-DOWN configuration. Currently I use a 230 Ohm resistor. I‘ve read in a post about button wiring that this could be too low, but I don‘t know if that is credible or if my problem is related.
EDIT: This is the schematic for the tactile buttons:
simulate this circuit– Schematic created using CircuitLab
(7) provides a 3.3V steady supply from the Raspi Zero.(8), (9), (11), (25) serve as inputs to listen to the individual button clicks.
I use this configuration (lines 52-65) for the GPIOs:
# KEYPAD PINS# PIN layoutkeypadPowerPin = 7button1 = 11button2 = 8button3 = 25button4 = 9GPIO.setup(keypadPowerPin, GPIO.OUT)GPIO.setup(button1, GPIO.IN, GPIO.PUD_DOWN)GPIO.setup(button2, GPIO.IN, GPIO.PUD_DOWN)GPIO.setup(button3, GPIO.IN, GPIO.PUD_DOWN)GPIO.setup(button4, GPIO.IN, GPIO.PUD_DOWN)# Power up 3.3V input pinGPIO.output(keypadPowerPin, 1)
Edit: The listeners to actually handle input events are further down in the referenced listing (lines 344-348):
# Add keypad button handlersGPIO.add_event_detect(button1, GPIO.RISING, callback=button_pressed_callback, bouncetime=300)GPIO.add_event_detect(button2, GPIO.RISING, callback=button_pressed_callback, bouncetime=300)GPIO.add_event_detect(button3, GPIO.RISING, callback=button_pressed_callback, bouncetime=300)GPIO.add_event_detect(button4, GPIO.RISING, callback=button_pressed_callback, bouncetime=300)
Thanks!