TCP/IP AT Examples

[中文]

This document provides detailed command examples to illustrate how to utilize TCP/IP AT Commands on ESP32-C3.

ESP32-C3 as a TCP client in single connection

  1. Set the Wi-Fi mode to station.

    Command:

    AT+CWMODE=1
    

    Response:

    OK
    
  2. Connect to the router.

    Command:

    AT+CWJAP="espressif","1234567890"
    

    Response:

    WIFI CONNECTED
    WIFI GOT IP
    
    OK
    

    Note:

    • The SSID and password you entered may be different from those in the above command. Please replace the SSID and password with those of your router settings.

  3. Query the device’s IP address.

    Command:

    AT+CIPSTA?
    

    Response:

    +CIPSTA:ip:"192.168.3.112"
    +CIPSTA:gateway:"192.168.3.1"
    +CIPSTA:netmask:"255.255.255.0"
    
    OK
    

    Note:

    • The query results you obtained may be different from those in the above response.

  4. Connect the PC to the same router which ESP32-C3 is connected to.

    Use a network tool on the PC to create a TCP server. For example, the TCP server on PC is 192.168.3.102, and the port is 8080.

  5. Connect ESP32-C3 to the TCP server as a client over TCP. The server’s IP address is 192.168.3.102, and the port is 8080.

    Command:

    AT+CIPSTART="TCP","192.168.3.102",8080
    

    Response:

    CONNECT
    
    OK
    
  6. Send 4 bytes of data.

    Command:

    AT+CIPSEND=4
    

    Response:

    OK
    
    >
    

    Input 4 bytes, for example, test, then AT will respond the following message.

    Recv 4 bytes
    
    SEND OK
    

    Note:

    • If the number of bytes inputted are more than the length (n) set by AT+CIPSEND, the system will reply busy p..., and send the first n bytes. And after sending the first n bytes, the system will reply SEND OK.

  7. Receive 4 bytes of data.

    Assume that the TCP server sends 4 bytes of data (data is test), the system will prompt:

    +IPD,4:test
    

ESP32-C3 as a TCP server in multiple connections

When ESP32-C3 works as a TCP server, multiple connections should be enabled by AT+CIPMUX=1 command, because in most cases more than one client needs to be connected to the ESP32-C3 server.

Below is an example showing how a TCP server is established when ESP32-C3 works in the softAP mode. If ESP32-C3 works as a station, you can set up a server in the same way mentioned above after connecting ESP32-C3 to the router.

  1. Set the Wi-Fi mode to softAP.

    Command:

    AT+CWMODE=2
    

    Response:

    OK
    
  2. Enable multiple connections.

    Command:

    AT+CIPMUX=1
    

    Response:

    OK
    
  3. Set softAP.

    Command:

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

    Response:

    OK
    
  4. Query softAP information.

    Command:

    AT+CIPAP?
    

    Response:

    AT+CIPAP?
    +CIPAP:ip:"192.168.4.1"
    +CIPAP:gateway:"192.168.4.1"
    +CIPAP:netmask:"255.255.255.0"
    
    OK
    

    Note:

    • The address you obtained may be different from that in the above response.

  5. Set up a TCP server, the default port is 333.

    Command:

    AT+CIPSERVER=1
    

    Response:

    OK
    
  6. Connect the PC to the ESP32-C3 softAP.

    Connect SoftAP
  7. Use a network tool on PC to create a TCP client and connect it to the TCP server that ESP32-C3 has created.

  8. Send 4 bytes of data to connection link 0.

    Command:

    AT+CIPSEND=0,4
    

    Response:

    OK
    
    >
    

    Input 4 bytes, for example, test, then AT will respond the following messages.

    Recv 4 bytes
    
    SEND OK
    

    Note:

    • If the number of bytes inputted are more than the length (n) set by AT+CIPSEND, the system will reply busy p..., and send the first n bytes. And after sending the first n bytes, the system will reply SEND OK.

  9. Receive 4 bytes of data from connection link 0.

    Assume that the TCP server sends 4 bytes of data (data is test), the system will prompt:

    +IPD,0,4:test
    
  10. Close TCP connection.

    Command:

    AT+CIPCLOSE=0
    

    Response:

    0,CLOSED
    
    OK
    

UDP transmission with fixed remote IP address and port

  1. Set the Wi-Fi mode to station.

    Command:

    AT+CWMODE=1
    

    Response:

    OK
    
  2. Connect to the router.

    Command:

    AT+CWJAP="espressif","1234567890"
    

    Response:

    WIFI CONNECTED
    WIFI GOT IP
    
    OK
    

    Note:

    • The SSID and password you entered may be different from those in the above command. Please replace the SSID and password with those of your router settings.

  3. Query the device’s IP address.

    Command:

    AT+CIPSTA?
    

    Response:

    +CIPSTA:ip:"192.168.3.112"
    +CIPSTA:gateway:"192.168.3.1"
    +CIPSTA:netmask:"255.255.255.0"
    
    OK
    

    Note:

    • The query results you obtained may be different from those in the above response.

  4. Connect the PC to the same router which ESP32-C3 is connected to.

    Use a network tool on the PC to create UDP transmission. For example, the PC’s IP address is 192.168.3.102, and the port is 8080.

  5. Enable multiple connections.

    Command:

    AT+CIPMUX=1
    

    Response:

    OK
    
  6. Create a UDP transmission. The connection link is 4, the remote host’s IP address is 192.168.3.102, the remote port is 8080, the local port is 1112, and the mode is 0.

    Important

    In UDP transmission, whether the remote IP address and port are fixed or not is determined by the mode parameter of AT+CIPSTART. If the parameter is 0, a specific connection link ID will be given to ensure that the remote IP address and port are fixed and the data sender and receiver will not be replaced by other devices.

    Command:

    AT+CIPSTART=4,"UDP","192.168.3.102",8080,1112,0
    

    Response:

    4,CONNECT
    
    OK
    

    Note:

    • "192.168.3.102" and 8080 are the remote IP address and port of UDP transmission on the remote side, i.e., the UDP configuration set by PC.

    • 1112 is the local port number of ESP32-C3. You can define this port number, or else, a random port will be used.

    • 0 means that the remote IP address and port are fixed and cannot be changed. For example, when there is another PC creating a UDP entity and sending data to ESP32-C3 port 1112, ESP32-C3 will still receive the data from UDP port 1112, and if the AT command AT+CIPSEND=4,X is used, the data will still be sent to the first PC end. However, if the parameter is not set as 0, the data will be sent to the new PC.

  7. Send 7 bytes of data to connection link 4.

    Command:

    AT+CIPSEND=4,7
    

    Response:

    OK
    
    >
    

    Input 7 bytes, for example, abcdefg, then AT will respond the following messages.

    Recv 7 bytes
    
    SEND OK
    

    Note:

    • If the number of bytes inputted are more than the length (n) set by AT+CIPSEND, the system will reply busy p..., and send the first n bytes. And after sending the first n bytes, the system will reply SEND OK.

  8. Receive 4 bytes of data from connection link 4.

    Assume that the PC sends 4 bytes of data (data is test), the system will prompt:

    +IPD,4,4:test
    
  9. Close UDP connection link 4.

    Command:

    AT+CIPCLOSE=4
    

    Response:

    4,CLOSED
    
    OK
    

UDP transmission with changeable remote IP address and port

  1. Set the Wi-Fi mode to station.

    Command:

    AT+CWMODE=1
    

    Response:

    OK
    
  2. Connect to the router.

    Command:

    AT+CWJAP="espressif","1234567890"
    

    Response:

    WIFI CONNECTED
    WIFI GOT IP
    
    OK
    

    Note:

    • The SSID and password you entered may be different from those in the above command. Please replace the SSID and password with those of your router settings.

  3. Query the device’s IP address.

    Command:

    AT+CIPSTA?
    

    Response:

    +CIPSTA:ip:"192.168.3.112"
    +CIPSTA:gateway:"192.168.3.1"
    +CIPSTA:netmask:"255.255.255.0"
    
    OK
    

    Note:

    • The query results you obtained may be different from those in the above response.

  4. Connect the PC to the same router which ESP32-C3 is connected to.

    Use a network tool on the PC to create UDP transmission. For example, the PC’s IP address is 192.168.3.102, and the port is 8080.

  5. Enable single connections.

    Command:

    AT+CIPMUX=0
    

    Response:

    OK
    
  6. Create a UDP transmission. The remote host’s IP address is 192.168.3.102, the remote port is 8080, the local port is 1112, and the mode is 2.

    Command:

    AT+CIPSTART="UDP","192.168.3.102",8080,1112,2
    

    Response:

    CONNECT
    
    OK
    

    Note:

    • "192.168.3.102" and 8080 are the remote IP address and port of UDP transmission on the remote side, i.e., the UDP configuration set by PC.

    • 1112 is the local port number of ESP32-C3. You can define this port number, or else, a random port will be used.

    • 2 means the opposite terminal of UDP transmission can be changed. The remote IP address and port will be automatically changed to those of the last UDP connection to ESP32-C3.

  7. Send 4 bytes of data.

    Command:

    AT+CIPSEND=4
    

    Response:

    OK
    
    >
    

    Input 4 bytes, for example, test, then AT will respond the following messages.

    Recv 4 bytes
    
    SEND OK
    

    Note:

    • If the number of bytes inputted are more than the length (n) set by AT+CIPSEND, the system will reply busy p..., and send the first n bytes. And after sending the first n bytes, the system will reply SEND OK.

  8. Send data to any other UDP terminal. For example, you can send 4 bytes of data with the remote host’s IP address as 192.168.3.103 and the remote port as 1000.

    If you want to send data to any other UDP terminal, please designate the IP address and port of the target terminal in the command.

    Command:

    AT+CIPSEND=4,"192.168.3.103",1000
    

    Response:

    OK
    
    >
    

    Input 4 bytes, for example, test, then AT will respond the following messages.

    Recv 4 bytes
    
    SEND OK
    
  9. Receive 4 bytes of data.

    Assume that the PC sends 4 bytes of data (data is test), the system will prompt:

    +IPD,4:test
    
  10. Close UDP connection.

    Command:

    AT+CIPCLOSE
    

    Response:

    CLOSED
    
    OK
    

ESP32-C3 as an SSL client in single connection

  1. Set the Wi-Fi mode to station.

    Command:

    AT+CWMODE=1
    

    Response:

    OK
    
  2. Connect to the router.

    Command:

    AT+CWJAP="espressif","1234567890"
    

    Response:

    WIFI CONNECTED
    WIFI GOT IP
    
    OK
    

    Note:

    • The SSID and password you entered may be different from those in the above command. Please replace the SSID and password with those of your router settings.

  3. Query the device’s IP address.

    Command:

    AT+CIPSTA?
    

    Response:

    +CIPSTA:ip:"192.168.3.112"
    +CIPSTA:gateway:"192.168.3.1"
    +CIPSTA:netmask:"255.255.255.0"
    
    OK
    

    Note:

    • The query results you obtained may be different from those in the above response.

  4. Connect the PC to the same router which ESP32-C3 is connected to.

  5. Use the OpenSSL command on the PC to create an SSL server. For example, the SSL server on PC is 192.168.3.102, and the port is 8070.

    Command:

    openssl s_server -cert /home/esp-at/components/customized_partitions/raw_data/server_cert/server_cert.crt -key /home/esp-at/components/customized_partitions/raw_data/server_key/server.key -port 8070
    

    Response:

    ACCEPT
    
  6. Connect the ESP32-C3 to the SSL server as a client over SSL. The server’s IP address is 192.168.3.102, and the port is 8070.

    Command:

    AT+CIPSTART="SSL","192.168.3.102",8070
    

    Response:

    CONNECT
    
    OK
    
  7. Send 4 bytes of data.

    Command:

    AT+CIPSEND=4
    

    Response:

    OK
    
    >
    

    Input 4 bytes, for example, test, then AT will respond the following message.

    Recv 4 bytes
    
    SEND OK
    

    Note:

    • If the number of bytes inputted are more than the length (n) set by AT+CIPSEND, the system will reply busy p..., and send the first n bytes. And after sending the first n bytes, the system will reply SEND OK.

  8. Receive 4 bytes of data.

    Assume that the SSL server sends 4 bytes of data (data is test), the system will prompt:

    +IPD,4:test
    

ESP32-C3 as an SSL server in multiple connections

When ESP32-C3 works as an SSL server, multiple connections should be enabled by AT+CIPMUX=1 command, because in most cases more than one client needs to be connected to the ESP32-C3 server.

Below is an example showing how an SSL server is established when ESP32-C3 works in the softAP mode. If ESP32-C3 works as a station, after connecting to the router, follow the steps for establishing a connection to an SSL server in this example.

  1. Set the Wi-Fi mode to softAP.

    Command:

    AT+CWMODE=2
    

    Response:

    OK
    
  2. Enable multiple connections.

    Command:

    AT+CIPMUX=1
    

    Response:

    OK
    
  3. Configure the ESP32-C3 softAP.

    Command:

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

    Response:

    OK
    
  4. Query softAP information.

    Command:

    AT+CIPAP?
    

    Response:

    AT+CIPAP?
    +CIPAP:ip:"192.168.4.1"
    +CIPAP:gateway:"192.168.4.1"
    +CIPAP:netmask:"255.255.255.0"
    
    OK
    

    Note:

    • The address you obtained may be different from that in the above response.

  5. Set up an SSL server.

    Command:

    AT+CIPSERVER=1,8070,"SSL"
    

    Response:

    OK
    
  6. Connect the PC to the ESP32-C3 softAP.

    Connect SoftAP
  7. Use the OpenSSL command on PC to create an SSL client and connect it to the SSL server that ESP32-C3 has created.

    Command:

    openssl s_client -host 192.168.4.1 -port 8070
    

    Response on the ESP32-C3:

    CONNECT
    
  8. Send 4 bytes of data to connection link 0.

    Command:

    AT+CIPSEND=0,4
    

    Response:

    OK
    
    >
    

    Input 4 bytes, for example, test, then AT will respond the following messages.

    Recv 4 bytes
    
    SEND OK
    

    Note:

    • If the number of bytes inputted are more than the length (n) set by AT+CIPSEND, the system will reply busy p..., and send the first n bytes. And after sending the first n bytes, the system will reply SEND OK.

  9. Receive 4 bytes of data from connection link 0.

    Assume that the SSL server sends 4 bytes of data (data is test), the system will prompt:

    +IPD,0,4:test
    
  10. Close SSL connection.

    Command:

    AT+CIPCLOSE=0
    

    Response:

    0,CLOSED
    
    OK
    

ESP32-C3 as an SSL client to create a single connection with mutual authentication

