Everything about Internet of Things and more

ESP8266 Arduino tutorial – WiFi module complete review

Gearbest  promotion

Technology goes ahead exponentially with each year whether we do something or not. With the same speed engineers work hard to reduce the size of every electronic device or component and loose most of the wiring. If you look back 20 years ago a device was called portable if you could rise it in your arms and carry up. Today nothing is portable if it can’t fit in your pocket. Nowadays devices, either they are made for regular or industrial use, are based on wireless communication technology and the main reason is not to get rid of wires, but to be able to interconnect between them. Meanwhile buying a wireless device became natural for everyone and price for WiFi Ready equipment lowered with time passing. While you read this, a WiFi microchip has no more than 5mm length and can be powered with as low as 10 micro Amps during sleep period. In this article we are going to test one of the cheapest and easy to use WiFi development platform, the ESP8266 arduino compatible device.

Cheap WiFi solution for your first IoT project – ESP8266 Arduino compatible wifi module with 1Mb flash upgrade

ESP8266 Arduino compatible module iot internet of things

ESP8266 Wifi Module design

The ESP8266 arduino compatible module is a low-cost Wi-Fi chip with full TCP/IP capability, and the amazing thing is that this little board has a MCU (Micro Controller Unit) integrated which gives the possibility to control I/O digital pins via simple and almost pseudo-code like programming language. This device is produced by Shanghai-based Chinese manufacturer, Espressif Systems.

This chip was first time seen in August 2014, in ESP-01 version module, made by AI-Thinker, a third-party manufacturer. This little module allows the MCU to connect to WiFi network and create simple TCP/IP connections. His His very low price (1.7$ – 3.5$) and the incredible small size attracted many geeks and hackers to explore it and use it in a large variety of projects. Being a true success, Espressif produces now many versions having different dimensions and technical specifications. One of the successors is ESP32. You can find over the internet hundreds of projects and various implementations like home automation, data logging solutions, robotics, controlling things over the internet, even drones or copters.

ESP8266-01Technical specifications

** CPU and flash clock speeds can be raised via overclocking on some devices and the 16 I/O are not available in all versions.

ESP8266 Arduino module comes with PCB trace antenna which seems to have a very good coverage (I saw a demonstration with more than 1km range!!!). Other version can have on-board ceramic antenna or an external connector which allows you to attach external WiFi antennas modules. ESP-01 has only 6 active pins, although the MCU can support up to 16 I/O. Board dimensions are 14.3 x 24.8 mm.

ESP8266 ESP-01 Arduino Module 1mb vs 0.5mbOver the internet i found that ESP8266 arduino module, version 01, is sold in two or more versions, which at first glance seem quite the same. After buying both of them i saw that there is a difference in size of the flash memory. You may encounter issues while flashing if you don’t make the proper settings according to board specifications.

Although the board default has 2 available GPIOs, you can do some workarounds and use other MCU available pins if you have the proper soldering tools. I managed to use GPIO 16 in order to wake up the device after DEEP SLEEP mode (explained later in SLEEP MODES).

Module pin description (pinout)ESP8266-01 PIN description pinout

Pins are arranged in two rows, having 4 on each row. Some models have pin description on the PCB, which make it simple. On the top row you can find following pins from the left to the right:

  1. GND (Ground from power supply)
  2. GPIO2 (Digital I/O programmable)
  3. GPIO0 (Digital I/O programmable, also used for BOOT modes)
  4. RX – UART Receiving channel

On the bottom (second row) you can find:

  1. TX – UART Transmitting channel
  2. CH_PD (enable/power down, must be pulled to 3.3v directly or via resistor)
  3. REST  – reset, must be pulled to 3.3v)
  4. VCC  -3.3v power supply

Power supply and current consumption

All esp8266 arduino compatible modules must be powered with DC current from any kind of source that can deliver stable 3.3V and at least 250mA. Also logic signal is rated at 3.3v and the RX channel should be protected by a 3.3v divisor step-down. You should be careful when using this module with Arduino or other boards which supplies 5v, because this module usually do not come with overpower protection and can be easily destroyed.

