ESP8266 AT Command Examples Version 1.
! ! Espressif Systems ESP8266 AT Command Examples ! Disclaimer and Copyright Notice Information in this document, including URL references, is subject to change without notice. THIS DOCUMENT IS PROVIDED AS IS WITH NO WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY, NON-INFRINGEMENT, FITNESS FOR ANY PARTICULAR PURPOSE, OR ANY WARRANTY OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.
! ! Espressif Systems ESP8266 AT Command Examples ! Table of Contents 1. Preambles .................................................................................................. 4 2. Single Connection as TCP Client .............................................................. 5 3. UDP Transmission ...................................................................................... 7 4. 3.1. UDP (remote IP and port are fixed) .........................................................8 3.2.
! ! Espressif Systems ESP8266 AT Command Examples ! 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.
! ! Espressif Systems 2. • Single Connection as TCP Client Set WiFi mode: AT+CWMODE=3 Response :OK • // softAP+station mode Connect to router: AT+CWJAP="SSID", "password" Response :OK • // SSID and password of router Query device’s IP: AT+CIFSR Response :192.168.3.106 • ESP8266 AT Command Examples ! // Device got an IP from router. Connect PC to the same router that ESP8266 is connected to. Using a network tool on the computer to create a server.
! ! Espressif Systems ESP8266 AT Command Examples ! 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.
! ! Espressif Systems ESP8266 AT Command Examples ! 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 ”.
! ! 3.1. Espressif Systems ESP8266 AT Command Examples ! UDP (remote IP and port are fixed) 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.
! ! 3.2. • Espressif Systems ESP8266 AT Command Examples ! UDP (remote IP, port can be changed) Create a UDP transmission, last parameter is “2”. AT+CIPSTART="UDP", "192.168.101.110", 8080, 1112, 2 Response :CONNECT OK 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 if it’s not defined beforehand.
! ! Espressif Systems 4. ESP8266 AT Command Examples ! Transparent Transmission Transparent transmission is enabled only when ESP8266 is working as TCP client creating a single connection, or in UDP transmission. 4.1. TCP client single connection UART - WiFi passthrough 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.
! ! • Espressif Systems ESP8266 AT Command Examples ! Device connect to server: AT+CIPSTART="TCP", "192.168.101.110", 8080 Response :OK • // protocol server IP & port Linked Enable transparent transmission mode: AT+CIPMODE=1 Response :OK • Start sending data: AT+CIPSEND Response: > //From now on, transparent transmitted to server. data received from UART will be The network tool on PC will receive the data.
! ! 4.2. Espressif Systems ESP8266 AT Command Examples ! UDP transmission UART - WiFi passthrough 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 ”.
! ! Espressif Systems ESP8266 AT Command Examples ! Response: > //From now on, transparent transmitted to server. • data received from UART will be Stop sending data: 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.
! ! 5. Espressif Systems ESP8266 AT Command Examples ! Multiple Connection as TCP Server 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.
! ! Espressif Systems ESP8266 AT Command Examples ! 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.
! ! Espressif Systems ESP8266 AT Command Examples ! 6. Questions & Answers If you have any questions about the execution of AT instructions, please contact feedback@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.