Problema con controllore serra

Dopo un po' di studio e prove pratiche sono arrivato alla soluzione:

/*
 Grow&Fun  
 v 1.0: Timer programmabile per luce e controlo ventola in base alla temperatura impostata
 v 1.1: Ora la ventola viene controllata in base all'umidità
 02/04/2014 
 da Guido Fabbrini
 */
#include <Wire.h>
#include <RTClib.h>
#include <Time.h>
#include <TimeAlarms.h>
#include "DHT.h"
#include <LiquidCrystal.h>
#define DHTPIN 8 
#define DHTTYPE DHT21 
DHT dht(DHTPIN, DHTTYPE);
#include <EEPROM.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

// Light states
#define STATE_OFF  0
#define STATE_ON   1

// Timer settings
#define START_TIME  0500
#define END_TIME    2300


RTC_DS1307 RTC;
// Var for Tmax e Tmin
byte tMIN;
byte tMAX;

// Var for Hmax e Hmin
byte hMIN;
byte hMAX;


int FanState; 
int lightState;

// Define Relay 
int lightRelay = 6;
int fanRelay = 7;

const int reset = 10;
int statoreset = 0;

void setup() {
  Serial.begin(9600);
  Wire.begin();
  RTC.begin();
  lcd.begin(20,4);
  dht.begin(); 
  tMIN=EEPROM.read(1);
  tMAX=EEPROM.read(2);
  hMIN=EEPROM.read(3);
  hMAX=EEPROM.read(4); 

  pinMode(reset, INPUT);
  digitalWrite(10, HIGH);
  // Set the pinmode
  pinMode(lightRelay, OUTPUT);
  pinMode(fanRelay, OUTPUT);
  digitalWrite(lightRelay, LOW);
  lightState = STATE_OFF;
  digitalWrite(fanRelay, LOW);
}

void loop() {
  {
    int h = dht.readHumidity();
    int t = dht.readTemperature();
    float h1 = dht.readHumidity();
    float t1 = dht.readTemperature();
    if (isnan(t) || isnan(h)) {
      Serial.println("FALIED to read from DHT");
    }
    else {
      lcd.setCursor(0,1);
      lcd.print("T:");
      lcd.print(t);
      lcd.print("C");
      lcd.setCursor(0,2);
      lcd.print("H:");
      lcd.print(h);
      lcd.print("%");

      Serial.print("T:");
      Serial.print(t1);
      Serial.println("");
      Serial.print("H:");
      Serial.print(h1);

      delay(100);
    }

    if (t > tMAX)
    {
      tMAX = t;
      EEPROM.write(2, t);
    }
    // se la temperatura supera il dato MAX allora modifico il dato MAX
    // scrivo questo dato anche nella eeprom
    if (t < tMIN)
    {
      tMIN = t;
      EEPROM.write(1, t);
    }
    // se la temperatura è minore del dato MIN allora modifico il dato MIN
    // scrivo questo dato anche nella eeprom


    if (h > hMAX)
    {
      hMAX = h;
      EEPROM.write(4, h);
    }
    // se la temperatura supera il dato MAX allora modifico il dato MAX
    // scrivo questo dato anche nella eeprom
    if (h < hMIN)
    {
      hMIN = h;
      EEPROM.write(3, h);
    }
    // se la temperatura è minore del dato MIN allora modifico il dato MIN
    // scrivo questo dato anche nella eeprom
    statoreset = digitalRead (reset);
    if( statoreset == LOW){
      tMIN = t;
      tMAX = t;
      hMAX = h;
      hMIN = h;
    }

    lcd.setCursor(6,1);
    lcd.print("T+:");
    lcd.print(tMAX);
    lcd.print("C");
    lcd.setCursor(13,1);
    lcd.print("T-:");
    lcd.print(tMIN);
    lcd.print("C");
    lcd.setCursor(6,2);
    lcd.print("H+:");
    lcd.print(hMAX);
    lcd.print("%");
    lcd.setCursor(13,2);
    lcd.print("H-:");
    lcd.print(hMIN);
    lcd.print("%");

    statoreset = digitalRead (reset);
    if( statoreset == LOW){
      tMIN = t;
      tMAX = t;
      hMAX = h;
      hMIN = h;
    }


  }
  DateTime now = RTC.now();
  int nowHourMinute = now.hour()*100 + now.minute(); 
  int h2 = dht.readHumidity();
  // FSM states
  switch(lightState) {

  case STATE_OFF:
    if(nowHourMinute > START_TIME && nowHourMinute < END_TIME) {
      Serial.print(now.hour(), DEC);
      Serial.print(':');
      Serial.print(now.minute(), DEC);
      digitalWrite(lightRelay, HIGH);
      digitalWrite(fanRelay, HIGH);
      Serial.println("\nFan On");
      Serial.println("\nLight On");
      FanState = STATE_ON;
      lcd.setCursor(10,3);
      lcd.print("Fan ON");
      lcd.setCursor(0,3);
      lcd.print("Light ON");
      lightState = STATE_ON;

    }
    break;

  case STATE_ON:
    if(nowHourMinute > END_TIME) {
      Serial.print(now.hour(), DEC);
      Serial.print(':');
      Serial.print(now.minute(), DEC);       
      digitalWrite(lightRelay, LOW);
      lcd.setCursor(0,3);
      lcd.print("        ");
      lightState = STATE_OFF;

    }    
    break;
  }
  switch(FanState) {

  case STATE_OFF:
    if(lightState = STATE_ON && h2>51) {
      digitalWrite(fanRelay, HIGH);
      Serial.println("\nFan On");
      FanState = STATE_ON;
      lcd.setCursor(10,3);
      lcd.print("Fan ON");

    }
    break;

  case STATE_ON:
    if(lightState= STATE_ON && h2<49) {
      digitalWrite(fanRelay, LOW);
      Serial.println("\nFan Off");
      lcd.setCursor(10,3);
      lcd.print("      ");
      FanState = STATE_OFF;
    }    
    break;
  }

  lcd.setCursor(0,0);
  if (now.day()<10)
  {
    lcd.print("0");
  }
  lcd.print(now.day(), DEC);
  lcd.print('/');
  if (now.month()<10)
  {
    lcd.print("0");
  }
  lcd.print(now.month(), DEC);
  lcd.print('/');
  lcd.print(now.year(), DEC);
  lcd.print(' ');
  if (now.hour()<10)
  {
    lcd.print("0");
  }
  lcd.print(now.hour(), DEC);
  lcd.print(":");
  if (now.minute()<10)
  {
    lcd.print("0");
  }
  lcd.print(now.minute(), DEC);
  lcd.print(":");
  if (now.second()<10)
  {
    lcd.print("0");
  }
  lcd.print(now.second(), DEC);

  Serial.println("");
  Serial.print(now.day(), DEC);
  Serial.print('/');
  Serial.print(now.month(), DEC);
  Serial.print('/');
  Serial.print(now.year(), DEC);
  Serial.print(' ');
  Serial.print(now.hour(), DEC);
  Serial.print(':');
  Serial.print(now.minute(), DEC);
  Serial.print(':');
  Serial.print(now.second(), DEC);
  Serial.println();   
  Serial.println();
  Alarm.delay(100);
}

L'ultima cosa che vorrei correggere è il problema del tempo:
i secondi non scorrono bene, e ogni settimana più o meno l'orologio è avanti di 5 minuti,
suggerimenti?