Home > Arduino, Bluetooth, TKJ Electronics, USB > Wiimote added to USB Host library

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.

Categories: Arduino, Bluetooth, TKJ Electronics, USB Tags:
  1. NicoHood
    April 16th, 2015 at 16:35 | #1

    Great! Have not tested it but thanks for the note. I really have no time for USB-Host sadly.
    Once ive finished with my HID-Project and HoodLoader2 I will present a simple Wiiu to USB adapter as ive done with the Gamecube controller.

    But you could also built this yourself. Seems i’ve never posted my project here:
    https://github.com/NicoHood/HID
    https://github.com/NicoHood/HoodLoader2
    https://nicohood.wordpress.com/2015/02/10/diy-gamecube-to-usb-pc-adapter-with-arduino/

  2. April 16th, 2015 at 17:55 | #2

    @NicoHood
    Okay should be pretty straightforward with your enchanted HID functionality! I will properly use it in the near future to emulate the Wii Balance Board.

  3. July 6th, 2015 at 21:37 | #3

    Hello, I’m french.

    Thank you for work and share.
    I want connect a chinese wiimote (http://fr.eachbuyer.com/remote-and-nunchuk-controller-set-for-nintendo-wii-game-p3452.html) on my arduino UNO.

    i use Wii.ino.
    I put 1 button and 2 button together. Wiimote Blue leds flash.
    I start the arduino.
    In the Serie monitor i have : Wiimote Bluetooth Library Started
    and that’s all.

    I was test with 2 differents wiimote.

    Can you help me?

    My Bluetooth dongle (http://www.banggood.com/Wholesale-Super-Mini-Bluetooth-2_0-Adapter-Dongle-Vista-Compatible-p-29703.html) is connected to USB shield V2 (http://www.banggood.com/USB-Host-Shield-Compatible-Google-Android-ADK-Support-UNO-MEGA-p-90129.html)

    USB_desc.ino result is:
    Device descriptor:
    Descriptor Length: 12
    Descriptor type: 01
    USB version: 0110
    Device class: E0
    Device Subclass: 01
    Device Protocol: 01
    Max.packet size: 10
    Vendor ID: 0A12
    Product ID: 0001
    Revision ID: 0134
    Mfg.string index: 00
    Prod.string index: 00
    Serial number index: 00
    Number of conf.: 01

    Configuration descriptor:
    Total length: 006C
    Num.intf: 02
    Conf.value: 01
    Conf.string: 00
    Attr.: 80
    Max.pwr: 32

    Interface descriptor:
    Intf.number: 00
    Alt.: 00
    Endpoints: 03
    Intf. Class: E0
    Intf. Subclass: 01
    Intf. Protocol: 01
    Intf.string: 00

    Endpoint descriptor:
    Endpoint address: 81
    Attr.: 03
    Max.pkt size: 0010
    Polling interval: 01

    Endpoint descriptor:
    Endpoint address: 82
    Attr.: 02
    Max.pkt size: 0040
    Polling interval: 00

    Endpoint descriptor:
    Endpoint address: 02
    Attr.: 02
    Max.pkt size: 0040
    Polling interval: 00

    Interface descriptor:
    Intf.number: 01
    Alt.: 00
    Endpoints: 02
    Intf. Class: E0
    Intf. Subclass: 01
    Intf. Protocol: 01
    Intf.string: 00

    Endpoint descriptor:
    Endpoint address: 83
    Attr.: 01
    Max.pkt size: 0000
    Polling interval: 01

    Endpoint descriptor:
    Endpoint address: 03
    Attr.: 01
    Max.pkt size: 0000
    Polling interval: 01

    Interface descriptor:
    Intf.number: 01
    Alt.: 01
    Endpoints: 02
    Intf. Class: E0
    Intf. Subclass: 01
    Intf. Protocol: 01
    Intf.string: 00

    Endpoint descriptor:
    Endpoint address: 83
    Attr.: 01
    Max.pkt size: 0009
    Polling interval: 01

    Endpoint descriptor:
    Endpoint address: 03
    Attr.: 01
    Max.pkt size: 0009
    Polling interval: 01

    Interface descriptor:
    Intf.number: 01
    Alt.: 02
    Endpoints: 02
    Intf. Class: E0
    Intf. Subclass: 01
    Intf. Protocol: 01
    Intf.string: 00

    Endpoint descriptor:
    Endpoint address: 83
    Attr.: 01
    Max.pkt size: 0011
    Polling interval: 01

    Endpoint descriptor:
    Endpoint address: 03
    Attr.: 01
    Max.pkt size: 0011
    Polling interval: 01

    Addr:1(0.0.1)

  4. July 6th, 2015 at 21:40 | #4
  5. Nickhil
    July 11th, 2015 at 08:54 | #5

    I have been trying for a while now but I’m not able to connect the wiimote to the arduino. I am using the example code, my usb dongle works (tried with a playstation controller and is the recommended one), my reset pin and pin 7 are connected and I do have external power (sparkfun shield). I am using the newest version of the library on github. It wont work for some reason though. I’ve tried both using the pair button and pressing both the 1 and 2 buttons simultaneously. A little confused here.
    -Nick

  6. July 11th, 2015 at 11:03 | #6

    @Nickhil
    Please enable serial debugging: https://github.com/felis/USB_Host_Shield_2.0#enable-debugging and post the output.

  7. Mike
    July 17th, 2015 at 17:11 | #7

    Hi, thanks for your work. I’m having trouble pairing my wiimote to the arduino, I’ve set ENABLE_UHS_DEBUGGING 1 but all I see in the serial monitor is “Wiimote Bluetooth Library Started” and nothing else. My setup is Arduino UNO + Arduino usb host shield + the recommended bt dongles (I have 2) + stock wiimote. I also have a Arduino MEGA to test with. I’ve tested the mouse example and it is working fine, but I can’t get my wiimote to work (or pair at all). Is there something else I gotta setup than just plugging the shield and dongle in and loading the sample program? Thanks a lot

  8. July 18th, 2015 at 21:36 | #8

    @Mike
    Please uncomment this line: https://github.com/felis/USB_Host_Shield_2.0/blob/master/BTD.cpp#L20 and post the output.

  9. AndyW
    August 24th, 2015 at 20:48 | #9

    Hi Kristian,

    I’m hoping you can help me with a problem I’ve got attempting to connect to a Wii Balance Board.

    I’m using an Arduino Uno with a USB Host Shield and a BT dongle.

    The Arduino refuses to connect to the board when I press the sync button and produces the following debug:-

    Wii Balance Board Bluetooth Library Started
    BTD ConfigureDevice
    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: 82
    Attributes: 02
    MaxPktSize: 0040
    Poll Intrv: 00
    Endpoint descriptor:
    Length: 07
    Type: 05
    Address: 02
    Attributes: 02
    MaxPktSize: 0040
    Poll Intrv: 00
    Bluetooth Dongle Initialized
    HCI Reset complete
    Write class of device
    Local Bluetooth Address: 00:15:83:0C:BF:EB
    Starting inquiry
    Press 1 & 2 on the Wiimote
    Or press the SYNC button if you are using a Wii U Pro Controller or a Wii Balance Board
    Number of responses: 1
    Class of device: 00 25 04
    BT Addr: A375B0F32400

    Wiimote found
    Now just create the instance like so:
    WII Wii(&Btd);
    And then press any button on the Wiimote
    Check remote name
    Remote Name: Nintendo RVL-WBC-01
    Wiimote is connecting -- Wii Balance Board
    Setting state to HCI_CONNECT_DEVICE_STATE
    Connecting to Wiimote
    HCI Command Failed: 0B
    HCI Command Failed: 0B
    HCI Command Failed: 0B
    HCI Command Failed: 0B
    HCI Command Failed: 0B
    HCI Command Failed: 0B
    HCI Command Failed: 0B
    HCI Command Failed: 0B
    HCI Command Failed: 0B
    HCI Command Failed: 0B
    HCI Command Failed: 0B
    HCI Command Failed: 0B
    HCI Command Failed: 0B

    Can you help me out here with the connection error ?

    Thanks,

    Andy.

  10. AndyW
    August 24th, 2015 at 20:49 | #10

    @AndyW

    (I’ve added some of my own debug lines too just in case some of the output isn’t what you’re expecting)

  11. August 24th, 2015 at 22:09 | #11

    @AndyW
    Please see: https://github.com/felis/USB_Host_Shield_2.0/issues/169. Unfortunately you will just have to try another dongle.

  12. AndyW
    August 25th, 2015 at 08:35 | #12

    @Kristian Sloth Lauszus

    Thanks for the quick reply!

    I’ve tried a couple of dongles, I guess I’ll have to try and source one from the list.

    One thing which I was confused about though. It looks like the hci_connect() call which results in the failure state is passing a PIN value based upon the MAC address of the Wii Board. Looking at the Wiimote Wiki it mentions that if the sync button is pressed then the connect/pair attempt should be based upon the MAC address of the host.

    “If connecting by holding down the 1+2 buttons, the PIN is the bluetooth address of the wiimote backwards, if connecting by pressing the “sync” button on the back of the wiimote, then the PIN is the bluetooth address of the host backwards.” *

    Is the Wii board different in this regard or have I just got the wrong end of the stick (I’m not a Bluetooth protocol guru by any means).

    Thanks,

    Andy.

    * http://wiibrew.org/wiki/Wiimote#Bluetooth_Pairing

  13. August 25th, 2015 at 13:47 | #13
  14. AndyW
    August 31st, 2015 at 16:03 | #14

    @Kristian Sloth Lauszus

    I can report back that the Trendnet TBW-107UB dongle (as listed on the compatible dongle list) does indeed work :)

    Local Bluetooth Address: 00:15:83:D0:FF:9E
    Wait For Incoming Connection Request
    Class of device: 00 25 04
    Incoming Connection Request
    Remote Name: Nintendo RVL-WBC-01
    Wiimote is connecting -- Wii Balance Board
    Connection Established:

    Connected to Device: 00:24:F3:B0:75:A3
    HID Control Incoming Connection Request
    HID Control Successfully Configured
    HID Interrupt Incoming Connection Request
    HID Channels Established
    Checking if a Motion Plus is connected
    Extension connected
    No Motion Plus was detected
    Checking if there is any extension connected
    Wii Balance Board connected
    Wait For Incoming Connection Request
    Reading Wii Balance Board calibration values
    Wii Balance Board calibration values read successfully
    Weight: 0.00 0.00 0.00 0.00 Total Weight: 0.00
    Weight: 0.00 0.00 0.00 0.00 Total Weight: 0.00
    Weight: 0.00 0.00 0.00 0.00 Total Weight: 0.00
    Weight: 0.00 0.00 0.00 0.00 Total Weight: 0.00
    Weight: 0.00 0.00 0.00 0.00 Total Weight: 0.00
    Weight: 0.00 0.00 0.00 0.00 Total Weight: 0.00
    Weight: 0.00 0.00 0.00 0.00 Total Weight: 0.00
    Weight: 0.00 0.00 0.00 0.00 Total Weight: 0.00
    Weight: 0.00 0.00 0.00 0.00 Total Weight: 0.00
    Weight: 0.00 0.00 0.00 0.00 Total Weight: 0.00
    Weight: 0.00 0.00 0.00 0.00 Total Weight: 0.00
    Weight: 0.25 0.22 1.76 2.00 Total Weight: 4.23
    Weight: 0.40 0.31 2.19 2.47 Total Weight: 5.36
    Weight: 0.40 0.31 2.19 2.47 Total Weight: 5.36
    Weight: 0.40 0.31 2.19 2.47 Total Weight: 5.36
    Weight: 0.40 0.31 2.19 2.47 Total Weight: 5.36
    Weight: 0.55 0.42 2.62 2.83 Total Weight: 6.42
    Weight: 0.55 0.42 2.62 2.83 Total Weight: 6.42
    Weight: 0.73 0.59 2.96 3.16 Total Weight: 7.45
    Weight: 0.73 0.59 2.96 3.16 Total Weight: 7.45
    Weight: 0.73 0.59 2.96 3.16 Total Weight: 7.45

    w00t!

  15. August 31st, 2015 at 16:15 | #15

    @AndyW
    Awesome :)

Comment pages
1 2 3384
  1. No trackbacks yet.