My post was edited while I was modifying it (thanks Werner for the readability), but then I couldn't save :-(
So some adds-on here.
I change the set points to adapt to my fan:
...
# declare -a CpuTemps=(75000 65000 55000 40000 25000 0)
declare -a CpuTemps=(75000 68000 60000 50000 40000 0)
# Duty cycle for each CPU temp range
# declare -a DutyCycles=(40000 6000 3000 2000 1500 0)
declare -a DutyCycles=(40000 30000 20000 12000 8000 0)
...
After modifying the script, don't forget to restart the service:
# systemctl restart pwm-fan.service
When starting, the fan will run for 10 s, which shows the service is working. Then it will stop and restart only if the temperature is above the lower temperature threshold and the corresponding duty cycle high enough to allow the fan to start. This may need some trials to find the correct values, as each fan reacts differently.
I exchanged the radiator provided with the sataHat by a bigger one, as the original was getting very hot (cannot keep a finger on it), even when the system was idle. Now temperatures of both the radiators of nanoPi and sataHat are similar (finger feeling again ;-)
It would be nice also to include temperature of the sataHat in the script, but I cannot find it. Is it measured and if yes, where is it available ?