Kodi Tutorial: Programming LIRC
Tuesday 2nd October 2018 10:39pm
What Is LIRC?
LIRC is a package that allows you to decode and send infra-red signals of many (but not all) commonly used remote controls.
Any Old Remote Control
The last option is to make use of an existing remote control you have lying around the house, but this requires a bit of soldering and wiring to the internal GPIO (General Purpose Input Output) pins of the Raspberry Pi and also requires LIRC (Linux Infrared Remote Control). LIRC is a mature and stable open source library that provides the ability to send and receive IR commands.
Wiring the Infrared Receiver to the Raspberry Pi, The Vishay TSOP31438 has 3 pins:
- Pin1 is DATA, goes to RPi pin 12 (GPIO 18)
- Pin2 is GND, goes to RPi pin 6 (GROUND)
- Pin3 is POWER, goes to RPi pin 1 (3.3V)
Connect to the Raspberry Pi using SSH (I use putty download from here) and type hostname as osmc (or the IP address of the Pi) connecting to port 22 and then click ‘Open’ if you get a security warning click onto ‘Yes’ to except:
This will present a shell command on the Raspberry Pi. Login using the default settings username osmc and password osmc:
At the command prompt type:
This will display a list of available names used to record the keystrokes sent from the IR remote control. Compare the names in this list to the buttons on your remote once you have a list of names that correspond with the buttons we are ready to begin mapping. At the command prompt type:
sudo /etc/init.d/lirc stop
This stops the LIRC service to free up /dev/lirc0
Type the following to start recording of key presses:
Irrecord –d /dev/lirc0 ~/lircd.conf
Press Return to start recording of key strokes.
Type the name of each key stroke followed by the return key.
Now point the remote press and hold the corresponding button:
Do this for each button in turn. Once you have finished press ‘Return’ this will save the new configuration file.
Next we make a copy of the old lircd.conf file:
sudo cp lircd.conf lircd-old.conf
Now delete the old lircd.conf file:
sudo rm lircd.conf
Make a copy of the lircd.conf.conf file:
sudo cp lircd.conf.conf lircd.conf
Now delete the old lircd.conf.conf file:
sudo rm lircd.conf.conf
Reboot to apply the new changes:
When the raspberry pi reboots wait for the lirc connection to apply and now your remote should start working.