# Fan Speed Regulation PWM GPIO

**URL:** <https://discourse.nodered.org/t/fan-speed-regulation-pwm-gpio/66240>\
**Category:** General\
**Tags:** node-red-dashboard, function-node\
**Created:** [9 August 2022 15:54 UTC](https://discourse.nodered.org/t/fan-speed-regulation-pwm-gpio/66240 "2022-08-09T15:54:58Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sleep](https://avatars.discourse-cdn.com/v4/letter/s/4bbf92/32.png) [@Sleep](https://discourse.nodered.org/u/Sleep)\
**Post date:** [9 August 2022 15:54 UTC](https://discourse.nodered.org/t/fan-speed-regulation-pwm-gpio/66240/1 "2022-08-09T15:54:58Z")

</div>

Hi,

I want to regulate the fan speed of my Noctua fans through PWM & GPIO.

The fans are supplied by an external 12V power supply.

I have tried to control the speed through a GPIO-out node and a slider sending a 0 - 100 PWM signal.

What am I doing wrong? Are there any example flows available? I would highly appreciate any help!

---

<div class="post-metadata">

**Author:** ![dynamicdave](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dynamicdave/32/96_2.png) [@dynamicdave](https://discourse.nodered.org/u/dynamicdave)\
**Post date:** [9 August 2022 16:35 UTC](https://discourse.nodered.org/t/fan-speed-regulation-pwm-gpio/66240/2 "2022-08-09T16:35:04Z")

</div>

You don't say, but I assume you are using a Raspberry Pi.  
Be VERY CAREFUL with the GPIO pins on the Pi as they work at 3V3 logic levels.  
DO NOT connect them to anything higher than +3.3V otherwise you will destroy the device.

The best way to control a fan is with an H-bridge module. The inputs would accept a PWM signal as well a direction signal (although that isn't needed for your fans). Here's one example out of many.  
 ![h-bridge-2](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/d/8/d864fe06948975027c5d253d370c25d4ed53cb27.png)

> **[JZK® L298n dual H bridge DC stepper motor stepping motor controller board motor...](https://www.amazon.co.uk/stepper-stepping-controller-Arduino-Raspberry/dp/B071KZQLL4)**
>
> \* JZK L298n dual H-bridge dual H bridge DC stepper motor stepping motor controller board motor driver module for creating smart vehicle, robot, etc. \* Works with Arduino & Raspberry Pi. \* L298N as main driver chip makes strong driving ability, low...

---

<div class="post-metadata">

**Author:** ![dynamicdave](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dynamicdave/32/96_2.png) [@dynamicdave](https://discourse.nodered.org/u/dynamicdave)\
**Post date:** [9 August 2022 17:24 UTC](https://discourse.nodered.org/t/fan-speed-regulation-pwm-gpio/66240/3 "2022-08-09T17:24:57Z")

</div>

Here's a link to my slot-car racing project.  
This used a PWM pin driving a power transistor.

> [@Slot car racing - - - just pure fun](https://discourse.nodered.org/t/slot-car-racing-just-pure-fun/8782):
>
> I make no excuse at all - this is just pure fun. My students will love it !!!! I've just bought a slot car racing set from a local charity shop and have connected it to a WeMos D1 Mini on a breadboard driven from Node-RED via MQTT. On the breadboard is a PCA9685 (16-channel, 12-bit PWM module). It took some time sorting out the best PWM frequency and range settings, but eventually settled on 1500Hz with a range also of 1500. The car goes from a slow "creep" to just below "max speed", as at …

---

<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:** [9 August 2022 17:30 UTC](https://discourse.nodered.org/t/fan-speed-regulation-pwm-gpio/66240/4 "2022-08-09T17:30:46Z")

</div>

Is it the pwm that is not working? If so, then show us how you have configured the GPIO node.

---

<div class="post-metadata">

**Author:** ![Sleep](https://avatars.discourse-cdn.com/v4/letter/s/4bbf92/32.png) [@Sleep](https://discourse.nodered.org/u/Sleep)\
**Post date:** [9 August 2022 17:33 UTC](https://discourse.nodered.org/t/fan-speed-regulation-pwm-gpio/66240/5 "2022-08-09T17:33:47Z")

</div>

Hi Colin,

I have just connected at 0-100 slider sending a PWM signal to a GPIO-out node. I would like to control the fan from 0% to 100% RPM.

---

<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:** [9 August 2022 17:50 UTC](https://discourse.nodered.org/t/fan-speed-regulation-pwm-gpio/66240/6 "2022-08-09T17:50:36Z")

</div>

So which bit isn't working?

---

<div class="post-metadata">

**Author:** ![Sleep](https://avatars.discourse-cdn.com/v4/letter/s/4bbf92/32.png) [@Sleep](https://discourse.nodered.org/u/Sleep)\
**Post date:** [9 August 2022 18:05 UTC](https://discourse.nodered.org/t/fan-speed-regulation-pwm-gpio/66240/7 "2022-08-09T18:05:03Z")

</div>

The is going at full speed all the time, its not responding to the slider so I do not know how to achieve the desired fan speed.

---

<div class="post-metadata">

**Author:** ![dynamicdave](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dynamicdave/32/96_2.png) [@dynamicdave](https://discourse.nodered.org/u/dynamicdave)\
**Post date:** [9 August 2022 18:22 UTC](https://discourse.nodered.org/t/fan-speed-regulation-pwm-gpio/66240/8 "2022-08-09T18:22:22Z")

</div>

A circuit digram would be useful to see how you have connected things together.  
You could also try controlling an LED (rather than your set of fans) to just make sure the Pi is working.

---

<div class="post-metadata">

**Author:** ![Sleep](https://avatars.discourse-cdn.com/v4/letter/s/4bbf92/32.png) [@Sleep](https://discourse.nodered.org/u/Sleep)\
**Post date:** [9 August 2022 18:33 UTC](https://discourse.nodered.org/t/fan-speed-regulation-pwm-gpio/66240/9 "2022-08-09T18:33:11Z")

</div>

I dont really know which GPIO pins I need to connect the 2 PWMs on that are not the power supply

---

<div class="post-metadata">

**Author:** ![craigcurtin](https://avatars.discourse-cdn.com/v4/letter/c/94ad74/32.png) [@craigcurtin](https://discourse.nodered.org/u/craigcurtin)\
**Post date:** [9 August 2022 22:40 UTC](https://discourse.nodered.org/t/fan-speed-regulation-pwm-gpio/66240/10 "2022-08-09T22:40:34Z")

</div>

As the others have stated we will need a wiring diagram.

Do the fans have 3 or 4 wires going to them ?

Do you have any external hardware (i.e.an external PWM controller as noted below) or are you trying to do this all with the native RPi components ?

Craig

---

<div class="post-metadata">

**Author:** ![dynamicdave](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dynamicdave/32/96_2.png) [@dynamicdave](https://discourse.nodered.org/u/dynamicdave)\
**Post date:** [10 August 2022 05:15 UTC](https://discourse.nodered.org/t/fan-speed-regulation-pwm-gpio/66240/11 "2022-08-10T05:15:27Z")

</div>

As others have said, we need a wiring diagram from you - just a rough sketch would help.

I've quickly looked up Noctua fans and it would seem they have some circuitry built inside them.  
I found this whitepaper that describes Noctua's PWM specification. On the very last page is a suggested 'Driving' circuit using PMOS and NMOS transistors. This is needed to protect the microcontroller (your Raspberry Pi) and act as a level shifter. The paper seems to suggest you could use the output pin of a microcontroller. I've never allowed my IoT students to drive a fan in that way - as it too easy to mess things up and destroy an expensive RPi. Maybe other people on the forum will share their experiences.

> **[Noctua\_PWM\_specifications\_white\_paper.pdf](https://noctua.at/pub/media/wysiwyg/Noctua_PWM_specifications_white_paper.pdf)**
>
> 1147.47 KB

Note:  
My responses at the top of this thread related to using an H-bidge to control a **simple DC fan**.  
It would appear the range of Noctua fans are far more sophisticated devices (than the humble DC fan).

---

<div class="post-metadata">

**Author:** ![Sleep](https://avatars.discourse-cdn.com/v4/letter/s/4bbf92/32.png) [@Sleep](https://discourse.nodered.org/u/Sleep)\
**Post date:** [10 August 2022 07:09 UTC](https://discourse.nodered.org/t/fan-speed-regulation-pwm-gpio/66240/12 "2022-08-10T07:09:28Z")

</div>

Hi Dave,

It's a 4-pin fan and that is my current flow. Please take a look.

[{"id":"8000c717.f75478","type":"tab","label":"PWM","disabled":false,"info":""},{"id":"efcea890.a8b378","type":"ui\_slider","z":"8000c717.f75478","name":"","label":"slider","tooltip":"","group":"b1d154fe.797058","order":10,"width":0,"height":0,"passthru":true,"outs":"all","topic":"topic","topicType":"str","min":"0","max":"100","step":"10","className":"","x":160,"y":460,"wires":[["e27f416c.25704","512269b4.61e768"]]},{"id":"e27f416c.25704","type":"rpi-gpio out","z":"8000c717.f75478","name":"","pin":"32","set":"","level":"0","freq":"100","out":"pwm","x":780,"y":320,"wires":},{"id":"512269b4.61e768","type":"ui\_gauge","z":"8000c717.f75478","name":"","group":"b1d154fe.797058","order":11,"width":0,"height":0,"gtype":"gage","title":"gauge","label":"units","format":"{{value}}","min":0,"max":"100","colors":["#00b500","#e6e600","#ca3838"],"seg1":"","seg2":"","className":"","x":780,"y":200,"wires":},{"id":"dedaf0d8.7d8b8","type":"rpi-gpio in","z":"8000c717.f75478","name":"","pin":"36","intype":"up","debounce":"25","read":true,"x":400,"y":720,"wires":[["63f8225a.5ab11c","5d59222d.793e3c"]]},{"id":"63f8225a.5ab11c","type":"debug","z":"8000c717.f75478","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":660,"y":720,"wires":},{"id":"5d59222d.793e3c","type":"ui\_chart","z":"8000c717.f75478","name":"","group":"b1d154fe.797058","order":11,"width":0,"height":0,"label":"chart","chartType":"line","legend":"true","xformat":"HH:mm:ss","interpolate":"linear","nodata":"","dot":false,"ymin":"","ymax":"","removeOlder":1,"removeOlderPoints":"","removeOlderUnit":"60","cutout":0,"useOneColor":false,"useUTC":false,"colors":["#1f77b4","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"outputs":1,"useDifferentColor":false,"className":"","x":630,"y":640,"wires":[]},{"id":"63e9723e.f1146c","type":"ui\_switch","z":"8000c717.f75478","name":"","label":"switch","tooltip":"","group":"b1d154fe.797058","order":12,"width":0,"height":0,"passthru":false,"decouple":"false","topic":"topic","topicType":"msg","style":"","onvalue":"100","onvalueType":"str","onicon":"","oncolor":"","offvalue":"0","offvalueType":"str","officon":"","offcolor":"","animate":false,"className":"","x":520,"y":460,"wires":[["e27f416c.25704"]]},{"id":"e6137c50.e671d","type":"comment","z":"8000c717.f75478","name":"Noctua min frequency 18 kHz","info":"","x":870,"y":400,"wires":},{"id":"ab4b26aa.d7cdb8","type":"comment","z":"8000c717.f75478","name":"GPIO 32 - PWM ","info":"","x":840,"y":500,"wires":},{"id":"db8ecb7b.d53f48","type":"comment","z":"8000c717.f75478","name":"GPIO 36 - SPEED","info":"","x":850,"y":540,"wires":},{"id":"55ab8732.4e95d8","type":"comment","z":"8000c717.f75478","name":"Frequency 100 Hz ?","info":"","x":830,"y":440,"wires":},{"id":"b1d154fe.797058","type":"ui\_group","name":"PWM","tab":"74da6fee.87ce6","order":1,"disp":true,"width":"15","collapse":false,"className":""},{"id":"74da6fee.87ce6","type":"ui\_tab","name":"PWM","icon":"dashboard","disabled":false,"hidden":false}]

---

<div class="post-metadata">

**Author:** ![Sleep](https://avatars.discourse-cdn.com/v4/letter/s/4bbf92/32.png) [@Sleep](https://discourse.nodered.org/u/Sleep)\
**Post date:** [10 August 2022 07:10 UTC](https://discourse.nodered.org/t/fan-speed-regulation-pwm-gpio/66240/13 "2022-08-10T07:10:14Z")

</div>

Hi Craig,

It's a 4-pin fan and that is my current flow. Please take a look.

[{"id":"8000c717.f75478","type":"tab","label":"PWM","disabled":false,"info":""},{"id":"efcea890.a8b378","type":"ui\_slider","z":"8000c717.f75478","name":"","label":"slider","tooltip":"","group":"b1d154fe.797058","order":10,"width":0,"height":0,"passthru":true,"outs":"all","topic":"topic","topicType":"str","min":"0","max":"100","step":"10","className":"","x":160,"y":460,"wires":[["e27f416c.25704","512269b4.61e768"]]},{"id":"e27f416c.25704","type":"rpi-gpio out","z":"8000c717.f75478","name":"","pin":"32","set":"","level":"0","freq":"100","out":"pwm","x":780,"y":320,"wires":},{"id":"512269b4.61e768","type":"ui\_gauge","z":"8000c717.f75478","name":"","group":"b1d154fe.797058","order":11,"width":0,"height":0,"gtype":"gage","title":"gauge","label":"units","format":"{{value}}","min":0,"max":"100","colors":["#00b500","#e6e600","#ca3838"],"seg1":"","seg2":"","className":"","x":780,"y":200,"wires":},{"id":"dedaf0d8.7d8b8","type":"rpi-gpio in","z":"8000c717.f75478","name":"","pin":"36","intype":"up","debounce":"25","read":true,"x":400,"y":720,"wires":[["63f8225a.5ab11c","5d59222d.793e3c"]]},{"id":"63f8225a.5ab11c","type":"debug","z":"8000c717.f75478","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":660,"y":720,"wires":},{"id":"5d59222d.793e3c","type":"ui\_chart","z":"8000c717.f75478","name":"","group":"b1d154fe.797058","order":11,"width":0,"height":0,"label":"chart","chartType":"line","legend":"true","xformat":"HH:mm:ss","interpolate":"linear","nodata":"","dot":false,"ymin":"","ymax":"","removeOlder":1,"removeOlderPoints":"","removeOlderUnit":"60","cutout":0,"useOneColor":false,"useUTC":false,"colors":["#1f77b4","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"outputs":1,"useDifferentColor":false,"className":"","x":630,"y":640,"wires":[]},{"id":"63e9723e.f1146c","type":"ui\_switch","z":"8000c717.f75478","name":"","label":"switch","tooltip":"","group":"b1d154fe.797058","order":12,"width":0,"height":0,"passthru":false,"decouple":"false","topic":"topic","topicType":"msg","style":"","onvalue":"100","onvalueType":"str","onicon":"","oncolor":"","offvalue":"0","offvalueType":"str","officon":"","offcolor":"","animate":false,"className":"","x":520,"y":460,"wires":[["e27f416c.25704"]]},{"id":"e6137c50.e671d","type":"comment","z":"8000c717.f75478","name":"Noctua min frequency 18 kHz","info":"","x":870,"y":400,"wires":},{"id":"ab4b26aa.d7cdb8","type":"comment","z":"8000c717.f75478","name":"GPIO 32 - PWM ","info":"","x":840,"y":500,"wires":},{"id":"db8ecb7b.d53f48","type":"comment","z":"8000c717.f75478","name":"GPIO 36 - SPEED","info":"","x":850,"y":540,"wires":},{"id":"55ab8732.4e95d8","type":"comment","z":"8000c717.f75478","name":"Frequency 100 Hz ?","info":"","x":830,"y":440,"wires":},{"id":"b1d154fe.797058","type":"ui\_group","name":"PWM","tab":"74da6fee.87ce6","order":1,"disp":true,"width":"15","collapse":false,"className":""},{"id":"74da6fee.87ce6","type":"ui\_tab","name":"PWM","icon":"dashboard","disabled":false,"hidden":false}]

---

<div class="post-metadata">

**Author:** ![dynamicdave](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dynamicdave/32/96_2.png) [@dynamicdave](https://discourse.nodered.org/u/dynamicdave)\
**Post date:** [10 August 2022 07:19 UTC](https://discourse.nodered.org/t/fan-speed-regulation-pwm-gpio/66240/14 "2022-08-10T07:19:08Z")

</div>

Sorry I can't import your flow.  
Have a look at this link that explains how to do it...

> [@How to share code or flow json](https://discourse.nodered.org/t/how-to-share-code-or-flow-json/506):
>
> To share code samples or flow json in this forum, you need to take care to format it properly so that it is displayed correctly. The easiest way to do that is to click the 'Preformatted Text' button in the toolbar: [image] Then paste in your code or flow json. You should end up with three back-tick characters - ``` - on their own line before and after the code. On standard US English keyboards, this is on the same key as the ~ character. Using the backticks will ens…

---

<div class="post-metadata">

**Author:** ![craigcurtin](https://avatars.discourse-cdn.com/v4/letter/c/94ad74/32.png) [@craigcurtin](https://discourse.nodered.org/u/craigcurtin)\
**Post date:** [10 August 2022 07:33 UTC](https://discourse.nodered.org/t/fan-speed-regulation-pwm-gpio/66240/15 "2022-08-10T07:33:40Z")

</div>

And as asked a number of times please post a wiring diagram so we can see how you are hooking this all up

Craig

---

<div class="post-metadata">

**Author:** ![Sleep](https://avatars.discourse-cdn.com/v4/letter/s/4bbf92/32.png) [@Sleep](https://discourse.nodered.org/u/Sleep)\
**Post date:** [10 August 2022 07:35 UTC](https://discourse.nodered.org/t/fan-speed-regulation-pwm-gpio/66240/16 "2022-08-10T07:35:34Z")

</div>

```auto
[
    {
        "id": "8000c717.f75478",
        "type": "tab",
        "label": "PWM",
        "disabled": false,
        "info": ""
    },
    {
        "id": "efcea890.a8b378",
        "type": "ui_slider",
        "z": "8000c717.f75478",
        "name": "",
        "label": "slider",
        "tooltip": "",
        "group": "b1d154fe.797058",
        "order": 10,
        "width": 0,
        "height": 0,
        "passthru": true,
        "outs": "all",
        "topic": "topic",
        "topicType": "str",
        "min": "0",
        "max": "100",
        "step": "10",
        "className": "",
        "x": 160,
        "y": 460,
        "wires": [
            [
                "e27f416c.25704",
                "512269b4.61e768"
            ]
        ]
    },
    {
        "id": "e27f416c.25704",
        "type": "rpi-gpio out",
        "z": "8000c717.f75478",
        "name": "",
        "pin": "32",
        "set": "",
        "level": "0",
        "freq": "100",
        "out": "pwm",
        "x": 780,
        "y": 320,
        "wires": []
    },
    {
        "id": "512269b4.61e768",
        "type": "ui_gauge",
        "z": "8000c717.f75478",
        "name": "",
        "group": "b1d154fe.797058",
        "order": 11,
        "width": 0,
        "height": 0,
        "gtype": "gage",
        "title": "gauge",
        "label": "units",
        "format": "{{value}}",
        "min": 0,
        "max": "100",
        "colors": [
            "#00b500",
            "#e6e600",
            "#ca3838"
        ],
        "seg1": "",
        "seg2": "",
        "className": "",
        "x": 780,
        "y": 200,
        "wires": []
    },
    {
        "id": "dedaf0d8.7d8b8",
        "type": "rpi-gpio in",
        "z": "8000c717.f75478",
        "name": "",
        "pin": "36",
        "intype": "up",
        "debounce": "25",
        "read": true,
        "x": 400,
        "y": 720,
        "wires": [
            [
                "63f8225a.5ab11c",
                "5d59222d.793e3c"
            ]
        ]
    },
    {
        "id": "63f8225a.5ab11c",
        "type": "debug",
        "z": "8000c717.f75478",
        "name": "",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 660,
        "y": 720,
        "wires": []
    },
    {
        "id": "5d59222d.793e3c",
        "type": "ui_chart",
        "z": "8000c717.f75478",
        "name": "",
        "group": "b1d154fe.797058",
        "order": 11,
        "width": 0,
        "height": 0,
        "label": "chart",
        "chartType": "line",
        "legend": "true",
        "xformat": "HH:mm:ss",
        "interpolate": "linear",
        "nodata": "",
        "dot": false,
        "ymin": "",
        "ymax": "",
        "removeOlder": 1,
        "removeOlderPoints": "",
        "removeOlderUnit": "60",
        "cutout": 0,
        "useOneColor": false,
        "useUTC": false,
        "colors": [
            "#1f77b4",
            "#aec7e8",
            "#ff7f0e",
            "#2ca02c",
            "#98df8a",
            "#d62728",
            "#ff9896",
            "#9467bd",
            "#c5b0d5"
        ],
        "outputs": 1,
        "useDifferentColor": false,
        "className": "",
        "x": 630,
        "y": 640,
        "wires": [
            []
        ]
    },
    {
        "id": "e6137c50.e671d",
        "type": "comment",
        "z": "8000c717.f75478",
        "name": "Noctua min frequency 18 kHz",
        "info": "",
        "x": 870,
        "y": 400,
        "wires": []
    },
    {
        "id": "ab4b26aa.d7cdb8",
        "type": "comment",
        "z": "8000c717.f75478",
        "name": "GPIO 32 - PWM ",
        "info": "",
        "x": 840,
        "y": 500,
        "wires": []
    },
    {
        "id": "db8ecb7b.d53f48",
        "type": "comment",
        "z": "8000c717.f75478",
        "name": "GPIO 36 - SPEED",
        "info": "",
        "x": 850,
        "y": 540,
        "wires": []
    },
    {
        "id": "55ab8732.4e95d8",
        "type": "comment",
        "z": "8000c717.f75478",
        "name": "Frequency 100 Hz ?",
        "info": "",
        "x": 830,
        "y": 440,
        "wires": []
    },
    {
        "id": "b1d154fe.797058",
        "type": "ui_group",
        "name": "PWM",
        "tab": "74da6fee.87ce6",
        "order": 1,
        "disp": true,
        "width": "15",
        "collapse": false,
        "className": ""
    },
    {
        "id": "74da6fee.87ce6",
        "type": "ui_tab",
        "name": "PWM",
        "icon": "dashboard",
        "disabled": false,
        "hidden": false
    }
]

```

---

<div class="post-metadata">

**Author:** ![dynamicdave](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dynamicdave/32/96_2.png) [@dynamicdave](https://discourse.nodered.org/u/dynamicdave)\
**Post date:** [10 August 2022 08:11 UTC](https://discourse.nodered.org/t/fan-speed-regulation-pwm-gpio/66240/17 "2022-08-10T08:11:02Z")

</div>

OK - managed to import your flow.  
 ![pwm_flow](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/6/9/6974a10de1f168a636e53bd8427a5c75d1faa51e.png)  
On the face of it, it looks as if the flow should work, however, I don't use the GPIO pins on my RPi so I can't test it. Like Craig said, a hook-up diagram would be useful.

Some things you could try...

1. **I assume you have a GND connection between the RPi and the 4-pin plug.**
2. I assume you have installed the Python library that is mentioned in the Help panel.
3. You could try using an LED and a series resistor (any value between 220 ohms to 1k should work) instead of the fan and see if you can control its illumination. That way you can rule out issues with the fan.

I'll see if I can find an old RPi later today and try your flow.

---

<div class="post-metadata">

**Author:** ![dynamicdave](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dynamicdave/32/96_2.png) [@dynamicdave](https://discourse.nodered.org/u/dynamicdave)\
**Post date:** [10 August 2022 09:05 UTC](https://discourse.nodered.org/t/fan-speed-regulation-pwm-gpio/66240/18 "2022-08-10T09:05:43Z")

</div>

I've just found an old RPi-Zero-H and connected an LED to pin 40 (GPIO-21) and GND to pin 39.  
Your PWM flow works fine with the LED, so you need to check some of the other things I suggested.

 ![pwm_wiring](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/1/c/1c159dbf59afd454e47347221d2b3f689ee74b3d.jpeg)  
 ![my_pwm](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/c/f/cf99e57260ea5222a04f7df685e9f7df971307a0.png)

---

<div class="post-metadata">

**Author:** ![Sleep](https://avatars.discourse-cdn.com/v4/letter/s/4bbf92/32.png) [@Sleep](https://discourse.nodered.org/u/Sleep)\
**Post date:** [10 August 2022 09:18 UTC](https://discourse.nodered.org/t/fan-speed-regulation-pwm-gpio/66240/19 "2022-08-10T09:18:31Z")

</div>

Hi Dave,

Thanks for your help. Since I have an external 12V power supply for the fans there's no GND connection between the RPI and the 4-pin plug. Is this neccessary? And if so do you have any solution?

---

<div class="post-metadata">

**Author:** ![dynamicdave](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dynamicdave/32/96_2.png) [@dynamicdave](https://discourse.nodered.org/u/dynamicdave)\
**Post date:** [10 August 2022 09:28 UTC](https://discourse.nodered.org/t/fan-speed-regulation-pwm-gpio/66240/20 "2022-08-10T09:28:12Z")

</div>

YES it is necessary to tie the grounds together (otherwsie everything floats and nothing works!!).  
How are you connecting the output pin of the RPi to the 4-pin plug?

If you had shown us your connection diagram, as requested, we could have got to this point much faster.

[Next page](https://discourse.nodered.org/t/fan-speed-regulation-pwm-gpio/66240.md?page=2)
