Click here to Skip to main content
15,115,557 members
Articles / Programming Languages / C++
Posted 21 Jan 2016

Tagged as


17 bookmarked

Programming the ESP8266 (NodeMCU) with the Arduino IDE

Rate me:
Please Sign up or sign in to vote.
4.87/5 (6 votes)
21 Jan 2016CPOL3 min read
Project with NodeMCU (ESP8266) to control an RGB LED using the Arduino Programming Language


This is an introductory article for those who already know the Arduino platform and are starting the programming the ESP8266 module through the NodeMCU platform or any other microcontroller of the same category.

The ESP8266 Module

The ESP8266 module is a IoT device consisting of a 32-bit ARM microprocessor with support of WIFI network and built-in flash memory. This architecture allows it to be programmed independently, without the need of other microcontrollers like the Arduino, for example.


The problem is that, to create a development environment  focused in the ESP8266, we need to build a circuit with other integrated components to facilitate the work. That's why several projects arose of boards that incorporate the ESP8266, from which we highlight the following:

In this article, we will use the NodeMCU board as an example, but the design can be easily adapted to any other ESP8266 platform.

The NodeMCU Platform

NodeMCU is a complete environment of hardware and software for IoT prototyping consisting of the following items:

  • Controller board consisting of a ESP8266 module
  • Micro USB Port to power (5 volts) and programming
  • 10 digital inputs GPIOs operating at 3.3V and an analog input GPIO to 1.8 V
  • Development kit based on the Lua language


Advantages of NodeMCU platform relative to the Arduino

  • Low cost
  • Integrated support for WIFI network
  • Reduced size of the board
  • Low energy consumption


  • Need to learn a new language and IDE
  • Reduced pinout
  • Scarce documentation

The NodeMCU programming can be as easy as in Arduino. The main difference is in the pinning of the board, described below:

Image 3

There are 6 extra GPIOs. All of them can be programmed as PWM, I2C, 1-wire, except for GPIO16 (D0).

For details on the ESP8266 and NodeMCU, see the references at the end of the page.
The purpose of this article is to show how we can program the NodeMCU using the Arduino programming language because, in this way, we are greatly reducing the disadvantages that the platform offers.

Example Project with NodeMCU

The sample project that we will develop consists in to make an RGB LED blinking, alternating their basic colors (red, green, blue) within an infinite loop. Watch a video demonstration here.

Necessary Components

  • NodeMCU board
  • Led RGB
  • 3 x 220 ohms resistors (or approximated values)
  • Wire jumpers

Mounting Details


Software Installation

  1. Before using the IDE, install the USB driver in the operating system, which may be the CH340 or CP2102, depending on the board version.
  2. Run the Arduino IDE. If it has not been installed, do so here:
  3. Open the Preferences window and type in the "Additional Board Manager URLs" the following address:
  4. On the Tools menu, configure your board according to the model you are using. The most common options are:
    1. Board: NodeMCU, according to its model
    2. CPU Frequency: 80 MHz
    3. Upload Speed: 115200

Ready? Now just do as the Arduino: Let's Sketch!

Note: When you use the NodeMCU board with the Arduino IDE, the Lua firmware will be deleted and replaced by the sketch. If you want to use the Lua SDK again, will be necessary "flashing" the firmware again.

The Sketch

NodeMCU example: RGB Led blinking
2016 by José Cintra

int redPin = D1, greenPin = D2, bluePin = D3;

void setup() {
  pinMode(redPin, OUTPUT); pinMode(greenPin, OUTPUT); pinMode(bluePin, OUTPUT);

void loop() {
  digitalWrite(redPin, HIGH); delay(500);
  digitalWrite(redPin, LOW); delay(500);
  digitalWrite(greenPin, HIGH); delay(500);
  digitalWrite(greenPin, LOW); delay(500);
  digitalWrite(bluePin, HIGH); delay(500);
  digitalWrite(bluePin, LOW); delay(500);



In this article, we saw how to configure NodeMCU in  the Arduino IDE. In upcoming articles, we will adapt this design to use Bluetooth and Wi-Fi.

See you in the next project ...


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

José Cintra
Software Developer
Brazil Brazil
I am a software developer focused on Mathematics, IoT and Games.
Homepage: HTML Apps

Comments and Discussions

Questionhave you consider to post this as a tip? Pin
Nelek7-Feb-16 0:43
protectorNelek7-Feb-16 0:43 
AnswerRe: have you consider to post this as a tip? Pin
José Cintra11-Feb-16 9:47
MemberJosé Cintra11-Feb-16 9:47 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.