Send Data From Arduino to NodeMCU and NodeMCU to Arduino Via Serial Communication

preview_player
Показать описание
Send Data From Arduino to NodeMCU and NodeMCU to Arduino Via Serial Communication
Scroll down for code.....

In this tutorial we will learn how to make serial communication between Arduino to ESP8266 & ESP8266 to Arduino. Serial communication is required when you want to transfer sensor data or any data from one device to another device, In our case it is ESP8266 NodeMCU and Arduino.  Moreover, we will transfer DHT22 Sensor data from Arduino to NodeMCU and NodeMCU to Arduino. Apart from this we will also see how to use software serial library on Arduino and Serial1 on ESP8266 NodeMCU, So that you can transfer data with another serial port, which we will be helpful. If you are doing lots of things on both Arduino and ESP8266 NodeMCU.

If you want to support my video please buy any product through my amazon affiliate link. I will receive a commission, at no extra cost to you.

LIST OF COMPONENT (affiliate links)

Music provided by NoCopyrightSounds.

Code for Arduino:
#include "DHT.h"
#include (SoftwareSerial.h) //instead of parenthesis () put angle bracket as YouTube description does not allow angle bracket
#define DHTPIN 2

// Uncomment whatever type you're using!
//#define DHTTYPE DHT11 // DHT 11
#define DHTTYPE DHT22 // DHT 22 (AM2302), AM2321
//#define DHTTYPE DHT21 // DHT 21 (AM2301)

SoftwareSerial espSerial(5, 6);
DHT dht(DHTPIN, DHTTYPE);
String str;

void setup(){
delay(2000);
}
void loop()
{
// Read temperature as Celsius (the default)
str =String("coming from arduino: ")+String("H= ")+String(h)+String("T= ")+String(t);
delay(1000);
}

Code for ESP8266:
void setup() {
// Open serial communications and wait for port to open:
while (!Serial) {
; // wait for serial port to connect. Needed for native USB port only
}
}

void loop() { // run over and over
}
}
Рекомендации по теме
Комментарии
Автор

I was able to fix the communication issue from the Arduino to the ESP8266. The problem can be solved by: 1. Change board for NodeMCU 0.9 (ESP-12 Module). 2. Change the baud rate to 9600. 3. Use the readString() function instead of the read() function. 4. Assign pins D6 and D5 as Rx and Tx, respectively

luistimana
Автор

The arduino uno cable and Nodemcu cable are same? Or both are different data cable?

Please reply, all clear by this video, only one doubt

spandanroy
Автор

Can I send and receive at same time I mean send on off value from nodemcu to arduino and receive relay status from arduino. Also can I apply same example to esp8266-01.

shehabxcode
Автор

Does it similarly applies to ESP32? When I looked through the serial monitor on the ESP32 I could not receive temperature and humidity readings from the Arduino.

leonardchung
Автор

In order to work with the divider, you need to swap pin 5 and 6

annachapmann
Автор

Pls Help me! If i want to Upload Code to nodeMcu it says that there are no programmers available! Pls Help, what should i do?!

startobytes
Автор

So, it's more safe if we do from nodemcu to arduino than from arduino to nodemcu.

candrasniper
Автор

How can i declare string variable to arduino uno? Ex . Nodemcu>>arduino where t= is the temperature

jeremytiempo
Автор

what about parsing the sent string and further send to cloud like Blynk.

baburamchaudhary
Автор

Did you use to cables? One for arduino and one for nodemcu?

ouafaebouamar
Автор

Can i connect Arduino mega with NodeMCU esp8266 and then connect to thingspeak to visualize sensor data?

nandhinijagadeesan
Автор

thanks for the simple understandable video, subbed

HakkiOgrt
Автор

i have pms sensor and i have data on arduino but i want to send to nodemcu to use esp8266 to send data on application it its possible?

icjay
Автор

sir, for example, if there are 2 arduino and each arduino there is sensor data and then it is sent to 1nodemcu, what do you do?

friendyprasetiawan
Автор

You displayed 9600 baud rate for arduino and node mcu. Is 9600 baud rate is enough for both arduino and node mcu becoz both are working at different baud rates arduino works at 9600 and node mcu works at 115200 pls anybody knows reply me.

lokeshsaravanan
Автор

HI, i flashed by error the arduino while tx was connected to rx, and now nodemcu is not recognized, can someone help me?

nelsonortega
Автор

Can I use Arduino 2-way communication with nodemcu?

yogabayuangganapratama
Автор

Can i use softwareserial if i want to send data from nodemcu to any othet microcontroller eg. Stm32f103c8

baslinjames
Автор

why does it need 10k resistor to dht22?

firstfokers
Автор

can Send Data From Arduino to NodeMCU and NodeMCU to Arduino Via Serial in the same time and same code

monzerkidda