Despite the fact that this guide has been created for the JustBoom IR Remote it can also be used for other IR remote controls.
This guide was originally published here.
In order to get LIRC to work on your Raspbian distribution you need to install the LIRC packages and configure two files.
This guide is based on Pixel and has been tested successfully with a number of OS.
If you haven’t done that yet follow the Add an IR Receiver to Your JustBoom Boards guide to install the IR receiver on your card.
This guide has been tested with:
- Moode Audio 2.7, 3.1, 3.7
- Volumio 2.041, 2.030
Step 1 – Make sure that your system is up to date i.e. had run:
sudo apt-get update
then at the command line execute:
sudo apt-get install lirc
Step 2 – Change the file /boot/config.txt
sudo nano /boot/config.txt
by adding
# Enable the lirc-rpi module
dtoverlay=lirc-rpi
# Override the defaults for the lirc-rpi module
dtparam=gpio_in_pin=25
In some distributions the config.txt is under /flash read the following section for more information.
Step 3 – Edit the file /etc/lirc/hardware.conf
sudo nano /etc/lirc/hardware.conf
so that it looks like this
# 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=""
Step 4 – Reboot by typing:
sudo reboot
Step 5 – If all went well you should now have a lirc0 device. Verify this by issuing the following command:
ls /dev/lirc0
this command should return a file named lirc0. If this commands doesn’t output go back and verify the configuration once again as the drivers have not been loaded.
Step 6 – You can test that the hardware is all working fine by running:
mode2 -d /dev/lirc0
and start pressing buttons on your IR remote which should result in some output on the screen. Hit CTRL^C to terminate mode2 execution.
Note that this is only verifying that the device is present and that the hardware is working fine, we are not testing yet any functions of LIRC.
Section 2 – Remote Training.At this point we need to “teach” LIRC about your remote control. You may find that your remote’s configuration is already available to download at the LIRC Remote Database but if you are using our JustBoom IR Remote you’ll be given a ready made configuration in this section of the guide.
Step 1 – Stop the LIRC service by typing:
sudo /etc/init.d/lirc stop
If you need to run the training because your IR remote is neither in the LIRC Remote Database nor is a JustBoom IR Remote then move to step 2a otherwise go to 2b.
Step 2a – To start the training run:
sudo irrecord -n -d /dev/lirc0 ~/lircd.conf
This will initiate the training for your remote and save the configuration in /home/pi/lircd.conf (Change with your distribution user’s home folder) Follow the instructions given by the program.
Step 2b – Create a new file called lircd.conf by typing:
nano ~/lircd.conf
and copy the following configuration within.
# Please make this file available to others
# by sending it to <lirc@bartelmus.de>
#
# this config file was automatically generated
# using lirc-0.9.0-pre1(default) on Thu Dec 15 14:58:27 2016
#
# contributed by: Francesco Vannini
#
# brand: JustBoom
# model no. of remote control: IR Remote
# devices being controlled by this remote:
#
begin remote
name lircd.conf
bits 5
flags RC5|CONST_LENGTH
eps 30
aeps 100
one 921 855
zero 921 855
plead 936
pre_data_bits 8
pre_data 0xA0
gap 114211
toggle_bit_mask 0x800
begin codes
Home 0x10
Mute 0x12
Power 0x11
Up 0x1A
Down 0x1B
Left 0x13
Right 0x14
OK 0x15
Menu 0x16
Back 0x17
Volume-Up 0x19
Volume-Down 0x18
end codes
end remote
This creates the configuration file so that it supports our JustBoom IR Remote.
Step 3 – Backup the old configuration and replace it with the newly created one by running:
sudo mv /etc/lirc/lircd.conf /etc/lirc/lircd.conf.org
sudo cp ~/lircd.conf /etc/lirc/lircd.conf
Step 4 – The restart the LIRC service
sudo /etc/init.d/lirc start
This will reload LIRC with the new configuration and you should now have a lircd daemon running. Type the following to verify that to be the case.
ls /var/run/lirc/
You should get a lircd and lircd.pid files proof that the daemon has been loaded properly and LIRC is working.
Section 3 – Controlling the MPD of your choice.Once LIRC is configured we need to create a file that will allow us to match the remote control IR signals to commands for the MPD used in the distro that you are running.
Step 1 – Create a file called.lircrc in your home folder e.g. /home/pi or /home/volumio whichever is the default user of your distribution
by issuing the command:
nano ~/.lircrc
with the following contents
begin
prog = irexec
button = OK
config = mpc toggle
end
begin
prog = irexec
button = Volume-Up
config = mpc volume +2
end
begin
prog = irexec
button = Volume-Down
config = mpc volume -2
end
begin
prog = irexec
button = Right
config = mpc next
end
begin
prog = irexec
button = Left
config = mpc prev
end
begin
prog = irexec
button = Up
config = mpc seek +00:00:10
end
begin
prog = irexec
button = Down
config = mpc seek -00:00:10
end
begin
prog = irexec
button = Back
config = mpc repeat on
end
begin
prog = irexec
button = Menu
config = mpc repeat off
end
add any new MPD/IR button associations by inserting a new block
begin
prog = irexec
button = <your new button>
config = mpc <command>
end
Step 2 – At this point we can test the configuration crated by running (CTRL^C to exit execution):
irw
Point the remote control to the JustBoom IR sensor and press some of the buttons, you should get an output similar to this:
000000000000141a 00 Up lircd.conf
000000000000141a 01 Up lircd.conf
0000000000001414 00 Right lircd.conf
0000000000001414 01 Right lircd.conf
This means that the remote is correctly mapped and all should be working fine. Lastly let’s test that the file.lircrc is also working fine and that the remote can issue commands to the MPD. Type (CTRL^C to exit execution):
irexec
Bu pressing buttons on your remote you should now get an output similar to the following:
volume: 39% repeat: off random: off single: off consume: off
volume: 37% repeat: off random: off single: off consume: off
With this last test we have verified that all the configuration is working as it should.
Step 3 – With irexec running you should have also seen things happening within the player of your distribution. If you had a song playing and you pressed the buttons of the volume, the audio level should have also changed. This means that we would need irexec to run a boot time.
Edit the rc.local file by issuing the following command:
sudo nano /etc/rc.local
and add the line highlighted below just before the exit 0
/usr/bin/udisks-glue/dev/null
/var/www/command/worker.php/dev/null
sudo -u pi irexec -d
exit 0
Bare in mind that the user specified in the line above will vary depending on which OS you are using.
Appendix – Tips and gotchas.Tip 1 – Some OS will replace the contents of the config.txt every time configurations settings are saved. This results in the LIRC configuration to be removed and hence your remote control stops working. In this case check the config.txt which may appear like:
hdmi_drive=2
dtparam=i2c_arm=on
dtparam=i2s=on
dtparam=audio=off
dtoverlay=justboom-digi
# Enable the lirc-rpi module
# Override the defaults for the lirc-rpi module
Simply add the missing lines to make it work again and reboot.
Tip 2 – If your OS has a directory called /flash instead of /boot in order to edit the config.txt you will have to:
mount -o remount,rw /flash
nano /flash/config.txt
then once the file has been changed ans saved
mount -o remount,ro /flash
reboot
Comments