jetson nano 风扇自动调速

jetson nano 风扇自动调速

概述

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)

三.开机启动

  1. 建立rc-local.service文件
sudo vi /etc/systemd/system/rc-local.service
  1. 将下列内容复制进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
  1. 创建文件rc.local
sudo vi /etc/rc.local
  1. 将下列内容复制进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
~       

在这里插入图片描述

  1. 给rc.local加上权限
sudo chmod +x /etc/rc.local
  1. 启用服务
sudo systemctl enable rc-local
  1. 启动服务并检查状态
sudo systemctl start rc-local.service
sudo systemctl status rc-local.service
  1. 重启并检查test.log文件
cat /usr/local/test.log
  • 5
    点赞
  • 40
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值