pythongpioraspberry-pi4

RPi.GPIO add_event_detect are sometimes ignored


I'm working on a project that is using GPIO(BCM) 17, 27, 22, 5 and 6.

Events on pin 17 are detected pretty well, but GPIO 27 is really reluctant to trigger events. they seems to get detected with a bit of delay...

I'm using a RPI4 with buster lite.

This is a video showing the issue

https://youtu.be/bLXQkA1bzKA

there is a photo of the wiring

This is the snippet that I'm using in the video in python3

import RPi.GPIO as GPIO

GPIO.setmode(GPIO.BCM)
GPIO.setup(27, GPIO.IN, pull_up_down=GPIO.PUD_UP)

def my_callback(channel):
        print("event!")
GPIO.add_event_detect(27, GPIO.FALLING, callback=my_callback, bouncetime=300)

while True:
    pass

Is there any better methods to detect button press? are there GPIO that must be avoided in the RaspberryPi platform ? Or maybe I'm doing something completely wrong...?


Solution

  • I already had a Pi with some strange IO behaviour. It was from the early batch of the Pi4. Keep in mind that Raspberry Pi are really cheaply made and even the slightest noise in the PSU or just bad luck in the silicon lottery can make the Pi an unreliable device. Just to be sure, swap the PSU (even if it's an official one) and if this doesn't solve the problem just ask for an RMA to your provider.