USB Host Shield is now available in the webshop
This is a short announcement regarding the USB Host Shield from Circuits@Home, which we are now carrying in in our store.
By buying the official shield you will support the continous development of the library and get support from us!
The shield can be found and bought here: USB Host Shield 2.0 for Arduino.
The shield can be used with almost any kind of Arduino including the most popular Arduino Uno, Arduino Mega, Arduino Leonardo etc. If you are in doubt if your Arduino is supported please don’t hesitate to write a comment below.
The USB Host Shield will allow you to use any of the Bluetooth and USB libraries I wrote.
In case you missed it I have written several libraries for the shield including:
The Serial Port Protocol (SPP)
Emulate a serial port via Bluetooth, which allows you to send data back and fourth wirelessly.
PS3 controllers
All the official controllers are supported both via USB and Bluetooth.
PS4 controllers
The PS4 controller is supported via both USB and Bluetooth as well.
Xbox controllers
Both the wireless and wired controllers are supported. You will need a special wireless receiver to use the wireless controller.
Wiimotes
The Wiimote is supported including the build IR camera. The Motion Plus and Nunchuck extensions are also supported. The Wii U Pro Controller is supported as well.
Bluetooth HID devices
Standard Bluetooth HID devices, like mice and keyboards are also supported by the library.
The USB Host Shield support several other devices including:
- USB to serial converters – FTDI, PL-2303, ACM, as well as certain cell phones and GPS receivers are supported.
- Android ADK
- Digital cameras
- HID device, such as keyboards, mice and joysticks
- USB MIDI driver
The source code can be found at Github:
https://github.com/felis/USB_Host_Shield_2.0.
More information can be found at Circuits@Home.
Dear Lauszus,
I’ve sent you an email regarding interfacing USB Modem with Arduino through USB Host Shield.
Kindly see it and let me know, hope you help me in this case π
Best Regards,
Kareem
@Kareem
I just replied to your email.
@Lauszus
Thanks for your cooperation.
@Kareem
You’re welcome π
Hello , I would like to thank you for the library .
I’m using it to control a motor of a rc Car using the ps3 controller by Bluetooth and arduino .
Im now in the programming process and I want to use switches or else the programe will be too long
so what should I edit to me code so that the the switch happens when I press a button
switch (when button pressed) {
case ‘PS3.getButtonPress(CROSS)’:
digitalWrite(BLP, HIGH);
break;
case ‘PS3.getButtonPress(SQUARE)’:
digitalWrite(BLP, LOW);
break;
}
@nero
I’m glad that you like my library. Have you got a video of it? I would love to see it π
You could simply do it like so:
digitalWrite(BLP, HIGH);
else if (PS3.getButtonClick(SQUARE))
digitalWrite(BLP, LOW);
You can find more information about the library and all it functions etc. here: http://felis.github.io/USB_Host_Shield_2.0/class_p_s3_b_t.html.
thanks for the quick response : ) I really appreciate it π and sorry for posting on more than one page π
I already wrote it this way , but I have many controls so I’ll be using around 10 buttons π thats why I’m thinking about the switch method
so is there an alternative way of saying “switch when a button is pressed and based on which button is pressed the motors will move ?
@nero
No problem π
You can’t do it that way, as you have to read the individual bits in the incoming data. That’s why I have made those functions. Take a look at the source code on how they work: https://github.com/felis/USB_Host_Shield_2.0/blob/master/PS3BT.cpp#L52-L61.
This means that you can’t use a switch method. Simply just use a bunch of if and else if as it is shown in the example.
If you just want to switch a light, when any button has been pressed, then simply make this public: https://github.com/felis/USB_Host_Shield_2.0/blob/master/PS3BT.h#L236 and then use it like so:
// Any button has been pressed
Ok got the point π . once I finish Ill post a video of what I did . Im currently having a problem with the outputs from arduino uno so Im trying to use the ps3bt with the arduino adk but its not working
the serial port gives me the following
OSC did not start
@nero
You need to uncomment the following line: https://github.com/felis/USB_Host_Shield_2.0/blob/master/avrpins.h#L25 for it to work.
Now I’m trying to connect Arduino board to a sensor board that was already made using USB Host Shield and libraries.
But unfortunately, you’re library doesn’t support CP210x usb to serial converters.
Do you have any plan to support CP201x? or Is there any solution to connect CP210x by modifing existing source code?
@Hong
Yes we are planning on that. Hopefully it will be ready before new year π
i am doing my final year project on robotic arm interfacing with the mouse on the platform of ardiuno,i have usbhost shield even from sparkfun,but how to connect ardiuno with the usb host shield i am not getting.
@ali
Please see the following comment: http://blog.tkjelectronics.dk/2012/07/xbox-360-controller-support-added-to-the-usb-host-library/comment-page-1/#comment-59256.
I just have an inquiry. Right now I have the Arduino UNO, and the USB Host shield from Circuits@Home. When I run and compile the code I get the message on my Serial Monitor saying that “OSC did not start”. I’m not sure if my BT dongles should have a light, but if it should Its not coming on.
@Chris
Hmm strange. Is it an official Arduino Uno? Also have you soldered the ICSP properly? You can find instructions here: http://www.circuitsathome.com/mcu/usb-host-shield-illustrated-assembly-guide.
Btw that error means that there is no communication with the MAX3421E chip on the shield.
@Lauszus
Hello, have you any clue when the library for the CP210x is ready? In a power supply, part of my present project, a CP2102 is installed. If the library takes even longer, I must attempt to disassemble the power supply and replace the chip by another.
@Juergen
This is unfortunately not something that is planned at the moment.
@Lauszus
everything is soldered on correctly as far as I know, I bought new dongles and I’m still getting the same message. I’m about to send an e-mail with pictures of the set up if thats ok.
@Chris
You need to solder the ICSP header as well! The SPI pins are located on that header!
Hello Lauszus,
For an arduino project I would like to connect a wireless ps3 controller to an arduino and so I am thinking to buy your usb-host shield. But I have one question: Why do I actually need the intermediate step of a usb-host shield? Is it not possible to directly connect a bluetooth receiver HC05 to the arduino like: http://www.instructables.com/id/Arduino-AND-Bluetooth-HC-05-Connecting-easily/ ?
Although I think it should be possible to connect a ps3 controller to the HC05 I cannot find any documentation on it (especially pairing the two together). In this way I wouldn’t need the intermediate step of transferring bluetooth data to USB data and the size of my project could be a bit smaller.
Already thanks, kind regards!
@Evert
No unfortunately that is not possible as the HC05 module doesn’t support Bluetooth HID. Furthermore paring with the PS3 controller is done via USB, so there is no way to pair with it using the HC05 module.
Hello!
I am using your library with success with wii mote!! Is there anay library for the wii balance board? I am trying to pair with it and read the sensors, like weight!
thank you!!!
@dk6
No I have not written a library for the Wii balance board, as I don’t own one.
First of all thank you for your quick reply. I must say that you done great job with the code!
Here there is some usefull info about the wii balance board:
http://wiibrew.org/wiki/Wii_Balance_Board#Summary
What steps should i follow such as to make modifications to your library, to be connected to the wii balance board. They say that wiimote functions are the same as wii balance board.
any ideas to start with??
thank you again!
@Lauszus
June 20th, 2014 at 18:17 | #25 Reply | Quote
First of all thank you for your quick reply. I must say that you done great job with the code!
Here there is some usefull info about the wii balance board:
http://wiibrew.org/wiki/Wii_Balance_Board#Summary
What steps should i follow such as to make modifications to your library, to be connected to the wii balance board. They say that wiimote functions are the same as wii balance board.
any ideas to start with??
thank you again!
Moreover i have noticed something:
With wii-mote when i make the pairing method button 1+2 i have connection. When i try with the red button pairing method (behind the battery pack of the wii mote) i have NO connection.
In the wii balance board there is only the red button for the pairing.
They say ( http://wiibrew.org/wiki/Wiimote#Bluetooth_Pairing ) the pairing pin is different depends the pairing method!
@dk6
Take a look how the Motion plus and Nunchuck are initialized. You need to do the same thing for the Wii Balance board and then you should be able to parse the incoming data – see: http://wiibrew.org/wiki/Wii_Balance_Board#Data_Format.
@dk6
The Pro U Controller does this as well. Take a look at the following function: https://github.com/felis/USB_Host_Shield_2.0/blob/b3b476af331e17f94ba6203eefd00869720a7478/BTD.cpp#L1068-L1102.
You should especially take a close look at these lines: https://github.com/felis/USB_Host_Shield_2.0/blob/b3b476af331e17f94ba6203eefd00869720a7478/BTD.cpp#L1080-L1089.
dk6: i had problems with the wiiu pro controller and the cheap 1? doogles. they only worked with the wiimote for me. (on pc they work with the pro controller, no idea why the host shield doesnt work with them fΓΌr wiiupro)
I recommend this doogle. Its cheap, looking okay and working for the pro controller:
http://www.aliexpress.com/item/USB-Bluetooth-Dongle-USB-2-0-Bluetooth-Adapter-100m-PC-Laptop-9347-free-shipping/421669286.html
@NicoHood
Thank you NicoHood for the usefull info! Just in case i have already order the dongle you told me. But until it comes to me i have to do the test with the current one i have. Wii balance board is an old controller although. I have to figure out how to pair with it with the red button method. I am still reading Lauszus libraries and try to find a solution. Every help is welcomed of course and thank you very much for your infos.
Also when i make this #define ENABLE_UHS_DEBUGGING 1
i am getting a lot of errors in Arduino IDE compiler…
librariesUSB_Host_Shield_20/settings.h:107:53: error: operator ‘&&’ has no right operand
@Lauszus
So can i use directly the
WII Wii(&Btd, PAIR); ??
which libraries i need for my arduino uno sketch to include? what libraries i have to modify?
Please a little help π
@dk6
Yes. By using this initializer method for the Wii part of the USB Host library you enable the pairing functionality that means it will look for Wii devices to pair with.
This is only needed once. Afterwards the initializer method can be changed to just: WII Wii(&Btd);
Regarding your issue with the ENABLE_UHS_DEBUGGING can you please confirm which version of the Arduino IDE you are using? Also which version of the USB Host library are you using? The latest from Github?
There shouldn’t appear any errors when enabling the debugging as long as you haven’t modified the library.
Well i have installed all over arduino IDE and the latest library from Github.
I just open settings.h and make the change ” #define ENABLE_UHS_DEBUGGING 0 ” 0->1
I open the wii example to compile it…. and i have these errors… please check image link
http://tinypic.com/view.php?pic=5bwcgg&s=8
when i open settings.h again and change 1->0 everything is ok!!!
ARDUINO 1.0.5-r2 and Github from https://github.com/felis/USB_Host_Shield_2.0
@dk6
As the error indicated the program is too large to fit on the Uno with debugging enabled. You might want to get a Arduino Mega instead.
Hello again! Now i have both dongles NicoHood suggested me. But still i can not connect with Wii balance board. I would like to ask you something. Why i can only pair with wii-mote (Wii.sch example) when i push button 1+2? and not with the red-sync button (battery case) ??? The library is only for the 1+2 method? I am telling you this because wii-balance board has only the red-sync button. Thank you for your support all of you!
@dk6
Please see my previous reply: http://blog.tkjelectronics.dk/2013/01/usb-host-shield-is-now-available-in-the-webshop/#comment-505352.
i know the mac addresses (bluetooth dongle and wii balance board) . The pin when i press the red sync button is the mac address of the bluetooth dongle but reverse. Is there any command which i can give directly with the pin already included? I don’t want automate discover and pairing.
like…WII Wii(&Btd, “PIN”); ???
thank you π
@dk6
No you will have to modify the library.
Please see my earlier reply: http://blog.tkjelectronics.dk/2013/01/usb-host-shield-is-now-available-in-the-webshop/#comment-505352.
Hello…
I am getting “OSC did not start.” error…
Is it linked to the power supply?
I am using an Arduino Pro (http://arduino.cc/en/Main/ArduinoBoardPro) powered&programmed via FTDI board.
My USB Host board is the “Sainsmart USB Host” board (http://www.sainsmart.com/sainsmart-usb-host-android-adk-shield-2-0-for-arduino-uno-mega-r3-mega2560-duemilanove-nano-robot.html)
@Luca
Have you remembered to solder the ICSP header as well?
Also please note that you have bought a clone! Please consider buying the official shield either from me: http://shop.tkjelectronics.dk/ or https://www.circuitsathome.com/products-page/arduino-shields in order to support the actual developers of the library and hardware!
Hello,
Will your library work with a BLE device? I would like to send serial data to the USB Host Shield from iOS using BLE. I don?t expect to use your BTHID.cpp methods but I?d like to be able to reuse some of the BTD.cpp code.
Thanks for your guidance.
@John Goodman
Yes it will work. You simply need a dongle that support Bluetooth 4.0, but you might need to modify the library as well.
Hi there!
I’m really excited to control my robot with a PS3 controller. I have ordered all of the hardware and it should be here by friday.
I have one question. I was going through your example code for the PS3 controller ( I believe this is the code I should upload to the arduino to test the PS3 controller connection) and it says I MUST us an arduino MEGA? Is there any way around this??? I only have an UNO π
thank you!!!
@Ian
I just realized that I was looking at the PS3SPP file, when I should have used the PS3BT file to initially sync my arduino with my PS3 controller! It looks like the PS3BT file should have no problem compiling on the arduino UNO(correct me if I’m wrong please!).
also, I noticed that you have some code for XBOX 360 controller. I’ll be testing that out as well!
Cheers.
@Ian
Yes that is correct. The PS3BT example will work just fine on an Uno!
Okay great! Just tell me if you have any more questions π
@Lauszus
Thank you!
now, I posted this question in another part of your website, and I can’t, for the life of me find it. So, I apologize if you already answered it!
I have the PS3 dual shock communicating with my arduino via the bluetooth dongle and usb host shield. I have a dongle that looks like a black half-circle with three lines in descending length for grip. it also has a red led inside. It looks absolutely identical, and came in the same packaging as the approved usb dongles. So, heres the problem:
When I connect the PS3 controller, I get this message:
PS3 Bluetooth Library Started
Bluetooth Dongle Initialized
No response to HCI Reset
HCI Reset complete
Local Bluetooth Address: 00:15:83:3D:0A:57
Wait For Incoming Connection Request
Incoming Connection Request
Remote Name: PLAYSTATION(R)3 Controller
Connected to Device: 60:38:0E:1B:4F:60
Your dongle may not support reading the analog buttons, sensors and status
Your HCI Version is: 2
But should be at least 3
This means that it doesn’t support Bluetooth Version 2.0+EDR
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
********************
So the part that concerns me is “Your HCI Version is: 2 , But should be at least 3”
The symptoms are:
All buttons work correctly and register in the serial out EXCEPT the analog L2 and R2, and the accelerometer doesn’t output values (stays at 255).
any help would be greatly appreciated!
@Ian
also, I’m using the older version of the ps3 library. The new version won’t try to find bluetooth it only outputs “PS3 bluetooth library started” and thats it.
Another symptom is that every minute or so the bluetooth outputs:
LeftHatX: 0 LeftHatY: 0 RightHatX: 0 RightHatY: 0
LeftHatX: 0 LeftHatY: 0 RightHatX: 0 RightHatY: 0
LeftHatX: 0 LeftHatY: 0 RightHatX: 0 RightHatY: 0
LeftHatX: 0 LeftHatY: 0 RightHatX: 0 RightHatY: 0
LeftHatX: 0 LeftHatY: 0 RightHatX: 0 RightHatY: 0
LeftHatX: 0 LeftHatY: 0 RightHatX: 0 RightHatY: 0
since I’m trying to control a robot, outputting these values randomly would be a terrible thing for my control!
thanks again
Ian
@Ian
The error message explains exactly what the problem is:
Your HCI Version is: 2
But should be at least 3
This means that it doesn?t support Bluetooth Version 2.0+EDR
In short you will have to use another dongle.
The reason why you don’t see any output in the new version is because debugging needs to be enabled: https://github.com/felis/USB_Host_Shield_2.0#enable-debugging.
@Lauszus
Lauszus,
Thank you! I ordered a different dongle from the wiki page, but there are a lot of links that don’t work anymore. As far as I understand, the dongle MUST be BT 2.0. However, I did see a dongle on the list of approved dongles that was BT 4.0? I’ll do some more research but I wanted to avoid buying a 10$ dongle that won’t work.
Thanks again and I’ll keep you posted
@Ian
Bluetooth 4.0 dongles with work just fine as well, as they are backwards compatible.
@Lauszus
UPDATE
I purchased a BT 4.0 dongle from amazon and it seems to be working well! I now have full control of L2 and R2 and the start/accelerometer function is working perfectly.
heres the link for the dongle:
http://www.amazon.com/gp/product/B00IMALOZ0/ref=oh_aui_detailpage_o00_s00?ie=UTF8&psc=1
However, I still have the problem in the serial out where rightHatX/y and leftHatX/y output all zeros randomly when I’m using the directional pad. It will also output a few lines of zeros when I’m not using the controller. I timed the intervals on a stopwatch a few times to find a pattern and it is completely random. I’ll enable debugging and see if that helps.
cheers
@Ian
Thank you. I just added it to the list on the wiki π
It sounds more like it is an issue with the PS3 controller? Have you tried another one?
@Lauszus
As I recall, it was having the same problem with the other controller I have. I will confirm this. Here’s a link to the controller controlling a DC motor:
https://www.youtube.com/watch?v=jumoDXIauP0&feature=youtu.be
thanks!
@Ian
I have never had this issue or heard from somebody else. If this was the case then this would mean that the Balanduino would suddenly start traveling forward!
An easy fix would be just to ignore the 0 value and if you encounter that just use the last receiver one?
Here’s a link to the soccer ball kicking robot moving around:
http://youtu.be/G_JtG4Ox0To
Thanks again! Still haven’t figured out the random zeros problem…
@Ian
Looks good π Hopefully you will solve those random zeros soon.
@Lauszus
Lauszus,
I am unclear as to whether we can use pins 8-13 on the arduino with the USB host shield connected. We are using pins 2-7 for our motor controls and we need to run a servo now. Anytime I connect it to pins 8-13 there are problems with the bluetooth. and it doesn’t seem like its even possible to run a servo from pins 0 or 1. Using arduino uno
@Ian
You can’t use pin 13-11 as these are used for SCK, MOSI and MISO and can not be rerouted. Pin 10 and pin 9 are used for SS and INT respectively and can be rerouted to any pin including the analog post – see: https://github.com/felis/USB_Host_Shield_2.0#interface-modifications.
The shield does not use pin 0 or 1, so that can’t be causing the issue with your servo, but make sure that they are not drawing too much current, as the Bluetooth dongle needs a stable 5V supply.
Hi Kristian,
Hope you’re doing well.
I’m trying to connect two Arduino UNO’s using Bluetooth USB dongles without any shields and was thinking of using your USB Host Library for it.
Is it possible to use the existing USB port on Arduino UNO (that we use to program Arduino) as a USB to Bluetooth port by connecting a dongle to it? I kinda went through the code and your explanation on SPP sketch and thought this might work.
To connect the USB dongle, I would be using a male to female connector on UNO’s USB.
http://www.amazon.com/Generic-Type-Female-Adapter-USB_A_F-USB_B_M/dp/B000AA2SMS
Would appreciate your inputs on this.
Regards,
Rahul
@Rahul Swaminathan
No that is not possible! The USB connector on the Arduino is for USB device communication. You will need a USB host port, like the one on the USB Host Shield.
@Lauszus
would you be able to recommend a bluetooth module that would be suitable. I’m considering perhaps RN-42 or perhaps RN-41? I would like to use it to connect directly to pyboard, but I dont see how that would differ from arduino (apart from the language).
Thanks!
– Jarryd
@Jarryd
Those modules will not work, as they do not support Bluetooth HID host. You will have to use a Bluetooth dongle or a Bluetooth chip where you would have to write firmware for it.
Hi @Lauszus
thank you for your valuable material. I have problems with PS3BT code in order to connect Bluetooth dongle with PS3 controller. The PS3BT code doesn’t recognise usbhub.h and spi4teensy3.h header files in fact they don’t appeared orange. Could be some problems with my Arduino version that is 1.6.12?
Regards
Hi, is it possible to pair without PIN? I have tried to set SPP instruction with “name of device” and without “pin” (SPP SerialBT(&Btd, “Controller_Semafori”);but it always requests pin when then I try to connect from phone.
Thanks
Danilo
@vtomic86
Please read the following section of the README on how to include the library: https://github.com/felis/USB_Host_Shield_2.0#arduino-library-manager.
@Danilo
You need to create an “insecure” RFCOMM socket: https://github.com/Lauszus/LaunchPadFlightControllerAndroid/blob/939fcbf3d7aee792f2229ef352b45292f9560da0/app/src/main/java/com/lauszus/launchpadflightcontrollerandroid/app/BluetoothChatService.java#L304-L306, then it will not ask for a pin. You should use a “secure” socket the first time and then an “insecure” socket from then on. Please also see: https://github.com/Lauszus/LaunchPadFlightControllerAndroid/blob/939fcbf3d7aee792f2229ef352b45292f9560da0/app/src/main/java/com/lauszus/launchpadflightcontrollerandroid/app/LaunchPadFlightControllerActivity.java#L350-L355 and https://github.com/Lauszus/LaunchPadFlightControllerAndroid/blob/939fcbf3d7aee792f2229ef352b45292f9560da0/app/src/main/java/com/lauszus/launchpadflightcontrollerandroid/app/DeviceListActivity.java#L211-L217.
I am currently using your usb 2.0 libraries for a robotics project. I was wondering if you could answer a question I had. I believe I bought the wrong USB host for the project. I bought the USB host listed in the first link. When I ran it, I got the OSC error listed in the second link. I am really okay with buying the right usb host but the shipping says that it could take up to 20 days to ship it. The project is due before then and I wanted to know if the usb host that I bought could work or if there was quicker way to get the right one or a way a list of the ones that would not have the ICSP error.
https://www.amazon.com/gp/product/B006J4G000/ref=oh_aui_detailpage_o00_s00?ie=UTF8&psc=1
https://github.com/felis/USB_Host_Shield_2.0/issues/130#issuecomment-70209796
http://shop.tkjelectronics.dk/product_info.php?manufacturers_id=13&products_id=43
Thanks!
@Grant Cignarella
We have just replied to your email as well.
Our webshop is mainly focused for retail sale why we only offer normal un-registered airmail shipping to keep the shipping costs down (international registered airmail rates for low-volume are very expensive out of Denmark).
Though at request as well as to all of our B2B customers we do offer several other shipping options including the registered courrier-based DHL shipping method.
Regards Thomas
Hi Dear
I want to read XBOX G920 Logitech steering wheel (pedal and keys ,…)with usb host shield.
I want to use your library, But I cannot read it!
can you help me?
Hi, thanks for work.
I am trying to get the USB HOST shield working on a Leonardo.
The leonardo has x4 LEDs.
1. Power
2. PC7 – LED_BUILTIN
3. PD5 – TX LED
4. PB0 – RX LED
When I plug the shield into the Leonardo board I get a solid LED on PC7/LED_BUILTIN and I cannot communicate with the board via COM port over USB.
I have tried connecting the shield to the leonardo via wire/jumpers and excluded the ICSP the LED_BUILTIN light turns off, and I can communicate with the Leonardo again.
I could not find a clear answer as to if / what I may need to re-route to make the demo work.
Thanks,
vivvvi
I can successfully upload the code onto my Arduino Uno, and start the serial monitor on the COM3 and it will display “PS4 Bluetooth Library Started”. But then when I try and plug my Arduino USB host shield into the Uno and hit the reset button to run again and display another “ps4 Bluetooth Library Started” it won’t do this. I’m not sure what I’m doing wrong with the host shield and it seems like the Uno can’t function when the shield is plugged in with or without a Bluetooth dongle.
I try to use the USB host shield with ESP32. The shield works very well on ab Arduino Uno, but on the ESP32 I get wrong SPI data. In the board_qc sketch I get 0x09 in place of 0x13 for the version. I tried to change the max SPI clock from 26000000 to 2600000 in usbhost.h. After this change I got the correct version, but the long test fails with write 0x01 -> read 0x00.
On other sketches I get the error “OSC did not start”.
It seems to be a problem with the SPI communication. What can I do to fix this?
Hi, I purchased your board to use with an optical power meter that has a usb output. I couldnt find in your libraries any documentation for that. Where does this fall under? I am linking the device here
https://www.newport.com/p/843-R-USB
Thank you