-
Notifications
You must be signed in to change notification settings - Fork 7.7k
Description
Related area
HID
Hardware specification
ESP32S3 Dev 16MB
Is your feature request related to a problem?
Yes. In my project using ESP32-S3, I need to use both a USB HID keyboard and a USB mass storage (pendrive) at different times. However, there is no way to properly stop or release one USB device before initializing another. This causes problems when switching between devices — for example, the pendrive won't work if the keyboard was used first, and vice versa. There’s no .end() or cleanup function in the current Arduino-ESP32 USB host libraries, which makes dynamic USB handling very difficult or impossible without a full reboot.
there is also a close issue on same topic
issue-9276
Describe the solution you'd like
I would like support in the Arduino-ESP32 core to allow starting and stopping USB devices dynamically. Specifically:
- .end() or .stop() method for USB HID (keyboard) and USB MSC (pendrive) classes that cleanly shuts down and releases the device.
- The ability to reinitialize another device after one has been stopped, without needing to reboot the ESP32.
This would make it possible to switch between a USB keyboard and a USB pendrive at runtime, which is important for applications involving both user input and data transfer dynamically.
Describe alternatives you've considered
I’ve tried using the HID example by @esp32beans and the MSC (pendrive) example by @nathalislight, but both are written for ESP-IDF and are not fully compatible with the Arduino framework.
More importantly, neither example offers a way to stop or release the USB device once initialized. As I mentioned earlier, this is the main blocker in my project — without a way to safely stop one device (e.g., keyboard) and start another (e.g., pendrive), it's impossible to switch devices without resetting the ESP32.
Adding .end() or similar functionality in the Arduino-ESP32 core would be a huge help.
Additional context
No response
I have checked existing list of Feature requests and the Contribution Guide
- I confirm I have checked existing list of Feature requests and Contribution Guide.