Introduction: Programming the ESP8266-12E Using Arduino Software/IDE

Picture of Programming the ESP8266-12E Using Arduino Software/IDE

The ESP8266 is like an Arduino with a builtin WiFi, the MCU and WiFi circuitry are in the same chip. Consider Arduino + WiFi Shield = ESP8266. In this instructable I will provide a step by step guide to procure and programming an ESP8266-12E WIFI Development Board. You will also learn how to install and update the Arduino software/IDE in the Windows environment to program your ESP8266-12E. We will then write a DoubleBlink sketch to brink the two on board LED.

Step 1: Purchasing the Board

Picture of Purchasing the Board

I bought the NodeMcu Lua ESP8266 ESP-12E + WiFi Motor Drive Expansion Board from a supplier in China. They arrived within two weeks. It was cost effective to buy the ESP8266-12E board with the Motor Drive Expansion Board. I paid $11.64 for the pair. More about the programming of the Motor Drive Expansion Board in a later instructable.

For the purpose of this instructable you only need the NodeMcu Lua ESP8266 ESP-12E WIFI Development Board. There are several benefits of using this development board rather than the module, the chief among them is - being able to use it right out of the box. It comes with the necessary circuitry to manage the voltages. The on-board USB to UART makes interfacing with computers a lot simpler.

The ESP8266-12E boards arrived in an anti-static bags. There was no USB cable. This board has a micro USB connector. I tried connecting the micro USB cable that came with my android charger. That did not work because it is not a data cable. I had some spare micro USB data cables sitting around and found one that worked.

Step 2: Installing the CP120x Drivers

Picture of Installing the CP120x Drivers

From this step onward make sure your ESP8266-12E is securely connected to your computer.

I have a Windows 7.0 laptop that I used to test and program the ESP8266-12E. When I first hooked the ESP8266-12E to the computer the “New device found - installing drivers” message showed up. By default Windows could not find the drivers and kept on looking and looking and looking. I killed that search!

To install the drivers, open the Window's Control Panel and clicked on the Device Manager. There you will find the USB controller that exists on your ESP8266-12E board. It is the CP120x USB to UART Bridge Controller chip. Right click on the CP120x USB Composite Controller (it has a tiny yellow caution symbol) under Other Devices.

I googled “CP1201 USB to UART drivers” and found the drivers here. This web page also has good instructions on how to install the drivers.

Download the zip file cp210x44.zip and unzip it. Your Windows drivers are in the YourDownloadDir/cp210x44/x86 directory. To install the drivers right click on the “CP120x USB Composite Controller” line in your Device Manager and in the popup select “Update Driver Software…” and take it from there on. From here on the process to install the USB to UART drivers is obvious.

Once the drivers are properly installed the caution symbol will disappear and the “CP120x USB Composite Controller” entry would have moved under “Universal Serial Bus Controllers” and also “Ports (COM & LPT)”. Your driver is installed!!!

Step 3: Installing Arduino Software/IDE

Picture of Installing Arduino Software/IDE

I downloaded the most current Arduino software (Version 1.6.5) from here. It is a Windows installer exe file so double clicking on it will start the installation including the installation of several peripheral drivers. You can find detailed instructions to install the Arduino software here.

Once the Arduono software is installed, I tested the install by connecting an existing Arduino Uno that I had and uploaded the Blink sketch. All systems worked as they were supposed to.

Step 4: Where to Find the Preferences Dialog

Picture of Where to Find the Preferences Dialog

You will need to familiarize yourself with the “File | Preferences” dialog box. We will need this info later.

Step 5: Where to Find the Boards Manager Dialog

Picture of Where to Find the Boards Manager Dialog

You will also need to know about the “Tools | Board:… | Boards Manager” dialog box. You have an older version of Arduino software if you cannot see “Board Manager” in the menu. Go update your software.

Step 6: Telling Arduino Where to Find the ESP8266-E12 Library

Picture of Telling Arduino Where to Find the ESP8266-E12 Library

The ESP8266-E12 board can be added to the Arduino software/IDE by installing the necessary libraries. This community supported Github page: Unofficial list of 3rd party boards support has the information needed to get your Arduino software to support the ESP8266-E12. Search/look for “ESP8266” on this webpage. Look for the URL shown in the image above. Copy and paste that URL into your Preferences dialog and select OK. Do not click on the URL.

