Menu

GPIO-IR

Andreas Dale Hamel Jason M Hayes

Setting up GPIO IR Receiver

*** NOTE *** ** Versions 0.1.32 and above will only require steps 5 and 6 for some remotes!!! **
(Some popular remotes will work out of the box: Apple Silver, MCE and XBox remote)

*** Update ***
Looks like things are not fully fixed yet. You may still need steps 4 - 6 for some remotes. Pay special attention to step 5.1 as this is very important.

Hardware setup

Connect the Receiver Pins with your RPi as follows:

  • DATA, goes to RPi pin 12 (GPIO 18)
  • GND, goes to RPI pin 6 (GROUND)
  • POWER, goes RPi pin 1 (3.3V!!!!)

Pinout details can be found at http://www.panu.it/raspberry/

Additional useful info can be fount at http://aron.ws/projects/lirc_rpi/

RasPlex setup

This walk-though has been verified on an Intel Mac Laptop running 10.8.2 to enable an Apple Silver Remote (A1294) though any remote will work with this walkthrough.

Step 1: Access your RasPlex

Use Terminal to SSH into RasPlex
Default username should be "root" and the default password should be "rasplex"

Step 2: Add module

*** This step is not required anymore! (Version >= 0.1.32) ***

First we add the module, since the modules file is mounted on a read only file system, we will use modpobe to modify openelec to load the lirc module using an autostart file.

Create the file and set the permissions of the file to execute:
touch /storage/.config/autostart.sh
chmod +x /storage/.config/autostart.sh

Next using "nano" command we will edit the autostart.sh file:
nano storage/.config/autostart.sh

Now add the following 2 lines:
#!/bin/sh
(modprobe lirc_rpi;)&

Save and exit.

Now reboot your device.

Step 3: Verify module is working

To check if the module is working:
ls -l /dev/lir*

This was my result and yours may vary but you get the gist:

crw------- 1 root root 249, 0 Jan 1 1970 /dev/lirc0

Next:
dmesg | grep lirc

This was my result and again yours may vary:

[    7.198363] lirc_dev: IR Remote Control driver registered, major 249
[    7.259752] lirc_rpi: module is from the staging directory, the quality is unknown, you have been warned.
[    7.293149] lirc_rpi lirc_rpi.0: lirc_dev: driver lirc_rpi registered at minor = 0
[    7.293171] lirc_rpi: driver registered!
[    7.848510] input: lircd as /devices/virtual/input/input1
[    8.245523] lirc_rpi: auto-detected active low receiver on GPIO pin 18

As you can see everything is working.

Step 4: Creating your lircd.conf file

We're now going to use the command "irrecord" to capture the key presses from you 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 program asks for them.

We will now run:
kill $(pidof lircd)
irrecord --list-namespace | grep KEY

Now copy and past that list to somewhere handy.

Then, run the "irrecord" command:
irrecord -d /dev/lirc0 ~/.config/lircd.conf

Irrecord will output to /storage/.config/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 /storage/.config/lircd.conf:

# Please make this file available to others
# by sending it to <lirc@bartelmus.de>
#
# this config file was automatically generated
# using lirc-0.9.1-git(default) on Sun Mar 17 05:08:39 2013
#
# contributed by 
#
# brand:                       /storage/.config/lircd.conf
# model no. of remote control: 
# devices being controlled by this remote:
#

begin remote

  name  /storage/.config/lircd.conf
  bits            8
  flags SPACE_ENC|CONST_LENGTH
  eps            30
  aeps          100

  header       9053  4453
  one           575  1650
  zero          575   547
  ptrail        576
  repeat       9062  2215
  pre_data_bits   16
  pre_data       0x77E1
  post_data_bits  8
  post_data      0xB1
  gap          107055
  toggle_bit_mask 0x0

      begin codes
          KEY_UP                   0xD0
          KEY_DOWN                 0xB0
          KEY_LEFT                 0x10
          KEY_RIGHT                0xE0
          KEY_PLAY                 0x7A 0x20
          KEY_MENU                 0x40
          KEY_OK                   0xBA 0x20
      end codes

end remote

Obviously your output will look different depending on the remote you use to record your commands.

Step 5: Setup your Lircmap.xml file

Next we will need to create an XML makking file to map your keys.
This file is kept in /storage/.plexht/userdata/Lircmap.xml and should look something like this:

 <lircmap>
        <remote device="devinput">
                <up>KEY_UP</up>
                <down>KEY_DOWN</down>
                <left>KEY_LEFT</left>
                <right>KEY_RIGHT</right>
                <play>KEY_PLAY</play>
                <menu>KEY_MENU</menu>
                <select>KEY_OK</select>
        </remote>
 </lircmap>

Again your output will look different depending on the keys you map.

Step 5.1: For RasPlex 0.1.32 or newer.

We need to add a special file that will override the default location of the built in lircd.conf

mkdir /storage/.config/udev.rules.d
nano /storage/.config/udev.rules.d/99-lircd.rules

Now add the following line:

SUBSYSTEM=="lirc", DRIVERS=="lirc_rpi", ENV{lircd_driver}="default", ENV{lircd_conf}="/storage/.config/lircd.conf"

Step 6: Reboot and enjoy

Finally reboot your Pi and you should now be able to enjoy using your remote with RasPlex though your GPIO IR Receiver.