Hello everyone,
I'm trying to create a UDP message sender using my Arduino Mega with a W5500 Ethernet module. I wired the W5500 to the Mega as shown in the diagram below:
I use the MISO, MOSI, SCK and Hardware SS
Here's the code I'm using to send a UDP message to my computer:
#include <SPI.h>
#include <Ethernet.h>
#include <EthernetUdp.h>
// MAC dan IP statis Arduino
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress ip(192, 168, 2, 177); // IP Arduino
// IPAddress subnet(255, 255, 255, 0);
EthernetUDP Udp;
unsigned int localPort = 8888; // Port UDP lokal Arduino
void setup() {
Serial.begin(9600);
while (!Serial) {}
Serial.println("Starting Ethernet...");
Ethernet.begin(mac, ip);
delay(1000);
Serial.println("Starting UDP...");
Udp.begin(localPort);
Serial.println("Setup complete.");
}
void loop() {
IPAddress remoteIp(192, 168, 2, 100);
unsigned int remotePort = 9999;
Udp.beginPacket(remoteIp, remotePort);
Udp.write("Hello from Arduino");
Udp.endPacket();
Serial.println("Message sent.");
delay(1000); // Kirim tiap 1 detik
}
The serial monitor shows "Message sent.", but my computer doesn't receive anything.
I've already set a static IP on both devices and disabled WiFi. I also monitored port 8888 using Wireshark, but no packets are detected.
To verify the hardware, I tested it with this sketch:
#include <SPI.h>
#include <Ethernet.h>
byte mac[] = {0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED};
IPAddress ip(192, 168, 2, 177);
void setup() {
Serial.begin(9600);
while (!Serial) {
}
Ethernet.begin(mac, ip);
if (Ethernet.hardwareStatus() == EthernetNoHardware) {
Serial.println("Ethernet shield was not found.");
}
else if (Ethernet.hardwareStatus() == EthernetW5100) {
Serial.println("W5100 Ethernet controller detected.");
}
else if (Ethernet.hardwareStatus() == EthernetW5200) {
Serial.println("W5200 Ethernet controller detected.");
}
else if (Ethernet.hardwareStatus() == EthernetW5500) {
Serial.println("W5500 Ethernet controller detected.");
}
}
void loop () {}
but somehow the output is
09:25:17.202 -> Ethernet shield was not found.
any idea what happen ? i also try connected it with RJ cross and Straight but still nothing happen