jetson nano 自动调节风扇转速

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权限。

可以看我另一篇文章,免sudo输入密码操作,可以最简单的实现开机自启,免sudo密码后,打开ubuntu自带的启动应用程序软件,直接添加 sudo xxx.py就可以开机运行了。

2020-6-1更新:

#!/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)

 

  • 2
    点赞
  • 33
    收藏
    觉得还不错? 一键收藏
  • 7
    评论
评论 7
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值