Argon One V1 - Fan Control Not Working

Hello,
I was an early adopter and purchased the first version of the Argon One case back when it was released, I was very pleased with it but haven’t been using it lately. Today I decided I would set it up again, however upon downloading the software as per the instructions the fan no longer works in any capacity. When booting up an old OS with the software already installed it works perfectly. This has lead me to believe that the latest version of the software isn’t compatible, so I wondered if anyone knew any work arounds, ways to access old copies of the software or maybe a way to get it from the old OS.
Thank You

  • Stephen
1 Like

Hi Stephen,

the commands for the fan control hasn‘t changed for V1/V2. So the script should normally work. But it depends on the OS that is in use. For example the support for LibreELEC 10+ is not in place with the official distributed ArgonRemote.zip add-on or argon1.sh.

Please can you provide more details which OS you try to use, perhaps this makes the difference.

I have tried it on Raspberry Pi OS Lite (64 Bit), Raspberry Pi OS Lite (32 Bit) & Raspberry Pi OS (Legacy 32 Bit) Lite! Thank You :smile:

Do you have installed additional HATs or packages/services like iobroker or something like that? This can blocking the GPIO pins or the I2C bus.

To test the fan without the script you can use these commands:

Please stop argononed service first, if you used argon1.sh before.
systemctl stop argononed

  • Check if MCU address (1a) inside the case is reachable at I2C.
    i2cdetect -y 1

  • Set the fan to 100% duty cycle:
    i2cset -y 1 0x1a 0x64

  • Disable the fan, if you wish:
    i2cset -y 1 0x1a 0x00

All installations I tested it on were fresh installs so no non-standard packages would be installed & no installed HATs. When running the i2cdetect -y 1 I get the following, which seems to suggest that it isn’t detected. Any ideas why that would be the case, especially since it works on an old install?

     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:                         -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --

Can you please check if your RPi4 is started with an outdated bootloader?
sudo rpi-eeprom-update

Additional, please post the content of your config.txt.

I ran rpi-eeprom-update and it was 3 years out of date so I ran the updater with sudo rpi-eeprom-update -a, however after doing so the fan is still not functional, and remains undetected using the i2cdetect command you mentioned earlier.
I wasn’t sure which config file you were referring too, but here is a copy of my argononed.conf file:

#
# Argon Fan Speed Configuration CPU
#
# Min Temp=Fan Speed
1=100

I meant this one: https://www.raspberrypi.com/documentation/computers/config_txt.html
In the case of the new OS version it should be at /boot/firmware/config.txt

Regarding the bootloader update, do you have made the required reboot after you fired the ‘rpi-eeprom-update -a’ command? Do you double checked that the new version is in place? You doesn’t reported which date version it’s now. Unfortunately this is the only available indication which one you use.

What you should prevent to use is the i2cdump command, if used it before. This triggers the MCU to disconnect from the I2C bus. The same behavior I have observed if the MCU power button (hold button longer as 3 seconds and shorter than 5 seconds ) was triggered to initiate a shutdown or the remote control power button command has been received.

After such issues it’s required to remove the power supply from the case for some seconds, to get MCU back to normal.

Currently I don’t know, why the MCU with the old OS should behave other than with the current OS version: But is the always-on jumper in your case available and how is it currently set?

Hi Ya,
Having the same issue as ‘Techery’,
Raspberry pi os 12 64bit
has the Script changed recently?
Reinstalled a few weeks ago and it was working
Reinstalled yesterday and not working
i2c is active but not detecting Hat
Firmware is latest.
copy of my config.txt
#For more options and information see
#http://rptl.io/configtxt
#Some settings may impact device functionality. See link above for details

#Uncomment some or all of these to enable the optional hardware interfaces
dtparam=i2c_arm=on
#dtparam=i2s=on
dtparam=spi=on

#Enable audio (loads snd_bcm2835)
dtparam=audio=on

#Additional overlays and parameters are documented
#/boot/firmware/overlays/README

#Automatically load overlays for detected cameras
camera_auto_detect=1

#Automatically load overlays for detected DSI displays
display_auto_detect=1

#Automatically load initramfs files, if found
auto_initramfs=1

#Enable DRM VC4 V3D driver
dtoverlay=vc4-kms-v3d
max_framebuffers=2

#Don’t have the firmware create an initial video= setting in cmdline.txt.
#Use the kernel’s default instead.
disable_fw_kms_setup=1

#Run in 64-bit mode
arm_64bit=1

#Disable compensation for displays with overscan
disable_overscan=1

#Run as fast as firmware / board allows
arm_boost=1

