Training LIRC IR remotes

TSOP4838 wiring is on the picture. 
Receiver Pin 1 is DATA, goes to RPi pin 12 (GPIO 18);
Receiver Pin 2 is GND, goes to RPI pin 6 (GROUND) 
Recevier Pin 3 is POWER, goes RPi pin 1 (3.3V
If you have different receiver you may have different pinout. Check the datasheet for you receiver!!!


Step 1:

Connect your IR receiver to your GPIO pins as described above. Many thanks to relyt. This is the same for both the TSOP receivers mentioned above. Connect to the 5v pin at your (potential) peril! Make sure to Google the Data Sheet for your receiver as pin positions vary.

Step 2:

We need to make sure that we have an output from the receiver being received by the Pi. To do this, run the following commands:

sudo modprobe lirc_rpi


sudo kill $(pidof lircd)

And finally 

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:

pulse 168
space 4816
pulse 169
space 4784
pulse 1333
space 3638

Assuming this is the case, you can move on to the next step. If not, you may have a faulty receiver, or have it connected wrongly. Go back to the first step and check. If still no joy, I had great responses in this thread to help me. Try it.

Check this thread for a lircd.conf file for your remote, if it exists copy it to /home/pi/lircd.conf you’ll have to remove the .txt from the end of the file. In Raspbmc settings select GPIO remote and custom as type, reboot and your remote should work. If no file was found then continue.

Step 3:

We’re now going to use the command ‘irrecord’ to capture the keypresses from your remote and assign them each a name which is then used by XBMC to create an action.

It is useful to get a list of available commands which XBMC can use, which you can then enter when the irrecord programme asks for them.


sudo kill $(pidof lircd)
irrecord --list-namespace | grep KEY

And copy and paste that list to somewhere handy.

Then, run the irrecord command:

sudo kill $(pidof lircd)
irrecord -d /dev/lirc0 ~/lircd.conf

Irrecord will output to /home/pi/lircd.conf, a file containing the results of your recording. Follow the instructions given by irrecord exactly, selecting the required buttons from the list you copied and pasted a moment ago.

Once you have recorded all required buttons, press enter to exit irrecord.

You should see something like this when you open the file /home/pi/lircd.conf:

# Please make this file available to others
# by sending it to <>
# this config file was automatically generated
# using lirc-0.9.0-pre1(default) on Sat Dec 22 23:05:43 2012
# contributed by
# brand:                       /home/pi/lircd.conf
# model no. of remote control:
# devices being controlled by this remote:
begin remote

name  /home/pi/lircd.conf
bits           16
eps            30
aeps          100

header       9014  4495
one           563  1687
zero          563   548
ptrail        560
repeat       9013  2245
pre_data_bits   16
pre_data       0xEF10
gap          107922
toggle_bit_mask 0x0

begin codes
KEY_UP                   0x02FD
KEY_DOWN                 0x827D
KEY_LEFT                 0xE01F
KEY_RIGHT                0x609F
KEY_ENTER                0x22DD
KEY_MENU                 0xD02F
KEY_BACK                 0x906F
KEY_VOLUMEUP             0x40BF
KEY_VOLUMEDOWN           0xC03F
KEY_1                    0x8877
KEY_2                    0x48B7
KEY_3                    0xC837
KEY_4                    0x28D7
KEY_5                    0xA857
KEY_6                    0x6897
KEY_7                    0xE817
KEY_8                    0x18E7
KEY_9                    0x9867
KEY_0                    0x08F7
end codes

end remote

As you can see, I have relatively few buttons programmed since I am using the standard remote for an LG LCD TV to try and make the Pi as integrated as possible. You may have more. I can confirm that all of the key names given above have the desired effect in XBMC.

AT THIS POINT IF YOU CHECK GPIO RECEIVER AND SELECT CUSTOM REMOTE IN THE RASPBMC SETTINGS APP THEN REBOOT YOUR REMOTE SHOULD WORK AND YOU ARE DONE. It would be a wise idea to copy /home/pi/lircd.conf to a safe location on another computer or some backup media so it will be easy to setup again if something happens to your install.

PLEASE POST YOUR RECORDED LIRCD.CONF TO THIS THREAD for the benefit of others, include a detailed description of the remote including part number if available.

Step 4

What we are now going to do is copy /home/pi/lircd.conf to a configuration file which comes pre-loaded as part of Raspbmc. We make a note of which configuration file we overwrote and then point XBMC to it in the Settings application in XBMC itself (so we ‘trick’ XBMC into thinking it’s being controlled by a pre-programmed remote Tongue).

Before we overwrite anything, it’s a good idea to make a backup of the files that are there as standard (in case one day you actually need to use that remote to control your Pi). I used xbox-lircd.conf, but you may want to use another:

sudo cp /home/pi/lircd.conf /etc/lirc/xbox-lircd.conf

And that concludes your dealings in Terminal Smile

Step 5:

Go into the settings application (Programs/Raspbmc settings). Scroll across to the IR Remote tab, and select the option to enable GPIO TSOP IR Receiver. Below that, select the relevant GPIO IR Remote Profile (Mine is ‘Original XBOX DVD Playback Remote’). Select OK at the bottom of that window. XBMC will then ask if you would like to reboot – select OK.

And that’s it. When XBMC restarts, you should find that your remote works.

If it doesn’t function, check each of the steps above were completed correctly (starting with the

mode2 -d /dev/lirc0

one to ensure that you still have an output from your receiver). If all else fails, the [HOW TO] thread is a great place to ask for support.

Please be aware that I have put together this post purely based on my own experience. There may be actions above which could be done easier in other ways, or that are simply not required.THIS IS NOT THE DEFINITIVE INSTRUCTION SET, it is purely what I know worked on my machine. By all means chip in in the replies to correct me, I will amend this post if required.

I hope you are successful. I will reply to any queries below if I can but would like to reitterate that I am simply regurgitating other people’s instructions here in a simple (hopefully) easily understandable format for a newcomer. Others are infinitely more qualified to provide support! Wink

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>