This repository contains a Python script to control the fan speed of a Raspberry Pi 5 based on the CPU temperature. The script reads the current temperature and adjusts the fan speed accordingly to ensure efficient cooling.
fan_controller.py: The main Python script that monitors the CPU temperature and adjusts the fan speed.
The fan speed is controlled based on the following temperature thresholds:
- Above 70°C: Full Speed
- 65°C to 70°C: High Speed
- 60°C to 65°C: Medium Speed
- 40°C to 60°C: Low Speed
- Below 40°C: Off
-
Clone the repository:
git clone https://github.com/yourusername/rpi5-fan-controller.git cd rpi5-fan-controller -
Ensure the script is executable:
chmod +x fan_controller.py
-
Set up the script to run on boot: Add the following line to your crontab using
crontab -e:@reboot python3 /root/fan_controller.py
-
Reboot the Raspberry Pi to start the fan controller:
sudo reboot