NodeMCU 101 - Things You Need to Know

on
NodeMCU 101 - Things You Need to Know

About NodeMCU

NodeMCU is an open-source platform that enables users to create IoT applications. NodeMCU devices are based on the ESP8266 chip, which includes a WiFi module that can be used to connect to a network. NodeMCU devices are popular because they are easy to use and have a low cost.

Applications of NodeMCU

  1. IoT applications
  2. Home automation
  3. Robotics
  4. Wearable technology
  5. Smart cars
  6. Smart cities
  7. Remote monitoring

Types of NodeMCU

There are two types of NodeMCU boards:

  1. NodeMCU v0.9
  2. NodeMCU v1.0
TypeColorChipsetPins
NodeMCU v0.9BlueESP-1216
NodeMCU v1.0GreenESP-12E22

Hardware of NodeMCU

Specifications of NodeMCU

Note
NodeMCU is a 32-bit microcontroller.
FieldValue
MicrocontrollerTensilica 32-bit RISC CPU Xtensa LX106
Input voltage7-12V
Operating voltage3.3V
Flash memory4MB
SRAM64KB
Clock Speed80MHz
GPIO Pins16
Analog Input (ADC) Pins1 (10-bit)
UART Pins1
SPI Pins1
I2C Pins1

Components 0f NodeMCU

The main components of NodeMCU are:

  • ESP-12E chip
  • 2.4 GHz antenna
  • Micro USB connector
  • 3.3V LDO voltage regulator
  • Reset button
  • Flash button
  • USB to TTL converter (CP2102)

Software Specifications of NodeMCU

FieldValue
Programming Languages UsedLua, C++ Toolchain, Micropython, Arduino Programming Language
Popular IDEsArduino IDE, PlatformIO, VS Code

A sample of blinking LED in NodeMCU is shown below in multiple languages:

Lua: Programming in Lua for NodeMCU is like Node.js. Lua is asynchronous and event driven.

main.lua
-- LED blink --

local pin = 4 -- D4
local delay = 500 -- 500 ms
local status = gpio.LOW

-- initializa pin --
gpio.mode(pin, gpio.OUTPUT)
gpio.write(pin, status)

-- led blink --
tmr.alarm(0, delay, 1, function ()
if status == gpio.LOW then
status = gpio.HIGH
else
status = gpio.LOW
end

    gpio.write(pin, status)

end)

Micropython: Micropython is a software implementation of Python3. It's written on C and optimized to run on a microcontroller.

main.py
import mchine
import time

pin = 4
led = machine.Pin(4, machine.Pin.OUT)

while True:
led.high()
time.sleed(0.5)
led.low()
time.sleep(0.5)

.ino: Arduino Programming Language: It's similar to C++.

main.ino
const int LED_PIN = 4;
const int LED_DELAY = 500;  // 500ms

void setup() {
pinMode(LED_PIN, OUTPUT);
}

void loop() {
digitalWrite(LED_PIN, 1);
delay(LED_DELAY);
digitalWrite(LED_PIN, 0);
delay(LED_DELAY);
}

NodeMCU Setup (in Arduino IDE)

Arduino IDE is an open-source IDE developed by Arduino. The Arduino IDE can be used to write programs for lots of microcontrollers including Arduino Boards, ESP8266, ESP32, Adafruit Boards, and Pi Pico Boards.

The setup process of Arduino IDE for NodeMCU is described in the following article 👉 How to Setup Arduino IDE for NodeMCU?.

Comparison Between NodeMCU and Arduino UNO

Although both NodeMCU and Arduino UNO can be used in IoT development, they have lots of differences. Some of their similarities and differences are as following:

Similarities between NodeMCU and Arduino UNO

There are a few similarities between the NodeMCU and Arduino Uno. Both boards use a microcontroller, which is a programmable chip that can be used to control electronic devices. They also both use the Arduino IDE (Integrated Development Environment) for programming. The Arduino Uno has a few more capabilities than the NodeMCU, such as the ability to use shields, which are add-on boards that can provide additional functions, such as motor control or wireless communication. The Arduino Uno also has more input and output pins than the NodeMCU.

Differences between NodeMCU and Arduino UNO

FieldNodeMCUArduino UNO
CreatorEspressifArduino
MicrocontrollerESP8266ATmega328p
Processor32-bit8-bit
Processor Speed80MHz16MHz
SRAM64KB2KB
Flash Memory4MB32KB
Input Voltage7-12V7-12V
Operating Voltage3.3V5V
GPIO Pins1614
PWM Pins46
Analog Input (ADC) Pins11
Wireless CommunicationESP8266 SoCNone
Serial CommunicationUART/I2C/SPIUART/I2C/SPI

References