Getting started with ESP8266 and Programming it using Arduino IDE

Getting started with ESP8266 and Programming it using Arduino IDE

In today’s world of IoT, the Wi-Fi technology is taking over day by day and number of connected devices also increasing. Many different types of modules with different features are used to take advantage of this technology. We always want to add internet connectivity in our project and confused which module should be chosen. So, here is a fantastic module called the ESP8266 from Espressif Systems. Using this low cost, small size module you can easily connect your device with the internet and can control any device.

Many people find ESP8266-01 module difficult to get started. They didn’t get the proper documentation or guidance in the beginning. So, This tutorial aims to introduce you to this ESP8266-01 module and help you get started with it. Follow the given instructions here and you should be able to get your ESP8266-01 module up and running in no time.

Before getting into the technical details lets see some basics about ESP8266 Module.

 

What is ESP8266?

The ESP8266 Wi-Fi module is a complete Wi-Fi solution with microcontroller functionality and this module has powerful storage and data processing capability built on the high degree on chip integration therefore it can easily integrate with sensors and external microcontrollers for gaining the access to any Wi-Fi network.

There are many types of ESP series modules ranging from ESP8266-01 to ESP8266-12. All the modules of ESP series has same processor, only difference is the breakout board which expose the number of pins. ESP8266-01 comes last in the list in terms of number of GPIOs. It has only 2 usable GPIOs. Also, it is a smaller one among ESP series.

ESP8266 Wi-Fi Module

 

It is very cost effective module with very helpful community all over the world. Also, we can program this module with the help of Arduino IDE to connect it with the any available Wi-Fi network.

 

Specifications of ESP8266-01 are:

Voltage

3.3V

Current Consumption

10uA-170mA

Maximum current consumption during flashing

800mA

Flash Memory

16MB (512K normal)

Processor

Tensilica L106 32 bit

Processor Speed

80-160MHz

RAM

32K+80K

GPIO

17 (but most are multiplexed)

Analog to digital Converter

1 (10-bit)

Maximum TCP connections

5

 

Pin Description:

ESP8266 Wi-Fi Module Pinout

 

Pin Number

Pin Name

Other Name

Pin Use

1

Ground

-

Connection with the ground of the circuit

2

TX

GPIO _1

Connected to Rx pin of uC to upload program,

Can act as a GPIO pin when not used as TX

3

GPIO_2

-

GPIO Pin

4

CH_EN

-

Chip Enable/Chip Power down – Active high, used to enable the esp8266 chip

5

GPIO _0

Flash

GPIO pin, connect this pin to GND when programming the module

6

Reset

-

Resets the module

7

RX

GPIO_3

Connected to Tx pin of uC to upload program, Can act as a GPIO pin when not used as Rx

8

Vcc

-

Connect to +3.3V only

 

Where to use ESP8266-01?

If you want to connect your project with the internet then this module can be used. This module can be act as an Access point i.e. it can act as hotspot and also as station mode which can connect this module with the Wi-fi. So, this module can easily send and receive the data over the internet and can make your device as Internet of things device. Also, this module can fetch the data available on the internet using different API’s. ESP series can also programmed using Arduino IDE which make ESP more user friendly. However, It can use as a standalone module if you have to use 2 GPIOs, otherwise you have to connect it with the microcontroller like Arduino. You can use ESP-12 or ESP-32 if you have to use more than 2 GPIOs. So, if you are looking for getting started with IoT and want to make your project Smart then this module is for you.

 

How to use the ESP8266 Module

Let’s see the Software and hardware requirements for the ESP8266. There are many IDEs which supports this module but mostly Arduino IDE is used due to its user friendly interface and easy program structure. This module can also be programmed using AT commands and Lua script.

All the newly purchased ESP8266 modules have a default firmware loaded into it. Using this inbuilt firmware, you can program it using AT commands.

If you use the Arduino IDE to program this module then you will lost this inbuilt firmware and unable to program it using AT commands. In that case you have upload the new firmware to start with the AT commands.

 

Hardware Setup

ESP8266 module works with 3.3v, voltage more than this would burn your module so, be careful with the applied voltage. Also, esp8266-01 is not breadboard friendly, you have to make a connector using male berg strips as shown below to plug it in breadboard. Else you can use simple male female connectors to wire other components with this module.

Hardware Setup for Programming ESP8266 using Arduino IDE

 

Programming ESP8266

For programming the esp-01 module, you have to use USB to serial converter or Arduino Uno board without atmega328 IC.  To program this module using FTDI module, connect the circuit a shown below.

If you don’t have FTDI module, use the Arduino Uno board, just remove the Atmega328 chip and make the connections as follow:

Rx of ESP -> Rx of Arduino uno

Tx of Esp -> Tx of Arduino uno

Vcc of Esp -> 3.3v of Arduino

GND of Esp -> GND of Arduino

 

Replace the connections in the below circuit diagram by removing the FTDI module. If you are using external power supply, don’t connect the Vcc of ESP with Arduino board. Only Rx, Tx and GND should be connected.

simplified circuit diagram for using the ESP8266-01 module with FTDI module is given below:

Circuit Diagram for Programming ESP8266 using Arduino IDE

 

In above diagram, Push button is used to reset the module. To program the module using Arduino IDE and to flash new firmware in the module make the GPIO_0 to GND using switch button. After programming the module remove the GND from GPIO_0.

You can make the above circuit on PCB to make the connections tight and clean.

Now, connect your FTDI module to your computer using a mini-USB to USB cable. Goto Device manager on your laptop/PC and you will find FTDI board connected to the COM port as shown below:

Connecting FTDI for Programming ESP8266 using Arduino IDE

 

Now, open the Arduino IDE and then Serial monitor. Make the baud rate 115200 and select Both NL and CR.

Reset the module using Push button, you should see some garbage values and then ready message on serial monitor. Now type AT and hit enter, it will reply back with OK.

Now, your module is ready to work in AT commands. To learn about AT commands read this documentation.