Software
The board itself does not have a controller and therefore no firmware. Here you can find some useful hints and code snippets to control the board. Until now, I only used Bash scripts.
config.txt
In /boot/config.txt (or /boot/firmware/config.txt for newer versions), the UART must be enabled in the [all] section. Here is an excerpt from my config.txt with the relevant entries:
#dtoverlay=vc4-fkms-v3d
dtoverlay=disable-wifi
dtparam=i2c_vc=on
enable_uart=1
dtoverlay=uart5,ctsrts
Bash Scripts (up to PI4b)
The direction of the I/O pins is already defined in the EEPROM. To make them usable by a bash script, we have to export them:
Then you can set and reset the pins like this:
Here you can also see how to generate pulses for the relays. The first sleep of two seconds guarantees that the storage capacitor is charged. Then we switch on the driver and generate the pulse time with a 50 ms sleep. Then we can switch off the driver again.
The timing via sleep is sufficiently accurate even in bash. For creating the measuring pulses and measuring the time, bash wont suffice. You would need a precise timing and resolution in a µs range. I did not try this until now and I don't know if thats even possible on a Pi, at least with raspbian.
It is important that only a single coil of a single relays is turned on and to wait two seconds before the next action to be sure the storage capacitor is fully charged again.
Bash Scripts (PI5 and later)
The I/O system has changed significantly with Raspberry Pi 5.
The previous method no longer works and is deprecated
.
Therefore, I had to make some changes when I switched to the Raspberry Pi 5.
In the current scripts, I use gpiod, which you might need to install first with apt install gpiod. This eliminates the need to initialize the I/Os; with `gpioset`, they are automatically programmed as outputs, and with `gpioget`, as inputs. Who came up with this? It's so far away from the hardware! Sometimes you need to read the pin state without programming it as an input, and sometimes you want to switch an input to an output without changing its output state! There's no data direction register, which is present in practically every port and can be set independently. So anyway, controlling the relays works something like this:
Cron Script
Being a system constant value, the NAS disk is defined by its UUID. This avoids to accidentally mount the wrong disk (/dev/sdx) as the NAS drive. But in /proc/mounts it will appear as sdx. $(/bin/readlink -e $d) helps finding the right match where $d is the UUID link (/dev/disk/by-uuid/<UUID>). Here as an example my powerOffNasDisk.

