How to control a PWM fan depending on CPU temperature on a Orange Pi Zero 2? You can use one of four built-in PWM. You don't need any libraries, only python.
TODO: rewrite python script to bash.
- Install Python 3.7 or higher.
- Configure PWM on orangepi zero2. See section 3.20.5 in user manual
sudo nano /boot/orangepiEnv.txt
Add to the end of file pwm12
or pwm34
.
overlays=pwm34
- Reboot.
- Clone repository.
git clone https://github.com/Serjdud/orangepizero2_pwm_fan_control.git
- Move to source
./orangepizero2_pwm_fan_control
- Make sh script executable
sudo chmod +x ./fan_control.sh
Run fan_control.sh with first argument = PWN nubmer. Wich PWM number you use depends on PWM pin. See picture above.
sudo ./fan_control.sh 3
To see other possible arguments run with -h argument
./fan_control.sh -h
- Move to source (for example
orangepizero2_pwm_fan_control
installed to orangepi user's home directory)
cd ~/orangepizero2_pwm_fan_control
- Get full path to fan_control.sh
pwd
/home/orangepi/orangepizero2_pwm_fan_control
- Copy the full path to the parameter ExecStart in
fan_control.service
and add PWM number argument.
sudo nano ./fan_control.service
ExecStart = /home/orangepi/orangepizero2_pwm_fan_control/fan_control.sh 3
- Copy fan_control.service to daemon service folder (usually
/etc/systemd/system/
).
sudo cp ./fan_control.service /etc/systemd/system/
- Reload systemd config
sudo systemctl daemon-reload
- Enable service autolaunch on system startup
sudo systemctl enable fan_control.service
- Start service end check
sudo systemctl start fan_control.service
systemctl status fan_control.service