RaspbmcCrystalbuntu
|
[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. ![]() 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!!! ![]() ![]() 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_rpiSave 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 eventlircdThis 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. ![]() 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 ![]() 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_rpiThen Code: sudo kill $(pidof lircd)And finally Code: mode2 -d /dev/lirc0Now, 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 168Assuming 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)And copy and paste that list to somewhere handy. Then, run the irrecord command: Code: sudo kill $(pidof lircd)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 othersAs 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 ).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.confAnd that concludes your dealings in Terminal ![]() 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/lirc0Please 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! ![]() |
|||
|
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. |
|||
|
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 OnKeyPi problems?? Start here http://forum.stmlabs.com/showthread.php?tid=3918 http://elinux.org/R-Pi_Troubleshooting http://elinux.org/RPi_config.txt |
|||
|
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 3 Guest(s)
Sponsored Advertisement

Member List
Calendar
Help



![[Image: gpioir.png]](http://imageshack.us/a/img248/2126/gpioir.png)
![[Image: gpiopinout.jpg]](http://imageshack.us/a/img543/5707/gpiopinout.jpg)
![[Image: dsc0560wx.jpg]](http://imageshack.us/a/img19/3525/dsc0560wx.jpg)

).

