firmware wip - add lightHour and veg/bloom phase control
This commit is contained in:
parent
171db2981c
commit
99ac7069fa
1 changed files with 15 additions and 3 deletions
|
@ -994,6 +994,7 @@ void loop() {
|
||||||
unsigned int secondsSunrise = (SunriseHour * 60 * 60) + (SunriseMinute * 60);
|
unsigned int secondsSunrise = (SunriseHour * 60 * 60) + (SunriseMinute * 60);
|
||||||
unsigned int secondsToday = (timeClient.getHours() * 60 * 60) + (timeClient.getMinutes() * 60) + timeClient.getSeconds();
|
unsigned int secondsToday = (timeClient.getHours() * 60 * 60) + (timeClient.getMinutes() * 60) + timeClient.getSeconds();
|
||||||
unsigned long currentRuntime = millis();
|
unsigned long currentRuntime = millis();
|
||||||
|
byte lightHours;
|
||||||
|
|
||||||
// first we call webserver handle client
|
// first we call webserver handle client
|
||||||
webserver.handleClient();
|
webserver.handleClient();
|
||||||
|
@ -1007,9 +1008,20 @@ void loop() {
|
||||||
Serial.println(secondsToday);
|
Serial.println(secondsToday);
|
||||||
//Serial.println("yolo");
|
//Serial.println("yolo");
|
||||||
|
|
||||||
// check if secondsToday is larger then secondsSunrise time
|
// calculate acutal DayOfGrow
|
||||||
if(secondsToday >= secondsSunrise) {
|
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
|
// turn on light
|
||||||
|
// TODO write a LED control function which takes also takes care of UseLEDrelais
|
||||||
analogWrite(PINled, PINled_PWM);
|
analogWrite(PINled, PINled_PWM);
|
||||||
} else {
|
} else {
|
||||||
// turn off
|
// turn off
|
||||||
|
@ -1287,7 +1299,7 @@ void WEBroot() {
|
||||||
body += returnStrDateFromEpoch(GrowStart);
|
body += returnStrDateFromEpoch(GrowStart);
|
||||||
body += "<br>";
|
body += "<br>";
|
||||||
body += "Day of Grow: ";
|
body += "Day of Grow: ";
|
||||||
body += int(ceil(float((timeClient.getEpochTime() - GrowStart) / 60 / 60 / 24))) ;
|
body += DayOfGrow;
|
||||||
body += "<br>";
|
body += "<br>";
|
||||||
body += "Soil Moisture: ";
|
body += "Soil Moisture: ";
|
||||||
body += getSoilmoisture(MoistureSensor_Type);
|
body += getSoilmoisture(MoistureSensor_Type);
|
||||||
|
|
Loading…
Reference in a new issue