https://github.com/kaulketh/simple-pi-fan-control
Simple fan control for a Raspberry Pi via GPIO
https://github.com/kaulketh/simple-pi-fan-control
fancontrol fancontrol-script gpio gpio-pins raspberry-pi raspberrypi
Last synced: about 1 month ago
JSON representation
Simple fan control for a Raspberry Pi via GPIO
- Host: GitHub
- URL: https://github.com/kaulketh/simple-pi-fan-control
- Owner: kaulketh
- License: unlicense
- Created: 2021-03-31T21:05:32.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2023-12-24T11:58:24.000Z (almost 2 years ago)
- Last Synced: 2025-06-11T09:36:00.599Z (4 months ago)
- Topics: fancontrol, fancontrol-script, gpio, gpio-pins, raspberry-pi, raspberrypi
- Language: Python
- Homepage:
- Size: 201 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
### Plan
I would have to switch the fan directly using a small piece of software via a
GPIO pin. The program reads the CPU+GPU temperature and then switches the fan.
The OS should start the program periodically or automatically.### Structure
The GPIO pins of the Raspberry Pi have 3V3 logic and cannot switch the power
even of such a small fan directly. That's why a switching amplifier is needed.
This is quite easy to implement with a transistor.### Hardware required in addition to the Raspberry Pi and its case with fan
* 1 NPN transistor e.g. BC547 B
* 1 Resistor 4,7 kOhmSee [circuit diagram](hardware/circuit_diagram.png)
and [wiring image](hardware/wiring.png)### The Python code
* Only required package: [**_RPi.GPIO_**](https://pypi.org/project/RPi.GPIO/)
* **_control.py_** : FanControl class
* In an infinite loop temperature is checked in a certain time interval
* If the temperature is greater than or equal the max value, and the
pin is
not already activated, GPIO pin will set to HIGH
* Is the temperature lower than or equal to the minimum value, and the
pin
is set to HIGH, GPIO pin will set to LOW
* **_config.py_** : Settings:
* GPIO pin of connected fan
* Max temperature at which the fan is switched on
* Min temperature at which the fan is switched off
* Check interval, in seconds* **_main.py_**: An instance of FanControl will load with passed parameters.
### Auto run at boot up
One possibility is described in **_service_** directory. Refer
to [README](service/README.md)### Installation possibilities and steps
* Clone this repository and configure manually
* Install distribution, service enabled automatically
* Adapt _config.py_