Shopping Cart


Teensy 3.0 now supported by the USB Host library

Layout of the Teensy 3.0

Layout of the Teensy 3.0

I am pleased to announce that the first ARM processor is now supported by the USB Host library. It is the Teensy 3.0 which features an 32 bit Cortex-M4 ARM processor running at up to 96MHz. This is a huge increase in speed if you are used to the Arduino Uno running at 16MHz.
The Teensy 3.0 is created by the Paul Stoffregen which is also a dedicated contributor to the Arduino IDE. If you are looking for a ARM based board for your next project, I recommend taking a look at the Teensy 3.0. A more detailed overview can be found at the official page.

To use the Teensy 3.0 with the library I recommend using the Mini variant of the USB Host Shield as it is much more compact and a bit cheaper too. Since the Teensy 3.0 is running at 3.3V no logic conversion is needed.
Note it is very important than you do not connect a 5V microcontroller to the Mini variant of the USB Host Shield, as this might damage the board. If you are planning to use a 5V microcontroller like the Arduino Uno I recommend getting the full sized version of the shield.

In order to use the Teensy 3.0 you will need to connect the Teensy 3.0 to the USB Host shield like so:

USB Host Shield Teensy 3.0
SS 10
SCK 13
3.3V 3.3V

The images to the right shows both the pinout for the Teensy 3.0 as well as the Mini USB Host Shield.

Layout of the USB Host Shield Mini variant

Layout of the USB Host Shield Mini variant

Furthermore I recommend cutting the VBUS jumper and then soldering a wire from the provided pad on the USB Host shield. This wire can then be connected to the VIN on the Teensy 3.0. The USB Host shield will then get powered directly from the same USB port as the Teensy 3.0 and the VBUS will be 5V as required by most devices – note that you might need a separate 5V regulator depending on which device you are using with the shield, as it might draw too much current.
More information about how to modify the shield can be found at the hardware manual.

Also take a look at the guide for the other Teensy boards, as the wiring is almost the identical.

Hopefully this is just the first of many ARM based boards that is going to be supported by the USB Host shield library.
If you got any questions or comments, then feel free to write a comment below and I will answer as fast as possible.

Both the Teensy 3.1 and Arduino Due is now also supported by the library.

No related posts.

37 comments to Teensy 3.0 now supported by the USB Host library

  • This is fantastic! I actually needed this for a project of my own and was looking into converting the libraries a couple weeks before this came together, but was a bit discouraged by the sheer volume of code.

  • Adapter board design is done. It works for me, and a DYI version will be published on this thread.

  • Is there a way to change the interrupt and SS pins?

  • Note that things work even faster when using spi4teensy3, written by me.
    SPI runs at the fastest speed that the max chip can take, and no longer becomes the bottleneck. It is available
    With good media attached (I tested A Lexor 2GB Premium 80x CF), you can get some really nice speeds.

  • Chris

    Is it possible to use the Mini USB Host Shield with an Arduino Uno? My Arduino Pro Micro fizzled out on me and I want to try using the shield with my Uno. Is it possible?

    • No. You need to level shift all logic signals or use full-size shield.

      • Chris

        Since a couple level shifters are a bit cheaper than a full shield, I think I’ll give it a shot. I just want to confirm all the channels that will need to be shifted. MOSI, MISO, SCK, SS(10), INT(9), correct? I’d power the board with the 3.3V pin, connect RAW to the 5V in case my VBUS needs 5V for a device, and obviously connect grounds. Does that sound right? Is there anything else that I will need to ensure compatibility?

        Thanks for your help.

        • Take a look at the schematic for the full size shield: There you can see what needs to be level shiftet. Anyway reset needs to be level shiftet as well.

          • Chris

            Ok. So I level shifted pins 9 through 13 and the “reset” pin from my arduino uno down to 3.3V and connected them to the usb host shield mini.

            The usb host mini only uses pins 9, 10, SCK, MISO, MOSI, and reset correct?
            Are any of the remaining through-holes on the perimeter necessary?

            Also, do i connect the “reset” pin on my uno to the “reset” pin on the usb host shield mini?

          • Yes both reset pins should be connected together via the level shifter ;)

          • Chris

            When I connect the reset pins via the level shifter, the arduino uno behaves as if the reset button on the board is continuously held down. the “L” LED is constant yellow and the board cannot be reset via the button. What might be going wrong? the board resets as soon as i disconnect the pins.

            I’m using the serial monitor at 57600 baud to try and see activity, but there is only gibberish.

            Thanks for your help.
            Also, the comment reply feature is a bit buggy. Couldn’t reply to your latest comment.

          • Try to connect a pullup resistor to the reset pin. Also make sure that you have connected the Arduino reset pin to an input on the level shifter and not an output.

          • Chris

            Adding the pullup resistor fixed the reset problem. Now the board_qc sketch is throwing this error message.

            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
            Test failed. Value written: 01 read: 00
            Unrecoverable error – test halted!!
            0×55 pattern is transmitted via SPI
            Press RESET to restart test

            Any idea what may be causing this error?

            Here is a diagram of my circuit.

          • Chris

            Whoops. I made a mistake in the other image that I posted.

            Here is the accurate diagram of my circuit.

          • If wires are long you may have issues with noise. Try to make them shorter, especially SCK.

          • Chris

            The jumper wires are only 10cm long. I don’t think I can cut them any shorter. I ordered a full size shield last week, so hopefully that one will operate correctly.

  • Vikram

    I’ve been trying to use the Teensy 3.0 with the example xbox controller code and it is not playing nice at all. I’ve been able to get the code to run using an Arduino Pro Mini, but I need it to run a bit faster. I’m really not an object oriented programming guy so some of this is over my head. Has anyone gotten the xbox controller working with the Teensy 3.0?

  • MagicianT

    Great news, that library is compatible with cortex family uCPU. I was wander how difficult it would be to port a library on tha maple (stm32F103RB) ? Have anyone already tried?

  • Vikram

    I have a wired AfterGlow Xbox 360 controller (blue looks really cool). The VID is the same as the MadCatz controller, but the PID is 0xF900 which is the only change I’ve made to the code. The controller is receiving a constant 5V and I checked the line for droops just in case I was not supplying enough current, but it’s fine. Code works great with the Pro Mini, but locks up on the Teensy. I get a few characters out on the serial port and then it just stops. My guess was that I messed something up in the library so I did a fresh install of arduino and the Teensy software as well as the USB Host Lib and same behavior. Know what’s going on?

    • Hmm that is strange. Have you got any other device you could test it with? For instance a USB mouse or keyboard?

      • Vikram

        Ran the keyboard example and it worked just fine. Probed it with an digital oscilloscope with an SPI decoder and the communication looks fine. It’s definitely not a hardware issue. I don’t have the wireless receiver for the wireless xbox controller otherwise I would just test that.

        • Vikram

          Figured it out! I did yet another clean install and this time installed none of the teensy libraries and it worked the first try! Not sure where the conflict is or why it’s not working with those libraries installed. I was able to replicate the problem by installing the extra libraries.

          • Okay. If you can figure out which of the Teensy libraries that is causing the problem, then it would be great. Then I will contact Paul and hopefully he will fix it for the next release.

  • Mark


    Very nice, thank you!

    I’m trying to connect a 3G dongle that needs to be USB mode switched. When powered up, the dongle will declare itself as a mass storage device (containing the Windows software). It must be USB mode switched to become a modem device.

    For more info see:

    I looked at the way this is done in Linux, analysing usb_modeswitch.c and the required setting for my modem, which I think can be determined by looking at the device reference file.

    It seems that in the case of my modem the mode switch is “simply” initiated by sending one raw bulk message to the first bulk output endpoint (find_first_bulk_output_endpoint).

    I tried to mimik this, using USB_desc as a starting point. I got this output from the original sketch:


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

    Configuration descriptor:
    Total length: 0037
    Num.intf: 02
    Conf.value: 01
    Conf.string: 01
    Attr.: E0
    Max.pwr: FA

    Interface descriptor:
    Intf.number: 00
    Alt.: 00
    Endpoints: 02
    Intf. Class: 08
    Intf. Subclass: 06
    Intf. Protocol: 50
    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

    Interface descriptor:
    Intf.number: 01
    Alt.: 00
    Endpoints: 02
    Intf. Class: 08
    Intf. Subclass: 06
    Intf. Protocol: 50
    Intf.string: 00

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

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


    Taking the Vendor/Product code and looking at the device reference file I got the follwing match:

    # Huawei E270+ (HSPA+ modem)
    # Huawei E1762
    # Huawei E1820
    # Contributor: Paranoid Paranoia

    DefaultVendor= 0x12d1
    DefaultProduct= 0x1446

    TargetVendor= 0x12d1
    TargetProduct= 0x14ac


    Taking the first bulk output endpoint which according to USB_desc is at address 01 and the above MessageContent I inserted the following code to the USB_desc loop:


    // ok now modeswitch

    // MessageContent="55534243123456780000000000000011060000000000000000000000000000"
    uint8_t msg[] = { 0x55, 0x53, 0x42, 0x43, 0x12, 0x34, 0x56, 0x78, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
    Serial.print("\r\nswitching mode - sending msg of length ");

    uint8_t ret = Usb.outTransfer(0x01, 0x01, sizeof(msg), msg);

    Serial.print("Usb.outTransfer() returned ");
    Serial.println(ret, HEX);


    Serial.println("\r\nprobing again");


    while( 1 ); //stop

    However, I got 0xDB (USB_ERROR_EP_NOT_FOUND_IN_TBL) as a return value. So I guess I misunderstand the meaning and usage of the device and/or end point address (or some setting up is required?).

    I tried several different things.

    Address 0×00, endpoint 0×00 sets up the adress OK but returns 0x0D (hrJERR) on outTransfer.
    Address 0×01, endpoint 0×00 sets up the adress OK but returns 0×04 (hrNAK) on outTransfer.

    I tried to find documentation and to understand other code before posting this. If I missed something obvious, please point me there.

    I found the following post that suggests it should work with microcontrollers (but no code available):

    This poster has a similar problem:,146603.0.html

    Thank you for all your help.

    - Mark

    • USB Desc doesn’t configure a device; generally, a device must be in a configured state to answer requests on non-zero endpoints. I suggest experimenting with Andrew’s mass storage code instead (look in xxxajk branch).

  • Oliver

    Is Teensy 3.1 supported also? Thanks

  • Bob Nelson

    Yes !! I have Teensy 3.1 matched up with your “Mini”
    USB host shield. And it all seems to be working fine,
    with a USB keyboard plugged into your board.
    VERY VERY nice to see it operating as intended.

    BUT of course I have a question: I am using your
    USBHIDBootKbd sketch to prove the hardware
    lashup is working OK. But this sketch is complex,
    and hard for an Arduino neophyte like myself to
    understand and modify easily.

    What I really want to do is extremely simple: Just
    cause the Teensy to light a red LED if I type an ‘r’
    on the attached USB keyboard, and a green LED
    if I type a ‘g’. Very simple.

    Is there an existing example sketch that is more
    appropriate for a beginner like me to modify for this
    simple operation? Something more straightforward
    than USBHIDBootKbd (which I don’t really understand
    at all) ?

    • you need to modify this method -> . It gets called when a key is pressed. A ‘key’ parameter contains ASCII code of the key being pressed. Just check if it were ‘r’ or ‘g’ and do what needs to be done. I can’t think of a simpler way.

    • Simply add the following in top of the USBHIDBootKbd code:

      const uint8_t redLed = 2;
      const uint8_t greenLed = 3;

      Then add this to the KbdRptParser class:

          KbdRptParser() {
            pinMode(redLed, OUTPUT);
            pinMode(greenLed, OUTPUT);

      And then modify OnKeyPressed like so:

      void KbdRptParser::OnKeyPressed(uint8_t key) {
        Serial.print(F("ASCII: "));
        if (key == 'r') // Turn red LED on
          digitalWrite(redLed, HIGH);
        else if (key == 'g') // Turn green LED on
          digitalWrite(greenLed, HIGH);
        else { // Turn both off
          digitalWrite(redLed, LOW);
          digitalWrite(greenLed, LOW);

      This should allow you to control the pins.

  • I have just uploaded to my github area the needed bits to allow you to use the storage part of the library in an unobtrusive way on the teensy 3.0 and 3.1. This is done by using my xmem2 memory management library, and provides you with ISR safe libc memory management, aka malloc/free/new/delete, etc.

    At present the preemptive multitasking of XMEM2 is not available on the Teensy 3.x products, or any other micro-controller that lacks banked memory at this time. This is because the IntervalTimer class for the Teensy 3.x is just perfect for polled tasks, such as what is used in the UHS library.

    Right now the only module available is xmemUSBFS. More will be written as time permits. Please consider contributing extra modules, even if they only work on the Teensy 3.x, or the AVR micro-controllers with the extra memory. I’ll be happy to complete them to support the board you don’t have.

    You will need the following libraries to take advantage of this and the upcoming ‘modules’: This gives you the high speed you want on SPI! This is to support timestamps on the filesystem, even if you lack an RTC on the i2c buss, it will use the one on the Freescale chip… This is for the FAT filesystem. This is for memory management. This is to place USB out of your way, behind the scenes so you don’t have to think about it! Ditto for the FAT filesystem

    Unfortunately the Arduino IDE does not allow you to do any manual defines for a build, so you will need so you can compile everything with the correct options.

  • Joe

    Hi, I noticed that Teensy 3.1 has USB-OTG support–can one use the USB Host Library on it without the usb host shield?

Leave a Reply




You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="" highlight="">