 
     // don't send out temperature too often as we'll get 
     // incorrect values if we sample too often
-    char tempMessage[MAX_MESSAGE_SIZE];
-    char floatBuffer[10];
+
 
     // read temperature in Celsius
-    float currentTemp = SHT2x.GetTemperature();
+    currentTemp = SHT2x.GetTemperature();
     snprintf(tempMessage, MAX_MESSAGE_SIZE, "0, 0 - temp: %s",
              dtostrf(currentTemp, 4, 2, floatBuffer));
     client.publish(TEMP_TOPIC, tempMessage);
 
     // read humidity
-    float currentHumidity = SHT2x.GetHumidity();
+    currentHumidity = SHT2x.GetHumidity();
     snprintf(tempMessage, MAX_MESSAGE_SIZE, "0, 0 - hum: %s",
              dtostrf(currentHumidity, 4, 2, floatBuffer));
     client.publish(HUM_TOPIC, tempMessage);
 
     char lightMessage[MAX_MESSAGE_SIZE];
-    int lightValue = analogRead(LIGHT_PIN);
+    lightValue = analogRead(LIGHT_PIN);
     snprintf(lightMessage, MAX_MESSAGE_SIZE, "0, 0 - light: %d", lightValue);
     client.publish(LIGHT_TOPIC, lightMessage);
 
     counter = 0;
   }
+
+  server.handleClient();
 }

};

ESP8266WiFiGenericClass wifi;

#ifdef USE_CERTS
// if certs are used the following must be defined in WirelessConfig.h


int counter = 0;
char macAddress[] = "00:00:00:00:00:00";


char tempMessage[MAX_MESSAGE_SIZE];
char floatBuffer[10];
float currentTemp = 0;
float currentHumidity = 0;
int lightValue = 0;
void provideMetrics() {
  snprintf(tempMessage, MAX_MESSAGE_SIZE, "plant_humidity %s\n",
             dtostrf(currentHumidity, 4, 2, floatBuffer));
  String ptr = tempMessage;
  snprintf(tempMessage, MAX_MESSAGE_SIZE, "plant_temperature %s\n",
           dtostrf(currentTemp,4, 2, floatBuffer));
  ptr+= tempMessage;
  snprintf(tempMessage, MAX_MESSAGE_SIZE, "plant_light %d\n", lightValue);
  ptr+= tempMessage;

  server.send(200, "text/plain", ptr);
}

void setup() {
  delay(1000);
