Difference between revisions of "LIRC - Raspberry Pi"

From ETCwiki
Jump to navigationJump to search
 
(No difference)

Latest revision as of 15:53, 14 October 2013

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
LIRCD_ARGS=""  

#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=true

#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 edit the file /etc/modules and add this line

lirc_rpi

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

begin
     prog = irexec
     button = KEY_POWER
     config = /home/pi/gpio/11blink.sh &
end

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

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