当前位置:网站首页>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
边栏推荐
猜你喜欢
向excel中导入mysql中的数据表
数据库查询优化:主从读写分离及常见问题
. Mp4 video test address
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
Voice network VQA: make the user's subjective experience of unknown video quality in real-time interaction known
Ten thousand words long article understanding business intelligence (BI) | recommended collection
基于AM335X开发板 ARM Cortex-A8——Acontis EtherCAT主站开发案例
Qu'est - ce que la numérisation? Qu'est - ce que la transformation numérique? Pourquoi les entreprises choisissent - elles la transformation numérique?
[description] solution to JMeter garbled code
Self supervised learning and drug discovery
随机推荐
【牛客討論區】第四章:Redis
Web3 技术初体验以及相关学习资料
Set collection usage
有监督、无监督与半监督学习
Adobe Premiere Basics - common video effects (cropping, black and white, clip speed, mirroring, lens halo) (XV)
Lefse analyzes the local implementation method with all installation files and details to ensure success.
模块化开发
声网 VQA:将实时互动中未知的视频画质用户主观体验变可知
MySQL十种锁,一篇文章带你全解析
【嵌入式基础】内存(Cache,RAM,ROM,Flash)
什么是数字化?什么是数字化转型?为什么企业选择数字化转型?
Chapitre 4: redis
Data analysts too hot? Monthly income 3W? Tell you the true situation of this industry with data
[Yocto RM]9 - QA Error and Warning Messages
The research group of Xuyong and duanwenhui of Tsinghua University has developed an efficient and accurate first principles electronic structure deep learning method and program
[DNS resolution] set the name DNSPod resolution for domain name access of COM
I/O限制进程与CPU限制进程
Capacitor
OS模块与OS.path 模块的学习
【ELT.ZIP】OpenHarmony啃论文俱乐部—数据密集型应用内存压缩