Zbotic Logo Zbotic Logo
  • Home
  • Shop
  • Sale
  • 3D Print Service
  • PCB Service
  • B2B
  • Blogs
  • Contact Us
0 0

View Wishlist Add all to cart

0 0
0 Shopping Cart
Shopping cart (0)
Subtotal: ₹0.00

View cartCheckout

  • Shop
  • About Us
  • Contact Us
  • Reseller
  • Blogs
020 69134444
1800 209 0998
[email protected]
Help Desk
Facebook Twitter Instagram Linkedin YouTube
Zbotic Logo Zbotic Logo
0 0

View Wishlist Add all to cart

0 0
0 Shopping Cart
Shopping cart (0)
Subtotal: ₹0.00

View cartCheckout

All departments
  • 3D Print Service
  • 3D Printer
  • Batteries & Chargers
  • Development Boards
  • Drone Parts
  • EBike parts
  • Sensor Modules
  • Electronic Components
  • Electronic Modules
  • IoT and Wireless
  • Mechanical Parts and Workbench Tools
  • Motors & Drivers & Pumps & Actuators
  • DIY and Robot Kits
  • Show more
  • Home
  • Shop
  • Sale
  • 3D Print Service
  • PCB Service
  • B2B
  • Blogs
  • Contact Us
Return to previous page
Home Arduino & Microcontrollers

ESP8266 WiFi Module Interfacing with Arduino UNO

ESP8266 WiFi Module Interfacing with Arduino UNO

June 16, 2017 /Posted byshreyans001 / 0
Introduction

ESP8266 wifi module is low cost standalone wireless transceiver that can be used for end-point IoT developments.

ESP8266 wifi module enables internet connectivity to embedded applications. It uses TCP/UDP communication protocol to connect with server/client.

ESP8266 WiFi Module

ESP8266 Wi-Fi Module

To communicate with the ESP8266 wifi module, microcontroller needs to use set of AT commands. Microcontroller communicates with ESP8266-01 wifi module using UART having specified Baud rate (Default 115200).

Now let’s interface ESP8266 wifi Module with Arduino UNO.

Interfacing diagram

ESP8266 wifi module Interfacing with Arduino

TCP Client using ESP8266 WiFi Module 

Let’s program Arduino UNO to configure ESP8266 wifi module as TCP Client and Receive/Send data from/to Server using WIFI.

Here, we are using Thingspeak server for TCP Client demo purpose.

Thingspeak is an open IOT platform where anyone can visualize and analyze live data from their sensor devices. Also, we can perform data analysis on data posted by remote devices with Matlab code in Thingspeak. To learn more about Thingspeak refer link https://thingspeak.com/pages/learn_more

Just sign up and create channel. We have below channel and write key available on Thingspeak for data send and receive.

  • channel ID is = 119922
  • Write Key is = C7JFHZY54GLCJY38

Note:  Do not forget to tick Make Public field in channel setting option on your thingspeak channel. It makes channel available to use as public. This allows any user to access channel data without any username & password.

For TCP RECEIVE method use below AT command steps shown in screenshot of RealTerm Serial Terminal.

Below screenshot consists of AT commands (Green) and Responses (Yellow).

TCP Receive using ESP8266 wifi module

 

For TCP SEND method use below AT command steps shown in screenshot of RealTerm Serial Terminal.

TCP Send using ESP8266 wifi module

 

For accessing required functionality i.e. TCP receive or send make changes in program  as per given below,

For TCP Client RECEIVE demo

#define RECEIVE_DEMO        /* Define RECEIVE demo */
//#define SEND_DEMO         /* Define SEND demo */

 For TCP Client SEND demo

//#define RECEIVE_DEMO     /* Define RECEIVE demo */
#define SEND_DEMO          /* Define SEND demo */

Edit fields below with respective data in header file of ESP 8266

/* Define Required fields shown below */
#define DOMAIN           "api.thingspeak.com"
#define PORT             "80"
#define API_WRITE_KEY    " Thingspeak Write Key "
#define CHANNEL_ID       " Thingspeak Channel ID "
#define SSID             " WiFi SSID "
#define PASSWORD         " WiFi Password "

Program

/*
 * ESP8266 wifi module Interfacing with Arduino Uno
 * http://www.electronicwings.com
 */ 
 #include "ESP8266_AT.h"

 /* Select Demo */
//#define RECEIVE_DEMO			/* Define RECEIVE demo */
#define SEND_DEMO			/* Define SEND demo */

/* Define Required fields shown below */
#define DOMAIN          "api.thingspeak.com"
#define PORT            "80"
#define API_WRITE_KEY   "Write your Write Key here"
#define CHANNEL_ID      "Write your Channel ID here"

#define SSID            "Write your WIFI SSID here"
#define PASSWORD        "Write your WIFI Password here"

char _buffer[150];
uint8_t Connect_Status;
#ifdef SEND_DEMO
uint8_t Sample = 0;
#endif

void setup() {
    Serial.begin(115200);
 
    while(!ESP8266_Begin());
    ESP8266_WIFIMode(BOTH_STATION_AND_ACCESPOINT);	/* 3 = Both (AP and STA) */
    ESP8266_ConnectionMode(SINGLE);     			/* 0 = Single; 1 = Multi */
    ESP8266_ApplicationMode(NORMAL);    			/* 0 = Normal Mode; 1 = Transperant Mode */
    if(ESP8266_connected() == ESP8266_NOT_CONNECTED_TO_AP)/*Check WIFI connection*/
    ESP8266_JoinAccessPoint(SSID, PASSWORD);		/*Connect to WIFI*/
    ESP8266_Start(0, DOMAIN, PORT);	
}

void loop() {
    Connect_Status = ESP8266_connected();
    if(Connect_Status == ESP8266_NOT_CONNECTED_TO_AP)	/*Again check connection to WIFI*/
    ESP8266_JoinAccessPoint(SSID, PASSWORD);		/*Connect to WIFI*/
    if(Connect_Status == ESP8266_TRANSMISSION_DISCONNECTED)
    ESP8266_Start(0, DOMAIN, PORT);			/*Connect to TCP port*/

    #ifdef SEND_DEMO
    memset(_buffer, 0, 150);
    sprintf(_buffer, "GET /update?api_key=%s&field1=%d", API_WRITE_KEY, Sample++); 	/*connect to thingspeak server to post data using your API_WRITE_KEY*/
    ESP8266_Send(_buffer);
    delay(15000); 					/* Thingspeak server delay */
    #endif
    
    #ifdef RECEIVE_DEMO
    memset(_buffer, 0, 150);
    sprintf(_buffer, "GET /channels/%s/feeds/last.txt", CHANNEL_ID); /*Connect to thingspeak server to get data using your channel ID*/
    ESP8266_Send(_buffer);
    Read_Data(_buffer);
    delay(600);
    #endif
  }

ESP8266 Response

At the client end, we need to check ESP8266 responses. We can check it on the serial terminal of PC/Laptop. Connect ESP8266 module transmit pin (TX) to the receive pin (RX) of Arduino UNO and to receive pin (RX) of USB to serial converter as shown in below figure. connect USB to serial converter to PC/Laptop. Open the serial terminal on PC/Laptop to see the ESP8266 responses for the AT command sent from Arduino UNO.

Read response of ESp8266 wifi module

Now for TCP SEND commands (sent from Arduino UNO module), we can see the below response from ESP8266 on the serial terminal for the thingspeak server.

ESP8266 WiFi module's response

In response with TCP SEND we get the data entry no. as shown in above figure i.e. 1131, 1132, and so on.

For TCP RECEIVE commands (sent from Arduino UNO Module), we can see the below response from ESP8266 on the serial terminal for the thingspeak server.

ESP8266 wifi module's response

In response with TCP RECEIVE we get the last entry data for field 1 on thingspeak as shown in above figure.

Note: here we are retrieving the last entry data on field1 of thingspeak server hence we get the last updated data of field1 from server as shown in above figure i.e. “field1”:”11”. In program, we used “GET /channels/119922/feeds/last.txt” to receive last updated data only.

  • Updates at thingspeak server on TCP SEND

For TCP SEND we can see the output at server end. Here we are using thingspeak server and sending incremented count to the field 1 on server. We get incremented count at field1 of thingspeak server as shown in figure below.

Data posted on Thingspeak

 


 

Share Post
  • Facebook
  • Linkedin
  • Whatsapp
Applications and Future Scope of Robotics
Atal Tinkering Labs by AIM

Related posts

Svg%3E
Read more

Arduino Batch Programming: Flash Multiple Boards Quickly

April 1, 2026 0
Table of Contents Introduction Components and Hardware Setup Wiring Diagram and Connections Complete Code with Explanation Customization and Improvements Troubleshooting... Continue reading
Svg%3E
Read more

Arduino Based Radar System with Ultrasonic Sensor

April 1, 2026 0
Table of Contents Introduction Components and Hardware Setup Wiring Diagram and Connections Complete Code with Explanation Customization and Improvements Troubleshooting... Continue reading
Svg%3E
Read more

Arduino Automatic Plant Monitor: Sunlight, Moisture, Temperature

April 1, 2026 0
Table of Contents Introduction Components and Hardware Setup Wiring Diagram and Connections Complete Code with Explanation Customization and Improvements Troubleshooting... Continue reading
Svg%3E
Read more

Arduino Lie Detector: GSR Sensor Polygraph Project

April 1, 2026 0
Table of Contents Introduction Components and Hardware Setup Wiring Diagram and Connections Complete Code with Explanation Customization and Improvements Troubleshooting... Continue reading
Svg%3E
Read more

Arduino Metal Detector: Build a Treasure Finder

April 1, 2026 0
Table of Contents Introduction Components and Hardware Setup Wiring Diagram and Connections Complete Code with Explanation Customization and Improvements Troubleshooting... Continue reading

Add comment Cancel reply

Your email address will not be published. Required fields are marked

Facebook Twitter Instagram Pinterest Linkedin Youtube

Get the latest deals and more.

Download on Google Play Download on the App Store

Call us: 020 69134444 / 1800 209 0998

Monday - Saturday 09:30 AM - 06:00 PM
For Technical Supports Email: [email protected]
For Sales / Enquiries Email: [email protected]

  • My Account

    • Cart

    • Wishlist

    • Checkout

    • My Orders

    • Track Order

    • My Account

  • Information

    • FAQs

    • Blogs

    • Career

    • About Us

    • Contact Us

    • Payment Options

  • Policies

    • Privacy Policy

    • Terms & Conditions

    • GST Input Tax Credit

    • Shipping Return Policy

    • E-Waste Collection Points

    • Our Sitemap

© Zbotic.in is registered trademark of Moxie Supply Pvt Ltd – All Rights Reserved
Login
Use Phone Number
Use Email Address
Not a member yet? Register Now
Reset Password
Use Phone Number
Use Email Address
Register
Already a member? Login Now