acri0002
Posts: 1
Joined: Sun Jun 04, 2023 5:47 pm

Control Noctua 5v PWM fan speed using pi 3b+

Sun Jun 04, 2023 5:52 pm

Hi I am trying tp control the speed of my noctua fan to no avaiI. Can anyone please help?

I connected my fan to VCC(5v), GND and GPIO18(PWM) and my goal is to rotate my fan based on given duty cycles. However, when I switch on my Pi, (Pi 3b+) the fan rotates without me running my script. When I do run my script, my fans stops then start again (I think some values of my code are sent to the pi) but later just keeps rotating without stopping.

Here is my Code:
import Rpi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BCM)

fan_pin = 18
frequency = 100
GPIO.setup(fan_pin, GPIO.OUT)

pwm = GPIO.PWM(fan_pin, frequency)
pwm.start(0)

for duty_cycle in range(0, 101, 10 )
pwm.ChangeDutyCycle(duty_cycle)
time.sleep(10)

pwm.stop()
GPIO.cleanup

My idea is to have my pwm fan rotate at 10 different speeds for 10 seconds each. Can anyone please assist? Thanks

lurk101
Posts: 2292
Joined: Mon Jan 27, 2020 2:35 pm
Location: Cumming, GA (US)

Re: Control Noctua 5v PWM fan speed using pi 3b+

Sun Jun 04, 2023 8:44 pm

acri0002 wrote:
Sun Jun 04, 2023 5:52 pm
Hi I am trying tp control the speed of my noctua fan to no avaiI. Can anyone please help?

I connected my fan to VCC(5v), GND and GPIO18(PWM) and my goal is to rotate my fan based on given duty cycles. However, when I switch on my Pi, (Pi 3b+) the fan rotates without me running my script. When I do run my script, my fans stops then start again (I think some values of my code are sent to the pi) but later just keeps rotating without stopping.

Code: Select all

Here is my Code:
import Rpi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BCM)

fan_pin = 18
frequency = 100
GPIO.setup(fan_pin, GPIO.OUT)

pwm = GPIO.PWM(fan_pin, frequency)
pwm.start(0)

for duty_cycle in range(0, 101, 10 )
      pwm.ChangeDutyCycle(duty_cycle)
      time.sleep(10)

pwm.stop()
GPIO.cleanup
My idea is to have my pwm fan rotate at 10 different speeds for 10 seconds each. Can anyone please assist? Thanks
Noctua fans require a PWM frequency of approximately 15 KHz. They work fine with the 3.3V PWM signal you're providing via GPIO.

User avatar
HawaiianPi
Posts: 7850
Joined: Mon Apr 08, 2013 4:53 am
Location: Aloha, Oregon USA

Re: Control Noctua 5v PWM fan speed using pi 3b+

Sun Jun 04, 2023 9:22 pm

Tell us which model Noctua fan are you using, and show us how it's wired to the Pi GPIO.

I'm using a Noctua NF-A4x10 5V PWM fan with the yellow wire connected to GPIO header pin #4 (5V), the black wire on pin #6 (GND), and the blue PWM wire on pin #12 (GPIO 18). I'm not using the green tach wire.

I have been able to control the speed using Python or another utility posted by a forum member I can't recall the name of at the moment.
My mind is like a browser. 27 tabs are open, 9 aren't responding,
lots of pop-ups, and where is that annoying music coming from?

lurk101
Posts: 2292
Joined: Mon Jan 27, 2020 2:35 pm
Location: Cumming, GA (US)

Re: Control Noctua 5v PWM fan speed using pi 3b+

Sun Jun 04, 2023 11:00 pm

acri0002 wrote:
Sun Jun 04, 2023 5:52 pm
I connected my fan to VCC(5v), GND and GPIO18(PWM) and my goal is to rotate my fan based on given duty cycles. However, when I switch on my Pi, (Pi 3b+) the fan rotates without me running my script.
This is normal. The Noctua PWM line has a builtin pull up resistor. That combined with GPIO 18 in the default high-impedance input mode looks like a PWM signal at 100%.
When I do run my script, my fans stops then start again (I think some values of my code are sent to the pi) but later just keeps rotating without stopping.
I'm not familiar with the Rpi.GPIO package, but it looks like you're setting the PWM frequency to 100 Hz which is too low. Try specifying a PWM frequency of 15,000 Hz.

ame
Posts: 7850
Joined: Sat Aug 18, 2012 1:21 am
Location: New Zealand

Re: Control Noctua 5v PWM fan speed using pi 3b+

Mon Jun 05, 2023 12:11 am

lurk101 wrote:
Sun Jun 04, 2023 11:00 pm
acri0002 wrote:
Sun Jun 04, 2023 5:52 pm
I connected my fan to VCC(5v), GND and GPIO18(PWM) and my goal is to rotate my fan based on given duty cycles. However, when I switch on my Pi, (Pi 3b+) the fan rotates without me running my script.
This is normal. The Noctua PWM line has a builtin pull up resistor. That combined with GPIO 18 in the default high-impedance input mode looks like a PWM signal at 100%.
When I do run my script, my fans stops then start again (I think some values of my code are sent to the pi) but later just keeps rotating without stopping.
I'm not familiar with the Rpi.GPIO package, but it looks like you're setting the PWM frequency to 100 Hz which is too low. Try specifying a PWM frequency of 15,000 Hz.
According to the Noctua data sheet the target frequency is 25kHz, with an acceptable range of 21kHz to 28kHz.
Oh no, not again.

Return to “Interfacing (DSI, CSI, I2C, etc.)”