Problems with repeating Serial data being recieved

I'm trying to receive data from serial port, but when the program is run, the serial monitor repeats the data three types between each interval,

below is the code and screenshot of the serial read being repeated and separated by few some dashes ("-----")

#include <SoftwareSerial.h>

SoftwareSerial mySerial(10,11, true); // RX, TX
String inData;
void setup()  
{
  // Open serial communications and wait for port to open:
  Serial.begin(9600);

  // set the data rate for the SoftwareSerial port
  mySerial.begin(9600);
}



void loop() {
  while (mySerial.available() > 0)
  {
    char recieved = mySerial.read();
    inData += recieved;  // Process message when new line character is recieved
    if (recieved == '\n')
    {
      //Serial.print("Arduino Received: ");
      Serial.println(inData);
        Serial.println ("------------");
      inData = """"; // Clear recieved buffer
    }
  }
  delay(800);

}

Loko:
the serial monitor repeats the data three types between each interval,

Can you try that sentence again? What data are you sending it and what are you expecting it to say?

      inData = """"; // Clear recieved buffer

Why are you trying to use 4 double quotes to clear the String? (It is NOT a buffer; an array is a buffer.)

Assuming your talking about the blank lines then

      Serial.println(inData);

line adds one (you are copying everything into inData).

I suspect your end of line is not '/n' but cr/lf, with the lf giving you the other blank line.

Mark

it turns out i needed to add the serial.flush() function to stop the frequent repetition

#include <SoftwareSerial.h>

SoftwareSerial mySerial(10,11, true); // RX, TX
String inData;
void setup()  
{
  // Open serial communications and wait for port to open:
  Serial.begin(9600);

  // set the data rate for the SoftwareSerial port
  mySerial.begin(9600);
}

void loop() {
  while (mySerial.available() > 0)
  {
    char recieved = mySerial.read();
    inData += recieved;  // Process message when new line character is recieved
    if (recieved == '\n')
    {
      //Serial.print("Arduino Received: ");
      //Serial.println(inData);
            Serial.println(inData);

     inData = ""; // Clear recieved buffer
      mySerial.flush();
            delay(1000);
    }
  } 
}

Loko:
it turns out i needed to add the serial.flush() function to stop the frequent repetition

That will have different effects depending what IDE version you are using, but it is NOT necessary to call flush() in order to handle serial port input and output correctly.

You haven't clarified what the actual problem is, but I very much doubt that flush() has fixed the underlying problem.