1

Currently I am working on an Arduino project. The project required to establish communication between Arduino Mega and NodeMCU ESP8266. Here are some details about the project:

  • NodeMCU Rx Pin is connected to Arduino Mega Pin 14 (Tx3), while NodeMCU Tx Pin is connected to Arduino Mega Pin 15 (Rx3), Jumper Wires is used to connect NodeMCU and Arduino Mega
  • Both Arduino Mega and NodeMCU are using baud rate 115200

Code for NodeMCU ESP8266 (Send The Data to Arduino Mega):

void loop(){
       esp.println("0000");

       esp.flush();
}

Code for Arduino Mega (Receive Data) :

 if(Serial3.available()){

  data = Serial3.readStringUntil('\n');

  Serial3.flush();

  Serial.println(data);

}

The result :

enter image description here The intented and expected result is "0000", however, the result shown in serial monitor is not accurate. Anyone could advise?

6
  • Is that a 3.3V Mega or did you use a level shifter? You know that the 5V of a normal Mega can fry your ESP? And the other thing is: Why do you flush Serial3 but have not written to it? That is a hight baud rate, so event the quality of the wiring could be a problem. Nov 12 '19 at 16:03
  • 1
    did you connect grounds?
    – Juraj
    Nov 12 '19 at 16:26
  • the spaces are \r. maybe the buffer overflows while you print the received string so you get incomplete 0000. try a small delay in esp8266
    – Juraj
    Nov 12 '19 at 16:30
  • @PeterPaulKiefer, the esp8266 has no problems with 5 V serial communication on UART, SPI, I2C and similar. And I run Mega to ESP-12F UART with 500000 baud on jumper wires
    – Juraj
    Nov 12 '19 at 17:46
  • @Juray I uv your comment questioning the grounds because I think that is the best idea and the most probable. -- As long as the arduino does not try to write to the ESP you're sure. But I had to bury one of the little esps I once owned after I tried to establish a 5V power connection ;-) So it may work or fail, but if it fails the part sails on the styx. The baud rate is not the problem. Want I meant is if you use a higher baud rate, lower parasitic capacitance can distort the communication. So if the connection are of bad quality, that could be a problem. But the gnd idea is still my favorit. Nov 12 '19 at 17:57
1

Sir mane ardunio mega 2560 my programing k hy jo k different sensor k value lake display karty hy aur sir ab my us value ko server jo k thingspeak hy aus p bajna chahta ho sir aus k leye mane esp8266 node-mcu use kar raha ho to sir ab my chahta ho k arduino value lake node-mcu ko send kary aur node mcu phr server p sir in k leye serial communication chahyae between two arduino sir is k leye koi refrence or any help

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.