Control speed of fan

OK, it’s installed. It doesn’t work

1 Like

Here’s the GitHub page for it, doesn’t look like the settings file has a speed.


The fan will start only when the SoC reach a certains temperature, it is not blowing all the time.

If you want to check it, just use this guide from github:

Change the threshold temperature

Edit /usr/local/bin/
line starts with MAX_TEMP=80

For devterm cm3(rpi os) the recommended MAX_TEMP is in range 60-80
then restart systemd service to take effect

sudo systemctl restart devterm-fan-temp-daemon

That can be found here:

Set the temp to a really low value, the fan will start as soon as you restart the service.

PS: It does not use any standard daemon, and there is no configuration file.


That’s just what I was looking for, thanks.

my DevTerm is A06. I have set the max temp in that file to 50, fan does not run. Does it only work on CM3?

for a06
EDIT /usr/local/bin/


50000 is 50 deg

and don’t install rpi package on A06

sudo apt update && apt install -y devterm-fan-daemon-cpi-a06
1 Like

thank you for the reply.
That a06 package was already installed, I just edited the wrong settings file.
I have now set the parameter to 40000 and rebooted. I can see the fan start turning but it stops after a few seconds despite htop showing 53 degrees.
Is htop showing a different temp sensor than the fan is using?

P.S.: I can see the fan turning now and then. I would have thought it would keep turning with 12 to 13 degrees above MAX_TEMP…

Even setting it to 20000 doesn‘t change the behaviour.

Is there a way to just have the fan run constantly on the A04? I have an issue with the screen developing errors after a few minutes of use and I am beginning to suspect it is caused by overheating.

1 Like

By changing the script to a lower temperature it should be always on.

I don’t think this is true, at least for the A06. I looked at the Python script and when its overheating it makes calls to turn the fan on (which has a sleep of 30 seconds, so I’m guessing it stays on that long) and then it immediately makes a call to turn the fan off with a sleep of 5 seconds. So if I’m reading the code correctly (for A06 one, haven’t looked at A04 script) the behavior whenever it it overheating is currently turn the fan on, then turn it off after 30 seconds, wait 5 seconds with it off, and then turn it on again if it’s still overheating.

That seems like a bug, but I haven’t edited the file yet since I’m.not sure if it actually is a bug or if it’s intended behavior. Seems weird though.

1 Like

Here’s the relevant code (with some functions in between removed, and my own comments added):

ONCE_TIME=30  # how long to keep the fan on in seconds
def fan_on():
    os.popen("gpio write 41 1")
    time.sleep(ONCE_TIME) # fan is on, and we're sleeping for 30 sec
def fan_off():
    os.popen("gpio write 41 0")
def fan_loop():
    while True:
        temps = glob.glob('/sys/class/thermal/thermal_zone[0-9]/')
        for var in temps:
            _f = os.path.join(var,"temp")
            #print( open(_f).read().strip("\n") )
            _t = open(_f).read().strip("\n")
            if isDigit(_t):
                if int(_t) > MAX_TEMP: 
                    fan_on() # it's hot so turn the fan on (for 30 sec)
                    fan_off() # but for some reason now we turn it off ?!?

        time.sleep(5)  # wait for 5 seconds, but fan is still off, even if hot!

Any script for A04? Seems there are only python files for a06 and cm3.

Do you have devterm-fan-daemon-cpi-a04 installed from apt? That should give you a script in /usr/local/bin

I tried lowering the fan trigger temperature in my script and it does not seem to take effect until after a reboot. I dropped the threshold temperature to 30C and the time to run the fan to 300 seconds because I wanted to achieve close to an “always on” functionality. Running at full load with 2 cores enabled, this dropped my temps by about 10C and I don’t have the fan shroud on yet. I will print a fan shroud this evening and look into possibly replacing the fan with another one altogether. This is on A0402.

when i type edit i receive the error no write permission for file. forgive my ignorance but how do i give myself write permissions?

Hey Jeremiah, welcome. What exactly are you trying to accomplish? Change the trigger temperature that the fan turns on that guu was talking about? The package to control the fan should be pre-installed and functioning. You do NOT need to edit this file unless you want to change the temp the fan turns on. The fan is near silent, and you really can’t tell when it’s running.

Let’s first make sure you have the package installed. Then you need to elevate your privileges on Linux to edit files not owned by you – that’s done by prepending “sudo” in front of the command you want to run. ‘sudo’ mean “super user, do this”.

sudo apt update && sudo apt install -y devterm-fan-daemon-cpi-a06
sudo nano /usr/local/bin/

The first command refreshes the database of packages available and installs the fan daemon, if needed. The second command opens the actual script that controls the fan using the editor nano.

Use the cursor keys to find the line “MAX_TEMP=XXXXXX”, backspace to remove the number and type in the new number. Now hit control-x. Type y to save. Now reboot.

yes i 3d printed a fan shroud but the device is shutting off whenever it gets too hot and i dont see the fan coming on so i am attempting to get it to come on earlier (perhaps something else is making it shut off but i always start from what i know and work backward)

-edit . i should also note it turns off whenever i attempt to play a video on youtube as well, so i may have other issues

-edit 2 fan works

1 Like

The command to change file permission is chmod

For write permission is chmod +w filename for executable permissions chmod +x filename

The FAN_EN transistor is connected to GPIO3_A0/MAC_TXD2/SPI4_RXD_d.
It’s not a hardware PWM pin, so no hardware speed control.


  1. Software PWM.
    Do it from the kernel, expose it as software pwm so a real fancontrol program can pick it up.
    Won’t be too heavy – we can lower the frequency to 50Hz or even 10Hz.
    Technically, the current fan control script is a 85.7% PWM at 0.028Hz

  2. Use the 40pin GPIO connector to loopback a real PWM pin to pull the leveler.

  3. Use the GPIO connector from the keyboard to loopback a real PWM pin. Stupidly amusing.

1 Like

I got it working.

Proof of pwm fan ramping up:

Patches uploaded here:

To test fan speed control:

cd /sys/class/pwm/pwmchip0
echo 0 > export
cd pwm0
# 50_000_000ns, 50ms period
echo 50000000 > period
# enable it...
echo 1 > enable
# ramp it...
for i in {20000000,30000000,35000000,40000000,42000000,44000000,46000000,47000000,48000000,49000000,50000000}
  echo $i
  echo $i > duty_cycle
  read a

Yet pwmconfig doesn’t detect it :joy:
Once we figure it out we can have fancontrol taking over (maybe more advanced fan control? the last steps in the ramps are rather exponential).

PWM-enabled fan control daemon:

Weekend project done in the first night :sunglasses:
Strangely satisfying.