I had a bit of a harder time that I should getting an IR receiver to work with my RPi & iQ Audio Pi-DAC, so I thought I would put up how I did manage to get it work to help others on this forum. It is really worth taking your time to do this as it makes Volumio a 1000x better than it already is, if feels like a real appliance after you do this, especially because you can shutdown Volumio with a power button
Hardware
RPi, obviously this will work without a PiDAC
I used a TSOP38238 IR Receiver, they are readily available on ebay. Buy a couple, just incase you burn them out (if you are clumsy like me) by connecting the wires wrong! (http://www.vishay.com/docs/82491/tsop382.pdf)
I also used a CD Audio Cable from Maplins to run the wire from the Pi-DAC case outside my TV cabinet. I pulled off the black plastic connectors and used the 3 metal pins crimped inside to connect the wires directly to the RPi and the pins of the IR Receiver. (http://www.maplin.co.uk/p/internal-analogue-audio-cables-lq80b)
Wiring Up
IR Receiver (with the domed bit facing towards you)
White cable: Left pin, marked as data out on the data sheet
Black cable: Middle pin, ground
Red cable: Right pin, supply voltage
RPi
White Cable: GPIO23 (IO23 on PiDAC)
Black Cable: Ground, 0V
Red Cable: 3.3V
Software
This was the part that gave me the most headaches. >:(
Login via SSH and install LIRC
sudo apt-get install lirc
Set LIRC to use GPIO 23
sudo modprobe lirc_rpi gpio_in_pin=23
See if it is working:
mode2 -d /dev/lirc0
If it has worked, it will output some pulse/space messages on the terminal when you press buttons on your remote. (Press Ctrl+C to exit)
If it has worked, edit /etc/modules to load lirc every time you boot.
sudo nano /etc/modules
Add these two lines to the file:
lirc_dev
lirc_rpi gpio_in_pin=23
Save and Exit.
Next, Edit /etc/lirc/hardware.conf
sudo nano /etc/lirc/hardware.conf
Replace its contents with this:
# /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=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="\etc\lirc\lircd.conf"
LIRCMD_CONF=""
(TIP) The START_IREXEC was the hardest part to figure out because IREXEC, which is the daemon that runs in the background to receive commands from your remote will not start if you add it to /etc/rc.local, the configuration file for lircrc has to be at /etc/lirc/lircrc, see the configuring LIRCEXEC section below.
Programming your remote
Stop lirc services running in the background
sudo /etc/init.d/lirc stop
The /etc/lirc/lircd.conf stores the buttons and their commands from your remote control. Generate a new configuration by running:
sudo irrecord -f -d /dev/lirc0 /etc/lirc/lircd.conf
Follow the onscreen instructions, when it asks you for command names, log into Volumio from another terminal session and run the following command to get a list of commands:
irrecord ālist-namespace
I used KEY_VOLUMEUP, KEY_VOLUMEDOWN, KEY_PLAY etc from the remote for my DVD Player.
Once you are done, reboot volumio and test that the remote is working by running:
irw
The buttons you press will be shown on the screen (Press Ctrl+C to exit).
Configuring IREXEC
Now we want volumio to respond to the buttons using IREXEC, which is a background process that listens for IR commands and runs corresponding commands on the system.
Many tutorials make a ~/.lircrc in the home folder, but it cannot be started automatically as a process this way with LIRC. For it to work properly, make the configuration file at /etc/lirc/lircrc:
sudo nano /etc/lirc/lircrc
Next, copy these commands into the lircrc file. I used the following to control MPD in the lircrc file. You will also notice I use two of the buttons to stop and start Squeezelite (find more info on configuring the lircrc file here: lirc.org/html/configure.html).
begin
prog = irexec
button = KEY_PREVIOUSSONG
config = mpc prev; mpc play
repeat = 0
end
begin
prog = irexec
button = KEY_NEXTSONG
config = mpc next; mpc play
repeat = 0
end
begin
prog = irexec
button = KEY_PLAY
config = mpc play
repeat = 0
end
begin
prog = irexec
button = KEY_PAUSE
config = mpc toggle
repeat = 0
end
begin
prog = irexec
button = KEY_STOP
config = mpc stop
repeat = 0
end
begin
prog = irexec
button = KEY_VOLUMEUP
config = mpc volume +1
repeat = 4
end
begin
prog = irexec
button = KEY_VOLUMEDOWN
config = mpc volume -1
repeat = 4
end
begin
prog = irexec
button = KEY_FASTFORWARD
config = mpc seek +1%
repeat = 4
end
begin
prog = irexec
button = KEY_REWIND
config = mpc seek -1%
repeat = 4
end
begin
prog = irexec
button = KEY_MUTE
config = mpc volume 0
repeat = 0
end
begin
prog = irexec
button = KEY_EJECTCD
config = /etc/init.d/squeezelite stop
repeat = 0
end
begin
prog = irexec
button = KEY_AUX
config = mpc stop; /etc/init.d/squeezelite start
repeat = 0
end
begin
prog = irexec
button = KEY_POWER
config = sudo halt
repeat = 0
end
Once that is done, reboot and your remote should be working with volumio Good Luck!