diff --git a/esp32/include/ControllerConfiguration.h b/esp32/include/ControllerConfiguration.h index 6035376..312934c 100644 --- a/esp32/include/ControllerConfiguration.h +++ b/esp32/include/ControllerConfiguration.h @@ -90,7 +90,7 @@ #define FLOWMETER_PULSES_PER_ML 2.2 #endif -#define MOIST_SENSOR_MAX_FRQ 60000 // 60kHz (500Hz margin) +#define MOIST_SENSOR_MAX_FRQ 5200 // 60kHz (500Hz margin) #define MOIST_SENSOR_MIN_FRQ 500 // 0.5kHz (500Hz margin) #define ANALOG_SENSOR_MAX_MV 1300 //successive approximation of good range diff --git a/esp32/include/HomieTypes.h b/esp32/include/HomieTypes.h index 0bc94a9..87d763a 100644 --- a/esp32/include/HomieTypes.h +++ b/esp32/include/HomieTypes.h @@ -47,6 +47,8 @@ static const char *SENSOR_STRING[] = { #define HYDROPONIC_MODE -3 //plant uses cooldown and duration and workhours, moisture is measured but ignored #define TIMER_ONLY -4 +//special value to indicate a shorted sensor when the plant is not deactivated but the sensor reads short circuit value +#define SHORT_CIRCUIT_MODE -5 typedef struct PlantSettings_t { diff --git a/esp32/include/PlantCtrl.h b/esp32/include/PlantCtrl.h index 524a9e8..91c236d 100644 --- a/esp32/include/PlantCtrl.h +++ b/esp32/include/PlantCtrl.h @@ -148,6 +148,10 @@ public: { return MISSING_SENSOR; } + if (mMoisture_raw.getMedian() > MOIST_SENSOR_MAX_FRQ) + { + return SHORT_CIRCUIT_MODE; + } } return mMoisture_raw.getMedian();