Esp8266 Serial Wifi Arduino

Buy Esp8266 Esp-12e Serial Wifi Wireless Transceiver Module for Arduino UNO 2560 R3(Pack of 2) by IFANCY-TECH: Network Transceivers - Amazon.com FREE DELIVERY possible on eligible purchases.

Connect your microcontroller to the internet by adding ESP8266 WiFi module!

  • 250,744 views
  • 106 comments
  • 155 respects

Components and supplies

Arduino UNO & Genuino UNO
×1
Espressif ESP8266 ESP-01
×1
Jumper wires (generic)
×1
Resistor 10k ohm
×1
Resistor 1k ohm
×2
Esp8266 Serial Wifi Arduino

Apps and online services

About this project

Updated as of February 1, 2019

Connect your Arduino to the internet by adding ESP8266 WiFi Module!

Esp8266 Serial Wifi Arduino

The ESP8266 Wifi module is a complete Wi­Fi network where you can easily connect as a serving Wi- Fi adapter, wireless internet access interface to any microcontroller­ based design on its simple connectivity through Serial Communication or UART interface.

Adding this module to your Arduino UNO will open you to more and exciting projects.

What is the process?

There are a lot of ways to use ESP866 for communication. Some may use it to send / receive data online or regularly upload data. For this tutorial I will just show you how can we communicate to Arduino wirelessly using your phone (Android or iPhone) . This will be done offline so no need to have internet connection.

Our ESP8266 will serve as Access Point (AP Mode), meaning it will provide access to Wi-Fi network to other devices (stations) and connects them further to a wired network

The process it pretty simple. Use your phone to send any command to Arduino. With the help of ESP8266, everything will work wirelessly.

Upload Sketch

First of all, upload my sample Arduino sketch.

If you want to know whats on my sketch go to About the code section

You can download the attached sketch or get the updated version on my github repo.

If you don't know how to upload a sketch then Read here

Do I need to flash my ESP?

No. Just use the stock firmware. But in case you need then read here

Built Circuit

Connect the pins more described on this Pin table

Follow these steps.

  • connect both ESP's VCC/3.3V/Power Pin and Enable Pin (red wires) to 10K resistor then to Uno's +3.3V power pin.
  • connect ESP's Ground/GND Pin (Black Wire) to Uno's Ground/GND Pin.
  • connect ESP's TX (green wire) to Uno's Pin 3
  • cconnect ESP's RX (blue wire) to 1K resistor then to Uno's Pin 2.
  • cconnect ESP's RX (blue wire) to 1K resistor then to Uno's GND Pin.

Set up connection

Once everything is set up, you would notice that your ESP8266 Wifi will be available within the range of your phone.

1. Download TCP Client for Android

You can download any TCP Client available in Play Store but I used TCP Client by Sollae Systems

2. From your phone, Connect to your ESP8266 Wifi

If your ESP8266 wifi is not displayed from available wifi networks, make sure your Arduino is running and everything is connected correctly. If not troubleshoot your ESP by following its documentation.

Usually the name of the wifi / ssid will start in ESP following its version name, mine is ESP11.

3. Once connected, get the Static IP address.

Important:You can check theESP's IP by going to Wifi Settings of your phone, and click the network info.

The default IP Address in AP mode is 192.168.4.1 .

You can change the static IP by following this Wifi.config() reference.

4. Open TCP Client you downloaded earlier.

Create connection by clicking connect , Add ESP's IP and port 80 like this:

80 is the port that I used for our ESP Server, but you can change it by replacing 80 to any port number you want from our code on line 23

6. Wait for the TCP Console to say 'Connected'.

Esp8266 Serial Wifi Arduino Code

Talk to you Arduino Uno via Smart Phone

Once connected send request by typing the following code to TCP Client:

esp8266: <any AT Commands>

Communication with ESP8266 is via Attention Command or AT Commands.
Check the AT Commands table attached to review the codes.

Or turn on built-in LED using command

LEDON

Or turn off built-in LED using command

LEDOFF

Or just say

HELLO

You can change what response from what you send depending on the logic you put into the code.

Important: esp8266, LEDON, LEDOFF, and HELLO is my custom command identifier. If you put anything other than these, it will return ErrRead.
ErrRead means no command identifier matched from the message you sent.
The ErrRead message is coded on Line 64.

About the circuit

ESP's Power pin is labeled VIN on my ESP11 however for some version it could be 3.3V or Power or VCC.

You will also need to power ESP's CH_EN Pin or Enable Pin in order for it to work.

IMPORTANT do not use voltageto ESP more than 3.3VC

ESP8266 is strictly uses 3.3 V. More that that will destroy the module.

Since Arduino is 5V, I had to put a voltage divider. Those are the resistors.

ESP's TX is connected to Uno's RX which means whatever we want to transmit(TX) in ESP will Receive(RX) by Uno, and vice versa.

Upon building this circuit, we now ready to start WIFI with Arduino UNO.

Note: If you attach serial debugger via USB cable or you open the COM port, the communication between ESP and Arduino will be disturbed and cannot work.
So before flashing Uno, remove the Rx/Tx of ESP first.

About the Code

Important: There are different types of ESP8266. Please change the baud rate on the attached code on Line 16 based on what your ESP8266 uses.

Esp8266 Serial Wifi Arduino Door Lock

All our request will be read and parse on the loop() function

You can see from above that I used my function find(<received message>,<message you want to find> ) to interpret the message and to tell Arduino which code to call.

If you want to communicate with Arduino UNO or ask todo something, just add your condition. for example :

I added some function to communicate with ESP8266.

Thats it! Now that you've learnt how to communicate to Arduino Uno through Wifi, you may now explore more Internet of Things projects. Maximize the power of this WiFI module and be a Maker!. Feel free to add revisions to my github repo

Sample Code

You can find the code on my github repo.

Feel free to send pull requests :)

Expert Mode

If you are familiar with building mobile apps, web apps, web services or web development in general, you can make client applications that can send TCP request to ESP.

Sample apps you can make are Remote Control, Web Control Panel, Chat Bot, Push the button app etc etc.

You can also make 2 of these project so they can talk to each other.

Or make another device that sends TCP request to command the Arduino Uno.

Have fun! :)

Code

ESP8266 Sample Communication with Arduino UNO

Schematics

connect both ESP's VCC/3.3V/Power Pin and Enable Pin (red wires) to 10K resistor then to Uno's +3.3V power pin.
connect ESP's Ground/GND Pin (Black Wire) to Uno's Ground/GND Pin.
connect ESP's TX (green wire) to Uno's Pin 3
cconnect ESP's RX (blue wire) to 1K resistor then to Uno's Pin 2.
cconnect ESP's RX (blue wire) to 1K resistor then to Uno's GND Pin.

Author

Jefferson Paredes
  • 7 projects
  • 55 followers

Published on

July 6, 2017
Write a comment

Members who respect this project

and 147 others

See similar projects
you might like

Table of contents

Write a comment

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

  • 231,821 views
  • 32 comments
  • 94 respects

Components and supplies

Arduino UNO & Genuino UNO
×1
Linear Regulator with Adjustable Output
×1
Resistor 475 ohm
×1
LED (generic)
×1
Espressif ESP8266 ESP-01
×1

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 .

Esp8266 Serial Wifi Arduino

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 Arduino Programming Tutorial

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.

Arduino Esp8266 Connect Wifi Code

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.

Code

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) .

Schematics

Author

Robin Kanattu Thomas

Esp8266-based Serial Wifi Shield For Arduino

  • 6 projects
  • 100 followers

Published on

May 26, 2016
Write a comment

Members who respect this project

and 86 others

See similar projects

Arduino Esp8266 Serial Wifi Wireless Module

you might like

Table of contents

Write a comment