ESP32-S3 Serial Monitor under Linux Not working

Hi, i have a Problem with my ESP32-S3 WROOM-1.
Im trying to Get the Serial Monitor working but It wont.

Next my Spezifications:
Board: ESP32-S3 WROOM-1 n16r8
The Docs.: ESP32-S3-DevKitC-1 v1.1 - ESP32-S3 - — esp-dev-kits latest documentation

IDE: Vscode with PlatformIO
OS: Manjaro Linux Latest Version
Hardware: Lenovo Ideapad 3, Ryzen 7 5700U, 16GB Ram, Radeon Graphics.

The .ini:

[env:esp32-s3-devkitc-1-n16r8v]
platform = espressif32
board = esp32-s3-devkitc-1-n16r8v
framework = arduino
monitor_speed = 115200
lib_deps =
  Adafruit_NeoPixel

So. I can Upload my Code via the USB C COM-Port and IT works fine. But when i unplug It and trying to use the UART-USB for the SerialMonitor It wont Work.

Error 2 during Upload. Cannot find the Upload-Port.

I Also have Tryed the issue fixes in the Documentation. I added my User to the “uucp” group and i also checked all Ports with "ls /dev/tty* " but the Port still Not appears.
Then i Tryed to reset the Board with the USB-C COM-Port, and plugged It Out to Plug in the cable in the UARt-USB Port and start IT with boot.
Still Not working…
I Tryed every Port i have.

This is my Project. I want to make a car that can Drive around obstacles. Yes there are Better ways to do It, i also could by a kit where is everything given also a 1 by 1 Manual but i wont. Because thats Not the lern effect i want.

Maybe you Guys can Help me i asked in multiple Groups but Sometimes No one answeres otherwise they could Not solve the Problem and sayed i should ask Here!

Thank you very much, and im so sorry for my Bad english, im still learning. :slight_smile:

Here is the Code:


#include <Arduino.h>
// Sensor front
#define trigPin1 6
#define echoPin1 7
// Sensor right
#define trigPin2 40
#define echoPin2 39
// Sensor left
#define trigPin3 8
#define echoPin3 18
// engine A
#define motorPin1 20
#define motorPin2 21
// engine B
#define motorPin3 11
#define motorPin4 10

// define sound speed in cm/uS
#define SOUND_SPEED 0.034
#define CM_TO_INCH 0.393701

long durationFront;
long durationRight;
long durationLeft;

float distanceCmFront;
float distanceCmRight;
float distanceCmLeft;

void setup() {
Serial.begin(115200); // Starts the serial communication
Serial.print("PROGRAM START");
pinMode(trigPin1, OUTPUT); // Set the trigPin1 as an Output
pinMode(echoPin1, INPUT); // Set the echoPin1 as an Input

pinMode(trigPin2, OUTPUT); // Set the trigPin2 as an Output
pinMode(echoPin2, INPUT); // Set the echoPin2 as an Input
pinMode(trigPin3, OUTPUT); // Set the trigPin3 as an Output
pinMode(echoPin3, INPUT); // Set the echoPin3 as an Input

pinMode(motorPin1, OUTPUT); // Set the enginePin1 as an Output
pinMode(motorPin2, OUTPUT); // Set the enginePin2 as an Output

pinMode(motorPin3, OUTPUT); // Set the enginePin3 as an Output
pinMode(motorPin4, OUTPUT); // Set the enginePin4 as an Output
}

enum motor_state { // This is a list with all different states for the motor
MOTOR_STATE_FORWARD,
MOTOR_STATE_BACKWARD,
MOTOR_STATE_STOP,
TURN_RIGHT,
TURN_LEFT,
TURN_AROUND,
UTURN, 
};

void change_motor_state(enum motor_state state){ // With this function will the Motor be controlled
switch (state) {
case MOTOR_STATE_FORWARD: // Let the car drive forward
digitalWrite(motorPin1, LOW);
digitalWrite(motorPin2, HIGH);
digitalWrite(motorPin3, LOW);
digitalWrite(motorPin4, HIGH);
break;
case MOTOR_STATE_BACKWARD: // Let the car drive backwards
digitalWrite(motorPin1, HIGH);
digitalWrite(motorPin2, LOW);
digitalWrite(motorPin3, HIGH);
digitalWrite(motorPin4, LOW);
break;
case MOTOR_STATE_STOP: // Stops the car
digitalWrite(motorPin1, LOW);
digitalWrite(motorPin2, LOW);
digitalWrite(motorPin3, LOW);
digitalWrite(motorPin4, LOW);
break;
case TURN_RIGHT: // 90 degrees turn to the right
digitalWrite(motorPin1,LOW);
digitalWrite(motorPin2,HIGH);
digitalWrite(motorPin3,HIGH);
digitalWrite(motorPin4,LOW);
delay(2000);
digitalWrite(motorPin1, LOW);
digitalWrite(motorPin2, LOW);
digitalWrite(motorPin3, LOW);
digitalWrite(motorPin4, LOW);
}
}

float calc_sensor_front(){ // This function reads the distance in front of the car in cm

digitalWrite(trigPin1, LOW); // Clears the TriggerPin
delayMicroseconds(2);
digitalWrite(trigPin1, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin1, LOW);
durationFront = pulseIn(echoPin1, HIGH); // Reads the echoPin, returns the sound wave travel time in microseconds
// Calculate the distance
distanceCmFront = durationFront * SOUND_SPEED/2;
// Prints the distance in the Serial Monitor
Serial.print("Distance_Front (cm): ");
Serial.println(distanceCmFront);
delay(1000);
return distanceCmFront; // The return gives me the different distances in front of the car
}

float calc_sensor_right(){ // This function reads the distance on the right of the car in cm

digitalWrite(trigPin2, LOW); // Clears the TriggerPin
delayMicroseconds(2);

digitalWrite(trigPin2, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin2, LOW);
durationRight = pulseIn(echoPin2, HIGH); // Reads the echoPin, returns the sound wave travel time in microseconds
// Calculate the distance
distanceCmRight = durationRight * SOUND_SPEED/2;
// Prints the distance in the Serial Monitor
Serial.print("Distance_Right (cm): ");
Serial.println(distanceCmRight);
delay(1000);
return distanceCmRight; // This return gives me the different distances on the right of the car
}

float calc_sensor_left(){ //This function reads the distance on the left of the car in cm

digitalWrite(trigPin3, LOW); // Clears the TriggerPin
delayMicroseconds(2);

digitalWrite(trigPin3, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin3, LOW);
durationLeft = pulseIn(echoPin3, HIGH); // Reads the echoPin, returns the sound wave travel time in microseconds
// Calculate the distance
distanceCmLeft = durationLeft * SOUND_SPEED/2;
// Prints the distance in the Serial Monitor
Serial.print("Distance_Left (cm): ");
Serial.println(distanceCmLeft);
delay(1000);
return distanceCmLeft; // This return gives me the different distances on the left of the car
}

void loop() {
Serial.print("PROGRAM START");
change_motor_state(MOTOR_STATE_FORWARD); // Starting the Motor Forward

// TEST BEGIN
digitalWrite(trigPin1, LOW); // Clears the TriggerPin
delayMicroseconds(2);

digitalWrite(trigPin1, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin1, LOW);
durationFront = pulseIn(echoPin1, HIGH); // Reads the echoPin, returns the sound wave travel time in microseconds
// Calculate the distance
distanceCmFront = durationFront * SOUND_SPEED/2;
// Prints the distance in the Serial Monitor
Serial.print("Distance_Front (cm): ");
Serial.println(distanceCmFront);
delay(1000);
// TEST END

// TEST BEGIN


/*if (sensorFront <= 50) {
change_motor_state(MOTOR_STATE_STOP);
}
else if(sensorLeft <= 50 && sensorRight <= 50 && sensorFront <= 50) {
change_motor_state(MOTOR_STATE_STOP);
} */
}

Where did you get the esp32-s3-devkitc-1-n16r8v.json from? This is not standardized. So please show the content of this file.

Probably your board manifest has

      "extra_flags": [
        "-DARDUINO_USB_CDC_ON_BOOT=1"

This will “route” the output of the Serial object to the native USB port.

In this case you need to unflag the macro in your platformio.ini

build_unflags=
  -DARDUINO_USB_CDC_ON_BOOT

See How to post logs and code in PlatformIO Community Forum

Hi, thanks for your response !
here is the Content of the .json u asked for:


{
    "build": {
      "arduino":{
        "ldscript": "esp32s3_out.ld",
        "partitions": "default_16MB.csv",
        "memory_type": "qio_opi"
      },
      "core": "esp32",
      "extra_flags": [
        "-DARDUINO_ESP32S3_DEV",
        "-DBOARD_HAS_PSRAM",
        "-DARDUINO_USB_MODE=1",
        "-DARDUINO_USB_CDC_ON_BOOT=1"
      ],
      "f_cpu": "240000000L",
      "f_flash": "80000000L",
      "flash_mode": "qio",
      "psram_type": "opi",
      "hwids": [
        [
          "0x303A",
          "0x1001"
        ]
      ],
      "mcu": "esp32s3",
      "variant": "esp32s3"
    },
    "connectivity": [
      "wifi",
      "bluetooth"
    ],
    "debug": {
      "default_tool": "esp-builtin",
      "onboard_tools": [
        "esp-builtin"
      ],
      "openocd_target": "esp32s3.cfg"
    },
    "frameworks": [
      "arduino",
      "espidf"
    ],
    "name": "Espressif ESP32-S3-DevKitC-1-N16R8V (16 MB QD, 8MB PSRAM)",
    "upload": {
      "flash_size": "16MB",
      "maximum_ram_size": 327680,
      "maximum_size": 16777216,
      "require_upload_port": true,
      "speed": 921600
    },
    "url": "https://docs.espressif.com/projects/esp-idf/en/latest/esp32s3/hw-reference/esp32s3/user-guide-devkitc-1.html",
    "vendor": "Espressif"
  }

I do found it on ArduinoForum:

by people having the same problem to connect with the board, because it is not the same board as in the documentation above in my post.
i bought this one from amazon an there was some Problems that i had to solder to get the onboard RGB-LED blinking…
for that it totally worked fine.

[quote=“nrtkonto, post:3, topic:44764, full:true”]
Hi, thanks for your response !
here is the Content of the .json u asked for:


{
    "build": {
      "arduino":{
        "ldscript": "esp32s3_out.ld",
        "partitions": "default_16MB.csv",
        "memory_type": "qio_opi"
      },
      "core": "esp32",
      "extra_flags": [
        "-DARDUINO_ESP32S3_DEV",
        "-DBOARD_HAS_PSRAM",
        "-DARDUINO_USB_MODE=1",
        "-DARDUINO_USB_CDC_ON_BOOT=1"
      ],
      "f_cpu": "240000000L",
      "f_flash": "80000000L",
      "flash_mode": "qio",
      "psram_type": "opi",
      "hwids": [
        [
          "0x303A",
          "0x1001"
        ]
      ],
      "mcu": "esp32s3",
      "variant": "esp32s3"
    },
    "connectivity": [
      "wifi",
      "bluetooth"
    ],
    "debug": {
      "default_tool": "esp-builtin",
      "onboard_tools": [
        "esp-builtin"
      ],
      "openocd_target": "esp32s3.cfg"
    },
    "frameworks": [
      "arduino",
      "espidf"
    ],
    "name": "Espressif ESP32-S3-DevKitC-1-N16R8V (16 MB QD, 8MB PSRAM)",
    "upload": {
      "flash_size": "16MB",
      "maximum_ram_size": 327680,
      "maximum_size": 16777216,
      "require_upload_port": true,
      "speed": 921600
    },
    "url": "https://docs.espressif.com/projects/esp-idf/en/latest/esp32s3/hw-reference/esp32s3/user-guide-devkitc-1.html",
    "vendor": "Espressif"
  }

I do found it on ArduinoForum:

by people having the same problem to connect with the board, because it is not the same board as in the documentation above in my post.
i bought this one from amazon an there was some Problems that i had to solder to get the onboard RGB-LED blinking…
for that it totally worked fine.

I tried to unflag it with ur example like u said, but it is still not working.

Here is the Error i got from the Console:

Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/espressif32/esp32-s3-devkitc-1-n16r8v.html
PLATFORM: Espressif 32 (6.9.0) > Espressif ESP32-S3-DevKitC-1-N16R8V (16 MB QD, 8MB PSRAM)
HARDWARE: ESP32S3 240MHz, 320KB RAM, 16MB Flash
DEBUG: Current (esp-builtin) On-board (esp-builtin) External (cmsis-dap, esp-bridge, esp-prog, iot-bus-jtag, jlink, minimodule, olimex-arm-usb-ocd, olimex-arm-usb-ocd-h, olimex-arm-usb-tiny-h, olimex-jtag-tiny, tumpa)
PACKAGES: 
 - framework-arduinoespressif32 @ 3.20017.0 (2.0.17) 
 - tool-esptoolpy @ 1.40501.0 (4.5.1) 
 - tool-mkfatfs @ 2.0.1 
 - tool-mklittlefs @ 1.203.210628 (2.3) 
 - tool-mkspiffs @ 2.230.0 (2.30) 
 - toolchain-riscv32-esp @ 8.4.0+2021r2-patch5 
 - toolchain-xtensa-esp32s3 @ 8.4.0+2021r2-patch5
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 36 compatible libraries
Scanning dependencies...
No dependencies
Building in release mode
Retrieving maximum program size .pio/build/esp32-s3-devkitc-1-n16r8v/firmware.elf
Checking size .pio/build/esp32-s3-devkitc-1-n16r8v/firmware.elf
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM:   [=         ]   5.8% (used 19060 bytes from 327680 bytes)
Flash: [          ]   4.3% (used 280557 bytes from 6553600 bytes)
Configuring upload protocol...
AVAILABLE: cmsis-dap, esp-bridge, esp-builtin, esp-prog, espota, esptool, iot-bus-jtag, jlink, minimodule, olimex-arm-usb-ocd, olimex-arm-usb-ocd-h, olimex-arm-usb-tiny-h, olimex-jtag-tiny, tumpa
CURRENT: upload_protocol = esptool
Looking for upload port...
Auto-detected: /dev/ttyS31
Uploading .pio/build/esp32-s3-devkitc-1-n16r8v/firmware.bin
esptool.py v4.5.1
Serial port /dev/ttyS31

A fatal error occurred: Could not open /dev/ttyS31, the port doesn't exist
*** [upload] Error 2
============================================================================= [FAILED] Took 5.63 seconds =============================================================================

 *  The terminal process "platformio 'run', '--target', 'upload'" terminated with exit code: 1. 
 *  Terminal will be reused by tasks, press any key to close it.

Check your com ports. It will be different to /dev/ttyS31.
You might also install the necessary drivers for the onboard Serial to USB chip (probably a CH343)

okay, i installed following driver: https://aur.archlinux.org/packages/ch343-dkms

now are both USB-C Ports are not working and i dont know why…
My ports in ls /dev/tty* havent changed.
I also rebooted my laptop to load the driver.

Here the Error again. but i dont see any differents

--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/espressif32/esp32-s3-devkitc-1-n16r8v.html
PLATFORM: Espressif 32 (6.9.0) > Espressif ESP32-S3-DevKitC-1-N16R8V (16 MB QD, 8MB PSRAM)
HARDWARE: ESP32S3 240MHz, 320KB RAM, 16MB Flash
DEBUG: Current (esp-builtin) On-board (esp-builtin) External (cmsis-dap, esp-bridge, esp-prog, iot-bus-jtag, jlink, minimodule, olimex-arm-usb-ocd, olimex-arm-usb-ocd-h, olimex-arm-usb-tiny-h, olimex-jtag-tiny, tumpa)
PACKAGES: 
 - framework-arduinoespressif32 @ 3.20017.0 (2.0.17) 
 - tool-esptoolpy @ 1.40501.0 (4.5.1) 
 - tool-mkfatfs @ 2.0.1 
 - tool-mklittlefs @ 1.203.210628 (2.3) 
 - tool-mkspiffs @ 2.230.0 (2.30) 
 - toolchain-riscv32-esp @ 8.4.0+2021r2-patch5 
 - toolchain-xtensa-esp32s3 @ 8.4.0+2021r2-patch5
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 36 compatible libraries
Scanning dependencies...
No dependencies
Building in release mode
Retrieving maximum program size .pio/build/esp32-s3-devkitc-1-n16r8v/firmware.elf
Checking size .pio/build/esp32-s3-devkitc-1-n16r8v/firmware.elf
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM:   [=         ]   5.8% (used 18860 bytes from 327680 bytes)
Flash: [          ]   4.1% (used 265569 bytes from 6553600 bytes)
Configuring upload protocol...
AVAILABLE: cmsis-dap, esp-bridge, esp-builtin, esp-prog, espota, esptool, iot-bus-jtag, jlink, minimodule, olimex-arm-usb-ocd, olimex-arm-usb-ocd-h, olimex-arm-usb-tiny-h, olimex-jtag-tiny, tumpa
CURRENT: upload_protocol = esptool
Looking for upload port...
Auto-detected: /dev/ttyS31
Uploading .pio/build/esp32-s3-devkitc-1-n16r8v/firmware.bin
esptool.py v4.5.1
Serial port /dev/ttyS31

A fatal error occurred: Could not open /dev/ttyS31, the port doesn't exist
*** [upload] Error 2
============================================================================= [FAILED] Took 5.37 seconds =============================================================================

 *  The terminal process "platformio 'run', '--target', 'upload'" terminated with exit code: 1. 
 *  Terminal will be reused by tasks, press any key to close it. 

So this isnt about Serial Monitor, this is about the connection itself (drivers, rights etc…)

Did you check Establish Serial Connection with ESP32-S3 - ESP32-S3 - — ESP-IDF Programming Guide v5.3.2 documentation

Hi, sorry for my very late answer, but i guess i found a solution.
Im not trying to use the “UART-USB-port” anymore and just use the the other one.
I changed two flags in the .json from the board:

"-DARDUINO_USB_MODE=0",
        "-DARDUINO_USB_CDC_ON_BOOT=0"

And additionaly i have used the command pio device monitor and it nor runs without issues and i have Serialmonitor to get an output.

Maybe i will try to solve the problem with the “UART-USB-port” again, but not today and not tomorror…

Thanks for your time and Help!
Have a nice day! :slight_smile:

But with this settings you are using the UART port !

ARDUINO_USB_CDC_ON_BOOT Output
0 UART (Serial to USB Chip)
1 native USB