Step 7: Installing the ESP8266 Board Via the Board Manager

Picture of Installing the ESP8266 Board Via the Board Manager

Open “Tools | Board:| Boards Manager” dialog box. Somewhere in there you will see the entry “esp8266 of ESP8266 Community” select that. The Install button will appear, click the Install button. Wait for a while… This process will take some time to download and complete. After the install I shut the Arduino program and restarted it.

Step 8: Determining the COM Port ESP8266-12E Shows Up On

Picture of Determining the COM Port ESP8266-12E Shows Up On

If not connected connect the ESP8266-E12 board to your computer. Give it a couple of minutes to settle down. Go to Device Manager and click on “Ports (COM & LPT)”. There you will find the port number that your ESP8266-12E is connected on. In my case it is COM17. Make a note of that, we need this info later.

Step 9: Selecting the ESP8266-E12 Board

Picture of Selecting the ESP8266-E12 Board

Now fire-up your Arduino software, you will see the boiler plate sketch. Go to “Tools | Board:…” and select “NodeMCU 1.0 (ESP8266-12E Module)”, in my case I had to scroll way down the menu to find it.

Step 10: Configuring COM Port

Picture of Configuring COM Port

In Step 8 we had determined the COM port ESP8266-12E appears on. To select the COM port, go to “Tools | Port:” and select the COM port,in my case it was COM17.

Step 11: Configuring COM Port Speed

Picture of Configuring COM Port Speed

To select the speed of communication between the ESP8266-12E and the computer.
Go to "Tools | Upload" Speed: and select 115200. We are ready to upload our first sketch.

Step 12: Test Drive the Setup

Picture of Test Drive the Setup

I prefer test driving the complete setup using the boiler plate sketch.

To upload the boiler plate sketch go to "Sketch | Upload" or use the shortcut key Crtl+U or click on the right arrow button next to the check mark. A successful compile and upload means all systems are working and we are ready to go prime time. We can pat yourselves on the back for a job well done.

Step 13: Writing the First Sketch: DoubleBlink

Picture of Writing the First Sketch: DoubleBlink

The NodeMcu ESP8266-12E WIFI Development Board has two LED connected to the digital I/O pins. One LED is on GPIO 2 and the other is on GPIO 16. The sketch DoubleBlink.ino will alternate the blinking of these LEDs. Save your sketch and upload it to your ESP8266-12E. The two blue onboard LED will blink alternately.

DoubleBlink.ino

const short int BUILTIN_LED1 = 2; //GPIO2
const short int BUILTIN_LED2 = 16;//GPIO16

void setup() {

pinMode(BUILTIN_LED1, OUTPUT); // Initialize the BUILTIN_LED1 pin as an output
pinMode(BUILTIN_LED2, OUTPUT); // Initialize the BUILTIN_LED2 pin as an output

}

void loop() {

digitalWrite(BUILTIN_LED1, LOW); // Turn the LED ON by making the voltage LOW digitalWrite(BUILTIN_LED2, HIGH); // Turn the LED off by making the voltage HIGH delay(1000); // Wait for a second
digitalWrite(BUILTIN_LED1, HIGH); // Turn the LED off by making the voltage HIGH
digitalWrite(BUILTIN_LED2, LOW); // Turn the LED ON by making the voltage LOW
delay(2000); // Wait for two seconds

}

Disconnect the ESP-8266-12E from your computer and connect an external 5V power source. I connected it to the power bank that I use to charge my phone. The LEDs will start blinking. I also connected the board to a couple of stacked CR2025 button cells which I taped behind the board and wore the contraption as a necklace.

HAPPY IoTing!!!

I enjoyed working with this tiny board. Time permitting I will write more Instructables sharing what I have learned.

My next Instructable is Programming a HTTP Server on ESP-8266-12E .

Step 14: List of Other Instructables I Have Written

Comments

wkraus (author)2016-05-03

Thanks for Your posting. Very helpful to me. I am still looking for the second LED. LED on Pin 2 works fine, but I cannot find any more LEDs on the board.

jainrk (author)wkraus2016-05-03

There is one on the mother board and the other is on the ESP board.

