I wanted to create a remote for a small tvscreen using Lirc and python. After booting I'm able to send commands from CLI (irsend) and it works. However when I start a Python scripts to read button inputs I receive various errors. "irsend command failed transmission failed" or "Hardware not supported" it depends on wether I start lirc first or python script. lirc is using GPIO 23 (I also tried other pins) Python is using GPIO 17,18,22,27


import RPi.GPIO as GPIO
from subprocess import call
import uinput
import time
GPIO.setup(17, GPIO.IN,pull_up_down=GPIO.PUD_UP)
GPIO.setup(18, GPIO.IN,pull_up_down=GPIO.PUD_UP)
GPIO.setup(22, GPIO.IN,pull_up_down=GPIO.PUD_UP)
GPIO.setup(27, GPIO.IN,pull_up_down=GPIO.PUD_UP)
events = (uinput.KEY_ESC,)
device = uinput.Device(events)

def VolUp(channel):
def VolDown(channel): 
def Input(channel):
def EscButton(): #Send Esc Key (like keyboard)
     device.emit(uinput.KEY_ESC, 1) # Press.
     device.emit(uinput.KEY_ESC, 0) # Release.

GPIO.add_event_detect(18, GPIO.RISING, callback=VolUp)
GPIO.add_event_detect(22, GPIO.RISING, callback=VolDown)
GPIO.add_event_detect(27, GPIO.RISING, callback=Input)

while True:
        GPIO.wait_for_edge(17, GPIO.FALLING)  

    except KeyboardInterrupt:  

Any Ideas why I'm having this behaviour? Can using pyLirc solve this?

  • 1
    I'd try a different Python GPIO module to see if it's related to RPi.GPIO or not. Which version are you using? pydoc RPi.GPIO shows a VERSION of 0.5.11 on my Pi. – joan Oct 7 '15 at 8:00
  • I updated yesterday. So that would be 0.5.11 as well. Which GPIO module are you suggesting? – Stapper Oct 7 '15 at 8:04
  • 1
    If you have RPIO that should be a direct replacement (but I'm not sure if it works on the Pi2). Any of the other Python GPIO modules would need tweaking to allow for callback differences. – joan Oct 7 '15 at 8:06

After rewriting this in C I faced the same issue. I was able to get it function by reloading the Lirc_rpi module and restarting the lirc Deamon. Lirc_rpi does set default pins if no pin out or pin in is given. So I had to set it explicity since the default pins are already in use by the script.

The script is roughly the same only added


After setting up the pins. I also removed lirc_rpi from /etc/modules and disabled lirc deamon on boot.


Have you Connected your IR Transmitter with Correct pins? You can Recheck with "http://alexba.in/blog/2013/01/06/setting-up-lirc-on-the-raspberrypi/"

This article gives a clear cut to use the Lirc Library with pi. Also first try to check with simple IRSEND Commands from Rpi's command line when all seems to be set up. Then Move to Python Scripting.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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