read sensor string data from mega serial 3, but lossing last few characters

void read_dust() {
String readString;
while (Serial3.available()) 
     // delay(10);
     char c =;  //gets one byte from serial buffer       
     readString += c;} //makes the string readString
     if (readString.length() >0) 

void setup() 
    Serial3.begin(230400, SERIAL_7N1);  // PM2.5 sensor,should use 203400, 8N1 
    Serial.begin(9600);  // mega  

void loop() 

this PM2.5 sensor is my lab's partner's work, they advise monitor it with baud rate 230400,8N1.

I should test it and capture the tofloat data from mega for picturising with Meguno . While using USB connect the sensor to computer, terminal can show the complete string. But when using the above code with mega board, the string sending back will lost last few numbers.

how to restore this number lossing problem with mega?

  1. use ttl to usb, data OK (complete string)

  2. use mega with above code, string lose some numbers

ps: If use Serial3.begin(230400, SERIAL_8N1); we get some number become garbled(revers question mark), so, after try and error, we use 7N1 (no garbled).

The first thing that I would do is not to use Strings (uppercase S) but to use a zero terminated array of chars (aka a C string (lowercase s)) instead. Using String objects can cause memory fragmentation over a period of time which does not happen when using strings.

That aside, how does the program know that the complete message has been received ? Is the message terminated in some way, perhaps with a carriage return, linefeed or both ? If so, then keep reading characters until the terminating character is read before deciding that input is complete. If the message could have a start of message indicator and an end of message indicator it would be helpful. See Serial input basics - updated