Go Down

Topic: Reset ethernet connection (Read 1 time) previous topic - next topic

Onions

Quote
So the wdt_reset(); command in the loop actually stops the reset from occurring.

Yes, resetting the watchdog timer prevents the arduino from resetting.
Quote

I could therefore write a IF/ELSE statement that normally runs the wdt_reset(); command, but say every hour it runs delay(3000) instead which should provide sufficient time for the reset to occur.

Personally, I'd try and connect to a website (any would do) every few minutes. If there is no connection, the site will not load. If the site does not load, then you do not reset the watchdog and the board will reset. Doing it every hour has the disadvantage that if the connection drops at the start of the hour, that's a full hour to wait before it will work again...

Onions.
My website: http://www.harryrabbit.co.uk/electronics/home.html Up and running now! (Feel free to look round!) :D

pauldreed


Personally, I'd try and connect to a website (any would do) every few minutes. If there is no connection, the site will not load. If the site does not load, then you do not reset the watchdog and the board will reset. Doing it every hour has the disadvantage that if the connection drops at the start of the hour, that's a full hour to wait before it will work again...

Onions.

Sorry for all the questions... but how can you determine if a site (such as google.com) has loaded or not?

Onions

Quote
Sorry for all the questions

Don't worry, I don't mind! :)

Quote
how can you determine if a site (such as google.com) has loaded or not?

http://arduino.cc/en/Reference/ClientConnect

Quote
Connect to the IP address and port specified in the constructor. The return value indicates success or failure.


Code: [Select]
if(!client.connect(  [google]  ){ //See if you can connect Note that you'll need to change [google] to google's URL/IP address
  connected = false;     //Not really needed, but it could be used if you decided on a different use...
  while(true);    //Do nothing for ever more. In reality, the watchdog will kick in and reset the board.
}


Have a look at the example for client.connect():
Code: [Select]
#include <Ethernet.h>

byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
byte ip[] = { 10, 0, 0, 177 };
byte server[] = { 64, 233, 187, 99 }; // Google

Client client(server, 80);

void setup()
{
  Ethernet.begin(mac, ip);
  Serial.begin(9600);

  delay(1000);

  Serial.println("connecting...");

  if (client.connect()) {
    Serial.println("connected");
    client.println("GET /search?q=arduino HTTP/1.0");
    client.println();
  } else {
    Serial.println("connection failed");
  }
}

void loop()
{
  if (client.available()) {
    char c = client.read();
    Serial.print(c);
  }

  if (!client.connected()) {
    Serial.println();
    Serial.println("disconnecting.");
    client.stop();
    for(;;)
      ;
  }
}


Onions.
My website: http://www.harryrabbit.co.uk/electronics/home.html Up and running now! (Feel free to look round!) :D

pauldreed

Thanks for your help Onions, I'll have a try with this over the weekend.

pauldreed


Quote
how can you determine if a site (such as google.com) has loaded or not?

http://arduino.cc/en/Reference/ClientConnect

Quote
Connect to the IP address and port specified in the constructor. The return value indicates success or failure.


Code: [Select]
if(!client.connect(  [google]  ){ //See if you can connect Note that you'll need to change [google] to google's URL/IP address
  connected = false;     //Not really needed, but it could be used if you decided on a different use...
  while(true);    //Do nothing for ever more. In reality, the watchdog will kick in and reset the board.
}


Onions.


I am using the Ethercard.h library, not the Ethernet.h library, will the client.connect command still work with Ethercard, or is the example at http://arduino.cc/en/Reference/ClientConnect written just to work with the ethernet.h library?

Go Up