Help with grow room controller, pump time issues

Hello there I’m having issues with my grow room controller.
im using arduino
mega
2 dht11
8 relay shield ywrobot

My pump timer is set to 1 min on 4min off repeat seems to restart my program after a while not sure why? Also I have two different lighting schedules Veg room 18 hrs on 6 off and bloom room 12 hrs on 12 hrs off and not sure if this could be the issue?

Anyways here’s my 1st part of code

#include <stdlib.h>
#include <Time.h>
#include <TimeAlarms.h>
#include <Wire.h>
#include <DS1307RTC.h>
#include <NewSoftSerial.h>
#include <SD.h>
#include <LiquidCrystal.h>
#include <DHT.h>


//Define CS pin for SD card and the ethernet board
#define SD_PIN 49
#define DHT1PIN A1          // DHT 11 On analog1
#define DHT2PIN A2          // DHT 11 On analog2

#define DHTTYPE DHT11       
DHT dht1(DHT1PIN, DHTTYPE);
DHT dht2(DHT2PIN, DHTTYPE);



// Control pins for the light, fan, heater, humidifier & dehumidifier
#define VEGLIGHT_PIN 24
#define VEGFANS_PIN 26
#define VEGPUMPS_PIN 28


#define FLWRLIGHT_PIN 32
#define FLWRFANS_PIN 34
#define FLWRPUMPS_PIN 36

//Global Variables/////////////////////////////////////////////////

#define HEATER_PIN 40
#define HUMIDIFIER_PIN 50
#define AIRCON_PIN 51
#define DEHUMIDIFIER_PIN 42

// LCD has 2x16 character display
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);

// Lenths of certain Messages and Strings
#define eventMsgLen 24


//LCD Message Delay Time
int lcdDelay = 1000;

// Create Controller Structure, one of these is needed for each appliance
struct Controller
{
  byte pin; //The pin that the relay that controlls the appliance is connected to
  int invert; // 0 - heater, humidifier, etc; 1 - Air Conditioner, dehumifier, etc.
  int turnPoint; //The maximum (minimum if inverted) the sensor reading can be before turning on
  int status; // 0 - off; 1 - on
  char label[16]; // The name of the appliance (ex: Heater)
  char controlLabel[12]; // The reading that is being controlled (ex: Temperature)
};

// Create controller for the Heater, VegFans, Humidifier
// and Dehumidifier

Controller VegFans;
Controller FlwrFans;
Controller AirCon;
Controller Heater;
Controller Humidifier;
Controller Dehumidifier;
extern volatile unsigned long timer0_overflow_count;

void PumpTimer(unsigned long onTime, unsigned long offTime, unsigned long previousMilis); //Function Prototype

unsigned long previousMillis=0;
unsigned long currentMillis=0;

//Zone Times
unsigned long onTime=60000; 
unsigned long offTime=240000;

// String to pass on to controlLabel for Temperature, Humidity and Light
const char VegtempString[12] = "Veg Temp";
const char VeghumiString[13] = "Veg Humidity";
const char VeglightStr[10] = "Veg Light";
const char VegpumpsStr[11] = "Veg Pumps";


const char FlwrtempString[15] = "Flower Temp";
const char FlwrhumiString[16] = "Flower Humidity";
const char FlwrlightStr[15] = "Flower Lights";
const char FlwrpumpsStr[15] = "Flower Pumps";

// CSV box Seperator
const char boxSeperator[3] = ", ";

// Message strings for powering on and off appliances
const char powerOnMsg[16] = "Power ON: ";
const char powerOffMsg[16] = "Power OFF: ";
  
// Variables to store the power state of the light, fan and heater
boolean veglightState = false;
boolean flwrlightState = false;
// Variable to store temperature and humidity readings
float VegTempVal;
float VegHumidVal;
float FlwrHumidVal;
float FlwrTempVal;
// Hours that the light is switched on and off
int VegLightOnHour = 24;
int VegLightOffHour = 1;
int FlwrLightOnHour = 24;
int FlwrLightOffHour =1;

// Maximum and minimum temperature and humidity
int maxVegTemp = 23;
int minVegTemp = 15;
int maxVegHumi = 65;
int minVegHumi = 50;

