ESP32S2 Serial Print not Working

I have bought the open source espressif drone ESP32S2 ESP32 Flight Control Open Source Quadcopter ESP-Drone Drone Model Wifi Remote Control Crazyflie - AliExpress 26
Since it is open source, I wanted to try to code it with custom programs wit the Arduino IDE on windows 10, the first thing I did was to blink an LED on board and I was successful at it. Then, I wanted to read the data from the onboard MPU6050, but was unable to get anything in the serial monitor.
I tried to run just a simple Hellow world program and I still was unable to do it, nothing would show up on the serial monitor! This is the code:

#include "USB.h"

void setup() {
  USB.begin();
  Serial.begin(115200);
  delay(1000); // Wait for Serial to initialize
  Serial.println("Serial communication is working!");
}

void loop() {
  Serial.println("Hello from ESP32-S2!");
  delay(1000);
}

Here are all the testings I made to fix the problem:

  1. Enable USB CDC on Boot which is disabled by default under the tools settings.
  2. Try different board names, the ESP32S2 Wrover is not listed, so I have been using the ESP32S2 dev module and also tried with the ESP32S2 Native USB.
  3. Change the tools settings, such as try to erase flash at upload, change upload speed etc.
  4. Delete the esp32 core file manually and re install it again.
  5. Uninstall and reinstall the Arduino IDE (2.3.2).
  6. Download the espressif IDE and run an example file with the Hello World project.
  7. Use ChatGPT to find any other fix I could do but that also did not work.
  8. Check my drivers, I have the Silicon Labs CP210x USB to UART bridge version: 11.3.0.176.
    None of the above steps worked. So, I gave my code to a colleague of mine with: Windows 10, same Arduino IDE version and same esp32 core and same board and same tools settings and drivers. When he uploaded my code, he started receiving the hello world on the serial monitor successfully, we even changed the serial monitor baud rate on code and it was still working.
    The weird thing is, after flashing the code on the other machine, I connected the drone to my laptop and I was able to see the message correctly. So, I flashed the same code again from my machine and gave it to my colleague, again there was no output on the serial monitor.
    Just to be sure, I flashed the blink test again, and the LEDs on my drone were blinking fine, it is specifically the serial library that is not working properly.
    I also tried to:
  9. Make a new user account on my laptop.
  10. Make a new clean installation of the Arduino Ide 2.3.2 and the esp32 core form espressif.
  11. Download the old Arduino IDE: 1.8.12
    Still not working. I also set the Core Debug Level to Verbose as requested by GPT and apparently everything is fine, I asked my colleague to do the same, and I copied my message and my colleague’s message on GPT to spot any difference and they were identical.
    All this time, from the very first upload, the only thing I always get on the Serial Monitor at specifically 115200 baud rates, irrespectively to what I put in the code (i.e. 9600), is the following message:
ESP-ROM:esp32s2-rc4-20191025
Build:Oct 25 2019
rst:0x1 (POWERON),boot:0x8 (SPI_FAST_FLASH_BOOT)
SPIWP:0xee
mode:DIO, clock div:1
load:0x3ffe6110,len:0x578
load:0x4004b000,len:0x4
load:0x4004b004,len:0x978
load:0x4004f000,len:0x2d78
entry 0x4004b138

If I enable the Verbose debug I get:

ESP-ROM:esp32s2-rc4-20191025
Build:Oct 25 2019
rst:0x1 (POWERON),boot:0x8 (SPI_FAST_FLASH_BOOT)
SPIWP:0xee
mode:DIO, clock div:1
load:0x3ffe6110,len:0x578
load:0x4004b000,len:0x4
load:0x4004b004,len:0x978
load:0x4004f000,len:0x2d78
entry 0x4004b138
[   545][V][esp32-hal-periman.c:235] perimanSetBusDeinit(): Deinit function for type UART_RX (2) successfully set to 0x40083c00
[   556][V][esp32-hal-periman.c:235] perimanSetBusDeinit(): Deinit function for type UART_TX (3) successfully set to 0x40083bd0
[   570][V][esp32-hal-periman.c:235] perimanSetBusDeinit(): Deinit function for type UART_CTS (4) successfully set to 0x40083ba0
[   583][V][esp32-hal-periman.c:235] perimanSetBusDeinit(): Deinit function for type UART_RTS (5) successfully set to 0x40083b70
[   597][V][esp32-hal-periman.c:235] perimanSetBusDeinit(): Deinit function for type UART_RX (2) successfully set to 0x40083c00
[   610][V][esp32-hal-periman.c:235] perimanSetBusDeinit(): Deinit function for type UART_TX (3) successfully set to 0x40083bd0
[   623][V][esp32-hal-periman.c:235] perimanSetBusDeinit(): Deinit function for type UART_CTS (4) successfully set to 0x40083ba0
[   637][V][esp32-hal-periman.c:235] perimanSetBusDeinit(): Deinit function for type UART_RTS (5) successfully set to 0x40083b70
[   651][D][esp32-hal-tinyusb.c:772] tinyusb_enable_interface2(): Interface CDC enabled
[   661][D][esp32-hal-tinyusb.c:655] tinyusb_load_enabled_interfaces(): Load Done: if_num: 2, descr_len: 75, if_mask: 0x10
[   677][V][esp32-hal-periman.c:160] perimanSetPinBus(): Pin 44 successfully set to type UART_RX (2) with bus 0x3ffbf358
[   688][V][esp32-hal-periman.c:160] perimanSetPinBus(): Pin 43 successfully set to type UART_TX (3) with bus 0x3ffbf358
=========== Before Setup Start ===========
Chip Info:
------------------------------------------
  Model             : ESP32-S2
  Package           : 0
  Revision          : 0
  Cores             : 1
  CPU Frequency     : 240 MHz
  XTAL Frequency    : 40 MHz
  Embedded Flash    : No
  Embedded PSRAM    : No
  2.4GHz WiFi       : Yes
  Classic BT        : No
  BT Low Energy     : No
  IEEE 802.15.4     : No
------------------------------------------
INTERNAL Memory Info:
------------------------------------------
  Total Size        :   246648 B ( 240.9 KB)
  Free Bytes        :   217676 B ( 212.6 KB)
  Allocated Bytes   :    26096 B (  25.5 KB)
  Minimum Free Bytes:   212524 B ( 207.5 KB)
  Largest Free Block:   196596 B ( 192.0 KB)
------------------------------------------
Flash Info:
------------------------------------------
  Chip Size         :  4194304 B (4 MB)
  Block Size        :    65536 B (  64.0 KB)
  Sector Size       :     4096 B (   4.0 KB)
  Page Size         :      256 B (   0.2 KB)
  Bus Speed         : 80 MHz
  Bus Mode          : QIO
------------------------------------------
Partitions Info:
------------------------------------------
                nvs : addr: 0x00009000, size:    20.0 KB, type: DATA, subtype: NVS
            otadata : addr: 0x0000E000, size:     8.0 KB, type: DATA, subtype: OTA
               app0 : addr: 0x00010000, size:  1280.0 KB, type:  APP, subtype: OTA_0
               app1 : addr: 0x00150000, size:  1280.0 KB, type:  APP, subtype: OTA_1
             spiffs : addr: 0x00290000, size:  1408.0 KB, type: DATA, subtype: SPIFFS
           coredump : addr: 0x003F0000, size:    64.0 KB, type: DATA, subtype: COREDUMP
------------------------------------------
Software Info:
------------------------------------------
  Compile Date/Time : Jun 27 2024 16:08:10
  Compile Host OS   : windows
  ESP-IDF Version   : v5.1.4-358-gbd2b9390ef-dirty
  Arduino Version   : 3.0.2
------------------------------------------
Board Info:
------------------------------------------
  Arduino Board     : ESP32S2_DEV
  Arduino Variant   : esp32s2
  Arduino FQBN      : esp32:esp32:esp32s2:UploadSpeed=921600,CDCOnBoot=cdc,MSCOnBoot=default,DFUOnBoot=default,UploadMode=default,CPUFreq=240,FlashFreq=80,FlashMode=qio,FlashSize=4M,PartitionScheme=default,DebugLevel=verbose,PSRAM=disabled,EraseFlash=none,JTAGAdapter=default,ZigbeeMode=default
============ Before Setup End ============
=========== After Setup Start ============
INTERNAL Memory Info:
------------------------------------------
  Total Size        :   246648 B ( 240.9 KB)
  Free Bytes        :   217324 B ( 212.2 KB)
  Allocated Bytes   :    26352 B (  25.7 KB)
  Minimum Free Bytes:   212032 B ( 207.1 KB)
  Largest Free Block:   196596 B ( 192.0 KB)
------------------------------------------
GPIO Info:
------------------------------------------
  GPIO : BUS_TYPE[bus/unit][chan]
  --------------------------------------
    43 : UART_TX[0]
    44 : UART_RX[0]
============ After Setup End =============

