Simple Raspberry Pi cooling setup
a quick low cost setup guide for heatsinks, fan and ventilation for a stock Raspberry Pi 4B case
I got one of these little things a while back after seeing a 10 year old kid program, market and publically present an IOT robot in a real world commercial solution using a Pi and Python as a fun robotics project. Cool enough to almost have me start existentially questioning my years in IT and what I'm doing in life, lol.
Sure there are more powerful SBC peers now, but the Raspberry Pi was the one that first sparked a phenomenon appeal for hobbyist tinkerers out there. It's got that wonderful component kitset lego-like system building ecosystem, versatile enough to encourage a plethora of creative projects. There's just something really satisfyingly candid about it.
But trying out the stock case, I found that with simple activities like streaming, mine runs hot, like bizarrely 80-90 deg C range hot. And no wonder as mine doesn't come with any stock cooling. You've got to buy it separately for a couple bucks.
So suffice to say, setting up cooling first for the Pi is a must before any future projects.
So I purchased an extra 3 piece aluminium Pi 4 heatsink kit and the official Raspberry Pi 4 case fan/black heatsink included, they're pretty cheap from your local online IT stockist or Amazon.
Ventilation
The stock Pi case is enclosed, so installing a case fan seemed a bit redundant as you would just have hot air blowing around inside without any ventilation holes. So why not make some Pi DIY in the spirit of a home hobbyist. :)
I marked out a nice grid layout pattern in pencil. I didn't want them too close as I wasn't sure of the integrity of warping the hard plastic shell.
I also used a battery power drill and a size 6 drill bit, you may want to vary a bit for your needs but it seemed a right enough size for me.
*remember to take the Pi board out first, have an empty case, I have to say it.
Drilling on the smooth surface accurately with a hand power drill can be a bit tricky. Because the drill bit spins clockwise, it will tend to jolt and shift diagonally upwards-left from your original position.
In hindsight I would suggest carefully pre-drilling a small indentation hole with something like a screwdriver/screw to allow the drill bit to seat properly. I just did a quick bang up job in 10 mins out of drilling excitment so my end result was a bit sloppy.
So now there should be some nice aligned holes. There will be burr in the back and interior so file or sand those down smoothly before resinstalling the Pi board (*which hopefully shouldn't have holes in it) - ;).
Heatsinks
The heat sinks are pretty easy, peel off with thermal pad stickers. Apparently aligning the fins across wise the board as such below gives the best cooling airflow, again arguable.
The middle rectagular heatsink was a pain. I found i had to cut it to size with a hacksaw to fit to size on the chip. I ended up pulling it out and not using it anyway as the heatsink actually obstructs the fan and causes the case not to close properly.
Fan
The fan is pretty easy to install, it just clips onto Pi case bracket slots along the port ends. I actually also took the fan unit out and reinstalled it reversed it so it pulls air out of the case instead of push. Arguable theory again being not blowing existing hot air in the case.
The GPIO pins for the fan in a default setup should be as follows:
GPIO 4 = red (5V Power)
GPIO 6 = black (Ground)
GPIO 14 = blue (TXD - fan control logic)
Fan Control
There are a number of ways to activate fan control at a certain temperature. I will highlight three.
You may want to do this to save on power draw and burning out the fan motor or to minimize having a soft continual high pitch whine as background noise which can annoy certain people.
Method 1: In Raspbian windows interface
Raspbian Menu > Preferences > Raspberry Pi Configuration > Performance tab
... Fan = Enable
... Fan GPIO = 14 (default)
... Fan Temperature = 65 (minimum 60 deg C)
Method 2: Using raspi-config
In the terminal use command.
sudo raspi-config
Performance Options > Fan
... Would you like to enable fan temperature control? = Y
... Which GPIO is fan control connected? = 14
... At what temperature in degrees Celsius should the fan turn on? = 60 (or 65 suggested)
... Ok
Method 3: Manually add entry in/boot/config.txt
In terminal use the following command.
sudo nano /boot/config.txt
Ensure the following section is added/modified in the config file.
#Enable Fan dtoverlay=gpio-fan,gpiopin=14,temp=65000
... gpiopin=14 (default, but can be other desired GPIO pins prefered)
... temp 65000 means 65 deg C. Modify this to your desired temperature where fan will activate.
NOTE: configuring fan control using this
/boot/config.txt
overlay file can be found in similar locations on many different Pi images, e.g. OpenWRT, Kali Linux, LibreELC etc.
Troubleshooting: issues I ran into
FAN IS ALWAYS ON WITH A HIGH PITCH WHINE
For some reason my fan was always on, despite all the above changes. I found that grounding the blue wire into any Ground GPIO pin, say GPIO 20 or 34, manually stopped my fan.
After rebooting in that blue wire grounded config the fan appeared to be in default off all the time.
So I reconfigured the blue wire back to GPIO 14, reconfigured the above fan control settings, rebooted and tested by running some high processing usage like 3-4 simultaneous youtube streams and found that the fan temperature activation was now working as it should correctly.
TIGHTLY PACKED CASE WILL COME APART ON SLIGHT BUMP
This can be a bit annoying, I haven't looked specifically at why the Pi case is so tightly packed. I suspect it is one of the heatsink fins causing this. For me I just have to be careful with handling and placement where the slightest bump and it will fly apart. Will look into this again one day, otherwise it isn't too major.
Wrapping Up
With cooling now setup, my temperatures now average around 50 deg C, rarely does the fan activate above 65 deg C unless under heavy processing load. No more throttling at 80 deg C with a Pi oven case :).
All in all this was a pleasant setup, as well as a nice intro blogging practise for me. My Raspberry Pi 4b is an 8GB model with some decent overhead with which I intend to try my hand at various projects like:
an OpenWRT multi-functional travel router (very awesome)
Kali pentesting box
web server
media center (has issues particularly with 4k)
movie streaming box (720p limit acceptable dropped frames)
mesh network experiments
Pimox virtual cluster, with docker, kubernetes, terraform experiments.
local AI box (non GPU dependant)
running it off a car battery for a zombie post apocalypse scenario (needs real world testing)
etc... the list goes on.
It's such a fun little kit to play with, along with many potential hours of projects on which to conduct creative experiments. Beyond just learning I'd highly recommend it to any one who just likes to tinker. :)