donbrew
Posts: 43
Joined: Sun Sep 04, 2016 2:32 pm

GPIO IR remote

Wed Feb 14, 2018 11:25 pm

Is there a place that has a current how-to for using a GPIO IR remote with Stretch and Kodi 17.6?

I have tried putting together 4-5 tutorials, but have not got it working either with LIRC or kernel.

I did get it working on LibreELEC, so I don't think I'm a "compleat idiot" maybe just a little bit.

dmesg seems to say everything is installed. I did find that I had to install ir-keytable, maybe I need some other module?

HiassofT
Posts: 100
Joined: Fri Jun 30, 2017 10:07 pm

Re: GPIO IR remote

Thu Feb 15, 2018 8:55 pm

Rough outline:

- use dtoverlay=gpio-ir to activate the kernel drvier (make sure you DON'T use lirc_rpi)
- apt-get install v4l-utils ir-keytable to get ir-keytable
- if necessary change the IR remote settings (protocol, scancodes) via /etc/rc_maps.cfg and/or custom keymaps in /etc/rc_keymaps
- apt-get install inputlirc and configure it to translate the linux input events from the IR driver into lirc events - this is what kodi currently supports best

That's about the same setup as we use in LibreELEC, only difference is that we use eventlircd instead of inputlirc (and, before you ask: no, eventlircd isn't in debian and you also are better off with inputlirc)

You can stick to the guide in the LibreELEC wiki https://wiki.libreelec.tv/infrared_remotes - just keep in mind that the paths are a bit different than in Debian/Raspbian (/storage/.config instead of /etc, /flash instead of /boot)

so long,

Hias
Last edited by HiassofT on Thu Feb 15, 2018 10:50 pm, edited 1 time in total.

donbrew
Posts: 43
Joined: Sun Sep 04, 2016 2:32 pm

Re: GPIO IR remote

Thu Feb 15, 2018 10:35 pm

Thanks, The only nearly right guide is the LibreELEC guide. Except finding the right directories and which files are not included.

I will try your way now.

HiassofT
Posts: 100
Joined: Fri Jun 30, 2017 10:07 pm

Re: GPIO IR remote

Thu Feb 15, 2018 10:51 pm

One minor but important correction - the debian package with ir-keytable is ir-keytable, not v4l-utils (the latter is for ir-ctl and other stuff). I've edited my post above and fixed my mistake.

so long,

Hias

donbrew
Posts: 43
Joined: Sun Sep 04, 2016 2:32 pm

Re: GPIO IR remote

Fri Feb 16, 2018 12:13 am

So, v4l-utils is already the newest version, no ir-keytable. but apt-get install ir-keytable works.

Now the problem is what paths to use; LibreELEC uses symbolic paths way different from Stretch. I have got to the point that dmesg says it found the ir receiver and everything looks right but ir-keytable -t does not see any keypresses and I can't make rc5 load on boot.

What worked in LE was: **hauppage in /storage/.config/rc_maps.cfg. I moved that to /home/pi/rc_maps.cfg, didn't work. Moved to /etc/rc_maps.cfg didn't work.

Code: Select all

sudo ir-keytable -a PATH TO rc_maps.cfg
does work

Code: Select all

sudo ir-keytable -c -w /lib/udev/rc_keymaps/hauppauge
does work

Still no response from ir-keytable -t .
Adding to my confusion is when and where sudo is needed.
seems that inputlircd needs no configuring? The man page seems to say everything is defaulted.

HiassofT
Posts: 100
Joined: Fri Jun 30, 2017 10:07 pm

Re: GPIO IR remote

Fri Feb 16, 2018 9:13 am

Odd that changing /etc/rc_maps.cfg didn't work, but this could be a bug in the ir-keytable version of Debian - we ran into a similar issue last year, and it's fixed in the latest upstream versions.

But since the official hauppauge keymap worked for you there's an easy solution that doesn't involve ir-keytable configuration - you can simply specify the keymap with the rc-map-name parameter in config.txt:

Code: Select all

dtoverlay=gpio-ir,rc-map-name=rc-hauppauge

