RockPro64 Cooling Fan Controller (Python Script)

  • I have a RockPro64 in the Pine64 NAS case. I wanted to have a controller for the fan. I didn't want to patch my own kernel so I revamped a script I found on this forum. I wrote it for the RockPro64 but I think the script will be system agnostic. Let me know if you tried it and made it work on other systems!

    https://github.com/kromsam/FanControllerRockPro64


    Usage

    Code
    usage: fan_controller.py [-h] [--min MIN] [--max MAX] [-l] [-p PATH] [-f [0-100]] [--minpwm [0-100]] [--gpu]
    
    optional arguments:  -h, --help            show this help message and exit  --min MIN             Fan will only switch on above set temperature threshold. Default: 40C.  --max MAX             Fan speed will be maximum from set temperature. Default: 60C.  -l, --log             Log to a file. Set path with '--path'.  -p PATH, --path PATH  Set path of logfile. Default: 'fan_controller.log' in folder of script.  -f [0-100], --force [0-100]                        Set a static fan speed, values from 0-100.  --minpwm [0-100]      Set minimum fan speed, values from 0-100. Default: 24 (PWM value: 60).  --gpu                 Use GPU temperature instead of CPU temperature.

    Automatic mode

    The fan will be switched on with its minimum speed when the minimum temperature is reached. Fan speed will rise incrementally and will be at full speed from the maximum temperature and above.

    Configuration

    Set up a cronjob (in this example the script runs every minute).

    Code
    */1 * * * * python fan_controller/fan_controller.py

    Static mode

    Instead of basing speed on measured temperature level, set a static speed for the fan. Values from 0-100.

    Code
    python fan_controller/fan_controller.py --force 90

    Constants

    The script uses the following constants.

    Code
    CPUMONPATH = "/sys/class/thermal/thermal_zone0/temp"
    GPUMONPATH = "/sys/class/thermal/thermal_zone1/temp"
    PWMMAX = 255
    PWMPATH = "/sys/devices/platform/pwm-fan/hwmon/hwmon2/pwm1"