Arduino does not see data from nodemcu I’m trying to send data from a NodeMCU to an Arduino nano. 

If I try to send data with one second delay - all working fine. 

But if I try to send without delay or with a delay less than one second, then arduino sees data but nothing not does. 

Arduino nano sketch: 

#include &lt;Servo.h&gt; 

Servo servo1; 

int servo = 6; 
int engine = 5; 

void setup() { 
Serial.begin(9600); 
analogWrite(servo, 67); 
servo1.attach(8); 
} 

void loop() { 
if (Serial.available()) { 
String model = Serial.readStringUntil(':'); 
i 

f (model.equals("engine")){ 
String value = Serial.readStringUntil('c'); 
int power = value.toInt(); 
analogWrite(engine, power); 
} 
if (model.equals("servo")){ 
String value_servo = Serial.readStringUntil('c'); 
int power_servo = value_servo.toInt(); 
servo1.write(power_servo); 
} 
} 
}


NodeMCU sketch: 

#include &lt;ESP8266WiFi.h&gt; 
#include &lt;WiFiClient.h&gt; 
#include &lt;ESP8266WebServer.h&gt; 
#include &lt;ESP8266mDNS.h&gt; 

const char* ssid = "my_wifi_ssid"; 
const char* password = "my_wifi_password"; 

ESP8266WebServer server(80); 


void get_vars(){ 
if (server.argName(0) == "engine"){ 
server.send(200, "text/plain", "Reading engine. Value: "+server.arg(0)); 
Serial.println("engine:"+server.arg(0)+"c"); 
} 
if (server.argName(0) == "servo"){ 
server.send(200, "text/plain", "Reading engine. Value: "+server.arg(0)); 
Serial.println("servo:"+server.arg(0)+"c"); 
} 
} 

void setup(void){ 
main_stuff(); 
} 

void loop(void){ 
server.handleClient(); 
} 


void main_stuff(){ 
Serial.begin(9600); 
WiFi.mode(WIFI_STA); 
WiFi.begin(ssid, password); 
Serial.println(""); 

// Wait for connection 
while (WiFi.status() != WL_CONNECTED) { 
delay(100); 
Serial.print("."); 
} 
Serial.println(""); 
Serial.print("Connected to "); 
Serial.println(ssid); 
Serial.print("IP address: "); 
Serial.println(WiFi.localIP()); 

if (MDNS.begin("esp8266")) { 
Serial.println("MDNS responder started"); 
} 

server.onNotFound(get_vars); 

server.begin(); 
Serial.println("HTTP server started"); 

}
the newline characters from println (\r\n) stay in the serial input buffer and you read them with Serial.readStringUntil(':');. then the string is not "servo" but "\r\nservo"

if you wait one second with sending, the the \r\n are discarded because the readStringUntil times out one second after reading them