Skip to content
This repository has been archived by the owner on Oct 25, 2022. It is now read-only.
Gray Marchiori edited this page Jul 31, 2018 · 1 revision

This guide is intended for a Pi 3B, Pi 3B+, Pi 0W or 0WH. All of these models have integrated bluetooth hardware.

For the base configuration, we will assume that your pi has a pre-existing network configuration, and that you can access it via a browser using your existing DNS. We will also assume that you are using the pre-existing 'pi' user account.

Pre-Configuration

Upgrade Raspberry Pi

sudo apt-get update && sudo apt-get upgrade

Install dependency libraries:

sudo apt-get install libxwiimote-dev libboost-program-options-dev libboost-system-dev libboost-date-time-dev libboost-random-dev libglibmm-2.4-dev libssl-dev cppcheck git cmake

Install node.js and node package manager:

sudo apt-get install nodejs npm nodejs-legacy

Install Wii-Scale:

Create the necessary user and group, and add user 'pi' to the group. You can give any password or other information, we'll be making this account 'nologon'.

sudo adduser wiiscale
sudo usermod -aG wiiscale pi

By default, Linux sets the default terminal of the 'wiiscale' user to BaSH. This is a security risk, so we'll replace it with nologon.

sudo nano /etc/passwd

The last value on the line starting with wiiscale is /bin/bash. Change this to /usr/sbin/nologin. Be very careful when editing this file.

Allow the pi and wiiscale users to control the bluetooth stack from inside the Wii-Scale application:

sudo usermod -aG lp pi
sudo usermod -aG lp wiiscale

Then log out and in, in order for the group changes to take effect.

Create an application folder, and grant permissions to the pi user.

cd /opt
sudo mkdir Wii-Scale
sudo chown root:wiiscale Wii-Scale
sudo chmod 775 Wii-Scale
cd Wii-Scale/

Clone the Wii-Scale software into the folder.

git clone https://github.com/mo-g/Wii-Scale.git --recursive --depth 1 .
git fetch origin systemdservice
git checkout FETCH_HEAD -b systemd

Allow non-root users to access balance board:

sudo cp wii-scale/70-wii-scales.rules /etc/udev/rules.d/

Run install:

mkdir build && cd build
cmake ../wii-scale && make
npm install --production
cd ..

Allow non-local web browsers to access the application:

npm config set wii-scale:host 0.0.0.0

Before we start the application, we need to connect the Wii Balance Board:

sudo bluetoothctl

Prepare the bluetooth controller for pairing:

power on
agent on
default-agent
scan on

At this point, we need to pair and connect the board. It is advised to keep the MAC address in the clipboard. If the connection fails, you must delete the pairing and run the sequence faster:

<press red sync button>
pair <MAC address of the discovered balance board>
connect <MAC address of the discovered balance board>

Allow the balance board to connect by itself:

trust <MAC address of the discovered balance board>

Close bluetoothctl:

disconnect <MAC of the wiimote>
scan off
exit

Now start Wii-Scale and test the website:

npm start

Press control-c to quit the program once you have tested it.

Run on boot

The reason we created a 'wiiscale' user is to allow wiiscale to run independently, without being manually started by the user.

sudo cp wiiscale.service /etc/systemd/system/
sudo chown root:root /etc/systemd/system/wiiscale.service
sudo chmod 664 /etc/systemd/system/wiiscale.service
systemctl enable wiiscale
systemctl start wiiscale

.....Aaaaaand that should be that. Except that it's 11pm, I'm writing about 40% of this from memory, and I am a lowly error-prone human. Tell me what doesn't work.

Clone this wiki locally