2 2
haajee

OrangePi 4 temperature controlled PWM fan

Recommended Posts

Hi all,

 

So if a lot of you maybe know is a heatsink and fan  a must for the OrangePi 4. With my temporarly installed fan makes a lot of noise i maked yesterday the step to order a Noctua NF-A4x20 5V PWM. The price was arround €17,- not the cheapest but te reviews are amazing.

 

Even on full speed its a lot more silence then the 20x20 mini fan but with a good air flow. But as you could read did i choose for a PWM variant so i could control the rpm´s with a PWM GPIO pin. And amazingly it did work! I have the PWM pin connected to pin 7 of the OrangePi 4.

 

Commands to start pwm for the first time:

 

cd /sys/class/pwm/pwmchip1/
echo 0 > export
  
echo 1000000 > pwmchip1/pwm0/period

echo 500000 > pwm0/duty_cycle
  
#and with this step the fan goes on a lower speed
  
echo 1 > pwm0/enable

#and back on full speed without PWM

echo 0 > pwm0/enable

 

So it´s really nice. And i found a nice script for the Nanopi M4 with also a RK3399 chip from @mar0ni in this topic

 

To make it complete i paste also here the script from @mar0n

Share this post


Link to post
Share on other sites
Just now, haajee said:

Hi all,

 

So if a lot of you maybe know is a heatsink and fan  a must for the OrangePi 4. With my temporarly installed fan makes a lot of noise i maked yesterday the step to order a Noctua NF-A4x20 5V PWM. The price was arround €17,- not the cheapest but te reviews are amazing.

 

Even on full speed its a lot more silence then the 20x20 mini fan but with a good air flow. But as you could read did i choose for a PWM variant so i could control the rpm´s with a PWM GPIO pin. And amazingly it did work! I have the PWM pin connected to pin 7 of the OrangePi 4.

 

Commands to start pwm for the first time:

 


cd /sys/class/pwm/pwmchip1/
echo 0 > export
  
echo 1000000 > pwmchip1/pwm0/period

echo 500000 > pwm0/duty_cycle
  
#and with this step the fan goes on a lower speed
  
echo 1 > pwm0/enable

#and back on full speed without PWM

echo 0 > pwm0/enable

 

So it´s really nice. And i found a nice script for the Nanopi M4 with also a RK3399 chip from @mar0ni in this topic

 

To make it complete i paste also here the script from @mar0ni

 


#!/bin/bash

if [ ! -d /sys/class/pwm/pwmchip1/pwm0 ]; then
    echo 0 > /sys/class/pwm/pwmchip1/export
fi
sleep 1
while [ ! -d /sys/class/pwm/pwmchip1/pwm0 ];
do
    sleep 1
done
ISENABLE=`cat /sys/class/pwm/pwmchip1/pwm0/enable`
if [ $ISENABLE -eq 1 ]; then
    echo 0 > /sys/class/pwm/pwmchip1/pwm0/enable
fi
echo 50000 > /sys/class/pwm/pwmchip1/pwm0/period
echo 1 > /sys/class/pwm/pwmchip1/pwm0/enable

# max speed run 5s
echo 0 > /sys/class/pwm/pwmchip1/pwm0/duty_cycle
sleep 5
echo 49994 > /sys/class/pwm/pwmchip1/pwm0/duty_cycle

declare -a CpuTemps=(75000 63000 58000 52000 48000 0)
declare -a PwmDutyCycles=(25000 37000 48300 49250 49300 49994)

while true
do
	temp=$(cat /sys/class/thermal/thermal_zone0/temp)
	for i in 0 1 2 3 4 5; do
		if [ $temp -gt ${CpuTemps[$i]} ]; then
			DUTY=${PwmDutyCycles[$i]}
			echo $DUTY > "/sys/class/pwm/pwmchip1/pwm0/duty_cycle";
			#echo "temp: $temp, target: ${CpuTemps[$i]}, duty: $DUTY"
			break		
		fi
	done
	sleep 2s;
done

 

I saved the file in my home dir as pwm-fan.sh and run it as administrator with

bash ./pwm-fan.sh

And the fan spins up full speed but after that it stops running. Even when the temperature is over the 30 degrees celsius. I have changed 48000 in the above script to 30000. So i think there is also something else to change but i have no idea what. Who could help me? :)

Share this post


Link to post
Share on other sites

Oh i see now there is a # for the echo temperature. Deleted and worked. #echo "temp: $temp, target: ${CpuTemps[$i]}, duty: $DUTY"

Share this post


Link to post
Share on other sites
On 4/19/2020 at 6:25 AM, VyacheslavS said:

@haajee,

I have for some reason does not work, there is no signal from the 7 pin.

Kernel 5.6.3 Buster.

What else do I need to do to make it work?

 

Oh sorry i didn´t saw your post. My fan script is now:

 

#!/bin/bash

if [ ! -d /sys/class/pwm/pwmchip1/pwm0 ]; then
    echo 0 > /sys/class/pwm/pwmchip1/export
fi
sleep 1
while [ ! -d /sys/class/pwm/pwmchip1/pwm0 ];
do
    sleep 1
done
ISENABLE=`cat /sys/class/pwm/pwmchip1/pwm0/enable`
if [ $ISENABLE -eq 1 ]; then
    echo 0 > /sys/class/pwm/pwmchip1/pwm0/enable
fi
echo 50000 > /sys/class/pwm/pwmchip1/pwm0/period
echo 1 > /sys/class/pwm/pwmchip1/pwm0/enable

# max speed run 60s
echo 0 > /sys/class/pwm/pwmchip1/pwm0/duty_cycle
sleep 5
echo 50000 > /sys/class/pwm/pwmchip1/pwm0/duty_cycle

declare -a CpuTemps=(45000 40000 38000 30000 28000 0)
declare -a PwmDutyCycles=(1000 5000 10000 15000 30000)

while true
do
        temp=$(cat /sys/class/thermal/thermal_zone0/temp)
        for i in 0 1 2 3 4 5; do
                if [ $temp -gt ${CpuTemps[$i]} ]; then
                        DUTY=${PwmDutyCycles[$i]}
                        echo $DUTY > "/sys/class/pwm/pwmchip1/pwm0/duty_cycle";
                        echo "temp: $temp, target: ${CpuTemps[$i]}, duty: $DUTY"
                        break
                fi
        done
        sleep 1s;
done

Do you see something if you go to /sys/class/pwm/pwmchip1?  And do you have installed wiring orangepi from:  https://github.com/orangepi-xunlong/wiringOP ?? what does the command gpio readall shows?

Share this post


Link to post
Share on other sites
On 7/9/2020 at 2:45 AM, haajee said:

what does the command gpio readall shows?

$ gpio readall shows
 +------+-----+----------+------+---+OrangePi 4+---+---+--+----------+-----+------+
 | GPIO | wPi |   Name   | Mode | V | Physical | V | Mode | Name     | wPi | GPIO |
 +------+-----+----------+------+---+----++----+---+------+----------+-----+------+
 |      |     |     3.3V |      |   |  1 || 2  |   |      | 5V       |     |      |
 |   64 |   0 | I2C2_SDA |   IN | 0 |  3 || 4  |   |      | 5V       |     |      |
 |   65 |   1 | I2C2_SCL |   IN | 0 |  5 || 6  |   |      | GND      |     |      |
 |  150 |   2 |     PWM1 | ALT2 | 1 |  7 || 8  | 1 | ALT2 | I2C3_SCL | 3   | 145  |
 |      |     |      GND |      |   |  9 || 10 | 1 | ALT2 | I2C3_SDA | 4   | 144  |
 |   33 |   5 | GPIO1_A1 |   IN | 0 | 11 || 12 | 1 | IN   | GPIO1_C2 | 6   | 50   |
 |   35 |   7 | GPIO1_A3 |  OUT | 1 | 13 || 14 |   |      | GND      |     |      |
 |   92 |   8 | GPIO2_D4 |   IN | 0 | 15 || 16 | 0 | IN   | GPIO1_C6 | 9   | 54   |
 |      |     |     3.3V |      |   | 17 || 18 | 0 | IN   | GPIO1_C7 | 10  | 55   |
 |   40 |  11 | SPI1_TXD | ALT3 | 0 | 19 || 20 |   |      | GND      |     |      |
 |   39 |  12 | SPI1_RXD | ALT3 | 1 | 21 || 22 | 0 | IN   | GPIO1_D0 | 13  | 56   |
 |   41 |  14 | SPI1_CLK | ALT3 | 1 | 23 || 24 | 1 | ALT3 | SPI1_CS  | 15  | 42   |
 |      |     |      GND |      |   | 25 || 26 | 0 | IN   | GPIO4_C5 | 16  | 149  |
 |   64 |  17 | I2C2_SDA |   IN | 0 | 27 || 28 | 0 | IN   | I2C2_SCL | 18  | 65   |
 |      |     |  I2S0_RX |      |   | 29 || 30 |   |      | GND      |     |      |
 |      |     |  I2S0_TX |      |   | 31 || 32 |   |      | I2S_CLK  |     |      |
 |      |     | I2S0_SCK |      |   | 33 || 34 |   |      | GND      |     |      |
 |      |     | I2S0_SI0 |      |   | 35 || 36 |   |      | I2S0_SO0 |     |      |
 |      |     | I2S0_SI1 |      |   | 37 || 38 |   |      | I2S0_SI2 |     |      |
 |      |     |      GND |      |   | 39 || 40 |   |      | I2S0_SI3 |     |      |
 +------+-----+----------+------+---+----++----+---+------+----------+-----+------+
 | GPIO | wPi |   Name   | Mode | V | Physical | V | Mode | Name     | wPi | GPIO |
 +------+-----+----------+------+---+OrangePi 4+---+---+--+----------+-----+------+

 

