Raspberry Pi Box of Cooling FAN With CPU Temperature Indicator
by jandb86 in Circuits > Raspberry Pi
1355 Views, 21 Favorites, 0 Comments
Raspberry Pi Box of Cooling FAN With CPU Temperature Indicator
I had introduced raspberry pi (Hereinafter as RPI) CPU temperature indicator circuit in the previous project.
The circuit is simply showing RPI 4 different CPU temperature level as follows.
- Green LED turned on when CPU temperature is within 30~39 degree
- Yellow LED indicates temperature is increased in range of 40 to 45 degree
- 3rd Red LED shows CPU become a little bit hot by reaching 46 ~ 49 degree
- Another Red LED will blink when temperature is exceeding more than 50 degree
***
When temperature is exceeding more than 50C, any help shall be necessary for little RPI does not stressed too much.
According to the information I saw at several web pages which are talking about maximum tolerable temperature level of RPI, opinions are diverse such as someone mention that more than 60C is still quite OK when heat-sink is used.
But my personal experience say something different that transmission server (using RPI with heat-sink) become slow and finally acting like zombie when I’m turning it on for several hours.
Therefore this additional circuit and cooling FAN is added for regulating CPU temperature under 50C for supporting stable operation of RPI.
***
Also previously introduced CPU temperature indicator circuit (Hereinafter as INDICATOR) is integrated together to support convenient temperature level check without executing “vcgencmd measure_temp” command on console terminal.
Preparing Schematics
In two previous projects, I had mentioned complete isolation of power supply between RPI and external circuits.
In case of cooling FAN, independent power supply is quite important as DC 5V FAN(motor) is relatively heavy load and quite noisy while operation.
Therefore, the following considerations are emphasized for designing this circuit.
- Opto-couplers is used to interface with RPI GPIO pin to get cooling FAN activating signal
- No power drawn from RPI and using common hand-phone charger for power source of this circuit.
- LED indicator is used for informing cooling FAN operation
- 5V relay is used for activating cooling FAN as mechanical manner
***
This circuit will inter-operate with CPU temperature indicator circuit (Hereinafter INDICATOR) by mean of python program control.
When INDICATOR start blinking (temperature is exceeding 50C), this cooling FAN circuit shall start operating.
Preparing Parts
Like other previous projects, very common components are used for making cooling FAN circuit as listed below.
- Opto-coupler: PC817 (SHARP) x 1
- 2N3904 (NPN) x 1, BD139 (NPN) x 1
- TQ2-5V (Panasonic) 5V relay
- 1N4148 diode
- Resistors(1/4Watt): 220ohm x 2 (current limiting), 2.2K (Transistor switching) x 2
- LED x 1
- 5V cooling FAN 200mA
- Universal board more than 20(W) by 20(H) holes size (You can cut any size of universal board to fit circuit)
- Tin wire (Please refer my “Raspberry Pi shutdown indicator” project posting for more detail of tin wire usage)
- Cable (red and blue common single wire cable)
- Any hand-phone charger 220V input and 5V output (USB type B connector)
- Pin head (3 pins) x 2
***
Cooling FAN’s physical dimension should be small enough to be mounted on the top of RPI.
Any type of relay can be used when it can operate at 5V and have more than one mechanical contact.
Making PCB Drawing
As number of components is small, required universal PCB size is not big.
Please take cares the pin polarity layout of TQ2-5V as shown in the picture above. (Contrary to the conventional thinking, actual plus/ground layout is reversely arranged)
Personally I have unexpected problem after soldering due to the reversely located (When comparing with other relay products) polarity pins of TQ2-5V.
Soldering
As circuit itself is quite simple, wiring pattern is not much complex.
I’m bolting “L” shape mounting bracket to fix PCB as upright direction.
As you can see later, acrylic chassis which mounting everything is sized a little bit small.
Therefore, narrowing foot print is necessary as acrylic chassis is very crowded with PCBs and other sub-parts.
LED is located to the front side for easily recognizing FAN operation.
Making and Mounting Cooling FAN HAT
I’m supposing universal PCB is very useful part which can be used for diverse usage purpose.
Cooling FAN is mounted on universal PCB and mounted and fixed with bolts and nuts.
For allowing air flow, I’m making big hole by drilling PCB.
Also for easy plugging jumper cables, GIPO 40 pins area is opened by cutting PCB.
Assemble PCBs
As mentioned above, I planned to consolidate two different circuits into single unit.
Previously made CPU temperature indicator circuit is merged with new cooling FAN circuit as shown in the picture above.,
Everything is packed together into transparent and small size of (15cm W x 10cm D) acrylic chassis.
Although about half of chassis space is empty and available, additional component will be housed to the remained space later.
Wiring RPI With Circuits
Two circuits are interconnected with RPI as isolated manner using opto-couplers.
Also no power is drawn from RPI as external hand-phone charger supply power to the circuits.
Later you will know this kind of isolated interface scheme is quite pay-off when additional components are integrated more to the acrylic chassis later.
Python Program Control All Circuits
Only minor addition of code is required from the source code of CPU temperature indicator circuit.
When temperature is exceeding 50C, twenty (20) iteration of turning on FAN for 10 second and turn off 3 second is starting.
As small motor of FAN requires maximum 200mA of current during operation, PWM (Pulse Width Modulation) type of motor activation method is used for less burdening hand-phone charger.
The modified source code is like below.
***
#-*- coding:utf-8 -*-
##
import subprocess, signal, sys
import time, re
import RPi.GPIO as g
##
A = 12
B = 16
FAN = 25
##
g.setmode(g.BCM)
g.setup(A, g.OUT)
g.setup(B, g.OUT)
g.setup(FAN, g.OUT)
##
def signal_handler(sig, frame):
print('You pressed Ctrl+C!')
g.output(A, False)
g.output(B, False)
g.output(FAN, False)
f.close()
sys.exit(0)
signal.signal(signal.SIGINT, signal_handler)
##
while True:
f = open('/home/pi/My_project/CPU_temperature_log.txt', 'a+')
temp_str = subprocess.check_output('/opt/vc/bin/vcgencmd measure_temp', shell=True)
temp_str = temp_str.decode(encoding = 'UTF-8', errors = 'strict')
CPU_temp = re.findall("\d+\.\d+", temp_str)
# extracting current CPU temperature
##
current_temp = float(CPU_temp[0])
if current_temp > 30 and current_temp < 40:
# temperature low A=0, B=0
g.output(A,False)
g.output(B,False)
time.sleep(5)
elif current_temp >= 40 and current_temp < 45:
# temperature medium A=1, B=0
g.output(A,True)
g.output(B,False)
time.sleep(5)
elif current_temp >= 45 and current_temp < 50:
# temperature high A=0, B=1
g.output(A,False)
g.output(B,True)
time.sleep(5)
elif current_temp >= 50:
# CPU cooling is required high A=1, B=1
g.output(A,True)
g.output(B,True)
for i in range(1, 20):
g.output(FAN,True)
time.sleep(10)
g.output(FAN, False)
time.sleep(3)
current_time = time.time()
formated_time = time.strftime("%H:%M:%S", time.gmtime(current_time))
f.write(str(formated_time)+'\t'+str(current_temp)+'\n')
f.close()
##
As operation logic of this python code is almost similar with that of CPU temperature indicator circuit, I will not repeat details here.
FAN Circuit Operation
When looking at the graph, temperature exceeding 50C without FAN circuit.
It seems the average CPU temperature is around 40 ~ 47C while RPI is operating.
If heavy system load such as playing Youtube on web browser is applied, usually temperature raise quickly up to 60C.
But with FAN circuit, temperature will be decreased less than 50C within 5 second by operation of cooling FAN.
As a result, you can turn on RPI all day long and doing any works you like without worrying of over-heating.
Further Development
As you can see, half of acrylic chassis is remained empty.
I’ll put additional components there and extend this basic block of RPI box into something more useful.
Of course more addition means a little bit increasing complexity also.
Anyway I’m integrating two circuits into single box in this project.
Thanks for reading this story.