Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Getting lirc to work with Raspberry Pi 3 (Raspbian Stretch)
Notes to make IR shield (made by LinkSprite) work in Raspberry Pi 3 (bought from Amazon [1]).
The vendor has some documentation [2] but that is not complete and sufficient for Raspbian Stretch.
Following are the changes that I made to make it work.
$ sudo apt-get update
$ sudo apt-get install lirc
# Add the following lines to /etc/modules file
lirc_dev
lirc_rpi gpio_in_pin=18 gpio_out_pin=17
# Add the following lines to /etc/lirc/hardware.conf file
LIRCD_ARGS="--uinput --listen"
LOAD_MODULES=true
DRIVER="default"
DEVICE="/dev/lirc0"
MODULES="lirc_rpi"
# Update the following line in /boot/config.txt
dtoverlay=lirc-rpi,gpio_in_pin=18,gpio_out_pin=17
# Update the following lines in /etc/lirc/lirc_options.conf
driver = default
device = /dev/lirc0
$ sudo /etc/init.d/lircd stop
$ sudo /etc/init.d/lircd start
# Check status to make lirc is running
$ sudo /etc/init.d/lircd status
# Reboot before testing
$ reboot
# To test if lirc driver is working
$ sudo /etc/init.d/lircd stop
$ mode2 -d /dev/lirc0
<press a key in remote and you should see multple lines like below>
pulse 560
space 1706
pulse 535
# to record a custom remote/register a remote device
$ sudo /etc/init.d/lircd stop
$ sudo irrecord -d /dev/lirc0 ~/lircd.conf
# follow the instruction prompted by the above command carefully
# at the end ~/lircd.conf file will be generated
# backup the original lircd.conf
$ sudo mv /etc/lirc/lircd.conf /etc/lirc/lircd_original.conf
$ sudo cp ~/lircd.conf /etc/lirc/lircd.conf
$ sudo /etc/init.d/lircd start
# you can test if the recorded remote works by
$ irsend SEND_ONCE <device-name> KEY_POWER
$ irsend SEND_ONCE <device-name> KEY_VOLUMEUP
[1] https://www.amazon.com/Infrared-Shield-for-Raspberry-Pi/dp/B00K2IICKK/ref=pd_sbs_328_1?_encoding=UTF8&psc=1&refRID=1QPY33VFCGETBJ17K8QE
[2] http://learn.linksprite.com/raspberry-pi/shield/infrared-transceiver-on-raspberry-pi-lirc-software-installation-and-configuration/
@Richard210363

This comment has been minimized.

Show comment Hide comment
@Richard210363

Richard210363 Nov 12, 2017

This is the only place amongst the many I have looked at that is both carefully written and laid out, and works.

Well Done and thanks

This is the only place amongst the many I have looked at that is both carefully written and laid out, and works.

Well Done and thanks

@felixfischer

This comment has been minimized.

Show comment Hide comment
@felixfischer

felixfischer Nov 12, 2017

Exactly what I wanted to say :)

Thank you @prasanthj!

Exactly what I wanted to say :)

Thank you @prasanthj!

@thierrytien

This comment has been minimized.

Show comment Hide comment
@thierrytien

thierrytien Nov 21, 2017

i like this

i like this

@OberstVonGatow

This comment has been minimized.

Show comment Hide comment
@OberstVonGatow

OberstVonGatow Dec 3, 2017

Only Tutorial that worked! Thank You

Only Tutorial that worked! Thank You

@sandman112

This comment has been minimized.

Show comment Hide comment
@sandman112

sandman112 Dec 18, 2017

spent the last 4-5 hours trying to get this to work on an old RPI 1 and energenie IR board, this worked perfectly

one thing I would add that I found elsewhere is to run the following command as well ...

sudo /usr/share/lirc/lirc-old2new

while this might not have been the cause of my problems this is where I managed to get things to start working, but the above sorted things out ...

sandman112 commented Dec 18, 2017

spent the last 4-5 hours trying to get this to work on an old RPI 1 and energenie IR board, this worked perfectly

one thing I would add that I found elsewhere is to run the following command as well ...

