jetson nano|折腾日志

一、jetson nano 风扇降温

2020-5-10 0:23 风雨敲窗櫺

1. 手动设定风扇转速终端命令

  • 全速
sudo sh -c 'echo 255 > /sys/devices/pwm-fan/target_pwm'
  • 停止(注意,是从当前速度缓慢降到0,减速过程为1分钟)
sudo sh -c 'echo 20 > /sys/devices/pwm-fan/target_pwm'

2. 根据CPU温度自动调节风扇转速

注意:以下程序的条件可根据需要自行更改。

# 源地址:https://blog.csdn.net/bornfree5511/article/details/103076414
#!/usr/bin/python
#~/fan_control.py
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 < 30: 
        thermal = 0
    elif thermal >= 30 and thermal < 70:
        thermal = thermal - 30
    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)

3. 开机自启动

参照ubuntu实现python脚本后台运行+开机自启

1.建立rc-local.service文件

sudo gedit /etc/systemd/system/rc-local.service

2.将下列内容替换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

3.创建文件rc.local

sudo gedit /etc/rc.local

4.将下列内容复制进rc.local文件

#!/bin/sh -e
# rc.local
nohup sudo python ~/fan_control.py > /usr/local/out.log 2>&1 &
exit 0

5.Ubuntu系统 sudo指令免密码

sudo gedit /etc/sudoers

%sudo ALL=(ALL:ALL) ALL 修改为%sudo ALL=(ALL) NOPASSWD:ALL

请仔细操作!
6.给rc.local加上权限

sudo chmod +x /etc/rc.local

7.启用服务

sudo systemctl enable rc-local

8.启动服务并检查状态

sudo systemctl start rc-local.service
sudo systemctl status rc-local.service

9.重启并检查是否成功

reboot

如果风扇自动转了起来,说明成功。

二、I2C总线之OLED屏显示

1. jetracer扩展板

在某宝上找到基于jetson nano的小车,有两款:1)jetbot;2)jetracer。jetbot利用差速驱动转向,jetracer则是迷你版的无人车(几何运动学模型为阿克曼轮转向模型)。后者是我想要的。jetracer很好,唯一不足的是,电机不带编码器,在之后的功能上有所缺失(无法得到较准确的里程计信息)。于是:我只购买了jetracer扩展板、锂电池组。

在这里插入图片描述

2.I2C总线

jetson nano总共有2组I2C总线,分别为(I2C BUS 1: 3,5)(I2C BUS 2: 27,28)。I2C总线的引脚在J41,也即那两排密集的引脚区。
在这里插入图片描述
查看总线1的设备

sudo i2cdetect -y -r 1

在这里插入图片描述
其中,3c就是OLED的I2C设备地址。

OLED显示

由于jetracer扩展板上使用的是SSD1306的0.91inch OLED屏幕,所以需要先安装Adafruit_SSD1306

sudo pip3 install Adafruit_SSD1306

由于OLED显示的示例程序在jetbot上,所以先安装jetbot.

git clone https://github.com/NVIDIA-AI-IOT/jetbot.git
cd jetbot
python3 setup.py build
sudo python3 setup.py install --record jetbot.uninstall.txt

如果需要卸载jetbot,可以在jetbot根目录下执行:

sudo cat jetbot.uninstall.txt | sudo xargs rm -rf

所以,最好保留jetbot.uninstall.txt文件。

运行程序:

cd jetbot/jetbot/apps/
sudo python3 stats.py

会看到OLED显示了以太网,wlan,内存与存储等信息。
在这里插入图片描述

在另一家店里挑了一款不带控制器的迷你小车(带编码的电机,舵机)。那家店里,也有带控制器的(买来直接能用游戏手柄控制运动的那种)。由于,车本来就很小,211 x 191 x 65mm。如果系统用两个计算板子,车体肯定很臃肿。我想把所有的全集中在jetson nano上,就像jetracer一样。在这里插入图片描述
Jetson Nano I2C说明及Python案例:MPU6050

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章