Introduction: 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
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
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
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
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
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
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
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
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
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
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
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
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
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 .
29 Comments
3 years ago
The 2 minutes quick start guide. excellent!
5 years ago
Thank you for sharing this. Normally i use Atmel uC directly but it's fun to try this board :) On my board i have only one LED... but working fine. 23% of total memory to flash a LED lol
5 years ago
I purchased a ESP8266 ESP12 WeMos
D1 Dev Board WiFi from ebay recently and have just followed the instructions above, they worked a treat.
https://www.ebay.com.au/itm/ESP8266-ESP12-WeMos-D1-Mini-WIFI-NodeMcu-Lua-Development-Board-2-4G-SMA-Antenna/302569206695?ssPageName=STRK%3AMEBIDX%3AIT&var=601408505148&_trksid=p2057872.m2749.l2649
Minor differences.
The board that I have only has one LED.
The ESP8266 board manager added to Arduino IDE has changed a little since the above was written/updated and there are a few extra options for the board, I left them all as default and had no issues.
Thank you for the great instructions.
5 years ago on Step 13
Awesome!!!
How can I connect RFID with the Wemos D1R2 using Arduino Ide?
Reply 5 years ago
https://www.superhouse.tv/17-home-automation-control-with-sonoff-arduino-openhab-and-mqtt/ Johnathon Oxer has a great video that shows how to setup the Arduino IDE for the ESP8266 his video is about the SONOFF but once you have the board manager updated you follow the instructions above.
Question 5 years ago on Step 1
i need a code of ESP8266 E12 v1.0
7 years ago
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.
Reply 7 years ago
There is one on the mother board and the other is on the ESP board.
Reply 7 years ago
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?
Reply 6 years ago
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
Reply 7 years ago
I have not played with it. My guess is it is to flash the interpreter.
7 years ago
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
Reply 7 years ago
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.
7 years ago
Thanks, very helpful!
7 years ago
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
7 years ago
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.
7 years ago
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.
7 years ago
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.
Reply 7 years ago
also Google "arduino uno esp8266 web server"
Reply 7 years ago
https://www.instructables.com/id/noobs-guide-to-ESP8266-with-Arduino-Mega-2560-or-U/