LIRC - Infrared receiver
![]() |
Nowerdays nearly every device comes with its own infrared remote control:
CD-Player, TV-Sets, VCRs and even garage-doors. Would a computer be missing from this listing ...? |
Save money
Even PCs understand infrared-signals by now. Many newer laptops/notebooks have
their own IR-Port which enables them to transfer data to another device (cellular phone, printers, etc.)
or even to another laptop.
Some TV-Tuner-Cards are sold with an IR-remote, too. Mostly you have to pay more
(sometimes a LOT more) for this comfy add-on.
As the typical Linux-User is thrifty and likes some manual work it is not suprising
that you find software and hardware solutions for DIY on the internet.
After all you probably own too many remote controls lying at home. Connected to a computer
you could define the function keys, too.
Change to the next MP3-song, adjust the volume or even change the station in kwintv just with your
fingertip? No problem!
The usability is - as usual - infinite.
But you can't just start programs, you can also simulate mouse-events with your remote control
for using it with your browser. ("Browse at your fingertips" ;) )
More useful would a remote control be for presentations: Change the slide beamed on the wall
by a beamer connected to a laptop with your remote control. The audience
would be amazed...
Drivers for using a remote control with a linux-computer have existed for a longer time now, so it is not suprising that many multimedia programs support remote controls. Those programs provide special commands which can be interpreted and be done while the user mustn't care about details.
compiling some hardware
Before you can use the remote control you'll need an infrared-receiver.
You can buy one, which is connected to the serial port, but you will have to pay a fortune
(mostly 35 EUR and more) and they won't work better than the DIY-version which costs about 8 EUR.
Furthermore those products are sold with windows-software (if ever) and why should you pay for that?
The used parts are neither exotic nor expensive so you should find them at the most-chaotic supplier. In case of emergency: You can order these devices at "Conrad Electronic". You find the article-IDs in the table below.
| Device | Article-ID |
| Resistor 4,7 kOhm | e.g. 41 83 31 |
| Condenser 10 µF | e.g. 46 82 31 |
| Condenser 100nF | e.g. 45 33 58 |
| IR-receiver module 78L05 | 17 10 77 |
| Diode 78L05 | 16 22 80 |
| Potential transformer 78L05 | 18 30 24 |
| 9-polige serial connector (female) (maybe with cable, see text) | |
| solder plate |
If you're a bit skilled it should be peanuts putting those parts together as shown on the circuit-plan, even for unexperienced Amateurs.
Although only 3 pins of the serial port connector are used it is suggested to buy a serial cable (with 9 pins) and cut it in the middle. But remember: Use a cable-tester to find out which cable belongs to which pin. Don't use them randomly ;) .
The pins are usually numbered on the connector-side. As a matter of fact, not everybody (mostly the vendors) knows about that... :( .
The used pins of the jack are
| 9-Pin (Sub-D Jack) |
|
RTS 7 Request To Send (Power supply) GND 5 Ground DCD 1 Data Carrier Detect (IR-Signal) |
The receiver circuit looks like this:

( download EPS-File )
and should look like this when assembled:
The assembled circuit can be very compact, depending on your technical knowledge. It is recommend to put the plate in a small case, but don't forget a hole for the receiver-module. You can also make it an "integrated" device by putting it inside your computer.
The receiver shown on the LIRC-Homepage is very compact. The receiver itself takes place in a serial plug.

Software installation
As soon as the receiver is completed you surely want to know whether it works. At first you need to install the needed software which can be found on the Homepage of the LIRC Project (Linux Infrared Remote Control) on http://www.lirc.org. The current version is 0.6.3. In case of problems it could be useful to use the newest CVS-version or (in case you don't know how to use CVS) the latest snapshot (can be found at http://www.lirc.org/software/snapshots/).
After unpacking into the /tmp-directory
>> tar zxvf lirc-0.6.3.tar.gz -C /tmpyou have to compile it:
>> cd /tmp/lirc-0.6.3 >> ./configureNow a configuration-window should appear where you can do your configuration work:
![[PIC] configure LIRC](../../share/issue6/lirc_config.jpg)
With the first menu-item - called "driver configuration" - you can configure (who thought THAT?) what kind of IR-receiver you are using. As for our DIY-type the type "Home-brew..." should do ;) Following this hard decision you have to choose the serial port and the interrupt the receiver can be found at. Now LIRC wants to know whether we want to send IR-signals. As we have no IR transmitter diode in our circuit the point "With transmitter diode" remains blank. The 2nd item "Software generated carrier" can be left activated.
After that we will (hopefully) be back in the main menu for taking care of point 2 called "Software configuration". Because we want to control X-Applications with our remote control the option "Compile tools for X-Windows" has to be activated. All other options should be blank.

And here we are again: back in the main menu. This time we choose "Save configuration & run configure" which is the 3rd item in the menu.
When the configure-script finished without error mesages (you maybe get a warning saying the serial ports are not implemented as module but directly compiled into the kernel) you can start compiling the software:
>> makeFinally, when everything compiled without errors, install them as "root":
>> su [password] >> make installAs LIRC uses kernel modules and works near to the hardware at all it may be uneasy to compile it on patched kernels. LIRC won't work with the kernel which comes with SuSE 7.0 (kernel 2.2.16) which is in fact a patched version.
Lirc uses its own device to communicate with the hardware. Depending on the distribution this file (/dev/lirc) may already exist, otherwise you have to create it (as root) yourself:
>> mknod /dev/lirc c 60 0The "c" means that this should be a character-device (this is important for the communication with the hardware). The two numbers define the major- and the minor-number the kernal uses internally to call the device.
After all this work you can test your receiver. The easiest way to do this is using xmode2 under X which should be found in lirc's tools-direcory.
>> xmode2On your X-Server a window should be shown where the signals received by our receiver are shown Hold your remote control in the direction of the receiver and you should see the received signals:
If there are some peaks which do not come from your remote control these are mostly peaks caused by the normal light in your room.
Hint: Try all remote controls you can find in your house and you will see how many different kinds of signals (correct: protocols) exist.
learning sessions
Though there are many different remote controls, no software knows them all.
Some configuration files for different kinds of remote controls can be found on the
LIRC Website http://www.lirc.org/remotes/,
But it's a lottery as to whether your one is listed there or not.
Because of this LIRC comes with its own program to create configuration files for your
remote control(s).
The program you need is irrecord and is located in lirc's daemons subdirectory.
You have to create a configuration file for every remote control you want to use with lirc.
According to the programs license you have to mail your configuration file to the program author to enable him
to increase the number of supported remote controls.
To avoid errors by other light than the IR signals the author of irrecord supposes to do the learning process in a dark room.
The program is started using:
>> irrecord /tmp/remote1.configAfter the first information for users, the software tries to determine the remote control's type ( it tries to determine the protocol). For that it is necessary to press nearly every key on your remote control (further information will be provided by irrecord).
The next step is to give every key a name (without blanks). This name is used for referencing in the configuration file we're going to create later. After naming the key has to be pressed several times.
After all keys have been named you can quit the program simply by pressing the "Enter"-key without entering a name first.
Our created configuration file can be found at /tmp/remote1.config and
should be copied to /usr/local/etc/lircd.conf.
If you want to use more than one remote control you have to create several configuration files and cat them into one file:
>> cat config1 config2 >config
Beneath some information about the remote conrol the so called codes can be found in our configuration file /usr/local/etc/lircd.conf. You can look up the names you assigned to your rc's keys there, too:
| /usr/local/etc/lircd.conf |
[...]
begin codes
Volume_down 0x000000000000601F
Volume_up 0x000000000000205F
Audio_Mute 0x000000000000502F
Class 0x0000000000002956
Tuner_Next 0x000000000000007F
Tuner_Prev 0x000000000000403F
CD_Next 0x0000000000005C23
CD_Prev 0x0000000000003C43
CD_Stop 0x0000000000001C63
CD_Disc 0x0000000000001D62
CD_Pause 0x0000000000007C03
CD_Play 0x0000000000006C13
DeckA_Rew 0x000000000000255A
DeckA_Forw 0x000000000000453A
DeckA_Stop 0x0000000000005926
DeckA_Rec 0x000000000000057A
DeckA_Play 0x0000000000003946
DeckA_PlayRev 0x0000000000007906
DeckB_Play 0x000000000000542B
DeckB_PlayRev 0x000000000000344B
DeckB_Stop 0x000000000000641B
DeckB_Rec 0x0000000000000C73
DeckB_Forw 0x0000000000004C33
DeckB_Rev 0x0000000000002C53
Phono 0x0000000000002857
CD 0x0000000000004837
Tuner 0x0000000000006817
Tape1 0x0000000000000877
Tape2 0x000000000000700F
Sleep 0x0000000000005D22
Power 0x000000000000106F
end codes
end remote
|
Configuration
Naming and announcing of one (or more) remote control(s) is being done system-wide by our just created, brand new configuration file /usr/local/etc/lircd.conf. The configuration which key should do which command can be done for each user seperately (or easier: they can do it by themselfes). To do so, a file named .lircrc has to be created in the user's home directory. Here is an example what a ~/.lircrc-file could look like (The key names can be different with you):
| ~/.lircrc |
begin
prog = irexec
button = CD
config = xmms &
mode = xmms
end
begin
prog = irexec
button = Sleep
config = xterm &
end
|
Finally some more programs must be run:
At first the lircd daemon has to be started (located in the lirc-0.6.3/daemons/lircd subdirectory). This has to be done as root user.
The IR-receiver can be connected to another computer than the one where the programs will run later. The hardware-software-communication is possibly done over a network.
The software for reading the configuration file and for executing the commands assigned to the keys can be found in lirc-0.6.3/contrib. In this directory, simply run (as user with the .lircrc-file in your homedir)
>> ./lircs -cFrom now on all programs should run as you wished and pressing the "CD" key should start xms, the "Sleep" key should open a terminal window.
Fine Tuning
The most important programs to be controlled by a remote control would be MP3-player and tv-applications.
As for xmms a plugin for using remote controls is available at http://sourceforge.net/project/showfiles.php?group_id=5444"
After compiling the created libraries have to be copied from the .libs directoy either to xmms's global plugin-directory or to the local plugin-directory (~/.xmms/Plugins). After restarting xmms the new plugin can be activated in the preferences-menu:

