README.md
1# Ethernet Example
2(See the README.md file in the upper level 'examples' directory for more information about examples.)
3
4## Overview
5
6This example demonstrates basic usage of `Ethernet driver` together with `tcpip_adapter`. The work flow of the example could be as follows:
7
81. Install Ethernet driver
92. Send DHCP requests and wait for a DHCP lease
103. If get IP address successfully, then you will be able to ping the device
11
12If 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.
13
14## How to use example
15
16### Hardware Required
17
18To run this example, it's recommended that you have an official ESP32 Ethernet development board - [ESP32-Ethernet-Kit](https://docs.espressif.com/projects/esp-idf/en/latest/hw-reference/get-started-ethernet-kit.html). 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.
19
20Besides 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.
21
22#### Pin Assignment
23
24See common pin assignments for Ethernet examples from [upper level](../README.md#common-pin-assignments).
25
26### Configure the project
27
28```
29idf.py menuconfig
30```
31
32See common configurations for Ethernet examples from [upper level](../README.md#common-configurations).
33
34### Build, Flash, and Run
35
36Build the project and flash it to the board, then run monitor tool to view serial output:
37
38```
39idf.py -p PORT build flash monitor
40```
41
42(Replace PORT with the name of the serial port to use.)
43
44(To exit the serial monitor, type ``Ctrl-]``.)
45
46See the [Getting Started Guide](https://docs.espressif.com/projects/esp-idf/en/latest/get-started/index.html) for full steps to configure and use ESP-IDF to build projects.
47
48## Example Output
49
50```bash
51I (394) eth_example: Ethernet Started
52I (3934) eth_example: Ethernet Link Up
53I (3934) eth_example: Ethernet HW Addr 30:ae:a4:c6:87:5b
54I (5864) tcpip_adapter: eth ip: 192.168.2.151, mask: 255.255.255.0, gw: 192.168.2.2
55I (5864) eth_example: Ethernet Got IP Address
56I (5864) eth_example: ~~~~~~~~~~~
57I (5864) eth_example: ETHIP:192.168.2.151
58I (5874) eth_example: ETHMASK:255.255.255.0
59I (5874) eth_example: ETHGW:192.168.2.2
60I (5884) eth_example: ~~~~~~~~~~~
61```
62
63Now you can ping your ESP32 in the terminal by entering `ping 192.168.2.151` (it depends on the actual IP address you get).
64
65## Troubleshooting
66
67See common troubleshooting for Ethernet examples from [upper level](../README.md#common-troubleshooting).
68
69(For any technical queries, please open an [issue](https://github.com/espressif/esp-idf/issues) on GitHub. We will get back to you as soon as possible.)
70