user60666: I connect my NodeMCU to Arduino Uno. The goal is to receive the whole string for example "12", every 1 sec.
This is my code on Arduino Uno side ( the sender) 
int mock = 0;

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

void loop() {
    //Write mock to NodeMCU
    s.print((int)mock,DEC);
    s.println();

    mock++;
    delay(1000);
}

On NodeMCU side ( the receiver) 
 char data; //Initialized variable to store recieved data
 String line;
 void setup() {
   Serial.begin(115200);
   s.begin(115200);
   while (!Serial) {
    ; 
  }
}

void loop() {

    if( s.available() >= 2) {
        for (int i = 0; i< 2; i++ ) {
            data = s.read();
            line += data;
        }
        delay(1000);
    }


    Serial.print(line);

}

But the result on the serial panel is not what I expected

How can I make it so that I can receive something like
12
(wait one sec)
13
(wait one sec)
....

Node MCU just prints the whole thing, I can't delay it. 

user31105: If you send "12" you send 4 characters/bytes: '1', '2' and a new line which is two characters:  ('\r', '\n').
On the receiver side you check for two characters (not the new line), so you should take it into account.
Actually, since you will eventually reach "100" you will receive 5 characters ('1', '0', '0', '\r', \'n').
So it is better to change the receiver side to store the bytes in line UNTIL a new line is received (than you can support values of any length).
Also remove the delay on the receiver side, or at least decrease it a lot, because it doesn't matter to check (too) often. if there is no byte available, it will check again. Now it can happen at time 1001 ms a byte would be received, but at time 1000 ms it is checked and it will not be checked again until time 2000 ms.

60666: <p>I connect my NodeMCU to Arduino Uno. The goal is to receive the whole string for example "12", every 1 sec.</p>

<p>This is my code on Arduino Uno side ( the sender) </p>

<pre><code>int mock = 0;

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

void loop() {
    //Write mock to NodeMCU
    s.print((int)mock,DEC);
    s.println();

    mock++;
    delay(1000);
}
</code></pre>

<p>On NodeMCU side ( the receiver) </p>

<pre><code> char data; //Initialized variable to store recieved data
 String line;
 void setup() {
   Serial.begin(115200);
   s.begin(115200);
   while (!Serial) {
    ; 
  }
}

void loop() {

    if( s.available() &gt;= 2) {
        for (int i = 0; i&lt; 2; i++ ) {
            data = s.read();
            line += data;
        }
        delay(1000);
    }


    Serial.print(line);

}
</code></pre>

<p>But the result on the serial panel is not what I expected
<a href="https://i.stack.imgur.com/NGC3k.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/NGC3k.png" alt="Serial terminal"></a></p>

<p>How can I make it so that I can receive something like</p>

<pre><code>12
(wait one sec)
13
(wait one sec)
....
</code></pre>

<p>Node MCU just prints the whole thing, I can't delay it. </p>
 31105: <p>If you send "12" you send 4 characters/bytes: '1', '2' and a new line which is two characters:  ('\r', '\n').</p>

<p>On the receiver side you check for two characters (not the new line), so you should take it into account.</p>

<p>Actually, since you will eventually reach "100" you will receive 5 characters ('1', '0', '0', '\r', \'n').</p>

<p>So it is better to change the receiver side to store the bytes in line UNTIL a new line is received (than you can support values of any length).</p>

<p>Also remove the delay on the receiver side, or at least decrease it a lot, because it doesn't matter to check (too) often. if there is no byte available, it will check again. Now it can happen at time 1001 ms a byte would be received, but at time 1000 ms it is checked and it will not be checked again until time 2000 ms.</p>
