Remote Switch to use a relay w/2 Arduinos over ethernet.

Hi there,
I´m a rookie on arduino and programing it, but i do have some experience in networking and electronics and programming in other (simplier) languages...

Well, what Im trying to make is a remote panic button that triggers an alarm siren, the problem is that the siren is half a mile away and passing some cable is not an option. So, i currently have a Wireless ethernet link to that place so on the network side im covered, but not on the button.

My idea is to use 2 Arduinos UNO with Ethernet Shields, and when i press a button on "Client" side it sends a GET command to the second arduino who will performing as a server and this triggers a relay on... and when i want it to shut down, press the button 5 seconds to do that. Here's the schematics.

CLIENT SIDE:

SERVER SIDE:

Right now i have the server side running but i have a week trying to figure it out how to do the client and honestly don't have any ideas left.. i feel stuck.

Here is the server side code, its not mine i just changes some values the credits are from Rui Santos. at
@Random Nerd Tutorials

heres the code. Im planning to use the server on 192.168.88.250 and the client on 192.168.88.251 on the same subnet and physical network segment.

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

//Establecer los datos de IP
byte mac[] = {
0x00, 0x02, 0x6F, 0x00, 0x00, 0x01 };
IPAddress ip(192,168,88,250);
IPAddress netmask(255,255,255,0);
IPAddress gateway(192,168,88,254);

// Initialize the Ethernet server library
// with the IP address and port you want to use
// (port 80 is default for HTTP):
EthernetServer server(80);

// Relay state and pin
String relay1State = "Off";
const int relay = 7;

// Client variables
char linebuf[80];
int charcount=0;

void setup() {
// Relay module prepared
pinMode(relay, OUTPUT);
digitalWrite(relay, HIGH);

// Open serial communication at a baud rate of 9600
Serial.begin(9600);

// start the Ethernet connection and the server:
Ethernet.begin(mac, ip);
server.begin();
Serial.print("server is at ");
Serial.println(Ethernet.localIP());
}

// Display dashboard page with on/off button for relay
// It also print Temperature in C and F
void dashboardPage(EthernetClient &client) {
client.println("");
client.println("<meta name="viewport" content="width=device-width, initial-scale=1" <link href="https://fonts.googleapis.com/css?family=Montserrat\" rel="stylesheet"> body { font-family: 'Montserrat', serif; font-size: 15px;}");
client.println("

Relay module control. - <a href="/">Refrescar

");
// Generates buttons to control the relay
client.println("

Relay 1 - Estado: " + relay1State + "

");
// If relay is off, it shows the button to turn the output on
if(relay1State == "Off"){
client.println("<a href="/relay1on">ON");
}
// If relay is on, it shows the button to turn the output off
else if(relay1State == "On"){
client.println("<a href="/relay1off">OFF");
}
client.println("");
}

void loop() {
// listen for incoming clients
EthernetClient client = server.available();
if (client) {
Serial.println("new client");
memset(linebuf,0,sizeof(linebuf));
charcount=0;
// an http request ends with a blank line
boolean currentLineIsBlank = true;
while (client.connected()) {
if (client.available()) {
char c = client.read();
//read char by char HTTP request
linebuf[charcount]=c;
if (charcount<sizeof(linebuf)-1) charcount++;
// if you've gotten to the end of the line (received a newline
// character) and the line is blank, the http request has ended,
// so you can send a reply
if (c == '\n' && currentLineIsBlank) {
dashboardPage(client);
break;
}
if (c == '\n') {
if (strstr(linebuf,"GET /relay1off") > 0){
digitalWrite(relay, HIGH);
relay1State = "Off";
}
else if (strstr(linebuf,"GET /relay1on") > 0){
digitalWrite(relay, LOW);
relay1State = "On";
}
// you're starting a new line
currentLineIsBlank = true;
memset(linebuf,0,sizeof(linebuf));
charcount=0;
}
else if (c != '\r') {
// you've gotten a character on the current line
currentLineIsBlank = false;
}
}
}
// give the web browser time to receive the data
delay(1);
// close the connection:
client.stop();
Serial.println("client disonnected");
}
}

Thank you so much for advance.

JB

Are you able to get the two to talk to each other?
Any signals aat all?

Hi, yes...
both arduinos are up and running, if i ping both with my pc on the same subnet both reply.

This code i attached to this post, is the server side running as a web page and a button, if i click the button it turns on and off the Relay.. this part works fine..

The part i havent figure it out is the client side, what i am trying to accomplish is that some can press a button on the client side and if the button is pressed equal or less than 4 secs, this will send a GET message to the server side to activate the relay on the remote side this will trigger the siren. When the issue is gone, to turn it off i would want to let the button pressed for greater or equal 5 secs so this will get the remote relay off

Right now if you see the code when you press the button on the webpage, it will trigger the relay using this path:

http://IPADDRESS/relay1on or /relay1off

This is working but via web, but i would like to do it with a physical button.. but i already broken my head off for a week and everything i tried did not work..

So here i am requesting some guidance for at least show me the way i should go for..

Thank you for your time and reply!
have a great one.

JB