The NodeMCU (Node MicroController Unit) is an open source software and hardware development environment that is built around a very inexpensive System-on-a-Chip (SoC) called the ESP8266. The ESP8266, designed and manufactured by Espressif Systems, contains all crucial elements of the modern computer: CPU, RAM, networking (wifi), and even a modern operating system and SDK.That makes it an excellent choice for IoT projects of all kinds.


Working Principle:

NodeMCU is an open-source IoT platform. It includes firmware that runs on the ESP8266 Wi-Fi SoC from Espressif Systems, and hardware which is based on the ESP-12 module. … It is based on the eLua project and built on the Espressif Non-OS SDK for ESP8266.


Types of NodeMCU:

WeMOS D1 Mini:

Link to datasheet:



  • 10 digit Analog-Digital converterOn board Antenna and RF balun
  • Uses 802.11 b/g/n Wifi standards 
  • Uses IPV4, HTTP, FTP, UDP & TCP network protocols
  • Operating voltages: 3-3.6V
  • Operating Frequency range: 2.4-2.6 GHz
  • On board power management modules,PLL, regulator, Power amplifier, Noise filters which makes it less external circuitry interface
  • Configured in both Android & iOS devices




  • Arduino-Like Hardware IO
  • Code like Arduino, but interactively in Lua script
  • Event-driven API for network applications, which facilitates developers writing code
  • Integrates GPIO, PWM, IIC, 1-Wire and ADC all in one board
  • 10 GPIO, every GPIO can be PWM, I2C, 1-wire
  • 4M Flash Memory
  • Built-in WiFi Antenna


  • Home Automation
  • Home Appliances i.e TV, Refrigerators, Light Bulbs , Fans etc. Control
  • . Motor Speed control
  • Can be used in IP Cameras , Sensor Networks, Wearable electronics
  • Security ID tags & Baby Monitors
  • WiFi location aware devices and WiFi position systems etc.

Getting started with NodeMCU:


Tools and component:


  • NodeMCU
  • LED
  • Breadboard
  • Micro USB
  • Arduino IDE

installing NodeMCU Board Package:

  1. Open up Arduino IDE. Go to Files-> Preferences. Enter

 into Additional Board Manager URLs field

  1. Now go to Tools->Boards->Board Manager, and search for ESP8266 and install the package.

Pin connection:

  • D7 of NodeMCU to LED’s +ve.
  • G of NodeMCU to LED’s -ve.

Source code:

#include <ESP8266WiFi.h>


const char* ssid = “MODI”;

const char* password = “8826675619”;


int ledPin = 13; // GPIO13—D7 of NodeMCU

WiFiServer server(80);


void setup() {




  pinMode(ledPin, OUTPUT);

  digitalWrite(ledPin, LOW);


  // Connect to WiFi network



  Serial.print(“Connecting to “);



  WiFi.begin(ssid, password);


  while (WiFi.status() != WL_CONNECTED) {





  Serial.println(“WiFi connected”);


  // Start the server


  Serial.println(“Server started”);


  // Print the IP address

  Serial.print(“Use this URL to connect: “);







void loop() {

  // Check if a client has connected

  WiFiClient client = server.available();

  if (!client) {




  // Wait until the client sends some data

  Serial.println(“new client”);





  // Read the first line of the request

  String request = client.readStringUntil(‘\r’);




  // Match the request


  int value = LOW;

  if (request.indexOf(“/LED=ON”) != -1)  {

    digitalWrite(ledPin, HIGH);

    value = HIGH;


  if (request.indexOf(“/LED=OFF”) != -1)  {

    digitalWrite(ledPin, LOW);

    value = LOW;



// Set ledPin according to the request

//digitalWrite(ledPin, value);


  // Return the response

  client.println(“HTTP/1.1 200 OK”);

  client.println(“Content-Type: text/html”);

  client.println(“”); //  do not forget this one

  client.println(“<!DOCTYPE HTML>”);



  client.print(“Led is now: “);


  if(value == HIGH) {


  } else {




  client.println(“<a href=\”/LED=ON\”\”><button>On </button></a>”);

  client.println(“<a href=\”/LED=OFF\”\”><button>Off </button></a><br />”);  




  Serial.println(“Client disonnected”);





Uploading The Code:

When u have successfully built your connection on the breadboard and write coding, you have to upload the coding into the NodeMCU by using a micro USB.

Now, go to Tools > Board > ESP8266 Modules and you can see many options for ESP8266. Select “NodeMCU 1.0 (ESP-12E Module). Next, select your port. If you cant recognize your port, go to the Control Panel > System > Device Manager > Port and update your USB driver.

Now upload the code to the board



Controlling The LED:


  • Now open up your Serial Monitor, and not down the URL.
  • Now put the URL in your phone’s browser.
  • A page will open having two buttons ON and OFF.
  • If everything is correct when you press ON the LED will light up and when you press OFF the LED will turn off.