summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFlorian Baumann <derflob@derflob.de>2020-06-19 15:23:11 +0200
committerFlorian Baumann <derflob@derflob.de>2020-06-19 15:26:59 +0200
commit06c4507a717616feaf57e70d84763c2145556e4d (patch)
treed3118e8bf82a54f0b4f4fc51046311f079a051fe
parent856a9d6b647753de16a886b1cb2185834228baf9 (diff)
downloadULPSoilMonitor-06c4507a717616feaf57e70d84763c2145556e4d.tar.gz
ULPSoilMonitor-06c4507a717616feaf57e70d84763c2145556e4d.tar.bz2
only publish soil data, if valid
-rw-r--r--ULPSoilMonitor.ino6
1 files changed, 5 insertions, 1 deletions
diff --git a/ULPSoilMonitor.ino b/ULPSoilMonitor.ino
index 87140c1..7349381 100644
--- a/ULPSoilMonitor.ino
+++ b/ULPSoilMonitor.ino
@@ -310,7 +310,7 @@ static float soil_moisture(uint16_t adc_value, float vcc, float offset, float gr
static void calculate_soil_data()
{
- if (isnan(soil.valid))
+ if (isnan(soil.vcc) or soil.vcc == 0.0)
return;
init_sensor_coefficients();
@@ -436,7 +436,11 @@ static void publish_soil(uint8_t index, float value)
static void publish_soil_data()
{
+ if (!soil.valid)
+ return;
+
publish_vcc();
+
publish_soil(0, soil.soil0);
publish_soil(1, soil.soil1);
publish_soil(2, soil.soil2);