Cannot get GPIO IR remote receiver to work

I am running OSMC Version February 2024.02-1 on a Raspberry pi model B. I have been using it for ages without problems, but my CEC-enabled TV has died. The replacement I have doesn’t support CEC, so I thought I would be able to get an IR receiver and easily get similar results. God, was I wrong! I am unable to get it to work at all. I bought a TSOP4838 IR receiver, and I can’t get it to do anything in OSMC. The hardware works fine, the driver(s) if needed are also OK but the OSMC software doesn’t recognise it. The guide I tried to use is out of date but I couldn’t find anything else relevent, and the options for setting the GPIO are different in the OSMC menu, so I can’t set them up. So in the end, I guessed them.

Here’s what I have done, and I now need the help of an expert. I think what I need is commands to set the GPIO correctly from a terminal, because the options I keep seeing on articles on the web are no longer available in the Hardware section of My OSMC. Most of the articles I have seen are around 10 years old.

dmesg shows the following:
[ 14.780522] rc_core: IR keymap rc-lirc not found
[ 14.780583] Registered IR keymap rc-empty
[ 14.780951] rc rc0: gpio_ir_recv as /devices/platform/ir-receiver@12/rc/rc0
[ 14.781581] rc rc0: lirc_dev: driver gpio_ir_recv registered at minor = 0, raw IR receiver, no transmitter

The first entry is in red.

Following procedure for OSMC (wiki.sunfounder.cc/index.php?title=IR_Remore_Controller_Configuration_for_OSMC). It says to go to Menu → My OSMC → Pi Config → Hardware Support and enable LIRC GPIO support. My menu doesn’t have that option. It also says to set output on pin 23 and input on pin 18. I don’t have those either, I only have “gpio_pin (0 for default).” It was at 0, I set it to 18. My menu also has an entry for “w1gpio” which can be none, w1-gpio=pullup-overlay, or w1-gpio-overlay. It was set at none, left it there. Also there’s an entry for Enable SPI support. It was disabled, I left it as such. I will try to attach a screenshot.

I ran:
sudo vi /etc/modules
(There were only comments in there)
Added:
lirc_dev
lirc_rpi gpio_in_pin=18

Ran:
pgrep -l lircd
Got:
218 eventlircd
410 lircd
which seems correct.

Ran:
sudo kill 218

Ran:
sudo lircd --permission 666
sudo /run/lirc/lircd-lirc0.sh

The system has created a symbolic link from /etc/lirc/ to the file that irrecord created in osmc’s home directory.

I ran:
irrecord -d /dev/lirc0 test.conf
It created a file for my remote, however it doesn’t actually control the OSMC. I did attempt to add it from My OSMC → Remotes → Browse. (The config file was in osmc’s home directory.) There was a popup asking me to confirm or revert, I selected confirm but still the Pi does not respond to any of the remote’s keypresses.

The article I was following says that’s it (but it doesn’t include the part about getting the codes for the remote), but it doesn’t work. Clearly the ir receiver is working and the OS has configured it and can accept and process signals from the remote. However, it seems that these signals are not being passed to the OSMC media server software.

