Adding an external fan to the Raspberry Pi 3 Model B

A while ago I had purchased a Raspberry Pi 3 to learn more about building software on the ARM platform (IoT), and getting to know configuration management software like SaltStack.

Since I intended to compile software on the Pi, I looked into external cooling solutions and found that adding a heat sink and fan should work. Ordered the items, and when they came I attached them to the Pi.

But there was an issue: the fan was too loud and not really required unless the Pi was heating.

Searching for solutions, I found two tutorials, the first of which used a transistor controlled via the Raspberry Pi’s GPIO system (I could not find the suitable transistor online) to turn the fan on/off as required, and the second  one which used a relay module (which I could find online and ordered).

After some fiddling around, managed to get the connections right, and it worked 🙂 There was a strange issue though that whenever the GPIO pin was set to output mode, irrespective of the fact whether the voltage was HIGH or LOW, the fan got switched on. As a workaround I set the GPIO pin to input mode instead of setting it to output LOW and it worked.

I took the scripts from the tutorials , modified them a bit to workaround the above issue, merged the best bits, and wrote some code for monitoring. All this is now available in a Github repo.

Raspberry Pi 3 fan setup


  1. Automated-cooling-fan-for-Pi
  2. how-to-control-a-fan-to-cool-the-cpu-of-your-raspberrypi
  3. raspi-fan

If anyone has any comments or queries feel free to post them in the comments section below.

Leave a Reply

Your email address will not be published. Required fields are marked *