!
4.2.2.
AT+CWJAP—Connects to an AP
Commands
Response
Parameters
Messages
Note
Examples
Espressif
Query Command:
AT+CWJAP?
Function: to query the AP to which the
ESP32 Station is already connected.
+CWJAP:<ssid>,<bssid>,<channel>,<rss
i>
OK
•
<ssid>: a string parameter showing
the SSID of the AP.
•
<bssid>: the AP's MAC address.
•
<channel>: channel
•
<rssi>: signal strength
// If ESP32 station connects to an AP, it will prompt messages:
WIFI CONNECTED
WIFI GOT IP
// If the WiFi connection ends, it will prompt messages:
WIFI DISCONNECT
•
The configuration changes will be saved in the NVS area.
•
This command requires Station mode to be active.
AT+CWJAP="abc","0123456789"
For example, if the target AP's SSID is "ab\,c" and the password is "0123456789"\", the
command is as follows:
AT+CWJAP="ab\\\,c","0123456789\"\\"
If multiple APs have the same SSID as "abc", the target AP can be found by BSSID:
AT+CWJAP="abc","0123456789","ca:d7:19:d8:a6:44"
14 97
!
Set Command:
AT+CWJAP=<ssid>,<pwd>[,<bssid>]
Function: to set the AP to which the ESP32
Station needs to be connected.
OK
or
+CWJAP:<error code>
ERROR
•
<ssid>: the SSID of the target AP.
•
<pwd>: password, MAX: 64-byte ASCII.
•
[<bssid>](optional parameter): the target
AP's MAC address, used when multiple APs
have the same SSID.
•
<error code>: (for reference only)
‣ 1: connection timeout.
‣ 2: wrong password.
‣ 3: cannot find the target AP.
‣ 4: connection failed.
‣ others: unknown error occurred.
Escape character syntax is needed if SSID or
password contains any special characters, such
as, or " or \.
/!
4. Wi-Fi AT Commands
2019.06
Need help?
Do you have a question about the ESP32 and is the answer not in the manual?
Questions and answers