1
1
Fork 0

added fancontrol script for odroid hc4

This commit is contained in:
david 2023-09-20 20:37:12 +02:00
parent 897c773468
commit bc7a8067c9
1 changed files with 36 additions and 0 deletions

36
hc4_fancontrol.sh Normal file
View File

@ -0,0 +1,36 @@
#!/bin/bash
THRESHOLD=42000
INTERVAL=30
FAN="/sys/class/hwmon/hwmon2/pwm1"
# set fan mode to manual
echo "disabled" | tee /sys/class/thermal/thermal_zone{0,1}/mode > /dev/null
# set fan speed to max if either cpu or ram is above $THRESHOLD
while true; do
TOOHOT=0
FANSPEED=$(cat $FAN)
TEMP=($(cat /sys/devices/virtual/thermal/thermal_zone{0,1}/temp))
for i in ${TEMP[@]}; do
if [ $i -gt $THRESHOLD ]; then
TOOHOT=255
fi
done
if [ $TOOHOT -eq 0 ]; then
if [ $FANSPEED -ne $TOOHOT ]; then
echo 170 > $FAN; sleep 2
echo 120 > $FAN; sleep 2
echo $TOOHOT > $FAN
fi
else
if [ $FANSPEED -ne $TOOHOT ]; then
echo 120 > $FAN; sleep 2
echo 170 > $FAN; sleep 2
echo $TOOHOT > $FAN
fi
fi
# debug output
#echo "temp=${TEMP[@]},speed=$FANSPEED, toohot=$TOOHOT"
sleep $INTERVAL
done