Argon One M.2. Case with Argon One IR Remote

Hi,

I have been struggling the last couple of days to get my Argon One IR Remote to work. I have followed countless articles that either don’t work or break the OS. But finally I got the irrecord to work and output a lircd.conf file, however the remote still does not work under OSMC. Am I missing something? What else can I check?

My Configuration:

Procedure:

osmc@osmc:~$ sudo nano /boot/config.txt

/boot/config.txt:

# Warning: do not edit this file, or it could prevent your OSMC system from starting.
# If you wish to make changes, you should do so via My OSMC or edit the config-user.txt file in this directory

# Any changes that you make here will be overwritten as this file is managed by the OSMC via the update system

[pi4]
dtoverlay=rpivid-v4l2
arm_64bit=1
kernel=kernel.img

[all]
dtoverlay=vc4-kms-v3d,cma-512,lirc-rpi,gpio-ir,gpio_pin=23
disable_overscan=0
start_x=1
disable_splash=1
disable_fw_kms_setup=1
include config-user.txt

osmc@osmc:~$ reboot

osmc@osmc:~$ sudo systemctl stop lircd_helper@lirc0

osmc@osmc:~$ sudo irrecord -d /dev/lirc0 /home/osmc/lircd.conf

Running as regular user osmc
Using driver devinput on device /dev/lirc0

irrecord -  application for recording IR-codes for usage with lirc
Copyright (C) 1998,1999 Christoph Bartelmus(lirc@bartelmus.de)

This program will record the signals from your remote control
and create a config file for lircd.

A proper config file for lircd is maybe the most vital part of this
package, so you should invest some time to create a working config
file. Although I put a good deal of effort in this program it is often
not possible to automatically recognize all features of a remote
control. Often short-comings of the receiver hardware make it nearly
impossible. If you have problems to create a config file READ THE
DOCUMENTATION at https://sf.net/p/lirc-remotes/wiki

If there already is a remote control of the same brand available at
http://sf.net/p/lirc-remotes you might want to try using such a
remote as a template. The config files already contains all
parameters of the protocol used by remotes of a certain brand and
knowing these parameters makes the job of this program much
easier. There are also template files for the most common protocols
available. Templates can be downloaded using irdb-get(1). You use a
template file by providing the path of the file as a command line
parameter.

Please take the time to finish the file as described in
https://sourceforge.net/p/lirc-remotes/wiki/Checklist/ an send it
to  <lirc@bartelmus.de> so it can be made available to others.

Press RETURN to continue.




Usually you should not create a new config file for devinput
devices. LIRC is installed with a devinput.lircd.conf file which
is built for the current system which works with all remotes
supported by the kernel. There might be a need to update
this file so it matches the current kernel. For this, use the
lirc-make-devinput(1) script.

Press RETURN to continue.

Checking for ambient light  creating too much disturbances.
Please don't press any buttons, just wait a few seconds...

No significant noise (received 0 bytes)

Enter name of remote (only ascii, no spaces) :argonforty
Using argonforty.lircd.conf as output filename

Hold down an arbitrary key
................................................................................
Found gap (107949 us)

Please enter the name for the next button (press <ENTER> to finish recording)
KEY_UP

Now hold down button "KEY_UP".

Please enter the name for the next button (press <ENTER> to finish recording)
KEY_RIGHT

Now hold down button "KEY_RIGHT".

Please enter the name for the next button (press <ENTER> to finish recording)
KEY_DOWN

Now hold down button "KEY_DOWN".

Please enter the name for the next button (press <ENTER> to finish recording)
KEY_LEFT

Now hold down button "KEY_LEFT".

Please enter the name for the next button (press <ENTER> to finish recording)
KEY_OK

Now hold down button "KEY_OK".

Please enter the name for the next button (press <ENTER> to finish recording)
KEY_INFO

Now hold down button "KEY_INFO".

Please enter the name for the next button (press <ENTER> to finish recording)
KEY_HOME

Now hold down button "KEY_HOME".

Please enter the name for the next button (press <ENTER> to finish recording)
KEY_BACK

Now hold down button "KEY_BACK".

Please enter the name for the next button (press <ENTER> to finish recording)
KEY_VOLUMEUP

Now hold down button "KEY_VOLUMEUP".

Please enter the name for the next button (press <ENTER> to finish recording)
KEY_VOLUMEDOWN

Now hold down button "KEY_VOLUMEDOWN".

