LIRC - Raspberry Pi

From ETCwiki
Jump to navigationJump to search
alt RPi Connected to a TSOP4838

This is a complicated guide to setting up LIRC on the Raspberry Pi to run remote commands. Materials

  • Vishay TSOP4838 $4 (aka 38kHz Infrared (IR) Receiver Module - Part Number 276-640 at Radio Shack)

Start by installing LIRC

apt-get install lirc

Now, edit the file /etc/lirc/hardware.conf

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

Now edit the file /etc/modules and add this line


Now edit (or make) the file /lib/udev/rules.d/98-lircd.rules and add this line

KERNEL=="lirc[0-9]*",   SUBSYSTEM=="lirc", SUBSYSTEMS=="platform", GOTO="begin"

Now test to see if receiver works, run this and press some buttons, see anything?

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

Now setup your remote control or use a default lircd.conf for a remote on file with LIRC Notes: setup as many or as few buttons as you want. I would recommend doing them all now.

irrecord --list-namespace      (print or save this, you will need it during setup)
irrecord -d /dev/lirc0 ~/lircd.conf     (follow instructions and use above command for key names)

Now copy the created ~/lircd.conf to its new home

mv /etc/lirc/lircd.conf /etc/lirc/lircd.original    (backup original)
cp ~/lircd.conf /etc/lirc/lircd.conf     (Copy it home)

Now test your keys and remote setup

service lirc restart
killall irexec
irw     (now spam some buttons! Ctrl + C to exit)

Want to launch programs with your remote? Edit or create ~/.lircrc ~/ means the users home directory

touch ~/.lircrc
vi ~/.lircrc

Add these lines to ~/.lircrc Note: Replace KEY_POWER with your key from your lircd.conf Note: Use an & at the end of the config = line. It will run the command without making you wait for it to complete

     prog = irexec
     button = KEY_POWER
     config = /home/pi/gpio/ &

Test... Again but this time to exec the program

killall irexec
service lirc restart
irexec -d    (now test your button)