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?
Are you measuring this with a voltmeter or do you have a device hooked up to the GPIO that indeed stays on?
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.
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 ?
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.
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