Programming ESP8266 ESP-01 with Arduino © GPL3+

ESP8266 is an impressive, low cost WiFi module suitable for adding WiFi functionality project.

  • 104,333 views
  • 27 comments
  • 59 respects

Components and supplies

About this project

ESP8266 module is of low cost and 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 a ftdi chip.

STEP 1 : Arduino Setup

First download Arduino IDE ensure that you have the latest software version (some older versions won’t work), visit the following URL: https://www.arduino.cc/en/Main/Software.

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 . Connect ESP8266 as per the above 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 Modes:

Setup continued

Open the serial monitor change the boud rate to 115200 and coose NL and CR (new line and carrage return).Type AT on the serial monitor you will see an OK 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.

ESP8266 module has threeoperational modes.

1. Access Point (AP)

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

2. Station (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 command set click here.

STEP 2: Installing ESP8266 Platform

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

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

2. Enter http://arduino.esp8266.com/stable/package_esp8266com_index.json into Additional Board Manager URLs field and click the “OK” button

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

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

5.Choose your ESP8266 board from Tools > Board > Generic ESP8266 Module.

STEP 3. Controlling Input and Output

In Arduino IDE go to examples and take blink change the pin no to 2 from 13 since there is only two gpio pins for ESP8266 (GPIO0 and GPIO2).

NOTE: Make sure that GPIO 0 is grounded while uploading the code.

Connect the ESP as per the image and upload the sketch and watch the magic.

Comments and Questions welcome! Thanks for reading.

Schematics

ESP8266_starter.fzz
ESP8266_starter.fzz
esp8266at.fzz
esp8266at.fzz

Code

Blink Sketch For ESP8266-ESP01C/C++
Use normal blink sketch from arduino examples and change the pin no to 2 from 13 since Esp8266 has got only two gpio pins(gpio0 and gpio2) .
void setup() {
  // initialize digital esp8266 gpio 2 as an output.
  pinMode(2, OUTPUT);
}

// the loop function runs over and over again forever
void loop() {
  digitalWrite(2, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(1000);              // wait for a second
  digitalWrite(2, LOW);    // turn the LED off by making the voltage LOW
  delay(1000);              // wait for a second
}

Comments

Add projectSign up / Login