× NETGEAR will be terminating ReadyCLOUD service by July 1st, 2023. For more details click here.
Orbi WiFi 7 RBE973
Reply

How to control fanspeed on a RN516

HuwSy
Guide

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
Top Contributors
Discussion stats
  • 0 replies
  • 417 views
  • 0 kudos
  • 1 in conversation
Announcements