Serial.readString() reads characters from the serial buffer into a String. The function terminates if it times out (see setTimeout()).
Serial.readString() inherits from the Stream utility class.
- Serial: serial port object. See the list of available serial ports for each board on the Serial main page.
- A String() read from the serial buffer
- Type "HELLO" on Serial Monitor and click Send button:
- The result on Serial Monitor:
※ NOTES AND WARNINGS:
- Serial.readString() may read a single incoming string in multiple times (resulting in multiple fragments). To read a single string at one time, use Serial.readStringUntil() with delimiter instead.
- Serial functions are not only used for the communication between an Arduino board and Serial Monitor of Arduino IDE but also used for the communication between:
- An Arduino board and other Arduino board
- An Arduino board and other sensors/devices
- An Arduino board and computer (any Serial software on computer)