Introduction: Raspberry Pi Universal Remote

Picture of 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

Picture of Parts

Step 2: Setting Up the Software

Picture of 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_dev
     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
LIRCD_ARGS="--uinput"

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

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

# Try to load appropriate kernel modules
LOAD_MODULES=true

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

# usually /dev/lirc0 is the correct setting for systems using udev
DEVICE="/dev/lirc0"
MODULES="lirc_rpi"

# Default configuration files for your hardware if any
LIRCD_CONF=""
LIRCMD_CONF=""
########################################################


Reboot the Pi

     sudo reboot
 

Step 3: Making LIRC Files

Picture of 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

Picture of 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?

Picture of 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)



Options.

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!

Comments

divanshu6467 (author)2016-06-01

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

DhiogoM (author)2016-03-11

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

CSS2 (author)2016-01-15

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 :)

CSS2 (author)2016-01-12

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

PaulM211 (author)2015-12-23

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#

Also

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#

FYI

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

TatjanaV (author)PaulM2112015-12-26

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

XrakE (author)2015-07-04

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

gauntface (author)XrakE2015-10-13

Does anyone know what is correct transistor for this - PNP or NPN?

rmd6502 (author)gauntface2015-11-08

From the way the LEDs are wired, should be NPN.

KalaiyarasanE made it! (author)2015-07-20

I face some problem while creating lircd.conf file using

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

Then, I followed steps in link:

http://www.ocinside.de/html/modding/linux_ir_irrec...

Note: Start with power button when create dots (2 X80).

ShamsB (author)2015-05-27

Hi,
Thank you for the nice writeup. I having problem to send IRSEND via the web interface. Can you help me to create a 6 button remote?

I have followed your Lirc installation and manage to get it working via the command line. IRSEND -#5 send_once sony key_up ; is good.

Just want to get my html and php to work. Thank you.

Slimbots (author)2015-04-04

I have had a setup like this up and running for over a year. I used LIRC and Webiopi to develop a web based home automation system that controls my home theater system. Initially I had issues with wifi dropping every couple of days and then had issues with SD card corruption. I think both of these were cause by not having a big enough power supply. I recently created a board and kit that can drive seven IR LEDs and has a receiver to make it really easy to build. Even after the electronics are assembled it can take some time to get all of the codes programmed. You can buy the kit it here. http://www.slimbots.com

gchinni (author)2015-03-29

I followed the Complete Process But as i stop lirc :

pi@raspberrypi ~ $ sudo /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..

This is coming . i changed the Hardware.conf file and added those two lines in modules as well. .

pi@raspberrypi ~ $ sudo /etc/init.d/lirc stop

pi@raspberrypi ~ $ mode2 -d /dev/lirc0

mode2: could not get file information for /dev/lirc0

mode2: default_init(): No such file or directory

When i run this command it is showing this. Can u please Help me. lirc/devo is not created. . . What to do with this ??? Please help me urgent.

mattgreen.com (author)2015-02-18

Parts list links are no longer working... how about digikey? (and perhaps part numbers on build list just in case links break again)

Thanks

mikejclark (author)mattgreen.com2015-02-20

remove the bracket " ) " from the end of the link...

Phobia1971 (author)2015-01-19

Why can't i create a lircd.conf for a remote?

RC-6 remote controle found.

Found possible header: 226 762

Header is not being repeated.

No repeat code found.

Signals are biphase encoded.

Signal length is 23

Checking for toggle bit kask.

Please press blah blah.......

Press RETURN to continue.

And then right after pressing a button it tells me:

No toggle bit mask found.

But I know for sure that RC6 has a toggle bit!

And the program stops and no file is made. The remote is for a arcadyan model HMB2260.

This box controles my digital tv so with out it my remote controle setup is useless

Please can some one help, google doesn't seem to be much of a help!

RobertoL (author)2014-12-30

how did you configure the emitter, i wire it as you show but i cant make it work. it just blink but doesnt turn on of off anything

mjanich (author)2014-11-18

I tried to make this /etc/lirc/lircd.conf file by downloading and concatenating all remote control files that you can find (also on the lirc website). But I never got it to work. Maybe you post your /etc/lirc/lircd.conf file and we can see where the problem is.

THANKS

-M

model matrix (author)2014-10-14

i want to configure my remote,and make an entry in one file.

how i will do it.

if any one know than plz help me.

model matrix (author)2014-10-14

i want to configure my remote,and make an entry in one file.

how i will do it.

if any one know than plz help me.

model matrix (author)2014-10-14

i want to configure my remote,and make an entry in one file.

how i will do it.

if any one know than plz help me.

model matrix (author)2014-10-14

i want to configure my remote,and make an entry in one file.

how i will do it.

if any one know than plz help me.

model matrix (author)2014-10-14

i want to configure my remote,and make an entry in one file.

how i will do it.

if any one know than plz help me.

model matrix (author)2014-10-14

i want to configure my remote,and make an entry in one file.

how i will do it.

if any one know than plz help me.

PeterJ4 (author)2014-10-07

IR Sensor spec

Leftmost pin=1, just as the image in this post

Pin1 Output (connect to the GPIO-input)

Pin2 GND

Pin3 Vcc

delahere (author)2014-07-13

Given the steps above, installation of tomcat6 failed because it couldn't find the jdk. It could have been something I did by mistake - I'm working with two keyboards/mice on two different systems at the same time and I accidentally typed on the Raspbian keyboard during the lamp install. In any case, if somebody sees a failure in the Tomcat6 install related to JDK not found, this is how I fixed it:

sudo apt-get install default-jdk

sudo apt-remove tomcat6

sudo apt-install tomcat6

This is my first Raspberry Pi project and I'm really enjoying it.

mikejclark (author)delahere2014-08-13

Thanks for this, I had the same error with JDK. You made a slight typo with the commands though, should be:

sudo apt-get remove tomcat6

sudo apt-get install tomcat6

You missed out "get"

mikejclark (author)2014-07-28

For those having problems with the links, remove the bracket " ) " from the end of the link...

dnicol1 (author)2014-04-04

Hey i am also in Toronto. Very cool projects you have. Would you be i nterested In a paid project? Need something done right away.

TheGreenToaster (author)2014-01-15

Alright. They work now

akinich (author)2014-01-13

it's good but please share your files for the web server ( sql and php along with the html )

TheGreenToaster (author)akinich2014-01-13

I just posted them on the last step

akinich (author)TheGreenToaster2014-01-14

Hey it say error 403 , please fix it

akinich (author)TheGreenToaster2014-01-14

Thank you

pumo (author)2014-01-14

May be you should change attachments to txt file.

now those doesnt work:

403 Forbidden
Request forbidden by administrative rules.