IoT gateway
Bridge WiFi or BLE devices to a wired network. Ethernet provides a stable upstream while the C6 co-processor handles wireless clients.
The ESP32-P4-WIFI6-DEV-KIT includes a 100 Mbps Ethernet port (RJ45) for wired network connectivity. Ethernet provides lower latency and more reliable throughput than WiFi, making it well-suited for industrial applications, IoT gateways, and any scenario where wired infrastructure is available.
| Specification | Value |
|---|---|
| Speed | 10/100 Mbps (Fast Ethernet) |
| Connector | RJ45 with integrated magnetics and LEDs |
| PHY | Onboard Ethernet PHY |
| Interface to ESP32-P4 | RMII |
Connect a standard Ethernet cable (Cat5e or better) between the board’s RJ45 port and your network switch or router.
The RJ45 connector has two integrated LEDs:
Verify the green LED illuminates after connecting the cable. If it does not, check the cable and the other end of the connection.
Include the required headers:
#include "esp_eth.h"#include "esp_netif.h"#include "esp_event.h"Initialize the network stack and Ethernet driver:
void app_main(void){ esp_netif_init(); esp_event_loop_create_default();
// Create default Ethernet netif esp_netif_config_t cfg = ESP_NETIF_DEFAULT_ETH(); esp_netif_t *eth_netif = esp_netif_new(&cfg);
// Configure the Ethernet MAC and PHY eth_mac_config_t mac_config = ETH_MAC_DEFAULT_CONFIG(); eth_phy_config_t phy_config = ETH_PHY_DEFAULT_CONFIG();
// The PHY address and reset GPIO depend on board design phy_config.phy_addr = 1; phy_config.reset_gpio_num = -1; // No dedicated reset pin
esp_eth_mac_t *mac = esp_eth_mac_new_esp32(&mac_config); esp_eth_phy_t *phy = esp_eth_phy_new_ip101(&phy_config);
esp_eth_config_t config = ETH_DEFAULT_CONFIG(mac, phy); esp_eth_handle_t eth_handle = NULL; esp_eth_driver_install(&config, ð_handle);
esp_netif_attach(eth_netif, esp_eth_new_netif_glue(eth_handle));
// Register event handlers esp_event_handler_register(ETH_EVENT, ESP_EVENT_ANY_ID, ð_event_handler, NULL); esp_event_handler_register(IP_EVENT, IP_EVENT_ETH_GOT_IP, &got_ip_event_handler, NULL);
esp_eth_start(eth_handle);}Handle Ethernet events:
static void eth_event_handler(void *arg, esp_event_base_t event_base, int32_t event_id, void *event_data){ switch (event_id) { case ETHERNET_EVENT_CONNECTED: printf("Ethernet link up\n"); break; case ETHERNET_EVENT_DISCONNECTED: printf("Ethernet link down\n"); break; case ETHERNET_EVENT_START: printf("Ethernet started\n"); break; case ETHERNET_EVENT_STOP: printf("Ethernet stopped\n"); break; }}
static void got_ip_event_handler(void *arg, esp_event_base_t event_base, int32_t event_id, void *event_data){ ip_event_got_ip_t *event = (ip_event_got_ip_t *)event_data; printf("Ethernet got IP: " IPSTR "\n", IP2STR(&event->ip_info.ip));}Build and flash:
idf.py buildidf.py -p /dev/ttyUSB0 flash monitorYou should see DHCP address assignment in the serial output once the cable is connected.
If your network does not have a DHCP server, configure a static IP:
esp_netif_dhcpc_stop(eth_netif);
esp_netif_ip_info_t ip_info = { .ip.addr = ESP_IP4TOADDR(192, 168, 1, 100), .gw.addr = ESP_IP4TOADDR(192, 168, 1, 1), .netmask.addr = ESP_IP4TOADDR(255, 255, 255, 0),};esp_netif_set_ip_info(eth_netif, &ip_info);The ESP32-P4 can run Ethernet and WiFi simultaneously, enabling gateway and bridge applications:
// Initialize both interfacesesp_netif_t *eth_netif = esp_netif_new(&ESP_NETIF_DEFAULT_ETH());esp_netif_t *wifi_netif = esp_netif_create_default_wifi_sta();
// Start bothesp_eth_start(eth_handle);esp_wifi_start();
// Each interface gets its own IP address.// Use routing configuration to control traffic flow.IoT gateway
Bridge WiFi or BLE devices to a wired network. Ethernet provides a stable upstream while the C6 co-processor handles wireless clients.
Industrial automation
Connect to factory PLCs and SCADA systems over wired Ethernet. The deterministic latency of wired connections is critical for real-time control.
Network appliance
Build a protocol translator, data logger, or edge computing node that plugs directly into the network infrastructure.
Development and debugging
Use Ethernet for high-speed log streaming and firmware OTA updates, keeping WiFi free for the application.
| Symptom | Cause | Fix |
|---|---|---|
| Green LED not lit | No link detected | Check cable, try a different port on the switch |
| DHCP timeout | Network does not have DHCP | Configure a static IP address |
esp_eth_driver_install returns error | Wrong PHY driver selected | Verify the PHY model matches your board revision |
| Can ping locally but not externally | Gateway not set correctly | Check gateway address in DHCP or static config |
| Link flaps (up/down repeatedly) | Bad cable or EMI | Replace cable; move away from interference sources |