目标

为大负荷时高温Orangepi Zero2 板子降温,增加一个可控的自动启停的5V风扇。

Orange Pi Zero2

香橙派是一款开源的单板卡片电脑,新一代的arm64开发板,它可以运行Android TV 10、Ubuntu 和 Debian 等操作系统。香橙派开发板(Orange Pi Zero 2)使用全志H616 系统级芯片,同时拥有 1GB DDR3 内存。

Orange-Pi-Zero-2-的硬件特性

硬件特性

顶层视图

顶层视图

底层视图

底层视图

Orange-Pi-Zero-2-开发板-26-pin-接口引脚的功能

Orange-Pi-Zero-2-开发板-26-pin-接口引脚的功能

连接

连接

代码

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# 在oangepi zero2 上实验通过
import os
import time
import configparser

# 采用wpi编号, 对应orangepi zero2 的pin 7 (gpio)
FAN_GPIO = 2
os.system('gpio mode '+str(FAN_GPIO)+' out')

while True:
# temp_hight = 50
# temp_low =49
# monitor_interval = 10
# opi_fan_auto = off
# 以上参数亦可来自某个配置文件,如下所示
cf = configparser.ConfigParser()
cf.read("Config.ini")
temp_hight = int(cf.get("fan", "temp_hight"))
temp_low = int(cf.get("fan", "temp_low"))
monitor_interval = int(cf.get("fan", "monitor_interval"))
opi_fan_auto = cf.get("fan", "opi_fan_auto")

if opi_fan_auto == "on":
# get cpu temp
temp=os.popen('cat /sys/class/thermal/thermal_zone0/temp').readlines()[0]
cpu_temp=int(temp)/1000

#print("cpu temp: "+str(cpu_temp))
current_time = time.strftime("%Y-%m-%d %H:%M:%S",time.localtime())

if cpu_temp >= temp_hight:
os.system('gpio write '+str(FAN_GPIO)+' 0')
print("Time:{}\tCPU Temp:{}\t\tFan Status:{}".format(current_time, cpu_temp, 'Running'))

if cpu_temp <= temp_low:
os.system('gpio write '+str(FAN_GPIO)+' 1')
print("Time:{}\tCPU Temp:{}\t\tFan Status:{}".format(current_time, cpu_temp, 'Stopped'))

time.sleep(monitor_interval)

集成

集成

参考