int maxFlwrTemp = 24;
int minFlwrTemp = 15;
int maxFlwrHumi = 60;
int minFlwrHumi = 40;

// Previous Date for keeping track of log files
int prevDate = 0;

// File object for the data log file
File dataFile;

// True if SD card was able to initilize
boolean SDavailable = false;

/************************************
 *               Setup              *
 ************************************/
 
void setup()
{  
  // Start the serial port to communicate to the PC at 9600 baud
  Serial.begin(9600);
  setTime(23, 59, 0, 02, 05, 2012); // sec, min, hour, date, month, year // Replace this with the most current time

  dht1.begin();
  dht2.begin();
   
  // Start up the LCD display
  lcd.begin(16,2);
  lcd.print("   Max Yield ");
  lcd.setCursor(0,1);
  lcd.print("    Ver 1.0");
  // Get the time from the RTC
 // setSyncProvider(RTC.get);
  
  // Report whether the Arduino was able to communicate with the RTC
  if(timeStatus()!= timeSet) 
     Serial.println("Unable to sync with the RTC");
  else
     Serial.println("RTC has set the system time");   

  // See if the card is present and can be initialized
  if (!SD.begin(SD_PIN)) {
    Serial.println("SD card failed to initialize");
  }
  else {
    Serial.println("SD card initialized.");
    SDavailable = true;
  }
  
  // Read values from the sensor
  VegHumidVal  = dht1.readHumidity();
  VegTempVal   = dht1.readTemperature();
  FlwrHumidVal = dht2.readHumidity();
  FlwrTempVal  = dht2.readTemperature();

  // Save a reading to the current log file
  LogData();
  
  // Log the time of Startup in the current event Log
  char startMsg[15] = "Device Startup";
  LogEvent(startMsg);
  
  // Create alarms that turn on and off the light
  Alarm.alarmRepeat(VegLightOnHour,00,0, VegLightOnAlarm);  // 8:00pm every day
  Alarm.alarmRepeat(VegLightOffHour,00,0,VegLightOffAlarm);  // 11:00am every day 
  
  // Create alarms that turn on and off the light
  Alarm.alarmRepeat(FlwrLightOnHour,00,0, FlwrLightOnAlarm);  // 8:00pm every day
  Alarm.alarmRepeat(FlwrLightOffHour,00,0,FlwrLightOffAlarm);  // 11:00am every day 
  
  // Update the time displayed on the LCD every 60 seconds
  Alarm.timerRepeat(30, LCDrefresh);
  
  // Set controller variables for VegFans
  VegFans.pin = VEGFANS_PIN;
  VegFans.invert = 0;
  VegFans.turnPoint = maxVegTemp;
  VegFans.status=1;
  strncpy(VegFans.label, "Veg Fans", 12);
  strncpy(VegFans.controlLabel, VegtempString, 12);
  
   // Set controller variables for FlwrFans
  FlwrFans.pin = FLWRFANS_PIN;
  FlwrFans.invert = 0;
  FlwrFans.turnPoint = maxFlwrTemp;
  FlwrFans.status=1;
  strncpy(FlwrFans.label, "Flwr Fans", 12);
  strncpy(FlwrFans.controlLabel, FlwrtempString, 12);
  
   // Set controller variables for Heater
  Heater.pin = HEATER_PIN;
  Heater.invert = 1;
  Heater.turnPoint = minFlwrTemp;
  Heater.status = 1;
  strncpy(Heater.label, "Heater", 8);
  strncpy(Heater.controlLabel, FlwrtempString, 12);
  
  // Set controller variables for Heater
  AirCon.pin = AIRCON_PIN;
  AirCon.invert = 0;
  AirCon.turnPoint = maxFlwrTemp;
  AirCon.status = 1;
  strncpy(AirCon.label, "AirCon", 8);
  strncpy(AirCon.controlLabel, FlwrtempString, 12);
    
  //Set controller variables for the Humidifier
  Humidifier.pin = HUMIDIFIER_PIN;
  Humidifier.invert = 1;
  Humidifier.turnPoint = minFlwrHumi;
  Humidifier.status=1;
  strncpy(Humidifier.label, "Humidifier", 12);
  strncpy(Humidifier.controlLabel, FlwrhumiString, 12);
  
  //Set controller variables for Dehumidifier
  Dehumidifier.pin = DEHUMIDIFIER_PIN;
  Dehumidifier.invert = 0;
  Dehumidifier.turnPoint = maxFlwrHumi;
  Dehumidifier.status=1;
  strncpy(Dehumidifier.label, "Dehumidifier", 12);
  strncpy(Dehumidifier.controlLabel, FlwrhumiString, 12);
  
  pinMode(VEGLIGHT_PIN, OUTPUT); // set pin as an output for light control
  pinMode(VEGFANS_PIN, OUTPUT); 
  pinMode(VEGPUMPS_PIN,OUTPUT);
  pinMode(FLWRLIGHT_PIN, OUTPUT); // set pin as an output for light control
  pinMode(FLWRFANS_PIN, OUTPUT);
  pinMode(FLWRPUMPS_PIN,OUTPUT);
 /////////////////////////////////////////////////////////////////////////////////// 
  pinMode(AIRCON_PIN, OUTPUT); // set pin as an output for fan control
  pinMode(HEATER_PIN, OUTPUT); // set pin as an output for heater control
  pinMode(HUMIDIFIER_PIN, OUTPUT); // set pin as output for humidifier control
  pinMode(DEHUMIDIFIER_PIN, OUTPUT); // set pin as output for dehumidifier control
  
  pinMode(SD_PIN, OUTPUT); // set chip seldect pin as an output
  
  digitalWrite(VEGLIGHT_PIN, HIGH);
  digitalWrite(VEGPUMPS_PIN,HIGH);
  digitalWrite(FLWRLIGHT_PIN, HIGH);
  digitalWrite(FLWRPUMPS_PIN,HIGH);
 
   // Update LCD Screen
  LCDrefresh();
}

Seem to be a lot of strings in there. Maybe you're running out of SRAM.

removed all strings and still issues

Well, without all the code and some observations of what the "issues" might be, we may as well break out the ouija board.

heres part 2

/*********************************
 *             Loop              *
 *********************************/

void loop()
{  

  
  if(second()%10==0)
  {
     digitalClockDisplay(); 
    // Display message over Serial
  Serial.println("Taking Sensor Readings");
  
  // Read values from the sensor
  VegHumidVal  = dht1.readHumidity();
  VegTempVal   = dht1.readTemperature();
  FlwrHumidVal = dht2.readHumidity();
  FlwrTempVal  = dht2.readTemperature();


  if (isnan(VegTempVal) || isnan(VegHumidVal)) {
    Serial.println("Failed to read from DHT");
  } else {
  // Print the temperature and humidity readings over the serial port
  Serial.print("Veg Temperature: ");
  Serial.print(VegTempVal, DEC);
  Serial.print("C. Veg Humidity: ");
  Serial.print(VegHumidVal);
  Serial.println("%");
  

  Serial.print("Flower Temperature: ");
  Serial.print(FlwrTempVal, DEC);
  Serial.print("C. Flower Humidity: ");
  Serial.print(FlwrHumidVal);
  Serial.println("%");
  
  // Check whether the temperature or humidity have passed
  // their turn point. If so turn on the required appliance.
  
  CheckController(VegTempVal, VegFans);
   //////////////////////////////////////////////////////////////
  CheckController(FlwrTempVal, FlwrFans);
  CheckController(FlwrTempVal, AirCon);
  CheckController(FlwrTempVal, Heater);
  CheckController(FlwrHumidVal, Humidifier);
  CheckController(FlwrHumidVal, Dehumidifier);
  ////////////////////////////////////////////////////////////////
  PumpTimer(onTime,offTime,previousMillis); 
  
  // Write Data Entry to SD Card
  LogData();
  
  }
  
  Alarm.delay(1000); // wait one second between clock display
  }
 }
  

/*************************************
 *        Light Control Alarms       *
 *************************************/
void PumpTimer(unsigned long onTime, unsigned long offTime,  unsigned long previousMilis){
  currentMillis = millis();

  if (currentMillis - previousMillis> offTime){
  previousMillis=currentMillis;

  while(millis()-previousMillis<=onTime){
    digitalWrite(FLWRPUMPS_PIN,LOW);
    digitalWrite(VEGPUMPS_PIN,LOW);
  }
    digitalWrite(FLWRPUMPS_PIN,HIGH);
    digitalWrite(VEGPUMPS_PIN,HIGH);
  }
}


void VegLightOffAlarm()
{
  // Turn off the light, update lightStatus, report the change
  // over Serial, in the current eventLog and on the LCD screen
  char msg[24];
  strncpy(msg, powerOffMsg, 24);
  strcat(msg, VeglightStr);
  
  digitalWrite(VEGLIGHT_PIN, HIGH);
  veglightState = false;
  
  lcd.clear();
  lcd.print(powerOffMsg);
  lcd.print(VeglightStr);
  Serial.println(msg);
  
  LogEvent(msg);
    
  Alarm.delay(lcdDelay);
  LCDrefresh();
}

void VegLightOnAlarm()
{
  // Turn on the light, update lightStatus, report the change
  // over Serial, in the current eventLog and on the LCD screen
  char msg[24];
  strncpy(msg, powerOnMsg, 24);
  strcat(msg, VeglightStr);
  
  digitalWrite(VEGLIGHT_PIN,LOW);
  veglightState = true;
  
  lcd.clear();
  lcd.print(powerOnMsg);
  lcd.print(VeglightStr);
  Serial.println(msg);  
  
  LogEvent(msg);
  
  Alarm.delay(lcdDelay);  
  LCDrefresh();
}

/*************************************
 *        Light Control Alarms       *
 *************************************/
 
void FlwrLightOffAlarm()
{
  // Turn off the light, update lightStatus, report the change
  // over Serial, in the current eventLog and on the LCD screen
  char msg[24];
  strncpy(msg, powerOffMsg, 24);
  strcat(msg, FlwrlightStr);
  
  digitalWrite(FLWRLIGHT_PIN, HIGH);
  flwrlightState = false;
  
  lcd.clear();
  lcd.print(powerOffMsg);
  lcd.print(FlwrlightStr);
  Serial.println(msg);
  
  LogEvent(msg);
    
  Alarm.delay(lcdDelay);
  LCDrefresh();
}

void FlwrLightOnAlarm()
{
  // Turn on the light, update lightStatus, report the change
  // over Serial, in the current eventLog and on the LCD screen
  char msg[24];
  strncpy(msg, powerOnMsg, 24);
  strcat(msg, FlwrlightStr);
  
  digitalWrite(FLWRLIGHT_PIN,LOW);
  flwrlightState = true;
  
  lcd.clear();
  lcd.print(powerOnMsg);
  lcd.print(FlwrlightStr);
  
  Serial.println(msg);  
  
  LogEvent(msg);
  
  Alarm.delay(lcdDelay);  
  LCDrefresh();
}

heres part 3

void CheckController(int sensorReading, struct Controller &c)
{
  
  // If inverted, check if sensorReading is below the turn point
  if(c.invert)
  {
    if(sensorReading<=c.turnPoint)
    {
      // Report that sensorReading is below the turnpoint
      Serial.print(c.controlLabel);
      Serial.println(" is BELOW nominal range");
      
      // If the appliance is powered off turn it on, update 
      // the controller status and report it over serial
      if(c.status==0)
      {
        // Display "Powering ON: 'LABEL'" on LCD screen
        
        
        lcd.print(powerOnMsg);
        lcd.print(c.label);
        
        // Set appliance control pin to HIGH
        digitalWrite(c.pin, LOW);
        c.status=1;
        
        // Log event on SD card
        char event[eventMsgLen];
        strncpy(event, powerOnMsg, eventMsgLen);
        strcat(event, c.label);
        LogEvent(event);
        
        // Display "Powering ON: 'LABEL'" over Serial
        Serial.print(powerOnMsg);
        Serial.println(c.label);
        Alarm.delay(lcdDelay);
        LCDrefresh();
      }
      // Else, report that it is already powered on
      else
      {
        Serial.print(c.label);
        Serial.println(" is ON");
      }
    }
    else
    {
      // If the sensorReading is not below the turn point power
      // the appliance off if needed, update the controller status
      // and report it over serial
      if(c.status==1 && sensorReading >= (c.turnPoint))
      {
        // Display "Powering OFF: 'LABEL'" on LCD screen
       
        
        lcd.print(powerOffMsg);
        lcd.print(c.label);
        
        // Set appliance control pin to LOW
        digitalWrite(c.pin, HIGH);
        c.status=0;
        
        // Log event on SD card
        char event[eventMsgLen];
        strncpy(event, powerOffMsg, eventMsgLen);
        strcat(event, c.label);
        LogEvent(event);
        
        // Display "Powering OFF: 'LABEL'" over Serial
        Serial.print(powerOffMsg);
        Serial.println(c.label);
        Alarm.delay(lcdDelay);
        LCDrefresh();
      }
      else
      {
      // Else, report that it is already powered off 
        Serial.print(c.label);
        Serial.println(" is OFF");
      }
    }
  }
  
  //if not inverted...
  else
  {
  // If inverted, check if sensorReading is above the turn point
    if(sensorReading>=c.turnPoint)
    {
      // Report that sensorReading is above the turnpoint
      Serial.print(c.controlLabel);
      Serial.println(" is ABOVE nominal range");
      
      // If the appliance is powered off turn it on, update 
      // the controller status and report it over serial
      if(c.status==0)
      {
        // Display "Powering ON: 'LABEL'" on LCD screen
       
        lcd.print(powerOnMsg);
       
        lcd.print(c.label);
        
        // Set appliance control pin to HIGH
        digitalWrite(c.pin, LOW);
        c.status=1;
        
        // Log event on SD card
        char event[eventMsgLen];
        strncpy(event, powerOnMsg, eventMsgLen);
        strcat(event, c.label);
        LogEvent(event);
        
        // Display "Powering ON: 'LABEL'" over Serial
        Serial.print(powerOnMsg);
        Serial.println(c.label);
        Alarm.delay(lcdDelay);
        LCDrefresh();
      }
      // Else, report that it is already powered on
      else
      {
        Serial.print(c.label);
        Serial.println(" is ON");
      }
    }
    // If the sensorReading is not below the turn point power
    // the appliance off if needed, update the controller status
    // and report it over serial
    else
    {
      if(c.status==1 && sensorReading <= (c.turnPoint))
      {
        // Display "Powering OFF: 'LABEL'" on LCD screen
       
        lcd.print(powerOffMsg);
       
        lcd.print(c.label);
        
        // Set appliance control pin to LOW
        digitalWrite(c.pin, HIGH);
        c.status=0;
        
        // Log event on SD card
        char event[eventMsgLen];
        strncpy(event, powerOffMsg, eventMsgLen);
        strcat(event, c.label);
        LogEvent(event);
        
        // Display "Powering OFF: 'LABEL'" over Serial
        Serial.print(powerOffMsg);
        Serial.println(c.label);
        Alarm.delay(lcdDelay);
        LCDrefresh();
      }
      
      // Else, report that it is already powered off
      else
      {
        Serial.print(c.label);
        Serial.println(" is OFF");
      }
    }
  }
}

void digitalClockDisplay()
{
  // digital clock display of the time
  Serial.print(hour());
  printDigits(minute());
  printDigits(second());
  Serial.print(" ");
  Serial.print(month());
  printDigitsDate(day());
  printDigitsDate(year());
  Serial.println(); 
}

void printDigits(int digits)
{
  // utility function for digital clock display: prints preceding colon and leading 0
  Serial.print(":");
  if(digits < 10)
   Serial.print('0');
   Serial.print(digits);
}

 void printDigitsDate(int digits)
{
  // utility function for digital clock display: prints preceding ":" and leading 0
  Serial.print("/");
  if(digits < 10)
   Serial.print('0');
   Serial.print(digits);
}



void LCDsensorRefresh()
{
  // Create a small buffer for itoa fuction
  char buf[3];
  // Clear the bottom line of the LCD screen
  lcd.print("                ");
  
  // If temperature reading is more or equal to 100,
  // display the characters one space to the right to
  // fit the reading, should look like this:
  // T:1XXF RH:XX% X
  if(VegTempVal>=100||FlwrTempVal>=100)
  {
    lcd.setCursor(0,0);
    lcd.print("T:1");
    lcd.print(VegTempVal);
    lcd.print("C H:");
    lcd.print(VegHumidVal);
    lcd.print("%");
    
    lcd.setCursor(0,1);
    lcd.print("T:1");
    lcd.print(FlwrTempVal);
    lcd.print("C H:");
    lcd.print(FlwrHumidVal);
    lcd.print("%");
    Alarm.delay(lcdDelay);
  }
  
  // If temperature reading is not more or equal to 100,
  // display the characters to fit the reading
  // it should look like this:
  // T:XXF RH:XX% X
  else
  {
    lcd.setCursor(0,0);
    lcd.print("T:");
    lcd.print(VegTempVal);
    lcd.print("C H:");
    lcd.print(VegHumidVal);
    lcd.print("%");
    lcd.setCursor(0,1);
    lcd.print("T:");
    lcd.print(FlwrTempVal);
    lcd.print("C H:");
    lcd.print(FlwrHumidVal);
    lcd.print("%");
    Alarm.delay(lcdDelay);
  }
}
void LCDtimeRefresh() {
  // Get the current hour and minute
  int displayHour = hour();
  int displayMinute = minute();
  // PM indicator, 0-AM ; 1-PM
  int PM = 0;
  // Create a small buffer for itoa function
  char buf[3];
 
  // If it is past noon, it is PM and subtract 12 from the display hour
  if(displayHour>12)
  {
    PM = 1; 
    displayHour = displayHour-12;
  }
  
  // if it is midnight display 12 as the display hour and it is AM
  if(displayHour==0)
  {
    displayHour=12;
    PM = 0;
  }
  
  // If it is noon it is PM
  if(hour()==12) PM=1;
  
  // Clear the section of the LCD that displays the time
 
 
  
  // If displayHour is more or equal to 10, format the time on
  // the screen to fit the extra integer, Exaple: "HH:MMXM" where XM= AM/PM
  if(displayHour >=10)
  {
    lcd.setCursor(5,0);
    lcd.print(itoa(displayHour,buf,10));

    lcd.print(":");
    lcd.print(displayMinute);
    LcdPrintAMPM(PM);
    
  }
  
  // If displayHour is not more or equal to 10, display the time
  // accordingly, Example: "H:MMXM" where XM = AM/PM
  else
  {
    lcd.setCursor(5,0);
    lcd.print(displayHour);
  
    lcd.print(":");
    lcd.print(displayMinute);
    LcdPrintAMPM(PM);
   
  }
}

void LcdPrintAMPM(boolean PM)
{
  // If PM is true, display "P" else display "A"
  if(PM==1)
  {
    lcd.print("P");
  }
  
  else
  {
    lcd.print("A");
  }
    
  lcd.print("M");
}

void LCDrefresh()
{
  // Clear the LCD and refresh all indicators
  lcd.clear();
  LCDtimeRefresh();
  Alarm.delay(lcdDelay);
  LCDsensorRefresh();
  Alarm.delay(lcdDelay);
  
}

heres the last part

/***********************************
 *      Data Logging Fuctions      *
 ***********************************/
 
String CurrentDirectory()
{
  // This function returns the current date's direcory
  char dirString[12];
  char buf[6];
  const char devider[2] = "/";
  
  // Assemble the directory string
  strncpy(dirString, itoa(year(),buf,10), 12);
  strcat(dirString, devider);
  strcat(dirString, itoa(month(),buf,10));
  strcat(dirString, devider);
  strcat(dirString, itoa(day(),buf,10));
  strcat(dirString, devider);
  Serial.print("Current Logging Directory: ");
  Serial.println(dirString);
  
  return dirString;
}
 
File OpenCurrentLog()
{
  // If the SD card is not present report it over serial and do nothing
  if (!SDavailable) {
    Serial.println("SD card failed to initialize");
  }
  else {
  // Create String and buffer for the file string
  String dirStr = CurrentDirectory();
  char dirString[32];
  dirStr.toCharArray(dirString,32);
  char fileString[32];
  char header[32] = "Time, Temperature(F), Humidity";
  
  //If any branch off the directory don't exist create it or them
  if(!SD.exists(dirString))
  {
    Serial.print(dirString);
    Serial.println(" does not exist");
    Serial.print("Creating: ");
    Serial.println(dirString);
    SD.mkdir(dirString);
  }
  else
  {
    // If it already exist report so over the Serial port
    Serial.print(dirString);
    Serial.println(" exists");
  }
  
  // Assemble the file string
  strncpy(fileString, dirString, 32);
  strcat(fileString, "datalog.csv");
  Serial.print("Current Logging File: ");
  Serial.println(fileString);
  
  //Open or Create the log file
  File logFile = SD.open(fileString, FILE_WRITE);
  
  //Check if header is already present, if not write it
  CheckFileHeader(logFile, header, fileString);
  
  // Return the logFile object
  return logFile;
  }
}

