Im trying to get my Pi to take input from an IR remote using lirc. But it is not working. Ive tried a few different tutorials like this one that basically did the same thing.

One problem here is the the Pi couldnt find /etc/init.d/lirc, so i could not stop it. The test (mode2 -d /dev/lirc0) also fails, it does not tell me anything.

Under /boot/config.txt I have


hardware.conf is

# /etc/lirc/hardware.conf
# Arguments which will be used when launching lircd

# Don't start lircmd even if there seems to be a good config file

# Don't start irexec, even if a good config file seems to exist.

# Try to load appropriate kernel modules

# Run "lircd --driver=help" for a list of supported drivers.
# usually /dev/lirc0 is the correct setting for systems using udev

Also the wiring is like this enter image description here

Here is how I got it to work. First of all: I use the latest Raspbian Stretch Lite 2018-03-13. With this version there is no /etc/lirc/hardware.conf anymore if you install lirc. You should also use up to date versions.

In /boot/config.txt enable overlay lirc-rpi. GPIO 17 out and GPIO 18 in are default and you can omit their settings. I have added them if you use other pins. You can find the settings in /boot/overlays/README.

# Uncomment this to enable the lirc-rpi module

Install lirc:

rpi3 ~$ sudo apt update
rpi3 ~$ sudo apt install lirc

Edit /etc/lirc/lirc_options.conf and change this settings to:

driver = default
device = /dev/lirc0


rpi3 ~$ sudo systemctl reboot

After login you should have a lirc0 device and see something like:

rpi3 ~$ ls -l /dev/lirc0
crw-rw---- 1 root video 244, 0 2018-01-28 16:58 /dev/lirc0
rpi3 ~$ lsmod | grep lirc
lirc_rpi                9032  3
lirc_dev               10583  1 lirc_rpi
rc_core                24377  1 lirc_dev

Check services with:

rpi3 ~$ systemctl status lircd.service
rpi3 ~$ systemctl status lircd.socket

Now you can test if you get signals. Start mode2 and push some buttons on your remote control. mode2 should show you very low level info in space and pulse:

rpi3 ~$ sudo systemctl stop lircd.service
rpi3 ~$ sudo systemctl stop lircd socket
rpi3 ~$ sudo mode2 --driver default --device /dev/lirc0

If everything is OK to this, we can start lirc again:

rpi3 ~$ sudo systemctl start lircd socket
rpi3 ~$ sudo systemctl start lircd.service

Now we need a configuration file that maps the lirc pulses to the buttons of your remote control. On the internet there is a database with many config files for remote controls. the config file for my remote control I have found there. If you cannot find yours you have to training your remote control by yourself with:

rpi3 ~$ sudo irrecord -n -d /dev/lirc0 ~/lircd.conf

That's your exercise ;-) Haven't tested it. If you have your config file move it to
and restart lirc to load this file:

rpi3 ~$ sudo systemctl restart lircd

Now we can look if we get the pushed buttons. Start irw and push buttons on your remote control. You should get something like:

rpi3 ~$ irw
0000000000002422 00 KEY_VOLUMEUP Sony_RMT-CS33AD
0000000000002422 01 KEY_VOLUMEUP Sony_RMT-CS33AD
0000000000002422 02 KEY_VOLUMEUP Sony_RMT-CS33AD
0000000000006422 00 KEY_VOLUMEDOWN Sony_RMT-CS33AD
0000000000006422 01 KEY_VOLUMEDOWN Sony_RMT-CS33AD
0000000000006422 02 KEY_VOLUMEDOWN Sony_RMT-CS33AD

Last step is to give these events actions, e.g. start a program. For this we use the program irexec. This needs its config file ~/.config/lircrc with entries like this (simple example):

prog = irexec
config = echo "Volume-Up"
prog = irexec
config = echo "Volume-Down"

For any button add a new block begin ... end. The button name is exact the name you get with irw. As action (line config =) I do a simple echo so you can see on the console what button was pressed. Here you can call any other program, e.g. system programs, bash scripts, python programs, what you want. Look at man irexec.

Thanks to manthony121 in his last comment.

Have fun :-)

Your Answer


By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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