Page 1 of 1

More than two USB pins on ESP32-S2?

Posted: Mon Oct 04, 2021 8:12 pm
by Da Flex
I successfully run the ESP32TinyUSB MIDI example (version 1.3.4 and this patch https://github.com/chegewara/EspTinyUSB ... -915718146). The ESP32-S2 is recognized as a MIDI device, and plays the song, which is included in the example. That's pretty cool so far!

However, it's just the first step to reach my goal, which is to filter selected MIDI events. I'm currently using GPIO 19 and 20 to connect an USB cable, as described in the ESP32-S2 manual. To pass-through or filter MIDI events, I need another two pins for I/O.

Question: Is it possible to use another two ESP32-S2 pins for USB? It probably means that the ESP32-S2 has to emulate two USB devices instead of one (maybe there is a smarter solution, and a software thread can emulate two devices):

MIDI source device -- USB-MIDI connection --> ESP32-S2 -- USB-MIDI connection --> MIDI target device


Thanks for answering!
Da Flex

Re: More than two USB pins on ESP32-S2?

Posted: Mon Oct 04, 2021 8:51 pm
by chegewara
Hi,
sorry, but esp32 S2/S3 has 1-port only (no hub) USB implementation.
You can try to use some software emulation like this one, but i dont know if there is MIDI support:
https://github.com/sdima1357/esp32_usb_soft_host
https://github.com/tobozo/ESP32-USB-Soft-Host

Another option would be to use 2x esp32 S2 with some UART or SPI comm.

Re: More than two USB pins on ESP32-S2?

Posted: Mon Oct 04, 2021 9:58 pm
by Da Flex
Thanks a lot @chegewara! A very helpful answer, especially because I also have an ESP32-C3. I have to puzzle with the parts now...

Re: More than two USB pins on ESP32-S2?

Posted: Tue Oct 05, 2021 12:18 am
by Da Flex
I had a look at the USB host software. It doesn't seem to have MIDI support.

Taking this into account, my idea is to deal with "USB-MIDI Event Packets" (pure USB data), and pass-through all other USB data. I think I can use regular pins for this, but it could be hard to program. :shock:

Another approach is to use ESP32TinyUSB with two ESP32-S2, as suggested by chegewara.

Both approaches are not prefect.

Re: More than two USB pins on ESP32-S2?

Posted: Sun Oct 17, 2021 9:30 pm
by Da Flex
After some more research, here is my current approach:

The Retrokits company offers the smart MIDI cable RK-002, which is basically a MIDI-DIN cable with a built-in MC.
They support Arduino, installation instructions are here: https://retrokits.com/rk002-duy/
RK-002 code for different MIDI processing is here: https://duy.retrokits.com/

After installing the mentioned board support for RK-002, an RK002.h library will be available. I think that's a good starting point to adapt MIDI filtering / processing to ESP32 chips. I don't know what MC the RK-002 uses, but I'm sure the ESP32-S2 is powerful enough to emulate whatever is inside that cable. Now the major task is to convert USB-MIDI to MIDI-DIN.


Da Flex

Re: More than two USB pins on ESP32-S2?

Posted: Tue May 17, 2022 3:02 am
by Da Flex
Update:
I figured out that it's way too complex to deal with raw USB data. The software from Retrokits doesn't help here.

New approach:
- connect your MIDI controller (USB device mode) to a USB host shield hardware (USB host mode)
- connect that host shield to ESP32-S2 (SPI interface)
- the ESP32-S2 then filters MIDI data, and emulates a USB device (GPIO19 / 20)
- connect the ESP32-S2 to your PC (DAW)

Driver for USB host shield is part of Arduino IDE, and also documented here: https://github.com/felis/USB_Host_Shield_2.0 .
As a result, you only deal with MIDI data for the filter, which is much easier.