From 41da6c3b99d7bc7e15acaef071beec576df4942e Mon Sep 17 00:00:00 2001 From: Mike Kinney Date: Sun, 16 Jan 2022 15:06:34 -0800 Subject: [PATCH 1/6] add DHT22 --- .../esp32/EnvironmentalMeasurementPlugin.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/plugins/esp32/EnvironmentalMeasurementPlugin.cpp b/src/plugins/esp32/EnvironmentalMeasurementPlugin.cpp index 992057364..5ef642c75 100644 --- a/src/plugins/esp32/EnvironmentalMeasurementPlugin.cpp +++ b/src/plugins/esp32/EnvironmentalMeasurementPlugin.cpp @@ -86,6 +86,13 @@ int32_t EnvironmentalMeasurementPlugin::runOnce() DEBUG_MSG("EnvironmentalMeasurement: Opened DS18B20 on pin: %d\n", radioConfig.preferences.environmental_measurement_plugin_sensor_pin); return (DS18B20_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS); + case RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_DHT22: + dht = new DHT(radioConfig.preferences.environmental_measurement_plugin_sensor_pin, DHT22); + this->dht->begin(); + this->dht->read(); + DEBUG_MSG("EnvironmentalMeasurement: Opened DHT22 on pin: %d\n", + radioConfig.preferences.environmental_measurement_plugin_sensor_pin); + return (DHT_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS); default: DEBUG_MSG("EnvironmentalMeasurement: Invalid sensor type selected; Disabling plugin"); return (INT32_MAX); @@ -132,6 +139,8 @@ int32_t EnvironmentalMeasurementPlugin::runOnce() return (DHT_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS); case RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_DS18B20: return (DS18B20_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS); + case RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_DHT22: + return (DHT_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS); default: return (DEFAULT_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS); } @@ -264,6 +273,15 @@ bool EnvironmentalMeasurementPlugin::sendOurEnvironmentalMeasurement(NodeNum des DEBUG_MSG("EnvironmentalMeasurement: FAILED TO READ DATA\n"); return false; } + case RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_DHT22: + if (!this->dht->read(true)) { + sensor_read_error_count++; + DEBUG_MSG("EnvironmentalMeasurement: FAILED TO READ DATA\n"); + return false; + } + m.relative_humidity = this->dht->readHumidity(); + m.temperature = this->dht->readTemperature(); + break; default: DEBUG_MSG("EnvironmentalMeasurement: Invalid sensor type selected; Disabling plugin"); return false; From 5797e3246176465a9c06bf29f2815aa5aace3dd4 Mon Sep 17 00:00:00 2001 From: Mike Kinney Date: Sun, 16 Jan 2022 15:16:03 -0800 Subject: [PATCH 2/6] add support for other 2 sensors --- src/plugins/esp32/EnvironmentalMeasurementPlugin.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/plugins/esp32/EnvironmentalMeasurementPlugin.cpp b/src/plugins/esp32/EnvironmentalMeasurementPlugin.cpp index 5ef642c75..7ed2cad09 100644 --- a/src/plugins/esp32/EnvironmentalMeasurementPlugin.cpp +++ b/src/plugins/esp32/EnvironmentalMeasurementPlugin.cpp @@ -71,10 +71,11 @@ int32_t EnvironmentalMeasurementPlugin::runOnce() // therefore, we should only enable the sensor loop if measurement is also enabled switch (radioConfig.preferences.environmental_measurement_plugin_sensor_type) { case RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_DHT11: + case RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_DHT12: dht = new DHT(radioConfig.preferences.environmental_measurement_plugin_sensor_pin, DHT11); this->dht->begin(); this->dht->read(); - DEBUG_MSG("EnvironmentalMeasurement: Opened DHT11 on pin: %d\n", + DEBUG_MSG("EnvironmentalMeasurement: Opened DHT11/DHT12 on pin: %d\n", radioConfig.preferences.environmental_measurement_plugin_sensor_pin); return (DHT_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS); case RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_DS18B20: @@ -86,11 +87,12 @@ int32_t EnvironmentalMeasurementPlugin::runOnce() DEBUG_MSG("EnvironmentalMeasurement: Opened DS18B20 on pin: %d\n", radioConfig.preferences.environmental_measurement_plugin_sensor_pin); return (DS18B20_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS); + case RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_DHT21: case RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_DHT22: dht = new DHT(radioConfig.preferences.environmental_measurement_plugin_sensor_pin, DHT22); this->dht->begin(); this->dht->read(); - DEBUG_MSG("EnvironmentalMeasurement: Opened DHT22 on pin: %d\n", + DEBUG_MSG("EnvironmentalMeasurement: Opened DHT21/DHT22 on pin: %d\n", radioConfig.preferences.environmental_measurement_plugin_sensor_pin); return (DHT_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS); default: @@ -136,9 +138,11 @@ int32_t EnvironmentalMeasurementPlugin::runOnce() switch (radioConfig.preferences.environmental_measurement_plugin_sensor_type) { case RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_DHT11: + case RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_DHT12: return (DHT_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS); case RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_DS18B20: return (DS18B20_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS); + case RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_DHT21: case RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_DHT22: return (DHT_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS); default: @@ -254,6 +258,7 @@ bool EnvironmentalMeasurementPlugin::sendOurEnvironmentalMeasurement(NodeNum des switch (radioConfig.preferences.environmental_measurement_plugin_sensor_type) { case RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_DHT11: + case RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_DHT12: if (!this->dht->read(true)) { sensor_read_error_count++; DEBUG_MSG("EnvironmentalMeasurement: FAILED TO READ DATA\n"); @@ -273,6 +278,7 @@ bool EnvironmentalMeasurementPlugin::sendOurEnvironmentalMeasurement(NodeNum des DEBUG_MSG("EnvironmentalMeasurement: FAILED TO READ DATA\n"); return false; } + case RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_DHT21: case RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_DHT22: if (!this->dht->read(true)) { sensor_read_error_count++; From 6d960918e22f3472524d50bcfd6b72dd6b1d963d Mon Sep 17 00:00:00 2001 From: Mike Kinney Date: Sun, 16 Jan 2022 15:22:17 -0800 Subject: [PATCH 3/6] minor change to re-trigger ci --- src/plugins/esp32/EnvironmentalMeasurementPlugin.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/plugins/esp32/EnvironmentalMeasurementPlugin.cpp b/src/plugins/esp32/EnvironmentalMeasurementPlugin.cpp index 7ed2cad09..08056ea5b 100644 --- a/src/plugins/esp32/EnvironmentalMeasurementPlugin.cpp +++ b/src/plugins/esp32/EnvironmentalMeasurementPlugin.cpp @@ -70,6 +70,7 @@ int32_t EnvironmentalMeasurementPlugin::runOnce() // it's possible to have this plugin enabled, only for displaying values on the screen. // therefore, we should only enable the sensor loop if measurement is also enabled switch (radioConfig.preferences.environmental_measurement_plugin_sensor_type) { + case RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_DHT11: case RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_DHT12: dht = new DHT(radioConfig.preferences.environmental_measurement_plugin_sensor_pin, DHT11); From ab87c0a9ee9cc6ec260e4e0e5786cce71c20842c Mon Sep 17 00:00:00 2001 From: Mike Kinney Date: Sun, 16 Jan 2022 23:49:18 +0000 Subject: [PATCH 4/6] updating proto --- proto | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/proto b/proto index d7b2791b7..be14ce595 160000 --- a/proto +++ b/proto @@ -1 +1 @@ -Subproject commit d7b2791b7cf00a4d7be61370fc5cd9554f075585 +Subproject commit be14ce595fc30e1f87f8182fab0a06fd8600cdaa From 1f227797c1d2dca37ee4dfb3b4f35645e97a95b2 Mon Sep 17 00:00:00 2001 From: Mike Kinney Date: Sun, 16 Jan 2022 23:54:10 +0000 Subject: [PATCH 5/6] updated file after updating protobufs --- src/mesh/generated/radioconfig.pb.h | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/mesh/generated/radioconfig.pb.h b/src/mesh/generated/radioconfig.pb.h index 3e6eea360..b6718ab47 100644 --- a/src/mesh/generated/radioconfig.pb.h +++ b/src/mesh/generated/radioconfig.pb.h @@ -92,7 +92,10 @@ typedef enum _InputEventChar { typedef enum _RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType { RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_DHT11 = 0, - RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_DS18B20 = 1 + RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_DS18B20 = 1, + RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_DHT12 = 2, + RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_DHT21 = 3, + RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_DHT22 = 4 } RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType; /* Struct definitions */ @@ -176,7 +179,7 @@ typedef struct _RadioConfig_UserPreferences { InputEventChar rotary1_event_ccw; InputEventChar rotary1_event_press; bool canned_message_plugin_enabled; - char canned_message_plugin_allow_input_origin[16]; + char canned_message_plugin_allow_input_source[16]; char canned_message_plugin_messages[1024]; bool canned_message_plugin_send_bell; } RadioConfig_UserPreferences; @@ -217,8 +220,8 @@ typedef struct _RadioConfig { #define _InputEventChar_ARRAYSIZE ((InputEventChar)(InputEventChar_BACK+1)) #define _RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_MIN RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_DHT11 -#define _RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_MAX RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_DS18B20 -#define _RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_ARRAYSIZE ((RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType)(RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_DS18B20+1)) +#define _RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_MAX RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_DHT22 +#define _RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_ARRAYSIZE ((RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType)(RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_DHT22+1)) #ifdef __cplusplus @@ -310,7 +313,7 @@ extern "C" { #define RadioConfig_UserPreferences_rotary1_event_ccw_tag 165 #define RadioConfig_UserPreferences_rotary1_event_press_tag 166 #define RadioConfig_UserPreferences_canned_message_plugin_enabled_tag 170 -#define RadioConfig_UserPreferences_canned_message_plugin_allow_input_origin_tag 171 +#define RadioConfig_UserPreferences_canned_message_plugin_allow_input_source_tag 171 #define RadioConfig_UserPreferences_canned_message_plugin_messages_tag 172 #define RadioConfig_UserPreferences_canned_message_plugin_send_bell_tag 173 #define RadioConfig_preferences_tag 1 @@ -401,7 +404,7 @@ X(a, STATIC, SINGULAR, UENUM, rotary1_event_cw, 164) \ X(a, STATIC, SINGULAR, UENUM, rotary1_event_ccw, 165) \ X(a, STATIC, SINGULAR, UENUM, rotary1_event_press, 166) \ X(a, STATIC, SINGULAR, BOOL, canned_message_plugin_enabled, 170) \ -X(a, STATIC, SINGULAR, STRING, canned_message_plugin_allow_input_origin, 171) \ +X(a, STATIC, SINGULAR, STRING, canned_message_plugin_allow_input_source, 171) \ X(a, STATIC, SINGULAR, STRING, canned_message_plugin_messages, 172) \ X(a, STATIC, SINGULAR, BOOL, canned_message_plugin_send_bell, 173) #define RadioConfig_UserPreferences_CALLBACK NULL From 6fdc16017a0bbc6fec37ee56414e6597ebf3493f Mon Sep 17 00:00:00 2001 From: Mike Kinney Date: Mon, 17 Jan 2022 02:31:25 +0000 Subject: [PATCH 6/6] revert the cheking for esptool --- bin/device-install.sh | 3 --- 1 file changed, 3 deletions(-) diff --git a/bin/device-install.sh b/bin/device-install.sh index f0157da2d..533361c39 100755 --- a/bin/device-install.sh +++ b/bin/device-install.sh @@ -44,9 +44,6 @@ shift "$((OPTIND-1))" shift } -# check that esptool is installed -"$PYTHON" -m esptool -h >/dev/null 2>&1 || echo "Error: esptool was not found."; exit 1 - if [ -f "${FILENAME}" ]; then echo "Trying to flash ${FILENAME}, but first erasing and writing system information" "$PYTHON" -m esptool erase_flash