Quantcast
Channel: Astro-Beano
Viewing all articles
Browse latest Browse all 33

Raspberry Pi XBMC infrared remote control

$
0
0
I've added an infrared receiver to my Raspberry Pi, tucked inside a PiBow case with its clear top layer letting it receive the signals. This lets me re-use an old DVD player IR remote to control XBMC running on the Pi.

IR sensor and cable hiding inside PiBow case

Basically I followed this AdaFruit Tutorial for adding an IR receiver to the Raspberry Pi, but not being in the USA I had to substitute parts which I sourced via eBay instead. Despite much searching, the shortest suitable jumper cables I could find (one pin to one pin, 1P-1P, and female-to-female, F/F) were 10cm long - which is a bit much to coil up inside the Pibow case but easier than soldering.

Parts:
  • 1x TSOP38238 InfraRed receiver (under £2 from eBay with shipping)
  • 3x 10cm Dupont Wire  2.54mm 1P-1P Female/Female jumper cable (pack of 40 for £1 on eBay)

The three jumper wires (split off my ribbon of 40 as a triple) connect the three pins of the IR sensor to GPIO18, GND, and 3V3 respectively (pins 12, 6, and 1).
IR sensor and 10cm jumper leads to Raspberry Pi

Raspian Configuration

I just used the following to check the hardware was working:

$ sudo apt-get install lirc
$ sudo modprobe lirc_rpi
$ mode2 -d /dev/lirc0

This showed it received signals from my assorted working IR remote controls. I didn't go any further with this since I'm not actually running XBMC under Raspian at the moment.

OpenELEC

Then for XBMC under OpenElec, I followed the instructions here via SSH. Under OpenElec LIRC is already installed, we just need to enable it for the current session, add this to the startup script for future use, and then configure the remote control.

$ modprobe lirc_rpi
$ echo "modprobe lirc_rpi">> /storage/.config/autostart.sh
$ irrecord /storage/.config/lircd.conf

Running irrecord is a bit fiddly, but seems to work nicely. I found it helps to have looked at the output of this command which lists all the KEY_* names that irrecord understands.

$ irrecord --list-namespace

Remote control configuration tips for XBMC (see this HowTo):
  • For navigating the menus in place of the cursor keys on a normal keyboard, define KEY_LEFT, KEY_RIGHT, KEY_UP and KEY_DOWN (at least that was easy).
  • For navigating the menus in place of 'enter' on a normal keyboard, define KEY_OK rather than KEY_SELECT or KEY_ENTER.
  • For navigating the menus in place of 'backspace' on a normal keyboard, use KEY_EXIT, none of KEY_BACKSPACE, KEY_BACK or KEY_CANCEL work.
  • For the context menu reached via 'c' on a normal keyboard, none of KEY_C, KEY_MENU or KEY_CONTEXT_MENU work. However, KEY_EPG (electronic program guide) does.
  • For media information reached via 'i' on a normal keyboard, defining KEY_INFO works.
  • For changing the volume, KEY_VOLUMEUP and KEY_VOLUMEDOWN work fine. However KEY_MUTE appears to have no effect.
  • For rapid scrolling through the menus I like to use Page Up/Down on my normal keyboard. Unfortunately KEY_PAGEUP and KEY_PAGEDOWN via the remote have no effect.

When I say things have no effect, they are being detected as you can monitor this live via SSH while running XMBC:

$ irw /var/run/lirc/lircd-lirc0

To rename a key, edit /storage/.config/lircd.conf and reboot.

This was done under OpenElec v2.95.6, which I then updated to v3.2.2 after releasing the automatic updates hadn't picked up the major releases.  The remote still seems to work (and seems to have fixed a playback glitch too). I may need to fine tune the repeat settings for best results...

Viewing all articles
Browse latest Browse all 33

Trending Articles