WiFly code help!

Hello,

I have the WiFly up and running and sending values from a soil moisture sensor out to a PHP script which then posts to Twitter. I’m using the WiFly.h library, and all that works - however, for some reason, the loop stalls out after a relatively short (it seems) period of time, and I’m not sure where to look in my code for the error or fix. Any help would be very much appreciated!! Code is below - thank you in advance.

Claudia

// (Based on Ethernet's WebClient Example)

#include "WiFly.h"
#include "Credentials.h"


byte server[] = {10, 0, 1, 2}; // server IP
Client client(server, 80);
//unsigned long time;
int timer;

void setup() {
  
  Serial.begin(9600);

  WiFly.begin();
  //time = millis();
  
  if (!WiFly.join(ssid, passphrase)) {
    Serial.println("Association failed.");
    while (1) {
      // Hang on failure.
    }
  }  

  Serial.println("Associated! Now connecting to client...");
  //check once on start
  //checkWater();
}

void loop() {
  checkWater();
  readClient();
  delay(50000);
}

void checkWater(){
  //faking the value for now
  Serial.println("checkWater()");
  int currVal = random(1000);
  
  if (client.connect()) {
    Serial.print("Connected! My Val is ");
    Serial.println(currVal);
    client.print("GET /~claudia/LYON/updatestatus.php?");
    client.print("val=");
    client.println(currVal);
  } 
  else {
    Serial.println("Connection failed.");
  } 
}

void readClient(){
  //Serial.print("reading Client, available is ");
  if (client.available()) {
    char c = client.read();
    Serial.print(c);
  }
  
  if (!client.connected()) {
    Serial.println();
    Serial.println("disconnecting.");
    client.stop();
    for(;;)
      ;
  }  
}

UPDATE: i wouldn’t think this is the problem, but i do occasionally get the error message that the USB port is drawing too much power. could this disrupt the loop itself somehow? wouldn’t seem like it - but if anyone has any experience with this, input would be great. in the meantime, i’m going to run it for a while via direct power and see what i get.