Please enter the name for the next button (press <ENTER> to finish recording)
KEY_POWER

Now hold down button "KEY_POWER".

Please enter the name for the next button (press <ENTER> to finish recording)


Successfully written config file argonforty.lircd.conf

osmc@osmc:~$ sudo systemctl start lircd_helper@lirc0

Then I went to My OSMC > Remotes > Browse and import argonforty.lircd.conf, unfortunately it just not work. I have tried rebooting, recreating the lircd.conf file but OSMC just doesn’t respond to the IR remote.

argonforty.lircd.conf:

# Please take the time to finish this file as described in
# https://sourceforge.net/p/lirc-remotes/wiki/Checklist/
# and make it available to others by sending it to
# <lirc@bartelmus.de>
#
# This config file was automatically generated
# using lirc-0.9.4c(devinput) on Tue May 25 12:17:02 2021
# Command line used: -d /dev/lirc0 /home/osmc/lircd.conf
# Kernel version (uname -r): 5.10.32-1-osmc
#
# Remote name (as of config file): argonforty
# Brand of remote device, the thing you hold in your hand:
# Remote device model nr:
# Remote device info url:
# Does remote device has a bundled capture device e. g., a
#     usb dongle? :
# For bundled USB devices: usb vendor id, product id
#     and device string (use dmesg or lsusb):
# Type of device controlled
#     (TV, VCR, Audio, DVD, Satellite, Cable, HTPC, ...) :
# Device(s) controlled by this remote:

begin remote

  name  argonforty
  driver devinput
  bits           56
  eps            30
  aeps          100

  one             0     0
  zero            0     0
  pre_data_bits   72
  pre_data       0x23
  gap          107949
  toggle_bit_mask 0x0
  frequency    38000

      begin codes
          KEY_UP                   0x3F010000001197
          KEY_RIGHT                0x5B01000000118C
          KEY_DOWN                 0x59010000001193
          KEY_LEFT                 0x5701000000119C
          KEY_OK                   0x51010000001198
          KEY_INFO                 0x57010000001196
          KEY_HOME                 0x56010000001181
          KEY_BACK                 0x57010000001197
          KEY_VOLUMEUP             0x5A010000001194
          KEY_VOLUMEDOWN           0x50010000001198
          KEY_POWER                0x55010000001197
      end codes

end remote

argonforty.lircd

I read some threads that you have to disable the HiFiberry in dtoverlay as it is in colflict with PIN23. I don’t know if that is my problem or not. I don’t have a HiFiberry in there, but I also cannot find the command to do it. But its strange that irrecord works and OSMC does not. Is there maybe another place that I need to set Pin23 in OSMC for IR?

Thanks in advance!

According to some of the articles there should be My OSMC > Pi Config > Hardware Support > Enable LIRC GPIO Support, gpio_out_pin, but I cant find it on this one.

I have also done the following to /boot/config.txt:

# Warning: do not edit this file, or it could prevent your OSMC system from sta$
# If you wish to make changes, you should do so via My OSMC or edit the config-$

# Any changes that you make here will be overwritten as this file is managed by$

[pi4]
dtoverlay=rpivid-v4l2
arm_64bit=1
kernel=kernel.img

[all]
dtoverlay=vc4-kms-v3d,cma-512,
dtoverlay=gpio-ir,gpio_pin=23
disable_overscan=0
start_x=1
disable_splash=1
disable_fw_kms_setup=1
include config-user.txt

I tried:

osmc@osmc:~$ lsmod | grep gpio
gpio_ir_recv           16384  0

osmc@osmc:~$ sudo modprobe gpio-ir
modprobe: FATAL: Module gpio-ir not found in directory /lib/modules/5.10.32-1-osmc

osmc@osmc:~$ irw
Cannot connect to socket /usr/var/run/lirc/lircd: No such file or directory

osmc@osmc:/etc/lirc$ mode2 -d /dev/lirc1
Using driver devinput on device /dev/lirc1
Trying device: /dev/lirc1
Using device: /dev/lirc1
code: 0x9a19c500f8d7c400c4010001a8370000
Partial read 12 bytes on /dev/lirc1

So from what I can tell the IR Remote and Receiver are working. It seems that OSMC really isn’t responding to the commands for some reason.

Does anyone have any ideas or suggestions?

My first suggestion would be to supply logs.