[cm4]
#Enable host mode on the 2711 built-in XHCI USB controller.
#This line should be removed if the legacy DWC2 controller is required
#(e.g. for USB device mode) or if USB support is not required.
otg_mode=1

[all]

[all]
dtparam=sd_poll_once
gpu_mem=256

Thanks

Sorry, but this sentence does not contain reliable information. Please keep in mind that your post can be read a day later and possibly a new version was released overnight. There are also some stable boot loader releases that are ahead of the last DEFAULT version from 2023-01-18. So it’s needed to be more specific.

Which bootloader date and kernel version do you have?

I2C relies on a stable reference clock. Please can you check if these additional lines

enable_uart=1
core_freq=250

at the end of your config.txt makes a difference? Don‘t forget to reboot to activate the changes.

PS: Do you have seen, that you have the scope „[all]“ twice?

G’Day Mate
Thanks for getting back.

Using script - curl https://download.argon40.com/argonfanhat.sh | bash

Added the lines to config.txt you suggested
Rebooted
No change.

Then reverted to default Firmware
current: Mon 22 Jan 10:41:21 UTC 2024 (1705920081)
update: Wed 11 Jan 17:40:52 UTC 2023 (1673458852)
Rebooted
No Change - fan still runs a %50

kernel - 6.6.20+rpt-rpi-v8

sudo rpi-eeprom-update
BOOTLOADER: up to date
CURRENT: Wed 11 Jan 17:40:52 UTC 2023 (1673458852)
LATEST: Wed 11 Jan 17:40:52 UTC 2023 (1673458852)
RELEASE: default (/lib/firmware/raspberrypi/bootloader-2711/default)
Use raspi-config to change the release.

VL805_FW: Dedicated VL805 EEPROM
VL805: up to date
CURRENT: 000138c0
LATEST: 000138c0

nn@ZoneMinder-Pi:~ $ i2cdetect -y 1
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: – – – – – – – –
10: – – – – – – – – – – – – – – – –
20: – – – – – – – – – – – – – – – –
30: – – – – – – – – – – – – – – – –
40: – – – – – – – – – – – – – – – –
50: – – – – – – – – – – – – – – – –
60: – – – – – – – – – – – – – – – –
70: – – – – – – – –

[cm4]
#Enable host mode on the 2711 built-in XHCI USB controller.
#This line should be removed if the legacy DWC2 controller is required
#(e.g. for USB device mode) or if USB support is not required.
otg_mode=1

[all]
dtparam=sd_poll_once
gpu_mem=384
enable_uart=1
core_freq=250

Cheers

It looks to me that there some changes regarding the i2c bus are ongoing at kernel level:

Please remove the line “core_freq=250”, I found out today that there are problems with newer kernels and that the dmesg protocol is flooding.
Can you grep your dmesg log for i2c messages and also check what pinctl is reporting?
sudo dmesg -T | grep -i "i2c"
sudo pinctrl 2-3

As a shot in the dark, you can try forcing the I2C bus to a lower speed:
dtparam=i2c_arm=on,i2c_arm_baudrate=100000

Why do you have enabled SPI? Do you have a HAT attached?
Please try without these 2 lines too:

dtparam=spi=on
dtparam=sd_poll_once

Thanks Harry

I’m booting from a usb ssd, is the reason for
dtparam=sd_poll_once. It WAS working with no issues.
Removed line
core_freq=250
#dtparam=spi=on
and added i2c_arm_baudrate=100000
rebooted

glenn@ZoneMinder-Pi:~ $ sudo dmesg -T | grep -i “i2c”
[Sat Mar 23 07:40:52 2024] brcmstb-i2c fef04500.i2c: @97500hz registered in polling mode
[Sat Mar 23 07:40:52 2024] brcmstb-i2c fef09500.i2c: @97500hz registered in polling mode
[Sat Mar 23 07:40:54 2024] i2c_dev: i2c /dev entries driver
[Sat Mar 23 07:41:07 2024] i2c-bcm2835 fe804000.i2c: i2c transfer timed out
[Sat Mar 23 07:41:08 2024] i2c-bcm2835 fe804000.i2c: i2c transfer timed out
[Sat Mar 23 07:42:09 2024] i2c-bcm2835 fe804000.i2c: i2c transfer timed out
glenn@ZoneMinder-Pi:~ $ sudo pinctrl 2-3
2: a0 pu | hi // GPIO2 = SDA1
3: a0 pu | lo // GPIO3 = SCL1

No change

I’m going to reinstall with raspberry pi OS Bullseye on a sdcard.
It does look like a kernel issue, NO expert!
and hope for the best.

Thanks for trying
Cheers

I almost gave up, Thinking it might be broken,
Downgrading the OS didnt work.
Managed to find a copy of an OLD script and it worked
SO…
Latest Raspberry pi os
Latest Firmware
OLD argon1 Script works!
argon1.sh -

#!/bin/bash


argon_create_file() {
	if [ -f $1 ]; then
		sudo rm $1
	fi
	sudo touch $1
	sudo chmod 666 $1
}
argon_check_pkg() {
	RESULT=$(dpkg-query -W -f='${Status}\n' "$1" 2> /dev/null | grep "installed")

	if [ "" == "$RESULT" ]; then
		echo "NG"
	else
		echo "OK"
	fi
}

# Check if Raspbian, Ubuntu, others
CHECKPLATFORM="Others"
if [ -f "/etc/os-release" ]
then
	source /etc/os-release
	if [ "$ID" = "raspbian" ]
	then
		CHECKPLATFORM="Raspbian"
	elif [ "$ID" = "ubuntu" ]
	then
		CHECKPLATFORM="Ubuntu"
	fi
fi


if [ "$CHECKPLATFORM" = "Raspbian" ]
then
	pkglist=(raspi-gpio python3-rpi.gpio python3-smbus i2c-tools)	
else
	# Todo handle lgpio
	# Ubuntu has serial and i2c enabled
	pkglist=(python3-rpi.gpio python3-smbus i2c-tools)
fi

for curpkg in ${pkglist[@]}; do
	sudo apt-get install -y $curpkg
	RESULT=$(argon_check_pkg "$curpkg")
	if [ "NG" == "$RESULT" ]
	then
		echo "********************************************************************"
		echo "Please also connect device to the internet and restart installation."
		echo "********************************************************************"
		exit
	fi
done

# Ubuntu Mate for RPi has raspi-config too
command -v raspi-config &> /dev/null
if [ $? -eq 0 ]
then
	# Enable i2c and serial
	sudo raspi-config nonint do_i2c 0
	sudo raspi-config nonint do_serial 2
fi

# Helper variables
daemonname="argononed"
powerbuttonscript=/usr/bin/$daemonname.py
shutdownscript="/lib/systemd/system-shutdown/"$daemonname"-poweroff.py"
daemonconfigfile=/etc/$daemonname.conf
configscript=/usr/bin/argonone-config
removescript=/usr/bin/argonone-uninstall

daemonfanservice=/lib/systemd/system/$daemonname.service
	
if [ ! -f $daemonconfigfile ]; then
	# Generate config file for fan speed
	sudo touch $daemonconfigfile
	sudo chmod 666 $daemonconfigfile
	echo '#' >> $daemonconfigfile
	echo '# Argon One Fan Configuration' >> $daemonconfigfile
	echo '#' >> $daemonconfigfile
	echo '# List below the temperature (Celsius) and fan speed (in percent) pairs' >> $daemonconfigfile
	echo '# Use the following form:' >> $daemonconfigfile
	echo '# min.temperature=speed' >> $daemonconfigfile
	echo '#' >> $daemonconfigfile
	echo '# Example:' >> $daemonconfigfile
	echo '# 55=10' >> $daemonconfigfile
	echo '# 60=55' >> $daemonconfigfile
	echo '# 65=100' >> $daemonconfigfile
	echo '#' >> $daemonconfigfile
	echo '# Above example sets the fan speed to' >> $daemonconfigfile
	echo '#' >> $daemonconfigfile
	echo '# NOTE: Lines begining with # are ignored' >> $daemonconfigfile
	echo '#' >> $daemonconfigfile
	echo '# Type the following at the command line for changes to take effect:' >> $daemonconfigfile
	echo '# sudo systemctl restart '$daemonname'.service' >> $daemonconfigfile
	echo '#' >> $daemonconfigfile
	echo '# Start below:' >> $daemonconfigfile
	echo '55=10' >> $daemonconfigfile
	echo '60=55' >> $daemonconfigfile
	echo '65=100' >> $daemonconfigfile
fi

# Generate script that runs every shutdown event
argon_create_file $shutdownscript

echo "#!/usr/bin/python3" >> $shutdownscript
echo 'import sys' >> $shutdownscript
echo 'import smbus' >> $shutdownscript
echo 'import RPi.GPIO as GPIO' >> $shutdownscript
echo 'rev = GPIO.RPI_REVISION' >> $shutdownscript
echo 'if rev == 2 or rev == 3:' >> $shutdownscript
echo '	bus = smbus.SMBus(1)' >> $shutdownscript
echo 'else:' >> $shutdownscript
echo '	bus = smbus.SMBus(0)' >> $shutdownscript

