Help with automated watering

I need help changing my current watering setup to water based on RTC. I am using a DS3231

Ideally I would like to use the RTC to set intervals to check current moisture levels and water as needed.
I would also like to put in a fail safe to water at a set time everyday regardless of moisture levels.

I have been working on what turned out to be a much more complex project than I should have ever attempted, but I have made progress. I am trying to work on an automated watering system. The sketch I have put together (mostly from copying other projects) currently displays the current time, temp, humidity, ph level. I have also had success in automating filling a reservoir (checks float switches and activates the solenoid) and have been playing with automating nutrient filling (that will require hours of fine tuning I imagine) It does currently work to read the moisture levels and to activate the watering pumps based on the hard coded moisture value, but in it’s current form basically keeps the plants watered at the same rate and does not allow for any dry time.

I have tried to use

if ((rtc.getTimeStr() >= “21:59:00”) && (rtc.getTimeStr() <= “21:59:59”))
{
Serial.println(“Woooopp”);
}

but it does not work. any help would be greatly appreciated. I will attach my crazy long and probably terribly coded sketch now for all to criticize. And please do, it will help me learn faster!

sketch49.ino (42 KB)

You cannot compare strings using >,<,=, etc. If you want to compare a string, use strcmp() and remember that the string comparison is based on the ascii value of the individual characters, not any notion of time. If you really want to compare time, you should get the unixtime() from the RTC (which is seconds since jan 1, 1970) and compare that - it is a number.

Another option might be to break the comparison down into smaller chunks. I don't know what RTC library your using but I expect it has functions to return all date-time elements individually.

if(rtc.getHour() == 21)
{
  if(rtc.getMinute() == 59)
  {
    Serial.println("Woooopp");
  }
}