3

I am sending data from ESP8266 (NodeMCU) to Arduino using serial and 9600 baud rate on both sides. Since it is uni-directional and from NodeMCU to Arduino, I am not using a voltage regulator and I have connected tx (Software Serial) of NodeMcu to Rx of Arduino. I've connected the usb of nodeMCU to my computer. I've done the same thing to power Arduino.

Here is some sample code on NodeMCU:

#define Arduino_RX 4 // D2
#define Arduino_TX 5 // D1
SoftwareSerial ArduinoSerial(Arduino_RX, Arduino_TX); // RX | TX

void setup() {
  Serial.begin(115200);
  ArduinoSerial.begin(9600);
  delay(10);

  // Connect to WiFi network
  Serial.print("Connecting to ");
  Serial.println(ssid);

  WiFi.begin(ssid, password);
  WiFi.config(ip, gateway, subnet);

  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }
  Serial.println("");
  Serial.println("WiFi connected");

  // Start the server
  server.begin();
  Serial.println("Server started"); 
}

void loop() 
{
    ArduinoSerial.println("hi");
    Serial.println("hi");
    delay(1); 
} 

Code on Arduino

#define ESP8266_RX   2
#define ESP8266_TX   3
#include <SoftwareSerial.h>
SoftwareSerial ESPserial(ESP8266_RX, ESP8266_TX); // RX | TX

void setup() {
  // put your setup code here, to run once:
    Serial.begin(9600);     // communication with the host computer
    ESPserial.begin(9600);  
    Serial.println("Ready");

}

void loop() {
  if ( ESPserial.available() )   {  
    Serial.write( ESPserial.read() ); 
  }
}
  • Thank you for your question. Could you please edit it and really make your question clear. For example, what do you expect to receive and what do you actually receive? – sa_leinad Oct 18 '16 at 0:36
  • Software serial doesn't always work to well at 9600. Try 56k. Also consider the esp is 3.3v and the Arduino is 5v. – Visual Micro Oct 18 '16 at 1:08
  • 1
    many ESP8266 modules default to 74880 baud rate – Jaromanda X Oct 18 '16 at 2:18
  • Tried with all the possible baud rate without avail. One thing to note is this worked couple of days ago and I started seeing garbage recently. – Nikhil Oct 18 '16 at 7:58
  • Why dont you try to use the default Rx and Tx pins on of nodeMCU. or in the Arduino code why not change the baud rate to 115200. – rahul0201 Oct 23 '17 at 16:14
0
  1. https://www.pjrc.com/teensy/td_libs_AltSoftSerial.html

  2. Do you GND them via your PC USB? Try connecting their GND as well.

  3. External power could be an issue as well, I am not aware of power consumption of ESP when they do stuff with their WiFi.

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.