EthernetENC library showing garbage values when used

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.

Here is the code:

/*
  DHCP-based IP printer

  This sketch uses the DHCP extensions to the Ethernet library
  to get an IP address via DHCP and print the address obtained.
  using an Arduino Wiznet Ethernet shield.

  Circuit:
   Ethernet shield attached to pins 10, 11, 12, 13

  created 12 April 2011
  modified 9 Apr 2012
  by Tom Igoe
  modified 02 Sept 2015
  by Arturo Guadalupi

*/

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

// Enter a MAC address for your controller below.
// Newer Ethernet shields have a MAC address printed on a sticker on the shield
byte mac[] = {
  0x00, 0xAA, 0xBB, 0xCC, 0xDE, 0x02
};

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(33);  // ESP32 with Adafruit Featherwing Ethernet

  // Open serial communications and wait for port to open:
  Serial.begin(9600);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for native USB port only
  }

  // start the Ethernet connection:
  Serial.println("Initialize Ethernet with DHCP:");
  if (Ethernet.begin(mac) == 0) {
    Serial.println("Failed to configure Ethernet using DHCP");
    if (Ethernet.hardwareStatus() == EthernetNoHardware) {
      Serial.println("Ethernet shield was not found.  Sorry, can't run without hardware. :(");
    } else if (Ethernet.linkStatus() == LinkOFF) {
      Serial.println("Ethernet cable is not connected.");
    }
    // no point in carrying on, so do nothing forevermore:
    while (true) {
      delay(1);
    }
  }
  // print your local IP address:
  Serial.print("My IP address: ");
  Serial.println(Ethernet.localIP());
}

void loop() {
  switch (Ethernet.maintain()) {
    case 1:
      //renewed fail
      Serial.println("Error: renewed fail");
      break;

    case 2:
      //renewed success
      Serial.println("Renewed success");
      //print your local IP address:
      Serial.print("My IP address: ");
      Serial.println(Ethernet.localIP());
      break;

    case 3:
      //rebind fail
      Serial.println("Error: rebind fail");
      break;

    case 4:
      //rebind success
      Serial.println("Rebind success");
      //print your local IP address:
      Serial.print("My IP address: ");
      Serial.println(Ethernet.localIP());
      break;

    default:
      //nothing happened
      break;
  }
}

This is the output:

 ⸮E⸮G⸮a⸮X⸮b⸮!pa⸮Initialize Ethernet with DHCP:

Please help me understand what I am doing wrong here

it has nothing to do with the EthernetENC library.
does you board have CH340 USB chip?

No, my ESP32 board doesn’t have CH340 chip. This is the ESP32 I am using. the ethernet module doesn’t have that chip either.

use 115200 baud in sketch and Serial Monitor and you will see that the garbage is the esp32 boot log at 115200 baud at 9600 baud

Ohh yes that's right. But why Isn't IP address printed then?

maybe it hangs in Ethernet.begin(mac)? is your CS pin really 33?

Yes the CS pin is 33

shruti02:
Yes the CS pin is 33

try an example which doesn’t use DHCP to get the IP address. for example the WebServer example.

I tried that 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 shield was not found.  Sorry, can't run without hardware. :(

The ethernet module is not detected.
My connection are as follows:
Ethernet module ----> ESP32
3.3V ----> 3.3V
GND ----> GND
SCK----> P14
MOSI ----> P13
MISO ----> P12
CS ----> P33

MAC address was the one assigned to ESP32 ( tried a unique mac address too) and
IP address is closer to the one my PC has, since I wasn't able to find the IP address of ethernet module. (Like IPv4 is 192.168.0.10 so in the code I put it as 192.168.0.9)

Is the ethernet module broken or am I missing something here?

the library uses SPI library. SPI library uses pins
MOSI = 23;
MISO = 19;
SCK = 18;
and default CS is 5

Oh it worked!! Thank you so much for helping :slight_smile: