uname -a
Linux OpenWrt 4.19.81 #0 SMP Sun Nov 3 19:25:07 2019 armv7l GNU/Linux.
/sbin/fan_ctrl.sh litters the system log with lots of messages like this:
----------------- Example of message, one every 5 minutes ---------------- Nov 29 15:45:00 2019 cron.err crond[2687]: USER root pid 14090 cmd /sbin/fan_ctrl.sh
Looking at my wrt 1900, through the holes/perforations on the top, it appears to have a fan.
Possible concerns:
If a fan action is not required, could the script do an "exit 0" instead of trying to "echo "0" > "The Device"". Why? I suspect the "hardware" is modulating fan speed to control temperature. It appears the script might be trying to turn the fan "off" instead of letting the "hardware" continue with whatever it is trying to do.
It appears that when the script determines it does not need to "correct" fan speed it is generating unnecessary messages in the system log.
#!/bin/sh
# put in /usr/sbin/fan_monitor
# fan_monitor
# Utility script to monitor temperatures and run fan at 50%/75%/100%
# For Reference the original Belkin specs.
INTERVAL=20 # sleep time in seconds between temp check
FANLOW=127 # low fan speed, set to 0 for off
FANMID=191 # mid fan speed
FANHI=255 # high fan speed
# Set fan to 100% on >= these temperatures
#CPU_HI=80000 # Belkin default is 85
#DDR_HI=58000 # Belkin default is 65
#WIFI_HI=75000 # Belkin default is 105
# Set fan to 75% <= these, otherwise 100%
CPU_MID=80000 # Belkin sets no default
DDR_MID=58000 # Belkin sets no default
WIFI_MID=75000 # Belkin sets no default
# Set fan to 50% <= these temperatures
CPU_LOW=72000 # Belkin default is 80
DDR_LOW=52000 # Belkin default is 60
WIFI_LOW=55000 # Belkin default is 100
cur_pwm=0
new_pwm="$FANHI" # start fan at HI while coming up
fan_set() {
local ppwm
cur_pwm=$1
if [ "$1" -eq $FANLOW ]; then
ppwm="50%"
elif [ "$1" -eq $FANMID ]; then
ppwm="75%"
else
ppwm="100%"
fi
logger -t FAN_MONITOR "Setting Fan to $ppwm"
echo "$1" > /sys/devices/platform/pwm_fan/hwmon/hwmon0/pwm1
}
# Crank fan on exit
trap "{ logger -t FAN_MONITOR Fan monitor exiting; fan_set $FANHI; logger -t FAN_MONITOR as a precaution; exit; }" SIGINT SIGTERM
# Main fan control loop
while :
do
if [ "$new_pwm" -ne "$cur_pwm" ]
then
fan_set "$new_pwm"
fi
sleep $INTERVAL
cpu=`cat /sys/class/hwmon/hwmon2/temp1_input`
ddr=`cat /sys/class/hwmon/hwmon1/temp1_input`
wifi=`cat /sys/class/hwmon/hwmon1/temp2_input`
if [ "$cpu" -le $CPU_LOW -a "$ddr" -le $DDR_LOW -a "$wifi" -le $WIFI_LOW ]
then
new_pwm="$FANLOW"
elif [ "$cpu" -le $CPU_MID -a "$ddr" -le $DDR_MID -a "$wifi" -le $WIFI_MID ]
then
new_pwm="$FANMID"
else
new_pwm="$FANHI"
fi
done
comment out the fan job in your crontab file, and enable /etc/init.d/fan_control enable; imo better than the other.
Keep meaning to update my github, but sloth gets the better of me
anomeome, Thank you for using some of your time to respond. I did a "first pass" read of the suggestions. First impression. There is more knowledge in the scripts. I need to read /lib/functions.sh and understand $(board_name). Not understanding the Arm processor features and how a "system fan" is supposed to be controlled leads to some "I want to understand more". I will give your suggestions a try, first by "testing/running" each script in verbose mode and then making them part of my configuration. I think I see a fan, but based on what the present script is doing, I am not sure it ever changes fan behavior. I will try using the Main Fan Control Loop to force the fan into HIGH SPEED. Hopefully I will be able to feel the air flow or hear the fan.