WiFi TV Remote and Creator

On December 31, 2012, in Projects, by Matt Defenthaler

I gave up on cable TV and all of its outmoded interfaces for what will probably be the final time. The entire world has changed, yet cable box interfaces are stuck in the same time-warp that things like restaurant POS systems seem to be in. Rather than go into a rant, this entry is about how I’ve put together my own TV experience.

Step One: Give the cable box back to Verizon and put a PC in its place.
Some people go all out on this step. I just wanted a decent machine that had a decent amount of memory, HDMI out, and a 1TB hard drive.

Step Two: Figure out which media center application to use
I’ve been through many of them. I tried Boxee, XBMC, Plex, Kylo, and probably some I’ve forgotten about. XBMC is great if you have a library of media and a degree in Engineering. Boxee is a good, simple interface, but I think it’s going away if it hasn’t already. Kylo is a customized browser for viewing web content, but after it seemed Hulu was actively trying to block them, I continued looking again. I use Plex. It works well for streamed content and has a fairly intuitive interface.

Step Three: Figure out how to control it all from the couch
There are some single purpose PC remote apps out there and they’re pretty good, but I like extensibility and having a swiss-army knife type tool so that I can do everything from one place; even if it requires a little customization work on my part. Unified Remote absolutely delivers. It comes with a handy selection of remotes out of the box, but the reason I paid for the app was to take advantage of the custom remote feature. As long as you can string together some XML, you can create your own layout and map the buttons to a wide variety of built-in actions. Even better is the ability to have the Unified Remote server (the application running on the PC to receive the wifi packets the phone app sends) execute arbitrary programs on the PC and feed them parameters.

Armed with this ability and sick of still needing to keep my TV’s remote within reach – instead of its natural habitat which is apparently in between the couch cushions – I set out to devise a method of controlling the TV from the phone as well. I wanted something that wasn’t intrusive and didn’t require me to break open the TV. I first looked into using CEC, but it’s not that well documented for my TV and it seemed like it was going to be a hassle. Instead, I decided good old-fashioned IR would be best.

I remembered seeing an IR library for the Arduino, so I started looking into it. I was surprised to learn that IR communication for things like TVs and stereo receivers is not as simple as just several flashes of light for different lengths of time. In fact, I’d go as far as to say that they’re packets! Fortunately, the library takes care of most of those details, but I did find it interesting. At the time the library didn’t support Panasonic, but I found a comment on the library’s author’s (Ken Shirriff) page that included the code I needed to get things working. The commands are sent as ‘Extras’ from the Unified Remote app to the server and passed as parameters to an executable specified in the remote config. In my case that executable was a python script that transmits the command over USB to the Arduino which, in turn, blinks the IR LED to transmit the packets to the TV.


Diagram of how the TV is controlled from a mobile device over WiFi.

Diagram of how the TV is controlled from a mobile device over WiFi.

Remote Creator

The rough part about creating custom remotes for Unified Remote is that there’s no WYSIWYG-style editor and it’s not easy to see what the XML will render until the phone pulls the updated config from the server. As a result, I never put together a hand-crafted remote with more than a couple of buttons to control the TV itself. To get beyond my reluctance to do so and to hopefully help others, I created an app called Remote Creator that lets one visually design a custom remote and have XML generated. It was also supposed to be a super simple app that didn’t take more than a day or so to write. However, I ended up spending several weeks on it in my spare time due to some rewrites since I wanted the code to look nice when it was released. The part I’m most proud of is the way the XML config is generated. It exploits knockoutjs’s ability to generate XML/HTML based on javascript models. Unfortunately, Unified Remote expects all XML tag and attribute names to have their first letter uppercase and remaining letters lowercase. This is a problem because browsers (at least Chrome and Firefox) tend to lowercase tag and attribute names. As a result, some regex-replace calls are required. Also, the ‘data-bind’ attribute must be removed from the XML nodes. Remote Creator does not support generation of all available features at this time due to my choice to iterate based on demand. The app is available here.



panasonicTvControl.pde for Arduino


Remote Creator web app


Tagged with:

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>