Grow Light Timer w/8 Channel Relay

This is my first time ever posting anything and I'm new to Arduino so please go easy. I've been trying to get my Arduino Nano to turn and off 6 relays on an 8 channel relay. I can only get 3 relays to work at a time. So basically the first one will close then 2 and 3 but never 4,5, and 6. When it's time for them to cycle off, 3 then 2 and 1 will turn off at their designated times. I can delete the lines that include 1 and 2 for example and 4,5, and 6 will work properly. It's as if the board can only go up to any 3 relays at a time. The code is below. Thanks in advance for the help.

#include <Wire.h>
#include <RTClib.h>
#include <Time.h>
#include <TimeAlarms.h>

RTC_DS1307 RTC;

// Start Time Light 1
int sHour = 06;
int sMinute = 40;
int sSecond = 0;

// Start Time Light 2
int s2Hour = 07;
int s2Minute = 00;
int s2Second = 00;

// Start Time Light 3
int s3Hour = 07;
int s3Minute = 20;
int s3Second = 00;

// Start Time Light 4
int s4Hour = 07;
int s4Minute = 40;
int s4Second = 00;

// Start Time Light 5
int s5Hour = 07;
int s5Minute = 00;
int s5Second = 00;

// Start Time Light 6
int s6Hour = 07;
int s6Minute = 20;
int s6Second = 24;

// End Time Light 1
int eHour = 17;
int eMinute = 40;
int eSecond = 00;

// End Time Light 2
int e2Hour = 18;
int e2Minute = 00;
int e2Second = 00;

// End Time Light 3
int e3Hour = 18;
int e3Minute = 20;
int e3Second = 00;

// End Time Light 4
int e4Hour = 18;
int e4Minute = 40;
int e4Second = 00;

// End Time Light 5
int e5Hour = 19;
int e5Minute = 00;
int e5Second = 00;

// End Time Light 6
int e6Hour = 19;
int e6Minute = 20;
int e6Second = 00;

int lightRelay1 = 9;
int lightRelay2 = 2;
int lightRelay3 = 3;
int lightRelay4 = 4;
int lightRelay5 = 5;
int lightRelay6 = 6;

