ENC28J60 Ethernet module with ESP32 not working

Hello everyone,
I am facing problems while reading IP address of my Ethernet module using EthernetENC.h library. I am using this ethernet module and ESP32. I have used the example code given in arduino’s Ethernet.h library and simply replaced #include<Ethernet.h> with #include<EthernetENC.h>. The example code is named DhcpAddressPrinter.
The code works perfectly fine and I can see the IP address as an output on the serial monitor.

But, when I use a different code (took reference from the code given here) I get the output as “Ethernet cable not detected”. Even the blinking LEDs near ethernet cable go OFF

Here is my code:

#include <EthernetENC.h>
#include <SPI.h>

// Enter a MAC address and IP address for your controller below.
// The IP address will be dependent on your local network:
byte mac[] = {
  0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED   // here I put the mac of ESP32
};
IPAddress ip(116,75,59,24);  // This is the IP address I got in the output of DhcpAddressPrinter code
IPAddress serv(192, 168, 0, 10);  // This is my PC's IPv4 address
String tagID = "123ABC";
String RTCtime2 = "2020-11-28%2011:58:30";
String GateNO = "gate4";

// Initialize the Ethernet server library
// with the IP address and port you want to use
// (port 80 is default for HTTP):
//EthernetServer server(80);
EthernetClient cliente;

void setup() {
  // You can use Ethernet.init(pin) to configure the CS pin
  //Ethernet.init(10);  // Most Arduino shields
  //Ethernet.init(5);   // MKR ETH shield
  //Ethernet.init(0);   // Teensy 2.0
  //Ethernet.init(20);  // Teensy++ 2.0
  //Ethernet.init(15);  // ESP8266 with Adafruit Featherwing Ethernet
  Ethernet.init(5);  // ESP32 with Adafruit Featherwing Ethernet

  // Open serial communications and wait for port to open:
  Serial.begin(115200);
  //  while (!Serial) {
  //    ; // wait for serial port to connect. Needed for native USB port only
  //  }
  Serial.println("Ethernet WebServer Example");

  // start the Ethernet connection and the server:
  Ethernet.begin(mac, ip);

  // 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.");
  }

  // start the server
  //  server.begin();
  //  Serial.print("server is at ");
  //  Serial.println(Ethernet.localIP());
}


void loop() {
  // listen for incoming clients
  // EthernetClient client = server.available();
  if (cliente.connect(serv, 80)) {
    Serial.println("new client");
    // send a standard http response header
    cliente.print(String("GET http://192.168.0.10/connect4.php?") +
                 ("tagID=") + tagID + ("&RTCtimestamp=") + RTCtime2 + ("&GateNO=") + GateNO +
                 ("&i=1") +
                 " HTTP/1.1\r\n" +
                 "Host: " + serv + "\r\n" +
                 "Connection: Keep-Alive\r\n\r\n");
    // output the value of each analog input pin
    Serial.println(String("GET http://192.168.0.10/connect4.php?") +
                   ("tagID=") + tagID + ("&RTCtimestamp=") + RTCtime2 + ("&GateNO=") + GateNO +
                   " HTTP/1.1\r\n" +
                   "Host: " + serv + "\r\n" +
                   "Connection: Keep-Alive\r\n\r\n");

  }
  // give the web browser time to receive the data
  delay(1);
  // close the connection:
  cliente.stop();
  Serial.println("client disconnected");
}

And this is the output:

ets Jun  8 2016 00:22:57

rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:1
load:0x3fff0018,len:4
load:0x3fff001c,len:1044
load:0x40078000,len:8896
load:0x40080400,len:5816
entry 0x400806ac
Ethernet WebServer Example
Ethernet cable is not connected.

My connections are as follows:
MOSI = 23;
MISO = 19;
SCK = 18;
CS = 5;
3.3V=3.3V
GND=GND

I’m probably doing something wrong in the code but I can’t see it. Please help me find the mistake here.

it takes a little time until the link is detected if you use a static IP.

if (Ethernet.linkStatus() == LinkOFF) {
delay(500);
if (Ethernet.linkStatus() == LinkOFF) {
Serial.println("Ethernet cable is not connected.");
}
}

I tried that and now I'm getting following output:

ets Jun  8 2016 00:22:57

rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:1
load:0x3fff0018,len:4
load:0x3fff001c,len:1044
load:0x40078000,len:8896
load:0x40080400,len:5816
entry 0x400806ac
Ethernet WebServer Example
client disconnected
client disconnected
client disconnected

Thank you Shruti02 and Juraj,
i was trying to communicate ESP32 DOIT ESP32 DEVKIT V1 board with ENC28J60 Ethernet Module.
I tried lot of things, different forums, but no luck.
I came across your post. And followed to get success.
I could run DhcpAddressPrinter, WebClient and WebServer.
For the Client i got really long output :

  DHCP assigned IP 192.168.1.5
connecting to www.google.com...
connected to 142.250.67.228
HTTP/1.1 200 OK
Content-Type: text/html; charset=ISO-8859-1
Date: Wed, 16 Dec 2020 10:24:51 GMT
Expires: -1
Cache-Control: private, max-age=0
P3P: CP="This is not a P3P policy! See g.co/p3phelp for more info."
Server: gws
X-XSS-Protection: 0
X-Frame-Options: SAMEORIGIN
Set-Cookie: 1P_JAR=2020-12-16-10; expires=Fri, 15-Jan-2021 10:24:51 GMT; path=/; domain=.google.com; Secure
Set-Cookie: CGIC=; expires=Mon, 14-Jun-2021 10:24:51 GMT; path=/complete/search; domain=.google.com; HttpOnly
Set-Cookie: CGIC=; expires=Mon, 14-Jun-2021 10:24:51 GMT; path=/search; domain=.google.com; HttpOnly
Set-Cookie: NID=205=L8XyJrd2sJ1S_y68bMB8k4rYpWPWEvAVW86oaW-suqaZnI9sVUAIg3MdfyoPeEuyEfNwrHXaLr_g46IF8aTfJpgkCX8iu974SvlG7FLSZSbYLmG2eFheoGa15lHcEj1q5aM5TyqeIuio9GH4s18OmWS84qPlOFBDfrrAYfNUWkQ; expires=Thu, 17-Jun-2021 10:24:51 GMT; path=/; domain=.google.com; HttpOnly
Accept-Ranges: none
Vary: Accept-Encoding
Connection: close
Transfer-Encoding: chunked

For the WebServer and others i observed that it takes time to get started. I did not put the delay for now. But i could connect automatically after some time.
For this patch below it seams the ESP32 is restarting, may be buffer overflow or any other reason. But ESP is not able to handle the code and thus restarting.

ets Jun  8 2016 00:22:57[color=#222222][/color]
[color=#222222][/color]
rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)[color=#222222][/color]
configsip: 0, SPIWP:0xee[color=#222222][/color]
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00[color=#222222][/color]
mode:DIO, clock div:1[color=#222222][/color]
load:0x3fff0018,len:4[color=#222222][/color]
load:0x3fff001c,len:1044[color=#222222][/color]
load:0x40078000,len:8896[color=#222222][/color]
load:0x40080400,len:5816[color=#222222][/color]
entry 0x400806ac[color=#222222][/color]
Ethernet WebServer Example[color=#222222][/color]
client disconnected[color=#222222][/color]
client disconnected[color=#222222][/color]
client disconnected

Anyways, thanks for the pin connection and code modifications. It really helped my.

For the other issue in post :

But, when I use a different code (took reference from the code given here) I get the output as "Ethernet cable not detected". Even the blinking LEDs near ethernet cable go OFF

I observed that when ESP32 is attached to ENC28J60 Ethernet module using SPI wires, when i download the new sketch / code into it and if LAN cable is attached into module, then the LED of LAN module stops blinking, i don't know the actual reason, but my router had virtually disconnected signals. When i re-plug in the cable, then LED started to blink again. SO later i started to disconnect the LAN cable when downloading sketch.