当前位置:网站首页>Raspberry pie realizes intelligent cooling by temperature control fan
Raspberry pie realizes intelligent cooling by temperature control fan
2022-06-28 01:56:00 【BluePROT】
Raspberry pie with shell , But he always makes a lot of noise , Then we can transform it , So that he can become a controllable fan , Realize a temperature control function
Materials needed
- triode S8550 PNP type : Two dollars more than fifty
- DuPont bus to bus
- DuPont line male to female
these tb You can buy , There is a shop with parcel post
Then introduce these things
The triode faces the plane towards itself , There are three pins , Left to right are E、B、C. Popular said E It's positive ,C Yes , Equivalent to diode , Base level B Low level is the only way to turn on the circuit .
Then there is the raspberry pie pin , There are forty pins , Here you can see that there are two kinds of codes , When writing code, you need to specify what kind of coding method is available , The corresponding pin is to put the network cable socket of raspberry pie downward , Corresponding pin sequence 
Wiring way
The red color of the fan is the positive pole , Connect to 5V,4 No. pin
Here, connect the triode to the negative pole of the fan , That is, the black line of the fan is connected to the... Of the triode C level
Transistor's E Level connection 6 Pin No , Grounding
Base stage of triode B Connect 8 Interface No , That is to say BCM Coded GPIO 14 Pin No
Start up after connecting , It seems that the fan will be powered on intermittently during startup , No big problem .
After power on , stay python Try to execute the command at the terminal , First, you need to install the library apt install RPi.GPIO
perform python
GPIO_OUT=14
GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)
GPIO.setup(GPIO_OUT,GPIO.OUT,initial=GPIO.HIGH)
self.Status=False
# start-up
GPIO.output(GPIO_OUT,GPIO.LOW)
# close
GPIO.output(GPIO_OUT,GPIO.HIGH)
Then you can execute the following command to check the temperature of raspberry pie , The output value is divided by 1000 Is the current temperature
cat /sys/class/thermal/thermal_zone0/temp
Last , This is a script , The fan can be controlled according to the temperature , The temperature exceeds 50 Open when , lower than 45 Close when , You can set it yourself , You can also set one here
import subprocess
import RPi.GPIO as GPIO
import time
class FanController:
def __init__(self,GPIO_PIN):
self.GPIO_OUT=GPIO_PIN
GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)
GPIO.setup(self.GPIO_OUT,GPIO.OUT,initial=GPIO.HIGH)
self.Status=False
def action(self,flag):
if flag=='start':
GPIO.output(self.GPIO_OUT,GPIO.LOW)
self.Status=True
elif flag=='stop':
GPIO.output(self.GPIO_OUT,GPIO.HIGH)
self.Status=False
def getTemp():
Temp=subprocess.getoutput('cat /sys/class/thermal/thermal_zone0/temp')
Temp=int(Temp)/1000
print(time.strftime('%Y-%m-%d %H:%M-%S')+'\ttemp is %s oC' % (str(Temp)))
return Temp
Fan=FanController(14)
print('start temp controller program')
while True:
Temp=getTemp()
if Temp>50 and not Fan.Status:
print('temp is higher than 50 , fan will start')
Fan.action('start')
elif Temp<45 and Fan.Status:
print('temp is less than 45 , fan will stop')
Fan.action('stop')
time.sleep(15)
Reference link
Raspberry pie — Use triode to control cooling fan
边栏推荐
- Adobe Premiere基础-声音调整(音量矫正,降噪,电话音,音高换挡器,参数均衡器)(十八)
- Implementation of timed tasks in laravel framework
- Drug interaction prediction based on learning size adaptive molecular substructure
- lefse分析本地实现方法带全部安装文件和所有细节,保证成功。
- Some problems in awk
- MapReduce elementary programming practice
- 零基礎多圖詳解圖神經網絡
- 面试官问:JS的this指向
- I/O限制进程与CPU限制进程
- centos8-操作记录-命令版-yum-redis-mysql-nacos-jdk
猜你喜欢

How to optimize the "message" list of IM

什麼是數字化?什麼是數字化轉型?為什麼企業選擇數字化轉型?

Xctf attack and defense world misc wage earner advanced zone

什么是数字化?什么是数字化转型?为什么企业选择数字化转型?

面试官问:JS的继承

Import the data table in MySQL into Excel

Ten thousand words long article understanding business intelligence (BI) | recommended collection

Drug interaction prediction based on learning size adaptive molecular substructure

要搞清楚什么是同步,异步,串行,并行,并发,进程,线程,协程

嵌入式必学!硬件资源接口详解——基于ARM AM335X开发板 (下)
随机推荐
要搞清楚什么是同步,异步,串行,并行,并发,进程,线程,协程
基于AM335X开发板 ARM Cortex-A8——Acontis EtherCAT主站开发案例
PV operation primitive
Google Earth engine (GEE) -- an error caused by the imagecollection (error) traversing the image collection
What problems should be evaluated before implementing MES management system
Review of drug discovery-03-molecular design and optimization
Adobe Premiere Basics - general operations for editing material files (offline files, replacing materials, material labels and grouping, material enabling, convenient adjustment of opacity, project pa
TIA botu_ Concrete method of making analog input and output Global Library Based on SCL language
万字长文看懂商业智能(BI)|推荐收藏
有监督、无监督与半监督学习
9. Openfeign service interface call
The number of nodes of a complete binary tree [non-O (n) solution > Abstract dichotomy]
Original | 2025 to achieve the "five ones" goal! The four products of Jiefang power are officially released
Huawei partners and Developers Conference 2022 | Kirin software cooperates with Huawei to jointly build the computing industry and create a digital intelligence future
Centos8 operation record command version Yum redis MySQL Nacos JDK
如何高效读书学习
PV操作原语
将某数据库N多表名作为另外一张表中某一列得值(范围可以是别的数据库中得某张表)
Qu'est - ce que la numérisation? Qu'est - ce que la transformation numérique? Pourquoi les entreprises choisissent - elles la transformation numérique?
Voice network VQA: make the user's subjective experience of unknown video quality in real-time interaction known