├── LICENSE ├── README.md ├── benchmark ├── bash_data │ ├── average.txt │ ├── bash_data.png │ ├── cpu.txt │ ├── ram.txt │ └── time.txt ├── mean.py ├── monitor.py ├── plot.py └── python_data │ ├── average.txt │ ├── cpu.txt │ ├── python_data.png │ ├── ram.txt │ └── time.txt ├── fan.py ├── fan.sh ├── install.sh ├── media ├── GPIO-Pinout-Diagram.png ├── PN2222A.jpg └── circuit.png └── uninstall.sh /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 浪人 4 | Copyright (c) 2020 0xHaru 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in all 14 | copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | SOFTWARE. 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Raspberry-Pi-Fan-Controller 2 | 3 | Raspberry-Pi-Fan-Controller is a temperature based fan controller that turns the fan on when a certain temperature is reached and turns the fan off when the threshold isn't met anymore. 4 | 5 | ## Components 6 | 7 | - Raspberry Pi 8 | 9 | - Fan 10 | 11 | - 2N2222 Transistor 12 | 13 | - 10K ohm Resistor 14 | 15 | ## Schema 16 | 17 | ![](media/circuit.png) 18 | 19 | [RPI4 GPIO Pinout](media/GPIO-Pinout-Diagram.png) 20 | 21 | [2N2222 Transistor](media/PN2222A.jpg) 22 | 23 | ## Prerequisites 24 | 25 | - Python 3.8+ 26 | 27 | - Bash 4.2+ 28 | 29 | ## Installation 30 | 31 | ### 1. Installation script 32 | 33 | The installation script will create an executable script, a config file and if selected it will autostart the script at boot. 34 | 35 | ```bash 36 | sh -c "$(wget -qO- https://raw.githubusercontent.com/0xharu/raspberry-pi-fan-controller/master/install.sh)" 37 | ``` 38 | 39 | To **uninstall** the program and all of its files use: 40 | 41 | ```bash 42 | sh -c "$(wget -qO- https://raw.githubusercontent.com/0xharu/raspberry-pi-fan-controller/master/uninstall.sh)" 43 | ``` 44 | 45 | #### Manual inspection 46 | 47 | It's always a good idea to inspect the installation script, you can do that by downloading the installation script first, looking through it and then running it. 48 | 49 | ```bash 50 | wget -q https://raw.githubusercontent.com/0xharu/raspberry-pi-fan-controller/master/install.sh 51 | ``` 52 | 53 | ### 2. Clone the repository 54 | 55 | ```bash 56 | git clone https://github.com/0xharu/raspberry-pi-fan-controller.git 57 | ``` 58 | 59 | ### 3. DownGit Links 60 | 61 | - [fan.py](https://downgit.github.io/#/home?url=https://github.com/0xHaru/Raspberry-Pi-Fan-Controller/blob/master/fan.py) 62 | 63 | - [fan.sh](https://downgit.github.io/#/home?url=https://github.com/0xHaru/Raspberry-Pi-Fan-Controller/blob/master/fan.sh) 64 | 65 | ## Usage 66 | 67 | If you cloned the repository or used the DownGit links use: `python3 fan.py` or `bash fan.sh`. 68 | 69 | If you used the installation script and installed only one of the scripts use: `fan` 70 | 71 | If you installed both scripts use: `fan-py` or `fan-sh`. 72 | 73 | In my experience even if the benchmarks are pretty much the same the python script seems to perform better and triggers the fan less frequently compared to the bash script. 74 | 75 | ## Autostart 76 | 77 | To autostart the script either use the installation script or edit your crontab list. 78 | 79 | #### How to edit your crontab list: 80 | 81 | 1. `chmod +x