Wednesday, November 15, 2017

IR to Network Bridge with an ESP8266

A year or so ago we cut the cord (cable) and started relying on a combination of OTA tuning via a Windows media center, the OTA tuner in our TV and a Roku stick. The original thought was the limited programming selection would push us to spend less time watching TV to focus on more productive things. (Spoiler - It never happened, somehow network programming filled the void.)

This setup has a pretty high WAF (wife approval factor) mainly since the media center handles IR and is controlled along with the TV via a single Harmony universal remote - but that damn Roku remote presents a number of issues:
  1. It doesn't use IR (some sort of proprietary RF) and therefore can't be setup in the Harmony or other IR based universal remote.
  2. It's also particularly small so seems inexplicably drawn into every nook and cranny in the furniture (or hidden by the kids)

One idea that was quickly dismissed (<WAF)
Attaching the small remote to the Harmony seemed a poor choice but something had to be done, the constant volume change within Roku apps had to be addressed!

One day I saw mention of a network API for the Roku and an idea was born... what if I setup a fake device in the Harmony and then used an ESP8266 to pickup the device IR and convert this to a corresponding network based Roku API call? The ESP was certainly capable of decoding IR (using one of the common Arduino libraries) and with it's on board WiFi it should be able to  make the REST API calls to the Roku.

A few hours later the IRtoRokuBridge was born. In a surprising twist this ends up even more capable than the original remote since you can program arbitrary shortcut buttons on the Harmony screen that take you directly into the requested app.


The code is pretty basic but it has been running well for 6 months or so. 

Two libraries/authors I leveraged and want to thank:

You can find the code/details on my Github page (https://github.com/lawrence-jeff/IRtoRokuBridge) a few things I learned:

  • Cheap off brand IR modules can give you issues with range and decode - switching my setup to use a name brand module (whatever Radio Shack sold 10 years ago) worked much better.
  • The Arduino code isn't as resilient as what you will find on a TV or other device, you really need to aim.. I kept meaning to implement a less exact match in the code but it works well enough that I never got around to it
  • If you use NEC codes holding down a button generates a unique repeat code which you need to handle. I found the Harmony sometimes sent these when not intended so via trial and error I filter out the first two repeat codes which makes it act better (this is for instances when you are holding down an arrow for instance to browse through the app menu)

This example uses the Roku API - but anything you can do on your home network you can now do via IR and a spare remote. Drop a comment if you do any other interesting things with IR control

1 comment: