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 = Serial3.read();  //gets one byte from serial buffer       
     readString += c;} //makes the string readString
     if (readString.length() >0) 
     {    
     Serial.print(readString);
     }
}
 

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

void loop() 
{
    read_dust();
    delay(1000);
    Serial.println();  
}

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)
    https://drive.google.com/file/d/1U-Cn7-nqBLqRnx0nrVFJ6_BbmEORTvp8/view

  2. use mega with above code, string lose some numbers
    https://drive.google.com/file/d/16DsfzM997WjepP1ZLFCqL73dmnMUdCit/view

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