UDP I'm totally confused

I have a controller for my pool. I have a temperature sensor in the skimmer and I can send the temperature back to my controller using another arduino via an RF signal. My problem is that nothing wireless works too well in my house or yard. Im not sure why and nobody has ever had much luck figuring it out. Basically anything wireless works but is not too reliable.

I want to try and send this temperature data via my network. Everything is wired so there is no wifi involved. My trouble is i can't seem to find anything on using 2 arduinos to communicate via UDP, one as a transmitter and one as a receiver. There are some sketches out there and examples but i am having quite a bit of trouble making any sense of them. There is a whole tutorial from Upenn but it is outdated and uses old libraries.

I found a sketch on the Arduino site for what i think is the transmitter but it makes reference to the remoteip and remote port but there is no way that i can see to define them. I suspect they are defined in the Udp library but i can't even find that. The code i am referring to is this:

#include <SPI.h>        

#include <Ethernet.h>

#include <EthernetUdp.h>



// Enter a MAC address and IP address for your controller below.

// The IP address will be dependent on your local network:

byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };

IPAddress ip(192, 168, 1, 177);



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



// 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);

}



void loop() {

  Udp.beginPacket(Udp.remoteIP(), Udp.remotePort()); ///// Is this defined in the EthernetUdp library?  How do i assign my own       //////////////////////////////////////////////////////////////////////////////////////////////values?

    Udp.write("hello");

    Udp.endPacket();

}

This is the way you should set the remote IP and port.

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

// Enter a MAC address and IP address for your controller below.
// The IP address will be dependent on your local network:
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress ip(192, 168, 1, 177);
unsigned int localPort = 8888;      // local port to listen on

// set these to the remote IP and port
IPAddress remoteIP(192,168,1,178);
unsigned int remotePort = 8888;

// 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);
}

void loop() {

   Udp.beginPacket(remoteIP,remotePort);
    Udp.write("hello");
    Udp.endPacket();
    delay(5000);
}

Thanks very much. For this response and the last problem you solved for me.

Still having trouble. Here is the code from both arduinos:

Uno code:

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

// Enter a MAC address and IP address for your controller below.
// The IP address will be dependent on your local network:
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress ip(192, 168, 0,27);
unsigned int localPort = 8888;      // local port to listen on

// set these to the remote IP and port
IPAddress remoteIP(192,168,0,26);
unsigned int remotePort = 8888;



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

void setup() {
  
  Serial.begin(9600);
  Serial.print(ip);

  // start the Ethernet and UDP:

  Ethernet.begin(mac,ip);
  Udp.begin(localPort);
}

void loop() {

   Udp.beginPacket(remoteIP,remotePort);
    Udp.write("hello");
    Udp.endPacket();
    delay(5000);
}

mega code

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

// Enter a MAC address and IP address for your controller below.
// The IP address will be dependent on your local network:
byte mac[] = {  
  0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress ip(192, 168, 0, 26);

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

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

char packetBuffer[UDP_TX_PACKET_MAX_SIZE]; //buffer to hold incoming packet,

void setup() {

  Serial.begin(9600);
  Serial.print(ip);

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

}

void loop() {

  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);
}
}

You can't use the same mac address for both devices. Change one to this:

byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xEE };