I can't read UDP packets from W5500 module

I'm trying to read received UDP packets in Arduino UNO using Wiznet w5500 module.
Wiring:

+5v -> 5v
GND -> GND
R -> Digital Pin 9
SS -> Digital Pin 10
MO -> Digital Pin 11
MI -> Digital Pin 12
CK -> Digital Pin 13

Code:

#include <SPI.h>
#include <Ethernet2.h>
#include <EthernetUdp2.h>

EthernetUDP Udp;
byte mac[] = {0xDE, 0xAD, 0xBE, 0xFF, 0xFE, 0xED};
IPAddress ip(172, 31, 92, 2);

unsigned int localPort = 10026; // local port to listen on
char packetBuffer[UDP_TX_PACKET_MAX_SIZE]; //buffer to hold incoming packet


void setup() {
  Ethernet.begin(mac, ip);
  Udp.begin(localPort);
  Serial.begin(9600);
}

void loop() {
  int packetSize = Udp.parsePacket();
  if (packetSize)
  {
    Serial.print("Received packet of size ");
    Serial.println(packetSize);
  
    // read the packet into packetBufffer
    Udp.read(packetBuffer, UDP_TX_PACKET_MAX_SIZE);
    Serial.print("Contents: ");
    Serial.println(packetBuffer);

  }

}

I successfully ping w5500 module from my PC's NIC. Then I use Packet Sender software to send a UDP packet (from my PC) to the IP and Port of the w5500 but Arduino doesn't even receive the packet.

I can't find the error.

Thanks

use the Ethernet library and try the WebClient example first

Another step closer. I receive the UDP packets from the sensor. I receive the size, and the source IP, but the content doesn't appear correctly.

Screenshot 2022-10-29 231159

do you use the Ethernet library?

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