Ethernet cable is not connected

Hi guys,

I am trying to use UDPSendReceiveString example with my Mega 2560 and Arduino Ethernet shield 2 and getting this error message: "Ethernet cable is not connected"

  include <Ethernet.h>
  #include <EthernetUdp.h>

  byte mac[] = {
     0xA8, 0x61, 0x0A, 0xAE, 0x2A, 0x12
    };
   IPAddress ip(192, 168, 137, 30);

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

   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() {
  // You can use Ethernet.init(pin) to configure the CS pin
  Ethernet.init(10);  // Most Arduino shields

  // start the Ethernet
  Ethernet.begin(mac, ip);

  // Open serial communications and wait for port to open:
  Serial.begin(9600);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for native USB port only
  }

  // Check for Ethernet hardware present
  if (Ethernet.hardwareStatus() == EthernetNoHardware) {
    Serial.println("Ethernet shield was not found.  Sorry, can't run without hardware. :(");
    while (true) {
      delay(1); // do nothing, no point running without Ethernet hardware
    }
  }
  if (Ethernet.linkStatus() == LinkOFF) {
    Serial.println("Ethernet cable is not connected.");
  }

  // start UDP
  Udp.begin(localPort);
}

The mac address could be found on the back side of the shield and the ip address is the one that I manually typed in the network configuration. Since I am not using any router and directly connected the shield with my laptop, I set turned on the sharing function of my WLAN. But do I need this even I just need to send values from my laptop to Arduino via UDP? Well, nevertheless the linkStatus is off all the time.

I would be thanksful to any suggestion.

xman236:
Since I am not using any router and directly connected the shield with my laptop

The Arduino Ethernet Shield 2 uses the W5500 Ethernet controller chip. That chip's datasheet says:
http://wizwiki.net/wiki/lib/exe/fetch.php?media=products:w5500:w5500_ds_v106e_141230.pdf

5.5.6 MDIX
W5500 does not support auto-MDIX feature.
Thus, user should use straight-through cables to connect to other switches or routers and
crossover cables to connect to devices such as servers, workstations or another W5500.
However, user can use either type of cable to connect to other devices with auto-MDIX
enabled, and the interface automatically corrects for any incorrect cabling.

This is a difference between the newer W5500 and the W5100 (used on the original Ethernet shield), which does have auto-MDIX. If the Ethernet adapter on your laptop doesn't do auto-MDIX, you would need to use a crossover cable. Lacking any experience with direct Ethernet connections, I don't know how likely that is to be the problem but it did stand out to me as a possibility.

 include <Ethernet.h>

For the Ethernet Shield 2 you must include the Ethernet2.h library and the correct include directive is:

#include <Ethernet2.h>

pylon:

 include <Ethernet.h>

For the Ethernet Shield 2 you must include the Ethernet2.h library and the correct include directive is:

#include <Ethernet2.h>

WHAT? Ethernet library supports W5500 and 5200 almost 6 months now

WHAT? Ethernet library supports W5500 and 5200 almost 6 months now

Oh, please excuse me for being outdated in this regard.