Skip to content

Country

Set Up LIRC For Your JustBoom IR Remote

Set Up LIRC For Your JustBoom IR Remote

This guide will show you how to configure LIRC on a Raspbian based OS.

Despite the fact that this guide has been created for the JustBoom IR Remote it can also be used for other IR remote controls.

LIRC installation and configuration.

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

Section 1 – Installation and configuration

Step 1 – Make sure that your system is up to date i.e. had run:

1
sudo apt-get update

then at the command line execute:

1
sudo apt-get install lirc

Step 2 – Change the file /boot/config.txt

1
sudo nano /boot/config.txt

by adding

1
2
3
4
5
# 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

1
sudo nano /etc/lirc/hardware.conf

so that it looks like this

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# 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:

1
sudo reboot

Step 5 – If all went well you should now have a lirc0 device. Verify this by issuing the following command:

1
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:

1
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:

1
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:

1
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:

1
nano ~/lircd.conf

and copy the following configuration within.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# 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:

1
2
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

1
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.

1
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:

1
nano ~/.lircrc

with the following contents

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
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

1
2
3
4
5
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):

1
irw

Point the remote control to the JustBoom IR sensor and press some of the buttons, you should get an output similar to this:

1
2
3
4
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):

1
irexec

Bu pressing buttons on your remote you should now get an output similar to the following:

1
2
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:

1
sudo nano /etc/rc.local

and add the line highlighted below just before the exit 0

1
2
3
4
5
6
/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:

1
2
3
4
5
6
7
8
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:

1
2
mount -o remount,rw /flash
nano /flash/config.txt

then once the file has been changed ans saved

1
2
mount -o remount,ro /flash
reboot
Previous article Set Up Your JustBoom For Game Streaming With Moonlight
Next article JustBoom Amps Use Cases And Usage Configurations