I'm trying to control three solenoids to water my plants in my house. The flow rate for the second line is below the threshold for my flow meter so I'm trying to change it to a time based interval.
The volume and time variables are being set with the Blynk app. Lines 1 & 3 that are volume based are working as intended, but I'm having a hard time getting the time based one to stop after the time interval lapses.
The section of code if the defined variables is below
long L2_wateringTime;
L2_wateringTime = t.getStartHour() * 3600 + t.getStartMinute() * 60 + t.getStartSecond();
long L2_TimeOpenDuration_Sec = 0;
//Controls the Line 2 Solenoid that is time dependent and should close after the L2_TimeOpenDuration_Sec passes
else if (L2_run) { // Solenoid 2 is supposed to be open
long currentTimeInSec = hour() * 3600 + minute() * 60 + second(); //was not declared in this scope
if (currentTimeInSec >= (L2_wateringTime + L2_TimeOpenDuration_Sec)) { //gets current time in seconds and if it is greater than or equal to the start time in seconds plus the interval time solenoid should be open, should close
AllVaulvesOff();
L2_wateringTriggered = false;
RunWateringSequence();
}
else {
Serial.print("Water L2 (mL) -> ");
Serial.println(waterDispensed * 1000);
}
}
}
Thanks