Skip to content

Instantly share code, notes, and snippets.

@Lessica
Created March 25, 2022 17:07
Show Gist options
  • Save Lessica/30240b63ac0e47d80a919209ea006c60 to your computer and use it in GitHub Desktop.
Save Lessica/30240b63ac0e47d80a919209ea006c60 to your computer and use it in GitHub Desktop.
Configure Raspberry Pi + Argon One Case for Lineage OS
#!/system/bin/sh
sleeptime=120
while true
do
cputemp=$(cat /sys/class/thermal/thermal_zone0/temp)
if [[ $cputemp -lt 55000 ]]; then
fanspeed="0x00"
elif [ $cputemp -ge 55000 -a $cputemp -lt 60000 ]; then
fanspeed="0x10"
elif [ $cputemp -ge 60000 -a $cputemp -lt 65000 ]; then
fanspeed="0x32"
elif [ $cputemp -ge 65000 ]; then
fanspeed="0x64"
fi
i2cget -y 1 0x01a $fanspeed
sleep $sleeptime
done
@Atomique13
Copy link

Atomique13 commented Jul 27, 2022

@mshs013

I've found on a forum that the location is "/system/etc/init.d/", mine was something like "/vendor/system/etc/init.d/", I've inserted the SD card on PC and paste the file as it is.

@mshs013
Copy link

mshs013 commented Sep 21, 2022

@mshs013

I've found on a forum that the location is "/system/etc/init.d/", mine was something like "/vendor/system/etc/init.d/", I've inserted the SD card on PC and paste the file as it is.

@Atomique13
I already follow your instruction but fan not working. my file path "/vendor/etc/init.d/".

@Atomique13
Copy link

Atomique13 commented May 12, 2023

@mshs013
I've found on a forum that the location is "/system/etc/init.d/", mine was something like "/vendor/system/etc/init.d/", I've inserted the SD card on PC and paste the file as it is.

@Atomique13 I already follow your instruction but fan not working. my file path "/vendor/etc/init.d/".

@mshs013
Clone any other file from that folder, and edit it with your code (permissions were the culprit). Also change "#!/system/bin/sh" with "#!/vendor/bin/sh", I don't know if this is needed but in my case it worked. I've tested it on LineageOS 20 - KonstaKANG Android 13.

Good permissions (group 2000 in my case was edited as root by ubuntu, but still good)

image

@VipinPatel1305
Copy link

VipinPatel1305 commented Sep 29, 2023

just in case if your fan running on official gpio 14 pin or you have pwm controlled fan, you can use this script to control fan.

sleeptime=120
echo 14 > /sys/class/gpio/export
echo out > /sys/class/gpio/gpio14/direction
echo 0 > /sys/class/gpio/gpio14/value
echo `date` > /data/local/fan-script.log

while true
do
	cputemp=$(cat /sys/class/thermal/thermal_zone0/temp)
	echo $cputemp >> /data/local/fan-script.log
	if [[ $cputemp -lt 55000 ]]; then
		echo 0 > /sys/class/gpio/gpio14/value
	elif [ $cputemp -ge 65000 ]; then
		echo 1 > /sys/class/gpio/gpio14/value
	fi
	sleep $sleeptime
done

@bernardovalente
Copy link

just in case if your fan running on official gpio 14 pin or you have pwm controlled fan, you can use this script to control fan.

sleeptime=120
echo 14 > /sys/class/gpio/export
echo out > /sys/class/gpio/gpio14/direction
echo 0 > /sys/class/gpio/gpio14/value
echo `date` > /data/local/fan-script.log

while true
do
	cputemp=$(cat /sys/class/thermal/thermal_zone0/temp)
	echo $cputemp >> /data/local/fan-script.log
	if [[ $cputemp -lt 55000 ]]; then
		echo 0 > /sys/class/gpio/gpio14/value
	elif [ $cputemp -ge 65000 ]; then
		echo 1 > /sys/class/gpio/gpio14/value
	fi
	sleep $sleeptime
done

I'm using the case as it came, where should I copy this file to? thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment