From 61098724b6168f84be7e47ff6686c64113ca8337 Mon Sep 17 00:00:00 2001 From: Your Name Date: Tue, 17 Aug 2021 16:55:52 +0200 Subject: [PATCH] fixed wrong percent calculation, emit trigger value to mqtt --- esp32/include/PlantCtrl.h | 5 +++-- esp32/src/PlantCtrl.cpp | 1 + 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/esp32/include/PlantCtrl.h b/esp32/include/PlantCtrl.h index 1946cf4..72b3078 100644 --- a/esp32/include/PlantCtrl.h +++ b/esp32/include/PlantCtrl.h @@ -92,8 +92,9 @@ public: { if (this->mSetting->pSensorDry != NULL) { - float percent = (this->mSetting->pSensorDry->get()); - return (((MOIST_SENSOR_MAX_FRQ - MOIST_SENSOR_MIN_FRQ) * percent) + MOIST_SENSOR_MIN_FRQ); + //1 is totally wet, 0 is try, 0 is MOIST_SENSOR_MAX_FRQ, 1 is MOIST_SENSOR_MIN_FRQ + float factor = (this->mSetting->pSensorDry->get()); + return map(factor,0,100,MOIST_SENSOR_MAX_FRQ,MOIST_SENSOR_MIN_FRQ); } else { diff --git a/esp32/src/PlantCtrl.cpp b/esp32/src/PlantCtrl.cpp index 117793e..a46a497 100644 --- a/esp32/src/PlantCtrl.cpp +++ b/esp32/src/PlantCtrl.cpp @@ -120,6 +120,7 @@ void Plant::postMQTTconnection(void) this->mPlant->setProperty("moist").send(String(round(pct*10)/10)); this->mPlant->setProperty("moistraw").send(String(raw)); + this->mPlant->setProperty("moisttrigger").send(String(getSetting2Moisture())); }