Raspberry Pi Configuration

This page contains a parts list and setup instructions for a Raspberry Pi HiveMind client, connected to the internet via WiFi.

Parts List

Easy Configuration

  • Download the image:
  • Write the image to an SD card.
    • You can use the Raspberry Pi Imager for this.
    • Download and unzip the image, click to select an operating system, then select "Use Custom"
  • To configure the system, connect to the WiFi network "HiveMind Config". The configuration screen should automatically load.
  • Enter your WiFi and cabinet configuration information. Disable the NFC sign-in option. You can also optionally set a password for the hivemind user, and/or add a SSH public key.
  • After saving the configuration, the system will reboot with the new configuration.

Manual Setup

If the above image doesn't work, you can install Raspberry Pi OS using the imager, and then use the following commands to configure your system from the terminal.

The initial user account created by this image has the username pi, and its initial password is raspberry.

Configure WiFi

/etc/wpa_supplicant/wpa_supplicant.conf" <<EOF
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
country=us
EOF

Then, with your network's SSID and PSK:

wpa_passphrase "<SSID>" "<PSK>" | sudo tee -a /etc/wpa_supplicant/wpa_supplicant.conf

Create HiveMind User

sudo -i
usermod -L pi
useradd -m -U -G sudo,gpio,plugdev hivemind
cat /etc/sudoers | sed 's/^\%sudo.*$/%sudo  ALL=(ALL) NOPASSWD:ALL/' > /tmp/sudoers
chown root:root /tmp/sudoers
chmod 600 /tmp/sudoers
mv /tmp/sudoers /etc/sudoers

passwd hivemind

Set your new password here.

Install NodeJS and Stats Client

sudo -u hivemind -i

wget https://nodejs.org/dist/v11.15.0/node-v11.15.0-linux-armv6l.tar.gz
tar xfz node-v11.15.0-linux-armv6l.tar.gz
sudo mv node-v11.15.0-linux-armv6l /usr/local/node

cat > /home/hivemind/hivemind-client.sh <<EOF
#!/bin/bash
cd /home/hivemind

/usr/local/node/bin/npm upgrade @kqhivemind/hivemind-client
/usr/local/node/bin/npx hivemind-client config.json | sudo tee -a /dev/tty0
EOF

chmod +x /home/hivemind/hivemind-client.sh
/usr/local/node/bin/npm install @kqhivemind/hivemind-client

Run Client on Startup

sudo tee "/lib/systemd/system/hivemind-client.service" <<EOF
[Unit]
Description=HiveMind Stats Client

[Service]
ExecStart=/home/hivemind/hivemind-client.sh
User=hivemind

[Install]
WantedBy=multi-user.target
EOF

sudo systemctl daemon-reload
sudo systemctl enable hivemind-client
sudo systemctl start hivemind-client

Configure Networking

This will set a static IP address for the wired network adapter, and install a DHCP server and assign the IP address 10.68.182.100 to any connected cabinet.

sudo apt -y install isc-dhcp-server

sudo tee -a /etc/dhcpcd.conf <<EOF
interface eth0
static ip_address=10.68.182.1
static domain_name_servers=8.8.8.8
EOF

sudo tee /etc/dhcp/dhcpd.conf <<EOF
ddns-update-style none;
option domain-name "hivemind.local";
option domain-name-servers 8.8.8.8, 8.8.4.4, 10.68.182.1;
default-lease-time 3600;
max-lease-time 86400;
authoritative;
log-facility local7;

subnet 10.68.182.0 netmask 255.255.255.0 {
    range 10.68.182.100 10.68.182.100;
    option routers 10.68.182.1;
}
EOF

sudo tee /etc/default/isc-dhcp-server <<EOF
INTERFACESv4="eth0"
INTERFACESv6=""
EOF

Update Config File

Use nano /home/hivemind/config.json to create the configuration file. You will need to edit the following values to match your cabinet.

{
  "cabinets": [
    {
      "sceneName": "<SCENE_NAME>",
      "cabinetName": "<CABINET_NAME>",
      "token": "<CABINET_TOKEN>",
      "url": "ws://10.68.182.100:12749"
    }
  ],
  "servers": [
    {
      "name": "HiveMind",
      "url": "wss://kqhivemind.com/ws/stats_listener/v3"
    }
  ]
}

This should match the configuration file that you can download from the cabinet's Edit window, except for the URL, which should be ws://10.68.182.100:12749.

Configure Router (optional)

Configuring your Pi as a router allows the cabinet to reach the internet. It is not necessary unless you want the cabinet to update using the internet and you don't want to configure WiFi access on the cabinet itself.

sudo apt -y install firewalld
sudo firewall-cmd --zone=home --add-interface=eth0
sudo firewall-cmd --zone=public --add-interface=wlan0
sudo firewall-cmd --zone=public --add-masquerade
sudo firewall-cmd --zone=home --add-service=dns
sudo firewall-cmd --zone=home --add-service=dhcp
sudo firewall-cmd --runtime-to-permanent