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