PWM Fan control?

It seems like the onboard fan spins up to 100% sometime during the boot process, and there’s no way to control the fan speed. The SoC temps are very low, so it seems like we could spin down the fan a bit and not worry bout overheating.

I found a fan on hwmon0:

root@ubuntu:/home/ubuntu# cat /sys/class/hwmon/hwmon0/name
eswin_fan_control

But changing the pwm1 value (default is 50) does nothing, nor does changing fan_pwm_duty (default is 5).

Is there any way to change the fan speed?


Because the default period is too small and the frequency is too high to be supported by the fan, the period needs to be increased. Please set pan_pwm_period to 10000 first, and then set the pwm1

1 Like

Here’s a little systemd to do it automatically on boot.

cat << EOF | sudo tee /etc/systemd/system/fan-speed-slower.timer
[Unit]
Description=timer to slow down fan speed
After=getty.target

[Timer]
OnActiveSec=30sec
Unit=fan-speed-slower.service

[Install]
WantedBy=timers.target
EOF

cat << EOF | sudo tee /etc/systemd/system/fan-speed-slower.service
[Unit]
Description="Slow down fan speed to 50%"
ConditionPathIsReadWrite=/sys/class/hwmon/hwmon0/fan_pwm_period
ConditionPathIsReadWrite=/sys/class/hwmon/hwmon0/pwm1

[Service]
Type=oneshot
ExecStart=/bin/bash -c '/bin/echo "10000" > /sys/class/hwmon/hwmon0/fan_pwm_period'
ExecStart=/bin/bash -c '/bin/echo "50" > /sys/class/hwmon/hwmon0/pwm1'
EOF

sudo systemctl enable fan-speed-slower.timer

And then reboot to try it out. You can change the timeout and speed to your liking.

1 Like

Thanks! It’s certainly less annoying having it right next to me on the desk now :slight_smile:

The manual override works, and your systemd unit works just as well.

Is there any chance PWM fan control can be added to the base image at some point? My CPU temps never seem to rise above 40-42°C, meaning there is a ton of headroom!