 
 boolean reconnect() {
   if  ( client.connect(MQTT::Connect((char*) clientName.c_str()).set_clean_session().set_keepalive(120))) {
-    client.publish(hellotopic, "hello again from ESP8266 s06");
+    client.publish(hellotopic, "hello again 1 from ESP8266 s06");
   }
   return client.connected();
 }

          payload = "{\"WeightPoop\":";
          payload += ( int(ave.mean()) - measured_empty );
          payload += ",\"NemoWeight\":0}";
          sendHx711toMqtt(payload, topicEvery);

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

          AvgMeasuredIsSent = LOW;
        } else {

  r = !r;
}

void sendHx711toMqtt(String payload, char* topic, int retain)
{
  if (!client.connected()) {
    if ( client.connect(MQTT::Connect((char*) clientName.c_str()).set_clean_session().set_keepalive(120))) {
      client.publish(hellotopic, "hello again 2 from ESP8266 s06");
    }
  }

  if (client.connected()) {
    Serial.print("Sending payload: ");
    Serial.println(payload);

    if ( retain == 1 ) {
      if ( client.publish(MQTT::Publish(topic, (char*) payload.c_str()).set_retain()) ) {
        if ( topic == "esp8266/arduino/s06" ) { AvgMeasuredIsSent = HIGH; }
        Serial.println("Publish ok");
      } else {
        Serial.println("Publish failed");
        abort();
      }
    } else {
      if ( client.publish(MQTT::Publish(topic, (char*) payload.c_str()) ) {
        if ( topic == "esp8266/arduino/s06" ) { AvgMeasuredIsSent = HIGH; }
        Serial.println("Publish ok");
      } else {
        Serial.println("Publish failed");
        abort();
      }      
    }

  }

}


