We will be having Diwali Festival holidays from 18th October to 24th October. Any orders placed during that time will ship from 25th October onwards. Good Wishes for a joyous Diwali and a Happy New Year with plenty of Peace and Prosperity.
SUNROM ELECTRONICS
Back to WiFi (3)

WiFi Module - ESP8266 - IPEX - ESP-07

Easily create IOT WiFi applications. On board Ceramic antenna and IPX connector for optional external antenna.

Sunrom Part# 4255

Available We dispatch same day if ordered by 4PM (excluding holidays), then courier usually takes 2-5 days.
Real Time Availability
Ready Stock: 14 nos.
Factory Leadtime for more quantity: 15 days
Quantity Pricing
Quantity :
Price (Discount%)
1-4 :
Rs.518/- (0%)
5-9 :
Rs.502/- (3%)
10-24 :
Rs.482/- (7%)
25-49 :
Rs.466/- (10%)
50-74 :
Rs.456/- (12%)
75-99 :
Rs.440/- (15%)
100-249 :
Rs.425/- (18%)
250-499 :
Rs.414/- (20%)
500-999 :
Rs.404/- (22%)
1000+ :
Rs.389/- (25%)

Downloads

Terminal-PC

This is ultra low cost module that is easy to use and reliable based on ESP8266 chipset to be used along with a microcontroller that configures and communicates through AT commands.

Till now embedded WiFi solutions was a bit pricey to implement for hobbyist. This module is changing the trend rapidly. It gives excellent working range and opening wide array of applications.

Applications

  • Internet of Things (IoT)
  • Wireless Remote Control
  • Wireless Sensor Networks
  • Web Server / Client
  • Wireless UART

Features

  • Built in Client-Server Mode
  • 400 Meters Working Distance
  • On Board 2.4 Ghz Ceramic Antenna
  • IPX Connector for optional external antenna
  • Metal Shielding

Resources

Interfacing to MCU/PC

Various Ways to Interface module with Systems operating at 3V and 5V.

 

Module Dimensions & Pinouts

We are now shipping V2 of module

Schematic of module's internal. Interfacing can simply by RX-TX-VCC-GND to external MCU.

Application: Access Weather Data from Internet

Let us see an application for the module. We will interface it to Arduino UNO.

We will use Arduino to use two UART for serial data 1) Goes to module 2) Debug for us to view by CP2102 to PC

For that we have to give module the Wifi details to connect to internet, Then tell it to go to weather website.

We will access the weather data on //openweathermap.org/current by City ID

The URL for weather ID is 

//api.openweathermap.org/data/2.5/weather?id=2172797

The same URL with IP address is 

188.226.224.148/data/2.5/weather?id=2172797

Which gives below data in JSON format

{"coord":{"lon":145.77,"lat":-16.92},"sys":{"message":0.0031,"country":"AU","sunrise":1419795905,"sunset":1419843172},"weather":[{"id":800,"main":"Clear","description":"Sky is Clear","icon":"01n"}],"base":"cmc stations","main":{"temp":299.599,"temp_min":299.599,"temp_max":299.599,"pressure":1004.41,"sea_level":1021.87,"grnd_level":1004.41,"humidity":100},"wind":{"speed":2.32,"deg":83.0022},"clouds":{"all":0},"dt":1419852016,"id":2172797,"name":"Cairns","cod":200}

Arduino Code #snippet:14

#include <SoftwareSerial.h>
#include  <JsonParser.h>
  
using namespace ArduinoJson::Parser;
 
#define SSID "" // insert your Wifi's SSID
#define PASS "" // insert your Wifi's password

#define DST_IP "188.226.224.148" //api.openweathermap.org 's IP Address
#define LOCATIONID "2925533" // Weather City ID

SoftwareSerial dbgSerial(2, 3); // RX, TX for debugging
JsonParser<32> parser;
 
void setup()
{
  Serial.begin(9600); // for module
  Serial.setTimeout(5000);
  dbgSerial.begin(9600); // for debuging
  dbgSerial.println("Init");

  Serial.println("AT+RST"); // restet and test if module is redy
  delay(1000);
  if(Serial.find("ready")) {
    dbgSerial.println("WiFi - Module is ready");
  }else{
    dbgSerial.println("Module didnt respond. Please reset.");
    while(1);
  }
  delay(1000);
  // try to connect to wifi
  boolean connected=false;
  for(int i=0;i<5;i++){
    if(connectWiFi()){
      connected = true;
      dbgSerial.println("Connected to WiFi...");
      break;
    }
  }
  if (!connected){
    dbgSerial.println("Coudn't connect to WiFi.");
    while(1);
  }
  delay(5000);
  Serial.println("AT+CIPMUX=0"); // set to single connection mode
}
void loop()
{
  String cmd = "AT+CIPSTART=\"TCP\",\"";
  cmd += DST_IP;
  cmd += "\",80";
  Serial.println(cmd);
  dbgSerial.println(cmd);
  if(Serial.find("Error")) return;
  cmd = "GET /data/2.5/weather?id=";
  cmd += LOCATIONID;
  cmd += " HTTP/1.0\r\nHost: api.openweathermap.org\r\n\r\n";
  Serial.print("AT+CIPSEND=");
  Serial.println(cmd.length());
  if(Serial.find(">")){
    dbgSerial.print(">");
  }else{
    Serial.println("AT+CIPCLOSE");
    dbgSerial.println("connection timeout");
    delay(1000);
    return;
  }
  Serial.print(cmd);
  unsigned int i = 0; //timeout counter
  int n = 1; // char counter
  char json[100]="{";
  while (!Serial.find("\"main\":{")){} // find the part we are interested in.
  while (i<60000) {
    if(Serial.available()) {
      char c = Serial.read();
      json[n]=c;
      if(c=='}') break;
      n++;
      i=0;
    }
    i++;
  }
  dbgSerial.println(json);
  JsonObject root = parser.parse(json);
  double temp = root["temp"];
  double pressure = root["pressure"];
  double humidity = root["humidity"];
  temp -= 273.15; // from kelvin to degree celsius

  dbgSerial.println(temp);
  dbgSerial.println(pressure);
  dbgSerial.println(humidity);
  dbgSerial.println("====");
  delay(600000);
}
 
boolean connectWiFi()
{
  Serial.println("AT+CWMODE=1");
  String cmd="AT+CWJAP=\"";
  cmd+=SSID;
  cmd+="\",\"";
  cmd+=PASS;
  cmd+="\"";
  dbgSerial.println(cmd);
  Serial.println(cmd);
  delay(2000);
  if(Serial.find("OK")){
    dbgSerial.println("OK, Connected to WiFi.");
    return true;
  }else{
    dbgSerial.println("Can not connect to the WiFi.");
    return false;
  }
}

Application: Create Webserver

#snippet:14

Let us see an application for the module. We will interface it to Arduino UNO.

We will use Arduino to use two UART for serial data 1) Goes to module 2) Debug for us to view by CP2102 to PC

We will use browser to access the website served by arduino and control a LED

//UNO & M328P
#include <SoftwareSerial.h>
SoftwareSerial dbgTerminal(10, 11); // RX, TX
HardwareSerial & espSerial = Serial;

//Leonardo
//Serial_ & dbgTerminal = Serial;
//HardwareSerial & espSerial = Serial1;

////MEGA2560 
//HardwareSerial & dbgTerminal = Serial;
//HardwareSerial & espSerial = Serial1;

// set pin numbers:
const int ledPin =  13;      // the number of the LED pin
const int ESP8266_CHPD = 4;

// Variables will change:
int ledState = HIGH;             // ledState used to set the LED, Control it by Browser

#define BUFFER_SIZE 128
char buffer[BUFFER_SIZE];

void setup() { 
  pinMode(ledPin, OUTPUT);  
  //pinMode(ESP8266_CHPD, OUTPUT);
      
  dbgTerminal.begin(9600); // Serial monitor
  espSerial.begin(9600); // ESP8266
    
  //while (!dbgTerminal) {
   // ; // wait for serial port to connect. Needed for Leonardo only
  //}

  dbgTerminal.println(F("ESP8266 demo."));

  //hardReset();
  //delay(2000);
  
  clearSerialBuffer();
  
  //connect to router
  //connectWiFi("YOUR_SSID", "YOUR_PASSWORD");
  
  //test if the module is ready
  //dbgTerminal.print("AT : ");
  //dbgTerminal.println( GetResponse("AT",100) );
    
  //Change to mode 1
  //dbgTerminal.print("AT+CWMODE=1 : ");
  //dbgTerminal.println( GetResponse("AT+CWMODE=1",10) );
        
  //set the multiple connection mode
  dbgTerminal.print(F("AT+CIPMUX=1 : "));
  dbgTerminal.println( GetResponse("AT+CIPMUX=1",10) );
  
  //set the server of port 80 check "no change" or "OK"
  dbgTerminal.print(F("AT+CIPSERVER=1,8888 : "));
  dbgTerminal.println( GetResponse("AT+CIPSERVER=1,8888", 10) );
 
  //set time out
  //dbgTerminal.print("AT+CIPSTO=15 : ");
  //dbgTerminal.println( GetResponse("AT+CIPSTO=15",10) );
  
   //print the ip addr
  dbgTerminal.print(F("ip address : "));
  dbgTerminal.println( GetResponse("AT+CIFSR", 10) );
  delay(200);

   
  dbgTerminal.println();
  dbgTerminal.println(F("Start Webserver"));

  digitalWrite(ledPin,ledState);  
}

void loop() {
  int ch_id, packet_len;
  char *pb;  
  espSerial.readBytesUntil('\n', buffer, BUFFER_SIZE);
  
  if(strncmp(buffer, "+IPD,", 5)==0) {
    // request: +IPD,ch,len:data
    sscanf(buffer+5, "%d,%d", &ch_id, &packet_len);
    if (packet_len > 0) {
      // read serial until packet_len character received
      // start from :
      pb = buffer+5;
      while(*pb!=':') pb++;
      pb++;
      if (strncmp(pb, "GET /led", 8) == 0) {
        dbgTerminal.print(millis());
        dbgTerminal.print(" : ");
        dbgTerminal.println(buffer);
        dbgTerminal.print( "get led from ch :" );
        dbgTerminal.println(ch_id);
 
        delay(100);
        clearSerialBuffer();
        
       if (ledState == LOW)
          ledState = HIGH;
       else
          ledState = LOW;
        digitalWrite(ledPin, ledState);
        
        homepage(ch_id);

      } else if (strncmp(pb, "GET / ", 6) == 0) {
        dbgTerminal.print(millis());
        dbgTerminal.print(" : ");
        dbgTerminal.println(buffer);
        dbgTerminal.print( "get Status from ch:" );
        dbgTerminal.println(ch_id);
        
        delay(100);
        clearSerialBuffer();

        homepage(ch_id);
      }
    }
  }
  clearBuffer();
}

void homepage(int ch_id) {
  String Header;

  Header =  "HTTP/1.1 200 OK\r\n";
  Header += "Content-Type: text/html\r\n";
  Header += "Connection: close\r\n";  
  //Header += "Refresh: 5\r\n";
  
  String Content;
  Content = "D";
  Content += String(ledState);
  
  Header += "Content-Length: ";
  Header += (int)(Content.length());
  Header += "\r\n\r\n";
  
  
  espSerial.print("AT+CIPSEND=");
  espSerial.print(ch_id);
  espSerial.print(",");
  espSerial.println(Header.length()+Content.length());
  delay(10);
  
  // for debug buffer serial error
  //while (espSerial.available() >0 )  {
  //  char c = espSerial.read();
  //  dbgTerminal.write(c);
  //  if (c == '>') {
  //      espSerial.print(Header);
  //      espSerial.print(Content);
  //  }
  //}
  
  if (espSerial.find(">")) {
      espSerial.print(Header);
      espSerial.print(Content);
      delay(10);
   }
 
//  Serial1.print("AT+CIPCLOSE=");
//  Serial1.println(ch_id);


}



// Get the data from the WiFi module and send it to the debug serial port
String GetResponse(String AT_Command, int wait){
  String tmpData;
  
  espSerial.println(AT_Command);
  delay(10);
  while (espSerial.available() >0 )  {
    char c = espSerial.read();
    tmpData += c;
    
    if ( tmpData.indexOf(AT_Command) > -1 )         
      tmpData = "";
    else
      tmpData.trim();       
          
   }
   return tmpData;
}

boolean hardReset() {
  String tmpData;
  
  digitalWrite(ESP8266_CHPD,LOW);
  delay(100);
  digitalWrite(ESP8266_CHPD,HIGH);
  delay(1000);
    
  while ( espSerial.available() > 0 ) {
    char c = espSerial.read();
    tmpData +=c;
    espSerial.write(c);
    if ( tmpData.indexOf("Ready") > -1 ) {
      //Serial.println("Ready");
        clearBuffer();
        return 1;
    } 
  }
}

void clearSerialBuffer(void) {
       while ( espSerial.available() > 0 ) {
         espSerial.read();
       }
}

void clearBuffer(void) {
       for (int i =0;i<BUFFER_SIZE;i++ ) {
         buffer[i]=0;
       }
}
         
boolean connectWiFi(String NetworkSSID,String NetworkPASS) {
  String cmd = "AT+CWJAP=\"";
  cmd += NetworkSSID;
  cmd += "\",\"";
  cmd += NetworkPASS;
  cmd += "\"";
  
  dbgTerminal.println(cmd); 
  dbgTerminal.println(GetResponse(cmd,10));
}

Bestselling Products

Sunrom Electronics & Sunrom Technologies are two companies, that are the foremost online e-commerce stores since 2004, providing innovative embedded systems, components & services. Our aim is to empower you to Make In India. We work closely with electronics manufacturing companies & individuals to understand & solve the challenges faced during production. We do not just sell things, We use them ourselves in our products, and provide you with high quality tested components for trouble free experience.

Sunrom Electronics GSTIN: 24AFBPT4632H1ZJ
Handles Online Payment by CCAvenue
Sunrom Technologies GSTIN: 24AJLPP4029L1ZW
Handles Offline Bank Payments / NEFT / P.O. / Telr