I cannot understand what is the difference between mine and my colleagues setup, please provide help as I am really stuck and even if I could just change machine, I want to really understand what the problem is like a real engineer.

Would be gad to see the picture of your Board that contains ESP32S2 MCU.

probably

https://docs.espressif.com/projects/espressif-esp-drone/en/latest/hardware.html#esp32-s2-drone-v1-2

Thank you very much for the link. It is an interesting one -- I may try to get one from overseas via Daraz.

The Drone shows that it contains (probably as I can't read the lasered characters) ESP32S2 MCU and a micro USB connector. So, it should be easily programmable by the Arduino IDE.

I have a mini version of ESP32S2 with C-USB connector which I am going to program now and if it (still) works, I may forward the sketch and setup to OP.

the doc states

Basic Component List Number Notes
Main board 1 ESP32-S2-WROVER + MPU6050
1 Like

That is correct I have a ESP32 S2 Wover as also stated in my original post, and yes, your link to the documentation is the one I used extensively to try to figure out the problem I am having with no luck. @J-M-L @GolamMostafa

After a lot of fighting, I have managed to recall what I did about six months ago to manage communicaton between ESP32S2 (ES32-S2F) and Serial Monitor. Now, it works:

A: Setup:
Arduino IDE 2.2.1
Board: ESP32S2 dev Module
Port: COM3 (Deneyap Mini)
USB CDC on Boot: "Enabled" //(default option)
Upload Mod: "UART0" //(default option)
Upload Speed: "921600" //(default option)

B: Sketch:

char myData[20];

void setup() {
  // initialize digital pin LED_BUILTIN as an output.
  pinMode(15, OUTPUT);
}

// the loop function runs over and over again forever
void loop() {

  digitalWrite(15, HIGH);  // turn onBoard LED 
  delay(1000);             // wait for a second
  digitalWrite(15, LOW);   // turn off onBoard LED
  delay(1000);             // wait for a second

  byte n = Serial.available(); //receive string from InputBox of Serial Monitor
  if (n != 0) {
    byte m = Serial.readBytesUntil('\n', myData, sizeof myData - 1);
    myData[m] = '\0'; //null character
    Serial.println(myData); //Send back the received string to OutputBox of SM
  }
}

C: Input/Output:

Are you here?

D: Operation:
1. Check Deiice Manager, and I have fond like this:
Ports ==> USB Serial Device (COM3)

2. Click Upload.
There could be connection fault and uploading is aborted.

3. There is a dong sound.

4. Open Device Manage. I have found like this:
Ports ==> USB Serial Device (COM3)
Other Devices ==> ESP32-S2

5. Click on Upload. The sketch is uploaded. The onBoard LED is blinking.

6. Open Serial Monitor with newline opton in Line ending box. Enter this string: "Are you here?" in the InputBox (Fig-1) of Serial Monitor and then click on the Send Button. Check that the same message has appeared on the OutputBox of Serial Monitor.


Figure-1:

7. Reading the posts of this thread may worth.

I have repeated your steps, after uploading your code the LED is blinking but there is no message out of the Serial Monitor

Have you followed all the steps of D: Operation Section of post #7? Which IDE version are you using?

Yes followed all of them and still did not work, I narrowed down where the issue is from, it must be related too the tool chain. Currently trying to figure out how. IDE is 2.3.2

Did you try with IDE 2.3.1 or IDE 1.8.19?

Yes, again, as stated in the original post, I also tried the 1.8.12.

I have also already narrowed down the issue: it has to do with the tool chain. Here is the reasoning.

I made again a second user on my laptop. I did re installed the espressif IDE and tools following this doc: Get Started - ESP32-S2 - — ESP-IDF Programming Guide release-v4.4 documentation

The other thing I did was run file in one the folders (as stated by the guide) to actually make the tool chain work.

And I was able to use the serial print on both the Arduino IDE and Espressif IDE on the second account.

When I tried to do the same on my main account, it did not work and it also stopped working on the second account because I messed with the installation. I tried to reinstall it on my second account, but the serial works only on the EspIDE and not on the Arduino IDE.

That is why I am trying to understand exactly how the tool chain work and how to link it to teh Arduino IDE.

In the A: Setup of post #7, I have clearly said to use IDE 2.2.1 which I think you have ignored!

I used the that, it made no difference, so I reinstalled the latest version.

I have made the Serial print work by changing the following option only, all the rest of the setup has not changed from the initial setup:

USB CDC ON BOOT: "DISABLED"

If I enable it it stops working, if I disable it then I can use the Serial Monitor.

I have no idea why this happens, thanks for reading this post and helping to get to a solution.