From 3835bd96a11a86dab9337352756d7c10fcbeef3c Mon Sep 17 00:00:00 2001 From: Empire Date: Sun, 12 Feb 2023 12:51:52 +0100 Subject: [PATCH] Revert "Revert "add resistive frequency sensor, updated dependencies"" This reverts commit 42ce4cdda2ae521129661115d4b381f6dfabae46. --- board/sym-lib-table | 11 ++++++----- esp32/include/ControllerConfiguration.h | 6 +----- esp32/include/HomieTypes.h | 2 +- esp32/include/PlantCtrl.h | 8 +++----- esp32/include/ulp-pwm.h | 11 ----------- esp32/platformio.ini | 23 +++++++++++------------ esp32/src/PlantCtrl.cpp | 9 ++++----- esp32/src/main.cpp | 2 +- 8 files changed, 27 insertions(+), 45 deletions(-) diff --git a/board/sym-lib-table b/board/sym-lib-table index 9987325..b8f1854 100644 --- a/board/sym-lib-table +++ b/board/sym-lib-table @@ -1,7 +1,8 @@ (sym_lib_table - (lib (name LP38690DT-3.3)(type Legacy)(uri ${KIPRJMOD}/kicad-stuff/LP38690DT-3.3.lib)(options "")(descr "")) - (lib (name ESP32-DEVKITC-32D)(type Legacy)(uri ${KIPRJMOD}/kicad-stuff/ESP32/ESP32-DEVKITC-32D.lib)(options "")(descr "")) - (lib (name DW01)(type Legacy)(uri ${KIPRJMOD}/kicad-stuff/DW01.lib)(options "")(descr "")) - (lib (name SX1308)(type Legacy)(uri ${KIPRJMOD}/kicad-stuff/SX1308.lib)(options "")(descr "")) - (lib (name ds2438)(type Legacy)(uri ${KIPRJMOD}/kicad-stuff/ds2438.lib)(options "")(descr "")) + (lib (name "LP38690DT-3.3")(type "Legacy")(uri "${KIPRJMOD}/kicad-stuff/LP38690DT-3.3.lib")(options "")(descr "")) + (lib (name "ESP32-DEVKITC-32D")(type "Legacy")(uri "${KIPRJMOD}/kicad-stuff/ESP32/ESP32-DEVKITC-32D.lib")(options "")(descr "")) + (lib (name "DW01")(type "Legacy")(uri "${KIPRJMOD}/kicad-stuff/DW01.lib")(options "")(descr "")) + (lib (name "SX1308")(type "Legacy")(uri "${KIPRJMOD}/kicad-stuff/SX1308.lib")(options "")(descr "")) + (lib (name "ds2438")(type "Legacy")(uri "${KIPRJMOD}/kicad-stuff/ds2438.lib")(options "")(descr "")) + (lib (name "PlantCtrlESP32-rescue")(type "Legacy")(uri "${KIPRJMOD}/PlantCtrlESP32-rescue.lib")(options "")(descr "")) ) diff --git a/esp32/include/ControllerConfiguration.h b/esp32/include/ControllerConfiguration.h index 20e47e7..6035376 100644 --- a/esp32/include/ControllerConfiguration.h +++ b/esp32/include/ControllerConfiguration.h @@ -82,11 +82,7 @@ /** \addtogroup Configuration * @{ */ -#define CONFIG_BOOTLOADER_APP_ROLLBACK_ENABLE -#define CONFIG_COMPILER_CXX_EXCEPTIONS - - -#define FIRMWARE_VERSION "2.4 HW0.10b" +#define FIRMWARE_VERSION "2.5 HW0.10b" #define TIMED_LIGHT_PIN CUSTOM1_PIN5 #define FLOWMETER_PIN CUSTOM1_PIN1 diff --git a/esp32/include/HomieTypes.h b/esp32/include/HomieTypes.h index d39cd3b..0bc94a9 100644 --- a/esp32/include/HomieTypes.h +++ b/esp32/include/HomieTypes.h @@ -21,7 +21,7 @@ #define FOREACH_SENSOR(SENSOR) \ SENSOR(NONE) \ - SENSOR(CAPACITIVE_FREQUENCY) \ + SENSOR(FREQUENCY_MOD_RESISTANCE_PROBE) \ SENSOR(ANALOG_RESISTANCE_PROBE) /** diff --git a/esp32/include/PlantCtrl.h b/esp32/include/PlantCtrl.h index 332b1a7..524a9e8 100644 --- a/esp32/include/PlantCtrl.h +++ b/esp32/include/PlantCtrl.h @@ -19,7 +19,6 @@ #include "MathUtils.h" #include "MQTTUtils.h" #include "LogDefines.h" -#include "SHT2x.h" #define ANALOG_REREADS 5 #define MOISTURE_MEASUREMENT_DURATION 400 /** ms */ @@ -39,7 +38,6 @@ private: bool mConnected = false; int mPlantId = -1; SENSOR_MODE mSensorMode; - SHT2x sht20; public: @@ -134,8 +132,8 @@ public: { case NONE: return DEACTIVATED_PLANT; - case CAPACITIVE_FREQUENCY: - return mapf(mMoisture_raw.getMedian(), MOIST_SENSOR_MAX_FRQ, MOIST_SENSOR_MIN_FRQ, 0, 100); + case FREQUENCY_MOD_RESISTANCE_PROBE: + return mapf(mMoisture_raw.getMedian(), MOIST_SENSOR_MIN_FRQ, MOIST_SENSOR_MAX_FRQ, 0, 100); case ANALOG_RESISTANCE_PROBE: return mapf(mMoisture_raw.getMedian(), ANALOG_SENSOR_MAX_MV, ANALOG_SENSOR_MIN_MV, 0, 100); } @@ -144,7 +142,7 @@ public: float getCurrentMoistureRaw() { - if (getSensorMode() == CAPACITIVE_FREQUENCY) + if (getSensorMode() == FREQUENCY_MOD_RESISTANCE_PROBE) { if (mMoisture_raw.getMedian() < MOIST_SENSOR_MIN_FRQ) { diff --git a/esp32/include/ulp-pwm.h b/esp32/include/ulp-pwm.h index 778d202..66c9cb9 100644 --- a/esp32/include/ulp-pwm.h +++ b/esp32/include/ulp-pwm.h @@ -101,17 +101,6 @@ static inline uint16_t ulp_internal_data_read(size_t offset) return RTC_SLOW_MEM[offset] & 0xffff; } -static inline uint32_t rtc_io_number_get(gpio_num_t gpio_num) -{ - assert(rtc_gpio_is_valid_gpio(gpio_num) && "Invalid GPIO for RTC"); - uint32_t bit = rtc_bit[gpio_num]; - Serial.print("Resolved GPIO "); - Serial.print(gpio_num); - Serial.print(" to rtc bit "); - Serial.println(bit); - return bit; -} - void ulp_internal_start(void) { rtc_gpio_init(PIN); diff --git a/esp32/platformio.ini b/esp32/platformio.ini index 060c0c3..392e8b2 100644 --- a/esp32/platformio.ini +++ b/esp32/platformio.ini @@ -13,23 +13,22 @@ platform = espressif32 board = esp32doit-devkit-v1 framework = arduino build_flags = -DPIO_FRAMEWORK_ARDUINO_LWIP2_LOW_MEMORY - -DPLANT0_SENSORTYPE=ANALOG_RESISTANCE_PROBE - -DPLANT1_SENSORTYPE=ANALOG_RESISTANCE_PROBE - -DPLANT2_SENSORTYPE=CAPACITIVE_FREQUENCY - -DPLANT3_SENSORTYPE=CAPACITIVE_FREQUENCY - -DPLANT4_SENSORTYPE=CAPACITIVE_FREQUENCY - -DPLANT5_SENSORTYPE=CAPACITIVE_FREQUENCY - -DPLANT6_SENSORTYPE=CAPACITIVE_FREQUENCY + -DPLANT0_SENSORTYPE=FREQUENCY_MOD_RESISTANCE_PROBE + -DPLANT1_SENSORTYPE=FREQUENCY_MOD_RESISTANCE_PROBE + -DPLANT2_SENSORTYPE=FREQUENCY_MOD_RESISTANCE_PROBE + -DPLANT3_SENSORTYPE=FREQUENCY_MOD_RESISTANCE_PROBE + -DPLANT4_SENSORTYPE=FREQUENCY_MOD_RESISTANCE_PROBE + -DPLANT5_SENSORTYPE=FREQUENCY_MOD_RESISTANCE_PROBE + -DPLANT6_SENSORTYPE=FREQUENCY_MOD_RESISTANCE_PROBE board_build.partitions = defaultWithSmallerSpiffs.csv ; the latest development brankitchen-lightch (convention V3.0.x) -lib_deps = ArduinoJson@6.16.1 - OneWire - DallasTemperature - pololu/VL53L0X +lib_deps = bblanchon/ArduinoJson@^6.20.1 + paulstoffregen/OneWire@^2.3.7 + milesburton/DallasTemperature@^3.11.0 + pololu/VL53L0X@^1.3.1 https://github.com/homieiot/homie-esp8266.git#develop - robtillaart/SHT2x@^0.1.3 [platformio] diff --git a/esp32/src/PlantCtrl.cpp b/esp32/src/PlantCtrl.cpp index a01f847..dfa0a82 100644 --- a/esp32/src/PlantCtrl.cpp +++ b/esp32/src/PlantCtrl.cpp @@ -23,7 +23,6 @@ Plant::Plant(int pinSensor, int pinPump, int plantId, HomieNode *plant, PlantSet this->mSetting = setting; this->mPlantId = plantId; this->mSensorMode = mode; - this->sht20 = SHT2x(); } void Plant::init(void) @@ -65,7 +64,7 @@ void Plant::initSensors(void) { switch (getSensorMode()) { - case CAPACITIVE_FREQUENCY: + case FREQUENCY_MOD_RESISTANCE_PROBE: { pcnt_unit_t unit = (pcnt_unit_t)(PCNT_UNIT_0 + this->mPlantId); @@ -112,7 +111,7 @@ void Plant::blockingMoistureMeasurement(void) } break; } - case CAPACITIVE_FREQUENCY: + case FREQUENCY_MOD_RESISTANCE_PROBE: case NONE: { // nothing to do here @@ -125,7 +124,7 @@ void Plant::startMoistureMeasurement(void) { switch (getSensorMode()) { - case CAPACITIVE_FREQUENCY: + case FREQUENCY_MOD_RESISTANCE_PROBE: { pcnt_unit_t unit = (pcnt_unit_t)(PCNT_UNIT_0 + this->mPlantId); pcnt_counter_resume(unit); @@ -143,7 +142,7 @@ void Plant::stopMoistureMeasurement(void) { switch (getSensorMode()) { - case CAPACITIVE_FREQUENCY: + case FREQUENCY_MOD_RESISTANCE_PROBE: { int16_t pulses; pcnt_unit_t unit = (pcnt_unit_t)(PCNT_UNIT_0 + this->mPlantId); diff --git a/esp32/src/main.cpp b/esp32/src/main.cpp index 0072fbf..fe5e151 100644 --- a/esp32/src/main.cpp +++ b/esp32/src/main.cpp @@ -318,7 +318,7 @@ void readPowerSwitchedSensors() Plant plant = mPlants[i]; switch (plant.getSensorMode()) { - case CAPACITIVE_FREQUENCY: { + case FREQUENCY_MOD_RESISTANCE_PROBE: { Serial << "Plant " << i << " measurement: " << mPlants[i].getCurrentMoistureRaw() << " hz " << mPlants[i].getCurrentMoisturePCT() << "%" << endl; break; }