This should already give you linux input events, you can verify eg with evtest ("apt-get install evtest" first), then select the "gpio_ir_recv" input. If you press buttons you should see EV_KEY lines like this:

Code: Select all

Event: time 1518771479.779270, type 1 (EV_KEY), code 106 (KEY_RIGHT), value 1
For the inputlirc configuration you can pretty much follow the guide in the kodi wiki: https://kodi.wiki/view/HOW-TO:Set_up_an ... _InputLirc

First create a udev rule to get a persistent device name (the eventX number might change across reboots). Creat a /etc/udev/rules.d/90-persistent-remote.rules file with the following contents:

Code: Select all

ACTION=="add|change", SUBSYSTEM=="input", KERNEL=="event*", ATTRS{name}=="gpio_ir_recv", SYMLINK+="input/myremote"
Then edit /etc/default/inputlirc, change EVENTS to point it to the persistent name and set OPTIONS:

Code: Select all

EVENTS="/dev/input/myremote"
OPTIONS="-g -c -m 0"
Now reboot (that's easier than "sudo udevadm control -R", "sudo udevadm trigger -s input", "sudo systemctl restart inputlirc").

If you run evtest as above you should now get a warning that some process has grabbed the device and you won't see events - that's fine, as it means inputlirc is working as expected.

You can verify that you now get lirc events from inputlirc on the /var/run/lirc/lircd via "nc -U /var/run/lirc/lircd". If you press buttons you should get lines like this:

Code: Select all

6a 0 KEY_RIGHT /dev/input/myremote
Now all that's left to do is change kodi's Lircmap.xml and tell it to handle your "/dev/input/myremote" remote (that stupid name is coming from inputlirc and it doesn't look like there's some option to change it).

Copy /usr/share/kodi/system/Lircmap.xml to /home/pi/.kodi/userdata/Lircmap.xml, find the "<remote device="linux-input-layer">" section and add the altname entry for "/dev/input/myremote"

Code: Select all

        <remote device="linux-input-layer">
                <altname>cx23885_remote</altname>
                <altname>/dev/input/myremote</altname>
That's it, now the basic remote buttons should work fine in kodi. If you want/need to change the button mapping in kodi you can do it in that section of Kodi's Lircmap.xml.

so long,

Hias

donbrew
Posts: 43
Joined: Sun Sep 04, 2016 2:32 pm

Re: GPIO IR remote

Fri Feb 16, 2018 5:37 pm

Thank you HiassofT! That got it working. After I did the idiot test and found the loose wire on the gpio, I thought I had done that first.

donbrew
Posts: 43
Joined: Sun Sep 04, 2016 2:32 pm

Re: GPIO IR remote

Mon Feb 19, 2018 10:48 pm

OK, so now some of the keys work in Kodi. 2 very important ones don't; OK and back.

All of the xml files seem to be the same between LE8 and Raspbian 9.

Tried to use Keymap Editor addon, but the keypresses don't show. They do show in ir-keytable and evtest on the Raspbian level

The remote.xml is in /usr/share/kodi/system/keymaps. Lircmap.xml is in /usr/share/kodi/system. The hauppauge profile file is correct; the codes and names are correct determined by evtest.

There are no files besides gen.xml (from Keymap Editor) in ~/.kodi/userdata/keymaps.

I copied the xml files from LE8 into the same directories in Raspbian STILL don't work. They are identical so I didn't expect anything.

I am using just the hauppauge remote, not the hauppauge tv card. is the <altname>cx23885_remote</altname> necessary and is that the correct section? maybe in devinput?


Any ideas?


UPDATE I changed the profile to rc-tivo and used my old Directv-Tivo remote; most buttons work Keymap Editor seems to fix the others. There must be a syntax error in the hauppauge profile, the scancodes are right.

donbrew
Posts: 43
Joined: Sun Sep 04, 2016 2:32 pm

Re: GPIO IR remote

Sun Feb 25, 2018 9:59 pm

In an attempt to close this out for future users:

It turns out that just adding the remote profile to the dtoverlay=gpio-ir statement gets the remote working as good as going through all of the setup. Many keys work except for OK and back. So the remote is basically useless.

I have tried editing all of the .xml files and none solves the problem. The codes transmitted match up with the kernel codes, evtest receives the codes; Kodi never is aware of them so Keymap Editor does not work.

Without input lirc installed and configured the keypresses that work show in Kodi log as keyboard events.

I just found out that when using a keyboard enter does nothing either! There is no action associated with the key. Keyboard.xml says different.

The fact that all of the keys work in LE8 but don't in Kodi 17.6 on Raspbian Stretch with desktop must mean something.

manthony121
Posts: 4
Joined: Tue Feb 27, 2018 1:33 pm

Re: GPIO IR remote

Tue Feb 27, 2018 2:20 pm

I came across this thread, and I don't understand the question. Is the "GPIO IR remote" a specific device? I just finished setting up my RPi3 with an IR receiver (TSOP38238 IR sensor from adafruit), as described here: https://learn.adafruit.com/using-an-ir- ... dia-center. It works fine. I can post the details, if this is the question you are asking.

donbrew
Posts: 43
Joined: Sun Sep 04, 2016 2:32 pm

Re: GPIO IR remote

Tue Feb 27, 2018 5:07 pm

A GPIO IR receiver is a TSOPXXXX sensor wired into the GPIO pins on the RPi, like what you have.

Not a USB device.

My problem is that the remote I am trying to use is not an RC6 protocol. I have tried 2, one is RC5 and 1 is NEC. They both behave the same way; no OK no BACK, I think most of the other keys work but I have not got past the 2 I really need.

When you activate the dtoverlay=gpio-ir RC6 is automatically setup.

My software is Raspbian Stretch with desktop and Kodi 17.6 standalone

manthony121
Posts: 4
Joined: Tue Feb 27, 2018 1:33 pm

Re: GPIO IR remote

Tue Feb 27, 2018 10:13 pm

You can use the "mode2" command to verify that the remote is sending signals when you press the "OK" and "BACK" buttons. I have an RCA Universal Learning Remote, model RCRN06GR. It can control 6 devices. While working with it, I noticed that some buttons would send no signal, depending on what type of device I had selected. I programmed it to use the AUX2 device to control the RPi3. If the remote is sending signals when those buttons are pressed, it should be possible to map them to kodi actions in the Lircmap.xml file.

donbrew
Posts: 43
Joined: Sun Sep 04, 2016 2:32 pm

Re: GPIO IR remote

Tue Feb 27, 2018 10:20 pm

As stated early on in this thread; the remote is sending, the receiver is receiving, Kodi does not get any signal at all.

No, you can't use mode2 if you are using gpio-ir overlay that is a lirc thing, However, evtest and ir-keytable show the same thing.

manthony121
Posts: 4
Joined: Tue Feb 27, 2018 1:33 pm

Re: GPIO IR remote

Tue Feb 27, 2018 10:43 pm

Yes, I am using LIRC. I can post the details when I get home from work (in about an hour), if you are interested. I'm not familiar with the setup you are describing.

manthony121
Posts: 4
Joined: Tue Feb 27, 2018 1:33 pm

Re: GPIO IR remote

Wed Feb 28, 2018 5:30 pm

OK, here is how I did it:

I am using an RCA RCRN06GR remote. It is a learning remote for controlling up to 6 devices. You can get one on Amazon for like $25.

- Install LIRC:

Code: Select all

sudo apt-get install lirc
.
- Edit /boot/config.txt so that the 'dtoverlay' line reads:

Code: Select all

dtoverlay=lirc-rpi,gpio_out_pin=17,gpio_in_pin=18,gpio_in_pull=up
- Edit /etc/llirc/lirc_options.conf so these values read:

Code: Select all

driver = default
device = /dev/lirc0
- Reboot.
- Check status of lirc service and sockets:

Code: Select all

systemctl status lircd.socket
systemctl status lircd.service
- Test that the receiver is seeing the remote:

Code: Select all

sudo systemctl stop lircd.socket
sudo systemctl stop lircd.service
mode2 --driver default  --device /dev/lirc0
Pressing buttons on the remote should give a series of space and pulse messages.
- Restart the lircd service:

Code: Select all

sudo systemctl start lircd
You will need a config file for the remote, that maps the buttons to the pattern of pulses the receiver sees. If you don't already have one, you can make the file using the 'irrecord' program. (I can post details of how I did that, if you wish).

- Once you have your config file, put it in the '/etc/lirc/lircd.conf.d/' directory.
- Edit the '/usr/share/kodi/system/Lircmap.xml' file so kodi knows what actions to perform for each button on the remote. Note that the button names are case sensitive, and must match the names used in the remote 'conf' file.
- Restart kodi, and the remote should work.

As a bonus, once you have 'lirc' working, it is easy to get 'lircmd' working, as well. Lircmd lets you move the mouse around on the desktop using the remote control as if it were a mouse.

donbrew
Posts: 43
Joined: Sun Sep 04, 2016 2:32 pm

Re: GPIO IR remote

Fri Jul 13, 2018 2:26 pm

I finally figured it out. Raspbian Stretch on a RPi 3 with gpio IR receiver.

Install ir-keytable; sudo apt install ir-keytable

go to /lib/udev/rc_keymaps and see if your remote is listed.

edit the keymap if needed; for my Hauppauge 45 button remote I had to change key_exit to key_back etc. The keymaps were converted to the new format, but not updated, some are very old.

create a file, if it is not already there; /etc/rc_maps.cfg
If it is there, there are some directions in it. In my case I added a line at the bottom : * * hauppauge

add a line to /etc/rc.local; ir-keytable -a /etc/rc_maps.cfg

add dtoverlay=gpio-ir,rc-map-name=rc-hauppauge to config.txt


If your remote is not in /lib/udev/rc_keymaps follow the directions to create your own lircd.conf using ir-keytable

That is all; all of the file modification is now not needed. Don't need to mess with hardware.conf or any other file.

DO NOT INSTALL Lirc! The remote will really misbehave. However; if /lib/udev/rc_keymaps is missing install Lirc then remove it don't purge it, the directories and files will appear.

For some reason Raspbian Stretch does not behave correctly; you should be able to just enable gpio-ir in config.txt and edit rc_maps.cfg.
Last edited by donbrew on Wed Jul 18, 2018 9:12 pm, edited 2 times in total.

donbrew
Posts: 43
Joined: Sun Sep 04, 2016 2:32 pm

Re: GPIO IR remote

Mon Jul 16, 2018 3:20 pm

I don't know why that works, it should not; dmesg reports that it can't find /etc/rc_maps.cfg so it loads keymap rc-empty.

I tried it without the files I added and it does not work, but the added files don't seem to change base behaviour. the edited keymap doesnt change anything. If I do the keymap-name thing some of the keys are weird.

Something odd is going on in Raspbian Stretch re: gpio-ir.

Anyway, I got my Hauppauge 45 button remote working. Must be magic!

donbrew
Posts: 43
Joined: Sun Sep 04, 2016 2:32 pm

Re: GPIO IR remote

Wed Jul 18, 2018 3:54 pm

I just loaded a new install of Raspbian Stretch Desktop compiled 2018-06-27.

The ONLY way to get a Hauppauge remote to work is to add the "dtoverlay=gpio-ir,rc-map-name=rc-hauppauge" to /boot/config.txt. Unfortunately, the keymap in the kernel is the original one from XBMC that has KEY_OK instead of KEY_ENTER and KEY_EXIT instead of KEY_BACK. Neither of those keys are recognized by Kodi, so messing with Lircmap.xml won't change anything.

Since the lircd.conf is in the kernel and I am not a compiling wiz. It is rather useless.

Maybe somebody in control at the Raspbian distro could look into it? I couldn't figure out where or how to submit a bug report, seems like all of the signs point to "the other guy".

I can only guess that they want you to use Lirc all the time they are advising against it and use dtoverlay=gpio-ir instead.

Return to “Raspbian”

Who is online

Users browsing this forum: No registered users and 19 guests