Nodemcu with Arduino, Serial Communication, Control and Monitoring

(Last Updated On: July 22, 2019)

Nodemcu with Arduino

Description:

Nodemcu with Arduino– In this tutorial, you will learn how to do Serial communication between Arduino and Nodemcu esp8266 wifi module. For the demonstration purpose in this project LDR and variable resistor will be monitored using the Blynk Application. The Variable Resistor and LDR values will be displayed on the Gauges using the Blynk Application.  Monitoring two Analog sensors is only possible due to the use of the Arduino Uno.


At the end of this tutorial you will be able to monitor multiple analog sensors and you will also be able to control multiple loads. In this project no multiplexers will be used. All the sensors and loads will be connected in a normal way. In this Tutorial I will also explain why we need to connect the Nodemcu and Arduino Uno together. I will also explain when and when not use the Arduino Uno with the Nodemcu ESP8266 wifi module. Without any further delay, let’s get started!!!

The components and tools used in this project can be purchased from Amazon, the components Purchase links are given below:

Arduino Uno: https://amzn.to/2tVz1vu
Mega 2560: https://amzn.to/2ze1kdu
Nodemcu esp8266 wifi module: Best price https://amzn.to/2NAvmiB
LM7805 Voltage Regulator: https://amzn.to/2IZEl5x
Potentiometer: https://amzn.to/2JSLbfg
330 ohm resistors pack: https://amzn.to/2NtlAeh
5v 2A adaptor: https://amzn.to/2GsNfcw
2n2222 npn transistors: https://amzn.to/2EmXsIb
10k Resistor: https://amzn.to/2KTd6OW
lm7805 Voltage Regulator: https://amzn.to/2IZEl5x
330-ohm resistors pack: https://amzn.to/2NtlAeh
female DC power jack socket: https://amzn.to/2KEo1gt
470 uf capacitors: https://amzn.to/2xDCOzf
5×7 cm vero board: https://amzn.to/2OHGbvn
female headers: https://amzn.to/2zqmtiJ
connection wires: https://amzn.to/2DpBuW7
Super Starter kit for Beginners: https://amzn.to/2KJvmKG
Jumper Wires: https://amzn.to/2KMoVXs
Bread Board: https://amzn.to/2MS4q8X
12v Adaptor: https://amzn.to/2Ntr6h1
PCB plate: https://amzn.to/2IUwpCt
Variable Supply: https://amzn.to/2MT4Qfj
Digital Multimeter: https://amzn.to/2Nvft9i
Vero Board / strip board: https://amzn.to/2MTf9jD
Soldering iron kit: “best” You guys should definitely purchase this: https://amzn.to/2zfoNuJ
Solder wire: https://amzn.to/2ufUMWf
Wire Stripper: https://amzn.to/2KOqxfU
wire cutter: https://amzn.to/2ucIq14
PCB small portable drill machine: https://amzn.to/2Nu62XF


Arduino and Nodemcu ESP8266 together:

I know we can make the same project using only the Nodemcu ESP8266 Wifi module, and we can reduce the project size, power and building time, etc. You know very well Nodemcu ESP8266 Wifi module has a very limited number of the IO pins, and there is only 1 analog Pin. I have been frequently asked by my followers on YouTube Channel “Electronic Clinic” that how to connect multiple analog sensors or how to increase the IO pins of the Nodemcu Module. My replay is always use Arduino or Mega with the Nodemcu Module. We can also use a multiplexer, but that needs wiring, and complicated programming which we really don’t want. So the easiest option is to use the Arduino Uno or Mega with the Nodemcu ESP8266 Wifi module.

So, that’s the reason I am using Arduino Uno with the Nodemcu Module. In this Project you will learn completely how to connect Nodemcu module with the Arduino and how to establish the Serial Communication. As this project is based on the two way communication, so, in this project we will be monitoring the sensors and controlling some electrical loads both at the same time using the Blynk Application. This project can be easily modified and can be used to monitor any type sensors.

This Project is based on my previous two tutorials.

 

 

In this tutorial you will learn how to install the Nodemcu esp8266 wifi board and how to download and use the blynk library and how to fix the USB UART driver error.


https://www.youtube.com/edit?o=U&video_id=3TlzoF0YpH8

While in this tutorial you will learn how to make a power supply for Nodemcu esp8266 wifi module so that it can be easily powered up using a 12v adaptor or battery.

Nodemcu with Arduino Circuit Diagram:

Nodemcu with Arduino

