Setting up a NodeMCU V3 ESP-12E (esp8266) for Arduino IDE

There are various environments that can be used to program an ESP8266, but as a lot of users will come to this chip after previously working with the Arduino system, being able to use this familiar environment would be great. And the good news is we can 🙂 Thanks to a lot of hard work by some people the Arduino IDE can talk to and program these boards.

A video is available for this article (but apologies for sound, I seemed to have picked up some mains hum on the mike)

Below is a picture of the ESP8266 varient I will  be using from LoLin. It’s a ESP-12E version. As there seem to be many variations of board using the 8266 I cannot guarantee that this guide will work for your particular variation.

Why use an ESP8266 variant?
Good question, for a lot of projects you wont need its power at all and a Arduino will be fine. However for various projects these boards are essential. The fundamental advantages for this version are

  • Much more program memory (various by board but 1 to 4meg is typical)
  • More variable memory (around 80K)
  • Built in Wifi
  • Much faster 40-80Mhz (switchable) compared to the Arduino’s 16Mhz

Disadvantages
Doesn’t fit a standard breadboard, the  development boards (as seen above) can be huge and you won’t fit them on a single width board. You will need to link two together usually or use a larger width bread board. Obviously on strip-board or PCB fabrication this is not as important.

Development Boards
These chips run on 3.3V but Dev. boards will have a regulator on board so you can connect it to your regular USB 5V supplies easily. Although it shouldn’t be easy to do never intercept any of the 5V supply on the board and connect to any pin-out of your board. The board will have 3.3V outputs for you to use for add-ons.

Updating the Arduino IDE
We need to add this board as an option on our IDE. However by default the Arduino IDE does not know where to get the drivers from. But we can tell it. On the Arduino IDE go to File->Preferences

You will see towards the bottom a text field titled

Additional Board Manager URLs

Paste the following line into it

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

If you already have something in there (from adding in other boards) then you will need to click the small icon just to the left of this field to allow you to put in more options.

Once this is done click “OK”. Then go to your board manager “Tools->Some Board previously selected->Boards Manager…“. The boards manager option is at the top of this menu, just in case you can’t see it.

You will then see this window:

Type esp8266 into the search field and the drivers from the esp8266 community should appear. Select it and click install, takes about 2-3mins depending upon your internet connection. Once done close the board manager window.

Selecting the right board
There will now be a lot of new boards to choose from, and it can look quite daunting. Look at the board you have in front of you to help you choose the right one from the list. Initially I chose the “Generic 8266 Module” board but this did not work giving the following errors

warning: espcomm_sync failed
error: espcomm_open failed
error: espcomm_upload_mem failed
error: espcomm_upload_mem failed

I looked at my board and saw that it was NodeMCU V3 and that the seller had labelled it as NodeMCU V3 ESP. So I selected the “NodeMCU 1.0 (ESP 12E Module). This seemed the nearest match. I then tested it with a blink program and it was fine. The NodeMCU 0.9 (ESP12 Module) also appeared to work for uploading but I couldn’t get the blink program to work so I presume my board is the 12E version.

The Blink Program
The example blink program (at time of writing) used a constant “LED_BUILTIN” to denote the built in LED. However this did not work. A little research on these boards revealed that it is in fact pin 2 that is connected to the little blue LED.  Changing all occurrences of LED_BUILTIN to 2 then worked great. The blink code I used is below.

Hope that’s helped some of you, it is difficult to write a generic guide that will work for all people due to the very wide variety of boards out these. But hopefully if you buy the board illustrated you will be fine and if not there is enough in this guide to help you get you particular board working!