Universal Remote

Universal Remote Project

Background: In our bonus room above our garage (aka “the media room”) we currently have the following when wanting to watch tv:

  1. Manual switch to lower the projector screen
  2. Remote control for the Dell projector
  3. Remote control for the Sony DVD/Audio system
  4. Remote control for the cable box
  5. Remote control for the Roku box
  6. Remote control for the Nielsen Peoplemeter box

When watching tv, right after getting settled into the comfy couch one of us inevitably has to either 1) get up and walk over and switch something on/off, up/down, etc. orIMG_20141226_132700 2) contort our arms up over the back of the couch and point a remote at something in order to make a change.

Wouldn’t it be great to do this all from a single, simple interface on a smartphone or tablet?  And thus, another Raspberry Pi project was born!

So, with that thought, a new project was born and it really only required a few additional parts.  Here’s what I used:

Parts List:

ITEMDESCRIPTIONCOSTPIC
Total cost = ~$10
Raspberry PiCredit-card sized linux server that runs Apache and MySQL and hosts the various php and python code files – I already had this but it sells for $35$0RPI
BreadboardI initially got this just for easy proto-typing on an earlier project but this cool package of 6 little ones was a great find and I used one of them just to handle easy break-out of the GPIO pins from the Pi$0small_breadboards
WireI just used some old bell wire I had in the shop$0bell_wire
IR transmitterI used 2 5mm IR LED’s (940nm wavelength) from Adafruit – 75 cents each$1.50IR LED
PN2222 TransistorThis helps drive the IR LED – had one in the spare parts pile but costs less than a dollar.$0PN2222
10K OhmResistorHad this in the parts pile too!$010K Resistor
IR receiverI didn’t actually need this for the final project but it was a simple way to learn the IR codes from the existing remotes in order to code them in to the final project.  I used the TSOP38283$1.95IR SENSOR

Code:  The basic structure of this project was to first capture and decode the signals generated by the various infrared remote control devices that we use and then write a  web-based interface to enable simple control of all devices from a single interface on any device with web access.

  • Step One – IR Remotes: Figure out how to do IR stuff with the Pi!  Fortunately, there is a ton of work already out there that can be leveraged.  The key to it is the LIRC project – Here is one of the best sources I found: http://alexba.in/blog/2013/01/06/setting-up-lirc-on-the-raspberrypi/  There is some simple wiring to hook up an IR receiver to the GPIO pins on the Pi.  Here’s what the final circuit looked like: IR CIRCUIT

At that point you can then install the LIRC tools and try to “decode” all of your IR remote signals so that you’ll then be able to send them back out to an IR LED emitter (also via the GPIO pins on the Pi)

 

  • Step Two – Roku Box:  I quickly realized that the remote control for the Roku box was not using Infrared to communicate (explains why it was our favorite of all the remotes).  It’s actually a wifi enabled remote and it speaks tcp/ip to the roku box.  Even better, I found a published api of sorts: http://a-more-common-hades.blogspot.com/2011/07/control-roku-from-command-line.html  and it was then a trivial matter to add in the web code to control this box.
  • Step Three – Projector Screen (WeMo Switch):  This was a bit trickier – we have a projector screen that uses a motor on the regular circuitry in the home to raise and lower when a switch is flipped.  I’m fairly comfortable working with wiring but did not wemowant to mess with trying to interface a low voltage relay from the pi into the normal home wiring.  The solution actually turned out to be somewhat simple though.  About a year ago I started getting interested in the whole home automation trend and wanted to play with some things so I bought a Belkin Wemo switch  This gives you simple ip access to flip power to an outlet on and off.  I then found this tool that let me run a simple server program on the Pi which could then pass toggle commands on to the switch: http://ouimeaux.readthedocs.org/en/latest/  Presto – now the projector screen motor can be controlled from the same app!
  • Step Four – The App: I wanted the app for this to be very “phone-friendly” and I also wanted to learn some new stuff to go on top of whatever python or php stuff I needed to write to make this all work.  I found the answer in the JQUERY Mobile Framework- http://demos.jquerymobile.com/1.1.1/docs/about/intro.html  This made it very easy to put a nice clean wrapper around some PHP and linux script stuff to emulate the various button pushes and switch flips.  Here’s what the code looked like when it was done:

 

IMG_20141226_210040

The main app screen best features are the “ALL ON” & “ALL OFF” buttons!

IMG_20141226_210033

Example of one of the sub-menu screens – individual control for the key buttons of each component is provided…

IMG_20141226_210046

The Roku page has the standard navigation buttons but also some quick link to the key apps we use (Netflix, Hulu, etc) – this is even better than the standard remote!

 

  • Step Five – Running Wires: Once everything was working I needed to get the IR LEDs to a spot where they faced the cabinet that has all of the equipment.  There is attic space behind and above this room so it was fairly easy to run soIMG_20141226_203956me old door-bell wire from the spot where the Raspberry Pi sits to a spot on the opposite wall directly across from the cabinet.  There happened to be a box with a blank faceplate on it that just had a speaker wire in it.  I drilled a small hole in the faceplate and popped the led through it.  The projector is the only piece of equipment that’s not in the media cabinet (It’s mounted on the ceiling) so it was hit-or-miss as to whether the IR would actually turn it on/off consistently.  This wound up being fairly easily solved by extending the bell wire around the corner and mounting a second IR LED at the end of it, facing directly at the projector – worked like a champ!

Key Challenges:

    • Not all IR remotes are created equal – I learned more than I wanted to about this stuff and there are a lot of formats, timings, etc.  Most of the popular ones have been figured out already and with a bit of web surfing you can find what you need.  As an example, my Sony DVD system gave me some headaches until I found that it needs to have each IR code sent 3 times in succession – worked great after making that small change.
    • Not so for the Nielsen Peoplemeter OK button – this has given me fits and I still have not figured it out – I have all the other buttons on this working but “OK” (which is the most important button) will not work.  This is not a common device and I only found one other reference to it anywhere on the web (another person asking how to solve the same problem I have!).  At this time, I’m waiting for our Nielsen rep to get back to me with some more details on the remote itself – hopefully that will lead somewhere.
    • Another strange problem that is not yet solved is that after adding the second IR LED (to handle the overhead projector) the cable box got  a bit flaky.  It still works, but not always on the first (or even second) button press.  I suspect there is some timing problem or interference issue when sending the codes from both LEDs at the same time (since it works flawlessly when I only have the single IR LED in place).  This hasn’t been a big enough headache to spend much time on yet but it’s on the to-do list to try to eventually figure it out!

Next Steps To-Do’s:

    • Resolve Nielsen OK button issue – if I can get this figured out then I’ll also update the code to autosend the OK button once every 60 mins while things are powered on (this is a requirement of the Nielsen program and something that we almost always forget to do since the box is behind us when we are watching tv)
    • Dimmers – we have 3 sets of overhead floodlights in this room – all on dimmers.  It looks like there are lots of technologies that I could use to be able to control these from the same app – just have to wait for prices to come down (a lot) or find some used stuff on eBay.  It would be cool to have this in the app but we rarely change the light settings once we hit the couch so it’s much more of a nice-to-have than need-to-have.

Acknowledgements: A couple of good web links helped me as I was tinkering with this project:

http://randomtutor.blogspot.com/2013/01/web-based-ir-remote-on-raspberry-pi.html

http://www.stavros.io/posts/how-turn-your-raspberry-pi-infrared-remote-control/

https://learn.adafruit.com/using-an-ir-remote-with-a-raspberry-pi-media-center/hardware

And here is the link to a great library of existing LIRC config files: http://lirc.sourceforge.net/remotes/

Leave a Reply