Добрейшей души человек (igrowing) wrote,
Добрейшей души человек

Making TV remove working with LibreELEC over Raspberry Pi

Reading this cool document didn't help me to make the RC working. Please, advise.

The IR receiver is connected to GPIO 18 on Raspberry PI 3 model B, running LibreELEC 9.2.0.

The log with configuration is here. Not sure I inserted the dtoverlay line in proper place of /flash/config.txt.

The lirc is up.


  1. # ps -ef | grep lirc

  2. 246 root 0:00 /usr/sbin/eventlircd -f --evmap=/etc/eventlircd.d --socket=/run/lirc/lircd

  3. # ir-keytable

  4. Found /sys/class/rc/rc0/ (/dev/input/event2) with:

  5. Name: gpio_ir_recv

  6. Driver: gpio_ir_recv, table: rc-rc6-mce

  7. lirc device: /dev/lirc0

  8. Supported protocols: lirc rc-5 rc-5-sz jvc sony nec sanyo mce_kbd rc-6 sharp xmp imon rc-mm

  9. Enabled protocols: lirc nec rc-6

  10. bus: 25, vendor/product: 0001:0001, version: 0x0100

  11. Repeat delay = 500 ms, repeat period = 125 ms

Display More

At this moment Kodi does not react on RC keys.

I found the proper RC configuration file for LIRC for the RC I have (TV LG xx-LW5700-yy), which looks different from all descriptions of the document above. I understand the file describes the protocol of LG TV.

This awesome page was a good start to connecting things together.

Here's a guide for newbies like me. Maybe this will help someone with info abuse and docs distraction.

Apparently, no need to 'enable LIRC' or install any service/software to have the IR RC working.

1. Get any Arduino-type IR receiver connected to Raspberry PI. Default pins:

IR -- RasPI

Vin -- 3.3V (Raspi GPIO intolerant to 5V, use 3.3V to not burn the CPU).

Out -- GPIO18 (you can choose any IO - just update the config later properly).

Gnd -- Gnd

2. Find and download the closest possible lircd.conf file in the internet. Look on part number or model name on your IR RC, search to your appliance model, be creative. In my case, the IR RC model matched first 5 symbols with what was published in sourceforge, and it works.

3. Configure /flash/config.txt as following:


  1. mount -oremount,rw /flash

  2. nano /flash/config.txt

  3. <add next line above [all] section>

  4. dtoverlay=gpio-ir,gpio_pin=18

  5. Ctrl+X -> Y -> Enter

  6. mount -oremount,ro /flash

4. Put the conf file you've found in step 2 at /storage/.config/lircd.conf. Usually, the files are published with model number before lircd.conf. So keep just lircd.conf as file name. You are going to work with this file a lot in next step. So keep it open in side window.

5. Prepare template for your own RC:


  1. cp /usr/share/kodi/system/Lircmap.xml /storage/.kodi/userdata/Lircmap.xml

Both lircd.conf and Lircmap.xml have definition for 'power' button on the RC.

Not clear how this can be useful: once you shut Raspi down with RC, you can't turn it on.

To workaround this I removel all lined in both files which contain word 'power'.

Now the RC turns the TV on and off, however Raspi is always on.

6. Add your RC into Lircmap.xml:


  1. nano /storage/.kodi/userdata/Lircmap.xml

  2. pick/cope any ready configuration in the file. The configuration starts from tag <remote .... and finishes with </remote>

  3. paste it under any remote, but above the </lircmap> tag.

  4. change <remote device="..."> with the name you device conf file you've found in step 2. Look into the lircd.conf, as said in step 4.

  5. change required key functions accordingly to key names in lircd.conf, as said in step 4.

  6. Ctrl+X -> Y -> Enter

7. reboot

That's it. Booted Kodi works with your RC.

Now I can control both TV and Kodi with the same remote :)

In addition to the "Controlling LibreELEC with LG TV IR remote guide​" my contribution to the forum back is:

The guide of IR command translation with LibreELEC.

