Node Red RPi - GPIO in flow

Good afternoon,

New user here, loving it so far with Hubitat and Pi integrations.

This is specifically for the Pi integration, I am currently using the "default" node-red-node-pi-gpio

I am trying to get a signal from my gate controller(Roger) when the gate is opened by normal methods, ie keyfob or manual exit button. My plan was to take a voltage signal from the controller and pass it into a GPIO pin to pull it high, via a relay. The only issue I can see is that state will stay high as the voltage will probably be from a light contact that will be on for the duration of the gate opening procedure.

So how does the GPIO in node work, is it just triggered by the high state/state change and doesn't care if the state stays high for a long period? What happens after the likely 5-10 mins when the state will go back to low? Can this state change, if an issue, be "noded" out somehow?

I could probably test it and watch the debug to see what happens but I haven't built the relay circuit yet to test, and I am trying to work out the pitfalls in the programming stage.

Thanks

James

Welcome to the @fenJames. The best way to do this is to enable the internal pullup resistor in the chip and then pull it down with the relay. Then in node-red you will get a message each time it goes low and each time it goes high. If your relay is not right by the pi then you might need an external pullup (4k7 or similar) as the internal one might not be low enough to stop noise pickup when the relay is open.

thanks @Colin so basically if I put a switch in the flow to ignore the high message and only listen to the low message, it shouldn't matter how long the trigger to the GPIO stays high for? Any reason why I should pull down and not up? or is either acceptable?

Thanks
James

Either will work, but if you pull up you have to be careful what you pull up to, the pi has 5v and 3.3v lines and if you pull up to 5v you will blow the board up. Also if you take the 3.3V off the board you might pickup noise onto the power line with is bad. Safer and simpler to pull it down to 0v. Also when configured as outputs the pins are active pull down, if you pull it up to 3.3v with a relay and then accidentally configure the pin as an output then you will be trying to short the 3.3v to ground which again is a Bad Thing. If the relay is pulling down then it won't do any damage if you configure the pin as an output.
Is there a reason why would you want to pull up instead of down?

Makes sense, no reason really, just always used pull ups, but as you say pull down to 0v is a lot safer when dealing with an external integration! Basically my relay board is triggered from 24v and then I was going to NO to the 3.3v and COM to the GPIO, but no reason why I can't NO to the 0v, much safer in the case of a misconfig.

Is my switch idea to "filter" out the state change to high when the controller turns off the light circuit, the way to go?

Thanks for the input

Yes, if you only want to know when it switches to a particular state then use a Switch node.

@Colin wired it all up today, looped 0v to a GPIO pin via the relay NO circuit and applied 24v from the courtesy light circuit. Built a switch in my flow and it works brilliantly, exactly what I wanted. I can now trigger Alexa to tell me the gates are opening, turn on smart lights from either a virtual switch in my automation hub(Hubitat) or from the keyfob. Thanks for your pointers.

James

Flow for prosperity:

1 Like

Excellent, glad to be of help.