树莓派集群外接散热电源

提供外接电源并可控制散热风扇开关的电路板

tinom

喜欢

4340
浏览
1
喜欢

> 更多图片

项目状态:已完成
开放度:公开
所属分类:电子
发布时间:2017-09-24
最近更新:2017-09-24

标签

描述

我有一3个树莓派的小集群,为提供可调节的风扇散热控制焊接了一个外接的电源,并加入了三极管开关电路,从树莓派引出控制电路。


详细说明

使用的是从树梅派的GPIO的7脚引出控制电路
我把三极管的正负极接翻了,但它还是依然工作了。

#!/usr/bin/python
# -*-coding:utf-8 -*-
# use python 2.7
import RPi.GPIO as GPIO
import time  # 导入time模块
import commands

GPIO.setmode(GPIO.BOARD)    #gpio采用board编号
GPIO.setup(7, GPIO.IN)    #7口输入
cpu_temp = 0  # 温度变量
gpu_temp = 0  # 温度变量
fan = "OFF"  # 风扇变量

def get_cpu_temp(): 
    file = open( "/sys/class/thermal/thermal_zone0/temp" )  # 打开CPU温度缓存文件
    cpu_temp = float( file.read( ) ) / 1000  # 读取结果,并转换为浮点数/1000
    file.close( )  # 关闭文件
    return cpu_temp
    
def get_gpu_temp():
    gpu_temp = commands.getoutput( '/opt/vc/bin/vcgencmd measure_temp' ).replace( 'temp=', '' ).replace( '\'C', '' )
    return float(gpu_temp)
    
while (1):  # 此处设置循环
    cpu_temp = str(get_cpu_temp())
    gpu_temp = str(get_cpu_temp())
    if ( cpu_temp > 50 and fan == "OFF"):  # 如果>50C
        GPIO.setup(7, GPIO.OUT, initial=GPIO.LOW) #7口输出
        fan = "ON"
    elif( cpu_temp < 40 and fan == "ON" ):    #如果小于40度
        GPIO.setup(7, GPIO.IN)  #7口输入,就是不输出了呗,因为高电平低电平都能驱动三极管。
        fan = "OFF"
    timenow = time.strftime( "%H:%M:%S", time.localtime( ) )  # 时间
    print timenow + " CPU temp:" + cpu_temp + "C ; GPU temp:" + gpu_temp + "C ; FAN is " + fan  # 时间+温度
    time.sleep(10)  # 间隔10秒

原理图
洞洞板图
添加图片描述
实景图
实景图
实景图
实景图
实景图
实景图
实景图
实景图
实景图

链接表


教程

使用的是从树梅派的GPIO的7脚引出控制电路

#!/usr/bin/python
# -*-coding:utf-8 -*-
# use python 2.7
import RPi.GPIO as GPIO
import time  # 导入time模块
import commands

GPIO.setmode(GPIO.BOARD)    #gpio采用board编号
GPIO.setup(7, GPIO.IN)    #7口输入
cpu_temp = 0  # 温度变量
gpu_temp = 0  # 温度变量
fan = "OFF"  # 风扇变量

def get_cpu_temp(): 
    file = open( "/sys/class/thermal/thermal_zone0/temp" )  # 打开CPU温度缓存文件
    cpu_temp = float( file.read( ) ) / 1000  # 读取结果,并转换为浮点数/1000
    file.close( )  # 关闭文件
    return cpu_temp
    
def get_gpu_temp():
    gpu_temp = commands.getoutput( '/opt/vc/bin/vcgencmd measure_temp' ).replace( 'temp=', '' ).replace( '\'C', '' )
    return float(gpu_temp)
    
while (1):  # 此处设置循环
    cpu_temp = str(get_cpu_temp())
    gpu_temp = str(get_cpu_temp())
    if ( cpu_temp > 50 and fan == "OFF"):  # 如果>50C
        GPIO.setup(7, GPIO.OUT, initial=GPIO.LOW) #7口输出
        fan = "ON"
    elif( cpu_temp < 40 and fan == "ON" ):    #如果小于40度
        GPIO.setup(7, GPIO.IN)  #7口输入,就是不输出了呗,因为高电平低电平都能驱动三极管。
        fan = "OFF"
    timenow = time.strftime( "%H:%M:%S", time.localtime( ) )  # 时间
    print timenow + " CPU temp:" + cpu_temp + "C ; GPU temp:" + gpu_temp + "C ; FAN is " + fan  # 时间+温度
    time.sleep(10)  # 间隔10秒

原理图
洞洞板图
实景图
实景图
实景图
实景图
实景图
实景图
实景图
实景图
实景图