GPIO input pin sometimes stopped

Hi,
this is my first post and I must admit that node-red is fantastic piece of software. Every task can be made with a great level of elegance and everything is transparent ... drag&drop in browser :slight_smile:

OK, installation on my Raspi 1 B+, configuration and implementing flows went without problem. Everything is working as expected. The only issue I have is sometimes my input GPIO pin is marked as "stopped". node-red-log doesn't show any kind of error. Here is output from flow restart:

15 Jun 12:48:05 - [info] Stopped flows
15 Jun 12:48:05 - [info] Starting flows
15 Jun 12:48:15 - [info] Started flows
15 Jun 12:48:15 - [info] [sqlitedb:a57deb46.324718] opened /home/dbunic/project/www/_database/house.sqlite3 ok
15 Jun 12:48:16 - [info] [mqtt-broker:raspi] Connected to broker: mqtt://192.168.100.3:1883
15 Jun 12:48:22 - [info] nora: synced 19 device(s), group: <default>

I'm running node-red version 1.3.3 on latest RaspianOS:

dbunic@raspi:~ $ more /etc/os-release 
PRETTY_NAME="Raspbian GNU/Linux 10 (buster)"
NAME="Raspbian GNU/Linux"
VERSION_ID="10"
VERSION="10 (buster)"
VERSION_CODENAME=buster
ID=raspbian
ID_LIKE=debian
HOME_URL="http://www.raspbian.org/"
SUPPORT_URL="http://www.raspbian.org/RaspbianForums"
BUG_REPORT_URL="http://www.raspbian.org/RaspbianBugs"

dbunic@raspi:~ $ cat /boot/issue.txt 
Raspberry Pi reference 2021-01-11
Generated using pi-gen, https://github.com/RPi-Distro/pi-gen, 21090519d85bdaa1615d5d5057d37b09368ea5d2, stage2

So my setup contains 20 GPIO output pins and 1 input. Sometimes this one input GPIO is marked as stopped. In that case there aren't any nrgpio processes. To resolve it I have to deploy again or just restart flows and after it everything is fine and nrgpio processes are listed:

dbunic@raspi:~ $ ps aux | grep tri
dbunic   27512  0.0  0.5   7652  2436 ?        S    12:48   0:00 /bin/bash /home/dbunic/.node-red/node_modules/node-red-node-pi-gpio/nrgpio in 8 tri 25
dbunic   27514  0.0  1.3  21736  5856 ?        Sl   12:48   0:00 python -u /home/dbunic/.node-red/node_modules/node-red-node-pi-gpio/nrgpio.py in 8 tri 25

Is it possible that somewhere is defined some kind of timeout to cause this kind of problem? Raspi 1 is a bit slow but it can handle all the task.

Oh, and here is my python version:

dbunic@raspi:~ $ python --version
Python 2.7.16

I would be very grateful if you can point me to right direction where to look.
Thank you in advance

Can you post your flow please?

Hi,
here is my "Doorbell" flow:

