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 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);
|
||||
|
|
Loading…
Reference in a new issue