GPIOs initialize not as expected

Hello, All,

kindly asking you for support on this matter:

I have a Raspi3B and Node Red running on it.

2 GPIOs are currently used as input (GPIO 18 and 27) and read the state of 2 water detectors.

These inputs drive a Trigger node which then triggers another GPIO (17) to activate some relays for 1 minute.

All of the above runs fine, BUT

After each deployment, the relays are triggered once, and it is sure, that this comes from node red, because after a reboot the relays do not activate, but some seconds later they do.

So, each and every tiny change I do in node red and deploy it, makes my family crazy, as they see the alarm flashing, and think there is a real alarm :wink:

I checked my GPIO 18 and 27 in detail - they initalize as "0" after reboot.
In node red, when I debug them, they both show "0" (inside the "rpi-gpio in" Node, I initialized them both as "pull-down")

So, despite they are supposed to be 0, they seem to get a "1" somewhere(obviously very shortly, as the debug node sees them as "0" as expected), so each time node red is started or any changes are deployed, the relay activate erroneously.
I tried to set the "debounce" value to 1000ms which did not help either.

Any hints about this behavior? Did anyone experience this issue and knows how to avoid this?

Thanks!

Hoinz

The relay is ultimately activated by the trigger node. Perhaps it is worth to have a close look on this node. Can you possibly share a screenshot of the trigger node configuration ?

You did well checking the state of GPIOs under initialization. Indeed those two pins are initialized with pull down. Reference.

Set the debug nodes to output to the console then restart node red in a terminal using
node-red-stop
node-red-start
And you will see what comes out of the gpio node on startup. Copy/paste the full output log text here if you don't think it is right.

[Edit] Also add debug nodes that output to the console on the outputs of the trigger nodes so you can see what is being sent to the relay pins on startup.

Hello, Andrei,
thanks for your input.
I tested the following: I removed the connections between the GPIO-in nodes and the Trigger nodes, but left the other connection between Trigger node and the GPIO-out node(finally the darlington array and the relay bihind).
After deploying, the relay did NOT activate, no alarm flashing as it did before that change.
Therefore, I conclude, that in fact, it is not the trigger node which behaves wrongly, or?

