Raspberry Pi Universal Remote





Introduction: Raspberry Pi Universal Remote

In this tutorial I hope to convince you that this is the ultimate universal remote built using a raspberry pi.

LIRC is the perfect for this job. It simplifies many of the more difficult tasks that we need to accomplish.

Step 1: Parts

Step 2: Setting Up the Software

There are a lot of steps in this that I will try to explain.

(Most of this step is from: http://alexba.in/blog/2013/01/06/setting-up-lirc-on-the-raspberrypi/ )

For the sake of this tutorial i'm assuming this is on a clean Raspbian image.

     sudo apt-get upgrade
     sudo apt-get update

Install LAMP

     sudo apt-get install apache2 php5 mysql-client mysql-server tomcat6 vsftpd

Install LIRC

     sudo apt-get install lirc

Set up the GPIO pins (remember this for later if you want to use other pins)

     sudo nano /etc/modules

Add these 2 lines to the bottom of the file

     lirc_rpi gpio_in_pin=23 gpio_out_pin=22

(CONTROL + C will save and exit)

Configure the hardware file.

     sudo nano /etc/lirc/hardware.conf

Erase the contents and paste this file

# /etc/lirc/hardware.conf
# Arguments which will be used when launching lircd

# Don't start lircmd even if there seems to be a good config file

# Don't start irexec, even if a good config file seems to exist.

# Try to load appropriate kernel modules

# Run "lircd --driver=help" for a list of supported drivers.

# usually /dev/lirc0 is the correct setting for systems using udev

# Default configuration files for your hardware if any

Reboot the Pi

     sudo reboot

Step 3: Making LIRC Files

Wire the IR sensor to the PI with the 3 Pin to the same GPIO In pin that you defined in step 2 in the /etc/modules file

Run the command and press remote buttons at the sensor and you should get some feedback

sudo /etc/init.d/lirc stop
mode2 -d /dev/lirc0

(CONTROL + C to stop)

Next we run the fallowing command wile in the pi directory to record the remote commands

irrecord -d /dev/lirc0 ~/out.conf

Fallow the instructions provided

When it asks for key names you must use the predefined names. To get the names I like to open a new window and run the command.

irrecord --list-namespace

Once you have finished recording, open out.conf

sudo nano out.conf

copy from "begin remote" all the way to "end remote" and open /etc/lirc/lircd.conf

sudo nano /etc/lirc/lircd.conf

Erase the content and paste the code and save.

Assign a name to the remote by replacing the line in the .conf that has a file path after NAME:

Repeat this for all the remotes you want to use

Reboot the Pi

sudo reboot

Step 4: Building the Board

The idea here is to build the circuit form the schematic above (the nice one) and replace the LEDs with an IR emitter instead. As you can see in the circuit above (the bad one) the tip of the headphone board is +5v and one of the rings must be connected to the transistor. The Pi does not go fast enough to run the LED itself It must have the transistor to work.

I started by soldering 2 female headers side by side on a perf board.

Then I added the circuit and trimmed the excess perf board off.

Step 5: Now What?

Now is the fun part.

execute remote command to devices with lines like

irsend SEND_ONCE device KEY_POWER

(device being the name you assigned to it)


Having a raspberry pi so close to you entertainment center with the ability to turn itself on is a great place to start.

I have set up a MySQL DB and written a PHP file to execute these. Then made a simple HTML page to call these PHP files.

You could write a batch file run a sequence of commands.

I plan to write an App on my phone that will control everything.

The possibilities are endless

As requested here are my html and php files. The SQL is a simple table with 3 fields.
The first field is the device name.
The second field is the command I give the PHP file.
The third is the key that is executed (KEY_POWER).
These files will not work with your setup but they are a good place to start

If you enjoyed this tutorial please vote for it!



  • Pocket-Sized Contest

    Pocket-Sized Contest
  • Pro Tips Challenge

    Pro Tips Challenge
  • Science of Cooking

    Science of Cooking

We have a be nice policy.
Please be positive and constructive.





Sir could you provide a screen shot of the database and the table which is used by the php please ? i just want to see the way the commands are saved there, this is the only part am missing so far to complete the project, please help you could send it to me by mail or here itself please ?!
thank you :)


Do you got an answer to your request ?

I need exactly what you wrote


Did you got any answer to share please?

I need exatly what you wrote

Thank you

I've had a similar thing working for about a year now. running on a zero being my TV.i use Tasker with an ssh plugin to send the command through ssh. it falls about half the time for no apparent reason.
you say that you have a web page for yours. I've been trying to get shell scripts to run using mqtt. but I cannot get it working. anyone have a working remotely controlled way of doing this? mqtt is small and fast, wish I could get it working. but an httpget could be nice too. any help figuring this out would be great.

thanks for above text.i want to know how can we use above thing in a c program that is how can i use irsend command in my c program

i would like to register another control, include that i alredy have, but i'm can't do it... could you please help me?!


hello sir :)
can you provide me with a screen shot of youre DB or can you provide me with a .sql file, everything works fine and i already have a website hosted on my pi and wanted to add a page to control my TV over the web :) please help sir
thank you

Hi, Been having a problem for days getting LIRC installed and running.

apt-get install lirc everything seems fine

Modified the hardware.conf and /etc/modules as per you instructions

mode2 -d /dev/lirc0 this reports an error

mode2 -d /dev/lirc0
mode2: could not get file information for /dev/lirc0
mode2: default_init(): No such file or directory


root@raspberrypi:/etc/lirc# irrecord -d /dev/lirc0 ~/out.con

irrecord - application for recording IR-codes for usage with lirc

Copyright (C) 1998,1999 Christoph Bartelmus(lirc@bartelmus.de)

irrecord: could not get file information for /dev/lirc0
irrecord: default_init(): No such file or directory
irrecord: could not init hardware (lircd running ? --> close it, check permissions)


root@raspberrypi:/etc/lirc# /etc/init.d/lirc start
[ ok ] No valid /etc/lirc/lircd.conf has been found..
[ ok ] Remote control support has been disabled..
[ ok ] Reconfigure LIRC or manually replace /etc/lirc/lircd.conf to enable..

Running jessie with latested updates banging my head

please help

Maybe you have another number, not /dev/lirc0, but something else?
What do you have in /dev/?

In my case, I had to manually create a symlink to /dev/lirc0, otherwise /dev/lirc was not present in the system:
sudo ln -s /dev/lirc0 /dev/lirc

Note that you've linked to a PNP transistor part at Sparkfun but your circuit diagram shows an NPN.