Skip to content
mrabinePublic

Repository files navigation

pifan

Raspberry Pi fan controller daemon

Test Status Security Status Codacy Badge GitHub Releases GitHub License

Start fan when CPU temperature is high and stop it when CPU temperature is low. Supports Raspberry Pi 4 and Raspberry Pi 5. The GPIO chip is auto-detected at startup and can be overridden with the -g option.

Note: tested on Ubuntu 24.04.

Dependencies

Pifan requires libgpiod, to install it do this:

sudo apt install libgpiod-dev

The gpiod package (CLI tools such as gpiodetect, gpioinfo) is optional but useful for troubleshooting:

sudo apt install gpiod

Download

To download the latest source do this:

git clone https://github.com/mrabine/pifan.git

Move to pifan directory:

cd pifan

Configuration

To configure pifan do this:

cmake --preset gcc-release -DCMAKE_INSTALL_PREFIX=/usr

Build

To build pifan do this:

cmake --build --preset gcc-release

Installation

To install pifan do this:

sudo cmake --install build/gcc-release

Enabling

To enable pifan do this:

sudo systemctl enable --now pifan

Usage

pifan [options]

-c
 print the cpu temperature
-g chip
 gpio chip device name (default: auto detection, "gpiochip0", "gpiochip4").
-h
 show available options
-i interval
 sleep interval in seconds (default: 2)
-l threshold
 lower threshold in °C, fan stops below this value (default: 55)
-n
 don't fork into background
-p pin
 gpio pin number (default: 14)
-u threshold
 upper threshold in °C, fan starts above this value (default: 65)
-v
 print version

Recommended thresholds

A 10°C hysteresis between lower and upper thresholds avoids rapid on/off cycling. The Raspberry Pi 5 begins thermal throttling at 80°C, so the following values provide a comfortable safety margin while keeping the fan off most of the time:

pifan -l 55 -u 65

These are also the default values.

License

MIT

Releases

Packages

Used by

Contributors

Languages