From ArchWiki
Jump to: navigation, search

Step-by-step quick-start HOWTO for a USB (MCE) IR receiver and universal remote control with lirc Clemmitt M. Sigler, cmsigler-remove-this-dot-online@gmail-dot-com February 10, 2018

  1. Get a USB IR receiver, preferably an MCE model which is almost always supported out-of-the-box. Re-purpose an old universal remote control you have lying around the house
  2. Install lirc
  3. Plug in the USB IR receiver
  4. 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 If you run `sudo mode2' and get no response to the universal remote control keys 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.) 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

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

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

See if button presses are detected

  1. 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
  1. Use irrecord to record keypress scancodes --

Run `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 `chown root:root device_name.lircd.conf' Move devinput.lircd.conf to devinput.lircd.dist to disable it, e.g., if you're not using an IR keyboard and/or mouse (because you're not :)

  1. Restart the lirc daemon so you use the newly created lircd.conf file --
   $ sudo systemctl restart lircd
  1. 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 above in step 11)

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

  1. Test! --

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

-- CMS