Raspberry pi 4 GPIO controlled cooling fan

Photo of talofer99

Made by talofer99

About the project

When it gets too hot

Project info

Difficulty: Easy

Platforms: Raspberry Pi

Estimated time: 1 hour

License: GNU General Public License, version 3 or later (GPL3+)

Items used in this project

Hardware components

Toggle Switch, (On)-Off-(On) Toggle Switch, (On)-Off-(On) x 1
1N4007 – High Voltage, High Current Rated Diode 1N4007 – High Voltage, High Current Rated Diode x 1
LED (generic) LED (generic) x 1
Resistor 220 ohm Resistor 220 ohm x 1
Resistor 1k ohm Resistor 1k ohm x 1
NPN s8050 NPN s8050 x 1
cooling fan for rpi cooling fan for rpi x 1
Raspberry Pi 4 Model B Raspberry Pi 4 Model B x 1

View all

Story

Using some python, few electronics parts and a fan, I added a GPIO controlled fan to my RPI 4.

While working on the raspberry live video with tkinter I noticed that my rpi 4 (knows issue) tend to run really hot. When I ordered the rpi4, I also ordered a case and a cooling fan, I should have bought a heat sink as well, which I did later (after the video was done). If you want to watch the project you can see it here

Now I did not want it to run all the time, so I did 2 things.I create a PCB that move the control of the fan to a GPIO using a NPN transistor as a switch.And I wrote a little python script that takes the core temperature using this command : vcgencmd measure_temp. Once I get the temperature, I check if it’s over the threshold, if so I turn on the fan. If not turn it off. Pretty simple. I added the script to the rc.local file and it works on boot now. When I tested it later on (again after the video was out) I noticed that my code was not perfect for the job, and changed it to have a gap between the turn on to the turn off by temperature, not using the same one. I also printed a case for the camera The files can be found here (not mine!) https://www.thingiverse.com/thing:2746186I had a great time also creating the box and mount using fusion360.I did not publish the files, but if any one wants then will be more the happy to send it to him. Hope you will find it useful.

Schematics, diagrams and documents

cooling_bb_9Bhghlq0Xw.png

Code

python code

Credits

Photo of talofer99

talofer99

Maker @ heart

   

Leave your feedback...