It's easy to use the USB Host FeatherWing with CircuitPython and the max3421e 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 Adafruit Feather form factor boards beginning with CircuitPython 9.1.0:
- Adafruit Feather HUZZAH32
- Adafruit Feather ESP32 V2
- Adafruit Feather ESP32-C6 4MB Flash No PSRAM
- Adafruit Feather ESP32S2
- Adafruit Feather ESP32-S2 Reverse TFT
- Adafruit Feather ESP32-S2 TFT
- Adafruit Feather ESP32S3 4MB Flash 2MB PSRAM
- Adafruit Feather ESP32S3 No PSRAM
- Adafruit Feather ESP32-S3 Reverse TFT
- Adafruit Feather ESP32-S3 TFT
- Adafruit Feather RP2040 DVI
CircuitPython Microcontroller Wiring
You can use a FeatherWing Doubler to easily connect a Feather and USB Host FeatherWing.
Plug a Feather and a USB Host FeatherWing into your FeatherWing Doubler. Here's an example connecting a Feather ESP32S3 to the FeatherWing.
CircuitPython Usage
To use with CircuitPython, 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 code.py file in a zip file. Extract the contents of the zip file and copy the code.py file to your CIRCUITPY drive.
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 to see the data printed out!
# SPDX-FileCopyrightText: 2024 Liz Clark for Adafruit Industries # # SPDX-License-Identifier: MIT """USB Host FeatherWing Device Info CircuitPython Example""" import time import board import max3421e import usb spi = board.SPI() cs = board.D10 irq = board.D9 host_chip = max3421e.Max3421E(spi, chip_select=cs, irq=irq) while True: print("Finding devices:") for device in usb.core.find(find_all=True): # pylint: disable=line-too-long print(f"{device.idVendor:04x}:{device.idProduct:04x}: {device.manufacturer} {device.product}") time.sleep(5)
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.
Text editor powered by tinymce.