GPIOs not responding to input change

Dear all

can I check what, in your experience, would prevent the (pre-installed) node-red GPIO input nodes from responding to changes in state of the GPIOs? On an RPi4 model b running bookworm.

looking at the state in terminal (using pinctrl) they are reporting properly via the OS.

thanks
justin

Have you got debug nodes directly to the GPIO nodes to confirm that is what is happening?

What status is shown under the nodes when they are not working?

Is this an intermittent problem or do they not work at all? If they don't work at all then run
node-red-stop
node-red-start
and show us what appears in the command window. Note that it is node-red-start not node-red start

thanks for the response.

doesn't seem to be an intermittent problem. remains the case through multiple reboots (not just restarts).

for debugging I'm asserting the pins directly against leads connected to 3.3v and gnd. I've also tried against the module that I'm working with (a standard EC11 rotary encoder).

here is the output from node-red-start

node-red-start

Start Node-RED
 
Once Node-RED has started, point a browser at http://10.10.10.112:1880
On Pi Node-RED works better with the Firefox or Chrome browser
 
Use   node-red-stop                          to stop Node-RED
Use   node-red-start                         to start Node-RED again
Use   node-red-log                           to view the recent log output
Use   sudo systemctl enable nodered.service  to autostart Node-RED at every boot
Use   sudo systemctl disable nodered.service to disable autostart on boot
 
To find more nodes and example flows - go to http://flows.nodered.org
 
Starting as a systemd service.
30 Jun 14:45:17 - [info]
Welcome to Node-RED
===================
30 Jun 14:45:17 - [info] Node-RED version: v4.0.1
30 Jun 14:45:17 - [info] Node.js  version: v18.20.3
30 Jun 14:45:17 - [info] Linux 6.6.31+rpt-rpi-v8 arm64 LE
30 Jun 14:45:18 - [info] Loading palette nodes
30 Jun 14:45:20 - [info] Settings file  : /home/jpadie/.node-red/settings.js
30 Jun 14:45:20 - [info] Context store  : 'default' [module=memory]
30 Jun 14:45:20 - [info] User directory : /home/jpadie/.node-red
30 Jun 14:45:20 - [warn] Projects disabled : editorTheme.projects.enabled=false
30 Jun 14:45:20 - [info] Flows file     : /home/jpadie/.node-red/flows.json
30 Jun 14:45:21 - [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.
---------------------------------------------------------------------
30 Jun 14:45:21 - [warn] Encrypted credentials not found
30 Jun 14:45:21 - [info] Server now running at http://127.0.0.1:1880/
30 Jun 14:45:21 - [info] Starting flows
30 Jun 14:45:21 - [info] Started flows

after the start I tried two different GPIOs against both the gnd and 3.3v leads.

attached is a screenshot of what the flow looks like.

What do you see in the debug pane for debug 3 4 and 5?
Do the status codes shown under the nodes change?
Are you absolutely certain that you are connecting to the correct pins?
What type of pi is it?

all good questions!

it's an official RPi4b.
there is nothing in the input pane for the debugs other than on deploy. the status codes do not change.
I've taken a video and the link is here. Apologies for shaky camera skills: I'm mid-50s and had a coffee after lunch.

Hopefully viewers can see that the lead assignments are:

green: 3.3v
yellow: gnd
red: GPIO17, pin 11
yellow: GPIO18, pin 12

nothing new in the system logs other than the deploy I did just before starting the video.

The green and yellow ones look as if they are off the end, or is that just a parallax issue?

Have they ever worked?

they are connected to 3.3 and gnd. sorry if the photography didn't seem that way.

I got some results when using the gpiod nodes yesterday but now do not. nothing has changed RPi wise in the meantime (no new packages installed) other than turning it off over night. I can't say for sure that the gpiod nodes were reporting anything accurate as one of the reasons for starting over with the standard nodes was that there was a requirement for the pigpiod daemon to be loaded with root privileges.

The standard gpio nodes do not use pigpiod.

exactly. that's why I moved to the standard nodes so that there would be no dependency on the daemon.

do you have any idea what can cause node red not to capture the state change of GPIOs when the OS is reporting it correctly?

Sorry, I misunderstood what you meant. Have you completely removed pigpiod? I don't know whether there might be a conflict otherwise.

pigpiod completely removed but no change in status.

is this perhaps because bookworm insists on python being run in a venv and perhaps the nodes try to use a non-virtual environment?

No machine handy at the mo but do you see any changes on the pins from the command line?

IIRC it's the gpioinfo command that shows anything else configured to use it and if they are set for input or output.

gpioinfo shows the two relevant pins (GPIO17 and 18) as occupied by "lg". Which I think is the library (lgpio) that is now used on bookworm

I've also just reinstalled nodered but that doesn't change anything.

I've also just added an ADC hat (some pin re-assigments necessary).
no response. But i can see that there are some errors in the journal


Jun 30 16:47:19 rp4 systemd[1]: Stopping nodered.service - Node-RED graphical event wiring tool...
Jun 30 16:47:20 rp4 Node-RED[3671]: Traceback (most recent call last):
Jun 30 16:47:20 rp4 Node-RED[3671]:   File "/home/jpadie/.node-red/node_modules/node-red-contrib-waveshare-shield-adda-11010/ads1256.py", line 416, in <modu>
Jun 30 16:47:20 rp4 Node-RED[3671]:     selfcal()
Jun 30 16:47:20 rp4 Node-RED[3671]:   File "/home/jpadie/.node-red/node_modules/node-red-contrib-waveshare-shield-adda-11010/ads1256.py", line 307, in selfc>
Jun 30 16:47:20 rp4 Node-RED[3671]:     if (GPIO.input(drdy) == 0):
Jun 30 16:47:20 rp4 Node-RED[3671]:         ^^^^^^^^^^^^^^^^
Jun 30 16:47:20 rp4 Node-RED[3671]:   File "/usr/local/lib/python3.11/dist-packages/RPi/GPIO/__init__.py", line 724, in input
Jun 30 16:47:20 rp4 Node-RED[3671]:     return _check(lgpio.gpio_read(_chip, gpio))
Jun 30 16:47:20 rp4 Node-RED[3671]:                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Jun 30 16:47:20 rp4 Node-RED[3671]:   File "/usr/lib/python3/dist-packages/lgpio.py", line 903, in gpio_read
Jun 30 16:47:20 rp4 Node-RED[3671]:     return _u2i(_lgpio._gpio_read(handle&0xffff, gpio))
Jun 30 16:47:20 rp4 Node-RED[3671]:                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Jun 30 16:47:20 rp4 Node-RED[3671]: KeyboardInterrupt
Jun 30 16:47:20 rp4 Node-RED[3671]: 30 Jun 16:47:20 - [warn] waveshare-shield-adda-11010 : ads1256.py python command failure

I think the answer is to roll-back to bullseye and try again.

I know there have been problems with the pi5 and gpio, but I have not heard of problems with bookworm on a 4 and gpio, and I can't find anything in the forum.

reporting back for posterity, rolling back to bullseye resolves all the issues. <touch wood, this is so... >

thanks for the help Colin.

It would be interesting to know whether it works on a fresh install on bookworm. Perhaps something got messed up along the way.

I may try in a couple of weeks but this visit I've only got another 48 hours to complete the build and deployment of the kit. and it's 1500km away from where I usually live!

interestingly I've just installed spidev and rpio.gpio (for the adc hat) and now the gpio nodes are not responding (and the ADC hat does not work either).

so am now thinking it may be more an issue with nodered 4 than bookworm. or maybe both.

Curious.