Contents
Introduction
NodeMCU is open source low cost IOT platform. Since nodeMCU is open open source platform their hardware design is open for edit ,modify and build. It includes firmware which runs on the ESP8266 Wi-Fi SoC from Espressif Systems, and hardware which is based on the ESP-12 module. The firmware uses the Lua scripting language.
Pin Layout
Nodemcu beginner’s may face little problem regarding the pin layout of node mcu. The level on the node mcu does not maps with corresponding GPIO pins.
For example – pin D2 of the board does not map to GPIO2 as you would expect, but to GPIO4 instead!
so before using any gpio in we must be aware about its corresponding pin layout.
- D0 = GPIO16
- D1 = GPIO5
- D2 = GPIO4
- D3 = GPIO0
- D4 = GPIO2
- D5 = GPIO14
- D6 = GPIO12
- D7 = GPIO13
- D8 = GPIO15
- D9 = GPIO3
- D10 = GPIO1
- LED_BUILTIN = GPIO16 (auxiliary constant for the board LED, not a board pin)
Hardware Overview
Node MCU has 4MB of storage and 128 Kb of Memory. It has several GPIO (General Purpose Input Output) pins for device connectivity. It has only one Analogue pin for Analogue input.
NodeMCU Dev Kit/board consist of ESP8266 wifi enabled chip. .
The ESP8266 is a low-cost wifi chip developed by Espressif Systems that uses TCP/IP protocol.
Programming to Nodemcu
Ide for nodemcu
NodeMCU with ESPlorer IDE:
LUA scripts are generally used to code the NodeMCU. Lua is an open source, lightweight, embeddable scripting language built on top of C programming language.
NodeMCU with Arduino IDE
We are very much familiar with arduino IDE. We can program our node mcu board using arduino ide
Starting Up In Arduino IDE
A node Mcu is a separate from arduino board so we need to add a separate board for nodemcu in arduino ide. If you have already installed arduino Ide in your PC then you can follow the following step to program nodemcu with arduino ide.
- open arduino ide and go to File – Preferences
- URL:
http://arduino.esp8266.com/stable/package_esp8266com_index.json
- Copy the URL below into the section Additional boards Manager and click OK to close the Preferences tab
- Then Goto Tools – Board … – Board Manager
- Goto search bar and type esp8266 and install it
- After you install it you can see a new nodemcu board in your arduino ide.
- Finally all the step are completed now lets start programming.
Blinking LED with node mcu
Connection Diagram
Code
#define LED D2 // Led in NodeMCU at pin GPIO4
void setup() {
pinMode(LED, OUTPUT);
}
void loop() {
digitalWrite(LED, HIGH);
delay(1000);
digitalWrite(LED, LOW);
delay(1000);
}