Posts

USB Host Shield library Version 2.0 released.

Hub demo

Hub demo


What started as a quick re-factoring effort transformed to a major redevelopment, but finally all pieces fit together tightly and I am pleased to announce that initial release of USB Host Shield library ver.2.0 has been posted to github. This new version contains several major improvements:

  1. Only 5 Arduino pins are now required for USB Host Shield to function – 3 standard SPI pins (SCK, MISO, MOSI) and 2 remappable pins (SS and INT).
  2. The low-level interface to MAX3421E has been re-designed. Arduino pin manipulation routines has been replaced with mechanism inspired by Konstantin Chizhov’s C++ AVR pin templates. As a result, low-level transfers became approximately 3.5 times faster. Also, pin reassignment can be done much easier by passing pin numbers into MAX3421E template during instantiation.
  3. The high-level interface to USB devices has been re-designed as well. It is now possible to connect USB hub to the shield and have many devices on USB bus, up to 7 daisy-chained 8-port hubs plus up to 44 devices connected to hub ports left after daisy-chaining, memory permitting. Also, a standard mechanism of device initialization/polling/releasing has been added to enumeration.

Several minor code improvements has also been made. NAK_LIMIT is now tied to an endpoint – it is now possible to have NAK_LIMIT set to 1 for interrupt endpoint and 32000 for bulk endpoint of the same device simultaneously. Control transfer function now accepts callback in order to split long chunks of data, if necessary. inTranser() function now is able to return actual number of bytes received.

Support for several popular device classes has been added. Device initialization and event handling is now moved to a library specific to device class, therefore user application does’n need to do this and only needs to process actual device data. The following devices are now supported by the library code:

  • Human Interface Device AKA HID. Keyboards, mice, game controllers, bar code scanners, magnetic card and RFID readers – the list goes on. Initialization, polling, report descriptor parsing, as wellas reading and sending reports is possible.
  • Asynchronous Serial over USB AKA CDC. Devices of this class provide serial connectivity. For example, newer Arduino boards, such as UNO and Mega 2560 communicate to a PC using CDC ACM-class device, while older boards, such as Duemilanove, use FTDI FT232 USB-to-serial converter. 3 main types of converters are supported – CDC ACM (newer Arduinos and most modern cell phones), FTDI FT232 (older Arduinos plus a ton of standalone converters ) and Prolific PL2303 (mainly used in USB cables for various cellphones).

Several other device classes are in the works and will be available soon. They include:

  • Mass Storage Devices – Flash Drives, USB sticks, card readers, etc.
  • PTP – a protocol used in digital cameras. The PTP code is being transferred from current PTP project with minor changes.
  • Android ADK protocol, recently introduced in versions 3.1 and 2.3.4 of Android OS. Simple lightweight protocol for bi-directional communication with Android phone or tablet.

In addition to that, USB hub is supported by its own class; however, in order to use it nothing special needs to be done apart from defining an instance of hub class for each hub.

Library code is compatible with current revisions of USB Host Shield, i.e. full-size shield r2.0 and Mini shield r1.1. Older shields can be made compatible with new library by performing a simple hardware modification. I will add a section to hardware manual eventually, in the mean time, if you still have an old shield and want to know how to mod it to make it compatible with new library, drop me a line. It also should be noted that due to extra code needed for multi-device support binaries compiled from this library are larger than old one – before migrating your existing project make sure it will fit into your Arduino.

A hub_demo directory under examples contains a sketch demonstrating hub functionality. The sketch goes from hub to hub initializing devices and then prints their device and configuration descriptors. As can be seen on the title picture, I have a 24 port hub, which actually consists of four daisy-chained 7-port hubs, 3 cell phones, couple mice, USB-to-serial converter, Xbee plugged into Explorer board, digital scale, a pair of RC controllers, digital camera, and RFID reader. The output of a sketch running this setup can be seen here.

The following lines:

USBHub  Hub1(&Usb);
USBHub  Hub2(&Usb);
USBHub  Hub3(&Usb);
USBHub  Hub4(&Usb);

create hub instances, if you need more than four (up to 7), add USBHub Hub5(&Usb);, USBHub Hub6(&Usb);, USBHub Hub7(&Usb);. If you need to address more than 16 devices, including hubs, increase USB_NUMDEVICES in Usb.h.

Except for hubs, the sketch doesn’t make any attempts to configure any devices, it can be run with any USB devices which are available.

At present, I only have one other sample sketch in acm directory. It is a simple terminal intended to be used with cell phones. I will post details about using it soon. In the mean time, take a look at the cdoe, run sketches and let me know what you think.

Oleg.