I don’t have a lot of experience of lirc on OSMC but I’m happy to try and help out. My main limitation is that I only have command-line access to my Pi4, so there’s only so much I can do at my end.

Dear dillthedog,

Thanks for your response, could you please let me know which logs to collect / how to collect them? Are there any actions that I need to perform before collecting the logs?

Are the attached logs enough? Sorry it seems I cannot upload log files so I changed the extension to bmp.

Use the official log uploader.

Dear Sam,

Thanks, that is actually a very nice tool, sorry I didn’t know about it.
I have just uploaded it: https://paste.osmc.tv/igolayarej

I have continued to try some more things, but it seems like LIRC is either not standard, or it is incomplete on this image.

So tried apt install lirc then it downloads and installs some things, fails, and then I have to do apt --fix-broken install.

We already ship LIRC. If you try and install the Debian version, you could have some conflicts.

gpio-ir is deprecated to my knowledge.

You might need to record the remote control profile on the Pi directly, i.e. something like:

systemctl stop mediacenter
systemctl stop eventlircd
systemctl stop system-lircd_helper.slice
irrecord -f -d /dev/lirc0 argon.conf

Hi Sam,

I didn’t know gpio-ir was depreciated, do you by any chance know what replaces gpio-ir? Because from what I googled gpio-ir was the replacement lirc-rpi, which was depreciated.

Do you know what the dtoverlay should be in the case of the latest OSMC, pi4 when I am using PIN23? Is it possible that I’m doing something wrong there? It does however seems to be recording the profile with my current settings and mode2 is working. Are there any other places / locations in OSMC where I need to change the PIN for the IR receiver?

My best guess is that the dtoverlay in /boot/config.txt should be:
dtoverlay=gpio-ir,gpio_pin=23
Does it matter where it goes in the file because I see there is one under [pi4] and one under [all]?

Unfortunately I have already recorded multiple profiles with irrecord, I can even browse in My OSMC > Pi Config > Remotes and add it there. But it just doesn’t work on OSMC.

I have even tried to replace /etc/lirc/lircd.conf with my recorded profile, you can find it the log file.

Does irw work on the OSMC image? I just get Cannot connect to socket /usr/var/run/lirc/lircd: No such file or directory

You might have to manually specify export LIRC_SOCKET_PATH=/var/run/lirc/lircd for now when running irw.

Unfortunately I don’t know much about the state of IR on Pi anymore, as there have been significant changes.

You should be editing /boot/config-user.txt, rather than /boot/config.txt, as this will be overwritten by the OSMC update system.

Indeed. AFAIK, gpio-rpi is current. lirc_rpi got replaced by gpio-ir and gpio-ir-tx, how do I upgrade? · Issue #2993 · raspberrypi/linux · GitHub

As already noted, you need to remove the line

dtoverlay=gpio-ir,gpio_in_pin=23,gpio_in_pull=up

from /boot/config.txt. Not only is is the wrong place but you also have an entry in /boot/config-user.txt that seems to be showing a duplication of function in the system journal, which might be causing a conflict:

May 28 11:34:52 osmc kernel: rc rc0: gpio_ir_recv as /devices/platform/ir-receiver@17/rc/rc0
May 28 11:34:52 osmc kernel: rc rc0: lirc_dev: driver gpio_ir_recv registered at minor = 0, raw IR receiver, no transmitter
May 28 11:34:52 osmc kernel: input: gpio_ir_recv as /devices/platform/ir-receiver@17/rc/rc0/input0
...
May 28 11:34:52 osmc kernel: rc rc1: gpio_ir_recv as /devices/platform/ir-receiver@12/rc/rc1
May 28 11:34:52 osmc kernel: rc rc1: lirc_dev: driver gpio_ir_recv registered at minor = 1, raw IR receiver, no transmitter
May 28 11:34:52 osmc kernel: input: gpio_ir_recv as /devices/platform/ir-receiver@12/rc/rc1/input1

Looks like I got that backwards.

It is indeed odd that @mvdm has a /dev/lirc1. I would expect only one device node.

Good to know! Thanks Sam I will do that from now on!

Thanks for pointing this out dillthedog, it would make sense why it has been behaving so erratically! First irrecord works, then for no reason it doesn’t, then it produces strange errors, then it works on /dev/lirc0 then on /dev/lirc1. Most of the times the irrecord profile was identical, except for one time it came out completely different. Finally I wasn’t able to select an IR remote from My OSMC > Pi Config > Remotes.

So to be sure I have just started with a fresh image, updating it, and I will try again but with /boot/config-user.txt instead.

In the mean time I have also located argon.lircd.conf file from ArgonForty.
It’s supposed to be for OpenElec but I guess it should still be the same right?

#
# Based on NEC templates at http://lirc.sourceforge.net/remotes/nec/
# Configured codes based on data gathered
#


begin remote

  name  argon
  bits           32
  flags SPACE_ENC
  eps            20
  aeps          200

  header       8800  4400
  one           550  1650
  zero          550   550
  ptrail        550
  repeat       8800  2200
  gap          38500
  toggle_bit      0

  frequency    38000

  begin codes
      KEY_POWER                0x00ff39c6
      KEY_UP                   0x00ff53ac
      KEY_DOWN                 0x00ff4bb4
      KEY_LEFT                 0x00ff9966
      KEY_RIGHT                0x00ff837c
      KEY_VOLUMEUP             0x00ff01fe
      KEY_VOLUMEDOWN           0x00ff817e
      KEY_OK                   0x00ff738c
      KEY_HOME                 0x00ffd32c
      KEY_MENU                 0x00ffb946
      KEY_BACK                 0x00ff09f6
  end codes

end remote

@sam_nazarko @dillthedog thank you guys so much for your support, I really appreciate it!
I’m going to give it another try and I will let you know how my test goes!

1 Like

Ok, that did the job. That was entirely a noob error on my behalf.