void setup() {
// Set the relay to off immediately
digitalWrite(lightRelay1, HIGH);
digitalWrite(lightRelay2, HIGH);
digitalWrite(lightRelay3, HIGH);
digitalWrite(lightRelay4, HIGH);
digitalWrite(lightRelay5, HIGH);
digitalWrite(lightRelay6, HIGH);
Serial.begin(9600);
Wire.begin();
RTC.begin();

// Set the pinmode
pinMode(lightRelay1, OUTPUT);
pinMode(lightRelay2, OUTPUT);
pinMode(lightRelay3, OUTPUT);
pinMode(lightRelay4, OUTPUT);
pinMode(lightRelay5, OUTPUT);
pinMode(lightRelay6, OUTPUT);

// Notify if the RTC isn't running
if (! RTC.isrunning()) {
Serial.println("RTC is NOT running");
}

// Get time from RTC
DateTime current = RTC.now();
DateTime compiled = DateTime(DATE, TIME);
if (current.unixtime() < compiled.unixtime()) {
Serial.println("RTC is older than compile time! Updating");
RTC.adjust(DateTime(DATE, TIME));
}

// Use RTC time to set the start time1
setTime(sHour, sMinute, sSecond, current.day(), current.month(), current.year());
time_t s = now();

// Use RTC time to set the start time2
setTime(s2Hour, s2Minute, s2Second, current.day(), current.month(), current.year());
time_t s2 = now();

// Use RTC time to set the start time3
setTime(s3Hour, s3Minute, s3Second, current.day(), current.month(), current.year());
time_t s3 = now();

// Use RTC time to set the start time4
setTime(s4Hour, s4Minute, s4Second, current.day(), current.month(), current.year());
time_t s4 = now();

// Use RTC time to set the start time5
setTime(s5Hour, s5Minute, s5Second, current.day(), current.month(), current.year());
time_t s5 = now();

// Use RTC time to set the start time6
setTime(s6Hour, s6Minute, s6Second, current.day(), current.month(), current.year());
time_t s6 = now();

// Use RTC time to set the end time1
setTime(eHour, eMinute, eSecond, current.day(), current.month(), current.year());
time_t e = now();

// Use RTC time to set the end time2
setTime(e2Hour, e2Minute, e2Second, current.day(), current.month(), current.year());
time_t e2 = now();

// Use RTC time to set the end time3
setTime(e3Hour, e3Minute, e3Second, current.day(), current.month(), current.year());
time_t e3 = now();

// Use RTC time to set the end time4
setTime(e4Hour, e4Minute, e4Second, current.day(), current.month(), current.year());
time_t e4 = now();

// Use RTC time to set the end time5
setTime(e5Hour, e5Minute, e5Second, current.day(), current.month(), current.year());
time_t e5 = now();

// Use RTC time to set the end time6
setTime(e6Hour, e6Minute, e6Second, current.day(), current.month(), current.year());
time_t e6 = now();

// Use RTC time to set the current time
setTime(current.hour(), current.minute(), current.second(), current.day(), current.month(), current.year());
time_t n = now();

// Test if grow light should be on
if (s <= n && n <= e) {
digitalWrite(lightRelay1, LOW); // Sets the grow light "on"
}
if (s2 <= n && n <= e2) {
digitalWrite(lightRelay2, LOW); // Sets the grow light "on"
}
if (s3 <= n && n <= e3) {
digitalWrite(lightRelay3, LOW); // Sets the grow light "on"
}
if (s4 <= n && n <= e4) {
digitalWrite(lightRelay4, LOW); // Sets the grow light "on"
}
if (s5 <= n && n <= e5) {
digitalWrite(lightRelay5, LOW); // Sets the grow light "on"
}
if (s6 <= n && n <= e6) {
digitalWrite(lightRelay6, LOW); // Sets the grow light "on"
}
Alarm.alarmRepeat(sHour, sMinute, sSecond, Light1On);
Alarm.alarmRepeat(eHour, eMinute, eSecond, Light1Off);
Alarm.alarmRepeat(s2Hour, s2Minute, s2Second, Light2On);
Alarm.alarmRepeat(e2Hour, e2Minute, e2Second, Light2Off);
Alarm.alarmRepeat(s3Hour, s3Minute, s3Second, Light3On);
Alarm.alarmRepeat(e3Hour, e3Minute, e3Second, Light3Off);
Alarm.alarmRepeat(s4Hour, s4Minute, s4Second, Light4On);
Alarm.alarmRepeat(e4Hour, e4Minute, e4Second, Light4Off);
Alarm.alarmRepeat(s5Hour, s5Minute, s5Second, Light5On);
Alarm.alarmRepeat(e5Hour, e5Minute, e5Second, Light5Off);
Alarm.alarmRepeat(s6Hour, s6Minute, s6Second, Light6On);
Alarm.alarmRepeat(e6Hour, e6Minute, e6Second, Light6Off);
}

