 // Create a unique MQTT client id.
 const char* mqtt_clientid = String(MQTTprefix +
                                    String(ESP.getChipId(), HEX)).c_str();
-#endif
+#endif  // MQTT_ENABLE
 
 // Debug messages get sent to the serial port.
 void debug(String str) {
 #ifdef DEBUG
-  Serial.println(str);
-#endif
+  uint32_t now = millis();
+  Serial.printf("%07u.%03u: %s\n", now / 1000, now % 1000, str.c_str());
+#endif  // DEBUG
 }
 
 // Root web page with example usage etc.

    // MQTT loop
    mqtt_client.loop();
  }
#endif
  delay(100);
}


}

bool reconnect() {
  // Loop a few times or until we're reconnected
  uint16_t tries = 1;
  while (!mqtt_client.connected() && tries <= 3) {
    int connected = false;
    // Attempt to connect
    debug("Attempting MQTT connection to " MQTT_SERVER ":" + String(MQTT_PORT) +
          "... ");
    if (mqtt_user && mqtt_password)
      connected = mqtt_client.connect(mqtt_clientid, mqtt_user, mqtt_password);
    else