echo 'if len(sys.argv)>1:' >> $shutdownscript
echo "	bus.write_byte(0x1a,0)"  >> $shutdownscript

# powercut signal
echo '	if sys.argv[1] == "poweroff" or sys.argv[1] == "halt":'  >> $shutdownscript
echo "		try:"  >> $shutdownscript
echo "			bus.write_byte(0x1a,0xFF)"  >> $shutdownscript
echo "		except:"  >> $shutdownscript
echo "			rev=0"  >> $shutdownscript

sudo chmod 755 $shutdownscript

# Generate script to monitor shutdown button

argon_create_file $powerbuttonscript

echo "#!/usr/bin/python3" >> $powerbuttonscript
echo 'import smbus' >> $powerbuttonscript
echo 'import RPi.GPIO as GPIO' >> $powerbuttonscript
echo 'import os' >> $powerbuttonscript
echo 'import time' >> $powerbuttonscript
echo 'from threading import Thread' >> $powerbuttonscript
echo 'rev = GPIO.RPI_REVISION' >> $powerbuttonscript
echo 'if rev == 2 or rev == 3:' >> $powerbuttonscript
echo '	bus = smbus.SMBus(1)' >> $powerbuttonscript
echo 'else:' >> $powerbuttonscript
echo '	bus = smbus.SMBus(0)' >> $powerbuttonscript

echo 'GPIO.setwarnings(False)' >> $powerbuttonscript
echo 'GPIO.setmode(GPIO.BCM)' >> $powerbuttonscript
echo 'shutdown_pin=4' >> $powerbuttonscript
echo 'GPIO.setup(shutdown_pin, GPIO.IN,  pull_up_down=GPIO.PUD_DOWN)' >> $powerbuttonscript

echo 'def shutdown_check():' >> $powerbuttonscript
echo '	while True:' >> $powerbuttonscript
echo '		pulsetime = 1' >> $powerbuttonscript
echo '		GPIO.wait_for_edge(shutdown_pin, GPIO.RISING)' >> $powerbuttonscript
echo '		time.sleep(0.01)' >> $powerbuttonscript
echo '		while GPIO.input(shutdown_pin) == GPIO.HIGH:' >> $powerbuttonscript
echo '			time.sleep(0.01)' >> $powerbuttonscript
echo '			pulsetime += 1' >> $powerbuttonscript
echo '		if pulsetime >=2 and pulsetime <=3:' >> $powerbuttonscript
echo '			os.system("reboot")' >> $powerbuttonscript
echo '		elif pulsetime >=4 and pulsetime <=5:' >> $powerbuttonscript
echo '			os.system("shutdown now -h")' >> $powerbuttonscript

echo 'def get_fanspeed(tempval, configlist):' >> $powerbuttonscript
echo '	for curconfig in configlist:' >> $powerbuttonscript
echo '		curpair = curconfig.split("=")' >> $powerbuttonscript
echo '		tempcfg = float(curpair[0])' >> $powerbuttonscript
echo '		fancfg = int(float(curpair[1]))' >> $powerbuttonscript
echo '		if tempval >= tempcfg:' >> $powerbuttonscript
echo '			if fancfg < 1:' >> $powerbuttonscript
echo '				return 0' >> $powerbuttonscript
echo '			elif fancfg < 25:' >> $powerbuttonscript
echo '				return 25' >> $powerbuttonscript
echo '			return fancfg' >> $powerbuttonscript
echo '	return 0' >> $powerbuttonscript

echo 'def load_config(fname):' >> $powerbuttonscript
echo '	newconfig = []' >> $powerbuttonscript
echo '	try:' >> $powerbuttonscript
echo '		with open(fname, "r") as fp:' >> $powerbuttonscript
echo '			for curline in fp:' >> $powerbuttonscript
echo '				if not curline:' >> $powerbuttonscript
echo '					continue' >> $powerbuttonscript
echo '				tmpline = curline.strip()' >> $powerbuttonscript
echo '				if not tmpline:' >> $powerbuttonscript
echo '					continue' >> $powerbuttonscript
echo '				if tmpline[0] == "#":' >> $powerbuttonscript
echo '					continue' >> $powerbuttonscript
echo '				tmppair = tmpline.split("=")' >> $powerbuttonscript
echo '				if len(tmppair) != 2:' >> $powerbuttonscript
echo '					continue' >> $powerbuttonscript
echo '				tempval = 0' >> $powerbuttonscript
echo '				fanval = 0' >> $powerbuttonscript
echo '				try:' >> $powerbuttonscript
echo '					tempval = float(tmppair[0])' >> $powerbuttonscript
echo '					if tempval < 0 or tempval > 100:' >> $powerbuttonscript
echo '						continue' >> $powerbuttonscript
echo '				except:' >> $powerbuttonscript
echo '					continue' >> $powerbuttonscript
echo '				try:' >> $powerbuttonscript
echo '					fanval = int(float(tmppair[1]))' >> $powerbuttonscript
echo '					if fanval < 0 or fanval > 100:' >> $powerbuttonscript
echo '						continue' >> $powerbuttonscript
echo '				except:' >> $powerbuttonscript
echo '					continue' >> $powerbuttonscript
echo '				newconfig.append( "{:5.1f}={}".format(tempval,fanval))' >> $powerbuttonscript
echo '		if len(newconfig) > 0:' >> $powerbuttonscript
echo '			newconfig.sort(reverse=True)' >> $powerbuttonscript
echo '	except:' >> $powerbuttonscript
echo '		return []' >> $powerbuttonscript
echo '	return newconfig' >> $powerbuttonscript

echo 'def temp_check():' >> $powerbuttonscript
echo '	fanconfig = ["65=100", "60=55", "55=10"]' >> $powerbuttonscript
echo '	tmpconfig = load_config("'$daemonconfigfile'")' >> $powerbuttonscript
echo '	if len(tmpconfig) > 0:' >> $powerbuttonscript
echo '		fanconfig = tmpconfig' >> $powerbuttonscript
echo '	address=0x1a' >> $powerbuttonscript
echo '	prevblock=0' >> $powerbuttonscript
echo '	while True:' >> $powerbuttonscript

echo '		try:' >> $powerbuttonscript
echo '			tempfp = open("/sys/class/thermal/thermal_zone0/temp", "r")' >> $powerbuttonscript
echo '			temp = tempfp.readline()' >> $powerbuttonscript
echo '			tempfp.close()' >> $powerbuttonscript
echo '			val = float(int(temp)/1000)' >> $powerbuttonscript
echo '		except IOError:' >> $powerbuttonscript
echo '			val = 0' >> $powerbuttonscript

echo '		block = get_fanspeed(val, fanconfig)' >> $powerbuttonscript
echo '		if block < prevblock:' >> $powerbuttonscript
echo '			time.sleep(30)' >> $powerbuttonscript
echo '		prevblock = block' >> $powerbuttonscript
echo '		try:' >> $powerbuttonscript
echo '			if block > 0:' >> $powerbuttonscript
echo '				bus.write_byte(address,100)' >> $powerbuttonscript
echo '				time.sleep(1)' >> $powerbuttonscript
echo '			bus.write_byte(address,block)' >> $powerbuttonscript
echo '		except IOError:' >> $powerbuttonscript
echo '			temp=""' >> $powerbuttonscript
echo '		time.sleep(30)' >> $powerbuttonscript

echo 'try:' >> $powerbuttonscript
echo '	t1 = Thread(target = shutdown_check)' >> $powerbuttonscript
echo '	t2 = Thread(target = temp_check)' >> $powerbuttonscript
echo '	t1.start()' >> $powerbuttonscript
echo '	t2.start()' >> $powerbuttonscript
echo 'except:' >> $powerbuttonscript
echo '	t1.stop()' >> $powerbuttonscript
echo '	t2.stop()' >> $powerbuttonscript
echo '	GPIO.cleanup()' >> $powerbuttonscript

sudo chmod 755 $powerbuttonscript

argon_create_file $daemonfanservice

# Fan Daemon
echo "[Unit]" >> $daemonfanservice
echo "Description=Argon One Fan and Button Service" >> $daemonfanservice
echo "After=multi-user.target" >> $daemonfanservice
echo '[Service]' >> $daemonfanservice
echo 'Type=simple' >> $daemonfanservice
echo "Restart=always" >> $daemonfanservice
echo "RemainAfterExit=true" >> $daemonfanservice
echo "ExecStart=/usr/bin/python3 $powerbuttonscript" >> $daemonfanservice
echo '[Install]' >> $daemonfanservice
echo "WantedBy=multi-user.target" >> $daemonfanservice

sudo chmod 644 $daemonfanservice

argon_create_file $removescript

# Uninstall Script
echo '#!/bin/bash' >> $removescript
echo 'echo "-------------------------"' >> $removescript
echo 'echo "Argon One Uninstall Tool"' >> $removescript
echo 'echo "-------------------------"' >> $removescript
echo 'echo -n "Press Y to continue:"' >> $removescript
echo 'read -n 1 confirm' >> $removescript
echo 'echo' >> $removescript
echo 'if [ "$confirm" = "y" ]' >> $removescript
echo 'then' >> $removescript
echo '	confirm="Y"' >> $removescript
echo 'fi' >> $removescript
echo '' >> $removescript
echo 'if [ "$confirm" != "Y" ]' >> $removescript
echo 'then' >> $removescript
echo '	echo "Cancelled"' >> $removescript
echo '	exit' >> $removescript
echo 'fi' >> $removescript
echo 'if [ -d "/home/pi/Desktop" ]; then' >> $removescript
echo '	sudo rm "/home/pi/Desktop/argonone-config.desktop"' >> $removescript
echo '	sudo rm "/home/pi/Desktop/argonone-uninstall.desktop"' >> $removescript
echo 'fi' >> $removescript
echo 'if [ -f '$powerbuttonscript' ]; then' >> $removescript
echo '	sudo systemctl stop '$daemonname'.service' >> $removescript
echo '	sudo systemctl disable '$daemonname'.service' >> $removescript
echo '	sudo /usr/bin/python3 '$shutdownscript' uninstall' >> $removescript
echo '	sudo rm '$powerbuttonscript >> $removescript
echo '	sudo rm '$shutdownscript >> $removescript
echo '	sudo rm '$removescript >> $removescript
echo '	echo "Removed Argon One Services."' >> $removescript
echo '	echo "Cleanup will complete after restarting the device."' >> $removescript
echo 'fi' >> $removescript

sudo chmod 755 $removescript

argon_create_file $configscript

# Config Script
echo '#!/bin/bash' >> $configscript
echo 'daemonconfigfile='$daemonconfigfile >> $configscript
echo 'echo "--------------------------------------"' >> $configscript
echo 'echo "Argon One Fan Speed Configuration Tool"' >> $configscript
echo 'echo "--------------------------------------"' >> $configscript
echo 'echo "WARNING: This will remove existing configuration."' >> $configscript
echo 'echo -n "Press Y to continue:"' >> $configscript
echo 'read -n 1 confirm' >> $configscript
echo 'echo' >> $configscript
echo 'if [ "$confirm" = "y" ]' >> $configscript
echo 'then' >> $configscript
echo '	confirm="Y"' >> $configscript
echo 'fi' >> $configscript
echo '' >> $configscript
echo 'if [ "$confirm" != "Y" ]' >> $configscript
echo 'then' >> $configscript
echo '	echo "Cancelled"' >> $configscript
echo '	exit' >> $configscript
echo 'fi' >> $configscript
echo 'echo "Thank you."' >> $configscript

echo 'get_number () {' >> $configscript
echo '	read curnumber' >> $configscript
echo '	if [ -z "$curnumber" ]' >> $configscript
echo '	then' >> $configscript
echo '		echo "-2"' >> $configscript
echo '		return' >> $configscript
echo '	elif [[ $curnumber =~ ^[+-]?[0-9]+$ ]]' >> $configscript
echo '	then' >> $configscript
echo '		if [ $curnumber -lt 0 ]' >> $configscript
echo '		then' >> $configscript
echo '			echo "-1"' >> $configscript
echo '			return' >> $configscript
echo '		elif [ $curnumber -gt 100 ]' >> $configscript
echo '		then' >> $configscript
echo '			echo "-1"' >> $configscript
echo '			return' >> $configscript
echo '		fi	' >> $configscript
echo '		echo $curnumber' >> $configscript
echo '		return' >> $configscript
echo '	fi' >> $configscript
echo '	echo "-1"' >> $configscript
echo '	return' >> $configscript
echo '}' >> $configscript
echo '' >> $configscript

echo 'loopflag=1' >> $configscript
echo 'while [ $loopflag -eq 1 ]' >> $configscript
echo 'do' >> $configscript
echo '	echo' >> $configscript
echo '	echo "Select fan mode:"' >> $configscript
echo '	echo "  1. Always on"' >> $configscript
echo '	echo "  2. Adjust to temperatures (55C, 60C, and 65C)"' >> $configscript
echo '	echo "  3. Customize behavior"' >> $configscript
echo '	echo "  4. Cancel"' >> $configscript
echo '	echo "NOTE: You can also edit $daemonconfigfile directly"' >> $configscript
echo '	echo -n "Enter Number (1-4):"' >> $configscript
echo '	newmode=$( get_number )' >> $configscript
echo '	if [[ $newmode -ge 1 && $newmode -le 4 ]]' >> $configscript
echo '	then' >> $configscript
echo '		loopflag=0' >> $configscript
echo '	fi' >> $configscript
echo 'done' >> $configscript

echo 'echo' >> $configscript
echo 'if [ $newmode -eq 4 ]' >> $configscript
echo 'then' >> $configscript
echo '	echo "Cancelled"' >> $configscript
echo '	exit' >> $configscript
echo 'elif [ $newmode -eq 1 ]' >> $configscript
echo 'then' >> $configscript
echo '	echo "#" > $daemonconfigfile' >> $configscript
echo '	echo "# Argon One Fan Speed Configuration" >> $daemonconfigfile' >> $configscript
echo '	echo "#" >> $daemonconfigfile' >> $configscript
echo '	echo "# Min Temp=Fan Speed" >> $daemonconfigfile' >> $configscript
echo '	echo 1"="100 >> $daemonconfigfile' >> $configscript
echo '	sudo systemctl restart '$daemonname'.service' >> $configscript
echo '	echo "Fan always on."' >> $configscript
echo '	exit' >> $configscript
echo 'elif [ $newmode -eq 2 ]' >> $configscript
echo 'then' >> $configscript
echo '	echo "Please provide fan speeds for the following temperatures:"' >> $configscript
echo '	echo "#" > $daemonconfigfile' >> $configscript
echo '	echo "# Argon One Fan Speed Configuration" >> $daemonconfigfile' >> $configscript
echo '	echo "#" >> $daemonconfigfile' >> $configscript
echo '	echo "# Min Temp=Fan Speed" >> $daemonconfigfile' >> $configscript
echo '	curtemp=55' >> $configscript
echo '	while [ $curtemp -lt 70 ]' >> $configscript
echo '	do' >> $configscript
echo '		errorfanflag=1' >> $configscript
echo '		while [ $errorfanflag -eq 1 ]' >> $configscript
echo '		do' >> $configscript
echo '			echo -n ""$curtemp"C (0-100 only):"' >> $configscript
echo '			curfan=$( get_number )' >> $configscript
echo '			if [ $curfan -ge 0 ]' >> $configscript
echo '			then' >> $configscript
echo '				errorfanflag=0' >> $configscript
echo '			fi' >> $configscript
echo '		done' >> $configscript
echo '		echo $curtemp"="$curfan >> $daemonconfigfile' >> $configscript
echo '		curtemp=$((curtemp+5))' >> $configscript
echo '	done' >> $configscript

echo '	sudo systemctl restart '$daemonname'.service' >> $configscript
echo '	echo "Configuration updated."' >> $configscript
echo '	exit' >> $configscript
echo 'fi' >> $configscript

echo 'echo "Please provide fan speeds and temperature pairs"' >> $configscript
echo 'echo' >> $configscript

echo 'loopflag=1' >> $configscript
echo 'paircounter=0' >> $configscript
echo 'while [ $loopflag -eq 1 ]' >> $configscript
echo 'do' >> $configscript
echo '	errortempflag=1' >> $configscript
echo '	errorfanflag=1' >> $configscript
echo '	while [ $errortempflag -eq 1 ]' >> $configscript
echo '	do' >> $configscript
echo '		echo -n "Provide minimum temperature (in Celsius) then [ENTER]:"' >> $configscript
echo '		curtemp=$( get_number )' >> $configscript
echo '		if [ $curtemp -ge 0 ]' >> $configscript
echo '		then' >> $configscript
echo '			errortempflag=0' >> $configscript
echo '		elif [ $curtemp -eq -2 ]' >> $configscript
echo '		then' >> $configscript
echo '			errortempflag=0' >> $configscript
echo '			errorfanflag=0' >> $configscript
echo '			loopflag=0' >> $configscript
echo '		fi' >> $configscript
echo '	done' >> $configscript
echo '	while [ $errorfanflag -eq 1 ]' >> $configscript
echo '	do' >> $configscript
echo '		echo -n "Provide fan speed for "$curtemp"C (0-100) then [ENTER]:"' >> $configscript
echo '		curfan=$( get_number )' >> $configscript
echo '		if [ $curfan -ge 0 ]' >> $configscript
echo '		then' >> $configscript
echo '			errorfanflag=0' >> $configscript
echo '		elif [ $curfan -eq -2 ]' >> $configscript
echo '		then' >> $configscript
echo '			errortempflag=0' >> $configscript
echo '			errorfanflag=0' >> $configscript
echo '			loopflag=0' >> $configscript
echo '		fi' >> $configscript
echo '	done' >> $configscript
echo '	if [ $loopflag -eq 1 ]' >> $configscript
echo '	then' >> $configscript
echo '		if [ $paircounter -eq 0 ]' >> $configscript
echo '		then' >> $configscript
echo '			echo "#" > $daemonconfigfile' >> $configscript
echo '			echo "# Argon One Fan Speed Configuration" >> $daemonconfigfile' >> $configscript
echo '			echo "#" >> $daemonconfigfile' >> $configscript
echo '			echo "# Min Temp=Fan Speed" >> $daemonconfigfile' >> $configscript
echo '		fi' >> $configscript
echo '		echo $curtemp"="$curfan >> $daemonconfigfile' >> $configscript
echo '		' >> $configscript
echo '		paircounter=$((paircounter+1))' >> $configscript
echo '		' >> $configscript
echo '		echo "* Fan speed will be set to "$curfan" once temperature reaches "$curtemp" C"' >> $configscript
echo '		echo' >> $configscript
echo '	fi' >> $configscript
echo 'done' >> $configscript
echo '' >> $configscript
echo 'echo' >> $configscript
echo 'if [ $paircounter -gt 0 ]' >> $configscript
echo 'then' >> $configscript
echo '	echo "Thank you!  We saved "$paircounter" pairs."' >> $configscript
echo '	sudo systemctl restart '$daemonname'.service' >> $configscript
echo '	echo "Changes should take effect now."' >> $configscript
echo 'else' >> $configscript
echo '	echo "Cancelled, no data saved."' >> $configscript
echo 'fi' >> $configscript

