# Hardware PWM Node-Red

**URL:** https://discourse.nodered.org/t/hardware-pwm-node-red/66733
**Category:** General
**Tags:** node-red-dashboard, function-node
**Created:** [21 August 2022 18:21 UTC](https://discourse.nodered.org/t/hardware-pwm-node-red/66733 "2022-08-21T18:21:08Z")
**Posts on this page:** 10
**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: [21 August 2022 18:21 UTC](https://discourse.nodered.org/t/hardware-pwm-node-red/66733/1 "2022-08-21T18:21:08Z")

</div>

Hi

I'm looking for a way to use fully hardware PWM on my RPi Zero.  
I want to control a PWM fan requiring 28 kHz.  
The GPIO PWM nodes are software only (?).

Does anyone have a script to control the PWM signal through red node?

---

<div class="post-metadata">

### Author: ![iiot2k](https://avatars.discourse-cdn.com/v4/letter/i/8baadc/32.png) [@iiot2k](https://discourse.nodered.org/u/iiot2k)
#### Post date: [21 August 2022 19:21 UTC](https://discourse.nodered.org/t/hardware-pwm-node-red/66733/2 "2022-08-21T19:21:40Z")

</div>

Hi Sleep,

you can use this module:  
This is a 1Hz-150Khz Signal Generator Modul.

 ![s-l1600](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/c/2/c276471f8585111c2ae92f8acb4e5b96aa0cec88.jpeg)  
 ![s-l1600](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/8/9/89e013fad0f92723f1a491b8eb3e341ecf139bbd.jpeg)  
They have RX and TX inputs.  
Connect only to RX with 9600bps, 1 stop bit.  
Send string "F28.0" for 28kHz.  
Send string "D050" for 50% duty.  
Use serial node in Node-Red.

---

<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: [21 August 2022 19:41 UTC](https://discourse.nodered.org/t/hardware-pwm-node-red/66733/3 "2022-08-21T19:41:56Z")

</div>

It's not possible without this additional hardware?  
Would it be possible to create the PWM with RPi hardware?

---

<div class="post-metadata">

### Author: ![iiot2k](https://avatars.discourse-cdn.com/v4/letter/i/8baadc/32.png) [@iiot2k](https://discourse.nodered.org/u/iiot2k)
#### Post date: [21 August 2022 19:54 UTC](https://discourse.nodered.org/t/hardware-pwm-node-red/66733/4 "2022-08-21T19:54:18Z")

</div>

You can use this python library that support this frequency:

> **[pigpio library](https://abyz.me.uk/rpi/pigpio/python.html)**
>
> Raspberry Pi Reg. C GPIO library and Python GPIO module and shell command utilities to control the GPIO, including SPI, I2C, and serial links.

But it is not used in any Node-Red 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: [21 August 2022 20:12 UTC](https://discourse.nodered.org/t/hardware-pwm-node-red/66733/5 "2022-08-21T20:12:23Z")

</div>

I'm completely new to this stuff.

Could you make a script for me and tell me where to run it?

☹

---

<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: [21 August 2022 20:42 UTC](https://discourse.nodered.org/t/hardware-pwm-node-red/66733/6 "2022-08-21T20:42:29Z")

</div>

> [@iiot2k](#):
>
> But it is not used in any Node-Red node.

Does [node-red-node-pi-gpiod](https://flows.nodered.org/node/node-red-node-pi-gpiod) use that?

---

<div class="post-metadata">

### Author: ![iiot2k](https://avatars.discourse-cdn.com/v4/letter/i/8baadc/32.png) [@iiot2k](https://discourse.nodered.org/u/iiot2k)
#### Post date: [21 August 2022 20:58 UTC](https://discourse.nodered.org/t/hardware-pwm-node-red/66733/7 "2022-08-21T20:58:56Z")

</div>

Oh yes @Colin, it use the pigpio, sorry.  
Node-Red has 4000 nodes and it isn't easy to remember all.  
@Sleep I think you can use it for 28 kHz.  
An other question: Which hardware do you use for driving PWM fan because the gpio drive only 16mA ?

---

<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: [21 August 2022 21:42 UTC](https://discourse.nodered.org/t/hardware-pwm-node-red/66733/8 "2022-08-21T21:42:53Z")

</div>

The node-red software generated pwm is not available for these higher frequencies. I havent figured out how to use the RPis build in hardware to generate 28k.

---

<div class="post-metadata">

### Author: ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)
#### Post date: [21 August 2022 21:56 UTC](https://discourse.nodered.org/t/hardware-pwm-node-red/66733/9 "2022-08-21T21:56:34Z")

</div>

Yes the pigpiod node uses that Pigpio library which can use hardware pwm, so use that node rather than the default pigpio node

---

<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: [20 October 2022 21:57 UTC](https://discourse.nodered.org/t/hardware-pwm-node-red/66733/10 "2022-10-20T21:57:08Z")

</div>

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