EasyManuals Logo

Freenove ESP32-S3 User Manual

Default Icon
142 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Page #43 background imageLoading...
Page #43 background image
Any concerns? support@freenove.com
41
Chapter 2 Serial Communication
www.freenove.com
The following is the program code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
String inputString = ""; //a String to hold incoming data
bool stringComplete = false; // whether the string is complete
void setup() {
Serial.begin(115200);
Serial.println(String("\nESP32S3 initialization completed! \r\n")
+ String("Please input some characters,\r\n")
+ String("select \"Newline\" below and Ctrl + Enter to send message to
ESP32S3. \r\n"));
}
void loop() {
if (Serial.available()) { // judge whether data has been received
char inChar = Serial.read(); // read one character
inputString += inChar;
if (inChar == '\n') {
stringComplete = true;
}
}
if (stringComplete) {
Serial.printf("inputString: %s \n", inputString);
inputString = "";
stringComplete = false;
}
}
In loop(), determine whether the serial port has data, if so, read and save the data, and if the newline
character is read, print out all the data that has been read.
Reference
String();
Constructs an instance of the String class.
For more information, please visit
https://www.arduino.cc/reference/en/language/variables/data-types/stringobject/
int available(void);
Get the number of bytes (characters) available for reading from the serial port. This is data that’s already
arrived and stored in the serial receive buffer.
Serial.read();
Reads incoming serial data.

Questions and Answers:

Question and Answer IconNeed help?

Do you have a question about the Freenove ESP32-S3 and is the answer not in the manual?

Freenove ESP32-S3 Specifications

General IconGeneral
BrandFreenove
ModelESP32-S3
CategoryControl Unit
LanguageEnglish