Purpose: Make additional IR device (LED strip in this case) to be controlled from TV remote. So TV + Kodi + Additional device are controlled with one IR RC. In this case, The TV remote turns TV and LED strip on/off + navigates in Kodi.

High level explanation: The IR signal from TV IR RC is parsed by LIRC in RasPi and passed to Kodi as key_name pressed. Kodi applies proper action per each key_name. For navigation internal Kodi actions used. For LED control additional LIRC channel used as lirc_tx. Kodi runs stateful python script which runs shell command ir-ctl.


1. As Hias advised above, connect IR receiver to GPIO17, powered by 3.3V. And connect the transmitting IR LED 940nm via simple transistor amplifier to GPIO18. Expose IR receiver towards you, and IR transmitter towards the IR LED controller. Done with the hardware!

2. As advised here​ with minor mods:

mount -oremount,rw /flash
nano /flash/config.txt
  #add these lines above section [all]
  #Ctrl+X -> Y -> Enter

​mount -oremount,ro /flash

3. Configure udev rules:

​nano /storage/.config/udev.rules.d/71-lirc.rules
​  #add these lines
  ACTION=="add", SUBSYSTEM=="lirc", DRIVERS=="gpio_ir_recv", SYMLINK+="lirc-rx"
  ACTION=="add", SUBSYSTEM=="lirc", DRIVERS=="gpio-ir-tx", SYMLINK+="lirc-tx"
  ACTION=="add", SUBSYSTEM=="lirc", DRIVERS=="pwm-ir-tx", SYMLINK+="lirc-tx"
​  #Ctrl+X -> Y -> Enter

4. Configure LIRC options for both RX and TX channels.

​cp /etc/lirc/lirc_options.conf /storage/.config/
​cd $_
​cp lirc_options.conf lirc_tx_options.conf
​nano lirc_options.conf
​​  #set proper parameters, avoid duplication thus
  device          = /dev/lirc-rx
  listen          =
​  #Ctrl+X -> Y -> Enter
​nano lirc_tx_options.conf
​​  #set proper parameters, avoid duplication thus
  device          = /dev/lirc-tx
  output          = /var/run/lirc/lircd-tx
  pidfile         = /var/run/lirc/lircd-tx.pid
  listen          =
  connect         =
​  #Ctrl+X -> Y -> Enter

5. Create LIRC TX service:

​cd /storage/.config/system.d/
​mkdir system
cd system/
systemctl cat lircd > lircd-tx.service
nano lircd-tx.service
​  #make sure these lines are unique:
​  [Unit]
  Description=Second lircd, the transmitter
  After=network.target lircd-setup.service lircd.service

  ExecStart=/usr/sbin/lircd --nodaemon --options-file /etc/lirc/lirc_tx_options.conf
​  # Do not alter [Install] section
​​  #Ctrl+X -> Y -> Enter

systemctl cat lircd.socket > lircd-tx.socket
nano lircd-tx.socket
  #make sure these lines are unique:
​​  [Socket]

​​  #Ctrl+X -> Y -> Enter

6. As Da Flex advised, create keymap file /storage/.kodi/userdata/keymaps/remote.xml and paste into it:


7. Map Power key to action in /storage/.kodi/userdata/Lircmap.xml:

​                KEY_POWER

​At this step I commented out all <power> actions from other devices in Lircmap: I don't want any chance that something will shut the LE off.

8. Place the LED toggling script in /storage/toggle_led.py:

​#!/usr/bin/env python
import os
indicator = '/tmp/led_on'

command = '0xef03'
if os.path.isfile(indicator):
    command = '0xef02'
    open(indicator, 'a').close()

os.system('ir-ctl -S necx:' + command)

Just in case, make the script executable: [tt]chmod a+x /storage/toggle_led.py[/tt]

How did I get the IR codes? Hias explained above :) [tt]ir-ctl -r[/tt]​​


9. [tt]reboot[/tt]

After reboot you might test the LED work from the script by running it manually from bash.

That's it.

Tags: computers, freeware, software, для себя

  • Post a new comment


    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded