Arduino internet checker

Hi all,
I'm struggling with a concept and how to approach it.

So I need to check that a remote location has an internet connection and log it every minute or so to check the connection is up and when it is down.

So I am thinking to place an Arduino at the remote location where the internet is to be checked.

Perhaps some sort of PHP app that pings and tries to get a response from the Arduino and then logs its response or not into a SQL DB. The php page will then print the results of the DB highlighting if a response was had or not.

How does this approach sound? The right way round, or?

I thought about getting the Arduino to send every minute a piece of data to the PHP app and the PHP app logs it in the DB, but then it may be difficult to tell when the internet was down from reading the DB results?

Any ideas would be great.
Thanks.

I have an ESP8266 temperature and humidity
Posts every 30 minutes
If there is a storm it resets and i can see the new time. Then figure how long it was down
You could have something similar.

Having your central location ping the remote location and then logging the results with a timestamp sounds fine to me.

Let's say the central location pings the remote location every minute.
Later when you look at the logged data you will see any time periods when the remote location was not responding.
Of course if there are gaps in the timestamps i.e. more than one minute between them, then you know that there was a problem with central location sending out pings and logging the results.

Just try the idea out by hand first e.g. try pinging google.

Rather than pinging an Arduino at the remote location you may be able to just ping the router to which the Arduino would be connected as long as you know the router's IP and it is configured to respond to pings.

An Arduino with an ethernet shield can be used as a server, client, or both. The client can query the server on a timed basis and the server respond to the client. A failure to respond "might" indicate some type of internet issue. The PHP part may be beyond the capability of the Arduino itself as I've never seen it implemented on an Arduino.

Hi, Here's an example that may help; it uses arduino / free Cayenne system for online/cloud connection.

See THIS PAGE for an example..

The second graphic shows a display of Arduino 'Millis" over time. You can see there are 4 or 5 days with no interruption. Today I rewired something and restarted it. So you have history. In my case I am monitoring my son's house which is currently unoccupied. Soon two apartments will be rented and we will track the temperatures, furnace run etc.

You could do this with an Arduino UNO, but I needed to be able to add lots of functions and the Cayenne library is huge, so I am using a Mega with a sensor shield. You can see some of the build HERE

Oh, guess I can link to the Millis display here:

zoomkat:
An Arduino with an ethernet shield can be used as a server, client, or both. The client can query the server on a timed basis and the server respond to the client. A failure to respond "might" indicate some type of internet issue. The PHP part may be beyond the capability of the Arduino itself as I've never seen it implemented on an Arduino.

Thanks. For clarification, the PHP / DB part would be on a web hosted web server, rather than on the Arduino

Below is some old code (maybe outdated) that requested the current IP address from an IP server. You might use something similar to connect to your server for a check.

//zoomkat 3-1-13
//simple client checkip test
//for use with IDE 1.0.1 or later
//with DNS, DHCP, and Host
//open serial monitor and send an e to test
//for use with W5100 based ethernet shields

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

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

char serverName[] = "checkip.dyndns.com"; // test web page server
EthernetClient client;

//////////////////////

void setup(){

  if (Ethernet.begin(mac) == 0) {
    Serial.println("Failed to configure Ethernet using DHCP");
    // no point in carrying on, so do nothing forevermore:
    while(true);
  }

  Serial.begin(9600); 
  Serial.println("Better client ip test 3/1/13"); // so I can keep track of what is loaded
  Serial.println("Send an e in serial monitor to test"); // what to do to test
}

void loop(){
  // check for serial input
  if (Serial.available() > 0) //if something in serial buffer
  {
    byte inChar; // sets inChar as a byte
    inChar = Serial.read(); //gets byte from buffer
    if(inChar == 'e') // checks to see byte is an e
    {
      sendGET(); // call sendGET function below when byte is an e
    }
  }  
} 

//////////////////////////

void sendGET() //client function to send/receive GET request data.
{
  if (client.connect(serverName, 80)) {  //starts client connection, checks for connection
    Serial.println("connected");
    client.println("GET / HTTP/1.1"); //download text
    client.println("Host: checkip.dyndns.com");
    client.println("Connection: close");  //close 1.1 persistent connection  
    client.println(); //end of get request
  } 
  else {
    Serial.println("connection failed"); //error message if no client connect
    Serial.println();
  }

  while(client.connected() && !client.available()) delay(1); //waits for data
  while (client.connected() || client.available()) { //connected or data available
    char c = client.read(); //gets byte from ethernet buffer
    Serial.print(c); //prints byte to serial monitor 
  }

  Serial.println();
  Serial.println("disconnecting.");
  Serial.println("==================");
  Serial.println();
  client.stop(); //stop client

}