382 comments to USB Host Shield library Version 2.0 released.

  • Guy

    Nevermind. It turns out the FTDI loopback example worked for me. I just had to adjust baud rates and command timing specific to my application.

  • Eric

    Guys, I haven’t found any clue that you released “Mass Storage Devices” support, any progress now? I am interesting in your shield and wondering whether it can make arduino to read the flash drive and show on LCD.

    Thanks.

  • mat66mat

    Good Morning,

    USB HOST SHIELD 2.0
    USB HOST SHIELD LIBRARY 2.0
    ARDUINO UNO R3

    It’s my first project in arduino environment. I must dialog with a health usb card reader (french project Sesam vital)

    If i connect this reader directly to windows system i can see in device manager “XIRING USB CDC 14 (COM57)”

    I use your acm_terminal example and i get FailGetDevDescr with return code 04, Can you explain what it mean ?

    Thank you very much for your help

    Here’s informations given by USB_desc
    Start

    01

    Device descriptor:
    Descriptor Length: 12
    Descriptor type: 01
    USB version: 0200
    Device class: 02
    Device Subclass: 00
    Device Protocol: 00
    Max.packet size: 40
    Vendor ID: 0F14
    Product ID: 0014
    Revision ID: 0100
    Mfg.string index: 01
    Prod.string index: 02
    Serial number index: 03
    Number of conf.: 01

    Configuration descriptor:
    Total length: 0043
    Num.intf: 02
    Conf.value: 01
    Conf.string: 00
    Attr.: 80
    Max.pwr: FA

    Interface descriptor:
    Intf.number: 00
    Alt.: 00
    Endpoints: 01
    Intf. Class: 02
    Intf. Subclass: 02
    Intf. Protocol: 01
    Intf.string: 00
    Unknown descriptor:
    Length: 05
    Type: 24
    Contents: 0010010424
    Unknown descriptor:
    Length: 04
    Type: 24
    Contents: 02060524
    Unknown descriptor:
    Length: 05
    Type: 24
    Contents: 0600010524
    Unknown descriptor:
    Length: 05
    Type: 24
    Contents: 0103010705

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

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

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

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

    Addr:1(0.0.1)

    • It means Get Device Descriptor request has failed. This is strange since USB_desc outputs it easily. Your device may need additional delays in initialization, try to add them and see if it makes any difference.

  • tab

    Hi Oleg,

    Im using the FTDI loopback example and everything is working fine, but Im unsure of how to use the hub function. What Im trying to do is send “Deadbeef1” to one device and “Deadbeef2” to another device, and make them both output on the serial monitor. Im just not sure how to address each device using the USBhub class. any help would be much appreciated.

    Thankyou

    • Hub is automatic, you just need to instantiate it. Devices are the same; if you need two, create two instances of FTDI, like this:

      FTDI             Ftdi1(&Usb, &FtdiAsync);
      FTDI             Ftdi2(&Usb, &FtdiAsync);
  • tab

    Thankyou for the immediate response Oleg, this clears up a lot of things.
    So, because I want deadbeef1 and deadbeef2 to alternate in the serial monitor, do I have to extra lines like this:
    rcode2 = Ftdi2.SndData(strlen(strbuf), (uint8_t*)strbuf);
    ?

    or is it something much more trivial, which Im too dopey to even think about lol,

    thankyou so much ! 🙂

  • tab

    ended up working, just repeated the first loop again, with different variable names. Thankyou Oleg! 🙂

  • Stuart Clark

    I have an arduino uno r3, and am trying to get the usb host shield 2.0 compiled so i can communicate with the android phone.

    i get the following errors

    In file included from HelloAndroid.cpp:3:
    C:\Documents and Settings\Stuart.CLARK\My Documents0 Software Development\arduino\arduino-1.0.1-windows\arduino-1.0.1\libraries\AndroidAccessory/AndroidAccessory.h:37: error: ‘EP_RECORD’ does not name a type

    C:\Documents and Settings\Stuart.CLARK\My Documents0 Software Development\arduino\arduino-1.0.1-windows\arduino-1.0.1\libraries\AndroidAccessory/AndroidAccessory.h:50: error: ‘EP_RECORD’ has not been declared

    C:\Documents and Settings\Stuart.CLARK\My Documents0 Software Development\arduino\arduino-1.0.1-windows\arduino-1.0.1\libraries\AndroidAccessory/AndroidAccessory.h:50: error: ‘EP_RECORD’ has not been declared

    C:\Documents and Settings\Stuart.CLARK\My Documents0 Software Development\arduino\arduino-1.0.1-windows\arduino-1.0.1\libraries\AndroidAccessory/AndroidAccessory.h:64: error: ‘USB_NAK_LIMIT’ was not declared in this scope

    help please

    • Stuart Clark

      if i use the “original” usb host shield instead i get the following errors on compile

      C:\Documents and Settings\Stuart.CLARK\My Documents0 Software Development\arduino\arduino-1.0.1-windows\arduino-1.0.1\libraries\USB_Host_Shield\Max3421e.cpp: In static member function ‘static void MAX3421E::setRST(uint8_t)’:

      C:\Documents and Settings\Stuart.CLARK\My Documents0 Software Development\arduino\arduino-1.0.1-windows\arduino-1.0.1\libraries\USB_Host_Shield\Max3421e.cpp:58: error: ‘PORTJ’ was not declared in this scope

      C:\Documents and Settings\Stuart.CLARK\My Documents0 Software Development\arduino\arduino-1.0.1-windows\arduino-1.0.1\libraries\USB_Host_Shield\Max3421e.cpp:58: error: ‘PJ2’ was not declared in this scope

      C:\Documents and Settings\Stuart.CLARK\My Documents0 Software Development\arduino\arduino-1.0.1-windows\arduino-1.0.1\libraries\USB_Host_Shield\Max3421e.cpp:60: error: ‘PORTJ’ was not declared in this scope

      C:\Documents and Settings\Stuart.CLARK\My Documents0 Software Development\arduino\arduino-1.0.1-windows\arduino-1.0.1\libraries\USB_Host_Shield\Max3421e.cpp:60: error: ‘PJ2’ was not declared in this scope

      C:\Documents and Settings\Stuart.CLARK\My Documents0 Software Development\arduino\arduino-1.0.1-windows\arduino-1.0.1\libraries\USB_Host_Shield\Max3421e.cpp: In static member function ‘static uint8_t MAX3421E::readINT()’:

      C:\Documents and Settings\Stuart.CLARK\My Documents0 Software Development\arduino\arduino-1.0.1-windows\arduino-1.0.1\libraries\USB_Host_Shield\Max3421e.cpp:65: error: ‘PINE’ was not declared in this scope

      C:\Documents and Settings\Stuart.CLARK\My Documents0 Software Development\arduino\arduino-1.0.1-windows\arduino-1.0.1\libraries\USB_Host_Shield\Max3421e.cpp:65: error: ‘PE6’ was not declared in this scope

      C:\Documents and Settings\Stuart.CLARK\My Documents0 Software Development\arduino\arduino-1.0.1-windows\arduino-1.0.1\libraries\USB_Host_Shield\Max3421e.cpp: In static member function ‘static void MAX3421E::pinInit()’:

      C:\Documents and Settings\Stuart.CLARK\My Documents0 Software Development\arduino\arduino-1.0.1-windows\arduino-1.0.1\libraries\USB_Host_Shield\Max3421e.cpp:77: error: ‘DDRE’ was not declared in this scope

      C:\Documents and Settings\Stuart.CLARK\My Documents0 Software Development\arduino\arduino-1.0.1-windows\arduino-1.0.1\libraries\USB_Host_Shield\Max3421e.cpp:77: error: ‘PE6’ was not declared in this scope

      C:\Documents and Settings\Stuart.CLARK\My Documents0 Software Development\arduino\arduino-1.0.1-windows\arduino-1.0.1\libraries\USB_Host_Shield\Max3421e.cpp:78: error: ‘DDRJ’ was not declared in this scope

      C:\Documents and Settings\Stuart.CLARK\My Documents0 Software Development\arduino\arduino-1.0.1-windows\arduino-1.0.1\libraries\USB_Host_Shield\Max3421e.cpp:78: error: ‘PJ2’ was not declared in this scope

    • Stuart Clark

      note i am using ADK_release_20120606 for

      AndroidAccessory.h and .cpp

      the “original” USB_Host_Shield is from here also

    • Stuart Clark

      EP_RECORD appears to be missing from Usb.h, someone from stackoverflow suggested adding

      typedef struct {
      byte epAddr;
      byte Attr;
      unsigned int MaxPktSize;
      byte Interval;
      byte sndToggle;
      byte rcvToggle;
      } EP_RECORD;

      is this correct ???

    • It doesn’t look like you are using the newest version of the USB Host library, but the version hosted by Google which is just a modified version of the old version.

      Simply just download the newest verison of the library: https://github.com/felis/USB_Host_Shield_2.0 and follow these instructions on how to add the library: https://github.com/felis/USB_Host_Shield_2.0#how-to-include-the-library.

      After you have installed the library, then see the following example: https://github.com/felis/USB_Host_Shield_2.0/blob/master/examples/adk/ArduinoBlinkLED/ArduinoBlinkLED.ino – that should get you started 🙂

  • Stuart Clark

    add the missing EP_RECORD typdef and then got a bunch of AndroidAccessory.cpp compile errors. Obviously not compatible, is there an updated version of AndroidAccessory is should be using

  • Vanessa

    Hi Oleg,

    I tried the acm_terminal example with a CDC-ACM device. It seems to work because I don’t receive any errors and see “ACM configured” printed out at the end. But from what I understand, since the acm_terminal example was successful, then the device I am using should be enumerated but I don’t think it is. The device I am using should send a signal once it’s enumerated and this is not happening. Do you know what could be going wrong in the enumeration process even though I receive a successful “ACM configured” message?

    • After “ACM configured” you should see data coming from device – if said device is sending something. If you have access to serial side of the converter, short TX and RX together and then type something in the terminal, the characters you’re typing should echo back to the screen.

  • Jeff

    Oleg,
    Just started coding again after long absence and just picked up USB Shield for Arduino UNO and am testing with Logitech Gamepad. Ran the HID Joystick code in library examples and the hardware is working fine.

    It’s been a long time since working with C++, so am trying to figure out a way to access the GamePadEventData. I tried calling JoystickEvents::OnGamePadChanged and passing in a pointer to a GamePadEventData variable, but obviously since I don’t know if the data has changed, or is available from the device that will not work. Was looking for a high level function I could call and check for changed data, but could not find one.

    I saw some PS3 examples where there were functions to test for changed data, then you could use a function to read the joystick or button values. That is what I am ultimately trying to develop. Since this is an HID device, which could be pretty generic, do I need to write my own routines to accomplish this? I see in your code example where you check the buffer for a change, and then call the various event handlers, so I guess my ultimate question is do I need to emulate the bulk of this code on my own to get usable data out?

    I have a degree in Computer Engineering, so I feel really dumb right now not being able to figure this out. My C++ knowledge has evaporated with age it seems.

    Thanks for your help.

    Jeff

  • Jeff

    Oleg,
    Stepped away from the computer to take a break and clear my head. Think I figured this out. If I add a boolean flag variable to the JoystickReportParser class, then when the Parse function is called and the data has changed I can set the variable to True. I can also add a few member functions to the class, one that returns the state if the flag, and another JoystickValue function that can return the GamePadEventData structure values passed in by pointer. I could then reset the flag to False, so I don’t keep reading the same data within my main program.

    Will see how this works in a bit.

    Jeff

    BTW, I am inspired by the effort you have taken to support this code library. Great stuff. I am mentoring a USFirst.org FRC robotics team, and am having a lot of fun working with the high school students on this kind of fun programming. A lot different from the code I wrote while in the military.

  • Jeff

    Oleg,
    Thanks for the references. The approach I mentioned in earlier comment works just fine. The only minor glitch I found is if I stop moving the joystick then the JoystickEvents::OnGamePadChanged function does not get called and motion of my driven servo stops. As long as the joystick is changing values, things move just fine. So I thought about storing old joystick values to use when new data is not present. Trying this required me to determine and/or monitor polling frequency to calculate a time basis for desired rate of servo movement over time. Seeing your code from the Poll() function shed some light on a better way to try and implement smooth motion.

    Thanks again for all of your help,

    Jeff

  • Henrique

    Hi, i’m using a Samsung Galaxy S4 and my arduino mega adk did not recognize the device, but some weeks ago, it recognized my Samsung Galaxy Ace.
    Any possible solutions?

  • Henrique

    Someone have some example about how i send data from arduino to android, and read it on android.

  • Ben

    Is there any way to shrink the code size of the Wiimote code to fit on a 32Kb AVR like the Uno or the Leonardo? I don’t need things like hub support or any of the bluetooth profiles not supported by the Wiimote. This is one of the many times I’ve wished Atmel would release a chip with more than 32Kb flash in a small package… Mega1284P is probably going to be my best bet :/

  • Hello Oleg. I’m relative new using the Arduino Board and the USB-Shield. I’m using a Arduino Leonardo and the USB-Shield from circuits@home. I use it for reprogramming a Keyboardlayout. the programm function good. But when I plug the Arduino with the Keyboard in another PC it doesn’t function anymore. It should works as a Plug and Play. can you help me? Because with the old USB-Shield Library it function normally. I also wrote an art extention for a mouse function in the same programm but it doesn’t work like it should.
    Thank You for your answer.
    Carolina

  • Scott

    Hi Oleg,

    I’m using a generic medical device – I need to send it simple commands like FF 02 01 and FF 04 00.
    When I plug the device into the laptop, it presents itself as a COM (virtual serial port).
    I’ve been able to use the board_qc test and everything works fine on my USB host shield.

    What sketch in your library would you suggest that would enable me to send serial commands through a virtual port using your shield? Are there any modifications I would need to make to the code to get it to work with my specific device?

    Thank you so much.

    • There are 3 USB to serial converter types supported by the library: CDC ACM, FTDI, and Prolific PL2303. First type can be determined by class/subclass/protocol (same as Arduino UNO ), other two have unique VID/PID. Run USB_Desc and post output here – I’ll take a look.

      There are also other USB to serial converters which are not yet supported.

      • Scott

        Here’s the output of USB_desc

        Thanks for your help!

        01

        Device descriptor:
        Descriptor Length: 12
        Descriptor type: 01
        USB version: 0200
        Device class: 00
        Device Subclass: 00
        Device Protocol: 00
        Max.packet size: 08
        Vendor ID: 0403
        Product ID: 6001
        Revision ID: 0600
        Mfg.string index: 01
        Prod.string index: 02
        Serial number index: 03
        Number of conf.: 01

        Configuration descriptor:
        Total length: 0020
        Num.intf: 01
        Conf.value: 01
        Conf.string: 00
        Attr.: A0
        Max.pwr: 2D

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

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

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

        Addr:1(0.0.1)

  • Scott

    I got the FTDI example code to send a char [0xFF, 0x02, 0x01] to the medical device. It received the command and turned on. I can’t figure out how to send it a second command after a short delay in the program. I tried inputting a delay(500) and then copied and pasted the send code but it didn’t work. What aspects do I need to repeat, what can I erase?

    Thank you for helping so far, if I can get this working our company plans on buying 50-100 units of your shield in the next year or two so I hope it’s worth your time.

    • Scott

      I found a crude workaround. I can run the Ftdi.Release(); and then Usb.Init(); commands and when I go to send another command, it goes through correctly. There has got to be a simpler way to do this?

      Thanks

      • Scott

        This actually doesn’t work. I’m missing some key element to do that either clears the RX/TX lines or resets the board to send the 2nd command. If I hit reset on the arduino it will then send through the 2nd command. As if it was waiting in the buffer for some signal to push it through.

        Is there some function I need to use between issuing multiple commands? Is there a function that could simply reset everything?

        • You need to understand what your peripheral needs. Trying random things won’t help – there is too much to try.

          • Scott

            Thank you for your response. I’ve spent about 30 hours trying things, luckily I won’t waste anymore time.

            Using an executable that the company provided, I then monitored my serial port and found a sequence of events that the laptop sends to the device to operate it. Every command is prefaced with these events:
            COM is open

            Baud rate 9600

            RTS off

            DTR off

            Data bits=8, Stop bits=1, Parity=None

            Set chars: Eof=0x1A, Error=0x00, Break=0x00, Event=0x1A, Xon=0x11, Xoff=0x13

            Handflow: ControlHandShake=(), FlowReplace=(), XonLimit=1024, XoffLimit=1024

            Baud rate 9600

            RTS off

            DTR off

            Data bits=8, Stop bits=1, Parity=None

            Set chars: Eof=0x1A, Error=0x00, Break=0x00, Event=0x1A, Xon=0x11, Xoff=0x13

            Handflow: ControlHandShake=(), FlowReplace=(), XonLimit=1024, XoffLimit=1024

            DTR off

            Set timeouts: ReadInterval=-1, ReadTotalTimeoutMultiplier=-1, ReadTotalTimeoutConstant=30, WriteTotalTimeoutMultiplier=0, WriteTotalTimeoutConstant=10

            In/out queue size 4096/2048

            Purge the serial port: RXABORT, RXCLEAR

            Purge the serial port: TXABORT, TXCLEAR

            *Command is then sent in hex code*

            DTR off

            Purge the serial port: RXABORT, RXCLEAR

            Purge the serial port: TXABORT, TXCLEAR

            COM is closed

            Can I perform these same operations with your FTDI code? It looks like I just need to purge the RX and TX ports. Or should I be using the ‘set characters’ that it just shows?

  • Dan C

    Hi Oleg,
    I’ve been trying to use an ACM device to receive data from (its a Serial USB thermistor) and transmit that data to an Android tablet. I am unable to recognize both the ACM device and the android at once (through a powered Hub). Both are able to be recognized and communicated to individually, but not simultaneously.
    I setup the code like so:

    USB Usb;
    USBHub Hub1(&Usb);

    ACMAsyncOper AsyncOper;
    ACM Acm(&Usb, &AsyncOper);

    ADK adk(&Usb,”Example”,
    “Example”,
    “Example,
    “1.0”,
    “1.0”,
    “1.0”);

    If I list the acm device first, it reads that just fine and ignores the android
    If I list the ADK first, it connects to the android but ignores the ACM device.
    Any thoughts on what I am doing wrong?
    Thanks for ll your help!
    Dan

  • Dan C

    It is in fact a 7 port hub. However, using two Hub instances makes no difference..
    I switched to a 4 port hub and only one instance and still the same behavior.
    This sounds similar to the 2 mouse issue I saw some people were having in the comments…could it be related?
    Thanks again for your fast responses!

  • Krit

    Hello

    I bought the USB host shield for arduino a couple weeks ago, but I just started playing with it a couple days ago
    I have arduino uno r2.
    Somehow when I connected the usb host shield and arduino board together, then
    plugged in my Bluetooth device/ PS3 controller, my computer did not recognize the devices that connected through the usb host shield at all.
    I tried to run the sample codes from usb host shield library that I downloaded online, and they give me the same result whether I have the usb host shield
    connected to the arduino uno board or not.

    For example when I upload the example code “acm_terminal” with and without the usb host shield on, it didn’t give me any error.
    And when I upload the example code “PS3BT” with and without the usb host shield on, it gave me

    avrdude: stk500_paged_write(): (a) protocol error, expect=0x14, resp=0x64
    avrdude: stk500_cmd(): programmer is out of sync

    It didn’t give me any compiling error.
    Only gave me error when I tried to upload the codes.

    I don’t know how to fix this problem,
    Is it because that the shield not working or it doesn’t work with arduino uno r2?

    Thank you.
    Krit S.

    • Maybe you don’t have enough memory? Try to disable debug and see if it makes any difference.

      • Krit S.

        Thank you.
        That’s probably the reason.
        I borrowed my friend’s arduino uno r3 to test it out, and it works great.

        But I run into another problem.
        when I run PS3USB code, all the buttons work and also show on the serial monitor.
        But, when I tried to run PS3BT code and link the Bluetooth and PS3 controller together, everything works except L2 & R2.

        • Oliver

          Same here. I can’t get L2 R2 to work with bluetooth. Also the accelerometer does not work with bluetooth. These work ok with USB connection.

          • That is caused by your dongle not supporting EDR (Enhanced Data Rate). If it doesn’t support it, it won’t be able to read all the data from the PS3 controller.
            You will have to get another dongle, as it’s a hardware issue with the dongle.

  • Jono

    I am unable to get the USB host board to connect to my Arduino Mega 2560 R3 board. It does not get past the following code:

    Serial.begin(115200);
    while (!Serial);
    if (Usb.Init() == -1) {
    Serial.print(F(“\r\nOSC did not start”));
    while (1); //halt
    }

    I always get the OSC did not start message.

    I am using the XBOXRECV tutorial code to connect and Xbox 360 wireless controller to a wireless receiver. I am powering it with an external power supply and it works just fine on an Arduino UNO R3 board.

    Thanks for any help.

    Jono

  • Jono

    The Sparkfun DEV-09947 USB Host Shield

    • As-s, it won’t work on Mega. You need to bring in SPI signals.

      • Jono

        Thank you for the quick reply. The SPI signals on the Mega appear to be: D50:MISO D51:MOSI D52:SCK D53:SS I will jumper them to D12, D11, D13 and D10 respectively on the USB Host Shield and see if I can get it to work.

  • manitou

    I hooked up logic analyzer to SPI pins (mega2560) with a USB mouse. As expected SPI clock was 8mhz. I see lots of 4 byte SPI events with 37.3 us between events. And about every 10.2 ms there is a more complex SPI sequence, poll request? I figured I’d just see SPI activty every 10ms. I was surpised at the higher rate of SPI events (NAKs?).

    • MAX3421E gets polled by several processes. 37us is likely the turnaround time of loop(), from which Usb.Task() is called. If you’re curious, run UsbTask() every millisecond or so, you’ll likely see traffic every millisecond or so. To see what it does look at the source code.

  • Filipe Jorge

    Hi,
    Is there any example that can send for example {0x33 0x44} to a specific endpoint?
    I’ve looked into the github examples and i didnt found anything that would do that. Also i´ve looked into the max3421e library to see that such functions exist in a similar way.
    Im asking for this because i want to send instructions to another device that uses usb without using a pc.
    Cheers

    • In USB, you can’t send random data to random endpoints. The device first needs to be initialized and initialization depends on the device type. Once this is done, the device class provides SndData() and RcvData() methods which can be used.

      • Filipe Jorge

        I understand how USB works, perhaps i didnt explain well what i wanted to ask.
        I already have a program in windows that communicates to a device through usb, i know that to communicate you need the vid, pid, the endpoints to write on the host and device and their length, etc…
        I wanted to ask if there was an example that could provide me some light on how to utilize the libraries available for any type of device. For example, ill show you some of the code i used on windows to send data to a usb device:

        uint8_t answear[5]; //answear from device
        uint8_t comando_on0[2]={0x04, 0x66}; //A1 ON
        uint8_t comando_on1[2]={0x06, 0x62}; //A1 ON
        uint8_t OK[1]={0x00}; //OK for transmission

        uint8_t endpoint;
        int length;
        int actual_length;
        int r;

        memset(answear, 0, sizeof(answear));
        length=2;
        endpoint = 0x02; //From Host to Device
        r=libusb_interrupt_transfer(CM15_handle, endpoint, (unsigned char*)&comando_on0, length, &actual_length, 1000);

        length=5;
        endpoint = 0x81; //From Device to Host
        r=libusb_interrupt_transfer(CM15_handle, endpoint, (unsigned char*)&answear, length, &actual_length, 1000);
        /*****************************************************************************************/

        //Send OK for transmission
        r=libusb_interrupt_transfer(CM15_handle, 0x02, (unsigned char*)&OK, 1, &actual_length, 1000);

        //Should receive 0x55 Interface ready.
        memset(answear, 0, sizeof(answear));
        r=libusb_interrupt_transfer(CM15_handle, 0x81, (unsigned char*)&answear, 5, &actual_length, 1000);

        length=2;
        endpoint = 0x02; //From Host to Device
        r=libusb_interrupt_transfer(CM15_handle, endpoint, (unsigned char*)&comando_on1, length, &actual_length, 1000);

        printf(“\n\n—>Equipment ON…\n”);

        Sry for my english

  • Ray Cho

    Hi
    I’m using arduino uno with usb host shield 2.0.
    I try to connect one keyboard and one mouse to the shiled one by one.
    The keyboard work fine when I try to use the code “USBHIDBootKbdAndMouse”, but the six button can’t(No any output on serial Monitor).
    On the other hand, I try to connect these through a usb hub,I combine the code “hub_demo” and “USBHIDBootKbdAndMouse”. The serial monitor seem detect the hub only.

    What I have missed?
    *************************
    Start

    41

    Device descriptor:
    Descriptor Length: 12
    Descriptor type: 01
    USB version: 0200
    Device class: 09
    Device Subclass: 00
    Device Protocol: 00
    Max.packet size: 40
    Vendor ID: 1A40
    Product ID: 0101
    Revision ID: 0111
    Mfg.string index: 00
    Prod.string index: 01
    Serial number index: 00
    Number of conf.: 01

    Configuration descriptor:
    Total length: 0019
    Num.intf: 01
    Conf.value: 01
    Conf.string: 00
    Attr.: E0
    Max.pwr: 32

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

    Endpoint descriptor:
    Endpoint address: 81
    Attr.: 03
    Max.pkt size: 0001
    Polling interval: FF

    Addr:41(1.0.1)

    *************************

  • Ray Cho

    Just to say thank you

  • Peter O

    Hello
    I have a hard time making the USB Host Shield run with my Arduino (both Mini). USB seems to be properly initialized, but the task loop remains in “USB_DETACHED_SUBSTATE_WAIT_FOR_DEVICE” no matter if the board comes up with a device plugged in or the device is plugged in after power-up. I use an additional power source to support the board and tried a BT adapter, a mouse and a keyboard.

    Any help is greatly appreciated.
    Thanks!
    Peter

      • Peter O

        Thanks for your reply, Oleg. I have an Arduino Mini 3,3V. My USB Mini Shield has the following pins soldered to the Arduino: 9,10,11,12,13, VCC, GND, RAW, RST. The label on BT Adapter says “GBU521”. The additional power source is a regulated lab power adapter with up to 1.5A which I’ve set to 5V and connected to the RAW pin. USB library is on commit b82835c877adecf507312b742dd687e2ea03628f, which should be the most recent.

      • Peter O

        I tried it with an Itead USB Host Shield and an Arduino Mega 2560. Most recent USB Library from git on master branch. The same effect – he stays in USB_DETACHED_SUBSTATE_WAIT_FOR_DEVICE.

  • Fabian Kluge

    Hello, im trying to get an USB HUB working with Arduino MEGA ADK board, but with the HUB_demo i only get back the HUB itself. Is there anythink special needed for ADK Board? Maybe some change in one of the library? The devices i want to connect via HUB work fine with the board itself(barcodescanner & multimeter). Thanks a lot!
    Fabian

  • Mr S

    Just wondering if anyone else had run into compilation issues with the FTDI example.

    Using a completely stock install of Arduino 1.5.7 on Win 8, building for an Atmega 2560 I get the following error on the unmodified example.

    USBFTDILoopback.ino:37:18: error: cannot declare variable ‘FtdiAsync’ to be of abstract type ‘FTDIAsync’
    USBFTDILoopback.ino:10:7: note: because the following virtual functions are pure within ‘FTDIAsync’:
    In file included from USBFTDILoopback.ino:1:0:
    C:\Program Files (x86)\Arduino\libraries\USB_Host_Shield_20/cdcftdi.h:82:25: note: virtual uint8_t FTDIAsyncOper::OnRelease(FTDI*)
    virtual uint8_t OnRelease(FTDI *pftdi) = 0;
    ^

  • db

    Hi there!

    This might be an incredibly stupid question (I have just recently started to work with Arduino, and programming as well), but I couldn’t find a solution anywhere.

    Using the 1.0.6 IDE, whenever I include:

    #include
    #include
    #include

    #define DEVADDR 1
    #define CONFVALUE 1

    void setup();
    void loop();

    MAX3421E Max;
    USB Usb;

    I get the error message:

    Arduino: 1.0.6 (Mac OS X), Board: “Arduino Uno”
    /Users/………../Downloads/Arduino 1.0.6.app/Contents/Resources/Java/hardware/tools/avr/bin/avr-g++ -c -g -Os -Wall -fno-exceptions -ffunction-sections -fdata-sections -mmcu=atmega328p -DF_CPU=16000000L -MMD -DUSB_VID=null -DUSB_PID=null -DARDUINO=106 -I/Users/…………./Downloads/Arduino 1.0.6.app/Contents/Resources/Java/hardware/arduino/cores/arduino -I/Users/…………/Downloads/Arduino 1.0.6.app/Contents/Resources/Java/hardware/arduino/variants/standard -I/Users/………../Downloads/Arduino 1.0.6.app/Contents/Resources/Java/libraries/SPI -I/Users/………./Documents/Arduino/libraries/USB_Host_Shield_20 /var/folders/b7/djs_vvh14bzcgtjccyyz9_340000gn/T/build2772892455749070897.tmp/sketch_oct16b.cpp -o /var/folders/b7/djs_vvh14bzcgtjccyyz9_340000gn/T/build2772892455749070897.tmp/sketch_oct16b.cpp.o
    In file included from sketch_oct16b.ino:3:
    /Users/…………./Documents/Arduino/libraries/USB_Host_Shield_20/max3421e.h:18:2: error: #error “Never include max3421e.h directly; include Usb.h instead”

    And even when I do include usb.h instead of max3421.h, it gives me the same error screen (aside from the last line). What should I do?

    • xl97

      Hi DB-

      I see nobody answered your question.. did you ever figure out why this is happening?

      I just got my shields.. and downloaded/installed the USB 2.0 lib.. and getting the same errors..

      (“Never include max3421e.h directly; include Usb.h instead”)…..

      This error was received when I tried a board_test.ino sketch to test that the board was connected correctly. (havent been able to move past this.. even a google search on the error didnt return anything useful) 🙁

  • Gary Malolepsy

    I have the USB shield and Arduino Mega working with a missile launcher. If I insert a USB hub between the USB shield and the launcher, the commands are sent but the launcher does not respond. I assume some USB hub code must be added but can find no examples. I assume usbhub.h must be included and some usb addressing code must be added, but what and where? Please help, thank you. ……. Gary

      • Gary Malolepsy

        I am using a sketch that uses the MissileLaunch library. Both call USB.h The sketch calls the USB Init via the MissileLaunch library. So do I modify the sketch or library or both? All of this code was copied from GitHub. The reason to use a hub is to add a USB game controller (joystick) to control the launcher instead of the serial input. I don’t understand how the hub instance that you presented can be applied to missile launcher code. It is probably simple once one knows how but I don’t see it.
        Thanks again……. Gary

        • Gary

          I tried the hub_demo example. It worked but only displayed the descriptors for the hub, not for the launcher device plugged into the hub. I noticed a “stop” in the loop code. When the stop was deleted, the descriptors are displayed forever but after the first 4 hub descriptor sets the launcher descriptors were printed. I put in a counter to allow the loop to run 5 times and then stop. Then the launcher descriptors are seen after the 4 hub descriptor sets are displayed.
          Not sure why. Now to get the launcher code to work with the hub?!?!…. Gary

          • Hub demo won’t do anything meaningful to the devices attached to the hub. AFAIK the missile launcher is a HID device, you may have better luck with HID examples.

  • Gary Malolepsy

    It works. I needed to run hub_demo to learn the USB address for the launcher. That address is used in the USB command packet.
    Both the missile library and the sketch need to be modified. I rewrote the sketch without using the library that now works the launcher through the USB hub. Here is the code:
    //
    // USB Missile Launcher
    //

    #include

    enum MissileLauncherActions
    {
    DOWN = 1, /*!< down */
    UP = 2, /*!< up */
    LEFT = 4, /*!< left */
    RIGHT = 8, /*!< right */
    FIRE = 16, /*!< fire */
    STOP = 32 /*!< Stop */
    };

    uint8_t addr;
    uint8_t endPoint;
    uint8_t bmReqType;
    uint8_t bRequest;
    uint8_t wValLo;
    uint8_t wValHi;
    uint16_t wInd;
    uint16_t total;

    USB Usb;
    USBHub Hub(&Usb);

    uint32_t next_time;

    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
    Serial.println("Start");
    if (Usb.Init() == -1)
    Serial.println("OSC did not start.");
    delay( 200 );
    next_time = millis() + 5000;

    Serial.println(F("Device Running. The following are the commands available"));
    Serial.println(F("L – Turn Left"));
    Serial.println(F("R – Turn Right"));
    Serial.println(F("U – Turn Up"));
    Serial.println(F("D – Turn Down"));
    Serial.println(F("F – Fire Missiles"));
    Serial.println(F("S – Stop"));

    delay(200);

    addr = 9; // Todo need to change it if connected through a USB Hub
    endPoint = 0;
    bmReqType = 0x21;
    bRequest = 0x09;
    wValLo = 0x00;
    wValHi = 0x02;
    wInd = 0;
    total = 1;
    }

    void loop()
    {
    char input = 0;

    Usb.Task();

    if (Serial.available())
    {
    input = Serial.read();

    switch (input)
    {
    case 'L':
    case 'l':
    Serial.println(F("Moving Left"));
    issueCommand(LEFT);
    break;

    case 'R':
    case 'r':
    Serial.println(F("Moving Right"));
    issueCommand(RIGHT);
    break;

    case 'U':
    case 'u':
    Serial.println(F("Moving Up"));
    issueCommand(UP);
    break;

    case 'D':
    case 'd':
    Serial.println(F("Moving Down"));
    issueCommand(DOWN);
    break;

    case 'F':
    case 'f':
    Serial.println(F("Fire. Hide your self ;)"));
    issueCommand(FIRE);
    break;

    case 'S':
    case 's':
    Serial.println(F("Stopping"));
    issueCommand(STOP);
    break;

    default:
    Serial.println(F("Sorry, I didn't understand your command"));
    }
    }
    }

    void issueCommand(byte action)
    {
    byte data[1] = {action};

    Usb.ctrlReq(addr, endPoint, bmReqType, bRequest, wValLo, wValHi, wInd, total, sizeof(data)/sizeof(byte), data, NULL);
    }

  • Gary Malolepsy

    The missing include is usbhub.h with left/right brackets around it which for some reason was deleted.

  • Igan

    Hi Oleg,
    Im trying to connect an Arduino UNO and an Arduino USB Host Shield(Sparkfun) to a Xenon 1900 barcode scanner using the usb host shield library version 2.0. With the “acm_terminal” example the barcode scanner turns on and prints the correct info to the Serial Monitor, but after a few succesful reads the scanner turns off, and the only way to make it work again is to restart the arduino. Sometimes it goes off after being in stand-by for a while too.

    I followed a tutorial from this website:
    http://www.electroingenio.com/arduino-en/bar-code-scanner-arduino-usb-shield-2/

    I can make it work using that code but i get the same problem.
    They mention that the Class, Subclass and Protocol are relevant, and they should be:

    Intf. Class: 03
    Intf. Subclass: 01
    Intf. Protocol: 01

    But the “USB_desc” code shows that the Xenon 1900 cofiguration is:

    Intf. Class: 03
    Intf. Subclass: 00
    Intf. Protocol: 00

    Could that be the problem? And if it is, is there a way to fix it?

    PS: The Xenon 1900 can be configured as HID keyboard, HID POS, and USB Serial. All the example codes work with the correct barcode configuration but the scanner turns off with all of them after a few succesful reads.

  • Daniel

    Hello,

    I’m using Arduino Mega 2560 in Linux.
    I’m testing the code sample provided but I cant’t get show all usb connected to the hub(I connected 2 pendrives in FAT32). I get the impression that displays only information hub or is giving error.

    This is the output:

    Start

    41
    --

    Device descriptor:
    Descriptor Length: 12
    Descriptor type: 01
    USB version: 0200
    Device class: 09
    Device Subclass: 00
    Device Protocol: 00
    Max.packet size: 40
    Vendor ID: 05E3
    Product ID: 0608
    Revision ID: 8536
    Mfg.string index: 00
    Prod.string index: 01
    Serial number index: 00
    Number of conf.: 01

    Configuration descriptor:
    Total length: 0019
    Num.intf: 01
    Conf.value: 01
    Conf.string: 00
    Attr.: E0
    Max.pwr: 32

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

    Endpoint descriptor:
    Endpoint address: 81
    Attr.: 03
    Max.pkt size: 0001
    Polling interval: FF

    Addr:41(1.0.1)

    I tried to connect the hub to pc and this works well. Detects the two pendrives.

    Thank you very much.

    • Daniel

      I tried it with another hub and the result is the same. Only changue the Revision ID, it is: 0702

      • Daniel

        I’ve gotten it to work. I simply commented the stop line, it seems needed more time to start, although I tried to increase the time by 20 seconds and neither worked me.

        Thank you very much ^_^

  • OSOGOE

    Hello Oleg,

    I could make USB-Serial device to receive but not transmit.

    Setup: Arduino UNO R3
    USB Host Shield 2.0(rev2.0.1 11 MAY 2013) arrived in this April
    Powered externally
    Arduino IDE 1.6.0 on Windows XP
    Library: USB_Host_Shield_2.0-master.zip downloaded on Mar. 27, 2015

    ————————————————-
    Output of board_qc:
    Circuits At Home 2011
    USB Host Shield Quality Control Routine
    Reading REVISION register… Die revision 03
    SPI long test. Transfers 1MB of data. Each dot is 64K……………. SPI long test passed
    PLL test. 100 chip resets will be performed
    Resetting oscillator
    Reset number 0 Time to stabilize – 495 cycles
    Reset number 1 Time to stabilize – 495 cycles
    Reset number 2 Time to stabilize – 495 cycles

    … snip …

    Reset number 97 Time to stabilize – 494 cycles
    Reset number 98 Time to stabilize – 493 cycles
    Reset number 99 Time to stabilize – 494 cycles

    Checking USB device communication.

    Reset complete. Waiting for the first SOF…
    Getting device descriptor
    Descriptor Length: 12
    Descriptor type: 01
    USB version: 0110
    Device class: 00
    Device Subclass: 00
    Device Protocol: 00
    Max.packet size: 40
    Vendor ID: 067B
    Product ID: 2303
    Revision ID: 0300
    Mfg.string index: 01
    Prod.string index: 02
    Serial number index: 00
    Number of conf.: 01

    All tests passed. Press RESET to restart test

    Application: pl2303_gprs_terminal
    In this applicaition, Pl.SndData() returns 0, but nothing is sent out, while Pl.RcvData() function as expected.

    The above is for PL2303 device.
    ————————————————-
    Then I tried another one of ftdi, and the result is as following.
    For this FTFI, neither transmit nor receive works.

    Output of board_qc:
    Circuits At Home 2011
    USB Host Shield Quality Control Routine
    Reading REVISION register… Die revision 03
    SPI long test. Transfers 1MB of data. Each dot is 64K……………. SPI long test passed
    PLL test. 100 chip resets will be performed
    Resetting oscillator

    Reset number 0 Time to stabilize – 495 cycles
    Reset number 1 Time to stabilize – 495 cycles
    Reset number 2 Time to stabilize – 495 cycles

    … snip …

    Reset number 97 Time to stabilize – 494 cycles
    Reset number 98 Time to stabilize – 493 cycles
    Reset number 99 Time to stabilize – 494 cycles
    Checking USB device communication.

    Reset complete. Waiting for the first SOF…
    Getting device descriptor
    Descriptor Length: 12
    Descriptor type: 01
    USB version: 0200
    Device class: 00
    Device Subclass: 00
    Device Protocol: 00
    Max.packet size: 08
    Vendor ID: 0403
    Product ID: 6015
    Revision ID: 1000
    Mfg.string index: 01
    Prod.string index: 02
    Serial number index: 03
    Number of conf.: 01

    All tests passed. Press RESET to restart test

    Application: ftdi_terminal which is modified from USBFTDILoopback.
    In this applicaition, Ftdi.SndData() returns 13, and Ftdi.RcvData() never returns other than 0.

    ————————————————-

    Well, what should I do next?

  • OSOGOE

    Thank you for a quick reply.
    No, it does not work. Only a dot repeats.
    Regards,

    • Just to clarify:


      uint8_t data = 'A';
      rcode = Pl.SndData(1, &data);

      should send out character ‘A’. Same for FTDI. After successful completion ‘data’ will contain number of bytes sent, one in this case. The function will return 0 if all was good.

  • OSOGOE

    I apply the code below to USBFTDILoopback.ino. By the way, Ftdi.SndData() instead of Pl.SndData().
    Result is same. And rcode return 13 again.

    uint8_t data = ‘A’;
    rcode = Pl.SndData(1, &data);

    I don’t bother trying anything you suggest, so please help.

  • OSOGOE

    The chip on the device is FT234X.
    Regards,

    • the driver was written for FT232, the chip you’re using may need different treatment. The rcode means the device didn’t recognize that you were sending data to it.

  • OSOGOE

    I understand the situation that FT234X might be different from FT232.

    If I look into the library, where to start regarding return code 13?

    Well, what to do about PL2303?
    The Pl.SndData() returns 0, but nothing is sent out.

  • OSOGOE

    The chip on the other one is PL2303HX.

  • OSOGOE

    So, I dig out a module which has FT232RL, and it works.
    Also, is it a problem that the chip is PL2303HX?

  • Roy Wood

    Using the USBFTDILoopback example with my usb device. Everything works fine until I need to send multiple commands. If I duplicate the loop code multiple times within the loop function everything works fine with a unique command sent in each duplicated section. As soon as I move the code out of the loop to another function, and just call that function from the loop, then the results are not repeatable at all. I have made sure the timing is identical.

    The code is identical when it is inside the main loop, or in another void function which is just called from the main loop.

    Thoughts?

  • xl97

    I recently got my USB Host Mini Shields in the mail.
    I am planning on using them with a +3.3v Pro Micro (Not Pro Mini).. which has almost the same pinout as the Pro Mini (minus the RESET pin in the same location)
    I have made my mod for getting +5v to the VBUS.
    I have made my mod getting the RESET pin connected to the RESET pin on the Pro Micro
    http://dmstudios.net/misc/Pro-Micro_USB-Host/jumper_2.jpg

    I am having trouble getting any sort of TEST sketch going to see if the USB Host Mini Shield is communicating/connected with the Pro Micro correctly.

    Is there a specific BOARD_TEST.ino file to use? (official?)

    I found one while searching.. but dont know if its old or even valid?

    When I tried to upload the sketch.. I got all sorts of errors.. (saying I didnt need to include the MAX3421e lib directly.. only Usb.h…etc)…

    after commenting out those lines.. I then got SPI errors?.. Spi include vs SPI include? Corrected case-sensitive and still errors.. is it because the Pro Micro uses different pins for its SPI bus or something?

    The board_qc, looks to be for the teensy?

    I guess my questions are:

    1.) Is there a default test sketch that is current and working with the Pro Micro? If yes.. can I have a link please?
    2.) Where you get the board_test.h file from? Seems like the board_test sketch wants it? And where do you place it once you have it?

    I am using IDE v 1.6.4 for this.. I have all my libraries in my documents >> Arduino >> libraries (directory)

    3.) What is the correct path/structure for all these required files (just to get a simple test going?)
    USB Host lib?
    SPI lib?
    Board_test.h file? placement?

    Hopefully this place still gets traffic.. seems like Oleg answers random questions/posts?

    thanks!

  • xl97

    (seems we can not edit our comments??) 🙁

    Anyways.. here is where I got the board_test sketch from.. (seems to be old?)
    https://github.com/felis/USB_Host_Shield/tree/master/examples/board_test

    As is.. it throws TONS of errors..

    (“Never include max3421e.h directly; include Usb.h instead”)….etc

    Is there an updated or at least working board_test file for beginners to use?

    Where do you place the board_test.h file at?

    I get errors (like above)..

    as well as errors about SPI (I’m using a Pro Micro)
    &
    board_test.h…etc

    why would those libs be included in the sketch if they were needed? (per the error message)??

  • xl97

    https://github.com/felis/USB_Host_Shield_2.0

    I do not see a board_test.h/.ino files at that link? Is it in a sub-directory?

    I am using the correct USB Host Shield library though…

    My Documents >> Arduino >> libraries >>USB_Host_Shield_2.0

    which has a bunch of .cpp/.h files.. the examples directory…

    (and some other odd files… .json, .properties, ..etc)

    So this is the current (for 2.0, not 3.0) library to use…correct?

    I guess I’m still not clear on what test a noob should be running?

    The you link you gave has a ton of files posted…. I see nothing board_test related???

    I found this before:
    board_qc.ino

    but seems to be specific for the Teensy..

    #include
    #include // Hack to use the SPI library
    #include // Hack to use the SPI library

    (not sure why the last line is a hack?.. I seem to be having SPI errors as well)

    can you please more specific about what sketch/file we are to use for initial board testing?

    A link is too general when there are not the same files mentioned in the post….

    Thanks

  • xl97

    I ran the board_qc.info file…
    (commented out the two teensy specific lines.. not sure if that is what we are supposed to do? I didnt see any comments/documentation about that?)

    It uploads.. I go to serial monitor to view any output:

    I get Circuits @ Home: 2011
    USB Host Shield Quality Control Routine
    Reading Revision Register: Die Revision invalid Value Returned: 00
    Unrecoverable error: test halted!
    0x55 pattern is transmitted via SPI
    Press RESET to restart test

    (Also when I hit REST on the Pro Micro.. nothing happens, as far as blinkies or anything to indicate its been reset? maybe thats normal for this board?)

    At least I’m further than I was last night/a little bit ago..

    thanks!

    • The test expects certain revision numbers from the chip and prints an error when it gets something other than the valid number. It could mean anything; in short, shield is not talking to the Arduino.

  • xl97

    Hi Oleg-

    I believe this is an SPI problem with the Pro Micro..

    How can you re-define the SS pin to be used?

    The Pro Micro doesnt have the SS pin broken out to an I/O…

    Can I turn this on as an OUTPUT (or something?) and then re-define/use another pin for this?

    Thanks!

  • xl97

    ok.. well I need to assign the SS pin to a NEW pin instead of the default/hardware pin #17… where it that done in your library?

    Do you have any plans to support the Arduino Pro Micro?

    I saw others posts (which I linked to before)

    https://forum.sparkfun.com/viewtopic.php?f=32&t=34873#p156711

    where people had made edits to the AVR pins declaration… (but the post was years old).. Does your library include this now? (I’m guessing no, since you say you are not familiar with the Pro Micro)?

    Or do I need to do this still?

    (These are question related to your library)