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/

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

Exactly what I wanted to say :)

Thank you @prasanthj!

i like this

Only Tutorial that worked! Thank You

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 ...

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 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 :)

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

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

@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.

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 @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

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