NodeMCU is an open source IoT platform. 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 term “NodeMCU” by default refers to the firmware rather than the dev kits. The firmware uses the Lua scripting language. It is based on the eLua project, and built on the Espressif Non-OS SDK for ESP8266. It uses many open source projects, such as lua-cjson, and spiffs.
NodeMCU was created shortly after the ESP8266 came out. On December 30, 2013, Espressif Systems began production of the ESP8266. The ESP8266 is a Wi-Fi SoC integrated with a Tensilica Xtensa LX106 core, widely used in IoT applications. NodeMCU started on 13 Oct 2014, when Hong committed the first file of nodemcu-firmware to GitHub. Two months later, the project expanded to include an open-hardware platform when developer Huang R committed the gerber file of an ESP8266 board, named devkit v0.9. Later that month, Tuan PM ported MQTT client library from Contiki to the ESP8266 SoC platform, and committed to NodeMCU project, then NodeMCU was able to support the MQTT IoT protocol, using Lua to access the MQTT broker. Another important update was made on 30 Jan 2015, when Devsaurus ported the u8glib to NodeMCU project, enabling NodeMCU to easily drive LCD, Screen, OLED, even VGA displays. In summer 2015 the creators abandoned the firmware project and a group of independent but dedicated contributors took over. By summer 2016 the NodeMCU included more than 40 different modules. Due to resource constraints users need to select the modules relevant for their project and build a firmware tailored to their needs.
Specifications & Features
- WiFi module: Built in WiFi 802.11 b/g/n; It can be used as access point and/or station, host a web server, connect to internet & exchange the data.
- USB port: It has Micro-B USB port (CP2012 USB-Serial converter onboard) with 921600 max baud rate for uploading for board power supply (5VDC), program uploading & debugging.
- Header: It has 2x 2.54mm 15-pin header with access to GPIOs, SPI, UART, ADC, and power pins. It has 4 mounting holes for board mounting.
- Buttons: On board RESET & FLASH buttons.
- Easy programming: Can be programmed with the simple and powerful Lua programming language or Arduino IDE.
- IO varieties: 10 GPIOs D0-D10 with PWM functionality, IIC & SPI communication, 1-Wire and ADC A0.
- Small size: Compact size of 49 x 24.5 x 13mm, smaller than Arduino UNO
- Onboard LEDs: Two onboard LEDs; GPIO2(D4-Tx) & GPIO16(D0), Pin #0 red LED for general purpose blinking. Pin #2 blue LED for bootloading debug & general purpose blinking.
- Memory: NodeMCU Devkit 1.0 has 4MB of FLASH (32 MBit).
NodeMCU DevKit Pinout
|NodeMCU DevKit Pins||ESP8266 Internal GPIO Pins|
For schematics, PCB & BOM, click here
ESP8266 is a System on Chip (SoC) design with components like the processor chip. The processor has around 16 GPIO lines, some of which are used internally to interface with other components of the SoC, like flash memory. Since several lines are used internally within the ESP8266 SoC, we have about 11 GPIO pins remaining for GPIO purpose. Now again 2 pins out of 11 are generally reserved for RX and TX in order to communicate with a host PC through which compiled object code is downloaded. Hence finally, this leaves just 9 general purpose I/O pins i.e. D0 to D8.
As shown in above figure of NodeMCU Dev Kit. We can see RX, TX, SD2, SD3 pins are not mostly used as GPIOs since they are used for other internal process. But we can try with SD3 (D12) pin which mostly like to respond for GPIO/PWM/interrupt like functions.
Note that D0/GPIO16 pin can be only used as GPIO read/write, no special functions are supported on it.
Firmware for Lua Programming
Normally, You can use NodeMCU with Arduino IDE without any special firmware installation or other process but if you want to use with Lua programming then firmware installation is required. To download firmware in NodeMCU for Lua programming, follow below procedure:
- Download latest firmware from here.
- Download firmware flashing tool from here.
- Connect NodeMCU with your PC & check if it is available in device manager. IF it is not available, you may need to install CP210x USB to UART Bridge VCP drivers available here. After installing drivers NodeMCU board will be available in ports, note down assigned COM port.
- Open flash tool, select COM port. Set firmware path in ‘config’ tab. If the path is correct, it will be highlighted in green color & if path is wrong then highlight will be in red color.
- Open ‘Operation’ tab & click ‘Flash’ button.
- Press Flash Switch and reset the module by pressing reset switch (both switches are available on both side of micro USB port of NodeMCU). You should keep on pressing Flash button while pressing and releasing Reset button. (Flash button connects GPIO0 to GND and Reset Button connects RST to GND). By doing this ESP8266 module will enter into flash mode, you may check this by clicking on Log tab of Flasher Software.
- In ‘log’ tab, it will shows acknowledgement from board, after successful acknowledgment it show the status of set base address. In the operation tab you can see current status of flashing. Once the module gets connected to Flasher software, it starts showing MAC address of the ESP8266 wifi module. On successful completion of flashing green tick mark appear on bottom left corner. The same can be seen from Log tab of Flasher software. After successful flashing Flasher software disconnects itself. The ESP8266 wifi module is now successfully flashed with NodeMCU firmware. You may use it for programming.
There are two methods to program NodeMCU, Lua & Arduino IDE. Lua is easy compared to Arduino IDE but ONLY FOR PROFESSIONALS, If you are a beginner or intermediate then you should go with Arduino IDE. Btw, it is up to you which one you can handle easily! Here we will explain programming with Arduino IDE; To learn programming with Lua go on this website & practise it.
Let’s begin with Arduino IDE method, The open-source Arduino Software (IDE) makes it easy to write code and upload it to the board. It runs on Windows, Mac OS X, and Linux. The environment is written in Java and based on Processing and other open-source software. Download Arduino IDE software with latest version from here. We will start with LED blink (Known as hello world of electronics) program as usual 🙂
Open Arduino IDE & go to File menu > Preferences.
copy below mentioned path and paste in Additional boards manager option.
Click OK and close the preference window. Now go to Tools > Board & Select ‘Board manager’
In board manager, search ESP8266 & install available board as shown in below image;
Now we are ready, Set port of NodeMCU board from Tools > Port. If you can’t find any port of NodeMCU then follow step 1 to 4 from ‘Firmware’ procedure above. Now we have to test the board & we will use ‘Hello World’ of Embedded aka ‘blink’ program. To avoid the need for external hardware, we are going to use the NodeMCU built in LED, which is connected to pin D0 (GPIO16) of the board.
Here is the blink program:
You can download this code (.ino) from here. Upload the code & Eureka!!
I hope this tutorial will be helpful for NodeMCU beginners, Further programs & hardware interface tutorials will be posted in future. Give your feedback about this tutorial in Contact, Your feedback will be appreciated.