Chapter 01 Serial

Project 1.1 SerialRW

Component List

Freenove ESP32-S3 Display x 1

Chapter01_02

USB cable x1

Chapter01_03

Circuit

Connect Freenove ESP32-S3 Display to the computer with USB cable.

../../../_images/Chapter01_04.png

Sketch

Open “Sketch_01.1_SerialRW” folder under “Freenove_ESP32_S3_Display_FNK0115\Sketch” and double-click “Sketch_01.1_SerialRW.ino”.

Sketch_01.1_SerialRW

 1/*
 2* @ File:   Sketch_01.1_SerialRW.ino
 3* @ Author: [Eason Shen]
 4* @ Date:   [2026-07-03]
 5*/
 6
 7String inputString = "";      //a String to hold incoming data
 8bool stringComplete = false;  // whether the string is complete
 9
10void setup() {
11  Serial.begin(115200);
12  while (!Serial);
13  Serial.println(String("\nESP32-S3 initialization completed!\n")
14                + String("Please input some characters,\n")
15                + String("select \"Newline\" below and click send button. \n"));
16}
17
18void loop() {
19  if (Serial.available()) {         // judge whether data has been received
20    char inChar = Serial.read();         // read one character
21    inputString += inChar;
22    if (inChar == '\n') {
23      stringComplete = true;
24    }
25  }
26  if (stringComplete) {
27    Serial.printf("InputString: %s", inputString);
28    inputString = "";
29    stringComplete = false;
30  }
31}

Code Explanation

Set the baud rate to 115200.

1Serial.begin(115200);

Determine whether there is data in the serial port buffer.

1if (Serial.available()) {         // judge whether data has been received

Receive serial port data and save it in the inputString string.

1char inChar = Serial.read();         // read one character
2inputString += inChar;

The purpose of this code is to display data on the serial monitor. Click “Upload” to upload the code to Freenove ESP32-S3 Display.

After downloading the code, open the serial port monitor, and set the baud rate to 115200, input any data in the messages bard and press Enter key, Freenove ESP32-S3 Display will print the received data.

Please note: This chapter does not involve the use of the screen. After the code for this chapter, the screen may not light up, which is normal and not a hardware malfunction. If you need to verify whether the screen is functioning properly, please refer to Chapter 10 for testing.

../../../_images/Chapter01_05.png

Reference

int available()

Serial.available() checks the number of bytes currently available to read in the Serial receive buffer. It returns the number of bytes available (int type), or 0 if the buffer is empty.

int read ()

Serial.read() reads one byte of data from the Serial receive buffer and returns it as an int. If no data is available to read, it returns -1.