Receive simple data (number 0-10,000,000) over USB from any devices

fikurimax
Posts: 2
Joined: Sat Jan 04, 2025 1:22 am

Receive simple data (number 0-10,000,000) over USB from any devices

Postby fikurimax » Sat Jan 04, 2025 3:04 am

I'd like to make a device that will read data from other devices (could be ESP / Arduino, or other devices) over USB. I've asked GPT on how to do this, and it says I must use intermediate USB Host. Tbh, I am a beginner at this electronics thing, so I don't really know the nitty gritty on how to use/pick this or that. Can anyone give me a brief explanation? or any resources / links would be appreciated. Thanks

PS: I currently use a pair of ESP32-C3

lbernstone
Posts: 886
Joined: Mon Jul 22, 2019 3:20 pm

Re: Receive simple data (number 0-10,000,000) over USB from any devices

Postby lbernstone » Sat Jan 04, 2025 6:34 pm

This depends on what you want to achieve. If you want an actual USB device, which will know how to behave with an appropriate driver and have a custom VID:PID that you provide, you need a device with a full USB peripheral (ie, the ESP32-S2 and -S3).
If you just want to transfer some data over the "USB", this can be done just by using the Serial port. On an ESP32 (or any Espressif device with a UART adapter), this is just a matter of plugging in the port, and reading/writing data to that Serial adapter (it will show up as a COM port on your Windows machine). On a cheap ESP32-C series device, there is often only a USB-CDC hardware adapter. This has been coded to emulate a UART device. If you select "USB CDC on boot" and upload code with bi-directional communication (eg settimeofday). Note that the USB port is sometimes a bit wonky, and likes to show up as a different device when it gets reset quickly, so this is not as rock solid as using a UART adapter or the full USB stack. I would not really recommend using a -C3 for your application when you can get an -S2 for the same price, but it can work.

fikurimax
Posts: 2
Joined: Sat Jan 04, 2025 1:22 am

Re: Receive simple data (number 0-10,000,000) over USB from any devices

Postby fikurimax » Sun Jan 05, 2025 9:32 am

You are right, it's just a matter of plugging in the port. Actually I chose USB because I thought it would be easier and pretty much common. But other than USB, what port would you recommend as an alternative? I don't want it to be connected directly on the pins like RX/TX, so I think an external specific port like USB would be a good idea

lbernstone
Posts: 886
Joined: Mon Jul 22, 2019 3:20 pm

Re: Receive simple data (number 0-10,000,000) over USB from any devices

Postby lbernstone » Mon Jan 06, 2025 12:06 am

If you want to send simple data between two devices, uart is a dead simple protocol. You only need 3 wires (Rx/Tx/Gnd) between the boards. Remember that Rx on one side is Tx on the other. Don't use gpio8 or 9, but any other free pin should be OK. You initialize Serial1 like:

Code: Select all

Serial1.begin(115200, SERIAL_8N1, PIN_Rx, PIN_Tx);

Who is online

Users browsing this forum: No registered users and 41 guests