Pages Menu
Categories Menu

Posted by on May 6, 2016 in Expressif ESP8266, Featured, Getting Started, IoT, Microcontrollers | 19 comments

Getting Started with ESP8266 WiFi Module

Getting Started with ESP8266 WiFi Module

This is an introductory post on getting started with ESP8266 WiFi Module/Microcontroller used in IoT applications. The purpose of this post is to get you up and running with this device using the Sparkfun Thing board and Arduino IDE. Once set up, in the next post we will learn how to connect it to the internet and stream sensor data to the cloud.


The ESP8266 WiFi Module + Microcontroller

Yes, you read it right – a low power 32-bit microcontroller with an embedded WiFi module on the same chip. That’s amazing! This tiny device can now connect almost any device to the internet. You know what’s more amazing? It costs just $2! Want even more? It is Arduino compatible! This is like a maker’s heaven. Read the datasheet to know how powerful it is!

ESP8266 Module

ESP8266 Module

Just imagine the possibilities. You can now send sensor data directly from your device to the cloud without sending it through a local host. Take the following two scenarios for instance.

Scenario 1: You have a local host (say a Raspberry Pi) connected to the internet. That’s it – no other device has internet connection. Say if your fridge wants to talk to the internet, then it needs to connect to your local host first, which then sends that data to the internet. What a pain!

Scenario 1 - Centralized Communication System

Scenario 1 – Centralized Communication System

Scenario 2: Everything remains the same as in scenario 1, except that we use the ESP8266 to connect the fridge to the internet. Now your fridge can directly talk to the internet without the need for a local host. Amazing!

Scenario 2 - Distributed Communication System

Scenario 2 – Distributed Communication System

ESP8266 – Usage Modes

The ESP8266 can be used in two ways:

ESP8266 as a WiFi Module

Here all the ESP8266 does is to provide internet connectivity to an already existing platform. Say you could connect an Arduino (or any other microcontroller/processor) to the internet using ESP8266 as a WiFi Module. So basically here it acts as a serial to WiFi converter.

ESP8266 as WiFi Module

ESP8266 as WiFi Module

ESP8266 as a Standalone Microcontroller + WiFi

Or you could get rid of the Arduino completely and replace it with the ESP8266 module and run your application code on it. Now this does has limitations – the ESP8266 doesn’t has as many peripherals as the Arduino, so it can only be used for smaller applications. But it works perfectly fine when all it needs to do is to send data from a bunch of sensors to the internet. You can also run a web server on the ESP8266 that can listen to incoming connections and serve web pages.

ESP8266 as Standalone Module

ESP8266 as Standalone Module

We will be using ESP8266 in standalone mode for this post. Once you get an idea of how to program it, you can use it the way you like, doesn’t really matter.

The Sparkfun ESP8266 Thing

But first you need the module! You can either get the cheap $2 module directly, or get a development board offering more functionality like NodeMCU, Adafruit HUZZAH, or Sparkfun Thing. We will be using SparFun ESP8266 Thing board for this post, but you should be able to get any generic ESP8266 module to work with little changes.

Sparkfun ESP8266 Thing

Sparkfun ESP8266 Thing

ESP8266 + Arduino = <3

Something that makes the ESP8266 even better is its compatibility with Arduino IDE. Which means you don’t really have to get to the nitty gritties of the ESP8266 hardware. As long as you’re little bit familiar with Arduino programming, you should be good with programming it.

There are other ways to program it as well – like using a virtual machine by Expressif, or fine-tuning Eclipse, or even the good old school method of using a text editor + gcc. To keep things simple and to encourage the maker community, we will be using Arduino IDE in this post.


Setting up Arduino for use with ESP8266

Let’s set it up.

Step 1: Download and Install Arduino Software

If you haven’t done so already, go ahead and download Arduino IDE from Install it as per the instructions for your OS. This should be straightforward.

Step 2: Install the ESP8266 Arduino Addon

In the latest version of Arduino (v1.6.8 today), this can be easily done using the boards manager. First we need to tell Arduino to fetch board info. We do this by updating the board manager with a custom URL. Open up Arduino and then head over to Preferences (File > Preferences or Arduino > Preferences, depends on your OS). At the bottom, add this as the Additional Boards Manager URLs:
ESP8266 Arduino Addon Custom URL

ESP8266 Arduino Addon Custom URL

If there are multiple URLs, you can separate them with comma (,) or use the expanded text box to add one URL per line. Click OK.

Step 3: Install Board Support Packages for ESP8266 based Boards

Now go to the Tools > Board > Boards Manager. Scroll to the end and you’ll find a new entry for ESP8266. Choose the latest version and install. It could take a while for Arduino to download all the new definitions, compilers and binaries.

Arduino Boards Manager

Arduino Boards Manager

Now choose the board by selecting Tools > Board > SparkFun ESP8266 Thing.

Hello World – LED Blinky

In order to quickly check if everything is set up fine, lets run the classic Hello World program – the LED blinky.

#define LED_PIN 5  // LED is pin 5 on Thing board

void setup() 
  // setup() runs just once before everything else
  pinMode(LED_PIN, OUTPUT);

void loop() 
  // code in loop() keeps iterating forever

  digitalWrite(LED_PIN, HIGH);  // turn LED on
  delay(500);                   // wait 500 ms
  digitalWrite(LED_PIN, LOW);   // turn LED off
  delay(500);                   // wait 500 ms

Connect your board and choose the appropriate serial port via Tools > Port. You can also change Tools > Upload Speed from 115200 bps to 921600 bps for faster uploads. Click Upload.

If all goes well, you should see the blue LED blinking every 500 ms. If it doesn’t upload, then try again, maybe unplug/replug the cables or turn the board on/off.

Alternate Board Setup as a Generic Module

Alternatively you could also try configuring a generic ESP8266 module:

Tools > Board > Generic ESP8266 Module
Tools > Flash Mode > DIO
Tools > Flash Frequency > 80 MHz
Tools > Upload Using > Serial
Tools > CPU Frequency > 80 MHz
Tools > Flash Size > 512K (no SPIFFS)
Tools > Debug Port > Disabled
Tools > Debug Level > None
Tools > Reset Method > nodemcu

And then try uploading again.


  • The ESP8266 is the device IoT enthusiasts have been looking for – microcontroller and WiFi connectivity on the same chip.
  • ESP8266 can be used as a WiFi module providing internet connectivity to your project, or can be used as a standalone device and be the center of your project.
  • ESP8266 support has been added to Arduino, thus allowing makers and creators to prototype their ideas much faster.
  • Programming ESP8266 is as simple as programming any other Arduino board.

In the next post, we will describe the Hello World of IoT – streaming data to the cloud. We will be building a weather station where we will stream temperature data to the cloud every minute using ESP8266. Let’s move beyond blinking lights!

Questions? Comments? Feedback? Write below! I will be glad to get a response from my awesome readers! Also subscribe to stay updated.

Written by Mayank Prasad (aka Max)


  1. Very good explanation Sir. I have interfaced 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 communicate web part and Arduino. I tried HTML with GET method . But not working .Can you please help.

    Thank you in advance.

    • Keshav, I’ll tell you a story. The lion summons all the animals in the jungle for a meeting. All animals show up except one. Do you know which one?
      Bottom line is, how the hell am I supposed to answer your question when you give me no background information at all about your application? How do I know which cloud platform you’re using? How are you programming your code? Are you running the web server on your ESP? Did you even write the correct APIs for HTTP requests? How did you write the webpage? Are you making the right API calls? “When i type text on webpage and click on submit button ,text should appear on LCD.” You’re talking as if all this happens magically. There are million ways to achieve this, not sure how you’re doing it. Either provide full information, or ask your question wherever you’re following the tutorial from. Thank you.

      • That was a little harsh a reply! The poster (Keshav) was quite polite in asking a question.

    • Dear keshav kindly in coding part for interfacing surfing with ES8266……

  2. Hello Max, where can we find the next post about the ESP

    • Working on it. :) I have the application ready, but writing is such a pain. :)

      • Hi Max/Mayank, thanks for sharing this inormation, its really well explained.
        I wonder if you could also share next part of your tutorial, I have some experience with arduino, but I am going to start with the ESP and I would be very interested in check how you connected it to the cloud. I want to make a data logger connectiong the ESP to an arduino or similar.

  3. A big thank you from the bottom of my heart for all your efforts of helping everyone to learn with such good study materials.

    Binu Joy
    Assistant Professor
    Electronics & Telecommunication

  4. This Post was Awesome.
    But is there a post that talks in detail about using the ESP8266 with Arduino So that An Arduino can talk to the Internet

    Thanks In advance.

  5. hi..I want to use esp8266 with ST microcontroller .I want to use UART.Simply I want to use it as serial to wifi module.I send some data from App(iphone app is developed for our particular device)i want to check if the data is received by esp..How can i check this?
    Currently i have used HLK wifi module in my project and whenever i send string from App ,I check the web page (developed by HLK )i can seen Rx bytes recived ..But esp doesnt have such web access.

  6. Mayank, i urgently need your help. Is there any way i can contact you? an email id or something? I urgently need your next post on IOT implementation using esp8266.

  7. Hello Max..

    Good to see ur post on ESP8266 as well.

    Currently, I am using ESP-01.
    I want to use ESP-01 as a file server so that I will be able to upload a file from the web page which will transfer the file to SD card on the board via wifi. (the board may have any micro-controller). I should also be able to download file of SD card that is visible on the webpage via wifi.

    Is it possible to do this ?

    I did not find such application being posted anywhere .

    Pradeep Ch.

  8. will this esp8266 wifi module compatible for cloud.?

  9. how can i connect this module to atmega 32 ?

  10. Hey Max, thanks for the info. Loved the post. I need a little help with something. In this post you have interfaced arduino with esp8266. Actually i am working on project and i am not allowed to use arduino in my college so instead i have to use Atmega controller and program it with C. So basically i am using atmega328p which is also used in arduino. Can you please guide on what all things i need to look out for if am not using an arduino board and the other way around… Like i ll have an ultrasonic sensor sending the data to microcontroller repeatedly and my controller would send it to esp and esp would send the data to the website which i will design through server.
    And also let me know whether the controller already present in the esp8266 is better or an external controller like atmega328p in my case… pleasee.. Hope to get ur reply as soon as possible. thanks..

  11. How can I connect ESP8266 with atmega8 ?
    help me plzz

  12. thank you for your sharing

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: