ESP32 + W5500 Ethernet Webserver Example not working

Hello, I want to use the W5500 Ethernet Board (SPI) in combination with a ESP32 Dev Board. I know that this is a known issue. I cant get it to compile, i tried a couple of libs and methodes, but it wont work:

cannot declare variable 'server' to be of abstract type 'EthernetServer'

I just want to get the Webserver Example to work, can anyone help me with that? :cry:

Do you think it might help if you provided full details of the hardware and your code ?

Please follow the advice on posting a programming question given in Read this before posting a programming question

In particular note the advice to Auto format code in the IDE and to use code tags when posting code here as it prevents some combinations of characters in code being interpreted as HTML commands such as italics, bold or a smiley character, all of which render the code useless

/*
  Web Server

 A simple web server that shows the value of the analog input pins.
 using an Arduino Wiznet Ethernet shield.

 Circuit:
 * Ethernet shield attached to pins 10, 11, 12, 13
 * Analog inputs attached to pins A0 through A5 (optional)

 created 18 Dec 2009
 by David A. Mellis
 modified 9 Apr 2012
 by Tom Igoe
 modified 02 Sept 2015
 by Arturo Guadalupi
 
 */

#include <SPI.h>
#include <Ethernet.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
};
IPAddress ip(192, 168, 1, 177);

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

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
  }
  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 (client) {
    Serial.println("new client");
    // an http request ends with a blank line
    boolean currentLineIsBlank = true;
    while (client.connected()) {
      if (client.available()) {
        char c = client.read();
        Serial.write(c);
        // if you've gotten to the end of the line (received a newline
        // character) and the line is blank, the http request has ended,
        // so you can send a reply
        if (c == '\n' && currentLineIsBlank) {
          // send a standard http response header
          client.println("HTTP/1.1 200 OK");
          client.println("Content-Type: text/html");
          client.println("Connection: close");  // the connection will be closed after completion of the response
          client.println("Refresh: 5");  // refresh the page automatically every 5 sec
          client.println();
          client.println("<!DOCTYPE HTML>");
          client.println("<html>");
          // output the value of each analog input pin
          for (int analogChannel = 0; analogChannel < 6; analogChannel++) {
            int sensorReading = analogRead(analogChannel);
            client.print("analog input ");
            client.print(analogChannel);
            client.print(" is ");
            client.print(sensorReading);
            client.println("
");
          }
          client.println("</html>");
          break;
        }
        if (c == '\n') {
          // you're starting a new line
          currentLineIsBlank = true;
        } else if (c != '\r') {
          // you've gotten a character on the current line
          currentLineIsBlank = false;
        }
      }
    }
    // give the web browser time to receive the data
    delay(1);
    // close the connection:
    client.stop();
    Serial.println("client disconnected");
  }
}

Thanks for your quick response, this is the Example, but i tried many different approaches.
Im using a board like this: W5500 Ethernet netzwerk modul hardware TCP / IP 51 / STM32 mikrocontroller programm über W5100 A32|tcp ip|programming microcontrollers - AliExpress

I did a google-search and found this site

though I don't know igf this solves your problems.
As an ESP32 has WLAN on board would these be an alternative option?

best regards Stefan

Hello Stefan, I already tried this and it was working just fine but then I tried to modify that code to work as Webserver, but the same issue occurred...

does someone have another idea to solve this problem?

I know that this is a known issue

Where did you see this ?

I ment that im not the only one with this problem :confused:

Philipp_Gretscher:
I ment that im not the only one with this problem :confused:

I give up

And i found the solution !!! Use the Ethernet2 Lib, but NOT from the LibManager. Use this one and copy it yourself into the Lib folder :slight_smile:

You can also try this EthernetWebServer Library, especially these examples written for ESP32/ESP8266

  1. WebClientRepeating_ESP
  2. WebClient_ESP

and also

Libraries Patches

  1. To fix ESP32 compile error, just copy the following file into the ESP32 cores/esp32 directory (e.g. ./arduino-1.8.12/hardware/espressif/cores/esp32) to overwrite the old file:
    Server.h

Philipp_Gretscher:
And i found the solution !!! Use the Ethernet2 Lib, but NOT from the LibManager. Use this one and copy it yourself into the Lib folder :slight_smile:

That worked for me too. Thank you very much! :smiley:

Philipp_Gretscher:
And i found the solution !!! Use the Ethernet2 Lib, but NOT from the LibManager. Use this one and copy it yourself into the Lib folder :slight_smile:

can you share your program at farikareem@gmail.com?

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.