sudo /usr/share/lirc/lirc-old2new

while this might not have been the cause of my problems this is where I managed to get things to start working, but the above sorted things out ...

@Alkuimista

This comment has been minimized.

Show comment Hide comment
@Alkuimista

Alkuimista Dec 28, 2017

HI, I'm trying to get lirc working on Strech, but theres no "/etc/lirc/hardware.conf" because it's version 0.9.4 for what I've been told:
In Raspian Stretch lirc 0.9.4 is included in the Debian package. The configuration is slightly different : - The hardware.conf file is not supported, obsoleted by a new lirc_options.conf file and systemd unit definitions.
Should I create the hardware.conf file?
Thanks in advanced

HI, I'm trying to get lirc working on Strech, but theres no "/etc/lirc/hardware.conf" because it's version 0.9.4 for what I've been told:
In Raspian Stretch lirc 0.9.4 is included in the Debian package. The configuration is slightly different : - The hardware.conf file is not supported, obsoleted by a new lirc_options.conf file and systemd unit definitions.
Should I create the hardware.conf file?
Thanks in advanced

@siggi60

This comment has been minimized.

Show comment Hide comment
@siggi60

siggi60 Jan 2, 2018

@prasanthj Very good How-to, but, as remarked by Alkuimista, there's no hardware.conf file.
Do you have a solution to solve the new way of integration?

Best regards and, of course, happy new Year :)

siggi60 commented Jan 2, 2018

@prasanthj Very good How-to, but, as remarked by Alkuimista, there's no hardware.conf file.
Do you have a solution to solve the new way of integration?

Best regards and, of course, happy new Year :)

@ageorgios

This comment has been minimized.

Show comment Hide comment
@ageorgios

ageorgios Jan 4, 2018

hardware.conf missing here too
Raspbian GNU/Linux 9 (stretch)
latest lirc

hardware.conf missing here too
Raspbian GNU/Linux 9 (stretch)
latest lirc

@grigrichaminou

This comment has been minimized.

Show comment Hide comment
@grigrichaminou

grigrichaminou Jan 6, 2018

Thank you very much for making this work. I looked for a long time but nothing worked. now everything is operational.

Thank you very much for making this work. I looked for a long time but nothing worked. now everything is operational.

@dominikbrandon

This comment has been minimized.

Show comment Hide comment
@dominikbrandon

dominikbrandon Jan 6, 2018

@Alkuimista @siggi60 @ageorgios
simply create the file and paste the settings. works for me.

also, i have faced a problem where everything seemed to work fine, but i didn't get any output running irw command. in case someone's stuck there: the problem is lircd.conf file which you've just generated. take a look at it - you probably will get two hex codes for each button, where the second one is always the same. simply delete this value from each line and everything should work now.

@Alkuimista @siggi60 @ageorgios
simply create the file and paste the settings. works for me.

also, i have faced a problem where everything seemed to work fine, but i didn't get any output running irw command. in case someone's stuck there: the problem is lircd.conf file which you've just generated. take a look at it - you probably will get two hex codes for each button, where the second one is always the same. simply delete this value from each line and everything should work now.

@jimbob-1

This comment has been minimized.

Show comment Hide comment
@jimbob-1

jimbob-1 Jan 13, 2018

Hi Guys,
Same issues here, every single one of your issues I had. Segmentation Fault, "read 8 bytes", etc. I tried everything (including moving rooms, but still had problems!)

I might have something that someone else might find useful, that I couldn't find anywhere else on the web.

Details:
#################################
I'm running Debian Stretch.
Raspberry Pi Zero W (doesnt matter what version, all the same)
pi@raspberrypi:~ $ apt list lirc
Listing... Done
lirc/stable,now 0.9.4c-9 armhf [installed]
#################################

Some of your issues I "resolved" by jumping around the web, but this one was what solved it all for me.

  1. I apt-get remove lirc
  2. then apt-get purge lirc (no backtick of course).
  3. Followed what @prasanthj had to say in the above noted guide.
  4. Stopped lircd.service and lirc.socket (systemctl stop lircd.....xyz)

