Serial Parse Data

Parse data in a specified data format through the serial port.

Device connection

Hardware connection

Use Type-B data cable to connect Arduino Uno and computer.

Software connection

Open the "Arduino IDE" software and select the model and serial port number corresponding to the development board.

Serial port parsing data

Control principle

Receive data through the serial port and determine whether the data is in the specified format, parse and store the specified data.

Control pin

Use the serial port on the Arduino IDE to send and parse data.

Serial portArduino Uno
RX0
TX1

Data format (communication protocol)

We only parse data in two data formats.

Data formatDescriptionExample
$Data header 
#Data tail 
Data,Data,DataData type 1Data represents only numbers: 1,0,0,0
Alphabet+DataData type 2Alphabet+Data represents a letter plus the following three digits: A100

Example:

Data format 1: $1,0,0,0#, $1,2,0,0#, $1,2,0,1#

Data format 2: $A100#, $A090#, $B120#

Note:

Data needs to be sent strictly in the above format.

Code analysis

Here is only a brief introduction to the code content. For detailed code, please refer to the corresponding code file, which is provided in the download area!

Note: Receive data between $ and #

Experimental results

After compiling the program successfully, upload the code to the Arduino Uno development board.

After the program is started, send data in the specified format, and the serial port will return the parsed data!

If there is no display content, you can check whether the serial port baud rate is consistent with the code setting, and then press the RESET button on the development board.

image-20240612161437330