4B-ESP8266 at Command Examples en v1.3
4B-ESP8266 at Command Examples en v1.3
Version 1.3
Espressif Systems IOT Team
Copyright 2015
Espressif Systems
2 /16
Espressif Systems
Table of Contents
1.
Preambles .................................................................................................. 4
2.
3.
4.
3.1.
3.2.
Transparent Transmission........................................................................ 10
4.1.
4.2.
5.
6.
3 /16
Espressif Systems
1.
Preambles
Herein we introduces some specific examples on the usage of Espressif AT Commands. For more
information about the complete instruction set, please refer to documentation 4A-ESP8266__AT
Instruction Set .
(1)
Flash in AT bin files which supports AT commands (/esp_iot_sdk/bin/at) into the ESP8266
device, according to readme.txt there.
(2)
Power on device and set serial baud rate to 115200. Enter AT commands.
Note: Please pay attention to the new line mode, AT command need /r/n to be the end.
4 /16
Espressif Systems
2.
// softAP+station mode
Connect to router:
AT+CWJAP="SSID", "password"
Response :OK
Send data:
AT+CIPSEND=4
>DGFY
// enter the data,
Response :SEND OK
such as 4 bytes
no CR
Note: If the number of bytes sent is bigger than the size defined (n), will reply busy, and after
sending n number of bytes, reply SEND OK.
5 /16
Espressif Systems
Receive data:
+IPD, n: xxxxxxxxxx
// received n bytes,
6 /16
data=xxxxxxxxxxx
Espressif Systems
3.
UDP Transmission
UDP transmission is established via AT+CIPSTART. There is no such definition as UDP server or UDP
client. For more information about AT commands, please refer to documentation 4A-ESP8266__AT
Instruction Set .
// softAP+station mode
Connect to router:
AT+CWJAP="SSID", "password"
Response :OK
7 /16
3.1.
Espressif Systems
In UDP transmission, whether remote IP and port is fixed or not is decided by the last parameter of
AT+CIPSTART. 0 means that the remote IP and port is fixed and cannot be changed. A specific ID
is given to such connection, making sure that the data sender and receiver will not be replaced by
other devices.
Note :
"192.168.101.110", 8080 here is the remote IP and port of UDP transmission of the opposite side,
1112 is the local port of ESP8266. User can self-define this port. The value of this port will be random
0 means that remote IP and port is fixed and cannot be changed. For example, if another PC also
creates a UDP entity and sends data to ESP8266 port 1112. ESP8266 can receive data sent from
UDP port 1112, but when data is sent using AT command AT+CIPSEND=4, X, it will still be sent to
the first PC end. If this parameter is not 0, it will send to a new PC.
Send data:
AT+CIPSEND=4, 5
// Send 5 bytes to transmission NO.4
>DGFYQ
// enter the data, no CR
Response :SEND OK
Note:
If the number of bytes sent is bigger than the size defined (n), will reply busy, and after sending n
number of bytes, reply SEND OK.
Receive data:
+IPD, 4, n: xxxxxxxxxx
// received n bytes,
data=xxxxxxxxxxx
OK
8 /16
3.2.
Espressif Systems
Note :
"192.168.101.110", 8080 here refer to the remote IP and port of UDP transmission terminal which
is created on PC in step 4;
1112 is the local port of ESP8266. User can self-define this port. The value of this port will be random
2 means the opposite terminal of UDP transmission side will change to be the latest one that has
Send data:
AT+CIPSEND=5
// Send 5 bytes
>DGFYQ
// enter the data,
Response :SEND OK
no CR
Note:
If the number of bytes sent is bigger than the size defined (n), will reply busy, and after sending n
number of bytes, reply SEND OK.
If you want to send data to any other UDP terminals, please set the IP and port of this terminal.
AT+CIPSEND=6, 192.168.101.111, 1000
>abcdef
// enter the data,
Response :SEND OK
no CR
Receive data:
+IPD, n: xxxxxxxxxx
// Send 6 bytes
// received n bytes,
data=xxxxxxxxxxx
OK
9 /16
Espressif Systems
4.
Transparent Transmission
Transparent transmission is enabled only when ESP8266 is working as TCP client creating a single
connection, or in UDP transmission.
4.1.
Here is an example that ESP8266 station as TCP client to create a single connection and execute
transparent transmission. For ESP8266 soft-AP, it can execute transparent transmission in the similar
way. For more information about AT commands, please refer to documentation 4A-ESP8266__AT
Instruction Set .
// softAP+station mode
Connect to router:
AT+CWJAP="SSID", "password"
Response :OK
10/16
Espressif Systems
If received a packet of data that contains only +++, then the transparent transmission process will
be stopped. Please wait at least 1 second before sending next AT command.
Please be noted that if you input +++ directly by typing, the +++, may not be recognised as three
consecutive + because of the Prolonged time when typing.
Note:
The aim of ending +++ is to exit transparent transmission and turn back to accept normal AT
command, while TCP still remains connected. However, we can also use command AT+CIPSEND to
turn back into transparent transmission.
OK
11/16
4.2.
Espressif Systems
Here is an example that ESP8266 soft-AP create a UDP transparent transmission. For ESP8266
station, it can execute UDP transparent transmission in the similar way. For more information about
AT commands, please refer to documentation 4A-ESP8266__AT Instruction Set .
// softAP+station mode
Device create a UDP transmission which remote IP and port are fixed.
AT+CIPSTART="UDP","192.168.4.2",1001,2233,0
Response :OK
12/16
Espressif Systems
Response: >
//From now on,
transparent transmitted to server.
If a packet of data that contains only +++, then the transparent transmission process will be
stopped. Please wait at least 1 second before sending next AT command.
Please be noted that if you input +++ directly by typing, the +++, may not be recognised as three
consecutive + because of the Prolonged time when typing.
Note:
The aim of ending +++ is to exit transparent transmission and turn back to accept normal AT
command, while UDP transmission still exists. However, we can also use command AT+CIPSEND to
turn back into transparent transmission.
OK
13/16
5.
Espressif Systems
When ESP8266 is working as a TCP server, a multiple of connections shall be maintained. That is to
say, there should be more than one client connecting to ESP8266.
Here is an example showing how TCP server is realized when ESP8266 is working in softAP mode:
// softAP+station mode
Setup server:
AT+CIPSERVER=1
Response :OK
14/16
Espressif Systems
Note:
When ESP8266 is working as a TCP server, there exists a timeout mechanism. If the TCP client is
connected to the ESP8266 TCP server, whereas there is no data transmission for a period of time,
then the server will stop the connection with the client. To avoid such problems, please set up a data
transmission circulation every 5 seconds.
Send data:
// ID number of connection is defaulted to be 0.
AT+CIPSEND=0, 4
// send 4 bytes to connection NO.0
>iopd
no CR
Response :SEND OK
Note:
If the number of bytes sent is bigger than the size defined (n), will reply busy, and after sending n
number of bytes, reply SEND OK.
Receive data:
+IPD, 0, n: xxxxxxxxxx
// received n bytes,
data = xxxxxxxxxx
15/16
Espressif Systems
6.
If you have any questions about the execution of AT instructions, please contact supportat@espressif.com. Please describe the issues that you encountered with information as follows:
Version info or AT Command: You can use command AT+GMR to acquire your current AT
command version info.
ets Jan
load 0x40100000,
len 26336,
tail 0
chksum 0xde
load 0x3ffe8000,
len 5672,
room 8
len 8348,
room 8
tail 0
chksum 0x69
load 0x3ffe9630,
tail 4
chksum 0xcb
csum 0xcb
SDK version: 0.9.1
addr not ack when tx write cmd
16/16