Skip to content

Part 2. Reading the Scale

jrbail01 edited this page May 30, 2015 · 11 revisions

It is time to connect our Wii Balance Board to our Raspberry Pi. We will do this by modifying a version of Stavros Korokithakis' Gr8W8Upd8M8.py script (https://github.com/skorokithakis/gr8w8upd8m8). The python script we will be using is located at https://github.com/InitialState/beerfridge/blob/master/wiiboard_test.py. You can copy the contents of this file to a file you create on your Raspberry Pi or you can clone all of the python files we will be using for this entire project. Let's do the latter. Type the following commands into a terminal on your Raspberry Pi:

$ cd ~
$ git clone https://github.com/InitialState/beerfridge.git beerfridge
Cloning into 'beerfridge'...
remote: Counting objects: 9, done.
remote: Compressing objects: 100% (7/7), done.
remote: Total 9 (delta 1), reused 6 (delta 1), pack-reused 0
Unpacking objects: 100% (9/9), done.
Checking connectivity... done.

You should see four python files in the new beerfridge directory - beerfridge.py, switch_test.py, temperature_test.py, and wiiboard_test.py.

$ cd beerfidge
$ ls
README.md		beerfridge.py		switch_test.py		temperature_test.py	wiiboard_test.py

Run the wiiboard_test.py script to test communication and take weight readings from the Wii Balance Board:

$ sudo python wiiboard_test.py

You will see the following response:

Discovering board...
Press the red sync button on the board now

Remove the battery cover underneath the Board to locate the red sync button. Make sure you press the button within a few seconds of running the script or a timeout will occur. Once successful, you will see something similar to the following:

Found Wiiboard at address 00:23:CC:2E:E1:44
Trying to connect...
Connected to Wiiboard at address 00:23:CC:2E:E1:44
Wiiboard connected
ACK to data write received
84.9185297 lbs
84.8826412 lbs
84.9275927 lbs

To stop the script, press CTRL+C. The script is taking the number of weight measurements specified on line 10 and outputting the average. You can play with this number to see the variation in measurement and time required for each measurement.

# --------- User Settings ---------
WEIGHT_SAMPLES = 500
# ---------------------------------

You have now successfully converted your Wii Balance Board into a Raspberry Pi connected scale. Let's get it ready to start taking measurements of our refrigerator.

<< Part 2: Bluetooth Setup - Part 2: Hardware Tweaks >>