ESP32-C3 Serial

I am using an ESP32-C3 SuperMini Board and have run Serial (GPIO18 - USB_N, GPIO19 - USBD_P) and Serial0 (GPIO20 - U0RXD, GPIO21 - U0TXD).
But the diagram shows that there is another Serial (GPIO1 - U1RXD, GPIO0 - U1TXD), but it does not work. Serial1 compiles, but then Serial USB stops working.
Anyone know how to get Serial1 to work?



ESP32-C3  pcb 18x23 (2)

// ESP32-C3 SuperMini Board (Aliexpress 1.7$)
// (PlatformIO IDE)

/*
  X1:
  1 - GPIO5 / ADC2 / SCL / SPI_MISO
  2 - GPIO6 / SPI_MOSI
  3 - GPIO7 / SPI_SS
  4 - GPIO8 / PWM / SDA
  5 - GPIO8 / BOOT / SCL
  6 - GPIO10
  7 - GPIO20 / U0RXD (Serial0)
  8 - GPIO21 / U0TXD (Serial0)

  X2:
  8 - VBUS (5V)
  7 - GND
  6 - 3.3V
  5 - GPIO4 / ADC1 / SDA / SPI_SCK
  4 - GPIO3
  3 - GPIO2 - R10k - 3.3V
  2 - GPIO1 / U1RXD (Serial1 - No Work)
  1 - GPIO0 / U1TXD (Serial1 - No Work)
  
  GPIO8  - LED (Blue) - R5k1 - 3.3V
  GPIO9  - Button PROG (BOOT) - GND
  GPIO18 - USBD_N (Serial)
  GPIO19 - USBD_P (Serial)
*/

/* === platformio.ini ===
[env:seeed_xiao_esp32c3]
platform = espressif32
board = seeed_xiao_esp32c3
framework = arduino
*/

/*
RAM:   [          ]   4.3% (used 14076 bytes from 327680 bytes)
Flash: [==        ]  19.1% (used 250218 bytes from 1310720 bytes)
*/

#include <WiFi.h>

#define LED 8               // BUILTIN Invert

char data[250];
int tik = 0;

void setup() {
	pinMode(LED, OUTPUT);
	digitalWrite(LED, HIGH);
	delay(100);               // For start USB

	Serial.begin(115200);
	while(!Serial);
	Serial.println("START USB");

	Serial0.begin(115200);
	while(!Serial0);
	Serial0.println("START U0");

	//Serial1.begin(115200);
	//while(!Serial1);
	//Serial1.println("START U1");
}

void loop() {
	tik++;
	digitalWrite(LED, LOW);
	delay(100);
	digitalWrite(LED, HIGH);
	delay(1000);

	if (Serial.available()) {
		byte m = Serial.readBytesUntil('\n', data, sizeof (data)-1);
		data[m] = '\0';
		Serial.println(data);
	}

	if (Serial0.available()) {
		byte m = Serial0.readBytesUntil('\n', data, sizeof (data)-1);
		data[m] = '\0';
		Serial0.println(data);
	}

	//if (Serial1.available()) {
	//	byte m = Serial1.readBytesUntil('\n', data, sizeof (data)-1);
	//	data[m] = '\0';
	//	Serial1.println(data);
	//}

	Serial.print("TIK USB: "); Serial.println(tik);
	Serial0.print("TIK U0: "); Serial0.println(tik);
	//Serial1.print("TIK U1: "); Serial1.println(tik);
}

Reading the relevant code snippets…

Especially in conjunction with the XIAO_ESP32C3/pins_arduino.h tells me, that the variant seeed_xiao_esp32c3 does not explicitly define the RX1, TX1 pins which should be used for Serial1, and thus the default macros push it to RX1 = GPIO18, TX1 = GPIO19, which however exactly are the USB D+ and D- pins.

Try to explicitly give it the pin numbers you want in the .begin() method.

	Serial1.begin(115200, SERIAL_8N1, /* RX */ 1, /* TX*/ 0);
1 Like

Thank you for your reply. It worked.
Now 3 serial ports work simultaneously.

Hi ave can you please help me.
Like you, I would like to use the serial interface on the ESP32 superMini. I have a USB-serial converter on pins 20 and 21. But I don’t see any signal there.
What board definition are you using?
what needs to be done besides the normal “Serial.begin(115200);” The setup says “Serial.println(“wonderful”);” functions
I am grateful for every hint

When I used the Serial1 and upload to esp32c3 super mini. Lather I cant anymore upload. After long k…a pressing button reset and boot I recovered board. In my proj its need 2 separate usart: usb and phisical usart. Maybe It is Serial0, pin 20, 21 ???

Your question is difficult to understand. Can you describe this in more detail?

Hi, thank for astensione. Question is: What “Serial” (0,1,2) connected to GPIO 20,21 on board esp32-c3 super mini in PlatformIO?

That depends to the project settings.
Please show the full content of your platformio.ini

[env:esp32-c3-devkitm-1]
platform = espressif32
board = esp32-c3-devkitm-1
framework = arduino
monitor_speed = 115200
build_flags =
-DARDUINO_USB_CDC_ON_BOOT=1
-DARDUINO_USB_MODE=1
lib_ldf_mode = chain+
lib_deps =
mathworks/ThingSpeak@^2.1.1
adafruit/Adafruit VEML7700 Library@^2.1.6
lib_extra_dirs =
/home/igor/Documents/PlatformIO/Projects/mylib

With these settings Serial0 is tied to RX0 (GPIO20) and TX0 (GPIO21) and
the Serial object (without a number) outputs to the native USB-Port.

ok, thanks a lot, I suggest it is that. no problem, later I find the way. It is info for community, be accurate with board esp32-c3 super mini with Serial1.

Serial1 on the ESP32-C3 will go to GPIO’s 18 & 19 by default. But these GPIO’s aren’t available on a ESP32-C3 super mini.

1 Like