firmware wip - add lightHour and veg/bloom phase control

This commit is contained in:
Marcus 2024-04-18 15:45:17 +02:00
parent 171db2981c
commit 99ac7069fa

View file

@ -994,6 +994,7 @@ void loop() {
unsigned int secondsSunrise = (SunriseHour * 60 * 60) + (SunriseMinute * 60);
unsigned int secondsToday = (timeClient.getHours() * 60 * 60) + (timeClient.getMinutes() * 60) + timeClient.getSeconds();
unsigned long currentRuntime = millis();
byte lightHours;
// first we call webserver handle client
webserver.handleClient();
@ -1007,9 +1008,20 @@ void loop() {
Serial.println(secondsToday);
//Serial.println("yolo");
// check if secondsToday is larger then secondsSunrise time
if(secondsToday >= secondsSunrise) {
// calculate acutal DayOfGrow
DayOfGrow = int(ceil(float((timeClient.getEpochTime() - GrowStart) / 60 / 60 / 24)));
// decide if we are in Veg or Bloom phase of grow
// when DayOfGrow is larger then DaysVeg we must be in Bloom
if(DayOfGrow > DaysVeg ) {
lightHours = LighthoursBloom;
} else {
lightHours = LighthoursVeg;
}
// check if secondsToday is larger then secondsSunrise time AND if secondsToday is smaller then the sum of secondsSunrise + seconds of lightHours
if( (secondsToday >= secondsSunrise) && (secondsToday <= ( secondsSunrise + (lightHours * 60 * 60) ) )){
// turn on light
// TODO write a LED control function which takes also takes care of UseLEDrelais
analogWrite(PINled, PINled_PWM);
} else {
// turn off
@ -1287,7 +1299,7 @@ void WEBroot() {
body += returnStrDateFromEpoch(GrowStart);
body += "<br>";
body += "Day of Grow: ";
body += int(ceil(float((timeClient.getEpochTime() - GrowStart) / 60 / 60 / 24))) ;
body += DayOfGrow;
body += "<br>";
body += "Soil Moisture: ";
body += getSoilmoisture(MoistureSensor_Type);