Switch from python script to node red

Hello, I would like to use node red instead of a python script which is started at system start. Unfortunately, I am not getting the functionality to run. Here is my python script:

klingel_gpio = 4 #GPIO, der mit der Schaltung verbunden ist

gpio.setup(klingel_gpio, gpio.IN, pull_up_down=gpio.PUD_UP)
gpio.add_event_detect(klingel_gpio, gpio.FALLING)

while True:
if gpio.event_detected(klingel_gpio):
actions.handleAction("Someone is in front of the door")

I tested the node node gpio_in (set it to gpio 4 and Pull up) but it does not work. Does anyone has an idea what I am doing wrong.

If you are running node-red, what does your node-red flow look like?
Do you have node-red running at startup?
What platform are you using? Pi, Windows?

1 Like

Also check that gpio 4 in the node-red node is the same pin as is meant by 4 in the python script. There is often confusion over pin number vs gpio number.

Do I have to do anything else?

You shouldn't have to. When the pin state chages you should get a message.

1 Like

Ok. Thank you. I will retry next weekend and give you feedback.

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.