Good day, everyone.
I am trying to connect and use the W5500 Ethernet module to an ESP32 to use a wired connection instead of a wifi one.
I have tried several solutions including the following:
ESP32_W5500_NTP_CLIENT
UIPEthernet
However as I was not able to get these to even compile, I reverted back to the Arduino provided example
#include <SPI.h>
#include <Ethernet.h>
// network configuration. gateway and subnet are optional.
// the media access control (ethernet hardware) address for the shield:
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
//the IP address for the shield:
byte ip[] = { 10, 0, 0, 177 };
// the router's gateway address:
byte gateway[] = { 10, 0, 0, 1 };
// the subnet:
byte subnet[] = { 255, 255, 0, 0 };
// telnet defaults to port 23
EthernetServer server = EthernetServer(23);
void setup()
{
// initialize the ethernet device
Ethernet.begin(mac, ip, gateway, subnet);
// start listening for clients
server.begin();
}
void loop()
{
// if an incoming client connects, there will be bytes available to read:
EthernetClient client = server.available();
if (client == true) {
// read bytes from the incoming client and write them back
// to any clients connected to the server:
server.write(client.read());
}
}
This was a straight copy paste of the example code. It works on an arduino Uno but does not on an ESP32.
This is the compile error. I am able to push simpler sketches including the WIFI one and Blink.
ESP_ETH2:14:42: error: invalid cast to abstract class type 'EthernetServer'
EthernetServer server = EthernetServer(23);
^
In file included from C:\Users\owner\Documents\Arduino\ESP_ETH2\ESP_ETH2.ino:2:
C:\Program Files (x86)\Arduino\libraries\Ethernet\src/Ethernet.h:253:7: note: because the following virtual functions are pure within 'EthernetServer':
class EthernetServer : public Server {
^~~~~~~~~~~~~~
In file included from C:\Users\owner\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.1\cores\esp32/Arduino.h:165,
from sketch\ESP_ETH2.ino.cpp:1:
C:\Users\owner\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.1\cores\esp32/Server.h:28:18: note: 'virtual void Server::begin(uint16_t)'
virtual void begin(uint16_t port=0) =0;
^~~~~
ESP_ETH2:14:16: error: cannot declare variable 'server' to be of abstract type 'EthernetServer'
EthernetServer server = EthernetServer(23);
^~~~~~
exit status 1
invalid cast to abstract class type 'EthernetServer'