Thanks to the guys those who ported the Esp8266 into Arduino IDE and helping all the arduino users happy to the core. Yes it's been long time since they did and this post is bit later to thanks the good hearted work by the guys out there.

Lets begin with Installing the Esp8266 support for the Arduino and see how to blink an LED ( the hello world in the electronics )

check out the video to know step by step tutorial on how to get started with our favourite chip Esp8266

Firstly open the Arduino IDE

Go to files and click on the preference in the Arduino IDE

copy the below code in the Additional boards Manager


click OK to close the preference Tab.

After completing the above steps , go to Tools and board, and then select board Manager

Navigate to esp8266 by esp8266 community and install the software for Arduino.

Once all the above process been completed we are read to program our esp8266 with Arduino IDE.

For this example I have used NodeMCU esp8266 and if you are using any other vendor wifi chips or generic wifi module please check with the esp8266 Pin mapping which is very essential to make things works.

The reason why I used D7 pin for this example is , I uploaded the basic blink program that comes with the examples program in the arduino IDE which is connected with 13 pin of arduino. The 13th pin is mapped into D7 pin of NodeMCU.

go to board and select the type of esp8266 you are using. and select the correct COM port to run the program on your esp8266 device.

<p>void setup() {<br>  // initialize digital pin 13 as an output.
  pinMode(13, OUTPUT);
}</p><p>// the loop function runs over and over again forever
void loop() {
  digitalWrite(13, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(1000);              // wait for a second
  digitalWrite(13, LOW);    // turn the LED off by making the voltage LOW
  delay(1000);              // wait for a second

upload the program and see the results.

if you like the above tutorial and if you want try out with cool projects you can also check this link here , that's the amazon book link where you can use that book to make IoT with Esp8266 or Nodemcu, that books gives you basic coverage on how to do simple things and get yourself started with arduino and goes on developing projects like sending data to webserver and creating a webserver, uploading and controlling data from a webpage, how to interface TFT LCD and I2C devices and many more things can find on the link.

Step 1: Control an LED From Web Browser

In this blog, we will see How to "Turn On and Turn Off" an LED that has connected to the Esp8266, the esp8266 has programmed from Arduino IDE to control the LED.

We will connect the Esp8266 to the Wi-Fi router using SSID and password of our Home network Wifi , where the esp8266 connect to our wifi and create a webserver, which can be accessed by looking through the serial Monitor of the Arduino window or you can also log into your Wifi router and check for the list of clients connected to your Wi-Fi router.

Here's a window which explains the step by step procedure to connect the Esp8266 to the Wi-fi server and How to access the Webpage and control the LED connected to the Esp8266

For the above video I have used NodeMcu, you can use any type of Esp8266 to make this thing work in your web browser.

look for the mapping of pins in with your Esp8266 vendor, if the program not working properly for you , the fault will be with the pin mapping functionalities, Here I used the D7 pin which mapped to 13th pin when program from the Arduino IDE.

Connect your Esp8266 to Arduino IDE and Select the correct COM Port and board type and 
upload the program. 
Note change the SSID to your WiFi Name and password to your Wifi password. if you forget to change it , esp8266 will not connect connect your wifi.



If everything completed you can turn to your serial monitor and check for the ip address that your devices has connected to . you will presented with an serial monitor that look exactly to the picture below.

if you like the above tutorial and if you want try out with cool projects you can also check this link here , that's the amazon book link where you can use that book to make IoT with Esp8266 or Nodemcu, that books gives you basic coverage on how to do simple things and get yourself started with arduino and goes on developing projects like sending data to webserver and creating a webserver, uploading and controlling data from a webpage, how to interface TFT LCD and I2C devices and many more things can find on the link.

Step 2: Control Electrical Devices From User Web Browser Using Esp8266 Nodemcu

Hi, in this tutorial we will see how to control electrical devices like fan, light, etc., to turn on and off using esp8266 from a web browser. if you are bored with a dedicated device controller like an app or an remote which will be available for only one particular device but using this method all the device which support web browsing will be act as a controller for us.

Make sure all the devices are connected to the same router, this example doesn't include a port forwarding function which will not allow us to control the device from outside the home network.

Components that you need for completing this project are very simple, you need to have an esp8266 wifi module and a relay, make sure you buying a 5v relay which very easy to use with esp chips doesn't require external supply too. we can make use of the Vin pin of the nodemcu or if you are using a generic chip, you need to supply an external 5v to the relay.

For this example project I have used only 2 relay circuit, but the actual program wrote for connecting four relay module.

You can check the above video on how this thing works and how to connect your browser to the ip address returned from esp and all the details are included in this video.

Copy the below arduino code and paste into your Arduino IDE and upload the program to your nodemcu or any other esp devices that you are using, make sure to choose the correct port and device name from the board. also don't forget to change the SSID and password to your Wi-fi settings.

This program for the esp8266 wrote to return the status of the device , which will in turn notify us with the device state in the browser which will also make the user to know which device has currently turned on or off.

Copy the above code and complete the process. Share and let others know about this tiny chip which can do dozens of magic.

if you like the above tutorial and if you want try out with cool projects you can also check this link here , that's the amazon book link where you can use that book to make IoT with Esp8266 or Nodemcu, that books gives you basic coverage on how to do simple things and get yourself started with arduino and goes on developing projects like sending data to webserver and creating a webserver, uploading and controlling data from a webpage, how to interface TFT LCD and I2C devices and many more things can find on the link.

Step 3: Upload DS18b20 Temperature Sensor Data to Thingspeak From Esp8266 (nodemcu)

Hello all in this tutorial you will know how to use Ds18b20 Temperature data to thingspeak.com, you can follow above fritzing circuit diagram to control the Ds18b20 temperature sensor, This sensor follows one wire protocol which means you can connect many sensors as you want to the single pin and access temperature data calling the sensor by address.

check the video below on how to work with this sensor and also proof of code working .

There is no much work to get work with this sensor, as there are plenty of example library that already available in the internet which anyone can make use and get started to work with this sensor.

Test the below code to know check whether you can get reading from the temperature sensor with ESP8266 or Nodemcu

if you get any error , make sure you have downloaded library for Ds18b20 Temperature sensor.

<iframe style="height: 510px; width: 100%; margin: 10px 0 10px;" allowtransparency="true" src="https://codebender.cc/embed/sketch:243987" frameborder="0"></iframe><br>

copy paste above code to your Arduino IDE and upload to your ESP8266 or Nodemcu if you are not sure about how to do this please check the video about to know how things work, if you don't know yet to search search on this blog for getting started with Esp8266 in Arduino IDE.

below you can see the code for sending temperature data to thingspeak.com from Esp8266 or Nodemcu to do this you need have thingspeak api key which can get easily by registering to the website.

change SSID and password to your router password and also update the Nodemcu api key.


<iframe style="height: 510px; width: 100%; margin: 10px 0 10px;" allowtransparency="true" src="https://codebender.cc/embed/sketch:243988" frameborder="0"></iframe>


if you like the above tutorial and if you want try out with cool projects you can also check this link here , that's the amazon book link where you can use that book to make IoT with Esp8266 or Nodemcu, that books gives you basic coverage on how to do simple things and get yourself started with arduino and goes on developing projects like sending data to webserver and creating a webserver, uploading and controlling data from a webpage, how to interface TFT LCD and I2C devices and many more things can find on the link.

Hey ! I'm new and I would like to know if it's possible to turn my nodemcu esp8266-12e as an acces point to internet ? Or juste to grap internet with it. My computer didn't have a wifi chip, i need an ethernet cable and I want to use the wifi chip of my nodemcu to get acces to internet with the wifi of my router on my computer. Possible ?
<p>Hi Magesh,</p><p>For of all, thank you very much for this tutorial, it works for me. I just need to add /dev/cu.SLAB_USBtoUART interface on my Mac.</p><p>I tried with a NodeMcu V1.0. Even with the simple &quot;blink&quot; sketch you provides (no wifi), there are a lot of watch doc timer, stacks dump and so on... Led blinks 2 or 3 times, then it stop to blink, then it restart, until it completely freezes...</p><p>Here are dump from console :</p><p> tail 8</p><p>chksum 0x2d</p><p>csum 0x2d</p><p>v09f0c112</p><p>~ld</p><p>������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������</p><p>Exception (0):</p><p>epc1=0x4021de30 epc2=0x00000000 epc3=0x00000000 excvaddr=0x00000000 depc=0x00000000</p><p>ctx: sys </p><p>sp: 3ffff920 end: 3fffffb0 offset: 01a0</p><p>&gt;&gt;&gt;stack&gt;&gt;&gt;</p><p>3ffffac0: 3ffe8cc2 40205e1e 00000000 4020c7f8 </p><p>3ffffad0: 4020632c 3ffe8ca0 00000012 3ffe8cc2 </p><p>3ffffae0: 3fffff10 4010143c 00000003 40206316 </p><p>3ffffaf0: 4010171c 000003fd 00000012 60000200 </p><p>3ffffb00: 3fffff10 02a1c6cd b40f0899 30c38390 </p><p>3ffffb10: ffffffff ffffffff ffff0003 00000000 </p><p>3ffffb20: feefef00 feefeffe feefeffe feefeffe</p><p>Do you have a clue on something I can investigate to solves this ?</p><p>Best regards,</p><p>Gr&eacute;goire.</p>
<p>idem, tu as une solution?</p>
<p>Good I have problems with the installation of the url in preferences I do but when going to tools presents an error and I can not install the card to ide I have not been able to use my wiffi module to do?</p>
<p>I had to search through about ten usb cables before I found one that would detect the device and add it to the ports section in windows device manager - just as I was getting ready to send all my modules back to the seller with a tirade....</p>
<p>What cable ended up working? I'm using this USB cable <a href="https://www.amazon.com/gp/product/B017D91A0Y/ref=oh_aui_detailpage_o00_s00?ie=UTF8&psc=1">https://www.amazon.com/gp/product/B017D91A0Y/ref=o...</a> They come in a 3 pack and I've tried 2 of them with neither adding the NodeMcu to the port. I bought my NodeMCU here <a href="https://www.amazon.com/gp/product/B010O1G1ES/ref=oh_aui_detailpage_o06_s00?ie=UTF8&psc=1">https://www.amazon.com/gp/product/B010O1G1ES/ref=o...</a>. Thanks.</p>
<p>I have done this by config the internal MCU Led..</p>
<p>Works absolutely perfectly! For my project, it was a quick tweak to specify what I wanted, and that was it! Thank you. Very good tutorial as well!</p>
Hey, Why this NodeMCu is so unstable? I used your code to blink an LED from browser, after several operations even the page(html code on NodeMcu) won't load, Do we need to disconnect client after every connection? Or What to do? So that Page will load evrytime whenever we type it's IP on browser. Please help me.
<p>I think I had the same issue. It ended up being with the 'Wait until the client sends some data' loop. I added a timeout so if data isn't received in a few seconds it can break out of the loop.</p>
<p>sorry em new to electronics , can u please explain what a time out is ? is like like a delay ? thank you in advance.</p>
<p>such a life saver thank you so much </p>
<p>Thanks! It's so frustrating trying to use Putty to get the thing to do anything! I bought a pretty cheap Amica one from Ebay ($4), and have been fiddling for a few hours trying to get the firmware right.</p><p>Anyway, after that, following your quick tutorial, and changing the &quot;pinMode(16, OUTPUT);&quot; and for the other references to 13, it flashes the onboard blue LED just fine. Now to tinker some more :)h</p>
<p>Very good tutorial! Really helpful!</p>
<p>Very good tutorial!</p>
धन्यवाद सर
Are you thw author of the linked book?
<p>Hello, thank you for this tutorial. But I'm in trouble with the pinout. Could you provide it ? I found some images over the internet but it seems they are wrong.</p><p>Thanks in advance!</p>
<p>(in case you're still looking for it or anyone else is wondering:)</p><p>it depends on which version of the nodemcu you got.</p><p>this pin mapping works for me: <a href="https://www.roboburada.com/public/assets/ESP8266/pinmap.png" rel="nofollow">https://www.roboburada.com/public/assets/ESP8266/p...</a></p><p>compare the number of &quot;reserved&quot; (RSV) pins with your board</p>
In the arduino ide board manager, which board do I select for the esp8266nonemcu? there are other 8266's listed but not the nodemcu.<br>thanks<br>D6
<p>worked great. thank you. i am now triggering a buzzer in the other room to piss off my girlfriend when she leased expects it ;)</p>
<p>Board nodemcuv2 (platform esp8266, package esp8266) is unknown </p><p>Error compiling</p><p>What am i supposed to do?</p>
<p>nice project ,worked in first attempt,can you explain how can this page be displayed in a network other than local</p>
<p>Great start to NodeMCU!</p><p>This code misses a trick - if you want this to work without serial or indeed a connected computer and you wish to see if the Nodemcu has connected to Wifi, set the pinout to high first by changing the pin out line to HIGH and not LOW: digitalWrite(ledPin, HIGH); , which will light the LED. Set the LED low after it has connected to Wifi with the following:</p><p> Serial.println(&quot;WiFi connected&quot;); &lt;- After this line</p><p> digitalWrite(ledPin, LOW); &lt;- Add this</p><p>So now the LED lights until the Nodemcu connects to Wifi, then goes out and you can then connect to it through the browser.</p>
<p>Thank you for this tutorial..!!!.. I was stumped in a couple areas until I found this page.... great help!!</p>
<p>can you please provide a code for iot based energy meter reading </p>
<p>Awesome tutorial, got me up and running with this microcontroller very quickly.</p><p>Thanks!</p>
<p>Thanks! Works fine. I have included two more leds (green and red) for connection status.</p>
<p>When i enter the URL, Arduino gives me this error,</p><p><a href="http://arduino.esp8266.com/stable/package_esp8266com_index.json" rel="nofollow">http://arduino.esp8266.com/stable/package_esp8266c...</a> file signature verification failed. File ignored.</p>
<p>Great !, Thanks for easy step.</p>
<p>Hi<br>I'm trying to make a web server using nodeMCU as a master and 2 Arduinos as my clients,I connected BH1750 and Ds18b20 to my Arduinos and I made a wireless connection between clients and master(nodeMCU).My nodeMCU is working by cp2102 not ch340g.I can coonect to my WIFI and I can load the webpage But there is a problem which I faced so many times and which is &quot;nodeMCU disconnects when I wanna get data from my clients and it won't load the web page and even it get disconnected from WIFI&quot;.so That's why I come to your web site and checked your tutorial,but when I upload your code on my nodeMCU it didn't connect to wifi.<br>I attached the Image of web server that I made <br>I desperately need your help.</p>
<p>my serial monitor always returns something like this:</p><p>&Ocirc;&yuml;H! )</p><p>please, how can i solve this problem?</p>
<p>Check your baudrate. It should be 115200 not 96000</p>
<p>Hi,</p><p>bravo for this fine Job. Please where is the code for the last part Ds18b20 to Thingspeak.</p><p>Cheers</p><p>Pierrick</p>
<p>I found it at here:</p><p>https://codebender.cc/embed/sketch:243988#Untitled_Project%20copy.ino</p>
<p>#include &lt;ESP8266WiFi.h&gt;</p><p>#include &lt;OneWire.h&gt;</p><p>#include &lt;DallasTemperature.h&gt;</p><p>#define myPeriodic 15 //in sec | Thingspeak pub is 15sec</p><p>#define ONE_WIRE_BUS 2 // DS18B20 on arduino pin2 corresponds to D4 on physical board</p><p>OneWire oneWire(ONE_WIRE_BUS);</p><p>DallasTemperature DS18B20(&amp;oneWire);</p><p>float prevTemp = 0;</p><p>const char* server = &quot;api.thingspeak.com&quot;;</p><p>String apiKey =&quot;Things speak api key&quot;;</p><p>const char* MY_SSID = &quot;your router name &quot;; </p><p>const char* MY_PWD = &quot;your wifi password&quot;;</p><p>int sent = 0;</p><p>void setup() {</p><p> Serial.begin(115200);</p><p> connectWifi();</p><p>}</p><p>void loop() {</p><p> float temp;</p><p> //char buffer[10];</p><p> DS18B20.requestTemperatures(); </p><p> temp = DS18B20.getTempCByIndex(0);</p><p> //String tempC = dtostrf(temp, 4, 1, buffer);//handled in sendTemp()</p><p> Serial.print(String(sent)+&quot; Temperature: &quot;);</p><p> Serial.println(temp);</p><p> //if (temp != prevTemp)</p><p> //{</p><p> //sendTeperatureTS(temp);</p><p> //prevTemp = temp;</p><p> //}</p><p> sendTeperatureTS(temp);</p><p> int count = myPeriodic;</p><p> while(count--)</p><p> delay(1000);</p><p>}</p><p>void connectWifi()</p><p>{</p><p> Serial.print(&quot;Connecting to &quot;+*MY_SSID);</p><p> WiFi.begin(MY_SSID, MY_PWD);</p><p> while (WiFi.status() != WL_CONNECTED) {</p><p> delay(1000);</p><p> Serial.print(&quot;.&quot;);</p><p> }</p><p> Serial.println(&quot;&quot;);</p><p> Serial.println(&quot;Connected&quot;);</p><p> Serial.println(&quot;&quot;); </p><p>}//end connect</p><p>void sendTeperatureTS(float temp)</p><p>{ </p><p> WiFiClient client;</p><p> if (client.connect(server, 80)) { // use ip or api.thingspeak.com</p><p> Serial.println(&quot;WiFi Client connected &quot;);</p><p> String postStr = apiKey;</p><p> postStr += &quot;&amp;field1=&quot;;</p><p> postStr += String(temp);</p><p> postStr += &quot;\r\n\r\n&quot;;</p><p> client.print(&quot;POST /update HTTP/1.1\n&quot;);</p><p> client.print(&quot;Host: api.thingspeak.com\n&quot;);</p><p> client.print(&quot;Connection: close\n&quot;);</p><p> client.print(&quot;X-THINGSPEAKAPIKEY: &quot; + apiKey + &quot;\n&quot;);</p><p> client.print(&quot;Content-Type: application/x-www-form-urlencoded\n&quot;);</p><p> client.print(&quot;Content-Length: &quot;);</p><p> client.print(postStr.length());</p><p> client.print(&quot;\n\n&quot;);</p><p> client.print(postStr);</p><p> delay(1000);</p><p> }//end if</p><p> sent++;</p><p> client.stop();</p><p>}//end send</p>
<p>Hi, your code has an extra &quot; character inside the &lt;a&gt; tags. It should be:</p><p><br>client.println(&quot;&lt;a href=\&quot;/LED=ON\&quot;&gt;&lt;button&gt;Turn On &lt;/button&gt;&lt;/a&gt;&quot;);</p><p> client.println(&quot;&lt;a href=\&quot;/LED=OFF\&quot;&gt;&lt;button&gt;Turn Off &lt;/button&gt;&lt;/a&gt;&lt;br /&gt;&quot;);</p>
<p>Very good tutorial but I couldn't get the ESP8266 Led control program to load into Arduino IDE. &quot;could not load sketch&quot;... Any ideas why this may be happening ? I have tried other sketches (led blink etc.) in the nodemcu v3 device and they work okay. </p>
<p>Thanks, really easy how-to.</p>
<p>Fantastic! thank you for explaining so well the process to connect and use the ESP8266.</p>
<p>How to establish communication between Nodemcu and d Raspberry pi over WiFi?? I am hosting nodemcu as Client and Pi as server. I am unable to fetch data to raspberry pi. Is it possible to communicate directly between these two??Or do we need a broker in between like webpage or App?? </p><p>I am troubled in sending &quot;hello World&quot; message to raspberry pi over WiFi. I can get the message to one particular IP address, but facing issues to connect to Raspberry Pi.</p><p>NodeMCU and Raspberry pi are connected to same network.</p><p>Please help.</p>
<p>Is there a way to install the environment other than through the arduino board manager? My board manager crashes and wont allow me to load from the json file. It is a fresh install of arduino but it doesn't work on my Windows 10 installation.</p>
<p>I could resolve warning: espcomm_sync failed error. However, I am not able to triger relay. It seems that relay get small amount of voltage from Nodemcu board (wimos). The red LED is very dimly lit. Could you please help resolving this.</p><p>PS. in my other project LED on Relay is brighly lit.</p>
<p>I am not from electronics field. I am an accountant in Mumbai. However, with some efforts I could complete two projects with ultrasonice range finder and Relay.</p><p>To further explore knowledge on this, I bought your book on amazon.in which includes above mentioned project. I want to do this project for controlling AC devices like Bulb and Fan from my mobile phone</p><p>However, I am stuck with error at initial stage. Below mentioned is the error.</p><p>warning: espcomm_sync failed<br>error: espcomm_open failed<br>error: espcomm_upload_mem failed</p><p>I will be grateful, if you could help me resolving these errors.</p>
<p>Thanks, easiest how-to (for nodemcu /ardunio ide) on the web - I think I'll splash out on your book! :D</p>
<p>Very nice write-up for a Quick Start! Helped me confirm my hardware and software environment are set up correctly for first experience with a NodeMCU/ESP8266. </p><p>One suggestion I'd like to make: Since the ESP8266 saves the SSID and password to non-volatile storage, I define them in preprocessor directives rather than variables. I then use a #ifdef/#else/#endif block to call WiFi.begin(MYSSID,MYPASSWORD) if MYSSID is defined or WiFi.begin() if it isn't. Once I've successfully connected the board to my WiFi I delete the preprocessor directives from my code. This greatly reduces the possibility that I'll accidentally store my WiFi credentials in plaintext on GitHub, Codebender or any other code-sharing site.</p>
<p>Got my little nodemcu v3 in the mail a couple of days ago and this &quot;how to&quot; has got me really enthused . Thankyou . </p><p>Your code specifies port 80 but can I manually set an IP address within the code or do I have to set that up in my router fixed to the Esp8266 mac address ?</p>
<p>good stuff, just ordered 2 of these boards. for the money, size and capability i believe that this is the best board on the market. it can handle 99% of a regular consumers needs. its just amazing what they have accomplished with the esp8266 community and implementing arduino ide. thank you for this detailed write up, i will be coming back.!!</p>
Excellent tut. Thank you for taking the time to write this up. It is most helpful ?

About This Instructable




Bio: I make hobbyist stuffs and play with electronics follow me to know more https://www.facebook.com/arduinolabviewsolidworks https://twitter.com/learnrobotix
More by Magesh Jayakumar:Quick Start to Nodemcu (ESP8266) on Arduino IDE Course on MIT App Inventor and Arduino Hat for the Party 
Add instructable to: