Ethernet sheild stops connecting after an extended period

You should be able to use that with your code.

SurferTim,
Call me stupid, I don't know how to do that. I've been at it all day.

Just use plain old char arrays with a null terminator - classic 'C strings. The String class is an attempt to make these easier to use but in its current implementation introduces a memory leak (has this been fixed yet?) and also tends to lead to heap fragmentation. For an application where stability was important, I'd suggest you stay away from anything using dynamic heap memory allocation and that includes the String class.

PeterH,
I've also tried to turn the Strings into Chars but I keep getting problems with the comparison operators between things like tweet and inChar.

Here is the original code, tidied up a bit. I feel like I'm watching paint dry in the rain today.
lil help?

//setup for all libs
#include <SPI.h> // needed in Arduino 0019 or later
#include <Ethernet.h>
#include <Twitter.h>
#include <EthernetUdp.h>
#include <PString.h>
#include <TextFinder.h>

int ledPin = 3;
byte mac[] = { $$$$$$$$ };
byte ip[] = {$$$$$$$4};
Twitter twitter("$$$$$$$$$$$$$");



//Ethernet Client

EthernetClient client;
const unsigned long requestInterval = 15000;  // delay between requests
char serverName[] = "api.twitter.com";  // twitter URL
boolean requested;                   // whether you've made a request since connecting
unsigned long lastAttemptTime = 0;            // last time you connected to the server, in milliseconds
String currentLine = "";            // string to hold the text from server
String previousLine = "";           //String to hold the previous text from server for comparison
String tweet = "";                  // string to hold the tweet
String makeCoffee = ">make me coffee";
boolean readingTweet = false;       // if you're currently reading the tweet
TextFinder finder( client );

//TweetString
char buffer[140] = {0};
PString tweetString(buffer, sizeof(buffer));
long randNumber;
boolean firstTweetRead = false;



void setup(){
 
  pinMode (ledPin, OUTPUT);
  randomSeed(analogRead(5));
  
  //Serial Reader
  Serial.begin(9600); // Initialize serial port
  
  //Ethernet Client
  currentLine.reserve(256);
  tweet.reserve(150);
  
  //General
  delay(1000);
  Ethernet.begin(mac);
  Serial.begin(9600);
    
 //Ethernet Client
   // attempt a DHCP connection:
  Serial.println("setup");
  if (!Ethernet.begin(mac)) {
    // if DHCP fails, start with a hard-coded address:
    Serial.println("failed, trying manually");
    Ethernet.begin(mac, ip);
  }

// connect to Twitter:
  connectToServer();
}




void loop(){
  
  Ethercheck();
}


void Ethercheck(){
 //Ethernet Client
   if (client.connected()) {
    if (client.available()) {
      // read incoming bytes:
      char inChar = client.read();

      // add incoming byte to end of line:
      currentLine += inChar; 

      // if you get a newline, clear the line:
      if (inChar == '\n') {
        previousLine = "";
        previousLine = tweet;
        currentLine = "";
      } 
      // if the current line ends with <text>, it will
      // be followed by the tweet:
      if ( currentLine.endsWith("<text>")) {
        // tweet is beginning. Clear the tweet string:
        readingTweet = true; 
        tweet = "";
      }
      // if you're currently reading the bytes of a tweet,
      // add them to the tweet String:
      if (readingTweet) {
        if (inChar != '<') {
          tweet += inChar;
        } 
        else {
          // if you got a "<" character,
          // you've reached the end of the tweet:
          readingTweet = false;
           if (tweet != previousLine){
          Serial.println(tweet);   
          // close the connection to the server:
          client.stop(); 
                
                if (firstTweetRead != false){
                if (tweet.startsWith (makeCoffee)){
                  
                  //if( waterLevel is higher than said amount){
                  Serial.println ("Making coffee");
                  tweetString.begin();
                  tweetString = " Making coffee now, random number: ";
                  randNumber = random(1000);
                  tweetString.print (randNumber);
                  
                  make();
                }

                }
                else{
                 firstTweetRead = true;
                }
                }
         else {
           Serial.println("no new tweets");
           client.stop(); 
          
         }
        }
      }
    }
  }
  else if (millis() - lastAttemptTime > requestInterval) {
    // if you're not connected, and fifteen seconds have passed since
    // your last connection, then attempt to connect again:
    connectToServer();
    
  }
  
}
  
  



void connectToServer() {
  // attempt to connect, and wait a millisecond:
  Serial.println("connecting to server...");
  if (client.connect(serverName, 80)) {
    Serial.println(serverName);
    Serial.println("making HTTP request...");
    // make HTTP GET request to twitter:
    client.println("GET /1/statuses/user_timeline.xml?screen_name=$$$$$$$&count=1 HTTP/1.1");
    client.println("HOST: api.twitter.com");
    client.println();
  }
  // note the time of this connect attempt:
  lastAttemptTime = millis();
}   







void make(){
  Serial.println("Tweeting ...");
  if (twitter.post(tweetString)) {
    // Specify &Serial to output received response to Serial.
    // If no output is required, you can just omit the argument, e.g.
    // int status = twitter.wait();
    int status = twitter.wait(&Serial);
    if (status == 200) {
      digitalWrite(ledPin, HIGH); //turn coffee maker on
      Serial.println(", Reply was tweeted. Making coffee now.");
      //Start the coffee making
        //when water level is low
          //Stop the coffee making and run the finished function
        
        
    } 
    else {
      Serial.print("failed : code ");
      Serial.println(status);
      Serial.println(tweetString);
      Serial.print("new Tweet is this: ");
              tweetString.begin();
              tweetString = " Making coffee now, random number: ";
               randNumber = random(1000);
              tweetString.print ( randNumber);
              Serial.println(tweetString);
              delay(10000);
              return make();
    }
  } 
  else {
    Serial.println("connection failed. Cannot Tweet");
  }
}