# Control GPIO Raspberry pi with Node-red in Windows PC

**URL:** <https://discourse.nodered.org/t/control-gpio-raspberry-pi-with-node-red-in-windows-pc/24055>\
**Category:** General\
**Created:** [1 April 2020 20:44 UTC](https://discourse.nodered.org/t/control-gpio-raspberry-pi-with-node-red-in-windows-pc/24055 "2020-04-01T20:44:35Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![FSN](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/fsn/32/19222_2.png) [@FSN](https://discourse.nodered.org/u/FSN)\
**Post date:** [1 April 2020 20:44 UTC](https://discourse.nodered.org/t/control-gpio-raspberry-pi-with-node-red-in-windows-pc/24055/1 "2020-04-01T20:44:35Z")

</div>

Good afternoon

I have Node-red installed on a Windows PC.  
I would like to know how to control Raspberry Pi GPIO.  
I know that the Raspberry pi / Rasbian has the Node-Red installed

Thank you

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [1 April 2020 21:10 UTC](https://discourse.nodered.org/t/control-gpio-raspberry-pi-with-node-red-in-windows-pc/24055/2 "2020-04-01T21:10:19Z")

</div>

Well, there are a couple of things you need to set up first.

You have to configure the RasPi to allow remote GPIO control.

It is one of the settings in the `raspi-config` screen.

Then you will need to communicate between the two machines.  
MQTT is a nominal protocol to use.  
On one of the machines you will have to install the MQTT broker.

[Try this link for how to.](https://www.google.com/url?sa=t&rct=j&q=&esrc=s&source=web&cd=7&cad=rja&uact=8&ved=2ahUKEwiY0LWukcjoAhVp8XMBHT1cDPwQFjAGegQIARAB&url=https%3A%2F%2Frandomnerdtutorials.com%2Fhow-to-install-mosquitto-broker-on-raspberry-pi%2F&usg=AOvVaw3rqRgC8C-nl50jkXn11ER6)

Then you set up a _flow_ (program) where you send commands to turn certain GPIO pins _on/off_ on the RasPie.

On the RasPie, you receive said messages and send the message to the respective GPIO pin.  
(Node called RasPiGPIO from memory)

---

<div class="post-metadata">

**Author:** ![FSN](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/fsn/32/19222_2.png) [@FSN](https://discourse.nodered.org/u/FSN)\
**Post date:** [1 April 2020 21:21 UTC](https://discourse.nodered.org/t/control-gpio-raspberry-pi-with-node-red-in-windows-pc/24055/3 "2020-04-01T21:21:08Z")

</div>

Thanks for responding so quickly.

The configuration screen is Remote GPIO interfaces?  
I also have the Mosquitto broker installed on the Raspberry.

The question is how do I communicate with the Node-Red nodes with the Rasberry some example

Thank you

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [1 April 2020 21:29 UTC](https://discourse.nodered.org/t/control-gpio-raspberry-pi-with-node-red-in-windows-pc/24055/4 "2020-04-01T21:29:35Z")

</div>

Either when you run `raspi-config` (from the CLI on the RasPi) or you select the config from the menu there is an option to allow remote control of the GPIO pins.

That MUST BE SET to ....... allow remote control of GPIO pins.

I am not using a RasPi just now so I can't give you a 100% sure answer to which it is.

On the windoze machine, you put an `inject` node to send a message.

This is a basic flow:  
Read the ReadMe node!

```auto
[{"id":"6d994209.790b24","type":"inject","z":"b4f1ccd4.5e8d1","name":"GPIO pin (in TOPIC) ON","topic":"3","payload":"ON","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":210,"y":930,"wires":[["74d3359f.b13b8c"]]},{"id":"74d3359f.b13b8c","type":"mqtt out","z":"b4f1ccd4.5e8d1","name":"","topic":"RASPIGPIO","qos":"","retain":"","broker":"8a2e80be.f7c928","x":460,"y":930,"wires":[]},{"id":"f7f385ef.6a98a","type":"mqtt in","z":"b4f1ccd4.5e8d1","name":"","topic":"RASPIGPIO/#","qos":"2","datatype":"auto","broker":"8a2e80be.f7c928","x":180,"y":1040,"wires":[["88237861.71a708"]]},{"id":"44091c56.c84b64","type":"inject","z":"b4f1ccd4.5e8d1","name":"GPIO pin (in TOPIC) OFF","topic":"3","payload":"OFF","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":210,"y":970,"wires":[["74d3359f.b13b8c"]]},{"id":"88237861.71a708","type":"switch","z":"b4f1ccd4.5e8d1","name":"you get the idea","property":"topic","propertyType":"msg","rules":[{"t":"eq","v":"1","vt":"num"},{"t":"eq","v":"2","vt":"num"},{"t":"eq","v":"3","vt":"num"}],"checkall":"true","repair":false,"outputs":3,"x":380,"y":1040,"wires":[[],[],["ef5c67b7.442068"]]},{"id":"ef5c67b7.442068","type":"function","z":"b4f1ccd4.5e8d1","name":"RASPIGPIO NODE","func":"\nreturn msg;","outputs":1,"noerr":0,"x":640,"y":1100,"wires":[[]]},{"id":"f0f610a8.32fbe8","type":"comment","z":"b4f1ccd4.5e8d1","name":"Read Me!","info":"The node below is a `function` node because I don't have the node/s installed as this machine is not a RasPi.\n\nThe top half you put on your PC, the lower on the RasPie.\n","x":630,"y":1060,"wires":[]},{"id":"8a2e80be.f7c928","type":"mqtt-broker","z":"","name":"MQTT host","broker":"192.168.0.99","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"2","birthPayload":"","closeTopic":"","closePayload":"","willTopic":"","willQos":"0","willPayload":""}]

```

---

<div class="post-metadata">

**Author:** ![FSN](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/fsn/32/19222_2.png) [@FSN](https://discourse.nodered.org/u/FSN)\
**Post date:** [1 April 2020 21:35 UTC](https://discourse.nodered.org/t/control-gpio-raspberry-pi-with-node-red-in-windows-pc/24055/5 "2020-04-01T21:35:30Z")

</div>

Thanks so much

I have import your code and i have put in Node-Red

Tomorrow are the tests

Note: When I say PC = my computer

Thanks, again Andrew

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [1 April 2020 21:37 UTC](https://discourse.nodered.org/t/control-gpio-raspberry-pi-with-node-red-in-windows-pc/24055/6 "2020-04-01T21:37:00Z")

</div>

Please understand, I am still learning Node-Red. So there are no promises.

---

<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:** [2 April 2020 08:11 UTC](https://discourse.nodered.org/t/control-gpio-raspberry-pi-with-node-red-in-windows-pc/24055/7 "2020-04-02T08:11:20Z")

</div>

Are you sure you need to run node-red on both the PC and on the Pi? If you run it in the Pi you can connect to it from the PC using your browser and control what you like on the Pi.

---

<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:** [1 June 2020 08:11 UTC](https://discourse.nodered.org/t/control-gpio-raspberry-pi-with-node-red-in-windows-pc/24055/8 "2020-06-01T08:11:26Z")

</div>

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