Using a USB host shield and a Bluetooth dongle to get data from a PS3 controller – Success!

As mentioned in a previous post, I’m interested in using a PS3 controller as the remote for future projects/robots. Having received all of the required hardware, I decided to make this video explaining the process of setting up the PS3 controller and Arduino for communication via Bluetooth. See below the video for details. UPDATE: The latest USB host library does not print out any debug information, so you won’t see any of the information that is printed out below “Bluetooth Library Started.” You should still be able to connect your PS3 controller and see it’s data output in the terminal.

Hardware (besides an Arduino):

A Sony-made, PS3 controller (Dualshock 3 or Sixaxis (I was unable to find a strictly Sixaxis controller)).

A USB host shield: Circuits@home and Sparkfun.

A Bluetooth dongle: UPDATE: Go here for the list of dongles confirmed working by the developers. The wiki page for using a PS3 controller will have a list of compatible dongles (although note that in the video I mention that one of the “supported” dongles doesn’t in fact work). Here are the two I have: The black one (working) and the green one (not working, although listed as compatible). These are also confirmed working (by the developers): Kingston and Zoom.

This dongle has also been confirmed working: http://www.amazon.com/gp/product/B007Q45EF4/ref=oh_aui_detailpage_o08_s00?ie=UTF8&psc=1

The Software (besides the Arduino IDE):

UPDATE: Some people have had trouble with the newer versions of the USB host shield library. The new library does not print out the debug information you see in my video and the sketch will become too large to upload to an UNO if you turn the debugging on. If you would like to use the exact same version I use in my video (and am still using), you can get it here. You can get the latest version of the USB host shield library below.

You will need to download the entire USB host shield library from GitHub. This is a direct download link, but if you’d like to take a look around the repository go here.

Install the library as you would any other (if you haven’t done this before see this page), and open the “PS3BT” example as I show in the video (File –> Examples –> (Whatever you named the library) –> Bluetooth –> PS3BT). Remember that the Arduino doesn’t allow for dots (.) or dashes (-) in the library folder name, so when you download the library (which for some reason does have dots and dashes in its folder name) you will have to rename for the Arduino IDE to recognize it.

If there is something I forgot to include here, or if you have a question about something in the video, please ask.

