Using MAC address with Ethernet Shield 2 and Arduino Uno

Hello,

I am trying to run the UDPSendRecieveString example with a newer Ethernet Shield 2 and an Arduino Uno. I have successfully run the code with an older version of the Ethernet board, one where you can assign it any MAC address. However, when I try to run the same code on the newer shield (I am entering the MAC address on the back) it doesn’t work. Here is the code:

#include <SPI.h>         // needed for Arduino versions later than 0018
#include <Ethernet.h>
#include <EthernetUdp.h>         // UDP library from: bjoern@cs.stanford.edu 12/30/2008


// Enter a MAC address and IP address for your controller below.
// The IP address will be dependent on your local network:
byte mac[] = {
  0x90, 0xA2, 0xDA, 0x10, 0x5E, 0xC9
};
IPAddress ip(192, 168, 2, 177);

unsigned int localPort = 8888;      // local port to listen on

// buffers for receiving and sending data
char packetBuffer[UDP_TX_PACKET_MAX_SIZE];  //buffer to hold incoming packet,
char  ReplyBuffer[] = "acknowledged";       // a string to send back

// An EthernetUDP instance to let us send and receive packets over UDP
EthernetUDP Udp;

void setup() {
  // start the Ethernet and UDP:
  Ethernet.begin(mac, ip);
  Udp.begin(localPort);

  Serial.begin(9600);
}

void loop() {
  // if there's data available, read a packet
  int packetSize = Udp.parsePacket();
  if (packetSize) {
    Serial.print("Received packet of size ");
    Serial.println(packetSize);
    Serial.print("From ");
    IPAddress remote = Udp.remoteIP();
    for (int i = 0; i < 4; i++) {
      Serial.print(remote[i], DEC);
      if (i < 3) {
        Serial.print(".");
      }
    }
    Serial.print(", port ");
    Serial.println(Udp.remotePort());

    // read the packet into packetBufffer
    Udp.read(packetBuffer, UDP_TX_PACKET_MAX_SIZE);
    Serial.println("Contents:");
    Serial.println(packetBuffer);

    // send a reply to the IP address and port that sent us the packet we received
    Udp.beginPacket(Udp.remoteIP(), Udp.remotePort());
    Udp.write(ReplyBuffer);
    Udp.endPacket();
  }
  delay(10);
}

The MAC address on the back is : 90-A2-DA-10-5E-C9.

Again this works with the older Ethernet Shield, but doesn’t work with the newer one. And that’s the MAC address that came with the newer one. Anyone have any idea why this wouldn’t work or how how to go about debugging?

If you want to use an ethernet shield with the w5200/w5500 controller, you need a different library. The standard library included with the Arduino.cc IDE is for the w5100 controller.