void loop() {
DateTime now = RTC.now();
setTime(now.hour(), now.minute(), now.second(), now.day(), now.month(), now.year());

Serial.print("Current time: ");
Serial.print(now.year(), DEC);
Serial.print('/');
Serial.print(now.month(), DEC);
Serial.print('/');
Serial.print(now.day(), 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(600000);
}
void Light1On() {
Serial.println("Turning Light 1 On");
digitalWrite(lightRelay1, LOW);
}
void Light1Off() {
Serial.println("Turning Light 1 Off");
digitalWrite(lightRelay1, HIGH);
}
void Light2On() {
Serial.println("Turning Light 2 On");
digitalWrite(lightRelay2, LOW);
}
void Light2Off() {
Serial.println("Turning Light 2 Off");
digitalWrite(lightRelay2, HIGH);
}
void Light3On() {
Serial.println("Turning Light 3 On");
digitalWrite(lightRelay3, LOW);
}
void Light3Off() {
Serial.println("Turning Light 3 Off");
digitalWrite(lightRelay3, HIGH);
}
void Light4On() {
Serial.println("Turning Light 4 On");
digitalWrite(lightRelay4, LOW);
}
void Light4Off() {
Serial.println("Turning Light 4 Off");
digitalWrite(lightRelay4, HIGH);
}
void Light5On() {
Serial.println("Turning Light 5 On");
digitalWrite(lightRelay5, LOW);
}
void Light5Off() {
Serial.println("Turning Light 5 Off");
digitalWrite(lightRelay5, HIGH);
}
void Light6On() {
Serial.println("Turning Light 6 On");
digitalWrite(lightRelay6, LOW);
}
void Light6Off() {
Serial.println("Turning Light 6 Off");
digitalWrite(lightRelay6, HIGH);
}

Alarm.alarmRepeat(sHour, sMinute, sSecond, Light1On);
  Alarm.alarmRepeat(eHour, eMinute, eSecond, Light1Off);
  Alarm.alarmRepeat(s2Hour, s2Minute, s2Second, Light2On);
  Alarm.alarmRepeat(e2Hour, e2Minute, e2Second, Light2Off);
  Alarm.alarmRepeat(s3Hour, s3Minute, s3Second, Light3On);
  Alarm.alarmRepeat(e3Hour, e3Minute, e3Second, Light3Off);
  Alarm.alarmRepeat(s4Hour, s4Minute, s4Second, Light4On);
  Alarm.alarmRepeat(e4Hour, e4Minute, e4Second, Light4Off);
  Alarm.alarmRepeat(s5Hour, s5Minute, s5Second, Light5On);
  Alarm.alarmRepeat(e5Hour, e5Minute, e5Second, Light5Off);
  Alarm.alarmRepeat(s6Hour, s6Minute, s6Second, Light6On);
  Alarm.alarmRepeat(e6Hour, e6Minute, e6Second, Light6Off);
}

Have you looked at the documentation for the Alarm class? There is a limit, unless you modify the library, of 6 alarms.

Your method of f**king with the clock time, so you can set the alarm time to now is fundamentally flawed.

With an RTC, you REALLY don't need the Alarm class.

I would drop alot of your stuff into arrays, so that you can decrease your code by at least 6.

also put your start and stop times in an array.

int lightrelay[] = {41,42,43,44,45,46,47};
int lightstatus[] = {0,0,0,0,0,0};
float starttime[] = {7,7,7,7,7,6.30};
float endtime[] = {16.30,17.00,17.30,18.00,19.30,18.00};
int relaycount = 6;

i used floats because you can see the hours and minutes as time versus doing a string.

then you can do a couple loops

do a loop in setup to check the time and if it's between startime and endtime turn on the relay

in the main loop
do a loop for starttime to turn on the relays
do a loop for endtime turn off the relays.

int thisPin;
for (int thisPin = 0; thisPin < relaycount; thisPin++) {

}

Thanks for the info. This really helps. Like I said I'm new to this so I don't know how to make some of the changes but the change to the library sounds like easy. Thanks again.

Keep us posted in this thread as you go along

With 8 relays the arduino may not have enough power to activate them all simultaneously. You will need to add power source for relay board separate from the arduino. From what I gather, the arduino maxes out around 4 or five, sometimes can do 6, but lacks enough voltage to activate 8 at one time. That is if you are powering the arduino via USB. You may not need additional power source if you use a higher (9-12 V maybe) wall adapter to run the arduino. Good luck.

Opto Isolation connections to Arduino from 8-relay module:

Setting the time every time you compile is lame. Use an example time setting sketch from the RTC library to do it once, accurately, and forget about it. It is battery backed up.