199 thoughts on “Using a USB host shield and a Bluetooth dongle to get data from a PS3 controller – Success!

  1. Hi Barrett,

    I would like to thank you for your tutorials. I was now able to connect my dualshock 4 to my Arduino. It’s now a matter of editing the code for my project.

    Something that I would like to add for everyone. I got a Hytac HGB737 bluetooth dongle, and it works fine.

    Sincerely,
    Chang

  2. Hello Barret,

    Thanks for the answer

    You know who made the shell USB host or someone who can help me on this?

  3. Hi Shawn,

    The reason you don’t see “Write class of device” in my tutorial is probably because I was using an older version of the library in my video. I doubt that seeing it indicates a problem.
    It sounds like you are having the same problem as Rui, another commenter on this thread. I’m not sure what the problem is, and I can’t do any testing because my Arduino is broken. I would suggest that you keep fiddling with it (it tends to be finicky), and if you don’t have any luck, contact the library developer.

    Regards,

    Barrett

  4. Hi Rui,

    That’s difficult to tell. Are the getting the following before the text you quoted?:

    “PS3 Bluetooth Library Started
    Bluetooth Dongle Initialized
    HCI Reset complete
    Write class of device
    Local Bluetooth Address: XX:XX:XX:XX:XX:XX
    Wait For Incoming Connection Request”

    If you are getting “Incoming Connection Request” then the dongle is probably working to some degree. It seems like you are having the same issue another user in this thread, Shawn, is having. You could ask him if he’s figured it out. If all else fails, you can contact the library developer. He has helped me in the past.

    Regards,

    Barrett

  5. Hi Jose,

    It would be possible, however you would have to write the library yourself. Someone figured out the PS3/4 communication protocol, then wrote a library to interpret it. You would have to do the same with the Ipega. If it is open source it might be easier to figure out the communication protocol. I am not an expert in this field, and I would suggest contacting the developer of the USB host shield library as he has experience with this.

    Regards,

    Barrett

  6. Hi, I wanna know if I can control a arduino with this controller ipega pg-9023.

    sorry for my poor inglish.

  7. Hello Barret

    Your videos helped me a lot! Thanks

    I have an issue.
    My dongle is not on the working list and I am not shore if the problem is because of that.

    The problem is that when I connect my ps3 controller to the dongle they both blink but I only receive this part of the message:

    “Gamepad is connecting
    Incoming Connection Request
    Remote Name: PLAYSTA”

    And they do not connect.

    Is this the usual problem with non working dongles?

  8. Hi Barrett,

    When I run the code like in the tutorial, the lines that pop up are:

    “PS3 Bluetooth Library Started
    Bluetooth Dongle Initialized
    HCI Reset complete
    Write class of device
    Local Bluetooth Address: 5C:F3:70:6A:81:61
    Wait For Incoming Connection Request”

    The problem is that after I also change the bluetooth address of the PS3 controller and stick the dongle back into the shield, the lights on both start blinking but won’t stop blinking and connect. After I do all this, the serial monitor shows:

    “Dualshock 3 Controller Connected
    Bluetooth Address was set to: 5C:F3:70:6A:81:61
    Bluetooth Dongle Initialized
    HCI Reset complete
    Write class of device
    Local Bluetooth Address: 5C:F3:70:6A:81:61
    Wait For Incoming Connection Request
    Gamepad is connecting
    Incoming Connection Request
    Remote Name: PLAYSTA”

    After that nothing else appears and the controller doesn’t connect. Could you help with fixing this? I also noticed that after the “HCI Reset complete” line of code, there is an extra line that wasn’t in the tutorial video – “Write class of device.” I have no idea what that means so what can I do to fix that?

    Thank you,
    Shawn

  9. Hi Barrett,

    That is good to know, thank you for the information.
    I now have extra cash for more parts. ^_^

    Sincerely,
    Chang

  10. Hi,
    I have been trouble choosing between the USB host shield from circuits at home, and the one from Arduino, well because the latter is cheaper. Have you done this set up using the USB host shield from Arduino. Do you think the shield from Arduino is compatible with the code?

    Sincerely,
    Chang

  11. Hi Jeferson,

    That is quite odd. I have no idea why that would be happening. This is unlikely, but could it be that your controller’s battery is low and it is turning itself off? I would suggest contacting the library developers about this if the problem persists.

    Regards,

    Barrett

  12. When this message displays the control LEDs blink and turn off after all , and nothing works .

  13. Hi Tanzim,

    I would think that it is possible, however, you would have to decode the communication protocol that the controller uses and write code to handle communication. People have already decoded the PS3 controller’s protocol, which helped in the development of associated code. I am not sure about the Logitech controller. It would certainly be a useful project!

    Regards,

    Barrett

  14. Hi Jeferson,

    From the output you have provided it appears that the controller connected properly. Generally when you see “Dualshock 3 Controller Enabled”, everything has worked correctly. Do you get to this point and nothing further happens? I don’t see anything wrong. Can you provide more detail as to what exactly is happening?

    Regards,

    Barrett

  15. Can I apply the same technique to interface a Logitech F710 wireless controller? Can you help me with that?

  16. Can you tell what the problem is what is happening to the Dualshock 3 does not connect with bluetooth ?

    PS3 Bluetooth Library Started
    Bluetooth Dongle Initialized
    HCI Reset complete
    Local Bluetooth Address: 00:19:86:00:3C:65
    Wait For Incoming Connection Request
    Incoming Connection Request
    Remote Name: PLAYSTA
    Connected to Device: 00:26:5C:3C:05:17
    HID Control Incoming Connection Request
    HID Control Configuration Request
    HID Control Successfully Configured
    HID Interrupt Incoming Connection Request
    HID Interrupt Configuration Request
    HID Interrupt Successfully Configured
    Wait For Incoming Connection Request
    Dualshock 3 Controller Enabled

  17. The baud rate in your serial monitor has to be the same as the baud rate defined in the code. What you are seeing is caused by mismatched baud rates.

    Regards,

    Barrett

  18. Hi Chokejer,

    It looks like it connected properly. Can you describe the problem more specifically?

    Regards,

    Barrett

  19. Hi Vaidhyanathan,

    I was never able to figure out what the error codes meant, but you could try contacting the developers. If I understand you correctly, you are able to retrieve the address from the USB dongle but not write it to the controller? I am not sure what could cause that. I would suggest that you contact the library developer.

    Regards,

    Barrett

  20. Hi Cem,

    What do you mean by “wireless dongle”. I need more specific information to help you.

    Regards,

    Barrett

  21. my problem

    Local Bluetooth Address: 00:1A:7D:DA:71:15
    Wait For Incoming Connection Request
    Keyboard is connecting
    Incoming Connection Request
    Remote Name: PLAYSTATION(R)3 Controller
    Connected to Device: 00:26:5C:07:D4:59
    HID Control Incoming Connection Request
    HID Control Successfully Configured
    HID Interrupt Incoming Connection Request
    HID Interrupt Successfully Configured
    Wait For Incoming Connection Request
    Dualshock 3 Controller Enabled

    LeftHatX: 0 LeftHatY: 0 RightHatX: 0 RightHatY: 1
    LeftHatX: 0 LeftHatY: 0 RightHatX: 0 RightHatY: 1
    LeftHatX: 0 LeftHatY: 0 RightHatX: 0 RightHatY: 1
    LeftHatX: 0 LeftHatY: 0 RightHatX: 0 RightHatY: 1
    LeftHatX: 0 LeftHatY: 0 RightHatX: 0 RightHatY: 1
    LeftHatX: 0 LeftHatY: 0 RightHatX: 0 RightHatY: 1
    LeftHatX: 0 LeftHatY: 0 RightHatX: 0 RightHatY: 1
    LeftHatX: 0 LeftHatY: 0 RightHatX: 0 RightHatY: 1
    LeftHatX: 0 LeftHatY: 0 RightHatX: 0 RightHatY: 1
    LeftHatX: 0 LeftHatY: 0 RightHatX: 0 RightHatY: 1
    LeftHatX: 0 LeftHatY: 0 RightHatX: 0 RightHatY: 1
    LeftHatX: 0 LeftHatY: 0 RightHatX: 0 RightHatY: 1

  22. Hello.
    If anyone was wondering if the PS3 controller will inadvertently power on a PS3, this is not the case. Once the controller has “paired” with the Bluetooth dongle you will need to press the hard reset button through the hole on the underside of the controller to allow communication with a PS3.

  23. Awesome blog!! Everything went on well with the same, until “bluetooth address was set to”, further on toggling to set master we received an error saying bluetooth initialization failed #error 13. What could be the issue?? Thanks!

  24. Hello Fredvine,

    It looks like the developers of the USB host shield have developed some code for joysticks. I would suggest looking at their page: http://www.circuitsathome.com/mcu/using-logitech-extreme-3d-pro-joystick-with-arduino-hid-library.
    There is a library that was written for use with USB joysticks, so it may work with yours. See their website: http://www.airspayce.com/mikem/arduino/USBJoystick/.
    This thread may also be helpful: http://forum.arduino.cc/index.php?topic=128703.0.

    Regards,

    Barrett

  25. Hi there, I just want to ask if you know a way for me to connect my logitech F710 wireless controller to the usb shield host and use it like the ps3 controller… logitech F710 comes with its own usb dongle … thanks in advance.. :)

  26. I would guess that the baud rate in the serial monitor is not the same as that in the code. Make sure that the baud rates match.

    Regards,

    Barrett

  27. can you post a diagram [scheamatic] so i can see the wiring in detail cause my school group is looking into this project and it would be to my aqdvantage

  28. Hi!

    When I start serial monitoring I get this “ÈÀü”×ý6ù†4þaÒ”. I probably have missed something, what is it?

    have a nice day and thx for help

  29. Hello Carl,

    I was never able to determine the exact cause of that error, but this page has some comments on it that might be helpful: https://www.sparkfun.com/products/9947. Search for “OSC did not start” in the page. A couple people have suggested solutions. As far as I understand that error is a result of the USB host chip failing to communicate with the Bluetooth dongle via the USB protocol. It may be an indicator that your dongle is incompatible.
    As for you question about an external power supply: Yes, you can plug in both the external power supply and the USB cable at the same time.

    Regards,

    Barrett

  30. Goodmorning sir!

    I have this USB host shield from E-Gizmo, arduino Mega and a BT dongle. The setup now is complete but I always receive the message “OSC did not start”. I can’t even check if the dongle is simply incompatible, because when I tried plugging the Ps3 USB to the shield the serial monitor’s display stays the same, “OSC did not start”. I thought of plugging an external power supply 12V 1A but the problem insist.

    (Will it be fine to plug both the external source and the serial cable to check the serial monitor? )

    How could I possibly check if the usb shield is working? the dongle’s compatibility?

    Thank you! :) GodBless

  31. Taki,

    That is interesting. Once I had setup the controller address I was always able to connect wirelessly. After you have programmed the address in the controller, and have plugged the Bluetooth dongle into the shield, you should get the “PS3 Bluetooth Library Started” message. After that, once you turn on your controller it should automatically connect. One thing to note is that if the controller is on before the Arduino has been turned on, it will not connect. Make sure that both the Arduino and controller (no blinking red lights on the front) are off, then turn on the Arduino. Once the Arduino is on, press the “PS” button on the controller to turn it on. It should then connect. If not, I am not sure what the problem is. If you have removed the disconnect code (as you mentioned), then you cannot turn off your controller until it times out and turns itself off. This might be your problem.

    Regards,

    Barrett

  32. Hi, I got it right later on though..had to turn off serial monitor and then turn it back on again..though I faced a new issue, as the only time I can connect the dongle with the joystick is when I open serial monitor(arduino connected to pc)..when I go wireless..I simple cannot connect it by clicking the “PS” buttons..though I removed the option to disconnect it by clicking “PS”, so I can connect it via serial monitor and never lose connection when unplugged..am I being gibbrish here?..:/..could you help me..I want to be able to connect and disconnect at will, wirelessly..:)

  33. Hello Taki,

    It sounds like everything is working correctly except in the last step. I would get that error when the dongle was not plugged in all the way, or in any case when the pins were not connecting properly. Once you have connected your PS3 controller once you do not need to plug it in again unless you reprogram the controller address elsewhere. Once you have have received the message

    “Dualshock 3 Controller Connected”
    “Bluetooth Address was set to: 00:15:83:0C:BF:EB”

    Try plugging the dongle in again and then restarting the system. Keep messing with the dongle until you get the first message again (i.e. “Wait For Incoming Connection Request”). Then your controller should connect.

    Regards,

    Barrett

  34. When you get that error, close the serial monitor and open it back up and wait a minute it should Initialize

  35. Hello Khan,

    As far as I can tell the HC-05 is a Bluetooth transceiver. Bluetooth transceivers not hosts/masters and are therefore not capable of actively seeking connections. Thus, they cannot connect to a PS3 controller. So no, the HC-05 will not work.

    Regards,

    Barrett

  36. You went for the usb shield coz u wanted to connect to a bluetooth dongle so that u can use it as your master for hosting the bluetooth connection for ur PS3 controller(slave)
    ri8??
    what if i use a hc-05 which can be used as master (not dumb) to connect directly to the PS3??
    would that be acceptable for PS3 ???

  37. Hey there! Someone in my Facebook group shared this site with us so I came to take a look. I’m definitely enjoying the information. I’m bookmarking and will be tweeting this to my followers! Great blog and great design and style.

  38. hi, I tried what was exactly told in the video, and this is how it goes..

    when I run the program with the dongle on I get this

    “PS3 Bluetooth Library Started
    Bluetooth Dongle Initialized
    HCI Reset complete
    Local Bluetooth Address: 00:15:83:0C:BF:EB
    Wait For Incoming Connection Request”

    when I unplug the dongle and connect the ps3 joystick I get this

    “Dualshock 3 Controller Connected
    Bluetooth Address was set to: 00:15:83:0C:BF:EB”

    now when I plug the dongle back on I get this

    “getConf
    BTD Init Failed, error code: 13″

    Please help me with this issue..:)

  39. /*
    Example sketch for the PS3 Bluetooth library – developed by Kristian Lauszus
    For more information visit my blog: http://blog.tkjelectronics.dk/ or
    send me an e-mail: kristianl@tkjelectronics.com
    */

    #include
    #include
    // Satisfy IDE, which only needs to see the include statment in the ino.
    #ifdef dobogusinclude
    #include
    #endif

    USB Usb;
    //USBHub Hub1(&Usb); // Some dongles have a hub inside

    BTD Btd(&Usb); // You have to create the Bluetooth Dongle instance like so
    /* You can create the instance of the class in two ways */
    PS3BT PS3(&Btd); // This will just create the instance
    //PS3BT PS3(&Btd, 0x00, 0x15, 0x83, 0x3D, 0x0A, 0x57); // This will also store the bluetooth address – this can be obtained from the dongle when running the sketch

    boolean printTemperature;
    boolean printAngle;

    int motor1 = 3;
    int motor2 = 5;
    int motor3 = 8;
    int val = 0;

    void setup() {
    Serial.begin(115200);
    while (!Serial); // Wait for serial port to connect – used on Leonardo, Teensy and other boards with built-in USB CDC serial connection
    if (Usb.Init() == -1) {
    Serial.print(F(“\r\nOSC did not start”));
    while (1); //halt
    }
    Serial.print(F(“\r\nPS3 Bluetooth Library Started”));
    pinMode(motor1, OUTPUT);
    pinMode(motor2, OUTPUT);
    pinMode(motor3, OUTPUT);

    }

    void loop() {
    Usb.Task();

    if (PS3.PS3Connected || PS3.PS3NavigationConnected)
    // Analog button values can be read from almost all buttons
    if (PS3.getAnalogButton(L2) || PS3.getAnalogButton(R2)) {
    Serial.print(F(“\r\nL2: “));
    motor1.write(map(PS3.getAnalogButton(L2), 0, 255,255, 0));
    if (PS3.PS3Connected) {
    Serial.print(F(“\tR2: “));
    motor2.write(map(PS3.getAnalogButton(R2), 0, 255,255, 0));
    }
    }
    if (PS3.getButtonClick(PS)) {
    Serial.print(F(“\r\nPS”));
    PS3.disconnect();
    }
    else {
    if (PS3.getButtonClick(TRIANGLE))
    Serial.print(F(“\r\nTraingle”));
    motor3.write(map(PS3.getAnalogButton(TRIANGLE), 0, 255,255, 0));
    }
    }

    just need a littlehelp

  40. Hello
    I have been facing issue for setting same address as that of Bluetooth dongle on PS 3 controller . When I turn on shield for first time I get messages till waiting for incoming connection request . That is first 3 to 4 lines . But when I connect my ps3 controller via usb cable for the first time to sheild nothing happens . I have been using dongles that looks same as that of yours in video .
    I need your help with one more issue . I don’t know how to interface ps3 controller just via usb cable that is using ps3 usb . I need step wise guide . I have arduino mega 2560 also , is it possible to connect usb host shield for Uno to it ?
    Kindly expects help !

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s