From 42ce4cdda2ae521129661115d4b381f6dfabae46 Mon Sep 17 00:00:00 2001 From: Empire Date: Sun, 12 Feb 2023 12:40:38 +0100 Subject: [PATCH] Revert "add resistive frequency sensor, updated dependencies" This reverts commit 17d16a6eef60715fb64cfeeff4c81baf43ddd5d1. --- 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, 45 insertions(+), 27 deletions(-) diff --git a/board/sym-lib-table b/board/sym-lib-table index b8f1854..9987325 100644 --- a/board/sym-lib-table +++ b/board/sym-lib-table @@ -1,8 +1,7 @@ (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 "PlantCtrlESP32-rescue")(type "Legacy")(uri "${KIPRJMOD}/PlantCtrlESP32-rescue.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 "")) ) diff --git a/esp32/include/ControllerConfiguration.h b/esp32/include/ControllerConfiguration.h index 6035376..20e47e7 100644 --- a/esp32/include/ControllerConfiguration.h +++ b/esp32/include/ControllerConfiguration.h @@ -82,7 +82,11 @@ /** \addtogroup Configuration * @{ */ -#define FIRMWARE_VERSION "2.5 HW0.10b" +#define CONFIG_BOOTLOADER_APP_ROLLBACK_ENABLE +#define CONFIG_COMPILER_CXX_EXCEPTIONS + + +#define FIRMWARE_VERSION "2.4 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 0bc94a9..d39cd3b 100644 --- a/esp32/include/HomieTypes.h +++ b/esp32/include/HomieTypes.h @@ -21,7 +21,7 @@ #define FOREACH_SENSOR(SENSOR) \ SENSOR(NONE) \ - SENSOR(FREQUENCY_MOD_RESISTANCE_PROBE) \ + SENSOR(CAPACITIVE_FREQUENCY) \ SENSOR(ANALOG_RESISTANCE_PROBE) /** diff --git a/esp32/include/PlantCtrl.h b/esp32/include/PlantCtrl.h index 524a9e8..332b1a7 100644 --- a/esp32/include/PlantCtrl.h +++ b/esp32/include/PlantCtrl.h @@ -19,6 +19,7 @@ #include "MathUtils.h" #include "MQTTUtils.h" #include "LogDefines.h" +#include "SHT2x.h" #define ANALOG_REREADS 5 #define MOISTURE_MEASUREMENT_DURATION 400 /** ms */ @@ -38,6 +39,7 @@ private: bool mConnected = false; int mPlantId = -1; SENSOR_MODE mSensorMode; + SHT2x sht20; public: @@ -132,8 +134,8 @@ public: { case NONE: return DEACTIVATED_PLANT; - case FREQUENCY_MOD_RESISTANCE_PROBE: - return mapf(mMoisture_raw.getMedian(), MOIST_SENSOR_MIN_FRQ, MOIST_SENSOR_MAX_FRQ, 0, 100); + case CAPACITIVE_FREQUENCY: + return mapf(mMoisture_raw.getMedian(), MOIST_SENSOR_MAX_FRQ, MOIST_SENSOR_MIN_FRQ, 0, 100); case ANALOG_RESISTANCE_PROBE: return mapf(mMoisture_raw.getMedian(), ANALOG_SENSOR_MAX_MV, ANALOG_SENSOR_MIN_MV, 0, 100); } @@ -142,7 +144,7 @@ public: float getCurrentMoistureRaw() { - if (getSensorMode() == FREQUENCY_MOD_RESISTANCE_PROBE) + if (getSensorMode() == CAPACITIVE_FREQUENCY) { if (mMoisture_raw.getMedian() < MOIST_SENSOR_MIN_FRQ) { diff --git a/esp32/include/ulp-pwm.h b/esp32/include/ulp-pwm.h index 66c9cb9..778d202 100644 --- a/esp32/include/ulp-pwm.h +++ b/esp32/include/ulp-pwm.h @@ -101,6 +101,17 @@ 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 392e8b2..060c0c3 100644 --- a/esp32/platformio.ini +++ b/esp32/platformio.ini @@ -13,22 +13,23 @@ platform = espressif32 board = esp32doit-devkit-v1 framework = arduino build_flags = -DPIO_FRAMEWORK_ARDUINO_LWIP2_LOW_MEMORY - -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 + -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 board_build.partitions = defaultWithSmallerSpiffs.csv ; the latest development brankitchen-lightch (convention V3.0.x) -lib_deps = bblanchon/ArduinoJson@^6.20.1 - paulstoffregen/OneWire@^2.3.7 - milesburton/DallasTemperature@^3.11.0 - pololu/VL53L0X@^1.3.1 +lib_deps = ArduinoJson@6.16.1 + OneWire + DallasTemperature + pololu/VL53L0X 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 dfa0a82..a01f847 100644 --- a/esp32/src/PlantCtrl.cpp +++ b/esp32/src/PlantCtrl.cpp @@ -23,6 +23,7 @@ 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) @@ -64,7 +65,7 @@ void Plant::initSensors(void) { switch (getSensorMode()) { - case FREQUENCY_MOD_RESISTANCE_PROBE: + case CAPACITIVE_FREQUENCY: { pcnt_unit_t unit = (pcnt_unit_t)(PCNT_UNIT_0 + this->mPlantId); @@ -111,7 +112,7 @@ void Plant::blockingMoistureMeasurement(void) } break; } - case FREQUENCY_MOD_RESISTANCE_PROBE: + case CAPACITIVE_FREQUENCY: case NONE: { // nothing to do here @@ -124,7 +125,7 @@ void Plant::startMoistureMeasurement(void) { switch (getSensorMode()) { - case FREQUENCY_MOD_RESISTANCE_PROBE: + case CAPACITIVE_FREQUENCY: { pcnt_unit_t unit = (pcnt_unit_t)(PCNT_UNIT_0 + this->mPlantId); pcnt_counter_resume(unit); @@ -142,7 +143,7 @@ void Plant::stopMoistureMeasurement(void) { switch (getSensorMode()) { - case FREQUENCY_MOD_RESISTANCE_PROBE: + case CAPACITIVE_FREQUENCY: { 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 fe5e151..0072fbf 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 FREQUENCY_MOD_RESISTANCE_PROBE: { + case CAPACITIVE_FREQUENCY: { Serial << "Plant " << i << " measurement: " << mPlants[i].getCurrentMoistureRaw() << " hz " << mPlants[i].getCurrentMoisturePCT() << "%" << endl; break; }