RaspbmcCrystalbuntu

Thread Closed 
 
Thread Rating:
  • 2 Vote(s) - 4.5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[How-to] GPIO IR receiver with RASBMC by cforehead and relyt
10-20-2012, 09:20 PM (This post was last modified: 01-21-2013 07:45 AM by Dilligaf.)
Post: #1
[How-to] GPIO IR receiver with RASBMC by cforehead and relyt
EDIT: THE TSOP4838 REFERENCED IN THIS TUTORIAL IS A 5V RECEIVER AND ALTHOUGH IT IS REPORTED WORKING IF YOU ARE ORDERING A RECEIVER YOU SHOULD GET A 3.3V ONE SUCH AS THE TSOP34138, THERE ARE MANY OTHERS, MAKE SURE TO CHECK THE DATA SHEET FOR YOUR RECEIVER AS THE PIN LOCATIONS/VALUES VARY FROM ONE TO THE OTHER. IF PLANNING ON USING AN ORIGINAL XBOX REMOTE SUBSTITUTE THE 38 ON THE END WITH A 56 AS THEY ARE 56kHz REMOTES.

Radio Shack part 276-640 is reported to work, link http://www.radioshack.com/product/index....e=Category

A little how-to setup GPIO IR receiver with Raspberry Pi. Thanks to Sam, s7mx1, Dilligaf, monkey13, sabresfan03 and others.

I bought Vishay TSOP4838. You can use CD-ROM internal audio cable as connecting cable. Just make sure that it has 3 wires next to each other one, because some of them has “wire, wire, empty, wire”. Actually those cable will also do but you will need to bend one of the receiver legs. Carefully remove pins from the plastic connector on the one end and put correct pins onto the GPIO ones (taping the spare safely out the way to avoid shorting) and the sensor plugs in very nicely to the remaining connector on the other end. Also computer chassis cables will do the trick. Of course you could solder it all if you hardcore enough. Smile

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!!!
[Image: gpioir.png]
[Image: gpiopinout.jpg]

And software part (The software part is obsoleted on recent RC5. Go to Remote tab on raspbmc settings addon):

Add to /lib/udev/rules.d/98-lircd.rules
Code:
KERNEL=="lirc[0-9]*",   SUBSYSTEM=="lirc", SUBSYSTEMS=="platform", GOTO="begin"

Add to /etc/modules
Code:
lirc_rpi

Save etc/lirc/lircd.conf to lircd.bak
Copy etc/lirc/rc6-mce-lircd.conf to lircd.conf

Add the parameter "--repeat-filter" in /etc/init/eventlircd.conf so that it looks like
Code:
exec eventlircd --evmap=/etc/eventlircd.d --socket=/var/run/lirc/lircd --repeat-filter --release=_UP -f 2>&1 | logger -t eventlircd
(it's already in RC5, for sure)

This configuration working ok with Harmony 600 configured as MCE remote.

If you have latest RC5 installed then 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 your remote if it is listed, otherwise continue reading to record your remote. Select OK at the bottom of that window. Reboot if your remote was listed, otherwise continue.


[Image: dsc0560wx.jpg]

Cforehead wrote:

In response to a request in this thread, I've put together a short guide to how I managed to get my ir receiver working with Raspbmc.

I used a TSOP 4838, connected to the 3.3v GPIO pin (despite it supposedly being a 5v component). I also tried a 34138 (which is a better fit for the 3.3v supply) but I seemed to get a lot of false reads so abandoned it. I did not use any current limiting resistors etc in either setup. Your experience may vary; eBay is the best place for these components unless you want to buy 20 at a time Sad

All my setup was completed using the Terminal application on a Mac, although I believe that the instructions would be identical for configuring the Pi from a Windows PC using something like Putty.

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:

Code:
sudo modprobe lirc_rpi

Then

Code:
sudo kill $(pidof lircd)

And finally

Code:
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:

Code:
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 http://forum.stmlabs.com/showthread.php?tid=6201 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.

Run

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

And copy and paste that list to somewhere handy.

Then, run the irrecord command:

Code:
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:

Code:
# Please make this file available to others
# by sending it to <lirc@bartelmus.de>
#
# 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
  flags SPACE_ENC|CONST_LENGTH
  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 http://forum.stmlabs.com/showthread.php?tid=6201 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:

Code:
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
Code:
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
Find all posts by this user
12-31-2012, 12:42 PM (This post was last modified: 01-21-2013 07:51 AM by Dilligaf.)
Post: #2
RE: [How-to] GPIO IR receiver with RASBMC by cforehead and relyt
Discussion is here http://forum.stmlabs.com/showthread.php?tid=3693

Please post your complete recorded lircd.conf file here http://forum.stmlabs.com/showthread.php?tid=6201 for the benefit of others.
Find all posts by this user
03-07-2013, 10:06 PM
Post: #3
RE: [How-to] GPIO IR receiver with RASBMC by cforehead and relyt
Handy command to "see" what xbmc sees when hitting a remote button, turn debug logging on and run
Code:
tail -F /home/pi/.xbmc/temp/xbmc.log | grep OnKey

Pi problems?? Start here http://forum.stmlabs.com/showthread.php?tid=3918
http://elinux.org/R-Pi_Troubleshooting
http://elinux.org/RPi_config.txt
Find all posts by this user
Thread Closed 


Forum Jump:


User(s) browsing this thread: 2 Guest(s)

Sponsored Advertisement