Building A Boxee Remote Control September 28, 2009

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 the WiFi network to a Python script running on the Boxee server.

Get the Flash Player to see this player.

Here’s how it works:

  1. An IR receiver is attached to an ATMega328 microcontroller (Arduino), which reads the IR codes from standard TV remote(s).
  2. The microcontroller is also connected to the serial port of a WRT54GSv4, which is connected as a client to my WiFi network.
  3. When the microcontroller receives an IR code, it pipes the code through netcat to a Python script running on the Boxee server.
  4. 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 xte utility.

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:

TSOP1738 Pin Out

TSOP1738 Pin Out


The microcontroller code was kept sweet and simple using Ken Shirrif’s multi-protocol infrared Arduino library. All it does is read a code from the IR receiver, check to make sure that it’s a valid code, and sends the command echo “<ir protocol>:<ir code>” | nc <boxee server> 4919 to the BusyBox shell running on the WRT54G’s serial port. The Arduino code can be downloaded here.

The WRT54G is an old Fonera router re-loaded with Tomato 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:

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
#

The following schematic depicts how the ATmega328 is interfaced with the IR receiver and the router’s serial port. Both the ATmega328 and the TSOP1738 require 5v, so a 7805 regulator is used to drop router’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’s TTL serial interface, while the 2200 ohm resistor limits the current through zener diode so that the it doesn’t burn out:

IR Receiver Schematic

IR Receiver Schematic


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:

Testing The Circuit Board

Testing The Circuit Board


To mount the IR receiver, the “Cisco Systems” 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:

The Cisco Logo Removed

The Cisco Logo Removed


The Cisco logo was used to cover the “Secure Easy Setup” 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:

Secure Easy Access Button

Secure Easy Access Button

Secure Easy Access Button Removed

Secure Easy Access Button Removed

Fitting The Circuit Board And IR Receiver Into The Case

Fitting The Circuit Board And IR Receiver Into The Case

The Router, Reassembled

The Router, Reassembled


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.

The Python script 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’t have an API for simulating keystrokes to GUI applications, the script uses the xte utility which is part of the xautomation package.

I managed to scrounge up most of the parts for this project (including the router), keeping the total cost to around $15. I’m also thinking of using a similar set-up to control other applications running on my PC.

6 Comments

[...] Link [...]

Rodrigo Medina September 29th, 2009

Hey congratulations for this projects its really awesome I don´t now if you have noticed but this kind of inventions are going to change the way people entertain itself we are at the end of the TV era as we know it congratulations again and keep up the good work.

plooger October 7th, 2009

Very innovative; congrats on your project.

Curiously, I’m looking for a bit of the reverse, a WRT54G hack that can receive a “signal” via the network, either wired or wireless, and emit an infrared signal (either via a built-in emitter or emitter extension wires).

Craig October 7th, 2009

Hi plooger,

You should be able to use the same hardware configuration as I did for your project – the Arduino IR library supports transmitting as well as receiving, so you could also use that for modulating an IR LED.

As some of the commenters on Hack-A-Day mentioned, if you use a low-voltage microcontroller, you can get rid of most of the external parts as well.

Felix November 5th, 2009

Hi, this post is very helpful as I am also thinking about a WRT54GL-Arduino project.
On the schematic, should the zener diode be connected to the serial in of the router instead of serial out?

Craig November 7th, 2009

Felix: The labeling on the schematic may be a bit confusing. The line labeled “serial out” is the serial output from the ATMega, which is connected to the router’s serial input line.

Leave a Reply