#!/bin/bash ########################################################################### # # Copyright (c) 2005 Simon "Sturmflut" Raffeiner # # This script is published under the terms of the GNU Public license # version 2 or later. # ########################################################################### # # Version History: # # 29.05.2005: Initial release # ########################################################################### # Path to your I2C driver in SysFS I2C_PATH=/sys/bus/i2c/devices/1-0290 # Name of the I2C device that returns the temperature we want to monitor I2C_TEMPERATURE_INPUT=temp2_input # Name of the PWM device to control I2C_PWM_DEVICE=pwm1 # Minimum temperature value (your fan stops below this value) # NOTE: My Winbond w83627hf returns temperatur values degrees*1000 TEMPERATURE_MIN=32000 # Maximum temperature value (your fan blows full speed above this value) # NOTE: My Winbond w83627hf returns temperatur values degrees*1000 TEMPERATURE_MAX=46000 # Number of uniquesteps your PWM generator is able to generate # NOTE: My Winbond w83627hf allows a value range from 0 to 255 in steps of 16 # so I have 16 steps (16*16 = 256) PWM_STEPS=16 if [ ! -e $I2C_PATH ]; then echo "I2C Device path does not exist!" fi while /bin/true do CPUTEMP=`cat $I2C_PATH/$I2C_TEMPERATURE_INPUT` FANSPEED=`cat $I2C_PATH/$I2C_PWM_DEVICE` echo "CPU Temperature: $CPUTEMP" echo "Fan Speed: $FANSPEED" # Calculate Factor let DIVIDER=($TEMPERATURE_MAX-$TEMPERATURE_MIN)/$PWM_STEPS let FACTOR=($CPUTEMP-$TEMPERATURE_MIN)/$DIVIDER echo "Faktor: $FACTOR" #Calculate new Fan Speed if [ $FACTOR -lt 1 ]; then FANSPEED_NEW=0 else if [ $FACTOR -le 16 ]; then let FANSPEED_NEW=$FACTOR*$PWM_STEPS else FANSPEED_NEW=255; fi fi echo "New fan speed: $FANSPEED_NEW" # Set new fan speed echo $FANSPEED_NEW > $I2C_PATH/$I2C_PWM_DEVICE # NOTE: I set the speed of my second fan (harddisk cage) to the same value echo $FANSPEED_NEW > $I2C_PATH/pwm2 sleep 3 done