Hello, Colin,
thank you too for the hints. Unfortunately I failed to follow your instruction. With "Terminal", you mean the putty-console, is that right?
I clicked "output to console" inside the Debug node.
But where should the output appear? I tried to find anything in /var/log/syslog, but did not find any related output? (didn't find any sensible /var/log/nodered-*whatever entry)
Thanks again for your help.
Hoinz

When you run
node-red-stop
node-red-start
The output should appear in the the putty window. If putty-console is how you access the device then yes, in there.

[Edit] Also show us how you have configured the Trigger node. You can paste a screenshot here.

OK, got it now :wink: thanks!

Here is the output of "node-red-start"
Some statements are in German, I hope its not hiding important information though.

27 Feb 12:55:48 - [info]

Willkommen bei Node-RED!
===================

27 Feb 12:55:48 - [info] Node-RED Version: v1.1.3
27 Feb 12:55:48 - [info] Node.js  Version: v12.22.7
27 Feb 12:55:48 - [info] Linux 5.10.63-v7+ arm LE
27 Feb 12:55:50 - [info] Paletten-Nodes werden geladen
27 Feb 12:55:51 - [debug] Module: node-red-contrib-bme280 1.0.0
27 Feb 12:55:51 - [debug]         /home/pi/.node-red/node_modules/node-red-contrib-bme280
27 Feb 12:55:51 - [debug] Module: node-red-contrib-bsb-lan 1.0.1
27 Feb 12:55:51 - [debug]         /home/pi/.node-red/node_modules/node-red-contrib-bsb-lan
27 Feb 12:55:51 - [debug] Module: node-red-contrib-device-manager 1.0.4
27 Feb 12:55:51 - [debug]         /home/pi/.node-red/node_modules/node-red-contrib-device-manager
27 Feb 12:55:51 - [debug] Module: node-red-contrib-dht-sensor 1.0.4
27 Feb 12:55:51 - [debug]         /home/pi/.node-red/node_modules/node-red-contrib-dht-sensor
27 Feb 12:55:51 - [debug] Module: node-red-contrib-heater-controller 1.2.2
27 Feb 12:55:51 - [debug]         /home/pi/.node-red/node_modules/node-red-contrib-heater-controller
27 Feb 12:55:51 - [debug] Module: node-red-contrib-hunterio 2.0.1
27 Feb 12:55:51 - [debug]         /home/pi/.node-red/node_modules/node-red-contrib-hunterio
27 Feb 12:55:51 - [debug] Module: node-red-contrib-i2c 0.7.5
27 Feb 12:55:51 - [debug]         /home/pi/.node-red/node_modules/node-red-contrib-i2c
27 Feb 12:55:51 - [debug] Module: node-red-contrib-knx-easy 0.3.3
27 Feb 12:55:51 - [debug]         /home/pi/.node-red/node_modules/node-red-contrib-knx-easy
27 Feb 12:55:51 - [debug] Module: node-red-contrib-knx-ultimate 1.1.82
27 Feb 12:55:51 - [debug]         /home/pi/.node-red/node_modules/node-red-contrib-knx-ultimate
27 Feb 12:55:51 - [debug] Module: node-red-contrib-multipart-stream-decoder 0.0.4
27 Feb 12:55:51 - [debug]         /home/pi/.node-red/node_modules/node-red-contrib-multipart-stream-decoder
27 Feb 12:55:51 - [debug] Module: node-red-contrib-onvif 1.0.1
27 Feb 12:55:51 - [debug]         /home/pi/.node-red/node_modules/node-red-contrib-onvif
27 Feb 12:55:51 - [debug] Module: node-red-contrib-pid 1.1.6
27 Feb 12:55:51 - [debug]         /home/pi/.node-red/node_modules/node-red-contrib-pid
27 Feb 12:55:51 - [debug] Module: node-red-contrib-play-audio 2.5.0
27 Feb 12:55:51 - [debug]         /home/pi/.node-red/node_modules/node-red-contrib-play-audio
27 Feb 12:55:51 - [debug] Module: node-red-contrib-ramp-thermostat 0.8.2
27 Feb 12:55:51 - [debug]         /home/pi/.node-red/node_modules/node-red-contrib-ramp-thermostat
27 Feb 12:55:51 - [debug] Module: node-red-contrib-sensor-htu21d 1.0.1
27 Feb 12:55:51 - [debug]         /home/pi/.node-red/node_modules/node-red-contrib-sensor-htu21d
27 Feb 12:55:51 - [debug] Module: node-red-contrib-toggle 0.1.1
27 Feb 12:55:51 - [debug]         /home/pi/.node-red/node_modules/node-red-contrib-toggle
27 Feb 12:55:51 - [debug] Module: node-red-contrib-ui-led 0.4.11
27 Feb 12:55:51 - [debug]         /home/pi/.node-red/node_modules/node-red-contrib-ui-led
27 Feb 12:55:51 - [debug] Module: node-red-contrib-ui-multistate-switch 1.2.1
27 Feb 12:55:51 - [debug]         /home/pi/.node-red/node_modules/node-red-contrib-ui-multistate-switch
27 Feb 12:55:51 - [debug] Module: node-red-contrib-webduino 0.0.15
27 Feb 12:55:51 - [debug]         /home/pi/.node-red/node_modules/node-red-contrib-webduino
27 Feb 12:55:51 - [debug] Module: node-red-dashboard 2.23.2
27 Feb 12:55:51 - [debug]         /home/pi/.node-red/node_modules/node-red-dashboard
27 Feb 12:55:51 - [debug] Module: node-red-node-email 1.8.0
27 Feb 12:55:51 - [debug]         /home/pi/.node-red/node_modules/node-red-node-email
27 Feb 12:55:51 - [debug] Module: node-red-node-pi-gpio 2.0.1
27 Feb 12:55:51 - [debug]         /home/pi/.node-red/node_modules/node-red-node-pi-gpio
27 Feb 12:55:51 - [debug] Module: node-red-node-ping 0.2.1
27 Feb 12:55:51 - [debug]         /home/pi/.node-red/node_modules/node-red-node-ping
27 Feb 12:55:51 - [debug] Module: node-red-node-random 0.2.0
27 Feb 12:55:51 - [debug]         /home/pi/.node-red/node_modules/node-red-node-random
27 Feb 12:55:51 - [debug] Module: node-red-node-serialport 0.11.0
27 Feb 12:55:51 - [debug]         /home/pi/.node-red/node_modules/node-red-node-serialport
27 Feb 12:55:51 - [debug] Module: node-red-node-smooth 0.1.2
27 Feb 12:55:51 - [debug]         /home/pi/.node-red/node_modules/node-red-node-smooth
27 Feb 12:55:51 - [debug] Module: node-red-node-ui-webcam 0.3.0
27 Feb 12:55:51 - [debug]         /home/pi/.node-red/node_modules/node-red-node-ui-webcam
27 Feb 12:55:51 - [debug] Module: red-contrib-shutter-controller 0.1.0
27 Feb 12:55:51 - [debug]         /home/pi/.node-red/node_modules/red-contrib-shutter-controller
27 Feb 12:55:51 - [debug] Module: node-red-node-rbe 0.2.9
27 Feb 12:55:51 - [debug]         /usr/lib/node_modules/node-red/node_modules/node-red-node-rbe
27 Feb 12:55:51 - [debug] Module: node-red-node-tail 0.1.1
27 Feb 12:55:51 - [debug]         /usr/lib/node_modules/node-red/node_modules/node-red-node-tail
[info] "2022-02-27T11:55:54.820Z"  'Loading knx: KNXnet/IP protocol implementation for Node(>=4.x), version: 2.3.3'
[info] "2022-02-27T11:55:56.959Z"  'Loading knxultimate-api: node-red-contrib-KNX-Ultimate KNX API (https://flows.nodered.org/node/node-red-contrib-knx-ultimate), version: 2.3.23'
27 Feb 12:55:57 - [info] Dashboard version 2.23.2 started at /ui
27 Feb 12:55:59 - [info] Einstellungsdatei: /home/pi/.node-red/settings.js
27 Feb 12:55:59 - [info] Kontextspeicher: 'default' [ module=memory]
27 Feb 12:55:59 - [info] Benutzerverzeichnis: /home/pi/.node-red
27 Feb 12:55:59 - [warn] Projekte inaktiviert: editorTheme.projects.enabled=false
27 Feb 12:55:59 - [info] Flow-Datei: /home/pi/.node-red/start
27 Feb 12:55:59 - [info] Neue flow-Datei wird erstellt
27 Feb 12:55:59 - [debug] loaded flow revision: d751713988987e9331980363e24189ce
27 Feb 12:55:59 - [debug] red/runtime/nodes/credentials.load : no user key present
27 Feb 12:55:59 - [debug] red/runtime/nodes/credentials.load : using default key
27 Feb 12:55:59 - [debug] red/runtime/nodes/credentials.load : keyType=system
27 Feb 12:55:59 - [warn]

---------------------------------------------------------------------
Die Datei mit den Datenflowberechtigungsnachweisen wird mit einem vom System generierten SchlĂĽssel verschlĂĽsselt.

Wenn der vom System generierte SchlĂĽssel aus irgendeinem Grund verloren geht, werden Ihre Berechtigungsnachweise
Die Datei kann nicht wiederhergestellt werden. Sie müssen sie löschen und erneut eingeben.
Ihre Berechtigungsnachweise.

Sie sollten Ihren eigenen SchlĂĽssel mit Hilfe der Option 'credentialSecret' in
Ihre Einstellungsdatei. Node-RED wird dann Ihre Berechtigungsnachweise erneut verschlĂĽsseln.
Datei mit dem ausgewählten Schlüssel beim nächsten Deployen einer Änderung verwenden.
---------------------------------------------------------------------

27 Feb 12:55:59 - [info] Flows starten
27 Feb 12:55:59 - [debug] red/nodes/flows.start : starting flow : global
27 Feb 12:55:59 - [info] Flows gestartet
27 Feb 12:55:59 - [error] Zuhören auf http://127.0.0.1:1890/ nicht möglich.
27 Feb 12:55:59 - [error] Fehler: Port wird verwendet

And here is the configuration of the Trigger Node:

The idea of the trigger node was just to avoid an endless alarm. So after 1 Minute it sends "false" to the GPIO-out node to stop the flashing.

And here is one of the GPIO-in nodes

GPIO-out configuration:

That means that it has not started properly as it cannot gain access to port 1890. That suggests that you already have node-red running. Did you run node-red-stop first.

I think you ran
node-red start
not
node-red-start
It is important to get the details correct.

Is there a reason you are running on a non-standard port?

Looking at your trigger node you have said that when it receives any input (whether it is a 0 or a 1) that it should send true and then false. On startup the gpio pin will send its initial state, so whatever that state is it will always activate the trigger node.

1 Like

Try deploying only the modified nodes.

That is a valid point, but it just covers up the fundamental problem, that the relay should not be triggered on startup.

Exactly ! I am wondering what could be done do discard that first trigger on startup. :face_with_monocle:

OK, this makes perfectly sense then. As the GPIO-in node initializes with 0, this initiates the following nodes. Then I really mis-understood the function of this Trigger node :face_with_open_eyes_and_hand_over_mouth:
... I thought a "1" is needed to trigger this node.

An I am keen on any improving idea aswell ...

I am thinking in a "gate" controlled by a context variable. The gate would allow messages only when it is explicitly opened by the logic in your flow. I use this artifact from times to times. I just can´t recall that config right now.

Something like this flow or similar... where the gate node would replace of the trigger node in your flow. The switch node(gate) would forward the message when the rule is true. It will only be true when the logic of your flow says so.

[{"id":"425f1b19.e495e4","type":"inject","z":"a87c60a2.f4723","name":"","repeat":"1","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":150,"y":240,"wires":[["7d43ff77.ab17a"]]},{"id":"7d43ff77.ab17a","type":"switch","z":"a87c60a2.f4723","name":"gate","property":"gate","propertyType":"flow","rules":[{"t":"true"}],"checkall":"true","repair":false,"outputs":1,"x":330,"y":240,"wires":[["348a76cb.c3f58a"]]},{"id":"d37f58de.700ea8","type":"inject","z":"a87c60a2.f4723","name":"","repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"true","payloadType":"bool","x":130,"y":120,"wires":[["e52c9aa2.853468"]]},{"id":"24ff0bad.72aaf4","type":"inject","z":"a87c60a2.f4723","name":"","repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"false","payloadType":"bool","x":130,"y":160,"wires":[["e52c9aa2.853468"]]},{"id":"348a76cb.c3f58a","type":"debug","z":"a87c60a2.f4723","name":"","active":true,"tosidebar":true,"console":true,"tostatus":true,"complete":"payload","x":520,"y":240,"wires":[]},{"id":"e52c9aa2.853468","type":"change","z":"a87c60a2.f4723","name":"","rules":[{"t":"set","p":"gate","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":290,"y":140,"wires":[["72c0c4cf.d5ebec"]]},{"id":"e05c34c2.97e3a8","type":"comment","z":"a87c60a2.f4723","name":"Simple gate using a flow variable","info":"","x":190,"y":60,"wires":[]},{"id":"72c0c4cf.d5ebec","type":"debug","z":"a87c60a2.f4723","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":530,"y":140,"wires":[]}]

Perhaps all you need is a Switch node before the trigger, configured to only pass payload values of 1.

1 Like