Relay Board Controller

8-channel relay board used for controlling devices

A cross-platform controller for managing an 8-channel relay power strip over serial/USB. Implements a hand-rolled binary protocol at 57600 baud with CRC8 checksums for reliable communication. The repository ships two parallel front-ends: a small Linux CLI built in C with CMake, and a feature-rich Windows GUI built in C++ Builder 6.0 with VCL.

The Linux side is intentionally minimal but production-ready: native termios for serial configuration (no shell-out to stty, no command-injection surface), reply validation on every received frame, and a state file + systemd unit so the board's last known configuration is automatically restored on boot or after a power loss. The Windows side adds a tray-resident GUI with per-relay scheduling, a TCP server for remote control, and Windows autostart via the registry.

Serial Protocol

All communication uses a fixed 5-byte frame at 57600 baud, 8N1:

The board responds to a Get command with a frame whose command byte is 'R' and whose data byte is the relay states as a bitmask (bit 0 = relay 1, bit 7 = relay 8). Every received frame is validated for sync byte, device address, command byte, and CRC8 before its contents are trusted.

Linux CLI

./power_strip status        # query and refresh power_strip.state
./power_strip allon         # turn all relays on
./power_strip alloff        # turn all relays off
./power_strip 3 on          # turn relay 3 on
./power_strip 3 off         # turn relay 3 off
./power_strip restore       # reapply last saved state

systemd Boot Restore

A small oneshot unit reapplies the last-known relay state on every boot — invaluable after a power loss, since the board itself does not preserve state across reboots.

[Unit]
Description=Restore RelayBoard relay state on boot
After=local-fs.target

[Service]
Type=oneshot
WorkingDirectory=/opt/power_strip
ExecStart=/opt/power_strip/power_strip restore

[Install]
WantedBy=multi-user.target

Windows GUI

Technical Details

Build Instructions

Linux

cd linux
mkdir build && cd build
cmake ..
make
./power_strip status

Windows

Open the .bpr project file in C++ Builder 6.0 and build (Project → Build All). The standalone network client lives in klient sterowanie/ as a separate .bpr.

Check out the project on GitHub: Relay Board Controller on GitHub

Back to Portfolio