PWM fan on Raspberry Pi


I am converting and old Raspberry Pi (old because 3B+) to OpenWRT. I used to be able to control the fan speed using PWM, but I could not find the way to do so with OpenWRT.

I have not been able to read the temperature from /sys/class/thermal and I have not been able to find how to install the command line GPIO to configure and invoke PWM.

I have the hardware part running (fan, transistor, cabling) running fine, I used it in an earlier project, that is the software that is causing my problem.

And I know that Raspberry Pi is supposed to run without fan, but in climates where temperature can climb to 40C, a fan is not a bad idea. And I know I could have the fan run permanently, but I like the idea of controlling the speed. it helps preserving the life of the fan.

Thanks in advance,


Are you intending to run STABLE or SNAPSHOT?

Majority of gpio like stuff is done with C or python, the latter being space intensive but modular for beginners.

How you hook into the GPIO may vary with the version of OpenWrt you are running.

What did you find?

I tried installing:

And none give me a way to configure GPIO in PWM mode (or I have not understand how to use them because I could not locate the man page).

I am looking for the same solution.
This feature would suit raspberry pi stored in the bottom of the box very well.
Has colleague @Olivier2553 found any solutions?

Nope, I am running the fan at full speed.

i'm not familiar with the rpi3 and it's packages

for the rpi4 os-level pwm(bcm)kmod + config.txt + sysfs do provide the ability to adjust pwm dutycycle...

the actual configuration of the GPIO for os-level pwm is achieved via config.txt... (dtoverlay)

Why not just connect a fan and let it run? I think there's not going to be much difference. My pie runs it as I just told you. Since you are running the Raspberry in heaty climates, it is better to just let it run. (Note: by "connect" I mean connect the fan to the pi's 3v3 and gnd pins)

This was what I used for the rpi4 case/fan in boot/config.txt as @anon50098793 pointed out, it worked, I'm guessing it would work for other fans, you'd just need to change the PIN number/temp for your needs

1 Like

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.