# GPIO output fails "on"?

**URL:** <https://discourse.nodered.org/t/gpio-output-fails-on/11302>\
**Category:** Hardware\
**Created:** [19 May 2019 23:58 UTC](https://discourse.nodered.org/t/gpio-output-fails-on/11302 "2019-05-19T23:58:44Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![rick](https://avatars.discourse-cdn.com/v4/letter/r/9f8e36/32.png) [@rick](https://discourse.nodered.org/u/rick)\
**Post date:** [19 May 2019 23:58 UTC](https://discourse.nodered.org/t/gpio-output-fails-on/11302/1 "2019-05-19T23:58:44Z")

</div>

Hi all,  
New to node-red & raspberry pi and found something peculiar about the behavior of the GPIO outputs. They default to "on". if the flow is blocked (say by an rbe) on the first pass, the node indicates "OK" and turns the output on. If a GPIO node is placed without a flow into it it will turn the output on. If the GPIO is passed an invalid value (must be 0 or 1) it will turn the output on. In my personal case, if the modbus connection fails up stream it turns the output on. This seems to me like a major flaw. Am i doing something wrong?

---

<div class="post-metadata">

**Author:** ![seth350](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/seth350/32/4617_2.png) [@seth350](https://discourse.nodered.org/u/seth350)\
**Post date:** [20 May 2019 02:08 UTC](https://discourse.nodered.org/t/gpio-output-fails-on/11302/2 "2019-05-20T02:08:25Z")

</div>

Are you measuring this with a voltmeter or do you have a device hooked up to the GPIO that indeed stays on?

---

<div class="post-metadata">

**Author:** ![rick](https://avatars.discourse-cdn.com/v4/letter/r/9f8e36/32.png) [@rick](https://discourse.nodered.org/u/rick)\
**Post date:** [20 May 2019 02:57 UTC](https://discourse.nodered.org/t/gpio-output-fails-on/11302/3 "2019-05-20T02:57:30Z")

</div>

Thanks for the reply.  
I don't have any hardware & i haven't checked with a volt meter (i guess i should), but it shows "on" in pi-gpio-display.  
....

now i've used a volt meter and confirmed the output is on.

I haven't tested every scenario, but it seems that the output goes on unless there is a valid message to turn it off, if that explains what i'm witnessing.

---

<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:** [20 May 2019 07:56 UTC](https://discourse.nodered.org/t/gpio-output-fails-on/11302/4 "2019-05-20T07:56:50Z")

</div>

Is this using the default Node-RED gpio nodes ? What is the exact status message in this scenario ?  
If it is green dot and OK that is just saying it has enabled talking to the pin OK and not set any value - If it's a green dot and 1 then yes it has set it high. If it is just OK and the pin is high that is just the way the Pi defaults that pin when it's set as an output. In the node you can say set initial value to force it to a level at deploy time.  
What invalid value(s) are you sending that sets it to a 1 ?

---

<div class="post-metadata">

**Author:** ![rick](https://avatars.discourse-cdn.com/v4/letter/r/9f8e36/32.png) [@rick](https://discourse.nodered.org/u/rick)\
**Post date:** [20 May 2019 18:27 UTC](https://discourse.nodered.org/t/gpio-output-fails-on/11302/5 "2019-05-20T18:27:31Z")

</div>

Default node-red gpio? - yes  
when the status indicates "OK" the output is "on". By simply injecting a 2 into a GPIO node, the node will indicate OK and the output will be high.  
I now see the "initialize pin state" (duh). i'll try that later today. that may do it.

---

<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:** [20 May 2019 19:51 UTC](https://discourse.nodered.org/t/gpio-output-fails-on/11302/6 "2019-05-20T19:51:49Z")

</div>

If it says OK then nothing has been passed to the output and it is as per the Pi defaults... which does vary by pin. Some pins with alternate uses default high and some default low... not something we control directly. As mentioned you can set it to an initial value as soon as we deploy, but until then we don't have control.  
Also if you look at the log when you send a 2 you should see something like  
`20 May 19:49:46 - [warn] [rpi-gpio out:4e98e8ef.4d0a78] Invalid input: 2`