So the procedure to make the Argon One IR Remote Work:

  1. Add dtoverlay=gpio-ir,gpio_pin=23 to /boot/config-user.txt
  2. Copy argon.lircd.conf and argon.lircd.png from ArgonForty (https://download.argon40.com/ArgonRemote.zip) to /etc/lirc/
  3. My OSMC > Remotes > Browse Locate argon.lircd.conf
3 Likes

Im posting this here in case it can help anyone else, ive figured out how to get the appropriate NEC byte code in order to correctly set the power on/off button on the argon one case even if you are using OSMC.

So the following python code is taken from the “argonirdecoder” script (/usr/bin/argonirdecoder) and i’ve set it up so that you can take the pulse output from mode2 for a single button and it will convert it to the appropriate NEC bytes.

So if you paste your pulse code into the “pulse1” variable this python script will spit out the
“bus.write_i2c_block_data(address, command, powerdata)” command.
Where address and command are always fixed and the “powerdata” is the decoded pulses for whatever button you want.

If you have installed “curl https://download.argon40.com/argonone-setup-osmc.sh | bash”
You wont have the “argonirdecode” installed, so to apply the code you would just need to uncomment the “bus.write_i2c_block_data” near the end to apply your power button update (and then reboot).

And you can get the mode2 pulse information by:
mode2 --driver default --device /dev/lirc0

#!/usr/bin/python3
import sys
import smbus
import RPi.GPIO as GPIO

from datetime import datetime
import os
import time


rev = GPIO.RPI_REVISION
if rev == 2 or rev == 3:
	bus = smbus.SMBus(1)
else:
	bus = smbus.SMBus(0)
	

#########################
# Common
irconffile = "/etc/lirc/lircd.conf.d/argon.lircd.conf"

# I2C
address = 0x1a	  # I2C Address
command = 0xaa	  # I2C Command

# Constants
PULSETIMEOUTMS = 1000
VERIFYTARGET = 3
PULSEDATA_MAXCOUNT = 200	# Fail safe

# NEC Protocol Constants
PULSEBIT_MAXMICROS_NEC = 2500
PULSEBIT_ZEROMICROS_NEC = 1000

PULSELEADER_MINMICROS_NEC = 8000
PULSELEADER_MAXMICROS_NEC = 10000
PULSETAIL_MAXMICROS_NEC = 12000


def getbytestring(pulsedata):
	outstring = ""
	for curbyte in pulsedata:
		tmpstr = hex(curbyte)[2:]
		while len(tmpstr) < 2:
			tmpstr = "0" + tmpstr
		outstring = outstring+tmpstr
	return outstring

def displaybyte(pulsedata):
	print (getbytestring(pulsedata))


def pulse2byteNEC(pulsedata):
	outdata = []
	bitdata = 1
	curbyte = 0
	bitcount = 0
	for (mode, duration) in pulsedata:
		if mode == 1:
			continue
		elif duration > PULSEBIT_MAXMICROS_NEC:
			continue
		elif duration > PULSEBIT_ZEROMICROS_NEC:
			curbyte = curbyte*2 + 1
		else:
			curbyte = curbyte*2

		bitcount = bitcount + 1
		if bitcount == 8:
			outdata.append(curbyte)
			curbyte = 0
			bitcount = 0
	# Shouldn't happen, but just in case
	if bitcount > 0:
		outdata.append(curbyte)

	return outdata


def bytecompare(a, b):
	idx = 0
	maxidx = len(a)
	if maxidx != len(b):
		return 1
	while idx < maxidx:
		if a[idx] != b[idx]:
			return 1
		idx = idx + 1
	return 0
	

#mode2 --driver default --device /dev/lirc0

pulse1 = '''
space 16777215
pulse 9008
space 4451
pulse 610
space 518
pulse 609
space 519
pulse 612
space 514
pulse 583
space 520
pulse 608
space 517
pulse 610
space 519
pulse 585
space 515
pulse 609
space 1622
pulse 608
space 519
pulse 609
space 518
pulse 583
space 519
pulse 609
space 1624
pulse 607
space 1622
pulse 608
space 522
pulse 605
space 1620
pulse 609
space 1626
pulse 606
space 517
pulse 607
space 1622
pulse 582
space 545
pulse 582
space 1649
pulse 581
space 522
pulse 606
space 1621
pulse 609
space 519
pulse 609
space 519
pulse 582
space 1648
pulse 582
space 520
pulse 607
space 1622
pulse 614
space 513
pulse 611
space 1624
pulse 603
space 519
pulse 582
space 1649
pulse 580
space 1648
pulse 583
space 43549
pulse 9006
space 2195
pulse 609
pulse 132661
'''

pulsedata = []

for i in pulse1.splitlines():
	if i != '':
		new_var = []
		new_var.append(int(i.replace('space','0,').replace('pulse','1,').split(',')[0]))
		new_var.append(int(i.replace('space','0,').replace('pulse','1,').split(',')[1]))
		pulsedata.append(new_var)

print(pulsedata)

powerdata = pulse2byteNEC(pulsedata)

if powerdata[len(powerdata)-1] == 1:
	powerdata2 = (powerdata[:-1])
try:
	print(powerdata2)
	powerdata = powerdata2
except:
	print(powerdata)

address = 26
command = 170
print('bus.write_i2c_block_data(' + str(address) +  ', ' + str(command) + ', ' + str(powerdata) + ')')
#bus.write_i2c_block_data(address, command, powerdata)

#mode2 --driver default --device /dev/lirc0

Additionally if you add the following to /etc/rc.local (or a cron job at reboot):

/usr/bin/sudo kill $(ps aux | grep 'lirc0' | awk '{print $2}') || true
/usr/bin/sudo /usr/sbin/lircd --driver=default --device=/dev/lirc0 --uinput --output=/usr/var/run/lirc/lircd --pidfile=/var/run/lirc/lircd2.pid /etc/lirc/lircd.conf
/usr/bin/sudo /usr/bin/irexec --daemon /home/osmc/.lircrc
/usr/bin/sudo /usr/bin/cat /var/run/lirc/lircd-lirc0.pid | /usr/bin/xargs /usr/bin/sudo /usr/bin/kill -9 || true

This will start an LIRC instance in addition to the OSMC lirc services with an IrExec file in your home folder with which you can setup whatever custom commands you want.

eg:
/home/osmc/.lircrc

begin
 prog = irexec
 remote = XBOX-ONE
 button = KEY_MUTE
 config = /usr/bin/kodi
end

begin
 prog = irexec
 remote = XBOX-ONE
 button = KEY_PROG3
 config = /usr/bin/sudo /usr/sbin/poweroff; /usr/bin/sudo /usr/bin/python3 /lib/systemd/system-shutdown/argononed-poweroff.py poweroff
end

And for information for the XBOX_ONE remote there are a couple of additional power buttons not enabled by default in the “/etc/lirc/xbox-one-lircd.conf”

      KEY_PROG2                0x54AB #POWER_ON
      KEY_PROG3                0x946B #POWER_OFF

Where you have selected the particular remote in osmc to be active and it will then be symlinked to “/etc/lirc/lircd.conf”

(Therefore the instance of lirc started by the commands above will use the default lircd.conf file and the same remote will be used within kodi and when you exit kodi)