KS0339 Keyestudio 8266 WIFI Module 2PCS

From Keyestudio Wiki
Jump to navigation Jump to search
keyestudio 8266 WIFI Module (2PCS)


Product Overview

Overview:

The package includes 2pcs of ESP8266 WIFI module.
It is an ultra-low-power UART-WiFi pass-through module with industry-leading package size and ultra-low power technology.
It is specially designed for mobile devices and IoT applications. It can connect users' physical devices to Wi-Fi wireless network for Internet or LAN communication, achieving the networking function.


Features:

  • 1)Support wireless 802.11 b/g/n standard
  • 2)Support three working modes: STA/AP/STA+AP
  • 3)Built-in TCP/IP protocol stack to support multiple TCP Client connections
  • 4)Support various Socket AT commands
  • 5)Support UART/GPIO data communication interface
  • 6)Support Smart Link intelligent networking function
  • 7)Support remote firmware upgrade (OTA)
  • 8)Built-in 32-bit MCU, able to double as an application processor
  • 9)Ultra low consumption, suitable for battery powered applications.
  • 10) 3.3V single power supply


Basic Parameters:


0339图片2.png

0339图片3.png


Hardware Introduction:

ESP8266 hardware has plentiful interfaces, and can support UART,IIC,PWM,GPIO,ADC and more, suited for mobile devices and IoT applications.

  • Module pins diagram:


0339图片4.png


  • Pins definition:


0339图片5.png


Power Consumption:

The following measured power consumption data is based on a 3.3V power supply at 25°ambient temperature.

  • 1. All measurements are done at the antenna interface.
  • 2. All transmit data is based on a 90% duty cycle and measured in continuous transmission mode.


0339图片6.png


Radio Frequency Indicator:

The following data are measured at indoor temperature when the voltage is 3.3v.
0339图片7.png

Note: 1. 72.2Mbps is measured in 802.11n mode,MCS=7,GI=200uS.
2.The output power of up to +19.5dBm can be reached in 802.11b mode.


Function Description

Main Function:

ESP8266 can realize the main functions as follows:

  • Serial port passthrough: data transmission, good reliability of transfer; the maximum transmission rate is up to 460800bps.
  • PWM regulation and control: light adjustment, RGB LED adjustment, motor speed control and more.
  • GPIO control: control the switches, relays and more.


Working Mode:

ESP8266 module supports three working modes: STA/AP/STA+AP

  • STA mode: The ESP8266 module can access to the Internet through a router, so the mobile phone or computer can remotely control the device through the Internet.
  • AP mode: The ESP8266 module acts as a hotspot to enable communication directly with the mobile phone or computer to achieve wireless control of the local area network (LAN).
  • STA+AP mode: The coexistence mode of the above two modes, that is, can achieve the seamless switching through the Internet control, more convenient for operation.


Applications:

  • 1)Serial port CH340 to Wi-Fi;
  • 2)Industrial transparent transmission DTU;
  • 3)Wi-Fi remote monitoring/control;
  • 4)Toy field
  • 5)Color LED control;
  • 6)Integrated management of fire protection and security intelligence;
  • 7)Smart card terminals, wireless POS machines, Wi-Fi cameras, handheld devices, etc



Example Use


Use Uno R3 and ESP-01 as server

Tools

(1)Prepare the hardware components as follows:

  • Computer *1;
  • UNO R3 development board*1;
  • Esp-01 module *1;
  • Square USB cable *1
  • 2-cell 18650 lithium battery case with batteries *1

(2)Software: using arduino IDE


Connection

Connect Uno R3 to ESP-01 module:
0339图片.png


Test Code

#include <SoftwareSerial.h>
SoftwareSerial mySerial(2, 3); // RX, TX
char OK[2]="";

//////////////////////////////////////////////////////////////////////////
void OK_config()
{  
 while(1)
  {
   OK[0]=mySerial.read();
   if(OK[0]=='O')
     {
      OK[1]=mySerial.read();
      if(OK[1]=='K')
        {
        break;
        }
     }
   delay(20);
   }  
}
//////////////////////////////////////////////////////////////////////////
void esp8266_config()
{
  Serial.println("AT+RST");   
  delay(1000);
  mySerial.println("AT+CWMODE_DEF=3");   //set the current Wi-Fi mode and save to Flash
  OK_config();
  mySerial.println("AT+CWSAP=\"KEYES_server\",\"123456789\",11,2");
  OK_config();
  mySerial.println("AT+CIPMUX=1");       //multiple connection   default port=333
  OK_config();
  mySerial.println("AT+CIPSERVER=1");    //build TCP Server
  OK_config();
  Serial.println("Initialize the server!");
  digitalWrite(13,HIGH);
  OK_config();                          //wait Client to send OK; access to Client
}
///////////////////////////////////////////////////////////////////////
void setup() 
{ 
  Serial.begin(115200);
  mySerial.begin(115200);
  pinMode(13,OUTPUT);
  digitalWrite(13,LOW);
  esp8266_config();
}
void loop()
{
 mySerial.println("AT+CIPSEND=0,9"); 
 delay(1000);
 mySerial.println("arduino"); 
 digitalWrite(13,LOW);
 delay(1000);
 digitalWrite(13,HIGH);
 delay(1000);
}


Note: The code USES the AT instruction of esp-01 to realize the required functions. Please refer to the specific AT instructions mentioned below.


Use and Result

  • A、connect the UNO R3 main board to the computer via USB port with a square USB cable; then open the arduino IDE to upload the test code to UNO R3.
  • B、Unplug the USB cable; connect the esp-01 module to UNO R3 main board using jumper wires according to the connection diagram.
  • C、supply the power to UNO R3 main board via black DC power jack with 2-cell 18650 batteries; wait for a few seconds, LED labeled L on the UNO R3 will normally turn on. Otherwise, pull out the power cable and repower again.


Set ESP-01 as Client and connect server

Tools

(1)Prepare the hardware components as follows:

  • Computer *1;
  • TTL USB to serial port module *1;
  • Esp-01 module *1;
  • Mini USB cable *1

(2)Software: using esp8266 debugging tool


Connection

Connect ESP-01 module to TTL USB-to-serial port module:
0339图片-2.png


Detailed debugging

  • A、Follow the connection diagram to connect ESP-01 module to TTL USB-to-serial port module;
  • B、Connect the TTL USB-to-serial port module to the computer using a mini USB cable.

SPECIAL NOTE: need to program the corresponding drive to the TTL USB-to-serial port module before use.

  • C、Open the esp8266 debug tool, select the proper USB port and set the baud rate to 115200; then open the serial port. As shown below.

0339图片-3.png

  • D、AT+CWMODE=3 set the ESP-01 module as mode 3:

0339图片-4.png

Special attention:

  • 1 : To fill in the instruction, a newline character should be added after the instruction is typed, as shown in the figure above. All subsequent instructions should be operated in this way.
  • 2 : To send instructions to esp-01.
  • 3 : The information returned after the instruction is received by esp-01.
  • E、AT+CWJAP="KEYES_server","123456789" connect to server ESP-01 WIFI:

0339图片-5.png

  • F、AT+CIPAP_CUR="192.168.1.20","192.168.1.20" modify the IP of client ESP-01 AP; modifying the IP of AP is to avoid the conflict between client AP’s IP and server AP’s IP. As figure shown below.

0339图片-6.png

  • G、AT+CIPSTART="TCP","192.168.4.1",333 connect to server ESP-01, as shown below.


0339图片-7.png

  • H、Send the AT+CIPMODE=1 command to set the client ESP-01 as pass-through mode. As shown below.


0339图片-8.png

  • I、Send the AT+CIPSEND command means the client ESP-01 send the data instruction to the server ESP-01. As shown below.


0339图片-9.png

  • J、client ESP-01 sends the “OK” character to server ESP-01; trigger the server ESP-01 to send the “arduino” character to client ESP-01 all the time. As figure shown below.


0339图片-10.png

  • K、At this moment, the LED labeled L on the UNO R3 main board connected to server ESP-01 will turn on normally, which illustrates it always send the data to client ESP-01.



Basic AT Commands

Test the AT

  • Syntax Rules:

thumb


WiFi Function AT Command

Select WiFi Application Mode: AT+CWMODE

  • Syntax Rules:

thumb


  • Parameter Definition: