4

I'm new to micro-controllers. I've got an ESP32-S3-DevKitC-1 and I'm trying to do a simple hello world with the Serial. I'm using the Arduino IDE for flashing and serial monitoring. My code is:

/**
 * As simple as it gets, right? Setup the Serial, wait on it. The periodically print during the loop.
 */
void setup() {
  Serial.begin(9600);   // Initialize serial communications with the PC
  while (!Serial);      
}

void loop() { Serial.println("Hello World"); delay(1000); }

I've tried various baud rates. I've also tried a few different configurations for flashing-- this includes flashing over the UART port with upload mode 'UART0/Hardware CDC' and 'USB-OTG CDC (TinyUSB)'. I'm basically at guess and check right now and am looking for some tips or resources to understand the ports. My serial always shows gibberish. I've even tried miniterm like this:

pyserial-miniterm /dev/cu.usbserial-1410 9600

Spina
  • 139
  • 1
  • 4
  • 1
    How do you install the Arduino-ESP32 core on your IDE? Arduino-ESP32 is still only support the ESP32-S3 on "development" release only, if you installed the ESP32-S3 with the "stable" release, it won't work with ESP32-S3 yet. See the installing. – hcheung Apr 28 '22 at 03:58

2 Answers2

5

The USB port connects directly to the D+/D- pins of the ESP32, which allows it to act as a USB host. CircuitPython, for instance, uses this functionality to look like a USB flash drive. You could also write software that might have the ESP32 mimic a keyboard or mouse or other simple USB devices over this port. You generally will not use it to program the board, though CircuitPython does install its own firmware updates from files written to the USB flash drive its boot loader presents.

The UART port connects to a USB/serial chip which is connected to the RX and TX pins of the ESP32. If you want to flash firmware to the board in a traditional way (using esptool.py) you'd use this connector. You may need to press the BOOT button to get the device into firmware download mode.

The ESP32 defaults to 115200 baud, which is why you'd see gibberish at 9600 baud - that would be the boot loader messages.

You'll need to ensure that the firmware you're trying to flash to it is built for the correct model CPU and also for the amount of PSRAM on your board. I would stick with 115200 baud for the serial speed so that you'll be able to see the boot loader messages as well as any output of your program, if it's correctly built and flashed to the board. [edit: as @hcheung pointed out there is no official stable support for the S3 in the Arduino Core at the time this question was asked]

You can learn more about your device by reading the official Espressif documentation on it.

romkey
  • 1,554
  • 8
  • 10
-1

I had to spent some additional time debugging my smart hardware electronics for a home automation wall mount switch based on the ESP32 S3 ( see it on my GitHub here )

enter image description here

because I was able to upload the firmware code into it however when reading serial output it only displayed "gibberish" characters.

On the internet I could not find the answer, so I had to work harder to find the solution. Common problems found when dealing with serial output errors are:

  • poor UART ground
  • absence of a 500 Ohm resistor on the TX line
  • UART cable to long
  • track coupling and track length mismatch

are all hardware issues that cause serial communication errors and malfunctioning. However, for the ESP32 there's one missing on the list above. On this particular hardware, I had incorrectly soldered the RTC crystal of 32,768MHz into the MCU crystal place which is for one of 40MHz. The result was, it is possible to do firmware upload using a 32,768Mhz crystal for the MCU however, and due to the incorrect clock frequency, serial output is no longer 115200bps and displays "gibberish" characters.

In summary make sure the crystal has the correct clock frequency value.

  • so you used a wrong crystal on your PCB and you add this as an answer to the question about the two USB connectors on an official dev kit? – Juraj Jul 20 '23 at 13:16
  • Don't expect to get an answer tailored to your understanding. Read all here, and make your own assessment of what can be wrong So, on my case, i accidentality used a different crystal. Firmware upload is still possible , no errors. However, serial communication is affected and shows "gibberish" . So in sum, check the crystal if has the correct frequency and if is working properly. – Miguel Tomás Jul 21 '23 at 14:14