Here is the declared power consumption from Espressif:

Tx802.11b, CCK 11Mbps, P OUT=+17dBm 170 mA
Tx 802.11g, OFDM 54Mbps, P OUT =+15dBm 140 mA
Tx 802.11n, MCS7, P OUT =+13dBm 120 mA
Rx 802.11b, 1024 bytes packet length , -80dBm 50 mA
Rx 802.11g, 1024 bytes packet length, -70dBm 56 mA
Rx 802.11n, 1024 bytes packet length, -65dBm 56 mA
Modem-Sleep 15 mA
Light-Sleep 0.9 mA
Deep-Sleep 10 uA
Power Off 0.5 uA

If you are going to use ESP-01 in a project that is powered by batteries or by solar power it is mandatory to know everything about ESP8266 arduino Sleep modes. Current version offers 3 different sleep modes which can be triggered programmatically. ESP8266WiFi library offers specific functions to call sleep modes which can take settings parameters that change the callback jobs after wake-up like waking up with RF module powered off or on. The most important mode is DEEP_SLEEP because of the very low power consumption rates during sleep. Deep sleep mode is very common in projects that do data-logging at specific intervals and idle between measurements. In order to take advantage of this mode when using esp8266 arduino compatible module, ESP-01 standard, you need to make a little workaround and connect REST pin with the GPIO16 pin (which is not available in default 6 six pins).
Here is an example how to do it
ESP8266 Wifi module GPIO16 deep sleep
ESP8266 Wifi module GPIO16 deep sleep
After doing this connection you can use the following command to trigger the deep sleep mode:

ESP.deepSleep(sleepTimeInSeconds * 1000000);

Another thing that you need to know about the esp8266 arduino 01 version is that usually comes with two LEDs, a red one for power, and a blue one for data transmitting. The red LED is always on when the module is powered on and the blue led blinks during serial activities. For newer versions the producers eliminated the RED pin because of the continuous power consumption, so if you are going to buy one, try to find a version which has only the serial blue LED especially if you are going to use a battery power supply in your project. The differences can be seen in the following pictures:

ESP8266 Wifi module power led indicator

While in the left picture you can see two smd LEDs near the antenna, one for power indicator and one for data indicator, the right module has a single LED just to indicate the data transmission. PCB design can differ from one to another because producers tend to reduce the costs by cutting down the materials.

Talking with ESP-01 (AT / LUA / Arduino)

ESP8266-01 gives you many methods to communicate with it trough the RX/TX pins or over the air (OTA). The differences are not only in hardware but can be also in what kind of firmware is flashed out of the box. No matter what firmware comes default installed, you should be able to flash your preferred firmware by following the firmware flashing instruction from the datasheet. This module can be programmed using LUA code, Arduino code or directly trough AT commands and this gives us more freedom when embedding this device in our projects. Also there are few python firmware modes but i haven’t had the chance to test them. I personally choose to work with Arduino because of the past experience and tones of libraries available.

As it comes, out of the box, this module is ready to talk via AT commands without any other extra settings or configurations. There are many software applications which you can use to communicate via AT and have tones of ready made tools and functions which will make everything easier. I used ESPlorer and i totally recommend it, you can find it here. After booting, to be able to use AT commands, module should display “ready” on the serial monitor.

Few basic AT commands examples:

See here a complete list with AT instruction set.

In order to be able to talk with the ESP8266 arduino compatible module, you need to choose a way to connect it with your computer. You can communicate with the module via standard Serial communication RS232 by using an Arduino board as a proxy/bridge , by default Arduino having a USB to Serial converter integrated. If you are a beginner in development boards I totally recommend you one of the best Arduino books by Jeremy Blum, the best combination of a formaly trained electronics engineer and a Maker/Hacker. Arduino Uno differs from all preceding boards in that it does not use the FTDI USB-to-serial driver chip. Instead, it features the Atmega16U2 (Atmega8U2 up to version R2) programmed as a USB-to-serial converter. In order to use Arduino as a bridge, first you need to load an empty program on it. After doing that, you need to make the following connections in order to work:

