ESP32 -S2/3 NAtive USB and Serial via TX/RX

HI,

I'm trying to get the native usb running along with the uart. The goal is to get the "regular" Serial to read/write data and then Write read data to the usb.

Basically forwarding data from the serial monitor to the USB and back.

I'm not so sure everything is working, so i would appreciate any help in explaining the things that should be done (and i might not did) Thanks.

The ESP should be in the OTG mode of course.

#include <Arduino.h>
#include <Wifi.h>

#include "USB.h"

void setup() {
  // put your setup code here, to run once:
  // pinMode(LED_IO1, OUTPUT); 
  
  Serial.begin(115200);
  Serial.println("This is the PC test");
  Serial.println("Test Begin");
  
  // USB Communication init
  SerialUSB.begin(115200);
  USB.begin();
}
void loop() {
  while (Serial.available()>0) {
      
  char UART_Data_IN = Serial.read();//Read_UART0 ();
      SerialUSB.write(ART_Data_IN);
      }//if   
  while (SerialUSB.available()) {
      char hex[3];
      hex[0] = SerialUSB.read();
      hex[1] = SerialUSB.read();
      hex[2] = '\0';
      long byteRead = strtol(hex, NULL, 16);
      Serial.write(byteRead);
    }
}

The uart to USB is on com 4 and the usb is on com7. the problem is that i cant open the regular terminal even though it should be on com4, it says there's a probelm with com7. Any way i can configure that ? or understand what the problem is? 

If it helps, i'm using VSCode with platformIO

Thanks, 

Schematics would likely make more helpers interested.
A block diagram showing what the main idea is would also be good.

Hi @Railroader the idea is just to transfer data between UART0 and the natiev USB.

Apperantly i had a driver issue with the windows USB driver, so it didn't work. It did work on the Mac .

In addition, in order to get the ESP32 S3 S2 into usb otg in VSCODE you need to add this to the platformio.ini file:
build_unflags = -DARDUINO_USB_MODE=1

And after that it worked

Case solved. Thanks for telling.

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