Run a script to setup a HAT on my Raspbery Pi 4 host

I need help to run the setup script for Witty Pi3 Rev2 a Realtime Clock and Power Management HAT for Raspberry Pi.

Let me start by saying that I’ve been trying to search the right info for hours but I’m new to this and are pretty much lost :stuck_out_tongue:

I followed the instruction here to setup my Pi as an Airplay receiver. That works as expected.

Now I want to ask a Witty HAT to be able to easily turn off my Pi with the press of a button, among other things.

I’m trying to go through the Terminal that I found on the balena cloud dashboard of my device.

First I turn the device read-write to be able to download my script:
mount -o remount,rw /
Then I download the script with:
Then I try to run the script with sudo as follows:
sudo sh

It seems like sudo in not available from here which makes me think that they are quite some things I did not understand yet, or maybe I’m meant to go through the CLI maybe?

Maybe I missed the documentation somewhere that helps me to update things to the host but I wasn’t able to find anything.

Can someone please point me to the right direction? I’d really appreciate. Thanks.

Also, once I do that, will my changes be overwritten by the next update or so? How do I persist my changes?

Thanks in advance,


When you log into the Host OS (or most containers), your command prompt will show a # indicating that you are already running as root. This means you don’t need the sudo bit for installation.
You only need to sudo if you are running as a normal user (indicated by $).

Ideally, you would try to do all of this in a container, but the device configuration actually needs to run before that.

I’ve taken a quick look at the install script, and noticed a few things off if you were to try to apply it to your Balena device.

First of all, it is attempting to modify your configuration file in /boot/config.txt, however in the HostOS this is found in /mnt/boot/config.txt.
The devicetree configuration done here, is also possible from the BalenaCloud dashboard.

Second, it tries to install wittypi as an init.d service, while Balena generally uses systemd as init system. In your own container, this shouldn’t be an issue.

I would split up the installation script into the configuration part (which needs to be done on the host), and the actual installation part, which can be run in its own container.

The changes to your config.txt should persist through updates, I’m not sure about manually installed things. The safe bet is to assume only your containers (and their /data volumes) are persisted.

1 Like

Hello TJvV,
Sorry I couldn’t get back to you earlier. Thanks a lot for looking into that and for taking the time to provide a detailed answer. It makes a lot of sense now. There is still so much I have to learn. Thanks for all the pointers, that is exactly what I needed. Cheers.


Hi, I’d like to know more about this.

I thought I’d be able to use ‘apt’ like I was with another balena project (I realize now it’s not a proper balena ‘product’), but it doesn’t seem to work this way with balenaSound. running ‘apt install python3-pip’ returns ‘bash: apt: command not found’.

The HAT I’m trying to get working with my multi-room setup is this.
It features a fan, OLED screen and RGB. It also has GPIO pins, which I have been using with a DAC (which is working, without additional configuration).

Some of my devices seem to be running at near 60-65C and I’m hoping this will help cool them down a bit (also, not sure but it looks like the hotter they get the more latency in the multi-room audio sync, is this something that everyone experiences, or is it just me?)

Any help would be greatly appreciated!
Thank you!