This is the complete circuit diagram. This schematic is designed in cadsoft eagle 9.1.0 version. If you want to learn how to make a schematics and PCB then watch my tutorial give above.

Let’s first start with the regulated Power Supply which is based on the famous LM7805 voltage Regulator. This Regulated Power Supply will be used to power up the Nodemcu ESP8266 wifi module. J1 is the female Power Jack and this is where we connect a 12v Adaptor or Battery or a Solar Panel. Two 470Uf capacitors are connect at the input and output of the voltage regulator. A 330 Ohm resistor is connected in series with a 2.5v LED. This is a current limiting resistor. This is a Power ON LED and it’s only purpose is to show that the circuit is Turned ON.

The Output of the Regulated Power Supply is connected with the Vin pin of the Nodemcu ESP8266 Wifi Module and the ground is connected with the ground.


A variable resistor is connected with A0 pin of Arduino, an LDR is connected in series with a 10k resistor, which makes a voltage divider and is connected with A1 pin of the Arduino. The Tx and Rx pin’s of the Nodemcu are connected with pin2 and pin3 of the Arduino. So the Nodemcu will communicate serially with Arduino Uno through pin2 and pin3. Pin2 is Rx and pin3 is Tx, which will be defined in the programming using the software serial library.

For controlling these relays we will need relay drivers, the relay drivers simply consists of the 2n2222 NPN transistors, 10k ohm resistors and diodes. As you can see a 10k resistor is connected with the base of 2n2222 NPN transistor as it’s a BJT “bipolar junction transistor” a current controlled device, that’s why we need a current limiting resistor. We usually use a 10k resistor. The emitter of the 2n2222 NPN transistor is connected with the ground while the collector is connected with one side of the relay coil, while the other side of the relay coil is connected with the 12 volts. This relay can be energized and de-energized using this transistor.  As you can see this relay consists of 5 pins, two coil Pins, common, normally closed and normally open. These three pins have no physical connection with the coil pins.

Nodemcu with Arduino

So this is the relay module, you can also use the readymade relay module.

Nodemcu with Arduino

these are 10k resistors connected with the base of 2n2222 NPN transistors,

Nodemcu with Arduino

these are the 1n4007 diodes connected across the relay coil pins,


Nodemcu with Arduino

these are 12v SPDT type relays and these are the terminal blocks. I have soldered some jumper wires so that this relay module can be easily interfaced with other circuits. This relay module consists of 7 relays but I will be using 2 relays. Connect 2 relays with pin number13…and …pin number12 of the Arduino Uno or mega And connect the relay module ground with the ground of Arduino.

Blynk Application Designing:

For the complete step by step application designing watch video tutorial given at the end of this article or following the instructions given below.

  • First of all open the blynk application…..
  • set the project name as Control and monitor…..
  • Click on the choose device and select nodemcu….
  • Make sure you set the connection type to wifi….
  • Then click on the create button, an authentication token will be sent on your email id, which will be then used in programming, simply copy and paste it in programming.
  • click on the screen and add a Gauge…..
  • Click on the gauge and set the name as variable resistor…..
  • Now click on the pin and select virtual and select v2….
  • Change the font….click on push and select 1 second…..
  • Now add another gauge and repeat the same steps. After you are done with adding the Gauges on the screen, then start adding the numeric inputs.
  • Click on the screen and add numeric input……
  • Click on the numeric input, click pin and select the virtual pin10.
  • Set the minimum value to 10 and the maximum value to 11. These 10 and 11 values will be used to control the relay connected with pin13 of the Arduino. finally set the name as relay1, if you want you can also change the font.
  • Now repeat the same steps for other numeric input and re-arrange the gauges and numeric inputs and change the color if you want.


Nodemcu with Arduino

Our basic application setup is completed.

Nodemcu with Arduino Programming:

This Project is based on two Programs, one program is written for the Arduino Uno while the other program is written for the Nodemcu ESP8266 Wifi Module. First let’s start with the Arduino Programming.


Arduino Programming:



Nodemcu Programming:

For the programs explanation, watch the following Video. Don’t forget to Subscribe. Support my channel by liking this video and sharing this video.


Watch Video Tutorial:

 

Recommended For You

About the Author: Engr Fahad

My name is Shahzada Fahad and I am an Electrical Engineer. I have been doing Job in UAE as a site engineer in an Electrical Construction Company. Currently, I am running my own YouTube channel "Electronic Clinic", and managing this Website. My Hobbies are * Watching Movies * Music * Martial Arts * Photography * Travelling * Make Sketches and so on...

Leave a Reply