Support for GPIO IR Receivers

I see there's a card (Trello) for GPIO IR support under "Planned Features".  But, I'm wondering if there's any timeline (estimated of course) that I could look forward to this being implemented.

 

Thanks!

Works already with some manual setup.

Use the instruction at http://www.raspberrypi.org/phpBB3/viewtopic.php?t=26946&p=241947

You do not need the first part, from half page after "Now for Openelec"

sudo is not woking on rasplex the "normal way" for me. I had to use su and password admin (after logging in as plexuser from ssh). Then you do not need sudo in front of the commands.

Not sure if autostart.sh is the bestplace to load lircd as a_wein mention modprobe.d in Trello, but it works. Maybe some of the experts can advice...

Easiest way to transfer and edit files to the .config and .xbmc folders is to use SMB shares.

I notice some of the keypress for the remote are repeated for me (i.e. one press down results in two steps down) but I have to test this better.

I see there's a card (Trello) for GPIO IR support under "Planned Features".  But, I'm wondering if there's any timeline (estimated of course) that I could look forward to this being implemented.

Thanks!

I will be working with the GPIO IR's this weekend. We'll make sure it works OOB.

you will always ned to record your own remote code and map it to XBMC actions.

How do you plan that OOB? GUI?

you will always ned to record your own remote code and map it to XBMC actions.

How do you plan that OOB? GUI?

Can we not simply use the existing keymaps for most remotes?

Yes, we'll have to have a custom GUI for this eventually.

I've setup my GPIO-IR already. There still a lot of manual work - at least for remotes without lircd config.

Expect more support and documentation soon.

For now: Just use the guides for OpenELEC out there and follow updates to the trello card (https://trello.com/card/support-for-gpio-ir/510c4d34e1d17df66c00092a/159).

Ok guys hope you are ready for this. I take no credit for this walkthrough except for setting the order of the steps and verifying that they work on both 1.27 and 1.28 of RasPlex.

This walk-though has only 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.

1.)

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

We need to create and edit a file called "rpi_lirc.conf" and will do this by using the "nano" command:

nano /storage/.config/modprobe.d/rpi_lirc.conf

Now add the following 2 lines to include the lirc module:

lirc_dev
lirc_rpi gpio_in_pin=18

Save and exit.

2.)

Next 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 again we will edit the autostart.sh file:

nano storage/.config/autostart.sh

Now add the following 3 lines:

root ~/.config # cat autostart.sh
#!/bin/sh
(modprobe lirc_rpi;)&

Save and exit.

Now reboot your device.

3.)

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

4.)

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

5.)

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:

 
        
                KEY_UP
                KEY_DOWN
                KEY_LEFT
                KEY_RIGHT
                KEY_PLAY
                KEY_MENU
                KEY_OK
        
 

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

6.)

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


Now add the following 2 lines to include the lirc module:

lirc_devlirc_rpi gpio_in_pin=18

I did not need step 1. What is about using lirc_dev?

It may not be needed. I found it as part of another walkthrough and that’s what they recommended. If its not needed then I can edit my post and comment it out.

Thanks for your for your work.
 
Some comments:

  • the file "/storage/.config/modprobe.d/rpi_lirc.conf" is not needed and the used syntax should be invalid too

Now add the following 3 lines:

root ~/.config # cat autostart.sh
#!/bin/sh
(modprobe lirc_rpi;)&
  • The first line should be excluded - it's just the prompt and not part of the bash script.

Thank you a_wein for your corrections, I have made the changes and updated the walkthrough.

Walkthrough 2.0 Updated!

Ok guys hope you are ready for this. I take no credit for this walkthrough except for setting the order of the steps and verifying that they work on both 1.27 and 1.28 of RasPlex.

This walk-though has only 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.

1.)

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


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.

2.)

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

3.)

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

4.)

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:

 
        
                KEY_UP
                KEY_DOWN
                KEY_LEFT
                KEY_RIGHT
                KEY_PLAY
                KEY_MENU
                KEY_OK
        
 

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

5.)

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

Hello,

Question about the ir receiver: what will be different from flirc?

The latter cost around 30usd…

Check out the flirc website. I read that they are currently working on a driver and/or software to let it work on the Pi. Remember flirc is USB not GPIO. This thread and walkthrough is just for GPIO.

Yeah, the appeal of GPIO is:

  • CHEAP! ~1$ receiver
  • No USB bandwidth contention
  • Frees up USB slot

Hi Dale,

Thank you for the reply!!.


It confirms that I really need your upcoming case for pi: for around 20 bucks we will have a case, an ir receiver, the power cord with the other cables and a vesa mount…

Big bargain!!!


Hurry up man!.!!! :wink:


Your project (both hard ans soft) is really exciting!

Hi there guys,

and first of all big thanks to Dale & Co for all the hard work with this project!

You are incredible!

Regarding this topic: can anyone verify that Jasons recepie on the wiki page made from this thread, works "all the way" for  RasPlex 1.32?

In an attempt to bind a couple of buttons on my remote to adjust the subtitle sync via "subtitledelayminus" and "subtitledelayplus" I found that the lircmap.xml don't seem to work at all for me.

The lircd.conf file works fine; for instance can I set any button to KEY_UP and a press on that will work as intended.

However a lircmap looking like this (where the up/down/left/right are switched around) doesn't affect the function at all:

 
       
                KEY_DOWN
                KEY_UP
                KEY_RIGHT
                KEY_LEFT
                KEY_PLAY
                KEY_MENU
                KEY_OK
       
 

 

And, as no surprise, the lircmap.xml and 99-lircd.rules can be erased without any change in function.

Well I'm stuck... don't have enough knowledge to trace it further than this.

Does anyone else see this? Any suggestions how to find where I've gone wrong?

Edit:

Surfing around I've found that a custom "Keymap.xml" probably can be my way forward, hopefully letting me map the buttons "one level up".

The lircmap still doesn't make sense to me of course, but there are so many things in this world that doesn't... :blink:

Some path values at section 5.1 are not valid - I fixed the issue. Please try step 5.1 again and things should work as expected.
(The folder needs to be /storage/.config/udev.rules.d - but just placing the lircd.conf at /storage/.config/lircd.conf seems to work too)

So now I've got:

/storage/.config/lircd.conf

/storage/.plexht/userdata/lircmap.xml - content as shown above
/storage/.config/udev.rules.d/99-lircd.rules - content from new section 5.1

Unfortunately no change... (yes, I reboot after editing the files)

So now I've got:
 
/storage/.config/lircd.conf
/storage/.plexht/userdata/lircmap.xml - content as shown above
/storage/.config/udev.rules.d/99-lircd.rules - content from new section 5.1
 
Unfortunately no change... (yes, I reboot after editing the files)

 
Would you please post the output of ps aux | grep lirc

Please remove any lirc related commands from autostart.sh

Output of ps aux | grep lirc:

  861 root       0:00 eventlircd --evmap=/etc/eventlircd.d --socket=/var/run/lirc/lircd --release=_UP
  883 root      52:46 /usr/lib/plexhometheater/plexhometheater --standalone -fs --lircdev /var/run/lirc/lircd
  891 root       0:00 /usr/sbin/lircd --driver=default --device=/dev/lirc0 --uinput --output=/var/run/lirc/lircd-lirc0 --pidfile=/var/run/lirc/lircd-lirc0   .pid /storage/.config/lircd.conf
 1855 root       0:00 grep lirc
 

There is no autostart.sh

A search (openelec:/ # find . -name "autostart.*") in root gives no hits...