Error setting up W5500 with ESP32S3, any advices?

I've tried to init my W5500, but somehow i just get errors. I have successfully communicated with different devices over the SPI bus, but have commented them out for testing the W5500 alone.

Errors i get after start (including Verbose output)

09:47:01.556 -> [   133][V][esp32-hal-periman.c:235] perimanSetBusDeinit(): Dein[  5682][V][esp32-hal-periman.c:235] perimanSetBusDeinit(): Deinit function for type GPIO (1) successfully set to 0x420503d0
09:47:01.556 -> [  5683][V][esp32-hal-periman.c:160] perimanSetPinBus(): Pin 47 successfully set to type GPIO (1) with bus 0x30
09:47:01.556 -> [  5692][V][esp32-hal-periman.c:235] perimanSetBusDeinit(): Deinit function for type GPIO (1) successfully set to 0x420503d0
09:47:01.556 -> [  5703][V][esp32-hal-periman.c:160] perimanSetPinBus(): Pin 21 successfully set to type GPIO (1) with bus 0x16
09:47:01.595 -> [  5712][V][esp32-hal-periman.c:235] perimanSetBusDeinit(): Deinit function for type GPIO (1) successfully set to 0x420503d0
09:47:01.595 -> [  5723][V][esp32-hal-periman.c:160] perimanSetPinBus(): Pin 48 successfully set to type GPIO (1) with bus 0x31
09:47:01.595 -> Resetting W5500...
09:47:02.178 -> [  6333][V][esp32-hal-periman.c:235] perimanSetBusDeinit(): Deinit function for type SPI_MASTER_SCK (34) successfully set to 0x42009d2c
09:47:02.214 -> [  6334][V][esp32-hal-periman.c:235] perimanSetBusDeinit(): Deinit function for type SPI_MASTER_MISO (35) successfully set to 0x42009c54
09:47:02.214 -> [  6346][V][esp32-hal-periman.c:235] perimanSetBusDeinit(): Deinit function for type SPI_MASTER_MOSI (36) successfully set to 0x42009b7c
09:47:02.214 -> [  6358][V][esp32-hal-periman.c:235] perimanSetBusDeinit(): Deinit function for type SPI_MASTER_SS (37) successfully set to 0x42009a68
09:47:02.249 -> [  6370][V][esp32-hal-periman.c:235] perimanSetBusDeinit(): Deinit function for type GPIO (1) successfully set to 0x420503d0
09:47:02.249 -> [  6381][V][esp32-hal-periman.c:160] perimanSetPinBus(): Pin 12 successfully set to type GPIO (1) with bus 0xd
09:47:02.249 -> [  6390][V][esp32-hal-periman.c:160] perimanSetPinBus(): Pin 12 successfully set to type SPI_MASTER_SCK (34) with bus 0x1
09:47:02.281 -> [  6401][V][esp32-hal-periman.c:235] perimanSetBusDeinit(): Deinit function for type GPIO (1) successfully set to 0x420503d0
09:47:02.281 -> [  6412][V][esp32-hal-periman.c:160] perimanSetPinBus(): Pin 13 successfully set to type GPIO (1) with bus 0xe
09:47:02.281 -> [  6422][V][esp32-hal-periman.c:160] perimanSetPinBus(): Pin 13 successfully set to type SPI_MASTER_MISO (35) with bus 0x1
09:47:02.319 -> [  6432][V][esp32-hal-periman.c:235] perimanSetBusDeinit(): Deinit function for type GPIO (1) successfully set to 0x420503d0
09:47:02.319 -> [  6443][V][esp32-hal-periman.c:160] perimanSetPinBus(): Pin 11 successfully set to type GPIO (1) with bus 0xc
09:47:02.319 -> [  6453][V][esp32-hal-periman.c:160] perimanSetPinBus(): Pin 11 successfully set to type SPI_MASTER_MOSI (36) with bus 0x1
09:47:02.319 -> Initializing Ethernet...
09:47:02.319 -> [  6464][V][esp32-hal-periman.c:235] perimanSetBusDeinit(): Deinit function for type ETHERNET_SPI (47) successfully set to 0x4200475c
09:47:02.359 -> [  6476][V][esp32-hal-periman.c:174] perimanSetPinBusExtraType(): Successfully set extra_type ETH_CS[0] for pin 21
09:47:02.431 -> E (6285) w5500.mac: w5500_reset(305): reset timeout
09:47:02.431 -> E (6285) w5500.mac: emac_w5500_init(823): reset w5500 failed
09:47:02.464 -> E (6286) esp_eth: esp_eth_driver_install(228): init mac failed
09:47:02.464 -> [  6592][E][ETH.cpp:668] beginSPI(): SPI Ethernet driver install failed: 263
09:47:02.464 -> Ethernet initialization failed!
09:47:02.464 -> =========== After Setup Start ============
09:47:02.464 -> INTERNAL Memory Info:
09:47:02.464 -> ------------------------------------------
09:47:02.464 ->   Total Size        :   392596 B ( 383.4 KB)
09:47:02.464 ->   Free Bytes        :   337624 B ( 329.7 KB)
09:47:02.464 ->   Allocated Bytes   :    49268 B (  48.1 KB)
09:47:02.496 ->   Minimum Free Bytes:   337480 B ( 329.6 KB)
09:47:02.496 ->   Largest Free Block:   319476 B ( 312.0 KB)
09:47:02.496 -> ------------------------------------------
09:47:02.496 -> GPIO Info:
09:47:02.496 -> ------------------------------------------
09:47:02.496 ->   GPIO : BUS_TYPE[bus/unit][chan]
09:47:02.496 ->   --------------------------------------  
09:47:02.496 ->     11 : SPI_MASTER_MOSI[0]
09:47:02.496 ->     12 : SPI_MASTER_SCK[0]
09:47:02.496 ->     13 : SPI_MASTER_MISO[0]
09:47:02.496 ->     19 : USB_DM
09:47:02.532 ->     20 : USB_DP
09:47:02.532 ->     21 : ETH_CS[0]
09:47:02.532 ->     43 : UART_TX[0]
09:47:02.532 ->     44 : UART_RX[0]
09:47:02.532 ->     47 : GPIO
09:47:02.532 ->     48 : GPIO
09:47:02.532 -> ============ After Setup End =============
09:47:03.453 -> E (14872) w5500.mac: w5500_send_command(207): send command timeout
09:47:03.453 -> E (14872) w5500.mac: emac_w5500_receive(687): issue RECV command failed
09:47:03.453 -> E (14873) w5500.mac: frame read from module failed
09:47:04.535 -> E (15977) w5500.mac: w5500_send_command(207): send command timeout
09:47:04.577 -> E (15977) w5500.mac: emac_w5500_receive(687): issue RECV command failed
09:47:04.577 -> E (15978) w5500.mac: frame read from module failed
09:47:05.640 -> E (17082) w5500.mac: w5500_send_command(207): send command timeout
09:47:05.680 -> E (17082) w5500.mac: emac_w5500_receive(687): issue RECV command failed

