 }
 
 //
-//  Function to connect and reconnect as necessary to the MQTT server.
-//  Should be called in the loop function and it will take care if connecting.
-//
-void MQTT_connect()
-{
-    int8_t result;
-
-    if (mqtt.connected())
-    {
-        return;
-    }
-
-    Debugger::DebugMessage("Connecting to MQTT... ");
-    while ((result = mqtt.connect()) != 0)
-    {
-        switch (result)
-        {
-            case 1: 
-                Debugger::DebugMessage("Wrong protocol");
-                break;
-            case 2: 
-                Debugger::DebugMessage("ID rejected");
-                break;
-            case 3: 
-                Debugger::DebugMessage("Server unavailable");
-                break;
-            case 4:
-                Debugger::DebugMessage("Bad user/password");
-                break;
-            case 5:
-                Debugger::DebugMessage("Not authenticated"); 
-                break;
-            case 6:
-                Debugger::DebugMessage("Failed to subscribe");
-                break;
-            default:
-                String message = "Couldn't connect to server, code: ";
-                char buffer[20];
-                message += itoa(result, buffer, 10);
-                Debugger::DebugMessage(message);
-                break;
-        }
-        Debugger::DebugMessage("Retrying MQTT connection in 5 seconds...");
-        mqtt.disconnect();
-        delay(5000);
-    }
-    Debugger::DebugMessage("MQTT Connected!");
-} 
-
-//
-//  Check if the data was sent to Adafruit IO OK
-//
-void CheckMQTTLoggingResult(bool result, String readingType)
-{
-    if (result)
-    {
-        Debugger::DebugMessage("MQTT Success: " + readingType);
-    }
-    else
-    {
-        Debugger::DebugMessage("MQTT Failed: " + readingType);
-    }
-}
-
-//
 //  Update the RTC with the time from the Internet.
 //
 void UpdateRTCWithInternetTime(DS3231 *rtc)

#define PHANT_DOMAIN        "data.sparkfun.com"
#define PHANT_PAGE          "/input/zDA9M8dQlahOqo4bx5Dd"
#define PHANT_PORT          80

//
//  Stuff required for Adafruit IO.
//
WiFiClient _wifiClient;
#define AIO_SERVER      "io.adafruit.com"
#define AIO_SERVERPORT  1883

// Store the MQTT server, client ID, username, and password in flash memory.
// This is required for using the Adafruit MQTT library.
const char MQTT_SERVER[] PROGMEM = AIO_SERVER;
// Set a unique MQTT client ID using the AIO key + the date and time the sketch
// was compiled (so this should be unique across multiple devices for a user,
// alternatively you can manually set this to a GUID or other random value).
const char MQTT_CLIENTID[] PROGMEM = AIO_KEY __DATE__ __TIME__;
const char MQTT_USERNAME[] PROGMEM = AIO_USERNAME;
const char MQTT_PASSWORD[] PROGMEM = AIO_KEY;

// Setup the MQTT client class by passing in the WiFi client and MQTT server and login details.
Adafruit_MQTT_Client mqtt(&_wifiClient, MQTT_SERVER, AIO_SERVERPORT, MQTT_CLIENTID, MQTT_USERNAME, MQTT_PASSWORD);
const char WINDSPEED_FEED[] PROGMEM = AIO_USERNAME "/feeds/windspeed";
Adafruit_MQTT_Publish _windSpeedFeed = Adafruit_MQTT_Publish(&mqtt, WINDSPEED_FEED);

const char WIND_DIRECTION[] PROGMEM = AIO_USERNAME "/feeds/winddirection";
Adafruit_MQTT_Publish _windDirectionFeed = Adafruit_MQTT_Publish(&mqtt, WIND_DIRECTION);

const char UVLIGHT_FEED[] PROGMEM = AIO_USERNAME "/feeds/uvlight";
Adafruit_MQTT_Publish _uvLightFeed = Adafruit_MQTT_Publish(&mqtt, UVLIGHT_FEED);

const char RAINFALL_FEED[] PROGMEM = AIO_USERNAME "/feeds/rainfall";
Adafruit_MQTT_Publish _rainFallFeed = Adafruit_MQTT_Publish(&mqtt, RAINFALL_FEED);

const char HUMIDITY_FEED[] PROGMEM = AIO_USERNAME "/feeds/humidity";
Adafruit_MQTT_Publish _humidityFeed = Adafruit_MQTT_Publish(&mqtt, HUMIDITY_FEED);

const char GROUND_TEMPERATURE_FEED[] PROGMEM = AIO_USERNAME "/feeds/groundTemperature";
Adafruit_MQTT_Publish _groundTemperatureFeed = Adafruit_MQTT_Publish(&mqtt, GROUND_TEMPERATURE_FEED);

const char DAYLIGHT_FEED[] PROGMEM = AIO_USERNAME "/feeds/daylight";
Adafruit_MQTT_Publish _daylightFeed = Adafruit_MQTT_Publish(&mqtt, DAYLIGHT_FEED);

const char AIR_TEMPERATURE_FEED[] PROGMEM = AIO_USERNAME "/feeds/airtemperature";
Adafruit_MQTT_Publish _airTemperatureFeed = Adafruit_MQTT_Publish(&mqtt, AIR_TEMPERATURE_FEED);

const char AIR_PRESSURE_FEED[] PROGMEM = AIO_USERNAME "/feeds/airpressure";
Adafruit_MQTT_Publish _airPressureFeed = Adafruit_MQTT_Publish(&mqtt, AIR_PRESSURE_FEED);

//
//  Used for debugging, determine the output state of the onboard LED.

//
void setup()
{
    Serial.begin(115200);
    Serial.println();
    Serial.println();
    Wire.begin();
