Problems with Raspberry Pi 4 GPIO input with Docker

For a while I have been using a Raspberry Pi 4 with Node Red and pigpiod to control some relays using GPIO output pins, and it works very well now. However now I try to use some GPIO pins as inputs and I am having a lot of trouble. The application is running in Docker containers - the pigpio daemon running in one container, and Node Red in another. The full sources and Docker containers are available in Github. I have configured pin 40 (GPIO21) as an output with pullup resistor.

[{"id":"19dcc58d.7bd56a","type":"debug","z":"9d7b7f7f.f540f","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":510,"y":1160,"wires":[]},{"id":"2ef83a07.16ae56","type":"pi-gpiod in","z":"9d7b7f7f.f540f","name":"","host":"","port":8888,"pin":"21","intype":"PUD_UP","debounce":"25","read":false,"x":270,"y":1160,"wires":[["19dcc58d.7bd56a"]]}]

On debugging I can see that inside the container the /usr/local/bin/pigs r 21 command is able to read the GPIO pins successfully - 1 normally, but 0 when the pin is pulled to ground but Node Red does not receive any trigger that the level changed.

Further testing showed that the Pi 3B seems to work better - I can fairly reliably get Node Red to trigger. Before I take the low road and just switch to a 3B can anyone give me some hints what may be going wrong on the Pi 4 or if I am missing something else?

Thanks in advance.

I'm no expert but this sounds like a Docker issue. Certainly not a Node-RED issue.

I tried the non-dockerised version and it worked too. It seems to lie in the link between the two containers, which is working in the output direction just fine. Can anyone explain the mechanism that pigpiod uses to communicate GPIO events to Node Red?

Sorry, I don't use that. But if you look at the source code for the node, you will probably be able to pick out the method. I'm guessing that it will use some kind of TCP/IP connection. But it might equally be a UNIX PIPES connection (though I've found that not many people seem to know about those).

Further digging has revealed that most of the weird behaviour was down to two depressingly simple factors - human error and crap wifi.

First - I guess as part of my fumbling I fried one of the GPIOs as it now maintains a stubborn 0.38V which is no use to anyone. Then, connecting either the Pi 4 or Pi 3B to a well functioning network creates a well functioning device. Who'd have thought? Putting either device in a weak wifi spot creates chaos. Now that Pi 3B and 4 have wired connections they both work fine.

Either way, Docker and the containerised applications were working best they could. Thanks for your help again, much appreciated.

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