Ethernet shield not accessing internet

Hi,
I was wondering if anyone could help I’m trying to upload this code to my arduino but it doesn’t seem to access the internet through the ethernet shield. I have had this code working in the past and I don’t know what has change that has stopped it working now.

#include <string.h>
#include <Ethernet.h>

// Define Constants
// Max string length may have to be adjusted depending on data to be extracted
#define MAX_STRING_LEN 20

// Setup vars
char tagStr[MAX_STRING_LEN] = “”;
char dataStr[MAX_STRING_LEN] = “”;
char tmpStr[MAX_STRING_LEN] = “”;
char endTag[3] = {’<’, ‘/’, ‘\0’};
int len;

// Flags to differentiate XML tags from document elements (ie. data)
boolean tagFlag = false;
boolean dataFlag = false;
//#include “/Users/ali/Documents/Arduino/mac.inc”
// Ethernet vars
byte mac = { 0x00, 0x09, 0xC2, 0x20, 0x09, 0x03 };
byte ip = { 192,168,2,100 };
byte server = { 38, 102, 136, 138 }; // api.wunderground.com

// Start ethernet client
Client client(server, 80);

void setup()
{
Serial.begin(9600);
Serial.println(“Starting WebWx”);
Serial.println(“connecting…”);
Ethernet.begin(mac,ip);
delay(1000);

if (client.connect()) {
Serial.println(“connected”);
client.println(“GET /weatherstation/WXCurrentObXML.asp?ID=IDUNDEE2 HTTP/1.0”);
client.println();
delay(2000);
} else {
Serial.println(“connection failed”);
}
}

void loop() {

// Read serial data in from web:
while (client.available()) {
serialEvent();
}

if (!client.connected()) {
//Serial.println();
//Serial.println(“Disconnected”);
client.stop();

// Time until next update
//Serial.println(“Waiting”);
for (int t = 1; t <= 15; t++) {
delay(10000); // 1 minute
}

if (client.connect()) {
//Serial.println(“Reconnected”);
client.println(“GET /weatherstation/WXCurrentObXML.asp?ID=IDUNDEE2 HTTP/1.0”);
client.println();
delay(2000);
} else {
Serial.println(“Reconnect failed”);
}
}
}

// Process each char from web
void serialEvent() {

// Read a char
char inChar = client.read();
//Serial.print(".");

if (inChar == ‘<’) {
addChar(inChar, tmpStr);
tagFlag = true;
dataFlag = false;

} else if (inChar == ‘>’) {
addChar(inChar, tmpStr);

if (tagFlag) {
strncpy(tagStr, tmpStr, strlen(tmpStr)+1);
}

// Clear tmp
clearStr(tmpStr);

tagFlag = false;
dataFlag = true;

} else if (inChar != 10) {
if (tagFlag) {
// Add tag char to string
addChar(inChar, tmpStr);

// Check for end tag, ignore it
if ( tagFlag && strcmp(tmpStr, endTag) == 0 ) {
clearStr(tmpStr);
tagFlag = false;
dataFlag = false;
}
}

if (dataFlag) {
// Add data char to string
addChar(inChar, dataStr);
}
}

// If a LF, process the line
if (inChar == 10 ) {

/*
Serial.print("tagStr: ");
Serial.println(tagStr);
Serial.print("dataStr: ");
Serial.println(dataStr);
*/

// Find specific tags and print data
if (matchTag("<temp_f>")) {
Serial.print(“Temp: “);
Serial.print(dataStr);
}
if (matchTag(”<relative_humidity>”)) {
Serial.print(", Humidity: “);
Serial.print(dataStr);
}
if (matchTag(”<dewpoint_f>")) {
Serial.print(", Dewpoint: “);
Serial.print(dataStr);
Serial.println(”");
}

// Clear all strings
clearStr(tmpStr);
clearStr(tagStr);
clearStr(dataStr);

// Clear Flags
tagFlag = false;
dataFlag = false;
}
}

/////////////////////
// Other Functions //
/////////////////////

// Function to clear a string
void clearStr (char* str) {
int len = strlen(str);
for (int c = 0; c < len; c++) {
str

 = 0;
   }
}

//Function to add a char to a string and check its length
void addChar (char ch, char* str) {
   char *tagMsg  = "<TRUNCATED_TAG>";
   char *dataMsg = "-TRUNCATED_DATA-";

   // Check the max size of the string to make sure it doesn't grow too
   // big.  If string is beyond MAX_STRING_LEN assume it is unimportant
   // and replace it with a warning message.
   if (strlen(str) > MAX_STRING_LEN - 2) {
      if (tagFlag) {
         clearStr(tagStr);
         strcpy(tagStr,tagMsg);
      }
      if (dataFlag) {
         clearStr(dataStr);
         strcpy(dataStr,dataMsg);
      }

      // Clear the temp buffer and flags to stop current processing
      clearStr(tmpStr);
      tagFlag = false;
      dataFlag = false;

   } else {
      // Add char to string
      str[strlen(str)] = ch;
   }
}

// Function to check the current tag for a specific string
boolean matchTag (char* searchTag) {
   if ( strcmp(tagStr, searchTag) == 0 ) {
      return true;
   } else {
      return false;
   }
}

Hmmm Good Question...

I could see no glaring error...so I installed on mine...

Starting WebWx
connecting...
connected
Temp: 39.6, Humidity: 92, Dewpoint: -999.0

I'd say it's working... actually

Thanks that's what it is meant to be doing but it just seems to becoming up with connection failed.

thanks for your help i will try to resolve this issue.

To connect to the internet your Arduino needs a default gateway.

Use: Ethernet.begin(mac, ip, gateway, subnet);

If the arduino is connected to the same network as your computer, you can find the gateway and subnet in the properties of your computer's network connection.

Edit: I just checked the source of the Ethernet library. The default gateway and subnet that the library assumes are: Gateway: A.B.C.1 Subnet: 255.255.255.0

The A.B.C are taken from the ip you specify, in your case that would be 192.168.2

So, if your computer uses 192.168.2.1 as a default gateway with a subnet 255.255.255.0, it's equal to what the arduino does and the problem lies elsewhere.