Ethernet w5500 which library to use?

Good morning,
I am using an Arduino Ethernet Shield with PoE and SD Card.
I followed the Arduino documentation and included Ethernet.h and SPI.h
PIO rightly tells me that the Ethernet.h library is missing. I tried to look for a library in the Libraries Menager but they come out:

  • PubSubClient
  • Time
  • WebSocket
  • Syslog
    etc…

Going already I found the library “Ethernet by Various” and “Ethernet2 by Various”.

You will want to know if I should use one or the other to communicate via SPI with the w5500.

Thank you

What’s the target board and platformio.ini?

Hello! You gave me a hand a few days ago remember? my platfprmio.ini file:

[env:abiot-gateway-arduinoesp32]
platform = https://github.com/tasmota/platform-espressif32/releases/download/v2.0.2idf/platform-espressif32-2.0.2.zip
framework = arduino
board = esp32-s2-saola-1
lib_deps =
knolleary/PubSubClient@^2.8
vshymanskyy/TinyGSM@^0.11.4
plerup/EspSoftwareSerial@^6.13.2
xreef/EByte LoRa E32 library@^1.5.2
adafruit/RTClib@^1.14.1
nickgammon/Regexp@^0.1.0
bblanchon/ArduinoJson@^6.18.5
upload_port = COM15
monitor_port = COM15

I did some tests with the “Ethernet.h by Various” library and the result is this:

— Available filters and text transformations: colorize, debug, default, direct, esp32_exception_decoder, hexlify, log2file, nocontrol, printable, send_on_enter, time
— More details at Redirecting...
— Miniterm on COM15 9600,8,N,1 —
— Quit: Ctrl+C | Menu: Ctrl+T | Help: Ctrl+T followed by Ctrl+H —
␑��!s��M�Initialize Ethernet with DHCP:
Failed to configure Ethernet using DHCP
Ethernet shield was not found. Sorry, can’t run without hardware. :frowning:

I’ve tried searching this forum and others online but they all set a static IP address and I don’t want to.

My products will go to more people and I don’t know which IP to assign, I would like it to be given to me automatically with DHCP.

There are two Arduino libraries for the W5500:

And yes the PIO library registry is horrible.

I have seen these libraries and especially the arduino-libraries one.
But how can I integrate them into my project if there isn’t in the library manager?

They’re both there

Mh :thinking:
So if so I had already done it, I tried to do it again, so in platformio.ini:

platform = https://github.com/tasmota/platform-espressif32/releases/download/v2.0.2idf/platform-espressif32-2.0.2.zip

framework = arduino

board = esp32-s2-saola-1

lib_deps =

knolleary/PubSubClient@^2.8

vshymanskyy/TinyGSM@^0.11.4

plerup/EspSoftwareSerial@^6.13.2

xreef/EByte LoRa E32 library@^1.5.2

adafruit/RTClib@^1.14.1

nickgammon/Regexp@^0.1.0

bblanchon/ArduinoJson@^6.18.5

arduino-libraries/Ethernet@^2.0.0

upload_port = COM15

monitor_port = COM15

In MainETH.cpp I included “#include <Ethernet.h>”

And my setup function:

void setup()

{

    // Set console baud rate

    SerialMon.begin(9600);

    delay(10);

    Ethernet.init(33); // set CS pin

    Serial.println("Initialize Ethernet with DHCP:");

    if (Ethernet.begin(mac) == 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.");

        }

    }

    else

    {

        Serial.print("  DHCP assigned IP ");

        Serial.println(Ethernet.localIP());

    }

    // give the Ethernet shield a second to initialize:

    delay(1000);

    // Serial.print("connecting to ");

    // Serial.print(server);

    // Serial.println("...");

    // MQTT Broker setup

    mqtt.setServer(broker, 1883);

    mqtt.setCallback(mqttCallback);

    mqttConnect();

}

And my serial monitor:

Executing task: C:\Users\Utente.platformio\penv\Scripts\platformio.exe device monitor <

— Available filters and text transformations: colorize, debug, default, direct, esp32_exception_decoder, hexlify, log2file, nocontrol, printable, send_on_enter, time
— More details at Redirecting...
— Miniterm on COM15 9600,8,N,1 —
— Quit: Ctrl+C | Menu: Ctrl+T | Help: Ctrl+T followed by Ctrl+H —
␌L�!�!)␜�Initialize Ethernet with DHCP:
Failed to configure Ethernet using DHCP
Ethernet shield was not found. Sorry, can’t run without hardware. :frowning:

P.S.: I don’t want fixed IP

Can you show a wire diagram for how you connected the Ethernet Shield to your ESP32?

Use Arduino Ethernet Shield 2 with POE (this) and ESP32-S2 Saola 1R ([this](https://ESP32-S2-SAOLA-1R ESPRESSIF))
ETH SHIELD—>ESP32-S2
SCK—>PIN 36 SCK
MISO—>PIN 37 MISO
MOSI—>PIN 35 MOSI
SS for Ethernet controller—>PIN 33 (I had tried to connect also in the PIN 34 SS of ESP32-S2 but same result)

This looks good per default SPI pins.

Per schematic the shield powers itself via the 3.3V (and GND) connection. Did you plug 3.3V into the 3.3V port or did you use 5V?

I feed the Ethernet card through a DC / DC 12V5V voltage regulator

Oh sorry, I overlooked the second page of the schematic with the power regulation. The board is not powered by 3.3V at the input, but has its own 5V->3.3V regulator (or via the ethernet jack / PoE it created the VIN voltage through a AG9612-2BR converter).

So you feed 5V to the shield’s “+5V” pin? Also you put 5V on the RESET pin to prevent the module from being deactivated?

I had not put the 5V on the RESET PIN.
Now I put it on but the result doesn’t change

If I read the schematics correctly, some logic-shifter ICs are powered by the IOREF pin.

Can you put 3.3V on the IOREF pin too?

I don’t know what pattern you are looking at, the right one is this
and there is no connection on the IOREF PIN nor on VIN and 3.3V
I tried to connect the RESET PIN of the Shield to the RESET pin of the ESP32-S2 but nothing changes … :tired_face:

Now I tried to connect directly to the ICSP Header but same result.

I did a test with an arduino uno linked below with the WebClient example and it works on the first try.

Are we sure the library is the same?

Arduino Skatch

/*
Web client

This sketch connects to a website (http://www.google.com)
using an Arduino Wiznet Ethernet shield.

Circuit:

  • Ethernet shield attached to pins 10, 11, 12, 13

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

*/

#include <SPI.h>
#include <Ethernet.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 = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };

// if you don’t want to use DNS (and reduce your sketch size)
// use the numeric IP instead of the name for the server:
//IPAddress server(74,125,232,128); // numeric IP for Google (no DNS)
char server = “www.google.com”; // name address for Google (using DNS)

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

// 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;

// Variables to measure the speed
unsigned long beginMicros, endMicros;
unsigned long byteCount = 0;
bool printWebData = true; // set to false for better speed measurement

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”);
// 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 congifure using IP address instead of DHCP:
Ethernet.begin(mac, ip, myDns);
} else {
Serial.print(" DHCP assigned IP ");
Serial.println(Ethernet.localIP());
}
// give the Ethernet shield a second to initialize:
delay(1000);
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 /search?q=arduino HTTP/1.1”);
client.println(“Host: www.google.com”);
client.println(“Connection: close”);
client.println();
} else {
// if you didn’t get a connection to the server:
Serial.println(“connection failed”);
}
beginMicros = micros();
}

void loop() {
// if there are incoming bytes available
// from the server, read them and print them:
int len = client.available();
if (len > 0) {
byte buffer[80];
if (len > 80) len = 80;
client.read(buffer, len);
if (printWebData) {
Serial.write(buffer, len); // show in the serial monitor (slows some boards)
}
byteCount = byteCount + len;
}

// if the server’s disconnected, stop the client:
if (!client.connected()) {
endMicros = micros();
Serial.println();
Serial.println(“disconnecting.”);
client.stop();
Serial.print(“Received “);
Serial.print(byteCount);
Serial.print(” bytes in “);
float seconds = (float)(endMicros - beginMicros) / 1000000.0;
Serial.print(seconds, 4);
float rate = (float)byteCount / seconds / 1000.0;
Serial.print(”, rate = “);
Serial.print(rate);
Serial.print(” kbytes/second”);
Serial.println();

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

}
}

Serial Monitor Response:

Initialize Ethernet with DHCP:
12:56:22.989 → DHCP assigned IP 10.0.0.31
12:56:23.966 → connecting to www.google.com
12:56:24.013 → connected to 216.58.209.36
12:56:24.202 → HTTP/1.1 200 OK
12:56:24.202 → Content-Type: text/html; charset=ISO-8859-1
12:56:24.249 → Date: Sat, 12 Feb 2022 11:56:24 GMT
12:56:24.295 → Expires: -1
12:56:24.342 → Cache-Control: private, max-age=0
12:56:24.342 → P3P: CP=“This is not a P3P policy! See P3P and Google's cookies - Google Account Help for more info.”
12:56:24.435 → Server: gws
12:56:24.435 → X-XSS-Protection: 0
12:56:24.481 → X-Frame-Options: SAMEORIGIN
12:56:24.481 → Set-Cookie: NID=511=praXIhaK2cF2rm7uFh1cxAOdIXmZ1oz44p_w1LeQD5jyFJt6nTG90mU4Z02sVWNANTlWvV7uvI4S_OyQCVyd9dh8ZUh7BsPoXNKRdGemVzcwaPjUN-SFgF9d4pgfYHy8ML9MCBWhBONELsa1w2Uha3DwvEwAd4JL2qrnPvv28lo; expires=Sun, 14-Aug-2022 11:56:24 GMT; path=/; domain=.google.com; HttpOnly
12:56:24.763 → Accept-Ranges: none
12:56:24.810 → Vary: Accept-Encoding
12:56:24.810 → Connection: close
12:56:24.857 → Transfer-Encoding: chunked
12:56:24.857 →
12:56:24.857 → 3478
12:56:24.857 → <!doctype html>arduino - Cerca con Google(function(){
12:56:25.137 → document.documentElement.addEventListener(“submit”,function(b){var a;if(a=b.target){var c=a.getAttribute(“data-submitfalse”);a=“1”===c||“q”===c&&!a.elements.q.value?!0:!1}else a=!1;a&&(b.preventDefault(),b.stopPropagation())},!0);document.documentElement.addEventListener(“click”,function(b){var a;a:{for(a=b.target;a&&a!==document.documentElement;a=a.parentElement)if(“A”===a.tagName){a=“1”===a.getAttribute(“data-nohref”);break a}a=!1}a&&b.preventDefault()},!0);}).call(this);(function(){
12:56:25.652 → var a=window.performance;window.start=Date.now();a:{var b=window;if(a){var c=a.timing;if(c){var d=c.navigationStart,f=c.responseStart;if(f>d&&f<=window.start){window.start=f;b.wsrt=f-d;break a}}a.now&&(b.wsrt=Math.floor(a.now()))}}window.google=window.google||{};var h=function(g){g&&g.target.setAttribute(“data-iml”,Date.now())};document.documentElement.addEventListener(“load”,h,!0);google.rglh=function(){document.documentElement.removeEventListener(“load”,h,!0)};}).call(this);(function(){window.google.erd={jsr:1,bv:1529,de:true};})();(function(){var sdo=false;var mei=10;
12:56:26.258 → var f=this||self;var g,h,k=null!==(g=f.mei)&&void 0!==g?g:1

RESOLVED!!!
In practice, I (as per official documentation) connected the SPI PINs to pins 11, 12 and 13 while 10 is SS
On the other hand, by carefully analyzing the Arduino Ethernet Shield 2 scheme, it is clear that the PINs 11 and 12 are not connected to anything.
The SPI connection goes through the ICSP connector and that’s it.


Oh my god what outdated documentation :face_with_symbols_over_mouth:

Thank you all for your support and I hope this can help someone else too.

You have 3.3V there? That’s IOREF.

Oh that’s a good observation too, I missed that. Does it fully work now, even without IOREF? Weird that both our schematics aer labeled as EthernetShield2V2.0_sch.pdf (and arduino-Ethernet-Shield2-V2-sch.pdf) but they have different internal connections.

Can you summarize all your hardware connctions between the ESP32 and the Ethernet Shield V2.0 with PoE?