Saturday, August 9, 2014

Raspberry Pi cooling fan

Hi ! So, after quiet some time I've decided to post something here. Recently I've been working with Raspberry Pi more often, and I noticed that even with small load for longer periods of time it can get hot, and that lead me to decision to add a small fan to it.

 
 
You can check temperature of your Pi in Celsius via terminal by typing one of these two commands :
 
  /opt/vc/bin/vcgencmd measure_temp 
   cat /sys/class/thermal/thermal_zone0/temp (divide by 1000)
 
After one hour of pretty much idle sitting, Pi can get all the way up to 53.5 °C, which may not be critical but it's not ideal, taking in consideration fact that while performing demanding tasks temperature will grow higher. I went for 30x30 mm fan, that can sit directly above the processor. Screw in the mounting hole available at the Pi alongside with the s-video jack hold it in place. I wanted to keep 2x13 GPIO pin headers intact, so instead I've used P5 pins, that have all that is needed in order to make this work. I've then added simple header connector that has a 2n2222 transistor on it, base of which is controlled by GPIO pin number 30. By changing resistor value you can pretty much vary fan speed. One I've used is rated 5V and 72mA, but I decided to use 10k resitor on the base which together with beta of transistor (~ 100) gives around 45 mA to the fan, so that it runs smoothly and very quietly. At the bottom you can see simple bash script that is executed in rc.local to run as a background process everytime Pi is turned on. It's basically constantly checking whether temperature has crossed the threshold and when yes it activates the fan for 5 minutes. Of course you can go even further, use python for instance that will give you with help of RPi.GPIO library ability to use PWM to scale the speed to current temperature, but I wanted to keep it simple. 





No comments:

Post a Comment