当前位置:网站首页>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
边栏推荐
- 混合app的介绍
- pytorch_ lightning. utilities. exceptions. MisconfigurationException: You requested GPUs: [1] But...
- 评价——秩和比综合评价
- What problems should be evaluated before implementing MES management system
- Ten thousand words long article understanding business intelligence (BI) | recommended collection
- 学习 pickle
- Solon 1.8.3 release, cloud native microservice development framework
- style中的scoped属性和lang属性
- Review of drug discovery-03-molecular design and optimization
- TIA botu_ Concrete method of making analog input and output Global Library Based on SCL language
猜你喜欢

万字长文看懂商业智能(BI)|推荐收藏

LMSOC:一种对社会敏感的预训练方法

Interviewer asked: Inheritance of JS
![完全二叉树的节点个数[非O(n)求法 -> 抽象二分]](/img/56/768f8be9f70bf751f176e40cbb1df2.png)
完全二叉树的节点个数[非O(n)求法 -> 抽象二分]

Adobe Premiere foundation - sound adjustment (volume correction, noise reduction, telephone tone, pitch shifter, parameter equalizer) (XVIII)

9. Openfeign service interface call

Overview of drug discovery-01 overview of drug discovery

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

Xctf attack and defense world misc wage earner advanced zone

【ELT.ZIP】OpenHarmony啃论文俱乐部—数据密集型应用内存压缩
随机推荐
嵌入式必学,硬件资源接口详解——基于ARM AM335X开发板 (上)
【牛客討論區】第四章:Redis
205. 同构字符串
Golang monkeys eat peaches and ask for the number of peaches on the first day
[Yocto RM]1 - System Requirements
ionic4实现半星评分
国外LEAD赚钱的一些习惯
Data analysts too hot? Monthly income 3W? Tell you the true situation of this industry with data
向excel中导入mysql中的数据表
766. toplitz matrix
MySQL - function
混合app的介绍
Supervised, unsupervised and semi supervised learning
Web3 technology initial experience and related learning materials
Adobe Premiere基础-声音调整(音量矫正,降噪,电话音,音高换挡器,参数均衡器)(十八)
I/o limit process and CPU limit process
同花顺上能炒股开户吗?安全吗?
Review of drug discovery-03-molecular design and optimization
What problems should be evaluated before implementing MES management system
将某数据库N多表名作为另外一张表中某一列得值(范围可以是别的数据库中得某张表)