2026-06-18 14:09:14 -04:00
2026-06-18 14:09:14 -04:00
2026-06-18 14:09:14 -04:00
2026-06-15 11:29:17 -04:00
2026-06-15 15:06:21 -04:00
2026-06-18 14:09:14 -04:00

TowerD

I wrote this to control the "hardware" on KW1FOX-1 tower.

its.. not really intended for use anywhere else but, if anything inspires you go ahead and grab it!

Install

sudo git clone https://git.kitsunehosting.net/Kenwood/towerd.git /opt/towerd
cd /opt/towerd
cargo build --release
sudo cp systemd/towerd.service /etc/systemd/system/
sudo systemctl daemon-reload
sudo systemctl enable --now towerd

Usage

./target/release/towerd --verbose

# systemd
sudo systemctl status towerd
sudo journalctl -u towerd -f

Metrics

Originally I was going to write to my influxdb server over the network but I learned that influxdb can be configured to save locally and drain when network is up, which would be pretty awesome for edge computing like the tower. So, new architecture is to run locally and configure it to replicate.

Local Config

Create /opt/towerd/.env

INFLUXDB_INIT_PASSWORD=change-me
INFLUXDB_INIT_ADMIN_TOKEN=change-me-to-a-long-random-token
INFLUXDB_INIT_ORG=tower
INFLUXDB_INIT_BUCKET=tower

then

cd /opt/towerd
docker compose up -d

Init vars only matter once

InfluxDB listens on 127.0.0.1:8086 only.

Configure towerd

Create /etc/towerd/env:

TOWERD_INFLUX_URL=http://127.0.0.1:8086
TOWERD_INFLUX_ORG=tower
TOWERD_INFLUX_BUCKET=tower
TOWERD_INFLUX_TOKEN=<same as INFLUXDB_INIT_ADMIN_TOKEN>
TOWERD_INFLUX_HOST=kw1fox-1

# optional
# TOWERD_INFLUX_INTERVAL_S=30

Restart towerd after editing:

sudo systemctl restart towerd

Replicate to remote InfluxDB

Need influx cli

# register the remote server
influx remote create \
  --host http://127.0.0.1:8086 \
  --token "$TOWERD_INFLUX_TOKEN" \
  --name kitsune-remote \
  --remote-url http://influx.kitsunehosting.net:8086 \
  --remote-api-token <remote-write-token> \
  --remote-org-id <remote-org-id>

# list remotes to get the ID from the previous step
influx remote list \
  --host http://127.0.0.1:8086 \
  --token "$TOWERD_INFLUX_TOKEN"

# replicate the local bucket to the remote bucket
influx replication create \
  --host http://127.0.0.1:8086 \
  --token "$TOWERD_INFLUX_TOKEN" \
  --name tower-to-kitsune \
  --remote-id <remote-id> \
  --local-bucket-id <local-bucket-id> \
  --remote-bucket <remote-bucket-name>

Find the local bucket ID:

influx bucket list \
  --host http://127.0.0.1:8086 \
  --token "$TOWERD_INFLUX_TOKEN"

Check replication queue health:

influx replication list \
  --host http://127.0.0.1:8086 \
  --token "$TOWERD_INFLUX_TOKEN"

Renogy controller

Need rs232 adapter to talk modbus to renogy controller

# list adapters: ls -l /dev/serial/by-id/
TOWERD_RENOGY_SERIAL=/dev/serial/by-id/usb-Silicon_Labs_CP2102N_USB_Bridge_...
# optional
TOWERD_RENOGY_SLAVE=255
TOWERD_RENOGY_BAUD=9600
TOWERD_RENOGY_INTERVAL_S=10
TOWERD_RENOGY_TIMEOUT_MS=1000

Thank you to ESP32ArduinoRenogy for doing all the hard work!

systemd

towerd loads /etc/towerd/env via EnvironmentFile. If using Docker for InfluxDB, ensure Docker starts before towerd:

[Unit]
After=docker.service
Wants=docker.service

Add those lines to /etc/systemd/system/towerd.service under [Unit].

Description
No description provided
Readme 65 KiB
Languages
Rust 100%