Here's a little tutorial on how to setup an IR Receiver on OpenELEC/Kodi in side one of our Head Case's
Activate Device Tree Overlay
First we need to edit our config.txt file. To do this, we need to make the flash directory writable:
mount -o remount,rw /flash
Now we can edit the config.txt within this directory
You need to add the following to the end of the config.txt
Once we have finished editing config.txt make sure to make the flash directory read-only again.
mount -o remount,ro /flash
Time to reboot to make our config changes active.
Connecting the IR Receiver
Once we have enabled the device tree overlay, we need to hook up our IR receiver to the Pi. Whenever you are plugging things into the GPIO of the Pi, always make sure the Pi is powered OFF, as to not short out anything and damage the Pi.
Start by shutting down the Pi
IR Receivers contain a semiconductor/chip inside them, so they need to be powered in some way (always check the datasheet for your specific receiver) before they can be tested. In this case, the receiver can be powered by 5V
Now using 3 female to female jumper wires, attach your IR receiver to your Pi:
Pin 1 is DATA, goes to RPi pin 12 (GPIO 18)
Pin 2 is GND, goes to RPI pin 6 (GROUND)
Pin 3 is POWER, goes RPi pin 1 (5V)
If you have different receiver you may have different pinout. Check the datasheet for you receiver.
With the receiver connected, we now need to run the wires out through a little gap at the back of the case, so that the IR receiver is on the outside of the case.
Using a bit of tape, stick the IR Receiver to the back of the case, making sure that it’s facing towards the front of the case. If you are using the TSOP382, then the side with the little lump on it is the front.
Testing the IR Receiver
To check if the IR Receiver is working on the Pi, simply run the following commands one after each other:
mode2 -d /dev/lirc0
Now, when you press buttons on your remote, assuming your receiver is connected correctly, you should see something resembling this appear on the screen with each press:
If nothing happens when you press buttons on your remote, please check the following:
Make sure the IR Receiver has been connected to the Pi correctly
Make sure the remote is working (try a different remote if you have one, change the batteries etc...)
Recording your remote
Before going through this process, have a look here: http://lirc.sourceforge.net/remotes/ and see if your remote has already had a lircd.conf created for it. If it has, then copy the lircd.conf file to this directory: /storage/.config/lircd.conf and reboot. You should now have a working remote!
(If you find the lircd.conf you have downloaded has incorect KEY mappings, then you can record your own)
First thing to do is to get the list of KEY commands that are accepted.
To do this, run the following commands (remember to copy the list that you get and save it somewhere, as you'll need them later)
irrecord --list-namespace | grep KEY
Once you have saved this list you are ready to record your remote.
To record your remote, run the following commands
Follow the instructions given by irrecord exactly.
When you get to the bit where you are asked "Please enter the name for the next button (press
This is where you start to configure each button.
So pick a button on the remote you want to configure, for example on our IR Remote Control, the first button is the Volume Down button.
So we need to find the KEY command that we want to associate with the Volume Down button. In this case, it makes sense to use the KEY_VOLUMEDOWN key. You can however configure any KEY command to any button.
Once you have found the KEY command for the button you want configure, simply enter that KEY and hit ENTER, you should now be prompted to press and hold the button on the remote you want to assign to this KEY.
Now do that for every button you want to use on the remote.
After you have configured the last button, simply hit ENTER to stop recording.
You'll then be asked to repeatedly press an arbitary button as fast as you can (make sure you press the same button each time, and that you don't hold the button down).
The recording has now been completed, and hopefully our lircd.conf has been created (this can be found here: /storage/.config/lircd.conf)
Now all that’s left to do is reboot, then you can start using your remote control!