Wiimote added to USB Host library
This is yet again a new announcement regarding the USB Host library. I just added support for the Wiimote via Bluetooth.
Check out the source code at github: https://github.com/felis/USB_Host_Shield_2.0/blob/master/Wii.cpp and the example sketch as well.
I will work on implementing support for the Nunchuck and Wii Motion Plus extension in the near future.
Update:
The library now also supports the Nunchuck controller and the Motion Plus extensions. The newest version of the library can be found at github.
Another Update:
The library now also work with the new Wiimote where the Motion Plus extension is built-in.
Check out my commit to see what where needed in order to make the new Wiimote work as well – the main difference is that you now have to send the data using the interrupt channel.
To tell if your Wiimote is the new type, it should have a label at the bottom saying “Wii MotionPlus INSIDE”. If you are in doubt take a look at this picture.
Yet another update:
The IR camera inside the Wiimote is now also supported. The the following commit for more information.
A new update once again:
The Wii U Pro Controller is now also supported via Bluetooth.


Good job, was annoyed over it working nicely in the past with pre 1.0 Arduino IDE and the author didn’t update for post 1.0, anyway I tried the example and I get this:
Wiimote Bluetooth Library Started
Bluetooth Dongle Initialized
No response to HCI Reset
HCI Reset complete
Local Bluetooth Address: 00:02:5B:46:86:DC
Connecting to Wiimote
Connected to Wiimote
Send HID Control Connection Request
And it sits there for ages, the wiimote and dongle both blink for a while and then go dark but nothing happens beyond that, am I doing something wrong? I assumed that at some point it would reach a state where it reported back what I’m pushing etc.
@Christian Gerefalk
Try to create the instance like so: https://github.com/felis/USB_Host_Shield_2.0/blob/master/examples/Bluetooth/Wiimote/Wiimote.ino#L11 so it does a inquiry. If that doesn’t work then try to uncomment EXTRADEBUG (https://github.com/felis/USB_Host_Shield_2.0/blob/master/Wii.cpp#L20) and send me the output.
Also try to use a different dongle
I got two dongles one tiny that isn’t much larger than the USB port itself, and an old big box on a lead, both give the same result:
”
Wiimote Bluetooth Library Started
Bluetooth Dongle Initialized
No response to HCI Reset
HCI Reset complete
Local Bluetooth Address: 00:08:F4:00:6D:ED
Starting inquiry
Press 1 & 2 on the Wiimote
Wiimote found
Create the instance like so to connect automatically:
WII Wii(&Btd,0x00,0x18,0x00,0xF0,0x1D,0x18);
Connecting to Wiimote
Connected to Wiimote
Send HID Control Connection Request
”
If it matters my wiimote is a chinese copy, it works with an actual Wii and Wii emulators/gamepad utilities (glovepie etc).
I uncommented that line, should the output have been in the serial monitor? I only get what I pasted above.
@Christian Gerefalk
Hmm, it looks like it doesn’t respond to the connection request. Did it work with the old library?
Try to add something like this:
After this line: https://github.com/felis/USB_Host_Shield_2.0/blob/master/Wii.cpp#L80
Sorry you should also uncomment this line: https://github.com/felis/USB_Host_Shield_2.0/blob/master/BTD.cpp#L20
So it will print more debugging.
I never got the old library to work at all since I got a 2.0 shield and 1.0.1 IDE
Small stick:
”
Wiimote Bluetooth Library Started
BTD Init
Addr: 01
Endpoint descriptor:
Length: 07
Type: 05
Address: 81
Attributes: 03
MaxPktSize: 0010
Poll Intrv: 01
Endpoint descriptor:
Length: 07
Type: 05
Address: 02
Attributes: 02
MaxPktSize: 0040
Poll Intrv: 01
Endpoint descriptor:
Length: 07
Type: 05
Address: 82
Attributes: 02
MaxPktSize: 0040
Poll Intrv: 01
Bluetooth Dongle Initialized
No response to HCI Reset
HCI Reset complete
Local Bluetooth Address: 00:02:5B:46:86:DC
Starting inquiry
Press 1 & 2 on the Wiimote
Number of responses: 1
Wiimote found
Create the instance like so to connect automatically:
WII Wii(&Btd,0x00,0x18,0x00,0xF0,0x1D,0x18);
Connecting to Wiimote
Connected to Wiimote
Send HID Control Connection Request”
Both the wiimote and LED on the stick flash for a while after reaching there.
Large dongle:
“Wiimote Bluetooth Library Started
BTD Init
Addr: 01
Endpoint descriptor:
Length: 07
Type: 05
Address: 81
Attributes: 03
MaxPktSize: 0010
Poll Intrv: 01
Endpoint descriptor:
Length: 07
Type: 05
Address: 02
Attributes: 02
MaxPktSize: 0040
Poll Intrv: 01
Endpoint descriptor:
Length: 07
Type: 05
Address: 82
Attributes: 02
MaxPktSize: 0040
Poll Intrv: 01
Bluetooth Dongle Initialized
No response to HCI Reset
HCI Reset complete
Local Bluetooth Address: 00:08:F4:00:6D:ED
Starting inquiry
Press 1 & 2 on the Wiimote
Number of responses: 1
Wiimote found
Create the instance like so to connect automatically:
WII Wii(&Btd,0x00,0x18,0x00,0xF0,0x1D,0x18);
Connecting to Wiimote
Connected to Wiimote
Send HID Control Connection Request”
Bah can’t edit.
I did add that line btw here is my Wii.ccp in full: http://pastebin.com/hEzK1M3C and BTD.ccp in full: http://pastebin.com/XRngCHCH
Copied yours from the links you gave but that gave me “AnalogHat not defined in this scope” errors, so these are based on the ones I downloaded from github
Just updated the library and tried again with the same results, I do get warnings when compiling both the new and old version of the library btw, mostly:
“C:\Program Files (x86)\arduino-1.0.1\libraries\USB_Host_Shield_2\RFCOMM.cpp:1233: warning: only initialized variables can be placed into program memory area” a ton of those on that file and confdescparser.h etc, full log here: http://pastebin.com/xpk97ArE
@Christian Gerefalk
It sounds like you have added the library incorrectly if you are getting compiler errors. See this page for more information: http://www.arduino.cc/en/Hacking/Libraries
Make sure that you can select the example sketch in File>Examples>”folder name”>Bluetooth>Wii. Don’t try to copy and paste the code from github.
I did add it as I’ve done with all others I have working, I can open the example in the IDE, I got warnings etc turned on which isn’t the default setting in the IDE, it warns me about those, it doesn’t error out and stop.
@Christian Gerefalk
What hardware are you using?
I will try the same to reflect your setup.
Recent uno and and older mega1280, bluetooth dongles: http://dx.com/p/world-s-smallest-bluetooth-2-0-edr-usb-dongle-12696?item=20 something like that, exact same “design” anyway, and a credit card sized 1cm thick ancient dongle on a lead, controller: http://dx.com/remote-and-nunchuck-controller-for-wii-blue-37855?item=6 not loading for me here atm but it’s the third on this search: http://dx.com/s/Remote+and+nunchuck+controller+for+wii+blue ($13.90 one) as said before I’ve tried both dongles and the remote on my PC (dolphin, GlovePIE) and the remote with a real wii, works fine.
@Christian Gerefalk
Your comment was caught in our spam filter, so I haven’t seen it until now.
Okay, I still think that you are including the libraries wrong, I have several people who has confirmed that the library works great and they don’t get any errors at all.
@Christian Gerefalk
I thought a bit more about the problems you are having. Do you by any change got other version of the USB library inside the library folder? If so then remove them from there.
Hi,
Thanks for your job first, and I got the following error message, when I pluged in a nunchuck:
Extension connected
Checking extension port
Unknown Device: 00FA
Data: FF 00 A4 20 00 00
or a classic controller pro:
Extension connected
Checking extension port
Unknown Device: 00FA
Data: 01 00 A4 20 01 01
what is wrong with this?
@Fisher Wei
It seems like you Nunchuck is not returning the correct signature. The right one should be 00 00 A4 20 00 00. See: https://github.com/felis/USB_Host_Shield_2.0/blob/master/Wii.cpp#L230 and http://wiibrew.org/wiki/Wiimote/Extension_Controllers.
Is it a third party Nunchuck? It’s pretty easy to fix. Just remove “l2capinbuf[15] == 0x00 &&” from the code at the line I just sent you.
The library doesn’t support the Classic controller as I haven’t got my hands on one yet.
@Lauszus
Hi, I think my nunchuck is not 3rd party, and if I plug nunchuck in before powering arduino on, it will work fine. If power on and pair at first, it will report error message. I don’t know why.
@Fisher Wei
Okay. Sounds weird. I can plug the Nunchuck in and out of the Wiimote without any problems. Try to remove the line I told you in the earlier reply and tell me if it works then. If so I will add it to the library.
@Lauszus
Yes, it works. I removed “l2capinbuf[15] == 0×00 &&”.
And then, I have a new issue: I pluged motion plus in, arduino has not any responses, no “Unknown Device”, no “Motion Plus connected”. If I plugin before powering on, it also works.
@Fisher Wei
That is normal. You have to plug in the motion plus before powerup.
Is there any plans to support the IR camera?
@Michael Motes
No not currently
Very nice!
However, when I wanted to run the latest Wii example from git I had to comment out some DEBUG macros within the library code in order to produce a sketch that could fit on my Uno… The sketch is still around 26 kB and I was wondering if there is more debug code that takes up lots of space?
@Rick
All the debug messages can be disabled by comment out these line: https://github.com/felis/USB_Host_Shield_2.0/blob/master/BTD.cpp#L19 and https://github.com/felis/USB_Host_Shield_2.0/blob/master/Wii.cpp#L19, but I guess you have already done that?
Yup…and that left me with a binary size of roughly 26 kB (Wii example). Is this ‘normal’? Kinda limits the possibilities when using the Uno with this library. But I guess that may be a problem of the complexity of USB…
@Rick
Yes that is normal. But you have to know that the example sketch actually takes up a lot of flash as it got so many strings.
Yes I’m afraid too, but take a look at the atmega644 (aka Sanguino: http://sanguino.cc/) at my github repository: https://github.com/Lauszus/sanguino it got the double amount of flash than the Uno and it’s also available in a DIP package.