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.
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.
- 1 NPN transistor e.g. BC547 B
- 1 Resistor 4,7 kOhm
See circuit diagram and wiring image
-
Only required package: 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
- In an infinite loop temperature is checked in a certain time interval
-
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.
One possibility is described in service directory. Refer to README
- Clone this repository and configure manually
- Install distribution, service enabled automatically
- Adapt config.py