ethernet module direct connection to PC to recieve/send UDP

Hello everybody.

I want to use my arduino mega (with sensor shield) and a ENC28j60 ethernet module (directly connected to my pc) to send and recieve UDP from a flight simulator (X-Plane 11, which is capable of sending UDP via the network).

I can't manage to write recieved UDP data into the serial monitor however.

The connection between ethernet module and pc seems to be fine, as the green led of the ethernet module's input is permanently on, and the yellow one is blinking as soon as i start my flight sim and send UDP from there.

I have have tried 2 ways of connecting the ENC28J60 ethernet module to the arduino mega sensor shield, as i found several guides.

Enc28j60 SO -> Arduino pin 12
Enc28j60 SI -> Arduino pin 11
Enc28j60 SCK -> Arduino pin 13
Enc28j60 CS -> Arduino pin 10
Enc28j60 VCC -> Arduino 3V3 pin
Enc28j60 GND -> Arduino Gnd pin

Enc28j60 Arduino Mega 2560
GND GND
3.3 3.3V
SO Pin50
SI Pin51
SCK Pin52
CS Pin53

I also tried several libs:

  1. EtherCard (There setting the cs pin accordingly to my connection)
  2. UIPEthernet

None of the combinations made it possible to have any output in the serial monitor.

The sketch i have tried is the following:
(Still have the different libs in there, but partially commented)

#include <Dhcp.h>
#include <Dns.h>
#include <ethernet_comp.h>
#include <UIPClient.h>
#include <UIPEthernet.h>
#include <UIPServer.h>
#include <UIPUdp.h>

// #include <enc28j60.h>
// #include <EtherCard.h>
// #include <net.h>

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

byte mac[] = {  0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress ip(192, 168, 1, 177);    // local IP - address of my Arduino 
unsigned int localPort = 49001;      // local port to listen - default X-Plane port 
byte buf = 00;   // buffer for  UDP packet (BYTE, not char)

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

//-------------------------------------------------------------------------------

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

  Serial.begin(9600);       // init serial port

}
void loop() {

  int packetSize = Udp.parsePacket();   //  Checks for the presence of a UDP packet, and returns its size
  if(packetSize)                        //  UDP packet was received and its size defined
  {
    Serial.println();
    Serial.print("Packet size: ");
    Serial.println(packetSize);         // Packet Size in bytes

 // When Udp.read used without parameters, it returns next char (byte in this case) :
 
      Serial.println("Xplane Data:");  
        for (int i =0; i < packetSize; i++)
        {
          buf = Udp.read();
          Serial.print(buf);
          Serial.print("-");
        }
  }
  delay(10);
}

So my questions are:

  1. Do i need a crossover cable to have the connection properly established between PC and ENC28J60?

  2. What is the easiest way to test both connections:
    PC->Ethernet module and
    Ethernet module->Arduino?

  3. Is my wiring correct?

  4. Do i need to set the used arduino pins in my sketch or does the lib do that?

  5. Is the sketch supposed to work properly?

Thanks very much in advance for any answers. And please excuse the maybe noobish questions..

  1. Do i need a crossover cable to have the connection properly established between PC and ENC28J60?

That depends on your PC supports auto MDI-X (also called auto-crossover). Most modern PCs do support that so it should work without a crossover cable.

  1. What is the easiest way to test both connections:
    PC->Ethernet module and
    Ethernet module->Arduino?

Use a webserver example on the Arduino and then use a browser to connect to it.

  1. Is my wiring correct?

Number one is wrong (that's for an UNO), number two should work given the library gets the CS line you selected.

  1. Do i need to set the used arduino pins in my sketch or does the lib do that?

In many cases you need to do that for the CS line. In the cases where you cannot specify it, most libraries for Arduino Ethernet boards use pin 10 as CS (also on the Mega). The other pins (MISO, MOSI, SCKL) are fixed by the hardware.

  1. Is the sketch supposed to work properly?

It may get some data by UDP but if it works properly depends on what you expect it to do. I don't know you PC program sending the data.