Products > Networking & Wireless

IR remote receiver for Linux

(1/8) > >>

I'm looking for a Linux infrared receiver that can learn the codes from a domestic remote control, and use the IR remote's buttons to control a Linux media player.  I was expecting this would be a standard and trivial setup, but apparently it is not.

Search engines return the first 1-2 pages full with LIRC (Linux Infrared Remote Control).  That used to work some years ago, then part of LIRC was integrated in the Linux kernel, though with less functionality than the original, and now LIRC doesn't work any longer with the current Ubuntu 22.04 LTS.  I've found a workaround by installing the much older LIRC from Ubuntu 16.04 (from about 5-10 years ago) but that doesn't create configuration files.

Meanwhile some players dropped the LIRC support expecting any IR control to be done through other Linux mechanisms.

I need a DIY IR receiver.  Already have TSOP1738 IR receiver IC, and CH340 or FT232R serial to USB bridges.  Also have ATmega8 or Arduino UNO/nano/DUE to connect the TSOP1738 to the desktop's USB.  I don't have any madia center installed, all I need is play/pause and volume for casual media players.

This is the second afternoon trying to get IR receiver functionality and nothing works when it comes to install LIRC.  Maybe LIRC is a thing of the past but I'm in a bubble search that only shows LIRC based solutions.  :-//

Anybody knows a tested and working setup for an easy to set IR receiver, please?

Solved (almost) by using a version of LIRC from many years ago, v0.9.0, like this:

More setting for executing shell commands from an IR remote (with LIRC and irexec), and other settings to control the 'mpv' player with the help of 'socat':

Even more settings and reconfigure the irexec service to control the last active player through MPRIS

That's a painful topic you're facing. Had painful time of learning there (and probably it is till not perfect). Some things I don't understand 100% and I still see an error message that a file is not found, but it works for me. Eventually you can use that stuff as starting-point. The things I did to get it up and running on an RasPi is:

Enable the gpio-ir overlay (not sure how this will be done for UEFI boot procedures), and don't load the lirc-rpi overlay:

--- Code: ---dtoverlay=gpio-ir,gpio_pin=23,rc-map-name=apple_remote
--- End code ---
The string apple_remote can freely chosen filename and the number is the IO-Pin I used (not all can be used!). After reboot this provides a new device under /dev/input/event0 (eventually the number might be different in your system). You can try cat  /dev/input/event0 to see if the remote is recognized already.

In /etc/rc_keymaps/ you create a file with the name you used above. There are many pre-defined keymaps you can try as well (here for the simplistic white Apple remote):

--- Code: ---# table apple_remote, type: NEC
0x87eec30b KEY_UP
0x87eec30d KEY_DOWN
0x87eec308 KEY_LEFT
0x87eec307 KEY_RIGHT
0x87eec304 KEY_ENTER
0x87eec302 KEY_ESC
--- End code ---

Now the file needs to be announced in the /etc/rc_maps.cfg by adding that at the end of the file:

--- Code: ---* * apple_remote
--- End code ---

