add resistive frequency sensor, updated dependencies

This commit is contained in:
Empire 2023-02-10 22:08:29 +01:00
parent 4a86d8c41c
commit 17d16a6eef
8 changed files with 27 additions and 45 deletions

View File

@ -1,7 +1,8 @@
(sym_lib_table (sym_lib_table
(lib (name LP38690DT-3.3)(type Legacy)(uri ${KIPRJMOD}/kicad-stuff/LP38690DT-3.3.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 "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 "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 "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 "ds2438")(type "Legacy")(uri "${KIPRJMOD}/kicad-stuff/ds2438.lib")(options "")(descr ""))
(lib (name "PlantCtrlESP32-rescue")(type "Legacy")(uri "${KIPRJMOD}/PlantCtrlESP32-rescue.lib")(options "")(descr ""))
) )

View File

@ -82,11 +82,7 @@
/** \addtogroup Configuration /** \addtogroup Configuration
* @{ * @{
*/ */
#define CONFIG_BOOTLOADER_APP_ROLLBACK_ENABLE #define FIRMWARE_VERSION "2.5 HW0.10b"
#define CONFIG_COMPILER_CXX_EXCEPTIONS
#define FIRMWARE_VERSION "2.4 HW0.10b"
#define TIMED_LIGHT_PIN CUSTOM1_PIN5 #define TIMED_LIGHT_PIN CUSTOM1_PIN5
#define FLOWMETER_PIN CUSTOM1_PIN1 #define FLOWMETER_PIN CUSTOM1_PIN1

View File

@ -21,7 +21,7 @@
#define FOREACH_SENSOR(SENSOR) \ #define FOREACH_SENSOR(SENSOR) \
SENSOR(NONE) \ SENSOR(NONE) \
SENSOR(CAPACITIVE_FREQUENCY) \ SENSOR(FREQUENCY_MOD_RESISTANCE_PROBE) \
SENSOR(ANALOG_RESISTANCE_PROBE) SENSOR(ANALOG_RESISTANCE_PROBE)
/** /**

View File

@ -19,7 +19,6 @@
#include "MathUtils.h" #include "MathUtils.h"
#include "MQTTUtils.h" #include "MQTTUtils.h"
#include "LogDefines.h" #include "LogDefines.h"
#include "SHT2x.h"
#define ANALOG_REREADS 5 #define ANALOG_REREADS 5
#define MOISTURE_MEASUREMENT_DURATION 400 /** ms */ #define MOISTURE_MEASUREMENT_DURATION 400 /** ms */
@ -39,7 +38,6 @@ private:
bool mConnected = false; bool mConnected = false;
int mPlantId = -1; int mPlantId = -1;
SENSOR_MODE mSensorMode; SENSOR_MODE mSensorMode;
SHT2x sht20;
public: public:
@ -128,8 +126,8 @@ public:
{ {
case NONE: case NONE:
return DEACTIVATED_PLANT; return DEACTIVATED_PLANT;
case CAPACITIVE_FREQUENCY: case FREQUENCY_MOD_RESISTANCE_PROBE:
return mapf(mMoisture_raw.getMedian(), MOIST_SENSOR_MAX_FRQ, MOIST_SENSOR_MIN_FRQ, 0, 100); return mapf(mMoisture_raw.getMedian(), MOIST_SENSOR_MIN_FRQ, MOIST_SENSOR_MAX_FRQ, 0, 100);
case ANALOG_RESISTANCE_PROBE: case ANALOG_RESISTANCE_PROBE:
return mapf(mMoisture_raw.getMedian(), ANALOG_SENSOR_MAX_MV, ANALOG_SENSOR_MIN_MV, 0, 100); return mapf(mMoisture_raw.getMedian(), ANALOG_SENSOR_MAX_MV, ANALOG_SENSOR_MIN_MV, 0, 100);
} }
@ -138,7 +136,7 @@ public:
float getCurrentMoistureRaw() float getCurrentMoistureRaw()
{ {
if (getSensorMode() == CAPACITIVE_FREQUENCY) if (getSensorMode() == FREQUENCY_MOD_RESISTANCE_PROBE)
{ {
if (mMoisture_raw.getMedian() < MOIST_SENSOR_MIN_FRQ) if (mMoisture_raw.getMedian() < MOIST_SENSOR_MIN_FRQ)
{ {

View File

@ -101,17 +101,6 @@ static inline uint16_t ulp_internal_data_read(size_t offset)
return RTC_SLOW_MEM[offset] & 0xffff; 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) void ulp_internal_start(void)
{ {
rtc_gpio_init(PIN); rtc_gpio_init(PIN);

View File

@ -13,23 +13,22 @@ platform = espressif32
board = esp32doit-devkit-v1 board = esp32doit-devkit-v1
framework = arduino framework = arduino
build_flags = -DPIO_FRAMEWORK_ARDUINO_LWIP2_LOW_MEMORY build_flags = -DPIO_FRAMEWORK_ARDUINO_LWIP2_LOW_MEMORY
-DPLANT0_SENSORTYPE=ANALOG_RESISTANCE_PROBE -DPLANT0_SENSORTYPE=FREQUENCY_MOD_RESISTANCE_PROBE
-DPLANT1_SENSORTYPE=ANALOG_RESISTANCE_PROBE -DPLANT1_SENSORTYPE=FREQUENCY_MOD_RESISTANCE_PROBE
-DPLANT2_SENSORTYPE=CAPACITIVE_FREQUENCY -DPLANT2_SENSORTYPE=FREQUENCY_MOD_RESISTANCE_PROBE
-DPLANT3_SENSORTYPE=CAPACITIVE_FREQUENCY -DPLANT3_SENSORTYPE=FREQUENCY_MOD_RESISTANCE_PROBE
-DPLANT4_SENSORTYPE=CAPACITIVE_FREQUENCY -DPLANT4_SENSORTYPE=FREQUENCY_MOD_RESISTANCE_PROBE
-DPLANT5_SENSORTYPE=CAPACITIVE_FREQUENCY -DPLANT5_SENSORTYPE=FREQUENCY_MOD_RESISTANCE_PROBE
-DPLANT6_SENSORTYPE=CAPACITIVE_FREQUENCY -DPLANT6_SENSORTYPE=FREQUENCY_MOD_RESISTANCE_PROBE
board_build.partitions = defaultWithSmallerSpiffs.csv board_build.partitions = defaultWithSmallerSpiffs.csv
; the latest development brankitchen-lightch (convention V3.0.x) ; the latest development brankitchen-lightch (convention V3.0.x)
lib_deps = ArduinoJson@6.16.1 lib_deps = bblanchon/ArduinoJson@^6.20.1
OneWire paulstoffregen/OneWire@^2.3.7
DallasTemperature milesburton/DallasTemperature@^3.11.0
pololu/VL53L0X pololu/VL53L0X@^1.3.1
https://github.com/homieiot/homie-esp8266.git#develop https://github.com/homieiot/homie-esp8266.git#develop
robtillaart/SHT2x@^0.1.3
[platformio] [platformio]

View File

@ -23,7 +23,6 @@ Plant::Plant(int pinSensor, int pinPump, int plantId, HomieNode *plant, PlantSet
this->mSetting = setting; this->mSetting = setting;
this->mPlantId = plantId; this->mPlantId = plantId;
this->mSensorMode = mode; this->mSensorMode = mode;
this->sht20 = SHT2x();
} }
void Plant::init(void) void Plant::init(void)
@ -65,7 +64,7 @@ void Plant::initSensors(void)
{ {
switch (getSensorMode()) switch (getSensorMode())
{ {
case CAPACITIVE_FREQUENCY: case FREQUENCY_MOD_RESISTANCE_PROBE:
{ {
pcnt_unit_t unit = (pcnt_unit_t)(PCNT_UNIT_0 + this->mPlantId); pcnt_unit_t unit = (pcnt_unit_t)(PCNT_UNIT_0 + this->mPlantId);
@ -112,7 +111,7 @@ void Plant::blockingMoistureMeasurement(void)
} }
break; break;
} }
case CAPACITIVE_FREQUENCY: case FREQUENCY_MOD_RESISTANCE_PROBE:
case NONE: case NONE:
{ {
// nothing to do here // nothing to do here
@ -125,7 +124,7 @@ void Plant::startMoistureMeasurement(void)
{ {
switch (getSensorMode()) switch (getSensorMode())
{ {
case CAPACITIVE_FREQUENCY: case FREQUENCY_MOD_RESISTANCE_PROBE:
{ {
pcnt_unit_t unit = (pcnt_unit_t)(PCNT_UNIT_0 + this->mPlantId); pcnt_unit_t unit = (pcnt_unit_t)(PCNT_UNIT_0 + this->mPlantId);
pcnt_counter_resume(unit); pcnt_counter_resume(unit);
@ -143,7 +142,7 @@ void Plant::stopMoistureMeasurement(void)
{ {
switch (getSensorMode()) switch (getSensorMode())
{ {
case CAPACITIVE_FREQUENCY: case FREQUENCY_MOD_RESISTANCE_PROBE:
{ {
int16_t pulses; int16_t pulses;
pcnt_unit_t unit = (pcnt_unit_t)(PCNT_UNIT_0 + this->mPlantId); pcnt_unit_t unit = (pcnt_unit_t)(PCNT_UNIT_0 + this->mPlantId);

View File

@ -315,7 +315,7 @@ void readPowerSwitchedSensors()
Plant plant = mPlants[i]; Plant plant = mPlants[i];
switch (plant.getSensorMode()) switch (plant.getSensorMode())
{ {
case CAPACITIVE_FREQUENCY: { case FREQUENCY_MOD_RESISTANCE_PROBE: {
Serial << "Plant " << i << " measurement: " << mPlants[i].getCurrentMoistureRaw() << " hz " << mPlants[i].getCurrentMoisturePCT() << "%" << endl; Serial << "Plant " << i << " measurement: " << mPlants[i].getCurrentMoistureRaw() << " hz " << mPlants[i].getCurrentMoisturePCT() << "%" << endl;
break; break;
} }