Fan speed controlled by CPU temp script
#1
Bug 
Hi,

I wrote a script to control my fan.
The fan speed is controlled by the temp of the CPU.
I'm pretty new to bash so I'm hoping for some feedback and off course is everybody free to use the script how they like. Big Grin

Code:
#!/bin/bash
#MikeD
#Automatic fan on cpu temp

CHECK_TIME=10 #IN SEC

function pwm(){
LOOP=0
while [ $LOOP -lt $(($CHECK_TIME*75)) ]; do
       echo 1 > /sys/class/gpio/gpio82/value
       sleep $1
       echo 0 > /sys/class/gpio/gpio82/value
       sleep $2
       LOOP=$(($LOOP+1))
done
}

function fanOff()
{
echo 0 > /sys/class/gpio/gpio82/value
sleep $CHECK_TIME
}

function fanTweFiv()
{
pwm .0025 .0075
}

function fanFifty()
{
pwm .0050 .0050
}

function fanSevFiv()
{
pwm .0075 .0025
}

function fanFull()
{
echo 1 > /sys/class/gpio/gpio82/value
sleep $CHECK_TIME
}

while [ 1 ]; do
       TEMP=$(cat /sys/class/thermal/thermal_zone0/temp)

       if [ $TEMP -le 20000 ]
       then
               fanOff
       fi
       if [ $TEMP -gt 20000  -a  $TEMP -le 35000 ]
       then
               fanTweFiv
       fi

       if [ $TEMP -gt 35000 -a $TEMP -le 50000 ]
       then
               fanFifty
       fi

       if [ $TEMP -gt 50000 -a $TEMP -le 65000 ]
       then
               fanSevFiv
       fi

       if [ $TEMP -gt 65000 ]
       then
               fanFull
       fi

done

Thx in advance Smile
  Reply
#2
Hey there, how is this script holding up today? Has anyone been using it?
  Reply
#3
Can't get it to work:

./fantemp.sh: line 10: /sys/class/gpio/gpio82/value: No such file or directory
./fantemp.sh: line 12: /sys/class/gpio/gpio82/value: No such file or directory

I have these gpio's:

rock64@rock64:/sys/class/gpio$ ls
export gpiochip0 gpiochip32 gpiochip510 gpiochip64 gpiochip96 unexport
  Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
Heart Best quick/easy way to control case fan speed? idillicah 4 6,875 06-24-2021, 09:14 AM
Last Post: CounterPillow
  low speed wifi pas059 4 5,917 05-13-2019, 12:09 PM
Last Post: pas059
  Network Speed stuartiannaylor 27 33,817 05-06-2018, 10:07 AM
Last Post: S3phi40T

Forum Jump:


Users browsing this thread: 1 Guest(s)