Got it thank you everyone for your input
![]()
#include <RTClib.h>Â Â Â Â Â Â Â // Real time clock
#include <DHT.h>Â Â Â Â Â Â Â Â Â // Air Temp Humid Sensor
#include <OneWire.h>Â Â Â Â Â Â Â // Sensors (water temp) connected to one wire
#include <DallasTemperature.h>Â Â // Water Temp Sensor
#include <LiquidCrystal_I2C.h>Â Â // Lcd display
const int lightingPin = 4;
const int bulblightingPin = 9;
const int pumpPin = 6;
RTC_DS3231 rtc;Â Â Â Â Â Â Â Â Â Â // Init the DS3231 using the hardware interface (Nano A4=SDA A5=SCL)
unsigned long currentTime;
unsigned long previousTime = 0;
int marker = 0;
int lampState =0;
unsigned long pumpState =0;
unsigned long pumpHour = 0;
char dateBuffer [12];
           Â
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Lcd Display ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);Â // Set the LCD I2C address
                                // set the LCD address to 0x3F or 0x27 depending what display using for a 16 chars 2 line display
                                // Set the pins on the I2C chip used for LCD connections:
                                // addr, en,rw,rs,d4,d5,d6,d7,bl,blpol    Â
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Air Temperature & Humidity sensor ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#define DHTPIN 2Â Â Â Â Â Â // what pin we're connected to
#define DHTTYPE DHT22Â Â Â Â // DHT 22Â (AM2302)
DHT dht(DHTPIN, DHTTYPE);Â Â // Initialize DHT sensor
int chk;
float hum;Â Â Â Â Â Â Â Â Â //Stores humidity value
float temp;Â Â Â Â Â Â Â Â Â //Stores temperature value
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Water Temperature sensor ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#define ONE_WIRE_BUS 7
OneWire oneWire(ONE_WIRE_BUS);Â Â Â Â Â // Setup a oneWire instance to communicate with any OneWire devices (not just Maxim/Dallas temperature ICs)
DallasTemperature sensors(&oneWire);Â Â // Pass our oneWire reference to Dallas Temperature.
//########################################################################## SETUP ###################################################################################################
void setup()
{
 Serial.begin(9600);
 rtc.begin();      // Initialize the rtc object
 lcd.begin(16,2);    // initialize the lcd for 16 chars 2 lines
 lcd.backlight();    // Turns backlight LCD on
 sensors.begin();    // water temp sensor
 dht.begin();      // temp humid sensor
Â
 pinMode (lightingPin, OUTPUT);
 digitalWrite (lightingPin, HIGH);
 pinMode (bulblightingPin, OUTPUT);
 digitalWrite (bulblightingPin, HIGH);
 pinMode (pumpPin, OUTPUT);
 digitalWrite (pumpPin, HIGH);
Â
Â
 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Uncomment to set the date and time ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Â
 // rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));   // Automatic RTC DS3231 time update from computer clock while compiling
 // rtc.adjust(DateTime(2014, 1, 21, 3, 0, 0));   // This line sets the RTC with an explicit date & time for example to set January 21, 2014 at 3am
 Â
 Â
}
//########################################################################## LOOP ###################################################################################################
void loop()
{
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ OUTPUT REAL TIME CLOCK ON SERIAL ~~~~~~~~~~~~~~~~~~~~~~~~~~
 DateTime now = rtc.now();
 sprintf(dateBuffer,"%02u-%02u-%04u ",now.day(),now.month(),now.year());
 Serial.print(dateBuffer);
 sprintf(dateBuffer,"%02u:%02u:%02u ",now.hour(),now.minute(),now.second());
 Serial.println(dateBuffer);
Â
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ lighting RELAY ACTION ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 lampState = (now.hour()*60) + now.minute();    // Hour times it by 60 add the minutes, 18 hour cycle 5am = 300 11pm = 1380
                           // 12 hour cycle 6am = 360 12am = 00
                           // 14 hour cycle 6am = 360 2am = 1200
                         Â
if (lampState >= 360 && lampState < 1200){
  digitalWrite (lightingPin, HIGH);
  digitalWrite (bulblightingPin, LOW);
  Serial.println("Lights ON");
}
 else {
  digitalWrite (lightingPin, LOW);
  digitalWrite (bulblightingPin, HIGH);
  Serial.println("Lights OFF");
}Â
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Water Pump Relay Times ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 pumpHour = now.hour();
 pumpState = (pumpHour*3600) + (now.minute()*60) + now.second();     Â
                                   Â
 if (pumpState >= 57120 && pumpState < 57165){
   digitalWrite (pumpPin, LOW);
   Serial.println("Water Pump ON");               Â
 }
 else {
  digitalWrite (pumpPin, HIGH);
  Serial.println("Water Pump OFF");
 }