Hackster is hosting Hackster Holidays, Ep. 6: Livestream & Giveaway Drawing. Watch previous episodes or stream live on Monday!Stream Hackster Holidays, Ep. 6 on Monday!

Create Custom USB Devices with the esp32s2Stick

ESP32-powered stick uses USB OTG to act like USB mass storage or HID devices.

James Lewis
4 years ago

Electronics tutorial writer and video creator Luca Dentella created a microcontroller board that might, at first, look like every other ESP32-based board. However, the esp32s2Stick's USB port has a creative secret! Using the ESP32-S2's OTG capability, this stick enumerates itself as various USB devices!

The well-known ESP32 continues to surprise us. The S2 and, presumably, the S3 modules contain support for USB On-The-Go (OTG). With the TinyUSB library, Arduino code can use the USB OTG feature to a wide variety of USB devices.

The TinyUSB library is an open-source, cross-platform USB stack that supports both the host and device roles. In addition to the ESP32-S2, the library supports a wide variety of popular microcontrollers.

Dentella's YouTube tutorial walks you through setting up the Arduino IDE with an ESP32-S2 based-board and the TinyUSB library. You can see how to create a USB-serial, USB mass storage, and USB HID device using it. The esp32s2Stick builds on that tutorial, creating a slick compact package.

On the PCB, there is a microSD socket, RGB LED, voltage regulator, and ESP32-S2 ROVER module. The board design is open source. You can either get the EAGLE design files from the esp32s2Stick Github repository or order a board directly from PCBWay.

The Github repo also contains example code to operate the on-board LED and microSD. As noted in the blog post, this implementation does not use the pseudo-standard pins for SD card access that Arduino-supported boards typically use. So if you are using Dentella's board, check the SD card code example to make sure the correct pins are selected.

Since esp32s2Stick's USB port plugs into a USB host to act as another USB-device, there is a 4-pin serial interface for debugging. However, programming the device with new firmware can still be done over USB by placing the stick into DFU mode.

For a detailed tutorial on USB OTG support on the ESP32-S2, check out the video above from Dentella's YouTube Channel. This esp32s2Stick blog post has more information about the board.

James Lewis
Electronics enthusiast, Bald Engineer, and freelance content creator. AddOhms on YouTube. KN6FGY.
Latest articles
Sponsored articles
Related articles
Latest articles
Read more
Related articles