 double currentTempC = 0;
 int counter = 0;
 
+int LOOP_DELAY_MS = 2500; // 2.5 sec
+int FORCE_SEND_TEMP_INTERVAL_MS = 120000; // 2 min
+
+int TEMP_LOOP_CNT_THRESHOLD;
+
 void printTemp(float celcius, float fahrenheit)
 {
-  char str[100];
-  sprintf(str, "Temperature: %f C, %f F", celcius, fahrenheit);
-  Serial.println(str);
+  Serial.printlnf("Main> Temperature: %f C, %f F", celcius, fahrenheit);
 }
 
 void test_server(){


      // If it has failed 5 times to send the data, then assume the service is
      // down and put the system in an error state
      if(counter > 15){
        Serial.println("Main> Failed to send data to the server several times.  Putting system in error state.");
        is_server_available = false;
      }
    }

    counter = counter + 1;
  }

  led.setColor(GREEN);
  Serial.flush();
  delay(2500);
}

    // If the temp has not changed (+/- .5 degrees) no need to send the data
    // However, if the counter reaches 10, then send the data anyway
    // to notify the server that you are still alive :)
    double diff = currentTempC - celcius;
    if (abs_d(diff) > .5 || counter > TEMP_LOOP_CNT_THRESHOLD) {
      led.setColor(BLUE);
      Serial.print("Main> Sending current temp data to server.");
      Serial.printlnf("Previous temp: %f C, Current temp: %f C", currentTempC, celcius);
      currentTempC = celcius;
      if (! client.SendTemperatureData(celcius, fahrenheit)) {
        Serial.println("Main> Failed to send data to server, will try again next time");
      }
