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


Messages In This Thread
Fan speed controlled by CPU temp script - by mikedhoore - 11-18-2017, 03:37 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
Heart Best quick/easy way to control case fan speed? idillicah 1 873 12-15-2020, 04:57 PM
Last Post: kidfrostbite
  low speed wifi pas059 4 1,629 05-13-2019, 12:09 PM
Last Post: pas059
  Network Speed stuartiannaylor 27 11,816 05-06-2018, 10:07 AM
Last Post: S3phi40T

Forum Jump:


Users browsing this thread: 1 Guest(s)