[{"id":"2854b769.c86be8","type":"tab","label":"Doorbell","disabled":false,"info":""},{"id":"e36775d5.afacc8","type":"exec","z":"2854b769.c86be8","command":"/home/dbunic/project/www/sound.sh","addpay":"payload","append":"","useSpawn":"false","timer":"","oldrc":false,"name":"ding dong","x":700,"y":160,"wires":[[],[],[]],"icon":"font-awesome/fa-bell"},{"id":"4c677590.616d0c","type":"rpi-gpio in","z":"2854b769.c86be8","name":"GPIO14","pin":"8","intype":"tri","debounce":"25","read":false,"x":80,"y":260,"wires":[["e42c75ec.c44de8","12f32abd.2b3105"]]},{"id":"8b6b60.15edb4a","type":"link out","z":"2854b769.c86be8","name":"paliti vanjsko svjetlo","links":["80e3aca4.881e3"],"x":1135,"y":380,"wires":[]},{"id":"12f32abd.2b3105","type":"trigger","z":"2854b769.c86be8","name":"","op1":"","op2":"1","op1type":"nul","op2type":"num","duration":"3","extend":false,"overrideDelay":false,"units":"s","reset":"0","bytopic":"all","topic":"topic","outputs":1,"x":280,"y":380,"wires":[["3fe280d1.6799b"]]},{"id":"e42c75ec.c44de8","type":"function","z":"2854b769.c86be8","name":"inside 3s","func":"// set initial values to context variables\ncontext.doorBellPressed = context.doorBellPressed || 0;\ncontext.doorBellReleased = context.doorBellReleased || 0;\n\n// set current time and util object reference from global context\nlet currentTime = Date.now(),\n    util = global.get(\"util\");\n\n// remember time when doorBell is pressed\nif (msg.payload == 1) {\n    context.doorBellPressed = currentTime;\n}\n// doorBell is released\nelse {\n    // calculate time between current and previous door bell button release\n    let previous = (currentTime - context.doorBellReleased) / 1000;\n    // filter quick pressing on door bell (if time between two button releasing is to short)\n    if (previous < 2) {\n        return null;\n    }\n    // calculate time between pressing and releasing door bell button\n    let elapsedTime = (currentTime - context.doorBellPressed) / 1000;\n    // if button press was short (e.g. within 3sec) then this is valid doorbell event\n    if (elapsedTime < 3) {\n        // remember current time when doorBell was released\n        context.doorBellReleased = currentTime;\n        // send message (proceed to other nodes)\n        return {payload: 1};\n    }\n}\n// don't send any message\nreturn null;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":280,"y":140,"wires":[["99c49270.69b6","7a2fe4a3.cb40cc"]]},{"id":"3fe280d1.6799b","type":"exec","z":"2854b769.c86be8","command":"/home/dbunic/project/gpio/gpio","addpay":"","append":"-r g25","useSpawn":"false","timer":"","oldrc":false,"name":"read GPIO25","x":470,"y":380,"wires":[["6c60aca3.8641f4"],[],[]]},{"id":"6c60aca3.8641f4","type":"change","z":"2854b769.c86be8","name":"toggle value","rules":[{"t":"change","p":"payload","pt":"msg","from":"1","fromt":"str","to":"0","tot":"num"},{"t":"change","p":"payload","pt":"msg","from":"0","fromt":"str","to":"1","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":690,"y":380,"wires":[["d1ed49a8.813fc8","f4ae6b82.86b968"]]},{"id":"dd70b715.01adc8","type":"trigger","z":"2854b769.c86be8","name":"after 3s","op1":"","op2":"1","op1type":"nul","op2type":"num","duration":"3","extend":false,"overrideDelay":false,"units":"s","reset":"0","bytopic":"all","topic":"topic","outputs":1,"x":280,"y":380,"wires":[[]]},{"id":"d1ed49a8.813fc8","type":"trigger","z":"2854b769.c86be8","name":"auto turn-off","op1":"","op2":"0","op1type":"nul","op2type":"num","duration":"5","extend":false,"overrideDelay":false,"units":"min","reset":"0","bytopic":"all","topic":"topic","outputs":1,"x":810,"y":500,"wires":[["f4ae6b82.86b968"]],"info":"Auto turn-off outside light"},{"id":"f4ae6b82.86b968","type":"noraf-light","z":"2854b769.c86be8","devicename":"vanjsko garaĹľa","lightcolor":false,"brightnesscontrol":false,"commandonlycolor":false,"turnonwhenbrightnesschanges":false,"passthru":true,"statepayload":true,"brightnessoverride":"","roomhint":"vanjsko","name":"","colortype":"hsv","nora":"df99e4f1.cb9728","topic":"","onvalue":"1","onvalueType":"num","offvalue":"0","offvalueType":"num","temperaturemin":"2700","temperaturemax":"5500","x":960,"y":380,"wires":[["d1ed49a8.813fc8","8b6b60.15edb4a"]]},{"id":"452d9cdc.d70274","type":"noraf-notify","z":"2854b769.c86be8","tag":"","title":"Zvono zvoni","body":"--","icon":"https://image.flaticon.com/icons/png/128/1554/1554201.png","name":"send notification","nora":"df99e4f1.cb9728","topic":"","actions":[],"x":720,"y":80,"wires":[[]]},{"id":"d2d06651.6e36a8","type":"link out","z":"2854b769.c86be8","name":"write to log","links":["41ad38e2.b29aa8"],"x":655,"y":240,"wires":[]},{"id":"4b9a7708.323e68","type":"comment","z":"2854b769.c86be8","name":"write to log","info":"","x":740,"y":240,"wires":[]},{"id":"99c49270.69b6","type":"function","z":"2854b769.c86be8","name":"1 msg in 20s","func":"// set initial values to context variables\ncontext.lastTime = context.lastTime || 0;\n\n// set current time\nlet currentTime = Date.now(),\n    elapsedTime = (currentTime - context.lastTime) / 1000;\n\n// filter messages for 20sec\nif (elapsedTime < 20) {\n    return null;\n}\n\n// local variables if message needs to be processed\nlet util = global.get(\"util\"),\n    time = util.getTime(\"hh:mm\"),\n    body;\n    \n// prepare message depending on doorbell switch (enabled/disabled)\nif (util.ringing === \"true\") {\n    body = \"Netko zvoni u \" + time;\n}\nelse {\n    body = \"Netko tiho zvoni u \" + time;\n}\n    \n// save time to lastTime\ncontext.lastTime = currentTime;\n\n// send message with body in payload to display in notification\nreturn {payload: {body: body}};\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":490,"y":80,"wires":[["452d9cdc.d70274"]]},{"id":"7a2fe4a3.cb40cc","type":"function","z":"2854b769.c86be8","name":"test if enabled","func":"// set reference to util\nlet util = global.get(\"util\");\n\n// if doorbell ringing is disabled then be quiet\n// but write to log\nif (util.ringing === \"false\") {\n    return [\n        null, \n        {payload: 1, params: {sensor: \"db\", text: \"Ringing (quiet)\"}}\n    ];\n}\n\n// otherwise ring with sound defined in util.doorbell\n// and write to log\nreturn [\n    {payload: util.doorbell},\n    {payload: 1, params: {sensor: \"db\", text: \"Ringing\"}}\n];","outputs":2,"noerr":0,"initialize":"","finalize":"","libs":[],"x":500,"y":200,"wires":[["e36775d5.afacc8"],["d2d06651.6e36a8"]]},{"id":"bc00192a.9ad5b8","type":"comment","z":"2854b769.c86be8","name":"vanjsko","info":"","x":930,"y":340,"wires":[]},{"id":"f79f625d.2355f","type":"comment","z":"2854b769.c86be8","name":"vanjsko upaljeno?","info":"","x":490,"y":340,"wires":[]},{"id":"df99e4f1.cb9728","type":"noraf-config","name":"nora config","group":"","twofactor":"off","twofactorpin":"","localexecution":true,"structure":""}]

Also, can you post the start of the node red startup log please.

Here is output from node-red-stop command and then node-red-start:

Stopping Node-RED graphical event wiring tool...
15 Jun 19:57:02 - [info] Stopping flows
15 Jun 19:57:03 - [info] [mqtt-broker:raspi] Disconnected from broker: mqtt://192.168.100.3:1883
15 Jun 19:57:04 - [info] Stopped flows
nodered.service: Succeeded.
Stopped Node-RED graphical event wiring tool.


Started Node-RED graphical event wiring tool.
15 Jun 19:57:59 - [info]
Welcome to Node-RED
===================
15 Jun 19:57:59 - [info] Node-RED version: v1.3.3
15 Jun 19:57:59 - [info] Node.js  version: v12.22.1
15 Jun 19:57:59 - [info] Linux 5.10.17+ arm LE
15 Jun 19:58:06 - [info] Loading palette nodes
15 Jun 19:58:30 - [info] Settings file  : /home/dbunic/.node-red/settings.js
15 Jun 19:58:30 - [info] Context store  : 'default' [module=memory]
15 Jun 19:58:30 - [info] User directory : /home/dbunic/.node-red
15 Jun 19:58:30 - [warn] Projects disabled : editorTheme.projects.enabled=false
15 Jun 19:58:30 - [info] Flows file     : /home/dbunic/.node-red/flows_raspi.json
15 Jun 19:58:30 - [info] Server now running at http://127.0.0.1:1880/
15 Jun 19:58:30 - [warn]
---------------------------------------------------------------------
Your flow credentials file is encrypted using a system-generated key.
If the system-generated key is lost for any reason, your credentials
file will not be recoverable, you will have to delete it and re-enter
your credentials.
You should set your own key using the 'credentialSecret' option in
your settings file. Node-RED will then re-encrypt your credentials
file using your chosen key the next time you deploy a change.
---------------------------------------------------------------------
15 Jun 19:58:31 - [info] Starting flows
15 Jun 19:58:43 - [info] Started flows
15 Jun 19:58:44 - [info] [sqlitedb:a57deb46.324718] opened /home/dbunic/project/www/_database/house.sqlite3 ok
15 Jun 19:58:47 - [info] [mqtt-broker:raspi] Connected to broker: mqtt://192.168.100.3:1883
15 Jun 19:58:50 - [info] nora: connected, uid: xxxxxxxxxxx
15 Jun 19:59:00 - [info] nora: synced 19 device(s), group: <default>

This time GPIO input pin was correctly started. Sometimes it is "stopped" and it can happen after Raspi is restarted or after deploying flows. Actually when developing other flows and deploy changes I usually check Doorbell flow to see is GPIO14 running. All I can say that sometimes is stopped (red) and next restart flows or developing further and deploying fix this problem. It would be much easier if this happen all the time or error message was written in logs so I can narrow issue but unfortunately this is not the case so I'm searching for guidance where to look ...

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