# Adafruit USB Host BFF

## Overview

![](https://cdn-learn.adafruit.com/assets/assets/000/129/751/medium800thumb/adafruit_products_5956-05.jpg?1714504643)

[Is your QT Py all alone](https://www.adafruit.com/?q=qt+py&sort=BestMatch), lacking a friend to travel the wide world with? When you were a kid, you may have learned about the "buddy" system. Well, this product is kind of like that! It is a board that will watch your QT Py's back and add a USB Host port.

That means that your tiny microcontroller project can have a keyboard, mouse, or disk drive plugged into it, opening up a huge ecosystem of common off-the-shelf devices that you can now integrate.

The&nbsp; **Adafruit USB Host BFF** makes it easy to add USB Host support, especially now that [TinyUSB supports it in the Arduino library](https://github.com/adafruit/Adafruit_TinyUSB_Arduino) as a 'native' interface for host support.

![](https://cdn-learn.adafruit.com/assets/assets/000/129/752/medium800/adafruit_products_5956-04.jpg?1714504674)

This BFF uses the MAX3421E - a tried and true USB Host chip. It uses SPI plus an IRQ pin to send data to just about any USB device.

Note that because the chip is older and you're limited to the SPI port speed, you won't get blazing 480Mbps high-speed data transfer. But for basic HID interfacing or even reading/writing to a Mass Storage device, it does work quite well.

There's a famous [USB Host Library that can be used](https://github.com/felis/USB_Host_Shield_2.0), and its specialty is AVR support, but it also seems to support nRF52 and ESP32.

We personally recommend using the [TinyUSB Arduino library](https://github.com/adafruit/Adafruit_TinyUSB_Arduino) - however, the trade-off is that the chip must have TinyUSB support already, which means it's great for **RP2040, ESP32-S2 or S3, nRF52840, SAMD21/51 chips**. Make sure your desired QT Py mainboard is supported between the two libraries before purchasing!

Warning: On the first batch of boards, the IRQ and CS silkscreen labels are swapped. Pin A1 is CS, labeled IRQ; pin A2 is IRQ, labeled CS.

![](https://cdn-learn.adafruit.com/assets/assets/000/129/754/medium800/adafruit_products_5956-02.jpg?1714504781)

To keep the BFF very compact, we use a micro-B USB "OTG" connector - a full sized USB Type A wouldn't fit! You'll need to use [a basic OTG adapter (such as those sold for use with the Pi Zero) to convert to type A](https://www.adafruit.com/search?q=otg+adapter). Unlike our [USB Host 'Wing](https://www.adafruit.com/product/5858) we don't include a 5V power booster, so you will need to power the QT Py + BFF over USB or in some other way provide 5V on the 5V power line.

However, to make it easier to power-cycle the peripheral, we have wired up a P-FET for switching the 5V host power on and off, you can either short the pin to A0 or you can use the MAX3421E's GPIO pin.

![](https://cdn-learn.adafruit.com/assets/assets/000/129/755/medium800/adafruit_products_5956-03.jpg?1714504926)

We include some header that you can solder to your QT Py. [You can also pick up an Itsy Bitsy short female header kit to make it removable but compact](https://www.adafruit.com/product/4174); you'll need to trim the headers to 7 pins long.

Remember, you need driver support for the MAX3421E (see above for chips that are known to work). Unless you're using a generic mouse, keyboard, CDC serial, or USB mass storage device, you will also need a USB driver that knows how to talk to the device—and writing a driver is non-trivial.

**QT Py or Xiao is not included!**

# Adafruit USB Host BFF

## Pinouts

![](https://cdn-learn.adafruit.com/assets/assets/000/129/760/medium800/adafruit_products_double.jpg?1714507148)

## Micro-B USB Port

On the bottom edge of the board is the micro-B USB port. This port can be used for sending or receiving data from an attached USB device with the MAX3421E. Since it's an "OTG" connector, you'll need [a basic OTG adapter (such as those sold for use with the Pi Zero) to convert to type A](https://www.adafruit.com/search?q=otg+adapter).

## MAX3421E Control Pins

The MAX3421E USB Host chip on the BFF uses SPI plus an IRQ pin to send data to just about any USB device.

- **MOSI** - This is the SPI MOSI ( **M** icrocontroller **O** ut / **S** erial **I** n) pin.
- **MISO** - This is the SPI MISO ( **M** icrocontroller **I** n **S** erial **O** ut) pin.
- **SCK** - This is the **S** PI clo **ck** input pin.
- **CS** - This is the **c** hip **s** elect pin. It is connected to **pin A1** on the BFF. It is also broken out directly next to pin A1.
- **IRQ** - This is the interrupt pin for the MAX3421E. It is connected to **pin A2** on the BFF and is broken out directly next to pin A2.

Warning: On the first batch of boards, the IRQ and CS silkscreen labels are swapped. Pin A1 is CS, labeled IRQ; pin A2 is IRQ, labeled CS.

## 5V Enable Pin and Jumper

- **5VEN** - Directly next to pin A0 on the BFF is a pin labeled **5VEN**. This is the **5V enable** output from the 5V selection circuitry. If you tie this pin to ground, it can disable 5V power to the micro-B USB port, effectively turning off your connected USB device.
- **5V Enable Jumper - A0&nbsp;** - On the back of the BFF, to the **left of the 5VEN** pin, is an open jumper pad surrounding pin A0. If you solder this jumper closed you will connect the&nbsp; **5V enable** pin to **A0** on the BFF. This means you can then enable or disable 5V to the micro-B USB port with this GPIO pin.
- **5V Enable Jumper - GPOUT0** - On the back of the BFF, to the **right of the 5VEN** pin, is an open jumper. It is outlined in white on the board silk. If you solder this jumper closed you will connect the&nbsp; **5V enable** pin to **GPOUT0** (general purpose output 0) on the MAX3421E. This output is controllable over SPI, which means you can then enable or disable 5V to the micro-B USB port in software. **GPOUT0 is only accessible with Arduino.**

## 5V LED

- **5V LED** - To the left of the micro-B USB port is a green LED labeled **ON** on the BFF silk. It indicates whether the power is enabled to the USB port.

# Adafruit USB Host BFF

## CircuitPython

It's easy to use the **USB Host BFF** with CircuitPython and the [max3421e](https://docs.circuitpython.org/en/latest/shared-bindings/max3421e/index.html) core module. This module allows you to easily write Python code that lets you utilize the MAX3421E USB Host chip. CircuitPython support is available for these QT Py and Xiao form factor boards:

- [Adafruit QT Py ESP32 PICO](https://www.adafruit.com/product/5395)
- [Adafruit QT Py ESP32C3](https://www.adafruit.com/product/5405)
- [Adafruit QT Py ESP32S2](https://www.adafruit.com/product/5325)
- [Adafruit QT Py ESP32-S3 4MB Flash 2MB PSRAM](https://www.adafruit.com/product/5700)
- [Adafruit QT Py ESP32-S3 no psram](https://www.adafruit.com/product/5426)
- [Seeed Studio XIAO ESP32C3](https://circuitpython.org/board/seeed_xiao_esp32c3/)

This support is currently available in the 9.1 beta builds of CircuitPython. On [CircuitPython.org](https://circuitpython.org/downloads), search for and select your board via the **Downloads tab**. On the board page, scroll down to the **9.1 beta** and select your UF2 and/or BIN file.

![adafruit_products_cp_beta.png](https://cdn-learn.adafruit.com/assets/assets/000/130/891/medium640/adafruit_products_cp_beta.png?1719330293)

## CircuitPython Microcontroller Wiring
Plug a USB Host BFF into your QT Py or Xiao form factor board. Then, plug an OTG adapter into the BFF. Here's an example connecting a QT Py ESP32-S3 to the BFF with a micro-B USB OTG cable plugged into the micro-B USB port on the BFF.

![adafruit_products_USB-BFF-assembled.jpg](https://cdn-learn.adafruit.com/assets/assets/000/129/813/medium640/adafruit_products_USB-BFF-assembled.jpg?1714751202)

### USB OTG Host Cable - MicroB OTG male to A female

[USB OTG Host Cable - MicroB OTG male to A female](https://www.adafruit.com/product/1099)
This cable looks like a USB micro cable but it isn't! Instead of a USB A Plug, it has a USB A Socket on the end. This cable is designed for use with OTG (On the Go) host devices (like the Arduino Due or many tablets) so you can connect a mouse, keyboard, or any other USB device. You'll...

In Stock
[Buy Now](https://www.adafruit.com/product/1099)
[Related Guides to the Product](https://learn.adafruit.com/products/1099/guides)
![USB OTG Host Cable with Micro B OTG male to A female in black](https://cdn-shop.adafruit.com/640x480/1099-00.jpg)

## CircuitPython Usage

To use with CircuitPython,&nbsp;you need to update **code.py** with the example script.

Thankfully, we can do this in one go. In the example below, click the **Download Project Bundle** button below to download the&nbsp; **code.py** file in a zip file. Extract the contents of the zip file and copy the **code.py** file to your **CIRCUITPY** drive.

![CIRCUITPY](https://adafruit.github.io/Adafruit_Learning_System_Guides/USB_Host_BFF_Examples_CircuitPython_DeviceInfo.png )

Info: Only core modules are used for these examples. No additional libraries need to be added to the /lib folder.

## Device Info Example Code

Once everything is saved to the **CIRCUITPY** drive, [connect to the serial console](https://learn.adafruit.com/welcome-to-circuitpython/kattni-connecting-to-the-serial-console) to see the data printed out!

https://github.com/adafruit/Adafruit_Learning_System_Guides/blob/main/USB_Host_BFF_Examples/CircuitPython_DeviceInfo/code.py

First, the MAX3421E is instantiated over SPI. In the loop, a scan is performed every 5 seconds on the USB host port for a connected USB device. If a device is detected, its VID, PID, manufacturer name and product name are printed to the serial monitor. You can plug and unplug devices to experiment with this.

![](https://cdn-learn.adafruit.com/assets/assets/000/129/806/medium800/adafruit_products_cp_serial.png?1714655145)

## HID Device Report Example

Update the **code.py** file on your CIRCUITPY drive with the code below. You'll need a USB HID keyboard to read device reports from.

### Miniature Keyboard- Microcontroller-Friendly PS/2 and USB

[Miniature Keyboard- Microcontroller-Friendly PS/2 and USB](https://www.adafruit.com/product/857)
Add a typing interface to your project with this microcontroller-friendly miniature keyboard. We found the smallest PS/2+USB keyboard available, a mere 8.75" x 4.65" x 0.6" (220mm x 118mm x 16mm)! It's small but usable to make a great accompaniment to either a...

In Stock
[Buy Now](https://www.adafruit.com/product/857)
[Related Guides to the Product](https://learn.adafruit.com/products/857/guides)
![Miniature Keyboard- Microcontroller in use](https://cdn-shop.adafruit.com/640x480/857-03.jpg)

https://github.com/adafruit/Adafruit_Learning_System_Guides/blob/main/USB_Host_BFF_Examples/CircuitPython_HIDReport/code.py

In this example, the HID input report from an HID keyboard are logged to the serial monitor. The code begins by instantiating the MAX3421E over SPI. Then, a scan is performed to find a USB device. When the HID device is found, its VID and PID are used to instantiate the device.

In the loop, the&nbsp;`read()` function is used to read the incoming report from the device. When a report is received, the buffer is printed to the serial monitor. The buffer is 8 bytes long. The first index contains any modifier keys and the third index contains the key number. For example, the letter A is 0x04 or `4`. When all keys are released, the buffer is filled with a `0` byte in each index.

If you plug in a USB HID keyboard to the USB Host BFF and press keys on it, you'll see those keycodes print to the serial monitor as keys are pressed and released.

![](https://cdn-learn.adafruit.com/assets/assets/000/129/811/medium800/adafruit_products_cp_hid_report.png?1714657930)

# Adafruit USB Host BFF

## Arduino

Warning: An issue was introduced in version 3.2.0 of the ESP32 Arduino board support package that causes [MAX3421E examples to not compile](https://github.com/adafruit/Adafruit_TinyUSB_Arduino/issues/513). To use this BFF with an ESP32 board in Arduino, downgrade to a previous version of the board support package (ex. 3.1.3).

Using the USB Host BFF with Arduino involves connecting your BFF to your Arduino-compatible QT Py or Xiao form factor board that has TinyUSB support ( **ESP32, ESP32-S2 or ESP32-S3**** , nRF52840, SAMD21/51, RP2040** chips), plugging a USB device into the USB OTG port on the USB Host BFF, installing the&nbsp;[Adafruit\_TinyUSB\_Arduino](https://github.com/adafruit/Adafruit_TinyUSB_Arduino) library, and running the provided example code.

### USB OTG Host Cable - MicroB OTG male to A female

[USB OTG Host Cable - MicroB OTG male to A female](https://www.adafruit.com/product/1099)
This cable looks like a USB micro cable but it isn't! Instead of a USB A Plug, it has a USB A Socket on the end. This cable is designed for use with OTG (On the Go) host devices (like the Arduino Due or many tablets) so you can connect a mouse, keyboard, or any other USB device. You'll...

In Stock
[Buy Now](https://www.adafruit.com/product/1099)
[Related Guides to the Product](https://learn.adafruit.com/products/1099/guides)
![USB OTG Host Cable with Micro B OTG male to A female in black](https://cdn-shop.adafruit.com/640x480/1099-00.jpg)

## Wiring
Plug a USB Host BFF into your QT Py or Xiao form factor board. Then, plug an OTG adapter into the BFF. Here's an example connecting a QT Py ESP32-S3 to the BFF with a micro-B USB OTG cable plugged into the micro-B USB port on the BFF.

![adafruit_products_USB-BFF-assembled.jpg](https://cdn-learn.adafruit.com/assets/assets/000/129/814/medium640/adafruit_products_USB-BFF-assembled.jpg?1714751214)

## Library Installation

You can install the **Adafruit\_TinyUSB\_Arduino** library using the Library Manager in the Arduino IDE.

![](https://cdn-learn.adafruit.com/assets/assets/000/129/801/medium800/adafruit_products_Arduino_Open_Library_Manager.png?1714592970)

Click the **Manage Libraries ...** menu item, search for **Adafruit\_TinyUSB** , and select the **Adafruit TinyUSB** library:

![](https://cdn-learn.adafruit.com/assets/assets/000/129/807/medium800/adafruit_products_lib.png?1714656515)

If asked about dependencies, click "Install all".

![](https://cdn-learn.adafruit.com/assets/assets/000/129/808/medium800/adafruit_products_depends.png?1714656523)

If the "Dependencies" window does not come up, then you already have the dependencies installed.

Warning: If the dependencies are already installed, you must make sure you update them through the Arduino Library Manager before loading the example!

## Device Info Example Code
https://github.com/adafruit/Adafruit_Learning_System_Guides/blob/main/USB_Host_BFF_Examples/Arduino_USB_Host_BFF_DeviceInfo/Arduino_USB_Host_BFF_DeviceInfo.ino

Upload the sketch to your board and open up the Serial Monitor ( **Tools -\> Serial Monitor** ) at 115200 baud. As you plug and unplug your USB device to the USB Host BFF, you will see the device info print out to the Serial Monitor.

![](https://cdn-learn.adafruit.com/assets/assets/000/129/802/medium800/adafruit_products_arduino_serial.png?1714593951)

## HID Device Report Example

You'll need an HID USB keyboard to read device reports from.

### Miniature Keyboard- Microcontroller-Friendly PS/2 and USB

[Miniature Keyboard- Microcontroller-Friendly PS/2 and USB](https://www.adafruit.com/product/857)
Add a typing interface to your project with this microcontroller-friendly miniature keyboard. We found the smallest PS/2+USB keyboard available, a mere 8.75" x 4.65" x 0.6" (220mm x 118mm x 16mm)! It's small but usable to make a great accompaniment to either a...

In Stock
[Buy Now](https://www.adafruit.com/product/857)
[Related Guides to the Product](https://learn.adafruit.com/products/857/guides)
![Miniature Keyboard- Microcontroller in use](https://cdn-shop.adafruit.com/640x480/857-03.jpg)

https://github.com/adafruit/Adafruit_Learning_System_Guides/blob/main/USB_Host_BFF_Examples/Arduino_USB_Host_BFF_HIDReport/Arduino_USB_Host_BFF_HIDReport.ino

Upload the sketch to your board and open up the Serial Monitor ( **Tools -\> Serial Monitor** ) at 115200 baud. Plug in a USB HID keyboard to the USB Host BFF. As you press keys, you'll see the report print to the Serial Monitor as keys are pressed and released.

![](https://cdn-learn.adafruit.com/assets/assets/000/129/809/medium800/adafruit_products_arduino_serial_hid_report.png?1714657175)

# Adafruit USB Host BFF

## Downloads

## Files

- [MAX3421E Datasheet](https://cdn-learn.adafruit.com/assets/assets/000/126/624/original/max3421e.pdf?1702561777)
- [EagleCAD PCB Files on GitHub](https://github.com/adafruit/Adafruit-USB-Host-BFF-PCB)
- [Fritzing object in the Adafruit Fritzing Library](https://github.com/adafruit/Fritzing-Library/blob/master/parts/Adafruit%20USB%20Host%20BFF.fzpz)

## Schematic and Fab Print
![](https://cdn-learn.adafruit.com/assets/assets/000/129/757/medium800/adafruit_products_schem.png?1714505161)

Warning: On the first batch of boards, the IRQ and CS silkscreen labels are swapped. Pin A1 is CS, labeled IRQ; pin A2 is IRQ, labeled CS.

![](https://cdn-learn.adafruit.com/assets/assets/000/129/758/medium800/adafruit_products_fab.png?1714505168 dimensions are in inches)


## Primary Products

### Adafruit USB Host BFF for QT Py or Xiao with MAX3421E

[Adafruit USB Host BFF for QT Py or Xiao with MAX3421E](https://www.adafruit.com/product/5956)
[Is your QT Py all alone](https://www.adafruit.com/?q=qt+py&sort=BestMatch), lacking a friend to travel the wide world with? When you were a kid, you may have learned about the "buddy" system. Well, this product is kind of like that! It is a board that will watch your...

In Stock
[Buy Now](https://www.adafruit.com/product/5956)
[Related Guides to the Product](https://learn.adafruit.com/products/5956/guides)

## Featured Products

### USB OTG Host Cable - MicroB OTG male to A female

[USB OTG Host Cable - MicroB OTG male to A female](https://www.adafruit.com/product/1099)
This cable looks like a USB micro cable but it isn't! Instead of a USB A Plug, it has a USB A Socket on the end. This cable is designed for use with OTG (On the Go) host devices (like the Arduino Due or many tablets) so you can connect a mouse, keyboard, or any other USB device. You'll...

In Stock
[Buy Now](https://www.adafruit.com/product/1099)
[Related Guides to the Product](https://learn.adafruit.com/products/1099/guides)
### Tiny OTG Adapter - USB Micro to USB

[Tiny OTG Adapter - USB Micro to USB](https://www.adafruit.com/product/2910)
This super slim, super tiny, and super cute Micro-B&nbsp;to USB on-the-go adapter is so slim, tiny, and cute that we'd pinch its cheeks if it was big enough to have cheeks. &nbsp;At just ~15.5mm long, ~11.3mm wide, and ~2mm, this really is the tiniest little adapter we've probably ever...

In Stock
[Buy Now](https://www.adafruit.com/product/2910)
[Related Guides to the Product](https://learn.adafruit.com/products/2910/guides)
### Miniature Keyboard- Microcontroller-Friendly PS/2 and USB

[Miniature Keyboard- Microcontroller-Friendly PS/2 and USB](https://www.adafruit.com/product/857)
Add a typing interface to your project with this microcontroller-friendly miniature keyboard. We found the smallest PS/2+USB keyboard available, a mere 8.75" x 4.65" x 0.6" (220mm x 118mm x 16mm)! It's small but usable to make a great accompaniment to either a...

In Stock
[Buy Now](https://www.adafruit.com/product/857)
[Related Guides to the Product](https://learn.adafruit.com/products/857/guides)

## Related Guides

- [Introducing the Adafruit nRF52840 Feather](https://learn.adafruit.com/introducing-the-adafruit-nrf52840-feather.md)
- [Adafruit ESP32-S3 Reverse TFT Feather](https://learn.adafruit.com/esp32-s3-reverse-tft-feather.md)
- [reef-pi Guide 1: Setup and Demonstration](https://learn.adafruit.com/reef-pi-installation-and-configuration.md)
- [Arduino Ethernet + SD Card](https://learn.adafruit.com/arduino-ethernet-sd-card.md)
- [MicroLipo v2 Case](https://learn.adafruit.com/microlipo-case.md)
- [MEMENTO Wireless Remote with TouchOSC](https://learn.adafruit.com/memento-wireless-remote.md)
- [Esenciales para CircuitPython](https://learn.adafruit.com/esenciales-para-circuitpython.md)
- [Adafruit Feather M0 WiFi with ATWINC1500](https://learn.adafruit.com/adafruit-feather-m0-wifi-atwinc1500.md)
- [Adafruit ESP32-S2 Reverse TFT Feather](https://learn.adafruit.com/esp32-s2-reverse-tft-feather.md)
- [Adafruit S-35710 Low-Power Wake Up Timer Breakout](https://learn.adafruit.com/adafruit-s-35710-low-power-wake-up-timer-breakout.md)
- [How to Choose a Microcontroller](https://learn.adafruit.com/how-to-choose-a-microcontroller.md)
- [eInk Literature Quotes Clock for MagTag](https://learn.adafruit.com/eink-literary-quotes-clock-for-magtag.md)
- [NeoTrellis MIDI Feedback Controller](https://learn.adafruit.com/neotrellis-midi-feedback-controller.md)
- [MicroPython Basics: How to Load MicroPython on a Board](https://learn.adafruit.com/micropython-basics-how-to-load-micropython-on-a-board.md)
- [Adafruit Sensirion SHT40, SHT41 & SHT45 Temperature & Humidity Sensors](https://learn.adafruit.com/adafruit-sht40-temperature-humidity-sensor.md)
