Hello,
I'm trying to light up a LED on GPIO pin 17 when an IR signal is received on GPIO pin 23. LIRC is also configured to listen to IR signals on this PIN through dtoverlay=gpio-ir,gpio_pin=23 in /boot/firmware/config.txt. Most existing guides propose to do this by polling the pin continuously. I would like to do this in an event-based manner. I'm using a RPi 5 on Raspberry Pi OS.
I tried the following:
I get an error saying that the pin is busy:LIRC provides a socket where the IR signals can be read but I don't know how to register an event on a socket. Any help appreciated.
I'm trying to light up a LED on GPIO pin 17 when an IR signal is received on GPIO pin 23. LIRC is also configured to listen to IR signals on this PIN through dtoverlay=gpio-ir,gpio_pin=23 in /boot/firmware/config.txt. Most existing guides propose to do this by polling the pin continuously. I would like to do this in an event-based manner. I'm using a RPi 5 on Raspberry Pi OS.
I tried the following:
Code:
import RPi.GPIO as GPIOfrom time import sleep# initialize GPIOGPIO.setmode(GPIO.BCM)GPIO.setwarnings(False)GPIO.setup(17, GPIO.OUT)GPIO.setwarnings(False)# event functiondef event(ev=None): GPIO.output(17, GPIO.HIGH)# setup the pin and the eventGPIO.setup(23, GPIO.IN, pull_up_down=GPIO.PUD_UP)GPIO.add_event_detect(23, GPIO.RISING, callback=event)while 1: continueCode:
Traceback (most recent call last): File "/home/mathieu/LED_service_pin.py", line 15, in <module> GPIO.setup(23, GPIO.IN, pull_up_down=GPIO.PUD_UP) File "/usr/lib/python3/dist-packages/RPi/GPIO/__init__.py", line 696, in setup _check(lgpio.gpio_claim_input(_chip, gpio, { ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3/dist-packages/lgpio.py", line 755, in gpio_claim_input return _u2i(_lgpio._gpio_claim_input(handle&0xffff, lFlags, gpio)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3/dist-packages/lgpio.py", line 458, in _u2i raise error(error_text(v))lgpio.error: 'GPIO busy'Statistics: Posted by CutterX — Sun Dec 07, 2025 1:47 pm — Replies 0 — Views 21