 }
 
 
-void sendHx711toMqtt(String payload, char* topic) 
+void sendHx711toMqtt(String payload, char* topic)
 {
   if (WiFi.status() == WL_CONNECTED) {
-      if (!client.connected()) {
-        if (
-          client.connect(MQTT::Connect((char*) clientName.c_str())
-                         .set_clean_session()
-                         .set_will("status", "down")
-                         .set_keepalive(60))
-        ) {
-          Serial.println("Connected to MQTT broker again HX711");
+    if (!client.connected()) {
+      if ( client.connect(MQTT::Connect((char*) clientName.c_str()).set_clean_session().set_keepalive(120))) {
+        client.publish(hellotopic, "hello from ESP8266 s06");
+      }
+    }
+
+    if (client.connected()) {
+      Serial.print("Sending payload: ");
+      Serial.println(payload);
+
+      if (client.publish(MQTT::Publish(topic, (char*) payload.c_str()).set_retain())) {
+        Serial.println("Publish ok");
+        if ( topic == "esp8266/arduino/s06" ) {
+          AvgMeasuredIsSent = HIGH;
         }
-        else {
-          Serial.println("MQTT connect failed");
-          Serial.println("Will reset and try again...");
-          ESP.restart(); 
-        }
-      }
-
-      if (client.connected()) {
-        Serial.print("Sending payload: ");
-        Serial.println(payload);
-
-        if (client.publish(MQTT::Publish(topic, (char*) payload.c_str()).set_retain())) {
-          Serial.println("Publish ok");
-          if ( topic == "esp8266/arduino/s06" ) {
-            AvgMeasuredIsSent = HIGH;
-          }
-        }
-        else {
-          Serial.println("Publish failed");
-          ESP.restart(); 
-        }
-      }
+      }
+      else {
+        Serial.println("Publish failed");
+        ESP.restart();
+      }
+    }
   } else {
-      Serial.println("Could not connect to WIFI");
-      ESP.restart();    
+    Serial.println("Could not connect to WIFI");
+    ESP.restart();
   }
 }
 

  sendHx711toMqtt(payload, topicEvery);

  payload = "{\"WeightAvg\":0}";
  sendHx711toMqtt(payload, topicAverage);  

}



  if (WiFi.status() == WL_CONNECTED) {
    if (!client.connected()) {
      if  ( client.connect(MQTT::Connect((char*) clientName.c_str()).set_clean_session().set_keepalive(120))) {
        client.publish(hellotopic, "hello from ESP8266 s06");
      }
    }

    if (client.connected()) {
      client.loop();
    }
  } else {
    Serial.println("Could not connect to WIFI");
    ESP.restart();
  }

  if ( blank_checked == LOW ) {
    delay(2000);
    check_blank();
