IMG_0952

Gesture Based TV Remote Control


 

Seeing my children mastering swiping, touching and tapping on the tablet, gave me the idea of making a gesture based TV remote control. Using the Raspberry Pi, the Skywriter HAT from Pimoroni and an IR LED, this was made possible rather easily. Here’s how I did it …

Raspberry Pi

Preparing the Raspberry Pi is the same as always. I flashed the latest Raspbian Jessie image onto a 8GB microSd card using “dd”.

For this project, I’m using the Raspberry Pi A+ as it has the exact same form factor as the Skywriter HAT.

Skywriter HAT

The Skywriter HAT is an add-on board by Pimoroni, capable of detecting gestures. The HAT fits on top of the Raspberry Pi via the 40-pin GPIO header, and the software can be installed with a single command. The command takes care of installing the software dependencies, enabling I2C and providing some example applications. The documentation can be found on the Pimoroni GitHub page: https://github.com/pimoroni/skywriter-hat
After connecting the HAT, I executed the oneliner to install the software:

And that’s all there is to it. Compliments to Pimoroni for making this install so easy!

After setting up the software, the Skywriter HAT can be tested. One of the example applications is called “test.py” and reports the detected gestures on screen. To run the example, execute following command:

Lirc

Lirc is the software in charge of the infrared (IR) signals. It is capable of recording signals from remote, as well as send them. This is why I have foreseen both an IR LED transmitter and and IR receiver.

Circuit

The circuit consists of two parts:

  • transmitter
  • receiver

For the transmitter part, an IR LED is controlled via a transistor and a GPIO pin. A resistor of about 50 ohms is put in series with the IR LED and the GPIO pin is connected to the base pin of the transistor using a 10k ohm resistor. The LED is powered using the Pi’s 3.3V GPIO pin.

For the receiver part, also powered at 3.3V, the data pin is connected to a GPIO pin via a 10k ohm resistor. Careful, depending on your type of IR receiver, the pinout could be different!

Screen Shot 2016-02-12 at 21.09.33IMG_0922

After prototyping the circuit and before soldering it onto a prototyping HAT, I verified basic functionality using an oscilloscope.

IMG_0920 IMG_0924

Software

First step is of course to install the lirc application itself. This can be done using “apt-get”.

Edit the module files and append following lines:

The default hardware config file won’t work. Here’s an example of one that will. I commented out the default values so you can see which ones changed.

Finally, one last change is required in the boot config.

Don’t forget to reboot to apply all the changes. After that, you should have a “lirc0” device available.

It is also possible to verify the correct modules (lirc_rpi & lirc_dev) have been loaded using the “lsmod” command.

If that’s the case, everything should be ready to use.

Record

When recording keys, the correct names need to be assigned to identify them. The full list of possible values can be obtained using the following command:

In order to start recording IR signals from the remotes, the lirc process needs to be stopped.

With lirc stopped, the recording process can start. Make sure you have the remote of the TV or decoder handy and follow the instructions.

The above was created using the remote control of the TV. But as we also have a decoder for digital TV, I repeated the process for the other remote. Except this time, I ned the output file “lirc-remote2.conf”. Both config files were then combined  (“lirc-remote1.conf” and “lirc-remote2.conf”) into a single file (“lirc-combined.conf”).

In the config file, it is also possible to giev the ramotes a proper name. I called mine “TV” and “Digibox”.

The finished file can then be copied to the proper location for the lirc application to use.

When all recording is done, the lirc process can be restarted.

Send

Before sensing any commands, it’s good to check what is available matches what was recorded. This can be achieved using the “irsend LIST” command, followed by the remote name and empty quotes.

Once the commands have been confirmed, it’s possible to test out the signals using the “irsend SEND_ONCE” command.

In my case, the TV and Digibox turned ON. Repeating the same commands turned them OFF.

Combined

Combining the Skywriter HAT’s functinality with Lirc is simply a matter fo taking the skywriter example code and expanding/adapting the functions with the desired IR send commands.

The code above does the following:

  • flick left and right to change the channel
  • flick up and down to change the volume
  • make a circular motion to turn TV and Digibox ON and OFF

Enclosure

For the enclosure, I milled two parts with the necessary slots for power, USB and the IR LEDs using the CNC. The two pieces are joined using four screws.

The enclosure’s finish is simple: a bit of sanding and oiling.

IMG_0934 IMG_0952
Let me know what you think in the comments! And don’t forget I’m giving away one of my Pi Zero to celebrate my first 1000 subscribers on Youtube and the fact that I’m going to exhibit at Maker Faire Paris: http://frederickvandenbosch.be/?p=1563

34 thoughts on “Gesture Based TV Remote Control

  1. This is wonderful,tell me,how much would you charge me to make,let’s say,100 of these devises for re-sale?

      1. sure. But if someone would be interested in throwing money at you to get one, how much money would one need to throw at you? cos I am insanely interested in getting one.

    1. You could control any device via IR signals, as long as you can record them first, as explained in the post.

      With some modifications, you could use another mechanism than IR for control.

  2. Hi! Amazing project, I’m very interested to try it out. Quick question, where did you get all the IR related components? It’s completely DIY rather than a pre set module, right? Could you maybe provide me with some links? Much appreciated!

  3. Finally an unique way to control an RPi used for music, etc. in a car! No need for keypad or a touch screen, just wiggle your finger at the dash. Brilliant!!!

  4. Are you using Raspberry pi 3 or RPi2 because I am trying on the pi 3 and I am not getting any response when pressing buttons on a remote after entering the command. irrecord -d /dev/lirc0 lirc-remote1.conf. Would this be a software issue or do you think the hardware setup was incorrect

    1. Hi Jason,

      actually, I’m using a Raspberry Pi A+, though I don’t think that should matter.
      Verify your infrared receiver is properly wired, and if you have a scope, verify if there is an incoming signal on its data pin.

Leave a Reply

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