This guide covers the necessary steps to install, configure, and maintain the Beatnik Hardware API on your Raspberry Pi.
There are two primary ways to install the service. Method 1 (Production Release) is the most robust and professional choice, as it keeps your Raspberry Pi free of development dependencies and compiling overhead. Method 2 (Source Script) is better suited for active development.
Before you begin, ensure your Raspberry Pi meets the following requirements:
- OS: Raspberry Pi OS (Bookworm or newer recommended)
- Privileges: Root access (
sudo) is required to modify system configuration files and manage systemd services. - Node.js: Version 22 is required.
If you don't have Node.js installed, we recommend using NVM (Node Version Manager):
# Install NVM
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.3/install.sh | bash
source ~/.bashrc
# Install and activate Node.js 22
nvm install 22
nvm use 22We provide an automated setup script that downloads the latest pre-built release artifact, installs dependencies, and configures the systemd service. This is the cleanest way to run the service in production.
wget https://raw.githubusercontent.com/byrdsandbytes/beatnik-hardware-api/master/setup.sh
chmod +x setup.sh
./setup.shWhat the script does:
- Creates the
/opt/beatnik-hardware-apidirectory. - Downloads and extracts the latest release artifact from GitHub.
- Installs Node.js v22 via NVM (if not present).
- Installs production dependencies (
npm install --omit=dev). - Automatically patches and installs
beatnik-hardware.serviceto systemd and starts it.
If you want to build the project directly from source on the Pi itself:
1. Clone Repository
sudo mkdir -p /opt/beatnik-hardware-api
sudo chown -R $USER:$USER /opt/beatnik-hardware-api
cd /opt/beatnik-hardware-api
git clone https://github.com/byrdsandbytes/beatnik-hardware-api.git .2. Install Dependencies & Build
npm install
npm run build3. Set up the System Service
# Copy the service file
sudo cp beatnik-hardware.service /etc/systemd/system/
# IMPORTANT: Edit the service file to ensure ExecStart points to your Node.js executable
# You can find your node path by running: which node
sudo nano /etc/systemd/system/beatnik-hardware.service
# Enable and start the service
sudo systemctl daemon-reload
sudo systemctl enable beatnik-hardware.service
sudo systemctl start beatnik-hardware.serviceTo make future updates completely seamless, the setup.sh script is designed to also act as an updater.
Whenever a new version (vX.X.X) is tagged and pushed to GitHub, an automated CI/CD pipeline (GitHub Actions) instantly builds a new release artifact. You can easily pull this update onto your Raspberry Pi by running the local setup script again:
cd /opt/beatnik-hardware-api
./setup.shWhat the updater does:
- Checks if the service is currently running, and smoothly stops it.
- Queries the GitHub API for the latest release of
byrdsandbytes/beatnik-hardware-api. - Downloads & extracts the new
beatnik-hardware-api.tar.gzartifact over the existing installation. - Runs
npm install --omit=devto sync any new dependencies. - Restarts the system service and cleans up.
Regardless of which method you chose, you can always check if the API is running smoothly via:
sudo systemctl status beatnik-hardware.serviceYou can also test the hardware status endpoint:
curl http://localhost:3000/api/hardware/status