sudo chmod 755 $configscript


sudo systemctl daemon-reload
sudo systemctl enable $daemonname.service

sudo systemctl start $daemonname.service


shortcutfile="/home/pi/Desktop/argonone-config.desktop"
if [ "$CHECKPLATFORM" = "Raspbian" ] && [ -d "/home/pi/Desktop" ]
then
	terminalcmd="lxterminal --working-directory=/home/pi/ -t"
	if  [ -f "/home/pi/.twisteros.twid" ]
	then
		terminalcmd="xfce4-terminal --default-working-directory=/home/pi/ -T"
	fi
	sudo wget http://download.argon40.com/ar1config.png -O /usr/share/pixmaps/ar1config.png --quiet
	sudo wget http://download.argon40.com/ar1uninstall.png -O /usr/share/pixmaps/ar1uninstall.png --quiet
	# Create Shortcuts
	echo "[Desktop Entry]" > $shortcutfile
	echo "Name=Argon One Configuration" >> $shortcutfile
	echo "Comment=Argon One Configuration" >> $shortcutfile
	echo "Icon=/usr/share/pixmaps/ar1config.png" >> $shortcutfile
	echo 'Exec='$terminalcmd' "Argon One Configuration" -e '$configscript >> $shortcutfile
	echo "Type=Application" >> $shortcutfile
	echo "Encoding=UTF-8" >> $shortcutfile
	echo "Terminal=false" >> $shortcutfile
	echo "Categories=None;" >> $shortcutfile
	chmod 755 $shortcutfile
	
	shortcutfile="/home/pi/Desktop/argonone-uninstall.desktop"
	echo "[Desktop Entry]" > $shortcutfile
	echo "Name=Argon One Uninstall" >> $shortcutfile
	echo "Comment=Argon One Uninstall" >> $shortcutfile
	echo "Icon=/usr/share/pixmaps/ar1uninstall.png" >> $shortcutfile
	echo 'Exec='$terminalcmd' -t "Argon One Uninstall" --working-directory=/home/pi/ -e '$removescript >> $shortcutfile
	echo "Type=Application" >> $shortcutfile
	echo "Encoding=UTF-8" >> $shortcutfile
	echo "Terminal=false" >> $shortcutfile
	echo "Categories=None;" >> $shortcutfile
	chmod 755 $shortcutfile
fi

# IR config script
sudo wget https://download.argon40.com/argonone-irconfig.sh -O /usr/bin/argonone-ir --quiet
sudo chmod 755 /usr/bin/argonone-ir

echo "***************************"
echo "Argon One Setup Completed."
echo "***************************"
echo
if [ ! "$CHECKPLATFORM" = "Raspbian" ]
then
		echo "You may need to reboot for changes to take effect"
		echo
fi 
if [ -f $shortcutfile ]; then
	echo Shortcuts created in your desktop.
else
	echo Use 'argonone-config' to configure fan
	echo Use 'argonone-uninstall' to uninstall
fi
echo

Nice find. Would you like to get to the bottom of the cause?