Control the 5V PWM fan on a CM3588 NAS.
Developed and tested on Armbian only (output of lsb_release -a shown below. Kernel: 6.12.1-edge-rockchip-rk3588).
Distributor ID: Debian
Description: Armbian 25.2.3 bookworm
Release: 12
Codename: bookworm
Might work on other RK3588 SBC also (like Orange PI 5+).
Usage of this software is purely at your own risk. I am just sharing what I developed for myself and use at home.
- Runs as background service
- Changes fan speed as per the temperature (configurable).
- Run
./test.pyand it should run without any errors. It should show some messages like following (example taken from my machine)2025-04-10 23:19:59,742 - INFO - Fan device: /sys/class/thermal/cooling_device4 2025-04-10 23:19:59,743 - INFO - Maximum state allowed: 5 2025-04-10 23:19:59,743 - INFO - Current state is set to: 1 - Try setting some speed for the fan where 0 mean off, and any value above 0 upto "Maximum state" sets different speeds.
For example
./test.py --desired-state 5will set it to maximum speed on my machine. Running./test.py --desired-state 0switches off the fan on my machine. - If all goes well, test a bit more as following instructions.
- In one terminal, run the script
./fan_control.py. This runs the script in foreground and debug logging enabled. The logs are pretty detailed. Leave it running. - In another terminal, simulate stress on the CPU using
stress --cpu 8 --timeout 120command. This will put CPU in 100% load for 120 seconds. - In the first terminal, notice the logs and also the fan speeding up when temperature rises and slowing down again when the command finishes and CPU cools down.
- If all goes well, kill the script by pressing ctrl-c and proceed to install it as background service.
- The script has dependency on python systemd module (to send log messages to system journal). I installed it using
apt-get install python3-systemd - Copy the file
fan_control.pyto/usr/local/bin/fan_control.py - Copy the file
fan_control.serviceto/etc/systemd/system/fan_control.service - Run the command
systemctl daemon-reload - Enable the service by running
systemctl enable --now fan_control.service
Now you can see the logs by running journalctl -u pwm-fan-cm3588
You can also configure the various parameters in the script itself by editing /usr/local/bin/fan_control.py (like temperature ranges which controls various fan speeds).
- Disable the service by running
systemctl disable --now fan_control.service - Delete
/etc/systemd/system/fan_control.service - Delete
/usr/local/bin/fan_control.py - Run the command
systemctl daemon-reload
My NAS is running in the case created using the great work by https://github.com/Nighthater/CM3588-NAS-Case.
I am using a Noctua 80mm fan.
