<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Hacking With Gum &#187; IR</title>
	<atom:link href="http://hackingwithgum.com/tag/ir/feed/" rel="self" type="application/rss+xml" />
	<link>http://hackingwithgum.com</link>
	<description>A Hardware Hacking Blog</description>
	<lastBuildDate>Tue, 23 Mar 2010 00:47:02 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Building A Boxee Remote Control</title>
		<link>http://hackingwithgum.com/2009/09/28/building-a-boxee-remote-control/</link>
		<comments>http://hackingwithgum.com/2009/09/28/building-a-boxee-remote-control/#comments</comments>
		<pubDate>Tue, 29 Sep 2009 02:22:36 +0000</pubDate>
		<dc:creator>cheffner</dc:creator>
				<category><![CDATA[Microcontrollers]]></category>
		<category><![CDATA[Routers]]></category>
		<category><![CDATA[TV]]></category>
		<category><![CDATA[Arduino]]></category>
		<category><![CDATA[Boxee]]></category>
		<category><![CDATA[IR]]></category>
		<category><![CDATA[Remote Control]]></category>
		<category><![CDATA[WRT54G]]></category>

		<guid isPermaLink="false">http://hackingwithgum.com/?p=234</guid>
		<description><![CDATA[After configuring my Boxee server to distribute video through the coax cabling in my house, I needed a way to control the Boxee server from other rooms. I built a remote control system that uses an ATMega328 microcontroller and a Linksys WRT54G to read IR codes from standard TV remote controls and relay them over [...]]]></description>
			<content:encoded><![CDATA[<p>After configuring my Boxee server to <a href="http://hackingwithgum.com/2009/06/01/building-a-boxee-tv-station/">distribute</a> video through the coax cabling in my house, I needed a way to control the Boxee server from other rooms.</p>
<p>I built a remote control system that uses an ATMega328 microcontroller and a Linksys WRT54G to read IR codes from standard TV remote controls and relay them over the WiFi network to a Python script running on the Boxee server.</p>
<div id="boxee_remote.flv"><a href="http://www.macromedia.com/go/getflashplayer">Get the Flash Player</a> to see this player.</div>
<p><script type="text/javascript">
var sd = new SWFObject('https://media.dreamhost.com/mediaplayer.swf','mpl','550','443','8');
sd.addParam('allowscriptaccess','always');
sd.addParam('allowfullscreen','true');
sd.addVariable('height','433');
sd.addVariable('width','550');
sd.addVariable('file','http://hackingwithgum.com/wp-content/uploads/2009/09/boxee_remote.flv');
sd.write('boxee_remote.flv');
</script></p>
<p>Here&#8217;s how it works:</p>
<ol>
<li>An IR receiver is attached to an ATMega328 microcontroller (Arduino), which reads the IR codes from standard TV remote(s).</li>
<li>The microcontroller is also connected to the serial port of a WRT54GSv4, which is connected as a client to my WiFi network.</li>
<li>When the microcontroller receives an IR code, it pipes the code through netcat to a Python script running on the Boxee server.</li>
<li>The Python script finds the keyboard key in its lookup table that corresponds to the received IR code and then simulates that key press using the <a href="http://linux.die.net/man/1/xte">xte</a> utility.</li>
</ol>
<p><span id="more-234"></span></p>
<p>The IR receiver is a TSOP1738 which was pulled out of a broken DirectTV box that had been thrown away. Most IR receivers from old VCRs / DVD players  / whatever should also work:</p>
<div id="attachment_254" class="wp-caption aligncenter" style="width: 202px"><a href="http://hackingwithgum.com/wp-content/uploads/2009/09/tsop1730.jpg"><img class="size-full wp-image-254" title="TSOP1738" src="http://hackingwithgum.com/wp-content/uploads/2009/09/tsop1730.jpg" alt="TSOP1738 Pin Out" width="192" height="147" /></a><p class="wp-caption-text">TSOP1738 Pin Out</p></div><br />
</p>
<p>The microcontroller code was kept sweet and simple using Ken Shirrif&#8217;s multi-protocol infrared Arduino <a href="http://arcfn.com/2009/08/multi-protocol-infrared-remote-library.html">library</a>. All it does is read a code from the IR receiver, check to make sure that it&#8217;s a valid code, and sends the command <em>echo &#8220;&lt;ir protocol&gt;:&lt;ir code&gt;&#8221; | nc &lt;boxee server&gt; 4919</em> to the BusyBox shell running on the WRT54G&#8217;s serial port. The Arduino code can be downloaded <a href="http:///hackingwithgum.com/wp-content/uploads/2009/09/ir.pde">here</a>.</p>
<p>The WRT54G is an old Fonera router re-loaded with <a href="http://www.polarcloud.com/firmware">Tomato</a> firmware. The router has two serial ports, one of which (/dev/ttyS0) provides a root shell; this shell is used by the microcontroller to send messages to the Boxee server:</p>
<blockquote>
<pre>
Tomato 1.25.1720

BusyBox v1.14.0 (2009-05-25 16:08:27 PDT) built-in shell (ash)
Enter 'help' for a list of built-in commands.

#
# echo "NEC:18E708F7" | nc boxee 4919
#
</pre>
</blockquote>
<p>The following schematic depicts how the ATmega328 is interfaced with the IR receiver and the router&#8217;s serial port. Both the ATmega328 and the TSOP1738 require 5v, so a 7805 regulator is used to drop router&#8217;s 12v power supply down to 5v, and suppress any power supply disturbances that may occur. The 3.3v zener diode drops the 5v output from the microcontroller down to 3.3v for the router&#8217;s TTL serial interface, while the 2200 ohm resistor limits the current through zener diode so that the it doesn&#8217;t burn out:</p>
<p><div id="attachment_281" class="wp-caption aligncenter" style="width: 310px"><a href="http://hackingwithgum.com/wp-content/uploads/2009/09/ir_receiver_schematic.jpg"><img class="size-medium wp-image-281" title="Schematic" src="http://hackingwithgum.com/wp-content/uploads/2009/09/ir_receiver_schematic-300x219.jpg" alt="IR Receiver Schematic" width="300" height="219" /></a><p class="wp-caption-text">IR Receiver Schematic</p></div><br />
</p>
<p>Here is the circuit wired up to the WRT54G during testing. As you can see, the WRT54G case has plenty of room for the new circuit board:</p>
<p><div id="attachment_257" class="wp-caption aligncenter" style="width: 310px"><a href="http://hackingwithgum.com/wp-content/uploads/2009/09/circuit_board_testing.jpg"><img class="size-medium wp-image-257" title="Testing The Circuit Board" src="http://hackingwithgum.com/wp-content/uploads/2009/09/circuit_board_testing-300x225.jpg" alt="Testing The Circuit Board" width="300" height="225" /></a><p class="wp-caption-text">Testing The Circuit Board</p></div><br />
</p>
<p>To mount the IR receiver, the &#8220;Cisco Systems&#8221; logo was cut away from the front panel of the case. The logo did not have any hard plastic behind it, so it was easy to cut out with a hobby knife, and is the perfect size for the TSOP1738:</p>
<p><div id="attachment_258" class="wp-caption aligncenter" style="width: 310px"><a href="http://hackingwithgum.com/wp-content/uploads/2009/09/remove_cisco_logo.jpg"><img class="size-medium wp-image-258" title="The Cisco Logo Removed" src="http://hackingwithgum.com/wp-content/uploads/2009/09/remove_cisco_logo-300x225.jpg" alt="The Cisco Logo Removed" width="300" height="225" /></a><p class="wp-caption-text">The Cisco Logo Removed</p></div><br />
</p>
<p>The Cisco logo was used to cover the &#8220;Secure Easy Setup&#8221; button, so in order to use that space for the IR receiver, the SES button needed to be removed from the Linksys board as well:</p>
<p><div id="attachment_260" class="wp-caption aligncenter" style="width: 310px"><a href="http://hackingwithgum.com/wp-content/uploads/2009/09/wps_button.jpg"><img class="size-medium wp-image-260" title="Secure Easy Access Button" src="http://hackingwithgum.com/wp-content/uploads/2009/09/wps_button-300x225.jpg" alt="Secure Easy Access Button" width="300" height="225" /></a><p class="wp-caption-text">Secure Easy Access Button</p></div>
<div id="attachment_259" class="wp-caption aligncenter" style="width: 310px"><a href="http://hackingwithgum.com/wp-content/uploads/2009/09/no_wps_button.jpg"><img class="size-medium wp-image-259" title="Secure Easy Access Button Removed" src="http://hackingwithgum.com/wp-content/uploads/2009/09/no_wps_button-300x225.jpg" alt="Secure Easy Access Button Removed" width="300" height="225" /></a><p class="wp-caption-text">Secure Easy Access Button Removed</p></div>
<div id="attachment_261" class="wp-caption aligncenter" style="width: 310px"><a href="http://hackingwithgum.com/wp-content/uploads/2009/09/board_in_case.jpg"><img class="size-medium wp-image-261" title="Fitting The Circuit Board And IR Receiver Into The Case" src="http://hackingwithgum.com/wp-content/uploads/2009/09/board_in_case-300x225.jpg" alt="Fitting The Circuit Board And IR Receiver Into The Case" width="300" height="225" /></a><p class="wp-caption-text">Fitting The Circuit Board And IR Receiver Into The Case</p></div>
<p><div id="attachment_262" class="wp-caption aligncenter" style="width: 310px"><a href="http://hackingwithgum.com/wp-content/uploads/2009/09/case_complete.jpg"><img class="size-medium wp-image-262" title="The Router, Reassembled" src="http://hackingwithgum.com/wp-content/uploads/2009/09/case_complete-300x225.jpg" alt="The Router, Reassembled" width="300" height="225" /></a><p class="wp-caption-text">The Router, Reassembled</p></div><br />
</p>
<p>With the hardware complete, as much of the logic as possible was placed into a Python script that runs on the Boxee server; this way if I need to add or change some IR codes, I can just edit the Python script, rather than re-program the microcontroller. </p>
<p>The <a href="http://hackingwithgum.com/wp-content/uploads/2009/09/ir.txt">Python script</a> runs as a daemon, and currently has codes for most of the buttons on my Sony, RC6, and NEC remote controls at home. Since Python in Linux doesn&#8217;t have an API for simulating keystrokes to GUI applications, the script uses the xte utility which is part of the <a href="http://hoopajoo.net/projects/xautomation.html">xautomation</a> package.</p>
<p>I managed to scrounge up most of the parts for this project (including the router), keeping the total cost to around $15. I&#8217;m also thinking of using a similar set-up to control other applications running on my PC.</p>
]]></content:encoded>
			<wfw:commentRss>http://hackingwithgum.com/2009/09/28/building-a-boxee-remote-control/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
	</channel>
</rss>
