Infrared Remote Control on the Raspberry Pi

2016-06-21 21.51.58Infrared remote control receiving and sending is a great thing to play with on a computer.  You don’t need a Pi to do this but its a lot more verstile than an Arduino and since the PiZero is only £10 (Pi + SD card) – the extra cost over an Arduino clone is well worth it.

And best of all – the extra hardware needed – a 3 pin IR receiver and a 2 pin IR sending diode for £1 in total is great VFM.

You may be thinking – what can I do with such a combo. Well the list becomes as long as your imagination.

My first project 6 years ago on an Arduino (but still could be useful today) was to notice that a lot of buttons weren’t being used for anything on my Sky+ remote when it was in TV mode

So I programmed my Arduino to listen out for these unused codes and then trasncode them into useful commands that my DVD player understood.  This avoided the need to have the DVD remote around and saved having to buy a universal All-in-100 remote.  And of course, it was FULLY customisable.

Last month, I decided to look into what software was available for the Pi and discovered the LIRC project which works on all Linux computers.  So I installed and configured it and am using it to transcode my old Sky+/SkyHD remotes to control my new SkyQ box (Mr Sky decided to make the old ones incompatible with the new system).

The advantage of a Pi over an Arduino is the small cost of adding WiFi, so now I’m able to make my PiZero respond to messages over WiFi and control my Sky boxes from my phone and use it as an alterative to an IR wireless sender to control box in living room from bedroom (Mr Sky also removed that facility from the new boxes as well!!!!)

I’ve another Pi that is listening out for Cheelight colours and beaming IR codes out to my garden solar RGB lights.

One idea I’ve had but not tried yet is just getting a pair of PiZero to “network” to each other using IR rather than WiFi (would save  £3/PiZero so well worth it)


(but a PiZero is cheap as chips so what the heck – maybe don’t do this on your expensive Pi3!)

Hardware – a 38Khz 3 pin receiver I’ve used one of these from CPC and an IR Diode 

Most instructions will tell you to use resistors and a transistor to control the IR Diode but like I say – the PiZero itself costs £6-50 and none of mine have broke so far so the added complexity is only needed if you use more powerful IR Diodes that consume a lot more that the 20ma that the one above does

I configure my PiZero to reciever on Pin11 (GPIO17) and transmit on Pin13 (GPIO27) but thats only because that’s the easiest wwiring method for me with my extended header poking out the bottom of my Pi.

Software – LIRC – I followed these instructions

LIRC takes some getting used to – its not very intuitive but it works!

Once you’ve got LIRC working, then for Python work I recommend using Tom Mark Preston’s python lib

(here are other libraries available but they all have little quirks – but Tom is part of the Codebug team and intial source of my ScratchGPIO so I trust him the most 🙂

There is also joan’s PiGPIO simpler solution which doesn’t need all the configuration that LIRC does but has some limitations and issues and can’t do anything complicated (yet).

I recommend having a play with IR and if you come up with any great projects or ideas – please come back and tell me

Also, please feel free to ask any questions as I’ve spent a lot of time on this and have already  fallen into 99% of the traps 🙂


You may also like...

Leave a Reply

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