Receiving long data using Serial

Hello, my friends!
I am trying to communicate Arduino Pro mini 3.3V that is collecting butch of data with ESP, so I can send such data to the web server. I will send data each second, and this data should be pushed to the server. So every message should be separated from the next one, so at the end of the message, I am adding "/r" so the ESP will know that it is the end of this message, and this message is ready to be pushed to server.

So the data is sending via serial port, here is the example of such code:

void setup() {
 
 Serial1.begin(9600);
}

void loop() {
    
        Serial1.print("123/r");
        delay(1000);
 }

Code from ESP:

#include<SoftwareSerial.h> 
SoftwareSerial s(3,1);

void setup() {
      s.begin(9600);
      Serial.begin(9600);
}

void loop() {
      while(Serial.available()){
      String readString = s.readStringUntil('/r'); 
      Serial.println(readString);
  }
  
}

So the problem is that ESP doesn't want to "exit" when it receives '/r'.
Serial monitor prints:

123/r123/r123/r123/r

so even no new line:(
As I understand, it keeps saving everything that is sending to serial and cannot do next line of the code

Don't use readString().

Have a look at the examples in Serial Input Basics - simple reliable ways to receive data.

...R

SoftwareSerial s(3,1);

Which pins are the hardware serial pins on the ESP?

The line feed is \r, NOT /r.

Thank you, Robin and Paul, for the tips appreciate that!

I rearranged my code, and everything was working fine until I decided to receive more than 255 characters.

With const byte numChars = 255; I am limited to max 255 characters

With const word numChars = 300; I am receiving only 77 characters, even not from the beginning of a message I am sending...

Same applies to const int numChars = 300;

what am I doing wrong?

#include<SoftwareSerial.h> 
SoftwareSerial s(15,13);

const int numChars = 300;
char receivedChars[numChars];

boolean newData = false;

void setup() {
    Serial.begin(19200);
    s.begin(19200);
    Serial.println("<Arduino is ready>");
}

void loop() {
    recvWithStartEndMarkers();
    showNewData();
}

void recvWithStartEndMarkers() {
    static boolean recvInProgress = false;
    static byte ndx = 0;
    char startMarker = '<';
    char endMarker = '>';
    char rc;
 
    while (s.available() > 0 && newData == false) {
        rc = s.read();

        if (recvInProgress == true) {
            if (rc != endMarker) {
                receivedChars[ndx] = rc;
                ndx++;
                if (ndx >= numChars) {
                    ndx = numChars - 1;
                }
            }
            else {
                receivedChars[ndx] = '\0'; // terminate the string
                recvInProgress = false;
                ndx = 0;
                newData = true;
            }
        }

        else if (rc == startMarker) {
            recvInProgress = true;
        }
    }
}

void showNewData() {
    if (newData == true) {
        Serial.println(receivedChars);
        newData = false;
    }
}

thank you

Turn on maximum compiler warnings in preferences. It will give you some warnings which boil down to an issue with this line:

  static byte ndx = 0;

ndx will need to be int now your buffer size exceeds 255