ESP32 Ethernet AT Examples

[中文]

This document provides an introduction and detailed command examples to illustrate how to utilize ESP32 Ethernet AT Commands on ESP32.

Important

  • Before you run any Ethernet AT commands, please make sure you have followed the Prerequisite.

  • The examples described in this document are based on the situation that network cable has been plugged in.

Establish a TCP connection on Ethernet network

  1. Enable multiple connections.

    Command:

    AT+CIPMUX=1
    

    Response:

    OK
    
  2. Create a TCP server.

    Command:

    AT+CIPSERVER=1,8081
    

    Response:

    OK
    
  3. Obtain the IP address of the server.

    Command:

    AT+CIPETH?
    

    Response:

    +CIPETH:ip:192.168.105.24
    +CIPETH:gateway:192.168.105.1
    +CIPETH:netmask:255.255.255.0
    OK
    

    Note:

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

  4. Use a network tool on PC to create a TCP client and connect to the TCP server by the step 2, which IP address is 192.168.105.24, port is 8081.

  5. Send 4 bytes of data to transmission link 0 in Normal Transmission Mode.

    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 input exceeds the length (n) set by AT+CIPSEND, the system will reply busy p..., and send the first n bytes. After sending the first n bytes, the system will reply SEND OK.

  6. Receive 4 bytes of data from transmission link 0 in Normal Transmission Mode.

    Assume that the TCP server received 4 bytes of data (data is test), the system would be prompt as:

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

    Command:

    AT+CIPCLOSE=0
    

    Response:

    0,CLOSED
    
    OK
    
  8. Delete the TCP server.

    Command:

    AT+CIPSERVER=0
    

    Response:

    OK
    

    Note:

    • The AT+CIPSERVER=0 command will only shutdown the server, but will keep the existing connection. If you want to close all client connections to the server at the same time, please execute the command AT+CIPSERVER=0,1.