Esp32 S2 connect USB device and send data

Hello. I have ESP32-S2-Saol-1RI with integration USB port. I try to connect USB device and send hex data to it.
I connect:

D+ --> GPIO 20
D- --> GPIO 19
VCC --> v5
GND --> GND

But can't found any information, how to send hex data to it? Can anyone help? Thanks!

The USB D+ and D- lines use a different format than the UART Rx and Tx lines. You cannot read them separately with GPIO inputs.

is this a question about how to send hex data or how to use the usb/serial interface?

you can use the same usb/com port used to download and communicate with the esp using the serial monitor without the Arduino IDE using a PC com interface program

all data sent over a serial interface is binary. ASCII characters can be displayed directly. binary data can be displayed in a number of ways: bits, octal, hex, decimal, ...

The question is: how to use ESP32 USB as Serial interface

as i said, any PC program can be used to send/receive serial data over the USB com port used by the Arduino IDE. but 2 programs can't use the same com port at the same time. the Arduino IDE can't be running when using some other PC program to access the port.

putty can be used to communicate over a com port

I understand...
I connect usb device, like card reader, with usb interface to ESP32.
card reader support HEX-command and I try to send this them from my esp32 board

is the card reader using the same USB interface on the esp32 that is used to download code to the esp32?

or does the esp32 have a 2nd USB interface?

can you provide a description of the card reader? link or model #?

Use 2nd USB interface esp32, on GPIO 20 and GPIO 19

Sorry, I don't have link of card-reader, but for test I connect it to PC - connect to it over putty/Termite - send hex command and get answer

a usb interface is much more than simple serial interface. the esp32 communicates with the PC thru a USB interface chip.

i don't know how the esp32 can support a 2nd USB interface

If you want to use ESP32S2/S3 as a USB host, search esp32.com which is run by Espressif. Espressif is the company that makes ESP32 chips.

Hi,
I have the same issue. I have a QR reader which outputs USB data. When I connect it to the PC and open Word/Excel etc... the data is automatically written, so I can see that it is working.
I now need to connect the d+ (green cable) and d- (white) connections to the ESP32 (C3 Mini 1) , using GPIO 18 and 19 (D-and D+). I do not need the Tx and RX pins, since these are used by the usb-to-uart CP2102 chip.
I know data is coming out from the QR reader in ASCII format. However, I do not know, and have not found any code, on how to read this data from the D+ and D- pins of the ESP32. Ideally, I would read them into a buffer, then send them through serial to the PC through the normal usb serial COM port.
thanks
M

Check the ESP32-C3 datasheet. I recall it does not support USB host. In fact,
even in device mode it cannot do mouse or keyboard. The USB controller is
hardware wired only for CDC ACM and JTAG. You need an ESP32-S2 or ESP32-S3 for
USB OTG.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.