 
   if ( Measured > 500 )
   {
+    delat(2000);
+    int average_Measured = int( scale.get_units(5) * 1000 );
     Serial.println("======> tilting detected, nemo is on pad");
-    /*
-    digitalWrite(espnemoIsOnPadPin, HIGH);
-    espReset();
-    */
+
+    for (int thisReading = 0; thisReading < numReadings; thisReading++) {
+      readings[thisReading] = average_Measured ;
+    }
 
   } else {
     Serial.println("======> tilting detected, but nemo is not on pad");

    sleepNow();
  }

  if ( IsEspReseted == LOW )
  {
    delay(500);
  } else {
    delay(1000);
  }
}

void espReset()

void loop()
{

  if ( IsEspReseted == LOW ) 
  {
      Measured = int( scale.get_units(5) * 1000 );
      Serial.print("==> weight : ");
      Serial.print(Measured);
      Serial.print(" ==> ");

      if (( Measured > 500 ) && ( Measured > (average - 500)))
      {
            total = total - readings[indexof];
            readings[indexof] = Measured;
            total = total + readings[indexof];
            indexof = indexof + 1;

            if (indexof >= numReadings) 
            {
              indexof = 0;
            }

            average = total / numReadings;

            Serial.print("  average ==>  ");
            Serial.println(average);
      } else {
            Serial.println("");
      }         

      if ( Measured <= 500 ) 
      {
            if ( Attempt == 0 ) 
            {
              Serial.println("");
              Serial.print("============> nemo is not on pad now");
            }
            Serial.println("");
            Attempt++;
      }

      if ( Attempt == 10 )
      {
            Serial.println("======> Measurement has problem");
            sleepNow();
      }

      if (( average > 1000 ) && ( Measured < (average - 1000)) )
      {
            VccValue = vcc.Read_Volts() * 1000 ;
            Serial.println("");
            Serial.print("==========> VCC ");
            Serial.println(VccValue);
            espReset();
            IsEspReseted = HIGH;
            Attempt = 0;
      }
      delay(500);
  }

  if ( IsEspReseted == HIGH ) {
      Attempt++;
      if ( Attempt == 20 ) 
      {
          Serial.println("======> I2C has problem");
          sleepNow();
      }
      delay(1000);
  }


  if ( mqttMsgSent == HIGH )
  {
