Become a subscriber (Free)

Join 29,000 other subscribers to receive subscriber sale discounts and other free resources.
:
:
Don't worry -- youre-mail address is totally secure. I promise to use it only to send you MicroZine.

How to Setup the ESP8266 Arduino IDE with the NodeMCU V3 (ESP8266 ESP12e)

The easy way to use the ESP8266 is with the Arduino IDE and this ESP8266 Arduino tutorial shows you how to install drivers into the Arduino IDE to program the ESP8266. It then shows you an example sketch using wifi.

The Lolin nodeMCU V3 breakout board is an ESP-12E style ESP8266 breakout board which makes it very easy to use an ESP8266 device - you just  plug it into a micro USB connector and its ready.

Lolin nodeMCU V3 Board
Lolin NodeMCU V3 ESP8266 ESP-12E

The board includes its own 3V3 power supply regulator, a reset button, a Flash button and a USB-to-serial chip (CH340G on mine). You can just plug it into a USB port (micro USB connector) and start using it.

When you follow the instructions below, you can program the Lolin NodeMCU as if it were any other Arduino device. This is convenient since it uses the same familiar Arduino IDE programming environment.

Note: Just so you don't get confused: Lolin is a manufacturer name - I originally thought it meant some kind of extended range radio (similar to a Lora device).
Warning: The Lolin nodeMCU V3 comes with the LUA scripting language flashed into it. Using the ESP8266 Arduino IDE as described below will loose that scripting language (overwritten). To get LUA back you would need to re-flash the firmware - just so you know. (LUA Scripting is interactive and quick - but you need to learn another language).

Starting the nodeMCU

When you power up the nodeMCU for the first time you will see this message - when you connect a serial terminal on the PC - such as Tera Term - at 9600, 8 bits, 1 stop bit, no parity (8 1 N):

Initial message from ESP8266 lua interface
This is a LUA interface which is an interactive script system - you can type commands directly at the prompt to get the ESP8266 to perform. However the rest of this page shows you how to use the Arduino programming environment to program the board in C/C++ as you would with any other Arduino board.

If you continue past this point and Flash the Arduino sketch then the LUA environment will be overwritten. If you want to use LUA again you will need to re-flash the firmware.

ESP8266 Arduino Tutorial

Install USB To Serial Drivers

The first step in setting up the ESP8266 Arduino IDE is to plug in the NODEMCU and check the Windows device Manager for an entry in the Ports section.

If you don't see the NodeMCU showing up as shown below then you will need to install drivers. The other possibility is that the NodeMCU is using too much power - I found it would not work from a powered hub but only from direct connection to the PC USB port. It needs 400mA!

External Power Source

Note: You can add an external power source to the Vin connection on the board with voltage >5V. Also connect ground labelled 'G' to complete the circuit.

Warning: The AMS1117 absolute maximum input voltage is 15V - do not go above this i.e. do not supply a voltage to 'Vin' above 15V.
Device manager showing NODEMCU ESP6288 com port

ESP8266 Arduino IDE Boards Manager

To setup the board use the board manager:

Add the following text to the "Additional Boards Manager URLs":

http://arduino.esp8266.com/stable/package_esp8266com_index.json


This will allow NODEMCU boards to appear in the main menu alongside boards such as the Arduino Uno.

ESP8266 Additional Boards Manager Setup

Now Install the nodeMCU Boards

Start the Boards manager dialogue. Click Boards Manager...

Choose NODEMCU board in the Arduino IDE


Search for and install the "esp8266 by ESP8266 community" Entry.

ESP8266 board manager selection

Now select the nodeMCU 1.0 (ESP-12E Module) entry - this is the base type for nodeMCU. nodeMCU is actually the firmware running on an ESP8266 ESP-12E.

nodeMCU Board Selection Arduino IDE

Now check that you have similar information to the following - especially these:

  • Board "nodeMCU 1.0 (ESP-12E Module)"
  • Upload speed "115200baud"
  • CPU frequency "80MHz"
  • Flash Size "1M (3M SPIFFS)"
Warning: I originally set the Flash Size to 4M no SPIFF - only the WiFi scanner example below worked - The SPIFFS is a virtual file system that allows programs to occupy a space separate to the wifi operational part - its like having a virtual SD card so make sure you use the setting above (or at least allow some SPIFFS room).
Board and processor settings for nodeMCU V3

ESP8266 Arduino Example Sketch

Use the ESP8266 Arduino IDE to load the following sketch - just copy to white area of the IED and hit the upload button. This shows you a quick example of the ESP8266 Arudino wifi capability.

This example is from github.

#include "ESP8266WiFi.h"

void setup() {
  Serial.begin(115200);

  // Set WiFi to station mode and disconnect from an AP if it was previously connected
  WiFi.mode(WIFI_STA);
  WiFi.disconnect();
  delay(100);

  Serial.println("Setup done");
}

void loop() {
  Serial.println("scan start");

  // WiFi.scanNetworks will return the number of networks found
  int n = WiFi.scanNetworks();
  Serial.println("scan done");
  if (n == 0) {
    Serial.println("no networks found");
  } else {
    Serial.print(n);
    Serial.println(" networks found");
    for (int i = 0; i < n; ++i) {
      // Print SSID and RSSI for each network found
      Serial.print(i + 1);
      Serial.print(": ");
      Serial.print(WiFi.SSID(i));
      Serial.print(" (");
      Serial.print(WiFi.RSSI(i));
      Serial.print(")");
      Serial.println((WiFi.encryptionType(i) == ENC_TYPE_NONE) ? " " : "*");
      delay(10);
    }
  }
  Serial.println("");

  // Wait a bit before scanning again
  delay(5000);
}

ESP8266 Arduino Example Output

Here's the typical output from the sketch using the serial monitor.

Setup done
scan start
scan done
15 networks found
1: SKY6F103 (-91)*
2: SKY7C621 (-88)*
3: SKY6F103 (-91)*
4: BTWifi-X (-87)
5: BTHub6-2MX3 (-87)*
6: talktalkt8974 (-61)*
7: VM989231-2G (-82)*
8: BNIPOF_6723 (-16)*
9: VM7227168 (-93)*
10: VM0345159 (-92)*
11: BTWifi-with-FON (-88)
12: Virgin Media (-90)*
13: Virgin Media (-93)*
14: VM-guest3451593 (-89)*
15: Virgin Media (-89)*

End of ESP8266 Arduino IDE tutorial showing how to flash an esp8266 with an Arduino .

<<< Back to Flashing nodeMCU Firmware

New! Comments

Have your say about what you just read! Leave me a comment in the box below.




Privacy Policy | Contact | About Me

Site Map | Terms of Use



Visit our Facebook Page:
To Visit Click Here


Recent Articles

  1. How to use the ADXL345 for movement sensing and more.

    With the ADXL345 acellerometer you can detect up to 16g! You can also find out how to use it for tap detection and more.

    Read more

  2. Arduino Interrupt : There are Some You May Never Have Heard About!

    Arduino Interrupt Tutorial: Find out how many external there are on an Arduino Uno - The answer is more than two!

    Read more

  3. Easy Switch Debounce

    Switch debounce: Three different ways to debounce input push switches with one amazing method that you can't miss.

    Read more

  4. How to use the ADS1115

    A tutorial on using the ADS1115 precision 16 bit ADC for low power use.

    Read more

  5. ESP8266 Webserver in Lua

    ESP8266 Webserver: This code shows you how to use lua to create a webserver using html button inputs to contrtol an LED on the ESP module.

    Read more

  6. ESP8266 NodeMCU Firmware: ESP8266 flash

    How to flash nodemcu firmware into a ESP8266 so you can use the LUA scripting language.

    Read more

Readers Comments

"I wanted to thank
you so so so much
for all the information
you have provided in
your site it's

SUPERB and FANTASTIC."

- Ranish Pottath

"This site really is
the best and my favorite.
I find here many useful
projects and tips."

- Milan

bursach<at>gmail.com<

"Awesome site,
very, very easy and nice
to navigate!"


- Matt
matt_tr<at>
wolf359.cjb.net


Learn Microcontrollers

"Interested in
Microcontrollers?"

Sign up for The
Free 7 day guide:

FREE GUIDE : CLICK HERE


"I am a newbie to PIC
and I wanted to say
 how great your
site has been for me."


- Dave

de_scott<at>bellsouth.net

"Your site is a great
and perfect work.
congratulations."


- Suresh

integratredinfosys<at>
yahoo.com

"I couldn't find the correct
words to define
yourweb site.

Very useful, uncovered,
honest and clear.

Thanks so much for
your time and works.
Regards."


- Anon

Back to Top