If I run sudo systemctl status, I get this:
● osmc
State: degraded [This is in red]
Jobs: 1 queued
Failed: 1 units
Since: Thu 1970-01-01 01:00:05 CET; 54 years 3 months ago
CGroup: /
├─user.slice
│ └─user-1000.slice
│ ├─user@1000.service …
│ │ └─init.scope
│ │ ├─745 /lib/systemd/systemd --user
│ │ └─746 (sd-pam)
│ └─session-1.scope
│ ├─742 sshd: osmc [priv]
│ ├─755 sshd: osmc@pts/0
│ ├─756 -bash
│ ├─780 sudo su
│ ├─781 su
│ ├─782 bash
│ ├─800 systemctl status
│ └─801 less
├─init.scope
│ └─1 /sbin/init
└─system.slice
├─irqbalance.service
│ └─213 /usr/sbin/irqbalance
├─udisks.service
│ ├─389 /usr/lib/udisks/udisks-daemon --no-debug
│ └─390 udisks-daemon: not polling any devices
├─systemd-tmpfiles-clean.service
│ └─802 systemd-tmpfiles --clean
├─dbus.service
│ └─196 /usr/bin/dbus-daemon --system --address=systemd: --nofork --nopidfile --systemd-activation --syslog-only
├─ssh.service
│ └─319 sshd: /usr/sbin/sshd -D [listener] 0 of 10-100 startups
├─avahi-daemon.service
│ ├─194 avahi-daemon: running [osmc.local]
│ └─202 avahi-daemon: chroot helper
├─system-lircd_helper.slice
│ └─lircd_helper@lirc0.service
│ └─412 /usr/sbin/lircd --driver=default --device=/dev/lirc0 --uinput --output=/var/run/lirc/lircd-lirc0 --pidfile=/var/run/lirc/lircd-lirc0.pid /etc/lirc/lircd.conf
├─eventlircd.service
│ └─215 /usr/sbin/eventlircd --evmap=/etc/eventlircd.d --socket=/var/run/lirc/lircd -f
├─ntp.service
│ └─574 /usr/sbin/ntpd -p /var/run/ntpd.pid -g -u 105:109
├─wpa_supplicant.service
│ └─214 /sbin/wpa_supplicant -u -s -O /run/wpa_supplicant
├─connman.service
│ └─225 /usr/sbin/connmand -n --config=/etc/connman.conf
├─rpcbind.service
│ └─182 /sbin/rpcbind -f -w
├─systemd-logind.service
│ └─207 /lib/systemd/systemd-logind
├─polkit.service
│ └─397 /usr/libexec/polkitd --no-debug
├─systemd-udevd.service
│ └─184 /lib/systemd/systemd-udevd
├─systemd-journald.service
│ └─164 /lib/systemd/systemd-journald
├─udisks-glue.service
│ └─361 /usr/bin/udisks-glue --foreground
└─mediacenter.service
├─261 /bin/bash /usr/bin/mediacenter
├─355 sudo -u osmc LIRC_SOCKET_PATH=/var/run/lirc/lircd /usr/lib/kodi/kodi.bin --standalone -fs
└─360 /usr/lib/kodi/kodi.bin --standalone -fs

╔root@osmc:/home/osmc
╚>#

The clock is not set as I am not currently connected to the Internet. It says state degraded (why?), one unit failed (which one?) I don’t know how to get further information and I suspect I have more than one problem.

I have spent longer on this than it took to connect the hardware. What have I missed?

Any help would be appreciated. I really don’t want to do a fresh install, but I am thinking it might be my only option. Additionally, the Pi doesn’t shut down any more when I try to power it off (since the last update). I can both ping it, and also ssh into it after selecting “Power off system” from the menu. Nothing is logged in dmesg after trying to shut down. Are these problems related?

Unfortunately I cannot attach a screenshot of the hardware menu :frowning:

PS - I have just installed the April update, and it is exactly the same. The log is here:
https://paste.osmc.tv/jiyamuzuvu.xml

This is a link to the menu which has the missing entries to configure the GPIO for an IR remote:

I’ve never played with one of these myself but my understanding is that you would need only to set that one GPIO setting (which in that screenshot you have set to 18) to match where you plugged your TSOP receiver into and then select a remote profile in the remote section of the My OSMC add-on to match what type of codes your sending out with your remote, and then after a reboot it should be working. Those instructions on the sunfounder site are ill advised. Also if it doesn’t work it may be worth checking to make sure you have the three pins connected to the correct locations on the header.

@darwindesign

Thanks for your reply.

As I said, I have been able to create a lircd.conf file using irrecord and the IR receiver which is configured as /dev/lirc0. So I know the receiver is correctly connected, and that the hardware can receive the codes from each keypress of the remote. The problem is that the options in the Hardware section under Settings have changed in the OSMC menu, and it is not possible to set up the OSMC software to receive the codes from the hardware (my guess).

I have reinstalled OSM from scratch, and the problem persists.

The remote profile is selected under the Remotes section.

