Skip to content

Nkeramov/raspberry_pi_fan_control

Repository files navigation

Raspberry Pi fan control

Raspberry Pi Python Checked with mypy license

This project provides examples of fan control based on the current CPU temperature.

It includes implementations of a relay controller and a proportional controller.

The fan is connected via a transistor switch to the 4th pin of the I/O ports. The fan connection pin can be changed in scripts. The remaining parameters can be set at startup.

Setting up and running the project

Clone repository:

git clone https://github.com/Nkeramov/raspberry_pi_fan_control.git

Switch to repo directory

cd raspberry_pi_fan_control

Сreate new virtual environment:

python -m venv .venv 

Activate the virtual environment with the command:

source .venv/bin/activate

Install dependencies from the requirements file:

pip install -r requirements.txt

Run relay fan controller with command (args for example):

python3 relay_controller.py --lower 45 --upper 50 --delay 5

Run proportional fan controller with command (args for example):

python3 proportional_controller.py --temp 45 --delay 5 --p 15.0 --dmin 50 --dmax 100

Or use a launch script run.sh, making it executable first

chmod +x run.sh

Script arguments can be changed.

Adding to startup

You can set up automatic script launch at system startup.

Open the /etc/rc.local file in editor:

sudo nano /etc/rc.local

Add to the end of file this line:

/home/pi/raspberry_pi_fan_control/run.sh &

Press Ctrl+O → Enter → Ctrl+X to save and exit. With these few easy steps, you now have automatic fan control.

Contributing

If you want to contribute, please follow these steps:

  1. Fork the repository.
  2. Create a new branch for your feature or bug fix.
  3. Make your changes and commit them.
  4. Push to your fork and create a pull request.

License

This project is licensed under the MIT License. See the LICENSE file for details.

Ref

About

Scripts for Raspberry Pi to control fan based on the CPU temperature

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published