Can't read GPIO without first running some python

#1

I created a simple flow that checks to see if a switch is depressed and deployed it, but it didn't work. Thinking that my GPIO was fried, i ran a little python script to read the same GPIO pin, The python script worked fine and could read the switch. When I went back to the node-red console, I saw that the flow was working. I made changes to the flow and deployed. It didn't work anymore. I ran the python script again and when I came back to the node red console, everything was magically working.
Is there something I need to do in node red to initialize the pin similar to "GPIO.setup(21, GPIO.IN, pull_up_down=GPIO.PUD_UP)" in Python? That is the python line of code that , when I execute it, the node red flow starts working
Running Node-RED v0.19.4 on Pi Zero

0 Likes

#2

I figured out how to get it to work.
I have a switch connected to GPIO 21 on one side, and ground on the other. I initially set the resistor type to pulldown when configuring the input node. Changing the resistor type to pullup and checking the read initial state checkbox resolved the issue.

0 Likes