This should already create the keystrokes mentioned in the /etc/rc_keymaps/* file.

(Probably you'll find that somewhere in the web with some ranting in a blog with some additional information)

Nominal Animal:

--- Quote from: RoGeorge on December 29, 2022, 06:08:13 pm ---I need a DIY IR receiver.  Already have TSOP1738 IR receiver IC, and CH340 or FT232R serial to USB bridges.
--- End quote ---
Serial to USB bridges?  Oh noooooooo....

If you had used a microcontroller with native USB, you could have done everything within the microcontroller, and simply send the events as HID keypresses (multimedia keys).  The result is an USB IR receiver that works in all OSes without any drivers, because it is an USB HID keyboard device.

Personally, I would have used a Teensy LC because I have one, they're cheap (difficult to obtain right now due to chipageddon, though), and because Teensyduino includes the IRremote library (but see Ken Shirriff's latest version at github:/Arduino-IRremote/Arduino-IRremote).

I'd first use the Receive example on the Teensyduino page to map out all the remotes I want to use and the codes they send.
Then, I'd write the couple of dozen lines needed to implement a Teensy USB HID Keyboard to emit the multimedia keypresses (KEY_MEDIA_PLAY, KEY_MEDIA_PAUSE, KEY_MEDIA_STOP, KEY_MEDIA_VOLUME_INC, KEY_MEDIA_VOLUME_DEC, etc.).

You do not actually need a Teensy one for this, of course.

You can buy one of the ATmega32u4 based Arduino clones (Pro Micro clones, look for Pro Micro silkscreened on the board) off eBay from European sellers for under 15€ shipped.  I've used the ones with USB Micro B connector, and they work just fine; they're clones off the SparkFun Pro Micro or Arduino Pro Micro ATmega32u4 board.
They use the Arduino Leonardo bootloader, so within the Arduino environment, you treat them as Arduino Leonardos.  For the pinout,  but use the Arduino Pro Micro pinout.  In Arduino, make sure you have both the Keyboard and IRremote libraries installed, and the same code shown at the Teensy pages above should work.

(In theory, it should be possible to use an ATtiny85 DigiSpark clone for this, but I haven't actually tried this myself.  These bit-bang the USB connection (low-speed USB HID), calibrating the internal clock to 16.5 MHz.  The latest versions of the IRremote and DigiSpark cores do have an interrupt conflict as well, so it definitely isn't as straightforward.  This is why I recommend using an Arduino-programmable MCU with hardware USB support instead.)

Made some progress with LIRC, got a FTDI based receiver working, but with the ancient version of LIRC v0.9.0 from ~6 years ago (LIRC from the Ubuntu 16.04 Xenial repositories, but installed in current Ubuntu 22.04 Jammy).  It was tedious, and still don't know how to add a random remote.  :horse:

FTDI FT232R, which is a USB to serial converter, can be used to receive IR with the help of an IR demodulator like TSOP1738.  The FTDI chips are using a special ftdi USB driver.  That allows FTDI chips to work with interrupts if needed, they have some parallel bits, too, apart from the standard RS232 signals, they can bitbang with timing and on any pin (this last mode I suppose is used by LIRC), etc.

I am using one, and the Out pin from TSOP is connected to the RxD pin of the FTDI (default in LIRC, the pin can be wired on other FTDI pins, too, then configured in LIRC accordingly).  Something like this:

Schematic from

There is another hardware dongle with the TSOP Out pin wired to the RxD of an RS232 COM port (port with 16550 UART chip, not USB COM).  That is why CH340G (USB to TTL serial) might not work.

The Arduino based are implementing a small GIRS (General InfraRed Server) which can only work with very few remotes, and GIRS is yet another layer, and apart from lirc it will require some firmware to compile/maintain over years.

About 10 years ago, some guy Igor wrote a bitbang USB1.1 firmware for AVR chips, like ATmega or even ATtiny.  That firmware allows 2 casual GPIO pins of the MCU to become D+ and D- data lines for USB.  Many projects used Igor's AVRUSB to connect a casual AVR chip to a PC through USB and control MCU GPIO from PC, log MCU ADC data, etc.  It was a total surprise back than, first time when an MCU was able to connect to USB without FTDI or alike USB to TTL bridges.  I think this is the current page, and a link with some demo projs:
Based on this AVRUSB firmware there is also an IR receiver suported by LIRC (Igor's plug USB LIRC).  Again, yet another FW to take care in time.

I would prefer LIRC because many media players like Rhythmbox, VLC, etc. have LIRC support.
Also happens to have an unused FT232RL and a TFM(S)1380, which are now wired together and could close Rhythmbox from some leftover IR remote from a former Leadtek WinFast FM+TVtuner.

There are many config settings to match:
- proper driver (here ftdi)
- proper lircd (daemon config)
- proper IR remote model config
- proper LIRC plugins config (specific to each media player that supports LIRC)
- proper scripts for each IR remote's button and each media player
- proper scripts for other normal application (not media players, LIRC can send events to X, sned keystrokes, emulate mouse move, etc. huge pile of features and config details)  :scared:

Now that the hardware+drivers+configs are known as working, next would be to try to redo the LIRC setup using the current LIRC from the Ubuntu 20.04 Jammy repositories, then to write down simple steps and commands to get LIRC working in Ubuntu with a FTDI receiver.

Nominal Animal:

--- Quote from: RoGeorge on December 30, 2022, 12:45:29 pm ---I would prefer LIRC because many media players like Rhythmbox, VLC, etc. have LIRC support.
--- End quote ---
All GUI players I've tested support multimedia keys out of the box.  It is because the Logitech et. al keyboards with such physical keys are quite common.
(Although, volume up and down is actually wired to the global volume control, not to the application volume.)

If this is a non-GUI installation, you do need a helper daemon to switch between applications, for example by switching between TTYs (with each appliance running on their own TTY, possibly on raw framebuffer/DRI).  If you use X, you can always use a keyboard mapping in X to eg. change applications (specific remote buttons switching to a specific application).

I really do not see why you're so invested in LIRC, when the HID approach is so much more common and actively used.


[0] Message Index

[#] Next page

There was an error while thanking
Go to full version
Powered by SMFPacks Advanced Attachments Uploader Mod