Freitag, 26. Dezember 2014

Raspberry PI + lirc + arch linux

Hello again!
This time I will tell you how to get lirc running with an arch linux running on my Raspberry PI!

First, get lirc and lirc-utils:

pacman -S lirc lirc-utils

Next, load the module:

modprobe lirc_rpi

Check if the modules are loaded:

lsmod | grep lirc
lirc_rpi                7346  0
lirc_dev               10291  1 lirc_rpi
rc_core                17437  1 lirc_dev

Looks good! By default lirc_rpi uses GPIO 17 as output and GPIO 18 as input. We can check this doing the following:

cat /sys/kernel/debug/gpio
GPIOs 0-53, bcm2708_gpio:
 gpio-16  (led0                ) out hi
 gpio-17  (lirc_rpi ir/out     ) in  lo
 gpio-18  (lirc_rpi ir/in      ) in  lo

If you have wired up everything, you can check if your receiver works properly:

mode2 -d /dev/lirc0

Now you should press some buttons on your remote and should see some output like this:

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

Great, the receiver works. 

If you want to record your remote codes, you need to know the available keys lircd knows, therefore run 

irrecord --list-namespace  

reading from /dev/lirc0, writing to ~/lircd.conf, hit:

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

The file now goes to /etc/lirc/lircd.conf and maybe you have to change the name variable  to REMOTE_NAME inside the config file, but I think this is more or less self-explanatory.

Now to test the blaster, fire up the lirc daemon:

systemctl start lircd

And finally blast some codes...


or whatever key you recorded.

If you like to start this automatically on boot, do this:

systemctl enable lircd

Additionally, the kernel modules need to be loaded, too. This is achieved by doing the following:

rm -f /etc/modules-load.d/lirc_dev.conf
echo "lirc_rpi" > /etc/modules-load.d/lirc_rpi.conf

I removed the lirc_dev.conf since lirc_rpi depends on lirc_dev and automatically loads lirc_dev. Now if you would like to employ different GPIO pins, you need to put the options for the kernel module into a different file.

echo "options lirc_rpi gpio_in_pin=23 gpio_out_pin=22" > /etc/modprobe.d/lirc_rpi.conf

This should do the trick.

Keine Kommentare:

Kommentar veröffentlichen