In this example, the certificate used is the default certificate in esp-at. You can also use your own certificate:

  • To use your own SSL client certificate, replace the default certificate according to the How to Update PKI Configuration document.

  • To use your own SSL server certificate, replace the SSL server certificate path below with your own certificate path.

  1. Set the Wi-Fi mode to station.

    Command:

    AT+CWMODE=1
    

    Response:

    OK
    
  2. Connect to the router.

    Command:

    AT+CWJAP="espressif","1234567890"
    

    Response:

    WIFI CONNECTED
    WIFI GOT IP
    
    OK
    

    Note:

    • The SSID and password you entered may be different from those in the above command. Please replace the SSID and password with those of your router settings.

  3. Set the SNTP server.

    Command:

    AT+CIPSNTPCFG=1,8,"cn.ntp.org.cn","ntp.sjtu.edu.cn"
    

    Response:

    OK
    

    Note:

    • You can set the SNTP server according to your country’s time zone.

  4. Query the SNTP time.

    Command:

    AT+CIPSNTPTIME?
    

    Response:

    +CIPSNTPTIME:Mon Oct 18 20:12:27 2021
    OK
    

    Note:

    • You can check whether the SNTP time matches the real-time time to determine whether the SNTP server you set takes effect.

  5. Query the device’s IP address.

    Command:

    AT+CIPSTA?
    

    Response:

    +CIPSTA:ip:"192.168.3.112"
    +CIPSTA:gateway:"192.168.3.1"
    +CIPSTA:netmask:"255.255.255.0"
    
    OK
    

    Note:

    • The query results you obtained may be different from those in the above response.

  6. Connect the PC to the same router which ESP32-C3 is connected to.

  7. Use the OpenSSL command on the PC to create an SSL server. For example, the SSL server on PC is 192.168.3.102, and the port is 8070.

    Command:

    openssl s_server -CAfile /home/esp-at/components/customized_partitions/raw_data/server_ca/server_ca.crt -cert /home/esp-at/components/customized_partitions/raw_data/server_cert/server_cert.crt -key /home/esp-at/components/customized_partitions/raw_data/server_key/server.key -port 8070 -verify_return_error -verify_depth 1 -Verify 1
    

    Response on the ESP32-C3:

    CONNECT
    

    Note:

    • The certificate path in the command can be adjusted according to the location of your certificate.

  8. The ESP32-C3 sets up the SSL client mutual authentication configuration.

    Command:

    AT+CIPSSLCCONF=3,0,0
    

    Response:

    OK
    
  9. Connect the ESP32-C3 to the SSL server as a client over SSL. The server’s IP address is 192.168.3.102, and the port is 8070.

    Command:

    AT+CIPSTART="SSL","192.168.3.102",8070
    

    Response:

    CONNECT
    
    OK
    
  10. Send 4 bytes of data.

    Command:

    AT+CIPSEND=4
    

    Response:

    OK
    
    >
    

    Input 4 bytes, for example, test, then AT will respond the following message.

    Recv 4 bytes
    
    SEND OK
    

    Note:

    • If the number of bytes inputted are more than the length (n) set by AT+CIPSEND, the system will reply busy p..., and send the first n bytes. And after sending the first n bytes, the system will reply SEND OK.

  11. Receive 4 bytes of data.

    Assume that the SSL server sends 4 bytes of data (data is test), the system will prompt:

    +IPD,4:test
    

ESP32-C3 as an SSL server to create multiple connections with mutual authentication

When ESP32-C3 works as an SSL server, multiple connections should be enabled by AT+CIPMUX=1 command, because in most cases more than one client needs to be connected to the ESP32-C3 server.

Below is an example showing how an SSL server is established when ESP32-C3 works in the station mode. If ESP32-C3 works as a softAP, refer to the example of ESP32-C3 as an SSL server in multiple connections.

  1. Set the Wi-Fi mode to station.

    Command:

    AT+CWMODE=1
    

    Response:

    OK
    
  2. Connect to the router.

    Command:

    AT+CWJAP="espressif","1234567890"
    

    Response:

    WIFI CONNECTED
    WIFI GOT IP
    
    OK
    

    Note:

    • The SSID and password you entered may be different from those in the above command. Please replace the SSID and password with those of your router settings.

  3. Query the device’s IP address.

    Command:

    AT+CIPSTA?
    

    Response:

    +CIPSTA:ip:"192.168.3.112"
    +CIPSTA:gateway:"192.168.3.1"
    +CIPSTA:netmask:"255.255.255.0"
    
    OK
    

    Note:

    • The query results you obtained may be different from those in the above response.

  4. Enable multiple connections.

    Command:

    AT+CIPMUX=1
    

    Response:

    OK
    
  5. Set up an SSL server.

    Command:

    AT+CIPSERVER=1,8070,"SSL",1
    

    Response:

    OK
    
  6. Connect the PC to the ESP32-C3 softAP.

    Connect SoftAP
  7. Use the OpenSSL command on PC to create an SSL client and connect it to the SSL server that ESP32-C3 has created.

    Command:

    openssl s_client -CAfile /home/esp-at/components/customized_partitions/raw_data/client_ca/client_ca_00.crt -cert /home/esp-at/components/customized_partitions/raw_data/client_cert/client_cert_00.crt -key /home/esp-at/components/customized_partitions/raw_data/client_key/client_key_00.key -host 192.168.3.112 -port 8070
    

    Response on the ESP32-C3:

    0,CONNECT
    
  8. Send 4 bytes of data to connection link 0.

    Command:

    AT+CIPSEND=0,4
    

    Response:

    OK
    
    >
    

    Input 4 bytes, for example, test, then AT will respond the following messages.

    Recv 4 bytes
    
    SEND OK
    

    Note:

    • If the number of bytes inputted are more than the length (n) set by AT+CIPSEND, the system will reply busy p..., and send the first n bytes. And after sending the first n bytes, the system will reply SEND OK.

  9. Receive 4 bytes of data from connection link 0.

    Assume that the SSL server sends 4 bytes of data (data is test), the system will prompt:

    +IPD,0,4:test
    
  10. Close SSL connection.

    Command:

    AT+CIPCLOSE=0
    

    Response:

    0,CLOSED
    
    OK
    
  11. Close SSL server.

    Command:

    AT+CIPSERVER=0
    

    Response:

    OK
    

UART Wi-Fi passthrough transmission when the ESP32-C3 works as a TCP client in single connection

  1. Set the Wi-Fi mode to station.

    Command:

    AT+CWMODE=1
    

    Response:

    OK
    
  2. Connect to the router.

    Command:

    AT+CWJAP="espressif","1234567890"
    

    Response:

    WIFI CONNECTED
    WIFI GOT IP
    
    OK
    

    Note:

    • The SSID and password you entered may be different from those in the above command. Please replace the SSID and password with those of your router settings.

  3. Query the device’s IP address.

    Command:

    AT+CIPSTA?
    

    Response:

    +CIPSTA:ip:"192.168.3.112"
    +CIPSTA:gateway:"192.168.3.1"
    +CIPSTA:netmask:"255.255.255.0"
    
    OK
    

    Note:

    • The query results you obtained may be different from those in the above response.

  4. Connect the PC to the same router which ESP32-C3 is connected to.

    Use a network tool on the PC to create a TCP server. For example, the TCP server on PC is 192.168.3.102, and the port is 8080.

  5. Connect the ESP32-C3 to the TCP server as a TCP client over TCP. The server’s IP address is 192.168.3.102, and the port is 8080.

    Command:

    AT+CIPSTART="TCP","192.168.3.102",8080
    

    Response:

    CONNECT
    
    OK
    
  6. Enable the UART Wi-Fi Passthrough Receiving Mode.

    Command:

    AT+CIPMODE=1
    

    Response:

    OK
    
  7. Enter the UART Wi-Fi Passthrough Mode and send data.

    Command:

    AT+CIPSEND
    

    Response:

    OK
    
    >
    
  8. Stop sending data.

    When receiving a packet that contains only +++, the UART Wi-Fi passthrough transmission process will be stopped. Then please wait at least 1 second before sending the next AT command. Please note that if you input +++ directly by typing, the +++ may not be recognized as three consecutive + because of the prolonged typing duration. For more details, please refer to [Passthrough Mode Only] +++.

    Important

    The aim of ending the packet with +++ is to exit Passthrough Mode and to accept normal AT commands, while TCP still remains connected. However, you can also use command AT+CIPSEND to go back into Passthrough Mode.

  9. Exit the UART Wi-Fi Passthrough Receiving Mode.

    Command:

    AT+CIPMODE=0
    

    Response:

    OK
    
  10. Close TCP connection.

    Command:

    AT+CIPCLOSE
    

    Response:

    CLOSED
    
    OK
    

UART Wi-Fi passthrough transmission when the ESP32-C3 works as a TCP server

  1. Set the Wi-Fi mode to station.

    Command:

    AT+CWMODE=1
    

    Response:

    OK
    
  2. Connect to the router.

    Command:

    AT+CWJAP="espressif","1234567890"
    

    Response:

    WIFI CONNECTED
    WIFI GOT IP
    
    OK
    

    Note:

    • The SSID and password you entered may be different from those in the above command. Please replace the SSID and password with those of your router settings.

  3. Enable multiple connections.

    Command:

    AT+CIPMUX=1
    

    Response:

    OK
    

    Note:

    • TCP server can be created only in multiple connections.

  4. Set the maximum number of TCP server connections to 1.

    Command:

    AT+CIPSERVERMAXCONN=1
    

    Response:

    OK
    

    Note:

    • The passthrough mode is point-to-point, so the maximum number of connections to the TCP server can only be 1.

  5. Create TCP server.

    Command:

    AT+CIPSERVER=1,8080
    

    Response:

    OK
    

    Note:

    • Set the TCP server port to 8080. You can also set it to other port.

  6. Query the device’s IP address.

    Command:

    AT+CIPSTA?
    

    Response:

    +CIPSTA:ip:"192.168.3.112"
    +CIPSTA:gateway:"192.168.3.1"
    +CIPSTA:netmask:"255.255.255.0"
    
    OK
    

    Note:

    • The query results you obtained may be different from those in the above response.

  7. Connect the PC to the ESP32-C3 TCP server

    Connect the PC to the same router which ESP32-C3 is connected to.

    Use a network tool on the PC to create a TCP client and connect to the ESP32-C3 TCP server. The remote address is 192.168.3.112, and the port is 8080.

    AT Response:

    0,CONNECT
    
  8. Enable the UART Wi-Fi Passthrough Receiving Mode.

    Command:

    AT+CIPMODE=1
    

    Response:

    OK
    
  9. Enter the UART Wi-Fi Passthrough Mode and send data.

    Command:

    AT+CIPSEND
    

    Response:

    OK
    
    >
    
  10. Stop sending data.

    When receiving a packet that contains only +++, the UART Wi-Fi passthrough transmission process will be stopped. Then please wait at least 1 second before sending the next AT command. Please note that if you input +++ directly by typing, the +++ may not be recognized as three consecutive + because of the prolonged typing duration. For more details, please refer to [Passthrough Mode Only] +++.

    Important

    The aim of ending the packet with +++ is to exit Passthrough Mode and to accept normal AT commands, while TCP still remains connected. However, you can also use command AT+CIPSEND to go back into Passthrough Mode.

  11. Exit the UART Wi-Fi Passthrough Receiving Mode.

    Command:

    AT+CIPMODE=0
    

    Response:

    OK
    
  12. Close TCP connection.

    Command:

    AT+CIPCLOSE
    

    Response:

    CLOSED
    
    OK
    

UART Wi-Fi passthrough transmission when the ESP32-C3 works as a softAP in UDP transparent transmission

  1. Set the Wi-Fi mode to softAP.

    Command:

    AT+CWMODE=2
    

    Response:

    OK
    
  2. Set softAP.

    Command:

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

    Response:

    OK
    
  3. Connect the PC to the ESP32-C3 softAP.

    Connect SoftAP
  4. Create a UDP endpoint.

    Use a network tool on PC to create a UDP endpoint. For example, the PC’s IP address is 192.168.4.2 and the port is 8080.

  5. Create a UDP transmission between ESP32-C3 and the PC with a fixed remote IP address and port. The remote host’s IP address is 192.168.4.2, the remote port is 8080, the local port is 2233, and the mode is 0.

    Command:

    AT+CIPSTART="UDP","192.168.4.2",8080,2233,0
    

    Response:

    CONNECT
    
    OK
    
  6. Enter the UART Wi-Fi Passthrough Receiving Mode.

    Command:

    AT+CIPMODE=1
    

    Response:

    OK
    
  7. Enter the UART Wi-Fi Passthrough Mode and send data.

    Command:

    AT+CIPSEND
    

    Response:

    OK
    
    >
    
  8. Stop sending data.

    When receiving a packet that contains only +++, the UART Wi-Fi passthrough transmission process will be stopped. Then please wait at least 1 second before sending the next AT command. Please note that if you input +++ directly by typing, the +++ may not be recognized as three consecutive + because of the prolonged typing duration. For more details, please refer to [Passthrough Mode Only] +++.

    Important

    The aim of ending the packet with +++ is to exit Passthrough Mode and to accept normal AT commands, while TCP still remains connected. However, you can also use command AT+CIPSEND to go back into Passthrough Mode.

  9. Exit the UART Wi-Fi Passthrough Receiving Mode.

    Command:

    AT+CIPMODE=0
    

    Response:

    OK
    
  10. Close TCP connection.

    Command:

    AT+CIPCLOSE
    

    Response:

    CLOSED
    
    OK
    

ESP32-C3 obtains socket data in passive receiving mode

When a large amount of network data is expected to be received and the MCU cannot process it timely, you can refer to this example and use the passive receive data mode.

  1. Set the Wi-Fi mode to station.

    Command:

    AT+CWMODE=1
    

    Response:

    OK
    
  2. Connect to the router.

    Command:

    AT+CWJAP="espressif","1234567890"
    

    Response:

    WIFI CONNECTED
    WIFI GOT IP
    
    OK
    

    Note:

    • The SSID and password you entered may be different from those in the above command. Please replace the SSID and password with those of your router settings.

  3. Query the device’s IP address.

    Command:

    AT+CIPSTA?
    

    Response:

    +CIPSTA:ip:"192.168.3.112"
    +CIPSTA:gateway:"192.168.3.1"
    +CIPSTA:netmask:"255.255.255.0"
    
    OK
    

    Note:

    • The query results you obtained may be different from those in the above response.

  4. Connect the PC to the same router which ESP32-C3 is connected to.

    Use a network tool on the PC to create a TCP server. For example, the TCP server on PC is 192.168.3.102, and the port is 8080.

  5. Connect ESP32-C3 to the TCP server as a client over TCP. The server’s IP address is 192.168.3.102, and the port is 8080.

    Command:

    AT+CIPSTART="TCP","192.168.3.102",8080
    

    Response:

    CONNECT
    
    OK
    
  6. ESP32-C3 sets the socket receiving mode to passive mode.

    Command:

    AT+CIPRECVMODE=1
    

    Response:

    OK
    
  7. The TCP server sends 4 bytes of data (data is test).

    Note:

    • The device replies with +IPD,4. If it receives server data again later, please refer to the note section of ref:AT+CIPRECVMODE<cmd CIPRECVMODE> for whether it will reply with +IPD,.

  8. ESP32-C3 obtains socket data length in passive receiving mode.

    Command:

    AT+CIPRECVLEN?
    

    Response:

    +CIPRECVLEN:4
    OK
    
  9. ESP32-C3 obtains socket data in passive receiving mode.

    Command:

    AT+CIPRECVDATA=4
    

    Response:

    +CIPRECVDATA:4,test
    OK