Hi Everyone,
I’ve looked through the forum for similar issues and tried their fixes to my code but unfortunately it hasn’t worked. Rather than hijacking a thread I wanted to start my own fresh one.
I have an hobby Aquaponics garden being built. I’d like to automate it with Arduino.
I’m having issues with my rtc script. Works perfectly for one go/cycle when reset but then won’t continue on the hourly loop.
Here it is below. Any help is greatly appreciated. Once other sensors are added and working well I plan to share my build with other aquaponic members, in the spirit of open source sharing.
int ch = 4;// number of relays
int relay={2,3,4,5}; // Arduino pin numbers
int distance;
#include “RTClib.h”
#include <DS1302RTC.h>
#include <Time.h>
#include <TimeLib.h>
DS1302RTC RTC( 7, 8, 9 );// CE reset - I/O Data - Clock
void setup() {
Serial.begin(9600);// Serial monitor start
// set pins as output
RTC.get();
Wire.begin();
time_t myTime;
myTime = RTC.get();
setTime(19, 29, 55, 14, 12, 2018);
RTC.set(now());
pinMode(relay[0], OUTPUT);// connected to relay1
digitalWrite(relay[0], HIGH); // Turn the relay OFF
pinMode(relay[1], OUTPUT);// connected to relay2
digitalWrite(relay[1], HIGH); // Turn the relay OFF
pinMode(relay[2], OUTPUT);// connected to relay2
digitalWrite(relay[2], HIGH); // Turn the relay OFF
pinMode(relay[3], OUTPUT);// connected to relay2
digitalWrite(relay[3], HIGH); // Turn the relay OFF
}
void loop() {
tmElements_t tm;
RTC.read™;
Serial.print(tm.Hour,DEC);
Serial.print(’:’);
Serial.print(tm.Minute,DEC);
Serial.print(’:’);
Serial.println(tm.Second,DEC);
if(tm.Minute == 30)
if(tm.Second == 00) {
digitalWrite(relay[2], LOW); Serial.println(“Tower On”);
}
if(tm.Minute == 30)
if(tm.Second == 10) {
digitalWrite(relay[2], HIGH); Serial.println(“Tower Off”);
}
if(tm.Minute == 30)
if(tm.Second == 00) {
digitalWrite(relay[3], LOW); Serial.println(“Bed On”);
}
if(tm.Minute == 35) {
digitalWrite(relay[3], HIGH); Serial.println(“Bed Off”);
}
delay(5000);
}// loop