樹莓派 Pi 4 Model B 壓克力外殼
原始網址: https://ec.makehub.tw/spot/rpi4b-enc-rpi4b-fan-enc
2019新版經典壓克力外殼適用Raspberry Pi4B
商品包含:
拿到貨時,壓克力板上有一層保護作用的黃色膠紙,撕掉後就是透明的了。
1、外殼*1套
2、固定RPi的螺絲包*1個(不建議上螺絲,可能會弄巧成拙)
3、風扇
如下圖所示(沒撕掉保護紙模樣,收到貨後便是如此,撕掉即可看到是透明的):
4、T9 風扇控制模塊TCFan Raspberry Pi 5V PWM 溫控控制轉速
適用任何Raspberry Pi版,特別Pi4B這種對散熱需求非常的型號。
可配套使用外殼(風扇需要安裝在外殼頂部,否則稍有抵觸)
模塊上引出了兩個獨立的5V,以及1個GPIO3針腳。
風扇速度控制範例程式 1(隨溫度加快轉速):
#!/usr/bin/env python
# encoding: utf-8
# From:shumeipai.net
import RPi.GPIO
import time
start = 40
stop = 27
RPi.GPIO.setwarnings(False)
RPi.GPIO.setmode(RPi.GPIO.BCM)
RPi.GPIO.setup(2, RPi.GPIO.OUT)
pwm = RPi.GPIO.PWM(2,100)
fan = False
try:
while True:
with open('/sys/class/thermal/thermal_zone0/temp') as f:
cur = int(f.read()) / 1000
now = time.strftime("%H:%M:%S",time.localtime(time.time()))
if not fan and cur >= start:
pwm.start(100)
fan = True
print("[%s] Fan on @ %s" % (now, cur))
if fan and cur <= stop:
pwm.stop()
fan = Fale
print("[%s] Fan off @ %s" % (now, cur))
time.sleep(1)
except KeyboardInterrupt:
pwm.stop()
風扇速度控制範例程式 2(超過 Threshold 值後開啟風扇):
#!/usr/bin/env python
# encoding: utf-8
import RPi.GPIO
import time
RPi.GPIO.setwarnings(False)
RPi.GPIO.setmode(RPi.GPIO.BCM)
RPi.GPIO.setup(2, RPi.GPIO.OUT)
pwm = RPi.GPIO.PWM(2,100)
RPi.GPIO.setwarnings(False)
speed = 0
prv_temp = 0
try:
while True:
tmpFile = open( '/sys/class/thermal/thermal_zone0/temp' )
cpu_temp = int(tmpFile.read())
tmpFile.close()
if cpu_temp>=34500 :
if prv_temp<34500 :
#啟動時防止風扇卡死先全功率轉 0.1 秒
pwm.start(0)
pwm.ChangeDutyCycle(100)
time.sleep(.1)
speed = min( cpu_temp/125-257 , 100 )
pwm.ChangeDutyCycle(speed)
else :
pwm.stop()
prv_temp = cpu_temp
time.sleep(5)
except KeyboardInterrupt:
pass
pwm.stop()