/* * GreenRoomController.pde * * This program keeps track of the current time, date, * temperature and humidity. It controls the enviroment * using a light, a heater and an exhast fan. The light is * turned on and off using the TimeAlarms library along with * a DS1307 RTC. Temperature is controlled using maxmimum * and minimum thesholds that turn on the designated banned. * The user is given a warning message when the current * humidity is outside the nominal range. A LCD display is used * to show the current time, sensor readings and appliance power * states. Update messages are sent over the serial port when the * a terminal if available. When a SD card is attached * data and events are logged onto CSV files that are * organized like so:'Year/Month/Date/file.csv' * * 2011 Nickolas K. Grillone * Email: Nikg92@gmail.com

// Create Controller Structure, one of these is needed for each appliancestruct Controller{ int 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 String label; // The name of the appliance (ex: Heater) String controlLabel; // The reading that is being controlled (ex: Temperature)};

// Create controller for both heater and FanController Heater;Controller Fan;

// String to pass on to controlLabel for Fan and HeaterString tempString = "Temperature";

pinMode(LIGHT_PIN, OUTPUT); // set pin as an output for light control pinMode(FAN_PIN, OUTPUT); // set pin as an output for fan control pinMode(HEATER_PIN, OUTPUT); // set pin as an output for heater control pinMode(SD_PIN, OUTPUT); // set chip seldect pin as an output digitalWrite(SD_PIN, HIGH);

// If the light is supposed to be on turn it on if(hour()<LightOffHour || hour()>=LightOnHour) { digitalWrite(LIGHT_PIN, HIGH); lightState = true; }

// Check whether the Heater or the Fan have passed their turn point. // If so turn on the required appliance CheckController(temp_f, Heater); CheckController(temp_f, Fan);

// 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(temp_f>=100) { lcd.print("T:1",1,0); lcd.print(itoa(((temp_f-100)/10),buf,10),1,3); lcd.print(itoa(((int)temp_f%10),buf,10),1,4); lcd.print("F",1,5);

// 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.print("T:",1,0); lcd.print(itoa(((int)temp_f/10),buf,10),1,2); lcd.print(itoa(((int)temp_f%10),buf,10),1,3); lcd.print("F",1,4);

// 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 lcd.print(" ",0,0);

// 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.print(itoa(displayHour,buf,10),0,0); lcd.print(":",0,1);

// If displayHour is not more or equal to 10, display the time // accordingly, Example: "H:MMXM" where XM = AM/PM else { lcd.print(itoa((displayHour/10),buf,10),0,0); lcd.print(itoa((displayHour%10),buf,10),0,1); lcd.print(":",0,2);

//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(); }

maybe you should try run the code before answering and not just guessing

Fair enough. Maybe you should tell us exactly which versions of the TimeAlarms, DS1307RTC, SHTA1x, SLCD, and SD you have installed, where they are from, and how they're installed.Since the "modern" method of installing libraries causes them to be put in the user's sketch area, you don't get version-specific copies. Since you successfully compile with 0023, that could mean that you have some old libraries... Add to that that people seem to be publishing "replacements" for older libraries of the same name. :-(