fix turn on/off of fan and switch to humidity mode

This commit is contained in:
Lukas Heiligenbrunner 2020-11-30 11:14:08 +01:00
parent ffb62b9297
commit 5943ffc97b
3 changed files with 12 additions and 17 deletions

View File

@ -20,13 +20,13 @@ void Heating::init(Temperature *tempsensor, unsigned mode) {
Serial.println("Turning on heating");
mTurnOffTicker.once((int)((float)refreshperiod * (float)percentOn / 100.0), []() {
mTurnOffTicker.once((int) ((float) refreshperiod * (float) percentOn / 100.0), []() {
digitalWrite(HeizungPin, LOW);
Serial.println("Turned off heating!");
});
mLuefterTicker.once((int)(((float)refreshperiod * (float)percentOn / 100.0) + 30.0), []() {
mLuefterTicker.once((int) (((float) refreshperiod * (float) percentOn / 100.0) + 30.0), []() {
digitalWrite(LuefterPin, LOW);
Serial.println("Turned off fan!");
@ -38,7 +38,7 @@ void Heating::init(Temperature *tempsensor, unsigned mode) {
break;
}
case HUMIDITY:
mFanWaiting = false;
mHeatingStatus = false;
mHeizungTicker.attach(10, [&tempsensor, this]() {
// shedule this function because tempread is blocking
@ -58,24 +58,21 @@ void Heating::init(Temperature *tempsensor, unsigned mode) {
// turn on heating and fan
digitalWrite(LuefterPin, HIGH);
digitalWrite(HeizungPin, HIGH);
// if fan waiting detach its ticker
if (mFanWaiting) {
mLuefterTicker.detach();
mFanWaiting = false;
}
mHeatingStatus = true;
} else if (hum < 60.0) {
// if humidity too low turn off heating and fan after 60secs
digitalWrite(HeizungPin, LOW);
Serial.println("heating should NOT run now!");
if (!mFanWaiting) {
mFanWaiting = true;
// if heating status in on set ticker to turn of fan in 60sec
if (mHeatingStatus) {
mLuefterTicker.once(60, []() {
// turn off fan
digitalWrite(LuefterPin, LOW);
Serial.println("turning off fan");
});
}
mHeatingStatus = false;
}
});
});

View File

@ -17,5 +17,5 @@ private:
Ticker mLuefterTicker;
Ticker mTurnOffTicker;
bool mFanWaiting;
bool mHeatingStatus;
};

View File

@ -8,7 +8,7 @@
#include "Pins.h"
#include "Temperature.h"
#define VERSION "v1.1"
#define VERSION "v1.1.1"
bool allow;
bool error = false;
@ -149,9 +149,6 @@ void setup() {
digitalWrite(SchuetzPin, LOW); //pumpe anfangs sofort abschalten
digitalWrite(LuefterPin, LOW);
digitalWrite(HeizungPin, LOW);
//
// digitalWrite(HeizungPin, HIGH);
// delay(1000000);
// initilize serial connection
Serial.begin(9600);
@ -188,8 +185,9 @@ void setup() {
Serial.println("Initializing wifi");
mang.init(&temp);
// initialize heating control
Serial.println("initializing heating service");
mHeat.init(&temp, Heating::TIME);
mHeat.init(&temp, Heating::HUMIDITY);
Serial.println("startup sequence complete!\n");
digitalWrite(LED_BUILTIN, HIGH);