Example Code for Arduino-Serial Port

Last revision 2026/01/31

This article explains how to use Arduino's Serial library for serial communication on FireBeetle 2 ESP32-E, including example code and setup details for real-time data printing.

Hardware Preparation

Other Preparation Work

We have learned how to light up the LED through the IO port before. In this lesson, we'll learn about the principle of serial communication. FireBeetle 2 ESP32-E development board has two hardware serial ports, and both of them are remappable. UART0, also Serial in Arduino, is used for USB.

Serial Name Arduino TX RX
UART0 Serial pin1 pin3
UART2 Serial2 pin17 pin16

Sample Code

Program function: the UART serial prints timing data once per second.

void setup() {
  Serial.begin(115200);    //Initialize the serial port and set the baud rate to 115200
}

void loop() {
 static unsigned long i = 0;  //Static variables(local variables), initialized only once
 Serial.println(i++);   //serial prints i++
 delay(1000);
}

Result

Open the serial monitor, set the baud rate to 115200, and you can see the printed value increasing every second.
DFR0654-Serial port result

Was this article helpful?

TOP