I just set the gpio pin setting in My OSMC to 18 just like you and checked and found it correctly added the line “dtoverlay=gpio-ir,gpio_pin=18” to /boot/config-user.txt which I believe is the correct setting for this kind of setup.

As for the other half of it that conf file you made wasn’t at a location that would cause it to load. You could from the remotes section of the My OSMC add-on point it to that file but I have some doubts about if this file is working or not as they normally are quite difficult to produce one that works as intended. What is most typically done is someone uses a universal remote that has been programmed to one of the devices listed in the remotes section (xbox 360 would be a good choice) and then they just enable that matching conf file in the add-on.

@darwindesign and @sam_nazarko

Thank you both for your replies.

I checked my /boot /config-user.txt and it does indeed have the line “dtoverlay=gpio-ir,gpio_pin=18” appended to it.

The comment from Sam prompted me (I don’t know why) to look through the preconfigured remotes and I noticed there is a WD Media Centre one there. It just so happens that I have such a media centre, and I set the remote to that - and it works perfectly. There is also a preconfigured Samsung remote (My TV is a Samsung), so I tried that, too. The up, down, left and right keys work OK but no others. I just need to figure out why irrecord isn’t working now. I’m getting there…

So I now know that there is a problem with the file produced by irrecord, its permissions or where it’s located.

I would recommend to not go down the path of making a custom lircd.conf but if you insist on being a glutton for punishment this thread probably has the clues needed to get you where you want to go…

1 Like

@darwindesign Once again, thank you for taking the time to respond to me.

There are a couple of developments. Firstly, when I use an external remote, the system often produces random signals after I press a key, as though the IR sensitivity is too high. I have seen several complaints about this, and one solution I saw was to use an old version of lirc. The instructions to follow were quite hairy!

As it is so unreliable, I will probably buy a remote with a USB dongle. This is a shame, because I think the hardware has the capability, but nobody can get it to work reliably.

I am grateful for your help :+1:

I do have other minor issues, I will start threads in the appropriate places if I can’t resolve them.

It sounds like there may have been a bit of miscommunication. I was not discouraging the use of this kind of receiver or the remote of your choice. I was intending to discourage wasting your time trying to record your own custom conf file only. It is not straightforward, has a learning curve, and simple guides that gathered all relevant information in an easily digestible format seemed to be elusive during my previous efforts of educating myself on the topic. Clearly a correctly formed file can work as you found with your WD media centre remote. You could see about finding a conf file on the internet that has already been developed for the remote you want to use or else use a universal remote that is programmed to a more ideal device. When you switched to the Samsung profile it had limited function as the conf file didn’t align very well with the particular Samsung remote you have. If you had ever programmed a universal remote with the books that listed all the codes you would see that all the manufacturers tend to use many different codes for their devices. This is where using a profile for an Xbox, MCE, or that WD have advantage as they are more specific targets.

As far as “buying a remote with a dongle” don’t be surprised if you end up buying one and it also has partial function without additional configuration. This is more common than you might suspect especially on the low end. The OSMC remote obviously is plug and play with OSMC.

Thank you once again for your time explaining things to me, it is extremely useful to me.

I have taken your advice, and I have been trying various configs for different Samsung remotes. I have found one which has a good degree of functionality, but the right arrow key and enter key weren’t working. It was then a case of transposing the values for those keys from a config file where they did work. I have discovered that the constant insertion of random codes is initiated by long-pressing any button, it just sends the box crazy. However, it’s a small price to pay to repeatedly press a button instead, for example, to scroll down through a long list of files. Some of the keys in the config file are defined as “BTN_…” instead of “KEY-…” the difference of which I don’t understand. It’s a pity the irw command doesn’t work, it says, “Cannot connect to socket /usr/var/run/lirc/lircd: No such file or directory.” It would be nice to see the codes directly on the screen when pressing a key.

Thank you once again for your help and advice. Progress was slow at first, but with your help I now have a system which has a good basic control using the TV remote.

1 Like

“kodi keymap wiki”, pageup, pagedown, JumpSMS (assuming you got number keys forwarding)

…since you’ve already gotten this far :grin: