Wi-Fi AT Commands

XXXX

AT+CWMODE:

Set the Wi-Fi mode (Station/SoftAP/Station+SoftAP).

AT+CWSTATE :

Query the Wi-Fi state and Wi-Fi information.

AT+CWJAP :

Connect to an AP.

AT+CWRECONNCFG :

Query/Set the Wi-Fi reconnecting configuration.

AT+CWLAPOPT :

Set the configuration for the command AT+CWLAP .

AT+CWLAP :

List available APs.

AT+CWQAP :

Disconnect from an AP.

AT+CWSAP :

Query/Set the configuration of an ESP SoftAP.

AT+CWLIF

: Obtain IP address of the station that connects to an ESP SoftAP.

AT+CWQIF

: Disconnect stations from an ESP SoftAP.

AT+CWDHCP

: Enable/disable DHCP.

AT+CWDHCPS

: Query/Set the IP addresses allocated by an ESP SoftAP DHCP server.

AT+CWAUTOCONN

: Connect to an AP automatically when powered on.

AT+CWAPPROTO

: Query/Set the 802.11 b/g/n protocol standard of SoftAP mode.

AT+CWSTAPROTO

: Query/Set the 802.11 b/g/n protocol standard of station mode.

AT+CIPSTAMAC

: Query/Set the MAC address of an ESP station.

AT+CIPAPMAC

: Query/Set the MAC address of an ESP SoftAP.

AT+CIPSTA

: Query/Set the IP address of an ESP station.

AT+CIPAP

: Query/Set the IP address of an ESP SoftAP.

AT+CWSTARTSMART

: Start SmartConfig.

AT+CWSTOPSMART

: Stop SmartConfig.

AT+WPS

: Enable the WPS function.

AT+MDNS

: Configure the mDNS function.

[ESP32 Only]AT+CWJEAP

: Connect to a WPA2 Enterprise AP.

AT+CWHOSTNAME

: Query/Set the host name of an ESP station.

AT+CWCOUNTRY

: Query/Set the Wi-Fi Country Code.




AT+CWMODE : Query/Set the Wi-Fi Mode (Station/SoftAP/Station+SoftAP) YY

Query Command YYY

Function:

Query the Wi-Fi mode of ESP devices.

Command:

AT+CWMODE?

Response:

CWMODE: <mode >

OK

Set Command YYY

Function:

Set the Wi-Fi mode of ESP devices.

Command:

AT+CWMODE <mode> [, < auto_connect > ]

Response:

OK

Parameters

Note XXX

Example exmpl

AT+CWMODE=3

AT+CWSTATE : Query the Wi-Fi state and Wi-Fi information at-cwstate-qurey-wifi-state

Query Command id1

Function:

Query the Wi-Fi state and Wi-Fi information of ESP devices.

Command:

AT+CWSTATE?

Response:

+CWSTATE:<state>,<"ssid">

OK

Parameters id2

Note ID3

AT+CWJAP to query Wi-Fi information.


AT+CWJAP : Connect to an AP at-cwjap-conn-to-ap

Query Command id4

Function:

Query the AP to which the ESP Station is already connected.

Command:

 
AT+CWJAP?  

Response:

+CWJAP:<ssid>,<bssid>,<channel>,<rssi>,<pci_en >,<reconn_interval>,<listen_interval>,<scan_mode>,<pmf>

OK

Set Command id5

Function:

Connect an ESP station to a targeted AP.

Command:

AT+CWJAP=[<ssid>],[<pwd>][,<bssid>][,<pci_en >][,<reconn_interval>][,<listen_interval>][,<scan_mode>][,<jap_timeout >][,<pmf>]

Response:

WIFI CONNECTEDWIFI 
WIFI GOT IP

OK

[WIFI GOT IPv6 LL]
[WIFI GOT IPv6 GL]

or

+CWJAP:<error code>
ERROR

Execute Command exec cmd

Function:

Connect an ESP station to a targeted AP with last Wi-Fi configuration.

Command:

AT+CWJAP

Response:

WIFI CONNECTED 
WIFI GOT IP

OK
[WIFI GOT IPv6 LL]
[WIFI GOT IPv6 GL]

or

+CWJAP: < error code >
ERROR

Parameters id6

Notes notes

Example id7

// If the target AP 's SSID is "abc" and the password is "0123456789", the command should be: AT + CWJAP = "abc" , "0123456789"
// If the target AP 's SSID is "ab\,c" and the password is "0123456789" \" , the command should be: AT + CWJAP = "ab
\\ \,c" , "0123456789 \"\\ "
// If multiple APs all have the SSID of "abc" , the target AP can be found by BSSID : AT+CWJAP="abc" , "0123456789" , "ca:d7:19:d8:a6:44"
// If esp - at is required that connect to a AP by protected management frame , the command should be : AT+CWJAP =
"abc" , "0123456789" ,,,,,,, 3


AT+CWRECONNCFG : Query/Set the Wi-Fi Reconnecting Configuration recon

Query Command reconn

Function:

Query the configuration of Wi-Fi reconnect.

Command:

AT+CWRECONNCFG?

Response:

+CWRECONNCFG:<interval_second>,<repeat_count> 
OK

Set Command id9

Function:

Set the configuration of Wi-Fi reconnect.

Command:

AT+CWRECONNCFG=<interval_second>,<repeat_count >

Response:

OK

Parameters id10

Example id11

// The ESP station tries to reconnect to AP at the interval of one second for 100 times .  AT+CWRECONNCFG = 1 , 100
// The ESP station will not reconnect to AP when disconnected .  AT+CWRECONNCFG=0,0

Notes id12


AT+CWLAPOPT : Set the Configuration for the Command AT+CWLAP zzz

Set Command id13

Command:

AT+CWLAPOPT=<reserved>,<print mask>[,<rssi filter>][,<authmode mask>]

Response:

OK

or

 ERROR

Parameters id14

Example id15

// The first parameter is 1 , meaning that the result of the command AT+CWLAP will be ordered according to RSSI;
// The second parameter is 31 , namely 0x1F , meaning that the corresponding bits of < print mask > are set to 1.  All parameters will be shown in the result of AT+CWLAP.AT+CWLAPOPT=1,31 AT+CWLAP
// Just show the AP which authmode is OPEN AT + CWLAPOPT = 1 , 31 , - 100 , 1 AT + CWLAP 

AT+CWLAP : List Available APs NNN

Set Command id16

Function:

Query the APs with specified parameters, such as the SSID, MAC address, or channel.

Command:

AT+CWLAP=[<ssid>,<mac>,<channel>,<scan_type>,<scan_time_min>,<scan_time_max>]

Execute Command id 17

Function:

List all available APs.

Command:

AT+CWLAP

Response:

+CWLAP:<ecn>,<ssid>,<rssi>,<mac>,<channel>,<freq_offset>,<freqcal_val>,<pairwise_cipher>,<group_cipher>,<bgn>,<wps>

OK

Parameters id18

Note id19

Example id20

AT+CWLAP="Wi-Fi","ca:d7:19:d8:a6:44",6,0,400,1000
 // Search for APs with a designated SSID : AT + CWLAP = "Wi-Fi"

AT+CWQAP : Disconnect from an AP an-ap

Execute Command id21

Command:

AT+CWQAP

Response:

OK

AT+CWSAP : Query/Set the configuration of an ESP SoftAP esp-softap

Query Command id22

Function:

Query the configuration parameters of an ESP SoftAP.

Command:

AT+CWSAP?  

Response:

+CWSAP:<ssid>,<pwd>,<channel>,<ecn>,<max conn>,<ssid hidden>
OK

Set Command id23

Function:

Set the configuration of an ESP SoftAP.

Command:

AT+CWSAP=<ssid>,<pwd>,<chl>,<ecn>[,<max conn>][,<ssid hidden>]

Response:

OK

Parameters id24

Notes id25

Example id16

AT+CWSAP="ESP","1234567890",5,3

AT+CWLIF : Obtain IP Address of the Station That Connects to an ESP SoftAP esp-softap

Execute Command

Command:

AT+CWLIF

Response:

+CWLIF:<ip addr>,<mac> 

OK

Parameters id28

Note id29


AT+CWQIF : Disconnect Stations from an ESP SoftAP esp-softap

Execute Command

Function:

Disconnect all stations that are connected to the ESP SoftAP.

Command:

AT+CWQIF 

Response:

OK

Set Command id31

Function:

Disconnect a specific station from the ESP SoftAP.

Command:

AT+CWQIF=<mac>

Response:

OK

Parameter param


AT+CWDHCP : Enable/Disable DHCP disab dhcp

Query Command id32

Command:

AT+CWDHCP?

Response:

< state >

Set Command id33

Function:

Enable/disable DHCP.

Command:

AT+CWDHCP=<operate>,<mode>

Response:

OK

Parameters id34

Notes id35

Example

// Enable Station DHCP .  If the last DHCP mode is 2 , the current DHCP mode will be 3.  AT + CWDHCP = 1 , 1
// Disable SoftAP DHCP .  If the last DHCP mode is 3 , the current DHCP mode will be 1.  AT + CWDHCP = 0 , 2

AT+CWDHCPS : Query/Set the IP Addresses Allocated by an ESP SoftAP DHCP Server dhcp Server

Query Command id37

Command:

AT+CWDHCPS?

Response:

+ CWDHCPS =< lease time > , < start IP > , < end IP >

OK

Set Command id38

Function:

Set the IP address range of the ESP SoftAP DHCP server.

Command:

AT+CWDHCPS=<enable>,<lease time>,<start IP>,<end IP>

Response:

OK

Parameters id39

Notes id40

Example id41

AT+CWDHCPS=1,3,"192.168.4.10","192.168.4.15"AT+CWDHCPS=0 
// Disable the settings and use the default IP address range .



AT+CWAUTOCONN : Automatically Connect to an AP When Powered on

Set Command id42

Command:

AT+CWAUTOCONN=<enable>

Response:

OK

Parameters id43

Note id44

Example id45

AT+CWAUTOCONN=1

AT+CWAPPROTO : Query/Set the 802.11 b/g/n Protocol Standard of SoftAP Mode softap mode

Query Command id46

Command:

AT+CWAPPROTO?

Response:

+CWAPPROTO=<protocol>

OK

Set Command id47

Command:

AT+CWAPPROTO=<protocol>

Response:

OK

Parameters id48

Note id49



AT+CWSTAPROTO : Query/Set the 802.11 b/g/n Protocol Standard of Station Mode sta mode

Query Command

Command:

AT+CWSTAPROTO?

Response:

+CWSTAPROTO=<protocol>

OK

Set Command id51

Command:

AT+CWSTAPROTO=<protocol>

Response:

OK

Parameters id52

Note id53



AT+CIPSTAMAC : Query/Set the MAC Address of an ESP Station esp station

Query Command id54

Function:

Query the MAC address of the ESP Station.

Command:

AT+CIPSTAMAC?

Response:

+CIPSTAMAC:<mac>

OK

Set Command id55

Function:

Set the MAC address of an ESP station.

Command:

AT+CIPSTAMAC=<mac>

Response:

OK

Parameters id56

Notes id57

Example id58

AT+CIPSTAMAC="1a:fe:35:98:d3:7b"


AT+CIPAPMAC : Query/Set the MAC Address of an ESP SoftAP esp softap

Query Command id59

Function:

Query the MAC address of the ESP SoftAP.

Command:

AT+CIPAPMAC?

Response:

+CIPAPMAC:<mac>

OK

Set Command id60

Function:

Set the MAC address of the ESP SoftAP.

Command:

AT+CIPAPMAC=<mac>

Response:

OK

Parameters id61

Notes id62

Example id63

AT+CIPAPMAC="18:fe:35:98:d3:7b"


AT+CIPSTA : Query/Set the IP Address of an ESP Station

Query Command id64

Function:

Query the IP address of the ESP Station.

Command:

AT+CIPSTA?

Response:

+CIPSTA:ip:<"ip">+CIPSTA:gateway:<"gateway">+CIPSTA:netmask:<"netmask">+CIPSTA:ip6ll:<"ipv6 addr">+CIPSTA:ip6gl:<"ipv6 addr">

OK

Set Command id65

Function:

Set the IPv4 address of the ESP station.

Command:

AT+CIPSTA=<"ip">[,<"gateway">,<"netmask">]

Response:

OK

Parameters id66

Notes id67

Example id68

AT+CIPSTA="192.168.6.100","192.168.6.1","255.255.255.0"


AT+CIPAP : Query/Set the IP Address of an ESP SoftAP esp softap

Query Command id69

Function:

Query the IP address of the ESP SoftAP.

Command:

AT+CIPAP?

Response:

+CIPAP:ip:<"ip">+CIPAP:gateway:<"gateway">+CIPAP:netmask:<"netmask">+CIPAP:ip6ll:<"ipv6 addr">+CIPAP:ip6gl:<"ipv6 addr">

OK

Set Command id70

Function:

Set the IPv4 address of the ESP SoftAP.

Command:

AT+CIPAP=<"ip">[,<"gateway">,<"netmask">]

Response:

OK

Parameters id71

Notes id72

Example id73

AT+CIPAP="192.168.5.1","192.168.5.1","255.255.255.0"


AT+CWSTARTSMART : Start SmartConfig

Execute Command id74

Function:

Start SmartConfig of the type ESP-TOUCH+AirKiss.

Command:

AT+CWSTARTSMART 

Set Command id75

Function:

Start SmartConfig of a designated type.

Command:

AT+CWSTARTSMART=<type>[,<auth floor>]

Response:

OK

Parameters id76

Notes id72

Example id78

AT+CWMODE=1
AT+CWSTARTSMART


AT+CWSTOPSMART : Stop SmartConfig smart config

Execute Command id79

Command:

AT+CWSTOPSMART

Response:

OK

Note id80

Example id81

AT+CWMODE=1
AT+CWSTARTSMART
AT+CWSTOPSMART


AT+WPS : Enable the WPS Function func

Set Command id82

Command:

 
AT+WPS=<enable>[,<auth floor>]

Response:

OK

Parameters id83

Notes id84

Example id85

AT+CWMODE=1
AT+WPS=1


AT+MDNS : Configure the mDNS Function mdns func

Set Command id86

Command:

AT+MDNS=<enable>[,<hostname>,<service_name>,<port>]

Response:

OK

Parameters

Example id88

AT+MDNS=1,"google.com","_iot",8080 
AT+MDNS=0


[ESP32 Only] AT+CWJEAP : Connect to a WPA2 Enterprise AP entreprise ap

Query Command id89

Function:

Query the configuration information of the Enterprise AP to which the ESP station is already connected.

Command:

AT+CWJEAP?

Response:

+CWJEAP:<ssid>,<method>,<identity>,<username>,<password>,<security>

OK

Set Command id90

Function:

Connect to the targeted Enterprise AP.

Command:

AT+CWJEAP=<ssid>,<method>,<identity>,<username>,<password>,<security>[,<jeap_timeout>]

Response:

OK

or

+CWJEAP:Timeout

ERROR

Parameters id91

Example id92

// Connect to EAP - TLS mode Enterprise AP , set identity , verify server certificate and load client certificate
AT+CWJEAP="dlink11111",0,"example@espressif.com",,, 3
// Connect to EAP - PEAP mode Enterprise AP , set identity , username and password , not verify server certificate and not load client certificate
AT+CWJEAP="dlink11111",1,"example@espressif.com","espressif","test11",0

Error Code:

The WPA2 Enterprise error code will be prompt as ERR CODE:0x<%08x>.

AT_EAP_MALLOC_FAILED

0x8001

AT_EAP_GET_NVS_CONFIG_FAILED

0x8002

AT_EAP_CONN_FAILED

0x8003

AT_EAP_SET_WIFI_CONFIG_FAILED

0x8004

AT_EAP_SET_IDENTITY_FAILED

0x8005

AT_EAP_SET_USERNAME_FAILED

0x8006

AT_EAP_SET_PASSWORD_FAILED

0x8007

AT_EAP_GET_CA_LEN_FAILED

0x8008

AT_EAP_READ_CA_FAILED

0x8009

AT_EAP_SET_CA_FAILED

0x800A

AT_EAP_GET_CERT_LEN_FAILED

0x800B

AT_EAP_READ_CERT_FAILED

0x800C

AT_EAP_GET_KEY_LEN_FAILED

0x800D

AT_EAP_READ_KEY_FAILED

0x800E

AT_EAP_SET_CERT_KEY_FAILED

0x800F

AT_EAP_ENABLE_FAILED

0x8010

AT_EAP_ALREADY_CONNECTED

0x8011

AT_EAP_GET_SSID_FAILED

0x8012

AT_EAP_SSID_NULL

0x8013

AT_EAP_SSID_LEN_ERROR

0x8014

AT_EAP_GET_METHOD_FAILED

0x8015

AT_EAP_CONN_TIMEOUT

0x8016

AT_EAP_GET_IDENTITY_FAILED

0x8017

AT_EAP_IDENTITY_LEN_ERROR

0x8018

AT_EAP_GET_USERNAME_FAILED

0x8019

AT_EAP_USERNAME_LEN_ERROR

0x801A

AT_EAP_GET_PASSWORD_FAILED

0x801B

AT_EAP_PASSWORD_LEN_ERROR

0x801C

AT_EAP_GET_SECURITY_FAILED

0x801D

AT_EAP_SECURITY_ERROR

0x801E

AT_EAP_METHOD_SECURITY_UNMATCHED

0x801F

AT_EAP_PARAMETER_COUNTS_ERROR

0x8020

AT_EAP_GET_WIFI_MODE_ERROR

0x8021

AT_EAP_WIFI_MODE_NOT_STA

0x8022

AT_EAP_SET_CONFIG_FAILED

0x8023

AT_EAP_METHOD_ERROR

0x8024

Note id93



AT+CWHOSTNAME : Query/Set the Host Name of an ESP Station esp station

Query Command id94

Function:

Query the host name of ESP Station.

Command:

AT+CWHOSTNAME?

Response:

+CWHOSTNAME:<hostname>

OK

Set Command id95

Function:

Set the host name of ESP Station.

Command:

AT+CWHOSTNAME=<hostname>

Response:

OK

If the Station mode is not enabled, the command will return:

ERROR

Parameters id96

Note id97

Example id98

AT+CWMODE=3
AT+CWHOSTNAME="my_test"


AT+CWCOUNTRY : Query/Set the Wi-Fi Country Code XX

Query Command id99

Function:

Query Wi-Fi country code information.

Command:

AT+CWCOUNTRY?

Response:

+CWCOUNTRY:<country_policy>,<country_code>,<start_channel>,<total_channel_count>

OK

Set Command id100

Function:

Set the Wi-Fi country code information.

Command:

AT+CWCOUNTRY=<country_policy>,<country_code>,<start_channel>, <total_channel_count>

Response:

OK

Parameters

Note id102

Example id103

AT+CWMODE=3 
AT+CWCOUNTRY=1,"CN",1,13