void LogData()
{
  // If the SD card is not present report it over serial and do nothing
  if (!SDavailable) {
    Serial.println("SD card failed to initialize");
  }
  else
  {
    // If the day has changed report so over Serial, close the old file
    // and open a new DataLog the current dates directory
    if(prevDate != day())
    {
      Serial.println("The Date has Changed");
      Serial.println("Opening New Log File");
      dataFile.close();
      dataFile = OpenCurrentLog();
      prevDate = day();
    }
  
    Serial.println("Preparing Data Entry...");
  
    // Get current temperature and humidity
    int vtemp = int(VegTempVal);
    int vhumid = int(VegHumidVal);
    int ftemp = int(FlwrTempVal);
    int fhumid = int(FlwrHumidVal);
    
    // Log Date Entry Ex: "HH:MM:SS, TT, RH"
    PrintTimeSD(dataFile);
    dataFile.print(VegTempVal);
    dataFile.print(boxSeperator);
    dataFile.println(VegHumidVal);
    dataFile.print(boxSeperator);
    dataFile.print(FlwrTempVal);
    dataFile.print(boxSeperator);
    dataFile.print(FlwrHumidVal);
    
    //Display the data entry over serial
    Serial.print("Data Entry: ");
    Serial.print(hour());
    printDigits(minute());
    printDigits(second());
    Serial.print(boxSeperator);
    Serial.print(VegTempVal);
    Serial.print(boxSeperator);
    Serial.println(VegHumidVal);
    Serial.print(boxSeperator);
    Serial.print(FlwrTempVal);
    Serial.print(boxSeperator);
    Serial.print(FlwrHumidVal);
  
  }
}

void LogEvent(char *msg)
{
  char fileString[32];
  String fileStr = CurrentDirectory();
  fileStr.toCharArray(fileString,32);
  char header[12] = "Time,Event"; //header for the file
  strcat(fileString, "eventlog.csv"); // assemble the file string
  
  // Close the dataLog and open the eventLog file
  dataFile.close();
  File eventFile = SD.open(fileString, FILE_WRITE);
  
  // If the header has not been placed yet write it to the file
  CheckFileHeader(eventFile, header, fileString);
  
  // Print the message as follows: "HH:MM:SS, 'MESSAGE'"
  PrintTimeSD(eventFile);
  eventFile.println(msg);
  
  //close the eventLog
  eventFile.close();
  
  // Reopen the dataLog
  dataFile = OpenCurrentLog();
}

void CheckFileHeader(File &logFile, char header[], char fileString[])
{
  // If this is a new file write the header at the top
  if(logFile) {
    if(logFile.size() == 0)
    {
      logFile.println(header);
      Serial.println("New File Detected, Writing Header");
    }
    // If log file already exists display the size and
    // begin writing to the end of the file
    else
    {
      char fileSize[32];
      itoa(logFile.size(), fileSize, 10);
      
      logFile.seek(logFile.size());
      Serial.print(fileString);
      Serial.print(" size: ");
      Serial.println(fileSize);
      Serial.println("Writing to end of the file");
    }
  }
    
  // If the file is unavailable report it over serial
  else {
    Serial.print("Error opening: ");
    Serial.println(fileString);
  }
}

void PrintTimeSD(File &file)
{
    // Print the current time of the day as follows to the current File:
    // "HH:MM:SS, "
    file.print(hour());
    printDigitsSD(minute(), file);
    printDigitsSD(second(), file);
    file.print(boxSeperator);
}
void printDigitsSD(int digits, File &file)
{
  // function for digital clock display: prints preceding colon and leading 0
  file.print(":");
  if(digits < 10)
    file.print('0');
  file.print(digits);
}

removed all strings and still issues

Not by a long shot. There are still loads of strings, and way too many Strings.

What board do you have?

#include <SD.h>

If you have a 328-based board, there’s more than 1/4 of your SRAM gone, right there,