# HTML to activate GPIO

**URL:** <https://discourse.nodered.org/t/html-to-activate-gpio/8232>\
**Category:** General\
**Created:** [21 February 2019 16:16 UTC](https://discourse.nodered.org/t/html-to-activate-gpio/8232 "2019-02-21T16:16:27Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![southside94](https://avatars.discourse-cdn.com/v4/letter/s/eb9ed0/32.png) [@southside94](https://discourse.nodered.org/u/southside94)\
**Post date:** [21 February 2019 16:16 UTC](https://discourse.nodered.org/t/html-to-activate-gpio/8232/1 "2019-02-21T16:16:27Z")

</div>

Hello together,

for the first, excuse me for my bad english.  
for the second, I doesn't know much about programming.

what i want to do is:

html to activate a GPIO for maybe 15 minutes

so when I write "[http://192.168.X.X/test/GPIO2](http://192.168.X.X/test/GPIO2)" in my browser, i want to activate the GPIO2  
when I write "[http://192.168.X.X/test/GPIO3](http://192.168.X.X/test/GPIO3)" in my browser, i want to activate the GPIO3

I hope you can help me.  
And again, excuse me for my bad english, I am german.

---

<div class="post-metadata">

**Author:** ![KenioCarvalho](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/keniocarvalho/32/5620_2.png) [@KenioCarvalho](https://discourse.nodered.org/u/KenioCarvalho)\
**Post date:** [21 February 2019 16:33 UTC](https://discourse.nodered.org/t/html-to-activate-gpio/8232/2 "2019-02-21T16:33:54Z")

</div>

If you are using node-red on Raspberry PI use the http request node ([https://pt.coursera.org/lecture/developer-nodered/creating-a-web-api-in-node-red-part-1-Io3F1](https://pt.coursera.org/lecture/developer-nodered/creating-a-web-api-in-node-red-part-1-Io3F1)) and use the raspberrypi nodes [https://projects.raspberrypi.org/en/projects/getting-started-with-node-red/7](https://projects.raspberrypi.org/en/projects/getting-started-with-node-red/7)

---

<div class="post-metadata">

**Author:** ![southside94](https://avatars.discourse-cdn.com/v4/letter/s/eb9ed0/32.png) [@southside94](https://discourse.nodered.org/u/southside94)\
**Post date:** [21 February 2019 18:33 UTC](https://discourse.nodered.org/t/html-to-activate-gpio/8232/3 "2019-02-21T18:33:02Z")

</div>

Okay but i don`t know, how i can do it.

When i write "[http://192.168.178.35/test?test=GPIO](http://192.168.178.35/test?test=GPIO)" i receive it.  
But how can i go on with this information?  
i mean my GPIO needs a 0 or \>1 to switch.  
and in the funktion how can i say when GPIO1 then Out1 and when GPIO2 then Out2

---

<div class="post-metadata">

**Author:** ![ukmoose](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ukmoose/32/13_2.png) [@ukmoose](https://discourse.nodered.org/u/ukmoose)\
**Post date:** [21 February 2019 18:53 UTC](https://discourse.nodered.org/t/html-to-activate-gpio/8232/4 "2019-02-21T18:53:16Z")

</div>

Take a look at the switch node and the change node

---

<div class="post-metadata">

**Author:** ![KenioCarvalho](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/keniocarvalho/32/5620_2.png) [@KenioCarvalho](https://discourse.nodered.org/u/KenioCarvalho)\
**Post date:** [21 February 2019 18:54 UTC](https://discourse.nodered.org/t/html-to-activate-gpio/8232/5 "2019-02-21T18:54:23Z")

</div>

Try using the switch node and get the data from msg.req.test. Send the payload do desired output

---

<div class="post-metadata">

**Author:** ![southside94](https://avatars.discourse-cdn.com/v4/letter/s/eb9ed0/32.png) [@southside94](https://discourse.nodered.org/u/southside94)\
**Post date:** [21 February 2019 18:58 UTC](https://discourse.nodered.org/t/html-to-activate-gpio/8232/6 "2019-02-21T18:58:19Z")

</div>

how can i send it to the payload?

---

<div class="post-metadata">

**Author:** ![KenioCarvalho](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/keniocarvalho/32/5620_2.png) [@KenioCarvalho](https://discourse.nodered.org/u/KenioCarvalho)\
**Post date:** [21 February 2019 19:03 UTC](https://discourse.nodered.org/t/html-to-activate-gpio/8232/7 "2019-02-21T19:03:04Z")

</div>

on a function node  
var gpio = msg.req.test  
msg.payload = {"gpio": gpio}

---

<div class="post-metadata">

**Author:** ![southside94](https://avatars.discourse-cdn.com/v4/letter/s/eb9ed0/32.png) [@southside94](https://discourse.nodered.org/u/southside94)\
**Post date:** [21 February 2019 21:32 UTC](https://discourse.nodered.org/t/html-to-activate-gpio/8232/8 "2019-02-21T21:32:43Z")

</div>

i tryed it but it doesn't worked.

my flow is like this:

1. http node with "Method GET" an "URL /test"
2. funktion node with:  
"var gpio = msg.req.test;"  
"msg.payload = {"gpio":gpio};"
3. switch node, here i don't know what to do!!!
4. GPIO node

my URL is "[http://192.168.178.35/test?test=gpio](http://192.168.178.35/test?test=gpio)"  
can you say me what i have to do?

what im looking for ist to switch on GPIO2 when the URL ist test=GPIO2, an to switch on GPIO3 when the URL ist test=GPIO3.

---

<div class="post-metadata">

**Author:** ![ukmoose](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ukmoose/32/13_2.png) [@ukmoose](https://discourse.nodered.org/u/ukmoose)\
**Post date:** [22 February 2019 08:37 UTC](https://discourse.nodered.org/t/html-to-activate-gpio/8232/9 "2019-02-22T08:37:40Z")

</div>

Please export your flow  
Then read the following post [How to share code or flow json](https://discourse.nodered.org/t/how-to-share-code-or-flow-json/506?u=ukmoose) and follow the instructions to post your flow here.