My biggest issue was non-cfl... IR noise, even with the TSOP in a cardboard box (with a lid loosely on). I'm in practical darkness (where the sporadic noise is)

mode -2 /dev/lirc0 kept saying "received 8 bytes" or "received 12 bytes", and would stop without any remote input.

irrecord kept telling me that it was detecting "170 bytes" but that it was minimal noise. Once I moved it to the GOOD location in my house, it stopped reporting any sign of IR. "No significant noise (received 0 bytes)" is what you want IRRECORD to say; anything else and YOU WILL HAVE PROBLEMS.

Another would be dead give away: irrecord would ask for button input, then a second or two later (before I press the button) it would say that it received a signal.
Should have been a dead giveaway, but the last and final was what really helped.

What really helped conclude was: cat /dev/lirc0, and seeing tons of random jibberish all across my screen for 30 seconds (and would pause for a couple seconds, then repeat). I would expect to see non-unicode characters, but ONLY when I press the button! No other time, because it is NOISE! Maybe a few characters are acceptable (here and there)...

While running cat /dev/lirc0 and moving the TSOP38328 sensor: I noticed it dropped right off as soon as I left my dark living room.

I can't believe that someone (myself) dealing with RF on a day to day basis; took 3 days to figure out this problem!

Thanks to all!

Hi Guys,
Same issues here, every single one of your issues I had. Segmentation Fault, "read 8 bytes", etc. I tried everything (including moving rooms, but still had problems!)

I might have something that someone else might find useful, that I couldn't find anywhere else on the web.

Details:
#################################
I'm running Debian Stretch.
Raspberry Pi Zero W (doesnt matter what version, all the same)
pi@raspberrypi:~ $ apt list lirc
Listing... Done
lirc/stable,now 0.9.4c-9 armhf [installed]
#################################

Some of your issues I "resolved" by jumping around the web, but this one was what solved it all for me.

  1. I apt-get remove lirc
  2. then apt-get purge lirc (no backtick of course).
  3. Followed what @prasanthj had to say in the above noted guide.
  4. Stopped lircd.service and lirc.socket (systemctl stop lircd.....xyz)

My biggest issue was non-cfl... IR noise, even with the TSOP in a cardboard box (with a lid loosely on). I'm in practical darkness (where the sporadic noise is)

mode -2 /dev/lirc0 kept saying "received 8 bytes" or "received 12 bytes", and would stop without any remote input.

irrecord kept telling me that it was detecting "170 bytes" but that it was minimal noise. Once I moved it to the GOOD location in my house, it stopped reporting any sign of IR. "No significant noise (received 0 bytes)" is what you want IRRECORD to say; anything else and YOU WILL HAVE PROBLEMS.

Another would be dead give away: irrecord would ask for button input, then a second or two later (before I press the button) it would say that it received a signal.
Should have been a dead giveaway, but the last and final was what really helped.

What really helped conclude was: cat /dev/lirc0, and seeing tons of random jibberish all across my screen for 30 seconds (and would pause for a couple seconds, then repeat). I would expect to see non-unicode characters, but ONLY when I press the button! No other time, because it is NOISE! Maybe a few characters are acceptable (here and there)...

While running cat /dev/lirc0 and moving the TSOP38328 sensor: I noticed it dropped right off as soon as I left my dark living room.

I can't believe that someone (myself) dealing with RF on a day to day basis; took 3 days to figure out this problem!

Thanks to all!

@josemotta

This comment has been minimized.

Show comment Hide comment
@josemotta

josemotta Jan 15, 2018

Hi @Alkuimista, the link below has info about new setup for Raspberry Raspbian Stretch Lircd version 0.9.4c

https://github.com/josemotta/IoT.Starter.Api/tree/master/gpio-base

Hi @Alkuimista, the link below has info about new setup for Raspberry Raspbian Stretch Lircd version 0.9.4c

https://github.com/josemotta/IoT.Starter.Api/tree/master/gpio-base

@unnamalai-kb

This comment has been minimized.

Show comment Hide comment
@unnamalai-kb

