Gernot Walzl

LIRC

Most Raspberry Pis are connected to a TV.
Nearly all TVs have an infrared (IR) remote control.
Using Linux Infrared Remote Control (LIRC), you can control your Raspberry Pi with an IR remote control.

Contents

Hardware: Infrared Receiver

Run the following command on the Raspberry Pi to show the pin layout:
pinout

Connect an IR receiver to the following pins:

Raspberry Pi 3 IR receiver TSOP4838
(12) GPIO18 1 = OUT
(14) GND 2 = GND
(17) 3V3 3 = VS

Be sure to check the datasheet if you are using another IR receiver.

Driver: Kernel Module

By default, the kernel module lirc_rpi uses GPIO18 for receiving and GPIO17 for transmitting.
A reboot loads the kernel module. When it is loaded, the device /dev/lirc0 will be available.

/boot/config.txt

# Uncomment this to enable the lirc-rpi module
dtoverlay=lirc-rpi

Software: LIRC

Install LIRC:
sudo apt-get install lirc

/etc/lirc/lirc_options.conf

[lircd]
driver = default
device = /dev/lirc0

[lircmd]
uinput = True

First Test

Reboot to load the kernel module:
reboot

Stop LIRC daemon:
sudo /etc/init.d/lircd stop

Show raw signals from IR receiver (use a remote to generate some signals):
mode2 -d /dev/lirc0

Configuration

List valid button names:
irrecord --list-namespace

Record signals from a remote control and generate a configuration for decoding:
irrecord myremote.lircd.conf

Use the configuration system-wide:
cd /etc/lirc/lircd.conf.d
sudo mv devinput.lircd.conf devinput.lircd.dist
sudo mv /home/pi/myremote.lircd.conf /etc/lirc/lircd.conf.d/

Restart LIRC daemon to load the new configuration:
sudo /etc/init.d/lircd restart

Test Configuration

Show decoded signals:
irw

Application: LIRC as a Mouse Input Device

/etc/lirc/lircmd.conf

PROTOCOL IntelliMouse

ACCELERATOR 2 32 2

MOVE_N * KEY_UP
MOVE_E * KEY_RIGHT
MOVE_S * KEY_DOWN
MOVE_W * KEY_LEFT

MOVE_OUT * KEY_REWIND       # mouse wheel up
MOVE_IN * KEY_FASTFORWARD   # mouse wheel down

BUTTON1_CLICK * KEY_OK      # left mouse button
BUTTON3_CLICK * KEY_MENU    # right mouse button

Disable Additional Features

If you do not want to receive keystrokes when you press a button on the remote, disable this feature:
sudo systemctl disable lircd-uinput.service

Known Issues

CONTENT.html 2019-01-06 4.86 KB
urc7980_media_1272.lircd.conf 2019-01-06 1.9 KB