Node-Red running with balena

With a brand new SD card (same type - just straight from the box) and a new device Image created and it actually let me update the program. I’m now going to try and add the ‘node-red-node-pi-gpio’ that was missing and see if the Node-red flow will start.

Hi @gregorr1,
It sounds like the previous SD card was faulty or badly written.
Let us know about your findings or if you start having issues again.

After one successful push, I then tried to add the node-red-node-pi-gpio that the logs had said was missing. This push did not go through (got to 100% downloaded then reverted back to release) and it appears to be doing the updating thing again.

The UUID for the latest device is 642c905c09d2b079f910f3b2f79898b5 if you need it.

I’ll be able to try a different SD card type later tonight/tomorrow morning.

I tried using a new Pi with the same Card in it and it has successfully updated the version. Could this be a Caching error or something to do with the pi itself?

hmm, that sounds pretty strange. Did you use the same power supply for both Pis? The only thing i can think of is that the one pi maybe draws a lot more power than the second one meaning it has more low voltage errors (you can see this if you run the diagnostics panel on the device) and that perhaps causes corruption of the docker download. But thats just a guess based on reading about variance in pis power draw.

Yeah it’s the same power supply. I tried running dmesg to see if I could see anything about undervoltage - but I didn’t notice anything.

The new pi managed one update then appears to be doing the same constant updating thing. It gets to 100% then jumps back to 0% and downloads it again.

wow, yeah that is strange. When the device was failing to update, did you ever reboot it? I wonder if switching the pi was more about just clean restarting the container engine?

I’m just leaving the office at the moment but I’ll try it out tomorrow and let you know what happens.

okay great, will be interested in the finding.

So I tried rebooting while it was downloading - but I got an “Operation Timed Out” error although it did appear to reboot. It continued to do the updating thing. Tried shutting it down and got the same error - but it eventually did shut itself down. I’ll try the Sandisk Ultra SD card today and see if that works better.

The Sandisk Card appears to be working, so I can start working again on getting my dependencies sorted.

When the container starts I’m getting this error:
image

I’ve made sure that my dockerfile includes:
RUN apt-get update && apt-get install -yq --no-install-recommends
rpi.gpio
python-dev
python-rpi.gpio
&& apt-get clean && rm -rf /var/lib/apt/lists/*

What else do I need to add?

I wanted to have a look but screenshot is not readable for me.

Maybe also share your full dockerfile.

You can format code in this forum by putting it between 3 back ticks.

like I have done here

image

Hi, thanks for the reply. So the error I’m getting is:

Traceback (most recent call last):
    File "/usr/local/lib/node_modules/node-red-node-pi-gpio/testgpio.py", line 4, in <module>
        import RPi.GPIO as GPIO
    File "/usr/lib/python2.7/dist-packages/RPi/GPIO/__init__.py", line 23, in <module>
        from RPi._GPIO import *
RuntimeError: This module can only be run on a Raspberry Pi!

My docker file is:

###
# Build step
###
FROM balenalib/raspberrypi4-64-debian-node:latest-build as build

RUN JOBS=MAX npm install -g --production --unsafe-perm \
        node-red \
        node-red-admin \
	node-red-node-pi-gpio \
        node-red-contrib-azure-iot-hub \
	node-red-contrib-frequency-meter \
        node-red-contrib-ibm-watson-iot \
	node-red-contrib-os \
	node-red-dashboard \
	node-red-contrib-simpletime
	
###
# Runtime image
###
FROM balenalib/raspberrypi4-64-debian-node:latest-run

RUN apt-get update && apt-get install -yq --no-install-recommends \
	build-essential \
	rpi.gpio \
  	python-dev \
  	python-rpi.gpio \
  	&& apt-get clean && rm -rf /var/lib/apt/lists/* && \

# Defines our working directory in container
WORKDIR /usr/src/app

# Copy over the files created in the previous step, including lib/, bin/
COPY --from=build /usr/local/bin /usr/local/bin
COPY --from=build /usr/local/lib/node_modules /usr/local/lib/node_modules

# This will copy all files in our root to the working  directory in the container
COPY . ./

# server.js will run when container starts up on the device
CMD ["bash", "/usr/src/app/start.sh"]

Thanks

Thanks,
There seems to be a compatibility issue between raspberry pi 4 and python-rpi.gpio library.

FYI: I found the error back in file py_gpio.c of the python-rpi.gpio package.

I would report this issue in the node-red forum. This is a very active forum so you will soon get feedback.

Hi @janvda when I first set up my Pi4 with the standard raspbian etc I had a similar error regarding the GPIO pins and node red. This was fixed by installing the latest version of the gpio library. Could it be that the
“balenalib/raspberrypi4-64-debian-node:latest” is not using the most recent version of this library?

That indeed might be a reason.

You can try with the recent node-red images provided by node-red community.
I think the following should work for raspberry pi:
https://hub.docker.com/layers/nodered/node-red/1.0.0-1-10-minimal-arm64v8/images/sha256-b92abab0eb1923756b610c878c67267451735222c7fae6053eec052b3f5289b5

Also have a look at section Raspberry PI - native GPIO support on page : https://nodered.org/docs/getting-started/docker
It says something about native GPIO support being dropped for raspberry pi.

Looking at the second link you sent - I already have the node-red-node-pi-gpiod being installed by my docker image. I don’t think I have the PiGPIOd daemon running though. How would I add this?

Could it be that the “balenalib/raspberrypi4-64-debian-node:latest” is not using the most recent version of this library?

Just FYI, our base images are rebuilt weekly, so as long as libraries are published to official repos, they should be picked up pretty soon.

@gregorr1 I know it has already been suggested, but I wanted to check if you have tried running on node-red example project as it is on your device

I know a few members of our team have run it successfully, but I’m not sure if we’ve tried it on rpi4.

OK - I see. The PiGPIOd daemon is part of the raspbian OS but we are not using raspbian OS. So we need to figure out how we can install and run that daemon.