ESP8266 Arduino UNO wire connections

3.3v VCC
RST 3.3v / float
CH_PD 3.3v

After that you should be able to see data and send AT commands in Serial Monitor by selecting Arduino’s COM port, setting a proper baudrate, default should be 115200, and make the additional settings to read “Both NL & CR“.

Firmware Over The Air (FOTA) solution in every embedded DIY or commercial project is a highly desirable if not a required feature today, when every project core needs to scalable. So the possibility to upload your code from a remote computer via Wi-Fi connection rather then Serial is a high advantage in every project. First you need FOTA needs needs prerequisites. First firmware upload needs to be done via Serial, and if the OTA routines are correctly implemented in the program next uploads can be done over the air. Because the module needs to be exposed wirelessly, the chance to being hacked and loaded with maleficent code exists. You can improve your security by setting custom port and password. Check functionalities from the ArduinoOTA library that may help you to boost security. Because of the complexity of this procedures we will cover the full story in a future article, but for now be aware that this option exists and it works pretty good.

Another way to connect the esp8266 arduino module to computer is to use a TTL or FTDI USB-to-serial dedicated module. There are plenty of them on the market and there are quite cheap, but make no mistake, here quality does matter. You may encounter problems when working with it if ending up with a cheap one because of the differences in connections and also driver compatibility. Most used TTL / FTDI converters chips are CH340G, CP2102 and FT232RL. I personally used the first two ones and i have no problem when loading programs. Following connections need to be done:

VCC 3.3v
RST 3.3v / float
CH_PD 3.3v

I highly recommend you not to use the TTL 3.3v power supply because most of them are not able to provide enough power to handle the esp8266 arduino compatible device. The embedded voltage regulator used on this modules are not the happiest choice and you may get in trouble if it cannot support ESP peeks. If you choose to use an external power supply don’t forget to setup a common ground in order to have a working circuit. You can find TTL modules that have TX rated at 3.3v, if not, you shod step-down the TX channel to protect your ESP-01 module. You can see bellow a wiring scheme between ESP-01 and CP2102 which includes a reset button connected to ground, and also GPIO0 for boot switch.

ESP8266-01 UART TTL connection GeeksTips.com

Here is a simple 3.3v divisor sketch using resistors:

3.3v divisor for ESP8266 Arduino

The most comfortable way to communicate with the ESP-01 is by using a dedicated ESP01 programmer module, which can be bought also from the same producers and the costs are very low. This kind of devices can have buttons integrated for RESET and BOOT switching and also come with a dedicated slot. All you need to do is to plug your esp and your done.

ESP8266-01 programmer ESP8266-01 programmer ESP8266-01 programmer

You can also build your own programmer if you have a bit of skills, you don’t need to be an expert. Here are few homemade tryouts:

ESP8266 DIY programmer ESP8266 DIY programmer ESP8266 DIY programmer ESP8266-01 homemade programmer

In order to setup your Arduino IDE to work with your esp8266 arduino compatible module you need to make the following steps:

  1. Connect your ESP8266-01 Module to PC
  2. Open your Arduino IDE
  3. Go to File -> Preferences
  4. Add this link to Additional Board Manager
  5. Go to Tools -> Board Manager
  6. Find ESP8266 board set and activate it
  7. Select Generic ESP8266 board from Tools->Boards
  8. Choose your programmer COM port
  9. You are ready to go!

Arduino IDE ESP8266 board installation

Now, to be able to download the program to your ESP-01 module, you first need to put your device in the proper BOOT mode (Download code from UART). ESP8266-01 have the following boot modes:

MTDO / GPIO15GPIO0GPIO2ModeDescription
L L H UART Download code from UART
L H H Flash Boot from SPI Flash
H X X SDIO Boot from SD-card

Note that L = LOW (putting to Ground / -3.3v) and H = HIGH (putting to 3.3v)

After resetting the module in Download code from UART you should see a message containing “boot mode:[1,6]” in the serial monitor, if you are on the correct baudrate. A wrong baudrate setting will display garbage text / characters or nothing at all. After that you should be able to upload your sketch to ESP8266. When upload is done, module should reset itself. Don’t forget to pull HIGH the GPI0 or the module will get in Download mode again and you will not be able to see it working. The module can be rebooted at anytime by pulling REST pin to LOW. After each reset it will follow the boot sequence and program loading.

Once the ESP8266 board is installed and activated in Arduino IDE, you will be able to include all ESP WiFi libraries and examples that comes with the package. The most used library is ESP8266WiFi which offers many implementation examples like WiFiClient, WiFiServer, WiFiAccessPoint etc. You can find allot of projects examples over the internet, I for example, found great ideas on arduino.cc projecthub. Here is a simple Arduino blink example which you can use to test the esp module with the built in LED:

 ESP8266 Arduino Blink by Simon Peter
 Blink the blue LED on the ESP-01 module
 This example code is in the public domain
 The blue LED on the ESP-01 module is connected to GPIO1 
 (which is also the TXD pin; so we cannot use Serial.print() at the same time)
 Note that this sketch uses LED_BUILTIN to find the pin with the internal LED

void setup() {
  pinMode(LED_BUILTIN, OUTPUT);     // Initialize the LED_BUILTIN pin as an output

// the loop function runs over and over again forever
void loop() {
  digitalWrite(LED_BUILTIN, LOW);   // Turn the LED on (Note that LOW is the voltage level
                                    // but actually the LED is on; this is because 
                                    // it is acive low on the ESP-01)
  delay(1000);                      // Wait for a second
  digitalWrite(LED_BUILTIN, HIGH);  // Turn the LED off by making the voltage HIGH
  delay(2000);                      // Wait for two seconds (to demonstrate the active low LED)

Off course, after that you can try a more complex example by loading a ESP8266 Arduino WiFi Client example program that sends data via WiFi to the data.spakfun.com iot platform:

 *  This sketch sends data via HTTP GET requests to data.sparkfun.com service.
 *  You need to get streamId and privateKey at data.sparkfun.com and paste them
 *  below. Or just customize this script to talk to other HTTP servers.
 *  ESP8266 Arduino example

#include <ESP8266WiFi.h>

const char* ssid     = "your-ssid";
const char* password = "your-password";

const char* host = "data.sparkfun.com";
const char* streamId   = "....................";
const char* privateKey = "....................";

void setup() {

  // We start by connecting to a WiFi network

  Serial.print("Connecting to ");
  WiFi.begin(ssid, password);
  while (WiFi.status() != WL_CONNECTED) {

  Serial.println("WiFi connected");  
  Serial.println("IP address: ");

int value = 0;

void loop() {

  Serial.print("connecting to ");
  // Use WiFiClient class to create TCP connections
  WiFiClient client;
  const int httpPort = 80;
  if (!client.connect(host, httpPort)) {
    Serial.println("connection failed");
  // We now create a URI for the request
  String url = "/input/";
  url += streamId;
  url += "?private_key=";
  url += privateKey;
  url += "&value=";
  url += value;
  Serial.print("Requesting URL: ");
  // This will send the request to the server
  client.print(String("GET ") + url + " HTTP/1.1\r\n" +
               "Host: " + host + "\r\n" + 
               "Connection: close\r\n\r\n");
  unsigned long timeout = millis();
  while (client.available() == 0) {
    if (millis() - timeout > 5000) {
      Serial.println(">>> Client Timeout !");
  // Read all the lines of the reply from server and print them to Serial
    String line = client.readStringUntil('\r');
  Serial.println("closing connection");

Or if you need to make a server in your network, you can try ESP8266 Arduino Wifi Server example program:

 *  This sketch demonstrates how to set up a simple HTTP-like server.
 *  The server will set a GPIO pin depending on the request
 *    http://server_ip/gpio/0 will set the GPIO2 low,
 *    http://server_ip/gpio/1 will set the GPIO2 high
 *  server_ip is the IP address of the ESP8266 Arduino module, will be 
 *  printed to Serial when the module is connected.

#include <ESP8266WiFi.h>

const char* ssid = "your-ssid";
const char* password = "your-password";

// Create an instance of the server
// specify the port to listen on as an argument
WiFiServer server(80);

void setup() {

  // prepare GPIO2
  pinMode(2, OUTPUT);
  digitalWrite(2, 0);
  // Connect to WiFi network
  Serial.print("Connecting to ");
  WiFi.begin(ssid, password);
  while (WiFi.status() != WL_CONNECTED) {
  Serial.println("WiFi connected");
  // Start the server
  Serial.println("Server started");

  // Print the IP address

void loop() {
  // Check if a client has connected
  WiFiClient client = server.available();
  if (!client) {
  // Wait until the client sends some data
  Serial.println("new client");
  // Read the first line of the request
  String req = client.readStringUntil('\r');
  // Match the request
  int val;
  if (req.indexOf("/gpio/0") != -1)
    val = 0;
  else if (req.indexOf("/gpio/1") != -1)
    val = 1;
  else {
    Serial.println("invalid request");

  // Set GPIO2 according to the request
  digitalWrite(2, val);

  // Prepare the response
  String s = "HTTP/1.1 200 OK\r\nContent-Type: text/html\r\n\r\n<!DOCTYPE HTML>\r\n<html>\r\nGPIO is now ";
  s += (val)?"high":"low";
  s += "</html>\n";

  // Send the response to the client
  Serial.println("Client disonnected");

  // The client will actually be disconnected 
  // when the function returns and 'client' object is detroyed

And in the last example an ESP8266 Arduino WiFi Access Point which hosts a web server is created:

/* Create a WiFi access point and provide a web server on it.
ESP8266 Arduino example

#include <ESP8266WiFi.h>
#include <WiFiClient.h> 
#include <ESP8266WebServer.h>

/* Set these to your desired credentials. */
const char *ssid = "ESPap";
const char *password = "thereisnospoon";

ESP8266WebServer server(80);

/* Just a little test message.  Go to in a web browser
 * connected to this access point to see it.
void handleRoot() {
	server.send(200, "text/html", "<h1>You are connected</h1>");

void setup() {
	Serial.print("Configuring access point...");
	/* You can remove the password parameter if you want the AP to be open. */
	WiFi.softAP(ssid, password);

	IPAddress myIP = WiFi.softAPIP();
	Serial.print("AP IP address: ");
	server.on("/", handleRoot);
	Serial.println("HTTP server started");

void loop() {

Final thoughts

After playing with this module for few weeks, i find it being one of the coolest gadget i ever used in my projects and i have nothing than beautiful words about it. If you are even just a bit attracted about development boards and you haven’t had the chance to play with ESP8266 series, this is one of the first thing that i recommend to get and play with. It easily checks every goal, the price is excellent, it has MCU integrated, it has Wi-Fi integrated, the signal range is pretty awesome, the size is excellent for embedding in most projects, and it can be powered by any average + batteries no problem.

In the further articles i will show you how i made to create a network of 5 ESP8266-01 in my house, and make them communicate each other to centralize data into a IoT web server. Also i want to come back with feedback about day to day behavior and especially power consumption.

Update: Multiple ESP8266 talking each other article ready. Find here an incredible story about a farmer from Europe who managed to implement a huge ESP8266 WiFi topology using more than 40 ESP modules in a real life example.

ESP8266 talk with each other -two esp connected

Hoping that this article inspired you, i kindly invite you share this articlesubscribe my YouTube channel and join the communities on social networks. Please feel free to comment or send suggestions / remarks so i can improve the content quality!

Gearbest  promotion

Share on: Facebook Twitter Google+

22 Replies to “ESP8266 Arduino tutorial – WiFi module complete review”

  1. Ray says:

    Nice job.
    Thanks for examples and notes.

    • GeeksTips says:

      Your welcome, feel free make remarks and also make proposals for the following articles ! Thank you!

    • GeeksTips says:

      Thanks for your time and interest! Stay close 🙂

  2. Jonas says:

    Good and thorough review. I’m looking forward to the multiple esp8266 communications tutorial.

    • GeeksTips says:

      Hello, I already implemented multiple ESP communication system in my house and I will write an tutorial about how to do that soon. Thank you for your interest!

  3. I see your website needs some fresh & unique articles.
    Writing manually is time consuming, but there
    is tool for this task. Just search for; Digitalpoilo’s tools

  4. Jeepers01 says:

    Very good and informative article. Under point 4. above, the link to additional boards is missing. It should be
    Feel free to email when the page is updated about the network of 5 ESP’s as this sounds interesting. Will it be with MQTT?

  5. jackshowme says:

    I am confused with the connection between Arduino and ESP8266 for RX.
    Why Arduino Rx(D0) is connected to ESP8266 RX and their TXs are also connected.
    I got the same result as you said here.
    In the begining of my experiment, I connected Arduino Rx/TX to ESP8266 TX/RX like as
    TTL / FTDI case. I got no response form ESP8266 when I give it a command.
    Next, I connected Arduino Rx/TX to ESP8266 RX/TX, and I found eveything is fine.
    I always think Arduino Rx(D0)/TX(D1) is for receive/transmit data to/from Arduino.
    Is it wrong?

    • GeeksTips says:

      When you use a dedicated TTL / FTDI the terminals needs to be aligned logical RX < -> TX, receiver < -> sender, but this is not the case when using Arduino board for programming. In this case the UNO acts like a repeater, a bridge. By running UNO with a blank sketch, you can use its serial port just to forward the signal. It actually does nothing but forwarding the packages, not programming. There are other modes to use UNO as a programmer, as a ISP, or by using emulated UART pins with SoftwareSerial library. I used this one, because is the simplest.

  6. Obrigado por seus artigos, estou lendo todos e estão me ajudando muito. Estarei inciando um projeto utilizando ESP8266, sou estudante de Engenharia Elétrica. Mais uma vez obrigado!

  7. Brundha sholaganga says:

    Thank you it was very informative article ,by the way do we need to code the wifi module initially i mean after installation of library in IDE you mentioned it right , what i thought is wifi sheild need to be set in AT mode for changes in default settings and later dump the code in arduino as per required task of operation by arduino

  8. Mohammad Abdellatif says:

    This is a great tutorial and i learned a lot from it.
    Iam doing a project where i use a VC0706 camera with arduino and use esp8266 wifi to send the images to a webserver.
    I managed to write a code that combines both of them. But when i use the method here to upload the data on the esp module, it connects to the internet but cannot communicate with the camera.
    My question is: is there a way to modify the code so it works directly on the arduino? meaning i select the board as the arduino and not the esp?

  9. GeeksTips says:

    You need to come with more details, otherwise I cannot know your setup. Good Luck!

  10. Chukwuka Okeke says:

    I appreciate your articles, they are very useful. I’m trying to do a database project where an esp8266 and an Android app exchange data(in JSON format) on specific ports on the server. You may not necessarily bother about d Android. It goes this way, d esp8266 acts as an access point for d Android to connect to so could you pls guide me on how I could send data to the Android on specific ports?

  11. GeeksTips says:

    This depends on how you want to receive the data, meaning on what channels. You could emulate a local webserver on the Android, and use it as an http Endpoint (or REST). After that you can just send requests to that endpoint from the ESP and attach the JSON. You can also use Blynk APP and send data over the serial, but its tricky.

Leave a Reply

Your email address will not be published.