diff --git a/bin/platformio-custom.py b/bin/platformio-custom.py index 234b6ef05..3cf45d287 100644 --- a/bin/platformio-custom.py +++ b/bin/platformio-custom.py @@ -17,7 +17,7 @@ Import("projenv") prefsLoc = projenv["PROJECT_DIR"] + "/version.properties" verObj = readProps(prefsLoc) -print("Using meshtastic platformio-custom.py, firmare version " + verObj['long']) +print("Using meshtastic platformio-custom.py, firmware version " + verObj['long']) # print("path is" + ','.join(sys.path)) # General options that are passed to the C and C++ compilers diff --git a/bin/readprops.py b/bin/readprops.py index 25eba4852..c23092e41 100644 --- a/bin/readprops.py +++ b/bin/readprops.py @@ -32,6 +32,6 @@ def readProps(prefsLoc): # traceback.print_exc() verObj['long'] = verObj['short'] - # print("firmare version " + verStr) + # print("firmware version " + verStr) return verObj # print("path is" + ','.join(sys.path)) diff --git a/platformio.ini b/platformio.ini index 5a69e24ab..5dd065503 100644 --- a/platformio.ini +++ b/platformio.ini @@ -78,7 +78,6 @@ lib_deps = [environmental_base] lib_deps = adafruit/Adafruit BusIO@^1.11.4 - adafruit/DHT sensor library@^1.4.1 adafruit/Adafruit Unified Sensor@^1.1.4 paulstoffregen/OneWire@^2.3.5 robtillaart/DS18B20@^0.1.11 diff --git a/protobufs b/protobufs index c63a16c32..8c6ada3df 160000 --- a/protobufs +++ b/protobufs @@ -1 +1 @@ -Subproject commit c63a16c32f0a7b41fc348a8f42c9c13a024d2700 +Subproject commit 8c6ada3df4a9ea17a89d31b4f814d83a3c503b53 diff --git a/src/Power.cpp b/src/Power.cpp index 6d95e2e09..fa09eaeba 100644 --- a/src/Power.cpp +++ b/src/Power.cpp @@ -112,7 +112,18 @@ class AnalogBatteryLevel : public HasBatteryLevel const uint32_t min_read_interval = 5000; if (millis() - last_read_time_ms > min_read_interval) { last_read_time_ms = millis(); + +#ifdef BATTERY_SENSE_SAMPLES +//Set the number of samples, it has an effect of increasing sensitivity, especially in complex electromagnetic environment. + uint32_t raw = 0; + for(uint32_t i=0; ichannelUtilizationPercent() < 40) { + if (node->has_position && (node->position.latitude_i != 0 || node->position.longitude_i != 0)) { + lastGpsSend = now; - lastGpsSend = now; + lastGpsLatitude = node->position.latitude_i; + lastGpsLongitude = node->position.longitude_i; - lastGpsLatitude = node->position.latitude_i; - lastGpsLongitude = node->position.longitude_i; + // If we changed channels, ask everyone else for their latest info + bool requestReplies = currentGeneration != radioGeneration; + currentGeneration = radioGeneration; - // If we changed channels, ask everyone else for their latest info - bool requestReplies = currentGeneration != radioGeneration; - currentGeneration = radioGeneration; - - DEBUG_MSG("Sending pos@%x:6 to mesh (wantReplies=%d)\n", node->position.pos_timestamp, requestReplies); - - sendOurPosition(NODENUM_BROADCAST, requestReplies); + DEBUG_MSG("Sending pos@%x:6 to mesh (wantReplies=%d)\n", node->position.pos_timestamp, requestReplies); + sendOurPosition(NODENUM_BROADCAST, requestReplies); + } } else { - DEBUG_MSG("Channel utilization is >50 percent. Skipping this opportunity to send.\n"); + DEBUG_MSG("Channel utilization is >40 percent. Skipping this opportunity to send.\n"); } } else if (!config.position.position_broadcast_smart_disabled) { diff --git a/src/modules/Telemetry/EnvironmentTelemetry.cpp b/src/modules/Telemetry/EnvironmentTelemetry.cpp index da18ee4e5..1fcc94723 100644 --- a/src/modules/Telemetry/EnvironmentTelemetry.cpp +++ b/src/modules/Telemetry/EnvironmentTelemetry.cpp @@ -13,17 +13,12 @@ // Sensors #include "Sensor/BME280Sensor.h" #include "Sensor/BME680Sensor.h" -#include "Sensor/DHTSensor.h" -#include "Sensor/DallasSensor.h" #include "Sensor/MCP9808Sensor.h" #include "Sensor/INA260Sensor.h" #include "Sensor/INA219Sensor.h" - BME280Sensor bme280Sensor; BME680Sensor bme680Sensor; -DHTSensor dhtSensor; -DallasSensor dallasSensor; MCP9808Sensor mcp9808Sensor; INA260Sensor ina260Sensor; INA219Sensor ina219Sensor; @@ -56,15 +51,9 @@ int32_t EnvironmentTelemetryModule::runOnce() without having to configure it from the PythonAPI or WebUI. */ - /* - moduleConfig.telemetry.environment_measurement_enabled = 1; - moduleConfig.telemetry.environment_screen_enabled = 1; - moduleConfig.telemetry.environment_read_error_count_threshold = 5; - moduleConfig.telemetry.environment_update_interval = 600; - moduleConfig.telemetry.environment_recovery_interval = 60; - moduleConfig.telemetry.environment_sensor_pin = 13; // If one-wire - moduleConfig.telemetry.environment_sensor_type = TelemetrySensorType::TelemetrySensorType_BME280; - */ + // moduleConfig.telemetry.environment_measurement_enabled = 1; + // moduleConfig.telemetry.environment_screen_enabled = 1; + // moduleConfig.telemetry.environment_update_interval = 45; if (!(moduleConfig.telemetry.environment_measurement_enabled || moduleConfig.telemetry.environment_screen_enabled)) { @@ -80,21 +69,6 @@ int32_t EnvironmentTelemetryModule::runOnce() DEBUG_MSG("Environment Telemetry: Initializing\n"); // it's possible to have this module enabled, only for displaying values on the screen. // therefore, we should only enable the sensor loop if measurement is also enabled - - switch (moduleConfig.telemetry.environment_sensor_type) { - case TelemetrySensorType_DHT11: - case TelemetrySensorType_DHT12: - case TelemetrySensorType_DHT21: - case TelemetrySensorType_DHT22: - result = dhtSensor.runOnce(); - break; - case TelemetrySensorType_DS18B20: - result = dallasSensor.runOnce(); - break; - default: - DEBUG_MSG("Environment Telemetry: No sensor type specified; Checking for detected i2c sensors\n"); - break; - } if (bme680Sensor.hasSensor()) result = bme680Sensor.runOnce(); if (bme280Sensor.hasSensor()) @@ -113,26 +87,6 @@ int32_t EnvironmentTelemetryModule::runOnce() return result; // this is not the first time OSThread library has called this function // so just do what we intend to do on the interval - if (sensor_read_error_count > moduleConfig.telemetry.environment_read_error_count_threshold) { - if (moduleConfig.telemetry.environment_recovery_interval > 0) { - DEBUG_MSG("Environment Telemetry: TEMPORARILY DISABLED; The " - "telemetry_module_environment_read_error_count_threshold has been exceed: %d. Will retry reads in " - "%d seconds\n", - moduleConfig.telemetry.environment_read_error_count_threshold, - moduleConfig.telemetry.environment_recovery_interval); - sensor_read_error_count = 0; - return (moduleConfig.telemetry.environment_recovery_interval * 1000); - } - DEBUG_MSG("Environment Telemetry: DISABLED; The telemetry_module_environment_read_error_count_threshold has " - "been exceed: %d. Reads will not be retried until after device reset\n", - moduleConfig.telemetry.environment_read_error_count_threshold); - return result; - - } else if (sensor_read_error_count > 0) { - DEBUG_MSG("Environment Telemetry: There have been %d sensor read failures. Will retry %d more times\n", - sensor_read_error_count, sensor_read_error_count, sensor_read_error_count, - moduleConfig.telemetry.environment_read_error_count_threshold - sensor_read_error_count); - } if (!sendOurTelemetry()) { // if we failed to read the sensor, then try again // as soon as we can according to the maximum polling frequency @@ -242,21 +196,6 @@ bool EnvironmentTelemetryModule::sendOurTelemetry(NodeNum dest, bool wantReplies DEBUG_MSG("-----------------------------------------\n"); DEBUG_MSG("Environment Telemetry: Read data\n"); - switch (moduleConfig.telemetry.environment_sensor_type) { - case TelemetrySensorType_DS18B20: - if (!dallasSensor.getMetrics(&m)) - sensor_read_error_count++; - break; - case TelemetrySensorType_DHT11: - case TelemetrySensorType_DHT12: - case TelemetrySensorType_DHT21: - case TelemetrySensorType_DHT22: - if (!dhtSensor.getMetrics(&m)) - sensor_read_error_count++; - break; - default: - DEBUG_MSG("Environment Telemetry: No specified sensor type; Trying any detected i2c sensors\n"); - } if (bme280Sensor.hasSensor()) bme280Sensor.getMetrics(&m); if (bme680Sensor.hasSensor()) diff --git a/src/modules/Telemetry/Sensor/DHTSensor.cpp b/src/modules/Telemetry/Sensor/DHTSensor.cpp deleted file mode 100644 index 999db7761..000000000 --- a/src/modules/Telemetry/Sensor/DHTSensor.cpp +++ /dev/null @@ -1,39 +0,0 @@ -#include "DHTSensor.h" -#include "./mesh/generated/telemetry.pb.h" -#include "MeshService.h" -#include "TelemetrySensor.h" -#include "configuration.h" -#include - -DHTSensor::DHTSensor() : - TelemetrySensor(TelemetrySensorType_NotSet, "DHT") -{ -} - -int32_t DHTSensor::runOnce() { - if (moduleConfig.telemetry.environment_sensor_type == TelemetrySensorType_DHT11 || - moduleConfig.telemetry.environment_sensor_type == TelemetrySensorType_DHT12) { - dht = new DHT(moduleConfig.telemetry.environment_sensor_pin, DHT11); - } else { - dht = new DHT(moduleConfig.telemetry.environment_sensor_pin, DHT22); - } - - dht->begin(); - dht->read(); - DEBUG_MSG("Opened DHT11/DHT12 on pin: %d\n", moduleConfig.telemetry.environment_sensor_pin); - - return DEFAULT_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS; -} - -void DHTSensor::setup() { } - -bool DHTSensor::getMetrics(Telemetry *measurement) { - DEBUG_MSG("DHTSensor::getMetrics\n"); - if (!dht->read(true)) { - DEBUG_MSG("Telemetry: FAILED TO READ DATA\n"); - return false; - } - measurement->variant.environment_metrics.relative_humidity = dht->readHumidity(); - measurement->variant.environment_metrics.temperature = dht->readTemperature(); - return true; -} \ No newline at end of file diff --git a/src/modules/Telemetry/Sensor/DHTSensor.h b/src/modules/Telemetry/Sensor/DHTSensor.h deleted file mode 100644 index cb26e66e7..000000000 --- a/src/modules/Telemetry/Sensor/DHTSensor.h +++ /dev/null @@ -1,16 +0,0 @@ -#include "../mesh/generated/telemetry.pb.h" -#include "TelemetrySensor.h" -#include - -class DHTSensor : virtual public TelemetrySensor { -private: - DHT *dht = NULL; - -protected: - virtual void setup() override; - -public: - DHTSensor(); - virtual int32_t runOnce() override; - virtual bool getMetrics(Telemetry *measurement) override; -}; \ No newline at end of file diff --git a/src/modules/Telemetry/Sensor/DallasSensor.cpp b/src/modules/Telemetry/Sensor/DallasSensor.cpp deleted file mode 100644 index 61852de4d..000000000 --- a/src/modules/Telemetry/Sensor/DallasSensor.cpp +++ /dev/null @@ -1,35 +0,0 @@ -#include "DallasSensor.h" -#include "../mesh/generated/telemetry.pb.h" -#include "MeshService.h" -#include "TelemetrySensor.h" -#include "configuration.h" -#include -#include - -DallasSensor::DallasSensor() : - TelemetrySensor(TelemetrySensorType_DS18B20, "DS18B20") -{ -} - -int32_t DallasSensor::runOnce() { - oneWire = new OneWire(moduleConfig.telemetry.environment_sensor_pin); - ds18b20 = new DS18B20(oneWire); - ds18b20->begin(); - ds18b20->setResolution(12); - ds18b20->requestTemperatures(); - DEBUG_MSG("Opened DS18B20 on pin: %d\n", moduleConfig.telemetry.environment_sensor_pin); - return DEFAULT_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS; -} - -void DallasSensor::setup() {} - -bool DallasSensor::getMetrics(Telemetry *measurement){ - DEBUG_MSG("DallasSensor::getMetrics\n"); - if (ds18b20->isConversionComplete()) { - measurement->variant.environment_metrics.temperature = ds18b20->getTempC(); - measurement->variant.environment_metrics.relative_humidity = 0; - ds18b20->requestTemperatures(); - return true; - } - return false; -} \ No newline at end of file diff --git a/src/modules/Telemetry/Sensor/DallasSensor.h b/src/modules/Telemetry/Sensor/DallasSensor.h deleted file mode 100644 index c33da3c1c..000000000 --- a/src/modules/Telemetry/Sensor/DallasSensor.h +++ /dev/null @@ -1,18 +0,0 @@ -#include "../mesh/generated/telemetry.pb.h" -#include "TelemetrySensor.h" -#include -#include - -class DallasSensor : virtual public TelemetrySensor { -private: - OneWire *oneWire = NULL; - DS18B20 *ds18b20 = NULL; - -protected: - virtual void setup() override; - -public: - DallasSensor(); - virtual int32_t runOnce() override; - virtual bool getMetrics(Telemetry *measurement) override; -}; \ No newline at end of file diff --git a/variants/rak4631/platformio.ini b/variants/rak4631/platformio.ini index 5671aae4d..d8e2ba3e9 100644 --- a/variants/rak4631/platformio.ini +++ b/variants/rak4631/platformio.ini @@ -1,4 +1,4 @@ -; The very slick RAK wireless RAK 4631 / 4630 board - Unified firmare for 5005/19003, with or without OLED RAK 1921 +; The very slick RAK wireless RAK 4631 / 4630 board - Unified firmware for 5005/19003, with or without OLED RAK 1921 [env:rak4631] extends = nrf52840_base board = wiscore_rak4631