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:
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 “” and reports the detected gestures on screen. To run the example, execute following command:


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.


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


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.


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.


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.


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


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:

© Frederick Vandenbosch, 2014-2019. Unauthorised use and/or duplication of this material without express and written permission from this blog’s author and owner is strictly prohibited. Excerpts and links may be used, provided that full and clear credit is given to Frederick Vandenbosch with appropriate and specific direction to the original content.