Get GPIO State Node-Red

#1

Hello,
I am running different actors with my Node-Red Flow. Over the GPIO Pins of my Raspberry Pi.
Now I would like to make a dashboard to show the actor activity.
I tried to use the gpi-gpio in Node but then the message "Pin x already set as tri" come and on the dashboard, I don't get any value.

Is there a different way to see if the Pin is active or not?
Thanks

#2

I am not sure what you mean by 'actors'.
A pin can only be output or input, you cannot read the state of an o/p pin. If you want to see what state the pin is definitely in then the only way is to connect the pin to another, configured as input.
If the state is written from the node-red flow then you can show the state that the flow is asking for by feeding the same value that is going to the gpio node into a dashboard node.

#3

By actor I mean for example a light.
The light turns on when i set the Pin to 1.
Now i want to know which Pins are 1 and which are 0.

#4

Again I am not certain what you mean by 'actor'. Normally an actor will be something that does something, but you say the light is an actor, so that suggests the light is setting the pin, rather than a pin setting the light.
However, as I said, if you just mean you have a flow in node-red that drives the pin (to control the light) then just send the same value to the dashboard as you send to the gpio node.

1 Like
#5

A pin is either an input or an output. If you have a pin controlling a light it is an output. You cannot query the current state of an output directly.

You will need to remember what state you've set each output pin within your flow using context.

#6

though on latest version I think the status shows it - so you could use the status node to get it back from there. But yes - much easier to remember in the first place.

1 Like