wkraus (author)jainrk2016-05-03

Only the LED on the ESP board is blinking. Not sure where on the mother board the second may be. Or maybe I have a different board (LoLin new ModeMcu V3).

2. Do you have any idea what the 'flash' button is for?

destroyedlolo (author)wkraus2017-10-07

Mine has only 1 LED too.

As per the doc of my board, holding "Flash" during a reset make the ESP entering a flashing mode. Well, it's a bit useless as the IDE can flash the ESP directly, without this key.

Does someone knowing if we can reuse this key for something useful in our code ?

A question about the code : why I see constants frequently defined as "const short int" for arduino code ? There is a raison instead of using a classical #define ?

I will not forget to thanks a lot for this article : very useful and well documented.

Thanks

jainrk (author)wkraus2016-05-03

I have not played with it. My guess is it is to flash the interpreter.

AlanGP (author)2016-10-02

I purchased an ESP 8266 NodeMCU board from eBay because they are receiving massive uTube attention, so what's it all about? The board is marked "0.9" although the advert was for the 12E - Ho hum eBay ?. My only concerns were the LUA programming environment and how to upload the code. This Instructable has knocked all those issues away so thank you very much jainrk for your work. Regards AlanGP

AlanGP (author)AlanGP2016-10-02

The LUA environment is an "add on" language (NodeMCU boards use LUA 5.1) so apart from the obvious differences i.e. GPIO as opposed to digital and analogue inputs/outputs programming has a familiar feel - only some of the terms have changed. There are plenty of LUA code snippets out there in Internet land, which will allow you to programme the basic functions.

MStylesMS (author)2016-07-26

Thanks, very helpful!

jescobar10 (author)2016-06-29

alguno de ustedes me podria apoyar? estoy tratando de hacer lectura de un potenciometro con el esp826607 e imprimirlo en un servidor web programandolo con arduino ide plugin

Jeujam (author)2016-05-28

Thanks for the nice instructions, works like a charm.

Please pay attention that when you copy the code from the website that it is missing enters. So code ends up in the comment.

Jeujam (author)2016-05-28

Thanks for the nice instructions, works like a charm.

Please pay attention that when you copy the code from the website that it is missing enters. So code ends up in the comment.

keshavadk (author)2016-05-16

I have interface Arduino Uno with ESP8266-01 and 16*2 LCD . The webpage has two text box and submit button. When i type text on webpage and click on submit button ,text should appear on LCD. I am stuck in web part . HOw to coomunicate web part and Arduino. I tried HTML with GET method . But not working .Can you please help.

jainrk (author)keshavadk2016-05-16

also Google "arduino uno esp8266 web server"

jainrk (author)keshavadk2016-05-16

https://www.instructables.com/id/noobs-guide-to-ESP8266-with-Arduino-Mega-2560-or-U/

Heikov (author)2016-05-04

Thanks for posting this tutorial. Works fine!

just_some_nerd (author)2016-03-12

Hi, which firmware are you using??

CelsoF2 (author)2016-02-26

Hello. Do you know what is the flash size of this board? Because esp-01 has only 512k, and it is not enough to do OTA. Did you have problems using it with arduino Ide because it came with node mcu firmware? It seems to be the best esp board today. What do you think? Thanks!

jainrk (author)CelsoF22016-02-26

I found this info on one of the vendors website - "Large -capacity flash-4Mbit serial ESP8266 WIFI , model : ESP-12E"

jainrk (author)jainrk2016-02-26

On closer look 4 Mbit could mean 512 kilobytes.


Dram229 (author)2016-02-11

Super easy to follow. Thanks for putting this together!

Philippe_ (author)2015-12-07

Thanks a lot for this perfect quick startup!!

tomatoskins (author)2015-10-14

Really cool! Thanks for sharing and welcome to the community!

jainrk (author)tomatoskins2015-10-14

Thanks for the warm welcome.

About This Instructable

262,971views

139favorites

License:

More by jainrk:DIY - Fold a Letter Envelopes From an 8 ½  X 11 Sheet of PaperESP8266: I2C PORT and Address Scanner$1 USB to UART-serial flashing device (dongle) with 3.3 V power supply for ESP8266MOD ESP-12 module
Add instructable to: