When the Teensy 4.0 development board hit the market in late 2019 it blew the doors off the place. Sporting a blazing fast 600 MHz ARM processor, 2 megabytes of flash memory, and over 40 I/O pins, at only an inch and a half long it packs a serious punch in a (Teensy) tiny package.
One of the awesome features of this board is its built-in USB host capability. This allows the microcontroller to talk to other USB devices such as human interface devices (mice, keyboards, joysticks), MIDI controllers, and even other development boards over USB serial. While some previous boards such as the Teensy 3.6 had this feature, this is the first Teensy board to include USB host functionality in a small format package.
To take advantage of this awesome new feature, I decided to design a minimalist USB host shield for the Teensy 4.0.
While the board includes USB host circuitry built into the microcontroller, it does not include the supporting electronics to make the host port stable. Namely, it is missing the current limiter that prevents a connected USB device from overloading the upstream port or browning out the microcontroller.
The USB specification says that devices can have a maximum input capacitance of 10 µF. That includes both the Teensy 4.0 itself and any attached device on the host port. Some devices with significant power draw may also exceed the inrush current specification of 50 µC. Exceeding these specifications puts more strain on the upstream USB port powering the Teensy. In some cases, hot-plugging a USB device to the Teensy’s host port may even cause the Teensy to brownout and reset.
To solve these problems, the design adds a current limit switch with a soft start feature. This slowly ramps up the current for the Teensy’s host port, and allows the use of a large (100 µF) capacitor to handle smaller surges. The current limit switch also allows devices to be “hot plugged”, meaning connected and disconnected while the microcontroller is running. As a bonus, the specific IC I used also provides some electrostatic discharge (ESD) protection on the USB data pins.
For good measure I also added a small ferrite inductor to form an LC filter and smooth the power, plus a 500 mA polyfuse to protect the Teensy in case of a short.
The goal for the PCB was to design a host circuit that’s as physically small as possible – just large enough for the Teensy itself and the USB-A port to connect to downstream devices. Compared to some more comprehensive “breakout boards”, I wanted a design that I could realistically throw inside a case as part of a prototype.
The resulting design is about as small as possible at 2.0 x 0.7″. There’s just enough room for the Teensy 4.0 board and a horizontal USB-A port. As the Teensy 4.0 does not come with castellated edges, the space under the necessary header pins provides a perfect location to place the SMD parts and save a little space. The components are slim enough to fit underneath the board even when using plain header pins.
When assembled with 0.1″ female headers, the data pins (D+/D-) for the USB host port use 12 mm tall pogo pins from RTLCS to connect to the SMD pads on the underside of the board. This makes it possible to add or remove the Teensy from the shield without any additional soldering or connectors other than the standard headers. When the shield is used without female headers, thin magnet wire can be used to connect the data pads to the shield.
To make this slightly more useful I also added two rows of pin headers on the inside in parallel with the headers on the Teensy. A pair of additional male headers can be soldered on to allow the shield to connect to a breadboard for prototyping.
Finally, I added two M3 holes (3.2 mm) to the board to use with alignment pins when the shield is installed in a case. The lower hole is hidden underneath the USB-A port, but with female headers on the board the upper hole has enough headroom underneath the Teensy 4.0 to add a bolt.
Configuration and Programming
Connected USB devices can be interfaced with using the USBHost_t36 library. So far I’ve tested the shield with a Logitech mouse, a MIDI keyboard, and a handful of controllers (PS3, PS4, Xbox 360, Xbox One, etc.). All performed great and without issue.
The shield has no digital logic and thus no special configuration is required when programming. It’s entirely plug and play with any existing Teensy 4 USB host programs.
While the design is solid there is always room for improvement. After finishing v1.0.0 I realized that it would be better if the edge of the board near the USB-A port was set back so the assembled shield could be cleanly integrated into an enclosure. That change has already been made and published as version 1.1.0.
For future revisions it would be great to integrate a USB hub so that the shield could use two stacked USB ports. This would provide a convenient way to use multiple USB devices with the Teensy, plus aesthetically it would make the assembly look more “balanced” against the tall Teensy stack when using female headers. In theory it would also be possible to provide some solder jumpers to make the same PCB compatible with two port (hub) and single port (no hub) configurations.
Want one of these boards? The design is open source! The original KiCAD design files are hosted on GitHub, along with Gerbers and the bill of materials on the releases page.