Port not detected/updated after it changes

Hi all. New to the platform.

I’m using PlatformIO in VSCode. I can run command manually but the buttons for serial connection and upload are not working because it’s trying to use the old port.

I do see the device in Devices > Serial, at Port /dev/cu.usbmodem1101.
But it’s trying to connect to /dev/cu.usbmodem101 when I use the functions mentioned above.

Related, what makes it change ports? It stayed consistent since last night and I’ve unplugged the device in between.

I understand I could set the port in platformio.ini but I’d rather use the auto detect.
Suggestions welcome, lmk if you need more info.

platformio.ini:

[env:esp32-s3-wroom-1-n16r8]
platform = espressif32
board = ESP32-S3-DevKitC-1  
framework = arduino
build_flags =
	-D ARDUINO_USB_CDC_ON_BOOT=1
lib_deps =
  WiFi

The answer to this question is:

You are using the built-in native USB port of the ESP32-S3.
This is also restarted when the ESP32-S3 is reset.
As a result, the connection to the computer is lost for a short time.

This does not happen with a UART 2 USB chip, as the external chip is not restarted and the connection is therefore kept alive.

Ok, thanks. Trying to digest all the details here. :slight_smile:

That flag was added because, before I added it, I could upload and make a serial connection but was not seeing any output.

Maybe folks typically run 2 cables- one for programming (labeled “Pass-through USB&OTG”), another for serial (“USB to Serial”)?

You can do both on both ports (uploading and serial monitor).

The flag just defines that the Serial object is of type USBCDC or HWCDC instead of HardwareSerial. See

and

It feels more like PlatformIO (in VSCode) is caching the port for my device and no restart of the editor or device gets it to use the port it detects and lists in the Devices tab.

I removed the build flag, used cli to upload it, and I can tell it was successful bc of the light blink pattern.

PlatformIO buttons still want to use modem101, and now when I use cli to connect to serial I don’t see my printlns.

>  pio device monitor --port /dev/cu.usbmodem1101 
--- Terminal on /dev/cu.usbmodem1101 | 115200 8-N-1
--- Available filters and text transformations: colorize, debug, default, direct, esp32_exception_decoder, hexlify, log2file, nocontrol, printable, send_on_enter, time
--- More details at https://bit.ly/pio-monitor-filters
--- Quit: Ctrl+C | Menu: Ctrl+T | Help: Ctrl+T followed by Ctrl+H

Current code fwiw:

#include <Arduino.h>
#include <WiFi.h> 

void setup()
{
  Serial.begin(115200);
  Serial.println("ESP32-S3 Booted!");
  // wifi does connect to my network
  // ...
}

void loop()
{
  Serial.println("LED ON...");
  digitalWrite(LED_BUILTIN, HIGH);
  delay(5000);
  Serial.println("LED OFF...");
  digitalWrite(LED_BUILTIN, LOW);
  delay(10000);
}


Then the Serial object outputs to the UART Port and you have to use the other USB-Port on your DevKit labled with COM / UART or something like that to see the output on your computer. Also the used com-port will be different on your computer.

Back at it. It sounds like you’re suggesting I need 2 USB cables- the current one seems to work for flashing and I can run the debugger, but I can’t also do serial over it so I’ll need another for the UART port for that. Is that typical or something about this device?

Since I can run the debugger and set breakpoints that’s probably good enough, just making sure I understand things.

Thanks again.

No, you can use the native USB port for serial output and for debugging.

But, it is easier to use the UART port for serial output. This is simply because the connection via the native USB connection is temporarily lost when the ESP32 is reset. This disconnection does not occur with the UART port, as the serial connection is maintained by an independent chip.