概述
jetson nano一定要配一个可调风扇,jetson nano散热不好极容易死机!!
一、临时调试
PWM范围:0-255 0为停止,255最大
sudo sh -c 'echo 255 > /sys/devices/pwm-fan/target_pwm'
二、驱动脚本
#!/usr/bin/python
# -*- coding: UTF-8 -*-
#临时改变风速 PWM范围:0-255
#sudo sh -c 'echo 255 > /sys/devices/pwm-fan/target_pwm'
#查看风扇PWM
#sudo jetson_clocks --show
import time
downThres = 25 #触发最低温度
upThres = 45 #超过阈值风扇全开
pwm = 0 #当前PWM值
basePwm = 100 #pwm基础值
ratio = (255-basePwm) / (upThres-downThres) #温度上升转pwm因数
sleepTime = 20 #执行间隔
while True:
fo = open("/sys/class/thermal/thermal_zone0/temp","r")
thermal = int(fo.read(10))
fo.close()
thermal = thermal / 1000
if thermal < downThres:
pwm = 0
else:
pwm = basePwm + (thermal - downThres) * ratio
pwm = str(pwm)
print "T:",thermal,"PWM:",pwm
fw=open("/sys/devices/pwm-fan/target_pwm","w")
fw.write(pwm)
fw.close()
time.sleep(sleepTime)
三.开机启动
- 建立rc-local.service文件
sudo vi /etc/systemd/system/rc-local.service
- 将下列内容复制进rc-local.service文件
[Unit]
Description=/etc/rc.local Compatibility
ConditionPathExists=/etc/rc.local
[Service]
Type=forking
ExecStart=/etc/rc.local start
TimeoutSec=0
StandardOutput=tty
RemainAfterExit=yes
SysVStartPriority=99
[Install]
WantedBy=multi-user.target
- 创建文件rc.local
sudo vi /etc/rc.local
- 将下列内容复制进rc.local文件(注:用户名修改路径为自己电脑路径!!!)
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution# bits.
#
# By default this script does nothing.
./home/<改为自己用户名>/ssh/fan-start.py & > /usr/local/test.log
exit 0
~
- 给rc.local加上权限
sudo chmod +x /etc/rc.local
- 启用服务
sudo systemctl enable rc-local
- 启动服务并检查状态
sudo systemctl start rc-local.service
sudo systemctl status rc-local.service
- 重启并检查test.log文件
cat /usr/local/test.log