ESP8266 Tutorial: Programming the onboard GPIO pins

From our STAR Maker: Robin Thomas


ESP8266 is the best tool for enabling your project to access the internet. You can plug it to an Arduino very easily as shown in this tutorial and allow your project to communicate through the internet. Or even more exciting, to control it from anywhere in the world!

The ESP8266 module is of very low cost, starting from around Rs.200 from Amazon. And it comes pre-programmed with an AT command set firmware, meaning, you can simply hook this up to your Arduino device and get about as much WiFi-ability as a WiFi Shield offers. This module has a powerful on-board processing and storage capability that allows it to be integrated with the sensors and other application through its GPIOs.

In this tutorial we can see how to get started with the ESP-01 Wi-Fi module, configure it, and verify that there is communication established between the module and another device without using an ftdi chip.

What are the stuff required to do this project?

  1. Arduino board.
  2. ESP8266.
  3. Breadboard.
  4. Female to male and male to male jumpers.

How does it work?

The ESP8266 communicates with the Arduino through a serial interface. That is, it uses the Rx and Tx pins of Arduino (digital pins 0 and 1) hooked up to the module for receiving commands and communicates back. The module features a full TCP/UDP stack support and can be configured as a web server.esp8266 pinout

The ESP8266 or ESP-01 module also has two GPIO pins that can be used for directly manipulating any output devices like LEDs or relays. Moreover, the ESP-01 module powers the onboard ESP8266 through 3.3V. Therefore if your Arduino doesn’t have a 3.3V output pin, you will have to use a voltage regulator like the 78R33 to step down the 5V from the Arduino to 3.3V in order to power the ESP8266.

STEP 1: Setting up the Arduino

First, download Arduino IDE ensure that you have the latest software version (some older versions won’t work). Visit the following URL:

Upload Bareminimum sketch from examples to arduino this is to make sure that there are no other programs running on arduino and using serial communication channel. AT firmware is compatible with the Arduino IDE, so we are going to use this firmware for this tutorial .

Arduino Bareminimum ESP8266

Now, connect ESP8266 as per the below circuit.

  • VCC shall be connected to the 3.3V power supply
  • GPIO0 and GPIO2 are general purpose digital ports. GPIO0 also controls the module mode (programming or normal operation). In our case (normal operation), it shall be connected to 3.3V (high). GPIO2 is not used in this example.
  • Rx: Goes to Arduino pin0 (But needs a voltage adjusting)
  • CH_PD: Chip enable. Keep it on high (3.3V) for normal operation
  • RST: Reset. Keep it on high (3.3V) for normal operation. Put it on 0V to reset the chip.
  • GND is ground.
  • Tx: Goes to Arduino pin1.

ESP8266 connection

ESP8266 modes: (Setup continued)

Open the serial monitor and change the baud rate to 115200 and choose NL and CR (new line and carriage return) from the drop-down menu. Type AT on the serial monitor you will see: OK as the response .If you see garbage value on the screen, try resetting the module, or checking your baud rate. Make sure the NL and CR option is set. Moreover, ESP8266 module has three operational modes:

1Access Point (AP)

In AP, the Wi-Fi module acts as a Wi-Fi network, or access point (hence the name). It allows other devices to connect to it. And establishes a two way communication between the ESP8266 and the device that is connected to it via Wi-Fi.

2Station (STA)

In STA mode, the ESP-01 can connect to an AP(access point) such as the Wi-Fi network from your house. This allows any device connected to that network to communicate with the module.

3. Both

In this mode ESP-01 act as both an AP as well as in STA mode.

You can refer the following site for more ESP8266 AT commands click here.

STEP 2: Installing ESP8266 platform

First, the Arduino environment has to be setup to make it compatible with the ESP-01 module. It is required to have Arduino version 1.6.4 or higher in order to be able to install the ESP8266’s platform packages.

1.Open the preferences window from the Arduino IDE. Go to File >PreferencesESP8266 preferences









2. Enter: into Additional Board Manager URLs field and click the “OK” button

ESP8266 setting

3.. Open boards manager. Go to: Tools > Board > Boards Manager…ESP8266 setting

4. Scroll down, select the ESP8266 board menu and install “esp8266 platform”.ESP8266 setting

5. Choose your ESP8266 board from Tools > Board > Generic ESP8266 ModuleESP8266 setup

STEP 3: Controlling Input and Output

In Arduino IDE go to examples and open the blink program. Change the pin no to 2 from 13, since there is only two GPIObpins for ESP8266 (GPIO0 and GPIO2).

NOTE:Make sure that GPIO0 is grounded while uploading the code.ESP8266 connection

Connect the ESP-01 module as per the diagram above, upload the sketch which is shown below and watch the magic.

ESP8266 program

Feedback and Questions are welcomed! Thanks for reading.

Robin Thomas - STAR Maker at DIY Hacking

Robin Thomas – STAR Maker at DIY Hacking


-Submitted by Robin Thomas

I am an electrical engineering student, and a Maker by passion who loves open source technologies.

Recommended Posts
Showing 4 comments
  • raul

    if the GIPO2 pin is 2, the pin for the GPIO 0 is 0?

  • Mohamed Hegab

    It Gives me

    warning: espcomm_sync failed

    I connected the circuit like the diagram

  • Thomas Kanattu

    Well done

    • raul

      NOTE:Make sure that GPIO0 is grounded while uploading the code.
      then connect the GPIO0 to ground before upload the sketch

Leave a Comment

+ 13 = 23

Start typing and press Enter to search