-
Notifications
You must be signed in to change notification settings - Fork 7.7k
USBSerial (S2,S3) like FTDI? #6865
-
Hi,
I am trying to use the USB as serial interface on the ESP32S3 (I have a ESP32S3 Dev Kit module). In this way, I don't need to use a FTDI.
There are some examples, but none of them seems to work. The documentation is all for the IDF and not for the Arduino, so I was asking me if it works or if the library is still in development.
Once I connect the USB, I see a serial interface on my PC. I can also upload the sketches over the USB. But this is all.
I try to use:
HWSerial.print("....");
USBCDC.print("....");
USBSerial.print("....");
Serial.print("....");
But either it does not compile, or I can't see anything on the serial monitor (Arduino IDE).
The Serial description is "COM11 ESP32S3 Dev Module", but also with the examples, I am not able to change this description.
Here is my IDE configuration:
image
So my question:
- is there a tutorial for Arduino, where I can set the right parameters and a simple working code?
Thanks!
Beta Was this translation helpful? Give feedback.
All reactions
Replies: 5 comments 6 replies
-
Try this sketch first.
Some documentation:
Beta Was this translation helpful? Give feedback.
All reactions
-
Try this sketch first.
Some documentation:
Thank you. In the "Tools Menu" there is also a USB Mode (not present in the documentation). I must set it to "USB-OTG" instead of Hardware CDC and JTAG".
And I can't write to the Serial in the Setup as it is still opening the port, I assume. I need to wait a little bit more to write on this port.
But I can use it as normal serial port now.
In the sketch, I was getting this warning: "This sketch should be used when USB is in OTG mode", but I didn't saw it :P
An error with a description how we can solve it, could be better. Example: set USB Mode to "USB-OTG CDC (TinyUSB) in the Arduino IDE".
Beta Was this translation helpful? Give feedback.
All reactions
-
We also provide a firmware for ESP32-S2 or S3 which acts as a USB - UART/JTAG bridge: https://github.com/espressif/esp-usb-bridge
Beta Was this translation helpful? Give feedback.
All reactions
-
Thanks. I am always afraid when I need to use python outside from Arduino IDE or I see a IDF-project...
Can I still compile and upload sketches compiled with the Arduino IDE, or does I need to upload another firmware again once I burn this bridge-firmware?
Beta Was this translation helpful? Give feedback.
All reactions
-
Sorry if I ask it here (maybe it is better if I open a new discussion?).
On the FTDI, I can set a serial number and this is not only set on the USB-controller-device (in the device manager), but also in the serial-port-device as instance ID.
FTDI:
FTDIBUS\VID_0403+PID_6011+SERIALNUMBER0000円
ESP32:
USB\VID_303A&PID_1001&MI_008円&3A0D5B63&0&0000
Where is this instance id generated? I can't find where in the code, this id is created. I would like to always have the same id and with the USB serial number. Because windows creates a new COM-number for each of this instance id.
Beta Was this translation helpful? Give feedback.
All reactions
-
ESP32:
USB\VID_303A&PID_1001&MI_008円&3A0D5B63&0&0000
Based on the PID=1001, this is the built-in (non-programmable) USB_SERIAL_JTAG peripheral of ESP32-C3 or ESP32-S3 (not ESP32, which doesn't have a USB peripheral.)
The serial number (3A0D5B63) matches the factory-programmed MAC address of the chip, and can't be changed for USB_SERIAL_JTAG.
If you flash an ESP32-S2 or ESP32-S3 with some kind of a "bridge" application (either based on Arduino or IDF), you should have full control of USB descriptors, and you can then change the serial number.
Beta Was this translation helpful? Give feedback.
All reactions
-
Hi @igrr
I've also got the same issue. I've created a custom board with only the USB-D+ connected to GPIO20 and USB-D- connected to GPIO19. That is, I only have available the on-board USB-to-UART bridge.
I'm also able to upload the sketches, but not to use the Serial port for communications.
How did you finally solve it?
Beta Was this translation helpful? Give feedback.
All reactions
-
Answered here: #7546
Beta Was this translation helpful? Give feedback.
All reactions
-
Thanks.
- USB CDC On Boot -> Enabled
- Upload Mode -> UART0 / Hardware CDC
Did the trick.
Beta Was this translation helpful? Give feedback.
All reactions
-
I also have a problem with my PCB customs design with an S3. The USB is also on D+ / D- and I'm trying to communicate with a SIMCOM module which is connected on 15 and 16. I'll see if this helps. Thanks for opening the way.
Beta Was this translation helpful? Give feedback.
All reactions
-
I am trying to understand the serial comms from two sides, in the ESP32-S3 and at the PC.
At the ESP32-S3 end
Serial Comms on four interfaces:
- Onboard USB connections
- USB (direct to ESP32-S3 pins)
- UART( via FTDI to Tx,Rx pins)
- Pin connections
- Serial1(HardwareSerial) (to available GPIO)
- Serial2(HardwareSerial) (to available GPIO)
In an Arduino program:
- Serial.begin() refers to the UART pins Tx, Rx
- Serial1.begin() refers to HardwareSerial Serial1(Baud Rate1, Data Protocol1, TxD1 pin, RxD1 pin);
- Serial2.begin() refers to HardwareSerial Serial2(Baud Rate2, Data Protocol2, TxD2 pin, RxD2 pin);
- USBSerial.begin(); USB.begin(); refers to the USBCDC USBSerial to the ESP-S3 USB pins
So I can write/read program data to three serial ports - Serial, Serial1, and Serial2.
I can write/read debug messages to the (CDC) serial port USBSerial.
At the PC end
If I plug both the USB and the UART cables into the PC, they present as two separate serial ports, say COMxx (USB), COMyy(UART).
COMxx is selected in the Arduino IDE and the two settings (USB CDC On Boot -> Enabled, Upload Mode -> UART0 / Hardware CDC) mean that the debug messages are received in the IDE.
(But I cannot use COMxx for JTAG debug in this mode.)
Serial data to/from COMyy can be monitored using another Serial Terminal program (e.g. YAT)
Have I understood this correctly?
USBCDC USBSerial;
HardwareSerial Serial1(1);
HardwareSerial Serial2(2);
void setup() {
Serial.begin(115200)
Serial1.begin(115200 ...);
Serial2.begin(115200 ...);
USBSerial.begin(115200);
USB.begin();
}
void loop() {
...
Serial.println("TxRx data");
...
USBSerial.println("debug message");
...
}
Thankyou for yoyr help.
Beta Was this translation helpful? Give feedback.