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.

   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:
  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) {
  // print your local IP address:
  Serial.print("My IP address: ");

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

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

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

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

      //nothing happened

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

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

configsip: 0, SPIWP:0xee
mode:DIO, clock div:1
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 so in the code I put it as

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: