            (((float) currentTemp) <= ((float) TEMP_TOO_LOW)))                           // humidifier goes too far, stop the air conditioning temperarily
         {
           daikin_all_off();
+          resend = 0;       // reset the sending count
           timeElapsed = 0;  // reset mode-switch timer
         }
         else if((((float) currentTemp) > ((float) TEMP_LOW) && currentRh < RH_LOW) ||   // humidity reaches low but temperature is higher than low
                 ((float) currentTemp > (float) TEMP_HIGH))                              // if high temp reached, switch to cooling
         {
           daikin_cooling_on();
+          resend = 0;       // reset the sending count
           timeElapsed = 0;  // reset mode-switch timer
         }
       }


// Elapsed Time Control
elapsedMillis timeElapsed;

/**
 *  Setup


  // =================================================================================================================================

  // Resend the same command every period of time in case the previous IR command is missing
  // Note: The buzzer on the Air Conditioning Set has been removed
  unsigned int resendTimerInMinutes = resendTimer / (long) 60000;
  if(resendTimerInMinutes >= RESEND_CMD_TIMER)
  {
    resend = 0;
    resendTimer = 0;
  }
  
  // delay a minutes until next reading
  delay(60000);

