Hello,
I have been trying to integrate a w5500 ethernet module with an esp32-s3 for days now, but to no success. I even used the connections and code defined here, but it doesn't work for me either.
I am using an ESP32-S3 NO PSRAM and I just want to connect it to the internet using the W5500 module.
Hello @fareed99,
can you please put a schematic for your connections and your code here so we can see what have you all done?
So we may be able to help you.
Sure, my bad. I should have included it in my question. Anyways, here are the connections and the code.
W5500 -> ESP32-S3
CS -> 10
MOSI -> 11
CLK -> 12
MISO -> 13
3.3V -> 3.3V
GND -> GND
#include <EthernetWebServer.h>
#include <Ethernet_Generic.h>
#define SPI_FREQ 32000000
// MAC and IP address for the Ethernet communication
byte mac[] = {0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED};
IPAddress ip(10, 10, 225, 210);
// (port 80 is default for HTTP):
EthernetWebServer server(80);
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
while(!Serial);
SPI.setFrequency(SPI_FREQ);
Ethernet.init(10);
delay(2000);
// Start the ethernet connection and the server:
Ethernet.begin(mac, ip);
Serial.println("Ethernet has begun!");
delay(500);
if (Ethernet.hardwareStatus() == EthernetNoHardware)
{
Serial.println("No Ethernet found");
while (true)
{
delay(1); // do nothing, no point running without Ethernet hardware
}
}
if (Ethernet.linkStatus() == 2)
{
Serial.println("No Ethernet cable");
}
delay(1000);
server.begin();
Serial.print("IP Address: ");
Serial.println(Ethernet.localIP());
}
void loop() {
// put your main code here, to run repeatedly:
}
I got it working with this library here along with this sample code
#if !( defined(ESP32) )
#error This code is designed for (ESP32_S2/3, ESP32_C3 + W5500) to run on ESP32 platform! Please check your Tools->Board setting.
#endif
#define DEBUG_ETHERNET_WEBSERVER_PORT Serial
// Debug Level from 0 to 4
#define _ETHERNET_WEBSERVER_LOGLEVEL_ 3
// Optional values to override default settings
// Don't change unless you know what you're doing
//#define ETH_SPI_HOST SPI3_HOST
//#define SPI_CLOCK_MHZ 25
// Must connect INT to GPIOxx or not working
#define INT_GPIO 16
#define MISO_GPIO 21
#define MOSI_GPIO 14
#define SCK_GPIO 47
#define CS_GPIO 38
//////////////////////////////////////////////////////////
#include <WebServer_ESP32_SC_W5500.h>
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x01 };
void setup() {
Serial.begin(115200);
// To be called before ETH.begin()
ESP32_W5500_onEvent();
ETH.begin(MISO_GPIO, MOSI_GPIO, SCK_GPIO, CS_GPIO, INT_GPIO, SPI_CLOCK_MHZ, ETH_SPI_HOST, mac);
ESP32_W5500_waitForConnect();
String ethernet_dhcp_ip = ETH.localIP().toString();
Serial.print(F("HTTP EthernetWebServer is @ IP : "));
Serial.println(ethernet_dhcp_ip);
}
void loop() {
}
The library demands INT pin of W5500 has to be connected to one of the ESP32-S3 GPIO for it to work
Hi @KASSIMSAMJI thanks for your reply. I'll try this out now and then post the results here.
However, did you get it working with an ESP32-S3?
Try the following:
try to use spi.define() function but you will need to include the spi library.
Try another pins:
#define SCK 36
#define SS 38
#define MOSI 35
#define MISO 37
the in the setup function:
SPI.begin(SCK, MISO, MOSI, SS);
SPI.setFrequency(SPI_FREQ);
Ethernet.init(SS);
When you use the serial, which error message do you get?
Yes I did
Thanks @hamokhalil for your reply. Unfortunately, I'm not even able to reach the Serial monitor as the compilation throws the following error.
In file included from /Users/fareedahmad/Documents/Arduino/libraries/EthernetWebServer/src/EthernetWebServer.h:67,
from /Users/fareedahmad/Documents/Arduino/Ethernet_Test/Ethernet_Test.ino:1:
/Users/fareedahmad/Documents/Arduino/libraries/EthernetWebServer/src/EthernetWebServer.hpp:576:22: error: cannot declare field 'EthernetWebServer::_server' to be of abstract type 'EthernetServer'
EthernetServer _server;
^~~~~~~
In file included from /Users/fareedahmad/Documents/Arduino/libraries/Ethernet_Generic/src/Ethernet_Generic.h:84,
from /Users/fareedahmad/Documents/Arduino/libraries/EthernetWebServer/src/EthernetWebServer.h:58,
from /Users/fareedahmad/Documents/Arduino/Ethernet_Test/Ethernet_Test.ino:1:
/Users/fareedahmad/Documents/Arduino/libraries/Ethernet_Generic/src/Ethernet_Generic.hpp:532:7: note: because the following virtual functions are pure within 'EthernetServer':
class EthernetServer : public Server
^~~~~~~~~~~~~~
In file included from /Users/fareedahmad/Library/Arduino15/packages/esp32/hardware/esp32/2.0.11/cores/esp32/Arduino.h:182,
from sketch/Ethernet_Test.ino.cpp:1:
/Users/fareedahmad/Library/Arduino15/packages/esp32/hardware/esp32/2.0.11/cores/esp32/Server.h:28:18: note: 'virtual void Server::begin(uint16_t)'
virtual void begin(uint16_t port=0) =0;
^~~~~
Multiple libraries were found for "EthernetWebServer.h"
Used: /Users/fareedahmad/Documents/Arduino/libraries/EthernetWebServer
Not used: /Users/fareedahmad/Documents/Arduino/libraries/EthernetWebServer-master
Multiple libraries were found for "functional-vlpp.h"
Used: /Users/fareedahmad/Documents/Arduino/libraries/Functional-Vlpp
Not used: /Users/fareedahmad/Documents/Arduino/libraries/functional-vlpp-master
exit status 1
Error compiling for board ESP32S3 Dev Module.
It is the same error that I was getting with the original code I was trying with.
@KASSIMSAMJI I added the library you pointed to, made the connections as defined in your code, and I was able to upload the code your provided. However, the Serial just prints "ETH Started" and nothing after that. Whereas, it should print the IP address after that.
Go to here:
/Users/fareedahmad/Library/Arduino15/packages/esp32/hardware/esp32/2.0.11/cores/esp32/Server.h
Then make the following change:
virtual void begin(uint16_t port=0) =0;
to:
virtual void begin() = 0;
then save it.
And now try to compile your code and upload it
Thanks @hamokhalil the code uploaded after this change.
But there is an error in the Serial Monitor:
[ETG] W5100::init: no chip :-(
Ethernet has begun!
No Ethernet found
Post your code please
#include <EthernetWebServer.h>
#include <Ethernet_Generic.h>
#include <SPI.h>
#define SCK 36
#define SS 38
#define MOSI 35
#define MISO 37
#define SPI_FREQ 32000000
// MAC and IP address for the Ethernet communication
byte mac[] = {0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED};
IPAddress ip(10, 10, 225, 210);
// (port 80 is default for HTTP):
EthernetWebServer server(80);
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
SPI.begin(SCK, MISO, MOSI, SS);
SPI.setFrequency(SPI_FREQ);
Ethernet.init(SS);
delay(2000);
// Start the ethernet connection and the server:
Ethernet.begin(mac, ip);
Serial.println("Ethernet has begun!");
delay(500);
if (Ethernet.hardwareStatus() == EthernetNoHardware)
{
Serial.println("No Ethernet found");
while (true)
{
delay(1); // do nothing, no point running without Ethernet hardware
}
}
if (Ethernet.linkStatus() == 2)
{
Serial.println("No Ethernet cable");
}
delay(1000);
server.begin();
Serial.print("IP Address: ");
Serial.println(Ethernet.localIP());
}
void loop() {
// put your main code here, to run repeatedly:
}
this ^^^ is all obsolete. with esp32 arduino version3 you can use for W5500 the bundled Ethernet library (or my EthernetSP32) library with the bundled WebServer library
EthernetSP32 has the same API as the Arduino Ethernet library while the bundled ETH object from the bundled Ethernet library is different
bundled = installed with the boards package (a.k.a. platform) and maintained with the plaform
Are you sure that you are connecting the W5500 module correctly to the ESP32S3?
i mean hardware connections.
I did a short test on all the wires running between the module and the ESP32S3. It turns out the MOSI wire didn't have a copper wire inside the cover. Changed the wire and it works.
Thank you so much @hamokhalil for your help.
My next step is to program the ESP32S3 as an MQTTClient using ethernet connection. Can you direct me towards a reference for that?
Thanks a bunch again!
i am glad that it works now.
In the examples in your EthernetWEbServer Library you may find an example which may guide you to your goal.
I will try to find something and guide you.
Thank you so much @hamokhalil you're a lifesaver!
Have you managed to program your MQtt Client?
Have a look at this tutorial, he is using WiFi but basically it should not be to different.
You have to use EthernetClient.
Try it and let us see if it works
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.