INTRODUCTION TO ESP8266 module

Today, in this article we are going to introduce you to a new Wi-Fi module named ESP8266. It is widely used in the Internet of things (IoT) and working voltage of this module is 3 V. We can use this module with our Arduino development boards that are used in simple as well as complex projects in order to provide Wi-Fi to Arduino development boards, as no Arduino development board comes up with built-in Wi-Fi feature so far. So in short, we can say that every ESP8266 module comes up preprogrammed with AT command set firmware and can be plugged with any other development board to act as a Wi-Fi shield. But to use it with some development boards we must be cautious that how should our ESP8266 should get operating voltage because it cannot bear more than 3.6 V and how to make serial connections with other development boards and how to ping other devices.

Introduction to ESP8266 wifi module

ESP8266 comes up with powerful processing speed on board. Storage space of this module is also high allowing it to integrate with other devices like sensors. To make this module compatible with other development boards, we have to do level shifting of voltages externally because this board doesn’t come up with on-board voltage regulator. This module is cost effective and thus used widely in many applications like the Internet of things and much more.So in this article, we are going to discuss key features of ESP8266, pins specifications, how to use this board for programming purposes and a sample program.

KEY FEATURES ESP8266 WIFI Module

  • 32 – bit microcontroller
  • Central processing unit: 80 MHz or 160 MHz
  • Instruction RAM: 32 KB
  • Cache RAM: 32 KB
  • User data RAM: 80 KB
  • ETS system data RAM: 16 Kb
  • External memory: 16 MB
  • General purpose input output pins: 16
  • SPI supported
  • I2C interface supported
  • I2S interface supported
  • Wi-Fi standard of 802.11 b / g / n
  • UART supported on specific pins
  • 10 – bit analog to digital converter (ADC)
  • Protocol stack: TCP / IP

PIN CONFIGURATION of ESP8266

  • VCC: to provide voltage up to 3.6 V at maximum
  • GND: to provide ground to the module
  • RX: serial data receiving
  • TX: serial data transmission
  • CH_PD (power down of the chip)
  • RST: reset pin
  • General purpose input output pins are 16

PROGRAMMING OF ESP8266

Like other Arduino development boards, we can use Arduino IDE for programming of this board too. But we have to install specific libraries and drivers to make this board recognizable by Arduino IDE. So, first of all, we will guide you through the installation process of ESP8266 in Arduino IDE.

STEPS TO CONFIGURE ESP8266 IN ARDUINO IDE:

  • So the first step is to open your Arduino IDE and open the preference window.1 introduction to esp8266
  • To open the preference window, you have to go to the file tab at the top left corner of Arduino IDE and then go to the 2nd last option which is named as a preference. You can also take guidance from the picture above.
  • After opening the preference window, you will see something like this.1 introduction to esp8266
  • You can clearly see the additional board’s manager URLs which is highlighted in the above picture you. In this URL you have to enter the package link of ESP8266. So in order to install ESP8266 package enter http://arduino.esp8266.com/stable/package_esp8266com_index.json and then click OK button. We can have more than one URL in this option. In order to keep more than one URL, you can write multiple URL and just separate them by using the comma after one complete URL.
  • After completion of the above step, you have to go to the board’s manager option. For that, go to the options Tools which is a 4th option in the upper tab of Arduino IDE. After expanding the tools tab, go to the board, and then you can see the board manager option. It is shown in the picture below.3 introduction to esp8266
  • Now you have to search for your required board. In our case, its ESP8266 so select this board by searching for it and then you can choose to install “ESP8266 platform”. In case of confusion, you can consult the picture below:4 introduction to esp8266
  • Once you are done with the above steps and everything went smoothly, then you can now choose your ESP8266 board. Now click on the tool tab again and then go to the board option and then click generic ESP8266 module just like in the picture below5 introduction to esp8266
  • You have to select your board as well as the port. It can be clear from the image below. After all, these steps just restart your Arduino IDE so that the changes we have done can be appropriately configured.6 introduction to esp8266

BOOTLOADER MODES OF ESP8266

Depending on the general purpose input output pins, i.e., 15, 2 and 0 our boot loader can have a number of modes as these modes are dependent on states of above mentioned general purpose input output pins. In our case, we are only interested in flash startup mode and UART download mode. By considering the above mentioned pin, we have drawn a table in which you can see that to use a specific download mode what should be your pin configuration.

MODEGPIO 0GPIO 2GPIO 15
UART download mode (for programming purposes)010
Flash Startup Mode110
SD card boot001

CIRCUIT DIAGRAM FOR ESP8266 WITH USB TO serial converter 

The circuit diagram to connect our ESP8266 board for programming purposes is given below. For uploading purposes, we just have to press the flash button. In some boards flash as well as reset button is used for this purpose but that’s not the case in this board. So for this purpose, by consulting the table above we can see that we have to connect GPIO 0 pin as low, GPIO 2 pin as high and GPIO 15 pin as low. In order to put our board in serial programming mode, we have to press and hold the reset button and while reset button in pressed we have to press and hold flash button. After it, we have to release our reset button while keeping your flash button in the pressed state and after releasing your reset button we can release our flash button too.7 introduction to esp8266

LED BLINKING with ESP8266 WIFI Module 

So we are going to discuss the led blinking program in detail here. There is a built-in led in our ESP8266 board which we will program and will compare the results according to our code which we are going to write.

CODE:

/*
ESP8266 Blink
Blink the blue LED on the ESP8266 module
*/

#define LED 2 //Define blinking LED pin

void setup() {
pinMode(LED, OUTPUT); // Initialize the LED pin as an output
}
// the loop function runs over and over again forever
void loop() {
digitalWrite(LED, LOW); // Turn the LED on (Note that LOW is the voltage level)
delay(1000); // Wait for a second
digitalWrite(LED, HIGH); // Turn the LED off by making the voltage HIGH
delay(1000); // Wait for two seconds
}

CODE DETAILS:

In the above program, we first defined our led that we are going to blink. If we look at the program flow, then we can say that our setup function in the program will run only once and it will run once our program is uploaded on the board. After the setup function, we will have a loop function. Why are we not doing all this in a single function? The answer to this question is that we have to show led blinking. If we use only the setup function, then our led will turn on and off only once. So we have to use another function that will run in a loop.

If we look at the structure of the Arduino IDE program, then we can see that setup and loop functions are a mandatory part of a program. We can many functions, but these two functions are compulsory. We have already discussed the use of setup function and now if we look at the loop function we can see that we first have turned on our led by assigning it low voltage level and then we waited for one sec, and after that we assigned it a high voltage level which will turn off our led and then again we will wait for a sec and then our led will turn off again and so on. As loop function will run continuously as long as your program is running. If we have to stop this program then either you can power off your board by disconnecting it or stop the program from running in Arduino IDE. So in this way, we can blink our led by using ESP8266 microcontroller.

So in this article, we looked at the key features, pin layout, how to make our board compatible with Arduino IDE and a sample program of blinking led. In case of any ambiguity, we can ask your questions related to this article in the comment section below.

Leave a Comment