This is a fan control for a Raspberry PI based on the SYSFS interface. It should be compatible with any SYSFS compatible system which exposes the GPIO pins and thermal zones.
I'm using these fan heatsinks for my Pis: Amazon / Reichelt
You connect the red wires from the fans to one of the two red pins from the Pi. The black wire from the fan gets cut in the middle and the part connected to the fan gets soldered to the emitter pin of a transistor and the part leading to the Pi to the collector pin of the transistor. Finally connect the base pin of the transistor to any GPIO pin (I used 23 and grabbed ground from the one next to it) with a resistor in between (I used a 1k Ohm one).
I currently publish 64 Bit Arm binarys, since I'm developing this for my Pi 4s.
System | Release Binary |
---|---|
Raspberry Pi 64 Bit | fan_control |
$ curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
Download the source from either the release, or the master of this repo.
$ git clone git@github.com:Snapstromegon/fan_control.git
$ cd fan_control
Inside of the project folder run:
$ cargo build --release
(Resulting binary will be $pwd/target/aarch64-unknown-linux-gnu/release/fan_control)
Copy the fancontrol bin to /opt/fancontrol and the fan_control.service (example in this repo) to /etc/systemd/system/fan_control.service.
You can either configure the program via anfironment variables or command line arguments (for both, check fan_control --help
).
You can configure:
- GPIO Pin: The pin which is used to turn the fan on/off
- Thermometer Path: SysFS path of the thermometer (should result in °C*1000 - so 40000 = 40°C)
- Fan On Temperature: When should the fan kick in
- Fan Off Temperature: When should the fan turn off again
- Log Level: Use the RUST_LOG environment variable to change the log level. The default is "info".
$ systemctl enable --now fan_control