- Table Of Contents
- About The Project
- Built With
- Getting Started
- Usage
- Roadmap
- Contributing
- License
- Authors
- Acknowledgements
I was looking to cool my Raspberry Pi which was running LibreELEC. The Raspberry Pi case was equipped with a 5V fan. It was running all the time on full speed when mounted to the 5V pin. It was too loud.
With this open-source project I wanted to:
- Cool the Raspberry Pi only if it is running warm.
- Adapt the fan speed, so that the noise is reduced.
- Play around with transistors.
- Enable program running on LibreELEC.
The available 5V fan has active power of up to 1W. However, the GPIO pins can only deliver 3.3V with a maximum of 1mA each. With a NPN transistor it is possible to control the 5V circuit with a low current from a GPIO pin providing voltage of 3.3V. To control the fan speed, Pulse-width modultion (PWM) is used (available on GPIO 12), with which the average power delivered to the 3.3V circuit can be controlled.
NPN-Transistor: 2N3904
- Emitter connected to GND.
- Base connected to GPIO 12 (PWM0) with a 1kOhm resistor in between.
- Collector connected to fan and fan connected to 5V.
- Pull-Down 10kOhm resistor between GND and GPIO 12
- Diode between Collector and 5V (optional to protect transistor from fan)
Install on LibreELEC the 'Raspberry Pi Tools' addon
Addons --> install from repository --> LibreELEC Add-ons --> Program Addons --> Raspberry PiTools
Run python program 'calibrate.py' to change speed via SSH for testing before setting lowest speed in the script.
- save the file 'PWM_fan.py' on your RaspberryPi to
/storage/.kodi/userdata/PWM_fan/PWM_fan.py
- and change permission of the PWM_fan.py file with
chmod 777
- save the file 'PWM_fan.service' on your RaspberryPi to
/storage/.config/system.d/PWM_fan.service
- enable the service with
systemctl enable PWM_fan
- start the service with
systemctl start PWM_fan
- check if the service is working with
systemctl status PWM_fan.service
- Start the program as service after each start.
- The CPU temperature is read.
- Calculate desired fan speed.
- Update new fan speed with desired speed.
See the open issues for a list of proposed features (and known issues).
Contributions are what make the open source community such an amazing place to be learn, inspire, and create. Any contributions you make are greatly appreciated.
- If you have suggestions for adding or removing projects, feel free to open an issue to discuss it, or directly create a pull request after you edit the README.md file with necessary changes.
- Please make sure you check your spelling and grammar.
- Create individual PR for each suggestion.
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature
) - Commit your Changes (
git commit -m 'Add some AmazingFeature'
) - Push to the Branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
Distributed under the MIT License. See LICENSE for more information.
- Franz Heinzl - https://github.com/FranzAT