Skip to content
A tiny script allowing temperature controlled Raspberry Pi cooling.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.

Pi Fan Controller

A simple, temperature-based fan controller for a Raspberry Pi.

Loosely based on the work done by Edoardo Paolo Scalafiotti found here, this simple python script controls a cooling fan using a BJT transistor connected via GPIO. It makes use of two temperature variables (a minimum and a maximum), allowing the user to define a temperature range to oscillate within, avoiding rapid on/off switching when trying to stabilize around a single value.

See for more information on how I personally use this script.


  • Fan turns on when the CPU temperature reaches 60°C
  • Fan turns off when the CPU temperature returns to 50°C.
  • The temperature is checked every 10 seconds.
  • The base pin of the transistor used to control the fan should be connected to BCM pin 14.

See the script's inline comments for more information on the user variables.


Download or clone the script and add python3 /path/to/ & to your rc.local file to have the script run on boot.


This work is licensed under the MIT license.

You can’t perform that action at this time.