I want to report the status of some binary sensors to a PC over the local LAN with a UDP packet whenever there is a change. My code starts like the example, but always gets "connection failed". Wireshark, the Ethernet packet display routine shows 1 packet going to and 1 from the PC, but they are type=TCP, not UDP. Is there a way to get the Arduino to send UDP ?
#include <Ethernet.h>
#define lightning 2
#define driveway 3
#define garage 4
#define shop 5
byte status = 0b0;
byte prvstat = 0b0;
byte Ardmac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
byte Ard_IP[] = { 192,168,123,73 }; // the Arduino
byte Server[] = { 192,168,123,70 }; // the PC
Client client(Server, 8888);
void setup()
{
pinMode(lightning, INPUT); // set pins as input
pinMode(driveway, INPUT);
pinMode(garage, INPUT);
pinMode(shop, INPUT);
Ethernet.begin(Ardmac,Ard_IP);
Serial.begin(9600);
delay(1000);
Serial.println("connecting...");
if (client.connect())
{
Serial.println("connected");
}
else
{
Serial.println("connection failed");
}
}
void loop()
{