{"id":286,"date":"2015-03-23T19:00:01","date_gmt":"2015-03-24T02:00:01","guid":{"rendered":"http:\/\/internetofhomethings.com\/homethings\/?p=286"},"modified":"2015-06-05T07:25:09","modified_gmt":"2015-06-05T14:25:09","slug":"getting-started-with-the-esp8266-12","status":"publish","type":"post","link":"https:\/\/internetofhomethings.com\/homethings\/?p=286","title":{"rendered":"Getting Started with the ESP8266-12"},"content":{"rendered":"<p class=\"western\">I was really excited when first discovering\u00a0the ESP8266. Imagine&#8230;a tiny footprint device capable of connecting to the internet with a WIFI connection. With the capability to control &#8216;things&#8217; and monitor sensors. A genuine SoC (System on a Chip). And best of all&#8230;for a price under 5 USD.<\/p>\n<p class=\"western\">I was determined to make this as low cost as possible. So I found an inexpensive Asian supplier and ordered a lot of 5 of them for $2.68 each. And FREE shipping.<\/p>\n<p class=\"western\">But I knew the delivery would be slow with these terms so I researched what else was needed. A USB to serial converter was the only other thing essential to getting started. This would be used both for programming the ESP8266 and providing it with the required 3.3V power source. Another search netted a supplier of these at $0.64 each (minimum order of 10).<\/p>\n<p class=\"western\">Hmmm&#8230;if this works, throw in a couple of sensors and stuff and we what we have is still a very low-cost solution to internet-enable something\u2014perhaps EVERYTHING!<\/p>\n<p class=\"western\">It did take a while for those ESP8266 devices to arrive&#8230;46 days from the order date. But hey, with all my other \u201cirons in the fire\u201d, this was not even an inconvenience.<\/p>\n<p class=\"western\">So when the hardware arrived, I started to search for a simple way to get started. What I found was that there are many variants of the ESP8266, and they do not all behave exactly the same. I had ordered the ESP8266-12 models. These were 16-pin devices and all the information I found was for the earlier designs, the 8-pin variety. And yes, there is an important set-up for the ESP8266-12 that was not mentioned for the earlier units.<\/p>\n<p class=\"western\">The purpose of this document is to provide a &#8216;getting started quickly&#8217; guide for the ESP8266-12. What&#8217;s great is that almost all of the steps also apply to the earlier versions.<\/p>\n<p class=\"western\">The ESP8266 is an open-source device with bits and pieces of the puzzle scattered about. Piecing it all together can be somewhat challenging. I hope the information presented here makes it possible for someone to get started quicker and easier than I did, without needed to jump elsewhere for missing pieces.<\/p>\n<p class=\"western\">Getting started with the ESP8266 breaks down into five steps:<\/p>\n<ol>\n<li>\n<p class=\"western\"><a href=\"#step1\">Connecting the hardware<\/a><\/p>\n<\/li>\n<li>\n<p class=\"western\"><a href=\"#step2\">Install the USB to serial device driver<\/a><\/p>\n<\/li>\n<li>\n<p class=\"western\"><a href=\"#step3\">Verify the unit is functional<\/a><\/p>\n<\/li>\n<li>\n<p class=\"western\"><a href=\"#step4\">Flashing NodeMcu<\/a><\/p>\n<\/li>\n<li>\n<p class=\"western\"><a href=\"#step5\">Installing an application<\/a><\/p>\n<\/li>\n<\/ol>\n<p><a name=\"step1\"><\/a><\/p>\n<h3><b>Step 1: Connecting the hardware<\/b><\/h3>\n<p class=\"western\">This is a list of all the components I used to get started:<\/p>\n<ul>\n<li class=\"western\">ESP8266 module<\/li>\n<li class=\"western\">USB to Serial converter<\/li>\n<li class=\"western\">3.3V 1A Power Supply<\/li>\n<li class=\"western\">Capacitor (4.7uf)<\/li>\n<li class=\"western\">LED<\/li>\n<li class=\"western\">Resistors (10 kohm (3), 330 ohm, 100 ohm)<\/li>\n<li class=\"western\">Zener Diode (3.3V)<\/li>\n<li class=\"western\">Breadboard<\/li>\n<li class=\"western\">Jumper wires<\/li>\n<\/ul>\n<p class=\"western\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-287 size-medium\" src=\"http:\/\/internetofhomethings.com\/homethings\/wp-content\/uploads\/2015\/03\/ESP8266-bag-243x300.jpg\" alt=\"ESP8266 in ESD bag\" width=\"243\" height=\"300\" srcset=\"https:\/\/internetofhomethings.com\/homethings\/wp-content\/uploads\/2015\/03\/ESP8266-bag-243x300.jpg 243w, https:\/\/internetofhomethings.com\/homethings\/wp-content\/uploads\/2015\/03\/ESP8266-bag-830x1024.jpg 830w\" sizes=\"auto, (max-width: 243px) 100vw, 243px\" \/><\/p>\n<p>&nbsp;<\/p>\n<p class=\"western\">The ESP8266-12 units were delivered in sealed ESD bags. No headers were installed on the printed wiring board. But a bigger issue was that the centers between each pin (8 on each side) are 2mm. That is tighter than the 2.54 mm of a standard breadboard.<\/p>\n<div id=\"attachment_312\" style=\"width: 310px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/internetofhomethings.com\/homethings\/wp-content\/uploads\/2015\/03\/ESP8266image.png\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-312\" class=\"wp-image-312 size-medium\" src=\"http:\/\/internetofhomethings.com\/homethings\/wp-content\/uploads\/2015\/03\/ESP8266image-300x228.png\" alt=\"ESP8266-12 Top and Bottom Views\" width=\"300\" height=\"228\" srcset=\"https:\/\/internetofhomethings.com\/homethings\/wp-content\/uploads\/2015\/03\/ESP8266image-300x228.png 300w, https:\/\/internetofhomethings.com\/homethings\/wp-content\/uploads\/2015\/03\/ESP8266image.png 997w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><p id=\"caption-attachment-312\" class=\"wp-caption-text\"><strong>ESP8266-12 Top and Bottom Views<\/strong><\/p><\/div>\n<p>&nbsp;<\/p>\n<p>First challenge was to make the module mountable on a breadboard. Anxious to get started, I took the quick and\u00a0dirty route and simply cut 8 breadboard jumpers in half, enough for 16 signals. The cut end was stripped and soldered to the ESP8266-12, one wire on each of the 16 holes. This got me started quickly without needing anything extra, like a separate perforated board to break-out the signals. Not pretty, but it&#8217;s working just fine for initial prototyping.<\/p>\n<p class=\"western\"><a href=\"http:\/\/internetofhomethings.com\/homethings\/wp-content\/uploads\/2015\/03\/ESP8266-jumpers.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-290 size-medium\" src=\"http:\/\/internetofhomethings.com\/homethings\/wp-content\/uploads\/2015\/03\/ESP8266-jumpers-300x141.jpg\" alt=\"ESP8266-jumpers\" width=\"300\" height=\"141\" srcset=\"https:\/\/internetofhomethings.com\/homethings\/wp-content\/uploads\/2015\/03\/ESP8266-jumpers-300x141.jpg 300w, https:\/\/internetofhomethings.com\/homethings\/wp-content\/uploads\/2015\/03\/ESP8266-jumpers-1024x482.jpg 1024w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p class=\"western\">The \u201cjumper-ed\u201d module mated easily to a breadboard.<\/p>\n<p class=\"western\">I would have used shorter jumpers if I had make this setup again. With tighter connections, the jumper pins would have connected to the breadboard somewhat cleaner; almost straight down from the module. But then, this is just a quick-start setup and has proven to be quite reliable.<\/p>\n<p class=\"western\"><a href=\"http:\/\/internetofhomethings.com\/homethings\/wp-content\/uploads\/2015\/03\/ESP8266-OnBreadboard.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-medium wp-image-291\" src=\"http:\/\/internetofhomethings.com\/homethings\/wp-content\/uploads\/2015\/03\/ESP8266-OnBreadboard-186x300.jpg\" alt=\"ESP8266-OnBreadboard\" width=\"186\" height=\"300\" srcset=\"https:\/\/internetofhomethings.com\/homethings\/wp-content\/uploads\/2015\/03\/ESP8266-OnBreadboard-186x300.jpg 186w, https:\/\/internetofhomethings.com\/homethings\/wp-content\/uploads\/2015\/03\/ESP8266-OnBreadboard-636x1024.jpg 636w, https:\/\/internetofhomethings.com\/homethings\/wp-content\/uploads\/2015\/03\/ESP8266-OnBreadboard.jpg 1313w\" sizes=\"auto, (max-width: 186px) 100vw, 186px\" \/><\/a><\/p>\n<p class=\"western\">As an initial test, a simple flashing LED will be coded. As shown below, the hardware needed for this is minimal. Note that GPIO15 must be grounded. That fact was not stated in much the information available on-line regarding this module. The unit will simply not work without this connection. I hope this saves someone from the initial grief I went through prior to properly configuring GPIO15.<\/p>\n<p class=\"western\"><a href=\"http:\/\/internetofhomethings.com\/homethings\/wp-content\/uploads\/2015\/03\/schematicNEW.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-647 size-large\" src=\"http:\/\/internetofhomethings.com\/homethings\/wp-content\/uploads\/2015\/03\/schematicNEW-1024x537.jpg\" alt=\"schematicNEW\" width=\"620\" height=\"325\" srcset=\"https:\/\/internetofhomethings.com\/homethings\/wp-content\/uploads\/2015\/03\/schematicNEW-1024x537.jpg 1024w, https:\/\/internetofhomethings.com\/homethings\/wp-content\/uploads\/2015\/03\/schematicNEW-300x157.jpg 300w\" sizes=\"auto, (max-width: 620px) 100vw, 620px\" \/><\/a><\/p>\n<p class=\"western\">A few notes regarding the circuit:<\/p>\n<ul>\n<li>\n<p class=\"western\">Components connected with &#8216;dashed&#8217; line are optional but recommended for reliable operation.<\/p>\n<\/li>\n<li>\n<p class=\"western\">Connecting GPIO0 to ground should only be made when flashing the ESP8266. It is shown with a switch in the path, but simply adding this connection as a breadboard jumper when flashing is adequate.<\/p>\n<\/li>\n<li>\n<p class=\"western\">During development and testing, there will be times when you will ant to reset the module. This can be done by momentarily connection a jumper from REST to ground.<\/p>\n<\/li>\n<li>\n<p class=\"western\">The 100 ohm resistor and 3.3V zener diode from the USB transmit signal to the ESP8266 receive protects the ESP8266 from potential damage from exposure to 5V. The module is not specified to accept any inputs greater than 3.3V.<\/p>\n<\/li>\n<li>\n<p class=\"western\">It is a good practice to have a capacitor across the power rails near the active components. The 4.7 uF capacitor I used is larger than what is needed for this simple circuit. I suggest using one greater than 0.1 uF.<\/p>\n<\/li>\n<li>\n<p class=\"western\">A separate 3.3V power source is needed. Do not use the USB 3.3V output.<\/p>\n<\/li>\n<\/ul>\n<p class=\"western\">To be honest, my initial set-up did not even include the external power supply. I was using the 3.3V provided by the USB to serial bridge (top contact of red device above). But the performance was intermittent. Sometimes it would fail during a flash, and the unit would often freeze it&#8217;s activity after a short time running. These problems were eliminated after using an external supply to power the ESP8266.<\/p>\n<p class=\"western\">The problem is that the USB bridge&#8217;s 3.3V output provides insufficient power. The current tops out at 100 ma while the ESP8266 can require more than 200 ma. I recommend that you save yourself some headaches; USE A SEPARATE 3.3V POWER SUPPLY.<\/p>\n<p class=\"western\" align=\"center\"><span style=\"font-size: large;\"><b>Slow boat from China<\/b><\/span><\/p>\n<p class=\"western\"><b>Another power supply option:<\/b> Almost everyone has a few 5V USB wall plus for various uses. And who doesn&#8217;t also have one or more USB cables that no longer charge properly? These cables, along with a cheap 3.3V voltage regulator offer an inexpensive way to satisfy the ESP8266 power requirements. I have found a supplier selling regulators, model LM1117, for 0.04 USD each, but you have to order a minimum of 100, a lifetime supply for 4 USD&#8230;and this includes free shipping). Only catch is that it will take about 45 days to receive the goods on that slow boat from China).<\/p>\n<p class=\"western\"><a href=\"http:\/\/internetofhomethings.com\/homethings\/wp-content\/uploads\/2015\/03\/5V_3.3V.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter  wp-image-294\" src=\"http:\/\/internetofhomethings.com\/homethings\/wp-content\/uploads\/2015\/03\/5V_3.3V-300x169.jpg\" alt=\"5V_3.3V\" width=\"437\" height=\"246\" srcset=\"https:\/\/internetofhomethings.com\/homethings\/wp-content\/uploads\/2015\/03\/5V_3.3V-300x169.jpg 300w, https:\/\/internetofhomethings.com\/homethings\/wp-content\/uploads\/2015\/03\/5V_3.3V.jpg 831w\" sizes=\"auto, (max-width: 437px) 100vw, 437px\" \/><\/a><\/p>\n<p class=\"western\">Here is what my test setup looked like after all the jumpers were in place:<\/p>\n<p class=\"western\"><a href=\"http:\/\/internetofhomethings.com\/homethings\/wp-content\/uploads\/2015\/03\/ESP8266-TestSetup.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter  wp-image-295\" src=\"http:\/\/internetofhomethings.com\/homethings\/wp-content\/uploads\/2015\/03\/ESP8266-TestSetup-300x211.jpg\" alt=\"ESP8266-TestSetup\" width=\"651\" height=\"458\" srcset=\"https:\/\/internetofhomethings.com\/homethings\/wp-content\/uploads\/2015\/03\/ESP8266-TestSetup-300x211.jpg 300w, https:\/\/internetofhomethings.com\/homethings\/wp-content\/uploads\/2015\/03\/ESP8266-TestSetup-1024x719.jpg 1024w\" sizes=\"auto, (max-width: 651px) 100vw, 651px\" \/><\/a><\/p>\n<p><a name=\"step2\"><\/a><\/p>\n<h3><b>Step 2: Install the USB to serial device driver<\/b><\/h3>\n<p class=\"western\">If you have already have a working serial interface, you can skip this section and move on to step 3.<\/p>\n<p class=\"western\">There are many USB to serial devices available that will work well to program the ESP8266. If you do not have one already, you simply need a serial port with 3 signals:<\/p>\n<ul>\n<li>\n<p class=\"western\">Transmit<\/p>\n<\/li>\n<li>\n<p class=\"western\">Receive<\/p>\n<\/li>\n<li>\n<p class=\"western\">Ground<\/p>\n<\/li>\n<\/ul>\n<p class=\"western\">The one I selected provided 3.3V output. At the time, I thought this was essential, thinking that it would be needed to drive the ESP8266. But now, using an external supply for the 3.3V source, this voltage out of the USB to serial module is not necessary and is not used.<\/p>\n<p class=\"western\">Just follow the instructions for your serial port to install the drivers. <a title=\"Serial Interface to the ESP8266-12\" href=\"http:\/\/internetofhomethings.com\/homethings\/?p=228\" target=\"_blank\">Installation for my device<\/a>, which is based on a CP210x chip, is provided in a separate <a title=\"Serial Link for ESP8266\" href=\"http:\/\/internetofhomethings.com\/homethings\/?p=228\" target=\"_blank\">post<\/a>.<\/p>\n<p><a name=\"step3\"><\/a><\/p>\n<h3><b>Step 3: Verify the unit is functional<\/b><\/h3>\n<p class=\"western\">We now have the hardware setup established. Let&#8217;s make this thing work. Here is where things start to get interesting.<\/p>\n<p class=\"western\">First, connect the USB to serial device to your computer and plug in the power supply. If the ESP8266-12 is functional, you should see the blue led flash twice when the power is applied. Great, this is the first confirmation that the unit is alive.<\/p>\n<p class=\"western\">What is needed now is a method to verify the unit is functional, the ability to develop code and to flash the unit with code. Here we go&#8230;<\/p>\n<p class=\"western\">First, open up your favorite terminal program such as putty or tera-term.<\/p>\n<p class=\"western\">Start-up by applying power to the unit, or connect and release a jumper from REST to ground with a powered up unit.<\/p>\n<p class=\"western\">Expect the blue led to flash twice on start-up.<\/p>\n<p class=\"western\">Note that start-up output at the terminal windows is garbage at both 9600 and 115200 baud. I tried this at all baud rates from 110 to 921600&#8230;none of these rates resulted in a recognizable output.<\/p>\n<p class=\"western\"><a href=\"http:\/\/internetofhomethings.com\/homethings\/wp-content\/uploads\/2015\/03\/initialserialoutput.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-296 size-full\" src=\"http:\/\/internetofhomethings.com\/homethings\/wp-content\/uploads\/2015\/03\/initialserialoutput.png\" alt=\"initialserialoutput\" width=\"677\" height=\"350\" srcset=\"https:\/\/internetofhomethings.com\/homethings\/wp-content\/uploads\/2015\/03\/initialserialoutput.png 677w, https:\/\/internetofhomethings.com\/homethings\/wp-content\/uploads\/2015\/03\/initialserialoutput-300x155.png 300w\" sizes=\"auto, (max-width: 677px) 100vw, 677px\" \/><\/a><\/p>\n<p class=\"western\">This suggests that the unit is not shipped with firmware. To get started then, you will need to get the AT command set firmware and flasher. There are many sites that have it. I got my copy <a title=\"ESP8266 Flasher and Firmware\" href=\"https:\/\/github.com\/thefarmers\/wake\/tree\/7b0c78b5998fba8b93db7d4904dd681f5864dc05\/ESP\/firmware\/esp8266_flasher\/Could%20update%20ESP8266\" target=\"_blank\">here<\/a>.<\/p>\n<p class=\"western\">Knowing that\u00a0things change over time, it is suggested that you do a search for &#8220;ESP8266 flasher&#8221; if it is no longer at the site mentioned.<\/p>\n<p class=\"western\" align=\"center\"><span style=\"font-size: large;\"><b>Flashing the AT command firmware<\/b><\/span><\/p>\n<p class=\"western\">Now let&#8217;s flash some\u00a0firmware:<\/p>\n<ul>\n<li>\n<p class=\"western\">Ground GPIO0 and start-up or reset device.<\/p>\n<ul>\n<li>\n<p class=\"western\">You should see the blue LED flash once.<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<ul>\n<li>\n<p class=\"western\">Run the executable \u201cesp8266_flasher.exe\u201d that was just downloaded.<\/p>\n<\/li>\n<li>\n<p class=\"western\">Click the \u201cBin\u201d button to select the downloaded firmware (ESP_8266_BIN0.22.bin).<\/p>\n<\/li>\n<li>\n<p class=\"western\">Enter the COMx number assigned to your serial port (mine was 7).<\/p>\n<\/li>\n<li>\n<p class=\"western\">Click \u201cdownload.<\/p>\n<\/li>\n<\/ul>\n<p class=\"western\"><a href=\"http:\/\/internetofhomethings.com\/homethings\/wp-content\/uploads\/2015\/03\/ESP8266Flasher21.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-301 size-full\" src=\"http:\/\/internetofhomethings.com\/homethings\/wp-content\/uploads\/2015\/03\/ESP8266Flasher21.png\" alt=\"ESP8266Flasher\" width=\"652\" height=\"356\" srcset=\"https:\/\/internetofhomethings.com\/homethings\/wp-content\/uploads\/2015\/03\/ESP8266Flasher21.png 652w, https:\/\/internetofhomethings.com\/homethings\/wp-content\/uploads\/2015\/03\/ESP8266Flasher21-300x164.png 300w\" sizes=\"auto, (max-width: 652px) 100vw, 652px\" \/><\/a><\/p>\n<p class=\"western\">When the download finishes, you will see \u201cFailed to leave Flash mode\u201d<\/p>\n<p class=\"western\">Ignore this and close the downloader program.<\/p>\n<p class=\"western\">Remove the GPIO0 to ground connection.<\/p>\n<p class=\"western\">Reset the ESP8266: You will see two blue flashes again (the second flash is dimmer than the first).<\/p>\n<p class=\"western\">The firmware is running at 115200 now and should respond to AT commands.<\/p>\n<p class=\"western\">The most basic command to verify the firmware:<\/p>\n<p class=\"western\">Enter \u201cAT&lt;enter&gt;\u201d<\/p>\n<p class=\"western\">ESP8266 response: OK<\/p>\n<p class=\"western\">The complete AT command set can be found\u00a0<a title=\"ESP8266 AT Commands\" href=\"http:\/\/www.pighixxx.com\/test\/wp-content\/uploads\/2014\/12\/ESP8266Ref.pdf\" target=\"_blank\">here<\/a>.<\/p>\n<p class=\"western\">If you plan to use the ESP8266 as a slave to an Arduino or other MCU, you are ready to go.<\/p>\n<p class=\"western\">But if you are planning to use the ESP8266 as a stand-alone prototyping platform, read on&#8230;<\/p>\n<p><a name=\"step4\"><\/a><\/p>\n<h3><b>Step 4: Flashing NodeMcu<\/b><\/h3>\n<p class=\"western\">NodeMcu is open-source firmware for the ESP8266 which makes it easy to prototype \u201cthings\u201d. It is similar to the Arduino development environment.<\/p>\n<p class=\"western\">More information is available <a title=\"All abot NodeMcu\" href=\"http:\/\/nodemcu.com\/\" target=\"_blank\">here<\/a>.<\/p>\n<p class=\"western\">Let&#8217;s set up the ESP8266 for NodeMcu.<\/p>\n<p class=\"western\">First, pull the Flasher and firmware from <a title=\"NodeMcu Flasher\" href=\"https:\/\/github.com\/nodemcu\/nodemcu-flasher\" target=\"_blank\">GitHub<\/a>:<\/p>\n<p class=\"western\">Click on the \u201cDownload ZIP\u201d file to get the entire package.<\/p>\n<p class=\"western\">I used the 64-bit version for my windows 7 PC. It was in the repository at:<\/p>\n<p class=\"western\">nodemcu-flasher-master\\Win64\\Release\\ESP8266Flasher.exe<\/p>\n<p class=\"western\">Before starting this program, make sure the GPIO0 is connected to ground. Then start the flasher program which should start up with:<\/p>\n<p class=\"western\"><a href=\"http:\/\/internetofhomethings.com\/homethings\/wp-content\/uploads\/2015\/03\/ESP8266-Flasher-NodeMcu.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-302 size-full\" src=\"http:\/\/internetofhomethings.com\/homethings\/wp-content\/uploads\/2015\/03\/ESP8266-Flasher-NodeMcu.png\" alt=\"ESP8266 Flasher NodeMcu\" width=\"572\" height=\"333\" srcset=\"https:\/\/internetofhomethings.com\/homethings\/wp-content\/uploads\/2015\/03\/ESP8266-Flasher-NodeMcu.png 572w, https:\/\/internetofhomethings.com\/homethings\/wp-content\/uploads\/2015\/03\/ESP8266-Flasher-NodeMcu-300x175.png 300w\" sizes=\"auto, (max-width: 572px) 100vw, 572px\" \/><\/a><\/p>\n<p class=\"western\">The COM Port should be the same one you have been using to communicate with the ESP8266.<\/p>\n<p class=\"western\">Click on the \u201cFlash(F)\u201d button to flash NodeMcu on your device. This will take a few minutes. You will see the progress bar fill and the ESP8266 blue LED blink during the flashing. A green Check will be displayed when the flash is completed.<\/p>\n<p class=\"western\"><a href=\"http:\/\/internetofhomethings.com\/homethings\/wp-content\/uploads\/2015\/03\/ESP8266-Flasher-NodeMcu-after.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-303 size-full\" src=\"http:\/\/internetofhomethings.com\/homethings\/wp-content\/uploads\/2015\/03\/ESP8266-Flasher-NodeMcu-after.png\" alt=\"After Flashing ESP8266 with NodeMcu\" width=\"572\" height=\"333\" srcset=\"https:\/\/internetofhomethings.com\/homethings\/wp-content\/uploads\/2015\/03\/ESP8266-Flasher-NodeMcu-after.png 572w, https:\/\/internetofhomethings.com\/homethings\/wp-content\/uploads\/2015\/03\/ESP8266-Flasher-NodeMcu-after-300x175.png 300w\" sizes=\"auto, (max-width: 572px) 100vw, 572px\" \/><\/a><\/p>\n<p class=\"western\">Once the flash is complete, you can remove the GPIO0 to ground jumper. It will no longer be needed. All that you will need now to develop your own applications is an integrated development environment (IDE).<\/p>\n<p class=\"western\">ESPlorer appears to be the most widely used ESP8266 IDE. Get it now\u00a0<a title=\"ESPlorer\" href=\"http:\/\/esp8266.ru\/esplorer\/#download\" target=\"_blank\">here<\/a>.<\/p>\n<p class=\"western\">Simply run the batch file \u201cESPlorer.bat\u201d to start the IDE. A command window will be launched along with the IDE GUI. DO NOT close the command window!<\/p>\n<p class=\"western\"><a href=\"http:\/\/internetofhomethings.com\/homethings\/wp-content\/uploads\/2015\/03\/ESPlorer1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-304 size-full\" src=\"http:\/\/internetofhomethings.com\/homethings\/wp-content\/uploads\/2015\/03\/ESPlorer1.png\" alt=\"ESPlorer IDE\" width=\"800\" height=\"600\" srcset=\"https:\/\/internetofhomethings.com\/homethings\/wp-content\/uploads\/2015\/03\/ESPlorer1.png 800w, https:\/\/internetofhomethings.com\/homethings\/wp-content\/uploads\/2015\/03\/ESPlorer1-300x225.png 300w\" sizes=\"auto, (max-width: 800px) 100vw, 800px\" \/><\/a><\/p>\n<p class=\"western\">The ESP8266 starts up now with it&#8217;s serial port set to 9600 baud. In order to start the communication link, you will need to click on the \u201cOpen\u201d button (COM port set to the number corresponding to the ESP8266 to PC serial bus).<\/p>\n<p class=\"western\">If the port opens successfully, the IDE window will look like this:<\/p>\n<p class=\"western\"><a href=\"http:\/\/internetofhomethings.com\/homethings\/wp-content\/uploads\/2015\/03\/ESPlorer2.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-306 size-full\" src=\"http:\/\/internetofhomethings.com\/homethings\/wp-content\/uploads\/2015\/03\/ESPlorer2.png\" alt=\"ESPlorer2\" width=\"800\" height=\"600\" srcset=\"https:\/\/internetofhomethings.com\/homethings\/wp-content\/uploads\/2015\/03\/ESPlorer2.png 800w, https:\/\/internetofhomethings.com\/homethings\/wp-content\/uploads\/2015\/03\/ESPlorer2-300x225.png 300w\" sizes=\"auto, (max-width: 800px) 100vw, 800px\" \/><\/a><\/p>\n<p class=\"western\">Now click on the \u201cResetESP\u201d button. The ESP8266 should respond with the firmware version:<\/p>\n<p class=\"western\">node.restart()<\/p>\n<p class=\"western\">&gt; #\u00fc!##\u00a4\u201e\u00ff1\u00e4)M\u00f41\u00e4)}\u20201\u00a4\u00f1\u00a1H\u00f8<\/p>\n<p class=\"western\">NodeMCU 0.9.5 build 20150311 powered by Lua 5.1.4<\/p>\n<p class=\"western\">&gt;<\/p>\n<p class=\"western\">Congratulations! Your ESP8266 development environment is now set up.<\/p>\n<p><a name=\"step5\"><\/a><\/p>\n<h3><b>Step 5: Installing an application<\/b><\/h3>\n<p class=\"western\">It is time to write and flash our first program.<\/p>\n<p class=\"western\">Lets try writing a simple program to blink an LED on and off. It is structure here to appear similar to the familiar Arduino structure. The code is entered in the window with the \u201cScripts\u201d tab selected:<\/p>\n<p class=\"western\"><a href=\"http:\/\/internetofhomethings.com\/homethings\/wp-content\/uploads\/2015\/03\/ESPlorer3.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-307 size-full\" src=\"http:\/\/internetofhomethings.com\/homethings\/wp-content\/uploads\/2015\/03\/ESPlorer3.png\" alt=\"ESPlorer3\" width=\"1024\" height=\"631\" srcset=\"https:\/\/internetofhomethings.com\/homethings\/wp-content\/uploads\/2015\/03\/ESPlorer3.png 1024w, https:\/\/internetofhomethings.com\/homethings\/wp-content\/uploads\/2015\/03\/ESPlorer3-300x185.png 300w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/p>\n<p class=\"western\">Notice the file is assigned the name \u201cinit.lua\u201d. This is the default file that is run on the ESP8266 at start-up. This program simply toggles the LED state every 1 second. The GPIO2 is assigned an index 4, which is why this value is used in our script to control the connected\u00a0LED.\u00a0\u00a0Look <a title=\"NodeMcu API\" href=\"https:\/\/github.com\/nodemcu\/nodemcu-firmware\/wiki\/nodemcu_api_en#gpio-new-table--build-20141219-and-later\" target=\"_blank\">here<\/a>\u00a0for the remaining GPIO to index mapping. Simply click on the \u201cSave to ESP\u201d button to flash the code to the ESP8266. The LED should then change state every 1 second.<\/p>\n<p class=\"western\">Also note the &#8216;dofile(\u201cinit.lua\u201d)&#8217; in the right window. The IDE commands the ESP8266 to start this script after flashing with this command.<\/p>\n<p class=\"western\">NOTE: While it may change in the future, currently, the IDE does not provide a means to create new files to your PC. The file \u201cinit.lua\u201d must be created with an external text editor before it can be opened in the IDE.<\/p>\n<p class=\"western\">This is just the beginning&#8230; A starting point so you can begin exploring what is possible with this remarkable device. I have already made a simple server to control an LED from a web-page and return a JSON string. I&#8217;ll leave that as an exercise for you and perhaps provide the details in another post.<\/p>\n<p class=\"western\">The complete API and GPIO index mapping is maintained\u00a0<a title=\"NodeMcu API\" href=\"https:\/\/github.com\/nodemcu\/nodemcu-firmware\/wiki\/nodemcu_api_en\" target=\"_blank\">here<\/a>.<\/p>\n<p class=\"western\">And there are examples of different code snippets, including configuring the ESP8266 WIFI for internet\u00a0<a href=\"http:\/\/nodemcu.com\/index_en.html\" target=\"_blank\">here<\/a>.<\/p>\n<p class=\"western\">I&#8217;ll be back with more as I get more experience with this device.<\/p>\n<p class=\"western\">My next step is to port the code I have currently deployed to a <a title=\"Spark Core\" href=\"https:\/\/store.spark.io\/\" target=\"_blank\">Spark Core<\/a>\u00a0(running continuously for almost a year now) to the ESP8266-12 platform to compare performance.<\/p>\n<p class=\"western\">What will you do next?<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I was really excited when first discovering\u00a0the ESP8266. Imagine&#8230;a tiny footprint device capable of connecting to the internet with a WIFI connection. With the capability to control &#8216;things&#8217; and monitor &hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1,10,19],"tags":[11,13,12],"class_list":["post-286","post","type-post","status-publish","format-standard","hentry","category-alltheposts","category-esp8266","category-internet-of-things","tag-esp8266","tag-home-automation","tag-iot"],"_links":{"self":[{"href":"https:\/\/internetofhomethings.com\/homethings\/index.php?rest_route=\/wp\/v2\/posts\/286","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/internetofhomethings.com\/homethings\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/internetofhomethings.com\/homethings\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/internetofhomethings.com\/homethings\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/internetofhomethings.com\/homethings\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=286"}],"version-history":[{"count":22,"href":"https:\/\/internetofhomethings.com\/homethings\/index.php?rest_route=\/wp\/v2\/posts\/286\/revisions"}],"predecessor-version":[{"id":310,"href":"https:\/\/internetofhomethings.com\/homethings\/index.php?rest_route=\/wp\/v2\/posts\/286\/revisions\/310"}],"wp:attachment":[{"href":"https:\/\/internetofhomethings.com\/homethings\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=286"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/internetofhomethings.com\/homethings\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=286"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/internetofhomethings.com\/homethings\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=286"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}