Skip to main content
improve formatting and grammar, edited tags
Source Link
VE7JRO
  • 2.5k
  • 19
  • 26
  • 29

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 <Servo.h> 

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 <ESP8266WiFi.h> 
#include <WiFiClient.h> 
#include <ESP8266WebServer.h> 
#include <ESP8266mDNS.h> 

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"); 

}

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 <Servo.h> 

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 <ESP8266WiFi.h> 
#include <WiFiClient.h> 
#include <ESP8266WebServer.h> 
#include <ESP8266mDNS.h> 

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"); 

}

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 <Servo.h> 

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 <ESP8266WiFi.h> 
#include <WiFiClient.h> 
#include <ESP8266WebServer.h> 
#include <ESP8266mDNS.h> 

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"); 

}

i have a question for you.

ImI’m trying to send data from my nodemcua NodeMCU to arduinoan Arduino nano.

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

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

Code of arduinoArduino nano sketch:

Code of nodemcuNodeMCU sketch:

i have a question for you.

Im trying to send data from my nodemcu to arduino nano.

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

But if i try to send without delay or delay < one second, then arduino sees data but nothing not does.

Code of arduino nano:

Code of 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:

NodeMCU sketch:

Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Source Link

Arduino does not see data from nodemcu

i have a question for you.

Im trying to send data from my nodemcu to arduino nano.

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

But if i try to send without delay or delay < one second, then arduino sees data but nothing not does.

Code of arduino nano:

#include <Servo.h> 

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); 
} 
} 
}

Code of nodemcu:

#include <ESP8266WiFi.h> 
#include <WiFiClient.h> 
#include <ESP8266WebServer.h> 
#include <ESP8266mDNS.h> 

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"); 

}