Pawan Kumar
Published © GPL3+

Serial Communication between NodeMCU and Arduino

Serial Communication between ESP2866-12 (NODE-MCU) and Arduino to increase the number of analog pins as my primary work.

BeginnerShowcase (no instructions)2 hours84,912
Serial Communication between NodeMCU and Arduino

Things used in this project

Hardware components

Arduino UNO & Genuino UNO
Arduino UNO & Genuino UNO
Arduino MEGA can be used.
×1
NodeMCU ESP8266 Breakout Board
NodeMCU ESP8266 Breakout Board
×1
DHT11 Temperature & Humidity Sensor (4 pins)
DHT11 Temperature & Humidity Sensor (4 pins)
×1
Jumper wires (generic)
Jumper wires (generic)
×6

Software apps and online services

Arduino IDE
Arduino IDE
Arduino IDE with ESP board manager.
adafruit.io

Story

Read more

Schematics

Arduino and Node MCU circuit

Arduino and Node MCU circuit

Code

Arduino_Code.ino

C/C++
#include <dht.h>
dht DHT;
int temp,humi;
#define DHT11_PIN A0
String str;
void setup(){
 Serial.begin(115200);
 Serial1.begin(115200);
 Serial.print(char(169)); // Copyright Symbol
 Serial.println(" Myengineeringstuffs.com");
 delay(2000);
}
void loop()
{
  DHT.read11(DHT11_PIN);
  humi=DHT.humidity;
  temp=DHT.temperature;
  Serial.print("H: ");
  Serial.print(humi); 
  Serial.print("% ");
  Serial.print(" T: ");
  Serial.print(temp); 
  Serial.print(char(176));
  Serial.println("C");
  str =String('H')+String(humi)+String('T')+String(temp);
  Serial1.println(str);
  delay(5000);
}

Node-MCU-Side.ino

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

void loop() { // run over and over
  if (Serial.available()) {
    Serial.write(Serial.read());
  }
}

Credits

Pawan Kumar

Pawan Kumar

6 projects • 57 followers
I Pawan Kumar interest in Robotics and Embedded System. Want to create more and more devices that can change the life style of every person.

Comments