Raspberry-Pi-Fan-Control icon indicating copy to clipboard operation
Raspberry-Pi-Fan-Control copied to clipboard

Simple Python and shell scripts to run a fan on a Raspberry Pi using CPU temperature.

Raspberry Pi Fan Control

Simple Python and shell scripts to run a fan based on CPU temperature for your Raspberry Pi.

Language License

The Setup

This setup uses GPIO pin 18 with an NPN Transistor (S8050). Wiring diagrams for this setup are provided in the wiring_diagrams directory, with an image of the most basic setup below.

Basic Wiring Diagram

Raspberry Pi Fan Wiring Diagram

Running on Boot

Here's how to run this script automatically on boot:

  • Modify the shell script to ensure you have the correct path run-fan.py.
  • Make the files executable using sudo chmod a+x run-fan.py and sudo chmod a+x launcher.sh.
  • Use crontab (or another method) to execute launcher.sh on boot.

Helpful Links

The code included in this repository is mainly the work of others, with some modification and adaptations made to the code to document the approach.

Thanks to @vollman-ariel for providing a wiring diagram which includes an additional resistor.