2

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() ); 
 }
}
asked Oct 17, 2016 at 20:10
6
  • 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? Commented Oct 18, 2016 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. Commented Oct 18, 2016 at 1:08
  • 1
    many ESP8266 modules default to 74880 baud rate Commented Oct 18, 2016 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. Commented Oct 18, 2016 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. Commented Oct 23, 2017 at 16:14

1 Answer 1

1
  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.

gre_gor
1,6824 gold badges18 silver badges28 bronze badges
answered Sep 21, 2018 at 10:21

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.