[ESP32 Only] Ethernet AT Commands

Prerequisite

Before you run any Ethernet AT Commands, please refer to the following steps to make preparations:

Note

This prerequisite takes ESP32-Ethernet-Kit as an example. If you use other modules or development boards, please refer to corresponding datasheets for RX/TX pins.

  • Change AT UART pins (because default AT UART pins are in conflict with the Ethernet function pins):

    In the row of module WROVER-32, change uart_rx_pin from GPIO19 to GPIO4, uart_tx_pin from GPIO22 to GPIO2, uart_cts_pin from GPIO15 to GPIO-1, and uart_rts_pin from GPIO14 to GPIO-1 (flow control is optional and is not used here). See How to Set AT Port Pin for more information.

  • Enable AT ethernet support.

  • Compile and flash the project onto ESP32-Ethernet-Kit.

  • Connect your hardware:

    • Connect Host MCU (PC with USB to serial converter) to GPIO2 (TX) and GPIO4 (RX) of ESP32-Ethernet-Kit when the flow control function is not enabled.
    • Connect ESP32-Ethernet-Kit with Ethernet network.

[ESP32 Only] AT+CIPETHMAC: Query/Set the MAC Address of the ESP Ethernet

Query Command

Function:

Obtain the MAC address of the ESP Ethernet.

Command:

AT+CIPETHMAC?

Response:

+CIPETHMAC:<mac>
OK

Set Command

Function:

Set the MAC address of the ESP Ethernet.

Command:

AT+CIPETHMAC=<mac>

Response:

OK

Parameter

  • <mac>: string parameter showing the MAC address of the Ethernet interface.

Notes

  • The default firmware does not support Ethernet AT commands (see How to understand the differences of each type of module), but you can enable it by ./build.py menuconfig > Component config > AT > AT ethernet support and compile the project (see How to clone project and compile it).
  • The configuration changes will be saved in the NVS area if AT+SYSSTORE=1.
  • Please make sure the MAC address of Ethernet interface you set is different from those of other interfaces.
  • Bit 0 of the ESP MAC address CANNOT be 1.
    • For example, a MAC address can be “1a:…” but not “15:…”.
  • FF:FF:FF:FF:FF:FF and 00:00:00:00:00:00 are invalid MAC addresses and cannot be set.

Example

AT+CIPETHMAC="1a:fe:35:98:d4:7b"

[ESP32 Only] AT+CIPETH: Query/Set the IP Address of the the ESP Ethernet

Query Command

Function:

Obtain the IP address of the ESP Ethernet.

Command:

AT+CIPETH?

Response:

+CIPETH:ip:<ip>
+CIPETH:gateway:<gateway>
+CIPETH:netmask:<netmask>
OK

Set Command

Function:

Set the IP address of the ESP Ethernet.

Command:

AT+CIPETH=<ip>[,<gateway>,<netmask>]

Response:

OK

Parameters

  • <ip>: string parameter showing the IP address of the ESP Ethernet.
  • [<gateway>]: gateway.
  • [<netmask>]: netmask.

Notes

  • The default firmware does not support Ethernet AT commands (see How to understand the differences of each type of module), but you can enable it by ./build.py menuconfig > Component config > AT > AT ethernet support and compile the project (see How to clone project and compile it).

  • Only after calling esp_at_eth_cmd_regist can its IP address be queried.

  • The configuration changes will be saved in the NVS area if AT+SYSSTORE=1.

  • This Set Command correlates with DHCP commands, such as AT+CWDHCP:

    • If static IP is enabled, DHCP will be disabled.
    • If DHCP is enabled, static IP will be disabled.
    • The last configuration overwrites the previous configuration.

Example

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