XMMS now understands the following commands which can be used directly in the LIRC-configuration file
| LIRC-XMMS Plugin commands |
PLAY ONE
STOP TWO
PAUSE THREE
PLAYPAUSE FOUR
NEXT [<tracks>] FIVE
PREV [<tracks>] SIX
SHUFFLE SEVEN
REPEAT EIGHT
FWD [<sec>] NINE
BWD [<sec>] ZERO
VOL_UP [<percent>] SETPOS
VOL_DOWN [<percent>] QUIT
BAL_LEFT [<percent>] LIST
BAL_RIGHT [<percent>] SELECT <chars>
BAL_CENTER PLAYLIST_CLEAR
PLAYLIST_ADD <file>
|
Xawtv supports IR-remotes (as of newer versions) by itself and does not need any plugins.
The newest xawtv version can be found at
http://bytesex.org/xawtv/.
The commands to be used with xawtv are the same which the program xawtv-remote (comes with xawtv)
can send to a running xawtv. The command which are interesting regardig the use of a remote control are:
| xawtv-commands |
setstation [ <name> | <nr> | next | prev | back ] setchannel [ <name> | next | prev ] setinput [ <input> | next ] capture [ on | off | overlay | grabdisplay ] volume [ inc | dec | mute | <n> ] snap [ jpeg | ppm ] [ full | win | widthxheight ] <filename> ] movie file <filename> | start | stop fullscreen msg text quit keypad n |
Further informations can be found on the xawtv-remote manpage.
A ~/.lircrc-file could e.g. look ike this (partly published):
| ~/.lircrc |
begin
prog = irexec
button = CD
config = xmms &
mode = xmms
flags = once
end
begin
prog = irexec
button = Tuner
config = xawtv &
mode = xawtv
flags = once
end
begin
prog = irexec
button = Sleep
config = xlock &
end
begin xmms
begin
prog = xmms
button = CD_Play
config = PLAY
end
begin
prog = xmms
button = CD_Pause
config = PAUSE
end
begin
prog = xmms
button = CD_Stop
config = STOP
end
[...]
end xmms
begin xawtv
begin
prog = xawtv
button = DeckA_Play
config = setstation next
end
begin
prog = xawtv
button = DeckA_PlayRev
config = setstation prev
end
begin
prog = xawtv
button = DeckA_Rec
config = fullscreen toggle
end
[..]
end xawtv
|
Every remote control has at least one key less than needed. LIRC gives you the possibility to use more than one key at a time. The entry
mode = xmms
causes that LIRC changes to the xmms-mode when the CD-key is pressed.LIRC will now execute the commands defined in the
begin xmms [... define keys here ...] end xmmsarea.
The same key could also be defined for another mode for executing different commands. But you have to press the key for changing to another mode first!
start automatically
For starting the daemon automatically the use of an init-script is - as usual - suggested. Some samples for init-scripts are provided in the contrib subdirectory but though these files are not only depending on the distribution as also depending on versions we suggest to copy a existing init-file of your distribution and modify it.
This init-script effects that the lirc-daemon is beeing started during every booting. Aditionally the users have to start the irxevent and irexec --daemon which execute the commands assigned to the remote control keys. This is usually be done by th lircs script located in the contrib subdirectory.
This script should not be executed as root but as user who owns a .lircrc file in his homedirectory.
whether the command
lircs -cshould be executed during booting or on starting the X-Server depends on the usage of the remote control and whether the computer is a multi-user-system or a single-user-system.
Placing the command in the init-file you have to execute it without root-rights using the
su nonrootuser -c "umask 022; /path/to/lircs -c"command.
Otherwise the command lircs -c has simply to be added to the user's ~/.xinitrc file to start it when the GUI starts.
The creation of X-events like mouselicks using LIRC is more difficult and will be theme of a LIRC-report in the 7th issue
of the Linux NetMag
Links
LIRC homepage: http://www.lirc.org
LIRC in the c't-Magazine (german): http://www.heise.de/ct/00/18/208/
Talkback Area
Enter Own Comment
