jetson nano 如果安裝風扇,需要自輸入控制指令或者寫程式實作自動控制。
sudo sh -c 'echo 255 > /sys/devices/pwm-fan/target_pwm'
這是風扇火力全開
sudo sh -c 'echo 20 > /sys/devices/pwm-fan/target_pwm'
這是風扇關閉,但是要注意執行關閉風扇指令後風扇并不會立即關閉,而是緩慢慢慢的關閉。用jtop(jtop是個軟體,我見經常有問jtop是什麼的,搜一下就會有下載下傳方法)檢視風扇的轉速,發現他是從100%緩慢降到0的。
但是這種方式有點手工,是以自動控制代碼:
#!/usr/bin/python
import time
while True:
fo = open("/sys/class/thermal/thermal_zone0/temp","r")
#thermal_zone1是cpu的溫度,thermal_zone2是gpu的溫度,thermal_zone0的溫度一直是最高的,可能
#是封裝的溫度,可用jtop檢視具體的資訊
thermal = int(fo.read(10))
fo.close()
thermal = thermal / 1000
if thermal < 60:
thermal = 0
elif thermal >= 60 and thermal < 70:
thermal = thermal - 50
else:
thermal = thermal
thermal = str(thermal)
print thermal
fw=open("/sys/devices/pwm-fan/target_pwm","w")
fw.write(thermal)
fw.close()
time.sleep(60)
執行的時候注意加sudo權限。
#!/usr/bin/python
import time
downThres = 48
upThres = 58
baseThres = 40
ratio = 5
sleepTime = 30
while True:
fo = open("/sys/class/thermal/thermal_zone0/temp","r")
thermal = int(fo.read(10))
fo.close()
thermal = thermal / 1000
if thermal < downThres:
thermal = 0
elif thermal >= downThres and thermal < upThres:
thermal = baseThres + (thermal - downThres) * ratio
else:
thermal = thermal
thermal = str(thermal)
# print thermal
fw=open("/sys/devices/pwm-fan/target_pwm","w")
fw.write(thermal)
fw.close()
time.sleep(sleepTime)