Reset router Ethernet

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

int RELAY_Pin = 2; //Relay Pin

byte mac[] = {  0xCA, 0xAA, 0xDE, 0xCA, 0xEL, 0xB0 };     //Mac of shield
IPAddress ip(192, 168, 10, 178);                          //Ip to be used
IPAddress pingAddr(8,8,8,8); // ip address to ping

SOCKET pingSocket = 0;

char buffer [256];
  ICMPPing ping(pingSocket, (uint16_t)random(0, 255));

void setup() {
  Ethernet.begin(mac, ip);
  pinMode(RELAY_Pin, OUTPUT);
  Serial.begin(9600);
  delay(10);
}

void loop() 

{
  ICMPEchoReply echoReply = ping(pingAddr,4);
  if (echoReply.status == SUCCESS)
  {
    digitalWrite(RELAY_Pin, HIGH);
            Serial.print("CONECTED");
            Serial.print("         ");
    sprintf(buffer,
            "Reply[%d] from: %d.%d.%d.%d: bytes=%d time=%ldms TTL=%d",
            echoReply.data.seq,
            echoReply.addr[0],
            echoReply.addr[1],
            echoReply.addr[2],
            echoReply.addr[3],
            REQ_DATASIZE,
            millis() - echoReply.data.time,
            echoReply.ttl);
            
  }
  else
  {
    sprintf(buffer, "Echo request failed; %d", echoReply.status);
    digitalWrite(RELAY_Pin, LOW);
    delay(9000);
    digitalWrite(RELAY_Pin, HIGH);
    Serial.print("         ");
    Serial.print("DISCONECTED");
    Serial.print("         ");
  }
  Serial.println(buffer);
  delay(100000);
  }

Did you forget to post something?

Paul

Some people just aren’t big on explanations …