I have just set up my rapberry Pi 4b and to get the audio output to work I have used an earlier version, [balenaOS 3.2.7+rev1]. I tried various suggestions but none worked.
Everything works now but I wish to use an off button to shut down the device.
First things first: connecting to your balena device.
Usually you do this through the balena-cli.
TLDR:
You can install it with npm install -g balena-cli, after which you can run balena login --web to authenticate and balena ssh <device uuid> <service> to connect to a specific container on a specific deivce.
Second: how do you install it?
After logging in to your service container, you can simply grab the git repository and run the script.
You may have to run chmod +x ./pi-power-button/script/install first to make it executable.
Note that this will install the listen/shutdown script to be run on /etc/init.d style init, this is not compatible with systemd. I’m not 100% sure which init system you get in your container. This part of the documentation suggest you may have to install it yourself.
Finally:
Just out of curiousity, is there a reason you are looking at this approach, instead of the devicetree overlay?
See for example here.
The gpio-shutdown overlay can be used to issue the shutdown command when a GPIO input is triggered.
The gpio-poweroff overlay can be used to set a GPIO output when the device is ready to be powered off.
This requires no extra installation steps, just a modification to the configuration, which can be done through the balenaCloud dashboard or by editing /boot/config.txt before the first boot. more details.
You have to look at the complete configuration.
GPIO3 is also an I2C pin (SCL).
If the I2C is enabled, it will override what the GPIO configuration is trying to do.
I2C is enabled with something like dtparam=arm_i2c=on; removing that entry should solve it.
You can use this site to get a nice overview of the GPIOs and their alternate functions.