unnamalai-kb Jan 24, 2018

I am running Raspbian Stretch with Desktop (kernel version 4.9) on a Raspberry Pi 3. and ANAVI Infrared pHAT IR board. I followed the steps as in this how-to. Created a hardware.conf as this was missing . But when I tried recording a panasonic aircon remote, it failed to create .conf file and seemed to hung in irrecord after two lines of dots of button presses.

Any help on this?

log

pi@raspberrypi:~ $ sudo irrecord -d /dev/lirc0 ~/lircd.conf
Running as regular user pi
Using driver default on device /dev/lirc0

irrecord - application for recording IR-codes ----


Press RETURN to continue.

Checking for ambient light creating too much disturbances.
Please don't press any buttons, just wait a few seconds...

No significant noise (received 0 bytes)

Enter name of remote (only ascii, no spaces) :panasonicir
Using panasonicir.lircd.conf as output filename

Now start pressing buttons on your remote control.

It is very important that you press many different buttons randomly
and hold them down for approximately one second. Each button should
generate at least one dot but never more than ten dots of output.
Don't stop pressing buttons until two lines of dots (2x80) have
been generated.

Press RETURN now to start recording.
................................................................................
Got gap (78301 us)}

Please keep on pressing buttons like described above.
...............................................................................

I am running Raspbian Stretch with Desktop (kernel version 4.9) on a Raspberry Pi 3. and ANAVI Infrared pHAT IR board. I followed the steps as in this how-to. Created a hardware.conf as this was missing . But when I tried recording a panasonic aircon remote, it failed to create .conf file and seemed to hung in irrecord after two lines of dots of button presses.

Any help on this?

log

pi@raspberrypi:~ $ sudo irrecord -d /dev/lirc0 ~/lircd.conf
Running as regular user pi
Using driver default on device /dev/lirc0

irrecord - application for recording IR-codes ----


Press RETURN to continue.

Checking for ambient light creating too much disturbances.
Please don't press any buttons, just wait a few seconds...

No significant noise (received 0 bytes)

Enter name of remote (only ascii, no spaces) :panasonicir
Using panasonicir.lircd.conf as output filename

Now start pressing buttons on your remote control.

It is very important that you press many different buttons randomly
and hold them down for approximately one second. Each button should
generate at least one dot but never more than ten dots of output.
Don't stop pressing buttons until two lines of dots (2x80) have
been generated.

Press RETURN now to start recording.
................................................................................
Got gap (78301 us)}

Please keep on pressing buttons like described above.
...............................................................................

@unnamalai-kb

This comment has been minimized.

Show comment Hide comment
@unnamalai-kb

unnamalai-kb Jan 26, 2018

I am now able to control the Panasonic aircon with anavi infrared phat on a raspberry pi board :-) by following the steps in the tutorial link https://www.cnx-software.com/2017/03/12/how-to-control-your-air-conditioner-with-raspberry-pi-board-and-anavi-infrared-phat/. Then, I had to update the lircd.conf file with the gap value that I had obtained in the past using irrecord (see my log posted earlier). The gap value was 78301 us.
Just a side note, for the latest Raspbian Stretch, it didn't require to update /etc/modules and /etc/lirc/hardware.conf.

I am now able to control the Panasonic aircon with anavi infrared phat on a raspberry pi board :-) by following the steps in the tutorial link https://www.cnx-software.com/2017/03/12/how-to-control-your-air-conditioner-with-raspberry-pi-board-and-anavi-infrared-phat/. Then, I had to update the lircd.conf file with the gap value that I had obtained in the past using irrecord (see my log posted earlier). The gap value was 78301 us.
Just a side note, for the latest Raspbian Stretch, it didn't require to update /etc/modules and /etc/lirc/hardware.conf.

@barsznica

This comment has been minimized.

Show comment Hide comment
@barsznica

barsznica Feb 25, 2018

I used that, too!

Just had to remove the trailing "large value" from every command, as well as the large one near the beginning.

barsznica commented Feb 25, 2018

I used that, too!

Just had to remove the trailing "large value" from every command, as well as the large one near the beginning.

@kdpatino

This comment has been minimized.

Show comment Hide comment
@kdpatino

kdpatino Mar 2, 2018

Hello! Do you know if it could work in GPIO16=IN and GPIO13=OUT? I'm testing with these pins and it not work for me 😭

kdpatino commented Mar 2, 2018

Hello! Do you know if it could work in GPIO16=IN and GPIO13=OUT? I'm testing with these pins and it not work for me 😭

@kdpatino

This comment has been minimized.

Show comment Hide comment
@kdpatino

kdpatino Mar 5, 2018

Just to Update. Thank You! I followed it and works on my MATRIX Creator Thank You!!!

kdpatino commented Mar 5, 2018

Just to Update. Thank You! I followed it and works on my MATRIX Creator Thank You!!!

@luyge

This comment has been minimized.

Show comment Hide comment
@luyge

luyge Mar 28, 2018

Tks my friend.
I install my RC using lircd on OSMC and now migrate to raspbian.
Only put my file .conf in new system and works
...best

luyge commented Mar 28, 2018

Tks my friend.
I install my RC using lircd on OSMC and now migrate to raspbian.
Only put my file .conf in new system and works
...best

@mcblacky

This comment has been minimized.

Show comment Hide comment
@mcblacky

mcblacky Mar 31, 2018

For lircd 0.9.4c Rpi3 with PiFi DAC+ v2.0 and Humax RM-F04 remote
Add dtoverlay=lirc-rpi,gpio_in_pin=26 into /boot/config.txt

Install lirc
sudo apt-get install lirc

Download the index from the remote repository
sudo irdb-get update

Find your remote
sudo irdb-get find humax

Download your remote
sudo irdb-get download humax/RM-F04.lircd.conf

Copy your remote
sudo cp RM-F04.lircd.conf /etc/lirc/lircd.conf.d/

Change etc/lirc/lircd.conf/lirc_options.conf
sudo nano /etc/lirc/lircd.conf/lirc_options.conf
Change following items:
driver = default
device = /dev/lirc0

Restart lirc deamon
systemctl restart lircd.service
Check if loaded without errors
sudo systemctl status lircd.socket lircd.service

Check your remote with command irw

With pressing remote Vol-Up output should be like this:
000000000008f807 00 KEY_VOLUMEUP humax
000000000008f807 01 KEY_VOLUMEUP humax
000000000008f807 02 KEY_VOLUMEUP humax

mcblacky commented Mar 31, 2018

For lircd 0.9.4c Rpi3 with PiFi DAC+ v2.0 and Humax RM-F04 remote
Add dtoverlay=lirc-rpi,gpio_in_pin=26 into /boot/config.txt

Install lirc
sudo apt-get install lirc

Download the index from the remote repository
sudo irdb-get update

Find your remote
sudo irdb-get find humax

Download your remote
sudo irdb-get download humax/RM-F04.lircd.conf

Copy your remote
sudo cp RM-F04.lircd.conf /etc/lirc/lircd.conf.d/

Change etc/lirc/lircd.conf/lirc_options.conf
sudo nano /etc/lirc/lircd.conf/lirc_options.conf
Change following items:
driver = default
device = /dev/lirc0

Restart lirc deamon
systemctl restart lircd.service
Check if loaded without errors
sudo systemctl status lircd.socket lircd.service

Check your remote with command irw

With pressing remote Vol-Up output should be like this:
000000000008f807 00 KEY_VOLUMEUP humax
000000000008f807 01 KEY_VOLUMEUP humax
000000000008f807 02 KEY_VOLUMEUP humax

@null-loop

This comment has been minimized.

Show comment Hide comment
@null-loop

null-loop Apr 14, 2018

Just wanted to echo other peoples comments - best description of how to get everything setup I've found. Thank you for your efforts.

Just wanted to echo other peoples comments - best description of how to get everything setup I've found. Thank you for your efforts.

@markusamuel

This comment has been minimized.

Show comment Hide comment
@markusamuel

markusamuel Apr 14, 2018

Thanks a lot ! I was having a rough time making this work on RPi

