# Problems with Raspberry Pi 4 GPIO input with Docker

**URL:** <https://discourse.nodered.org/t/problems-with-raspberry-pi-4-gpio-input-with-docker/31537>\
**Category:** General\
**Created:** [13 August 2020 21:48 UTC](https://discourse.nodered.org/t/problems-with-raspberry-pi-4-gpio-input-with-docker/31537 "2020-08-13T21:48:24Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Charry2014](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/charry2014/32/46308_2.png) [@Charry2014](https://discourse.nodered.org/u/Charry2014)\
**Post date:** [13 August 2020 21:48 UTC](https://discourse.nodered.org/t/problems-with-raspberry-pi-4-gpio-input-with-docker/31537/1 "2020-08-13T21:48:24Z")

</div>

For a while I have been using a Raspberry Pi 4 with Node Red and [pigpiod](http://abyz.me.uk/rpi/pigpio/pigpiod.html) 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](https://github.com/Charry2014/balena-node-red-raspberry-pi-gpio). I have configured pin 40 (GPIO21) as an output with pullup resistor.

```auto
[{"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":"172.17.0.1","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.

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [14 August 2020 00:36 UTC](https://discourse.nodered.org/t/problems-with-raspberry-pi-4-gpio-input-with-docker/31537/2 "2020-08-14T00:36:27Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Charry2014](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/charry2014/32/46308_2.png) [@Charry2014](https://discourse.nodered.org/u/Charry2014)\
**Post date:** [14 August 2020 06:22 UTC](https://discourse.nodered.org/t/problems-with-raspberry-pi-4-gpio-input-with-docker/31537/3 "2020-08-14T06:22:22Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [14 August 2020 09:06 UTC](https://discourse.nodered.org/t/problems-with-raspberry-pi-4-gpio-input-with-docker/31537/4 "2020-08-14T09:06:51Z")

</div>

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).

---

<div class="post-metadata">

**Author:** ![Charry2014](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/charry2014/32/46308_2.png) [@Charry2014](https://discourse.nodered.org/u/Charry2014)\
**Post date:** [14 August 2020 22:04 UTC](https://discourse.nodered.org/t/problems-with-raspberry-pi-4-gpio-input-with-docker/31537/5 "2020-08-14T22:04:20Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [28 August 2020 22:04 UTC](https://discourse.nodered.org/t/problems-with-raspberry-pi-4-gpio-input-with-docker/31537/6 "2020-08-28T22:04:21Z")

</div>

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