On 7/9/2020 at 2:45 AM, haajee said:

Do you see something if you go to /sys/class/pwm/pwmchip1?

$ ls /sys/class/pwm/pwmchip1
device  export  npwm  power  subsystem  uevent  unexport

I don't have a pwm0 folder.

 

On 7/9/2020 at 2:45 AM, haajee said:

And do you have installed wiring orangepi from:  https://github.com/orangepi-xunlong/wiringOP ??

Yes.

Share this post


Link to post
Share on other sites

@haajee , This is a problem with my cooler.  It starts rotating with 3.3 V. If the tension is less, then silence.

I took voltage measurements from 7 pin.  The voltage on this pin is: min=1.0 V, max=2.9 V.

Tell me please did you connect Noctua NF-A4x20 5V PWM directly or via MOSFET?

In Noctua cooler with 4 pins or 3 pins?

Share this post


Link to post
Share on other sites
On 7/11/2020 at 2:25 PM, VyacheslavS said:

@haajee , This is a problem with my cooler.  It starts rotating with 3.3 V. If the tension is less, then silence.

I took voltage measurements from 7 pin.  The voltage on this pin is: min=1.0 V, max=2.9 V.

Tell me please did you connect Noctua NF-A4x20 5V PWM directly or via MOSFET?

In Noctua cooler with 4 pins or 3 pins?

 

Very sorry for my always late anwsers. I have my nf-a4x20-5v-pwm directly connected to gnd and 5V pin on the orange pi. The PWM pin do i have connected to pin 7. The RPM pin did i have not connected. I have bought the Noctua in a local internet store for arround €12,- without shipping. The fan is also on full speed so much silent than al the fans i got. I am a really Fanboy now of Noctua ;) I could advice you to buy. :) more specifications are here https://noctua.at/en/products/fan/nf-a4x20-5v-pwm

 

All what you post is exactly the same what i have... I don´t see a different.

 

Share this post


Link to post
Share on other sites
On 8/2/2020 at 3:32 AM, haajee said:

I have bought the Noctua in a local internet store for arround €12,- without shipping.

 

I also bought the same one, about 15 Euros.  I configured the script and now it starts to rotate from +35, the rotation speed is floating. The maximum spin speed starts at +60 . This cooler is really quiet and worth it money.

Share this post


Link to post
Share on other sites

Another solution to avoid noise and fan management for orange pi 4 is to use a big heatsink (fanless solution):

 

Orange Pi 4 Heatsink

 

I tried it and it works well.

 

The temperature can rise to 85°C in peak (and 82°C in average) when I tried to stress the cpu with benchmark or with high resolution youtube video, but I never stayed stuck due to a overheat.

In normal use, I have more something between 58 to 65 °C.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
2 2