Wherein my weight is broadcast live to the good people of the internet.

A few days ago, I looked under the couch and found my dusty, disused Wii Balance Board. I bought it years ago, when I was a bit chubbier and thought Wii Fit might help me lose some weight and become fitter. It worked very very well, although I think it was mostly because I didn’t want to eat junk any more, as that would mean that the mind-numbingly boring hour of exercise I just did would be for naught.

For those of you who don’t know what a Wii Balance Board is, it’s the bastard offspring of a bathroom scale and a step pad. It connects to the Wii via Bluetooth, and it can weigh you and also tell which way you are leaning.

Seeing the board, I thought it would be fun to connect it to the computer and try to read the weight values from a script. I started by trying to pair it with the computer, and, after searching online for a bit, I eventually discovered that, for permanent pairing, one must needs use the PIN “000000”. Using that, the board was permanently paired with my computer, and I would no longer need to turn it over, remove the battery cover, press the red “sync” button, replace the cover, flip it over, and then (finally) use it, every single time.

A cartoon of a guy on various weird poses on a Wii Balance BoardLook ridiculous in many different ways!

Searching around, I found various packages that allow you to use the Wiiboard with Python without having to mess with the protocol, such as cwiid (which Matt Cutts used in his hackery of his board), but in the end I went with wiiboard-simple, because it’s one simple and straightforward Python class.

With wiiboard-simple, I could read the weight values from the board, but it is a bit heavy. It requires threading and pygame for events for something which is pretty much one simple loop, so I gutted it and removed all those depencencies in favor of a processor class that gets called whenever an event is generated. That’s a much cleaner design, in my opinion, although it’s still pretty hacky.

I called my script Gr8W8Upd8M8, and you can find it on GitHub here:

https://github.com/skorokithakis/gr8w8upd8m8

It’s pretty much the same as wiiboard-simple, but has two crucial differences:

  • It doesn’t require threading or pygame, so it’s much lighter.
  • It uses bluez-tools to disconnect the board after a measurement, which doesn’t otherwise happen on my system (the board would just stay on for ever).

Problems

Unfortunately, I ran into two problems: First, and least importantly, the problem I mentioned above: The board wouldn’t disconnect after the Bluetooth connection was closed (this is Ubuntu, your mileage may vary), and would just stay on for ever. I couldn’t find a way to do this from Python, so I just shelled out to bt-device to disconnect the device, which worked beautifully.

The second problem was that automatic pairing doesn’t really work. It does connect to my laptop automatically, but I have to disconnect it from the Ubuntu Bluetooth device manager, which is a major inconvenience, as it means that I can’t just step on the scale and take a measurement. I will solve this later. I have solved this, see edit at the bottom of the page.

Complete solution

In the end, after pairing and using the script, I had something that will (almost) automatically connect to the board as soon as it’s turned on, wait for me to step on it, read the weight (I use a histogram and just read the most frequent value reported by the scale for this, as it reports a few values per second), and shut off when I get off the scale.

However, at that point, I needed to actually do something with the data. I figured that a good thing to do with it would be to log it somewhere and maybe graph it, but where? I could write a small Python script to output a graph, but where’s the fun in that? A few minutes later, I had written a simple way to send the data to this very site you are reading, and plot it using Google Charts (which is pretty nifty).

So, here it is: A live feed of my weight that automatically updates whenever I step onto my Wii Balance board. I didn’t care enough to make it private, because I figure that, for one, nobody will be interested in it, and two, it probably can’t be used against me, unless someone wants to tackle me.

Epilogue

So, that’s what this weekend was about. If you have any cool Balance Board hacks or ideas, please let me know, as I am very interested. Stay tuned for next week’s post, where I get a Leap Motion (it’s in the mail). Hopefully it won’t suck and I’ll be able to make something cool with it!

2019-01-17 update: I did some more research and discovered that Ubuntu connects fine to the board and turns it into an HCI device, but I didn’t manage to figure out how to actually talk to it afterwards. I spent a bunch of time on this, but apparently you need to do some DBus magic to talk to the device. If someone knows how you can talk to Bluetooth HCI devices over DBus, please let me know, as I think it will be easy to get the board working after that.

2015 update: HUGER EDIT BEFORE THE HUGE EDIT BELOW: The steps below are obsolete, just run the xwiibind.sh script that’s in the repo, and the board will pair automatically.

2013 update: HUGE EDIT: I have finally managed to get the Wii Board to successfully (and permanently) pair with my Ubuntu computer. Here are the steps:

  • sudo apt-get install build-essential libdbus-1-dev check checkinstall to install the dependencies.
  • apt-get source bluez to get the source.
  • Apply this patch to actually get it to recognize hex pin codes.
  • ./configure --enable-test, make
  • sudo checkinstall to create a .deb you can remove after pairing.
  • Restart your computer/bluetooth services/etc.
  • ./test/simple-agent hciX ##:##:##:##:##:##, you need to change hciX to whatever your Bluetooth adapter is (usually hci0, find it with hcitool dev). The hashes are the Balance Board’s Bluetooth address.
  • Your pin is now $FFEEDDCCBBAA, where AA:BB:CC:DD:EE:FF is your Bluetooth adapter’s bluetooth address. Just reverse the order of the octets, so 01:23:45:67:89:AB becomes $ab8967452310.
  • Your balance board will pair, and you have to immediately connect to it with python gr8w8upd8m8.py ##:##:##:##:##:##, or it might not pair.
  • If you missed the connecting step above, run ./test/simple-agent hciX ##:##:##:##:##:## remove and try again.
  • To trust the device so it will connect in the future, run bt-device --set ##:##:##:##:##:## Trusted 1

Hopefully that will work for you, let me know in the comments!