Thanks a lot ! I was having a rough time making this work on RPi

@LachlanHogan

This comment has been minimized.

Show comment Hide comment
@LachlanHogan

LachlanHogan May 2, 2018

Anyone else using Raspbian Stretch that runs into the error: Info: Cannot configure the rc device for /dev/lirc0 try following the last comment in the bug report: https://sourceforge.net/p/lirc/tickets/168/

When I recorded signals with irrecord, I got:

begin codes
      KEY_POWER                0x219E48B7 0x7E825B6C
      KEY_HOME                 0x219E609F 0x7E825B6C
      KEY_UP                   0x219EA05F 0x7E825B6C
      KEY_LEFT                 0x219EE01F 0x7E825B6C
      KEY_ENTER                0x219E10EF 0x7E825B6C
      KEY_RIGHT                0x219E906F 0x7E825B6C
      KEY_DOWN                 0x219E00FF 0x7E825B6C
      KEY_BACK                 0x219ED827 0x7E825B6C
      KEY_STOP                 0x219E20DF 0x7E825B6C
      KEY_OPTION               0x219E58A7 0x7E825B6C
      KEY_REWIND               0x219EF807 0x7E825B6C
      KEY_PLAYPAUSE            0x219E50AF 0x7E825B6C
      KEY_FASTFORWARD          0x219E7887 0x7E825B6C
      KEY_PREVIOUS             0x219E40BF 0x7E825B6C
      KEY_NEXT                 0x219E807F 0x7E825B6C
      KEY_SEARCH               0x219EF00F 0x7E825B6C
      KEY_EJECTCD              0x219E08F7 0x7E825B6C
  end codes

After installing this configuration file at /etc/lirc/lircd.conf.d and rebooting, irw produced no output, though I could see using strace
that my /usr/sbin/lircd --nodaemon process was reading data from /dev/lirc0. Removing the 0x7E825B6C codes from each of the
above lines and rebooting caused irw to begin showing the key values in the left column above when I pressed the corresponding
buttons on my WD TV Live remote control.

After I removed the right hand codes from my *.lircd.conf file it all started working nicely!

LachlanHogan commented May 2, 2018

Anyone else using Raspbian Stretch that runs into the error: Info: Cannot configure the rc device for /dev/lirc0 try following the last comment in the bug report: https://sourceforge.net/p/lirc/tickets/168/

When I recorded signals with irrecord, I got:

begin codes
      KEY_POWER                0x219E48B7 0x7E825B6C
      KEY_HOME                 0x219E609F 0x7E825B6C
      KEY_UP                   0x219EA05F 0x7E825B6C
      KEY_LEFT                 0x219EE01F 0x7E825B6C
      KEY_ENTER                0x219E10EF 0x7E825B6C
      KEY_RIGHT                0x219E906F 0x7E825B6C
      KEY_DOWN                 0x219E00FF 0x7E825B6C
      KEY_BACK                 0x219ED827 0x7E825B6C
      KEY_STOP                 0x219E20DF 0x7E825B6C
      KEY_OPTION               0x219E58A7 0x7E825B6C
      KEY_REWIND               0x219EF807 0x7E825B6C
      KEY_PLAYPAUSE            0x219E50AF 0x7E825B6C
      KEY_FASTFORWARD          0x219E7887 0x7E825B6C
      KEY_PREVIOUS             0x219E40BF 0x7E825B6C
      KEY_NEXT                 0x219E807F 0x7E825B6C
      KEY_SEARCH               0x219EF00F 0x7E825B6C
      KEY_EJECTCD              0x219E08F7 0x7E825B6C
  end codes

After installing this configuration file at /etc/lirc/lircd.conf.d and rebooting, irw produced no output, though I could see using strace
that my /usr/sbin/lircd --nodaemon process was reading data from /dev/lirc0. Removing the 0x7E825B6C codes from each of the
above lines and rebooting caused irw to begin showing the key values in the left column above when I pressed the corresponding
buttons on my WD TV Live remote control.

After I removed the right hand codes from my *.lircd.conf file it all started working nicely!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment