         Debugger::DebugMessage("Setting RTC to: " + rtc->DateTimeString(dateTime));
         delay(1000);
     }
+    else
+    {
+        Debugger::DebugMessage("NTP retry count exceeded.");
+    }
     ntp->stop();
 }
 

    char number[20];
    
    String url = PHANT_PAGE "?private_key=" PHANT_PRIVATE_KEY;
    url += "&When=";
    ts *currentDateTime = rtc->GetDateTime();
    String dateTime = rtc->DateTimeString(currentDateTime);
    dateTime.replace(" ", "T");
    url += dateTime;
    delete(currentDateTime);
    url += "&airpressure=";
    url += Debugger::FloatToAscii(number, _sensors->GetAirPressure() / 100, 0);
    url += "&groundmoisture=0";
    url += "&groundtemperature=";
    url += Debugger::FloatToAscii(number, _sensors->GetGroundTemperatureReading(), 2);
    url += "&temperature=";
    url += Debugger::FloatToAscii(number, _sensors->GetAirTemperature(), 2);
    url += "&humidity=";
    url += Debugger::FloatToAscii(number, _sensors->GetHumidity(), 2);
    url += "&luminosity=";
    url += Debugger::FloatToAscii(number, _sensors->GetLuminosityReading(), 2);
    url += "&rainfall=";
    url += Debugger::FloatToAscii(number, _sensors->GetRainfall(), 2);
    url += "&ultravioletlight=";
    url += Debugger::FloatToAscii(number, _sensors->GetUltravioletLightStrength(), 2);
    url += "&winddirection=0";
    url += "&windspeed=";
    url += Debugger::FloatToAscii(number, _sensors->GetWindSpeed(), 2);
    _udpDebug.println(url);
    //
    //  Send the data to Phant (Sparkfun's data logging service).
    //

    delete(dateTime);
}

void ReadAndPublishData()
{
    char _buffer[20];
    String _message;

    digitalWrite(PIN_ONBOARD_LED, HIGH);
    _message = "Reading sensor data (";
    _message += itoa(_readingNumber, _buffer, 10);
    _message += ")";
    Debugger::DebugMessage(_message);
    _sensors->ReadAllSensors();
    Debugger::LogLuminosityData(_sensors->GetLuminosityReading());
    Debugger::LogTemperatureHumidityAndPressureData(_sensors->GetAirTemperature(), _sensors->GetHumidity(), _sensors->GetAirPressure());
    Debugger::LogGroundTemperature(_sensors->GetGroundTemperatureReading());
    //Debugger::LogUltravioletData(_sensors->GetUltravioletLightStrength());
    Debugger::LogRainfall(0, _pluviometerCountToday * 0.2794);
    //
    _message = "Wind speed pulse count: ";
    _message += itoa(_lastFiveSecondWindSpeedCount, _buffer, 10);
    Debugger::DebugMessage(_message);
    //
    _message = "Wind speed: ";
    _message += Debugger::FloatToAscii(_buffer, (_lastFiveSecondWindSpeedCount * 1.492) / 5, 2);
    _message += "mph";
    Debugger::DebugMessage(_message);
    //
    //  Now post to the Internet.
    //
    Debugger::DebugMessage("Posting to Internet.");
    PostDataToPhant();
    //MQTT_connect();
    //CheckMQTTLoggingResult(_airPressureFeed.publish(_sensors->GetAirPressure() / 100), "Air Pressure");
    //CheckMQTTLoggingResult(_airTemperatureFeed.publish(_sensors->GetAirTemperature()), "Air Temperature");
    //CheckMQTTLoggingResult(_daylightFeed.publish(_sensors->GetLuminosityReading()), "Daylight");
    //CheckMQTTLoggingResult(_groundTemperatureFeed.publish(_sensors->GetGroundTemperatureReading()), "Ground Temperature");
    //CheckMQTTLoggingResult(_humidityFeed.publish(_sensors->GetHumidity()), "Humidity");
    //CheckMQTTLoggingResult(_rainFallFeed.publish(_sensors->GetTotalRainfallToday()), "Rainfall");
    //CheckMQTTLoggingResult(_windSpeedFeed.publish(_sensors->GetWindSpeed()), "Wind Speed");
    //CheckMQTTLoggingResult(_windDirectionFeed.publish(_sensors->GetWindDirectionAsString()), "Wind Direction");
    //CheckMQTTLoggingResult(_uvLightFeed.publish(_sensors->GetUltravioletLightStrength()), "Ultraviolet Light");
    //Debugger::DebugMessage("Posting complete'");
    digitalWrite(PIN_ONBOARD_LED, LOW);
}

//
//  Handle the RTC interrupt.
//
