# PWM fan control over GPIO

**URL:** <https://discourse.nodered.org/t/pwm-fan-control-over-gpio/47682>\
**Category:** General\
**Created:** [25 June 2021 21:01 UTC](https://discourse.nodered.org/t/pwm-fan-control-over-gpio/47682 "2021-06-25T21:01:13Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Becker](https://avatars.discourse-cdn.com/v4/letter/b/c77e96/32.png) [@Becker](https://discourse.nodered.org/u/Becker)\
**Post date:** [25 June 2021 21:01 UTC](https://discourse.nodered.org/t/pwm-fan-control-over-gpio/47682/1 "2021-06-25T21:01:13Z")

</div>

Hi,  
i want to obstruct the originally pwm fan

> **[Buy a Raspberry Pi 4 Case Fan – Raspberry Pi](https://www.raspberrypi.org/products/raspberry-pi-4-case-fan/)**
>
> Works with Raspberry Pi 4 and the Raspberry Pi 4 Case. Designed for overclockers and other power users, it keeps your Raspberry Pi 4 at a comfortable operating temperature even under heavy load

you can activate it by OS, but only on/off at 60°C over pwm gpio.

can I set the pwm by using gpio out:  
 ![grafik](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/3/d/3da078d9613429b39a643dfac0b52cf33dcf532f.png)

I'm not sure, because you should only set it up to a maximum of 100 Hz says the node.

I thought fan control pwm works at about 25000 Hz ?  
but I don´t know about the range of the original RPi fan.

---

<div class="post-metadata">

**Author:** ![Gunner](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gunner/32/43582_2.png) [@Gunner](https://discourse.nodered.org/u/Gunner)\
**Post date:** [25 June 2021 22:57 UTC](https://discourse.nodered.org/t/pwm-fan-control-over-gpio/47682/2 "2021-06-25T22:57:16Z")

</div>

So... what happens when you try a range between 0 and 100? Often an answer can be found by testing. Something we can't do from here, in your case.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [26 June 2021 07:44 UTC](https://discourse.nodered.org/t/pwm-fan-control-over-gpio/47682/3 "2021-06-26T07:44:35Z")

</div>

What makes you think that it will not work with 100hz?

> [@Becker](#):
>
> I thought fan control pwm works at about 25000 Hz

What makes you think that?

---

<div class="post-metadata">

**Author:** ![Christian-Me](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/christian-me/32/10774_2.png) [@Christian-Me](https://discourse.nodered.org/u/Christian-Me)\
**Post date:** [26 June 2021 09:39 UTC](https://discourse.nodered.org/t/pwm-fan-control-over-gpio/47682/4 "2021-06-26T09:39:29Z")

</div>

If you use a 4 wire fan:

> Target **frequency** 25 kHz, acceptable operational range 21 kHz to 28 kHz

[https://www.electroschematics.com/4-wire-pc-fan/](https://www.electroschematics.com/4-wire-pc-fan/)  
On raspberries the pwm freqency is limited (as it is software generated)

> The minimum PWM output frequency is 10 Hz. The maximum PWM output frequency is 8 KHz using writePWMFrequency(mypi, 12, 8000).

Perhaps use a i2c pwm controller chip.

You probably don’t want to dedicate one core of your raspberry to generate a pwm signal too cool the cpu just because you generate the pwm to cool …. 🌞

If you use a standard dc fan you need a mosfet and filtering to run your fan smoothly. You can perhaps get rid of some filters on higher frequencies but you run into hearable hiss or other noises and emi problems as you push spiky pulses along a wire

---

<div class="post-metadata">

**Author:** ![Christian-Me](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/christian-me/32/10774_2.png) [@Christian-Me](https://discourse.nodered.org/u/Christian-Me)\
**Post date:** [26 June 2021 10:04 UTC](https://discourse.nodered.org/t/pwm-fan-control-over-gpio/47682/5 "2021-06-26T10:04:49Z")

</div>

Quickly looking @ the spec they use the serial UART tx pin to drive the pwm. The serial controller probably able to generate the 25k.  
So you probably take a look into that path.  
But I’m not a raspberry expert. I would go the i2c path as it is always better to have real hardware pwm.

---

<div class="post-metadata">

**Author:** ![Becker](https://avatars.discourse-cdn.com/v4/letter/b/c77e96/32.png) [@Becker](https://discourse.nodered.org/u/Becker)\
**Post date:** [27 June 2021 20:30 UTC](https://discourse.nodered.org/t/pwm-fan-control-over-gpio/47682/6 "2021-06-27T20:30:01Z")

</div>

I don´t have the fan here yet aaaand on the Pi4 Node-Red is not installed. 😬

I think I give the os-fan controll a chance, but on off with pwm 0 / 1 should also be ok.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [26 August 2021 20:30 UTC](https://discourse.nodered.org/t/pwm-fan-control-over-gpio/47682/7 "2021-08-26T20:30:04Z")

</div>

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