# Multiple GPIO pins on Raspberry with https://flows.nodered.org/node/node-red-node-pi-gpio

**URL:** https://discourse.nodered.org/t/multiple-gpio-pins-on-raspberry-with-https-flows-nodered-org-node-node-red-node-pi-gpio/61330
**Category:** General
**Created:** [15 April 2022 12:21 UTC](https://discourse.nodered.org/t/multiple-gpio-pins-on-raspberry-with-https-flows-nodered-org-node-node-red-node-pi-gpio/61330 "2022-04-15T12:21:35Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![mibian](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/mibian/32/60132_2.png) [@mibian](https://discourse.nodered.org/u/mibian)
#### Post date: [15 April 2022 12:21 UTC](https://discourse.nodered.org/t/multiple-gpio-pins-on-raspberry-with-https-flows-nodered-org-node-node-red-node-pi-gpio/61330/1 "2022-04-15T12:21:36Z")

</div>

I have made a solution, that referenceses several sources for information, a file, a webpage etc. It then determins the proper state for a GPIO pin from the data, and sets it.

My problem is that the GPIO node only takes it's input from msg.payload, so I don't see any way of controlling other GPIO pins on the raspberry from the same function node, and it's a pain to do some of the same work multiple times in different function nodes.

I guess another option was to use some global variables, but as I read it around here, that is frowned upon :o)

Does anyone have any better ideas?

Thanks

---

<div class="post-metadata">

### Author: ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)
#### Post date: [15 April 2022 12:39 UTC](https://discourse.nodered.org/t/multiple-gpio-pins-on-raspberry-with-https-flows-nodered-org-node-node-red-node-pi-gpio/61330/2 "2022-04-15T12:39:07Z")

</div>

> [@mibian](#):
>
> I guess another option was to use some global variables, but as I read it around here, that is frowned upon :o)

That is only an opinion by some, I use global, flow and context variables where they make sense. After all, if it was really a bad idea, why would it be offered??

As for the gpio nodes, you will need a separate gpio node for each pin you want to use. They are not able to be dynamically set.

---

<div class="post-metadata">

### Author: ![mibian](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/mibian/32/60132_2.png) [@mibian](https://discourse.nodered.org/u/mibian)
#### Post date: [16 April 2022 07:04 UTC](https://discourse.nodered.org/t/multiple-gpio-pins-on-raspberry-with-https-flows-nodered-org-node-node-red-node-pi-gpio/61330/3 "2022-04-16T07:04:07Z")

</div>

Thankyou Paul 🙂

---

<div class="post-metadata">

### Author: ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)
#### Post date: [16 April 2022 11:09 UTC](https://discourse.nodered.org/t/multiple-gpio-pins-on-raspberry-with-https-flows-nodered-org-node-node-red-node-pi-gpio/61330/4 "2022-04-16T11:09:27Z")

</div>

Your function can set msg.gpio1, msg.gpio2 etc.  
Pass the output via change nodes, which move eg msg.gpio2 to msg.payload.

---

<div class="post-metadata">

### Author: ![mibian](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/mibian/32/60132_2.png) [@mibian](https://discourse.nodered.org/u/mibian)
#### Post date: [16 April 2022 13:10 UTC](https://discourse.nodered.org/t/multiple-gpio-pins-on-raspberry-with-https-flows-nodered-org-node-node-red-node-pi-gpio/61330/5 "2022-04-16T13:10:25Z")

</div>

Thank you 🙂

---

<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: [15 June 2022 13:11 UTC](https://discourse.nodered.org/t/multiple-gpio-pins-on-raspberry-with-https-flows-nodered-org-node-node-red-node-pi-gpio/61330/6 "2022-06-15T13:11:04Z")

</div>

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