I've just started messing around with the WDT - I've incorporated into into one of my projects that sends data to pachube using a ethernet module. I'm using the Ethercard libraries.
Before I inserted the WDT code it all worked great - now the code keeps resetting every few seconds. If I comment out these lines then it works:
if (!ether.dnsLookup(website))
Serial.println(F("DNS failed"));
Here's my full code:
#include <avr/wdt.h>
#include <EtherCard.h>
#include <Wire.h>
char website[] PROGMEM = "api.pachube.com";
// ethernet interface mac address, must be unique on the LAN
byte mymac[] = {
0x70,0x60,0x60,0x20,0x30,0x30 };
static uint8_t myip[4] = {
10,1,1,20 }; //IP
static uint8_t gwip[4] = {
10,1,1,1 }; //Gateway IP
static uint8_t dnsip[4] = {
10,1,1,1 }; //DNS IP
byte Ethernet::buffer[700];
uint32_t timer;
Stash stash;
void setup () {
wdt_enable(WDTO_2S);
Serial.begin(9600);
Serial.println(F("Setup Network"));
if (ether.begin(sizeof Ethernet::buffer, mymac) == 0)
Serial.println(F("Failed to access Ethernet controller"));
ether.staticSetup(myip, gwip, dnsip);
ether.printIp("IP: ", ether.myip);
ether.printIp("GW: ", ether.gwip);
ether.printIp("DNS: ", ether.dnsip);
if (!ether.dnsLookup(website))
Serial.println(F("DNS failed"));
}
void loop () {
wdt_reset();
}
Any idea where I'm going wrong?