Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
How to control fanspeed on a RN516
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2023-08-15
07:17 AM
2023-08-15
07:17 AM
How to control fanspeed on a RN516
Because the old topic related to the RN104 is no longer repliable and because I used this as my basis before going a little further with this then I will create a new to post my.
#!/bin/bash
## Variables ##
FANPWMPATH=/sys/devices/platform/nct6775.2608/hwmon/hwmon1/pwm1
FANPWMENABLE=/sys/devices/platform/nct6775.2608/hwmon/hwmon1/pwm1_enable
FANSPEEDPATH=/sys/devices/platform/nct6775.2608/hwmon/hwmon1/fan1_input
CORETEMPPATH=/sys/devices/platform/nct6775.2608/hwmon/hwmon1/temp7_input
INTERNALDRIVES=/dev/sd[a-e]
MAXFAN=100 # Maximum operable speed
MINFAN=0 # Minimum operable speed
MINPWM=75 # PWM Limit
MAXPWM=255 # PWM Limit
MINTEMP=40 # Min temp -> Fan slowest
MAXTEMP=75 # Max temp -> Fan fastest
MINTEMPD=35 # Min drive temp -> Fan slowest
MAXTEMPD=60 # Max drive temp -> Fan fastest
NEWSPEED=65 # Initial fan speed (%)
## Functions ##
function getReadings {
FANPWM=$(cat $FANPWMPATH)
FANSPEED=$(cat $FANSPEEDPATH)
CORETEMP=$(cat $CORETEMPPATH)
if [ $CORETEMP -gt 1000 ]; then
CORETEMP=$(expr $CORETEMP / 1000)
fi
DRIVETEMP=$(/sbin/hdparm -H $INTERNALDRIVES | sed -nr 's/[^0-9]*([0-9]+)/\1/p' | sort -r | head -n 1)
echo "$CORETEMP,CPU,$DRIVETEMP,HDD,$(/sbin/hdparm -C $INTERNALDRIVES | grep active | wc -l),ACT,$FANSPEED,FAN" | systemd-cat -t fancontrol -p info
}
function calcFanPercent {
TEMPRAN=$(expr $MAXTEMP - $MINTEMP)
TEMPREL=$(expr $CORETEMP - $MINTEMP)
TEMPPER=$(expr $TEMPREL \* 100 / $TEMPRAN)
NEWSPEED=$TEMPPER
TEMPRAN=$(expr $MAXTEMPD - $MINTEMPD)
TEMPREL=$(expr $DRIVETEMP - $MINTEMPD)
TEMPPER=$(expr $TEMPREL \* 100 / $TEMPRAN)
if [ $TEMPPER -gt $NEWSPEED ]; then
NEWSPEED=$TEMPPER
fi
}
function setFanSpeed {
if [ $NEWSPEED -lt $MINFAN ]; then
NEWSPEED=$MINFAN
fi
if [ $NEWSPEED -gt $MAXFAN ]; then
NEWSPEED=$MAXFAN
fi
NEWPWM=$(expr $MAXPWM - $MINPWM)
NEWPWM=$(expr $NEWPWM \* $NEWSPEED)
NEWPWM=$(expr $NEWPWM / 100)
NEWPWM=$(expr $NEWPWM + $MINPWM)
echo 1 > $FANPWMENABLE
echo $NEWPWM > $FANPWMPATH
}
###################
while true
do
getReadings
calcFanPercent
setFanSpeed
sleep 10
done
###################
Message 1 of 1