PWM fan speed control python script according to cpu temperature

I write a python script to control pwm fan speed according to the cpu temperature. The control is very simple: When the temperature is higher than a gate temperature(for example 65°C), the fan speed will get increased. When the temperature is lower than the gate temperature, the fan speed will get decreased.
Before using this script, you have to initialize your pwm fan according to this wiki page: https://wiki.radxa.com/Rock3/Debian#Control_PWM_Fan
Control script source: https://gist.github.com/amazingfate/38b12841d8a79e06771a7ba8013372ae
You can create a systemd service to run this script.

2 Likes

Does this code remove the auto fan settings? For example, my MSI computer already automatically adjusts the fan according to the CPU temperature. I just want a way to manually control fan speed from a program (I’m making a AI hand tracker that identifies a specific movement to toggle the fan)

This script is out of date now. New kernel is using pwm-fan driver to control the fan speed.

Wait I’m just dumb I didn’t realize what Radxa was. The code only works for Radxa computers right?

The code only works on boards that use method like https://wiki.radxa.com/Rock3/Debian#Control_PWM_Fan