NodeMCU 101

Tasnim Zotder
3 min readFeb 5, 2022
Image Courtesy: Wikimedia

About NodeMCU

NodeMCU is an open-source platform that enables users to create IoT devices using Lua scripting. NodeMCU devices are based on the ESP8266 microcontroller, which features a WiFi module and allows users to program the device using the Lua scripting language. NodeMCU devices are popular among hobbyists and makers due to their low cost and easy programming.

Applications of NodeMCU

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

Types of NodeMCU

There are two types of NodeMCU board.

  1. NodeMCU v0.9
  • Color: Blue
  • Chip: ESP-12
  • Pins: 16

2. NodeMCU v1.0

  • Color: Black
  • Chip: ESP-12E
  • Pins: 22

Hardware of NodeMCU

Specifications of NodeMCU

Microcontroller: Tensilica 32-bit RISC CPU Xtensa LX106

Input Voltage: 7–12V

Operating Voltage: 3.3V

Flash Memory: 4 MBSRAM64 KB

Clock Speed: 80 MHz

GPIO Pins: 16

Analog Input (ADC) Pins: 1 (10-bit)

UART Pins: 1

SPI Pins: 1

I2C Pins: 1

Components of NodeMCU

The main components in 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

  1. Lua: Programming in Lua for NodeMCU is like Node.js. Lua is asynchronous and event driven.
-- 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)

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

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)

3. Arduino Programming Language: It’s similar to C++.

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 👉

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

  • Field → NodeMCU → Arduino IDE
  • Creator → Espressif Systems → Arduino
  • Microcontroller → ESP8266 → ATmega328p
  • Processor → 32-bit → 8-bit
  • Processor Speed → 80MHz → 16MHz
  • SRAM → 64KB → 2KB
  • Flash Memory → 4MB → 32KB
  • Operating Voltage → 3.3V → 5V
  • Input Voltage → 7–12 → V7–12V
  • Digital I/O Pins → 16 → 14
  • PWM Pins → 4 → 6
  • Analog Input Pins → 1 → 6
  • Wireless Communication → ESP8266 SoC → None
  • Serial Communications → UART/I2C/SPI → UART/I2C/SPI

References 📃

Originally published at https://tasnimzotder.com on February 5, 2022.

--

--