Posted: Sun Jan 21, 2018 3:19 Post subject: Temperature controlled cooling fan (usb powered) on R7000
I’m mainly typing this up for my own reference, but since I’d never keep it filed anywhere logical I figured it’d be best to throw it to the web and let google look after it.
I decided my R7000 was getting to hot running constantly at 70C, so I purchased a cheap USB powered laptop cooler to sit it on. Works a treat, easily dropping temp by >10C. Then I decided I wanted it to be temperature controlled.
Apparently you’re supposed to be able to issue commands like
Code:
echo on > /sys/bus/usb/devices/usb1/power/level
or /sys/bus/usb/devices/usbX/power/autosuspend_delay_ms
depending on kernel version and control the power to specific USB ports. However, the /power sub-directory doesn’t appear to exist under any of the usb devices for my installation.
After spending hours trying many variants on that theme, I realised the port powered on and off when enabling/disabling “Core USB Support” in the web GUI under Services > USB, so I looked up the USB related nvramoptions and found “usb_enable”. Sadly, using nvram set usb_enable 1 wouldn’t immediately apply the change, even when followed by a nvram commit. I couldn’t find any way to get it to apply on demand like you can in the GUI. So that lead ran dry.
Eventually I came across the gpio approach as a possibility. As most of us know it’s the way we kill most of the LEDs to stop the router blinding us at night. I tried playing around with every gpio number that wasn’t already listed as identified, but none seemed to do anything.
Then I remembered 0 is a number too.
Fortunately gpio 0 is power to the usb, so using gpio enable 0 and gpio disable 0 I can power on and off the fan. It’s a bit ham-fisted as it takes out both ports, so you can’t have anything useful plugged in the other one, but since I don’t it works for me.
If anyone knows a way to target just one of the ports then please let us know!
Here’s the script I made, there’s probably a more elegant way of doing this, so let me know that too…
Code:
# TURN FAN ON (I.E. USB POWER) WHEN ROUTER IS HOT
usbgpiopin=0
#Temperature above which to turn on fan (650 = 65C)
hightemp=650
#Turn fan back off when temperature gets below (600 = 60C)
lowtemp=600
gpio disable usbgpiopin #get it to a known state before we start
while [ 0 ];do
temp=$(cat /proc/dmu/temperature) #Get temperature
if [ $temp -gt $hightemp ];then #power on if greater than high temp
gpio enable usbgpiopin
echo $(date) "FAN ON" >> /tmp/var/log/messages
while [ $temp -gt $lowtemp ];do
sleep 10
temp=$(cat /proc/dmu/temperature) #Get temperature
done
gpio disable usbgpiopin #power off now we're less than low temp
echo $(date) "FAN OFF" >> /tmp/var/log/messages
fi
sleep 10 #wait 10s before checking temps again
done
Last edited by jase80 on Sun Jan 21, 2018 18:40; edited 1 time in total
Posted: Sun Jan 21, 2018 12:58 Post subject: Re: Temperature controlled cooling fan (usb powered) on R700
jase80 wrote:
I decided my R7000 was getting to hot running constantly at 70C,
You decided haha... So funny. Indeed you did it because you were bored (and because you have no clue about thermal specs on these chips architecture), it has no use at all. _________________ R6400v2 (boardID:30) - Kong 36480 running since 03/09/18 - (AP - DNSMasq - AdBlocking - QoS) R7800 - BS 31924 running since 05/26/17 - (AP - OpenVPN Client - DNSMasq - AdBlocking - QoS) R7000 - BS 30771 running since 12/16/16 - (AP - NAS - FTP - SMB - OpenVPN Server - Transmission - DDNS - DNSMasq - AdBlocking - QoS) R6250 - BS 29193 running since 03/20/16 - (AP - NAS - FTP - SMB - DNSMasq - AdBlocking)
Last edited by Xeon2k8 on Sun Jan 21, 2018 14:47; edited 1 time in total
It's usually a good sign you're doing something useless when you don't find anything about it in your web searches...
I did note that 70C is well within operating range, however with 43C days coming here and 70C showing when I thought the thing was under base load I embarked on my little learning exercise.
If nothing else I've learnt more about hot this thing operates!
Interesting and I presume is something neat. However I have found that just keeping a laptop cooler running 24/7 is simple and keeps the router cooler at all times. Rather then relying upon a temp to be reached and trigger additional cooling, I find it more simple to just have the fan running all the time. Most routers are designed well and work with the design and cooling them selves as long as placement is good and good air flow is available. However over the years working with electronics and routers, I've found that having additional external air flow doesn't hurt either. Heat eventually has a impact on electronics and slowly degrades components. Having additional cooling is good too.
I just have a laptop cooler which came with variable fan speed and keep it on all the time.
Interesting and I presume is something neat. However I have found that just keeping a laptop cooler running 24/7 is simple and keeps the router cooler at all times.
You're not wrong! The noise bothered me and I let myself go down this rabbit hole... Specifically I don't want the fan resonating away overnight if it doesn't need to be. And yeah, maybe it isn't even needed on hot days under high load.
Hopefully the fact I've documented the gpio 0 thing will be useful to someone for something in the future as it's not something I could find elsewhere.
Doesn't need to be triggered by temperature, and it doesn't need to be a fan that's powered on and off by the USB.
Well seems to me you could have accomplished the same thing by buying a temperature controlled fan with an external thermistor and mounting the thermistor on the CPU but each to his own!!!
There are a lot of examples online of people going overkill on cooling that just is not needed. Raspberry Pis are good example. You see multiple examples of people heatsinking the hell out of them when it just is not needed.
So what I'm hearing is I should control a cooling system for the router (which doesn't need cooling) with an overclocked raspberry pi that in turn needs a cooling system...
tedm wrote:
Well seems to me you could have accomplished the same thing by buying a temperature controlled fan with an external thermistor and mounting the thermistor on the CPU but each to his own!!!
Yeah, I just plugged in a fan and wrote a script. Didn't have to touch a screw. :p
So what I'm hearing is I should control a cooling system for the router (which doesn't need cooling) with an overclocked raspberry pi that in turn needs a cooling system...
Lol, nicely done.
What I read is...now that you've dropped the temp more than 10degC, you need to overclock and get the temp back up to spec! _________________ #NAT/SFE/CTF: limited speed w/ DD#Repeater issues#DD-WRT info: FAQ, Builds, Types, Modes, Changes, Demo#
OPNsense x64 5050e ITX|DD: DIR-810L, 2*EA6900@1GHz, R6300v1, RT-N66U@663, WNDR4000@533, E1500@353,
WRT54G{Lv1.1,Sv6}@250|FreshTomato: F7D8302@532|OpenWRT: F9K1119v1, RT-ACRH13, R6220, WNDR3700v4
so how often and for how long does the fan cycle on/off now?
its a cool idea for a project (no pun intended) if for nothing else then to learn something.
besides, regardless of what the thermal specs of that one chip say, the heat is going to affect other components on the board also. capacitors in particular can have a lifetime directly affected by temperature.
I can't understand why so much criticism for something that's actually useful.
The critics should know, for example, that an AC68U (BCM4708A0), witch has a Tj Max of 130ºC, becomes unstable above 90ºC. Many reports of this at SNB... What's causing it? CPU? The neighboring components?
@jase80
I have no suggestion to improve your code, and for that reason, I just want to thank you for sharing your findings. I am using your script.
Joined: 26 Mar 2013 Posts: 1858 Location: Hung Hom, Hong Kong
Posted: Sun Sep 20, 2020 20:30 Post subject: Re: Temperature controlled cooling fan (usb powered) on R700
jase80 wrote:
Code:
# TURN FAN ON (I.E. USB POWER) WHEN ROUTER IS HOT
usbgpiopin=0
#Temperature above which to turn on fan (650 = 65C)
hightemp=650
#Turn fan back off when temperature gets below (600 = 60C)
lowtemp=600
gpio disable usbgpiopin #get it to a known state before we start
while [ 0 ];do
temp=$(cat /proc/dmu/temperature) #Get temperature
if [ $temp -gt $hightemp ];then #power on if greater than high temp
gpio enable usbgpiopin
echo $(date) "FAN ON" >> /tmp/var/log/messages
while [ $temp -gt $lowtemp ];do
sleep 10
temp=$(cat /proc/dmu/temperature) #Get temperature
done
gpio disable usbgpiopin #power off now we're less than low temp
echo $(date) "FAN OFF" >> /tmp/var/log/messages
fi
sleep 10 #wait 10s before checking temps again
done
There are never too many scripts! Submit your work to:
Joined: 31 Jul 2021 Posts: 2146 Location: All over YOUR webs
Posted: Wed Sep 01, 2021 10:00 Post subject:
This script as was posted above doesn't work on my router and contains a few issues mainly the usage of variables is wrong and gpio pin is router/usbport dependent.
The main issue is that the USBGPIOPIN is different, you can find out what your gpiopin is exactly by running nvram show | grep gpio and modding the USBGPIOPIN value accordingly.
Here is the modded script which contains formatting to run directly in terminal (ssh)
For Asus RT-AC68U connected to USB 2.0 port.
If you connect to USB 3.0 port will be a different gpio pin.
The script below has messages / formatting to be used on an active terminal session and spits outs the output nicely formatted, if you dont need this functionality just comment out the messages block.
Ive not included syslog messages, too much spam IMO but easily added if you want to.
Code:
#!/bin/sh
#set -o pipefail
set +x
# License MIT https://mit-license.org/
USBGPIOPIN=9
#Temperature above which to turn on fan (650 = 65°C)
HIGHTEMP=612
#Turn fan off when temperature gets below (500 = 50°C)
LOWTEMP=512
FIVED=50
DEC () {
echo "+-------------------------------------+"
}
# Set it to a known state before we start
gpio disable $USBGPIOPIN
#TEMP=$(cat /proc/dmu/temperature) #Get temperature
WAIT() {
sleep 10
}
# add comma separator to temperature values
CLEAN() {
sed -r 's/([0-9]{2})/\1./g' | sed 's/^,//'
}
MESSAGE() {
clear
DEC
echo " tempCTL | Temperature:" "$TEMP" "C" | CLEAN
DEC
#echo "" > nohup.out
echo "FAN ON @: "$HIGHTEMP 'C' | CLEAN
echo "FAN OFF @: "$LOWTEMP 'C' | CLEAN
PLUSF
DEC
}
PLUSF() {
# On starting script dont start fans
# unless we are at 5 degrees over $LOWTEMP
MINTON=$((LOWTEMP + FIVED))
echo MIN START: "$MINTON" C != "$TEMP" C | CLEAN
}
while true
do
TEMP=$(cat /proc/dmu/temperature)
if [ "$TEMP" -gt "$HIGHTEMP" ] || [ "$TEMP" -gt "$MINTON" ]
then
gpio enable $USBGPIOPIN
MESSAGE
echo "$(date +"%b %d %X"): Triggering FAN ON"
while [ "$TEMP" -gt "$LOWTEMP" ]
do
WAIT
TEMP=$(cat /proc/dmu/temperature)
done
else
gpio disable $USBGPIOPIN
MESSAGE
echo "$(date +"%b %d %X"): Triggering FAN OFF"
fi
TEMP=$(cat /proc/dmu/temperature)
echo "$TEMP" "C" | CLEAN
WAIT
done
There are some caveats, CPU usage by script when the USB is activated FAN ON is around 8%, while OFF its 0.1%, I've no idea how to fix this in script if its a script issue, makes no sense to me.