W5500 Lite Problem in ESP32(SOLVED)

Good day, I want to use w5500 lite ethernet module with mqtt using esp32. However, I get the error Could not configure Ethernet using DHCP. The code and module links I used are attached.

#include <Ethernet.h>
#include <PubSubClient.h>

byte mac[] = {0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED};

EthernetClient net;
PubSubClient client;  

unsigned long lastMillis = 0;

void connect() {
  Serial.print("connecting...");
  while (!client.connect("arduino32")) {


  }

  Serial.println("\nconnected!");

  client.subscribe("/hello");
  // client.unsubscribe("/hello");
}

void callback(char* topic, byte* payload, unsigned int length) {
}

void setup() {
  Serial.begin(57600);
  Serial.println("Start Setup");
if (Ethernet.begin(mac)==0){
  Serial.println("Failed to configure Ethernet using DHCP");
  for(;;)
  ;
  }
  Ethernet.begin(mac, Ethernet.localIP());
 Serial.println("Start MQTT");
  client.setKeepAlive(90);
  client.setClient(net);
  client.setServer("xx.xxx.xxx.xxx", 1883);
  client.setCallback(callback);

  connect();
}

void loop() {


  if (!client.connected()) {

    connect();
  }


  // publish a message roughly every second.
  if (millis() - lastMillis >5000) {
    lastMillis = millis();
    client.publish("/hello", "world");

  }
  client.loop();
}

buy a LAN8720 module and see the ETH_LAN8720 example of the WiFi library

I want to use w5500 because the dimensions are ideal, I drew the PCB circuit :frowning:

but the esp32 already has a MAC peripheral a TCP/IP stack and Arduino networking library and you duplicate this all with a W5500 and Ethernet library

Isn't it possible to use it with W5500 esp32?

Which pin are you using for chip select?

ESP32 / W5500
23 ------> MO
19 ------> MI
18 ------> SCK
5 ------> CS

Have a look inside the library to see what it is using by default. On the Uno it's pin 10 but I have no idea what it uses on the ESP32.

default pins i wrote

try Ethernet.init(5); before Ethernet.begin

and it should be PubSubClient client(net);

1 Like

Thank you very much i was researching this problem for 2 days you saved me from a big mess.