Please help with Light Automation

Hello and a heads up Newbie Alert

I am trying to automate the grow lights on my strawberries that only get the morning to midday sun. My aim is to set a digital pin HIGH or LOW which will drive a IRFZ44N FET to turn on the 12v power at about 1 - 1:30pm and turn off at 9pm. Current draw is around 3.5 amps.

The RTC I am using requires the PCF8563 library and I know my code has some obvious flaws that you guru’s will probably identify in seconds but it has taken me all afternoon to get this far. I appreciate any help you may offer, thank you in advance.

The code I have thus far is as follows;

#include <Wire.h>
#include <Rtc_Pcf8563.h>
#define PCF8563address 0x51

int lightPin = 5;         // Set the LIGHT POWER pin
int t;
int second;
int minute;
int hour;
const int OnHour = 13;    // Set the start and end times
const int OnMinute = 30;
const int OffHour = 21;
const int OffMinute = 0;

void readPCF8563()// this gets the time and date from the PCF8563
{
  Wire.beginTransmission(PCF8563address);
  Wire.requestFrom(PCF8563address, 7);
}
void loop () {
   
  if(hour == OnHour && minute == OnMinute){
    {digitalWrite(lightPin,HIGH);}
 }
 }
 {  
  else if(hour == OffHour && minute == OffMinute)
      {digitalWrite(lightPin,LOW);} 
 }
  delay(1000);  
}

You'd be better off starting with an example which does not need such low level operations with the Wire library.
Say, this: Rtc_Pcf8563/lcd_clock.pde at master · elpaso/Rtc_Pcf8563 · GitHub if this is the library you are using.

I looked at all these examples but they all just print the time to an LCD Screen.
I am not wanting to use an LCD Screen on this project, I just want it all put into a box with the 12v cable coming in and a circuit to feed 5v to the Arduino while the 12v continues to power the lights when time is between the set times.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.