From 9eb16637dc24aab8b008ea1b5bd49b08eef41276 Mon Sep 17 00:00:00 2001 From: Ollo Date: Wed, 22 Mar 2023 21:01:24 +0100 Subject: [PATCH] Reset as distance is > 8 meter --- esp32test/Esp32DeepSleepTest/src/main.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/esp32test/Esp32DeepSleepTest/src/main.cpp b/esp32test/Esp32DeepSleepTest/src/main.cpp index 69588b9..f7f600f 100644 --- a/esp32test/Esp32DeepSleepTest/src/main.cpp +++ b/esp32test/Esp32DeepSleepTest/src/main.cpp @@ -13,9 +13,9 @@ VL53L0X tankSensor; void initializeTanksensor() { Wire.begin(SENSOR_TANK_SDA, SENSOR_TANK_SCL, 100000UL /* 100kHz */); - tankSensor.setTimeout(500); tankSensor.setBus(&Wire); - delay(20); + delay(100); + tankSensor.setTimeout(500); long start = millis(); bool distanceReady = false; while (start + 500 > millis()) @@ -64,11 +64,10 @@ void loop() { if (!tankSensor.timeoutOccurred()) { uint16_t distance = tankSensor.readRangeSingleMillimeters(); - if (distance == 8191) { - Serial.println("Reset due to 8.191 meter"); - tankSensor.stopContinuous(); + if (distance > 8000) { + Serial.println("Reset due invalid distance: 8 meter"); Wire.end(); - delay(100); + delay(1000); initializeTanksensor(); } else { Serial.print("Distance");