T-Dongle-ESP32S2 icon indicating copy to clipboard operation
T-Dongle-ESP32S2 copied to clipboard

Example using the OTG female port for USB keyboard?

Open bertrandom opened this issue 2 years ago • 12 comments

Hi, is there an example of how to hook up a USB keyboard to the USB OTG female port using Arduino?

bertrandom avatar Sep 12 '22 16:09 bertrandom

You can see the example in the example by installing the ESP32's library.

LilyGO avatar Sep 13 '22 01:09 LilyGO

sketch_sep12a | Arduino 1 8 19 2022-09-12 23-27-41 All of the USB examples, including the Keyboard ones, are for programming the male USB connector to show up as a HID device on the computer that it's plugged in to, but none of them demonstrate using the USB female OTG port.

bertrandom avatar Sep 13 '22 06:09 bertrandom

I join the question. I've been looking for information about it for a few days.

sergio-arroyo avatar Sep 25 '22 20:09 sergio-arroyo

Here is an example of USB host usage of ESP-IDF. https://github.com/espressif/esp-idf/tree/master/examples/peripherals/usb/host/cdc/cdc_acm_host

LilyGO avatar Sep 26 '22 09:09 LilyGO

Do you have an Arduino example (that's a esp-idf example)? Or an example of using a keyboard HID?

bertrandom avatar Sep 28 '22 04:09 bertrandom

https://github.com/chegewara/EspTinyUSB

lyusupov avatar Oct 20 '22 06:10 lyusupov

The female port on this board uses the same physical pins as the male connector. This means that you cannot use the host port (the female one) at the same time as the male one connected e.g. to the PC.

harbaum avatar Nov 09 '22 09:11 harbaum

One can use (built-in) DIP switches to isolate D+/D- signals of the 'male' connector from the ESP32-S2, so both USB ports can be used at the same time:

  • male - to supply power
  • female - to provide USB-Host function

This is an example of the USB-Host use case: https://github.com/lyusupov/SoftRF/wiki/WebTop-USB

lyusupov avatar Nov 09 '22 09:11 lyusupov

That's correct. But that means you can only use the male port for power supply then. Data lines are disconnected and you cannot use it as a COM port to the PC.

But the GPIO43 and GPIO44 on the groove are actually UART0 TxD and RxD and it should be possible to use that with a USB TTL serial converter to upload a new sketch and have a serial console.

harbaum avatar Nov 09 '22 09:11 harbaum

Great stuff. Thanks. I downloaded the WebTop-USB SW and it works nicely. To reproduce your results: Any chance to show the related USB code to read external devices?

weissm avatar Apr 24 '23 07:04 weissm

@weissm look into 'examples' area of ESP-IDF and/or WebTop

lyusupov avatar Apr 24 '23 07:04 lyusupov

I am looking for a device were I can connect a Barcode reader, apply some business rules to the read barcode and send this result to a second usb port that acts like a keyboard interface? Any ideas? So the read barcode is transferred to the right format expected by the software.

GerOtten avatar Feb 22 '24 14:02 GerOtten