Skip to content
Branch: master
Find file History

Latest commit

Stanimir-Petev Update
Updated example with the stable 4.0 version of the ESP-IDF following the instructions here:
Latest commit 1f254b4 Mar 11, 2020


Type Name Latest commit message Commit time
Failed to load latest commit information.
main Update Mar 11, 2020
CMakeLists.txt Update ethernet example Dec 10, 2019
Makefile Update ethernet example Dec 10, 2019 Update Mar 11, 2020
sdkconfig Update Mar 11, 2020

Ethernet Example

(See the file in the upper level 'examples' directory for more information about examples.)


This example demonstrates basic usage of Ethernet driver together with tcpip_adapter. The work flow of the example could be as follows:

  1. Install Ethernet driver
  2. Send DHCP requests and wait for a DHCP lease
  3. If get IP address successfully, then you will be able to ping the device

If you have a new Ethernet application to go (for example, connect to IoT cloud via Ethernet), try this as a basic template, then add your own code.

How to use example

Hardware Required

To run this example, it's recommended that you have an official ESP32 Ethernet development board - ESP32-Ethernet-Kit. This example should also work for 3rd party ESP32 board as long as it's integrated with a supported Ethernet PHY chip. Up until now, ESP-IDF supports up to four Ethernet PHY: LAN8720, IP101, DP83848 and RTL8201, additional PHY drivers should be implemented by users themselves.

Besides that, esp_eth component can drive third-party Ethernet module which integrates MAC and PHY and provides common communication interface (e.g. SPI, USB, etc). This example will take the DM9051 as an example, illustrating how to install the Ethernet driver in the same manner.

Pin Assignment

See common pin assignments for Ethernet examples from upper level.

Configure the project menuconfig

See common configurations for Ethernet examples from upper level.

Build, Flash, and Run

Build the project and flash it to the board, then run monitor tool to view serial output: -p PORT build flash monitor

(Replace PORT with the name of the serial port to use.)

(To exit the serial monitor, type Ctrl-].)

See the Getting Started Guide for full steps to configure and use ESP-IDF to build projects.

Example Output

I (394) eth_example: Ethernet Started
I (3934) eth_example: Ethernet Link Up
I (3934) eth_example: Ethernet HW Addr 30:ae:a4:c6:87:5b
I (5864) tcpip_adapter: eth ip:, mask:, gw:
I (5864) eth_example: Ethernet Got IP Address
I (5864) eth_example: ~~~~~~~~~~~
I (5864) eth_example: ETHIP:
I (5874) eth_example: ETHMASK:
I (5874) eth_example: ETHGW:
I (5884) eth_example: ~~~~~~~~~~~

Now you can ping your ESP32 in the terminal by entering ping (it depends on the actual IP address you get).


See common troubleshooting for Ethernet examples from upper level.

(For any technical queries, please open an issue on GitHub. We will get back to you as soon as possible.)

You can’t perform that action at this time.