I am wondering if anyone has had any success in getting pigpio daemon pigpiod to run on a raspberry pi 3? I have written a .sh startup script with this simple command:
systemctl enable pigpiod
I then get the following error:
Failed to enable unit, unit pigpiod.service does not exist
When I google this I run into some folks talking about having to setup config.txt or raspi-config to enable “remote gpio”
So the question would be how to do this with Balena? Is it an environmental variable and if so how do I set it up?
FROM balenalib/raspberrypi3-debian:buster-build
RUN apt-get update && apt-get install build-essential unzip wget
WORKDIR /usr/src/app
RUN wget https://github.com/joan2937/pigpio/archive/master.zip
RUN unzip master.zip
WORKDIR /usr/src/app/pigpio-master
RUN make
RUN make install
CMD pigpiod
This helped a little. Now I no longer see the error “Failed to enable unit, unit pigpiod.service does not exist” however there is still an issue with connecting to it. I am getting this additional error:
main Can’t connect to pigpio at localhost(8888)
main Did you start the pigpio daemon? E.g. sudo pigpiod
main
main Did you specify the correct Pi host/port in the environment
main variables PIGPIO_ADDR/PIGPIO_PORT?
E.g. export PIGPIO_ADDR=soft, export PIGPIO_PORT=8888
main
main Did you specify the correct Pi host/port in the
main pigpio.pi() function? E.g. pigpio.pi(‘soft’, 8888)
When I read online there are several mentions of having to turn on “remote gpio” in raspi-config. However that is usually done in Balena by Variables that we set in the device configuration correct?
What command(s) are you trying to run when you get the Failed to enable unit, unit pigpiod.service does not exist error?
There’re also some tests included in the repository that you could run to see if pigpiod is working:
./x_pigpiod_if2 # test the C I/F to the pigpio daemon
./x_pigpio.py # test the Python I/F to the pigpio daemon
./x_pigs # test the socket I/F to the pigpio daemon
./x_pipe # test the pipe I/F to the pigpio daemon
I am trying a totally new approach now which is to try to split pigpiod into its own service container. In my .yml file I expose port 8888 on the pigpio service and then make my other container dependent on it. It looks like it might work but the issue I am having is that both containers are now constantly exiting and restarting. I found another topic on this Container stuck continuously restarting but not sure if that is the issue.
Any suggestions on how to prevent these containers from constantly restarting?
This sounds like the services are starting their commands, and then exiting, which is why the Supervisor is restarting the containers. Could you paste your Dockerfiles and docker-compose.yml manifest here, that would allow us to see what might be going on.
Thanks for these. I notice that you’re trying to use systemd as an init system. The balenalib base images do not include systemd, and so the ENV INITSYSTEM on command will not work. There’s some documentation on these changes here: https://www.balena.io/docs/reference/base-images/base-images/#major-changes which include directions on how you could install your own init system, including systemd.
Thanks everyone. I removed all the systemmd and INIT stuff and I have it running now back in a single container. I kept getting this error “init mbox zaps failed” each time it would upload and restart with latest build. Then I found this article in regards to this issue https://raspberrypi.stackexchange.com/questions/29983/pigpio-initialization-failing-with-init-mbox-zaps-failed . I rebooted and it started working. I then went in and upped my GPU memory to 32 and the reboot was not longer required. I also went back to simple approach of apt-get install of pigpio \ python-pigpio \ python3-pigpio and they all worked instead of the more complicated install build ZVIN had suggested above. So I think I am all good.