My code for the Init:

#define ETH_PHY_TYPE ETH_PHY_W5500
#define ETH_PHY_ADDR 1
#define ETH_PHY_CS   21
#define ETH_PHY_IRQ  48
#define ETH_PHY_RST  47


#define CLOCK_PIN  12 // SCLK
#define MISO_PIN   13 // MISO
#define MOSI_PIN   11 // MOSI

ETHClass ETH1(1);

void setup() {
  Serial.begin(115200);
  delay(5000);

  pinMode(ETH_PHY_RST, OUTPUT);
  pinMode(ETH_PHY_CS, OUTPUT);
  pinMode(ETH_PHY_IRQ, INPUT);  // IRQ pin is usually input

  // Ensure all CS pins are HIGH initially (deselected)
  digitalWrite(ETH_PHY_CS, HIGH);

  // Reset W5500
  Serial.println("Resetting W5500...");
  digitalWrite(ETH_PHY_RST, LOW);
  delay(100);  // Hold reset for 100ms (increase if necessary)
  digitalWrite(ETH_PHY_RST, HIGH);
  delay(500); // Wait longer for W5500 to stabilize (increase if necessary)

  // Initialize SPI
  SPI.begin(CLOCK_PIN, MISO_PIN, MOSI_PIN, ETH_PHY_CS);
  SPI.setFrequency(500000); // Lower SPI frequency
  SPI.setDataMode(SPI_MODE0); // Ensure correct SPI mode

  // Initialize Ethernet
  Serial.println("Initializing Ethernet...");
  if (!ETH.begin(ETH_PHY_TYPE, ETH_PHY_ADDR, ETH_PHY_CS, ETH_PHY_IRQ, ETH_PHY_RST, SPI)) {
    Serial.println("Ethernet initialization failed!");
  } else {
    Serial.println("Ethernet initialized successfully.");
  }
}

Does anyone have a solution for this? What could be the cause?


w5500_init_2


esp32_s3_2

try it without the optional interrupt and reset pin. try automatic PHY_ADDR

#define ETH_PHY_ADDR -1
#define ETH_PHY_CS   21
#define ETH_PHY_IRQ  -1
#define ETH_PHY_RST  -1

don't specify CS pin in SPI.begin. it is handled by the ETH library.
you use the default pins so you don't have to specify MISO, MOSI, CLK
use just SPI.begin()

ETH.begin(); does automatically all the parameters you listed. you don't have to specify them.

alternatively you can try the WebClient example from my EthernetESP32 library. it uses the defaults

Hi Juray,

thanks for your answer!

unfortunately it does not quite work with this lib either, i have set the ss/cs pin directly in EthDriver.h (since i wasn't able to find it in any other file).

GPIO38 needs to be high for giving power to the shield.

/*
  The classic Arduino WebClient Ethernet example

 This sketch connects to a website (http://arduino.cc) using Ethernet.

 created 18 Dec 2009
 by David A. Mellis
 modified 9 Apr 2012
 by Tom Igoe, based on work by Adrian McEwen

 */
 #define GPIO38 38

#include <EthernetESP32.h>

W5500Driver driver;
//ENC28J60Driver driver;
//EMACDriver driver(ETH_PHY_LAN8720);

char server[] = "arduino.tips";

// Set the static IP address to use if the DHCP fails to assign
IPAddress ip(192, 168, 0, 177);

// Initialize the Ethernet client library
// with the IP address and port of the server
// that you want to connect to (port 80 is default for HTTP):
EthernetClient client;

void setup() {

  Serial.begin(115200);
  pinMode(GPIO38, OUTPUT);
  digitalWrite(GPIO38, HIGH);
  Serial.println("Set GPIO38 HIGH");
  delay(500);
  while (!Serial);

  Ethernet.init(driver);

  // start the Ethernet connection:
  Serial.println("Initialize Ethernet with DHCP:");
  if (Ethernet.begin() == 0) {
    Serial.println("Failed to configure Ethernet using DHCP");
    // Check for Ethernet hardware present
    if (Ethernet.hardwareStatus() == EthernetNoHardware) {
      Serial.println("Ethernet shield was not found.  Sorry, can't run without hardware. :(");
      while (true) {
        delay(1); // do nothing, no point running without Ethernet hardware
      }
    }
    if (Ethernet.linkStatus() == LinkOFF) {
      Serial.println("Ethernet cable is not connected.");
    }
    // try to configure using IP address instead of DHCP:
    Ethernet.begin(ip);
  } else {
    Serial.print("  DHCP assigned IP ");
    Serial.println(Ethernet.localIP());
  }

  Serial.print("connecting to ");
  Serial.print(server);
  Serial.println("...");

  // if you get a connection, report back via serial:
  if (client.connect(server, 80)) {
    Serial.print("connected to ");
    Serial.println(client.remoteIP());
    // Make a HTTP request:
    client.println("GET /asciilogo.txt HTTP/1.1");
    client.print("Host: ");
    client.println(server);
    client.println("Connection: close");
    client.println();
  } else {
    // if you didn't get a connection to the server:
    Serial.println("connection failed");
  }
}

void loop() {
  // if there are incoming bytes available
  // from the server, read them and print them:
  while (client.available()) {
    char c = client.read();
    Serial.write(c);
  }

  // if the server's disconnected, stop the client:
  if (!client.connected()) {
    Serial.println();
    Serial.println("disconnecting.");
    client.stop();

    // do nothing forevermore:
    while (true) {
      delay(1);
    }
  }
}

11:56:08.680 -> [   132][V][esp32-hal-periman.c:235] perimanSetBusDeinit(): DeinSet GPIO38 HIGH
11:56:08.680 -> Initialize Ethernet with DHCP:
11:56:08.680 -> manSetPinBus(): Pin 11 successfully set to type SPI_MASTER_MOSI (36) with bus 0x1
11:56:08.743 -> E (1152) w5500.mac: W5500 version mismatched, expected 0x04, got 0x00
11:56:08.743 -> E (1152) w5500.mac: emac_w5500_init(825): vefiry chip ID failed
11:56:08.743 -> E (1153) esp_eth: esp_eth_driver_install(228): init mac failed
11:56:08.743 -> [  1459][E][Ethernet.cpp:210] beginETH(): Ethernet driver install failed: 266
11:56:08.743 -> Failed to configure Ethernet using DHCP
11:56:08.743 -> Ethernet shield was not found.  Sorry, can't run without hardware. :(

the README in EthernetESP32 describes the settings.

with ETH.h try ETH_PHY_ADDR 0

but it looks like it is a hardware problem

using ESP32 Dev Module just loaded and ran File>Examples>EthernetESP32>HelloServer

serial monitor displays

Initialize Ethernet with DHCP:
  DHCP assigned IP 192.168.1.69
MDNS responder started
HTTP server started

web client displays
image

setup looks like
image

EDIT: ran HelloServer with a ESP32_S3_DevKit_1 using connections

 // ESP32_S3_DevKit_1 connections
// ESP32_S3 SCK pin GPIO12  to W5500 SCK
// ESP32_S3 MISO pin GPIO13  to W5500 MISO
// ESP32_S3 MOSI pin GPIO11  to W5500 MOSI
// ESP32_S3 SS  pin GPIO 10   to W5500 SCS

serial monitor displays

Initialize Ethernet with DHCP:
  DHCP assigned IP 192.168.1.70
MDNS responder started
HTTP server started

web client displays
image

setup
image