From 060fa80efd757da8d47251a302725fe37f15cadf Mon Sep 17 00:00:00 2001 From: Ollo Date: Wed, 11 Nov 2020 21:54:38 +0100 Subject: [PATCH] read only once --- esp32/src/main.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/esp32/src/main.cpp b/esp32/src/main.cpp index 8f9e072..5cd36ff 100644 --- a/esp32/src/main.cpp +++ b/esp32/src/main.cpp @@ -411,8 +411,7 @@ bool readSensors() rtcLastTemp2 = temp2.getAverage(); /* Use the Ultrasonic sensor to measure waterLevel */ - for (int i = 0; i < 5; i++) - { + digitalWrite(SENSOR_SR04_TRIG, LOW); delayMicroseconds(2); digitalWrite(SENSOR_SR04_TRIG, HIGH); @@ -421,8 +420,7 @@ bool readSensors() float duration = pulseIn(SENSOR_SR04_ECHO, HIGH); waterRawSensor.add((duration * .343) / 2); Serial << "Distance sensor " << duration << " ms : " << waterRawSensor.getAverage() << " cm" << endl; - delay(20); - } + /* deactivate the sensors */ digitalWrite(OUTPUT_SENSOR, LOW); return leaveMode1;