Feb 122013
 

Matt Hawkins from Raspberry Pi Spy has done the leg-work enabling Pi users to use a Wii controller – along with a Bluetooth USB dongle to send inputs to the Raspberry Pi. It uses a Python library called “CWiid” (I imagine this is pronounced “seaweed”).

This is awesome because the Wii controller has 11 different digital inputs. When you consider combinations of inputs, that gives you a lot of extra possible “input commands” to play with.

Theoretically*, with 11 buttons, there are 55 different 2-button combinations (11C2). That should be enough for most uses. If you need more than that, you could use 3-button combos. :)

Here’s a little video of some Wiimote controlled Gertboard madness

How do you do it then?

I followed the installation instructions on Matt’s site…
http://www.raspberrypi-spy.co.uk/2013/02/nintendo-wii-remote-python-and-the-raspberry-pi/

And, happily, they worked first time with my Tesco’s own-brand Technika nano Bluetooth dongle, which has a Pi-compatible chipset. I bought mine in Tesco Extra for about £4.

This is what to look out for in Tesco

So I think we can look forward to seeing a proliferation of Wii remote controlled Raspberry Pi programs in the near future.

What will you do with yours?

Matt’s going to control an RC car with his. After my initial Gertboard experiments, I’d like to see if it’s possible to use two controllers for an interactive Quiz.
What will you do with yours?

