Installing LIRC on Raspbian

Here's what you need to do in order to get LIRC working properly on Raspbian:

  1. Make sure you are running the version of Raspbian which has the LIRC modules included
  2. Install lirc from apt-get
  3. Add a couple of entries into the /etc/modules file
  4. Use dmesg to ensure the Lirc settings have loaded properly
  5. Run a system command to ensure the the device is reading the signals from the remote control
  6. Run an lirc program to record the IR commands from the remote control
  7. Test the IR commands are being properly interpreted by the final setup.

Here's the steps in detail:

Upgrading Raspbian

type apt-get upgrade

Install lirc from apt-get

type apt-get install lirc

Here's the ouput from that:

Reading package lists... Done
Building dependency tree
Reading state information... Done
Suggested packages:
  lirc-x setserial ir-keytable
The following NEW packages will be installed:
  lirc
0 upgraded, 1 newly installed, 0 to remove and 354 not upgraded.
Need to get 562 kB of archives.
After this operation, 1,784 kB of additional disk space will be used.
Get:1 http://mirrordirector.raspbian.org/raspbian/ wheezy/main lirc armhf 0.9.0~pre1-1 
Fetched 562 kB in 2min 7s (4,404 B/s)
Selecting previously unselected package lirc.
(Reading database ... 103145 files and directories currently installed.)
Unpacking lirc (from .../lirc_0.9.0~pre1-1_armhf.deb) ...
Processing triggers for man-db ...
Setting up lirc (0.9.0~pre1-1) ...
No valid /etc/lirc/lircd.conf has been found..
Remote control support has been disabled..
Reconfigure LIRC or manually replace /etc/lirc/lircd.conf to enable..

Modify the /etc/mo

dules file

I added the following lines to /etc/modules

lirc_dev
lirc_rpi gpio_in_pin=18 gpio_out_pin=25

Als o changed the file /etc/lirc/hardware.conf

########################################################
# /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=""
########################################################

Now restart lircd so it pi cks up these changes:

sudo /etc/init.d/lirc stop
sudo /etc/init.d/lirc start

Check dmesg

It should look something like this:

 lirc_dev: IR Remote Control driver registered, major 248 
 lirc_rpi: module is from the staging directory, the quality is unknown, you have been warned.
 lirc_rpi lirc_rpi.0: lirc_dev: driver lirc_rpi registered at minor = 0
 lirc_rpi: driver registered!
 lirc_rpi: auto-detected active low receiver on GPIO pin 18
 input: lircd as /devices/virtual/input/input0

Init

ial test

Type the following:

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

Poi nt a remote control at your IR receiver and press some buttons. You should see something like this:

space 16300
pulse 95
space 28794
pulse 80
space 19395
pulse 83
space 402351
pulse 135
space 7085
pulse 85
space 2903

Recording

IR commands

Be sure to run irrecord --list-namespace to see the valid names before you begin.

Here were the commands that I ran to generate a remote configuration file:

# Stop lirc to free up /dev/lirc0
sudo /etc/init.d/lirc stop

# Create a new remote control configuration file (using /dev/lirc0) and save the output to ~/lircd.conf
irrecord -d /dev/lirc0 ~/lircd.conf

# Make a backup of the original lircd.conf file
sudo mv /etc/lirc/lircd.conf /etc/lirc/lircd_original.conf

# Copy over your new configuration file
sudo cp ~/lircd.conf /etc/lirc/lircd.conf

# Start up lirc again
sudo /etc/init.d/lirc start

Testing the

final setup.

type irw to detect the commands

example output:

0000000000000002 00 KEY_DOWN /home/james/lircd.conf
0000000000000002 01 KEY_DOWN /home/james/lircd.conf
0000000000000002 02 KEY_DOWN /home/james/lircd.conf
0000000000000002 03 KEY_DOWN /home/james/lircd.conf
0000000000000001 00 KEY_CHANNELUP /home/james/lircd.conf
0000000000000001 01 KEY_CHANNELUP /home/james/lircd.conf
0000000000000001 02 KEY_CHANNELUP /home/james/lircd.conf
0000000000000001 03 KEY_CHANNELUP /home/james/lircd.conf
0000000000000003 00 KEY_POWER /home/james/lircd.conf
0000000000000003 01 KEY_POWER /home/james/lircd.conf
0000000000000003 02 KEY_POWER /home/james/lircd.conf


Resources

Tags:
Source:
2326hrs.txt
Published:
19-05-2013 23:26