     }
 
     client.close();
+    lastWebUpdateTime = millis();
     Serial.println(F("Done."));
   } else {
     Serial.println(F("Web server connection failed."));
   }
-
-  data_port.flush();  // clear any data in the serial buffer we missed while sending.
 }

  Serial.println(F("wireless connection successful."));

  while (!cc3000.checkDHCP()) {
    delay(100); // TODO: Insert a DHCP timeout!
  }

  uint32_t ipAddress, netmask, gateway, dhcpserv, dnsserv;
  if(!cc3000.getIPAddress(&ipAddress, &netmask, &gateway, &dhcpserv, &dnsserv)) {
    Serial.println(F("Unable to retrieve network info!"));
  } else {
    Serial.print(F("  IP Addr: ")); cc3000.printIPdotsRev(ipAddress);
    Serial.print(F("/"));           cc3000.printIPdotsRev(netmask);   Serial.println();
    Serial.print(F("  Gateway: ")); cc3000.printIPdotsRev(gateway);   Serial.println();
    Serial.print(F("  DHCPsrv: ")); cc3000.printIPdotsRev(dhcpserv);  Serial.println();
    Serial.print(F("  DNSserv: ")); cc3000.printIPdotsRev(dnsserv);   Serial.println();
  }

  initThermometer();

  // Data port setup
  data_port.begin(2400);

  Serial.println(F("Waiting for data..."));
}


void updateWeb() {
  Serial.println(F("Sending data..."));

  // The Adafruit CC3000 library only supports about 90 bytes in the fastrprint()
  // method, therefore we need two char arrays to hold all the Eagle query args.
  char eagle_query_args1[66] = "&runtime=0:00&coll_t=&stor_t=&diff_t=&hili_t=";
  char eagle_query_args2[66] = "&aux_1=&aux_2=&pump=OFF&uplim=OFF&fault=";

  if (strlen(eagle_data) > 0) {
    char *tokenptr;

    sprintf(eagle_query_args1, "&runtime=%s&coll_t=%s&stor_t=%s&diff_t=%s&hili_t=%s",
      strtok_r(eagle_data, " ", &tokenptr),
      strtok_r(NULL, " ", &tokenptr),
      strtok_r(NULL, " ", &tokenptr),
      strtok_r(NULL, " ", &tokenptr),
      strtok_r(NULL, " ", &tokenptr)
    );

    sprintf(eagle_query_args2, "&aux_1=%s&aux_2=%s&pump=%s&uplim=%s&fault=%s",
      strtok_r(NULL, " ", &tokenptr),
      strtok_r(NULL, " ", &tokenptr),
      strtok_r(NULL, " ", &tokenptr),
      strtok_r(NULL, " ", &tokenptr),
      strtok_r(NULL, " ", &tokenptr)
    );
  }

  // Convert the temerature float to something fastrprint likes
  char temp_str[7]; // "123.45"
  dtostrf(getTemperature(), 1, 2, temp_str);

  client.connect(PHANT_HOST, PHANT_HOST_PORT);
  if (client.connected()) {
    client.fastrprint(F("GET /input/")); client.fastrprint(PHANT_PUBLIC_KEY);
    client.fastrprint(F("?private_key=")); client.fastrprint(PHANT_PRIVATE_KEY);
    client.fastrprint(eagle_query_args1);
    client.fastrprint(eagle_query_args2);
    client.fastrprint(F("&ambient_t=")); client.fastrprint(temp_str);
    client.fastrprint(F(" HTTP/1.1\r\n"));

    client.fastrprint(F("Host: ")); client.fastrprintln(PHANT_HOST);

    client.fastrprint("\r\n");

    // Show the response
    unsigned long lastRead = millis();