________________________________
* In practice, the direction controller slightly restricts the number of choices, e.g. you can’t have opposites pressed simultaneously, but we’ll ignore that.

  37 Responses to “Using a Wii controller with your Raspberry Pi, Gertboard, Bluetooth and Python”

  1. Well… that had me giggling like a maniac :-) Very cool experiments :-) And all of it run off battery, too!

    • Well it’s all a part of my plan to take over the world. Mwahahahahaha :rotfl:
      It could be run off just one of those lipo batteries, but I’d need to make an adaptor and don’t have enough Deans connectors. But since I have four of the lipos…

  2. Well that’s decided the input method for my next project then! :-) Great demo! I’m interested to know whether it’s possible to read the accelerometer values? There’d be some great potential projects if that’s possible.

  3. […] Using a Wii controller with your Raspberry Pi, Gertboard, Bluetooth and Python: Matt Hawkins from Raspberry Pi Spy has done the leg-work enabling Pi users to use a Wii controller – along with a Bluetooth USB dongle to send inputs to the Raspberry Pi. It uses a Python library called “CWiid” (I imagine this is pronounced “seaweed”). […]

  4. I have been struggling for a long while to get my PI to detect my logitech wingman joystick in order to control a robotic arm. ( it works with a borrowed joystick of a different make).

    so I have purchased the same Bluetooth dongle but bit a problem with the HCITOOL SCAN command in the blog. Nothing works after that.

    I will get it cracked, like your demo, I will have to add a gertboard to my shopping list!

  5. Where did you get the switching power unit that supplies power to the Pi?

    • That’s an ebay job – very cheap, but very good. I’ve got lots of them. Search on “DC-DC StepDown Adjustable Power Supply Module LM2596”. I bought the bare board with reg on and added two USB ports, wires and heatshrink. Quite good because you can tweak the output voltage.

  6. can this be done with an Xbox remote as well?

    • Good question. I don’t know. Does it run on Bluetooth? Has someone written a Python library for it? If so, YES. It would be very interesting to find out.

  7. Bought the Tesco Bluetooth dongle, and downloaded and installed all relevant software, but I am afraid I have had a total lack of success with either of my Wii remotes. Thought it may be due my mouse/keyboard and WiFi dongles, so eliminated them and switched to wired Ethernet/USB attachments, but this did not make any difference. The Wii remotes are never detected by the hcitool scan or the python program supplied. The hcitool did locate my panasonic viera television downstairs though!. Also my keyboard entry started to play up in ways I have seen described elsewhere (arbitrary keys being entered eg aaaaaaaaa etc) I dont know if there is a connection. Any ideas of how to recover of have I just wasted a fiver at Tescos?

    • Well whatever you apt-get install, you can also apt-get uninstall.

      I would flash a brand new install of Raspbian on an SD card and follow Matt’s instructions to the letter. So many people have got this working that something must be wrong. The only way you can be sure it’s not your existing setup is to start with a fresh Raspbian install.

      It is also possible that your dongle is faulty, I suppose. Tesco has a 1 year guarantee, so you can always take it back. But I’d rather you got it working. :)

      • Hi Alex, Thanks for the advice. I did have a (very) brief moment of success! but mostly I get the message “Device is not available: No such device” response from hcitool.
        To give further background. I was given the Maplin Pi package at Christmas (Pi,USB Keyboard/Mouse, WiFi dongle, 1amp power supply,and a separately powered USB extension, as well as a 4gb Raspbian SD card), I think this is a good value package for starters. I began by using the separate USB extension, which had the WiFi dongle and a remote keyboard/mouse dongle inserted as well as the Bluetooth one. Since I was lacking success, I removed the two other dongles (Wifi,mouse/keyboard), and switched to direct USB mouse/keyboard and wired ethernet, presuming some interference maybe – no improvement, although I did get my downstairs Panasonic TV turning up at one stage! I do have several SD cards with Raspbian installed, so I did follow your advice to try a fresh install of the Wii/Bluetooth software on a different base. I still got the “device is not available” message until!……I moved the Bluetooth dongle off the separate USB extension, and plugged it directly into the Raspbery Pi spare USB slot. Then the hcitool started its scan and did pick up on the Wii remote! I then started up the Python program and it also recognised the Wii remote. I was able to get it to respond correctly to the various Wii remote button presses with the proviso that it never a gave a single keypress response, usually 2 or 3 repetitions. That was the only time I had success. Now after a reboot, I am back with the “Device is not available: no such device” response,

        ps Love your YouTube vids, keep them up

        • I wonder if your dongle is intermittently faulty? I suppose that could be checked on a Windows machine by installing the software that came on the disk and seeing if you can connect to a phone or other BT device. It couldn’t hurt to exchange it at Tescos, but if it doesn’t solve the problem, you’re back at square 1. I’d still recommend an absolutely virgin install of Raspbian and direct connection to the Pi. I don’t even own a USB hub, so I never plug any USB devices in any other way than directly. :)

          • Hi Alex again, I did check my bluetooth dongle on my Windows system and there were no problems apart from snooty messages from Windows 7 about
            its software not being uptodate in its terms. I have now had some more success with the dongle attached to the pi rather than the USB hub, and in fact have returned to using my wireless mouse/keyboard without problems. I did increase the the button_delay to 0.3 secs to avoid multiple keypress problems. It is very strange how some Linux problems seem to self-cure themselves in time; I have never known that sort of behavior in Windows. Also the “stuck keyboard” phenomena as gone away for the moment. That can be immensely frustrating when it occurs; I had at least 25 LXTerminal windows opening themselves in succession because of “stuck” key symptom until I switched power off. Having spent most of a lifetime fighting software and/or system bugs nothing surprises me in this business. Thanks for your advice and interest.

            • 0.3 is exactly what I changed it to as well. :) It seemed like the best compromise.

              When I get stuck keyboard issues with my wireless kbd/mouse dongle, I swap out for a different keyboard. It doesn’t happen very often since I don’t use the GUI much and usually log in headless.

  8. The Youtube video isn’t working! :weep:

    • Thanks. Not working for me either, but my other vids are. I suggest trying again later like it says. Hopefully it’s a technical glitch. That’s my second most popular video, so hope it’s not knackered. :(

      It works fine for me on my Nexus 7 in chrome or the Youtube App, but not on my Win7 PC with Firefox. No idea what the issue is. Hope it goes away soon. ;)

  9. […] Mike Brojak from DesignSpark, whose voice you can hear in the video, asked me to put together a Wii controller flag-waving demo (plus other bits) on their new PiGo board. You may remember catching a glimpse of it in the flag […]

  10. […] They’ve also recently had a go with the Wii controller Gertboard “Whackadoodle” demo. […]

  11. The second dongle pictured at the bottom is a wifi dongle, right? Not another Bluetooth one?

  12. Possibly a silly question, but wonder if you could give a steer on how you connected up the relay to the Gertboard?

    I have got a solenoid / relay circuit working (with a power supply for the solenoid) – however, I am getting a bit stuck on the connections to the Gertboard.

    This is all part of a master plan to use a Wii-mote as the controller for a water droplet photo setup!

    Any help would be great. BTW have tried the instructions for the bluetooth set-up and it works great!

    Thanks!

  13. Hi Alex, I saw the original article on Raspberry Pi Spy and want to use the Wii controller to control my robot. I have the sample code working fine, however since I have only recently started using Python I am using Python3, CWiid does not seem to work in Python3, I get an import error “No module named cwiid”

    Do you have any idea if cwiid can be used with Python3?

    • Can’t find any references to it. I learnt Python 2 because I started in 2012 when a lot of stuff wasn’t available for python 3, and the recommended book I bought for my son and me was 2. It’s what all the cool kids used back then. I can see that I’ll need to make the transition at some point, but for the vast majority of stuff I do, 2.7 is still fine.

  14. Hi Alex, I just watched a youtube video of your radio controlled car at the April 2013 Oxford Raspberry Jam and noticed you were controlling the car wittha nunchuck. I am successfully using a wiimote with cwiid but I don’t know how to get the nunchuck to work. Could you please point me in the right direction ?

Leave a Reply to Michael Horne Cancel reply