add new ticker to check after 500ms if water outage is correct.
This commit is contained in:
parent
6adfb3c09e
commit
697ed69d95
@ -16,6 +16,6 @@
|
||||
#define TempSensorPin D4
|
||||
|
||||
// version info
|
||||
#define VERSION "v1.2.4-Alpa1"
|
||||
#define VERSION "v1.2.4-Alpha2"
|
||||
|
||||
#endif //PUMPENSTEUERUNG_PINS_H
|
||||
|
73
src/main.cpp
73
src/main.cpp
@ -15,7 +15,7 @@ bool error = false;
|
||||
Ticker status;
|
||||
|
||||
//pumpendauer maximum ticker
|
||||
Ticker pumpendauer;
|
||||
Ticker pumpendauer, wasserSensorDoubleCheck;
|
||||
|
||||
//WifiManager mang;
|
||||
Heating mHeat;
|
||||
@ -45,9 +45,10 @@ void pumpeSchalten(bool on) {
|
||||
pumpcycles++;
|
||||
generalinfo.setPumpCycles(pumpcycles);
|
||||
|
||||
pumpendauer.once((float)settingsservice.getSettings()->maxpumpduration + 1, []() {
|
||||
pumpendauer.once((float) settingsservice.getSettings()->maxpumpduration + 1, []() {
|
||||
//erlaube keine einschaltung von mehr als 60 sek
|
||||
if (Timer::getSystemSeconds() - turnontime >= (unsigned)settingsservice.getSettings()->maxpumpduration && turnontime != 0) {
|
||||
if (Timer::getSystemSeconds() - turnontime >=
|
||||
(unsigned) settingsservice.getSettings()->maxpumpduration && turnontime != 0) {
|
||||
//error zu lange
|
||||
Serial.println("\n\npumpe lief mehr als 10 Minuten durchgaengig");
|
||||
pumpeSchalten(false);
|
||||
@ -64,7 +65,8 @@ void pumpeSchalten(bool on) {
|
||||
digitalWrite(SchuetzPin, on);
|
||||
Serial.println("[Erfolg] pumpe wird geschalten");
|
||||
} else {
|
||||
Serial.println("[FEHLGESCHLAGEN] Schalten des Schütz gesperrt durch Timeout oder Fehler-- sofortiges ausschalten der pumpe\n");
|
||||
Serial.println(
|
||||
"[FEHLGESCHLAGEN] Schalten des Schütz gesperrt durch Timeout oder Fehler-- sofortiges ausschalten der pumpe\n");
|
||||
turnontime = -1;
|
||||
digitalWrite(SchuetzPin, LOW);
|
||||
}
|
||||
@ -93,41 +95,46 @@ int wateroutagewaitduration;
|
||||
|
||||
void WasserSensorCheck() {
|
||||
if (digitalRead(WasserSensorPin) == LOW) {
|
||||
Serial.println("Wasser Sensor AUS");
|
||||
//kein Wasser dh timer auf 10min stellen
|
||||
// check if water sensor is also low after 500ms and lock it then
|
||||
wasserSensorDoubleCheck.once_ms(500, []() {
|
||||
if (digitalRead(WasserSensorPin) == LOW) {
|
||||
Serial.println("Wasser Sensor AUS");
|
||||
//kein Wasser dh timer auf 10min stellen
|
||||
|
||||
// refresh wateroutage counter
|
||||
generalinfo.setlastWaterOutage(Timer::getSystemSeconds());
|
||||
// refresh wateroutage counter
|
||||
generalinfo.setlastWaterOutage(Timer::getSystemSeconds());
|
||||
|
||||
allow = false;
|
||||
Serial.println("Schalte pumpe aus");
|
||||
pumpeSchalten(false);
|
||||
allow = false;
|
||||
Serial.println("Schalte pumpe aus");
|
||||
pumpeSchalten(false);
|
||||
|
||||
Serial.println("warte 30min");
|
||||
Serial.println("warte 30min");
|
||||
|
||||
status.detach();
|
||||
|
||||
wateroutagewaitduration = settingsservice.getSettings()->waterOutageWaitDuration;
|
||||
|
||||
status.detach();
|
||||
status.attach(5, []() {
|
||||
wateroutagewaitduration -= 5;
|
||||
Serial.print("noch ");
|
||||
Serial.print(wateroutagewaitduration);
|
||||
Serial.println(" Sekunden verbleibend");
|
||||
|
||||
if (wateroutagewaitduration <= 0) {
|
||||
status.detach();
|
||||
if (digitalRead(WasserSensorPin)) {
|
||||
allow = true;
|
||||
Serial.println("Einschalten der Pumpe wieder erlaubt.");
|
||||
|
||||
//pruefen ob drucksensor ein
|
||||
DruckschalterInt();
|
||||
} else {
|
||||
Serial.print("wassersensor immer noch kein Wasser --> verlaengern um 120min\n\n");
|
||||
WasserSensorCheck();
|
||||
}
|
||||
wateroutagewaitduration = settingsservice.getSettings()->waterOutageWaitDuration;
|
||||
|
||||
status.detach();
|
||||
status.attach(5, []() {
|
||||
wateroutagewaitduration -= 5;
|
||||
Serial.print("noch ");
|
||||
Serial.print(wateroutagewaitduration);
|
||||
Serial.println(" Sekunden verbleibend");
|
||||
|
||||
if (wateroutagewaitduration <= 0) {
|
||||
status.detach();
|
||||
if (digitalRead(WasserSensorPin)) {
|
||||
allow = true;
|
||||
Serial.println("Einschalten der Pumpe wieder erlaubt.");
|
||||
|
||||
//pruefen ob drucksensor ein
|
||||
DruckschalterInt();
|
||||
} else {
|
||||
Serial.print("wassersensor immer noch kein Wasser --> verlaengern um 120min\n\n");
|
||||
WasserSensorCheck();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user