Programming time intervals with LCD Shield

Hi Everyone!

I’m building an automated garden waterer, and I’ve come to a bit of a wall. I have it built, but I’m not sure how to program it.

I’m using an Arduino UNO with:

  • 16x2 LCD Shield,
  • a DS3231 clock module
  • two channel relay module

I’d like to be able to enter two time intervals, in 24h mode, for the arduino to turn on a relay if the current time is within the entered range. I have two relays so I’d want to do 4 time intervals total, but if I can get some help with setting up two time intervals for one relay, I’m sure I could figure out how to do it twice.

Thus far I’m displaying the current temperature and time on line 1, and would like to implement the adjustable time intervals on line 2… Any ideas? Thanks in advance :slight_smile:

#include <DS3231.h>
#include <Wire.h>
DS3231  rtc(SDA, SCL);
#include <LiquidCrystal.h>
int relaypin = 8;
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);

void setup()
{
 
  Serial.begin(9600);
  rtc.begin();
  pinMode(relaypin, OUTPUT);
  digitalWrite(relaypin,LOW);
  lcd.begin(16, 2);
}

void loop()
{

  String curTime = rtc.getTimeStr();
  int curTemp = rtc.getTemp();
  int curHour = curTime.substring(0,2).toInt();
  int curMin = curTime.substring(3,5).toInt();
  //int shutoffB = onHour+Bon;

  updateDisplay(curTemp, curTime);
  Serial.println("---------------------");
  serialPrint(curTime, curHour, curMin,  curTemp);
  digitalWrite(relaypin,LOW);
       

  delay (1000);
}

void updateDisplay(int temperature, String curTime){
  lcd.setCursor(0, 0); // Positions the cursor in the first column (0) and the firt row (1) at LCD
  lcd.print("T:   C "); 
  lcd.setCursor(2,0);
  lcd.print(temperature);
  lcd.print(" C  ");
  lcd.print(curTime);

}

void serialPrint(String curTime, int curHour, int curMin, int curTemp){
Serial.println(curTime);
Serial.print("Current Temperature: ");
Serial.println(curTemp);
}

I'd like to be able to enter two time intervals

How? By wishful thinking?