Since the Raspberry Pi 4 was released, many have noticed that it can get pretty hot, especially when the CPU is under heavy load.

Mentioned here Raspberry Pi 4: Review, Specs, and Where to Buy The latest and greatest in single-board computing!

A Raspberry Pi enthusiast, Jeff Geerling, released a pretty cool video showing how to add a fan to the Raspberry Pi to help keep the temperature under control. That project was pretty great but I wanted to take it to the next level and add the ability to only turn the fan on when needed by monitoring the core temperature. This way, a noisy fan isn't running all the time.

Mentioned here How to Add a Fan to the Raspberry Pi 4 for Proper Cooling (You Need One) It's getting hot in here, a fan will cool your Pi.

In this guide, I'll cover the whole project from start to finish. First, we'll install the fan onto the official Raspberry Pi case and wire it up so it can be activated by a GPIO pin. Then we'll write some Python code to monitor the temperature and activate the Pi when the temperature reaches a certain threshold.

Requirements

In order to complete this guide, you'll need a Raspberry Pi 4 with the latest version of Raspbian installed. The scripts I've included are written for Python 3.7, which is the default Python 3 version in the September 2019 version of Raspbian. Newer Raspbian versions will work as well :)