Controlling an i-racer RC car using a Wii Balance Board and @Raspberry_Pi

#“Controlling an i-racer RC car using a Wii Balance Board and @Raspberry_Pi”

I love watching ideas bounce back and forward between people on Twitter and see them grow. The best for me recently started when The Verge posted a story about an OpenSource Android App which basically turned a Wii Balance Board into a Withings weighing scales, including RunKeeper and Fitbit integration. I retweeted it and it was picked up by Joe Desbonnet. He realised you could also do some interesting things with the Balance Board and a Raspberry Pi and started hacking. Which of course made me realise I could control the i-racer with it!

Here’s a wee video of it in action:

https://www.youtube.com/watch?v=8cdn_LFKQXI

Apologies for the mobile interference in the audio. I was using my new SGS4 to SSH to the Raspberry Pi to kick off the Python code. The ConnectBot guys really need to fix the microscopic font on screens like the SGS4!

The car isn’t very fast in the video as the Lego added a lot of weight and I hardcoded the speed to 50%. We’ll try again next weekend using a lighter shell, full speed and tarmac instead of cobblelock.

Technical Nitty Gritty (not too Gritty!)

My initial experiments with the Balance Board did not go well. Eventually I discovered that the version of the cwiid Wii library that is available on Raspberry Pi (and Ubuntu etc) is not able to deal with the Balance Board. See this bug. I applied the patch and re-built my own deb files. To use them, just unzip them on the raspberry pi and install like so:

wget https://github.com/conoro/iracer-controllers/raw/master/iracer_balance_board/cwiid_for_balance_board.zip
unzip cwiid_for_balance_board.zip
sudo dpkg -i *.deb

The rest of the time was just spent tweaking the numbers so that I could interpret someone leaning in various directions irrespective of their weight. It’s still not great but works for me, a 7yo and a 6yo.

All the old i-racer Bluetooth code carried over unchanged from our Cheese Controlled Car. Follow the instructions there for installing various Bluetooth bits and bobs on the Raspberry Pi.

I was very surprised that I could talk to both the i-racer and the Balance Board over the same $2 Bluetooth adapter. I was sure I’d end up having to use two adapters.

You can, as ever, grab the code from Github. The only changes you need to make in the code are to set the Bluetooth MAC addresses of both the Balance Board and the i-racer.

Sidenote: The Android App was a dead end. It doesn’t work on Android 4.2 because Google decided to upgrade their broken Bluetooth stack and actually managed to make it worse.

Any questions, leave a comment.

Only if you really need it: Building those cwiid libraries yourself


sudo nano /etc/apt/sources.list

Add the following line:


deb-src http://archive.raspbian.org/raspbian wheezy main contrib non-free rpi

Then do the following:


mkdir ~/build
cd build
apt-get source python-cwiid
apt-get build-dep python-cwiid
cd cwiid-0.6.00+svn201/

Then edit these three files and add the changes from https://launchpadlibrarian.net/115501163/balanceboard.patch (or run “patch” if you are familiar with that)


nano libcwiid/cwiid_internal.h
nano libcwiid/process.c
nano libcwiid/thread.c
dpkg-source --commit
dpkg-buildpackage -us -uc
cd ..
sudo apt-get remove python-cwiid
sudo dpkg -i *.deb

Conor O'Neill

Tech guy who likes running slowly

Bandon, Cork, Ireland https://conoroneill.net