0B-Beginner's Guide to ESP8266_V0.4.1 - Itead

Sep 17, 2014 - Query. A T+? Returns the current value of the parameter. Set. A T+= Set the value of user-defined parameters in commands and run ...
3MB taille 5 téléchargements 127 vues
ESP8266EX Beginner’s Guide

Espressif Systems

! ! ! ! !

AL

ESPRESSIF

TI

ESP8266EX:

EN

A BEGINNER’S GUIDE

FI D

!

N

!

C

!

O

!

! ! 1! | P a g e "

"

September 17, 2014

ESP8266EX Beginner’s Guide

Espressif Systems

! !

AL

!

TI

!

EN

!

FI D

!

N

!

C

!

O

!

! !

2! | P a g e "

"

September 17, 2014

ESP8266EX Beginner’s Guide

Espressif Systems

! ! Disclaimer and Copyright Notice

AL

Information in this document, including URL references, is subject to change without notice.

EN

TI

THIS DOCUMENT IS PROVIDED "AS IS" WITH NO WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY, NONINFRINGEMENT, FITNESS FOR ANY PARTICULAR PURPOSE, OR ANY WARRANTY OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE. All liability, including liability for infringement of any proprietary rights, relating to use of information in this document is disclaimed. No licenses express or implied, by estoppel or otherwise, to any intellectual property rights are granted herein. The Wi-Fi Alliance Member Logo is a trademark of the Wi-Fi Alliance.

FI D

All trade names, trademarks and registered trademarks mentioned in this document are property of their respective owners, and are hereby acknowledged. Copyright © 2013 Espressif Systems Inc. All rights reserved.

C

O

N

!

3! | P a g e "

"

September 17, 2014

ESP8266EX Beginner’s Guide

Espressif Systems

Table of Contents

!

EN

TI

AL

1. INTRODUCTION .....................................................................................................................................7 1.1. GENERAL OVERVIEW ...........................................................................................................................7 1.1.1. Features 9 1.1.2. Specifications .............................................................................................................................9 1.1.3. Applications 11 1.2. HARDWARE OVERVIEW .....................................................................................................................12 1.2.1. Pin Definition ...........................................................................................................................12 1.2.2. Electrical Characteristics ...........................................................................................................14 1.2.3. Power Consumption .................................................................................................................14 1.2.4. Package Footprint .....................................................................................................................15 1.2.5. Hardware Development Kit......................................................................................................16 1.2.6. ESP8266EX Modules (WROOM) ..............................................................................................18 1.3. APPLICATIONS USING ESP8266EX......................................................................................................20 1.3.1. UART Connector (as in Fig. 4 Demo Board) ............................................................................20 1.3.2. Sensor Application (as in Fig. 5 USB Sensor Demo) .................................................................20 1.3.3. Smart Light Application (as in Fig. 6 Smart Light Demo) ...........................................................21 1.3.4. Wi-Fi Smart Plug Application ....................................................................................................23

O

N

FI D

2. SOFTWARE FEATURES ............................................................................................................................24 2.1. WIRELESS NETWORKING ....................................................................................................................24 2.1.1. SoftAP Mode 24 2.1.2. Station Mode 25 2.1.3. SoftAP + Station Mode .............................................................................................................25 2.2. PASS-THROUGH CONNECTION...........................................................................................................26 2.3. UART FRAMES .................................................................................................................................26 2.4. ENCRYPTION ....................................................................................................................................27 2.5. LOW POWER OPERATION ..................................................................................................................28 2.6. FIRMWARE UPDATER .........................................................................................................................28

C

3. ESPRESSIF CLOUD SERVER.....................................................................................................................29 3.1. GUIDE TO USING ESPRESSIF CLOUD SERVER WEBSITE ............................................................................29 3.1.1. Device Development ...............................................................................................................31 3.1.2. Product Management ...............................................................................................................35 3.2. GUIDE TO USING ESP8266EX MODULES ............................................................................................36 3.2.1. Software Debugging Tools .......................................................................................................36 3.2.2. Network Connections ..............................................................................................................36 3.2.3. Default Connection Parameters ................................................................................................36 3.3. APPLICATION EXAMPLES.....................................................................................................................37 3.3.1. Wi-Fi Remote Control ...............................................................................................................37 3.3.2. Wi-Fi Remote Access ................................................................................................................37

4! | P a g e "

"

September 17, 2014

ESP8266EX Beginner’s Guide

Espressif Systems

3.3.3. Transparent Serial .....................................................................................................................38 4. AT INSTRUCTION SET ...........................................................................................................................39 4.1. OVERVIEW 39 4.2. BASIC AT INSTRUCTIONS ...................................................................................................................39 4.3. WI-FI INSTRUCTIONS ........................................................................................................................40 4.4. TCP/IP TOOLBOX .............................................................................................................................42 5. DEVELOPMENT KIT ................................................................................................................................48 5.1. COMPONENTS OF ESP8266EX DEVELOPMENT KIT ...............................................................................48 5.2. DOCUMENTATION LIST......................................................................................................................49

C

O

N

FI D

EN

TI

AL

APPENDIX: CONTACT DETAILS .................................................................................................................50

5! | P a g e "

"

September 17, 2014

ESP8266EX Beginner’s Guide

Espressif Systems

! ! !

C

O

N

FI D

EN

TI

AL

!

6! | P a g e "

"

September 17, 2014

ESP8266EX Beginner’s Guide

Espressif Systems

1. Introduction 1.1. General Overview

Analog transmit

AL

RF transmit

PMU



1/2

Crystal

Interface

Registers

SDIO

CPU

SPI

EN

VCO

Sequencers

GPIO

Accelerator

I2C

PLL

FI D

PLL

MAC

TI

Analog receive Digital baseband

RF receive Switch

RF balun

Espressif Systems’ Smart Connectivity Platform (ESCP) is a set of high performance, high integration wireless SOCs, designed for space and power constrained mobile platform designers. It provides unsurpassed ability to embed Wi-Fi capabilities within other systems, or to function as a standalone application, with the lowest cost, and minimal space requirement.

Bias circuits

SRAM

PMU

N

Figure 1: ESP8266EX Block Diagram

O

!

C

ESP8266EX offers a complete and self-contained Wi-Fi networking solution; it can be used to host the application or to offload Wi-Fi networking functions from another application processor. When ESP8266EX hosts the application, it boots up directly from an external flash. In has integrated cache to improve the performance of the system in such applications. Alternately, serving as a Wi-Fi adapter, wireless internet access can be added to any microcontroller-based design with simple connectivity (SPI/SDIO or I2C/UART interface). ESP8266EX is among the most integrated WiFi chip in the industry; it integrates the antenna switches, RF balun, power amplifier, low noise receive amplifier, filters, power

7! | P a g e "

"

September 17, 2014

ESP8266EX Beginner’s Guide

Espressif Systems

management modules, it requires minimal external circuitry, and the entire solution, including front-end module, is designed to occupy minimal PCB area. ESP8266EX also integrates an enhanced version of Tensilica’s L106 Diamond series 32-bit processor, with on-chip SRAM, besides the Wi-Fi functionalities. ESP8266EX is often integrated with external sensors and other application specific devices through its GPIOs; codes for such applications are provided in examples in the SDK.

AL

Sophisticated system-level features include fast sleep/wake context switching for energyefficient VoIP, adaptive radio biasing for low-power operation, advance signal processing, and spur cancellation and radio co-existence features for common cellular, Bluetooth, DDR, LVDS, LCD interference mitigation.

C

O

N

FI D

EN

TI

!

8! | P a g e "

"

September 17, 2014

ESP8266EX Beginner’s Guide

Espressif Systems

1.1.1. Features ▪ 802.11 b/g/n protocol ▪ Wi-Fi 2.4 GHz, support WPA/WPA2 ▪ Super small module size (11.5mm x 11.5mm) ▪ Integrated 10-bit ADC ▪ Integrated TCP/IP protocol stack

AL

▪ Integrated TR switch, balun, LNA, power amplifier and matching network ▪ Integrated PLL, regulators, and power management units ▪ +20dBm output power in 802.11b mode ▪ Supports antenna diversity

TI

▪ Deep sleep power ”Developer API

发者API”: API device control instructions

“Start

始”->”Help 帮助”: Example to help user setup their own products

AL

“Start

“Register 注册”: New user registration

FI D

EN

TI

“Login 登录”: Login if registered user



C

O

N

! !

! |Page" 29

"

September 17, 2014

ESP8266EX Beginner’s Guide

Espressif Systems

B. After logging in, click on “Device Development 设备开发”. User can edit the settings for all the devices. “Search 搜索”: Enter device name or device key to search for device “Export 导出”: Export the device list “Create 创建”: Create a new device

EN

TI

AL

!

FI D



! !

N

C. “Product Management 产品管理”shows the list of products. Use “Search 搜索”,

C

O

“Product 产品”, “Status 状态” to filter and query products.



! |Page" 30

"

September 17, 2014

ESP8266EX Beginner’s Guide

Espressif Systems

3.1.1. Device Development

In this menu, the user can view the device history, add timer, upgrade firmware and customize reverse control.

! 3.1.1.1. Device History On the device page -> “Data Model 数据模型” -> “Data 数据” to view device history.

FI D

EN

TI

AL

!

!

C

O

N

!

! |Page" 31

"

September 17, 2014

ESP8266EX Beginner’s Guide

Espressif Systems

3.1.1.2. Debugging Info

EN

TI

AL

“Request Log 请求⽇日志“ logs the commands received by the server and used to debug the device.

!

C

O

N

FI D

! !

! |Page" 32

"

September 17, 2014

ESP8266EX Beginner’s Guide

Espressif Systems

3.1.1.3. Timer Espressif Cloud server supports 3 kinds of timers: Precise timer 精

时间: Execute a command at a specified time

Cycle Timer 周期循环: Execute a command at fixed intervals Weekly Timer 按周循环: Execute a command at weekly or on certain days each week

O

C

! !

!

N

FI D

EN

TI

AL

!

! |Page" 33

"

September 17, 2014

ESP8266EX Beginner’s Guide

Espressif Systems

3.1.1.4. Customized Reverse Control User can customize an action to reverse control the device.

TI

AL

!

3.1.1.5. Firmware upgrade

EN

!

!

User update the firmware through Cloud Server

O

!

C

! !

N

FI D

!

! |Page" 34

"

September 17, 2014

ESP8266EX Beginner’s Guide

Espressif Systems

3.1.2. Product Management

Here, the user can control the sales of products and upload firmware updates.

FI D

EN

TI

AL

In the product list, the Activated/Total number shows how many products has been activated by the customers vs the total number of products made.

!

C

O

N

To upgrade a product’s firmware, simply upload it and Espressif Cloud Server will push the update to all devices. The user can choose to upgrade or not.

!

! |Page" 35

"

September 17, 2014

ESP8266EX Beginner’s Guide

Espressif Systems

3.2. Guide to using ESP8266EX modules 3.2.1. Software Debugging Tools

The following tools are recommended for debugging ESP8266EX modules. The user can also choose to use other similar tools. ▪ Flash programming tools: FLASH_DOWNLOAD_TOOLS.exe (provided in the SDK)

!

AL

▪ Serial Transfer tools: SecureCRTPortable.exe ▪ Network Debugging tools: NetAssist.exe

TI

3.2.2. Network Connections

▪ SoftAP interface:

EN

ESP8266EX has 2 types of network interface, softAP and station. Both can be used at the same time. Depending on the user’s actual requirements:

FI D

Mobile phone or PC acts as station, connects to ESP8266EX through softAP interface. PC can connect to ESP8266EX serial port for debugging info. ▪ Station interface:

!

N

ESP8266EX acts as station, connects to router (AP). PC can connect to ESP8266EX serial port for debugging info.

O

3.2.3. Default Connection Parameters

▪ Default SSID: ESP_XXXXXX

C

(XXXXXX are the last 6 characters of module’s MAC address)

▪ Default Encryption: WPA/WPA2 ▪ Default Serial Parameters: 74880, 8, 1, None ▪ Default Mode: SoftAP ▪ Default IP Address: 192.168.4.1


! |Page" 36

"

September 17, 2014

ESP8266EX Beginner’s Guide

Espressif Systems

3.3. Application Examples 3.3.1. Wi-Fi Remote Control

TI

AL

Example: Mobile phone acts as station, connects to ESP8266EX through softAP. ESP8266EX can connect to device via UART and mobile phone can now control the device.

! 3.3.2. Wi-Fi Remote Access

EN



FI D

Example: ESP8266EX acts as station, connects through router (AP) to internet. It can then upload or download data via Cloud server. Mobile phone/tablets etc can now control ESP8266EX via Cloud server.

N

Cloud server

C

O

Router

!

!

! |Page" 37

"

September 17, 2014

ESP8266EX Beginner’s Guide

Espressif Systems

3.3.3. Transparent Serial

AL

Example: Device’s MCU as host, connects and transmits data to ESP8266EX through UART. ESP8266EX then transmits via W-Fi destination address, working in pass-through mode.

EN

!

C

O

N

FI D

! !

TI

!

! |Page" 38

"

September 17, 2014

ESP8266EX Beginner’s Guide

Espressif Systems

4. AT Instruction Set 4.1. Overview Each instruction set contains four types of AT commands.

!

A T+=?

Query the Set command or internal parameters and its range values.

Query

A T+?

Returns the current value of the parameter.

Set

A T+=

Set the value of user-defined parameters in commands and run.

Execute

A T+

Runs commands with no user-defined parameters.

TI

!

AL

Test

FI D

EN

Note: 1. Not all AT instruction has four commands. 2. [] = default value, not required or may not appear 3. String values require double quotation marks, example AT +CWSAP=“ESP756190”,”21030826”,1,4 4. Baud rate = 115200

4.2. Basic AT Instructions

!

AT

Response

Test AT startup

OK

Restart module

OK

View version info

OK

O

AT+RST

Description

N

Command

C

AT+GMR

!

! |Page" 39

"

September 17, 2014

Reference

= 8-digit version no.

ESP8266EX Beginner’s Guide

Espressif Systems

4.3. Wi-Fi Instructions

! Command

Description

Response

AT+CWMODE

Select Wi-Fi application mode Test AT+CWMODE=?

+CWMODE:( value list) OK

EN

OK Set AT+CWMODE=

OK

Back to selected AP +CWJAP:

FI D

Query AT+CWJAP?

!

OK

Set AT +CWJAP=,

!!

OK

!

N

Lists available AP

Execute AT+CWLAP

Back to list of AP +CWLAP:,,

C

! !

OK ERROR

! |Page" 40

=string value, AP name =string value, max 64 ASCII chars

ERROR

O

AT+CWLAP

Set command requires reboot (AT+RST)

Back to current mode +CWMODE:

!

Join Ap

!

TI

Query AT+CWMODE?

1: Station 2:AP 3. Both

AL

!

AT+CWJAP

Reference

"

September 17, 2014

0: Open 1: WEP 2: WPA_PSK 3: WPA2_PSK 4: WPA_WPA2_PSK =string value, AP name =signal strength

!! !

ESP8266EX Beginner’s Guide

Espressif Systems

Command

Description

Response

AT+CWQAP

Disconnect from AP Test AT+CWQAP=?

OK

OK

AL

Execute AT+CWQAP

AT+ CWSAP

Reference

Set parameters under AP mode

Set command requires reboot

!

Back to current AP parameters +CWSAP=,, ,

EN !

ERROR

Check IP of connected device

Execute AT+CWLIF



N

!

OK

C

O

! !

OK

FI D

Set AT +CWSAP=,, ,

AT+ CWLIF

!

! |Page" 41

=string value, AP name =string value, max 64 ASCII chars =channel no. 0: Open 1: WEP 2: WPA_PSK 3: WPA2_PSK 4: WPA_WPA2_PSK

TI

Query AT+CWSAP?

"

September 17, 2014

=IP address of connected device

ESP8266EX Beginner’s Guide

Espressif Systems

4.4. TCP/IP Toolbox

! Description

AT+CIPSTATUS

Get connection status

Execute AT+CIPSTATUS

Response

Reference

Back to current connection mode and status +CIPSTATUS:,, ,,

=connected ID no. 0-4 =string value, conection type “TCP” or “UDP” =string value, IP address = port no. 0: Connect as client 1: Connect as server

! Establish TCP connection or register UDP ports

1. AT+CIPMUX=0 +CIPSTART:(value list),(range), (range) +CIPSTART:(value list),(range), (range)

FI D

Test AT+CIPSTART=?

EN

AT+CIPSTART

TI

OK

AL

Command

! !

OK

C

O

N

2. AT+CIPMUX=1 +CIPSTART:(id), (value list),(range), (range) +CIPSTART:(id), (value list), (range), (range)

!

OK

! |Page" 42

"

September 17, 2014

=connected ID no. 0-4 =string value, conection type “TCP” or “UDP” =string value, IP address of remote server = port no. of remote server

ESP8266EX Beginner’s Guide

Description

Response

Set 1. Single Connection (+CIPMUX=0) AT +CIPSTART=,,

!!

Reference

Syntax correct and connection successful, returns

! ! ! ! ! !!

OK else returns

2.

Multiple Connections (+CIPMUX=0) AT +CIPSTART=,, ,

ERROR

AL

Command

Espressif Systems

If connection already exists, returns

Send Data Test AT+CIPSTART=?

EN

AT+CIPSEND

TI

ALREADY CONNECT

OK

Wrap return “>” after set command. Begins receive of serial data, when data length is met, starts transmission of data.

FI D

Set 1. Single Connection (+CIPMUX=0) AT+CIPSEND=

!!

Multiple Connections (+CIPMUX=0) AT +CIPSEND=,

O

N

2.

If connection cannot be established or gets disconnected during send, returns

! ! ! !

ERROR If data is transmitted successfully, returns

C ! |Page" 43

!

SEND OK

"

September 17, 2014

= required ID no. of transmit connection =numeric value, size of transmit packet, maximum 2048 bytes

!

ESP8266EX Beginner’s Guide

Command

Espressif Systems

Description

Response

Execute AT+CIPSEND

Reference

Wrap return “>” after execute command. Enters pass-through mode, 20ms interval between each packet, maximum 2048 bytes per packet. When single packet containing “+++” is received, it returns to command mode.

AL

!

Command can only be used in pass-through mode and single connection mode.

EN

AT+CIPCLOSE

TI

!! ! Close TCP or UDP connection

OK

FI D

Test AT+CIPCLOSE=?

Set Multiply connection mode AT+CIPCLOSE=

No errors, returns OK

!

O

N

If connection is disconnected, returns LINK IS NOT

Execute Single connection mode AT+CIPCLOSE

No errors, returns OK

!

C

If no such connection, returns ERROR

! !

Prints UNLINK when there is no connection

! |Page" 44

"

September 17, 2014

= required ID no. of connection to close, when id=5, all connections will be closed. (id=5 has no effect in server mode)

ESP8266EX Beginner’s Guide

Espressif Systems

Command

Description

Response

AT+CIPSR

Get local IP address Test AT+CIPSR=?

: device’s current IP address (Station mode) OK

No effect under AP mode

+CIFSR:

! !! !! !! !! !!

EN

TI

OK ERROR

FI D

Start multiple connections

Query AT+CIPMUX?

+CIPMUX:

!

OK

Set AT+CIPMUX=

OK

N

!

O

If already connected, returns LINK IS BUILDED

!! !! !! !! !

C ! |Page" 45

"

! !! !! !! !! !! !! !

AL

Execute AT+CIPSR

AT+CIPMUX

Reference

September 17, 2014

0: Single Connection 1: Multiple Connection

!

Mode can only be changed after all connections are disconnected. If server is started, reboot is required.

ESP8266EX Beginner’s Guide

Espressif Systems

Command

Description

AT+ CIPSERVER

Configure as server Set AT +CIPSERVER=[,< port>]

Response

Reference

OK

0: Server mode OFF 1: Server mode ON : port number, default value=333

!

Server has to be restarted

AL

!

Server monitor will automatically be created when Server mode ON.

!

N

FI D

EN

TI

When a client is connected to the server, it will take up one connection. Server can only be turned ON when AT +CIPMUX=1

Set module transfer mode

O

AT+ CIPMODE

C

Query AT+CIPMODE?

0: No-passthrough 2: Passthrough +CIPMODE:

!

OK Set AT+CIPMODE=

OK

!

If already connected, returns LINK IS BUILDED

! |Page" 46

"

!! !! !! !! !

September 17, 2014

ESP8266EX Beginner’s Guide

Espressif Systems

Command

Description

Response

AT+CIPSTO

Set server timeout Query AT+CIPSTO?

Reference

+CIPSTO: