From ArchWiki
Jump to: navigation, search

lirc step-by-step quick-start HOWTO for a USB (MCE [Media Center Edition]) IR receiver and universal remote control

Author: Clemmitt M. Sigler, cmsigler--remove-this--dot-online@gmail-dot-com

Date: February 10, 2018

  • First, get a USB IR receiver, preferably an MCE model which is almost always supported out-of-the-box. Then, re-purpose an old universal remote control you have lying around the house
  • Install lirc
  • Plug in the USB IR receiver
  • Get some kind of output/response from the remote using mode2, changing protocols if it's not working
   $ sudo mode2

This will attempt to autodetect the correct input device using the default "devinput" driver. Remember that this might not work without further configuration.

Make sure there are fully charged batteries in your remote control, then point it at the IR receiver and press some buttons.

If you get no response to the universal remote control buttons you want to use, you likely need to enable different protocols using:

   $ sudo ir-keytable -p <protocol> -p <protocol> ...

Look at the output of `ir-keytable' (as well as `cat /sys/class/rc/rc0/protocols').

NOTE: When you have problems, `sudo ir-keytable -p all' is your friend :)

You may also need to try different universal remote device modes (TV, DVD, Audio, etc., buttons) in order to detect button presses when you're getting started. You could possibly reprogram the universal remote's modes, but that would likely be a trial-and-error process to find a setting that works.

  • If you have narrowed down what protocols you need to support for your remote control, set them
   $ ir-keytable
   $ sudo ir-keytable -p sony -p rc-5

Otherwise, you can just use all protocols:

   $ sudo ir-keytable -p all
  • Determine the correct device for your IR receiver. Use either the default "devinput" driver or the older "default" driver
   $ mode2 --driver devinput --list-devices
   $ mode2 --driver default --list-devices
   $ ir-keytable

Use the device found for your USB IR receiver, e.g., /dev/input/event11:

   $ sudo mode2 --driver devinput --device /dev/input/event11

or just try:

   $ sudo mode2 --driver devinput --device auto

See if button presses are detected.

  • Edit /etc/lirc/lirc_options.conf if needed, e.g., you're not using the default "devinput" driver
  • Test your remote to see if scancodes are printed
   $ sudo ir-keytable -t

See if button presses are detected.

  • Start the lirc daemon so you can record keypresses in order to write an lircd.conf file for your remote control
   $ sudo systemctl start lircd
  • Use irrecord to record keypress scancodes


   $ sudo irrecord

to save/record the keystrokes on the universal remote to be used for your application. Follow the instructions.

Move the created device_name.lircd.conf file to /etc/lirc/lircd.conf.d and:

   $ sudo chown root:root /etc/lirc/lircd.conf.d/device_name.lircd.conf

Move /etc/lirc/lircd.conf.d/devinput.lircd.conf to /etc/lirc/lircd.conf.d/devinput.lircd.dist to disable it, e.g., if you're not using an IR keyboard and/or mouse (because you're not ;)

  • Restart the lirc daemon so you use the newly created lircd.conf file
   $ sudo systemctl restart lircd
  • Test to make sure the keys you recorded are correctly detected, that is, the correct key symbol is output for each button you press
   $ irw

See if the correct key symbols are reported, and if repeated signals are properly detected (so they can be rejected) as well.

If you're having keypress repeating problems (each key or button press is echoed, for example), examine the output of `irw'. The second column parameter printed is the repeat count. This will increment when repeated signals are detected. Each decoded button press with the count reset to "00" is reported as a separate button press by lircd.

To fix this problem, generally the "gap" parameter sampled by `irrecord' in the device_name.lircd.conf file should be adjusted, often to a much larger value (e.g., from 44968 up to 113975).

After editing/adjusting any lircd.conf file or lirc_options.conf, be sure to restart lircd (as shown in the previous step).

  • Write an lircrc file for your end user application. This file is used by all client programs built with lirc support that attach to lircd to read IR control events

Edit ~/.config/lircrc to issue commands to the program to be controlled. Test this configuration by running:

   $ ircat prog

to see if the correct "config" strings for program "prog" are being output when you press all the buttons you wish to use.

  • Test!

Finally, test remote control button presses to control your end user application. If it works, you're done!