From 060fa80efd757da8d47251a302725fe37f15cadf Mon Sep 17 00:00:00 2001 From: Ollo Date: Wed, 11 Nov 2020 21:54:38 +0100 Subject: [PATCH 1/3] 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; From 58cb523e1b5462206e0fba71675f9523fa8a2b0f Mon Sep 17 00:00:00 2001 From: Ollo Date: Fri, 1 Oct 2021 22:53:40 +0200 Subject: [PATCH 2/3] added determineTimeLightState in TIMED_LIGHT_PIN define --- esp32/src/main.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/esp32/src/main.cpp b/esp32/src/main.cpp index 2f2a4f3..412c35a 100644 --- a/esp32/src/main.cpp +++ b/esp32/src/main.cpp @@ -974,7 +974,7 @@ void plantcontrol() /** @}*/ - +#ifdef TIMED_LIGHT_PIN bool determineTimedLightState(bool lowLight){ bool onlyAllowedWhenDark = timedLightOnlyWhenDark.get(); long hoursStart = timedLightStart.get(); @@ -1010,6 +1010,8 @@ bool determineTimedLightState(bool lowLight){ } } +#endif + void log(int level, String message, int statusCode) { String buffer; From 1619b93fa1286e5a9eab15e00d0fc0aeb9fa0c59 Mon Sep 17 00:00:00 2001 From: Ollo Date: Fri, 1 Oct 2021 23:00:24 +0200 Subject: [PATCH 3/3] Updated ini.example --- esp32/custom_platformio.ini.example | 5 ++--- esp32/include/ControllerConfiguration.h | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/esp32/custom_platformio.ini.example b/esp32/custom_platformio.ini.example index df8c67a..c4c2974 100644 --- a/esp32/custom_platformio.ini.example +++ b/esp32/custom_platformio.ini.example @@ -5,13 +5,12 @@ framework = arduino build_flags = -DPIO_FRAMEWORK_ARDUINO_LWIP2_LOW_MEMORY board_build.partitions = defaultWithSmallerSpiffs.csv -extra_configs = custom_platformio.ini - ; the latest development brankitchen-lightch (convention V3.0.x) lib_deps = ArduinoJson@6.16.1 - https://github.com/homieiot/homie-esp8266.git#v3.0 OneWire DallasTemperature + pololu/VL53L0X + https://github.com/homieiot/homie-esp8266.git#develop ; add additional parameter, like the upload port upload_port=/dev/ttyUSB1 diff --git a/esp32/include/ControllerConfiguration.h b/esp32/include/ControllerConfiguration.h index f279d09..cad6639 100644 --- a/esp32/include/ControllerConfiguration.h +++ b/esp32/include/ControllerConfiguration.h @@ -84,7 +84,7 @@ */ #define FIRMWARE_VERSION "sw 1.3 hw 0.10" -#define TIMED_LIGHT_PIN CUSTOM1_PIN5 +#define TIMED_LIGHT_PIN CUSTOM1_PIN5 #define MOIST_SENSOR_MAX_FRQ 60000 // 60kHz (500Hz margin) #define MOIST_SENSOR_MIN_FRQ 1000 // 1kHz (500Hz margin)