From 6dea4681e4cee6a3225584e7b76181b90b079e77 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Thu, 25 Sep 2025 11:33:09 -0400 Subject: [PATCH 001/533] Remove unused countMaxToAverage and _maxSamplesToAverage Signed-off-by: Sara Damiano --- src/VariableArray.cpp | 19 ------------------- src/VariableArray.h | 11 ----------- 2 files changed, 30 deletions(-) diff --git a/src/VariableArray.cpp b/src/VariableArray.cpp index b713b4e69..9a03e4b8c 100644 --- a/src/VariableArray.cpp +++ b/src/VariableArray.cpp @@ -16,14 +16,12 @@ VariableArray::VariableArray() {} VariableArray::VariableArray(uint8_t variableCount, Variable* variableList[]) : arrayOfVars(variableList), _variableCount(variableCount) { - _maxSamplesToAverage = countMaxToAverage(); _sensorCount = getSensorCount(); } VariableArray::VariableArray(uint8_t variableCount, Variable* variableList[], const char* uuids[]) : arrayOfVars(variableList), _variableCount(variableCount) { - _maxSamplesToAverage = countMaxToAverage(); _sensorCount = getSensorCount(); matchUUIDs(uuids); } @@ -36,7 +34,6 @@ void VariableArray::begin(uint8_t variableCount, Variable* variableList[], _variableCount = variableCount; arrayOfVars = variableList; - _maxSamplesToAverage = countMaxToAverage(); _sensorCount = getSensorCount(); matchUUIDs(uuids); checkVariableUUIDs(); @@ -45,12 +42,10 @@ void VariableArray::begin(uint8_t variableCount, Variable* variableList[]) { _variableCount = variableCount; arrayOfVars = variableList; - _maxSamplesToAverage = countMaxToAverage(); _sensorCount = getSensorCount(); checkVariableUUIDs(); } void VariableArray::begin() { - _maxSamplesToAverage = countMaxToAverage(); _sensorCount = getSensorCount(); checkVariableUUIDs(); } @@ -922,20 +917,6 @@ bool VariableArray::getSensorStatusBit(int arrayIndex, return arrayOfVars[arrayIndex]->parentSensor->getStatusBit(bitToGet); } -// Count the maximum number of measurements needed from a single sensor for the -// requested averaging -uint8_t VariableArray::countMaxToAverage(void) { - uint8_t numReps = 0; - for (uint8_t i = 0; i < _variableCount; i++) { - if (isLastVarFromSensor(i)) { // Skip non-unique sensors - numReps = max( - numReps, - arrayOfVars[i]->parentSensor->getNumberMeasurementsToAverage()); - } - } - return numReps; -} - // Check that all variable have valid UUID's, if they are assigned bool VariableArray::checkVariableUUIDs(void) { diff --git a/src/VariableArray.h b/src/VariableArray.h index 777916723..725d065dc 100644 --- a/src/VariableArray.h +++ b/src/VariableArray.h @@ -283,10 +283,6 @@ class VariableArray { * @brief The count of unique sensors tied to variables in the array */ uint8_t _sensorCount; - /** - * @brief The maximum number of samples to average of an single sensor. - */ - uint8_t _maxSamplesToAverage; private: /** @@ -300,13 +296,6 @@ class VariableArray { * @return True if the variable is the last in the array. */ bool isLastVarFromSensor(int arrayIndex); - /** - * @brief Count the maximum number of measurements needed from a single - * sensor for the requested averaging - * - * @return The number of measurements needed. - */ - uint8_t countMaxToAverage(void); /** * @brief Check that all variable have valid UUID's, if they are assigned * From e1fc8d03efdbc87a0641a964fa2ce75bb2985499 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Thu, 25 Sep 2025 14:56:47 -0400 Subject: [PATCH 002/533] Add _measurementAttemptsCompleted and bump it where failure Signed-off-by: Sara Damiano --- src/SensorBase.cpp | 4 +++ src/SensorBase.h | 47 ++++++++++++++++++++++++---------- src/sensors/ANBpH.cpp | 4 +++ src/sensors/AtlasParent.cpp | 5 ++++ src/sensors/BoschBMP3xx.cpp | 3 +++ src/sensors/GeoluxHydroCam.cpp | 7 +++++ src/sensors/MaximDS18.cpp | 4 +++ src/sensors/MaximDS3231.cpp | 3 +++ src/sensors/SDI12Sensors.cpp | 8 ++++++ 9 files changed, 72 insertions(+), 13 deletions(-) diff --git a/src/SensorBase.cpp b/src/SensorBase.cpp index 2d36484ff..05e229bc4 100644 --- a/src/SensorBase.cpp +++ b/src/SensorBase.cpp @@ -256,6 +256,10 @@ bool Sensor::startSingleMeasurement(void) { _millisMeasurementRequested = 0; clearStatusBit(MEASUREMENT_SUCCESSFUL); success = false; + // Bump the number of measurement attempts completed - since the start + // failed, we now consider the attempt complete. + // NOTE: Don't bump the successful measurements count! + _measurementAttemptsCompleted++; } return success; } diff --git a/src/SensorBase.h b/src/SensorBase.h index 44e77fdc2..c996d35f4 100644 --- a/src/SensorBase.h +++ b/src/SensorBase.h @@ -393,6 +393,11 @@ class Sensor { * @todo Support int16_t and int32_t directly in the value array so no * casting is needed. This could be done using a template or a union similar * to the modbus library's leFrame union. + * + * @note The values in this array will not be usable until after the sensor + * completes all requested measurements! Prior to that, the values in this + * array will be the sum of all good values measured so far (or -9999 if no + * good values have been measured yet). */ float sensorValues[MAX_NUMBER_VARS]; @@ -538,6 +543,16 @@ class Sensor { * are *included* in this total. */ const uint8_t _numReturnedValues; + /** + * @brief The number of included calculated variables from the sensor, if + * any. + * + * These are used for values that we would always calculate for a sensor and + * depend only on the raw results of that single sensor. This is separate + * from any calculated variables that are created on-the-fly and depend on + * multiple other sensors. + */ + uint8_t _incCalcValues; /** * @brief The number of measurements from the sensor to average. * @@ -549,18 +564,23 @@ class Sensor { */ uint8_t _measurementsToAverage; /** - * @brief The number of included calculated variables from the - * sensor, if any. - * - * These are used for values that we would always calculate for a sensor and - * depend only on the raw results of that single sensor. This is separate - * from any calculated variables that are created on-the-fly and depend on - * multiple other sensors. + * @brief The number of measurements attempts by the sensor that have + * finished **since last power on**. */ - uint8_t _incCalcValues; + uint8_t _measurementAttemptsCompleted = 0; /** - * @brief Array with the number of valid measurement values taken by the - * sensor in the current update cycle. + * @brief The number of measurements that have been **successfully** + * completed by the sensor **since last power on**. + */ + uint8_t _measurementsSucceeded = 0; + /** + * @brief Array with the number of valid measurement values per variable by + * the sensor in the current update cycle. + * + * @note The number of good measurements may vary between variables if + * some values are more likely to be invalid than others - ie, a pH sensor + * may also measure temperature and report a valid temperature when the pH + * is junk. */ uint8_t numberGoodMeasurementsMade[MAX_NUMBER_VARS]; @@ -615,9 +635,10 @@ class Sensor { /** * @brief An array for each sensor containing pointers to the variable - * objects tied to that sensor. The #MAX_NUMBER_VARS cannot be determined - * on a per-sensor basis, because of the way memory is used on an Arduino. - * It must be defined once for the whole class. + * objects tied to that sensor. + * + * The #MAX_NUMBER_VARS cannot be determined on a per-sensor basis; it must + * be defined at compile time and applied to the entire class. */ Variable* variables[MAX_NUMBER_VARS]; }; diff --git a/src/sensors/ANBpH.cpp b/src/sensors/ANBpH.cpp index 2aafc3b90..7773600ef 100644 --- a/src/sensors/ANBpH.cpp +++ b/src/sensors/ANBpH.cpp @@ -222,6 +222,10 @@ bool ANBpH::startSingleMeasurement(void) { F("did not successfully start a measurement.")); _millisMeasurementRequested = 0; clearStatusBit(MEASUREMENT_SUCCESSFUL); + // Bump the number of measurement attempts completed - since the start + // failed, we now consider the attempt complete. + // NOTE: Don't bump the successful measurements count! + _measurementAttemptsCompleted++; } return success; diff --git a/src/sensors/AtlasParent.cpp b/src/sensors/AtlasParent.cpp index e1a307217..017913f88 100644 --- a/src/sensors/AtlasParent.cpp +++ b/src/sensors/AtlasParent.cpp @@ -129,6 +129,11 @@ bool AtlasParent::startSingleMeasurement(void) { F("did not successfully start a measurement.")); _millisMeasurementRequested = 0; clearStatusBit(MEASUREMENT_SUCCESSFUL); + // Bump the number of measurement attempts completed - since the start + // failed, we now consider the attempt complete. + // NOTE: Don't bump the + // successful measurements count! + _measurementAttemptsCompleted++; } return success; diff --git a/src/sensors/BoschBMP3xx.cpp b/src/sensors/BoschBMP3xx.cpp index e0d8463eb..4ff6c521b 100644 --- a/src/sensors/BoschBMP3xx.cpp +++ b/src/sensors/BoschBMP3xx.cpp @@ -270,6 +270,9 @@ bool BoschBMP3xx::startSingleMeasurement(void) { _millisMeasurementRequested = millis(); } + // NOTE: There's no possibility of failure here - we always return true. + // There's no condition where we would need to bump the number of completed + // measurement attempts here. return true; } diff --git a/src/sensors/GeoluxHydroCam.cpp b/src/sensors/GeoluxHydroCam.cpp index a1ebf235c..a5dddcae1 100644 --- a/src/sensors/GeoluxHydroCam.cpp +++ b/src/sensors/GeoluxHydroCam.cpp @@ -156,6 +156,10 @@ bool GeoluxHydroCam::startSingleMeasurement(void) { // unset _millisMeasurementRequested = 0; clearStatusBit(MEASUREMENT_SUCCESSFUL); + // Bump the number of measurement attempts completed - since the start + // failed, we now consider the attempt complete. + // NOTE: Don't bump the successful measurements count! + _measurementAttemptsCompleted++; return false; } @@ -178,6 +182,9 @@ bool GeoluxHydroCam::startSingleMeasurement(void) { F("did not successfully start a measurement.")); _millisMeasurementRequested = 0; clearStatusBit(MEASUREMENT_SUCCESSFUL); + // Bump the number of measurement attempts completed + // NOTE: Don't bump the successful measurements count! + _measurementAttemptsCompleted++; } return true; diff --git a/src/sensors/MaximDS18.cpp b/src/sensors/MaximDS18.cpp index 4d37d51b7..ddbabf4f3 100644 --- a/src/sensors/MaximDS18.cpp +++ b/src/sensors/MaximDS18.cpp @@ -172,6 +172,10 @@ bool MaximDS18::startSingleMeasurement(void) { F("did not successfully start a measurement.")); _millisMeasurementRequested = 0; clearStatusBit(MEASUREMENT_SUCCESSFUL); + // Bump the number of measurement attempts completed - since the start + // failed, we now consider the attempt complete. + // NOTE: Don't bump the successful measurements count! + _measurementAttemptsCompleted++; } return success; diff --git a/src/sensors/MaximDS3231.cpp b/src/sensors/MaximDS3231.cpp index 32debf783..3070c325b 100644 --- a/src/sensors/MaximDS3231.cpp +++ b/src/sensors/MaximDS3231.cpp @@ -46,6 +46,9 @@ bool MaximDS3231::startSingleMeasurement(void) { MS_DBG(F("Forcing new temperature reading by DS3231")); rtc.convertTemperature(false); + // NOTE: There's no possibility of failure here - we always return true. + // There's no condition where we would need to bump the number of completed + // measurement attempts here. return true; } diff --git a/src/sensors/SDI12Sensors.cpp b/src/sensors/SDI12Sensors.cpp index 3932ac26d..596be3e2f 100644 --- a/src/sensors/SDI12Sensors.cpp +++ b/src/sensors/SDI12Sensors.cpp @@ -390,6 +390,10 @@ bool SDI12Sensors::startSingleMeasurement(void) { _millisMeasurementRequested = 0; clearStatusBit(MEASUREMENT_SUCCESSFUL); deactivate(); + // Bump the number of measurement attempts completed - since the start + // failed, we now consider the attempt complete. + // NOTE: Don't bump the successful measurements count! + _measurementAttemptsCompleted++; return false; } @@ -415,6 +419,10 @@ bool SDI12Sensors::startSingleMeasurement(void) { F("did not respond to measurement request!")); _millisMeasurementRequested = 0; clearStatusBit(MEASUREMENT_SUCCESSFUL); + // Bump the number of measurement attempts completed - since the start + // failed, we now consider the attempt complete. + // NOTE: Don't bump the successful measurements count! + _measurementAttemptsCompleted++; return false; } } From 0b52e0f0c2dd8ea7ec61b32fecac15c8a85a9d10 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Thu, 25 Sep 2025 14:57:04 -0400 Subject: [PATCH 003/533] Fix hydrocam return value on start measurement Signed-off-by: Sara Damiano --- src/sensors/GeoluxHydroCam.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/sensors/GeoluxHydroCam.cpp b/src/sensors/GeoluxHydroCam.cpp index a5dddcae1..7d6a69f1b 100644 --- a/src/sensors/GeoluxHydroCam.cpp +++ b/src/sensors/GeoluxHydroCam.cpp @@ -187,7 +187,7 @@ bool GeoluxHydroCam::startSingleMeasurement(void) { _measurementAttemptsCompleted++; } - return true; + return success; } @@ -316,6 +316,9 @@ void GeoluxHydroCam::powerDown(void) { _millisSensorActivated = 0; // Unset the measurement request time _millisMeasurementRequested = 0; + // Unset the number of measurements attempted and succeeded + _measurementAttemptsCompleted = 0; + _measurementsSucceeded = 0; // Unset the status bits for sensor power (bits 1 & 2), // activation (bits 3 & 4), and measurement request (bits 5 & 6) clearStatusBits(POWER_ATTEMPTED, POWER_SUCCESSFUL, WAKE_ATTEMPTED, From e07f84e681519bdc71dba6bc1a3ab137cea240a5 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Thu, 25 Sep 2025 15:04:43 -0400 Subject: [PATCH 004/533] Clear attempts and completions at sleep and power down Signed-off-by: Sara Damiano --- src/SensorBase.cpp | 3 +++ src/sensors/ANBpH.cpp | 6 ++++++ src/sensors/AtlasParent.cpp | 3 +++ src/sensors/GroPointParent.cpp | 6 ++++++ src/sensors/KellerParent.cpp | 3 +++ src/sensors/SensirionSHT4x.cpp | 3 +++ src/sensors/YosemitechParent.cpp | 6 ++++++ 7 files changed, 30 insertions(+) diff --git a/src/SensorBase.cpp b/src/SensorBase.cpp index 05e229bc4..de6c320e8 100644 --- a/src/SensorBase.cpp +++ b/src/SensorBase.cpp @@ -139,6 +139,9 @@ void Sensor::powerDown(void) { clearStatusBits(POWER_ATTEMPTED, POWER_SUCCESSFUL, WAKE_ATTEMPTED, WAKE_SUCCESSFUL, MEASUREMENT_ATTEMPTED, MEASUREMENT_SUCCESSFUL); + // Unset the number of measurements attempted and succeeded + _measurementAttemptsCompleted = 0; + _measurementsSucceeded = 0; } else { MS_DBG(F("Power to"), getSensorNameAndLocation(), F("is not controlled by this library.")); diff --git a/src/sensors/ANBpH.cpp b/src/sensors/ANBpH.cpp index 7773600ef..01196f145 100644 --- a/src/sensors/ANBpH.cpp +++ b/src/sensors/ANBpH.cpp @@ -292,6 +292,9 @@ bool ANBpH::sleep(void) { _millisSensorActivated = 0; // Unset the measurement request time _millisMeasurementRequested = 0; + // Unset the number of measurements attempted and succeeded + _measurementAttemptsCompleted = 0; + _measurementsSucceeded = 0; // Unset the status bits for sensor activation (bits 3 & 4) and // measurement request (bits 5 & 6) clearStatusBits(WAKE_ATTEMPTED, WAKE_SUCCESSFUL, MEASUREMENT_ATTEMPTED, @@ -355,6 +358,9 @@ void ANBpH::powerDown(void) { _millisSensorActivated = 0; // Unset the measurement request time _millisMeasurementRequested = 0; + // Unset the number of measurements attempted and succeeded + _measurementAttemptsCompleted = 0; + _measurementsSucceeded = 0; // Unset the status bits for sensor power (bits 1 & 2), // activation (bits 3 & 4), and measurement request (bits 5 & 6) clearStatusBits(POWER_ATTEMPTED, POWER_SUCCESSFUL, WAKE_ATTEMPTED, diff --git a/src/sensors/AtlasParent.cpp b/src/sensors/AtlasParent.cpp index 017913f88..20e91af47 100644 --- a/src/sensors/AtlasParent.cpp +++ b/src/sensors/AtlasParent.cpp @@ -84,6 +84,9 @@ bool AtlasParent::sleep(void) { _millisSensorActivated = 0; // Unset the measurement request time _millisMeasurementRequested = 0; + // Unset the number of measurements attempted and succeeded + _measurementAttemptsCompleted = 0; + _measurementsSucceeded = 0; // Unset the status bits for sensor activation (bits 3 & 4) and // measurement request (bits 5 & 6) clearStatusBits(WAKE_ATTEMPTED, WAKE_SUCCESSFUL, MEASUREMENT_ATTEMPTED, diff --git a/src/sensors/GroPointParent.cpp b/src/sensors/GroPointParent.cpp index 96d941703..a6c709ebe 100644 --- a/src/sensors/GroPointParent.cpp +++ b/src/sensors/GroPointParent.cpp @@ -141,6 +141,9 @@ bool GroPointParent::sleep(void) { _millisSensorActivated = 0; // Unset the measurement request time _millisMeasurementRequested = 0; + // Unset the number of measurements attempted and succeeded + _measurementAttemptsCompleted = 0; + _measurementsSucceeded = 0; // Unset the status bits for sensor activation (bits 3 & 4) and // measurement request (bits 5 & 6) clearStatusBits(WAKE_ATTEMPTED, WAKE_SUCCESSFUL, MEASUREMENT_ATTEMPTED, @@ -204,6 +207,9 @@ void GroPointParent::powerDown(void) { _millisSensorActivated = 0; // Unset the measurement request time _millisMeasurementRequested = 0; + // Unset the number of measurements attempted and succeeded + _measurementAttemptsCompleted = 0; + _measurementsSucceeded = 0; // Unset the status bits for sensor power (bits 1 & 2), // activation (bits 3 & 4), and measurement request (bits 5 & 6) clearStatusBits(POWER_ATTEMPTED, POWER_SUCCESSFUL, WAKE_ATTEMPTED, diff --git a/src/sensors/KellerParent.cpp b/src/sensors/KellerParent.cpp index e8a657441..aa6518e0b 100644 --- a/src/sensors/KellerParent.cpp +++ b/src/sensors/KellerParent.cpp @@ -131,6 +131,9 @@ void KellerParent::powerDown(void) { _millisSensorActivated = 0; // Unset the measurement request time _millisMeasurementRequested = 0; + // Unset the number of measurements attempted and succeeded + _measurementAttemptsCompleted = 0; + _measurementsSucceeded = 0; // Unset the status bits for sensor power (bits 1 & 2), // activation (bits 3 & 4), and measurement request (bits 5 & 6) clearStatusBits(POWER_ATTEMPTED, POWER_SUCCESSFUL, WAKE_ATTEMPTED, diff --git a/src/sensors/SensirionSHT4x.cpp b/src/sensors/SensirionSHT4x.cpp index 6455d3964..d30bcc37b 100644 --- a/src/sensors/SensirionSHT4x.cpp +++ b/src/sensors/SensirionSHT4x.cpp @@ -173,6 +173,9 @@ bool SensirionSHT4x::sleep(void) { _millisSensorActivated = 0; // Unset the measurement request time _millisMeasurementRequested = 0; + // Unset the number of measurements attempted and succeeded + _measurementAttemptsCompleted = 0; + _measurementsSucceeded = 0; // Unset the status bits for sensor activation (bits 3 & 4) and // measurement request (bits 5 & 6) clearStatusBits(WAKE_ATTEMPTED, WAKE_SUCCESSFUL, MEASUREMENT_ATTEMPTED, diff --git a/src/sensors/YosemitechParent.cpp b/src/sensors/YosemitechParent.cpp index 3ff15d997..e231148ae 100644 --- a/src/sensors/YosemitechParent.cpp +++ b/src/sensors/YosemitechParent.cpp @@ -150,6 +150,9 @@ bool YosemitechParent::sleep(void) { _millisSensorActivated = 0; // Unset the measurement request time _millisMeasurementRequested = 0; + // Unset the number of measurements attempted and succeeded + _measurementAttemptsCompleted = 0; + _measurementsSucceeded = 0; // Unset the status bits for sensor activation (bits 3 & 4) and // measurement request (bits 5 & 6) clearStatusBits(WAKE_ATTEMPTED, WAKE_SUCCESSFUL, MEASUREMENT_ATTEMPTED, @@ -213,6 +216,9 @@ void YosemitechParent::powerDown(void) { _millisSensorActivated = 0; // Unset the measurement request time _millisMeasurementRequested = 0; + // Unset the number of measurements attempted and succeeded + _measurementAttemptsCompleted = 0; + _measurementsSucceeded = 0; // Unset the status bits for sensor power (bits 1 & 2), // activation (bits 3 & 4), and measurement request (bits 5 & 6) clearStatusBits(POWER_ATTEMPTED, POWER_SUCCESSFUL, WAKE_ATTEMPTED, From d7350a7f41508613cab7fe94215ebf4d1052d26b Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Thu, 25 Sep 2025 16:04:14 -0400 Subject: [PATCH 005/533] Bump completion and success in add result fxn (not start fxn) Signed-off-by: Sara Damiano --- src/SensorBase.cpp | 4 ---- src/sensors/ANBpH.cpp | 17 +++++++++++++---- src/sensors/AOSongAM2315.cpp | 6 ++++++ src/sensors/AOSongDHT.cpp | 8 ++++++++ src/sensors/AlphasenseCO2.cpp | 4 ++++ src/sensors/AnalogElecConductivity.cpp | 7 +++++++ src/sensors/ApogeeSQ212.cpp | 5 +++++ src/sensors/AtlasParent.cpp | 14 +++++++++----- src/sensors/BoschBME280.cpp | 9 +++++++++ src/sensors/BoschBMP3xx.cpp | 9 +++++++++ src/sensors/CampbellOBS3.cpp | 4 ++++ src/sensors/EverlightALSPT19.cpp | 6 ++++++ src/sensors/FreescaleMPL115A2.cpp | 9 ++++++++- src/sensors/GeoluxHydroCam.cpp | 16 +++++++++------- src/sensors/GroPointParent.cpp | 7 +++++++ src/sensors/KellerParent.cpp | 11 +++++++++++ src/sensors/MaxBotixSonar.cpp | 8 ++++++++ src/sensors/MaximDS18.cpp | 11 +++++++---- src/sensors/MaximDS3231.cpp | 6 ++++++ src/sensors/MeaSpecMS5803.cpp | 9 +++++++++ src/sensors/PaleoTerraRedox.cpp | 7 +++++++ src/sensors/ProcessorStats.cpp | 6 ++++++ src/sensors/RainCounterI2C.cpp | 9 +++++++++ src/sensors/SDI12Sensors.cpp | 22 ++++++++++++++-------- src/sensors/SensirionSHT4x.cpp | 9 +++++++++ src/sensors/TIADS1x15.cpp | 4 ++++ src/sensors/TIINA219.cpp | 10 ++++++++++ src/sensors/TallyCounterI2C.cpp | 7 +++++++ src/sensors/TurnerCyclops.cpp | 4 ++++ src/sensors/TurnerTurbidityPlus.cpp | 4 ++++ src/sensors/YosemitechParent.cpp | 7 +++++++ 31 files changed, 226 insertions(+), 33 deletions(-) diff --git a/src/SensorBase.cpp b/src/SensorBase.cpp index de6c320e8..8c3bcc2f6 100644 --- a/src/SensorBase.cpp +++ b/src/SensorBase.cpp @@ -259,10 +259,6 @@ bool Sensor::startSingleMeasurement(void) { _millisMeasurementRequested = 0; clearStatusBit(MEASUREMENT_SUCCESSFUL); success = false; - // Bump the number of measurement attempts completed - since the start - // failed, we now consider the attempt complete. - // NOTE: Don't bump the successful measurements count! - _measurementAttemptsCompleted++; } return success; } diff --git a/src/sensors/ANBpH.cpp b/src/sensors/ANBpH.cpp index 01196f145..4544e6dce 100644 --- a/src/sensors/ANBpH.cpp +++ b/src/sensors/ANBpH.cpp @@ -222,10 +222,6 @@ bool ANBpH::startSingleMeasurement(void) { F("did not successfully start a measurement.")); _millisMeasurementRequested = 0; clearStatusBit(MEASUREMENT_SUCCESSFUL); - // Bump the number of measurement attempts completed - since the start - // failed, we now consider the attempt complete. - // NOTE: Don't bump the successful measurements count! - _measurementAttemptsCompleted++; } return success; @@ -452,6 +448,19 @@ bool ANBpH::addSingleMeasurementResult(void) { _millisMeasurementRequested = 0; // Unset the status bits for a measurement request (bits 5 & 6) clearStatusBits(MEASUREMENT_ATTEMPTED, MEASUREMENT_SUCCESSFUL); + // Bump the number of completed measurement attempts + _measurementAttemptsCompleted++; + + // We consider a measurement successful if we got a modbus response and + // the pH value is in range or the health code says the sensor is not + // immersed. We accept the not immersed condition as a successful + // measurement because the sensor will not retry for at least 5 minutes + // after an immersion error. + if (success && + ((0.0 < pH && pH < 14.00) || health == ANBHealthCode::NOT_IMMERSED)) { + // Bump the number of successful measurements + _measurementsSucceeded++; + } // Return true when finished return success; diff --git a/src/sensors/AOSongAM2315.cpp b/src/sensors/AOSongAM2315.cpp index c28f13436..097b8091c 100644 --- a/src/sensors/AOSongAM2315.cpp +++ b/src/sensors/AOSongAM2315.cpp @@ -79,6 +79,12 @@ bool AOSongAM2315::addSingleMeasurementResult(void) { _millisMeasurementRequested = 0; // Unset the status bits for a measurement request (bits 5 & 6) clearStatusBits(MEASUREMENT_ATTEMPTED, MEASUREMENT_SUCCESSFUL); + // Bump the number of completed measurement attempts + _measurementAttemptsCompleted++; + if (ret_val && !isnan(temp_val) && !isnan(humid_val)) { + // Bump the number of successful measurements + _measurementsSucceeded++; + } return ret_val; } diff --git a/src/sensors/AOSongDHT.cpp b/src/sensors/AOSongDHT.cpp index 76886214e..a8e7d3cb2 100644 --- a/src/sensors/AOSongDHT.cpp +++ b/src/sensors/AOSongDHT.cpp @@ -72,6 +72,7 @@ bool AOSongDHT::addSingleMeasurementResult(void) { success = true; break; } else { + /// @todo align retries with other sensors? if (i < 4) { MS_DBG(F(" Failed to read from DHT sensor, Retrying...")); delay(100); @@ -95,6 +96,13 @@ bool AOSongDHT::addSingleMeasurementResult(void) { _millisMeasurementRequested = 0; // Unset the status bits for a measurement request (bits 5 & 6) clearStatusBits(MEASUREMENT_ATTEMPTED, MEASUREMENT_SUCCESSFUL); + // Bump the number of completed measurement attempts + _measurementAttemptsCompleted++; + + if (success && !isnan(temp_val) && !isnan(humid_val)) { + // Bump the number of successful measurements + _measurementsSucceeded++; + } return success; } diff --git a/src/sensors/AlphasenseCO2.cpp b/src/sensors/AlphasenseCO2.cpp index 4269cf28d..d27af1c5c 100644 --- a/src/sensors/AlphasenseCO2.cpp +++ b/src/sensors/AlphasenseCO2.cpp @@ -112,8 +112,12 @@ bool AlphasenseCO2::addSingleMeasurementResult(void) { _millisMeasurementRequested = 0; // Unset the status bits for a measurement request (bits 5 & 6) clearStatusBits(MEASUREMENT_ATTEMPTED, MEASUREMENT_SUCCESSFUL); + // Bump the number of completed measurement attempts + _measurementAttemptsCompleted++; if (adcVoltage < 3.6 && adcVoltage > -0.3) { + // Bump the number of successful measurements + _measurementsSucceeded++; return true; } else { return false; diff --git a/src/sensors/AnalogElecConductivity.cpp b/src/sensors/AnalogElecConductivity.cpp index 4b34ad709..09f3013ab 100644 --- a/src/sensors/AnalogElecConductivity.cpp +++ b/src/sensors/AnalogElecConductivity.cpp @@ -95,6 +95,13 @@ bool AnalogElecConductivity::addSingleMeasurementResult(void) { // Unset the status bits for a measurement request (bits 5 & 6) clearStatusBits(MEASUREMENT_ATTEMPTED, MEASUREMENT_SUCCESSFUL); + // Bump the number of completed measurement attempts + _measurementAttemptsCompleted++; + // Bump the number of successful measurements + // NOTE: We don't actually have any criteria for if the reading was any good + // or not. + _measurementsSucceeded++; + // Return true when finished return true; } diff --git a/src/sensors/ApogeeSQ212.cpp b/src/sensors/ApogeeSQ212.cpp index d013f297c..93f9e459f 100644 --- a/src/sensors/ApogeeSQ212.cpp +++ b/src/sensors/ApogeeSQ212.cpp @@ -107,8 +107,13 @@ bool ApogeeSQ212::addSingleMeasurementResult(void) { _millisMeasurementRequested = 0; // Unset the status bits for a measurement request (bits 5 & 6) clearStatusBits(MEASUREMENT_ATTEMPTED, MEASUREMENT_SUCCESSFUL); + // Bump the number of completed measurement attempts + _measurementAttemptsCompleted++; + if (adcVoltage < 3.6 && adcVoltage > -0.3) { + // Bump the number of successful measurements + _measurementsSucceeded++; return true; } else { return false; diff --git a/src/sensors/AtlasParent.cpp b/src/sensors/AtlasParent.cpp index 20e91af47..1571efc57 100644 --- a/src/sensors/AtlasParent.cpp +++ b/src/sensors/AtlasParent.cpp @@ -132,11 +132,6 @@ bool AtlasParent::startSingleMeasurement(void) { F("did not successfully start a measurement.")); _millisMeasurementRequested = 0; clearStatusBit(MEASUREMENT_SUCCESSFUL); - // Bump the number of measurement attempts completed - since the start - // failed, we now consider the attempt complete. - // NOTE: Don't bump the - // successful measurements count! - _measurementAttemptsCompleted++; } return success; @@ -199,6 +194,15 @@ bool AtlasParent::addSingleMeasurementResult(void) { _millisMeasurementRequested = 0; // Unset the status bits for a measurement request (bits 5 & 6) clearStatusBits(MEASUREMENT_ATTEMPTED, MEASUREMENT_SUCCESSFUL); + // Bump the number of completed measurement attempts + _measurementAttemptsCompleted++; + + if (success) { + // Bump the number of successful measurements + // NOTE: This is bumped if we got a successful response code, + // even if the results were NaN or otherwise invalid! + _measurementsSucceeded++; + } return success; } diff --git a/src/sensors/BoschBME280.cpp b/src/sensors/BoschBME280.cpp index fb9de7f9b..4e8879903 100644 --- a/src/sensors/BoschBME280.cpp +++ b/src/sensors/BoschBME280.cpp @@ -167,6 +167,15 @@ bool BoschBME280::addSingleMeasurementResult(void) { _millisMeasurementRequested = 0; // Unset the status bits for a measurement request (bits 5 & 6) clearStatusBits(MEASUREMENT_ATTEMPTED, MEASUREMENT_SUCCESSFUL); + // Bump the number of completed measurement attempts + _measurementAttemptsCompleted++; + + if (success) { + // Bump the number of successful measurements + // NOTE: Any one of the values being NOT -9999 is not considered a + // success! + _measurementsSucceeded++; + } return success; } diff --git a/src/sensors/BoschBMP3xx.cpp b/src/sensors/BoschBMP3xx.cpp index 4ff6c521b..286b0d5a5 100644 --- a/src/sensors/BoschBMP3xx.cpp +++ b/src/sensors/BoschBMP3xx.cpp @@ -316,6 +316,15 @@ bool BoschBMP3xx::addSingleMeasurementResult(void) { _millisMeasurementRequested = 0; // Unset the status bits for a measurement request (bits 5 & 6) clearStatusBits(MEASUREMENT_ATTEMPTED, MEASUREMENT_SUCCESSFUL); + // Bump the number of completed measurement attempts + _measurementAttemptsCompleted++; + + if (success) { + // Bump the number of successful measurements + // NOTE: This is bumped if we successfully got a response, even if the + // results were NaN or otherwise invalid! + _measurementsSucceeded++; + } return success; } diff --git a/src/sensors/CampbellOBS3.cpp b/src/sensors/CampbellOBS3.cpp index cec02baf6..6b45e3b2e 100644 --- a/src/sensors/CampbellOBS3.cpp +++ b/src/sensors/CampbellOBS3.cpp @@ -111,8 +111,12 @@ bool CampbellOBS3::addSingleMeasurementResult(void) { _millisMeasurementRequested = 0; // Unset the status bits for a measurement request (bits 5 & 6) clearStatusBits(MEASUREMENT_ATTEMPTED, MEASUREMENT_SUCCESSFUL); + // Bump the number of completed measurement attempts + _measurementAttemptsCompleted++; if (adcVoltage < 3.6 && adcVoltage > -0.3) { + // Bump the number of successful measurements + _measurementsSucceeded++; return true; } else { return false; diff --git a/src/sensors/EverlightALSPT19.cpp b/src/sensors/EverlightALSPT19.cpp index 996ff612c..4b47c6756 100644 --- a/src/sensors/EverlightALSPT19.cpp +++ b/src/sensors/EverlightALSPT19.cpp @@ -83,6 +83,12 @@ bool EverlightALSPT19::addSingleMeasurementResult(void) { _millisMeasurementRequested = 0; // Unset the status bits for a measurement request (bits 5 & 6) clearStatusBits(MEASUREMENT_ATTEMPTED, MEASUREMENT_SUCCESSFUL); + // Bump the number of completed measurement attempts + _measurementAttemptsCompleted++; + // Bump the number of successful measurements + // NOTE: We don't actually have any criteria for if the reading was any good + // or not. + _measurementsSucceeded++; return true; } diff --git a/src/sensors/FreescaleMPL115A2.cpp b/src/sensors/FreescaleMPL115A2.cpp index 79d33ed03..986c7e04f 100644 --- a/src/sensors/FreescaleMPL115A2.cpp +++ b/src/sensors/FreescaleMPL115A2.cpp @@ -93,7 +93,14 @@ bool FreescaleMPL115A2::addSingleMeasurementResult(void) { _millisMeasurementRequested = 0; // Unset the status bits for a measurement request (bits 5 & 6) clearStatusBits(MEASUREMENT_ATTEMPTED, MEASUREMENT_SUCCESSFUL); + // Bump the number of completed measurement attempts + _measurementAttemptsCompleted++; - // no way of knowing if successful, just return true + if (temp != -9999 && press != -9999) { + // Bump the number of successful measurements + _measurementsSucceeded++; + } + + // no way of knowing if the communication was successful, just return true return true; } diff --git a/src/sensors/GeoluxHydroCam.cpp b/src/sensors/GeoluxHydroCam.cpp index 7d6a69f1b..9041490e8 100644 --- a/src/sensors/GeoluxHydroCam.cpp +++ b/src/sensors/GeoluxHydroCam.cpp @@ -156,10 +156,6 @@ bool GeoluxHydroCam::startSingleMeasurement(void) { // unset _millisMeasurementRequested = 0; clearStatusBit(MEASUREMENT_SUCCESSFUL); - // Bump the number of measurement attempts completed - since the start - // failed, we now consider the attempt complete. - // NOTE: Don't bump the successful measurements count! - _measurementAttemptsCompleted++; return false; } @@ -182,9 +178,6 @@ bool GeoluxHydroCam::startSingleMeasurement(void) { F("did not successfully start a measurement.")); _millisMeasurementRequested = 0; clearStatusBit(MEASUREMENT_SUCCESSFUL); - // Bump the number of measurement attempts completed - // NOTE: Don't bump the successful measurements count! - _measurementAttemptsCompleted++; } return success; @@ -266,6 +259,15 @@ bool GeoluxHydroCam::addSingleMeasurementResult(void) { _millisMeasurementRequested = 0; // Unset the status bits for a measurement request (bits 5 & 6) clearStatusBits(MEASUREMENT_ATTEMPTED, MEASUREMENT_SUCCESSFUL); + // Bump the number of completed measurement attempts + _measurementAttemptsCompleted++; + + if (success) { + // Bump the number of successful measurements + // NOTE: We consider the measurement a success only if we got all the + // bytes we expected! + _measurementsSucceeded++; + } // Return values shows if we got a not-obviously-bad reading return success; diff --git a/src/sensors/GroPointParent.cpp b/src/sensors/GroPointParent.cpp index a6c709ebe..dc3faf532 100644 --- a/src/sensors/GroPointParent.cpp +++ b/src/sensors/GroPointParent.cpp @@ -328,6 +328,13 @@ bool GroPointParent::addSingleMeasurementResult(void) { _millisMeasurementRequested = 0; // Unset the status bits for a measurement request (bits 5 & 6) clearStatusBits(MEASUREMENT_ATTEMPTED, MEASUREMENT_SUCCESSFUL); + // Bump the number of completed measurement attempts + _measurementAttemptsCompleted++; + + if (success && successT) { + // Bump the number of successful measurements + _measurementsSucceeded++; + } // Return true when finished return success && successT; diff --git a/src/sensors/KellerParent.cpp b/src/sensors/KellerParent.cpp index aa6518e0b..ab799814d 100644 --- a/src/sensors/KellerParent.cpp +++ b/src/sensors/KellerParent.cpp @@ -200,6 +200,17 @@ bool KellerParent::addSingleMeasurementResult(void) { _millisMeasurementRequested = 0; // Unset the status bits for a measurement request (bits 5 & 6) clearStatusBits(MEASUREMENT_ATTEMPTED, MEASUREMENT_SUCCESSFUL); + // Bump the number of completed measurement attempts + _measurementAttemptsCompleted++; + + if (success && + (waterPressureBar != -9999 || waterTemperatureC != -9999 || + waterDepthM != -9999)) { + // Bump the number of successful measurements + // NOTE: Any one of the values being NOT -9999 is not considered a + // success! + _measurementsSucceeded++; + } // Return true when finished return success; diff --git a/src/sensors/MaxBotixSonar.cpp b/src/sensors/MaxBotixSonar.cpp index 92e430330..1682d397a 100644 --- a/src/sensors/MaxBotixSonar.cpp +++ b/src/sensors/MaxBotixSonar.cpp @@ -151,6 +151,7 @@ bool MaxBotixSonar::addSingleMeasurementResult(void) { uint8_t rangeAttempts = 0; while (success == false && rangeAttempts < 25) { + /// @todo unify retries with other sensors? // If the sonar is running on a trigger, activating the trigger // should in theory happen within the startSingleMeasurement // function. Because we're really taking up to 25 measurements @@ -197,6 +198,13 @@ bool MaxBotixSonar::addSingleMeasurementResult(void) { _millisMeasurementRequested = 0; // Unset the status bits for a measurement request (bits 5 & 6) clearStatusBits(MEASUREMENT_ATTEMPTED, MEASUREMENT_SUCCESSFUL); + // Bump the number of completed measurement attempts + _measurementAttemptsCompleted++; + + if (success) { + // Bump the number of successful measurements + _measurementsSucceeded++; + } // Return values shows if we got a not-obviously-bad reading return success; diff --git a/src/sensors/MaximDS18.cpp b/src/sensors/MaximDS18.cpp index ddbabf4f3..4d5e2304d 100644 --- a/src/sensors/MaximDS18.cpp +++ b/src/sensors/MaximDS18.cpp @@ -172,10 +172,6 @@ bool MaximDS18::startSingleMeasurement(void) { F("did not successfully start a measurement.")); _millisMeasurementRequested = 0; clearStatusBit(MEASUREMENT_SUCCESSFUL); - // Bump the number of measurement attempts completed - since the start - // failed, we now consider the attempt complete. - // NOTE: Don't bump the successful measurements count! - _measurementAttemptsCompleted++; } return success; @@ -214,6 +210,13 @@ bool MaximDS18::addSingleMeasurementResult(void) { _millisMeasurementRequested = 0; // Unset the status bits for a measurement request (bits 5 & 6) clearStatusBits(MEASUREMENT_ATTEMPTED, MEASUREMENT_SUCCESSFUL); + // Bump the number of completed measurement attempts + _measurementAttemptsCompleted++; + + if (success && result != -9999) { + // Bump the number of successful measurements + _measurementsSucceeded++; + } return success; } diff --git a/src/sensors/MaximDS3231.cpp b/src/sensors/MaximDS3231.cpp index 3070c325b..aea18b9b1 100644 --- a/src/sensors/MaximDS3231.cpp +++ b/src/sensors/MaximDS3231.cpp @@ -65,6 +65,12 @@ bool MaximDS3231::addSingleMeasurementResult(void) { _millisMeasurementRequested = 0; // Unset the status bits for a measurement request (bits 5 & 6) clearStatusBits(MEASUREMENT_ATTEMPTED, MEASUREMENT_SUCCESSFUL); + // Bump the number of completed measurement attempts + _measurementAttemptsCompleted++; + // Bump the number of successful measurements + // NOTE: We don't actually have any criteria for if the reading was any good + // or not. + _measurementsSucceeded++; // Return true when finished return true; diff --git a/src/sensors/MeaSpecMS5803.cpp b/src/sensors/MeaSpecMS5803.cpp index eb7898093..adb5b9964 100644 --- a/src/sensors/MeaSpecMS5803.cpp +++ b/src/sensors/MeaSpecMS5803.cpp @@ -97,6 +97,15 @@ bool MeaSpecMS5803::addSingleMeasurementResult(void) { _millisMeasurementRequested = 0; // Unset the status bits for a measurement request (bits 5 & 6) clearStatusBits(MEASUREMENT_ATTEMPTED, MEASUREMENT_SUCCESSFUL); + // Bump the number of completed measurement attempts + _measurementAttemptsCompleted++; + + if (success && (temp != -9999 || press != -9999)) { + // Bump the number of successful measurements + // NOTE: Any one of the values being NOT -9999 is not considered a + // success! + _measurementsSucceeded++; + } return success; } diff --git a/src/sensors/PaleoTerraRedox.cpp b/src/sensors/PaleoTerraRedox.cpp index 9414ef9a2..d609254f3 100644 --- a/src/sensors/PaleoTerraRedox.cpp +++ b/src/sensors/PaleoTerraRedox.cpp @@ -155,6 +155,13 @@ bool PaleoTerraRedox::addSingleMeasurementResult(void) { clearStatusBit(MEASUREMENT_ATTEMPTED); // Set the status bit for measurement completion (bit 6) setStatusBit(MEASUREMENT_SUCCESSFUL); + // Bump the number of completed measurement attempts + _measurementAttemptsCompleted++; + + if (success && (res != -9999)) { + // Bump the number of successful measurements + _measurementsSucceeded++; + } return success; } diff --git a/src/sensors/ProcessorStats.cpp b/src/sensors/ProcessorStats.cpp index 21ec4d541..8f18bf8fd 100644 --- a/src/sensors/ProcessorStats.cpp +++ b/src/sensors/ProcessorStats.cpp @@ -293,6 +293,12 @@ bool ProcessorStats::addSingleMeasurementResult(void) { _millisMeasurementRequested = 0; // Unset the status bits for a measurement request (bits 5 & 6) clearStatusBits(MEASUREMENT_ATTEMPTED, MEASUREMENT_SUCCESSFUL); + // Bump the number of completed measurement attempts + _measurementAttemptsCompleted++; + // Bump the number of successful measurements + // NOTE: We don't actually have any criteria for if the reading was any good + // or not. + _measurementsSucceeded++; // Return true when finished return true; diff --git a/src/sensors/RainCounterI2C.cpp b/src/sensors/RainCounterI2C.cpp index 6b677d7cd..aa623733b 100644 --- a/src/sensors/RainCounterI2C.cpp +++ b/src/sensors/RainCounterI2C.cpp @@ -154,6 +154,15 @@ bool RainCounterI2C::addSingleMeasurementResult(void) { _millisMeasurementRequested = 0; // Unset the status bits for a measurement request (bits 5 & 6) clearStatusBits(MEASUREMENT_ATTEMPTED, MEASUREMENT_SUCCESSFUL); + // Bump the number of completed measurement attempts + _measurementAttemptsCompleted++; + + if (rain != -9999 || tips != -9999) { + // Bump the number of successful measurements + // NOTE: Any one of the values being NOT -9999 is not considered a + // success! + _measurementsSucceeded++; + } // Return true when finished return true; diff --git a/src/sensors/SDI12Sensors.cpp b/src/sensors/SDI12Sensors.cpp index 596be3e2f..0196bbd31 100644 --- a/src/sensors/SDI12Sensors.cpp +++ b/src/sensors/SDI12Sensors.cpp @@ -390,10 +390,6 @@ bool SDI12Sensors::startSingleMeasurement(void) { _millisMeasurementRequested = 0; clearStatusBit(MEASUREMENT_SUCCESSFUL); deactivate(); - // Bump the number of measurement attempts completed - since the start - // failed, we now consider the attempt complete. - // NOTE: Don't bump the successful measurements count! - _measurementAttemptsCompleted++; return false; } @@ -419,10 +415,6 @@ bool SDI12Sensors::startSingleMeasurement(void) { F("did not respond to measurement request!")); _millisMeasurementRequested = 0; clearStatusBit(MEASUREMENT_SUCCESSFUL); - // Bump the number of measurement attempts completed - since the start - // failed, we now consider the attempt complete. - // NOTE: Don't bump the successful measurements count! - _measurementAttemptsCompleted++; return false; } } @@ -736,6 +728,13 @@ bool SDI12Sensors::addSingleMeasurementResult(void) { _millisMeasurementRequested = 0; // Unset the status bits for a measurement request (bits 5 & 6) clearStatusBits(MEASUREMENT_ATTEMPTED, MEASUREMENT_SUCCESSFUL); + // Bump the number of completed measurement attempts + _measurementAttemptsCompleted++; + + if (success) { + // Bump the number of successful measurements + _measurementsSucceeded++; + } return success; } @@ -817,6 +816,13 @@ bool SDI12Sensors::addSingleMeasurementResult(void) { _millisMeasurementRequested = 0; // Unset the status bits for a measurement request (bits 5 & 6) clearStatusBits(MEASUREMENT_ATTEMPTED, MEASUREMENT_SUCCESSFUL); + // Bump the number of completed measurement attempts + _measurementAttemptsCompleted++; + + if (success) { + // Bump the number of successful measurements + _measurementsSucceeded++; + } return success; } diff --git a/src/sensors/SensirionSHT4x.cpp b/src/sensors/SensirionSHT4x.cpp index d30bcc37b..f2a2c5b1e 100644 --- a/src/sensors/SensirionSHT4x.cpp +++ b/src/sensors/SensirionSHT4x.cpp @@ -127,6 +127,15 @@ bool SensirionSHT4x::addSingleMeasurementResult(void) { _millisMeasurementRequested = 0; // Unset the status bits for a measurement request (bits 5 & 6) clearStatusBits(MEASUREMENT_ATTEMPTED, MEASUREMENT_SUCCESSFUL); + // Bump the number of completed measurement attempts + _measurementAttemptsCompleted++; + + if (ret_val && (temp_val != -9999 || humid_val != -9999)) { + // Bump the number of successful measurements + // NOTE: Any one of the values being NOT -9999 is not considered a + // success! + _measurementsSucceeded++; + } return ret_val; } diff --git a/src/sensors/TIADS1x15.cpp b/src/sensors/TIADS1x15.cpp index 0f4bdc3fe..a8801a61e 100644 --- a/src/sensors/TIADS1x15.cpp +++ b/src/sensors/TIADS1x15.cpp @@ -103,8 +103,12 @@ bool TIADS1x15::addSingleMeasurementResult(void) { _millisMeasurementRequested = 0; // Unset the status bits for a measurement request (bits 5 & 6) clearStatusBits(MEASUREMENT_ATTEMPTED, MEASUREMENT_SUCCESSFUL); + // Bump the number of completed measurement attempts + _measurementAttemptsCompleted++; if (adcVoltage < 3.6 && adcVoltage > -0.3) { + // Bump the number of successful measurements + _measurementsSucceeded++; return true; } else { return false; diff --git a/src/sensors/TIINA219.cpp b/src/sensors/TIINA219.cpp index 6957c1def..797ac933f 100644 --- a/src/sensors/TIINA219.cpp +++ b/src/sensors/TIINA219.cpp @@ -110,6 +110,16 @@ bool TIINA219::addSingleMeasurementResult(void) { _millisMeasurementRequested = 0; // Unset the status bits for a measurement request (bits 5 & 6) clearStatusBits(MEASUREMENT_ATTEMPTED, MEASUREMENT_SUCCESSFUL); + // Bump the number of completed measurement attempts + _measurementAttemptsCompleted++; + + if (success && + (current_mA != -9999 || busV_V != -9999 || power_mW != -9999)) { + // Bump the number of successful measurements + // NOTE: Any one of the values being NOT -9999 is not considered a + // success! + _measurementsSucceeded++; + } return success; } diff --git a/src/sensors/TallyCounterI2C.cpp b/src/sensors/TallyCounterI2C.cpp index 9e043c2d6..1101d77a8 100644 --- a/src/sensors/TallyCounterI2C.cpp +++ b/src/sensors/TallyCounterI2C.cpp @@ -111,6 +111,13 @@ bool TallyCounterI2C::addSingleMeasurementResult(void) { _millisMeasurementRequested = 0; // Unset the status bits for a measurement request (bits 5 & 6) clearStatusBits(MEASUREMENT_ATTEMPTED, MEASUREMENT_SUCCESSFUL); + // Bump the number of completed measurement attempts + _measurementAttemptsCompleted++; + + if (success) { + // Bump the number of successful measurements + _measurementsSucceeded++; + } return success; } diff --git a/src/sensors/TurnerCyclops.cpp b/src/sensors/TurnerCyclops.cpp index d7dd41a8f..0d98ea32d 100644 --- a/src/sensors/TurnerCyclops.cpp +++ b/src/sensors/TurnerCyclops.cpp @@ -111,8 +111,12 @@ bool TurnerCyclops::addSingleMeasurementResult(void) { _millisMeasurementRequested = 0; // Unset the status bits for a measurement request (bits 5 & 6) clearStatusBits(MEASUREMENT_ATTEMPTED, MEASUREMENT_SUCCESSFUL); + // Bump the number of completed measurement attempts + _measurementAttemptsCompleted++; if (adcVoltage < 3.6 && adcVoltage > -0.3) { + // Bump the number of successful measurements + _measurementsSucceeded++; return true; } else { return false; diff --git a/src/sensors/TurnerTurbidityPlus.cpp b/src/sensors/TurnerTurbidityPlus.cpp index 19999664d..2d622e5bc 100644 --- a/src/sensors/TurnerTurbidityPlus.cpp +++ b/src/sensors/TurnerTurbidityPlus.cpp @@ -173,8 +173,12 @@ bool TurnerTurbidityPlus::addSingleMeasurementResult(void) { _millisMeasurementRequested = 0; // Unset the status bits for a measurement request (bits 5 & 6) clearStatusBits(MEASUREMENT_ATTEMPTED, MEASUREMENT_SUCCESSFUL); + // Bump the number of completed measurement attempts + _measurementAttemptsCompleted++; if (adcVoltage < 5.3 && adcVoltage > -0.3) { + // Bump the number of successful measurements + _measurementsSucceeded++; return true; } else { return false; diff --git a/src/sensors/YosemitechParent.cpp b/src/sensors/YosemitechParent.cpp index e231148ae..9ee2bb9e4 100644 --- a/src/sensors/YosemitechParent.cpp +++ b/src/sensors/YosemitechParent.cpp @@ -331,6 +331,13 @@ bool YosemitechParent::addSingleMeasurementResult(void) { _millisMeasurementRequested = 0; // Unset the status bits for a measurement request (bits 5 & 6) clearStatusBits(MEASUREMENT_ATTEMPTED, MEASUREMENT_SUCCESSFUL); + // Bump the number of completed measurement attempts + _measurementAttemptsCompleted++; + + if (success) { + // Bump the number of successful measurements + _measurementsSucceeded++; + } // Return true when finished return success; From a5d68ca019176f84796729c07eb4ee0f0f7de6cc Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Thu, 25 Sep 2025 16:31:43 -0400 Subject: [PATCH 006/533] Unset the number of measurements attempted and succeeded only in clear values function Signed-off-by: Sara Damiano --- src/SensorBase.cpp | 5 ++--- src/sensors/ANBpH.cpp | 6 ------ src/sensors/AtlasParent.cpp | 3 --- src/sensors/GeoluxHydroCam.cpp | 3 --- src/sensors/GroPointParent.cpp | 6 ------ src/sensors/KellerParent.cpp | 3 --- src/sensors/SensirionSHT4x.cpp | 3 --- src/sensors/YosemitechParent.cpp | 6 ------ 8 files changed, 2 insertions(+), 33 deletions(-) diff --git a/src/SensorBase.cpp b/src/SensorBase.cpp index 8c3bcc2f6..28e99b2af 100644 --- a/src/SensorBase.cpp +++ b/src/SensorBase.cpp @@ -139,9 +139,6 @@ void Sensor::powerDown(void) { clearStatusBits(POWER_ATTEMPTED, POWER_SUCCESSFUL, WAKE_ATTEMPTED, WAKE_SUCCESSFUL, MEASUREMENT_ATTEMPTED, MEASUREMENT_SUCCESSFUL); - // Unset the number of measurements attempted and succeeded - _measurementAttemptsCompleted = 0; - _measurementsSucceeded = 0; } else { MS_DBG(F("Power to"), getSensorNameAndLocation(), F("is not controlled by this library.")); @@ -296,6 +293,8 @@ void Sensor::clearValues(void) { sensorValues[i] = -9999; numberGoodMeasurementsMade[i] = 0; } + _measurementAttemptsCompleted = 0; + _measurementsSucceeded = 0; } diff --git a/src/sensors/ANBpH.cpp b/src/sensors/ANBpH.cpp index 4544e6dce..10d77e7c2 100644 --- a/src/sensors/ANBpH.cpp +++ b/src/sensors/ANBpH.cpp @@ -288,9 +288,6 @@ bool ANBpH::sleep(void) { _millisSensorActivated = 0; // Unset the measurement request time _millisMeasurementRequested = 0; - // Unset the number of measurements attempted and succeeded - _measurementAttemptsCompleted = 0; - _measurementsSucceeded = 0; // Unset the status bits for sensor activation (bits 3 & 4) and // measurement request (bits 5 & 6) clearStatusBits(WAKE_ATTEMPTED, WAKE_SUCCESSFUL, MEASUREMENT_ATTEMPTED, @@ -354,9 +351,6 @@ void ANBpH::powerDown(void) { _millisSensorActivated = 0; // Unset the measurement request time _millisMeasurementRequested = 0; - // Unset the number of measurements attempted and succeeded - _measurementAttemptsCompleted = 0; - _measurementsSucceeded = 0; // Unset the status bits for sensor power (bits 1 & 2), // activation (bits 3 & 4), and measurement request (bits 5 & 6) clearStatusBits(POWER_ATTEMPTED, POWER_SUCCESSFUL, WAKE_ATTEMPTED, diff --git a/src/sensors/AtlasParent.cpp b/src/sensors/AtlasParent.cpp index 1571efc57..6dfe421cf 100644 --- a/src/sensors/AtlasParent.cpp +++ b/src/sensors/AtlasParent.cpp @@ -84,9 +84,6 @@ bool AtlasParent::sleep(void) { _millisSensorActivated = 0; // Unset the measurement request time _millisMeasurementRequested = 0; - // Unset the number of measurements attempted and succeeded - _measurementAttemptsCompleted = 0; - _measurementsSucceeded = 0; // Unset the status bits for sensor activation (bits 3 & 4) and // measurement request (bits 5 & 6) clearStatusBits(WAKE_ATTEMPTED, WAKE_SUCCESSFUL, MEASUREMENT_ATTEMPTED, diff --git a/src/sensors/GeoluxHydroCam.cpp b/src/sensors/GeoluxHydroCam.cpp index 9041490e8..6d0b3801c 100644 --- a/src/sensors/GeoluxHydroCam.cpp +++ b/src/sensors/GeoluxHydroCam.cpp @@ -318,9 +318,6 @@ void GeoluxHydroCam::powerDown(void) { _millisSensorActivated = 0; // Unset the measurement request time _millisMeasurementRequested = 0; - // Unset the number of measurements attempted and succeeded - _measurementAttemptsCompleted = 0; - _measurementsSucceeded = 0; // Unset the status bits for sensor power (bits 1 & 2), // activation (bits 3 & 4), and measurement request (bits 5 & 6) clearStatusBits(POWER_ATTEMPTED, POWER_SUCCESSFUL, WAKE_ATTEMPTED, diff --git a/src/sensors/GroPointParent.cpp b/src/sensors/GroPointParent.cpp index dc3faf532..342c77b8d 100644 --- a/src/sensors/GroPointParent.cpp +++ b/src/sensors/GroPointParent.cpp @@ -141,9 +141,6 @@ bool GroPointParent::sleep(void) { _millisSensorActivated = 0; // Unset the measurement request time _millisMeasurementRequested = 0; - // Unset the number of measurements attempted and succeeded - _measurementAttemptsCompleted = 0; - _measurementsSucceeded = 0; // Unset the status bits for sensor activation (bits 3 & 4) and // measurement request (bits 5 & 6) clearStatusBits(WAKE_ATTEMPTED, WAKE_SUCCESSFUL, MEASUREMENT_ATTEMPTED, @@ -207,9 +204,6 @@ void GroPointParent::powerDown(void) { _millisSensorActivated = 0; // Unset the measurement request time _millisMeasurementRequested = 0; - // Unset the number of measurements attempted and succeeded - _measurementAttemptsCompleted = 0; - _measurementsSucceeded = 0; // Unset the status bits for sensor power (bits 1 & 2), // activation (bits 3 & 4), and measurement request (bits 5 & 6) clearStatusBits(POWER_ATTEMPTED, POWER_SUCCESSFUL, WAKE_ATTEMPTED, diff --git a/src/sensors/KellerParent.cpp b/src/sensors/KellerParent.cpp index ab799814d..56f4e708a 100644 --- a/src/sensors/KellerParent.cpp +++ b/src/sensors/KellerParent.cpp @@ -131,9 +131,6 @@ void KellerParent::powerDown(void) { _millisSensorActivated = 0; // Unset the measurement request time _millisMeasurementRequested = 0; - // Unset the number of measurements attempted and succeeded - _measurementAttemptsCompleted = 0; - _measurementsSucceeded = 0; // Unset the status bits for sensor power (bits 1 & 2), // activation (bits 3 & 4), and measurement request (bits 5 & 6) clearStatusBits(POWER_ATTEMPTED, POWER_SUCCESSFUL, WAKE_ATTEMPTED, diff --git a/src/sensors/SensirionSHT4x.cpp b/src/sensors/SensirionSHT4x.cpp index f2a2c5b1e..6e896905d 100644 --- a/src/sensors/SensirionSHT4x.cpp +++ b/src/sensors/SensirionSHT4x.cpp @@ -182,9 +182,6 @@ bool SensirionSHT4x::sleep(void) { _millisSensorActivated = 0; // Unset the measurement request time _millisMeasurementRequested = 0; - // Unset the number of measurements attempted and succeeded - _measurementAttemptsCompleted = 0; - _measurementsSucceeded = 0; // Unset the status bits for sensor activation (bits 3 & 4) and // measurement request (bits 5 & 6) clearStatusBits(WAKE_ATTEMPTED, WAKE_SUCCESSFUL, MEASUREMENT_ATTEMPTED, diff --git a/src/sensors/YosemitechParent.cpp b/src/sensors/YosemitechParent.cpp index 9ee2bb9e4..4539ed0f6 100644 --- a/src/sensors/YosemitechParent.cpp +++ b/src/sensors/YosemitechParent.cpp @@ -150,9 +150,6 @@ bool YosemitechParent::sleep(void) { _millisSensorActivated = 0; // Unset the measurement request time _millisMeasurementRequested = 0; - // Unset the number of measurements attempted and succeeded - _measurementAttemptsCompleted = 0; - _measurementsSucceeded = 0; // Unset the status bits for sensor activation (bits 3 & 4) and // measurement request (bits 5 & 6) clearStatusBits(WAKE_ATTEMPTED, WAKE_SUCCESSFUL, MEASUREMENT_ATTEMPTED, @@ -216,9 +213,6 @@ void YosemitechParent::powerDown(void) { _millisSensorActivated = 0; // Unset the measurement request time _millisMeasurementRequested = 0; - // Unset the number of measurements attempted and succeeded - _measurementAttemptsCompleted = 0; - _measurementsSucceeded = 0; // Unset the status bits for sensor power (bits 1 & 2), // activation (bits 3 & 4), and measurement request (bits 5 & 6) clearStatusBits(POWER_ATTEMPTED, POWER_SUCCESSFUL, WAKE_ATTEMPTED, From 97a1a0887a813b0872039a34773c078c31a929e5 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Thu, 25 Sep 2025 17:03:12 -0400 Subject: [PATCH 007/533] Made a secondary power pin a component of all sensors Signed-off-by: Sara Damiano --- src/SensorBase.cpp | 35 +++++++++++--- src/SensorBase.h | 30 ++++++++++++ src/sensors/GeoluxHydroCam.cpp | 74 +++-------------------------- src/sensors/GeoluxHydroCam.h | 8 ---- src/sensors/GroPointParent.cpp | 80 ++++---------------------------- src/sensors/GroPointParent.h | 8 ---- src/sensors/KellerParent.cpp | 77 +++--------------------------- src/sensors/KellerParent.h | 8 ---- src/sensors/YosemitechParent.cpp | 78 +++---------------------------- src/sensors/YosemitechParent.h | 8 ---- 10 files changed, 86 insertions(+), 320 deletions(-) diff --git a/src/SensorBase.cpp b/src/SensorBase.cpp index 28e99b2af..2fc71de61 100644 --- a/src/SensorBase.cpp +++ b/src/SensorBase.cpp @@ -22,6 +22,7 @@ Sensor::Sensor(const char* sensorName, const uint8_t totalReturnedValues, uint8_t measurementsToAverage, uint8_t incCalcValues) : _dataPin(dataPin), _powerPin(powerPin), + _powerPin2(-1), _sensorName(sensorName), _numReturnedValues(totalReturnedValues), _measurementsToAverage(measurementsToAverage), @@ -64,6 +65,14 @@ String Sensor::getSensorNameAndLocation(void) { int8_t Sensor::getPowerPin(void) { return _powerPin; } +// This returns the number of the secondary power pin +int8_t Sensor::getSecondaryPowerPin(void) { + return _powerPin2; +} +// This sets the secondary power pin +void Sensor::setSecondaryPowerPin(int8_t pin) { + _powerPin2 = pin; +} // These functions get and set the number of readings to average for a sensor @@ -102,13 +111,21 @@ void Sensor::clearStatusBit(sensor_status_bits bitToClear) { // This turns on sensor power void Sensor::powerUp(void) { - if (_powerPin >= 0) { + if (_powerPin >= 0 || _powerPin2 >= 0) { // Reset power pin mode every power up because pins are set to tri-state // on sleep - pinMode(_powerPin, OUTPUT); - MS_DBG(F("Powering"), getSensorNameAndLocation(), F("with pin"), - _powerPin); - digitalWrite(_powerPin, HIGH); + if (_powerPin >= 0) { + pinMode(_powerPin, OUTPUT); + MS_DBG(F("Powering"), getSensorNameAndLocation(), F("with pin"), + _powerPin); + digitalWrite(_powerPin, HIGH); + } + if (_powerPin2 >= 0) { + pinMode(_powerPin2, OUTPUT); + MS_DBG(F("Giving secondary power to"), getSensorNameAndLocation(), + F("with pin"), _powerPin2); + digitalWrite(_powerPin2, HIGH); + } // Mark the time that the sensor was powered _millisPowerOn = millis(); } else { @@ -418,12 +435,16 @@ bool Sensor::checkPowerOn(bool debug) { MS_DBG(F("Checking power status: Power to"), getSensorNameAndLocation()); } - if (_powerPin >= 0) { + if (_powerPin >= 0 || _powerPin2 >= 0) { auto powerBitNumber = static_cast(log(digitalPinToBitMask(_powerPin)) / log(2)); + auto powerBitNumber2 = + static_cast(log(digitalPinToBitMask(_powerPin2)) / log(2)); if (bitRead(*portInputRegister(digitalPinToPort(_powerPin)), - powerBitNumber) == LOW) { + powerBitNumber) == LOW || + bitRead(*portInputRegister(digitalPinToPort(_powerPin2)), + powerBitNumber2) == LOW) { if (debug) { MS_DBG(F("was off.")); } // Reset time of power on, in-case it was set to a value _millisPowerOn = 0; diff --git a/src/SensorBase.h b/src/SensorBase.h index c996d35f4..d9e419cf2 100644 --- a/src/SensorBase.h +++ b/src/SensorBase.h @@ -147,6 +147,26 @@ class Sensor { * @return The pin on the mcu controlling power to the sensor. */ virtual int8_t getPowerPin(void); + /** + * @brief Get the pin number controlling secondary sensor power. + * + * @return The pin on the mcu controlling secondary power + * + * This is for a second power needed to communicate with a sensor. Generally + * to an adapter or converter needed to talk to the sensor - ie, an RS232 + * adapter, an RS485 adapter, or an IO multiplexer. + */ + virtual int8_t getSecondaryPowerPin(void); + /** + * @brief Set the pin number controlling secondary sensor power. + * + * This is for a second power needed to communicate with a sensor. Generally + * to an adapter or converter needed to talk to the sensor - ie, an RS232 + * adapter, an RS485 adapter, or an IO multiplexer. + * + * @param pin The pin on the mcu controlling secondary power + */ + virtual void setSecondaryPowerPin(int8_t pin); /** * @brief Set the number measurements to average. @@ -531,6 +551,16 @@ class Sensor { * @note SIGNED int, to allow negative numbers for unused pins */ int8_t _powerPin; + /** + * @brief Digital pin number on the mcu controlling secondary power + * + * This is for a second power needed to communicate with a sensor. Generally + * to an adapter or converter needed to talk to the sensor - ie, an RS232 + * adapter, an RS485 adapter, or an IO multiplexer. + * + * @note SIGNED int, to allow negative numbers for unused pins + */ + int8_t _powerPin2; /** * @brief The sensor name. */ diff --git a/src/sensors/GeoluxHydroCam.cpp b/src/sensors/GeoluxHydroCam.cpp index 6d0b3801c..465f0dd9f 100644 --- a/src/sensors/GeoluxHydroCam.cpp +++ b/src/sensors/GeoluxHydroCam.cpp @@ -18,13 +18,14 @@ GeoluxHydroCam::GeoluxHydroCam(Stream* stream, int8_t powerPin, : Sensor("GeoluxHydroCam", HYDROCAM_NUM_VARIABLES, HYDROCAM_WARM_UP_TIME_MS, HYDROCAM_STABILIZATION_TIME_MS, HYDROCAM_MEASUREMENT_TIME_MS, powerPin, -1, 1, HYDROCAM_INC_CALC_VARIABLES), - _powerPin2(powerPin2), _imageResolution(imageResolution), _filePrefix(filePrefix), _alwaysAutoFocus(alwaysAutoFocus), _baseLogger(&baseLogger), _stream(stream), - _camera(stream) {} + _camera(stream) { + setSecondaryPowerPin(powerPin2); +} GeoluxHydroCam::GeoluxHydroCam(Stream& stream, int8_t powerPin, @@ -34,13 +35,14 @@ GeoluxHydroCam::GeoluxHydroCam(Stream& stream, int8_t powerPin, : Sensor("GeoluxHydroCam", HYDROCAM_NUM_VARIABLES, HYDROCAM_WARM_UP_TIME_MS, HYDROCAM_STABILIZATION_TIME_MS, HYDROCAM_MEASUREMENT_TIME_MS, powerPin, -1, 1, HYDROCAM_INC_CALC_VARIABLES), - _powerPin2(powerPin2), _imageResolution(imageResolution), _filePrefix(filePrefix), _alwaysAutoFocus(alwaysAutoFocus), _baseLogger(&baseLogger), _stream(&stream), - _camera(&stream) {} + _camera(&stream) { + setSecondaryPowerPin(powerPin2); +} // Destructor GeoluxHydroCam::~GeoluxHydroCam() {} @@ -273,70 +275,6 @@ bool GeoluxHydroCam::addSingleMeasurementResult(void) { return success; } - -// This turns on sensor power -void GeoluxHydroCam::powerUp(void) { - if (_powerPin >= 0) { - // Reset power pin mode every power up because pins are set to tri-state - // on sleep - pinMode(_powerPin, OUTPUT); - MS_DBG(F("Powering"), getSensorNameAndLocation(), F("with pin"), - _powerPin); - digitalWrite(_powerPin, HIGH); - } - if (_powerPin2 >= 0) { - // Reset power pin mode every power up because pins are set to tri-state - // on sleep - pinMode(_powerPin2, OUTPUT); - MS_DBG(F("Applying secondary power to"), getSensorNameAndLocation(), - F("with pin"), _powerPin2); - digitalWrite(_powerPin2, HIGH); - } - if (_powerPin < 0 && _powerPin2 < 0) { - MS_DBG(F("Power to"), getSensorNameAndLocation(), - F("is not controlled by this library.")); - // Mark the power-on time, just in case it had not been marked - if (_millisPowerOn == 0) _millisPowerOn = millis(); - } else { - // Mark the time that the sensor was powered - _millisPowerOn = millis(); - } - // Set the status bit for sensor power attempt (bit 1) and success (bit 2) - setStatusBits(POWER_ATTEMPTED, POWER_SUCCESSFUL); -} - - -// This turns off sensor power -void GeoluxHydroCam::powerDown(void) { - if (_powerPin >= 0) { - MS_DBG(F("Turning off power to"), getSensorNameAndLocation(), - F("with pin"), _powerPin); - digitalWrite(_powerPin, LOW); - // Unset the power-on time - _millisPowerOn = 0; - // Unset the activation time - _millisSensorActivated = 0; - // Unset the measurement request time - _millisMeasurementRequested = 0; - // Unset the status bits for sensor power (bits 1 & 2), - // activation (bits 3 & 4), and measurement request (bits 5 & 6) - clearStatusBits(POWER_ATTEMPTED, POWER_SUCCESSFUL, WAKE_ATTEMPTED, - WAKE_SUCCESSFUL, MEASUREMENT_ATTEMPTED, - MEASUREMENT_SUCCESSFUL); - } - if (_powerPin2 >= 0) { - MS_DBG(F("Turning off secondary power to"), getSensorNameAndLocation(), - F("with pin"), _powerPin2); - digitalWrite(_powerPin2, LOW); - } - if (_powerPin < 0 && _powerPin2 < 0) { - MS_DBG(F("Power to"), getSensorNameAndLocation(), - F("is not controlled by this library.")); - // Do NOT unset any status bits or timestamps if we didn't really power - // down! - } -} - // check if the camera is ready bool GeoluxHydroCam::isCameraReady(uint32_t #if defined(MS_GEOLUXHYDROCAM_DEBUG) diff --git a/src/sensors/GeoluxHydroCam.h b/src/sensors/GeoluxHydroCam.h index 4e5f508b0..56510ef92 100644 --- a/src/sensors/GeoluxHydroCam.h +++ b/src/sensors/GeoluxHydroCam.h @@ -335,10 +335,6 @@ class GeoluxHydroCam : public Sensor { */ bool addSingleMeasurementResult(void) override; - // Override these to use two power pins - void powerUp(void) override; - void powerDown(void) override; - /** * @copydoc Sensor::isWarmedUp(bool debug) * @@ -374,10 +370,6 @@ class GeoluxHydroCam : public Sensor { bool isMeasurementComplete(bool debug = false) override; private: - /** - * @brief Private reference to the power pin fro the RS-485 adapter. - */ - int8_t _powerPin2; const char* _imageResolution; ///< The image resolution from the Geolux HydroCam const char* diff --git a/src/sensors/GroPointParent.cpp b/src/sensors/GroPointParent.cpp index 342c77b8d..6835f8ae9 100644 --- a/src/sensors/GroPointParent.cpp +++ b/src/sensors/GroPointParent.cpp @@ -26,8 +26,9 @@ GroPointParent::GroPointParent(byte modbusAddress, Stream* stream, _model(model), _modbusAddress(modbusAddress), _stream(stream), - _RS485EnablePin(enablePin), - _powerPin2(powerPin2) {} + _RS485EnablePin(enablePin) { + setSecondaryPowerPin(powerPin2); +} GroPointParent::GroPointParent(byte modbusAddress, Stream& stream, int8_t powerPin, int8_t powerPin2, int8_t enablePin, uint8_t measurementsToAverage, @@ -42,8 +43,9 @@ GroPointParent::GroPointParent(byte modbusAddress, Stream& stream, _model(model), _modbusAddress(modbusAddress), _stream(&stream), - _RS485EnablePin(enablePin), - _powerPin2(powerPin2) {} + _RS485EnablePin(enablePin) { + setSecondaryPowerPin(powerPin2); +} // Destructor GroPointParent::~GroPointParent() {} @@ -61,7 +63,6 @@ bool GroPointParent::setup(void) { bool retVal = Sensor::setup(); // this will set pin modes and the setup status bit if (_RS485EnablePin >= 0) { pinMode(_RS485EnablePin, OUTPUT); } - if (_powerPin2 >= 0) { pinMode(_powerPin2, OUTPUT); } #ifdef MS_GROPOINTPARENT_DEBUG_DEEP _gsensor.setDebugStream(&MS_SERIAL_OUTPUT); #endif @@ -83,6 +84,9 @@ bool GroPointParent::wake(void) { // and status bits. If it returns false, there's no reason to go on. if (!Sensor::wake()) return false; + // Reset enable pin because pins are set to tri-state on sleep + if (_RS485EnablePin >= 0) { pinMode(_RS485EnablePin, OUTPUT); } + // Send the command to begin taking readings, trying up to 5 times bool success = false; uint8_t ntries = 0; @@ -158,72 +162,6 @@ bool GroPointParent::sleep(void) { } -// This turns on sensor power -void GroPointParent::powerUp(void) { - if (_powerPin >= 0) { - // Reset power pin mode every power up because pins are set to tri-state - // on sleep - pinMode(_powerPin, OUTPUT); - MS_DBG(F("Powering"), getSensorNameAndLocation(), F("with pin"), - _powerPin); - digitalWrite(_powerPin, HIGH); - } - if (_powerPin2 >= 0) { - // Reset power pin mode every power up because pins are set to tri-state - // on sleep - pinMode(_powerPin2, OUTPUT); - MS_DBG(F("Applying secondary power to"), getSensorNameAndLocation(), - F("with pin"), _powerPin2); - digitalWrite(_powerPin2, HIGH); - } - if (_powerPin < 0 && _powerPin2 < 0) { - MS_DBG(F("Power to"), getSensorNameAndLocation(), - F("is not controlled by this library.")); - // Mark the power-on time, just in case it had not been marked - if (_millisPowerOn == 0) _millisPowerOn = millis(); - } else { - // Mark the time that the sensor was powered - _millisPowerOn = millis(); - } - // Reset enable pin because pins are set to tri-state on sleep - if (_RS485EnablePin >= 0) { pinMode(_RS485EnablePin, OUTPUT); } - // Set the status bit for sensor power attempt (bit 1) and success (bit 2) - setStatusBits(POWER_ATTEMPTED, POWER_SUCCESSFUL); -} - - -// This turns off sensor power -void GroPointParent::powerDown(void) { - if (_powerPin >= 0) { - MS_DBG(F("Turning off power to"), getSensorNameAndLocation(), - F("with pin"), _powerPin); - digitalWrite(_powerPin, LOW); - // Unset the power-on time - _millisPowerOn = 0; - // Unset the activation time - _millisSensorActivated = 0; - // Unset the measurement request time - _millisMeasurementRequested = 0; - // Unset the status bits for sensor power (bits 1 & 2), - // activation (bits 3 & 4), and measurement request (bits 5 & 6) - clearStatusBits(POWER_ATTEMPTED, POWER_SUCCESSFUL, WAKE_ATTEMPTED, - WAKE_SUCCESSFUL, MEASUREMENT_ATTEMPTED, - MEASUREMENT_SUCCESSFUL); - } - if (_powerPin2 >= 0) { - MS_DBG(F("Turning off secondary power to"), getSensorNameAndLocation(), - F("with pin"), _powerPin2); - digitalWrite(_powerPin2, LOW); - } - if (_powerPin < 0 && _powerPin2 < 0) { - MS_DBG(F("Power to"), getSensorNameAndLocation(), - F("is not controlled by this library.")); - // Do NOT unset any status bits or timestamps if we didn't really power - // down! - } -} - - bool GroPointParent::addSingleMeasurementResult(void) { bool success = false; bool successT = false; diff --git a/src/sensors/GroPointParent.h b/src/sensors/GroPointParent.h index 4a4695c3c..ce81b2371 100644 --- a/src/sensors/GroPointParent.h +++ b/src/sensors/GroPointParent.h @@ -187,10 +187,6 @@ class GroPointParent : public Sensor { */ bool sleep(void) override; - // Override these to use two power pins - void powerUp(void) override; - void powerDown(void) override; - /** * @copydoc Sensor::addSingleMeasurementResult() */ @@ -220,10 +216,6 @@ class GroPointParent : public Sensor { * pin. */ int8_t _RS485EnablePin; - /** - * @brief Private reference to the power pin fro the RS-485 adapter. - */ - int8_t _powerPin2; }; #endif // SRC_SENSORS_GROPOINTPARENT_H_ diff --git a/src/sensors/KellerParent.cpp b/src/sensors/KellerParent.cpp index 56f4e708a..9ab679720 100644 --- a/src/sensors/KellerParent.cpp +++ b/src/sensors/KellerParent.cpp @@ -26,8 +26,9 @@ KellerParent::KellerParent(byte modbusAddress, Stream* stream, int8_t powerPin, _model(model), _modbusAddress(modbusAddress), _stream(stream), - _RS485EnablePin(enablePin), - _powerPin2(powerPin2) {} + _RS485EnablePin(enablePin) { + setSecondaryPowerPin(powerPin2); +} KellerParent::KellerParent(byte modbusAddress, Stream& stream, int8_t powerPin, int8_t powerPin2, int8_t enablePin, uint8_t measurementsToAverage, kellerModel model, @@ -41,8 +42,9 @@ KellerParent::KellerParent(byte modbusAddress, Stream& stream, int8_t powerPin, _model(model), _modbusAddress(modbusAddress), _stream(&stream), - _RS485EnablePin(enablePin), - _powerPin2(powerPin2) {} + _RS485EnablePin(enablePin) { + setSecondaryPowerPin(powerPin2); +} // Destructor KellerParent::~KellerParent() {} @@ -60,7 +62,6 @@ bool KellerParent::setup(void) { bool retVal = Sensor::setup(); // this will set pin modes and the setup status bit if (_RS485EnablePin >= 0) { pinMode(_RS485EnablePin, OUTPUT); } - if (_powerPin2 >= 0) { pinMode(_powerPin2, OUTPUT); } #ifdef MS_KELLERPARENT_DEBUG_DEEP _ksensor.setDebugStream(&MS_SERIAL_OUTPUT); @@ -85,72 +86,6 @@ bool KellerParent::sleep(void) { }; -// This turns on sensor power -void KellerParent::powerUp(void) { - if (_powerPin >= 0) { - // Reset power pin mode every power up because pins are set to tri-state - // on sleep - pinMode(_powerPin, OUTPUT); - MS_DBG(F("Powering"), getSensorNameAndLocation(), F("with pin"), - _powerPin); - digitalWrite(_powerPin, HIGH); - } - if (_powerPin2 >= 0) { - // Reset power pin mode every power up because pins are set to tri-state - // on sleep - pinMode(_powerPin2, OUTPUT); - MS_DBG(F("Applying secondary power to"), getSensorNameAndLocation(), - F("with pin"), _powerPin2); - digitalWrite(_powerPin2, HIGH); - } - if (_powerPin < 0 && _powerPin2 < 0) { - MS_DBG(F("Power to"), getSensorNameAndLocation(), - F("is not controlled by this library.")); - // Mark the power-on time, just in case it had not been marked - if (_millisPowerOn == 0) _millisPowerOn = millis(); - } else { - // Mark the time that the sensor was powered - _millisPowerOn = millis(); - } - // Reset enable pin because pins are set to tri-state on sleep - if (_RS485EnablePin >= 0) { pinMode(_RS485EnablePin, OUTPUT); } - // Set the status bit for sensor power attempt (bit 1) and success (bit 2) - setStatusBits(POWER_ATTEMPTED, POWER_SUCCESSFUL); -} - - -// This turns off sensor power -void KellerParent::powerDown(void) { - if (_powerPin >= 0) { - MS_DBG(F("Turning off power to"), getSensorNameAndLocation(), - F("with pin"), _powerPin); - digitalWrite(_powerPin, LOW); - // Unset the power-on time - _millisPowerOn = 0; - // Unset the activation time - _millisSensorActivated = 0; - // Unset the measurement request time - _millisMeasurementRequested = 0; - // Unset the status bits for sensor power (bits 1 & 2), - // activation (bits 3 & 4), and measurement request (bits 5 & 6) - clearStatusBits(POWER_ATTEMPTED, POWER_SUCCESSFUL, WAKE_ATTEMPTED, - WAKE_SUCCESSFUL, MEASUREMENT_ATTEMPTED, - MEASUREMENT_SUCCESSFUL); - } - if (_powerPin2 >= 0) { - MS_DBG(F("Turning off secondary power to"), getSensorNameAndLocation(), - F("with pin"), _powerPin2); - digitalWrite(_powerPin2, LOW); - } - if (_powerPin < 0 && _powerPin2 < 0) { - MS_DBG(F("Power to"), getSensorNameAndLocation(), - F("is not controlled by this library.")); - // Do NOT unset any status bits or timestamps if we didn't really power - // down! - } -} - - bool KellerParent::addSingleMeasurementResult(void) { bool success = false; diff --git a/src/sensors/KellerParent.h b/src/sensors/KellerParent.h index 4a4148670..505efa302 100644 --- a/src/sensors/KellerParent.h +++ b/src/sensors/KellerParent.h @@ -254,10 +254,6 @@ class KellerParent : public Sensor { // override to empty and flush the stream bool sleep(void) override; - // Override these to use two power pins - void powerUp(void) override; - void powerDown(void) override; - /** * @copydoc Sensor::addSingleMeasurementResult() */ @@ -287,10 +283,6 @@ class KellerParent : public Sensor { * pin. */ int8_t _RS485EnablePin; - /** - * @brief Private reference to the power pin fro the RS-485 adapter. - */ - int8_t _powerPin2; }; /**@}*/ #endif // SRC_SENSORS_KELLERPARENT_H_ diff --git a/src/sensors/YosemitechParent.cpp b/src/sensors/YosemitechParent.cpp index 4539ed0f6..a179674ef 100644 --- a/src/sensors/YosemitechParent.cpp +++ b/src/sensors/YosemitechParent.cpp @@ -24,8 +24,9 @@ YosemitechParent::YosemitechParent( _model(model), _modbusAddress(modbusAddress), _stream(stream), - _RS485EnablePin(enablePin), - _powerPin2(powerPin2) {} + _RS485EnablePin(enablePin) { + setSecondaryPowerPin(powerPin2); +} YosemitechParent::YosemitechParent( byte modbusAddress, Stream& stream, int8_t powerPin, int8_t powerPin2, int8_t enablePin, uint8_t measurementsToAverage, yosemitechModel model, @@ -38,8 +39,9 @@ YosemitechParent::YosemitechParent( _model(model), _modbusAddress(modbusAddress), _stream(&stream), - _RS485EnablePin(enablePin), - _powerPin2(powerPin2) {} + _RS485EnablePin(enablePin) { + setSecondaryPowerPin(powerPin2); +} // Destructor YosemitechParent::~YosemitechParent() {} @@ -57,7 +59,6 @@ bool YosemitechParent::setup(void) { bool retVal = Sensor::setup(); // this will set pin modes and the setup status bit if (_RS485EnablePin >= 0) { pinMode(_RS485EnablePin, OUTPUT); } - if (_powerPin2 >= 0) { pinMode(_powerPin2, OUTPUT); } #ifdef MS_YOSEMITECHPARENT_DEBUG_DEEP _ysensor.setDebugStream(&MS_SERIAL_OUTPUT); @@ -79,6 +80,7 @@ bool YosemitechParent::wake(void) { // Sensor::wake() checks if the power pin is on and sets the wake timestamp // and status bits. If it returns false, there's no reason to go on. if (!Sensor::wake()) return false; + if (_RS485EnablePin >= 0) { pinMode(_RS485EnablePin, OUTPUT); } // Send the command to begin taking readings, trying up to 5 times bool success = false; @@ -167,72 +169,6 @@ bool YosemitechParent::sleep(void) { } -// This turns on sensor power -void YosemitechParent::powerUp(void) { - if (_powerPin >= 0) { - // Reset power pin mode every power up because pins are set to tri-state - // on sleep - pinMode(_powerPin, OUTPUT); - MS_DBG(F("Powering"), getSensorNameAndLocation(), F("with pin"), - _powerPin); - digitalWrite(_powerPin, HIGH); - } - if (_powerPin2 >= 0) { - // Reset power pin mode every power up because pins are set to tri-state - // on sleep - pinMode(_powerPin2, OUTPUT); - MS_DBG(F("Applying secondary power to"), getSensorNameAndLocation(), - F("with pin"), _powerPin2); - digitalWrite(_powerPin2, HIGH); - } - if (_powerPin < 0 && _powerPin2 < 0) { - MS_DBG(F("Power to"), getSensorNameAndLocation(), - F("is not controlled by this library.")); - // Mark the power-on time, just in case it had not been marked - if (_millisPowerOn == 0) _millisPowerOn = millis(); - } else { - // Mark the time that the sensor was powered - _millisPowerOn = millis(); - } - // Reset enable pin because pins are set to tri-state on sleep - if (_RS485EnablePin >= 0) { pinMode(_RS485EnablePin, OUTPUT); } - // Set the status bit for sensor power attempt (bit 1) and success (bit 2) - setStatusBits(POWER_ATTEMPTED, POWER_SUCCESSFUL); -} - - -// This turns off sensor power -void YosemitechParent::powerDown(void) { - if (_powerPin >= 0) { - MS_DBG(F("Turning off power to"), getSensorNameAndLocation(), - F("with pin"), _powerPin); - digitalWrite(_powerPin, LOW); - // Unset the power-on time - _millisPowerOn = 0; - // Unset the activation time - _millisSensorActivated = 0; - // Unset the measurement request time - _millisMeasurementRequested = 0; - // Unset the status bits for sensor power (bits 1 & 2), - // activation (bits 3 & 4), and measurement request (bits 5 & 6) - clearStatusBits(POWER_ATTEMPTED, POWER_SUCCESSFUL, WAKE_ATTEMPTED, - WAKE_SUCCESSFUL, MEASUREMENT_ATTEMPTED, - MEASUREMENT_SUCCESSFUL); - } - if (_powerPin2 >= 0) { - MS_DBG(F("Turning off secondary power to"), getSensorNameAndLocation(), - F("with pin"), _powerPin2); - digitalWrite(_powerPin2, LOW); - } - if (_powerPin < 0 && _powerPin2 < 0) { - MS_DBG(F("Power to"), getSensorNameAndLocation(), - F("is not controlled by this library.")); - // Do NOT unset any status bits or timestamps if we didn't really power - // down! - } -} - - bool YosemitechParent::addSingleMeasurementResult(void) { bool success = false; diff --git a/src/sensors/YosemitechParent.h b/src/sensors/YosemitechParent.h index d71490790..9811a44ba 100644 --- a/src/sensors/YosemitechParent.h +++ b/src/sensors/YosemitechParent.h @@ -240,10 +240,6 @@ class YosemitechParent : public Sensor { */ bool sleep(void) override; - // Override these to use two power pins - void powerUp(void) override; - void powerDown(void) override; - /** * @copydoc Sensor::addSingleMeasurementResult() */ @@ -273,10 +269,6 @@ class YosemitechParent : public Sensor { * pin. */ int8_t _RS485EnablePin; - /** - * @brief Private reference to the power pin fro the RS-485 adapter. - */ - int8_t _powerPin2; }; #endif // SRC_SENSORS_YOSEMITECHPARENT_H_ From 165e04303587152fd60b80b85fb641e5c819fd86 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Thu, 25 Sep 2025 17:19:22 -0400 Subject: [PATCH 008/533] Missed ANB with power pins Signed-off-by: Sara Damiano --- src/sensors/ANBpH.cpp | 76 +++---------------------------------------- src/sensors/ANBpH.h | 8 ----- 2 files changed, 4 insertions(+), 80 deletions(-) diff --git a/src/sensors/ANBpH.cpp b/src/sensors/ANBpH.cpp index 10d77e7c2..2f67294dd 100644 --- a/src/sensors/ANBpH.cpp +++ b/src/sensors/ANBpH.cpp @@ -19,11 +19,11 @@ ANBpH::ANBpH(byte modbusAddress, Stream* stream, int8_t powerPin, -1, measurementsToAverage, ANB_PH_INC_CALC_VARIABLES), _anb_sensor(modbusAddress, stream, enablePin), _stream(stream), - _RS485EnablePin(enablePin), - _powerPin2(powerPin2) { + _RS485EnablePin(enablePin) { #ifdef MS_ANB_SENSORS_PH_DEBUG_DEEP _anb_sensor.setDebugStream(&MS_SERIAL_OUTPUT); #endif + setSecondaryPowerPin(powerPin2); } ANBpH::ANBpH(byte modbusAddress, Stream& stream, int8_t powerPin, int8_t powerPin2, int8_t enablePin, uint8_t measurementsToAverage) @@ -33,11 +33,11 @@ ANBpH::ANBpH(byte modbusAddress, Stream& stream, int8_t powerPin, _anb_sensor(modbusAddress, stream, enablePin), _modbusAddress(modbusAddress), _stream(&stream), - _RS485EnablePin(enablePin), - _powerPin2(powerPin2) { + _RS485EnablePin(enablePin) { #ifdef MS_ANB_SENSORS_PH_DEBUG_DEEP _anb_sensor.setDebugStream(&MS_SERIAL_OUTPUT); #endif + setSecondaryPowerPin(powerPin2); } // Destructor ANBpH::~ANBpH() {} @@ -56,7 +56,6 @@ bool ANBpH::setup(void) { bool retVal = Sensor::setup(); // this will set pin modes and the setup // status bit if (_RS485EnablePin >= 0) { pinMode(_RS485EnablePin, OUTPUT); } - if (_powerPin2 >= 0) { pinMode(_powerPin2, OUTPUT); } // This sensor needs power for setup! delay(10); @@ -304,73 +303,6 @@ bool ANBpH::sleep(void) { return success; } - -// This turns on sensor power -void ANBpH::powerUp(void) { - if (_powerPin >= 0) { - // Reset power pin mode every power up because pins are set to tri-state - // on sleep - pinMode(_powerPin, OUTPUT); - MS_DBG(F("Powering"), getSensorNameAndLocation(), F("with pin"), - _powerPin); - digitalWrite(_powerPin, HIGH); - } - if (_powerPin2 >= 0) { - // Reset power pin mode every power up because pins are set to tri-state - // on sleep - pinMode(_powerPin2, OUTPUT); - MS_DBG(F("Applying secondary power to"), getSensorNameAndLocation(), - F("with pin"), _powerPin2); - digitalWrite(_powerPin2, HIGH); - } - if (_powerPin < 0 && _powerPin2 < 0) { - MS_DBG(F("Power to"), getSensorNameAndLocation(), - F("is not controlled by this library.")); - // Mark the power-on time, just in case it had not been marked - if (_millisPowerOn == 0) _millisPowerOn = millis(); - } else { - // Mark the time that the sensor was powered - _millisPowerOn = millis(); - } - // Reset enable pin because pins are set to tri-state on sleep - if (_RS485EnablePin >= 0) { pinMode(_RS485EnablePin, OUTPUT); } - // Set the status bit for sensor power attempt (bit 1) and success (bit 2) - setStatusBits(POWER_ATTEMPTED, POWER_SUCCESSFUL); -} - - -// This turns off sensor power -void ANBpH::powerDown(void) { - if (_powerPin >= 0) { - MS_DBG(F("Turning off power to"), getSensorNameAndLocation(), - F("with pin"), _powerPin); - digitalWrite(_powerPin, LOW); - // Unset the power-on time - _millisPowerOn = 0; - // Unset the activation time - _millisSensorActivated = 0; - // Unset the measurement request time - _millisMeasurementRequested = 0; - // Unset the status bits for sensor power (bits 1 & 2), - // activation (bits 3 & 4), and measurement request (bits 5 & 6) - clearStatusBits(POWER_ATTEMPTED, POWER_SUCCESSFUL, WAKE_ATTEMPTED, - WAKE_SUCCESSFUL, MEASUREMENT_ATTEMPTED, - MEASUREMENT_SUCCESSFUL); - } - if (_powerPin2 >= 0) { - MS_DBG(F("Turning off secondary power to"), getSensorNameAndLocation(), - F("with pin"), _powerPin2); - digitalWrite(_powerPin2, LOW); - } - if (_powerPin < 0 && _powerPin2 < 0) { - MS_DBG(F("Power to"), getSensorNameAndLocation(), - F("is not controlled by this library.")); - // Do NOT unset any status bits or timestamps if we didn't really power - // down! - } -} - - bool ANBpH::addSingleMeasurementResult(void) { bool success = false; // Initialize variables for each value diff --git a/src/sensors/ANBpH.h b/src/sensors/ANBpH.h index 0080c1600..93cafbf23 100644 --- a/src/sensors/ANBpH.h +++ b/src/sensors/ANBpH.h @@ -530,10 +530,6 @@ class ANBpH : public Sensor { bool startSingleMeasurement(void) override; bool addSingleMeasurementResult(void) override; - // Override these to use two power pins - void powerUp(void) override; - void powerDown(void) override; - /** * @copydoc Sensor::isWarmedUp(bool debug) * @@ -617,10 +613,6 @@ class ANBpH : public Sensor { * pin. */ int8_t _RS485EnablePin; - /** - * @brief Private reference to the power pin fro the RS-485 adapter. - */ - int8_t _powerPin2; /** * @brief Private reference to the salinity mode for the ANB pH sensor. * @remark The salinity mode is set to low salinity by default. From e432d881baa82062227ec8ed5ba3ab415e1a2cbe Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Thu, 25 Sep 2025 17:48:36 -0400 Subject: [PATCH 009/533] Actually, lets track the number of retries Signed-off-by: Sara Damiano --- cspell.json | 2 ++ src/SensorBase.cpp | 11 +++++++- src/SensorBase.h | 39 ++++++++++++++++++++++++-- src/sensors/ANBpH.cpp | 14 +++++---- src/sensors/AOSongAM2315.cpp | 12 +++++--- src/sensors/AOSongDHT.cpp | 12 +++++--- src/sensors/AlphasenseCO2.cpp | 13 ++++++--- src/sensors/AnalogElecConductivity.cpp | 10 +++---- src/sensors/ApogeeSQ212.cpp | 14 +++++---- src/sensors/AtlasParent.cpp | 12 +++++--- src/sensors/BoschBME280.cpp | 10 +++++-- src/sensors/BoschBMP3xx.cpp | 10 +++++-- src/sensors/CampbellOBS3.cpp | 13 ++++++--- src/sensors/EverlightALSPT19.cpp | 9 +++--- src/sensors/FreescaleMPL115A2.cpp | 12 +++++--- src/sensors/GeoluxHydroCam.cpp | 10 +++++-- src/sensors/GroPointParent.cpp | 14 +++++---- src/sensors/KellerParent.cpp | 10 +++++-- src/sensors/MaxBotixSonar.cpp | 12 +++++--- src/sensors/MaximDS18.cpp | 12 +++++--- src/sensors/MaximDS3231.cpp | 9 +++--- src/sensors/MeaSpecMS5803.cpp | 10 +++++-- src/sensors/PaleoTerraRedox.cpp | 12 +++++--- src/sensors/ProcessorStats.cpp | 9 +++--- src/sensors/RainCounterI2C.cpp | 10 +++++-- src/sensors/SDI12Sensors.cpp | 24 ++++++++++------ src/sensors/SensirionSHT4x.cpp | 10 +++++-- src/sensors/TIADS1x15.cpp | 13 ++++++--- src/sensors/TIINA219.cpp | 12 ++++++-- src/sensors/TIINA219.h | 10 ++++--- src/sensors/TallyCounterI2C.cpp | 12 +++++--- src/sensors/TurnerCyclops.cpp | 13 ++++++--- src/sensors/TurnerTurbidityPlus.cpp | 11 ++++++-- src/sensors/YosemitechParent.cpp | 12 +++++--- 34 files changed, 287 insertions(+), 131 deletions(-) diff --git a/cspell.json b/cspell.json index b486606fa..1f2c4d2dc 100644 --- a/cspell.json +++ b/cspell.json @@ -173,6 +173,8 @@ "micromoles", "microsiemen", "microsiemens", + "milliamp", + "milliwatt", "Modbus", "MODSENSORCONFIG", "MODSENSORDEBUGGER", diff --git a/src/SensorBase.cpp b/src/SensorBase.cpp index 2fc71de61..f3da9be0d 100644 --- a/src/SensorBase.cpp +++ b/src/SensorBase.cpp @@ -83,6 +83,15 @@ void Sensor::setNumberMeasurementsToAverage(uint8_t nReadings) { uint8_t Sensor::getNumberMeasurementsToAverage(void) { return _measurementsToAverage; } +uint8_t Sensor::getNumberCompleteMeasurementsAttempts(void) { + return _measurementAttemptsCompleted; +} +uint8_t Sensor::getNumberRetryAttemptsMade(void) { + return _retryAttemptsMade; +} +uint8_t Sensor::getAllowedMeasurementRetries(void) { + return _allowedMeasurementRetries; +} // This returns the 8-bit code for the current status of the sensor. @@ -311,7 +320,7 @@ void Sensor::clearValues(void) { numberGoodMeasurementsMade[i] = 0; } _measurementAttemptsCompleted = 0; - _measurementsSucceeded = 0; + _retryAttemptsMade = 0; } diff --git a/src/SensorBase.h b/src/SensorBase.h index d9e419cf2..cf731a46c 100644 --- a/src/SensorBase.h +++ b/src/SensorBase.h @@ -43,6 +43,10 @@ // Include other in-library and external dependencies #include +/// @brief The maximum number of power pins the library can support for a single +/// sensor. +#define NUMBER_SUPPORTED_POWER_PINS 2 + class Variable; // Forward declaration /** @@ -186,6 +190,31 @@ class Sensor { * @copydetails _measurementsToAverage */ uint8_t getNumberMeasurementsToAverage(void); + /** + * @brief Get the number of measurement attempts that have been made and + * completed (whether successful or not). + * + * @return The number of complete measurement attempts. + */ + uint8_t getNumberCompleteMeasurementsAttempts(void); + /** + * @brief Get the number of retry attempts that have been made for a + * measurement + * + * @return The number of retries that have been made for the current + * measurement attempt. + * + * @note What is "successful" vs what qualifies for a retry varies by + * sensor. For some it may be that if any values were returned, for others + * that a specific value is in range, etc. + */ + uint8_t getNumberRetryAttemptsMade(void); + /** + * @brief Get the number of allowed retries if a measurement fails. + * + * @return The number of allowed retries. + */ + uint8_t getAllowedMeasurementRetries(void); /// @brief The significance of the various status bits @@ -599,10 +628,14 @@ class Sensor { */ uint8_t _measurementAttemptsCompleted = 0; /** - * @brief The number of measurements that have been **successfully** - * completed by the sensor **since last power on**. + * @brief The number of retries that have been attempted so far for a single + * measurement. + */ + uint8_t _retryAttemptsMade = 0; + /** + * @brief The number of allowed retries if a measurement fails. */ - uint8_t _measurementsSucceeded = 0; + uint8_t _allowedMeasurementRetries = 1; /** * @brief Array with the number of valid measurement values per variable by * the sensor in the current update cycle. diff --git a/src/sensors/ANBpH.cpp b/src/sensors/ANBpH.cpp index 2f67294dd..97b55e96d 100644 --- a/src/sensors/ANBpH.cpp +++ b/src/sensors/ANBpH.cpp @@ -374,8 +374,8 @@ bool ANBpH::addSingleMeasurementResult(void) { _millisMeasurementRequested = 0; // Unset the status bits for a measurement request (bits 5 & 6) clearStatusBits(MEASUREMENT_ATTEMPTED, MEASUREMENT_SUCCESSFUL); - // Bump the number of completed measurement attempts - _measurementAttemptsCompleted++; + // Bump the number of attempted retries + _retryAttemptsMade++; // We consider a measurement successful if we got a modbus response and // the pH value is in range or the health code says the sensor is not @@ -384,11 +384,15 @@ bool ANBpH::addSingleMeasurementResult(void) { // after an immersion error. if (success && ((0.0 < pH && pH < 14.00) || health == ANBHealthCode::NOT_IMMERSED)) { - // Bump the number of successful measurements - _measurementsSucceeded++; + // Bump the number of completed measurement attempts + _measurementAttemptsCompleted++; + } else if (_retryAttemptsMade >= _allowedMeasurementRetries) { + // Bump the number of completed measurement attempts - we've failed but + // exceeded retries + _measurementAttemptsCompleted++; } - // Return true when finished + // Return success value when finished return success; } diff --git a/src/sensors/AOSongAM2315.cpp b/src/sensors/AOSongAM2315.cpp index 097b8091c..0d2080a89 100644 --- a/src/sensors/AOSongAM2315.cpp +++ b/src/sensors/AOSongAM2315.cpp @@ -79,12 +79,16 @@ bool AOSongAM2315::addSingleMeasurementResult(void) { _millisMeasurementRequested = 0; // Unset the status bits for a measurement request (bits 5 & 6) clearStatusBits(MEASUREMENT_ATTEMPTED, MEASUREMENT_SUCCESSFUL); - // Bump the number of completed measurement attempts - _measurementAttemptsCompleted++; + // Bump the number of attempted retries + _retryAttemptsMade++; if (ret_val && !isnan(temp_val) && !isnan(humid_val)) { - // Bump the number of successful measurements - _measurementsSucceeded++; + // Bump the number of completed measurement attempts + _measurementAttemptsCompleted++; + } else if (_retryAttemptsMade >= _allowedMeasurementRetries) { + // Bump the number of completed measurement attempts - we've failed + // but exceeded retries + _measurementAttemptsCompleted++; } return ret_val; } diff --git a/src/sensors/AOSongDHT.cpp b/src/sensors/AOSongDHT.cpp index a8e7d3cb2..0f5b29c74 100644 --- a/src/sensors/AOSongDHT.cpp +++ b/src/sensors/AOSongDHT.cpp @@ -96,12 +96,16 @@ bool AOSongDHT::addSingleMeasurementResult(void) { _millisMeasurementRequested = 0; // Unset the status bits for a measurement request (bits 5 & 6) clearStatusBits(MEASUREMENT_ATTEMPTED, MEASUREMENT_SUCCESSFUL); - // Bump the number of completed measurement attempts - _measurementAttemptsCompleted++; + // Bump the number of attempted retries + _retryAttemptsMade++; if (success && !isnan(temp_val) && !isnan(humid_val)) { - // Bump the number of successful measurements - _measurementsSucceeded++; + // Bump the number of completed measurement attempts + _measurementAttemptsCompleted++; + } else if (_retryAttemptsMade >= _allowedMeasurementRetries) { + // Bump the number of completed measurement attempts - we've failed but + // exceeded retries + _measurementAttemptsCompleted++; } return success; diff --git a/src/sensors/AlphasenseCO2.cpp b/src/sensors/AlphasenseCO2.cpp index d27af1c5c..59f210235 100644 --- a/src/sensors/AlphasenseCO2.cpp +++ b/src/sensors/AlphasenseCO2.cpp @@ -112,13 +112,18 @@ bool AlphasenseCO2::addSingleMeasurementResult(void) { _millisMeasurementRequested = 0; // Unset the status bits for a measurement request (bits 5 & 6) clearStatusBits(MEASUREMENT_ATTEMPTED, MEASUREMENT_SUCCESSFUL); - // Bump the number of completed measurement attempts - _measurementAttemptsCompleted++; + // Bump the number of attempted retries + _retryAttemptsMade++; if (adcVoltage < 3.6 && adcVoltage > -0.3) { - // Bump the number of successful measurements - _measurementsSucceeded++; + // Bump the number of completed measurement attempts + _measurementAttemptsCompleted++; return true; + } else if (_retryAttemptsMade >= _allowedMeasurementRetries) { + // Bump the number of completed measurement attempts - we've failed but + // exceeded retries + _measurementAttemptsCompleted++; + return false; } else { return false; } diff --git a/src/sensors/AnalogElecConductivity.cpp b/src/sensors/AnalogElecConductivity.cpp index 09f3013ab..8cfc8942e 100644 --- a/src/sensors/AnalogElecConductivity.cpp +++ b/src/sensors/AnalogElecConductivity.cpp @@ -94,13 +94,11 @@ bool AnalogElecConductivity::addSingleMeasurementResult(void) { _millisMeasurementRequested = 0; // Unset the status bits for a measurement request (bits 5 & 6) clearStatusBits(MEASUREMENT_ATTEMPTED, MEASUREMENT_SUCCESSFUL); - - // Bump the number of completed measurement attempts - _measurementAttemptsCompleted++; - // Bump the number of successful measurements + // Bump the number of attempted retries + _retryAttemptsMade++; // NOTE: We don't actually have any criteria for if the reading was any good - // or not. - _measurementsSucceeded++; + // or not, so we mark it as completed no matter what. + _measurementAttemptsCompleted++; // Return true when finished return true; diff --git a/src/sensors/ApogeeSQ212.cpp b/src/sensors/ApogeeSQ212.cpp index 93f9e459f..0a7422784 100644 --- a/src/sensors/ApogeeSQ212.cpp +++ b/src/sensors/ApogeeSQ212.cpp @@ -107,14 +107,18 @@ bool ApogeeSQ212::addSingleMeasurementResult(void) { _millisMeasurementRequested = 0; // Unset the status bits for a measurement request (bits 5 & 6) clearStatusBits(MEASUREMENT_ATTEMPTED, MEASUREMENT_SUCCESSFUL); - // Bump the number of completed measurement attempts - _measurementAttemptsCompleted++; - + // Bump the number of attempted retries + _retryAttemptsMade++; if (adcVoltage < 3.6 && adcVoltage > -0.3) { - // Bump the number of successful measurements - _measurementsSucceeded++; + // Bump the number of completed measurement attempts + _measurementAttemptsCompleted++; return true; + } else if (_retryAttemptsMade >= _allowedMeasurementRetries) { + // Bump the number of completed measurement attempts - we've failed but + // exceeded retries + _measurementAttemptsCompleted++; + return false; } else { return false; } diff --git a/src/sensors/AtlasParent.cpp b/src/sensors/AtlasParent.cpp index 6dfe421cf..364f2351a 100644 --- a/src/sensors/AtlasParent.cpp +++ b/src/sensors/AtlasParent.cpp @@ -191,14 +191,18 @@ bool AtlasParent::addSingleMeasurementResult(void) { _millisMeasurementRequested = 0; // Unset the status bits for a measurement request (bits 5 & 6) clearStatusBits(MEASUREMENT_ATTEMPTED, MEASUREMENT_SUCCESSFUL); - // Bump the number of completed measurement attempts - _measurementAttemptsCompleted++; + // Bump the number of attempted retries + _retryAttemptsMade++; if (success) { - // Bump the number of successful measurements + // Bump the number of completed measurement attempts // NOTE: This is bumped if we got a successful response code, // even if the results were NaN or otherwise invalid! - _measurementsSucceeded++; + _measurementAttemptsCompleted++; + } else if (_retryAttemptsMade >= _allowedMeasurementRetries) { + // Bump the number of completed measurement attempts - we've failed but + // exceeded retries + _measurementAttemptsCompleted++; } return success; diff --git a/src/sensors/BoschBME280.cpp b/src/sensors/BoschBME280.cpp index 4e8879903..f568cf4f6 100644 --- a/src/sensors/BoschBME280.cpp +++ b/src/sensors/BoschBME280.cpp @@ -167,14 +167,18 @@ bool BoschBME280::addSingleMeasurementResult(void) { _millisMeasurementRequested = 0; // Unset the status bits for a measurement request (bits 5 & 6) clearStatusBits(MEASUREMENT_ATTEMPTED, MEASUREMENT_SUCCESSFUL); - // Bump the number of completed measurement attempts - _measurementAttemptsCompleted++; + // Bump the number of attempted retries + _retryAttemptsMade++; if (success) { // Bump the number of successful measurements // NOTE: Any one of the values being NOT -9999 is not considered a // success! - _measurementsSucceeded++; + _measurementAttemptsCompleted++; + } else if (_retryAttemptsMade >= _allowedMeasurementRetries) { + // Bump the number of completed measurement attempts - we've failed but + // exceeded retries + _measurementAttemptsCompleted++; } return success; diff --git a/src/sensors/BoschBMP3xx.cpp b/src/sensors/BoschBMP3xx.cpp index 286b0d5a5..05e18a14e 100644 --- a/src/sensors/BoschBMP3xx.cpp +++ b/src/sensors/BoschBMP3xx.cpp @@ -316,14 +316,18 @@ bool BoschBMP3xx::addSingleMeasurementResult(void) { _millisMeasurementRequested = 0; // Unset the status bits for a measurement request (bits 5 & 6) clearStatusBits(MEASUREMENT_ATTEMPTED, MEASUREMENT_SUCCESSFUL); - // Bump the number of completed measurement attempts - _measurementAttemptsCompleted++; + // Bump the number of attempted retries + _retryAttemptsMade++; if (success) { // Bump the number of successful measurements // NOTE: This is bumped if we successfully got a response, even if the // results were NaN or otherwise invalid! - _measurementsSucceeded++; + _measurementAttemptsCompleted++; + } else if (_retryAttemptsMade >= _allowedMeasurementRetries) { + // Bump the number of completed measurement attempts - we've failed but + // exceeded retries + _measurementAttemptsCompleted++; } return success; diff --git a/src/sensors/CampbellOBS3.cpp b/src/sensors/CampbellOBS3.cpp index 6b45e3b2e..d004cb0d3 100644 --- a/src/sensors/CampbellOBS3.cpp +++ b/src/sensors/CampbellOBS3.cpp @@ -111,13 +111,18 @@ bool CampbellOBS3::addSingleMeasurementResult(void) { _millisMeasurementRequested = 0; // Unset the status bits for a measurement request (bits 5 & 6) clearStatusBits(MEASUREMENT_ATTEMPTED, MEASUREMENT_SUCCESSFUL); - // Bump the number of completed measurement attempts - _measurementAttemptsCompleted++; + // Bump the number of attempted retries + _retryAttemptsMade++; if (adcVoltage < 3.6 && adcVoltage > -0.3) { - // Bump the number of successful measurements - _measurementsSucceeded++; + // Bump the number of completed measurement attempts + _measurementAttemptsCompleted++; return true; + } else if (_retryAttemptsMade >= _allowedMeasurementRetries) { + // Bump the number of completed measurement attempts - we've failed but + // exceeded retries + _measurementAttemptsCompleted++; + return false; } else { return false; } diff --git a/src/sensors/EverlightALSPT19.cpp b/src/sensors/EverlightALSPT19.cpp index 4b47c6756..e4714d883 100644 --- a/src/sensors/EverlightALSPT19.cpp +++ b/src/sensors/EverlightALSPT19.cpp @@ -83,12 +83,11 @@ bool EverlightALSPT19::addSingleMeasurementResult(void) { _millisMeasurementRequested = 0; // Unset the status bits for a measurement request (bits 5 & 6) clearStatusBits(MEASUREMENT_ATTEMPTED, MEASUREMENT_SUCCESSFUL); - // Bump the number of completed measurement attempts - _measurementAttemptsCompleted++; - // Bump the number of successful measurements + // Bump the number of attempted retries + _retryAttemptsMade++; // NOTE: We don't actually have any criteria for if the reading was any good - // or not. - _measurementsSucceeded++; + // or not, so we mark it as completed no matter what. + _measurementAttemptsCompleted++; return true; } diff --git a/src/sensors/FreescaleMPL115A2.cpp b/src/sensors/FreescaleMPL115A2.cpp index 986c7e04f..519bf7ca9 100644 --- a/src/sensors/FreescaleMPL115A2.cpp +++ b/src/sensors/FreescaleMPL115A2.cpp @@ -93,12 +93,16 @@ bool FreescaleMPL115A2::addSingleMeasurementResult(void) { _millisMeasurementRequested = 0; // Unset the status bits for a measurement request (bits 5 & 6) clearStatusBits(MEASUREMENT_ATTEMPTED, MEASUREMENT_SUCCESSFUL); - // Bump the number of completed measurement attempts - _measurementAttemptsCompleted++; + // Bump the number of attempted retries + _retryAttemptsMade++; if (temp != -9999 && press != -9999) { - // Bump the number of successful measurements - _measurementsSucceeded++; + // Bump the number of completed measurement attempts + _measurementAttemptsCompleted++; + } else if (_retryAttemptsMade >= _allowedMeasurementRetries) { + // Bump the number of completed measurement attempts - we've failed but + // exceeded retries + _measurementAttemptsCompleted++; } // no way of knowing if the communication was successful, just return true diff --git a/src/sensors/GeoluxHydroCam.cpp b/src/sensors/GeoluxHydroCam.cpp index 465f0dd9f..cc6243459 100644 --- a/src/sensors/GeoluxHydroCam.cpp +++ b/src/sensors/GeoluxHydroCam.cpp @@ -261,14 +261,18 @@ bool GeoluxHydroCam::addSingleMeasurementResult(void) { _millisMeasurementRequested = 0; // Unset the status bits for a measurement request (bits 5 & 6) clearStatusBits(MEASUREMENT_ATTEMPTED, MEASUREMENT_SUCCESSFUL); - // Bump the number of completed measurement attempts - _measurementAttemptsCompleted++; + // Bump the number of attempted retries + _retryAttemptsMade++; if (success) { // Bump the number of successful measurements // NOTE: We consider the measurement a success only if we got all the // bytes we expected! - _measurementsSucceeded++; + _measurementAttemptsCompleted++; + } else if (_retryAttemptsMade >= _allowedMeasurementRetries) { + // Bump the number of completed measurement attempts - we've failed but + // exceeded retries + _measurementAttemptsCompleted++; } // Return values shows if we got a not-obviously-bad reading diff --git a/src/sensors/GroPointParent.cpp b/src/sensors/GroPointParent.cpp index 6835f8ae9..0f3d566cf 100644 --- a/src/sensors/GroPointParent.cpp +++ b/src/sensors/GroPointParent.cpp @@ -260,15 +260,19 @@ bool GroPointParent::addSingleMeasurementResult(void) { _millisMeasurementRequested = 0; // Unset the status bits for a measurement request (bits 5 & 6) clearStatusBits(MEASUREMENT_ATTEMPTED, MEASUREMENT_SUCCESSFUL); - // Bump the number of completed measurement attempts - _measurementAttemptsCompleted++; + // Bump the number of attempted retries + _retryAttemptsMade++; if (success && successT) { - // Bump the number of successful measurements - _measurementsSucceeded++; + // Bump the number of completed measurement attempts + _measurementAttemptsCompleted++; + } else if (_retryAttemptsMade >= _allowedMeasurementRetries) { + // Bump the number of completed measurement attempts - we've failed but + // exceeded retries + _measurementAttemptsCompleted++; } - // Return true when finished + // Return success value when finished return success && successT; } diff --git a/src/sensors/KellerParent.cpp b/src/sensors/KellerParent.cpp index 9ab679720..e1ee7fa43 100644 --- a/src/sensors/KellerParent.cpp +++ b/src/sensors/KellerParent.cpp @@ -132,8 +132,8 @@ bool KellerParent::addSingleMeasurementResult(void) { _millisMeasurementRequested = 0; // Unset the status bits for a measurement request (bits 5 & 6) clearStatusBits(MEASUREMENT_ATTEMPTED, MEASUREMENT_SUCCESSFUL); - // Bump the number of completed measurement attempts - _measurementAttemptsCompleted++; + // Bump the number of attempted retries + _retryAttemptsMade++; if (success && (waterPressureBar != -9999 || waterTemperatureC != -9999 || @@ -141,7 +141,11 @@ bool KellerParent::addSingleMeasurementResult(void) { // Bump the number of successful measurements // NOTE: Any one of the values being NOT -9999 is not considered a // success! - _measurementsSucceeded++; + _measurementAttemptsCompleted++; + } else if (_retryAttemptsMade >= _allowedMeasurementRetries) { + // Bump the number of completed measurement attempts - we've failed but + // exceeded retries + _measurementAttemptsCompleted++; } // Return true when finished diff --git a/src/sensors/MaxBotixSonar.cpp b/src/sensors/MaxBotixSonar.cpp index 1682d397a..120c1a096 100644 --- a/src/sensors/MaxBotixSonar.cpp +++ b/src/sensors/MaxBotixSonar.cpp @@ -198,12 +198,16 @@ bool MaxBotixSonar::addSingleMeasurementResult(void) { _millisMeasurementRequested = 0; // Unset the status bits for a measurement request (bits 5 & 6) clearStatusBits(MEASUREMENT_ATTEMPTED, MEASUREMENT_SUCCESSFUL); - // Bump the number of completed measurement attempts - _measurementAttemptsCompleted++; + // Bump the number of attempted retries + _retryAttemptsMade++; if (success) { - // Bump the number of successful measurements - _measurementsSucceeded++; + // Bump the number of completed measurement attempts + _measurementAttemptsCompleted++; + } else if (_retryAttemptsMade >= _allowedMeasurementRetries) { + // Bump the number of completed measurement attempts - we've failed but + // exceeded retries + _measurementAttemptsCompleted++; } // Return values shows if we got a not-obviously-bad reading diff --git a/src/sensors/MaximDS18.cpp b/src/sensors/MaximDS18.cpp index 4d5e2304d..347c65829 100644 --- a/src/sensors/MaximDS18.cpp +++ b/src/sensors/MaximDS18.cpp @@ -210,12 +210,16 @@ bool MaximDS18::addSingleMeasurementResult(void) { _millisMeasurementRequested = 0; // Unset the status bits for a measurement request (bits 5 & 6) clearStatusBits(MEASUREMENT_ATTEMPTED, MEASUREMENT_SUCCESSFUL); - // Bump the number of completed measurement attempts - _measurementAttemptsCompleted++; + // Bump the number of attempted retries + _retryAttemptsMade++; if (success && result != -9999) { - // Bump the number of successful measurements - _measurementsSucceeded++; + // Bump the number of completed measurement attempts + _measurementAttemptsCompleted++; + } else if (_retryAttemptsMade >= _allowedMeasurementRetries) { + // Bump the number of completed measurement attempts - we've failed but + // exceeded retries + _measurementAttemptsCompleted++; } return success; diff --git a/src/sensors/MaximDS3231.cpp b/src/sensors/MaximDS3231.cpp index aea18b9b1..6c81aa8ee 100644 --- a/src/sensors/MaximDS3231.cpp +++ b/src/sensors/MaximDS3231.cpp @@ -65,12 +65,11 @@ bool MaximDS3231::addSingleMeasurementResult(void) { _millisMeasurementRequested = 0; // Unset the status bits for a measurement request (bits 5 & 6) clearStatusBits(MEASUREMENT_ATTEMPTED, MEASUREMENT_SUCCESSFUL); - // Bump the number of completed measurement attempts - _measurementAttemptsCompleted++; - // Bump the number of successful measurements + // Bump the number of attempted retries + _retryAttemptsMade++; // NOTE: We don't actually have any criteria for if the reading was any good - // or not. - _measurementsSucceeded++; + // or not, so we mark it as completed no matter what. + _measurementAttemptsCompleted++; // Return true when finished return true; diff --git a/src/sensors/MeaSpecMS5803.cpp b/src/sensors/MeaSpecMS5803.cpp index adb5b9964..7aefde181 100644 --- a/src/sensors/MeaSpecMS5803.cpp +++ b/src/sensors/MeaSpecMS5803.cpp @@ -97,14 +97,18 @@ bool MeaSpecMS5803::addSingleMeasurementResult(void) { _millisMeasurementRequested = 0; // Unset the status bits for a measurement request (bits 5 & 6) clearStatusBits(MEASUREMENT_ATTEMPTED, MEASUREMENT_SUCCESSFUL); - // Bump the number of completed measurement attempts - _measurementAttemptsCompleted++; + // Bump the number of attempted retries + _retryAttemptsMade++; if (success && (temp != -9999 || press != -9999)) { // Bump the number of successful measurements // NOTE: Any one of the values being NOT -9999 is not considered a // success! - _measurementsSucceeded++; + _measurementAttemptsCompleted++; + } else if (_retryAttemptsMade >= _allowedMeasurementRetries) { + // Bump the number of completed measurement attempts - we've failed but + // exceeded retries + _measurementAttemptsCompleted++; } return success; diff --git a/src/sensors/PaleoTerraRedox.cpp b/src/sensors/PaleoTerraRedox.cpp index d609254f3..978377184 100644 --- a/src/sensors/PaleoTerraRedox.cpp +++ b/src/sensors/PaleoTerraRedox.cpp @@ -155,12 +155,16 @@ bool PaleoTerraRedox::addSingleMeasurementResult(void) { clearStatusBit(MEASUREMENT_ATTEMPTED); // Set the status bit for measurement completion (bit 6) setStatusBit(MEASUREMENT_SUCCESSFUL); - // Bump the number of completed measurement attempts - _measurementAttemptsCompleted++; + // Bump the number of attempted retries + _retryAttemptsMade++; if (success && (res != -9999)) { - // Bump the number of successful measurements - _measurementsSucceeded++; + // Bump the number of completed measurement attempts + _measurementAttemptsCompleted++; + } else if (_retryAttemptsMade >= _allowedMeasurementRetries) { + // Bump the number of completed measurement attempts - we've failed but + // exceeded retries + _measurementAttemptsCompleted++; } return success; diff --git a/src/sensors/ProcessorStats.cpp b/src/sensors/ProcessorStats.cpp index 8f18bf8fd..42f61604b 100644 --- a/src/sensors/ProcessorStats.cpp +++ b/src/sensors/ProcessorStats.cpp @@ -293,12 +293,11 @@ bool ProcessorStats::addSingleMeasurementResult(void) { _millisMeasurementRequested = 0; // Unset the status bits for a measurement request (bits 5 & 6) clearStatusBits(MEASUREMENT_ATTEMPTED, MEASUREMENT_SUCCESSFUL); - // Bump the number of completed measurement attempts - _measurementAttemptsCompleted++; - // Bump the number of successful measurements + // Bump the number of attempted retries + _retryAttemptsMade++; // NOTE: We don't actually have any criteria for if the reading was any good - // or not. - _measurementsSucceeded++; + // or not, so we mark it as completed no matter what. + _measurementAttemptsCompleted++; // Return true when finished return true; diff --git a/src/sensors/RainCounterI2C.cpp b/src/sensors/RainCounterI2C.cpp index aa623733b..68abadb70 100644 --- a/src/sensors/RainCounterI2C.cpp +++ b/src/sensors/RainCounterI2C.cpp @@ -154,14 +154,18 @@ bool RainCounterI2C::addSingleMeasurementResult(void) { _millisMeasurementRequested = 0; // Unset the status bits for a measurement request (bits 5 & 6) clearStatusBits(MEASUREMENT_ATTEMPTED, MEASUREMENT_SUCCESSFUL); - // Bump the number of completed measurement attempts - _measurementAttemptsCompleted++; + // Bump the number of attempted retries + _retryAttemptsMade++; if (rain != -9999 || tips != -9999) { // Bump the number of successful measurements // NOTE: Any one of the values being NOT -9999 is not considered a // success! - _measurementsSucceeded++; + _measurementAttemptsCompleted++; + } else if (_retryAttemptsMade >= _allowedMeasurementRetries) { + // Bump the number of completed measurement attempts - we've failed but + // exceeded retries + _measurementAttemptsCompleted++; } // Return true when finished diff --git a/src/sensors/SDI12Sensors.cpp b/src/sensors/SDI12Sensors.cpp index 0196bbd31..692640bc1 100644 --- a/src/sensors/SDI12Sensors.cpp +++ b/src/sensors/SDI12Sensors.cpp @@ -728,12 +728,16 @@ bool SDI12Sensors::addSingleMeasurementResult(void) { _millisMeasurementRequested = 0; // Unset the status bits for a measurement request (bits 5 & 6) clearStatusBits(MEASUREMENT_ATTEMPTED, MEASUREMENT_SUCCESSFUL); - // Bump the number of completed measurement attempts - _measurementAttemptsCompleted++; + // Bump the number of attempted retries + _retryAttemptsMade++; if (success) { - // Bump the number of successful measurements - _measurementsSucceeded++; + // Bump the number of completed measurement attempts + _measurementAttemptsCompleted++; + } else if (_retryAttemptsMade >= _allowedMeasurementRetries) { + // Bump the number of completed measurement attempts - we've failed but + // exceeded retries + _measurementAttemptsCompleted++; } return success; @@ -816,12 +820,16 @@ bool SDI12Sensors::addSingleMeasurementResult(void) { _millisMeasurementRequested = 0; // Unset the status bits for a measurement request (bits 5 & 6) clearStatusBits(MEASUREMENT_ATTEMPTED, MEASUREMENT_SUCCESSFUL); - // Bump the number of completed measurement attempts - _measurementAttemptsCompleted++; + // Bump the number of attempted retries + _retryAttemptsMade++; if (success) { - // Bump the number of successful measurements - _measurementsSucceeded++; + // Bump the number of completed measurement attempts + _measurementAttemptsCompleted++; + } else if (_retryAttemptsMade >= _allowedMeasurementRetries) { + // Bump the number of completed measurement attempts - we've failed but + // exceeded retries + _measurementAttemptsCompleted++; } return success; diff --git a/src/sensors/SensirionSHT4x.cpp b/src/sensors/SensirionSHT4x.cpp index 6e896905d..a16447def 100644 --- a/src/sensors/SensirionSHT4x.cpp +++ b/src/sensors/SensirionSHT4x.cpp @@ -127,14 +127,18 @@ bool SensirionSHT4x::addSingleMeasurementResult(void) { _millisMeasurementRequested = 0; // Unset the status bits for a measurement request (bits 5 & 6) clearStatusBits(MEASUREMENT_ATTEMPTED, MEASUREMENT_SUCCESSFUL); - // Bump the number of completed measurement attempts - _measurementAttemptsCompleted++; + // Bump the number of attempted retries + _retryAttemptsMade++; if (ret_val && (temp_val != -9999 || humid_val != -9999)) { // Bump the number of successful measurements // NOTE: Any one of the values being NOT -9999 is not considered a // success! - _measurementsSucceeded++; + _measurementAttemptsCompleted++; + } else if (_retryAttemptsMade >= _allowedMeasurementRetries) { + // Bump the number of completed measurement attempts - we've failed but + // exceeded retries + _measurementAttemptsCompleted++; } return ret_val; diff --git a/src/sensors/TIADS1x15.cpp b/src/sensors/TIADS1x15.cpp index a8801a61e..11a32bb22 100644 --- a/src/sensors/TIADS1x15.cpp +++ b/src/sensors/TIADS1x15.cpp @@ -103,13 +103,18 @@ bool TIADS1x15::addSingleMeasurementResult(void) { _millisMeasurementRequested = 0; // Unset the status bits for a measurement request (bits 5 & 6) clearStatusBits(MEASUREMENT_ATTEMPTED, MEASUREMENT_SUCCESSFUL); - // Bump the number of completed measurement attempts - _measurementAttemptsCompleted++; + // Bump the number of attempted retries + _retryAttemptsMade++; if (adcVoltage < 3.6 && adcVoltage > -0.3) { - // Bump the number of successful measurements - _measurementsSucceeded++; + // Bump the number of completed measurement attempts + _measurementAttemptsCompleted++; return true; + } else if (_retryAttemptsMade >= _allowedMeasurementRetries) { + // Bump the number of completed measurement attempts - we've failed but + // exceeded retries + _measurementAttemptsCompleted++; + return false; } else { return false; } diff --git a/src/sensors/TIINA219.cpp b/src/sensors/TIINA219.cpp index 797ac933f..409a761a7 100644 --- a/src/sensors/TIINA219.cpp +++ b/src/sensors/TIINA219.cpp @@ -110,16 +110,22 @@ bool TIINA219::addSingleMeasurementResult(void) { _millisMeasurementRequested = 0; // Unset the status bits for a measurement request (bits 5 & 6) clearStatusBits(MEASUREMENT_ATTEMPTED, MEASUREMENT_SUCCESSFUL); - // Bump the number of completed measurement attempts - _measurementAttemptsCompleted++; + // Bump the number of attempted retries + _retryAttemptsMade++; if (success && (current_mA != -9999 || busV_V != -9999 || power_mW != -9999)) { // Bump the number of successful measurements // NOTE: Any one of the values being NOT -9999 is not considered a // success! - _measurementsSucceeded++; + _measurementAttemptsCompleted++; + } else if (_retryAttemptsMade >= _allowedMeasurementRetries) { + // Bump the number of completed measurement attempts - we've failed but + // exceeded retries + _measurementAttemptsCompleted++; } return success; } + +// cSpell:ignore TIINA219 diff --git a/src/sensors/TIINA219.h b/src/sensors/TIINA219.h index e96426aff..55737a0f0 100644 --- a/src/sensors/TIINA219.h +++ b/src/sensors/TIINA219.h @@ -6,7 +6,7 @@ * @author Written By: Neil Hancock * Edited by Sara Geleskie Damiano * - * @brief Contains the TIINA219 sensor subclass and the variale subclasses + * @brief Contains the TIINA219 sensor subclass and the variable subclasses * TIINA219_Current, TIINA219_Voltage, and TIINA219_Power. * * These are for the Texas Instruments INA219 current/voltage sensor. @@ -24,7 +24,7 @@ * @tableofcontents * @m_footernavigation * - * @section sensor_ina219_intro Intruduction + * @section sensor_ina219_intro Introduction * * The [TI INA219](http://www.ti.com/product/INA219) is a bi-directional, * high-side, current/power monitor that communicates with the board via I2C. @@ -34,7 +34,7 @@ * of this sensor can be increased to increase sensitivity (at the expense of * range) but this library assumes the maximum range. * - * Commuincation between the INA219 and the mcu is managed by the + * Communications between the INA219 and the mcu is managed by the * [Adafruit INA219 Library](https://github.com/adafruit/Adafruit_INA219) * * @note Software I2C is *not* supported for the INA219. @@ -119,7 +119,7 @@ /** * @brief Sensor::_stabilizationTime_ms; the INA219 is stable after 4000ms. * - * Stable numbers can be acheived after 500ms, but waiting up to 4s gave more + * Stable numbers can be achieved after 500ms, but waiting up to 4s gave more * consistent numbers based on tests using INA219timingTest.ino */ #define INA219_STABILIZATION_TIME_MS 4000 @@ -454,3 +454,5 @@ class TIINA219_Power : public Variable { }; /**@}*/ #endif // SRC_SENSORS_TIINA219_H_ + +// cSpell:ignore TIINA219 diff --git a/src/sensors/TallyCounterI2C.cpp b/src/sensors/TallyCounterI2C.cpp index 1101d77a8..54ba576b9 100644 --- a/src/sensors/TallyCounterI2C.cpp +++ b/src/sensors/TallyCounterI2C.cpp @@ -111,12 +111,16 @@ bool TallyCounterI2C::addSingleMeasurementResult(void) { _millisMeasurementRequested = 0; // Unset the status bits for a measurement request (bits 5 & 6) clearStatusBits(MEASUREMENT_ATTEMPTED, MEASUREMENT_SUCCESSFUL); - // Bump the number of completed measurement attempts - _measurementAttemptsCompleted++; + // Bump the number of attempted retries + _retryAttemptsMade++; if (success) { - // Bump the number of successful measurements - _measurementsSucceeded++; + // Bump the number of completed measurement attempts + _measurementAttemptsCompleted++; + } else if (_retryAttemptsMade >= _allowedMeasurementRetries) { + // Bump the number of completed measurement attempts - we've failed but + // exceeded retries + _measurementAttemptsCompleted++; } return success; diff --git a/src/sensors/TurnerCyclops.cpp b/src/sensors/TurnerCyclops.cpp index 0d98ea32d..bc90d639f 100644 --- a/src/sensors/TurnerCyclops.cpp +++ b/src/sensors/TurnerCyclops.cpp @@ -111,13 +111,18 @@ bool TurnerCyclops::addSingleMeasurementResult(void) { _millisMeasurementRequested = 0; // Unset the status bits for a measurement request (bits 5 & 6) clearStatusBits(MEASUREMENT_ATTEMPTED, MEASUREMENT_SUCCESSFUL); - // Bump the number of completed measurement attempts - _measurementAttemptsCompleted++; + // Bump the number of attempted retries + _retryAttemptsMade++; if (adcVoltage < 3.6 && adcVoltage > -0.3) { - // Bump the number of successful measurements - _measurementsSucceeded++; + // Bump the number of completed measurement attempts + _measurementAttemptsCompleted++; return true; + } else if (_retryAttemptsMade >= _allowedMeasurementRetries) { + // Bump the number of completed measurement attempts - we've failed but + // exceeded retries + _measurementAttemptsCompleted++; + return false; } else { return false; } diff --git a/src/sensors/TurnerTurbidityPlus.cpp b/src/sensors/TurnerTurbidityPlus.cpp index 2d622e5bc..91adaf7e2 100644 --- a/src/sensors/TurnerTurbidityPlus.cpp +++ b/src/sensors/TurnerTurbidityPlus.cpp @@ -173,13 +173,18 @@ bool TurnerTurbidityPlus::addSingleMeasurementResult(void) { _millisMeasurementRequested = 0; // Unset the status bits for a measurement request (bits 5 & 6) clearStatusBits(MEASUREMENT_ATTEMPTED, MEASUREMENT_SUCCESSFUL); - // Bump the number of completed measurement attempts - _measurementAttemptsCompleted++; + // Bump the number of attempted retries + _retryAttemptsMade++; if (adcVoltage < 5.3 && adcVoltage > -0.3) { // Bump the number of successful measurements - _measurementsSucceeded++; + _measurementAttemptsCompleted++; return true; + } else if (_retryAttemptsMade >= _allowedMeasurementRetries) { + // Bump the number of completed measurement attempts - we've failed but + // exceeded retries + _measurementAttemptsCompleted++; + return false; } else { return false; } diff --git a/src/sensors/YosemitechParent.cpp b/src/sensors/YosemitechParent.cpp index a179674ef..9dba5cd29 100644 --- a/src/sensors/YosemitechParent.cpp +++ b/src/sensors/YosemitechParent.cpp @@ -261,12 +261,16 @@ bool YosemitechParent::addSingleMeasurementResult(void) { _millisMeasurementRequested = 0; // Unset the status bits for a measurement request (bits 5 & 6) clearStatusBits(MEASUREMENT_ATTEMPTED, MEASUREMENT_SUCCESSFUL); - // Bump the number of completed measurement attempts - _measurementAttemptsCompleted++; + // Bump the number of attempted retries + _retryAttemptsMade++; if (success) { - // Bump the number of successful measurements - _measurementsSucceeded++; + // Bump the number of completed measurement attempts + _measurementAttemptsCompleted++; + } else if (_retryAttemptsMade >= _allowedMeasurementRetries) { + // Bump the number of completed measurement attempts - we've failed but + // exceeded retries + _measurementAttemptsCompleted++; } // Return true when finished From a93f89039b2e878538df32a01e49afceb3e33786 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Thu, 25 Sep 2025 18:17:49 -0400 Subject: [PATCH 010/533] remove dumb copydocs Signed-off-by: Sara Damiano --- src/sensors/ANBpH.h | 3 --- src/sensors/AOSongAM2315.h | 3 --- src/sensors/AOSongDHT.h | 9 --------- src/sensors/AlphasenseCO2.h | 3 --- src/sensors/AnalogElecConductivity.h | 3 --- src/sensors/ApogeeSQ212.h | 3 --- src/sensors/AtlasParent.h | 3 --- src/sensors/BoschBME280.h | 11 +---------- src/sensors/BoschBMP3xx.h | 14 +------------- src/sensors/CampbellOBS3.h | 6 ------ src/sensors/EverlightALSPT19.h | 3 --- src/sensors/FreescaleMPL115A2.h | 8 +------- src/sensors/GeoluxHydroCam.h | 11 ----------- src/sensors/GroPointParent.h | 10 +--------- src/sensors/KellerParent.h | 6 ------ src/sensors/MaxBotixSonar.h | 6 ------ src/sensors/MaximDS18.h | 8 +------- src/sensors/MaximDS3231.h | 6 ------ src/sensors/MeaSpecMS5803.h | 8 +------- src/sensors/PaleoTerraRedox.h | 8 +------- src/sensors/ProcessorStats.h | 3 --- src/sensors/RainCounterI2C.h | 8 +------- src/sensors/SDI12Sensors.h | 3 --- src/sensors/SensirionSHT4x.h | 3 --- src/sensors/TIADS1x15.h | 6 ------ src/sensors/TIINA219.h | 8 +------- src/sensors/TallyCounterI2C.h | 9 +-------- src/sensors/TurnerCyclops.h | 6 ------ src/sensors/TurnerTurbidityPlus.h | 6 ------ src/sensors/YosemitechParent.h | 9 --------- 30 files changed, 10 insertions(+), 183 deletions(-) diff --git a/src/sensors/ANBpH.h b/src/sensors/ANBpH.h index 93cafbf23..f23a4661c 100644 --- a/src/sensors/ANBpH.h +++ b/src/sensors/ANBpH.h @@ -508,9 +508,6 @@ class ANBpH : public Sensor { */ virtual ~ANBpH(); - /** - * @copydoc Sensor::getSensorLocation() - */ String getSensorLocation(void) override; /** diff --git a/src/sensors/AOSongAM2315.h b/src/sensors/AOSongAM2315.h index 3fbf53cc3..2edaf734e 100644 --- a/src/sensors/AOSongAM2315.h +++ b/src/sensors/AOSongAM2315.h @@ -237,9 +237,6 @@ class AOSongAM2315 : public Sensor { */ bool setup(void) override; - /** - * @copydoc Sensor::addSingleMeasurementResult() - */ bool addSingleMeasurementResult(void) override; private: diff --git a/src/sensors/AOSongDHT.h b/src/sensors/AOSongDHT.h index 849eae226..577b95ab6 100644 --- a/src/sensors/AOSongDHT.h +++ b/src/sensors/AOSongDHT.h @@ -244,19 +244,10 @@ class AOSongDHT : public Sensor { */ ~AOSongDHT(); - /** - * @copydoc Sensor::setup() - */ bool setup(void) override; - /** - * @copydoc Sensor::getSensorName() - */ String getSensorName(void) override; - /** - * @copydoc Sensor::addSingleMeasurementResult() - */ bool addSingleMeasurementResult(void) override; private: diff --git a/src/sensors/AlphasenseCO2.h b/src/sensors/AlphasenseCO2.h index 2d4de16b3..998647536 100644 --- a/src/sensors/AlphasenseCO2.h +++ b/src/sensors/AlphasenseCO2.h @@ -289,9 +289,6 @@ class AlphasenseCO2 : public Sensor { */ String getSensorLocation(void) override; - /** - * @copydoc Sensor::addSingleMeasurementResult() - */ bool addSingleMeasurementResult(void) override; private: diff --git a/src/sensors/AnalogElecConductivity.h b/src/sensors/AnalogElecConductivity.h index ac2f1bde8..e575e037f 100644 --- a/src/sensors/AnalogElecConductivity.h +++ b/src/sensors/AnalogElecConductivity.h @@ -302,9 +302,6 @@ class AnalogElecConductivity : public Sensor { */ String getSensorLocation(void) override; - /** - * @copydoc Sensor::addSingleMeasurementResult() - */ bool addSingleMeasurementResult(void) override; /** diff --git a/src/sensors/ApogeeSQ212.h b/src/sensors/ApogeeSQ212.h index 4da555419..acd839dce 100644 --- a/src/sensors/ApogeeSQ212.h +++ b/src/sensors/ApogeeSQ212.h @@ -281,9 +281,6 @@ class ApogeeSQ212 : public Sensor { */ String getSensorLocation(void) override; - /** - * @copydoc Sensor::addSingleMeasurementResult() - */ bool addSingleMeasurementResult(void) override; private: diff --git a/src/sensors/AtlasParent.h b/src/sensors/AtlasParent.h index 5d6ac8118..294ec7fa6 100644 --- a/src/sensors/AtlasParent.h +++ b/src/sensors/AtlasParent.h @@ -222,9 +222,6 @@ class AtlasParent : public Sensor { * successfully. */ bool startSingleMeasurement(void) override; - /** - * @copydoc Sensor::addSingleMeasurementResult() - */ bool addSingleMeasurementResult(void) override; protected: diff --git a/src/sensors/BoschBME280.h b/src/sensors/BoschBME280.h index c05e28a1a..b9c963dbf 100644 --- a/src/sensors/BoschBME280.h +++ b/src/sensors/BoschBME280.h @@ -320,9 +320,6 @@ class BoschBME280 : public Sensor { */ ~BoschBME280(); - /** - * @copydoc Sensor::wake() - */ bool wake(void) override; /** * @brief Do any one-time preparations needed before the sensor will be able @@ -334,16 +331,10 @@ class BoschBME280 : public Sensor { * * @return True if the setup was successful. */ - bool setup(void) override; - /** - * @copydoc Sensor::getSensorLocation() - */ + bool setup(void) override; String getSensorLocation(void) override; // bool startSingleMeasurement(void) override; // for forced mode - /** - * @copydoc Sensor::addSingleMeasurementResult() - */ bool addSingleMeasurementResult(void) override; private: diff --git a/src/sensors/BoschBMP3xx.h b/src/sensors/BoschBMP3xx.h index a3ec76000..3a16862f7 100644 --- a/src/sensors/BoschBMP3xx.h +++ b/src/sensors/BoschBMP3xx.h @@ -441,9 +441,6 @@ class BoschBMP3xx : public Sensor { */ ~BoschBMP3xx(); - /** - * @copydoc Sensor::wake() - */ bool wake(void) override; /** * @brief Do any one-time preparations needed before the sensor will be able @@ -455,19 +452,10 @@ class BoschBMP3xx : public Sensor { * * @return True if the setup was successful. */ - bool setup(void) override; - /** - * @copydoc Sensor::getSensorLocation() - */ + bool setup(void) override; String getSensorLocation(void) override; - /** - * @copydoc Sensor::startSingleMeasurement() - */ bool startSingleMeasurement(void) override; - /** - * @copydoc Sensor::addSingleMeasurementResult() - */ bool addSingleMeasurementResult(void) override; private: diff --git a/src/sensors/CampbellOBS3.h b/src/sensors/CampbellOBS3.h index 50634f782..8a7febd11 100644 --- a/src/sensors/CampbellOBS3.h +++ b/src/sensors/CampbellOBS3.h @@ -280,14 +280,8 @@ class CampbellOBS3 : public Sensor { */ ~CampbellOBS3(); - /** - * @copydoc Sensor::getSensorLocation() - */ String getSensorLocation(void) override; - /** - * @copydoc Sensor::addSingleMeasurementResult() - */ bool addSingleMeasurementResult(void) override; private: diff --git a/src/sensors/EverlightALSPT19.h b/src/sensors/EverlightALSPT19.h index 9e8a1b8c4..7b7e758e0 100644 --- a/src/sensors/EverlightALSPT19.h +++ b/src/sensors/EverlightALSPT19.h @@ -258,9 +258,6 @@ class EverlightALSPT19 : public Sensor { */ ~EverlightALSPT19(); - /** - * @copydoc Sensor::addSingleMeasurementResult() - */ bool addSingleMeasurementResult(void) override; private: diff --git a/src/sensors/FreescaleMPL115A2.h b/src/sensors/FreescaleMPL115A2.h index 56384e4c1..6e0939de4 100644 --- a/src/sensors/FreescaleMPL115A2.h +++ b/src/sensors/FreescaleMPL115A2.h @@ -233,15 +233,9 @@ class FreescaleMPL115A2 : public Sensor { * * @return True if the setup was successful. */ - bool setup(void) override; - /** - * @copydoc Sensor::getSensorLocation() - */ + bool setup(void) override; String getSensorLocation(void) override; - /** - * @copydoc Sensor::addSingleMeasurementResult() - */ bool addSingleMeasurementResult(void) override; private: diff --git a/src/sensors/GeoluxHydroCam.h b/src/sensors/GeoluxHydroCam.h index 56510ef92..317c533c0 100644 --- a/src/sensors/GeoluxHydroCam.h +++ b/src/sensors/GeoluxHydroCam.h @@ -290,9 +290,6 @@ class GeoluxHydroCam : public Sensor { */ String getLastSavedImageName(); - /** - * @copydoc Sensor::getSensorLocation() - */ String getSensorLocation(void) override; /** @@ -324,15 +321,7 @@ class GeoluxHydroCam : public Sensor { bool wake(void) override; bool sleep(void) override; - - /** - * @copydoc Sensor::startSingleMeasurement() - */ bool startSingleMeasurement(void) override; - - /** - * @copydoc Sensor::addSingleMeasurementResult() - */ bool addSingleMeasurementResult(void) override; /** diff --git a/src/sensors/GroPointParent.h b/src/sensors/GroPointParent.h index ce81b2371..506469f89 100644 --- a/src/sensors/GroPointParent.h +++ b/src/sensors/GroPointParent.h @@ -156,9 +156,6 @@ class GroPointParent : public Sensor { */ virtual ~GroPointParent(); - /** - * @copydoc Sensor::getSensorLocation() - */ String getSensorLocation(void) override; /** @@ -173,9 +170,7 @@ class GroPointParent : public Sensor { * @return True if the setup was successful. */ bool setup(void) override; - /** - * @copydoc Sensor::wake() - */ + bool wake(void) override; /** * @brief Puts the sensor to sleep, if necessary. @@ -187,9 +182,6 @@ class GroPointParent : public Sensor { */ bool sleep(void) override; - /** - * @copydoc Sensor::addSingleMeasurementResult() - */ bool addSingleMeasurementResult(void) override; private: diff --git a/src/sensors/KellerParent.h b/src/sensors/KellerParent.h index 505efa302..6b1f4ca5a 100644 --- a/src/sensors/KellerParent.h +++ b/src/sensors/KellerParent.h @@ -233,9 +233,6 @@ class KellerParent : public Sensor { */ virtual ~KellerParent(); - /** - * @copydoc Sensor::getSensorLocation() - */ String getSensorLocation(void) override; /** @@ -254,9 +251,6 @@ class KellerParent : public Sensor { // override to empty and flush the stream bool sleep(void) override; - /** - * @copydoc Sensor::addSingleMeasurementResult() - */ bool addSingleMeasurementResult(void) override; private: diff --git a/src/sensors/MaxBotixSonar.h b/src/sensors/MaxBotixSonar.h index f9c66d394..e987174f4 100644 --- a/src/sensors/MaxBotixSonar.h +++ b/src/sensors/MaxBotixSonar.h @@ -222,9 +222,6 @@ class MaxBotixSonar : public Sensor { */ ~MaxBotixSonar(); - /** - * @copydoc Sensor::getSensorLocation() - */ String getSensorLocation(void) override; /** @@ -256,9 +253,6 @@ class MaxBotixSonar : public Sensor { // override to empty and flush the stream bool sleep(void) override; - /** - * @copydoc Sensor::addSingleMeasurementResult() - */ bool addSingleMeasurementResult(void) override; private: diff --git a/src/sensors/MaximDS18.h b/src/sensors/MaximDS18.h index 5d5e17b14..3e367d0b9 100644 --- a/src/sensors/MaximDS18.h +++ b/src/sensors/MaximDS18.h @@ -238,10 +238,7 @@ class MaximDS18 : public Sensor { * * @return True if the setup was successful. */ - bool setup(void) override; - /** - * @copydoc Sensor::getSensorLocation() - */ + bool setup(void) override; String getSensorLocation(void) override; /** @@ -256,9 +253,6 @@ class MaximDS18 : public Sensor { * successfully. successfully. */ bool startSingleMeasurement(void) override; - /** - * @copydoc Sensor::addSingleMeasurementResult() - */ bool addSingleMeasurementResult(void) override; private: diff --git a/src/sensors/MaximDS3231.h b/src/sensors/MaximDS3231.h index 9a65ffee4..33b6411cb 100644 --- a/src/sensors/MaximDS3231.h +++ b/src/sensors/MaximDS3231.h @@ -168,9 +168,6 @@ class MaximDS3231 : public Sensor { */ ~MaximDS3231(); - /** - * @copydoc Sensor::getSensorLocation() - */ String getSensorLocation(void) override; /** @@ -198,9 +195,6 @@ class MaximDS3231 : public Sensor { * successfully. successfully. */ bool startSingleMeasurement(void) override; - /** - * @copydoc Sensor::addSingleMeasurementResult() - */ bool addSingleMeasurementResult(void) override; }; diff --git a/src/sensors/MeaSpecMS5803.h b/src/sensors/MeaSpecMS5803.h index 605ca46d0..9c740b8cb 100644 --- a/src/sensors/MeaSpecMS5803.h +++ b/src/sensors/MeaSpecMS5803.h @@ -249,15 +249,9 @@ class MeaSpecMS5803 : public Sensor { * * @return True if the setup was successful. */ - bool setup(void) override; - /** - * @copydoc Sensor::getSensorLocation() - */ + bool setup(void) override; String getSensorLocation(void) override; - /** - * @copydoc Sensor::addSingleMeasurementResult() - */ bool addSingleMeasurementResult(void) override; private: diff --git a/src/sensors/PaleoTerraRedox.h b/src/sensors/PaleoTerraRedox.h index 5448b306e..6e8b6d962 100644 --- a/src/sensors/PaleoTerraRedox.h +++ b/src/sensors/PaleoTerraRedox.h @@ -263,15 +263,9 @@ class PaleoTerraRedox : public Sensor { * * @return True if the setup was successful. */ - bool setup(void) override; - /** - * @copydoc Sensor::getSensorLocation() - */ + bool setup(void) override; String getSensorLocation(void) override; - /** - * @copydoc Sensor::addSingleMeasurementResult() - */ bool addSingleMeasurementResult(void) override; private: diff --git a/src/sensors/ProcessorStats.h b/src/sensors/ProcessorStats.h index 2e4387e96..16d35e0ab 100644 --- a/src/sensors/ProcessorStats.h +++ b/src/sensors/ProcessorStats.h @@ -421,9 +421,6 @@ class ProcessorStats : public Sensor { */ String getSensorLocation(void) override; - /** - * @copydoc Sensor::addSingleMeasurementResult() - */ bool addSingleMeasurementResult(void) override; /** diff --git a/src/sensors/RainCounterI2C.h b/src/sensors/RainCounterI2C.h index b8bdd1804..991674293 100644 --- a/src/sensors/RainCounterI2C.h +++ b/src/sensors/RainCounterI2C.h @@ -282,15 +282,9 @@ class RainCounterI2C : public Sensor { * * @return True if the setup was successful. */ - bool setup(void) override; - /** - * @copydoc Sensor::getSensorLocation() - */ + bool setup(void) override; String getSensorLocation(void) override; - /** - * @copydoc Sensor::addSingleMeasurementResult() - */ bool addSingleMeasurementResult(void) override; private: diff --git a/src/sensors/SDI12Sensors.h b/src/sensors/SDI12Sensors.h index 896647e28..4545ab207 100644 --- a/src/sensors/SDI12Sensors.h +++ b/src/sensors/SDI12Sensors.h @@ -251,9 +251,6 @@ class SDI12Sensors : public Sensor { */ bool startSingleMeasurement(void) override; #endif - /** - * @copydoc Sensor::addSingleMeasurementResult() - */ bool addSingleMeasurementResult(void) override; protected: diff --git a/src/sensors/SensirionSHT4x.h b/src/sensors/SensirionSHT4x.h index fb152789d..b81efded1 100644 --- a/src/sensors/SensirionSHT4x.h +++ b/src/sensors/SensirionSHT4x.h @@ -274,9 +274,6 @@ class SensirionSHT4x : public Sensor { */ bool setup(void) override; - /** - * @copydoc Sensor::addSingleMeasurementResult() - */ bool addSingleMeasurementResult(void) override; /** diff --git a/src/sensors/TIADS1x15.h b/src/sensors/TIADS1x15.h index a7e473084..cdd54400d 100644 --- a/src/sensors/TIADS1x15.h +++ b/src/sensors/TIADS1x15.h @@ -296,14 +296,8 @@ class TIADS1x15 : public Sensor { */ ~TIADS1x15(); - /** - * @copydoc Sensor::getSensorLocation() - */ String getSensorLocation(void) override; - /** - * @copydoc Sensor::addSingleMeasurementResult() - */ bool addSingleMeasurementResult(void) override; private: diff --git a/src/sensors/TIINA219.h b/src/sensors/TIINA219.h index 55737a0f0..86761802c 100644 --- a/src/sensors/TIINA219.h +++ b/src/sensors/TIINA219.h @@ -290,15 +290,9 @@ class TIINA219 : public Sensor { * * @return True if the setup was successful. */ - bool setup(void) override; - /** - * @copydoc Sensor::getSensorLocation() - */ + bool setup(void) override; String getSensorLocation(void) override; - /** - * @copydoc Sensor::addSingleMeasurementResult() - */ bool addSingleMeasurementResult(void) override; private: diff --git a/src/sensors/TallyCounterI2C.h b/src/sensors/TallyCounterI2C.h index c603f1b41..95c517514 100644 --- a/src/sensors/TallyCounterI2C.h +++ b/src/sensors/TallyCounterI2C.h @@ -215,17 +215,10 @@ class TallyCounterI2C : public Sensor { * * @return True if the setup was successful. */ - bool setup(void) override; - /** - * @copydoc Sensor::getSensorLocation() - */ - + bool setup(void) override; String getSensorLocation(void) override; // bool startSingleMeasurement(void) override; // for forced mode - /** - * @copydoc Sensor::addSingleMeasurementResult() - */ bool addSingleMeasurementResult(void) override; private: diff --git a/src/sensors/TurnerCyclops.h b/src/sensors/TurnerCyclops.h index 71d5b8cb0..c5ef7503c 100644 --- a/src/sensors/TurnerCyclops.h +++ b/src/sensors/TurnerCyclops.h @@ -340,14 +340,8 @@ class TurnerCyclops : public Sensor { */ ~TurnerCyclops(); - /** - * @copydoc Sensor::getSensorLocation() - */ String getSensorLocation(void) override; - /** - * @copydoc Sensor::addSingleMeasurementResult() - */ bool addSingleMeasurementResult(void) override; private: diff --git a/src/sensors/TurnerTurbidityPlus.h b/src/sensors/TurnerTurbidityPlus.h index 2420f7006..1a620993d 100644 --- a/src/sensors/TurnerTurbidityPlus.h +++ b/src/sensors/TurnerTurbidityPlus.h @@ -251,9 +251,6 @@ class TurnerTurbidityPlus : public Sensor { */ ~TurnerTurbidityPlus(); - /** - * @copydoc Sensor::getSensorLocation() - */ String getSensorLocation(void) override; /** @@ -277,9 +274,6 @@ class TurnerTurbidityPlus : public Sensor { void powerDown(void) override; - /** - * @copydoc Sensor::addSingleMeasurementResult() - */ bool addSingleMeasurementResult(void) override; private: diff --git a/src/sensors/YosemitechParent.h b/src/sensors/YosemitechParent.h index 9811a44ba..82d0fd2e4 100644 --- a/src/sensors/YosemitechParent.h +++ b/src/sensors/YosemitechParent.h @@ -209,9 +209,6 @@ class YosemitechParent : public Sensor { */ virtual ~YosemitechParent(); - /** - * @copydoc Sensor::getSensorLocation() - */ String getSensorLocation(void) override; /** @@ -226,9 +223,6 @@ class YosemitechParent : public Sensor { * @return True if the setup was successful. */ bool setup(void) override; - /** - * @copydoc Sensor::wake() - */ bool wake(void) override; /** * @brief Puts the sensor to sleep, if necessary. @@ -240,9 +234,6 @@ class YosemitechParent : public Sensor { */ bool sleep(void) override; - /** - * @copydoc Sensor::addSingleMeasurementResult() - */ bool addSingleMeasurementResult(void) override; private: From 1ed6ecc163bc0ca4c3a498f3b0b537c0cd9b67d6 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Thu, 25 Sep 2025 18:18:22 -0400 Subject: [PATCH 011/533] Gave sensor friend classes of variable and variable array Signed-off-by: Sara Damiano --- src/SensorBase.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/SensorBase.h b/src/SensorBase.h index cf731a46c..5440893c8 100644 --- a/src/SensorBase.h +++ b/src/SensorBase.h @@ -47,7 +47,8 @@ /// sensor. #define NUMBER_SUPPORTED_POWER_PINS 2 -class Variable; // Forward declaration +class Variable; // Forward declaration +class VariableArray; // Forward declaration /** * @brief The "Sensor" class is used for all sensor-level operations - waking, @@ -66,6 +67,8 @@ class Variable; // Forward declaration */ class Sensor { public: + friend class Variable; + friend class VariableArray; /** * @brief Construct a new Sensor object. * From 5025569e47c49ce7366a54871f691c3dcb6e24b8 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Thu, 25 Sep 2025 18:21:16 -0400 Subject: [PATCH 012/533] Check for pointer equality Signed-off-by: Sara Damiano --- src/VariableArray.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/VariableArray.cpp b/src/VariableArray.cpp index 9a03e4b8c..cbd15a1ad 100644 --- a/src/VariableArray.cpp +++ b/src/VariableArray.cpp @@ -896,12 +896,10 @@ bool VariableArray::isLastVarFromSensor(int arrayIndex) { if (arrayOfVars[arrayIndex]->isCalculated) { return false; } else { - String sensNameLoc = - arrayOfVars[arrayIndex]->getParentSensorNameAndLocation(); - bool unique = true; + Sensor* parSens = arrayOfVars[arrayIndex]->parentSensor; + bool unique = true; for (int j = arrayIndex + 1; j < _variableCount; j++) { - if (sensNameLoc == - arrayOfVars[j]->getParentSensorNameAndLocation()) { + if (parSens == arrayOfVars[j]->parentSensor) { unique = false; break; } From c11139607338ce82f22cbb041ac8b159ccb2a841 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Thu, 25 Sep 2025 18:22:07 -0400 Subject: [PATCH 013/533] Set activated to power on if no wake Signed-off-by: Sara Damiano --- src/SensorBase.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/SensorBase.cpp b/src/SensorBase.cpp index f3da9be0d..d6495b2cb 100644 --- a/src/SensorBase.cpp +++ b/src/SensorBase.cpp @@ -228,7 +228,11 @@ bool Sensor::wake(void) { } // NOTE: Not turning on processor pull-up or pull-down! // Mark the time that the sensor was activated - _millisSensorActivated = millis(); + // NOTE: If we didn't do anything to wake the sensor, we **don't** + // want to mark the time as **now** but as the last time we did do + // something. Since we didn't actively wake the sensor, we assume the + // measurement was started at power on. + _millisSensorActivated = _millisPowerOn; // Set the status bit for sensor wake/activation success (bit 4) setStatusBit(WAKE_SUCCESSFUL); From 632d56f47f8845b594734ed92063a62c2d064b63 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Thu, 25 Sep 2025 18:34:17 -0400 Subject: [PATCH 014/533] Add millis completed - which can be start time if no start needed Signed-off-by: Sara Damiano --- src/SensorBase.cpp | 13 ++++++++++++- src/SensorBase.h | 8 ++++++++ src/sensors/ANBpH.cpp | 3 ++- src/sensors/AOSongAM2315.cpp | 2 ++ src/sensors/AOSongDHT.cpp | 2 ++ src/sensors/AlphasenseCO2.cpp | 2 ++ src/sensors/AnalogElecConductivity.cpp | 2 ++ src/sensors/ApogeeSQ212.cpp | 2 ++ src/sensors/AtlasParent.cpp | 2 ++ src/sensors/BoschBME280.cpp | 2 ++ src/sensors/BoschBMP3xx.cpp | 2 ++ src/sensors/CampbellOBS3.cpp | 2 ++ src/sensors/EverlightALSPT19.cpp | 2 ++ src/sensors/FreescaleMPL115A2.cpp | 2 ++ src/sensors/GeoluxHydroCam.cpp | 2 ++ src/sensors/GroPointParent.cpp | 2 ++ src/sensors/KellerParent.cpp | 2 ++ src/sensors/MaxBotixSonar.cpp | 2 ++ src/sensors/MaximDS18.cpp | 2 ++ src/sensors/MaximDS3231.cpp | 2 ++ src/sensors/MeaSpecMS5803.cpp | 2 ++ src/sensors/PaleoTerraRedox.cpp | 2 ++ src/sensors/ProcessorStats.cpp | 2 ++ src/sensors/RainCounterI2C.cpp | 2 ++ src/sensors/SDI12Sensors.cpp | 4 ++++ src/sensors/SensirionSHT4x.cpp | 2 ++ src/sensors/TIADS1x15.cpp | 2 ++ src/sensors/TIINA219.cpp | 2 ++ src/sensors/TallyCounterI2C.cpp | 2 ++ src/sensors/TurnerCyclops.cpp | 2 ++ src/sensors/TurnerTurbidityPlus.cpp | 2 ++ src/sensors/YosemitechParent.cpp | 2 ++ 32 files changed, 82 insertions(+), 2 deletions(-) diff --git a/src/SensorBase.cpp b/src/SensorBase.cpp index d6495b2cb..88cf80137 100644 --- a/src/SensorBase.cpp +++ b/src/SensorBase.cpp @@ -275,7 +275,18 @@ bool Sensor::startSingleMeasurement(void) { // Only mark the measurement request time if it is if (getStatusBit(WAKE_SUCCESSFUL)) { // Mark the time that a measurement was requested - _millisMeasurementRequested = millis(); + // NOTE: If we didn't do anything to start a measurement, we **don't** + // want to mark the time as **now** but as the last time we did do + // something. Since we didn't actively start the measurement, we assume + // the measurement was started either at wake or at the time the last + // measurement was finished. + if (_millisMeasurementCompleted != 0) { + _millisMeasurementRequested = + _millisMeasurementCompleted; // immediately after last + // measurement + } else { + _millisMeasurementRequested = _millisSensorActivated; // at wake + } // Set the status bit for measurement start success (bit 6) setStatusBit(MEASUREMENT_SUCCESSFUL); } else { diff --git a/src/SensorBase.h b/src/SensorBase.h index 5440893c8..8c7d4d3ff 100644 --- a/src/SensorBase.h +++ b/src/SensorBase.h @@ -693,6 +693,14 @@ class Sensor { * addSingleMeasurementResult() function. */ uint32_t _millisMeasurementRequested = 0; + /** + * @brief The processor elapsed time when a measurement was completed - ie, + * when the addSingleMeasurementResult() function was run. + * + * The #_millisMeasurementCompleted value is set in the + * addSingleMeasurementResult() function. + */ + uint32_t _millisMeasurementCompleted = 0; /** * @brief An 8-bit code for the sensor status diff --git a/src/sensors/ANBpH.cpp b/src/sensors/ANBpH.cpp index 97b55e96d..c0bb5c937 100644 --- a/src/sensors/ANBpH.cpp +++ b/src/sensors/ANBpH.cpp @@ -369,7 +369,8 @@ bool ANBpH::addSingleMeasurementResult(void) { } else { MS_DBG(getSensorNameAndLocation(), F("is not currently measuring!")); } - + // Record the time that the measurement was completed + _millisMeasurementCompleted = millis(); // Unset the time stamp for the beginning of this measurement _millisMeasurementRequested = 0; // Unset the status bits for a measurement request (bits 5 & 6) diff --git a/src/sensors/AOSongAM2315.cpp b/src/sensors/AOSongAM2315.cpp index 0d2080a89..ed73e4a35 100644 --- a/src/sensors/AOSongAM2315.cpp +++ b/src/sensors/AOSongAM2315.cpp @@ -75,6 +75,8 @@ bool AOSongAM2315::addSingleMeasurementResult(void) { verifyAndAddMeasurementResult(AM2315_TEMP_VAR_NUM, temp_val); verifyAndAddMeasurementResult(AM2315_HUMIDITY_VAR_NUM, humid_val); + // Record the time that the measurement was completed + _millisMeasurementCompleted = millis(); // Unset the time stamp for the beginning of this measurement _millisMeasurementRequested = 0; // Unset the status bits for a measurement request (bits 5 & 6) diff --git a/src/sensors/AOSongDHT.cpp b/src/sensors/AOSongDHT.cpp index 0f5b29c74..e9da465c3 100644 --- a/src/sensors/AOSongDHT.cpp +++ b/src/sensors/AOSongDHT.cpp @@ -92,6 +92,8 @@ bool AOSongDHT::addSingleMeasurementResult(void) { verifyAndAddMeasurementResult(DHT_HUMIDITY_VAR_NUM, humid_val); verifyAndAddMeasurementResult(DHT_HI_VAR_NUM, hi_val); + // Record the time that the measurement was completed + _millisMeasurementCompleted = millis(); // Unset the time stamp for the beginning of this measurement _millisMeasurementRequested = 0; // Unset the status bits for a measurement request (bits 5 & 6) diff --git a/src/sensors/AlphasenseCO2.cpp b/src/sensors/AlphasenseCO2.cpp index 59f210235..88d91f33f 100644 --- a/src/sensors/AlphasenseCO2.cpp +++ b/src/sensors/AlphasenseCO2.cpp @@ -108,6 +108,8 @@ bool AlphasenseCO2::addSingleMeasurementResult(void) { verifyAndAddMeasurementResult(ALPHASENSE_CO2_VAR_NUM, calibResult); verifyAndAddMeasurementResult(ALPHASENSE_CO2_VOLTAGE_VAR_NUM, adcVoltage); + // Record the time that the measurement was completed + _millisMeasurementCompleted = millis(); // Unset the time stamp for the beginning of this measurement _millisMeasurementRequested = 0; // Unset the status bits for a measurement request (bits 5 & 6) diff --git a/src/sensors/AnalogElecConductivity.cpp b/src/sensors/AnalogElecConductivity.cpp index 8cfc8942e..9b7b5cb66 100644 --- a/src/sensors/AnalogElecConductivity.cpp +++ b/src/sensors/AnalogElecConductivity.cpp @@ -90,6 +90,8 @@ bool AnalogElecConductivity::addSingleMeasurementResult(void) { verifyAndAddMeasurementResult(ANALOGELECCONDUCTIVITY_EC_VAR_NUM, sensorEC_uScm); + // Record the time that the measurement was completed + _millisMeasurementCompleted = millis(); // Unset the time stamp for the beginning of this measurement _millisMeasurementRequested = 0; // Unset the status bits for a measurement request (bits 5 & 6) diff --git a/src/sensors/ApogeeSQ212.cpp b/src/sensors/ApogeeSQ212.cpp index 0a7422784..c6e4255f6 100644 --- a/src/sensors/ApogeeSQ212.cpp +++ b/src/sensors/ApogeeSQ212.cpp @@ -103,6 +103,8 @@ bool ApogeeSQ212::addSingleMeasurementResult(void) { verifyAndAddMeasurementResult(SQ212_PAR_VAR_NUM, calibResult); verifyAndAddMeasurementResult(SQ212_VOLTAGE_VAR_NUM, adcVoltage); + // Record the time that the measurement was completed + _millisMeasurementCompleted = millis(); // Unset the time stamp for the beginning of this measurement _millisMeasurementRequested = 0; // Unset the status bits for a measurement request (bits 5 & 6) diff --git a/src/sensors/AtlasParent.cpp b/src/sensors/AtlasParent.cpp index 364f2351a..7f0d2daee 100644 --- a/src/sensors/AtlasParent.cpp +++ b/src/sensors/AtlasParent.cpp @@ -187,6 +187,8 @@ bool AtlasParent::addSingleMeasurementResult(void) { } } + // Record the time that the measurement was completed + _millisMeasurementCompleted = millis(); // Unset the time stamp for the beginning of this measurement _millisMeasurementRequested = 0; // Unset the status bits for a measurement request (bits 5 & 6) diff --git a/src/sensors/BoschBME280.cpp b/src/sensors/BoschBME280.cpp index f568cf4f6..92ae24cc1 100644 --- a/src/sensors/BoschBME280.cpp +++ b/src/sensors/BoschBME280.cpp @@ -163,6 +163,8 @@ bool BoschBME280::addSingleMeasurementResult(void) { verifyAndAddMeasurementResult(BME280_PRESSURE_VAR_NUM, press); verifyAndAddMeasurementResult(BME280_ALTITUDE_VAR_NUM, alt); + // Record the time that the measurement was completed + _millisMeasurementCompleted = millis(); // Unset the time stamp for the beginning of this measurement _millisMeasurementRequested = 0; // Unset the status bits for a measurement request (bits 5 & 6) diff --git a/src/sensors/BoschBMP3xx.cpp b/src/sensors/BoschBMP3xx.cpp index 05e18a14e..fafe95388 100644 --- a/src/sensors/BoschBMP3xx.cpp +++ b/src/sensors/BoschBMP3xx.cpp @@ -312,6 +312,8 @@ bool BoschBMP3xx::addSingleMeasurementResult(void) { verifyAndAddMeasurementResult(BMP3XX_PRESSURE_VAR_NUM, press); verifyAndAddMeasurementResult(BMP3XX_ALTITUDE_VAR_NUM, alt); + // Record the time that the measurement was completed + _millisMeasurementCompleted = millis(); // Unset the time stamp for the beginning of this measurement _millisMeasurementRequested = 0; // Unset the status bits for a measurement request (bits 5 & 6) diff --git a/src/sensors/CampbellOBS3.cpp b/src/sensors/CampbellOBS3.cpp index d004cb0d3..f132963b2 100644 --- a/src/sensors/CampbellOBS3.cpp +++ b/src/sensors/CampbellOBS3.cpp @@ -107,6 +107,8 @@ bool CampbellOBS3::addSingleMeasurementResult(void) { verifyAndAddMeasurementResult(OBS3_TURB_VAR_NUM, calibResult); verifyAndAddMeasurementResult(OBS3_VOLTAGE_VAR_NUM, adcVoltage); + // Record the time that the measurement was completed + _millisMeasurementCompleted = millis(); // Unset the time stamp for the beginning of this measurement _millisMeasurementRequested = 0; // Unset the status bits for a measurement request (bits 5 & 6) diff --git a/src/sensors/EverlightALSPT19.cpp b/src/sensors/EverlightALSPT19.cpp index e4714d883..b271d8ec7 100644 --- a/src/sensors/EverlightALSPT19.cpp +++ b/src/sensors/EverlightALSPT19.cpp @@ -79,6 +79,8 @@ bool EverlightALSPT19::addSingleMeasurementResult(void) { verifyAndAddMeasurementResult(ALSPT19_CURRENT_VAR_NUM, current_val); verifyAndAddMeasurementResult(ALSPT19_ILLUMINANCE_VAR_NUM, lux_val); + // Record the time that the measurement was completed + _millisMeasurementCompleted = millis(); // Unset the time stamp for the beginning of this measurement _millisMeasurementRequested = 0; // Unset the status bits for a measurement request (bits 5 & 6) diff --git a/src/sensors/FreescaleMPL115A2.cpp b/src/sensors/FreescaleMPL115A2.cpp index 519bf7ca9..a46642bec 100644 --- a/src/sensors/FreescaleMPL115A2.cpp +++ b/src/sensors/FreescaleMPL115A2.cpp @@ -89,6 +89,8 @@ bool FreescaleMPL115A2::addSingleMeasurementResult(void) { verifyAndAddMeasurementResult(MPL115A2_TEMP_VAR_NUM, temp); verifyAndAddMeasurementResult(MPL115A2_PRESSURE_VAR_NUM, press); + // Record the time that the measurement was completed + _millisMeasurementCompleted = millis(); // Unset the time stamp for the beginning of this measurement _millisMeasurementRequested = 0; // Unset the status bits for a measurement request (bits 5 & 6) diff --git a/src/sensors/GeoluxHydroCam.cpp b/src/sensors/GeoluxHydroCam.cpp index cc6243459..5af8e3f09 100644 --- a/src/sensors/GeoluxHydroCam.cpp +++ b/src/sensors/GeoluxHydroCam.cpp @@ -257,6 +257,8 @@ bool GeoluxHydroCam::addSingleMeasurementResult(void) { verifyAndAddMeasurementResult(HYDROCAM_SIZE_VAR_NUM, bytes_transferred); verifyAndAddMeasurementResult(HYDROCAM_ERROR_VAR_NUM, byte_error); + // Record the time that the measurement was completed + _millisMeasurementCompleted = millis(); // Unset the time stamp for the beginning of this measurement _millisMeasurementRequested = 0; // Unset the status bits for a measurement request (bits 5 & 6) diff --git a/src/sensors/GroPointParent.cpp b/src/sensors/GroPointParent.cpp index 0f3d566cf..6877bc751 100644 --- a/src/sensors/GroPointParent.cpp +++ b/src/sensors/GroPointParent.cpp @@ -256,6 +256,8 @@ bool GroPointParent::addSingleMeasurementResult(void) { MS_DBG(getSensorNameAndLocation(), F("is not currently measuring!")); } + // Record the time that the measurement was completed + _millisMeasurementCompleted = millis(); // Unset the time stamp for the beginning of this measurement _millisMeasurementRequested = 0; // Unset the status bits for a measurement request (bits 5 & 6) diff --git a/src/sensors/KellerParent.cpp b/src/sensors/KellerParent.cpp index e1ee7fa43..4dd188dc3 100644 --- a/src/sensors/KellerParent.cpp +++ b/src/sensors/KellerParent.cpp @@ -128,6 +128,8 @@ bool KellerParent::addSingleMeasurementResult(void) { verifyAndAddMeasurementResult(KELLER_TEMP_VAR_NUM, waterTemperatureC); verifyAndAddMeasurementResult(KELLER_HEIGHT_VAR_NUM, waterDepthM); + // Record the time that the measurement was completed + _millisMeasurementCompleted = millis(); // Unset the time stamp for the beginning of this measurement _millisMeasurementRequested = 0; // Unset the status bits for a measurement request (bits 5 & 6) diff --git a/src/sensors/MaxBotixSonar.cpp b/src/sensors/MaxBotixSonar.cpp index 120c1a096..7ae66b35c 100644 --- a/src/sensors/MaxBotixSonar.cpp +++ b/src/sensors/MaxBotixSonar.cpp @@ -194,6 +194,8 @@ bool MaxBotixSonar::addSingleMeasurementResult(void) { verifyAndAddMeasurementResult(HRXL_VAR_NUM, result); + // Record the time that the measurement was completed + _millisMeasurementCompleted = millis(); // Unset the time stamp for the beginning of this measurement _millisMeasurementRequested = 0; // Unset the status bits for a measurement request (bits 5 & 6) diff --git a/src/sensors/MaximDS18.cpp b/src/sensors/MaximDS18.cpp index 347c65829..7151227a4 100644 --- a/src/sensors/MaximDS18.cpp +++ b/src/sensors/MaximDS18.cpp @@ -206,6 +206,8 @@ bool MaximDS18::addSingleMeasurementResult(void) { // Put value into the array verifyAndAddMeasurementResult(DS18_TEMP_VAR_NUM, result); + // Record the time that the measurement was completed + _millisMeasurementCompleted = millis(); // Unset the time stamp for the beginning of this measurement _millisMeasurementRequested = 0; // Unset the status bits for a measurement request (bits 5 & 6) diff --git a/src/sensors/MaximDS3231.cpp b/src/sensors/MaximDS3231.cpp index 6c81aa8ee..bfde59527 100644 --- a/src/sensors/MaximDS3231.cpp +++ b/src/sensors/MaximDS3231.cpp @@ -61,6 +61,8 @@ bool MaximDS3231::addSingleMeasurementResult(void) { verifyAndAddMeasurementResult(DS3231_TEMP_VAR_NUM, tempVal); + // Record the time that the measurement was completed + _millisMeasurementCompleted = millis(); // Unset the time stamp for the beginning of this measurement _millisMeasurementRequested = 0; // Unset the status bits for a measurement request (bits 5 & 6) diff --git a/src/sensors/MeaSpecMS5803.cpp b/src/sensors/MeaSpecMS5803.cpp index 7aefde181..ac9c6cf3a 100644 --- a/src/sensors/MeaSpecMS5803.cpp +++ b/src/sensors/MeaSpecMS5803.cpp @@ -93,6 +93,8 @@ bool MeaSpecMS5803::addSingleMeasurementResult(void) { verifyAndAddMeasurementResult(MS5803_TEMP_VAR_NUM, temp); verifyAndAddMeasurementResult(MS5803_PRESSURE_VAR_NUM, press); + // Record the time that the measurement was completed + _millisMeasurementCompleted = millis(); // Unset the time stamp for the beginning of this measurement _millisMeasurementRequested = 0; // Unset the status bits for a measurement request (bits 5 & 6) diff --git a/src/sensors/PaleoTerraRedox.cpp b/src/sensors/PaleoTerraRedox.cpp index 978377184..bf607fea3 100644 --- a/src/sensors/PaleoTerraRedox.cpp +++ b/src/sensors/PaleoTerraRedox.cpp @@ -149,6 +149,8 @@ bool PaleoTerraRedox::addSingleMeasurementResult(void) { // Store the results in the sensorValues array verifyAndAddMeasurementResult(PTR_VOLTAGE_VAR_NUM, res); + // Record the time that the measurement was completed + _millisMeasurementCompleted = millis(); // Unset the time stamp for the beginning of this measurement _millisMeasurementRequested = 0; // Unset the status bit for a measurement having been requested (bit 5) diff --git a/src/sensors/ProcessorStats.cpp b/src/sensors/ProcessorStats.cpp index 42f61604b..1ea8c2bd1 100644 --- a/src/sensors/ProcessorStats.cpp +++ b/src/sensors/ProcessorStats.cpp @@ -289,6 +289,8 @@ bool ProcessorStats::addSingleMeasurementResult(void) { MS_DBG(F("Skipping reset cause check on reps")); } + // Record the time that the measurement was completed + _millisMeasurementCompleted = millis(); // Unset the time stamp for the beginning of this measurement _millisMeasurementRequested = 0; // Unset the status bits for a measurement request (bits 5 & 6) diff --git a/src/sensors/RainCounterI2C.cpp b/src/sensors/RainCounterI2C.cpp index 68abadb70..1940d81e9 100644 --- a/src/sensors/RainCounterI2C.cpp +++ b/src/sensors/RainCounterI2C.cpp @@ -150,6 +150,8 @@ bool RainCounterI2C::addSingleMeasurementResult(void) { verifyAndAddMeasurementResult(BUCKET_RAIN_VAR_NUM, rain); verifyAndAddMeasurementResult(BUCKET_TIPS_VAR_NUM, tips); + // Record the time that the measurement was completed + _millisMeasurementCompleted = millis(); // Unset the time stamp for the beginning of this measurement _millisMeasurementRequested = 0; // Unset the status bits for a measurement request (bits 5 & 6) diff --git a/src/sensors/SDI12Sensors.cpp b/src/sensors/SDI12Sensors.cpp index 692640bc1..7fd40ebcc 100644 --- a/src/sensors/SDI12Sensors.cpp +++ b/src/sensors/SDI12Sensors.cpp @@ -724,6 +724,8 @@ bool SDI12Sensors::addSingleMeasurementResult(void) { } } + // Record the time that the measurement was completed + _millisMeasurementCompleted = millis(); // Unset the time stamp for the beginning of this measurement _millisMeasurementRequested = 0; // Unset the status bits for a measurement request (bits 5 & 6) @@ -816,6 +818,8 @@ bool SDI12Sensors::addSingleMeasurementResult(void) { // Empty the buffer and de-activate the SDI-12 Object deactivate(); + // Record the time that the measurement was completed + _millisMeasurementCompleted = millis(); // Unset the time stamp for the beginning of this measurement _millisMeasurementRequested = 0; // Unset the status bits for a measurement request (bits 5 & 6) diff --git a/src/sensors/SensirionSHT4x.cpp b/src/sensors/SensirionSHT4x.cpp index a16447def..c94e64103 100644 --- a/src/sensors/SensirionSHT4x.cpp +++ b/src/sensors/SensirionSHT4x.cpp @@ -123,6 +123,8 @@ bool SensirionSHT4x::addSingleMeasurementResult(void) { verifyAndAddMeasurementResult(SHT4X_TEMP_VAR_NUM, temp_val); verifyAndAddMeasurementResult(SHT4X_HUMIDITY_VAR_NUM, humid_val); + // Record the time that the measurement was completed + _millisMeasurementCompleted = millis(); // Unset the time stamp for the beginning of this measurement _millisMeasurementRequested = 0; // Unset the status bits for a measurement request (bits 5 & 6) diff --git a/src/sensors/TIADS1x15.cpp b/src/sensors/TIADS1x15.cpp index 11a32bb22..0570d21f7 100644 --- a/src/sensors/TIADS1x15.cpp +++ b/src/sensors/TIADS1x15.cpp @@ -99,6 +99,8 @@ bool TIADS1x15::addSingleMeasurementResult(void) { verifyAndAddMeasurementResult(TIADS1X15_VAR_NUM, calibResult); + // Record the time that the measurement was completed + _millisMeasurementCompleted = millis(); // Unset the time stamp for the beginning of this measurement _millisMeasurementRequested = 0; // Unset the status bits for a measurement request (bits 5 & 6) diff --git a/src/sensors/TIINA219.cpp b/src/sensors/TIINA219.cpp index 409a761a7..5a9ac63c6 100644 --- a/src/sensors/TIINA219.cpp +++ b/src/sensors/TIINA219.cpp @@ -106,6 +106,8 @@ bool TIINA219::addSingleMeasurementResult(void) { verifyAndAddMeasurementResult(INA219_POWER_MW_VAR_NUM, power_mW); + // Record the time that the measurement was completed + _millisMeasurementCompleted = millis(); // Unset the time stamp for the beginning of this measurement _millisMeasurementRequested = 0; // Unset the status bits for a measurement request (bits 5 & 6) diff --git a/src/sensors/TallyCounterI2C.cpp b/src/sensors/TallyCounterI2C.cpp index 54ba576b9..e22bb0298 100644 --- a/src/sensors/TallyCounterI2C.cpp +++ b/src/sensors/TallyCounterI2C.cpp @@ -107,6 +107,8 @@ bool TallyCounterI2C::addSingleMeasurementResult(void) { verifyAndAddMeasurementResult(TALLY_EVENTS_VAR_NUM, events); + // Record the time that the measurement was completed + _millisMeasurementCompleted = millis(); // Unset the time stamp for the beginning of this measurement _millisMeasurementRequested = 0; // Unset the status bits for a measurement request (bits 5 & 6) diff --git a/src/sensors/TurnerCyclops.cpp b/src/sensors/TurnerCyclops.cpp index bc90d639f..bda374435 100644 --- a/src/sensors/TurnerCyclops.cpp +++ b/src/sensors/TurnerCyclops.cpp @@ -107,6 +107,8 @@ bool TurnerCyclops::addSingleMeasurementResult(void) { verifyAndAddMeasurementResult(CYCLOPS_VAR_NUM, calibResult); verifyAndAddMeasurementResult(CYCLOPS_VOLTAGE_VAR_NUM, adcVoltage); + // Record the time that the measurement was completed + _millisMeasurementCompleted = millis(); // Unset the time stamp for the beginning of this measurement _millisMeasurementRequested = 0; // Unset the status bits for a measurement request (bits 5 & 6) diff --git a/src/sensors/TurnerTurbidityPlus.cpp b/src/sensors/TurnerTurbidityPlus.cpp index 91adaf7e2..22733ed66 100644 --- a/src/sensors/TurnerTurbidityPlus.cpp +++ b/src/sensors/TurnerTurbidityPlus.cpp @@ -169,6 +169,8 @@ bool TurnerTurbidityPlus::addSingleMeasurementResult(void) { verifyAndAddMeasurementResult(TURBIDITY_PLUS_VAR_NUM, calibResult); verifyAndAddMeasurementResult(TURBIDITY_PLUS_VOLTAGE_VAR_NUM, adcVoltage); + // Record the time that the measurement was completed + _millisMeasurementCompleted = millis(); // Unset the time stamp for the beginning of this measurement _millisMeasurementRequested = 0; // Unset the status bits for a measurement request (bits 5 & 6) diff --git a/src/sensors/YosemitechParent.cpp b/src/sensors/YosemitechParent.cpp index 9dba5cd29..1f11bfc65 100644 --- a/src/sensors/YosemitechParent.cpp +++ b/src/sensors/YosemitechParent.cpp @@ -257,6 +257,8 @@ bool YosemitechParent::addSingleMeasurementResult(void) { MS_DBG(getSensorNameAndLocation(), F("is not currently measuring!")); } + // Record the time that the measurement was completed + _millisMeasurementCompleted = millis(); // Unset the time stamp for the beginning of this measurement _millisMeasurementRequested = 0; // Unset the status bits for a measurement request (bits 5 & 6) From 2831af5f59aa3d882aa925f6c02cea2a1696cfec Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Thu, 25 Sep 2025 18:34:51 -0400 Subject: [PATCH 015/533] Use retries for ANB timing windows Signed-off-by: Sara Damiano --- src/sensors/ANBpH.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/sensors/ANBpH.cpp b/src/sensors/ANBpH.cpp index c0bb5c937..aff3aca2a 100644 --- a/src/sensors/ANBpH.cpp +++ b/src/sensors/ANBpH.cpp @@ -520,18 +520,20 @@ bool ANBpH::isStable(bool debug) { // ready based on the power style. uint32_t ANBpH::getStartImmersionErrorWindow(void) { if (!_immersionSensorEnabled) { return getEndMeasurementWindow(); } - return _powerPin >= 0 ? ANB_PH_2ND_IMMERSION_ERROR - : ANB_PH_1ST_IMMERSION_ERROR; + return (_powerPin >= 0 || _retryAttemptsMade > 0) + ? ANB_PH_2ND_IMMERSION_ERROR + : ANB_PH_1ST_IMMERSION_ERROR; } uint32_t ANBpH::getEndImmersionErrorWindow(void) { if (!_immersionSensorEnabled) { return getEndMeasurementWindow(); } - return _powerPin >= 0 ? ANB_PH_2ND_IMMERSION_ERROR_MAX - : ANB_PH_1ST_IMMERSION_ERROR_MAX; + return (_powerPin >= 0 || _retryAttemptsMade > 0) + ? ANB_PH_2ND_IMMERSION_ERROR_MAX + : ANB_PH_1ST_IMMERSION_ERROR_MAX; } uint32_t ANBpH::getStartMeasurementWindow(void) { - if (_powerPin >= 0) { + if (_powerPin >= 0 || _retryAttemptsMade > 0) { if (_salinityMode == ANBSalinityMode::HIGH_SALINITY) { return ANB_PH_1ST_VALUE_HIGH_SALT; } else { From 13b7583437d2cc650c5dfeebd69bc4e79dfaf1f1 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Thu, 25 Sep 2025 18:36:04 -0400 Subject: [PATCH 016/533] re-write array looping Signed-off-by: Sara Damiano --- src/VariableArray.cpp | 294 ++++++++++++------------------------------ 1 file changed, 82 insertions(+), 212 deletions(-) diff --git a/src/VariableArray.cpp b/src/VariableArray.cpp index cbd15a1ad..61de4e907 100644 --- a/src/VariableArray.cpp +++ b/src/VariableArray.cpp @@ -16,13 +16,13 @@ VariableArray::VariableArray() {} VariableArray::VariableArray(uint8_t variableCount, Variable* variableList[]) : arrayOfVars(variableList), _variableCount(variableCount) { - _sensorCount = getSensorCount(); + _sensorCount = getSensorCount(); } VariableArray::VariableArray(uint8_t variableCount, Variable* variableList[], const char* uuids[]) : arrayOfVars(variableList), _variableCount(variableCount) { - _sensorCount = getSensorCount(); + _sensorCount = getSensorCount(); matchUUIDs(uuids); } @@ -34,7 +34,7 @@ void VariableArray::begin(uint8_t variableCount, Variable* variableList[], _variableCount = variableCount; arrayOfVars = variableList; - _sensorCount = getSensorCount(); + _sensorCount = getSensorCount(); matchUUIDs(uuids); checkVariableUUIDs(); } @@ -42,11 +42,11 @@ void VariableArray::begin(uint8_t variableCount, Variable* variableList[]) { _variableCount = variableCount; arrayOfVars = variableList; - _sensorCount = getSensorCount(); + _sensorCount = getSensorCount(); checkVariableUUIDs(); } void VariableArray::begin() { - _sensorCount = getSensorCount(); + _sensorCount = getSensorCount(); checkVariableUUIDs(); } @@ -498,130 +498,19 @@ bool VariableArray::completeUpdate(void) { bool deepDebugTiming = false; #endif - // Create an array with the unique-ness value (so we can skip the function - // calls later) - MS_DBG(F("Creating a mask array with the uniqueness for each sensor..")); - bool lastSensorVariable[_variableCount]; - for (uint8_t i = 0; i < _variableCount; i++) { - lastSensorVariable[i] = isLastVarFromSensor(i); - } - - // Create an array for the number of measurements already completed and set - // all to zero - MS_DBG(F("Creating an array for the number of completed measurements..")); - uint8_t nMeasurementsCompleted[_variableCount]; + MS_DBG(F("Creating an array of pointers to the sensors..")); + Sensor* sensorList[_sensorCount]; + uint8_t addedSensors = 0; for (uint8_t i = 0; i < _variableCount; i++) { - nMeasurementsCompleted[i] = 0; - } - - // Create an array for the number of measurements to average (another short - // cut) - MS_DBG(F("Creating an array with the number of measurements to average..")); - uint8_t nMeasurementsToAverage[_variableCount]; - for (uint8_t i = 0; i < _variableCount; i++) { - if (lastSensorVariable[i]) { - nMeasurementsToAverage[i] = - arrayOfVars[i]->parentSensor->getNumberMeasurementsToAverage(); - } else { - nMeasurementsToAverage[i] = 0; - } - } - - // Create an array of the power pins - MS_DBG(F("Creating an array of the power pins..")); - int8_t powerPins[_variableCount]; - for (uint8_t i = 0; i < _variableCount; i++) { - if (lastSensorVariable[i]) { - powerPins[i] = arrayOfVars[i]->parentSensor->getPowerPin(); - } else { - powerPins[i] = 0; + if (isLastVarFromSensor(i)) { + sensorList[addedSensors++] = arrayOfVars[i]->parentSensor; } } - // Create an array of the last variable on each power pin - MS_DBG(F("Creating arrays of the power pin locations..")); - bool lastPinVariable[_variableCount]; - for (uint8_t i = 0; i < _variableCount; i++) { lastPinVariable[i] = true; } - // Create an array containing the index of the power pin in the powerPins - // array - int8_t powerPinIndex[_variableCount]; - for (uint8_t i = 0; i < _variableCount; i++) { powerPinIndex[i] = 0; } - // Create an array to tell us how many measurements must be taken - // before all the sensors attached to a power pin are done - uint8_t nMeasurementsOnPin[_variableCount]; - for (uint8_t i = 0; i < _variableCount; i++) { - nMeasurementsOnPin[i] = nMeasurementsToAverage[i]; - } - // Now correctly populate the previous three arrays - for (uint8_t i = 0; i < _variableCount; i++) { - for (uint8_t j = i + 1; j < _variableCount; j++) { - if (!lastSensorVariable[i]) { - lastPinVariable[i] = false; - } else if (powerPins[i] == powerPins[j]) { - lastPinVariable[i] = false; - } - i++; - } - } - for (uint8_t i = 0; i < _variableCount; i++) { - if (lastPinVariable[i]) { - powerPinIndex[i] = i; - nMeasurementsOnPin[i] = nMeasurementsToAverage[i]; - for (uint8_t j = 0; j < _variableCount; j++) { - if (powerPins[j] == powerPins[i] && i != j) { - powerPinIndex[j] = i; - nMeasurementsOnPin[i] += nMeasurementsToAverage[j]; - nMeasurementsOnPin[j] = 0; - } - } - } - } - -// This is just for debugging -#ifdef MS_VARIABLEARRAY_DEBUG_DEEP - uint8_t arrayPositions[_variableCount]; - for (uint8_t i = 0; i < _variableCount; i++) { arrayPositions[i] = i; } - String nameLocation[_variableCount]; - for (uint8_t i = 0; i < _variableCount; i++) { - // nameLocation[i] = arrayOfVars[i]->getParentSensorNameAndLocation(); - nameLocation[i] = arrayOfVars[i]->getParentSensorName(); - } - MS_DEEP_DBG(F("----------------------------------")); - MS_DEEP_DBG(F("arrayPositions:\t\t\t")); - prettyPrintArray(arrayPositions); - MS_DEEP_DBG(F("sensor:\t\t\t")); - prettyPrintArray(nameLocation); - MS_DEEP_DBG(F("lastSensorVariable:\t\t")); - prettyPrintArray(lastSensorVariable); - MS_DEEP_DBG(F("nMeasurementsToAverage:\t\t")); - prettyPrintArray(nMeasurementsToAverage); - MS_DEEP_DBG(F("nMeasurementsCompleted:\t\t")); - prettyPrintArray(nMeasurementsCompleted); - MS_DEEP_DBG(F("powerPins:\t\t\t")); - prettyPrintArray(powerPins); - MS_DEEP_DBG(F("lastPinVariable:\t\t")); - prettyPrintArray(lastPinVariable); - MS_DEEP_DBG(F("powerPinIndex:\t\t\t")); - prettyPrintArray(powerPinIndex); - MS_DEEP_DBG(F("nMeasurementsOnPin:\t\t")); - prettyPrintArray(nMeasurementsOnPin); - MS_DEEP_DBG(F("powerPinIndex:\t\t\t")); - prettyPrintArray(powerPinIndex); -#endif - - // Another array for the number of measurements already completed per power - // pin - uint8_t nCompletedOnPin[_variableCount]; - for (uint8_t i = 0; i < _variableCount; i++) { nCompletedOnPin[i] = 0; } - // Clear the initial variable arrays MS_DBG(F("----->> Clearing all results arrays before taking new " "measurements. ...")); - for (uint8_t i = 0; i < _variableCount; i++) { - if (lastSensorVariable[i]) { - arrayOfVars[i]->parentSensor->clearValues(); - } - } + for (uint8_t i = 0; i < _sensorCount; i++) { sensorList[i]->clearValues(); } MS_DBG(F(" ... Complete. <<-----")); // power up all of the sensors together @@ -630,44 +519,13 @@ bool VariableArray::completeUpdate(void) { MS_DBG(F(" ... Complete. <<-----")); while (nSensorsCompleted < _sensorCount) { - for (uint8_t i = 0; i < _variableCount; i++) { - /*** - // THIS IS PURELY FOR DEEP DEBUGGING OF THE TIMING! - // Leave this whole section commented out unless you want excessive - // printouts (ie, thousands of lines) of the timing information!! - if (lastSensorVariable[i] and - nMeasurementsToAverage[i] > nMeasurementsCompleted[i]) { - MS_DEEP_DBG( - i, '-', arrayOfVars[i]->getParentSensorNameAndLocation(), - F("- millis:"), millis(), F("- status: 0b"), - getSensorStatusBit(i,7), - getSensorStatusBit(i,6), - getSensorStatusBit(i,5), - getSensorStatusBit(i,4), - getSensorStatusBit(i,3), - getSensorStatusBit(i,2), - getSensorStatusBit(i,1), - getSensorStatusBit(i,0), - F("- measurement #"), (nMeasurementsCompleted[i] + 1)); - } - MS_DEEP_DBG(F("----------------------------------")); - MS_DEEP_DBG(F("nMeasurementsToAverage:\t\t")); - prettyPrintArray(nMeasurementsToAverage); - MS_DEEP_DBG(F("nMeasurementsCompleted:\t\t")); - prettyPrintArray(nMeasurementsCompleted); - MS_DEEP_DBG(F("nMeasurementsOnPin:\t\t")); - prettyPrintArray(nMeasurementsOnPin); - MS_DEEP_DBG(F("nCompletedOnPin:\t\t\t")); - prettyPrintArray(nCompletedOnPin); - // END CHUNK FOR DEBUGGING! - ***/ - + for (uint8_t i = 0; i < _sensorCount; i++) { // Only do checks on sensors that still have measurements to finish - if (lastSensorVariable[i] && - nMeasurementsToAverage[i] > nMeasurementsCompleted[i]) { - if (getSensorStatusBit(i, Sensor::WAKE_ATTEMPTED) == + if (sensorList[i]->getNumberMeasurementsToAverage() > + sensorList[i]->getNumberCompleteMeasurementsAttempts()) { + if (sensorList[i]->getStatusBit(Sensor::WAKE_ATTEMPTED) == 0 // If no attempts yet made to wake the sensor up - && arrayOfVars[i]->parentSensor->isWarmedUp( + && sensorList[i]->isWarmedUp( deepDebugTiming) // and if it is already warmed up ) { MS_DBG(i, F("--->> Waking"), @@ -676,8 +534,7 @@ bool VariableArray::completeUpdate(void) { // Make a single attempt to wake the sensor after it is // warmed up - bool sensorSuccess_wake = - arrayOfVars[i]->parentSensor->wake(); + bool sensorSuccess_wake = sensorList[i]->wake(); success &= sensorSuccess_wake; if (sensorSuccess_wake) { @@ -690,42 +547,38 @@ bool VariableArray::completeUpdate(void) { // If attempts were made to wake the sensor, but they failed // then we're just bumping up the number of measurements to // completion - if (getSensorStatusBit(i, Sensor::WAKE_ATTEMPTED) == 1 && - getSensorStatusBit(i, Sensor::WAKE_SUCCESSFUL) == 0) { + if (sensorList[i]->getStatusBit(Sensor::WAKE_ATTEMPTED) == 1 && + sensorList[i]->getStatusBit(Sensor::WAKE_SUCCESSFUL) == 0) { MS_DBG(i, F("--->>"), - arrayOfVars[i]->getParentSensorNameAndLocation(), + sensorList[i]->getSensorNameAndLocation(), F("did not wake up! No measurements will be taken! " "<<---"), i); // Set the number of measurements already equal to whatever // total number requested to ensure the sensor is skipped in // further loops. - nMeasurementsCompleted[i] = nMeasurementsToAverage[i]; - // increment the number of measurements that the power pin - // has completed - nCompletedOnPin[powerPinIndex[i]] += - nMeasurementsToAverage[i]; + sensorList[i]->_measurementAttemptsCompleted = + sensorList[i]->_measurementsToAverage; } // If the sensor was successfully awoken/activated, but no // measurement was either started or finished ... - if (getSensorStatusBit(i, Sensor::WAKE_SUCCESSFUL) == 1 && - getSensorStatusBit(i, Sensor::MEASUREMENT_ATTEMPTED) == 0 && - getSensorStatusBit(i, Sensor::MEASUREMENT_SUCCESSFUL) == - 0) { + if (sensorList[i]->getStatusBit(Sensor::WAKE_SUCCESSFUL) == 1 && + sensorList[i]->getStatusBit( + Sensor::MEASUREMENT_ATTEMPTED) == 0 && + sensorList[i]->getStatusBit( + Sensor::MEASUREMENT_SUCCESSFUL) == 0) { // .. check if it's stable - if (arrayOfVars[i]->parentSensor->isStable( - deepDebugTiming)) { + if (sensorList[i]->isStable(deepDebugTiming)) { // Start a reading MS_DBG(i, '.', nMeasurementsCompleted[i] + 1, F("--->> Starting reading"), nMeasurementsCompleted[i] + 1, F("on"), - arrayOfVars[i]->getParentSensorNameAndLocation(), + sensorList[i]->getSensorNameAndLocation(), F("...")); bool sensorSuccess_start = - arrayOfVars[i] - ->parentSensor->startSingleMeasurement(); + sensorList[i]->startSingleMeasurement(); success &= sensorSuccess_start; if (sensorSuccess_start) { @@ -744,28 +597,21 @@ bool VariableArray::completeUpdate(void) { // isMeasurementComplete(deepDebugTiming) will do that. // We want the addSingleMeasurementResult() function to fill in // the -9999 results for a failed measurement. - if (getSensorStatusBit(i, Sensor::MEASUREMENT_ATTEMPTED) == 1) { + if (sensorList[i]->getStatusBit( + Sensor::MEASUREMENT_ATTEMPTED) == 1) { // If a measurement is finished, get the result and tick up // the number of finished measurements. - if (arrayOfVars[i]->parentSensor->isMeasurementComplete( - deepDebugTiming)) { + if (sensorList[i]->isMeasurementComplete(deepDebugTiming)) { // Get the value MS_DBG(i, '.', nMeasurementsCompleted[i] + 1, F("--->> Collected result of reading"), nMeasurementsCompleted[i] + 1, F("from"), - arrayOfVars[i]->getParentSensorNameAndLocation(), + sensorList[i]->getSensorNameAndLocation(), F("...")); bool sensorSuccess_result = - arrayOfVars[i] - ->parentSensor->addSingleMeasurementResult(); + sensorList[i]->addSingleMeasurementResult(); success &= sensorSuccess_result; - nMeasurementsCompleted[i] += - 1; // increment the number of measurements that - // sensor has completed - nCompletedOnPin[powerPinIndex[i]] += - 1; // increment the number of measurements that the - // power pin has completed if (sensorSuccess_result) { MS_DBG(F(" ... got measurement result. <<---"), i, @@ -779,14 +625,14 @@ bool VariableArray::completeUpdate(void) { } // If all the measurements are done - if (nMeasurementsCompleted[i] == nMeasurementsToAverage[i]) { + if (sensorList[i]->getNumberCompleteMeasurementsAttempts() >= + sensorList[i]->getNumberMeasurementsToAverage()) { MS_DBG(i, F("--->> Finished all measurements from"), arrayOfVars[i]->getParentSensorNameAndLocation(), F(", putting it to sleep. ...")); // Put the completed sensor to sleep - bool sensorSuccess_sleep = - arrayOfVars[i]->parentSensor->sleep(); + bool sensorSuccess_sleep = sensorList[i]->sleep(); success &= sensorSuccess_sleep; if (sensorSuccess_sleep) { @@ -799,19 +645,45 @@ bool VariableArray::completeUpdate(void) { // Now cut the power, if ready, to this sensors and all that // share the pin - if (nCompletedOnPin[powerPinIndex[i]] == - nMeasurementsOnPin[powerPinIndex[i]]) { - for (uint8_t k = 0; k < _variableCount; k++) { - if (powerPinIndex[k] == powerPinIndex[i] && - lastSensorVariable[k]) { - arrayOfVars[k]->parentSensor->powerDown(); - MS_DBG(k, F("--->>"), - arrayOfVars[k] - ->getParentSensorNameAndLocation(), - F("powered down. <<---"), k); - } + bool canPowerDown = false; + for (uint8_t k = 0; k < _sensorCount; k++) { + if ((sensorList[k]->getPowerPin() == + sensorList[i]->getPowerPin() || + sensorList[k]->getSecondaryPowerPin() == + sensorList[i]->getPowerPin() || + sensorList[k]->getPowerPin() == + sensorList[i]->getSecondaryPowerPin() || + sensorList[k]->getSecondaryPowerPin() == + sensorList[i]->getSecondaryPowerPin()) && + (sensorList[k] + ->getNumberCompleteMeasurementsAttempts() < + sensorList[k]->getNumberMeasurementsToAverage())) { + canPowerDown = false; // another sensor on this pin + // still needs to take + // measurements + break; + } else { + canPowerDown = + true; // no other sensors on this pin + // need to take measurements } } + if (canPowerDown) { + MS_DBG( + i, F("--->> All measurements from"), + arrayOfVars[i]->getParentSensorNameAndLocation(), + F("are complete and no other sensors on the same " + "power pin need to take measurements. " + "Powering down all sensors on pin"), + sensorList[i]->getPowerPin(), F("...")); + } else { + MS_DBG(i, F("--->> All measurements from"), + arrayOfVars[i]->getParentSensorNameAndLocation(), + F("are complete but other sensors on the same " + "power pin still need to take measurements. " + "Leaving power on pin"), + sensorList[i]->getPowerPin(), F("ON. <<---")); + } nSensorsCompleted++; // mark the whole sensor as done MS_DBG(F("*****---"), nSensorsCompleted, @@ -828,15 +700,13 @@ bool VariableArray::completeUpdate(void) { // Average measurements and notify variables of the updates MS_DBG(F("----->> Averaging results and notifying all variables. ...")); - for (uint8_t i = 0; i < _variableCount; i++) { - if (lastSensorVariable[i]) { - MS_DBG(F("--- Averaging results from"), - arrayOfVars[i]->getParentSensorNameAndLocation(), F("---")); - arrayOfVars[i]->parentSensor->averageMeasurements(); - MS_DBG(F("--- Notifying variables from"), - arrayOfVars[i]->getParentSensorNameAndLocation(), F("---")); - arrayOfVars[i]->parentSensor->notifyVariables(); - } + for (uint8_t i = 0; i < _sensorCount; i++) { + MS_DBG(F("--- Averaging results from"), + sensorList[i]->getSensorNameAndLocation(), F("---")); + sensorList[i]->averageMeasurements(); + MS_DBG(F("--- Notifying variables from"), + sensorList[i]->getSensorNameAndLocation(), F("---")); + sensorList[i]->notifyVariables(); } MS_DBG(F("... Complete. <<-----")); From 62b5ad27cdee3c4d55b4a66ec76b183f073632e9 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Thu, 25 Sep 2025 18:42:53 -0400 Subject: [PATCH 017/533] Setter for retries Signed-off-by: Sara Damiano --- src/SensorBase.cpp | 3 +++ src/SensorBase.h | 6 ++++++ 2 files changed, 9 insertions(+) diff --git a/src/SensorBase.cpp b/src/SensorBase.cpp index 88cf80137..04652010f 100644 --- a/src/SensorBase.cpp +++ b/src/SensorBase.cpp @@ -89,6 +89,9 @@ uint8_t Sensor::getNumberCompleteMeasurementsAttempts(void) { uint8_t Sensor::getNumberRetryAttemptsMade(void) { return _retryAttemptsMade; } +void Sensor::setAllowedMeasurementRetries(uint8_t allowedMeasurementRetries) { + _allowedMeasurementRetries = allowedMeasurementRetries; +} uint8_t Sensor::getAllowedMeasurementRetries(void) { return _allowedMeasurementRetries; } diff --git a/src/SensorBase.h b/src/SensorBase.h index 8c7d4d3ff..07c0ac59e 100644 --- a/src/SensorBase.h +++ b/src/SensorBase.h @@ -218,6 +218,12 @@ class Sensor { * @return The number of allowed retries. */ uint8_t getAllowedMeasurementRetries(void); + /** + * @brief Set the number of retries if a measurement fails. + * + * @param allowedMeasurementRetries The number of allowed retries. + */ + void setAllowedMeasurementRetries(uint8_t allowedMeasurementRetries); /// @brief The significance of the various status bits From 4c64b6672163a9d8e993ddeae2bbea85861dc283 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Fri, 26 Sep 2025 08:43:29 -0400 Subject: [PATCH 018/533] Default to 5 retries for ANB pH Signed-off-by: Sara Damiano --- src/sensors/ANBpH.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/sensors/ANBpH.cpp b/src/sensors/ANBpH.cpp index aff3aca2a..929261448 100644 --- a/src/sensors/ANBpH.cpp +++ b/src/sensors/ANBpH.cpp @@ -24,6 +24,7 @@ ANBpH::ANBpH(byte modbusAddress, Stream* stream, int8_t powerPin, _anb_sensor.setDebugStream(&MS_SERIAL_OUTPUT); #endif setSecondaryPowerPin(powerPin2); + setAllowedMeasurementRetries(5); } ANBpH::ANBpH(byte modbusAddress, Stream& stream, int8_t powerPin, int8_t powerPin2, int8_t enablePin, uint8_t measurementsToAverage) @@ -38,6 +39,7 @@ ANBpH::ANBpH(byte modbusAddress, Stream& stream, int8_t powerPin, _anb_sensor.setDebugStream(&MS_SERIAL_OUTPUT); #endif setSecondaryPowerPin(powerPin2); + setAllowedMeasurementRetries(5); } // Destructor ANBpH::~ANBpH() {} From 10bf5119bbf0ca4d275e228080ffb71dbf7a97b8 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Fri, 26 Sep 2025 08:43:49 -0400 Subject: [PATCH 019/533] Reset timing and status bits in clearValues fxn Signed-off-by: Sara Damiano --- src/SensorBase.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/SensorBase.cpp b/src/SensorBase.cpp index 04652010f..0a6205790 100644 --- a/src/SensorBase.cpp +++ b/src/SensorBase.cpp @@ -337,8 +337,18 @@ void Sensor::clearValues(void) { sensorValues[i] = -9999; numberGoodMeasurementsMade[i] = 0; } + // Reset measurement attempt counters _measurementAttemptsCompleted = 0; _retryAttemptsMade = 0; + // reset all timing values + _millisPowerOn = 0; + _millisSensorActivated = 0; + _millisMeasurementRequested = 0; + _millisMeasurementCompleted = 0; + // Unset all status bits except setup (bit 0) and error (bit 7) + clearStatusBits(POWER_ATTEMPTED, POWER_SUCCESSFUL, WAKE_ATTEMPTED, + WAKE_SUCCESSFUL, MEASUREMENT_ATTEMPTED, + MEASUREMENT_SUCCESSFUL); } From d015dc9edfb5aa10d8d7f1aa2ee82df8ff1b6914 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Fri, 26 Sep 2025 09:12:04 -0400 Subject: [PATCH 020/533] Fix debug print error and processor warning Signed-off-by: Sara Damiano --- src/SensorBase.cpp | 2 +- src/VariableArray.cpp | 58 ++++++++++++++++++------------------------- 2 files changed, 25 insertions(+), 35 deletions(-) diff --git a/src/SensorBase.cpp b/src/SensorBase.cpp index 0a6205790..e824c7edd 100644 --- a/src/SensorBase.cpp +++ b/src/SensorBase.cpp @@ -25,8 +25,8 @@ Sensor::Sensor(const char* sensorName, const uint8_t totalReturnedValues, _powerPin2(-1), _sensorName(sensorName), _numReturnedValues(totalReturnedValues), - _measurementsToAverage(measurementsToAverage), _incCalcValues(incCalcValues), + _measurementsToAverage(measurementsToAverage), _warmUpTime_ms(warmUpTime_ms), _stabilizationTime_ms(stabilizationTime_ms), _measurementTime_ms(measurementTime_ms) { diff --git a/src/VariableArray.cpp b/src/VariableArray.cpp index 61de4e907..8f432b3be 100644 --- a/src/VariableArray.cpp +++ b/src/VariableArray.cpp @@ -520,17 +520,20 @@ bool VariableArray::completeUpdate(void) { while (nSensorsCompleted < _sensorCount) { for (uint8_t i = 0; i < _sensorCount; i++) { + uint8_t nReq = sensorList[i]->getNumberMeasurementsToAverage(); + uint8_t nDone = + sensorList[i]->getNumberCompleteMeasurementsAttempts(); +#ifdef MS_VARIABLEARRAY_DEBUG || MS_VARIABLEARRAY_DEBUG_DEEP + String sName = sensorList[i]->getSensorNameAndLocation(); +#endif // Only do checks on sensors that still have measurements to finish - if (sensorList[i]->getNumberMeasurementsToAverage() > - sensorList[i]->getNumberCompleteMeasurementsAttempts()) { + if (nReq > nDone) { if (sensorList[i]->getStatusBit(Sensor::WAKE_ATTEMPTED) == 0 // If no attempts yet made to wake the sensor up && sensorList[i]->isWarmedUp( deepDebugTiming) // and if it is already warmed up ) { - MS_DBG(i, F("--->> Waking"), - arrayOfVars[i]->getParentSensorNameAndLocation(), - F("...")); + MS_DBG(i, F("--->> Waking"), sName, F("...")); // Make a single attempt to wake the sensor after it is // warmed up @@ -538,7 +541,7 @@ bool VariableArray::completeUpdate(void) { success &= sensorSuccess_wake; if (sensorSuccess_wake) { - MS_DBG(F(" ... wake up success. <<---"), i); + MS_DBG(F(" ... wake up succeeded. <<---"), i); } else { MS_DBG(F(" ... wake up failed! <<---"), i); } @@ -549,8 +552,7 @@ bool VariableArray::completeUpdate(void) { // completion if (sensorList[i]->getStatusBit(Sensor::WAKE_ATTEMPTED) == 1 && sensorList[i]->getStatusBit(Sensor::WAKE_SUCCESSFUL) == 0) { - MS_DBG(i, F("--->>"), - sensorList[i]->getSensorNameAndLocation(), + MS_DBG(i, F("--->>"), sName, F("did not wake up! No measurements will be taken! " "<<---"), i); @@ -570,12 +572,8 @@ bool VariableArray::completeUpdate(void) { Sensor::MEASUREMENT_SUCCESSFUL) == 0) { // .. check if it's stable if (sensorList[i]->isStable(deepDebugTiming)) { - // Start a reading - MS_DBG(i, '.', nMeasurementsCompleted[i] + 1, - F("--->> Starting reading"), - nMeasurementsCompleted[i] + 1, F("on"), - sensorList[i]->getSensorNameAndLocation(), - F("...")); + MS_DBG(i, '.', nDone + 1, F("--->> Starting reading"), + nDone + 1, F("on"), sName, F("...")); bool sensorSuccess_start = sensorList[i]->startSingleMeasurement(); @@ -583,10 +581,10 @@ bool VariableArray::completeUpdate(void) { if (sensorSuccess_start) { MS_DBG(F(" ... start reading succeeded. <<---"), - i, '.', nMeasurementsCompleted[i] + 1); + i, '.', nDone + 1); } else { MS_DBG(F(" ... start reading failed! <<---"), i, - '.', nMeasurementsCompleted[i] + 1); + '.', nDone + 1); } } } @@ -603,11 +601,9 @@ bool VariableArray::completeUpdate(void) { // the number of finished measurements. if (sensorList[i]->isMeasurementComplete(deepDebugTiming)) { // Get the value - MS_DBG(i, '.', nMeasurementsCompleted[i] + 1, + MS_DBG(i, '.', nDone + 1, F("--->> Collected result of reading"), - nMeasurementsCompleted[i] + 1, F("from"), - sensorList[i]->getSensorNameAndLocation(), - F("...")); + nDone + 1, F("from"), sName, F("...")); bool sensorSuccess_result = sensorList[i]->addSingleMeasurementResult(); @@ -615,20 +611,18 @@ bool VariableArray::completeUpdate(void) { if (sensorSuccess_result) { MS_DBG(F(" ... got measurement result. <<---"), i, - '.', nMeasurementsCompleted[i]); + '.', nDone + 1); } else { MS_DBG(F(" ... failed to get measurement result! " "<<---"), - i, '.', nMeasurementsCompleted[i]); + i, '.', nDone + 1); } } } // If all the measurements are done - if (sensorList[i]->getNumberCompleteMeasurementsAttempts() >= - sensorList[i]->getNumberMeasurementsToAverage()) { - MS_DBG(i, F("--->> Finished all measurements from"), - arrayOfVars[i]->getParentSensorNameAndLocation(), + if (nDone >= nReq) { + MS_DBG(i, F("--->> Finished all measurements from"), sName, F(", putting it to sleep. ...")); // Put the completed sensor to sleep @@ -670,15 +664,13 @@ bool VariableArray::completeUpdate(void) { } if (canPowerDown) { MS_DBG( - i, F("--->> All measurements from"), - arrayOfVars[i]->getParentSensorNameAndLocation(), + i, F("--->> All measurements from"), sName, F("are complete and no other sensors on the same " "power pin need to take measurements. " "Powering down all sensors on pin"), sensorList[i]->getPowerPin(), F("...")); } else { - MS_DBG(i, F("--->> All measurements from"), - arrayOfVars[i]->getParentSensorNameAndLocation(), + MS_DBG(i, F("--->> All measurements from"), sName, F("are complete but other sensors on the same " "power pin still need to take measurements. " "Leaving power on pin"), @@ -701,11 +693,9 @@ bool VariableArray::completeUpdate(void) { // Average measurements and notify variables of the updates MS_DBG(F("----->> Averaging results and notifying all variables. ...")); for (uint8_t i = 0; i < _sensorCount; i++) { - MS_DBG(F("--- Averaging results from"), - sensorList[i]->getSensorNameAndLocation(), F("---")); + MS_DBG(F("--- Averaging results from"), sName, F("---")); sensorList[i]->averageMeasurements(); - MS_DBG(F("--- Notifying variables from"), - sensorList[i]->getSensorNameAndLocation(), F("---")); + MS_DBG(F("--- Notifying variables from"), sName, F("---")); sensorList[i]->notifyVariables(); } MS_DBG(F("... Complete. <<-----")); From a4574e84587cdfe40dac5a0427835a9c9a0c887d Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Fri, 26 Sep 2025 09:16:02 -0400 Subject: [PATCH 021/533] ifdef fix Signed-off-by: Sara Damiano --- src/SensorBase.cpp | 2 +- src/VariableArray.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/SensorBase.cpp b/src/SensorBase.cpp index e824c7edd..3c631316b 100644 --- a/src/SensorBase.cpp +++ b/src/SensorBase.cpp @@ -125,7 +125,7 @@ void Sensor::clearStatusBit(sensor_status_bits bitToClear) { void Sensor::powerUp(void) { if (_powerPin >= 0 || _powerPin2 >= 0) { // Reset power pin mode every power up because pins are set to tri-state - // on sleep + // on sleep on SAMD boards if (_powerPin >= 0) { pinMode(_powerPin, OUTPUT); MS_DBG(F("Powering"), getSensorNameAndLocation(), F("with pin"), diff --git a/src/VariableArray.cpp b/src/VariableArray.cpp index 8f432b3be..6eeada2ca 100644 --- a/src/VariableArray.cpp +++ b/src/VariableArray.cpp @@ -523,7 +523,7 @@ bool VariableArray::completeUpdate(void) { uint8_t nReq = sensorList[i]->getNumberMeasurementsToAverage(); uint8_t nDone = sensorList[i]->getNumberCompleteMeasurementsAttempts(); -#ifdef MS_VARIABLEARRAY_DEBUG || MS_VARIABLEARRAY_DEBUG_DEEP +#if defined(MS_VARIABLEARRAY_DEBUG) || defined(MS_VARIABLEARRAY_DEBUG_DEEP) String sName = sensorList[i]->getSensorNameAndLocation(); #endif // Only do checks on sensors that still have measurements to finish From ea5b693a60b01a89c28a206fff1d0ef6f5ab73b7 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Fri, 26 Sep 2025 09:19:26 -0400 Subject: [PATCH 022/533] Re-Fixed sName Signed-off-by: Sara Damiano --- src/VariableArray.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/VariableArray.cpp b/src/VariableArray.cpp index 6eeada2ca..b672baf7f 100644 --- a/src/VariableArray.cpp +++ b/src/VariableArray.cpp @@ -693,9 +693,11 @@ bool VariableArray::completeUpdate(void) { // Average measurements and notify variables of the updates MS_DBG(F("----->> Averaging results and notifying all variables. ...")); for (uint8_t i = 0; i < _sensorCount; i++) { - MS_DBG(F("--- Averaging results from"), sName, F("---")); + MS_DBG(F("--- Averaging results from"), + sensorList[i]->getSensorNameAndLocation(), F("---")); sensorList[i]->averageMeasurements(); - MS_DBG(F("--- Notifying variables from"), sName, F("---")); + MS_DBG(F("--- Notifying variables from"), + sensorList[i]->getSensorNameAndLocation(), F("---")); sensorList[i]->notifyVariables(); } MS_DBG(F("... Complete. <<-----")); From 1751b6bda8048e4767ff712abd3c98f983b1e4a6 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Fri, 26 Sep 2025 09:39:35 -0400 Subject: [PATCH 023/533] Fix conflated wake and start measurement on ANB pH Signed-off-by: Sara Damiano --- src/sensors/ANBpH.cpp | 68 ++++++++++++++++++------------------------- src/sensors/ANBpH.h | 2 +- 2 files changed, 29 insertions(+), 41 deletions(-) diff --git a/src/sensors/ANBpH.cpp b/src/sensors/ANBpH.cpp index 929261448..80f91b6a0 100644 --- a/src/sensors/ANBpH.cpp +++ b/src/sensors/ANBpH.cpp @@ -188,12 +188,32 @@ bool ANBpH::setup(void) { } -// Start measurements -bool ANBpH::startSingleMeasurement(void) { - // Sensor::startSingleMeasurement() checks that if it's awake/active and - // sets the timestamp and status bits. If it returns false, there's no - // reason to go on. - if (!Sensor::startSingleMeasurement()) return false; +// This confirms that the sensor is really giving modbus responses so nothing +// further happens if not. - It's a "check if it's awake" function rather than a +// "wake it up" function. +bool ANBpH::wake(void) { + // Sensor::wake() checks if the power pin is on and sets the wake timestamp + // and status bits. If it returns false, there's no reason to go on. + if (!Sensor::wake()) return false; + + MS_DEEP_DBG(F("Checking for modbus response confirming"), + getSensorNameAndLocation(), F("is awake")); + bool is_ready = isSensorReady(&anbSensor::gotModbusResponse, + ANB_PH_MINIMUM_REQUEST_SPACING, + _millisPowerOn); + if (!is_ready) { + MS_DEEP_DBG(getSensorNameAndLocation(), + F("isn't responding to modbus commands; wake failed!")); + // Set the status error bit (bit 7) + setStatusBit(ERROR_OCCURRED); + // Make sure that the wake time and wake success bit (bit 4) are unset + _millisSensorActivated = 0; + clearStatusBit(WAKE_SUCCESSFUL); + return false; + } + + MS_DEEP_DBG(getSensorNameAndLocation(), + F("responded properly to modbus commands; it must be awake.")); // If the sensor is being power cycled, set the clock before each // measurement. The sensor stores the measurements on its internal storage, @@ -211,50 +231,18 @@ bool ANBpH::startSingleMeasurement(void) { } if (success) { - MS_DEEP_DBG(getSensorNameAndLocation(), F("started a scan.")); + MS_DEEP_DBG(getSensorNameAndLocation(), F("started scanning.")); // Update the time that a measurement was requested - _millisMeasurementRequested = millis(); + _millisSensorActivated = millis(); } else { // Set the status error bit (bit 7) setStatusBit(ERROR_OCCURRED); - // Otherwise, make sure that the measurement start time and success bit - // (bit 6) are unset - MS_DBG(getSensorNameAndLocation(), - F("did not successfully start a measurement.")); - _millisMeasurementRequested = 0; - clearStatusBit(MEASUREMENT_SUCCESSFUL); - } - - return success; -} - - -// This confirms that the sensor is really giving modbus responses so nothing -// further happens if not. - It's a "check if it's awake" function rather than a -// "wake it up" function. -bool ANBpH::wake(void) { - // Sensor::wake() checks if the power pin is on and sets the wake timestamp - // and status bits. If it returns false, there's no reason to go on. - if (!Sensor::wake()) return false; - - MS_DEEP_DBG(F("Checking for modbus response confirming"), - getSensorNameAndLocation(), F("is awake")); - bool is_ready = isSensorReady(&anbSensor::gotModbusResponse, - ANB_PH_MINIMUM_REQUEST_SPACING, - _millisPowerOn); - if (!is_ready) { - MS_DEEP_DBG(getSensorNameAndLocation(), - F("isn't responding to modbus commands; wake failed!")); - // Set the status error bit (bit 7) - setStatusBit(ERROR_OCCURRED); // Make sure that the wake time and wake success bit (bit 4) are unset _millisSensorActivated = 0; clearStatusBit(WAKE_SUCCESSFUL); return false; } - MS_DEEP_DBG(getSensorNameAndLocation(), - F("responded properly to modbus commands; it must be awake.")); return true; } diff --git a/src/sensors/ANBpH.h b/src/sensors/ANBpH.h index f23a4661c..92841c913 100644 --- a/src/sensors/ANBpH.h +++ b/src/sensors/ANBpH.h @@ -524,7 +524,7 @@ class ANBpH : public Sensor { bool setup(void) override; bool wake(void) override; bool sleep(void) override; - bool startSingleMeasurement(void) override; + bool addSingleMeasurementResult(void) override; /** From bf27ff09845697a620f623f539f794b99da0a9cc Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Fri, 26 Sep 2025 09:39:55 -0400 Subject: [PATCH 024/533] Add comments Signed-off-by: Sara Damiano --- src/SensorBase.cpp | 2 +- src/sensors/MaximDS18.cpp | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/SensorBase.cpp b/src/SensorBase.cpp index 3c631316b..cbcf39818 100644 --- a/src/SensorBase.cpp +++ b/src/SensorBase.cpp @@ -225,7 +225,7 @@ bool Sensor::wake(void) { return false; } // Set the data pin mode on every wake because pins are set to tri-state on - // sleep + // sleep on SAMD boards if (_dataPin >= 0) { pinMode(_dataPin, INPUT); } // NOTE: Not turning on processor pull-up or pull-down! diff --git a/src/sensors/MaximDS18.cpp b/src/sensors/MaximDS18.cpp index 7151227a4..d27cd9f3c 100644 --- a/src/sensors/MaximDS18.cpp +++ b/src/sensors/MaximDS18.cpp @@ -130,6 +130,8 @@ bool MaximDS18::setup(void) { // Tell the sensor that we do NOT want to wait for conversions to finish // That is, we're in ASYNC mode and will get values when we're ready + // NOTE: This is a setting of the library, not the sensor itself; it is not + // changed by the sensor powering down. _internalDallasTemp.setWaitForConversion(false); // Turn the power back off it it had been turned on From 201f1b7318b60ca5abc7c1c40f1c2ee5b74d61ad Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Fri, 26 Sep 2025 09:59:23 -0400 Subject: [PATCH 025/533] Debugging loop hang Signed-off-by: Sara Damiano --- src/SensorBase.cpp | 5 ++--- src/VariableArray.cpp | 29 ++++++++++++++++++----------- 2 files changed, 20 insertions(+), 14 deletions(-) diff --git a/src/SensorBase.cpp b/src/SensorBase.cpp index cbcf39818..4e5bce2ca 100644 --- a/src/SensorBase.cpp +++ b/src/SensorBase.cpp @@ -208,8 +208,7 @@ bool Sensor::setup(void) { // The function to wake up a sensor bool Sensor::wake(void) { - MS_DBG(F("Waking"), getSensorNameAndLocation(), - F("using default wake of taking no action!")); + MS_DBG(F("Waking"), getSensorNameAndLocation(), F("by doing nothing!")); // Set the status bit for sensor activation attempt (bit 3) // Setting this bit even if the activation failed, to show the attempt was // made @@ -268,7 +267,7 @@ bool Sensor::startSingleMeasurement(void) { } MS_DBG(F("Starting measurement on"), getSensorNameAndLocation(), - F("using default start of taking no action!")); + F("by doing nothing!")); // Set the status bits for measurement requested (bit 5) // Setting this bit even if we failed to start a measurement to show that an // attempt was made. diff --git a/src/VariableArray.cpp b/src/VariableArray.cpp index b672baf7f..cc951cf4d 100644 --- a/src/VariableArray.cpp +++ b/src/VariableArray.cpp @@ -524,7 +524,10 @@ bool VariableArray::completeUpdate(void) { uint8_t nDone = sensorList[i]->getNumberCompleteMeasurementsAttempts(); #if defined(MS_VARIABLEARRAY_DEBUG) || defined(MS_VARIABLEARRAY_DEBUG_DEEP) - String sName = sensorList[i]->getSensorNameAndLocation(); + String sName = sensorList[i]->getSensorNameAndLocation(); + String dCount = String(i) + '.' + String(nDone + 1) + '.' + + String(sensorList[i]->getNumberRetryAttemptsMade()); + #endif // Only do checks on sensors that still have measurements to finish if (nReq > nDone) { @@ -572,8 +575,8 @@ bool VariableArray::completeUpdate(void) { Sensor::MEASUREMENT_SUCCESSFUL) == 0) { // .. check if it's stable if (sensorList[i]->isStable(deepDebugTiming)) { - MS_DBG(i, '.', nDone + 1, F("--->> Starting reading"), - nDone + 1, F("on"), sName, F("...")); + MS_DBG(dCount, F("--->> Starting reading"), nDone + 1, + F("on"), sName, F("...")); bool sensorSuccess_start = sensorList[i]->startSingleMeasurement(); @@ -581,10 +584,10 @@ bool VariableArray::completeUpdate(void) { if (sensorSuccess_start) { MS_DBG(F(" ... start reading succeeded. <<---"), - i, '.', nDone + 1); + dCount); } else { - MS_DBG(F(" ... start reading failed! <<---"), i, - '.', nDone + 1); + MS_DBG(F(" ... start reading failed! <<---"), + dCount); } } } @@ -601,8 +604,7 @@ bool VariableArray::completeUpdate(void) { // the number of finished measurements. if (sensorList[i]->isMeasurementComplete(deepDebugTiming)) { // Get the value - MS_DBG(i, '.', nDone + 1, - F("--->> Collected result of reading"), + MS_DBG(dCount, F("--->> Collected result of reading"), nDone + 1, F("from"), sName, F("...")); bool sensorSuccess_result = @@ -610,12 +612,12 @@ bool VariableArray::completeUpdate(void) { success &= sensorSuccess_result; if (sensorSuccess_result) { - MS_DBG(F(" ... got measurement result. <<---"), i, - '.', nDone + 1); + MS_DBG(F(" ... got measurement result. <<---"), + dCount); } else { MS_DBG(F(" ... failed to get measurement result! " "<<---"), - i, '.', nDone + 1); + dCount); } } } @@ -680,9 +682,14 @@ bool VariableArray::completeUpdate(void) { nSensorsCompleted++; // mark the whole sensor as done MS_DBG(F("*****---"), nSensorsCompleted, F("sensors now complete ---*****")); + } else { + MS_DBG(i, F("--->>"), sName, F("still needs to take"), + nReq - nDone, F("measurements.")); } } } + MS_DBG(F("xxxxx---"), _sensorCount - nSensorsCompleted, + F("sensors remaining ---xxxxx")); } // // power down all the sensors again, just in case From 6b37789ed2b71f17dcb3b5e74df8bad1142f068a Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Fri, 26 Sep 2025 10:35:09 -0400 Subject: [PATCH 026/533] Fix infinite loop by rechecking completion Signed-off-by: Sara Damiano --- src/SensorBase.cpp | 19 +++++++++++++++---- src/VariableArray.cpp | 44 ++++++++++++++++++++++++++----------------- src/sensors/ANBpH.cpp | 2 +- 3 files changed, 43 insertions(+), 22 deletions(-) diff --git a/src/SensorBase.cpp b/src/SensorBase.cpp index 4e5bce2ca..c77efb4fe 100644 --- a/src/SensorBase.cpp +++ b/src/SensorBase.cpp @@ -153,10 +153,21 @@ void Sensor::powerUp(void) { // This turns off sensor power void Sensor::powerDown(void) { - if (_powerPin >= 0) { - MS_DBG(F("Turning off power to"), getSensorNameAndLocation(), - F("with pin"), _powerPin); - digitalWrite(_powerPin, LOW); + if (_powerPin >= 0 || _powerPin2 >= 0) { + // Reset power pin mode every power up because pins are set to tri-state + // on sleep on SAMD boards + if (_powerPin >= 0) { + pinMode(_powerPin, OUTPUT); + MS_DBG(F("Turning off"), getSensorNameAndLocation(), F("with pin"), + _powerPin); + digitalWrite(_powerPin, LOW); + } + if (_powerPin2 >= 0) { + pinMode(_powerPin2, OUTPUT); + MS_DBG(F("Turning off secondary power to"), + getSensorNameAndLocation(), F("with pin"), _powerPin2); + digitalWrite(_powerPin2, LOW); + } // Unset the power-on time _millisPowerOn = 0; // Unset the activation time diff --git a/src/VariableArray.cpp b/src/VariableArray.cpp index cc951cf4d..332b51a41 100644 --- a/src/VariableArray.cpp +++ b/src/VariableArray.cpp @@ -506,6 +506,12 @@ bool VariableArray::completeUpdate(void) { sensorList[addedSensors++] = arrayOfVars[i]->parentSensor; } } +#if defined(MS_VARIABLEARRAY_DEBUG) || defined(MS_VARIABLEARRAY_DEBUG_DEEP) + for (uint8_t i = 0; i < _sensorCount; i++) { + MS_DBG(F(" Sensor"), i, F("is"), + sensorList[i]->getSensorNameAndLocation()); + } +#endif // Clear the initial variable arrays MS_DBG(F("----->> Clearing all results arrays before taking new " @@ -521,16 +527,15 @@ bool VariableArray::completeUpdate(void) { while (nSensorsCompleted < _sensorCount) { for (uint8_t i = 0; i < _sensorCount; i++) { uint8_t nReq = sensorList[i]->getNumberMeasurementsToAverage(); - uint8_t nDone = - sensorList[i]->getNumberCompleteMeasurementsAttempts(); #if defined(MS_VARIABLEARRAY_DEBUG) || defined(MS_VARIABLEARRAY_DEBUG_DEEP) - String sName = sensorList[i]->getSensorNameAndLocation(); - String dCount = String(i) + '.' + String(nDone + 1) + '.' + - String(sensorList[i]->getNumberRetryAttemptsMade()); - + String sName = sensorList[i]->getSensorNameAndLocation(); + String cycCount = String(i) + '.' + + String(sensorList[i]->getNumberCompleteMeasurementsAttempts() + + 1) + + '.' + String(sensorList[i]->getNumberRetryAttemptsMade()); #endif // Only do checks on sensors that still have measurements to finish - if (nReq > nDone) { + if (nReq > sensorList[i]->getNumberCompleteMeasurementsAttempts()) { if (sensorList[i]->getStatusBit(Sensor::WAKE_ATTEMPTED) == 0 // If no attempts yet made to wake the sensor up && sensorList[i]->isWarmedUp( @@ -575,8 +580,8 @@ bool VariableArray::completeUpdate(void) { Sensor::MEASUREMENT_SUCCESSFUL) == 0) { // .. check if it's stable if (sensorList[i]->isStable(deepDebugTiming)) { - MS_DBG(dCount, F("--->> Starting reading"), nDone + 1, - F("on"), sName, F("...")); + MS_DBG(cycCount, F("--->> Starting reading on"), sName, + F("...")); bool sensorSuccess_start = sensorList[i]->startSingleMeasurement(); @@ -584,10 +589,10 @@ bool VariableArray::completeUpdate(void) { if (sensorSuccess_start) { MS_DBG(F(" ... start reading succeeded. <<---"), - dCount); + cycCount); } else { MS_DBG(F(" ... start reading failed! <<---"), - dCount); + cycCount); } } } @@ -604,8 +609,9 @@ bool VariableArray::completeUpdate(void) { // the number of finished measurements. if (sensorList[i]->isMeasurementComplete(deepDebugTiming)) { // Get the value - MS_DBG(dCount, F("--->> Collected result of reading"), - nDone + 1, F("from"), sName, F("...")); + MS_DBG(cycCount, + F("--->> Collected result of reading from"), + sName, F("...")); bool sensorSuccess_result = sensorList[i]->addSingleMeasurementResult(); @@ -613,17 +619,18 @@ bool VariableArray::completeUpdate(void) { if (sensorSuccess_result) { MS_DBG(F(" ... got measurement result. <<---"), - dCount); + cycCount); } else { MS_DBG(F(" ... failed to get measurement result! " "<<---"), - dCount); + cycCount); } } } // If all the measurements are done - if (nDone >= nReq) { + if (sensorList[i]->getNumberCompleteMeasurementsAttempts() >= + nReq) { MS_DBG(i, F("--->> Finished all measurements from"), sName, F(", putting it to sleep. ...")); @@ -684,7 +691,10 @@ bool VariableArray::completeUpdate(void) { F("sensors now complete ---*****")); } else { MS_DBG(i, F("--->>"), sName, F("still needs to take"), - nReq - nDone, F("measurements.")); + nReq - + sensorList[i] + ->getNumberCompleteMeasurementsAttempts(), + F("measurements.")); } } } diff --git a/src/sensors/ANBpH.cpp b/src/sensors/ANBpH.cpp index 80f91b6a0..300aff512 100644 --- a/src/sensors/ANBpH.cpp +++ b/src/sensors/ANBpH.cpp @@ -223,7 +223,7 @@ bool ANBpH::wake(void) { // Send the command to begin taking readings, trying up to 5 times bool success = false; uint8_t ntries = 0; - MS_DBG(F("Start Measurement on"), getSensorNameAndLocation()); + MS_DBG(F("Start scanning on"), getSensorNameAndLocation()); while (!success && ntries < 5) { MS_DEEP_DBG('(', ntries + 1, F("):")); success = _anb_sensor.start(); From b83a75cfe16baec4116f89d319a7c1dbdd019279 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Fri, 26 Sep 2025 10:35:52 -0400 Subject: [PATCH 027/533] Don't return immediately on NIST error for XBees Signed-off-by: Sara Damiano --- src/modems/DigiXBeeCellularTransparent.cpp | 7 ++++++- src/modems/DigiXBeeWifi.cpp | 7 ++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/modems/DigiXBeeCellularTransparent.cpp b/src/modems/DigiXBeeCellularTransparent.cpp index bd878b65f..29f8669cb 100644 --- a/src/modems/DigiXBeeCellularTransparent.cpp +++ b/src/modems/DigiXBeeCellularTransparent.cpp @@ -239,7 +239,12 @@ uint32_t DigiXBeeCellularTransparent::getNISTTime(void) { byte response[4] = {0}; gsmClient.read(response, 4); gsmClient.stop(); - return parseNISTBytes(response); + uint32_t nistParsed = parseNISTBytes(response); + if (nistParsed != 0) { + return nistParsed; + } else { + MS_DBG(F("NIST response was invalid!")); + } } else { MS_DBG(F("NIST Time server did not respond!")); gsmClient.stop(); diff --git a/src/modems/DigiXBeeWifi.cpp b/src/modems/DigiXBeeWifi.cpp index 8a92a74e2..6e3885b47 100644 --- a/src/modems/DigiXBeeWifi.cpp +++ b/src/modems/DigiXBeeWifi.cpp @@ -419,7 +419,12 @@ uint32_t DigiXBeeWifi::getNISTTime(void) { byte response[NIST_RESPONSE_BYTES] = {0}; gsmClient.read(response, NIST_RESPONSE_BYTES); gsmClient.stop(); - return parseNISTBytes(response); + uint32_t nistParsed = parseNISTBytes(response); + if (nistParsed != 0) { + return nistParsed; + } else { + MS_DBG(F("NIST response was invalid!")); + } } else { MS_DBG(F("NIST Time server did not respond!")); gsmClient.stop(); From aeb78b384b32b528fd408d8e7ee074bdb87f02bf Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Fri, 26 Sep 2025 11:09:25 -0400 Subject: [PATCH 028/533] Debug power pin turn off Signed-off-by: Sara Damiano --- src/VariableArray.cpp | 51 +++++++++++++++++++++++++++++++++++++------ 1 file changed, 44 insertions(+), 7 deletions(-) diff --git a/src/VariableArray.cpp b/src/VariableArray.cpp index 332b51a41..6ac956deb 100644 --- a/src/VariableArray.cpp +++ b/src/VariableArray.cpp @@ -684,22 +684,59 @@ bool VariableArray::completeUpdate(void) { "power pin still need to take measurements. " "Leaving power on pin"), sensorList[i]->getPowerPin(), F("ON. <<---")); +#if defined(MS_VARIABLEARRAY_DEBUG_DEEP) + for (uint8_t k = 0; k < _sensorCount; k++) { + if ((sensorList[k]->getPowerPin() == + sensorList[i]->getPowerPin() || + sensorList[k]->getSecondaryPowerPin() == + sensorList[i]->getPowerPin() || + sensorList[k]->getPowerPin() == + sensorList[i]->getSecondaryPowerPin() || + sensorList[k]->getSecondaryPowerPin() == + sensorList[i]->getSecondaryPowerPin()) && + (sensorList[k] + ->getNumberCompleteMeasurementsAttempts() < + sensorList[k] + ->getNumberMeasurementsToAverage())) { + MS_DEEP_DBG( + i, sName, F("shares a power pin with"), + sensorList[k]->getSensorNameAndLocation(), + F("which still needs to take"), + sensorList[k] + ->getNumberMeasurementsToAverage() - + sensorList[k] + ->getNumberCompleteMeasurementsAttempts(), + F("measurements.")); + MS_DEEP_DBG( + sName, F("pins are"), + sensorList[i]->getPowerPin(), F("and"), + sensorList[i]->getSecondaryPowerPin()); + MS_DEEP_DBG( + sensorList[k]->getSensorNameAndLocation(), + F("pins are"), sensorList[i]->getPowerPin(), + F("and"), + sensorList[i]->getSecondaryPowerPin()); + break; + } + } +#endif } nSensorsCompleted++; // mark the whole sensor as done MS_DBG(F("*****---"), nSensorsCompleted, F("sensors now complete ---*****")); } else { - MS_DBG(i, F("--->>"), sName, F("still needs to take"), - nReq - - sensorList[i] - ->getNumberCompleteMeasurementsAttempts(), - F("measurements.")); + MS_DEEP_DBG( + i, F("--->>"), sName, F("still needs to take"), + nReq - + sensorList[i] + ->getNumberCompleteMeasurementsAttempts(), + F("measurements.")); } } } - MS_DBG(F("xxxxx---"), _sensorCount - nSensorsCompleted, - F("sensors remaining ---xxxxx")); + MS_DEEP_DBG(F("xxxxx---"), _sensorCount - nSensorsCompleted, + F("sensors remaining ---xxxxx")); } // // power down all the sensors again, just in case From 8299d9651173b424c90ed43578643dec8993b621 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Fri, 26 Sep 2025 13:59:13 -0400 Subject: [PATCH 029/533] Fix ANB timing for retries Signed-off-by: Sara Damiano --- src/sensors/ANBpH.cpp | 31 +++++++++++------------ src/sensors/ANBpH.h | 57 +++++++++++++++++++++---------------------- 2 files changed, 44 insertions(+), 44 deletions(-) diff --git a/src/sensors/ANBpH.cpp b/src/sensors/ANBpH.cpp index 300aff512..50d7505b4 100644 --- a/src/sensors/ANBpH.cpp +++ b/src/sensors/ANBpH.cpp @@ -504,26 +504,27 @@ bool ANBpH::isStable(bool debug) { // The minimum time before we start checking for a result depends on whether // the immersion sensor is enabled or not and on the power style. -// If the immersion sensor is enabled, we wait the minimum time that it -// would return a not-immersed error to start querying. If the immersion -// sensor is not enabled, we wait the minimum time for a measurement to be -// ready based on the power style. +// If the immersion sensor is enabled and it's the first measurement after +// applying power, we wait the minimum time that it would return a not-immersed +// error to start querying because it will return an immersion error much faster +// than the full sensing time. If the immersion sensor is not enabled or it's +// not the first measurement after power-up, we wait the minimum time for a +// measurement to be ready based on the power style. uint32_t ANBpH::getStartImmersionErrorWindow(void) { - if (!_immersionSensorEnabled) { return getEndMeasurementWindow(); } - return (_powerPin >= 0 || _retryAttemptsMade > 0) - ? ANB_PH_2ND_IMMERSION_ERROR - : ANB_PH_1ST_IMMERSION_ERROR; + if (!_immersionSensorEnabled || _powerPin < 0 || _retryAttemptsMade > 0) { + return getEndMeasurementWindow(); + } + return ANB_PH_IMMERSION_ERROR; } - uint32_t ANBpH::getEndImmersionErrorWindow(void) { - if (!_immersionSensorEnabled) { return getEndMeasurementWindow(); } - return (_powerPin >= 0 || _retryAttemptsMade > 0) - ? ANB_PH_2ND_IMMERSION_ERROR_MAX - : ANB_PH_1ST_IMMERSION_ERROR_MAX; + if (!_immersionSensorEnabled || _powerPin < 0 || _retryAttemptsMade > 0) { + return getEndMeasurementWindow(); + } + return ANB_PH_IMMERSION_ERROR_MAX; } uint32_t ANBpH::getStartMeasurementWindow(void) { - if (_powerPin >= 0 || _retryAttemptsMade > 0) { + if (_powerPin >= 0 && _retryAttemptsMade == 0) { if (_salinityMode == ANBSalinityMode::HIGH_SALINITY) { return ANB_PH_1ST_VALUE_HIGH_SALT; } else { @@ -543,7 +544,7 @@ uint32_t ANBpH::getStartMeasurementWindow(void) { // If a pin was provided for power, we assume it's on-demand powered and use // the maximum wait time for the first measurement as our maximum wait. uint32_t ANBpH::getEndMeasurementWindow(void) { - if (_powerPin >= 0) { + if (_powerPin >= 0 && _retryAttemptsMade == 0) { if (_salinityMode == ANBSalinityMode::HIGH_SALINITY) { return ANB_PH_1ST_VALUE_HIGH_SALT_MAX; } else { diff --git a/src/sensors/ANBpH.h b/src/sensors/ANBpH.h index 92841c913..f9fd30e65 100644 --- a/src/sensors/ANBpH.h +++ b/src/sensors/ANBpH.h @@ -153,37 +153,19 @@ /// @brief The maximum time to wait for ready to measure. #define ANB_PH_STABILIZATION_TIME_MAX 5000L -/// @brief The minimum time before a failure response is returned on the 2nd or -/// subsequent value when the immersion sensor is not immersed. This is a guess -/// based on testing. -#define ANB_PH_2ND_IMMERSION_ERROR 4000L -/// @brief The minimum time before a failure response is returned on the 2nd or -/// subsequent value when the immersion sensor is not immersed. This is a guess -/// based on testing. -#define ANB_PH_2ND_IMMERSION_ERROR_MAX 12000L -/// @brief The minimum time for the 2nd or subsequent values in high -/// salinity (documented new output time of 10.5s) -#define ANB_PH_2ND_VALUE_HIGH_SALT 5000L -/// @brief The maximum time for the 2nd or subsequent values in high -/// salinity. -#define ANB_PH_2ND_VALUE_HIGH_SALT_MAX 15000L -/// @brief The minimum time for the 2nd or subsequent values in low -/// salinity (documented new output time of 14s). -#define ANB_PH_2ND_VALUE_LOW_SALT 6000L -/// @brief The maximum time for the 2nd or subsequent values in low -/// salinity (documented new output time of 14s). -#define ANB_PH_2ND_VALUE_LOW_SALT_MAX 18000L +/// @brief The minimum time after a new scan after power-up before a failure +/// response is returned when the immersion sensor is not immersed. +/// This is a guess based on testing. +/// @note This only applies when it is the first measurement after power-up and +/// the immersion sensor is enabled! +#define ANB_PH_IMMERSION_ERROR 6000L +/// @brief The minimum time after a new scan after power-up before a failure +/// response is returned when the immersion sensor is not immersed. +/// This is a guess based on testing. +#define ANB_PH_IMMERSION_ERROR_MAX 12000L -/// @brief The minimum time before a failure response is returned on the first -/// measurement when the immersion sensor is not immersed. This is a guess -/// based on testing. -#define ANB_PH_1ST_IMMERSION_ERROR 6000L -/// @brief The maximum time before a failure response is returned on the first -/// measurement when the immersion sensor is not immersed. This is a guess -/// based on testing. -#define ANB_PH_1ST_IMMERSION_ERROR_MAX 12000L /// @brief The minimum time for the first value in high salinity (documented min -/// time of 129s - 9s). +/// time of 129s). #define ANB_PH_1ST_VALUE_HIGH_SALT 120000L /// @brief The maximum time for the first value in high salinity (documented max /// time of 238s for a long interval delay + 10s). @@ -194,6 +176,23 @@ /// @brief The maximum time for the first value in low salinity (documented max /// time of 255s for a long interval delay + 10s). #define ANB_PH_1ST_VALUE_LOW_SALT_MAX 265000L + +/// @brief The minimum time for the 2nd or subsequent values in high +/// salinity (documented new output time of 10.5s) +/// @warning After the first reading, the sensor will *always* say the sensor is +/// ready! But there will not be a **new** value available before this time. +#define ANB_PH_2ND_VALUE_HIGH_SALT 10600L +/// @brief The maximum time to wait for the 2nd or subsequent values in high +/// salinity. +#define ANB_PH_2ND_VALUE_HIGH_SALT_MAX 15000L +/// @brief The minimum time for the 2nd or subsequent values in low +/// salinity (documented new output time of 14s). +/// @warning After the first reading, the sensor will *always* say the sensor is +/// ready! But there will not be a **new** value available before this time. +#define ANB_PH_2ND_VALUE_LOW_SALT 14100L +/// @brief The maximum time to wait for the 2nd or subsequent values in low +/// salinity. +#define ANB_PH_2ND_VALUE_LOW_SALT_MAX 18000L /**@}*/ /** From 392316060dc4e7f05764682040991c64e395d08b Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Fri, 26 Sep 2025 14:10:06 -0400 Subject: [PATCH 030/533] Change note about serial wait Signed-off-by: Sara Damiano --- examples/data_saving/data_saving.ino | 8 +++----- examples/logging_to_MMW/logging_to_MMW.ino | 14 ++++++-------- examples/menu_a_la_carte/menu_a_la_carte.ino | 5 ++--- 3 files changed, 11 insertions(+), 16 deletions(-) diff --git a/examples/data_saving/data_saving.ino b/examples/data_saving/data_saving.ino index 40213be69..94eec7aac 100644 --- a/examples/data_saving/data_saving.ino +++ b/examples/data_saving/data_saving.ino @@ -391,12 +391,10 @@ float getBatteryVoltage() { /** Start [setup] */ void setup() { // Wait for USB connection to be established by PC -// NOTE: Only use this when debugging - if not connected to a PC, this -// could prevent the script from starting +// NOTE: Only use this when debugging - if not connected to a PC, this adds an +// unnecessary startup delay #if defined(SERIAL_PORT_USBVIRTUAL) - while (!SERIAL_PORT_USBVIRTUAL && (millis() < 10000)) { - // wait - } + while (!SERIAL_PORT_USBVIRTUAL && (millis() < 10000L)) {} #endif // Start the primary serial connection diff --git a/examples/logging_to_MMW/logging_to_MMW.ino b/examples/logging_to_MMW/logging_to_MMW.ino index c68c610c6..ea41053c4 100644 --- a/examples/logging_to_MMW/logging_to_MMW.ino +++ b/examples/logging_to_MMW/logging_to_MMW.ino @@ -250,18 +250,16 @@ float getBatteryVoltage() { // ========================================================================== /** Start [setup] */ void setup() { + // Start the primary serial connection + Serial.begin(serialBaud); + // Wait for USB connection to be established by PC -// NOTE: Only use this when debugging - if not connected to a PC, this -// could prevent the script from starting +// NOTE: Only use this when debugging - if not connected to a PC, this adds an +// unnecessary startup delay #if defined(SERIAL_PORT_USBVIRTUAL) - while (!SERIAL_PORT_USBVIRTUAL && (millis() < 10000)) { - // wait - } + while (!SERIAL_PORT_USBVIRTUAL && (millis() < 10000L)) {} #endif - // Start the primary serial connection - Serial.begin(serialBaud); - // Print a start-up note to the first serial port Serial.print(F("Now running ")); Serial.print(sketchName); diff --git a/examples/menu_a_la_carte/menu_a_la_carte.ino b/examples/menu_a_la_carte/menu_a_la_carte.ino index 6ffae3a4d..f70c7ea9a 100644 --- a/examples/menu_a_la_carte/menu_a_la_carte.ino +++ b/examples/menu_a_la_carte/menu_a_la_carte.ino @@ -3589,9 +3589,8 @@ void setup() { // NOTE: Only use this when debugging - if not connected to a PC, this adds an // unnecessary startup delay #if defined(SERIAL_PORT_USBVIRTUAL) - while (!SERIAL_PORT_USBVIRTUAL && (millis() < 10000L)) { - // wait - } + while (!SERIAL_PORT_USBVIRTUAL && (millis() < 10000L)) {} + greenRedFlash(3, 10); #endif /** End [setup_wait] */ From 26f576ec6623a1780050c549f4a3fea7a9e87648 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Fri, 26 Sep 2025 16:03:52 -0400 Subject: [PATCH 031/533] Create a helper function to bump counts Signed-off-by: Sara Damiano --- src/SensorBase.cpp | 19 +++++++++++++++++++ src/SensorBase.h | 8 ++++++++ 2 files changed, 27 insertions(+) diff --git a/src/SensorBase.cpp b/src/SensorBase.cpp index c77efb4fe..0fd4c04f6 100644 --- a/src/SensorBase.cpp +++ b/src/SensorBase.cpp @@ -635,3 +635,22 @@ void Sensor::waitForMeasurementCompletion(void) { // wait } } + + +bool Sensor::bumpMeasurementAttemptCount(bool wasSuccessful) { + // Record the time that the measurement was completed + _millisMeasurementCompleted = millis(); + // Unset the time stamp for the beginning of this measurement + _millisMeasurementRequested = 0; + // Unset the status bits for a measurement request (bits 5 & 6) + clearStatusBits(MEASUREMENT_ATTEMPTED, MEASUREMENT_SUCCESSFUL); + // Bump the number of attempted retries + _retryAttemptsMade++; + + if (wasSuccessful || _retryAttemptsMade >= _allowedMeasurementRetries) { + // Bump the number of completed measurement attempts - we've succeeded + // or failed but exceeded retries + _measurementAttemptsCompleted++; + } + return wasSuccessful; +} diff --git a/src/SensorBase.h b/src/SensorBase.h index 07c0ac59e..6ca6e35a4 100644 --- a/src/SensorBase.h +++ b/src/SensorBase.h @@ -721,6 +721,14 @@ class Sensor { * be defined at compile time and applied to the entire class. */ Variable* variables[MAX_NUMBER_VARS]; + + /** + * @brief A helper function to correctly bump the measurement counts and + * retries and set the appropriate timestamp and status bits. + * @param wasSuccessful True if the measurement attempt was successful. + * @return Returns the input parameter wasSuccessful. + */ + bool bumpMeasurementAttemptCount(bool wasSuccessful); }; #endif // SRC_SENSORBASE_H_ From c827468697ed22b836f2770ddd5b556cb6f37139 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Fri, 26 Sep 2025 16:25:39 -0400 Subject: [PATCH 032/533] Use helper to simplify all addSingleMeasurementResult functions and remove a lot of extra setting invalid values back to -9999. Signed-off-by: Sara Damiano --- continuous_integration/dependencies.json | 10 +- src/sensors/ANBpH.cpp | 92 ++++++-------- src/sensors/AOSongAM2315.cpp | 52 +++----- src/sensors/AOSongDHT.cpp | 91 +++++--------- src/sensors/AlphasenseCO2.cpp | 124 ++++++++---------- src/sensors/AnalogElecConductivity.cpp | 33 ++--- src/sensors/ApogeeSQ212.cpp | 110 +++++++--------- src/sensors/AtlasParent.cpp | 105 ++++++---------- src/sensors/BoschBME280.cpp | 103 ++++++--------- src/sensors/BoschBMP3xx.cpp | 67 +++------- src/sensors/CampbellOBS3.cpp | 119 +++++++----------- src/sensors/EverlightALSPT19.cpp | 80 +++++------- src/sensors/FreescaleMPL115A2.cpp | 66 ++++------ src/sensors/GeoluxHydroCam.cpp | 137 +++++++++----------- src/sensors/GroPointParent.cpp | 154 ++++++++--------------- src/sensors/KellerParent.cpp | 88 +++++-------- src/sensors/MaxBotixSonar.cpp | 112 +++++++---------- src/sensors/MaximDS18.cpp | 61 +++------ src/sensors/MaximDS3231.cpp | 19 +-- src/sensors/MeaSpecMS5803.cpp | 83 +++++------- src/sensors/PaleoTerraRedox.cpp | 96 ++++++-------- src/sensors/ProcessorStats.cpp | 16 +-- src/sensors/RainCounterI2C.cpp | 44 +++---- src/sensors/SDI12Sensors.cpp | 69 ++-------- src/sensors/SensirionSHT4x.cpp | 70 ++++------- src/sensors/TIADS1x15.cpp | 102 ++++++--------- src/sensors/TIINA219.cpp | 72 ++++------- src/sensors/TallyCounterI2C.cpp | 73 ++++------- src/sensors/TurnerCyclops.cpp | 119 +++++++----------- src/sensors/TurnerTurbidityPlus.cpp | 145 +++++++++------------ src/sensors/YosemitechParent.cpp | 135 ++++++++------------ 31 files changed, 983 insertions(+), 1664 deletions(-) diff --git a/continuous_integration/dependencies.json b/continuous_integration/dependencies.json index 11c195fd1..fbfe1b9b4 100644 --- a/continuous_integration/dependencies.json +++ b/continuous_integration/dependencies.json @@ -1,5 +1,5 @@ { - "action_cache_version": 38, + "action_cache_version": 39, "dependencies": [ { "name": "EnviroDIY_DS3231", @@ -293,7 +293,7 @@ "owner": "envirodiy", "library id": "1824", "url": "https://github.com/EnviroDIY/SensorModbusMaster", - "version": "~1.6.5", + "version": "~1.6.6", "note": "EnviroDIY SensorModbusMaster - Arduino library for communicating via modbus with the Arduino acting as the modbus master.", "authors": [ "Sara Damiano" @@ -305,7 +305,7 @@ "owner": "envirodiy", "library id": "5439", "url": "https://github.com/EnviroDIY/KellerModbus", - "version": "~0.2.5", + "version": "~0.2.6", "note": "Arduino library for communication with Keller pressure and water level sensors via Modbus.", "authors": [ "Anthony Aufdenkampe" @@ -316,7 +316,7 @@ "owner": "envirodiy", "library id": "2078", "url": "https://github.com/EnviroDIY/YosemitechModbus", - "version": "~0.5.2", + "version": "~0.5.3", "note": "Arduino library for communication with Yosemitech sensors via Modbus.", "authors": [ "Sara Damiano", @@ -328,7 +328,7 @@ "name": "GroPointModbus", "owner": "envirodiy", "url": "https://github.com/EnviroDIY/GroPointModbus", - "version": "~0.1.3", + "version": "~0.1.4", "note": "A library to use an Arduino as a master to control and communicate via modbus with GroPoint soil moisture sensors.", "authors": [ "Anthony Aufdenkampe" diff --git a/src/sensors/ANBpH.cpp b/src/sensors/ANBpH.cpp index 50d7505b4..dacc17bde 100644 --- a/src/sensors/ANBpH.cpp +++ b/src/sensors/ANBpH.cpp @@ -294,8 +294,12 @@ bool ANBpH::sleep(void) { } bool ANBpH::addSingleMeasurementResult(void) { - bool success = false; - // Initialize variables for each value + // Immediately quit if the measurement was not successfully started + if (!getStatusBit(MEASUREMENT_SUCCESSFUL)) { + return bumpMeasurementAttemptCount(false); + } + + bool success = false; float pH, temp, sal, spcond, raw_cond = -9999; ANBHealthCode health = ANBHealthCode::UNKNOWN; ANBStatusCode status = ANBStatusCode::UNKNOWN; @@ -318,33 +322,38 @@ bool ANBpH::addSingleMeasurementResult(void) { ':', time_buff); #endif - // Check a measurement was *successfully* started (status bit 6 set) - // Only go on to get a result if it was - if (getStatusBit(MEASUREMENT_SUCCESSFUL)) { - // Print Moisture Values - MS_DBG(F("Get Values from"), getSensorNameAndLocation()); - success = _anb_sensor.getValues(pH, temp, sal, spcond, raw_cond, health, - diagnostic); - status = _anb_sensor.getStatusCode(); - - // Print the values for debugging - MS_DBG(F(" pH:"), pH); - MS_DBG(F(" Temperature (C):"), temp); - MS_DBG(F(" Salinity (ppt):"), sal); - MS_DBG(F(" Specific Conductance (µS/cm):"), spcond); - MS_DBG(F(" Raw Conductance (µS/cm):"), raw_cond); - MS_DBG(F(" Health Code:"), static_cast(health), '-', - _anb_sensor.getHealthString(health)); - MS_DBG(F(" Diagnostic Code:"), static_cast(diagnostic), '-', - _anb_sensor.getDiagnosticString(diagnostic)); - MS_DBG(F(" Status Code:"), static_cast(status), '-', - _anb_sensor.getStatusString(status)); - - if (health == ANBHealthCode::NOT_IMMERSED) { - PRINTOUT(F(" WARNING: ANB pH sensor is not immersed!")); - } + MS_DBG(F("Get Values from"), getSensorNameAndLocation()); + success = _anb_sensor.getValues(pH, temp, sal, spcond, raw_cond, health, + diagnostic); + status = _anb_sensor.getStatusCode(); + + // Print the values for debugging + MS_DBG(F(" pH:"), pH); + MS_DBG(F(" Temperature (C):"), temp); + MS_DBG(F(" Salinity (ppt):"), sal); + MS_DBG(F(" Specific Conductance (µS/cm):"), spcond); + MS_DBG(F(" Raw Conductance (µS/cm):"), raw_cond); + MS_DBG(F(" Health Code:"), static_cast(health), '-', + _anb_sensor.getHealthString(health)); + MS_DBG(F(" Diagnostic Code:"), static_cast(diagnostic), '-', + _anb_sensor.getDiagnosticString(diagnostic)); + MS_DBG(F(" Status Code:"), static_cast(status), '-', + _anb_sensor.getStatusString(status)); + + if (health == ANBHealthCode::NOT_IMMERSED) { + PRINTOUT(F(" WARNING: ANB pH sensor is not immersed!")); + } + + // We consider a measurement successful if we got a modbus response and + // the pH value is in range or the health code says the sensor is not + // immersed. We accept the not immersed condition as a successful + // measurement because the sensor will not retry for at least 5 minutes + // after an immersion error. + success &= ((0.0 < pH && pH < 14.00) || + health == ANBHealthCode::NOT_IMMERSED); - // Put values into the array + // Put values into the array - if it's a success or our last try + if (success || _retryAttemptsMade == _allowedMeasurementRetries - 1) { verifyAndAddMeasurementResult(ANB_PH_PH_VAR_NUM, pH); verifyAndAddMeasurementResult(ANB_PH_TEMP_VAR_NUM, temp); verifyAndAddMeasurementResult(ANB_PH_SALINITY_VAR_NUM, sal); @@ -356,35 +365,10 @@ bool ANBpH::addSingleMeasurementResult(void) { static_cast(diagnostic)); verifyAndAddMeasurementResult(ANB_PH_STATUS_CODE_VAR_NUM, static_cast(status)); - } else { - MS_DBG(getSensorNameAndLocation(), F("is not currently measuring!")); - } - // Record the time that the measurement was completed - _millisMeasurementCompleted = millis(); - // Unset the time stamp for the beginning of this measurement - _millisMeasurementRequested = 0; - // Unset the status bits for a measurement request (bits 5 & 6) - clearStatusBits(MEASUREMENT_ATTEMPTED, MEASUREMENT_SUCCESSFUL); - // Bump the number of attempted retries - _retryAttemptsMade++; - - // We consider a measurement successful if we got a modbus response and - // the pH value is in range or the health code says the sensor is not - // immersed. We accept the not immersed condition as a successful - // measurement because the sensor will not retry for at least 5 minutes - // after an immersion error. - if (success && - ((0.0 < pH && pH < 14.00) || health == ANBHealthCode::NOT_IMMERSED)) { - // Bump the number of completed measurement attempts - _measurementAttemptsCompleted++; - } else if (_retryAttemptsMade >= _allowedMeasurementRetries) { - // Bump the number of completed measurement attempts - we've failed but - // exceeded retries - _measurementAttemptsCompleted++; } // Return success value when finished - return success; + return bumpMeasurementAttemptCount(success); } // check if the sensor is ready diff --git a/src/sensors/AOSongAM2315.cpp b/src/sensors/AOSongAM2315.cpp index ed73e4a35..3c03ef657 100644 --- a/src/sensors/AOSongAM2315.cpp +++ b/src/sensors/AOSongAM2315.cpp @@ -51,46 +51,32 @@ bool AOSongAM2315::setup(void) { bool AOSongAM2315::addSingleMeasurementResult(void) { - // Initialize float variables + // Immediately quit if the measurement was not successfully started + if (!getStatusBit(MEASUREMENT_SUCCESSFUL)) { + return bumpMeasurementAttemptCount(false); + } + + bool success = false; float temp_val = -9999; float humid_val = -9999; bool ret_val = false; - // Check a measurement was *successfully* started (status bit 6 set) - // Only go on to get a result if it was - if (getStatusBit(MEASUREMENT_SUCCESSFUL)) { - MS_DBG(getSensorNameAndLocation(), F("is reporting:")); + MS_DBG(getSensorNameAndLocation(), F("is reporting:")); - ret_val = am2315ptr->readTemperatureAndHumidity(&temp_val, &humid_val); + success = am2315ptr->readTemperatureAndHumidity(&temp_val, &humid_val); - if (!ret_val || isnan(temp_val)) temp_val = -9999; - if (!ret_val || isnan(humid_val)) humid_val = -9999; - MS_DBG(F(" Temp:"), temp_val, F("°C")); - MS_DBG(F(" Humidity:"), humid_val, '%'); - } else { - MS_DBG(getSensorNameAndLocation(), F("is not currently measuring!")); - } + success &= !isnan(temp_val) && temp_val != -9999 && !isnan(humid_val) && + humid_val != -9999; - verifyAndAddMeasurementResult(AM2315_TEMP_VAR_NUM, temp_val); - verifyAndAddMeasurementResult(AM2315_HUMIDITY_VAR_NUM, humid_val); - - // Record the time that the measurement was completed - _millisMeasurementCompleted = millis(); - // Unset the time stamp for the beginning of this measurement - _millisMeasurementRequested = 0; - // Unset the status bits for a measurement request (bits 5 & 6) - clearStatusBits(MEASUREMENT_ATTEMPTED, MEASUREMENT_SUCCESSFUL); - // Bump the number of attempted retries - _retryAttemptsMade++; - - if (ret_val && !isnan(temp_val) && !isnan(humid_val)) { - // Bump the number of completed measurement attempts - _measurementAttemptsCompleted++; - } else if (_retryAttemptsMade >= _allowedMeasurementRetries) { - // Bump the number of completed measurement attempts - we've failed - // but exceeded retries - _measurementAttemptsCompleted++; + MS_DBG(F(" Temp:"), temp_val, F("°C")); + MS_DBG(F(" Humidity:"), humid_val, '%'); + + if (success) { + verifyAndAddMeasurementResult(AM2315_TEMP_VAR_NUM, temp_val); + verifyAndAddMeasurementResult(AM2315_HUMIDITY_VAR_NUM, humid_val); } - return ret_val; + + // Return success value when finished + return bumpMeasurementAttemptCount(success); } diff --git a/src/sensors/AOSongDHT.cpp b/src/sensors/AOSongDHT.cpp index e9da465c3..504b2bf31 100644 --- a/src/sensors/AOSongDHT.cpp +++ b/src/sensors/AOSongDHT.cpp @@ -18,7 +18,9 @@ AOSongDHT::AOSongDHT(int8_t powerPin, int8_t dataPin, const uint8_t type, DHT_STABILIZATION_TIME_MS, DHT_MEASUREMENT_TIME_MS, powerPin, dataPin, measurementsToAverage, DHT_INC_CALC_VARIABLES), dht_internal(dataPin, type), - _dhtType(type) {} + _dhtType(type) { + setAllowedMeasurementRetries(5); +} // Destructor - does nothing. AOSongDHT::~AOSongDHT() {} @@ -42,73 +44,36 @@ String AOSongDHT::getSensorName(void) { bool AOSongDHT::addSingleMeasurementResult(void) { - bool success = false; + // Immediately quit if the measurement was not successfully started + if (!getStatusBit(MEASUREMENT_SUCCESSFUL)) { + return bumpMeasurementAttemptCount(false); + } - // Initialize float variables + bool success = false; float humid_val = -9999; float temp_val = -9999; float hi_val = -9999; - // Check a measurement was *successfully* started (status bit 6 set) - // Only go on to get a result if it was - if (getStatusBit(MEASUREMENT_SUCCESSFUL)) { - // Reading temperature or humidity takes about 250 milliseconds! - // Make 5 attempts to get a decent reading - for (uint8_t i = 0; i < 5; i++) { - MS_DBG(getSensorNameAndLocation(), F("is reporting:")); - // First read the humidity - humid_val = dht_internal.readHumidity(); - // Read temperature as Celsius (the default) - temp_val = dht_internal.readTemperature(); - // Check if any reads failed - // If they are NaN (not a number) then something went wrong - if (!isnan(humid_val) && !isnan(temp_val)) { - // Compute heat index in Celsius (isFahrenheit = false) - hi_val = dht_internal.computeHeatIndex(temp_val, humid_val, - false); - MS_DBG(F(" Temp:"), temp_val, F("°C")); - MS_DBG(F(" Humidity:"), humid_val, '%'); - MS_DBG(F(" Calculated Heat Index:"), hi_val, F("°C")); - success = true; - break; - } else { - /// @todo align retries with other sensors? - if (i < 4) { - MS_DBG(F(" Failed to read from DHT sensor, Retrying...")); - delay(100); - } else { - MS_DBG(F(" Failed to read from DHT sensor!")); - if (isnan(humid_val)) humid_val = -9999; - if (isnan(temp_val)) temp_val = -9999; - } - } - } - } else { - MS_DBG(getSensorNameAndLocation(), F("is not currently measuring!")); - } - - // Store the results in the sensorValues array - verifyAndAddMeasurementResult(DHT_TEMP_VAR_NUM, temp_val); - verifyAndAddMeasurementResult(DHT_HUMIDITY_VAR_NUM, humid_val); - verifyAndAddMeasurementResult(DHT_HI_VAR_NUM, hi_val); - - // Record the time that the measurement was completed - _millisMeasurementCompleted = millis(); - // Unset the time stamp for the beginning of this measurement - _millisMeasurementRequested = 0; - // Unset the status bits for a measurement request (bits 5 & 6) - clearStatusBits(MEASUREMENT_ATTEMPTED, MEASUREMENT_SUCCESSFUL); - // Bump the number of attempted retries - _retryAttemptsMade++; - - if (success && !isnan(temp_val) && !isnan(humid_val)) { - // Bump the number of completed measurement attempts - _measurementAttemptsCompleted++; - } else if (_retryAttemptsMade >= _allowedMeasurementRetries) { - // Bump the number of completed measurement attempts - we've failed but - // exceeded retries - _measurementAttemptsCompleted++; + // Reading temperature or humidity takes about 250 milliseconds! + MS_DBG(getSensorNameAndLocation(), F("is reporting:")); + // First read the humidity + humid_val = dht_internal.readHumidity(); + // Read temperature as Celsius (the default) + temp_val = dht_internal.readTemperature(); + // Check if any reads failed + // If they are NaN (not a number) then something went wrong + if (!isnan(humid_val) && !isnan(temp_val)) { + // Compute heat index in Celsius (isFahrenheit = false) + hi_val = dht_internal.computeHeatIndex(temp_val, humid_val, false); + MS_DBG(F(" Temp:"), temp_val, F("°C")); + MS_DBG(F(" Humidity:"), humid_val, '%'); + MS_DBG(F(" Calculated Heat Index:"), hi_val, F("°C")); + verifyAndAddMeasurementResult(DHT_TEMP_VAR_NUM, temp_val); + verifyAndAddMeasurementResult(DHT_HUMIDITY_VAR_NUM, humid_val); + verifyAndAddMeasurementResult(DHT_HI_VAR_NUM, hi_val); + success = true; } - return success; + // Return success value when finished + return bumpMeasurementAttemptCount(success); } diff --git a/src/sensors/AlphasenseCO2.cpp b/src/sensors/AlphasenseCO2.cpp index 88d91f33f..cb866d10c 100644 --- a/src/sensors/AlphasenseCO2.cpp +++ b/src/sensors/AlphasenseCO2.cpp @@ -43,90 +43,68 @@ String AlphasenseCO2::getSensorLocation(void) { bool AlphasenseCO2::addSingleMeasurementResult(void) { - // Variables to store the results in + // Immediately quit if the measurement was not successfully started + if (!getStatusBit(MEASUREMENT_SUCCESSFUL)) { + return bumpMeasurementAttemptCount(false); + } + + bool success = false; int16_t adcCounts = -9999; float adcVoltage = -9999; float co2Current = -9999; float calibResult = -9999; - // Check a measurement was *successfully* started (status bit 6 set) - // Only go on to get a result if it was - if (getStatusBit(MEASUREMENT_SUCCESSFUL)) { - MS_DBG(getSensorNameAndLocation(), F("is reporting:")); + MS_DBG(getSensorNameAndLocation(), F("is reporting:")); // Create an auxiliary ADD object -// We create and set up the ADC object here so that each sensor using -// the ADC may set the gain appropriately without effecting others. +// We create and set up the ADC object here so that each sensor using the ADC +// may set the gain appropriately without effecting others. #ifndef MS_USE_ADS1015 - Adafruit_ADS1115 ads; // Use this for the 16-bit version + Adafruit_ADS1115 ads; // Use this for the 16-bit version #else - Adafruit_ADS1015 ads; // Use this for the 12-bit version + Adafruit_ADS1015 ads; // Use this for the 12-bit version #endif - // ADS Library default settings: - // - TI1115 (16 bit) - // - single-shot mode (powers down between conversions) - // - 128 samples per second (8ms conversion time) - // - 2/3 gain +/- 6.144V range (limited to VDD +0.3V max) - // - TI1015 (12 bit) - // - single-shot mode (powers down between conversions) - // - 1600 samples per second (625µs conversion time) - // - 2/3 gain +/- 6.144V range (limited to VDD +0.3V max) - - // Bump the gain up to 1x = +/- 4.096V range - // Sensor return range is 0-2.5V, but the next gain option is 2x which - // only allows up to 2.048V - ads.setGain(GAIN_ONE); - // Begin ADC - ads.begin(_i2cAddress); - - // Read Analog to Digital Converter (ADC) - // Taking this reading includes the 8ms conversion delay. - // Measure the voltage differential across the two voltage pins - adcCounts = ads.readADC_Differential_2_3(); - // Convert ADC counts value to voltage (V) - adcVoltage = ads.computeVolts(adcCounts); - MS_DBG(F(" ads.readADC_Differential_2_3() converted to volts:"), - adcVoltage); - - if (adcVoltage < 3.6 && adcVoltage > -0.3) { - // Skip results out of range - // Convert voltage to current (mA) - assuming a 250 Ohm resistor is - // in series - co2Current = (adcVoltage / 250) * 1000; - // Convert current to ppm (using a formula recommended by the sensor - // manufacturer) - calibResult = 312.5 * co2Current - 1250; - MS_DBG(F(" calibResult:"), calibResult); - } else { - // set invalid voltages back to -9999 - adcVoltage = -9999; - } - } else { - MS_DBG(getSensorNameAndLocation(), F("is not currently measuring!")); - } - - verifyAndAddMeasurementResult(ALPHASENSE_CO2_VAR_NUM, calibResult); - verifyAndAddMeasurementResult(ALPHASENSE_CO2_VOLTAGE_VAR_NUM, adcVoltage); - - // Record the time that the measurement was completed - _millisMeasurementCompleted = millis(); - // Unset the time stamp for the beginning of this measurement - _millisMeasurementRequested = 0; - // Unset the status bits for a measurement request (bits 5 & 6) - clearStatusBits(MEASUREMENT_ATTEMPTED, MEASUREMENT_SUCCESSFUL); - // Bump the number of attempted retries - _retryAttemptsMade++; + // ADS Library default settings: + // - TI1115 (16 bit) + // - single-shot mode (powers down between conversions) + // - 128 samples per second (8ms conversion time) + // - 2/3 gain +/- 6.144V range (limited to VDD +0.3V max) + // - TI1015 (12 bit) + // - single-shot mode (powers down between conversions) + // - 1600 samples per second (625µs conversion time) + // - 2/3 gain +/- 6.144V range (limited to VDD +0.3V max) + + // Bump the gain up to 1x = +/- 4.096V range + // Sensor return range is 0-2.5V, but the next gain option is 2x which + // only allows up to 2.048V + ads.setGain(GAIN_ONE); + // Begin ADC + ads.begin(_i2cAddress); + + // Read Analog to Digital Converter (ADC) + // Taking this reading includes the 8ms conversion delay. + // Measure the voltage differential across the two voltage pins + adcCounts = ads.readADC_Differential_2_3(); + // Convert ADC counts value to voltage (V) + adcVoltage = ads.computeVolts(adcCounts); + MS_DBG(F(" ads.readADC_Differential_2_3() converted to volts:"), + adcVoltage); if (adcVoltage < 3.6 && adcVoltage > -0.3) { - // Bump the number of completed measurement attempts - _measurementAttemptsCompleted++; - return true; - } else if (_retryAttemptsMade >= _allowedMeasurementRetries) { - // Bump the number of completed measurement attempts - we've failed but - // exceeded retries - _measurementAttemptsCompleted++; - return false; - } else { - return false; + // Skip results out of range + // Convert voltage to current (mA) - assuming a 250 Ohm resistor is in + // series + co2Current = (adcVoltage / 250) * 1000; + // Convert current to ppm (using a formula recommended by the sensor + // manufacturer) + calibResult = 312.5 * co2Current - 1250; + MS_DBG(F(" calibResult:"), calibResult); + verifyAndAddMeasurementResult(ALPHASENSE_CO2_VAR_NUM, calibResult); + verifyAndAddMeasurementResult(ALPHASENSE_CO2_VOLTAGE_VAR_NUM, + adcVoltage); + success = true; } + + // Return success value when finished + return bumpMeasurementAttemptCount(success); } diff --git a/src/sensors/AnalogElecConductivity.cpp b/src/sensors/AnalogElecConductivity.cpp index 9b7b5cb66..addf41fbc 100644 --- a/src/sensors/AnalogElecConductivity.cpp +++ b/src/sensors/AnalogElecConductivity.cpp @@ -76,34 +76,23 @@ float AnalogElecConductivity::readEC(uint8_t analogPinNum) { bool AnalogElecConductivity::addSingleMeasurementResult(void) { + // Immediately quit if the measurement was not successfully started + if (!getStatusBit(MEASUREMENT_SUCCESSFUL)) { + return bumpMeasurementAttemptCount(false); + } + float sensorEC_uScm = -9999; - if (getStatusBit(MEASUREMENT_SUCCESSFUL)) { - MS_DBG(getSensorNameAndLocation(), F("is reporting:")); + MS_DBG(getSensorNameAndLocation(), F("is reporting:")); - sensorEC_uScm = readEC(_dataPin); - MS_DBG(F("Water EC (uSm/cm)"), sensorEC_uScm); - } else { - MS_DBG(getSensorNameAndLocation(), F("is not currently measuring!")); - } + sensorEC_uScm = readEC(_dataPin); + MS_DBG(F("Water EC (uSm/cm)"), sensorEC_uScm); + // NOTE: We don't actually have any criteria for if the reading was any good + // or not, so we mark it as successful no matter what. verifyAndAddMeasurementResult(ANALOGELECCONDUCTIVITY_EC_VAR_NUM, sensorEC_uScm); - - // Record the time that the measurement was completed - _millisMeasurementCompleted = millis(); - // Unset the time stamp for the beginning of this measurement - _millisMeasurementRequested = 0; - // Unset the status bits for a measurement request (bits 5 & 6) - clearStatusBits(MEASUREMENT_ATTEMPTED, MEASUREMENT_SUCCESSFUL); - // Bump the number of attempted retries - _retryAttemptsMade++; - // NOTE: We don't actually have any criteria for if the reading was any good - // or not, so we mark it as completed no matter what. - _measurementAttemptsCompleted++; - - // Return true when finished - return true; + return bumpMeasurementAttemptCount(true); } // cSpell:ignore AnalogElecConductivity Rseries_ohms sensorEC_Konst Rwater_ohms diff --git a/src/sensors/ApogeeSQ212.cpp b/src/sensors/ApogeeSQ212.cpp index c6e4255f6..4fcb07c8d 100644 --- a/src/sensors/ApogeeSQ212.cpp +++ b/src/sensors/ApogeeSQ212.cpp @@ -43,85 +43,61 @@ String ApogeeSQ212::getSensorLocation(void) { bool ApogeeSQ212::addSingleMeasurementResult(void) { - // Variables to store the results in + // Immediately quit if the measurement was not successfully started + if (!getStatusBit(MEASUREMENT_SUCCESSFUL)) { + return bumpMeasurementAttemptCount(false); + } + + bool success = false; int16_t adcCounts = -9999; float adcVoltage = -9999; float calibResult = -9999; - // Check a measurement was *successfully* started (status bit 6 set) - // Only go on to get a result if it was - if (getStatusBit(MEASUREMENT_SUCCESSFUL)) { - MS_DBG(getSensorNameAndLocation(), F("is reporting:")); + MS_DBG(getSensorNameAndLocation(), F("is reporting:")); // Create an auxiliary ADD object // We create and set up the ADC object here so that each sensor using // the ADC may set the gain appropriately without effecting others. #ifndef MS_USE_ADS1015 - Adafruit_ADS1115 ads; // Use this for the 16-bit version + Adafruit_ADS1115 ads; // Use this for the 16-bit version #else - Adafruit_ADS1015 ads; // Use this for the 12-bit version + Adafruit_ADS1015 ads; // Use this for the 12-bit version #endif - // ADS Library default settings: - // - TI1115 (16 bit) - // - single-shot mode (powers down between conversions) - // - 128 samples per second (8ms conversion time) - // - 2/3 gain +/- 6.144V range (limited to VDD +0.3V max) - // - TI1015 (12 bit) - // - single-shot mode (powers down between conversions) - // - 1600 samples per second (625µs conversion time) - // - 2/3 gain +/- 6.144V range (limited to VDD +0.3V max) - - // Bump the gain up to 1x = +/- 4.096V range - // Sensor return range is 0-2.5V, but the next gain option is 2x which - // only allows up to 2.048V - ads.setGain(GAIN_ONE); - // Begin ADC - ads.begin(_i2cAddress); - - // Read Analog to Digital Converter (ADC) - // Taking this reading includes the 8ms conversion delay. - // Measure the ADC raw count - adcCounts = ads.readADC_SingleEnded(_adsChannel); - // Convert ADC raw counts value to voltage (V) - adcVoltage = ads.computeVolts(adcCounts); - MS_DBG(F(" ads.readADC_SingleEnded("), _adsChannel, F("):"), - adcVoltage); - - if (adcVoltage < 3.6 && adcVoltage > -0.3) { - // Skip results out of range - // Apogee SQ-212 Calibration Factor = 1.0 μmol m-2 s-1 per mV - calibResult = 1000 * adcVoltage * SQ212_CALIBRATION_FACTOR; - MS_DBG(F(" calibResult:"), calibResult); - } else { - // set invalid voltages back to -9999 - adcVoltage = -9999; - } - } else { - MS_DBG(getSensorNameAndLocation(), F("is not currently measuring!")); - } - - verifyAndAddMeasurementResult(SQ212_PAR_VAR_NUM, calibResult); - verifyAndAddMeasurementResult(SQ212_VOLTAGE_VAR_NUM, adcVoltage); - - // Record the time that the measurement was completed - _millisMeasurementCompleted = millis(); - // Unset the time stamp for the beginning of this measurement - _millisMeasurementRequested = 0; - // Unset the status bits for a measurement request (bits 5 & 6) - clearStatusBits(MEASUREMENT_ATTEMPTED, MEASUREMENT_SUCCESSFUL); - // Bump the number of attempted retries - _retryAttemptsMade++; + // ADS Library default settings: + // - TI1115 (16 bit) + // - single-shot mode (powers down between conversions) + // - 128 samples per second (8ms conversion time) + // - 2/3 gain +/- 6.144V range (limited to VDD +0.3V max) + // - TI1015 (12 bit) + // - single-shot mode (powers down between conversions) + // - 1600 samples per second (625µs conversion time) + // - 2/3 gain +/- 6.144V range (limited to VDD +0.3V max) + + // Bump the gain up to 1x = +/- 4.096V range + // Sensor return range is 0-2.5V, but the next gain option is 2x which only + // allows up to 2.048V + ads.setGain(GAIN_ONE); + // Begin ADC + ads.begin(_i2cAddress); + + // Read Analog to Digital Converter (ADC) + // Taking this reading includes the 8ms conversion delay. + // Measure the ADC raw count + adcCounts = ads.readADC_SingleEnded(_adsChannel); + // Convert ADC raw counts value to voltage (V) + adcVoltage = ads.computeVolts(adcCounts); + MS_DBG(F(" ads.readADC_SingleEnded("), _adsChannel, F("):"), adcVoltage); if (adcVoltage < 3.6 && adcVoltage > -0.3) { - // Bump the number of completed measurement attempts - _measurementAttemptsCompleted++; - return true; - } else if (_retryAttemptsMade >= _allowedMeasurementRetries) { - // Bump the number of completed measurement attempts - we've failed but - // exceeded retries - _measurementAttemptsCompleted++; - return false; - } else { - return false; + // Skip results out of range + // Apogee SQ-212 Calibration Factor = 1.0 μmol m-2 s-1 per mV + calibResult = 1000 * adcVoltage * SQ212_CALIBRATION_FACTOR; + MS_DBG(F(" calibResult:"), calibResult); + verifyAndAddMeasurementResult(SQ212_PAR_VAR_NUM, calibResult); + verifyAndAddMeasurementResult(SQ212_VOLTAGE_VAR_NUM, adcVoltage); + success = true; } + + // Return success value when finished + return bumpMeasurementAttemptCount(success); } diff --git a/src/sensors/AtlasParent.cpp b/src/sensors/AtlasParent.cpp index 7f0d2daee..cb9c698cf 100644 --- a/src/sensors/AtlasParent.cpp +++ b/src/sensors/AtlasParent.cpp @@ -136,78 +136,53 @@ bool AtlasParent::startSingleMeasurement(void) { bool AtlasParent::addSingleMeasurementResult(void) { + // Immediately quit if the measurement was not successfully started + if (!getStatusBit(MEASUREMENT_SUCCESSFUL)) { + return bumpMeasurementAttemptCount(false); + } + bool success = false; - // Check a measurement was *successfully* started (status bit 6 set) - // Only go on to get a result if it was - if (getStatusBit(MEASUREMENT_SUCCESSFUL)) { - // call the circuit and request 40 bytes (this may be more than we need) - _i2c->requestFrom(static_cast(_i2cAddressHex), 40, 1); - // the first byte is the response code, we read this separately. - int code = _i2c->read(); - - MS_DBG(getSensorNameAndLocation(), F("is reporting:")); - // Parse the response code - switch (code) { - case 1: // the command was successful. - MS_DBG(F(" Measurement successful")); - success = true; - break; - - case 2: // the command has failed. - MS_DBG(F(" Measurement Failed")); - break; - - case 254: // the command has not yet been finished calculating. - MS_DBG(F(" Measurement Pending")); - break; - - case 255: // there is no further data to send. - MS_DBG(F(" No Data")); - break; - - default: break; - } - // If the response code is successful, parse the remaining results - if (success) { - for (uint8_t i = 0; i < _numReturnedValues; i++) { - float result = _i2c->parseFloat(); - if (isnan(result)) { result = -9999; } - if (result < -1020) { result = -9999; } - MS_DBG(F(" Result #"), i, ':', result); - verifyAndAddMeasurementResult(i, result); - } - } - } else { - // If there's no measurement, need to make sure we send over all - // of the "failed" result values - MS_DBG(getSensorNameAndLocation(), F("is not currently measuring!")); - for (uint8_t i = 0; i < _numReturnedValues; i++) { - verifyAndAddMeasurementResult(i, static_cast(-9999)); - } - } + // call the circuit and request 40 bytes (this may be more than we need) + _i2c->requestFrom(static_cast(_i2cAddressHex), 40, 1); + // the first byte is the response code, we read this separately. + int code = _i2c->read(); - // Record the time that the measurement was completed - _millisMeasurementCompleted = millis(); - // Unset the time stamp for the beginning of this measurement - _millisMeasurementRequested = 0; - // Unset the status bits for a measurement request (bits 5 & 6) - clearStatusBits(MEASUREMENT_ATTEMPTED, MEASUREMENT_SUCCESSFUL); - // Bump the number of attempted retries - _retryAttemptsMade++; + MS_DBG(getSensorNameAndLocation(), F("is reporting:")); + // Parse the response code + switch (code) { + case 1: // the command was successful. + MS_DBG(F(" Measurement successful")); + success = true; + break; + case 2: // the command has failed. + MS_DBG(F(" Measurement Failed")); + break; + + case 254: // the command has not yet been finished calculating. + MS_DBG(F(" Measurement Pending")); + break; + + case 255: // there is no further data to send. + MS_DBG(F(" No Data")); + break; + + default: break; + } + // If the response code is successful, parse the remaining results if (success) { - // Bump the number of completed measurement attempts - // NOTE: This is bumped if we got a successful response code, - // even if the results were NaN or otherwise invalid! - _measurementAttemptsCompleted++; - } else if (_retryAttemptsMade >= _allowedMeasurementRetries) { - // Bump the number of completed measurement attempts - we've failed but - // exceeded retries - _measurementAttemptsCompleted++; + for (uint8_t i = 0; i < _numReturnedValues; i++) { + float result = _i2c->parseFloat(); + if (isnan(result)) { result = -9999; } + if (result < -1020) { result = -9999; } + MS_DBG(F(" Result #"), i, ':', result); + verifyAndAddMeasurementResult(i, result); + } } - return success; + // Return success value when finished + return bumpMeasurementAttemptCount(success); } diff --git a/src/sensors/BoschBME280.cpp b/src/sensors/BoschBME280.cpp index 92ae24cc1..87daa9d21 100644 --- a/src/sensors/BoschBME280.cpp +++ b/src/sensors/BoschBME280.cpp @@ -115,75 +115,48 @@ bool BoschBME280::wake(void) { bool BoschBME280::addSingleMeasurementResult(void) { - bool success = false; - - // Initialize float variables - float temp = -9999; - float humid = -9999; - float press = -9999; - float alt = -9999; - - // Check a measurement was *successfully* started (status bit 6 set) - // Only go on to get a result if it was - if (getStatusBit(MEASUREMENT_SUCCESSFUL)) { - MS_DBG(getSensorNameAndLocation(), F("is reporting:")); - - // Read values - temp = bme_internal.readTemperature(); - if (isnan(temp)) temp = -9999; - humid = bme_internal.readHumidity(); - if (isnan(humid)) humid = -9999; - press = bme_internal.readPressure(); - if (isnan(press)) press = -9999; - alt = bme_internal.readAltitude(SEALEVELPRESSURE_HPA); - if (isnan(alt)) alt = -9999; - - // Assume that if all three are 0, really a failed response - // May also return a very negative temp when receiving a bad response - if ((temp == 0 && press == 0 && humid == 0) || temp < -40) { - MS_DBG(F("All values 0 or bad, assuming sensor non-response!")); - temp = -9999; - press = -9999; - humid = -9999; - alt = -9999; - } else { - success = true; - } - - MS_DBG(F(" Temperature:"), temp, F("°C")); - MS_DBG(F(" Humidity:"), humid, F("%RH")); - MS_DBG(F(" Barometric Pressure:"), press, F("Pa")); - MS_DBG(F(" Calculated Altitude:"), alt, F("m ASL")); - } else { - MS_DBG(getSensorNameAndLocation(), F("is not currently measuring!")); + // Immediately quit if the measurement was not successfully started + if (!getStatusBit(MEASUREMENT_SUCCESSFUL)) { + return bumpMeasurementAttemptCount(false); } - verifyAndAddMeasurementResult(BME280_TEMP_VAR_NUM, temp); - verifyAndAddMeasurementResult(BME280_HUMIDITY_VAR_NUM, humid); - verifyAndAddMeasurementResult(BME280_PRESSURE_VAR_NUM, press); - verifyAndAddMeasurementResult(BME280_ALTITUDE_VAR_NUM, alt); - - // Record the time that the measurement was completed - _millisMeasurementCompleted = millis(); - // Unset the time stamp for the beginning of this measurement - _millisMeasurementRequested = 0; - // Unset the status bits for a measurement request (bits 5 & 6) - clearStatusBits(MEASUREMENT_ATTEMPTED, MEASUREMENT_SUCCESSFUL); - // Bump the number of attempted retries - _retryAttemptsMade++; - - if (success) { - // Bump the number of successful measurements - // NOTE: Any one of the values being NOT -9999 is not considered a - // success! - _measurementAttemptsCompleted++; - } else if (_retryAttemptsMade >= _allowedMeasurementRetries) { - // Bump the number of completed measurement attempts - we've failed but - // exceeded retries - _measurementAttemptsCompleted++; + bool success = false; + float temp = -9999; + float humid = -9999; + float press = -9999; + float alt = -9999; + + MS_DBG(getSensorNameAndLocation(), F("is reporting:")); + + // Read values + temp = bme_internal.readTemperature(); + if (isnan(temp)) temp = -9999; + humid = bme_internal.readHumidity(); + if (isnan(humid)) humid = -9999; + press = bme_internal.readPressure(); + if (isnan(press)) press = -9999; + alt = bme_internal.readAltitude(SEALEVELPRESSURE_HPA); + if (isnan(alt)) alt = -9999; + + MS_DBG(F(" Temperature:"), temp, F("°C")); + MS_DBG(F(" Humidity:"), humid, F("%RH")); + MS_DBG(F(" Barometric Pressure:"), press, F("Pa")); + MS_DBG(F(" Calculated Altitude:"), alt, F("m ASL")); + + // Assume that if all three are 0, really a failed response + // May also return a very negative temp when receiving a bad response + if ((temp == 0 && press == 0 && humid == 0) || temp < -40) { + MS_DBG(F("All values 0 or bad, assuming sensor non-response!")); + } else { + verifyAndAddMeasurementResult(BME280_TEMP_VAR_NUM, temp); + verifyAndAddMeasurementResult(BME280_HUMIDITY_VAR_NUM, humid); + verifyAndAddMeasurementResult(BME280_PRESSURE_VAR_NUM, press); + verifyAndAddMeasurementResult(BME280_ALTITUDE_VAR_NUM, alt); + success = true; } - return success; + // Return success value when finished + return bumpMeasurementAttemptCount(success); } // cSpell:ignore SEALEVELPRESSURE_HPA diff --git a/src/sensors/BoschBMP3xx.cpp b/src/sensors/BoschBMP3xx.cpp index fafe95388..3837b0ae0 100644 --- a/src/sensors/BoschBMP3xx.cpp +++ b/src/sensors/BoschBMP3xx.cpp @@ -278,61 +278,32 @@ bool BoschBMP3xx::startSingleMeasurement(void) { bool BoschBMP3xx::addSingleMeasurementResult(void) { - bool success = false; - - // Initialize float variables - float temp = -9999; - float press = -9999; - float alt = -9999; - - // Check a measurement was *successfully* started (status bit 6 set) - // Only go on to get a result if it was - if (getStatusBit(MEASUREMENT_SUCCESSFUL)) { - MS_DBG(getSensorNameAndLocation(), F("is reporting:")); - - // Read values - success = bmp_internal.getMeasurements(temp, press, alt); - - // Assume that if all three are 0, really a failed response - // May also return a very negative temp when receiving a bad response - if (!success) { - temp = -9999; - press = -9999; - alt = -9999; - } - - MS_DBG(F(" Temperature:"), temp, F("°C")); - MS_DBG(F(" Barometric Pressure:"), press, F("Pa")); - MS_DBG(F(" Calculated Altitude:"), alt, F("m ASL")); - } else { - MS_DBG(getSensorNameAndLocation(), F("is not currently measuring!")); + // Immediately quit if the measurement was not successfully started + if (!getStatusBit(MEASUREMENT_SUCCESSFUL)) { + return bumpMeasurementAttemptCount(false); } - verifyAndAddMeasurementResult(BMP3XX_TEMP_VAR_NUM, temp); - verifyAndAddMeasurementResult(BMP3XX_PRESSURE_VAR_NUM, press); - verifyAndAddMeasurementResult(BMP3XX_ALTITUDE_VAR_NUM, alt); + bool success = false; + float temp = -9999; + float press = -9999; + float alt = -9999; + + MS_DBG(getSensorNameAndLocation(), F("is reporting:")); - // Record the time that the measurement was completed - _millisMeasurementCompleted = millis(); - // Unset the time stamp for the beginning of this measurement - _millisMeasurementRequested = 0; - // Unset the status bits for a measurement request (bits 5 & 6) - clearStatusBits(MEASUREMENT_ATTEMPTED, MEASUREMENT_SUCCESSFUL); - // Bump the number of attempted retries - _retryAttemptsMade++; + // Read values + success = bmp_internal.getMeasurements(temp, press, alt); + MS_DBG(F(" Temperature:"), temp, F("°C")); + MS_DBG(F(" Barometric Pressure:"), press, F("Pa")); + MS_DBG(F(" Calculated Altitude:"), alt, F("m ASL")); if (success) { - // Bump the number of successful measurements - // NOTE: This is bumped if we successfully got a response, even if the - // results were NaN or otherwise invalid! - _measurementAttemptsCompleted++; - } else if (_retryAttemptsMade >= _allowedMeasurementRetries) { - // Bump the number of completed measurement attempts - we've failed but - // exceeded retries - _measurementAttemptsCompleted++; + verifyAndAddMeasurementResult(BMP3XX_TEMP_VAR_NUM, temp); + verifyAndAddMeasurementResult(BMP3XX_PRESSURE_VAR_NUM, press); + verifyAndAddMeasurementResult(BMP3XX_ALTITUDE_VAR_NUM, alt); } - return success; + // Return success value when finished + return bumpMeasurementAttemptCount(success); } // cSpell:ignore oversample SEALEVELPRESSURE diff --git a/src/sensors/CampbellOBS3.cpp b/src/sensors/CampbellOBS3.cpp index f132963b2..ceabaec4e 100644 --- a/src/sensors/CampbellOBS3.cpp +++ b/src/sensors/CampbellOBS3.cpp @@ -43,89 +43,66 @@ String CampbellOBS3::getSensorLocation(void) { bool CampbellOBS3::addSingleMeasurementResult(void) { - // Variables to store the results in + // Immediately quit if the measurement was not successfully started + if (!getStatusBit(MEASUREMENT_SUCCESSFUL)) { + return bumpMeasurementAttemptCount(false); + } + + bool success = false; int16_t adcCounts = -9999; float adcVoltage = -9999; float calibResult = -9999; - // Check a measurement was *successfully* started (status bit 6 set) - // Only go on to get a result if it was - if (getStatusBit(MEASUREMENT_SUCCESSFUL)) { - MS_DBG(getSensorNameAndLocation(), F("is reporting:")); + MS_DBG(getSensorNameAndLocation(), F("is reporting:")); // Create an auxiliary ADD object // We create and set up the ADC object here so that each sensor using // the ADC may set the gain appropriately without effecting others. #ifndef MS_USE_ADS1015 - Adafruit_ADS1115 ads; // Use this for the 16-bit version + Adafruit_ADS1115 ads; // Use this for the 16-bit version #else - Adafruit_ADS1015 ads; // Use this for the 12-bit version + Adafruit_ADS1015 ads; // Use this for the 12-bit version #endif - // ADS Library default settings: - // - TI1115 (16 bit) - // - single-shot mode (powers down between conversions) - // - 128 samples per second (8ms conversion time) - // - 2/3 gain +/- 6.144V range (limited to VDD +0.3V max) - // - TI1015 (12 bit) - // - single-shot mode (powers down between conversions) - // - 1600 samples per second (625µs conversion time) - // - 2/3 gain +/- 6.144V range (limited to VDD +0.3V max) - - // Bump the gain up to 1x = +/- 4.096V range - // Sensor return range is 0-2.5V, but the next gain option is 2x which - // only allows up to 2.048V - ads.setGain(GAIN_ONE); - // Begin ADC - ads.begin(_i2cAddress); - - // Print out the calibration curve - MS_DBG(F(" Input calibration Curve:"), _x2_coeff_A, F("x^2 +"), - _x1_coeff_B, F("x +"), _x0_coeff_C); - - // Read Analog to Digital Converter (ADC) - // Taking this reading includes the 8ms conversion delay. - // Measure the ADC raw count - adcCounts = ads.readADC_SingleEnded(_adsChannel); - // Convert ADC raw counts value to voltage (V) - adcVoltage = ads.computeVolts(adcCounts); - MS_DBG(F(" ads.readADC_SingleEnded("), _adsChannel, F("):"), - adcVoltage); - - if (adcVoltage < 3.6 && adcVoltage > -0.3) { - // Skip results out of range - // Apply the unique calibration curve for the given sensor - calibResult = (_x2_coeff_A * sq(adcVoltage)) + - (_x1_coeff_B * adcVoltage) + _x0_coeff_C; - MS_DBG(F(" calibResult:"), calibResult); - } else { // set invalid voltages back to -9999 - adcVoltage = -9999; - } - } else { - MS_DBG(getSensorNameAndLocation(), F("is not currently measuring!")); - } - - verifyAndAddMeasurementResult(OBS3_TURB_VAR_NUM, calibResult); - verifyAndAddMeasurementResult(OBS3_VOLTAGE_VAR_NUM, adcVoltage); - - // Record the time that the measurement was completed - _millisMeasurementCompleted = millis(); - // Unset the time stamp for the beginning of this measurement - _millisMeasurementRequested = 0; - // Unset the status bits for a measurement request (bits 5 & 6) - clearStatusBits(MEASUREMENT_ATTEMPTED, MEASUREMENT_SUCCESSFUL); - // Bump the number of attempted retries - _retryAttemptsMade++; + // ADS Library default settings: + // - TI1115 (16 bit) + // - single-shot mode (powers down between conversions) + // - 128 samples per second (8ms conversion time) + // - 2/3 gain +/- 6.144V range (limited to VDD +0.3V max) + // - TI1015 (12 bit) + // - single-shot mode (powers down between conversions) + // - 1600 samples per second (625µs conversion time) + // - 2/3 gain +/- 6.144V range (limited to VDD +0.3V max) + + // Bump the gain up to 1x = +/- 4.096V range + // Sensor return range is 0-2.5V, but the next gain option is 2x which + // only allows up to 2.048V + ads.setGain(GAIN_ONE); + // Begin ADC + ads.begin(_i2cAddress); + + // Print out the calibration curve + MS_DBG(F(" Input calibration Curve:"), _x2_coeff_A, F("x^2 +"), + _x1_coeff_B, F("x +"), _x0_coeff_C); + + // Read Analog to Digital Converter (ADC) + // Taking this reading includes the 8ms conversion delay. + // Measure the ADC raw count + adcCounts = ads.readADC_SingleEnded(_adsChannel); + // Convert ADC raw counts value to voltage (V) + adcVoltage = ads.computeVolts(adcCounts); + MS_DBG(F(" ads.readADC_SingleEnded("), _adsChannel, F("):"), adcVoltage); if (adcVoltage < 3.6 && adcVoltage > -0.3) { - // Bump the number of completed measurement attempts - _measurementAttemptsCompleted++; - return true; - } else if (_retryAttemptsMade >= _allowedMeasurementRetries) { - // Bump the number of completed measurement attempts - we've failed but - // exceeded retries - _measurementAttemptsCompleted++; - return false; - } else { - return false; + // Skip results out of range + // Apply the unique calibration curve for the given sensor + calibResult = (_x2_coeff_A * sq(adcVoltage)) + + (_x1_coeff_B * adcVoltage) + _x0_coeff_C; + MS_DBG(F(" calibResult:"), calibResult); + verifyAndAddMeasurementResult(OBS3_TURB_VAR_NUM, calibResult); + verifyAndAddMeasurementResult(OBS3_VOLTAGE_VAR_NUM, adcVoltage); + success = true; } + + // Return success value when finished + return bumpMeasurementAttemptCount(success); } diff --git a/src/sensors/EverlightALSPT19.cpp b/src/sensors/EverlightALSPT19.cpp index b271d8ec7..9b6f82e53 100644 --- a/src/sensors/EverlightALSPT19.cpp +++ b/src/sensors/EverlightALSPT19.cpp @@ -34,62 +34,48 @@ EverlightALSPT19::~EverlightALSPT19() {} bool EverlightALSPT19::addSingleMeasurementResult(void) { - // Initialize float variables + // Immediately quit if the measurement was not successfully started + if (!getStatusBit(MEASUREMENT_SUCCESSFUL)) { + return bumpMeasurementAttemptCount(false); + } + float volt_val = -9999; float current_val = -9999; float lux_val = -9999; - // Check a measurement was *successfully* started (status bit 6 set) - // Only go on to get a result if it was - if (getStatusBit(MEASUREMENT_SUCCESSFUL)) { - MS_DBG(getSensorNameAndLocation(), F("is reporting:")); - - // First measure the analog voltage. - // The return value from analogRead() is IN BITS NOT IN VOLTS!! - // Take a priming reading. - // First reading will be low - discard - analogRead(_dataPin); - // Take the reading we'll keep - uint32_t sensor_adc = analogRead(_dataPin); - MS_DEEP_DBG(" ADC Bits:", sensor_adc); - - if (0 == sensor_adc) { - // Prevent underflow, can never be outside of PROCESSOR_ADC_RANGE - sensor_adc = 1; - } - // convert bits to volts - volt_val = (_supplyVoltage / static_cast(PROCESSOR_ADC_MAX)) * - static_cast(sensor_adc); - // convert volts to current - // resistance is entered in kΩ and we want µA - current_val = (volt_val / (_loadResistor * 1000)) * 1e6; - // convert current to illuminance - // from sensor datasheet, typical 200µA current for 1000 Lux - lux_val = current_val * (1000. / 200.); + MS_DBG(getSensorNameAndLocation(), F("is reporting:")); + // First measure the analog voltage. + // The return value from analogRead() is IN BITS NOT IN VOLTS!! + // Take a priming reading. + // First reading will be low - discard + analogRead(_dataPin); + // Take the reading we'll keep + uint32_t sensor_adc = analogRead(_dataPin); + MS_DEEP_DBG(" ADC Bits:", sensor_adc); - MS_DBG(F(" Voltage:"), volt_val, F("V")); - MS_DBG(F(" Current:"), current_val, F("µA")); - MS_DBG(F(" Illuminance:"), lux_val, F("lux")); - } else { - MS_DBG(getSensorNameAndLocation(), F("is not currently measuring!")); + if (0 == sensor_adc) { + // Prevent underflow, can never be outside of PROCESSOR_ADC_RANGE + sensor_adc = 1; } + // convert bits to volts + volt_val = (_supplyVoltage / static_cast(PROCESSOR_ADC_MAX)) * + static_cast(sensor_adc); + // convert volts to current + // resistance is entered in kΩ and we want µA + current_val = (volt_val / (_loadResistor * 1000)) * 1e6; + // convert current to illuminance + // from sensor datasheet, typical 200µA current for 1000 Lux + lux_val = current_val * (1000. / 200.); + MS_DBG(F(" Voltage:"), volt_val, F("V")); + MS_DBG(F(" Current:"), current_val, F("µA")); + MS_DBG(F(" Illuminance:"), lux_val, F("lux")); + + // NOTE: We don't actually have any criteria for if the reading was any + // good or not, so we mark it as successful no matter what. verifyAndAddMeasurementResult(ALSPT19_VOLTAGE_VAR_NUM, volt_val); verifyAndAddMeasurementResult(ALSPT19_CURRENT_VAR_NUM, current_val); verifyAndAddMeasurementResult(ALSPT19_ILLUMINANCE_VAR_NUM, lux_val); - - // Record the time that the measurement was completed - _millisMeasurementCompleted = millis(); - // Unset the time stamp for the beginning of this measurement - _millisMeasurementRequested = 0; - // Unset the status bits for a measurement request (bits 5 & 6) - clearStatusBits(MEASUREMENT_ATTEMPTED, MEASUREMENT_SUCCESSFUL); - // Bump the number of attempted retries - _retryAttemptsMade++; - // NOTE: We don't actually have any criteria for if the reading was any good - // or not, so we mark it as completed no matter what. - _measurementAttemptsCompleted++; - - return true; + return bumpMeasurementAttemptCount(true); } diff --git a/src/sensors/FreescaleMPL115A2.cpp b/src/sensors/FreescaleMPL115A2.cpp index a46642bec..ca968796f 100644 --- a/src/sensors/FreescaleMPL115A2.cpp +++ b/src/sensors/FreescaleMPL115A2.cpp @@ -60,53 +60,29 @@ bool FreescaleMPL115A2::setup(void) { bool FreescaleMPL115A2::addSingleMeasurementResult(void) { - // Initialize float variables - float temp = -9999; - float press = -9999; - - // Check a measurement was *successfully* started (status bit 6 set) - // Only go on to get a result if it was - if (getStatusBit(MEASUREMENT_SUCCESSFUL)) { - MS_DBG(getSensorNameAndLocation(), F("is reporting:")); - - // Read values - mpl115a2_internal.getPT(&press, &temp); - - if (isnan(temp)) temp = -9999; - if (isnan(press)) press = -9999; - - if (press > 115.0 || temp < -40.0) { - temp = -9999; - press = -9999; - } - - MS_DBG(F(" Temperature:"), temp); - MS_DBG(F(" Pressure:"), press); - } else { - MS_DBG(getSensorNameAndLocation(), F("is not currently measuring!")); + // Immediately quit if the measurement was not successfully started + if (!getStatusBit(MEASUREMENT_SUCCESSFUL)) { + return bumpMeasurementAttemptCount(false); } - verifyAndAddMeasurementResult(MPL115A2_TEMP_VAR_NUM, temp); - verifyAndAddMeasurementResult(MPL115A2_PRESSURE_VAR_NUM, press); - - // Record the time that the measurement was completed - _millisMeasurementCompleted = millis(); - // Unset the time stamp for the beginning of this measurement - _millisMeasurementRequested = 0; - // Unset the status bits for a measurement request (bits 5 & 6) - clearStatusBits(MEASUREMENT_ATTEMPTED, MEASUREMENT_SUCCESSFUL); - // Bump the number of attempted retries - _retryAttemptsMade++; - - if (temp != -9999 && press != -9999) { - // Bump the number of completed measurement attempts - _measurementAttemptsCompleted++; - } else if (_retryAttemptsMade >= _allowedMeasurementRetries) { - // Bump the number of completed measurement attempts - we've failed but - // exceeded retries - _measurementAttemptsCompleted++; + bool success = false; + float temp = -9999; + float press = -9999; + + MS_DBG(getSensorNameAndLocation(), F("is reporting:")); + + // Read values + mpl115a2_internal.getPT(&press, &temp); + + MS_DBG(F(" Temperature:"), temp); + MS_DBG(F(" Pressure:"), press); + + if (!isnan(temp) && !isnan(press) && press <= 115.0 && temp >= -40.0) { + verifyAndAddMeasurementResult(MPL115A2_TEMP_VAR_NUM, temp); + verifyAndAddMeasurementResult(MPL115A2_PRESSURE_VAR_NUM, press); + success = true; } - // no way of knowing if the communication was successful, just return true - return true; + // Return success value when finished + return bumpMeasurementAttemptCount(success); } diff --git a/src/sensors/GeoluxHydroCam.cpp b/src/sensors/GeoluxHydroCam.cpp index 5af8e3f09..7273e6a93 100644 --- a/src/sensors/GeoluxHydroCam.cpp +++ b/src/sensors/GeoluxHydroCam.cpp @@ -187,98 +187,75 @@ bool GeoluxHydroCam::startSingleMeasurement(void) { bool GeoluxHydroCam::addSingleMeasurementResult(void) { - // Initialize values + // Immediately quit if the measurement was not successfully started + if (!getStatusBit(MEASUREMENT_SUCCESSFUL)) { + return bumpMeasurementAttemptCount(false); + } + bool success = false; int32_t bytes_transferred = -9999; int32_t byte_error = -9999; - // Check a measurement was *successfully* started (status bit 6 set) - // Only go on to get a result if it was - if (getStatusBit(MEASUREMENT_SUCCESSFUL)) { - // set a new filename based on the current RTC time - String filename = _baseLogger->generateFileName( - true, HYDROCAM_FILE_EXTENSION, _filePrefix); - MS_DBG(F("Attempting to create the file: "), filename); - - // Initialise the SD card - // skip everything else if there's no SD card, otherwise it might hang - if (!_baseLogger->initializeSDCard()) return false; - - // Create and then open the file in write mode - if (imgFile.open(filename.c_str(), O_CREAT | O_WRITE | O_AT_END)) { - MS_DBG(F("Created new file:"), filename); - success = true; - } else { - MS_DBG(F("Failed to create the image file"), filename); - success = false; - } + // set a new filename based on the current RTC time + String filename = _baseLogger->generateFileName( + true, HYDROCAM_FILE_EXTENSION, _filePrefix); + MS_DBG(F("Attempting to create the file: "), filename); - int32_t image_size = _camera.getImageSize(); - MS_DBG(F("Completed image is"), image_size, F("bytes.")); - success &= image_size != 0; - - if (success) { - // dump anything in the camera stream, just in case - _camera.streamDump(); - - // Disable the watch-dog timer to reduce interrupts during transfer - MS_DBG(F("Disabling the watchdog during file transfer")); - extendedWatchDog::disableWatchDog(); - - // transfer the image from the camera to a file on the SD card - MS_START_DEBUG_TIMER; - bytes_transferred = _camera.transferImage(imgFile, image_size); - byte_error = abs(bytes_transferred - image_size); - // Close the image file - imgFile.close(); - - // See how long it took us - MS_DBG(F("Wrote"), bytes_transferred, F("of expected"), image_size, - F("bytes to the SD card - a difference of"), byte_error, - F("bytes")); - MS_DBG(F("Total read/write time was"), MS_PRINT_DEBUG_TIMER, - F("ms")); - - // Re-enable the watchdog - MS_DBG(F("Re-enabling the watchdog after file transfer")); - extendedWatchDog::enableWatchDog(); - - // Store the last image name - _filename = filename; - - success = bytes_transferred == image_size; - MS_DBG(F("Image transfer was a"), - success ? F("success") : F("failure")); - } + // Initialise the SD card + // skip everything else if there's no SD card, otherwise it might hang + if (!_baseLogger->initializeSDCard()) return false; + + // Create and then open the file in write mode + if (imgFile.open(filename.c_str(), O_CREAT | O_WRITE | O_AT_END)) { + MS_DBG(F("Created new file:"), filename); + success = true; } else { - MS_DBG(getSensorNameAndLocation(), F("is not currently measuring!")); + MS_DBG(F("Failed to create the image file"), filename); + success = false; } - verifyAndAddMeasurementResult(HYDROCAM_SIZE_VAR_NUM, bytes_transferred); - verifyAndAddMeasurementResult(HYDROCAM_ERROR_VAR_NUM, byte_error); - - // Record the time that the measurement was completed - _millisMeasurementCompleted = millis(); - // Unset the time stamp for the beginning of this measurement - _millisMeasurementRequested = 0; - // Unset the status bits for a measurement request (bits 5 & 6) - clearStatusBits(MEASUREMENT_ATTEMPTED, MEASUREMENT_SUCCESSFUL); - // Bump the number of attempted retries - _retryAttemptsMade++; + int32_t image_size = _camera.getImageSize(); + MS_DBG(F("Completed image is"), image_size, F("bytes.")); + success &= image_size != 0; if (success) { - // Bump the number of successful measurements - // NOTE: We consider the measurement a success only if we got all the - // bytes we expected! - _measurementAttemptsCompleted++; - } else if (_retryAttemptsMade >= _allowedMeasurementRetries) { - // Bump the number of completed measurement attempts - we've failed but - // exceeded retries - _measurementAttemptsCompleted++; + // dump anything in the camera stream, just in case + _camera.streamDump(); + + // Disable the watch-dog timer to reduce interrupts during transfer + MS_DBG(F("Disabling the watchdog during file transfer")); + extendedWatchDog::disableWatchDog(); + + // transfer the image from the camera to a file on the SD card + MS_START_DEBUG_TIMER; + bytes_transferred = _camera.transferImage(imgFile, image_size); + byte_error = abs(bytes_transferred - image_size); + // Close the image file + imgFile.close(); + + // See how long it took us + MS_DBG(F("Wrote"), bytes_transferred, F("of expected"), image_size, + F("bytes to the SD card - a difference of"), byte_error, + F("bytes")); + MS_DBG(F("Total read/write time was"), MS_PRINT_DEBUG_TIMER, F("ms")); + + // Re-enable the watchdog + MS_DBG(F("Re-enabling the watchdog after file transfer")); + extendedWatchDog::enableWatchDog(); + + // Store the last image name + _filename = filename; + + success = bytes_transferred == image_size; + MS_DBG(F("Image transfer was a"), + success ? F("success") : F("failure")); + + verifyAndAddMeasurementResult(HYDROCAM_SIZE_VAR_NUM, bytes_transferred); + verifyAndAddMeasurementResult(HYDROCAM_ERROR_VAR_NUM, byte_error); } - // Return values shows if we got a not-obviously-bad reading - return success; + // Return success value when finished + return bumpMeasurementAttemptCount(success); } // check if the camera is ready diff --git a/src/sensors/GroPointParent.cpp b/src/sensors/GroPointParent.cpp index 6877bc751..6723b955c 100644 --- a/src/sensors/GroPointParent.cpp +++ b/src/sensors/GroPointParent.cpp @@ -163,6 +163,11 @@ bool GroPointParent::sleep(void) { bool GroPointParent::addSingleMeasurementResult(void) { + // Immediately quit if the measurement was not successfully started + if (!getStatusBit(MEASUREMENT_SUCCESSFUL)) { + return bumpMeasurementAttemptCount(false); + } + bool success = false; bool successT = false; // Initialize moisture variables for each probe segment @@ -170,112 +175,63 @@ bool GroPointParent::addSingleMeasurementResult(void) { // Initialize temperature variables for each probe sensor float T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13 = -9999; - // Check a measurement was *successfully* started (status bit 6 set) - // Only go on to get a result if it was - if (getStatusBit(MEASUREMENT_SUCCESSFUL)) { - switch (_model) { - case GPLP8: { - // Get Moisture Values - MS_DBG(F("Get Values from"), getSensorNameAndLocation()); - success = _gsensor.getValues(M1, M2, M3, M4, M5, M6, M7, M8); - - // Fix not-a-number values - if (!success || isnan(M1)) M1 = -9999; - if (!success || isnan(M2)) M2 = -9999; - if (!success || isnan(M3)) M3 = -9999; - if (!success || isnan(M4)) M4 = -9999; - if (!success || isnan(M5)) M5 = -9999; - if (!success || isnan(M6)) M6 = -9999; - if (!success || isnan(M7)) M7 = -9999; - if (!success || isnan(M8)) M8 = -9999; - - MS_DBG(F(" "), _gsensor.getParameter()); - MS_DBG(F(" "), _gsensor.getUnits()); - MS_DBG(F(" "), M1, ',', M2, ',', M3, ',', M4, ',', M5, ',', - M6, ',', M7, ',', M8); - - // Get Temperature Values - successT = _gsensor.getTemperatureValues( - T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13); - - // Fix not-a-number values - if (!successT || isnan(T1)) T1 = -9999; - if (!successT || isnan(T2)) T2 = -9999; - if (!successT || isnan(T3)) T3 = -9999; - if (!successT || isnan(T4)) T4 = -9999; - if (!successT || isnan(T5)) T5 = -9999; - if (!successT || isnan(T6)) T6 = -9999; - if (!successT || isnan(T7)) T7 = -9999; - if (!successT || isnan(T8)) T8 = -9999; - if (!successT || isnan(T9)) T9 = -9999; - if (!successT || isnan(T10)) T10 = -9999; - if (!successT || isnan(T11)) T11 = -9999; - if (!successT || isnan(T12)) T12 = -9999; - if (!successT || isnan(T13)) T13 = -9999; - - MS_DBG(F(" "), _gsensor.getParameter1()); - MS_DBG(F(" "), _gsensor.getUnits1()); - MS_DBG(F(" "), T1, ',', T2, ',', T3, ',', T4, ',', T5, ',', - T6, ',', T7, ',', T8, ',', T9, ',', T10, ',', T11, ',', - T12, ',', T13); - - - // Put values into the array - verifyAndAddMeasurementResult(0, M1); - verifyAndAddMeasurementResult(1, M2); - verifyAndAddMeasurementResult(2, M3); - verifyAndAddMeasurementResult(3, M4); - verifyAndAddMeasurementResult(4, M5); - verifyAndAddMeasurementResult(5, M6); - verifyAndAddMeasurementResult(6, M7); - verifyAndAddMeasurementResult(7, M8); - - verifyAndAddMeasurementResult(8, T1); - verifyAndAddMeasurementResult(9, T2); - verifyAndAddMeasurementResult(10, T3); - verifyAndAddMeasurementResult(11, T4); - verifyAndAddMeasurementResult(12, T5); - verifyAndAddMeasurementResult(13, T6); - verifyAndAddMeasurementResult(14, T7); - verifyAndAddMeasurementResult(15, T8); - verifyAndAddMeasurementResult(16, T9); - verifyAndAddMeasurementResult(17, T10); - verifyAndAddMeasurementResult(18, T11); - verifyAndAddMeasurementResult(19, T12); - verifyAndAddMeasurementResult(20, T13); - - - break; - } - default: { - // Get Values - MS_DBG(F("Other GroPoint models not yet implemented.")); - } + switch (_model) { + case GPLP8: { + // Get Moisture Values + MS_DBG(F("Get Values from"), getSensorNameAndLocation()); + success = _gsensor.getValues(M1, M2, M3, M4, M5, M6, M7, M8); + + MS_DBG(F(" "), _gsensor.getParameter()); + MS_DBG(F(" "), _gsensor.getUnits()); + MS_DBG(F(" "), M1, ',', M2, ',', M3, ',', M4, ',', M5, ',', M6, + ',', M7, ',', M8); + + // Get Temperature Values + successT = _gsensor.getTemperatureValues( + T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13); + + MS_DBG(F(" "), _gsensor.getParameter1()); + MS_DBG(F(" "), _gsensor.getUnits1()); + MS_DBG(F(" "), T1, ',', T2, ',', T3, ',', T4, ',', T5, ',', T6, + ',', T7, ',', T8, ',', T9, ',', T10, ',', T11, ',', T12, ',', + T13); + + break; + } + default: { + // Get Values + MS_DBG(F("Other GroPoint models not yet implemented.")); } - } else { - MS_DBG(getSensorNameAndLocation(), F("is not currently measuring!")); } - // Record the time that the measurement was completed - _millisMeasurementCompleted = millis(); - // Unset the time stamp for the beginning of this measurement - _millisMeasurementRequested = 0; - // Unset the status bits for a measurement request (bits 5 & 6) - clearStatusBits(MEASUREMENT_ATTEMPTED, MEASUREMENT_SUCCESSFUL); - // Bump the number of attempted retries - _retryAttemptsMade++; - if (success && successT) { - // Bump the number of completed measurement attempts - _measurementAttemptsCompleted++; - } else if (_retryAttemptsMade >= _allowedMeasurementRetries) { - // Bump the number of completed measurement attempts - we've failed but - // exceeded retries - _measurementAttemptsCompleted++; + // Put values into the array + verifyAndAddMeasurementResult(0, M1); + verifyAndAddMeasurementResult(1, M2); + verifyAndAddMeasurementResult(2, M3); + verifyAndAddMeasurementResult(3, M4); + verifyAndAddMeasurementResult(4, M5); + verifyAndAddMeasurementResult(5, M6); + verifyAndAddMeasurementResult(6, M7); + verifyAndAddMeasurementResult(7, M8); + + verifyAndAddMeasurementResult(8, T1); + verifyAndAddMeasurementResult(9, T2); + verifyAndAddMeasurementResult(10, T3); + verifyAndAddMeasurementResult(11, T4); + verifyAndAddMeasurementResult(12, T5); + verifyAndAddMeasurementResult(13, T6); + verifyAndAddMeasurementResult(14, T7); + verifyAndAddMeasurementResult(15, T8); + verifyAndAddMeasurementResult(16, T9); + verifyAndAddMeasurementResult(17, T10); + verifyAndAddMeasurementResult(18, T11); + verifyAndAddMeasurementResult(19, T12); + verifyAndAddMeasurementResult(20, T13); } // Return success value when finished - return success && successT; + return bumpMeasurementAttemptCount((success && successT)); } // cSpell:ignore gsensor diff --git a/src/sensors/KellerParent.cpp b/src/sensors/KellerParent.cpp index 4dd188dc3..8e283ea5b 100644 --- a/src/sensors/KellerParent.cpp +++ b/src/sensors/KellerParent.cpp @@ -87,71 +87,47 @@ bool KellerParent::sleep(void) { bool KellerParent::addSingleMeasurementResult(void) { - bool success = false; + // Immediately quit if the measurement was not successfully started + if (!getStatusBit(MEASUREMENT_SUCCESSFUL)) { + return bumpMeasurementAttemptCount(false); + } - // Initialize float variables + bool success = false; float waterPressureBar = -9999; float waterTemperatureC = -9999; float waterDepthM = -9999; float waterPressure_mBar = -9999; - // Check a measurement was *successfully* started (status bit 6 set) - // Only go on to get a result if it was - if (getStatusBit(MEASUREMENT_SUCCESSFUL)) { - MS_DBG(getSensorNameAndLocation(), F("is reporting:")); - - // Get Values - success = _ksensor.getValues(waterPressureBar, waterTemperatureC); - waterDepthM = _ksensor.calcWaterDepthM( - waterPressureBar, - waterTemperatureC); // float calcWaterDepthM(float - // waterPressureBar, float waterTemperatureC) - - // Fix not-a-number values - if (!success || isnan(waterPressureBar)) waterPressureBar = -9999; - if (!success || isnan(waterTemperatureC)) waterTemperatureC = -9999; - if (!success || isnan(waterDepthM)) waterDepthM = -9999; - - // For waterPressureBar, convert bar to millibar - if (waterPressureBar != -9999) - waterPressure_mBar = 1000 * waterPressureBar; - - MS_DBG(F(" Pressure_mbar:"), waterPressure_mBar); - MS_DBG(F(" Temp_C:"), waterTemperatureC); - MS_DBG(F(" Height_m:"), waterDepthM); - } else { - MS_DBG(getSensorNameAndLocation(), F("is not currently measuring!")); - } + MS_DBG(getSensorNameAndLocation(), F("is reporting:")); + + // Get Values + success = _ksensor.getValues(waterPressureBar, waterTemperatureC); + waterDepthM = _ksensor.calcWaterDepthM( + waterPressureBar, + waterTemperatureC); // float calcWaterDepthM(float + // waterPressureBar, float waterTemperatureC) + + // For waterPressureBar, convert bar to millibar + if (!isnan(waterPressureBar) && waterPressureBar != -9999) + waterPressure_mBar = 1000 * waterPressureBar; + + MS_DBG(F(" Pressure_mbar:"), waterPressure_mBar); + MS_DBG(F(" Temp_C:"), waterTemperatureC); + MS_DBG(F(" Height_m:"), waterDepthM); + + success &= (waterPressureBar != -9999 && waterTemperatureC != -9999 && + waterDepthM != -9999); - // Put values into the array - verifyAndAddMeasurementResult(KELLER_PRESSURE_VAR_NUM, waterPressure_mBar); - verifyAndAddMeasurementResult(KELLER_TEMP_VAR_NUM, waterTemperatureC); - verifyAndAddMeasurementResult(KELLER_HEIGHT_VAR_NUM, waterDepthM); - - // Record the time that the measurement was completed - _millisMeasurementCompleted = millis(); - // Unset the time stamp for the beginning of this measurement - _millisMeasurementRequested = 0; - // Unset the status bits for a measurement request (bits 5 & 6) - clearStatusBits(MEASUREMENT_ATTEMPTED, MEASUREMENT_SUCCESSFUL); - // Bump the number of attempted retries - _retryAttemptsMade++; - - if (success && - (waterPressureBar != -9999 || waterTemperatureC != -9999 || - waterDepthM != -9999)) { - // Bump the number of successful measurements - // NOTE: Any one of the values being NOT -9999 is not considered a - // success! - _measurementAttemptsCompleted++; - } else if (_retryAttemptsMade >= _allowedMeasurementRetries) { - // Bump the number of completed measurement attempts - we've failed but - // exceeded retries - _measurementAttemptsCompleted++; + if (success) { + // Put values into the array + verifyAndAddMeasurementResult(KELLER_PRESSURE_VAR_NUM, + waterPressure_mBar); + verifyAndAddMeasurementResult(KELLER_TEMP_VAR_NUM, waterTemperatureC); + verifyAndAddMeasurementResult(KELLER_HEIGHT_VAR_NUM, waterDepthM); } - // Return true when finished - return success; + // Return success value when finished + return bumpMeasurementAttemptCount(success); } // cSpell:ignore ksensor diff --git a/src/sensors/MaxBotixSonar.cpp b/src/sensors/MaxBotixSonar.cpp index 7ae66b35c..f8e785c5a 100644 --- a/src/sensors/MaxBotixSonar.cpp +++ b/src/sensors/MaxBotixSonar.cpp @@ -123,6 +123,11 @@ bool MaxBotixSonar::sleep(void) { bool MaxBotixSonar::addSingleMeasurementResult(void) { + // Immediately quit if the measurement was not successfully started + if (!getStatusBit(MEASUREMENT_SUCCESSFUL)) { + return bumpMeasurementAttemptCount(false); + } + // Initialize values bool success = false; int16_t result = -9999; @@ -144,74 +149,49 @@ bool MaxBotixSonar::addSingleMeasurementResult(void) { #endif } - // Check a measurement was *successfully* started (status bit 6 set) - // Only go on to get a result if it was - if (getStatusBit(MEASUREMENT_SUCCESSFUL)) { - MS_DBG(getSensorNameAndLocation(), F("is reporting:")); - - uint8_t rangeAttempts = 0; - while (success == false && rangeAttempts < 25) { - /// @todo unify retries with other sensors? - // If the sonar is running on a trigger, activating the trigger - // should in theory happen within the startSingleMeasurement - // function. Because we're really taking up to 25 measurements - // for each "single measurement" until a valid value is returned - // and the measurement time is <166ms, we'll actually activate - // the trigger here. - if (_triggerPin >= 0) { - MS_DBG(F(" Triggering Sonar with"), _triggerPin); - digitalWrite(_triggerPin, HIGH); - delayMicroseconds(30); // Trigger must be held high for >20 µs - digitalWrite(_triggerPin, LOW); - } - - // Immediately ask for a result and let the stream timeout be our - // "wait" for the measurement. - result = static_cast(_stream->parseInt()); - _stream->read(); // To throw away the carriage return - MS_DBG(F(" Sonar Range:"), result); - rangeAttempts++; - - // If it cannot obtain a result, the sonar is supposed to send a - // value just above its max range. If the result becomes garbled or - // the sonar is disconnected, the parseInt function returns 0. - // Luckily, these sensors are not capable of reading 0, so we also - // know the 0 value is bad. - if (result <= 0 || result >= _maxRange) { - MS_DBG(F(" Bad or Suspicious Result, Retry Attempt #"), - rangeAttempts); - result = -9999; - } else { - MS_DBG(F(" Good result found")); - // convert result from cm to mm if convertCm is set to true - if (_convertCm == true) { result *= 10; } - success = true; - } + MS_DBG(getSensorNameAndLocation(), F("is reporting:")); + + uint8_t rangeAttempts = 0; + while (success == false && rangeAttempts < 25) { + /// @todo unify retries with other sensors? + // If the sonar is running on a trigger, activating the trigger + // should in theory happen within the startSingleMeasurement + // function. Because we're really taking up to 25 measurements + // for each "single measurement" until a valid value is returned + // and the measurement time is <166ms, we'll actually activate + // the trigger here. + if (_triggerPin >= 0) { + MS_DBG(F(" Triggering Sonar with"), _triggerPin); + digitalWrite(_triggerPin, HIGH); + delayMicroseconds(30); // Trigger must be held high for >20 µs + digitalWrite(_triggerPin, LOW); } - } else { - MS_DBG(getSensorNameAndLocation(), F("is not currently measuring!")); - } - verifyAndAddMeasurementResult(HRXL_VAR_NUM, result); - - // Record the time that the measurement was completed - _millisMeasurementCompleted = millis(); - // Unset the time stamp for the beginning of this measurement - _millisMeasurementRequested = 0; - // Unset the status bits for a measurement request (bits 5 & 6) - clearStatusBits(MEASUREMENT_ATTEMPTED, MEASUREMENT_SUCCESSFUL); - // Bump the number of attempted retries - _retryAttemptsMade++; - - if (success) { - // Bump the number of completed measurement attempts - _measurementAttemptsCompleted++; - } else if (_retryAttemptsMade >= _allowedMeasurementRetries) { - // Bump the number of completed measurement attempts - we've failed but - // exceeded retries - _measurementAttemptsCompleted++; + // Immediately ask for a result and let the stream timeout be our + // "wait" for the measurement. + result = static_cast(_stream->parseInt()); + _stream->read(); // To throw away the carriage return + MS_DBG(F(" Sonar Range:"), result); + rangeAttempts++; + + // If it cannot obtain a result, the sonar is supposed to send a + // value just above its max range. If the result becomes garbled or + // the sonar is disconnected, the parseInt function returns 0. + // Luckily, these sensors are not capable of reading 0, so we also + // know the 0 value is bad. + if (result <= 0 || result >= _maxRange) { + MS_DBG(F(" Bad or Suspicious Result, Retry Attempt #"), + rangeAttempts); + result = -9999; + } else { + MS_DBG(F(" Good result found")); + // convert result from cm to mm if convertCm is set to true + if (_convertCm == true) { result *= 10; } + success = true; + } } + if (success) { verifyAndAddMeasurementResult(HRXL_VAR_NUM, result); } - // Return values shows if we got a not-obviously-bad reading - return success; + // Return success value when finished + return bumpMeasurementAttemptCount(success); } diff --git a/src/sensors/MaximDS18.cpp b/src/sensors/MaximDS18.cpp index d27cd9f3c..e33fcfeba 100644 --- a/src/sensors/MaximDS18.cpp +++ b/src/sensors/MaximDS18.cpp @@ -181,50 +181,27 @@ bool MaximDS18::startSingleMeasurement(void) { bool MaximDS18::addSingleMeasurementResult(void) { - bool success = false; - - // Initialize float variable - float result = -9999; - - // Check a measurement was *successfully* started (status bit 6 set) - // Only go on to get a result if it was - if (getStatusBit(MEASUREMENT_SUCCESSFUL)) { - MS_DBG(getSensorNameAndLocation(), F("is reporting:")); - result = _internalDallasTemp.getTempC(_OneWireAddress); - MS_DBG(F(" Received"), result, F("°C")); - - // If a DS18 cannot get a good measurement, it returns 85 - // If the sensor is not properly connected, it returns -127 - if (result == 85 || result == -127) { - result = -9999; - } else { - success = true; - } - MS_DBG(F(" Temperature:"), result, F("°C")); - } else { - MS_DBG(getSensorNameAndLocation(), F("is not currently measuring!")); + // Immediately quit if the measurement was not successfully started + if (!getStatusBit(MEASUREMENT_SUCCESSFUL)) { + return bumpMeasurementAttemptCount(false); } - // Put value into the array - verifyAndAddMeasurementResult(DS18_TEMP_VAR_NUM, result); - - // Record the time that the measurement was completed - _millisMeasurementCompleted = millis(); - // Unset the time stamp for the beginning of this measurement - _millisMeasurementRequested = 0; - // Unset the status bits for a measurement request (bits 5 & 6) - clearStatusBits(MEASUREMENT_ATTEMPTED, MEASUREMENT_SUCCESSFUL); - // Bump the number of attempted retries - _retryAttemptsMade++; - - if (success && result != -9999) { - // Bump the number of completed measurement attempts - _measurementAttemptsCompleted++; - } else if (_retryAttemptsMade >= _allowedMeasurementRetries) { - // Bump the number of completed measurement attempts - we've failed but - // exceeded retries - _measurementAttemptsCompleted++; + bool success = false; + float result = -9999; + + MS_DBG(getSensorNameAndLocation(), F("is reporting:")); + result = _internalDallasTemp.getTempC(_OneWireAddress); + MS_DBG(F(" Received"), result, F("°C")); + + // If a DS18 cannot get a good measurement, it returns 85 + // If the sensor is not properly connected, it returns -127 + if (result != 85 && result != -127) { + // Put value into the array + verifyAndAddMeasurementResult(DS18_TEMP_VAR_NUM, result); + success = true; } + MS_DBG(F(" Temperature:"), result, F("°C")); - return success; + // Return success value when finished + return bumpMeasurementAttemptCount(success); } diff --git a/src/sensors/MaximDS3231.cpp b/src/sensors/MaximDS3231.cpp index bfde59527..556452d17 100644 --- a/src/sensors/MaximDS3231.cpp +++ b/src/sensors/MaximDS3231.cpp @@ -54,6 +54,9 @@ bool MaximDS3231::startSingleMeasurement(void) { bool MaximDS3231::addSingleMeasurementResult(void) { + // NOTE: This can't fail! If it does we have much bigger problems because + // that means we can't get the timeand the whole system is not working. + // get the temperature value MS_DBG(getSensorNameAndLocation(), F("is reporting:")); float tempVal = rtc.getTemperature(); @@ -61,18 +64,6 @@ bool MaximDS3231::addSingleMeasurementResult(void) { verifyAndAddMeasurementResult(DS3231_TEMP_VAR_NUM, tempVal); - // Record the time that the measurement was completed - _millisMeasurementCompleted = millis(); - // Unset the time stamp for the beginning of this measurement - _millisMeasurementRequested = 0; - // Unset the status bits for a measurement request (bits 5 & 6) - clearStatusBits(MEASUREMENT_ATTEMPTED, MEASUREMENT_SUCCESSFUL); - // Bump the number of attempted retries - _retryAttemptsMade++; - // NOTE: We don't actually have any criteria for if the reading was any good - // or not, so we mark it as completed no matter what. - _measurementAttemptsCompleted++; - - // Return true when finished - return true; + // Return success value when finished + return bumpMeasurementAttemptCount(true); } diff --git a/src/sensors/MeaSpecMS5803.cpp b/src/sensors/MeaSpecMS5803.cpp index ac9c6cf3a..de5f91b00 100644 --- a/src/sensors/MeaSpecMS5803.cpp +++ b/src/sensors/MeaSpecMS5803.cpp @@ -55,63 +55,36 @@ bool MeaSpecMS5803::setup(void) { bool MeaSpecMS5803::addSingleMeasurementResult(void) { - bool success = false; - - // Initialize float variables - float temp = -9999; - float press = -9999; - - // Check a measurement was *successfully* started (status bit 6 set) - // Only go on to get a result if it was - if (getStatusBit(MEASUREMENT_SUCCESSFUL)) { - MS_DBG(getSensorNameAndLocation(), F("is reporting:")); - // Read values - // NOTE: These functions actually include the request to begin - // a measurement and the wait for said measurement to finish. - // It's pretty fast (max of 11 ms) so we'll just wait. - temp = MS5803_internal.getTemperature(CELSIUS, ADC_512); - press = MS5803_internal.getPressure(ADC_4096); - - if (isnan(temp)) temp = -9999; - if (isnan(press)) press = -9999; - if (temp < -50 || temp > 95) { // Range is -40°C to +85°C - temp = -9999; - press = -9999; - } - if (press == 0) { // Returns 0 when disconnected, which is highly - // unlikely to be a real value. - temp = -9999; - press = -9999; - } - - MS_DBG(F(" Temperature:"), temp); - MS_DBG(F(" Pressure:"), press); - } else { - MS_DBG(getSensorNameAndLocation(), F("is not currently measuring!")); + // Immediately quit if the measurement was not successfully started + if (!getStatusBit(MEASUREMENT_SUCCESSFUL)) { + return bumpMeasurementAttemptCount(false); } - verifyAndAddMeasurementResult(MS5803_TEMP_VAR_NUM, temp); - verifyAndAddMeasurementResult(MS5803_PRESSURE_VAR_NUM, press); - - // Record the time that the measurement was completed - _millisMeasurementCompleted = millis(); - // Unset the time stamp for the beginning of this measurement - _millisMeasurementRequested = 0; - // Unset the status bits for a measurement request (bits 5 & 6) - clearStatusBits(MEASUREMENT_ATTEMPTED, MEASUREMENT_SUCCESSFUL); - // Bump the number of attempted retries - _retryAttemptsMade++; - - if (success && (temp != -9999 || press != -9999)) { - // Bump the number of successful measurements - // NOTE: Any one of the values being NOT -9999 is not considered a - // success! - _measurementAttemptsCompleted++; - } else if (_retryAttemptsMade >= _allowedMeasurementRetries) { - // Bump the number of completed measurement attempts - we've failed but - // exceeded retries - _measurementAttemptsCompleted++; + bool success = false; + float temp = -9999; + float press = -9999; + + MS_DBG(getSensorNameAndLocation(), F("is reporting:")); + // Read values + // NOTE: These functions actually include the request to begin + // a measurement and the wait for said measurement to finish. + // It's pretty fast (max of 11 ms) so we'll just wait. + temp = MS5803_internal.getTemperature(CELSIUS, ADC_512); + press = MS5803_internal.getPressure(ADC_4096); + + MS_DBG(F(" Temperature:"), temp); + MS_DBG(F(" Pressure:"), press); + + if (!isnan(temp) && !isnan(press) && temp > -50 && temp < 95 && + press != 0) { + // Temperature Range is -40°C to +85°C + // Pressure returns 0 when disconnected, which is highly unlikely to be + // a real value. + verifyAndAddMeasurementResult(MS5803_TEMP_VAR_NUM, temp); + verifyAndAddMeasurementResult(MS5803_PRESSURE_VAR_NUM, press); + success = true; } - return success; + // Return success value when finished + return bumpMeasurementAttemptCount(success); } diff --git a/src/sensors/PaleoTerraRedox.cpp b/src/sensors/PaleoTerraRedox.cpp index bf607fea3..014585924 100644 --- a/src/sensors/PaleoTerraRedox.cpp +++ b/src/sensors/PaleoTerraRedox.cpp @@ -97,6 +97,11 @@ bool PaleoTerraRedox::setup(void) { bool PaleoTerraRedox::addSingleMeasurementResult(void) { + // Immediately quit if the measurement was not successfully started + if (!getStatusBit(MEASUREMENT_SUCCESSFUL)) { + return bumpMeasurementAttemptCount(false); + } + bool success = false; byte config = 0; // Data transfer values @@ -104,70 +109,49 @@ bool PaleoTerraRedox::addSingleMeasurementResult(void) { float res = 0; // Calculated voltage in uV byte i2c_status = -1; - if (_millisMeasurementRequested > 0) { - _i2c->beginTransmission(_i2cAddressHex); - _i2c->write(0b10001100); // initiate conversion, One-Shot mode, 18 - // bits, PGA x1 - i2c_status = _i2c->endTransmission(); - - delay(300); - - _i2c->requestFrom(int(_i2cAddressHex), - 4); // Get 4 bytes from device - byte res1 = _i2c->read(); - byte res2 = _i2c->read(); - byte res3 = _i2c->read(); - config = _i2c->read(); - - res = 0; - int sign = bitRead(res1, 1); // one but least significant bit - if (sign == 1) { - res1 = ~res1; - res2 = ~res2; - res3 = ~res3; // two's complements - res = bitRead(res1, 0) * - -1024; // 256 * 256 * 15.625 uV per LSB = 16 - res -= res2 * 4; - res -= res3 * 0.015625; - res -= 0.015625; - } else { - res = bitRead(res1, 0) * - 1024; // 256 * 256 * 15.625 uV per LSB = 16 - res += res2 * 4; - res += res3 * 0.015625; - } + + _i2c->beginTransmission(_i2cAddressHex); + _i2c->write(0b10001100); // initiate conversion, One-Shot mode, 18 + // bits, PGA x1 + i2c_status = _i2c->endTransmission(); + + delay(300); + + _i2c->requestFrom(int(_i2cAddressHex), + 4); // Get 4 bytes from device + byte res1 = _i2c->read(); + byte res2 = _i2c->read(); + byte res3 = _i2c->read(); + config = _i2c->read(); + + res = 0; + int sign = bitRead(res1, 1); // one but least significant bit + if (sign == 1) { + res1 = ~res1; + res2 = ~res2; + res3 = ~res3; // two's complements + res = bitRead(res1, 0) * -1024; // 256 * 256 * 15.625 uV per LSB = 16 + res -= res2 * 4; + res -= res3 * 0.015625; + res -= 0.015625; } else { - MS_DBG(F("Sensor is not currently measuring!\n")); + res = bitRead(res1, 0) * 1024; // 256 * 256 * 15.625 uV per LSB = 16 + res += res2 * 4; + res += res3 * 0.015625; } - // ADD FAILURE CONDITIONS!! + /// @todo ADD FAILURE CONDITIONS for PaleoTerraRedox!! if (isnan(res)) res = -9999; // list a failure if the sensor returns nan (not sure // how this would happen, keep to be safe) else if (res == 0 && i2c_status == 0 && config == 0) res = -9999; // List a failure when the sensor is not connected - // Store the results in the sensorValues array - verifyAndAddMeasurementResult(PTR_VOLTAGE_VAR_NUM, res); - - // Record the time that the measurement was completed - _millisMeasurementCompleted = millis(); - // Unset the time stamp for the beginning of this measurement - _millisMeasurementRequested = 0; - // Unset the status bit for a measurement having been requested (bit 5) - clearStatusBit(MEASUREMENT_ATTEMPTED); - // Set the status bit for measurement completion (bit 6) - setStatusBit(MEASUREMENT_SUCCESSFUL); - // Bump the number of attempted retries - _retryAttemptsMade++; - - if (success && (res != -9999)) { - // Bump the number of completed measurement attempts - _measurementAttemptsCompleted++; - } else if (_retryAttemptsMade >= _allowedMeasurementRetries) { - // Bump the number of completed measurement attempts - we've failed but - // exceeded retries - _measurementAttemptsCompleted++; + success = res != -9999; + if (success) { + // Store the results in the sensorValues array + verifyAndAddMeasurementResult(PTR_VOLTAGE_VAR_NUM, res); } - return success; + // Return success value when finished + return bumpMeasurementAttemptCount(success); } diff --git a/src/sensors/ProcessorStats.cpp b/src/sensors/ProcessorStats.cpp index 1ea8c2bd1..75fe9b7e5 100644 --- a/src/sensors/ProcessorStats.cpp +++ b/src/sensors/ProcessorStats.cpp @@ -289,20 +289,8 @@ bool ProcessorStats::addSingleMeasurementResult(void) { MS_DBG(F("Skipping reset cause check on reps")); } - // Record the time that the measurement was completed - _millisMeasurementCompleted = millis(); - // Unset the time stamp for the beginning of this measurement - _millisMeasurementRequested = 0; - // Unset the status bits for a measurement request (bits 5 & 6) - clearStatusBits(MEASUREMENT_ATTEMPTED, MEASUREMENT_SUCCESSFUL); - // Bump the number of attempted retries - _retryAttemptsMade++; - // NOTE: We don't actually have any criteria for if the reading was any good - // or not, so we mark it as completed no matter what. - _measurementAttemptsCompleted++; - - // Return true when finished - return true; + // Return true value when finished + return bumpMeasurementAttemptCount(true); } // cSpell:ignore ADALOGGER RSTC RCAUSE BKUPEXIT BODCORE BODVDD BBPS brkval MCUSR diff --git a/src/sensors/RainCounterI2C.cpp b/src/sensors/RainCounterI2C.cpp index 1940d81e9..56413e66c 100644 --- a/src/sensors/RainCounterI2C.cpp +++ b/src/sensors/RainCounterI2C.cpp @@ -91,9 +91,14 @@ bool RainCounterI2C::setup(void) { bool RainCounterI2C::addSingleMeasurementResult(void) { - // initialize values - float rain = -9999; // Number of mm of rain - int32_t tips = -9999; // Number of tip events, increased for anemometer + // Immediately quit if the measurement was not successfully started + if (!getStatusBit(MEASUREMENT_SUCCESSFUL)) { + return bumpMeasurementAttemptCount(false); + } + + bool success = false; // assume the worst + float rain = -9999; // Number of mm of rain + int32_t tips = -9999; // Number of tip events, increased for anemometer // Get data from external tip counter // if the 'requestFrom' returns 0, it means no bytes were received @@ -143,33 +148,16 @@ bool RainCounterI2C::addSingleMeasurementResult(void) { MS_DBG(F(" Rain:"), rain); MS_DBG(F(" Tips:"), tips); + + if (rain != -9999 || tips != -9999) { + verifyAndAddMeasurementResult(BUCKET_RAIN_VAR_NUM, rain); + verifyAndAddMeasurementResult(BUCKET_TIPS_VAR_NUM, tips); + success = true; + } } else { MS_DBG(F("No bytes received from"), getSensorNameAndLocation()); } - verifyAndAddMeasurementResult(BUCKET_RAIN_VAR_NUM, rain); - verifyAndAddMeasurementResult(BUCKET_TIPS_VAR_NUM, tips); - - // Record the time that the measurement was completed - _millisMeasurementCompleted = millis(); - // Unset the time stamp for the beginning of this measurement - _millisMeasurementRequested = 0; - // Unset the status bits for a measurement request (bits 5 & 6) - clearStatusBits(MEASUREMENT_ATTEMPTED, MEASUREMENT_SUCCESSFUL); - // Bump the number of attempted retries - _retryAttemptsMade++; - - if (rain != -9999 || tips != -9999) { - // Bump the number of successful measurements - // NOTE: Any one of the values being NOT -9999 is not considered a - // success! - _measurementAttemptsCompleted++; - } else if (_retryAttemptsMade >= _allowedMeasurementRetries) { - // Bump the number of completed measurement attempts - we've failed but - // exceeded retries - _measurementAttemptsCompleted++; - } - - // Return true when finished - return true; + // Return success value when finished + return bumpMeasurementAttemptCount(success); } diff --git a/src/sensors/SDI12Sensors.cpp b/src/sensors/SDI12Sensors.cpp index 7fd40ebcc..bf2192cd4 100644 --- a/src/sensors/SDI12Sensors.cpp +++ b/src/sensors/SDI12Sensors.cpp @@ -709,43 +709,23 @@ bool SDI12Sensors::getResults(bool verify_crc) { #ifndef MS_SDI12_NON_CONCURRENT bool SDI12Sensors::addSingleMeasurementResult(void) { - bool success = false; - - // Check a measurement was *successfully* started (status bit 6 set) - // Only go on to get a result if it was - if (getStatusBit(MEASUREMENT_SUCCESSFUL)) { - success = getResults(MS_SDI12_USE_CRC); - } else { - // If there's no measurement, need to make sure we send over all - // of the "failed" result values - MS_DBG(getSensorNameAndLocation(), F("is not currently measuring!")); - for (uint8_t i = 0; i < _numReturnedValues; i++) { - verifyAndAddMeasurementResult(i, static_cast(-9999)); - } + // Immediately quit if the measurement was not successfully started + if (!getStatusBit(MEASUREMENT_SUCCESSFUL)) { + return bumpMeasurementAttemptCount(false); } - // Record the time that the measurement was completed - _millisMeasurementCompleted = millis(); - // Unset the time stamp for the beginning of this measurement - _millisMeasurementRequested = 0; - // Unset the status bits for a measurement request (bits 5 & 6) - clearStatusBits(MEASUREMENT_ATTEMPTED, MEASUREMENT_SUCCESSFUL); - // Bump the number of attempted retries - _retryAttemptsMade++; - - if (success) { - // Bump the number of completed measurement attempts - _measurementAttemptsCompleted++; - } else if (_retryAttemptsMade >= _allowedMeasurementRetries) { - // Bump the number of completed measurement attempts - we've failed but - // exceeded retries - _measurementAttemptsCompleted++; - } + bool success = getResults(MS_SDI12_USE_CRC); - return success; + // Return success value when finished + return bumpMeasurementAttemptCount(success); } #else bool SDI12Sensors::addSingleMeasurementResult(void) { + // Immediately quit if the measurement was not successfully started + if (!getStatusBit(MEASUREMENT_SUCCESSFUL)) { + return bumpMeasurementAttemptCount(false); + } + bool success = false; String startCommand; @@ -807,35 +787,12 @@ bool SDI12Sensors::addSingleMeasurementResult(void) { verifyAndAddMeasurementResult(i, static_cast(-9999)); } } - } else { - // If there's no response, we still need to send over all the failed - // values - for (uint8_t i = 0; i < _numReturnedValues; i++) { - verifyAndAddMeasurementResult(i, static_cast(-9999)); - } } // Empty the buffer and de-activate the SDI-12 Object deactivate(); - // Record the time that the measurement was completed - _millisMeasurementCompleted = millis(); - // Unset the time stamp for the beginning of this measurement - _millisMeasurementRequested = 0; - // Unset the status bits for a measurement request (bits 5 & 6) - clearStatusBits(MEASUREMENT_ATTEMPTED, MEASUREMENT_SUCCESSFUL); - // Bump the number of attempted retries - _retryAttemptsMade++; - - if (success) { - // Bump the number of completed measurement attempts - _measurementAttemptsCompleted++; - } else if (_retryAttemptsMade >= _allowedMeasurementRetries) { - // Bump the number of completed measurement attempts - we've failed but - // exceeded retries - _measurementAttemptsCompleted++; - } - - return success; + // Return success value when finished + return bumpMeasurementAttemptCount(success); } #endif // #ifndef MS_SDI12_NON_CONCURRENT diff --git a/src/sensors/SensirionSHT4x.cpp b/src/sensors/SensirionSHT4x.cpp index c94e64103..743d5776e 100644 --- a/src/sensors/SensirionSHT4x.cpp +++ b/src/sensors/SensirionSHT4x.cpp @@ -88,62 +88,42 @@ bool SensirionSHT4x::setup(void) { bool SensirionSHT4x::addSingleMeasurementResult(void) { - // Initialize float variables + // Immediately quit if the measurement was not successfully started + if (!getStatusBit(MEASUREMENT_SUCCESSFUL)) { + return bumpMeasurementAttemptCount(false); + } + + bool success = false; float temp_val = -9999; float humid_val = -9999; bool ret_val = false; - // Check a measurement was *successfully* started (status bit 6 set) - // Only go on to get a result if it was - if (getStatusBit(MEASUREMENT_SUCCESSFUL)) { - MS_DBG(getSensorNameAndLocation(), F("is reporting:")); - - // Make sure the heater is *not* going to run. We want the ambient - // values. - sht4x_internal.setHeater(SHT4X_NO_HEATER); + MS_DBG(getSensorNameAndLocation(), F("is reporting:")); - // we need to create Adafruit "sensor events" to use the library - sensors_event_t temp_event; - sensors_event_t humidity_event; - ret_val = sht4x_internal.getEvent(&humidity_event, &temp_event); + // Make sure the heater is *not* going to run. We want the ambient + // values. + sht4x_internal.setHeater(SHT4X_NO_HEATER); - // get the values from the sensor events - temp_val = temp_event.temperature; - humid_val = humidity_event.relative_humidity; + // we need to create Adafruit "sensor events" to use the library + sensors_event_t temp_event; + sensors_event_t humidity_event; + ret_val = sht4x_internal.getEvent(&humidity_event, &temp_event); - if (!ret_val || isnan(temp_val)) temp_val = -9999; - if (!ret_val || isnan(humid_val)) humid_val = -9999; + // get the values from the sensor events + temp_val = temp_event.temperature; + humid_val = humidity_event.relative_humidity; - MS_DBG(F(" Temp:"), temp_val, F("°C")); - MS_DBG(F(" Humidity:"), humid_val, '%'); - } else { - MS_DBG(getSensorNameAndLocation(), F("is not currently measuring!")); - } + MS_DBG(F(" Temp:"), temp_val, F("°C")); + MS_DBG(F(" Humidity:"), humid_val, '%'); - verifyAndAddMeasurementResult(SHT4X_TEMP_VAR_NUM, temp_val); - verifyAndAddMeasurementResult(SHT4X_HUMIDITY_VAR_NUM, humid_val); - - // Record the time that the measurement was completed - _millisMeasurementCompleted = millis(); - // Unset the time stamp for the beginning of this measurement - _millisMeasurementRequested = 0; - // Unset the status bits for a measurement request (bits 5 & 6) - clearStatusBits(MEASUREMENT_ATTEMPTED, MEASUREMENT_SUCCESSFUL); - // Bump the number of attempted retries - _retryAttemptsMade++; - - if (ret_val && (temp_val != -9999 || humid_val != -9999)) { - // Bump the number of successful measurements - // NOTE: Any one of the values being NOT -9999 is not considered a - // success! - _measurementAttemptsCompleted++; - } else if (_retryAttemptsMade >= _allowedMeasurementRetries) { - // Bump the number of completed measurement attempts - we've failed but - // exceeded retries - _measurementAttemptsCompleted++; + if (ret_val && !isnan(temp_val) && !isnan(humid_val)) { + verifyAndAddMeasurementResult(SHT4X_TEMP_VAR_NUM, temp_val); + verifyAndAddMeasurementResult(SHT4X_HUMIDITY_VAR_NUM, humid_val); + success = true; } - return ret_val; + // Return success value when finished + return bumpMeasurementAttemptCount(success); } diff --git a/src/sensors/TIADS1x15.cpp b/src/sensors/TIADS1x15.cpp index 0570d21f7..48a72f997 100644 --- a/src/sensors/TIADS1x15.cpp +++ b/src/sensors/TIADS1x15.cpp @@ -43,81 +43,57 @@ String TIADS1x15::getSensorLocation(void) { bool TIADS1x15::addSingleMeasurementResult(void) { - // Variables to store the results in + // Immediately quit if the measurement was not successfully started + if (!getStatusBit(MEASUREMENT_SUCCESSFUL)) { + return bumpMeasurementAttemptCount(false); + } + bool success = false; int16_t adcCounts = -9999; float adcVoltage = -9999; float calibResult = -9999; - // Check a measurement was *successfully* started (status bit 6 set) - // Only go on to get a result if it was - if (getStatusBit(MEASUREMENT_SUCCESSFUL)) { - MS_DBG(getSensorNameAndLocation(), F("is reporting:")); + MS_DBG(getSensorNameAndLocation(), F("is reporting:")); // Create an auxiliary ADD object // We create and set up the ADC object here so that each sensor using // the ADC may set the gain appropriately without effecting others. #ifndef MS_USE_ADS1015 - Adafruit_ADS1115 ads; // Use this for the 16-bit version + Adafruit_ADS1115 ads; // Use this for the 16-bit version #else - Adafruit_ADS1015 ads; // Use this for the 12-bit version + Adafruit_ADS1015 ads; // Use this for the 12-bit version #endif - // ADS Library default settings: - // - TI1115 (16 bit) - // - single-shot mode (powers down between conversions) - // - 128 samples per second (8ms conversion time) - // - 2/3 gain +/- 6.144V range (limited to VDD +0.3V max) - // - TI1015 (12 bit) - // - single-shot mode (powers down between conversions) - // - 1600 samples per second (625µs conversion time) - // - 2/3 gain +/- 6.144V range (limited to VDD +0.3V max) - - // Bump the gain up to 1x = +/- 4.096V range - ads.setGain(GAIN_ONE); - // Begin ADC - ads.begin(_i2cAddress); - - // Read Analog to Digital Converter (ADC) - // Taking this reading includes the 8ms conversion delay. - // Measure the ADC raw count - adcCounts = ads.readADC_SingleEnded(_adsChannel); - // Convert ADC raw counts value to voltage (V) - adcVoltage = ads.computeVolts(adcCounts); - MS_DBG(F(" ads.readADC_SingleEnded("), _adsChannel, F("):"), - adcVoltage); - - if (adcVoltage < 3.6 && adcVoltage > -0.3) { - // Skip results out of range - // Apply the gain calculation, with a default gain of 10 V/V Gain - calibResult = adcVoltage * _gain; - MS_DBG(F(" calibResult:"), calibResult); - } else { // set invalid voltages back to -9999 - adcVoltage = -9999; - } - } else { - MS_DBG(getSensorNameAndLocation(), F("is not currently measuring!")); - } - - verifyAndAddMeasurementResult(TIADS1X15_VAR_NUM, calibResult); - - // Record the time that the measurement was completed - _millisMeasurementCompleted = millis(); - // Unset the time stamp for the beginning of this measurement - _millisMeasurementRequested = 0; - // Unset the status bits for a measurement request (bits 5 & 6) - clearStatusBits(MEASUREMENT_ATTEMPTED, MEASUREMENT_SUCCESSFUL); - // Bump the number of attempted retries - _retryAttemptsMade++; + // ADS Library default settings: + // - TI1115 (16 bit) + // - single-shot mode (powers down between conversions) + // - 128 samples per second (8ms conversion time) + // - 2/3 gain +/- 6.144V range (limited to VDD +0.3V max) + // - TI1015 (12 bit) + // - single-shot mode (powers down between conversions) + // - 1600 samples per second (625µs conversion time) + // - 2/3 gain +/- 6.144V range (limited to VDD +0.3V max) + + // Bump the gain up to 1x = +/- 4.096V range + ads.setGain(GAIN_ONE); + // Begin ADC + ads.begin(_i2cAddress); + + // Read Analog to Digital Converter (ADC) + // Taking this reading includes the 8ms conversion delay. + // Measure the ADC raw count + adcCounts = ads.readADC_SingleEnded(_adsChannel); + // Convert ADC raw counts value to voltage (V) + adcVoltage = ads.computeVolts(adcCounts); + MS_DBG(F(" ads.readADC_SingleEnded("), _adsChannel, F("):"), adcVoltage); if (adcVoltage < 3.6 && adcVoltage > -0.3) { - // Bump the number of completed measurement attempts - _measurementAttemptsCompleted++; - return true; - } else if (_retryAttemptsMade >= _allowedMeasurementRetries) { - // Bump the number of completed measurement attempts - we've failed but - // exceeded retries - _measurementAttemptsCompleted++; - return false; - } else { - return false; + // Skip results out of range + // Apply the gain calculation, with a default gain of 10 V/V Gain + calibResult = adcVoltage * _gain; + MS_DBG(F(" calibResult:"), calibResult); + verifyAndAddMeasurementResult(TIADS1X15_VAR_NUM, calibResult); + success = true; } + + // Return success value when finished + return bumpMeasurementAttemptCount(success); } diff --git a/src/sensors/TIINA219.cpp b/src/sensors/TIINA219.cpp index 5a9ac63c6..115320ea8 100644 --- a/src/sensors/TIINA219.cpp +++ b/src/sensors/TIINA219.cpp @@ -72,62 +72,38 @@ bool TIINA219::wake(void) { bool TIINA219::addSingleMeasurementResult(void) { - bool success = false; + // Immediately quit if the measurement was not successfully started + if (!getStatusBit(MEASUREMENT_SUCCESSFUL)) { + return bumpMeasurementAttemptCount(false); + } - // Initialize float variables + bool success = false; float current_mA = -9999; float busV_V = -9999; float power_mW = -9999; - // Check a measurement was *successfully* started (status bit 6 set) - // Only go on to get a result if it was - if (getStatusBit(MEASUREMENT_SUCCESSFUL)) { - MS_DBG(getSensorNameAndLocation(), F("is reporting:")); - - // Read values - current_mA = ina219_phy.getCurrent_mA(); - if (isnan(current_mA)) current_mA = -9999; - busV_V = ina219_phy.getBusVoltage_V(); - if (isnan(busV_V)) busV_V = -9999; - power_mW = ina219_phy.getPower_mW(); - if (isnan(power_mW)) power_mW = -9999; - - success = true; - - MS_DBG(F(" Current [mA]:"), current_mA); - MS_DBG(F(" Bus Voltage [V]:"), busV_V); - MS_DBG(F(" Power [mW]:"), power_mW); - } else { - MS_DBG(getSensorNameAndLocation(), F("is not currently measuring!")); - } + MS_DBG(getSensorNameAndLocation(), F("is reporting:")); + + // Read values + current_mA = ina219_phy.getCurrent_mA(); + busV_V = ina219_phy.getBusVoltage_V(); + power_mW = ina219_phy.getPower_mW(); - verifyAndAddMeasurementResult(INA219_CURRENT_MA_VAR_NUM, current_mA); - verifyAndAddMeasurementResult(INA219_BUS_VOLTAGE_VAR_NUM, busV_V); - verifyAndAddMeasurementResult(INA219_POWER_MW_VAR_NUM, power_mW); - - - // Record the time that the measurement was completed - _millisMeasurementCompleted = millis(); - // Unset the time stamp for the beginning of this measurement - _millisMeasurementRequested = 0; - // Unset the status bits for a measurement request (bits 5 & 6) - clearStatusBits(MEASUREMENT_ATTEMPTED, MEASUREMENT_SUCCESSFUL); - // Bump the number of attempted retries - _retryAttemptsMade++; - - if (success && - (current_mA != -9999 || busV_V != -9999 || power_mW != -9999)) { - // Bump the number of successful measurements - // NOTE: Any one of the values being NOT -9999 is not considered a - // success! - _measurementAttemptsCompleted++; - } else if (_retryAttemptsMade >= _allowedMeasurementRetries) { - // Bump the number of completed measurement attempts - we've failed but - // exceeded retries - _measurementAttemptsCompleted++; + success = !isnan(current_mA) && !isnan(busV_V) && !isnan(power_mW); + + MS_DBG(F(" Current [mA]:"), current_mA); + MS_DBG(F(" Bus Voltage [V]:"), busV_V); + MS_DBG(F(" Power [mW]:"), power_mW); + + if (success) { + verifyAndAddMeasurementResult(INA219_CURRENT_MA_VAR_NUM, current_mA); + verifyAndAddMeasurementResult(INA219_BUS_VOLTAGE_VAR_NUM, busV_V); + verifyAndAddMeasurementResult(INA219_POWER_MW_VAR_NUM, power_mW); } - return success; + + // Return success value when finished + return bumpMeasurementAttemptCount(success); } // cSpell:ignore TIINA219 diff --git a/src/sensors/TallyCounterI2C.cpp b/src/sensors/TallyCounterI2C.cpp index e22bb0298..fd935a81d 100644 --- a/src/sensors/TallyCounterI2C.cpp +++ b/src/sensors/TallyCounterI2C.cpp @@ -68,62 +68,37 @@ bool TallyCounterI2C::setup(void) { bool TallyCounterI2C::addSingleMeasurementResult(void) { - bool success = false; - - // Initialize variables - int16_t events = -9999; // Number of events - - // Check a measurement was *successfully* started (status bit 6 set) - // Only go on to get a result if it was - if (getStatusBit(MEASUREMENT_SUCCESSFUL)) { - MS_DBG(getSensorNameAndLocation(), F("is reporting:")); - - // Read values - // Read data from counter before clear - - events = counter_internal.Peek(); - if (isnan(events)) events = -9999; + // Immediately quit if the measurement was not successfully started + if (!getStatusBit(MEASUREMENT_SUCCESSFUL)) { + return bumpMeasurementAttemptCount(false); + } - // Assume that if negative a failed response - // May also return a very negative temp when receiving a bad response - if (events < 0) { - MS_DBG(F("All values 0 or bad, assuming sensor non-response!")); - events = -9999; - } else { - success = true; - } + bool success = false; + int16_t events = -9999; // Number of events - // Clear count value - counter_internal.Clear(); + MS_DBG(getSensorNameAndLocation(), F("is reporting:")); - if (events < 0) - events = -9999; // If negative value results, return failure + // Read values + // Read data from counter before clear - MS_DBG(F(" Events:"), events); + events = counter_internal.Peek(); + if (isnan(events)) events = -9999; + // Assume that if negative a failed response + // May also return a very negative temp when receiving a bad response + if (events < 0) { + MS_DBG(F("All values 0 or bad, assuming sensor non-response!")); + events = -9999; } else { - MS_DBG(getSensorNameAndLocation(), F("is not currently measuring!")); + verifyAndAddMeasurementResult(TALLY_EVENTS_VAR_NUM, events); + success = true; } - verifyAndAddMeasurementResult(TALLY_EVENTS_VAR_NUM, events); - - // Record the time that the measurement was completed - _millisMeasurementCompleted = millis(); - // Unset the time stamp for the beginning of this measurement - _millisMeasurementRequested = 0; - // Unset the status bits for a measurement request (bits 5 & 6) - clearStatusBits(MEASUREMENT_ATTEMPTED, MEASUREMENT_SUCCESSFUL); - // Bump the number of attempted retries - _retryAttemptsMade++; - - if (success) { - // Bump the number of completed measurement attempts - _measurementAttemptsCompleted++; - } else if (_retryAttemptsMade >= _allowedMeasurementRetries) { - // Bump the number of completed measurement attempts - we've failed but - // exceeded retries - _measurementAttemptsCompleted++; - } + // Clear count value + counter_internal.Clear(); + + MS_DBG(F(" Events:"), events); - return success; + // Return success value when finished + return bumpMeasurementAttemptCount(success); } diff --git a/src/sensors/TurnerCyclops.cpp b/src/sensors/TurnerCyclops.cpp index bda374435..021ef2cb8 100644 --- a/src/sensors/TurnerCyclops.cpp +++ b/src/sensors/TurnerCyclops.cpp @@ -43,89 +43,66 @@ String TurnerCyclops::getSensorLocation(void) { bool TurnerCyclops::addSingleMeasurementResult(void) { - // Variables to store the results in + // Immediately quit if the measurement was not successfully started + if (!getStatusBit(MEASUREMENT_SUCCESSFUL)) { + return bumpMeasurementAttemptCount(false); + } + + bool success = false; int16_t adcCounts = -9999; float adcVoltage = -9999; float calibResult = -9999; - // Check a measurement was *successfully* started (status bit 6 set) - // Only go on to get a result if it was - if (getStatusBit(MEASUREMENT_SUCCESSFUL)) { - MS_DBG(getSensorNameAndLocation(), F("is reporting:")); + MS_DBG(getSensorNameAndLocation(), F("is reporting:")); // Create an auxiliary ADD object // We create and set up the ADC object here so that each sensor using // the ADC may set the gain appropriately without effecting others. #ifndef MS_USE_ADS1015 - Adafruit_ADS1115 ads; // Use this for the 16-bit version + Adafruit_ADS1115 ads; // Use this for the 16-bit version #else - Adafruit_ADS1015 ads; // Use this for the 12-bit version + Adafruit_ADS1015 ads; // Use this for the 12-bit version #endif - // ADS Library default settings: - // - TI1115 (16 bit) - // - single-shot mode (powers down between conversions) - // - 128 samples per second (8ms conversion time) - // - 2/3 gain +/- 6.144V range (limited to VDD +0.3V max) - // - TI1015 (12 bit) - // - single-shot mode (powers down between conversions) - // - 1600 samples per second (625µs conversion time) - // - 2/3 gain +/- 6.144V range (limited to VDD +0.3V max) - - // Bump the gain up to 1x = +/- 4.096V range - // Sensor return range is 0-2.5V, but the next gain option is 2x which - // only allows up to 2.048V - ads.setGain(GAIN_ONE); - // Begin ADC - ads.begin(_i2cAddress); - - // Print out the calibration curve - MS_DBG(F(" Input calibration Curve:"), _volt_std, F("V at"), _conc_std, - F(". "), _volt_blank, F("V blank.")); - - // Read Analog to Digital Converter (ADC) - // Taking this reading includes the 8ms conversion delay. - // Measure the ADC raw count - adcCounts = ads.readADC_SingleEnded(_adsChannel); - // Convert ADC raw counts value to voltage (V) - adcVoltage = ads.computeVolts(adcCounts); - MS_DBG(F(" ads.readADC_SingleEnded("), _adsChannel, F("):"), - adcVoltage); - - if (adcVoltage < 3.6 && adcVoltage > -0.3) { - // Skip results out of range - // Apply the unique calibration curve for the given sensor - calibResult = (_conc_std / (_volt_std - _volt_blank)) * - (adcVoltage - _volt_blank); - MS_DBG(F(" calibResult:"), calibResult); - } else { // set invalid voltages back to -9999 - adcVoltage = -9999; - } - } else { - MS_DBG(getSensorNameAndLocation(), F("is not currently measuring!")); - } - - verifyAndAddMeasurementResult(CYCLOPS_VAR_NUM, calibResult); - verifyAndAddMeasurementResult(CYCLOPS_VOLTAGE_VAR_NUM, adcVoltage); - - // Record the time that the measurement was completed - _millisMeasurementCompleted = millis(); - // Unset the time stamp for the beginning of this measurement - _millisMeasurementRequested = 0; - // Unset the status bits for a measurement request (bits 5 & 6) - clearStatusBits(MEASUREMENT_ATTEMPTED, MEASUREMENT_SUCCESSFUL); - // Bump the number of attempted retries - _retryAttemptsMade++; + // ADS Library default settings: + // - TI1115 (16 bit) + // - single-shot mode (powers down between conversions) + // - 128 samples per second (8ms conversion time) + // - 2/3 gain +/- 6.144V range (limited to VDD +0.3V max) + // - TI1015 (12 bit) + // - single-shot mode (powers down between conversions) + // - 1600 samples per second (625µs conversion time) + // - 2/3 gain +/- 6.144V range (limited to VDD +0.3V max) + + // Bump the gain up to 1x = +/- 4.096V range + // Sensor return range is 0-2.5V, but the next gain option is 2x which + // only allows up to 2.048V + ads.setGain(GAIN_ONE); + // Begin ADC + ads.begin(_i2cAddress); + + // Print out the calibration curve + MS_DBG(F(" Input calibration Curve:"), _volt_std, F("V at"), _conc_std, + F(". "), _volt_blank, F("V blank.")); + + // Read Analog to Digital Converter (ADC) + // Taking this reading includes the 8ms conversion delay. + // Measure the ADC raw count + adcCounts = ads.readADC_SingleEnded(_adsChannel); + // Convert ADC raw counts value to voltage (V) + adcVoltage = ads.computeVolts(adcCounts); + MS_DBG(F(" ads.readADC_SingleEnded("), _adsChannel, F("):"), adcVoltage); if (adcVoltage < 3.6 && adcVoltage > -0.3) { - // Bump the number of completed measurement attempts - _measurementAttemptsCompleted++; - return true; - } else if (_retryAttemptsMade >= _allowedMeasurementRetries) { - // Bump the number of completed measurement attempts - we've failed but - // exceeded retries - _measurementAttemptsCompleted++; - return false; - } else { - return false; + // Skip results out of range + // Apply the unique calibration curve for the given sensor + calibResult = (_conc_std / (_volt_std - _volt_blank)) * + (adcVoltage - _volt_blank); + MS_DBG(F(" calibResult:"), calibResult); + verifyAndAddMeasurementResult(CYCLOPS_VAR_NUM, calibResult); + verifyAndAddMeasurementResult(CYCLOPS_VOLTAGE_VAR_NUM, adcVoltage); + success = true; } + + // Return success value when finished + return bumpMeasurementAttemptCount(success); } diff --git a/src/sensors/TurnerTurbidityPlus.cpp b/src/sensors/TurnerTurbidityPlus.cpp index 22733ed66..bdbea215b 100644 --- a/src/sensors/TurnerTurbidityPlus.cpp +++ b/src/sensors/TurnerTurbidityPlus.cpp @@ -90,104 +90,83 @@ void TurnerTurbidityPlus::powerUp(void) { } bool TurnerTurbidityPlus::addSingleMeasurementResult(void) { - // Variables to store the results in + // Immediately quit if the measurement was not successfully started + if (!getStatusBit(MEASUREMENT_SUCCESSFUL)) { + return bumpMeasurementAttemptCount(false); + } + + bool success = false; int16_t adcCounts = -9999; float adcVoltage = -9999; float calibResult = -9999; - // Check a measurement was *successfully* started (status bit 6 set) - // Only go on to get a result if it was - if (getStatusBit(MEASUREMENT_SUCCESSFUL)) { - MS_DBG(getSensorNameAndLocation(), F("is reporting:")); + MS_DBG(getSensorNameAndLocation(), F("is reporting:")); // Create an auxiliary ADD object // We create and set up the ADC object here so that each sensor using // the ADC may set the gain appropriately without effecting others. #ifndef MS_USE_ADS1015 - Adafruit_ADS1115 ads; // Use this for the 16-bit version + Adafruit_ADS1115 ads; // Use this for the 16-bit version #else - Adafruit_ADS1015 ads; // Use this for the 12-bit version + Adafruit_ADS1015 ads; // Use this for the 12-bit version #endif - // ADS Library default settings: - // - TI1115 (16 bit) - // - single-shot mode (powers down between conversions) - // - 128 samples per second (8ms conversion time) - // - 2/3 gain +/- 6.144V range (limited to VDD +0.3V max) - // - TI1015 (12 bit) - // - single-shot mode (powers down between conversions) - // - 1600 samples per second (625µs conversion time) - // - 2/3 gain +/- 6.144V range (limited to VDD +0.3V max) - - ads.setGain(_PGA_gain); - // Begin ADC - ads.begin(_i2cAddress); - - // Print out the calibration curve - MS_DBG(F(" Input calibration Curve:"), _volt_std, F("V at"), _conc_std, - F(". "), _volt_blank, F("V blank.")); - - // Read Analog to Digital Converter (ADC) - // Taking this reading includes the 8ms conversion delay. - // Measure the voltage differential across the two voltage pins - switch (_adsDiffMux) { - case DIFF_MUX_0_1: { - adcCounts = ads.readADC_Differential_0_1(); - break; - } - case DIFF_MUX_0_3: { - adcCounts = ads.readADC_Differential_0_3(); - break; - } - case DIFF_MUX_1_3: { - adcCounts = ads.readADC_Differential_1_3(); - break; - } - case DIFF_MUX_2_3: { - adcCounts = ads.readADC_Differential_2_3(); - break; - } + // ADS Library default settings: + // - TI1115 (16 bit) + // - single-shot mode (powers down between conversions) + // - 128 samples per second (8ms conversion time) + // - 2/3 gain +/- 6.144V range (limited to VDD +0.3V max) + // - TI1015 (12 bit) + // - single-shot mode (powers down between conversions) + // - 1600 samples per second (625µs conversion time) + // - 2/3 gain +/- 6.144V range (limited to VDD +0.3V max) + + ads.setGain(_PGA_gain); + // Begin ADC + ads.begin(_i2cAddress); + + // Print out the calibration curve + MS_DBG(F(" Input calibration Curve:"), _volt_std, F("V at"), _conc_std, + F(". "), _volt_blank, F("V blank.")); + + // Read Analog to Digital Converter (ADC) + // Taking this reading includes the 8ms conversion delay. + // Measure the voltage differential across the two voltage pins + switch (_adsDiffMux) { + case DIFF_MUX_0_1: { + adcCounts = ads.readADC_Differential_0_1(); + break; + } + case DIFF_MUX_0_3: { + adcCounts = ads.readADC_Differential_0_3(); + break; + } + case DIFF_MUX_1_3: { + adcCounts = ads.readADC_Differential_1_3(); + break; } - // Convert ADC counts value to voltage (V) - adcVoltage = ads.computeVolts(adcCounts); - MS_DBG(F(" ads.readADC_Differential("), _adsDiffMux, F("):"), - String(adcVoltage, 3)); - - // The ADS1X15 outputs a max value corresponding to Vcc + 0.3V - if (adcVoltage < 5.3 && adcVoltage > -0.3) { - // Skip results out of range - // Apply the unique calibration curve for the given sensor - calibResult = (_conc_std / (_volt_std - _volt_blank)) * - (adcVoltage - _volt_blank); - MS_DBG(F(" calibResult:"), String(calibResult, 3)); - } else { // set invalid voltages back to -9999 - adcVoltage = -9999; + case DIFF_MUX_2_3: { + adcCounts = ads.readADC_Differential_2_3(); + break; } - } else { - MS_DBG(getSensorNameAndLocation(), F("is not currently measuring!")); } + // Convert ADC counts value to voltage (V) + adcVoltage = ads.computeVolts(adcCounts); + MS_DBG(F(" ads.readADC_Differential("), _adsDiffMux, F("):"), + String(adcVoltage, 3)); - verifyAndAddMeasurementResult(TURBIDITY_PLUS_VAR_NUM, calibResult); - verifyAndAddMeasurementResult(TURBIDITY_PLUS_VOLTAGE_VAR_NUM, adcVoltage); - - // Record the time that the measurement was completed - _millisMeasurementCompleted = millis(); - // Unset the time stamp for the beginning of this measurement - _millisMeasurementRequested = 0; - // Unset the status bits for a measurement request (bits 5 & 6) - clearStatusBits(MEASUREMENT_ATTEMPTED, MEASUREMENT_SUCCESSFUL); - // Bump the number of attempted retries - _retryAttemptsMade++; - + // The ADS1X15 outputs a max value corresponding to Vcc + 0.3V if (adcVoltage < 5.3 && adcVoltage > -0.3) { - // Bump the number of successful measurements - _measurementAttemptsCompleted++; - return true; - } else if (_retryAttemptsMade >= _allowedMeasurementRetries) { - // Bump the number of completed measurement attempts - we've failed but - // exceeded retries - _measurementAttemptsCompleted++; - return false; - } else { - return false; + // Skip results out of range + // Apply the unique calibration curve for the given sensor + calibResult = (_conc_std / (_volt_std - _volt_blank)) * + (adcVoltage - _volt_blank); + MS_DBG(F(" calibResult:"), String(calibResult, 3)); + verifyAndAddMeasurementResult(TURBIDITY_PLUS_VAR_NUM, calibResult); + verifyAndAddMeasurementResult(TURBIDITY_PLUS_VOLTAGE_VAR_NUM, + adcVoltage); + success = true; } + + // Return success value when finished + return bumpMeasurementAttemptCount(success); } diff --git a/src/sensors/YosemitechParent.cpp b/src/sensors/YosemitechParent.cpp index 1f11bfc65..7be425f6d 100644 --- a/src/sensors/YosemitechParent.cpp +++ b/src/sensors/YosemitechParent.cpp @@ -170,45 +170,40 @@ bool YosemitechParent::sleep(void) { bool YosemitechParent::addSingleMeasurementResult(void) { - bool success = false; + // Immediately quit if the measurement was not successfully started + if (!getStatusBit(MEASUREMENT_SUCCESSFUL)) { + return bumpMeasurementAttemptCount(false); + } - // Check a measurement was *successfully* started (status bit 6 set) - // Only go on to get a result if it was - if (getStatusBit(MEASUREMENT_SUCCESSFUL)) { - switch (_model) { - case Y4000: { - // Initialize float variables - float DOmgL = -9999; - float Turbidity = -9999; - float Cond = -9999; - float pH = -9999; - float Temp = -9999; - float ORP = -9999; - float Chlorophyll = -9999; - float BGA = -9999; - - // Get Values - MS_DBG(F("Get Values from"), getSensorNameAndLocation()); - success = _ysensor.getValues(DOmgL, Turbidity, Cond, pH, Temp, - ORP, Chlorophyll, BGA); - - // Fix not-a-number values - if (!success || isnan(DOmgL)) DOmgL = -9999; - if (!success || isnan(Turbidity)) Turbidity = -9999; - if (!success || isnan(Cond)) Cond = -9999; - if (!success || isnan(pH)) pH = -9999; - if (!success || isnan(Temp)) Temp = -9999; - if (!success || isnan(ORP)) ORP = -9999; - if (!success || isnan(Chlorophyll)) Chlorophyll = -9999; - if (!success || isnan(BGA)) BGA = -9999; - - // For conductivity, convert mS/cm to µS/cm - if (Cond != -9999) Cond *= 1000; - - MS_DBG(F(" "), _ysensor.getParameter()); - MS_DBG(F(" "), DOmgL, ',', Turbidity, ',', Cond, ',', pH, - ',', Temp, ',', ORP, ',', Chlorophyll, ',', BGA); + bool success = false; + switch (_model) { + case Y4000: { + // Initialize float variables + float DOmgL = -9999; + float Turbidity = -9999; + float Cond = -9999; + float pH = -9999; + float Temp = -9999; + float ORP = -9999; + float Chlorophyll = -9999; + float BGA = -9999; + + // Get Values + MS_DBG(F("Get Values from"), getSensorNameAndLocation()); + success = _ysensor.getValues(DOmgL, Turbidity, Cond, pH, Temp, ORP, + Chlorophyll, BGA); + + // For conductivity, convert mS/cm to µS/cm + if (success && !isnan(Cond)) Cond *= 1000; + + MS_DBG(F(" "), _ysensor.getParameter()); + MS_DBG(F(" "), DOmgL, ',', Turbidity, ',', Cond, ',', pH, ',', + Temp, ',', ORP, ',', Chlorophyll, ',', BGA); + + // NOTE: Success depends on getting values, not on them being valid + // numbers! + if (success) { // Put values into the array verifyAndAddMeasurementResult(0, DOmgL); verifyAndAddMeasurementResult(1, Turbidity); @@ -218,65 +213,43 @@ bool YosemitechParent::addSingleMeasurementResult(void) { verifyAndAddMeasurementResult(5, ORP); verifyAndAddMeasurementResult(6, Chlorophyll); verifyAndAddMeasurementResult(7, BGA); - - break; } - default: { - // Initialize float variables - float parmValue = -9999; - float tempValue = -9999; - float thirdValue = -9999; + break; + } + default: { + // Initialize float variables + float parmValue = -9999; + float tempValue = -9999; + float thirdValue = -9999; - // Get Values - MS_DBG(F("Get Values from"), getSensorNameAndLocation()); - success = _ysensor.getValues(parmValue, tempValue, thirdValue); + // Get Values + MS_DBG(F("Get Values from"), getSensorNameAndLocation()); + success = _ysensor.getValues(parmValue, tempValue, thirdValue); - // Fix not-a-number values - if (!success || isnan(parmValue)) parmValue = -9999; - if (!success || isnan(tempValue)) tempValue = -9999; - if (!success || isnan(thirdValue)) thirdValue = -9999; + // For conductivity, convert mS/cm to µS/cm + if (_model == Y520 && !isnan(parmValue)) parmValue *= 1000; - // For conductivity, convert mS/cm to µS/cm - if (_model == Y520 && parmValue != -9999) parmValue *= 1000; + MS_DBG(F(" "), _ysensor.getParameter(), ':', parmValue); + MS_DBG(F(" Temp:"), tempValue); - MS_DBG(F(" "), _ysensor.getParameter(), ':', parmValue); - MS_DBG(F(" Temp:"), tempValue); + // Not all sensors return a third value + if (_numReturnedValues > 2) { MS_DBG(F(" Third:"), thirdValue); } - // Not all sensors return a third value - if (_numReturnedValues > 2) { - MS_DBG(F(" Third:"), thirdValue); - } + // NOTE: Success depends on getting values, not on them being valid + // numbers! + if (success) { // Put values into the array verifyAndAddMeasurementResult(0, parmValue); verifyAndAddMeasurementResult(1, tempValue); verifyAndAddMeasurementResult(2, thirdValue); } + break; } - } else { - MS_DBG(getSensorNameAndLocation(), F("is not currently measuring!")); } - // Record the time that the measurement was completed - _millisMeasurementCompleted = millis(); - // Unset the time stamp for the beginning of this measurement - _millisMeasurementRequested = 0; - // Unset the status bits for a measurement request (bits 5 & 6) - clearStatusBits(MEASUREMENT_ATTEMPTED, MEASUREMENT_SUCCESSFUL); - // Bump the number of attempted retries - _retryAttemptsMade++; - - if (success) { - // Bump the number of completed measurement attempts - _measurementAttemptsCompleted++; - } else if (_retryAttemptsMade >= _allowedMeasurementRetries) { - // Bump the number of completed measurement attempts - we've failed but - // exceeded retries - _measurementAttemptsCompleted++; - } - - // Return true when finished - return success; + // Return success value when finished + return bumpMeasurementAttemptCount(success); } // cSpell:ignore ysensor From 8cd6342e64ea1d6e91ae3cdffc51f0f0ca4a0467 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Fri, 26 Sep 2025 16:43:07 -0400 Subject: [PATCH 033/533] Remove unused var Signed-off-by: Sara Damiano --- continuous_integration/dependencies.json | 4 ++-- src/sensors/AOSongAM2315.cpp | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/continuous_integration/dependencies.json b/continuous_integration/dependencies.json index fbfe1b9b4..253bb11e3 100644 --- a/continuous_integration/dependencies.json +++ b/continuous_integration/dependencies.json @@ -1,5 +1,5 @@ { - "action_cache_version": 39, + "action_cache_version": 40, "dependencies": [ { "name": "EnviroDIY_DS3231", @@ -362,7 +362,7 @@ "name": "ANBSensorsModbus", "owner": "envirodiy", "url": "https://github.com/EnviroDIY/ANBSensorsModbus", - "version": "~0.2.5", + "version": "~0.2.6", "note": "A library for communicating with pH sensors manufactured by ANB Sensors using Modbus.", "authors": [ "Sara Damiano" diff --git a/src/sensors/AOSongAM2315.cpp b/src/sensors/AOSongAM2315.cpp index 3c03ef657..ba77fc5e1 100644 --- a/src/sensors/AOSongAM2315.cpp +++ b/src/sensors/AOSongAM2315.cpp @@ -59,7 +59,6 @@ bool AOSongAM2315::addSingleMeasurementResult(void) { bool success = false; float temp_val = -9999; float humid_val = -9999; - bool ret_val = false; MS_DBG(getSensorNameAndLocation(), F("is reporting:")); From b0a49736f2a205e45b8900a11773be4fefb7ad43 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Fri, 26 Sep 2025 18:06:37 -0400 Subject: [PATCH 034/533] bump all of the modbus stuff Signed-off-by: Sara Damiano --- library.json | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/library.json b/library.json index 8540e2fcc..3b60a2372 100644 --- a/library.json +++ b/library.json @@ -299,7 +299,7 @@ "owner": "envirodiy", "library id": "1824", "url": "https://github.com/EnviroDIY/SensorModbusMaster", - "version": "~1.6.5", + "version": "~1.6.6", "note": "EnviroDIY SensorModbusMaster - Arduino library for communicating via modbus with the Arduino acting as the modbus master.", "authors": ["Sara Damiano"], "frameworks": "arduino" @@ -309,7 +309,7 @@ "owner": "envirodiy", "library id": "5439", "url": "https://github.com/EnviroDIY/KellerModbus", - "version": "~0.2.5", + "version": "~0.2.6", "note": "Arduino library for communication with Keller pressure and water level sensors via Modbus.", "authors": ["Anthony Aufdenkampe"] }, @@ -318,7 +318,7 @@ "owner": "envirodiy", "library id": "2078", "url": "https://github.com/EnviroDIY/YosemitechModbus", - "version": "~0.5.2", + "version": "~0.5.3", "note": "Arduino library for communication with Yosemitech sensors via Modbus.", "authors": ["Sara Damiano", "Anthony Aufdenkampe"], "frameworks": "arduino" @@ -327,7 +327,7 @@ "name": "GroPointModbus", "owner": "envirodiy", "url": "https://github.com/EnviroDIY/GroPointModbus", - "version": "~0.1.3", + "version": "~0.1.4", "note": "A library to use an Arduino as a master to control and communicate via modbus with GroPoint soil moisture sensors.", "authors": ["Anthony Aufdenkampe"], "frameworks": "arduino" @@ -355,7 +355,7 @@ "name": "ANBSensorsModbus", "owner": "envirodiy", "url": "https://github.com/EnviroDIY/ANBSensorsModbus", - "version": "~0.2.5", + "version": "~0.2.6", "note": "A library for communicating with pH sensors manufactured by ANB Sensors using Modbus.", "authors": ["Sara Damiano"], "frameworks": "arduino" From 570f7168d83b94232afb9a75355c84bad80506e5 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Mon, 29 Sep 2025 13:42:59 -0400 Subject: [PATCH 035/533] Keep the watchdog enabled until the last instant on sleep Signed-off-by: Sara Damiano --- src/LoggerBase.cpp | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/src/LoggerBase.cpp b/src/LoggerBase.cpp index a1e1e6b01..39d751382 100644 --- a/src/LoggerBase.cpp +++ b/src/LoggerBase.cpp @@ -820,10 +820,6 @@ void Logger::systemSleep(void) { digitalWrite(SCL, LOW); #endif - // Disable the watch-dog timer - MS_DEEP_DBG(F("Disabling the watchdog")); - extendedWatchDog::disableWatchDog(); - #if defined(ARDUINO_ARCH_SAMD) // force all pins to minimum power draw levels (tri-state) @@ -978,6 +974,12 @@ void Logger::systemSleep(void) { SCB->SCR |= SCB_SCR_SLEEPDEEP_Msk; #endif + // Disable the watch-dog timer - the very last thing before sleeping just in + // case anything else goes wrong in between. + // NOTE: Because this is last, we can't print a message after disabling the + // watch-dog. + extendedWatchDog::disableWatchDog(); + __DSB(); // Data sync barrier - to ensure outgoing memory accesses // complete __WFI(); // wait for interrupt @@ -1059,6 +1061,12 @@ void Logger::systemSleep(void) { MS_2ND_OUTPUT.flush(); #endif + // Disable the watch-dog timer - the very last thing before sleeping just in + // case anything else goes wrong in between. + // NOTE: Because this is last, we can't print a message after disabling the + // watch-dog. + extendedWatchDog::disableWatchDog(); + // Actually put the processor into sleep mode. // This must happen after the SE bit is set. sleep_cpu(); @@ -1070,10 +1078,13 @@ void Logger::systemSleep(void) { // --------------------------------------------------------------------- // -- The portion below this happens on wake up, after any wake ISR's -- + // Re-enable the watch-dog timer right away! + extendedWatchDog::enableWatchDog(); + #if defined(ENVIRODIY_STONEFLY_M4) pinMode(LED_BUILTIN, OUTPUT); digitalWrite(LED_BUILTIN, - HIGH); // turn off the built-in LED if using a Stonefly M4 + HIGH); // turn on the built-in LED if using a Stonefly M4 #endif #if defined(ARDUINO_ARCH_SAMD) @@ -1127,10 +1138,6 @@ void Logger::systemSleep(void) { #endif - // Re-enable the watch-dog timer - MS_DEEP_DBG(F("Re-enabling the watchdog")); - extendedWatchDog::enableWatchDog(); - // Re-start the I2C interface MS_DEEP_DBG(F("Restarting I2C")); // The Wire.begin() function will set the propper pin modes for SCL and SDA From 50801b25edb900dc29f0116e1d753a7188de53f7 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Mon, 29 Sep 2025 13:44:29 -0400 Subject: [PATCH 036/533] Simplify ANB pH timing checks Signed-off-by: Sara Damiano --- src/sensors/ANBpH.cpp | 87 +++++++++++++++++++------------------------ src/sensors/ANBpH.h | 43 ++++----------------- 2 files changed, 46 insertions(+), 84 deletions(-) diff --git a/src/sensors/ANBpH.cpp b/src/sensors/ANBpH.cpp index dacc17bde..69404ff79 100644 --- a/src/sensors/ANBpH.cpp +++ b/src/sensors/ANBpH.cpp @@ -15,7 +15,7 @@ ANBpH::ANBpH(byte modbusAddress, Stream* stream, int8_t powerPin, int8_t powerPin2, int8_t enablePin, uint8_t measurementsToAverage) : Sensor("ANBpHSensor", ANB_PH_NUM_VARIABLES, ANB_PH_WARM_UP_TIME_MS, - ANB_PH_STABILIZATION_TIME_MS, ANB_PH_1ST_VALUE_HIGH_SALT, powerPin, + ANB_PH_STABILIZATION_TIME_MS, ANB_PH_2ND_VALUE_LOW_SALT, powerPin, -1, measurementsToAverage, ANB_PH_INC_CALC_VARIABLES), _anb_sensor(modbusAddress, stream, enablePin), _stream(stream), @@ -29,7 +29,7 @@ ANBpH::ANBpH(byte modbusAddress, Stream* stream, int8_t powerPin, ANBpH::ANBpH(byte modbusAddress, Stream& stream, int8_t powerPin, int8_t powerPin2, int8_t enablePin, uint8_t measurementsToAverage) : Sensor("ANBpHSensor", ANB_PH_NUM_VARIABLES, ANB_PH_WARM_UP_TIME_MS, - ANB_PH_STABILIZATION_TIME_MS, ANB_PH_1ST_VALUE_HIGH_SALT, powerPin, + ANB_PH_STABILIZATION_TIME_MS, ANB_PH_2ND_VALUE_LOW_SALT, powerPin, -1, measurementsToAverage, ANB_PH_INC_CALC_VARIABLES), _anb_sensor(modbusAddress, stream, enablePin), _modbusAddress(modbusAddress), @@ -156,10 +156,7 @@ bool ANBpH::setup(void) { retVal &= intervalSet; // Set Sensor Salinity Mode - MS_DBG(F("Set sensor salinity mode...")); - bool salinitySet = _anb_sensor.setSalinityMode(_salinityMode); - MS_DBG(F("..."), salinitySet ? F("success") : F("failed")); - retVal &= salinitySet; + retVal &= setSalinityMode(_salinityMode); // Set Immersion Rule MS_DBG(F("Set sensor immersion rule to"), @@ -234,6 +231,7 @@ bool ANBpH::wake(void) { MS_DEEP_DBG(getSensorNameAndLocation(), F("started scanning.")); // Update the time that a measurement was requested _millisSensorActivated = millis(); + _lastModbusCommandTime = 0; } else { // Set the status error bit (bit 7) setStatusBit(ERROR_OCCURRED); @@ -485,28 +483,6 @@ bool ANBpH::isStable(bool debug) { } } - -// The minimum time before we start checking for a result depends on whether -// the immersion sensor is enabled or not and on the power style. -// If the immersion sensor is enabled and it's the first measurement after -// applying power, we wait the minimum time that it would return a not-immersed -// error to start querying because it will return an immersion error much faster -// than the full sensing time. If the immersion sensor is not enabled or it's -// not the first measurement after power-up, we wait the minimum time for a -// measurement to be ready based on the power style. -uint32_t ANBpH::getStartImmersionErrorWindow(void) { - if (!_immersionSensorEnabled || _powerPin < 0 || _retryAttemptsMade > 0) { - return getEndMeasurementWindow(); - } - return ANB_PH_IMMERSION_ERROR; -} -uint32_t ANBpH::getEndImmersionErrorWindow(void) { - if (!_immersionSensorEnabled || _powerPin < 0 || _retryAttemptsMade > 0) { - return getEndMeasurementWindow(); - } - return ANB_PH_IMMERSION_ERROR_MAX; -} - uint32_t ANBpH::getStartMeasurementWindow(void) { if (_powerPin >= 0 && _retryAttemptsMade == 0) { if (_salinityMode == ANBSalinityMode::HIGH_SALINITY) { @@ -515,11 +491,7 @@ uint32_t ANBpH::getStartMeasurementWindow(void) { return ANB_PH_1ST_VALUE_LOW_SALT; } } else { - if (_salinityMode == ANBSalinityMode::HIGH_SALINITY) { - return ANB_PH_2ND_VALUE_HIGH_SALT; - } else { - return ANB_PH_2ND_VALUE_LOW_SALT; - } + return 0; } } @@ -536,9 +508,9 @@ uint32_t ANBpH::getEndMeasurementWindow(void) { } } else { if (_salinityMode == ANBSalinityMode::HIGH_SALINITY) { - return ANB_PH_2ND_VALUE_HIGH_SALT_MAX; + return ANB_PH_2ND_VALUE_HIGH_SALT; } else { - return ANB_PH_2ND_VALUE_LOW_SALT_MAX; + return ANB_PH_2ND_VALUE_LOW_SALT; } } } @@ -560,6 +532,25 @@ bool ANBpH::isMeasurementComplete(bool debug) { } uint32_t elapsed_since_meas_start = millis() - _millisMeasurementRequested; + + // After the first measurement, the sensor will always report that a + // measurement is ready, but a new value will not be available for at + // least 10.5 (high salinity) or 14 (low salinity) seconds. + if (_retryAttemptsMade > 0) { + if (elapsed_since_meas_start > _measurementTime_ms) { + if (debug) { + MS_DBG(F("It's been"), elapsed_since_meas_start, + F("ms, and measurement by"), getSensorNameAndLocation(), + F("should be complete!")); + } + return true; + } else { + // If the sensor is measuring but the time hasn't passed, we still + // need to wait + return false; + } + } + // If we're past the maximum wait time, the measurement failed, but our wait // is over if (elapsed_since_meas_start > getEndMeasurementWindow()) { @@ -568,24 +559,12 @@ bool ANBpH::isMeasurementComplete(bool debug) { F("timed out waiting for a measurement to complete.")); return true; // timeout } - // If we haven't gotten to the minimum response time, we need to wait - if (elapsed_since_meas_start < getStartImmersionErrorWindow()) { - return false; - } bool is_ready = false; - // Check every half second if we're in the window where the immersion - // sensor might return a not-immersed error - if (elapsed_since_meas_start > getStartImmersionErrorWindow() && - elapsed_since_meas_start <= getEndImmersionErrorWindow()) { - is_ready = isSensorReady(&anbSensor::isMeasurementComplete, 1000L, - _millisMeasurementRequested); - } // Since the sensor takes so very long to measure when it's power cycled, if // we know it's going to be a while, we drop the query frequency to once // every 15 seconds because there's no point in asking more often than that. - if (elapsed_since_meas_start > getEndImmersionErrorWindow() && - elapsed_since_meas_start <= getStartMeasurementWindow()) { + if (elapsed_since_meas_start <= getStartMeasurementWindow()) { is_ready = isSensorReady(&anbSensor::isMeasurementComplete, 15000L, _millisMeasurementRequested); } @@ -606,8 +585,18 @@ bool ANBpH::isMeasurementComplete(bool debug) { bool ANBpH::setSalinityMode(ANBSalinityMode newSalinityMode) { + MS_DBG(F("Set sensor salinity mode...")); + bool salinitySet = _anb_sensor.setSalinityMode(newSalinityMode); + MS_DBG(F("..."), salinitySet ? F("success") : F("failed")); + if (!salinitySet) { return false; } + // If we succeeded in setting the salinity mode, update the local copy and + // the measurement time _salinityMode = newSalinityMode; - return _anb_sensor.setSalinityMode(newSalinityMode); + if (_salinityMode == ANBSalinityMode::HIGH_SALINITY) { + _measurementTime_ms = ANB_PH_2ND_VALUE_HIGH_SALT; + } else { + _measurementTime_ms = ANB_PH_2ND_VALUE_LOW_SALT; + } } bool ANBpH::enableImmersionSensor(bool enable) { diff --git a/src/sensors/ANBpH.h b/src/sensors/ANBpH.h index f9fd30e65..2cbd85c6b 100644 --- a/src/sensors/ANBpH.h +++ b/src/sensors/ANBpH.h @@ -153,26 +153,19 @@ /// @brief The maximum time to wait for ready to measure. #define ANB_PH_STABILIZATION_TIME_MAX 5000L -/// @brief The minimum time after a new scan after power-up before a failure -/// response is returned when the immersion sensor is not immersed. -/// This is a guess based on testing. -/// @note This only applies when it is the first measurement after power-up and -/// the immersion sensor is enabled! -#define ANB_PH_IMMERSION_ERROR 6000L -/// @brief The minimum time after a new scan after power-up before a failure -/// response is returned when the immersion sensor is not immersed. -/// This is a guess based on testing. -#define ANB_PH_IMMERSION_ERROR_MAX 12000L - /// @brief The minimum time for the first value in high salinity (documented min /// time of 129s). +/// @note If the immersion sensor is enabled and the sensor is not immersed, a +/// failure response may be returned sooner #define ANB_PH_1ST_VALUE_HIGH_SALT 120000L /// @brief The maximum time for the first value in high salinity (documented max /// time of 238s for a long interval delay + 10s). #define ANB_PH_1ST_VALUE_HIGH_SALT_MAX 248000L /// @brief The minimum time for the first value in low salinity (documented min /// time is 184s, but I got responses at 160s). -#define ANB_PH_1ST_VALUE_LOW_SALT 155000L +/// @note If the immersion sensor is enabled and the sensor is not immersed, a +/// failure response may be returned sooner +#define ANB_PH_1ST_VALUE_LOW_SALT 159000L /// @brief The maximum time for the first value in low salinity (documented max /// time of 255s for a long interval delay + 10s). #define ANB_PH_1ST_VALUE_LOW_SALT_MAX 265000L @@ -182,18 +175,11 @@ /// @warning After the first reading, the sensor will *always* say the sensor is /// ready! But there will not be a **new** value available before this time. #define ANB_PH_2ND_VALUE_HIGH_SALT 10600L -/// @brief The maximum time to wait for the 2nd or subsequent values in high -/// salinity. -#define ANB_PH_2ND_VALUE_HIGH_SALT_MAX 15000L /// @brief The minimum time for the 2nd or subsequent values in low /// salinity (documented new output time of 14s). /// @warning After the first reading, the sensor will *always* say the sensor is /// ready! But there will not be a **new** value available before this time. #define ANB_PH_2ND_VALUE_LOW_SALT 14100L -/// @brief The maximum time to wait for the 2nd or subsequent values in low -/// salinity. -#define ANB_PH_2ND_VALUE_LOW_SALT_MAX 18000L -/**@}*/ /** * @anchor sensor_anb_ph_ph @@ -473,6 +459,9 @@ /* clang-format off */ /** * @brief The Sensor sub-class for the [ANB pH sensors](@ref sensor_anb_ph) + * + * @note For the ANB pH sensor, the sensor::_measurementTime_ms is the time of the 2nd or subsequent reading. + * The time for the first reading after power on is variable and much longer. */ /* clang-format on */ class ANBpH : public Sensor { @@ -643,22 +632,6 @@ class ANBpH : public Sensor { uint32_t spacing = ANB_PH_MINIMUM_REQUEST_SPACING, uint32_t startTime = 0); - /** - * @brief Get the start of the estimated time window before an immersion - * error is returned based on power cycling and the immersion sensor - * enablement. * - * @return The start of the estimated time window before an immersion error - * is returned. - */ - uint32_t getStartImmersionErrorWindow(void); - /** - * @brief Get the end of the estimated time window before an immersion - * error is returned based on power cycling and the immersion sensor - * enablement. - * @return The end of the estimated time window before an immersion error - * is returned. - */ - uint32_t getEndImmersionErrorWindow(void); /** * @brief Get the start of the estimated time window for a measurement to * complete based on the sensor's current configuration. From 9e11d8d54b55d399884181776b0dc6dc30e52348 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Mon, 29 Sep 2025 13:51:22 -0400 Subject: [PATCH 037/533] Corrected case of setInitialShortIntervals function. I hope no one was using it. Signed-off-by: Sara Damiano --- examples/menu_a_la_carte/menu_a_la_carte.ino | 2 +- src/LoggerBase.cpp | 2 +- src/LoggerBase.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/menu_a_la_carte/menu_a_la_carte.ino b/examples/menu_a_la_carte/menu_a_la_carte.ino index f70c7ea9a..d4ce028ec 100644 --- a/examples/menu_a_la_carte/menu_a_la_carte.ino +++ b/examples/menu_a_la_carte/menu_a_la_carte.ino @@ -3694,7 +3694,7 @@ void setup() { PRINTOUT(F("Setting logging interval to"), loggingInterval, F("minutes")); dataLogger.setLoggingInterval(loggingInterval); PRINTOUT(F("Setting number of initial 1 minute intervals to 10")); - dataLogger.setinitialShortIntervals(10); + dataLogger.setInitialShortIntervals(10); // Attach the variable array to the logger PRINTOUT(F("Attaching the variable array")); dataLogger.setVariableArray(&varArray); diff --git a/src/LoggerBase.cpp b/src/LoggerBase.cpp index 39d751382..d293ab64c 100644 --- a/src/LoggerBase.cpp +++ b/src/LoggerBase.cpp @@ -198,7 +198,7 @@ void Logger::setLoggingInterval(int16_t loggingIntervalMinutes) { // Sets the number of initial short intervals -void Logger::setinitialShortIntervals(int16_t initialShortIntervals) { +void Logger::setInitialShortIntervals(int16_t initialShortIntervals) { _remainingShortIntervals = initialShortIntervals; } diff --git a/src/LoggerBase.h b/src/LoggerBase.h index 0222b9d53..17d65dac4 100644 --- a/src/LoggerBase.h +++ b/src/LoggerBase.h @@ -232,7 +232,7 @@ class Logger { * regardless of the programmed interval. Useful for fast field * verification. */ - void setinitialShortIntervals(int16_t initialShortIntervals); + void setInitialShortIntervals(int16_t initialShortIntervals); /** * @brief Get the number of 1-minute intervals at the start before logging * on the regular logging interval From 888a7e6680e214b4debe539950db7034a337bd0d Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Mon, 29 Sep 2025 13:54:17 -0400 Subject: [PATCH 038/533] Fix doxygen grouping commands Signed-off-by: Sara Damiano --- src/sensors/ANBpH.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/sensors/ANBpH.h b/src/sensors/ANBpH.h index 2cbd85c6b..147f4f4d7 100644 --- a/src/sensors/ANBpH.h +++ b/src/sensors/ANBpH.h @@ -180,6 +180,7 @@ /// @warning After the first reading, the sensor will *always* say the sensor is /// ready! But there will not be a **new** value available before this time. #define ANB_PH_2ND_VALUE_LOW_SALT 14100L +/**@}*/ /** * @anchor sensor_anb_ph_ph From 446d112efd9b0b3d4bd7f68e886726b2be558d07 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Mon, 29 Sep 2025 14:32:45 -0400 Subject: [PATCH 039/533] Add to-do; update changelog Signed-off-by: Sara Damiano --- ChangeLog.md | 33 +++++++++++++++++++++++++++++++++ src/SensorBase.h | 4 ++++ 2 files changed, 37 insertions(+) diff --git a/ChangeLog.md b/ChangeLog.md index 1bca0eea0..3f7c872cc 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -12,12 +12,45 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm ### Changed +- **BREAKING** Changed capitalization of `setInitialShortIntervals(#)` function + - Previously the 'i' of initial was not capitalized. +- Made the enabling and disabling of the watch dog the very first and very last steps of sleep to keep the watchdog enabled through the whole getting ready for bed and waking up process. +- **ANB pH** Changed timing slightly and simplified timing logic. +- Bumped several dependencies - including crucial bug fixes to SensorModbusMaster. +- Re-wrote most of the logic for looping variables within the complete update function of the VariableArray. +- Simplified the `addSingleMeasurementResult()` function of all sensors to use an internal function to help set the bits and timing values and to quit sooner if the measurement was not started successfully. + - The `verifyAndAddMeasurementResult()` is now consistently used in all sensors and is only called when the sensor successfully returned a measurement response. + - Also removed all places where sensor values were re-set to -9999 after a measurement failed and then that -9999 was sent to the `verifyAndAddMeasurementResult()` function. +These resets were an awkward attempt to deal with bad values before feeding any bad values to the `verifyAndAddMeasurementResult()` function which was previously always called even if the sensor returned junk. +This was probably a hold-over from incorrect implementation and calling of the clearValues function deep in the library history. + - Also made the return from the `addSingleMeasurementResult()` function consistently false for a bad sensor response and true for a good one - where it's possible to tell the difference. +- The Sensor::clearValues() function now resets all timing and bits for the sensor in addition to setting all values in the value array to -9999.. + ### Added +- **Added support for retrying measurements for all sensors**. + - Each sensor now supports a number of possible retry attempts for when the sensor returns a bad or no value. +The number of retry attempts can be set using the `setAllowedMeasurementRetries(uint8_t)` function. + - The number of retries is independent of the number of measurements to average. +A retry is performed when a sensor doesn't report a value or reports an error value. +If multiple retries are needed, only the result of the final (successful) retry is stored. +When multiple 'measurements to average' are requested, the values of each successful measurement is stored and averaged. +Measurements that return bad values even after retries are still not included in averaging. + - The default number of retry attempts for most sensors is 1. +- Made a secondary power pin a property of all sensors. +- Added internal function to run the steps of setting the timing and bits after a measurement. + ### Removed +- Remove the unused `_maxSamplesToAverage` parameter of the VariableArray and the `countMaxToAverage()` function which set the parameter. +- Removed unnecessary copy doc calls for inherited functions and properties. +- Removed all overrides of the powerUp and powerDown functions that are no-longer needed since all sensors have two power pins built in. + ### Fixed +- Fixed major bug where sensors with two power pins where either was shared with another sensor may be turned off inappropriately when one of the other sensors was turned off. +- Correctly retry NIST sync on XBees which a not-sane timestamp is return. + *** ## [0.37.0] diff --git a/src/SensorBase.h b/src/SensorBase.h index 6ca6e35a4..82272669d 100644 --- a/src/SensorBase.h +++ b/src/SensorBase.h @@ -381,6 +381,8 @@ class Sensor { * * Generally this is done by setting the #_powerPin `HIGH`. Also sets the * #_millisPowerOn timestamp and updates the #_sensorStatus. + * + * @todo Universally support power pins that are active LOW. */ virtual void powerUp(void); /** @@ -389,6 +391,8 @@ class Sensor { * Generally this is done by setting the #_powerPin `LOW`. Also un-sets * the #_millisPowerOn timestamp (sets #_millisPowerOn to 0) and updates the * #_sensorStatus. + * + * @todo Universally support power pins that are inactive HIGH. */ virtual void powerDown(void); From 6bce4630460f774cd8964d20295d005c1b4f4cb0 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Mon, 29 Sep 2025 14:34:37 -0400 Subject: [PATCH 040/533] Fix missing return for ANBpH::setSalinityMode Signed-off-by: Sara Damiano --- src/sensors/ANBpH.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/sensors/ANBpH.cpp b/src/sensors/ANBpH.cpp index 69404ff79..86c198019 100644 --- a/src/sensors/ANBpH.cpp +++ b/src/sensors/ANBpH.cpp @@ -597,6 +597,7 @@ bool ANBpH::setSalinityMode(ANBSalinityMode newSalinityMode) { } else { _measurementTime_ms = ANB_PH_2ND_VALUE_LOW_SALT; } + return true; } bool ANBpH::enableImmersionSensor(bool enable) { From 71bd20180d051b2c99b2bfa092a4e42c010c64c3 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Mon, 29 Sep 2025 15:21:51 -0400 Subject: [PATCH 041/533] Reset retry attempts after success Signed-off-by: Sara Damiano --- src/SensorBase.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/SensorBase.cpp b/src/SensorBase.cpp index 0fd4c04f6..68fb20cad 100644 --- a/src/SensorBase.cpp +++ b/src/SensorBase.cpp @@ -647,10 +647,12 @@ bool Sensor::bumpMeasurementAttemptCount(bool wasSuccessful) { // Bump the number of attempted retries _retryAttemptsMade++; - if (wasSuccessful || _retryAttemptsMade >= _allowedMeasurementRetries) { + if (wasSuccessful || _retryAttemptsMade > _allowedMeasurementRetries) { // Bump the number of completed measurement attempts - we've succeeded // or failed but exceeded retries _measurementAttemptsCompleted++; + // Reset the number of retries made for the next measurement attempt + _retryAttemptsMade = 0; } return wasSuccessful; } From 1e9767a491e9b4f22d694da880c018c0d32869d6 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Mon, 29 Sep 2025 15:34:01 -0400 Subject: [PATCH 042/533] When debugging, give the USB time to reconnect Signed-off-by: Sara Damiano --- src/LoggerBase.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/LoggerBase.cpp b/src/LoggerBase.cpp index d293ab64c..cfb70ad4c 100644 --- a/src/LoggerBase.cpp +++ b/src/LoggerBase.cpp @@ -1113,6 +1113,13 @@ void Logger::systemSleep(void) { // ^^ Restarts the bus, including re-attaching the NVIC interrupts USBDevice.attach(); // ^^ USB->DEVICE.CTRLB.bit.DETACH = 0; enables USB interrupts +#if (defined(MS_LOGGERBASE_DEBUG_DEEP) || defined(MS_LOGGERBASE_DEBUG)) && \ + defined(SERIAL_PORT_USBVIRTUAL) + // if debugging is enabled, wait for the USB port to connect + uint32_t startSerialWait = millis(); + SERIAL_PORT_USBVIRTUAL.begin(0); // baud rate is ignored on USB + while (!SERIAL_PORT_USBVIRTUAL && (millis() - startSerialWait < 250)); +#endif #endif // USE_TINYUSB #endif // ARDUINO_ARCH_SAMD From ce92b9d1c68b537d5b5f28e7aa21730c9dd81a58 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Mon, 29 Sep 2025 15:36:38 -0400 Subject: [PATCH 043/533] Reattached note. Signed-off-by: Sara Damiano --- src/LoggerBase.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/LoggerBase.cpp b/src/LoggerBase.cpp index cfb70ad4c..e4a6e0f2d 100644 --- a/src/LoggerBase.cpp +++ b/src/LoggerBase.cpp @@ -1119,6 +1119,7 @@ void Logger::systemSleep(void) { uint32_t startSerialWait = millis(); SERIAL_PORT_USBVIRTUAL.begin(0); // baud rate is ignored on USB while (!SERIAL_PORT_USBVIRTUAL && (millis() - startSerialWait < 250)); + MS_DEEP_DBG(F("USBDevice reattached")); #endif #endif // USE_TINYUSB #endif // ARDUINO_ARCH_SAMD From 391b403cf2da3a5a2f7e7bdda7d5ecf961ce5c73 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Mon, 29 Sep 2025 17:40:04 -0400 Subject: [PATCH 044/533] Check that power pins are non zero in addition to shared (sharing -1 doesn't count). Signed-off-by: Sara Damiano --- src/VariableArray.cpp | 68 +++++++++++++++++++++++-------------------- 1 file changed, 37 insertions(+), 31 deletions(-) diff --git a/src/VariableArray.cpp b/src/VariableArray.cpp index 6ac956deb..8827df6a8 100644 --- a/src/VariableArray.cpp +++ b/src/VariableArray.cpp @@ -650,14 +650,16 @@ bool VariableArray::completeUpdate(void) { // share the pin bool canPowerDown = false; for (uint8_t k = 0; k < _sensorCount; k++) { - if ((sensorList[k]->getPowerPin() == - sensorList[i]->getPowerPin() || - sensorList[k]->getSecondaryPowerPin() == - sensorList[i]->getPowerPin() || - sensorList[k]->getPowerPin() == - sensorList[i]->getSecondaryPowerPin() || - sensorList[k]->getSecondaryPowerPin() == - sensorList[i]->getSecondaryPowerPin()) && + if (((sensorList[i]->getPowerPin() >= 0 && + (sensorList[i]->getPowerPin() == + sensorList[k]->getPowerPin() || + sensorList[i]->getPowerPin() == + sensorList[k]->getSecondaryPowerPin())) || + (sensorList[i]->getSecondaryPowerPin() >= 0 && + (sensorList[i]->getSecondaryPowerPin() == + sensorList[k]->getPowerPin() || + sensorList[i]->getSecondaryPowerPin() == + sensorList[k]->getSecondaryPowerPin()))) && (sensorList[k] ->getNumberCompleteMeasurementsAttempts() < sensorList[k]->getNumberMeasurementsToAverage())) { @@ -671,35 +673,41 @@ bool VariableArray::completeUpdate(void) { // need to take measurements } } + if (canPowerDown) { sensorList[i]->powerDown(); } +#if defined(MS_VARIABLEARRAY_DEBUG) if (canPowerDown) { MS_DBG( i, F("--->> All measurements from"), sName, F("are complete and no other sensors on the same " "power pin need to take measurements. " - "Powering down all sensors on pin"), - sensorList[i]->getPowerPin(), F("...")); + "Powered down all sensors on pin"), + sensorList[i]->getPowerPin(), F("or pin"), + sensorList[i]->getSecondaryPowerPin(), F("...")); } else { MS_DBG(i, F("--->> All measurements from"), sName, F("are complete but other sensors on the same " "power pin still need to take measurements. " "Leaving power on pin"), sensorList[i]->getPowerPin(), F("ON. <<---")); -#if defined(MS_VARIABLEARRAY_DEBUG_DEEP) for (uint8_t k = 0; k < _sensorCount; k++) { - if ((sensorList[k]->getPowerPin() == - sensorList[i]->getPowerPin() || - sensorList[k]->getSecondaryPowerPin() == - sensorList[i]->getPowerPin() || - sensorList[k]->getPowerPin() == - sensorList[i]->getSecondaryPowerPin() || - sensorList[k]->getSecondaryPowerPin() == - sensorList[i]->getSecondaryPowerPin()) && + if (((sensorList[i]->getPowerPin() >= 0 && + (sensorList[i]->getPowerPin() == + sensorList[k]->getPowerPin() || + sensorList[i]->getPowerPin() == + sensorList[k] + ->getSecondaryPowerPin())) || + (sensorList[i]->getSecondaryPowerPin() >= 0 && + (sensorList[i]->getSecondaryPowerPin() == + sensorList[k]->getPowerPin() || + sensorList[i]->getSecondaryPowerPin() == + sensorList[k] + ->getSecondaryPowerPin()))) && (sensorList[k] ->getNumberCompleteMeasurementsAttempts() < sensorList[k] ->getNumberMeasurementsToAverage())) { - MS_DEEP_DBG( - i, sName, F("shares a power pin with"), + MS_DBG( + sName, F("shares a power pin with"), sensorList[k]->getSensorNameAndLocation(), F("which still needs to take"), sensorList[k] @@ -707,21 +715,19 @@ bool VariableArray::completeUpdate(void) { sensorList[k] ->getNumberCompleteMeasurementsAttempts(), F("measurements.")); - MS_DEEP_DBG( - sName, F("pins are"), - sensorList[i]->getPowerPin(), F("and"), - sensorList[i]->getSecondaryPowerPin()); - MS_DEEP_DBG( + MS_DBG(sName, '(', i, ')', F("pins are"), + sensorList[i]->getPowerPin(), F("and"), + sensorList[i]->getSecondaryPowerPin()); + MS_DBG( sensorList[k]->getSensorNameAndLocation(), - F("pins are"), sensorList[i]->getPowerPin(), - F("and"), - sensorList[i]->getSecondaryPowerPin()); + '(', k, ')', F("pins are"), + sensorList[k]->getPowerPin(), F("and"), + sensorList[k]->getSecondaryPowerPin()); break; } } -#endif } - +#endif nSensorsCompleted++; // mark the whole sensor as done MS_DBG(F("*****---"), nSensorsCompleted, F("sensors now complete ---*****")); From 9135ad0035f4874f47a6755c8d7f112afa078c5b Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Tue, 30 Sep 2025 11:27:36 -0400 Subject: [PATCH 045/533] Fix checkPowerOn with two pins Signed-off-by: Sara Damiano --- src/SensorBase.cpp | 62 +++++++++++++++++++++++++++------------------- 1 file changed, 36 insertions(+), 26 deletions(-) diff --git a/src/SensorBase.cpp b/src/SensorBase.cpp index 68fb20cad..2aa549ba5 100644 --- a/src/SensorBase.cpp +++ b/src/SensorBase.cpp @@ -482,40 +482,50 @@ bool Sensor::checkPowerOn(bool debug) { MS_DBG(F("Checking power status: Power to"), getSensorNameAndLocation()); } - if (_powerPin >= 0 || _powerPin2 >= 0) { + if (_powerPin < 0 && _powerPin2 < 0) { + if (debug) { MS_DBG(F("is not controlled by this library.")); } + // Mark the power-on time, just in case it had not been marked + if (_millisPowerOn == 0) _millisPowerOn = millis(); + // Set the status bit for sensor power attempt (bit 1) and success (bit + // 2) + setStatusBits(POWER_ATTEMPTED, POWER_SUCCESSFUL); + return true; + } + bool pp1_off = false; + bool pp2_off = false; + if (_powerPin >= 0) { auto powerBitNumber = static_cast(log(digitalPinToBitMask(_powerPin)) / log(2)); + pp1_off = bitRead(*portInputRegister(digitalPinToPort(_powerPin)), + powerBitNumber) == LOW; + } + if (_powerPin2 >= 0) { auto powerBitNumber2 = static_cast(log(digitalPinToBitMask(_powerPin2)) / log(2)); + pp2_off = bitRead(*portInputRegister(digitalPinToPort(_powerPin2)), + powerBitNumber2) == LOW; + } - if (bitRead(*portInputRegister(digitalPinToPort(_powerPin)), - powerBitNumber) == LOW || - bitRead(*portInputRegister(digitalPinToPort(_powerPin2)), - powerBitNumber2) == LOW) { - if (debug) { MS_DBG(F("was off.")); } - // Reset time of power on, in-case it was set to a value - _millisPowerOn = 0; - // Unset the status bits for sensor power (bits 1 & 2), - // activation (bits 3 & 4), and measurement request (bits 5 & 6) - clearStatusBits(POWER_ATTEMPTED, POWER_SUCCESSFUL, WAKE_ATTEMPTED, - WAKE_SUCCESSFUL, MEASUREMENT_ATTEMPTED, - MEASUREMENT_SUCCESSFUL); - return false; - } else { - if (debug) { MS_DBG(" was on."); } - // Mark the power-on time, just in case it had not been marked - if (_millisPowerOn == 0) _millisPowerOn = millis(); - // Set the status bit for sensor power attempt (bit 1) and success - // (bit 2) - setStatusBits(POWER_ATTEMPTED, POWER_SUCCESSFUL); - return true; - } + if (pp1_off || pp2_off) { + if (debug) { MS_DBG(F("was off.")); } + // Unset time of power on, in-case it was set to a value + _millisPowerOn = 0; + // Unset the activation time + _millisSensorActivated = 0; + // Unset the measurement request time + _millisMeasurementRequested = 0; + // Unset the status bits for sensor power (bits 1 & 2), + // activation (bits 3 & 4), and measurement request (bits 5 & 6) + clearStatusBits(POWER_ATTEMPTED, POWER_SUCCESSFUL, WAKE_ATTEMPTED, + WAKE_SUCCESSFUL, MEASUREMENT_ATTEMPTED, + MEASUREMENT_SUCCESSFUL); + return false; } else { - if (debug) { MS_DBG(F("is not controlled by this library.")); } + if (debug) { MS_DBG(" was on."); } // Mark the power-on time, just in case it had not been marked if (_millisPowerOn == 0) _millisPowerOn = millis(); - // Set the status bit for sensor power attempt (bit 1) and success (bit - // 2) + // Set the status bit for sensor power attempt (bit 1) and success + // (bit 2) setStatusBits(POWER_ATTEMPTED, POWER_SUCCESSFUL); return true; } From ab279e6ee788d6fc7124bf0405bd8f8726a8ee1a Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Tue, 30 Sep 2025 15:21:40 -0400 Subject: [PATCH 046/533] Minor rearrangement of looping - check for failed wake before checking for stability Signed-off-by: Sara Damiano --- src/VariableArray.cpp | 340 +++++++++++++++++++++--------------------- 1 file changed, 167 insertions(+), 173 deletions(-) diff --git a/src/VariableArray.cpp b/src/VariableArray.cpp index 8827df6a8..7fd25d887 100644 --- a/src/VariableArray.cpp +++ b/src/VariableArray.cpp @@ -534,121 +534,161 @@ bool VariableArray::completeUpdate(void) { 1) + '.' + String(sensorList[i]->getNumberRetryAttemptsMade()); #endif - // Only do checks on sensors that still have measurements to finish - if (nReq > sensorList[i]->getNumberCompleteMeasurementsAttempts()) { - if (sensorList[i]->getStatusBit(Sensor::WAKE_ATTEMPTED) == - 0 // If no attempts yet made to wake the sensor up - && sensorList[i]->isWarmedUp( - deepDebugTiming) // and if it is already warmed up - ) { - MS_DBG(i, F("--->> Waking"), sName, F("...")); - - // Make a single attempt to wake the sensor after it is - // warmed up - bool sensorSuccess_wake = sensorList[i]->wake(); - success &= sensorSuccess_wake; - - if (sensorSuccess_wake) { - MS_DBG(F(" ... wake up succeeded. <<---"), i); - } else { - MS_DBG(F(" ... wake up failed! <<---"), i); - } - } + // Skip sensors that have already completed all their measurements + if (sensorList[i]->getNumberCompleteMeasurementsAttempts() >= + nReq) { + continue; + } - // If attempts were made to wake the sensor, but they failed - // then we're just bumping up the number of measurements to - // completion - if (sensorList[i]->getStatusBit(Sensor::WAKE_ATTEMPTED) == 1 && - sensorList[i]->getStatusBit(Sensor::WAKE_SUCCESSFUL) == 0) { - MS_DBG(i, F("--->>"), sName, - F("did not wake up! No measurements will be taken! " - "<<---"), - i); - // Set the number of measurements already equal to whatever - // total number requested to ensure the sensor is skipped in - // further loops. - sensorList[i]->_measurementAttemptsCompleted = - sensorList[i]->_measurementsToAverage; - } + // If attempts were made to wake the sensor, but they failed... + if (sensorList[i]->getStatusBit(Sensor::WAKE_ATTEMPTED) == 1 && + sensorList[i]->getStatusBit(Sensor::WAKE_SUCCESSFUL) == 0) { + MS_DBG(i, F("--->>"), sName, + F("did not wake up! No measurements will be taken! " + "<<---"), + i); + // Set the number of measurements already complete equal to + // whatever total number requested to ensure the sensor is + // skipped in further loops. NOTE: These are protected members + // of the sensor class; we can only access them because the + // variableArray class is a friend of the sensor class. + sensorList[i]->_measurementAttemptsCompleted = + sensorList[i]->_measurementsToAverage; + } - // If the sensor was successfully awoken/activated, but no - // measurement was either started or finished ... - if (sensorList[i]->getStatusBit(Sensor::WAKE_SUCCESSFUL) == 1 && - sensorList[i]->getStatusBit( - Sensor::MEASUREMENT_ATTEMPTED) == 0 && - sensorList[i]->getStatusBit( - Sensor::MEASUREMENT_SUCCESSFUL) == 0) { - // .. check if it's stable - if (sensorList[i]->isStable(deepDebugTiming)) { - MS_DBG(cycCount, F("--->> Starting reading on"), sName, - F("...")); + if (sensorList[i]->getStatusBit(Sensor::WAKE_ATTEMPTED) == + 0 // If no attempts yet made to wake the sensor up + && sensorList[i]->isWarmedUp( + deepDebugTiming) // and if it is already warmed up + ) { + MS_DBG(i, F("--->> Waking"), sName, F("...")); - bool sensorSuccess_start = - sensorList[i]->startSingleMeasurement(); - success &= sensorSuccess_start; + // Make a single attempt to wake the sensor after it is + // warmed up + bool sensorSuccess_wake = sensorList[i]->wake(); + success &= sensorSuccess_wake; - if (sensorSuccess_start) { - MS_DBG(F(" ... start reading succeeded. <<---"), - cycCount); - } else { - MS_DBG(F(" ... start reading failed! <<---"), - cycCount); - } - } + if (sensorSuccess_wake) { + MS_DBG(F(" ... wake up succeeded. <<---"), i); + } else { + MS_DBG(F(" ... wake up failed! <<---"), i); } + } - // if measurements have been started, whether or not - // successfully... - // We aren't checking if the measurement start was successful; - // isMeasurementComplete(deepDebugTiming) will do that. - // We want the addSingleMeasurementResult() function to fill in - // the -9999 results for a failed measurement. - if (sensorList[i]->getStatusBit( - Sensor::MEASUREMENT_ATTEMPTED) == 1) { - // If a measurement is finished, get the result and tick up - // the number of finished measurements. - if (sensorList[i]->isMeasurementComplete(deepDebugTiming)) { - // Get the value - MS_DBG(cycCount, - F("--->> Collected result of reading from"), - sName, F("...")); - - bool sensorSuccess_result = - sensorList[i]->addSingleMeasurementResult(); - success &= sensorSuccess_result; + // If the sensor was successfully awoken/activated, but no + // measurement was either started or finished ... + if (sensorList[i]->getStatusBit(Sensor::WAKE_SUCCESSFUL) == 1 && + sensorList[i]->getStatusBit(Sensor::MEASUREMENT_ATTEMPTED) == + 0 && + sensorList[i]->getStatusBit(Sensor::MEASUREMENT_SUCCESSFUL) == + 0) { + // .. check if it's stable + if (sensorList[i]->isStable(deepDebugTiming)) { + MS_DBG(cycCount, F("--->> Starting reading on"), sName, + F("...")); + + bool sensorSuccess_start = + sensorList[i]->startSingleMeasurement(); + success &= sensorSuccess_start; + + if (sensorSuccess_start) { + MS_DBG(F(" ... start reading succeeded. <<---"), + cycCount); + } else { + MS_DBG(F(" ... start reading failed! <<---"), + cycCount); + } + } + } - if (sensorSuccess_result) { - MS_DBG(F(" ... got measurement result. <<---"), - cycCount); - } else { - MS_DBG(F(" ... failed to get measurement result! " - "<<---"), - cycCount); - } + // if measurements have been started, whether or not + // successfully... + // We aren't checking if the measurement start was successful; + // isMeasurementComplete(deepDebugTiming) will do that. + if (sensorList[i]->getStatusBit(Sensor::MEASUREMENT_ATTEMPTED) == + 1) { + // If a measurement is finished, get the result and tick up + // the number of finished measurements. + if (sensorList[i]->isMeasurementComplete(deepDebugTiming)) { + // Get the value + MS_DBG(cycCount, + F("--->> Collected result of reading from"), sName, + F("...")); + + bool sensorSuccess_result = + sensorList[i]->addSingleMeasurementResult(); + success &= sensorSuccess_result; + + if (sensorSuccess_result) { + MS_DBG(F(" ... got measurement result. <<---"), + cycCount); + } else { + MS_DBG(F(" ... failed to get measurement result! " + "<<---"), + cycCount); } } + } - // If all the measurements are done - if (sensorList[i]->getNumberCompleteMeasurementsAttempts() >= - nReq) { - MS_DBG(i, F("--->> Finished all measurements from"), sName, - F(", putting it to sleep. ...")); + // If all the measurements are now done + if (sensorList[i]->getNumberCompleteMeasurementsAttempts() >= + nReq) { + MS_DBG(i, F("--->> Finished all measurements from"), sName, + F(", putting it to sleep. ...")); - // Put the completed sensor to sleep - bool sensorSuccess_sleep = sensorList[i]->sleep(); - success &= sensorSuccess_sleep; + // Put the completed sensor to sleep + bool sensorSuccess_sleep = sensorList[i]->sleep(); + success &= sensorSuccess_sleep; - if (sensorSuccess_sleep) { - MS_DBG(F(" ... succeeded in putting sensor to sleep. " - "<<---"), - i); + if (sensorSuccess_sleep) { + MS_DBG(F(" ... succeeded in putting sensor to sleep. " + "<<---"), + i); + } else { + MS_DBG(F(" ... sleep failed! <<---"), i); + } + + // Now cut the power, if ready, to this sensors and all that + // share the pin + bool canPowerDown = false; + for (uint8_t k = 0; k < _sensorCount; k++) { + if (((sensorList[i]->getPowerPin() >= 0 && + (sensorList[i]->getPowerPin() == + sensorList[k]->getPowerPin() || + sensorList[i]->getPowerPin() == + sensorList[k]->getSecondaryPowerPin())) || + (sensorList[i]->getSecondaryPowerPin() >= 0 && + (sensorList[i]->getSecondaryPowerPin() == + sensorList[k]->getPowerPin() || + sensorList[i]->getSecondaryPowerPin() == + sensorList[k]->getSecondaryPowerPin()))) && + (sensorList[k] + ->getNumberCompleteMeasurementsAttempts() < + sensorList[k]->getNumberMeasurementsToAverage())) { + canPowerDown = false; // another sensor on this pin + // still needs to take + // measurements + break; } else { - MS_DBG(F(" ... sleep failed! <<---"), i); + canPowerDown = true; // no other sensors on this pin + // need to take measurements } - - // Now cut the power, if ready, to this sensors and all that - // share the pin - bool canPowerDown = false; + } + if (canPowerDown) { sensorList[i]->powerDown(); } +#if defined(MS_VARIABLEARRAY_DEBUG) + if (canPowerDown) { + MS_DBG(i, F("--->> All measurements from"), sName, + F("are complete and no other sensors on the same " + "power pin need to take measurements. " + "Powered down all sensors on pin"), + sensorList[i]->getPowerPin(), F("or pin"), + sensorList[i]->getSecondaryPowerPin(), F("...")); + } else { + MS_DBG(i, F("--->> All measurements from"), sName, + F("are complete but other sensors on the same " + "power pin still need to take measurements. " + "Leaving power on pin"), + sensorList[i]->getPowerPin(), F("ON. <<---")); for (uint8_t k = 0; k < _sensorCount; k++) { if (((sensorList[i]->getPowerPin() >= 0 && (sensorList[i]->getPowerPin() == @@ -663,82 +703,36 @@ bool VariableArray::completeUpdate(void) { (sensorList[k] ->getNumberCompleteMeasurementsAttempts() < sensorList[k]->getNumberMeasurementsToAverage())) { - canPowerDown = false; // another sensor on this pin - // still needs to take - // measurements - break; - } else { - canPowerDown = - true; // no other sensors on this pin - // need to take measurements - } - } - if (canPowerDown) { sensorList[i]->powerDown(); } -#if defined(MS_VARIABLEARRAY_DEBUG) - if (canPowerDown) { - MS_DBG( - i, F("--->> All measurements from"), sName, - F("are complete and no other sensors on the same " - "power pin need to take measurements. " - "Powered down all sensors on pin"), - sensorList[i]->getPowerPin(), F("or pin"), - sensorList[i]->getSecondaryPowerPin(), F("...")); - } else { - MS_DBG(i, F("--->> All measurements from"), sName, - F("are complete but other sensors on the same " - "power pin still need to take measurements. " - "Leaving power on pin"), - sensorList[i]->getPowerPin(), F("ON. <<---")); - for (uint8_t k = 0; k < _sensorCount; k++) { - if (((sensorList[i]->getPowerPin() >= 0 && - (sensorList[i]->getPowerPin() == - sensorList[k]->getPowerPin() || - sensorList[i]->getPowerPin() == - sensorList[k] - ->getSecondaryPowerPin())) || - (sensorList[i]->getSecondaryPowerPin() >= 0 && - (sensorList[i]->getSecondaryPowerPin() == - sensorList[k]->getPowerPin() || - sensorList[i]->getSecondaryPowerPin() == - sensorList[k] - ->getSecondaryPowerPin()))) && - (sensorList[k] - ->getNumberCompleteMeasurementsAttempts() < - sensorList[k] - ->getNumberMeasurementsToAverage())) { - MS_DBG( - sName, F("shares a power pin with"), - sensorList[k]->getSensorNameAndLocation(), - F("which still needs to take"), + MS_DBG( + sName, F("shares a power pin with"), + sensorList[k]->getSensorNameAndLocation(), + F("which still needs to take"), + sensorList[k] + ->getNumberMeasurementsToAverage() - sensorList[k] - ->getNumberMeasurementsToAverage() - - sensorList[k] - ->getNumberCompleteMeasurementsAttempts(), - F("measurements.")); - MS_DBG(sName, '(', i, ')', F("pins are"), - sensorList[i]->getPowerPin(), F("and"), - sensorList[i]->getSecondaryPowerPin()); - MS_DBG( - sensorList[k]->getSensorNameAndLocation(), - '(', k, ')', F("pins are"), - sensorList[k]->getPowerPin(), F("and"), - sensorList[k]->getSecondaryPowerPin()); - break; - } + ->getNumberCompleteMeasurementsAttempts(), + F("measurements.")); + MS_DBG(sName, '(', i, ')', F("pins are"), + sensorList[i]->getPowerPin(), F("and"), + sensorList[i]->getSecondaryPowerPin()); + MS_DBG(sensorList[k]->getSensorNameAndLocation(), + '(', k, ')', F("pins are"), + sensorList[k]->getPowerPin(), F("and"), + sensorList[k]->getSecondaryPowerPin()); + break; } } -#endif - nSensorsCompleted++; // mark the whole sensor as done - MS_DBG(F("*****---"), nSensorsCompleted, - F("sensors now complete ---*****")); - } else { - MS_DEEP_DBG( - i, F("--->>"), sName, F("still needs to take"), - nReq - - sensorList[i] - ->getNumberCompleteMeasurementsAttempts(), - F("measurements.")); } +#endif + nSensorsCompleted++; // mark the whole sensor as done + MS_DBG(F("*****---"), nSensorsCompleted, + F("sensors now complete ---*****")); + } else { + MS_DEEP_DBG( + i, F("--->>"), sName, F("still needs to take"), + nReq - + sensorList[i]->getNumberCompleteMeasurementsAttempts(), + F("measurements.")); } } MS_DEEP_DBG(F("xxxxx---"), _sensorCount - nSensorsCompleted, From 1e810b4bb1013f6bed00721a77ca8a9f4f7677fb Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Tue, 30 Sep 2025 15:22:53 -0400 Subject: [PATCH 047/533] Skip millis check in isStable for repeats Signed-off-by: Sara Damiano --- src/SensorBase.cpp | 10 ++++++++++ src/sensors/ANBpH.cpp | 10 ++++++++++ 2 files changed, 20 insertions(+) diff --git a/src/SensorBase.cpp b/src/SensorBase.cpp index 2aa549ba5..dda2a9fd1 100644 --- a/src/SensorBase.cpp +++ b/src/SensorBase.cpp @@ -582,6 +582,16 @@ bool Sensor::isStable(bool debug) { return true; } + // If we're taking a repeat measurement, we may have already waited for + // stabilization after the initial wake, so we can skip this wait. + if (_retryAttemptsMade != 0) { + if (debug) { + MS_DBG(getSensorNameAndLocation(), + F("is retrying and doesn't need to stabilize again.")); + } + return true; + } + uint32_t elapsed_since_wake_up = millis() - _millisSensorActivated; // If the sensor has been activated and enough time has elapsed, it's stable if (elapsed_since_wake_up > _stabilizationTime_ms) { diff --git a/src/sensors/ANBpH.cpp b/src/sensors/ANBpH.cpp index 86c198019..c0de12482 100644 --- a/src/sensors/ANBpH.cpp +++ b/src/sensors/ANBpH.cpp @@ -457,6 +457,16 @@ bool ANBpH::isStable(bool debug) { return true; } + // If we're taking a repeat measurement, we may have already waited for + // stabilization after the initial wake, so we can skip this wait. + if (_retryAttemptsMade != 0) { + if (debug) { + MS_DBG(getSensorNameAndLocation(), + F("is retrying and doesn't need to stabilize again.")); + } + return true; + } + uint32_t elapsed_since_wake_up = millis() - _millisSensorActivated; uint32_t minTime = _stabilizationTime_ms; uint32_t maxTime = ANB_PH_STABILIZATION_TIME_MAX; From b9fb33f1c2f20368501ed86108156cee4c2bfc1e Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Tue, 30 Sep 2025 16:24:58 -0400 Subject: [PATCH 048/533] Combine updateAllSensors and completeUpdate Signed-off-by: Sara Damiano --- ChangeLog.md | 6 +- src/VariableArray.cpp | 379 +++++++++++------------------------------- src/VariableArray.h | 10 +- 3 files changed, 104 insertions(+), 291 deletions(-) diff --git a/ChangeLog.md b/ChangeLog.md index 3f7c872cc..bd639b80a 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -24,7 +24,11 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm These resets were an awkward attempt to deal with bad values before feeding any bad values to the `verifyAndAddMeasurementResult()` function which was previously always called even if the sensor returned junk. This was probably a hold-over from incorrect implementation and calling of the clearValues function deep in the library history. - Also made the return from the `addSingleMeasurementResult()` function consistently false for a bad sensor response and true for a good one - where it's possible to tell the difference. -- The Sensor::clearValues() function now resets all timing and bits for the sensor in addition to setting all values in the value array to -9999.. +- The Sensor::clearValues() function now resets all timing and bits for the sensor in addition to setting all values in the value array to -9999. +- Re-wrote some of the logic of the `completeUpdate()` function. +Also added optional arguments to the `completeUpdate()` function to allow users to specify if the sensors should be powered/woken. + - The `updateAllSensors()` function is now deprecated. +Use `completeUpdate(false, false, false, false)` instead. ### Added diff --git a/src/VariableArray.cpp b/src/VariableArray.cpp index 7fd25d887..cc5c7e325 100644 --- a/src/VariableArray.cpp +++ b/src/VariableArray.cpp @@ -281,214 +281,12 @@ void VariableArray::sensorsPowerDown(void) { // Please note that this does NOT run the update functions, it instead uses // the startSingleMeasurement and addSingleMeasurementResult functions to // take advantage of the ability of sensors to be measuring concurrently. -// NOTE: Calculated variables will always be skipped in this process because -// a calculated variable will never be marked as the last variable from a -// sensor. bool VariableArray::updateAllSensors(void) { - bool success = true; - uint8_t nSensorsCompleted = 0; - -#ifdef MS_VARIABLEARRAY_DEBUG_DEEP - bool deepDebugTiming = true; -#else - bool deepDebugTiming = false; -#endif - - // Create an array with the unique-ness value (so we can skip the function - // calls later) - MS_DBG(F("Creating a mask array with the uniqueness for each sensor..")); - bool lastSensorVariable[_variableCount]; - for (uint8_t i = 0; i < _variableCount; i++) { - lastSensorVariable[i] = isLastVarFromSensor(i); - } - - // Create an array for the number of measurements already completed and set - // all to zero - MS_DBG(F("Creating an array for the number of completed measurements..")); - uint8_t nMeasurementsCompleted[_variableCount]; - for (uint8_t i = 0; i < _variableCount; i++) { - nMeasurementsCompleted[i] = 0; - } - - // Create an array for the number of measurements to average (another short - // cut) - MS_DBG(F("Creating an array with the number of measurements to average..")); - uint8_t nMeasurementsToAverage[_variableCount]; - for (uint8_t i = 0; i < _variableCount; i++) { - if (lastSensorVariable[i]) { - nMeasurementsToAverage[i] = - arrayOfVars[i]->parentSensor->getNumberMeasurementsToAverage(); - } else { - nMeasurementsToAverage[i] = 0; - } - } - - // Clear the initial variable arrays - MS_DBG(F("----->> Clearing all results arrays before taking new " - "measurements. ...")); - for (uint8_t i = 0; i < _variableCount; i++) { - if (lastSensorVariable[i]) { - arrayOfVars[i]->parentSensor->clearValues(); - } - } - MS_DBG(F(" ... Complete. <<-----")); - - // Check for any sensors that didn't wake up and mark them as "complete" so - // they will be skipped in further looping. - for (uint8_t i = 0; i < _variableCount; i++) { - if (lastSensorVariable[i] // Skip non-unique sensors - && (getSensorStatusBit(i, Sensor::WAKE_ATTEMPTED) == - 0 // No attempt made to wake the sensor up - || getSensorStatusBit(i, Sensor::WAKE_SUCCESSFUL) == - 0 // OR Wake up failed - )) { - MS_DBG(i, F("--->>"), - arrayOfVars[i]->getParentSensorNameAndLocation(), - F("isn't awake/active! No measurements will be taken! " - "<<---"), - i); - - // Set the number of measurements already equal to whatever - // total number requested to ensure the sensor is skipped in - // further loops. - nMeasurementsCompleted[i] = nMeasurementsToAverage[i]; - // Bump up the finished count. - nSensorsCompleted++; - } - } - - while (nSensorsCompleted < _sensorCount) { - for (uint8_t i = 0; i < _variableCount; i++) { - /*** - // THIS IS PURELY FOR DEEP DEBUGGING OF THE TIMING! - // Leave this whole section commented out unless you want excessive - // printouts (ie, thousands of lines) of the timing information!! - if (lastSensorVariable[i] and - nMeasurementsToAverage[i] > nMeasurementsCompleted[i]) { - MS_DEEP_DBG( - i, '-', arrayOfVars[i]->getParentSensorNameAndLocation(), - F("- millis:"), millis(), F("- status: 0b"), - getSensorStatusBit(i, Sensor::ERROR_OCCURRED), - getSensorStatusBit(i, Sensor::MEASUREMENT_SUCCESSFUL), - getSensorStatusBit(i, Sensor::MEASUREMENT_ATTEMPTED), - getSensorStatusBit(i, Sensor::WAKE_SUCCESSFUL), - getSensorStatusBit(i, Sensor::WAKE_ATTEMPTED), - getSensorStatusBit(i, Sensor::POWER_SUCCESSFUL), - getSensorStatusBit(i, Sensor::POWER_ATTEMPTED), - getSensorStatusBit(i, Sensor::SETUP_SUCCESSFUL), - F("-measurement #"), nMeasurementsCompleted[i] + 1); - } - // END CHUNK FOR DEBUGGING! - ***/ - - // Only do checks on sensors that still have measurements to finish - if (lastSensorVariable[i] && - nMeasurementsToAverage[i] > nMeasurementsCompleted[i]) { - // first, make sure the sensor is stable - if (arrayOfVars[i]->parentSensor->isStable(deepDebugTiming)) { - // now, if the sensor is not currently measuring... - if (getSensorStatusBit(i, Sensor::MEASUREMENT_ATTEMPTED) == - 0) { // NO attempt yet to start a measurement - // Start a reading - MS_DBG(i, '.', nMeasurementsCompleted[i] + 1, - F("--->> Starting reading"), - nMeasurementsCompleted[i] + 1, F("on"), - arrayOfVars[i]->getParentSensorNameAndLocation(), - '-'); - - bool sensorSuccess_start = - arrayOfVars[i] - ->parentSensor->startSingleMeasurement(); - success &= sensorSuccess_start; - - if (sensorSuccess_start) { - MS_DBG(F(" ... reading started! <<---"), i, '.', - nMeasurementsCompleted[i] + 1); - } else { - MS_DBG(F(" ... failed to start reading! <<---"), - i, '.', nMeasurementsCompleted[i] + 1); - } - } - - // otherwise, it is currently measuring so... - // if a measurement is finished, get the result and tick up - // the number of finished measurements - // NOTE: isMeasurementComplete(deepDebugTiming) will - // immediately return true if the attempt to start a - // measurement failed (bit 6 not set). In that case, the - // addSingleMeasurementResult() will be "adding" -9999 - // values. - if (arrayOfVars[i]->parentSensor->isMeasurementComplete( - deepDebugTiming)) { - // Get the value - MS_DBG(i, '.', nMeasurementsCompleted[i] + 1, - F("--->> Collected result of reading"), - nMeasurementsCompleted[i] + 1, F("from"), - arrayOfVars[i]->getParentSensorNameAndLocation(), - F("...")); - - bool sensorSuccess_result = - arrayOfVars[i] - ->parentSensor->addSingleMeasurementResult(); - success &= sensorSuccess_result; - nMeasurementsCompleted[i] += - 1; // increment the number of measurements that - // sensor has completed - - if (sensorSuccess_result) { - MS_DBG(F(" ... got measurement result. <<---"), i, - '.', nMeasurementsCompleted[i]); - } else { - MS_DBG(F(" ... failed to get measurement result! " - "<<---"), - i, '.', nMeasurementsCompleted[i]); - } - } - } - - // if all the measurements are done, mark the whole sensor as - // done - if (nMeasurementsCompleted[i] == nMeasurementsToAverage[i]) { - MS_DBG(F("--- Finished all measurements from"), - arrayOfVars[i]->getParentSensorNameAndLocation(), - F("---")); - - nSensorsCompleted++; - MS_DBG(F("*****---"), nSensorsCompleted, - F("sensors now complete ---*****")); - } - } - } - } - - // Average measurements and notify variables of the updates - MS_DBG(F("----->> Averaging results and notifying all variables. ...")); - for (uint8_t i = 0; i < _variableCount; i++) { - if (lastSensorVariable[i]) { - MS_DEEP_DBG(F("--- Averaging results from"), - arrayOfVars[i]->getParentSensorNameAndLocation(), - F("---")); - arrayOfVars[i]->parentSensor->averageMeasurements(); - MS_DEEP_DBG(F("--- Notifying variables from"), - arrayOfVars[i]->getParentSensorNameAndLocation(), - F("---")); - arrayOfVars[i]->parentSensor->notifyVariables(); - } - } - MS_DBG(F("... Complete. <<-----")); - - MS_DBG(F("Updating calculated variables. ...")); - for (uint8_t i = 0; i < _variableCount; i++) { - if (arrayOfVars[i]->isCalculated) { arrayOfVars[i]->getValue(true); } - } - - return success; + return completeUpdate(false, false, false, false); } - -// This function is an even more complete version of the updateAllSensors -// function - it handles power up/down and wake/sleep. -bool VariableArray::completeUpdate(void) { +bool VariableArray::completeUpdate(bool powerUp, bool wake, bool sleep, + bool powerDown) { bool success = true; uint8_t nSensorsCompleted = 0; @@ -520,9 +318,11 @@ bool VariableArray::completeUpdate(void) { MS_DBG(F(" ... Complete. <<-----")); // power up all of the sensors together - MS_DBG(F("----->> Powering up all sensors together. ...")); - sensorsPowerUp(); - MS_DBG(F(" ... Complete. <<-----")); + if (powerUp) { + MS_DBG(F("----->> Powering up all sensors together. ...")); + sensorsPowerUp(); + MS_DBG(F(" ... Complete. <<-----")); + } while (nSensorsCompleted < _sensorCount) { for (uint8_t i = 0; i < _sensorCount; i++) { @@ -556,10 +356,12 @@ bool VariableArray::completeUpdate(void) { sensorList[i]->_measurementsToAverage; } - if (sensorList[i]->getStatusBit(Sensor::WAKE_ATTEMPTED) == - 0 // If no attempts yet made to wake the sensor up - && sensorList[i]->isWarmedUp( - deepDebugTiming) // and if it is already warmed up + if (wake + // ^^ if we're supposed to wake the sensors + && sensorList[i]->getStatusBit(Sensor::WAKE_ATTEMPTED) == 0 + // ^^ And no attempts yet made to wake the sensor up + && sensorList[i]->isWarmedUp(deepDebugTiming) + // ^^ and if it is already warmed up ) { MS_DBG(i, F("--->> Waking"), sName, F("...")); @@ -630,65 +432,30 @@ bool VariableArray::completeUpdate(void) { } } - // If all the measurements are now done + // If all the measurements are now complete if (sensorList[i]->getNumberCompleteMeasurementsAttempts() >= nReq) { - MS_DBG(i, F("--->> Finished all measurements from"), sName, - F(", putting it to sleep. ...")); + if (sleep) { + MS_DBG(i, F("--->> Finished all measurements from"), sName, + F(", putting it to sleep. ...")); - // Put the completed sensor to sleep - bool sensorSuccess_sleep = sensorList[i]->sleep(); - success &= sensorSuccess_sleep; + // Put the completed sensor to sleep + bool sensorSuccess_sleep = sensorList[i]->sleep(); + success &= sensorSuccess_sleep; - if (sensorSuccess_sleep) { - MS_DBG(F(" ... succeeded in putting sensor to sleep. " - "<<---"), - i); - } else { - MS_DBG(F(" ... sleep failed! <<---"), i); - } - - // Now cut the power, if ready, to this sensors and all that - // share the pin - bool canPowerDown = false; - for (uint8_t k = 0; k < _sensorCount; k++) { - if (((sensorList[i]->getPowerPin() >= 0 && - (sensorList[i]->getPowerPin() == - sensorList[k]->getPowerPin() || - sensorList[i]->getPowerPin() == - sensorList[k]->getSecondaryPowerPin())) || - (sensorList[i]->getSecondaryPowerPin() >= 0 && - (sensorList[i]->getSecondaryPowerPin() == - sensorList[k]->getPowerPin() || - sensorList[i]->getSecondaryPowerPin() == - sensorList[k]->getSecondaryPowerPin()))) && - (sensorList[k] - ->getNumberCompleteMeasurementsAttempts() < - sensorList[k]->getNumberMeasurementsToAverage())) { - canPowerDown = false; // another sensor on this pin - // still needs to take - // measurements - break; + if (sensorSuccess_sleep) { + MS_DBG(F(" ... succeeded in putting sensor to sleep. " + "<<---"), + i); } else { - canPowerDown = true; // no other sensors on this pin - // need to take measurements + MS_DBG(F(" ... sleep failed! <<---"), i); } } - if (canPowerDown) { sensorList[i]->powerDown(); } -#if defined(MS_VARIABLEARRAY_DEBUG) - if (canPowerDown) { - MS_DBG(i, F("--->> All measurements from"), sName, - F("are complete and no other sensors on the same " - "power pin need to take measurements. " - "Powered down all sensors on pin"), - sensorList[i]->getPowerPin(), F("or pin"), - sensorList[i]->getSecondaryPowerPin(), F("...")); - } else { - MS_DBG(i, F("--->> All measurements from"), sName, - F("are complete but other sensors on the same " - "power pin still need to take measurements. " - "Leaving power on pin"), - sensorList[i]->getPowerPin(), F("ON. <<---")); + if (powerDown) { + // NOTE: We are NOT checking if the sleep command succeeded! + // Cut the power, if ready, to this sensors and all that + // share the pin + bool canPowerDown = false; for (uint8_t k = 0; k < _sensorCount; k++) { if (((sensorList[i]->getPowerPin() >= 0 && (sensorList[i]->getPowerPin() == @@ -703,27 +470,72 @@ bool VariableArray::completeUpdate(void) { (sensorList[k] ->getNumberCompleteMeasurementsAttempts() < sensorList[k]->getNumberMeasurementsToAverage())) { - MS_DBG( - sName, F("shares a power pin with"), - sensorList[k]->getSensorNameAndLocation(), - F("which still needs to take"), - sensorList[k] - ->getNumberMeasurementsToAverage() - - sensorList[k] - ->getNumberCompleteMeasurementsAttempts(), - F("measurements.")); - MS_DBG(sName, '(', i, ')', F("pins are"), - sensorList[i]->getPowerPin(), F("and"), - sensorList[i]->getSecondaryPowerPin()); - MS_DBG(sensorList[k]->getSensorNameAndLocation(), - '(', k, ')', F("pins are"), - sensorList[k]->getPowerPin(), F("and"), - sensorList[k]->getSecondaryPowerPin()); + canPowerDown = false; // another sensor on this pin + // still needs to take + // measurements break; + } else { + canPowerDown = + true; // no other sensors on this pin need to + // take measurements + } + } + if (canPowerDown) { sensorList[i]->powerDown(); } +#if defined(MS_VARIABLEARRAY_DEBUG) + if (canPowerDown) { + MS_DBG( + i, F("--->> All measurements from"), sName, + F("are complete and no other sensors on the same " + "power pin need to take measurements. " + "Powered down all sensors on pin"), + sensorList[i]->getPowerPin(), F("or pin"), + sensorList[i]->getSecondaryPowerPin(), F("...")); + } else { + MS_DBG(i, F("--->> All measurements from"), sName, + F("are complete but other sensors on the same " + "power pin still need to take measurements. " + "Leaving power on pin"), + sensorList[i]->getPowerPin(), F("ON. <<---")); + for (uint8_t k = 0; k < _sensorCount; k++) { + if (((sensorList[i]->getPowerPin() >= 0 && + (sensorList[i]->getPowerPin() == + sensorList[k]->getPowerPin() || + sensorList[i]->getPowerPin() == + sensorList[k] + ->getSecondaryPowerPin())) || + (sensorList[i]->getSecondaryPowerPin() >= 0 && + (sensorList[i]->getSecondaryPowerPin() == + sensorList[k]->getPowerPin() || + sensorList[i]->getSecondaryPowerPin() == + sensorList[k] + ->getSecondaryPowerPin()))) && + (sensorList[k] + ->getNumberCompleteMeasurementsAttempts() < + sensorList[k] + ->getNumberMeasurementsToAverage())) { + MS_DBG( + sName, F("shares a power pin with"), + sensorList[k]->getSensorNameAndLocation(), + F("which still needs to take"), + sensorList[k] + ->getNumberMeasurementsToAverage() - + sensorList[k] + ->getNumberCompleteMeasurementsAttempts(), + F("measurements.")); + MS_DBG(sName, '(', i, ')', F("pins are"), + sensorList[i]->getPowerPin(), F("and"), + sensorList[i]->getSecondaryPowerPin()); + MS_DBG( + sensorList[k]->getSensorNameAndLocation(), + '(', k, ')', F("pins are"), + sensorList[k]->getPowerPin(), F("and"), + sensorList[k]->getSecondaryPowerPin()); + break; + } } } - } #endif + } nSensorsCompleted++; // mark the whole sensor as done MS_DBG(F("*****---"), nSensorsCompleted, F("sensors now complete ---*****")); @@ -739,11 +551,6 @@ bool VariableArray::completeUpdate(void) { F("sensors remaining ---xxxxx")); } - // // power down all the sensors again, just in case - // MS_DBG(F("----->> Running a final power-down of all the sensors. ...")); - // sensorsPowerDown(); - // MS_DBG(F(" ... Complete. <<-----")); - // Average measurements and notify variables of the updates MS_DBG(F("----->> Averaging results and notifying all variables. ...")); for (uint8_t i = 0; i < _sensorCount; i++) { diff --git a/src/VariableArray.h b/src/VariableArray.h index 725d065dc..ffc4f6fcc 100644 --- a/src/VariableArray.h +++ b/src/VariableArray.h @@ -239,9 +239,10 @@ class VariableArray { /** * @brief Update the values for all connected sensors. * - * Does not power or wake/sleep sensors. Returns a boolean indication the - * overall success. Does NOT return any values. Repeatedly checks each - * sensor's readiness state to optimize timing. + * @m_deprecated_since{0,38,0} + * + * Use completeUpdate() instead and set the powerUp, wake, sleep and + * powerDown parameters as needed. * * @return True if all steps of the update succeeded. */ @@ -259,7 +260,8 @@ class VariableArray { * * @return True if all steps of the update succeeded. */ - bool completeUpdate(void); + bool completeUpdate(bool powerUp = true, bool wake = true, + bool sleep = true, bool powerDown = true); /** * @brief Print out the results for all connected sensors to a stream From 2b237a4f0bb3b151361d506921c92508b286798c Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Tue, 30 Sep 2025 16:30:18 -0400 Subject: [PATCH 049/533] Remove internal and example references to `updateAllSensors()` Signed-off-by: Sara Damiano --- examples/double_logger/double_logger.ino | 47 +++--------------------- src/LoggerBase.cpp | 2 +- 2 files changed, 6 insertions(+), 43 deletions(-) diff --git a/examples/double_logger/double_logger.ino b/examples/double_logger/double_logger.ino index 7b4f8a8ce..12e6fb49c 100644 --- a/examples/double_logger/double_logger.ino +++ b/examples/double_logger/double_logger.ino @@ -311,27 +311,8 @@ void loop() { // Turn on the LED to show we're taking a reading digitalWrite(greenLED, HIGH); - // Send power to all of the sensors (do this directly on the - // VariableArray) - Serial.print(F("Powering sensors...\n")); - array1min.sensorsPowerUp(); - extendedWatchDog::resetWatchDog(); - // Wake up all of the sensors (do this directly on the VariableArray) - Serial.print(F("Waking sensors...\n")); - array1min.sensorsWake(); - extendedWatchDog::resetWatchDog(); - // Update the values from all attached sensors (do this directly on the - // VariableArray) - Serial.print(F("Updating sensor values...\n")); - array1min.updateAllSensors(); - extendedWatchDog::resetWatchDog(); - // Put sensors to sleep (do this directly on the VariableArray) - Serial.print(F("Putting sensors back to sleep...\n")); - array1min.sensorsSleep(); - extendedWatchDog::resetWatchDog(); - // Cut sensor power (do this directly on the VariableArray) - Serial.print(F("Cutting sensor power...\n")); - array1min.sensorsPowerDown(); + Serial.print(F("Running a complete sensor update...\n")); + array1min.completeUpdate(); extendedWatchDog::resetWatchDog(); // Stream the csv data to the SD card @@ -354,27 +335,9 @@ void loop() { // Turn on the LED to show we're taking a reading digitalWrite(redLED, HIGH); - // Send power to all of the sensors (do this directly on the - // VariableArray) - Serial.print(F("Powering sensors...\n")); - array5min.sensorsPowerUp(); - extendedWatchDog::resetWatchDog(); - // Wake up all of the sensors (do this directly on the VariableArray) - Serial.print(F("Waking sensors...\n")); - array5min.sensorsWake(); - extendedWatchDog::resetWatchDog(); - // Update the values from all attached sensors (do this directly on the - // VariableArray) - Serial.print(F("Updating sensor values...\n")); - array5min.updateAllSensors(); - extendedWatchDog::resetWatchDog(); - // Put sensors to sleep (do this directly on the VariableArray) - Serial.print(F("Putting sensors back to sleep...\n")); - array5min.sensorsSleep(); - extendedWatchDog::resetWatchDog(); - // Cut sensor power (do this directly on the VariableArray) - Serial.print(F("Cutting sensor power...\n")); - array5min.sensorsPowerDown(); + // Complete sensor update on this VariableArray + Serial.print(F("Running a complete sensor update...\n")); + array5min.completeUpdate(); extendedWatchDog::resetWatchDog(); // Stream the csv data to the SD card diff --git a/src/LoggerBase.cpp b/src/LoggerBase.cpp index e4a6e0f2d..731ad0add 100644 --- a/src/LoggerBase.cpp +++ b/src/LoggerBase.cpp @@ -1621,7 +1621,7 @@ void Logger::benchTestingMode(bool sleepBeforeReturning) { // Update the values from all attached sensors // NOTE: NOT using complete update because we want the sensors to be // left on between iterations in testing mode. - _internalArray->updateAllSensors(); + _internalArray->completeUpdate(false, false, false, false); // Print out the current logger time PRINTOUT(F("Current logger time is"), formatDateTime_ISO8601(getNowLocalEpoch())); From 7a0045d819f5de0c0fddd72cea77f19e641968a3 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Tue, 30 Sep 2025 16:42:19 -0400 Subject: [PATCH 050/533] Debug print total awake time Signed-off-by: Sara Damiano --- src/VariableArray.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/VariableArray.cpp b/src/VariableArray.cpp index cc5c7e325..e7970e93f 100644 --- a/src/VariableArray.cpp +++ b/src/VariableArray.cpp @@ -344,7 +344,7 @@ bool VariableArray::completeUpdate(bool powerUp, bool wake, bool sleep, if (sensorList[i]->getStatusBit(Sensor::WAKE_ATTEMPTED) == 1 && sensorList[i]->getStatusBit(Sensor::WAKE_SUCCESSFUL) == 0) { MS_DBG(i, F("--->>"), sName, - F("did not wake up! No measurements will be taken! " + F("failed to wake up! No measurements will be taken! " "<<---"), i); // Set the number of measurements already complete equal to @@ -445,8 +445,9 @@ bool VariableArray::completeUpdate(bool powerUp, bool wake, bool sleep, if (sensorSuccess_sleep) { MS_DBG(F(" ... succeeded in putting sensor to sleep. " - "<<---"), - i); + "Total wake time was"), + millis() - sensorList[i]->_millisSensorActivated, + F("ms <<---"), i); } else { MS_DBG(F(" ... sleep failed! <<---"), i); } From ecbce6504a2b70ab4d9ee3fd8643ae58b7fe9dea Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Wed, 1 Oct 2025 09:56:57 -0400 Subject: [PATCH 051/533] Add missing docs Signed-off-by: Sara Damiano --- src/VariableArray.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/VariableArray.h b/src/VariableArray.h index ffc4f6fcc..06ad47662 100644 --- a/src/VariableArray.h +++ b/src/VariableArray.h @@ -258,6 +258,11 @@ class VariableArray { * values. Repeatedly checks each sensor's readiness state to optimize * timing. * + * @param powerUp If true, powers up all sensors before updating. + * @param wake If true, wakes all sensors before updating. + * @param sleep If true, puts all sensors to sleep after updating. + * @param powerDown If true, cuts power to all sensors after updating. + * * @return True if all steps of the update succeeded. */ bool completeUpdate(bool powerUp = true, bool wake = true, From 12ecc21b97ce987e1c2ec81b1d82b4f1242ce2ef Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Wed, 1 Oct 2025 10:00:50 -0400 Subject: [PATCH 052/533] Add extra setters and getters for sensor timing. Use only if you know what you're doing. Signed-off-by: Sara Damiano --- ChangeLog.md | 8 ++++++++ src/SensorBase.cpp | 23 +++++++++++++++++++++++ src/SensorBase.h | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 77 insertions(+) diff --git a/ChangeLog.md b/ChangeLog.md index bd639b80a..63c091856 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -43,6 +43,14 @@ Measurements that return bad values even after retries are still not included in - The default number of retry attempts for most sensors is 1. - Made a secondary power pin a property of all sensors. - Added internal function to run the steps of setting the timing and bits after a measurement. +- Added setter and getter functions for sensor timing variables. +These values should generally be set in the specific sensor constructors and only changed if you know what you're doing. + - `setWarmUpTime(uint32_t warmUpTime_ms)` + - `getWarmUpTime()` + - `setStabilizationTime(uint32_t stabilizationTime_ms)` + - `getStabilizationTime()` + - `setMeasurementTime(uint32_t measurementTime_ms)` + - `getMeasurementTime()` ### Removed diff --git a/src/SensorBase.cpp b/src/SensorBase.cpp index dda2a9fd1..b4fee62f9 100644 --- a/src/SensorBase.cpp +++ b/src/SensorBase.cpp @@ -65,6 +65,10 @@ String Sensor::getSensorNameAndLocation(void) { int8_t Sensor::getPowerPin(void) { return _powerPin; } +// This sets the power pin +void Sensor::setPowerPin(int8_t pin) { + _powerPin = pin; +} // This returns the number of the secondary power pin int8_t Sensor::getSecondaryPowerPin(void) { return _powerPin2; @@ -97,6 +101,25 @@ uint8_t Sensor::getAllowedMeasurementRetries(void) { } +void Sensor::setWarmUpTime(uint32_t warmUpTime_ms) { + _warmUpTime_ms = warmUpTime_ms; +} +uint32_t Sensor::getWarmUpTime(void) { + return _warmUpTime_ms; +} +void Sensor::setStabilizationTime(uint32_t stabilizationTime_ms) { + _stabilizationTime_ms = stabilizationTime_ms; +} +uint32_t Sensor::getStabilizationTime(void) { + return _stabilizationTime_ms; +} +void Sensor::setMeasurementTime(uint32_t measurementTime_ms) { + _measurementTime_ms = measurementTime_ms; +} +uint32_t Sensor::getMeasurementTime(void) { + return _measurementTime_ms; +} + // This returns the 8-bit code for the current status of the sensor. // Bit 0 - 0=Has NOT been set up, 1=Has been setup // Bit 1 - 0=No attempt made to power sensor, 1=Attempt made to power sensor diff --git a/src/SensorBase.h b/src/SensorBase.h index 82272669d..9be8150e3 100644 --- a/src/SensorBase.h +++ b/src/SensorBase.h @@ -154,6 +154,11 @@ class Sensor { * @return The pin on the mcu controlling power to the sensor. */ virtual int8_t getPowerPin(void); + /** + * @brief Set the pin number controlling sensor power. + * @param pin The pin on the mcu controlling power to the sensor. + */ + virtual void setPowerPin(int8_t pin); /** * @brief Get the pin number controlling secondary sensor power. * @@ -225,6 +230,47 @@ class Sensor { */ void setAllowedMeasurementRetries(uint8_t allowedMeasurementRetries); + // _warmUpTime_ms _stabilizationTime_ms _measurementTime_ms + + /** + * @brief Set the warm-up time for the sensor. + * @param warmUpTime_ms The warm-up time in milliseconds. + * @remark This is the time between when the sensor is powered on and when + * it is ready to receive a wake command. It should be set in the sensor + * constructor. Only change this if you know what you're doing! + */ + void setWarmUpTime(uint32_t warmUpTime_ms); + /** + * @brief Get the warm-up time for the sensor. + * @return The warm-up time in milliseconds. + */ + uint32_t getWarmUpTime(void); + /** + * @brief Set the stabilization time for the sensor. + * @param stabilizationTime_ms The stabilization time in milliseconds. + * @remark This is the time between when the sensor receives a wake command + * and when it is able to return stable values. It should be set in the + * sensor constructor. Only change this if you know what you're doing! + */ + void setStabilizationTime(uint32_t stabilizationTime_ms); + /** + * @brief Get the stabilization time for the sensor. + * @return The stabilization time in milliseconds. + */ + uint32_t getStabilizationTime(void); + /** + * @brief Set the measurement time for the sensor. + * @param measurementTime_ms The measurement time in milliseconds. + * @remark This is the time between when a measurement is started and when + * the result value is available. It should be set in the sensor + * constructor. Only change this if you know what you're doing! + */ + void setMeasurementTime(uint32_t measurementTime_ms); + /** + * @brief Get the measurement time for the sensor. + * @return The measurement time in milliseconds. + */ + uint32_t getMeasurementTime(void); /// @brief The significance of the various status bits typedef enum { From 12168e08bcd87428b7cf33306306d3c66947c0ae Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Wed, 1 Oct 2025 11:25:13 -0400 Subject: [PATCH 053/533] Added processor analog Signed-off-by: Sara Damiano --- ChangeLog.md | 3 + src/sensors/EverlightALSPT19.cpp | 14 +- src/sensors/EverlightALSPT19.h | 25 +-- src/sensors/KnownProcessors.h | 268 +++++++++++++++++++++++++++++++ src/sensors/ProcessorAnalog.cpp | 62 +++++++ src/sensors/ProcessorAnalog.h | 258 +++++++++++++++++++++++++++++ src/sensors/ProcessorStats.cpp | 49 +----- src/sensors/ProcessorStats.h | 135 ++++------------ 8 files changed, 647 insertions(+), 167 deletions(-) create mode 100644 src/sensors/KnownProcessors.h create mode 100644 src/sensors/ProcessorAnalog.cpp create mode 100644 src/sensors/ProcessorAnalog.h diff --git a/ChangeLog.md b/ChangeLog.md index 63c091856..dc1ab4a18 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -51,6 +51,9 @@ These values should generally be set in the specific sensor constructors and onl - `getStabilizationTime()` - `setMeasurementTime(uint32_t measurementTime_ms)` - `getMeasurementTime()` +- **NEW SENSOR** Added a new sensor for simple analog voltage using the built-in processor ADC +- Added KnownProcessors.h and moved defines values for supported built-in sensors on known processors to that file. + - This affects ProcessorStats and the Everlight ALS PT-19. ### Removed diff --git a/src/sensors/EverlightALSPT19.cpp b/src/sensors/EverlightALSPT19.cpp index 9b6f82e53..3b8001adf 100644 --- a/src/sensors/EverlightALSPT19.cpp +++ b/src/sensors/EverlightALSPT19.cpp @@ -11,8 +11,6 @@ #include "EverlightALSPT19.h" -// The constructor - because this is I2C, only need the power pin -// This sensor has a set I2C address of 0XB8 EverlightALSPT19::EverlightALSPT19(int8_t powerPin, int8_t dataPin, float supplyVoltage, float loadResistor, uint8_t measurementsToAverage) @@ -22,14 +20,18 @@ EverlightALSPT19::EverlightALSPT19(int8_t powerPin, int8_t dataPin, measurementsToAverage), _supplyVoltage(supplyVoltage), _loadResistor(loadResistor) {} +#if defined(BUILT_IN_ALS_POWER_PIN) && defined(BUILT_IN_ALS_DATA_PIN) && \ + defined(BUILT_IN_ALS_SUPPLY_VOLTAGE) && \ + defined(BUILT_IN_ALS_LOADING_RESISTANCE) EverlightALSPT19::EverlightALSPT19(uint8_t measurementsToAverage) : Sensor("Everlight ALS-PT19", ALSPT19_NUM_VARIABLES, ALSPT19_WARM_UP_TIME_MS, ALSPT19_STABILIZATION_TIME_MS, - ALSPT19_MEASUREMENT_TIME_MS, MAYFLY_ALS_POWER_PIN, - MAYFLY_ALS_DATA_PIN, measurementsToAverage, + ALSPT19_MEASUREMENT_TIME_MS, BUILT_IN_ALS_POWER_PIN, + BUILT_IN_ALS_DATA_PIN, measurementsToAverage, ALSPT19_INC_CALC_VARIABLES), - _supplyVoltage(MAYFLY_ALS_SUPPLY_VOLTAGE), - _loadResistor(MAYFLY_ALS_LOADING_RESISTANCE) {} + _supplyVoltage(BUILT_IN_ALS_SUPPLY_VOLTAGE), + _loadResistor(BUILT_IN_ALS_LOADING_RESISTANCE) {} +#endif EverlightALSPT19::~EverlightALSPT19() {} diff --git a/src/sensors/EverlightALSPT19.h b/src/sensors/EverlightALSPT19.h index 7b7e758e0..53fcedb12 100644 --- a/src/sensors/EverlightALSPT19.h +++ b/src/sensors/EverlightALSPT19.h @@ -47,6 +47,9 @@ // Include the library config before anything else #include "ModSensorConfig.h" +// Include the known processors for default values +#include "KnownProcessors.h" + // Include the debugging config #include "ModSensorDebugConfig.h" @@ -85,23 +88,6 @@ #define ALSPT19_INC_CALC_VARIABLES 2 /**@}*/ -/** - * @anchor sensor_alspt19_mayfly - * @name Pin Definitions for the Mayfly - * Specific pin definitions for the ALS-PT19 built in to the EnviroDIY Mayfly - * v1.x - */ -/**@{*/ -/// @brief The power pin for the ALS on the EnviroDIY Mayfly v1.x -#define MAYFLY_ALS_POWER_PIN -1 -/// @brief The data pin for the ALS on the EnviroDIY Mayfly v1.x -#define MAYFLY_ALS_DATA_PIN A4 -/// @brief The supply voltage for the ALS on the EnviroDIY Mayfly v1.x -#define MAYFLY_ALS_SUPPLY_VOLTAGE 3.3 -/// @brief The loading resistance for the ALS on the EnviroDIY Mayfly v1.x -#define MAYFLY_ALS_LOADING_RESISTANCE 10 -/**@}*/ - /** * @anchor sensor_alspt19_timing * @name Sensor Timing @@ -240,6 +226,10 @@ class EverlightALSPT19 : public Sensor { */ EverlightALSPT19(int8_t powerPin, int8_t dataPin, float supplyVoltage, float loadResistor, uint8_t measurementsToAverage = 10); + +#if defined(BUILT_IN_ALS_POWER_PIN) && defined(BUILT_IN_ALS_DATA_PIN) && \ + defined(BUILT_IN_ALS_SUPPLY_VOLTAGE) && \ + defined(BUILT_IN_ALS_LOADING_RESISTANCE) /** * @brief Construct a new EverlightALSPT19 object with pins and resistors * for the EnviroDIY Mayfly 1.x. @@ -253,6 +243,7 @@ class EverlightALSPT19 : public Sensor { * default value of 10. */ explicit EverlightALSPT19(uint8_t measurementsToAverage = 10); +#endif /** * @brief Destroy the EverlightALSPT19 object - no action needed. */ diff --git a/src/sensors/KnownProcessors.h b/src/sensors/KnownProcessors.h new file mode 100644 index 000000000..d6a7cde9f --- /dev/null +++ b/src/sensors/KnownProcessors.h @@ -0,0 +1,268 @@ +/** + * @file KnownProcessors.h + * @copyright Stroud Water Research Center + * @author Sara Damiano (sdamiano@stroudcenter.org) + * + * @brief Defines for parameters of known processor types for the EnviroDIY + * ModularSensors library + */ + +// Header Guards +#ifndef SRC_SENSORS_KNOWN_PROCESSORS_H_ +#define SRC_SENSORS_KNOWN_PROCESSORS_H_ + +/** + * @def LOGGER_BOARD + * @brief Pretty text for the board name derived from the board's compiler + * define. + * + * @def OPERATING_VOLTAGE + * @brief The operating voltage of the board in volts. + * + * @def BATTERY_PIN + * @brief The analog pin of the processor tied directly to the main battery + * input and used to measure the battery voltage. + * @note The battery pin is not available on all boards and may vary by board + * version. Where the battery pin is not available, it is set to -1. Where + * it's variable, it must be fixed in the ProcessorStats module or constructor. + * + * @def BATTERY_MULTIPLIER + * @brief The multiplier to convert the raw "bits" measured on the battery pin + * to voltage. This value is based on any resistors or voltage dividers between + * the battery and the pin. + * @note The battery multiplier is not available on all boards and may vary by + * board version. Where the battery multiplier is not available, it is set to + * -1. Where it's variable, it must be fixed in the ProcessorStats module or + * constructor. + */ + +// EnviroDIY boards +#if defined(ARDUINO_AVR_ENVIRODIY_MAYFLY) +#define LOGGER_BOARD "EnviroDIY Mayfly" +#define OPERATING_VOLTAGE 3.3 +#define BATTERY_PIN A6 +#define BATTERY_MULTIPLIER 4.7 // for v0.5 and later +/// @brief The power pin for the ALS on the EnviroDIY Mayfly v1.x +#define BUILT_IN_ALS_POWER_PIN -1 +/// @brief The data pin for the ALS on the EnviroDIY Mayfly v1.x +#define BUILT_IN_ALS_DATA_PIN A4 +/// @brief The supply voltage for the ALS on the EnviroDIY Mayfly v1.x +#define BUILT_IN_ALS_SUPPLY_VOLTAGE 3.3 +/// @brief The loading resistance for the ALS on the EnviroDIY Mayfly v1.x +#define BUILT_IN_ALS_LOADING_RESISTANCE 10 +#elif defined(ENVIRODIY_STONEFLY_M4) +#define LOGGER_BOARD "EnviroDIY Stonefly" +#define OPERATING_VOLTAGE 3.3 +#define BATTERY_PIN A9 +#define BATTERY_MULTIPLIER 4.7 +/// @brief The power pin for the ALS on the EnviroDIY Stonefly v0.x +#define BUILT_IN_ALS_POWER_PIN -1 +/// @brief The data pin for the ALS on the EnviroDIY Stonefly v0.x +#define BUILT_IN_ALS_DATA_PIN A8 +/// @brief The supply voltage for the ALS on the EnviroDIY Stonefly v0.x +#define BUILT_IN_ALS_SUPPLY_VOLTAGE 3.3 +/// @brief The loading resistance for the ALS on the EnviroDIY Stonefly v0.x +#define BUILT_IN_ALS_LOADING_RESISTANCE 10 + +// Sodaq boards +#elif defined(ARDUINO_SODAQ_EXPLORER) +#define LOGGER_BOARD "SODAQ ExpLoRer" +#define OPERATING_VOLTAGE 3.3 +#define BATTERY_PIN -1 +#define BATTERY_MULTIPLIER -1 +#elif defined(ARDUINO_SODAQ_AUTONOMO) +#define LOGGER_BOARD "SODAQ Autonomo" +#define OPERATING_VOLTAGE 3.3 +#define BATTERY_PIN 48 // for version v0.1 +#define BATTERY_MULTIPLIER 1.47 +#elif defined(ARDUINO_SODAQ_ONE_BETA) +#define LOGGER_BOARD "SODAQ ONE Beta" +#define OPERATING_VOLTAGE 3.3 +#define BATTERY_PIN 10 +#define BATTERY_MULTIPLIER 2 // for version v0.1 +#elif defined(ARDUINO_SODAQ_ONE) +#define LOGGER_BOARD "SODAQ ONE" +#define OPERATING_VOLTAGE 3.3 +#define BATTERY_PIN 10 +#define BATTERY_MULTIPLIER 2 // for version v0.1 +#elif defined(ARDUINO_AVR_SODAQ_MBILI) +#define LOGGER_BOARD "SODAQ Mbili" +#define OPERATING_VOLTAGE 3.3 +#define BATTERY_PIN A6 +#define BATTERY_MULTIPLIER 1.47 +#elif defined(ARDUINO_AVR_SODAQ_NDOGO) +#define LOGGER_BOARD "SODAQ Ndogo" +#define OPERATING_VOLTAGE 3.3 +#define BATTERY_PIN 10 +#define BATTERY_MULTIPLIER 1.47 +#elif defined(ARDUINO_AVR_SODAQ_TATU) +#define LOGGER_BOARD "SODAQ Tatu" +#define OPERATING_VOLTAGE 3.3 +#define BATTERY_PIN -1 +#define BATTERY_MULTIPLIER -1 +#elif defined(ARDUINO_AVR_SODAQ_MOJA) +#define LOGGER_BOARD "SODAQ Moja" +#define OPERATING_VOLTAGE 3.3 +#define BATTERY_PIN -1 +#define BATTERY_MULTIPLIER -1 + +// Adafruit boards +#elif defined(ARDUINO_AVR_FEATHER328P) +#define LOGGER_BOARD "Adafruit Feather 328p" +#define OPERATING_VOLTAGE 3.3 +#define BATTERY_PIN 9 +#define BATTERY_MULTIPLIER 2 +#elif defined(ARDUINO_AVR_FEATHER32U4) +#define LOGGER_BOARD "Adafruit Feather 32u4" +#define OPERATING_VOLTAGE 3.3 +#define BATTERY_PIN 9 +#define BATTERY_MULTIPLIER 2 +#elif defined(ARDUINO_SAMD_FEATHER_M0_EXPRESS) || \ + defined(ADAFRUIT_FEATHER_M0_EXPRESS) +#define LOGGER_BOARD "Adafruit Feather M0 Express" +#define OPERATING_VOLTAGE 3.3 +#define BATTERY_PIN 9 +#define BATTERY_MULTIPLIER 2 +#elif defined(ARDUINO_SAMD_FEATHER_M0) || defined(ADAFRUIT_FEATHER_M0) +#define LOGGER_BOARD "Adafruit Feather M0" +#define OPERATING_VOLTAGE 3.3 +#define BATTERY_PIN 9 +#define BATTERY_MULTIPLIER 2 +#elif defined(ARDUINO_FEATHER_M4) || defined(ADAFRUIT_FEATHER_M4_EXPRESS) +#define LOGGER_BOARD "Adafruit Feather M4" +#define OPERATING_VOLTAGE 3.3 +#define BATTERY_PIN 9 +#define BATTERY_MULTIPLIER 2 +#elif defined(ARDUINO_FEATHER_M4_CAN) || defined(ADAFRUIT_FEATHER_M4_CAN) +#define LOGGER_BOARD "Feather M4 CAN" +#define OPERATING_VOLTAGE 3.3 +#define BATTERY_PIN 9 +#define BATTERY_MULTIPLIER 2 +#elif defined(ADAFRUIT_FEATHER_M4_ADALOGGER) +#define LOGGER_BOARD "Adafruit Feather M4 Adalogger" +#define OPERATING_VOLTAGE 3.3 +#define BATTERY_PIN 9 +#define BATTERY_MULTIPLIER 2 +#elif defined(ADAFRUIT_GRAND_CENTRAL_M4) +#define LOGGER_BOARD "Adafruit Grand Central" +#define OPERATING_VOLTAGE 3.3 +#define BATTERY_PIN -1 +#define BATTERY_MULTIPLIER -1 + +// Arduino boards +#elif defined(ARDUINO_AVR_ADK) +#define LOGGER_BOARD "Arduino Mega ADK" +#define OPERATING_VOLTAGE 5 +#define BATTERY_PIN -1 +#define BATTERY_MULTIPLIER -1 +// Bluetooth +#elif defined(ARDUINO_AVR_BT) +#define LOGGER_BOARD "Arduino BT" +#define OPERATING_VOLTAGE 5 +#define BATTERY_PIN -1 +#define BATTERY_MULTIPLIER -1 +#elif defined(ARDUINO_AVR_DUEMILANOVE) +#define LOGGER_BOARD "Arduino Duemilanove" +#define OPERATING_VOLTAGE 5 +#define BATTERY_PIN -1 +#define BATTERY_MULTIPLIER -1 +#elif defined(ARDUINO_AVR_ESPLORA) +#define LOGGER_BOARD "Arduino Esplora" +#define OPERATING_VOLTAGE 5 +#define BATTERY_PIN -1 +#define BATTERY_MULTIPLIER -1 +#elif defined(ARDUINO_AVR_ETHERNET) +#define LOGGER_BOARD "Arduino Ethernet" +#define OPERATING_VOLTAGE 5 +#define BATTERY_PIN -1 +#define BATTERY_MULTIPLIER -1 +#elif defined(ARDUINO_AVR_FIO) +#define LOGGER_BOARD "Arduino Fio" +#define OPERATING_VOLTAGE 3.3 +#define BATTERY_PIN -1 +#define BATTERY_MULTIPLIER -1 +#elif defined(ARDUINO_AVR_GEMMA) +#define LOGGER_BOARD "Arduino Gemma" +#define OPERATING_VOLTAGE 3.3 +#define BATTERY_PIN -1 +#define BATTERY_MULTIPLIER -1 +#elif defined(ARDUINO_AVR_LEONARDO) +#define LOGGER_BOARD "Arduino Leonardo" +#define OPERATING_VOLTAGE 5 +#define BATTERY_PIN -1 +#define BATTERY_MULTIPLIER -1 +#elif defined(ARDUINO_AVR_LILYPAD) +#define LOGGER_BOARD "Arduino Lilypad" +// NOTE: The operating voltage is 2.7-5.5V +#define OPERATING_VOLTAGE 3.3 +#define BATTERY_PIN -1 +#define BATTERY_MULTIPLIER -1 +#elif defined(ARDUINO_AVR_LILYPAD_USB) +#define LOGGER_BOARD "Arduino Lilypad USB" +#define OPERATING_VOLTAGE 3.3 +#define BATTERY_PIN -1 +#define BATTERY_MULTIPLIER -1 +#elif defined(ARDUINO_AVR_MEGA) +#define LOGGER_BOARD "Arduino Mega" +#define OPERATING_VOLTAGE 5 +#define BATTERY_PIN -1 +#define BATTERY_MULTIPLIER -1 +#elif defined(ARDUINO_AVR_MEGA2560) +#define LOGGER_BOARD "Arduino Mega 2560" +#define OPERATING_VOLTAGE 5 +#define BATTERY_PIN -1 +#define BATTERY_MULTIPLIER -1 +#elif defined(ARDUINO_AVR_MICRO) +#define LOGGER_BOARD "Arduino Micro" +#define OPERATING_VOLTAGE 5 +#define BATTERY_PIN -1 +#define BATTERY_MULTIPLIER -1 +#elif defined(ARDUINO_AVR_MINI) +#define LOGGER_BOARD "Arduino Mini 05" +#define OPERATING_VOLTAGE 5 +#define BATTERY_PIN -1 +#define BATTERY_MULTIPLIER -1 +#elif defined(ARDUINO_AVR_NANO) +#define LOGGER_BOARD "Arduino Nano" +#define OPERATING_VOLTAGE 5 +#define BATTERY_PIN -1 +#define BATTERY_MULTIPLIER -1 +#elif defined(ARDUINO_AVR_NG) +#define LOGGER_BOARD "Arduino NG" +// WARNING: I can't find confirmation of the operating voltage online! +#define OPERATING_VOLTAGE 5 +#define BATTERY_PIN -1 +#define BATTERY_MULTIPLIER -1 +#elif defined(ARDUINO_AVR_PRO) +#define LOGGER_BOARD "Arduino Pro" +// NOTE: The operating voltage is 3.3V or 5V depending on the model +#define OPERATING_VOLTAGE 5 +#define BATTERY_PIN -1 +#define BATTERY_MULTIPLIER -1 +#elif defined(ARDUINO_AVR_UNO) +#define LOGGER_BOARD "Arduino Uno" +#define OPERATING_VOLTAGE 5 +#define BATTERY_PIN -1 +#define BATTERY_MULTIPLIER -1 +#elif defined(ARDUINO_AVR_YUN) +#define LOGGER_BOARD "Arduino Yun" +#define OPERATING_VOLTAGE 5 +#define BATTERY_PIN -1 +#define BATTERY_MULTIPLIER -1 +#elif defined(ARDUINO_SAMD_ZERO) +#define LOGGER_BOARD "Arduino Zero" +#define OPERATING_VOLTAGE 3.3 +#define BATTERY_PIN -1 +#define BATTERY_MULTIPLIER -1 +#endif + +// Print warnings if expected processor defines are missing +#ifndef OPERATING_VOLTAGE +#define OPERATING_VOLTAGE 3.3 +#pragma message \ + "Warning: OPERATING_VOLTAGE is not defined for this processor.\n" \ + "If you have specified the operating voltage in your code, you can ignore this message\n." \ + "The operating voltage can be added by editing KnownProcessors.h." +#endif + +#endif diff --git a/src/sensors/ProcessorAnalog.cpp b/src/sensors/ProcessorAnalog.cpp new file mode 100644 index 000000000..eacd5e8b4 --- /dev/null +++ b/src/sensors/ProcessorAnalog.cpp @@ -0,0 +1,62 @@ +/** + * @file ProcessorAnalog.cpp * + * @copyright Stroud Water Research Center + * Part of the EnviroDIY ModularSensors library for Arduino. + * This library is published under the BSD-3 license. + * @author Sara Geleskie Damiano + * + * @brief Implements the ProcessorAnalog class. + */ + + +#include "ProcessorAnalog.h" + + +// The constructor - need the power pin, the data pin, the voltage divider +// value, and the operating voltage +ProcessorAnalog::ProcessorAnalog(int8_t powerPin, uint8_t dataPin, + float voltageMultiplier, + float operatingVoltage, + uint8_t measurementsToAverage) + : Sensor("ProcessorAnalog", PROCESSOR_ANALOG_NUM_VARIABLES, + PROCESSOR_ANALOG_WARM_UP_TIME_MS, + PROCESSOR_ANALOG_STABILIZATION_TIME_MS, + PROCESSOR_ANALOG_MEASUREMENT_TIME_MS, powerPin, dataPin, + measurementsToAverage, PROCESSOR_ANALOG_INC_CALC_VARIABLES), + _voltageMultiplier(voltageMultiplier), + _operatingVoltage(operatingVoltage) {} +// Destructor +ProcessorAnalog::~ProcessorAnalog() {} + + +bool ProcessorAnalog::addSingleMeasurementResult(void) { + // Immediately quit if the measurement was not successfully started + if (!getStatusBit(MEASUREMENT_SUCCESSFUL)) { + return bumpMeasurementAttemptCount(false); + } + if (_dataPin < 0 && _voltageMultiplier <= 0) { + MS_DBG(F("No analog pin or voltage divider specified!")); + return bumpMeasurementAttemptCount(false); + } + + MS_DBG(getSensorNameAndLocation(), F("is reporting:")); + + float sensorValue_analog = -9999; + // Get the analog voltage + MS_DBG(F("Getting analog voltage from pin"), _dataPin); + pinMode(_dataPin, INPUT); + analogRead(_dataPin); // priming reading + // The return value from analogRead() is IN BITS NOT IN VOLTS!! + analogRead(_dataPin); // another priming reading + float rawAnalog = analogRead(_dataPin); + MS_DBG(F("Raw analog pin reading in bits:"), rawAnalog); + // convert bits to volts + sensorValue_analog = + (_operatingVoltage / static_cast(PROCESSOR_ADC_MAX)) * + _voltageMultiplier * rawAnalog; + MS_DBG(F("Voltage:"), sensorValue_analog); + // NOTE: We don't actually have any criteria for if the reading was any + // good or not, so we mark it as successful no matter what. + verifyAndAddMeasurementResult(PROCESSOR_ANALOG_VAR_NUM, sensorValue_analog); + return bumpMeasurementAttemptCount(true); +} diff --git a/src/sensors/ProcessorAnalog.h b/src/sensors/ProcessorAnalog.h new file mode 100644 index 000000000..178e60745 --- /dev/null +++ b/src/sensors/ProcessorAnalog.h @@ -0,0 +1,258 @@ +/** + * @file ProcessorAnalog.h * + * @copyright Stroud Water Research Center + * Part of the EnviroDIY ModularSensors library for Arduino. + * This library is published under the BSD-3 license. + * @author Sara Geleskie Damiano + * + * @brief This file contains the ProcessorAnalog sensor subclass and the + * ProcessorAnalog_Voltage variable subclass. + * + * These are used for any voltage measurable on an analog processor pin. There + * is a multiplier allowed for a voltage divider between the raw voltage and the + * processor pin. + */ +/** + * @defgroup sensor_processor_analog Processor Analog Voltage Sensor + * Classes for simple external analog voltage measurements using the built-in + * processor ADC. + * + * @ingroup analog_group + * + * @tableofcontents + * @m_footernavigation + * + * @section sensor_processor_analog_intro Introduction + * + * The Processor Analog module is used for any case where the voltage itself is + * the desired value (as for an external battery) and the voltage will be + * measured on a processor pin using the built-in ADC. It can also be used in + * combination with a calculated variable to support any other analog sensor not + * explicitly supported by ModularSensors. To increase the range available for + * voltage measurements, this module supports the use of a voltage divider. + * + * @section sensor_processor_analog_flags Build flags + * - `-D MS_PROCESSOR_ADC_RESOLUTION=##` + * - used to set the resolution of the processor ADC + * - @see #MS_PROCESSOR_ADC_RESOLUTION + * - `-D MS_PROCESSOR_ADC_REFERENCE_MODE=xxx` + * - used to set the processor ADC value reference mode + * - @see #MS_PROCESSOR_ADC_REFERENCE_MODE + * + * @section sensor_processor_analog_ctor Sensor Constructor + * {{ @ref ProcessorAnalog::ProcessorAnalog }} + * + * ___ + * @section sensor_processor_analog_examples Example Code + * The processor analog voltage sensor is used in the + * @menulink{processor_analog} example. + * + * @menusnip{processor_analog} + */ + +// Header Guards +#ifndef SRC_SENSORS_PROCESSOR_ANALOG_H_ +#define SRC_SENSORS_PROCESSOR_ANALOG_H_ + +// Include the library config before anything else +#include "ModSensorConfig.h" + +// Include the debugging config +#include "ModSensorDebugConfig.h" + +// Include the known processors for default values +#include "KnownProcessors.h" + +// Define the print label[s] for the debugger +#ifdef MS_PROCESSOR_ANALOG_DEBUG +#define MS_DEBUGGING_STD "ProcessorAnalog" +#endif + +// Include the debugger +#include "ModSensorDebugger.h" +// Undefine the debugger label[s] +#undef MS_DEBUGGING_STD + +// Include other in-library and external dependencies +#include "VariableBase.h" +#include "SensorBase.h" + +/** @ingroup sensor_processor_analog */ +/**@{*/ + +/** + * @anchor sensor_processor_analog_var_counts + * @name Sensor Variable Counts + * The number of variables that can be returned from an analog reading on a + * processor pin. + */ +/**@{*/ +/// @brief Sensor::_numReturnedValues; an analog reading on a processor pin is 1 +/// value. +#define PROCESSOR_ANALOG_NUM_VARIABLES 1 +/// @brief Sensor::_incCalcValues; we don't calculate any additional values. +#define PROCESSOR_ANALOG_INC_CALC_VARIABLES 0 +/**@}*/ + +/** + * @anchor sensor_processor_analog_timing + * @name Sensor Timing + * The sensor timing for the processor ADC + */ +/**@{*/ +/// @brief Sensor::_warmUpTime_ms; the processor ADC does not need to warm up, +#define PROCESSOR_ANALOG_WARM_UP_TIME_MS 0 +/** + * @brief Sensor::_stabilizationTime_ms; the processor ADC is stable 0ms after + * warm-up - we assume a voltage is instantly ready. + * + * It's not really *quite* instantly, but it is very fast and the time to + * measure is included in the read function. + * On ATmega based boards (UNO, Nano, Mini, Mega), it takes about 100 + * microseconds (0.0001 s) to read an analog input, so the maximum reading rate + * is about 10,000 times a second. + */ +#define PROCESSOR_ANALOG_STABILIZATION_TIME_MS 0 +/** + * @brief Sensor::_measurementTime_ms; the processor ADC measurement time is + * variable, but we assume it is effectively instant. + */ +#define PROCESSOR_ANALOG_MEASUREMENT_TIME_MS 0 +/**@}*/ + +/** + * @anchor sensor_processor_analog_volt + * @name Voltage + * The voltage variable for the processor analog voltage sensor + * - Range is dependent on the supply voltage and any voltage divider + * + * {{ @ref ProcessorAnalog_Voltage::ProcessorAnalog_Voltage }} + */ +/**@{*/ +/// Variable number; voltage is stored in sensorValues[0]. +#define PROCESSOR_ANALOG_VAR_NUM 0 +/// @brief Variable name in +/// [ODM2 controlled vocabulary](http://vocabulary.odm2.org/variablename/); +/// "voltage" +#define PROCESSOR_ANALOG_VAR_NAME "voltage" +/// @brief Variable unit name in +/// [ODM2 controlled vocabulary](http://vocabulary.odm2.org/units/); "volt" +#define PROCESSOR_ANALOG_UNIT_NAME "volt" +/// @brief Default variable short code; "analogVoltage" +#define PROCESSOR_ANALOG_DEFAULT_CODE "analogVoltage" + +#if MS_PROCESSOR_ADC_RESOLUTION == 12 +/// @brief Decimals places in string representation; a 3.3V processor at 12-bit +/// resolution should have 4 [3.3V / 4096 ~= 0.0008] . +#define PROCESSOR_ANALOG_RESOLUTION 4 +#elif MS_PROCESSOR_ADC_RESOLUTION == 10 +/// @brief Decimals places in string representation; a 3.3V processor at 10-bit +/// resolution should have 3 [3.3V / 1024 ~= 0.0032] . +#define PROCESSOR_ANALOG_RESOLUTION 3 +#endif +/**@}*/ + +/* clang-format off */ +/** + * @brief The Sensor sub-class for the + * [external voltage as measured by the processor ADC](@ref sensor_processor_analog). + * + * @ingroup sensor_processor_analog + */ +/* clang-format on */ +class ProcessorAnalog : public Sensor { + public: + /** + * @brief Construct a new Processor Analog object - need the power pin and + * the data pin on the processor. + * + * The gain value and number of measurements to average are optional. If + * nothing is given a 1x gain is used. + * + * @note ModularSensors only supports connecting the ADS1x15 to the primary + * hardware I2C instance defined in the Arduino core. Connecting the ADS to + * a secondary hardware or software I2C instance is *not* supported! + * + * @param powerPin The pin on the mcu controlling power to the sensor + * Use -1 if it is continuously powered. + * @param dataPin The processor ADC port pin to read the voltage from the EC + * probe. Not all processor pins can be used as analog pins. Those usable + * as analog pins generally are numbered with an "A" in front of the number + * - ie, A1. + * @param voltageMultiplier Any multiplier needed to convert raw battery + * readings from `analogRead()` into true battery values based on any + * resistors or voltage dividers + * @param operatingVoltage The processor's operating voltage; most + * likely 3.3 or 5. + * @param measurementsToAverage The number of measurements to take and + * average before giving a "final" result from the sensor; optional with a + * default value of 1. + */ + ProcessorAnalog(int8_t powerPin, uint8_t dataPin, float voltageMultiplier, + float operatingVoltage = OPERATING_VOLTAGE, + uint8_t measurementsToAverage = 1); + /** + * @brief Destroy the Processor Analog object + */ + ~ProcessorAnalog(); + + bool addSingleMeasurementResult(void) override; + + private: + float _voltageMultiplier; ///< Internal reference to any multiplier needed + ///< to convert raw battery readings into true + ///< battery values based on any resistors or + ///< voltage dividers + float _operatingVoltage; ///< Internal reference to processor's operating + ///< voltage +}; + + +// The single available variable is voltage +/* clang-format off */ +/** + * @brief The Variable sub-class used for the + * [voltage output](@ref sensor_processor_analog_volt) from a + * [analog processor pin](@ref sensor_processor_analog). + * + * @ingroup sensor_processor_analog + */ +/* clang-format on */ +class ProcessorAnalog_Voltage : public Variable { + public: + /** + * @brief Construct a new ProcessorAnalog_Voltage object. + * + * @param parentSense The parent ProcessorAnalog providing the result + * values. + * @param uuid A universally unique identifier (UUID or GUID) for the + * variable; optional with the default value of an empty string. + * @param varCode A short code to help identify the variable in files; + * optional with a default value of "extVoltage". + */ + explicit ProcessorAnalog_Voltage( + ProcessorAnalog* parentSense, const char* uuid = "", + const char* varCode = PROCESSOR_ANALOG_DEFAULT_CODE) + : Variable(parentSense, (uint8_t)PROCESSOR_ANALOG_VAR_NUM, + (uint8_t)PROCESSOR_ANALOG_RESOLUTION, + PROCESSOR_ANALOG_VAR_NAME, PROCESSOR_ANALOG_UNIT_NAME, + varCode, uuid) {} + /** + * @brief Construct a new ProcessorAnalog_Voltage object. + * + * @note This must be tied with a parent ProcessorAnalog before it can be + * used. + */ + ProcessorAnalog_Voltage() + : Variable((uint8_t)PROCESSOR_ANALOG_VAR_NUM, + (uint8_t)PROCESSOR_ANALOG_RESOLUTION, + PROCESSOR_ANALOG_VAR_NAME, PROCESSOR_ANALOG_UNIT_NAME, + PROCESSOR_ANALOG_DEFAULT_CODE) {} + /** + * @brief Destroy the ProcessorAnalog_Voltage object - no action needed. + */ + ~ProcessorAnalog_Voltage() {} +}; + +/**@}*/ +#endif // SRC_SENSORS_PROCESSOR_ANALOG_H_ diff --git a/src/sensors/ProcessorStats.cpp b/src/sensors/ProcessorStats.cpp index 75fe9b7e5..2c0afca2d 100644 --- a/src/sensors/ProcessorStats.cpp +++ b/src/sensors/ProcessorStats.cpp @@ -19,48 +19,18 @@ ProcessorStats::ProcessorStats(const char* version, -1, measurementsToAverage, PROCESSOR_INC_CALC_VARIABLES), _version(version), _boardName(LOGGER_BOARD) { - // change the battery related settings for known boards + _operatingVoltage = OPERATING_VOLTAGE; + _batteryPin = BATTERY_PIN; + _batteryMultiplier = BATTERY_MULTIPLIER; + + // change the battery related settings for known boards where the pin or + // multiplier is version dependent #if defined(ARDUINO_AVR_ENVIRODIY_MAYFLY) - _operatingVoltage = 3.3; - _batteryPin = A6; + // fix battery multiplier for older Mayfly versions if (strcmp(_version, "v0.3") == 0 || strcmp(_version, "v0.4") == 0) { _batteryMultiplier = 1.47; - } else if (strcmp(_version, "v0.5") == 0 || strcmp(_version, "v0.5b") || - strcmp(_version, "v1.0") || strcmp(_version, "v1.1") == 0) { - _batteryMultiplier = 4.7; - } else { - _batteryPin = -1; - _batteryMultiplier = -1; - } -#elif defined(ENVIRODIY_STONEFLY_M4) - if (strcmp(_version, "v0.1") == 0) { - _operatingVoltage = 3.3; - _batteryPin = A9; // aka 75 - _batteryMultiplier = 4.7; - } else { - _batteryPin = -1; - _batteryMultiplier = -1; } -#elif defined(ARDUINO_AVR_FEATHER328P) || defined(ARDUINO_AVR_FEATHER32U4) || \ - defined(ARDUINO_SAMD_FEATHER_M0) || defined(SAMD_FEATHER_M0) || \ - defined(ARDUINO_SAMD_FEATHER_M0_EXPRESS) || \ - defined(SAMD_FEATHER_M0_EXPRESS) || defined(ARDUINO_FEATHER_M4) || \ - defined(ADAFRUIT_FEATHER_M4_EXPRESS) || defined(ARDUINO_FEATHER_M4_CAN) || \ - defined(ADAFRUIT_FEATHER_M4_CAN) || defined(ADAFRUIT_FEATHER_M4_ADALOGGER) - _operatingVoltage = 3.3; - _batteryPin = 9; - _batteryMultiplier = 2; -#elif defined(ARDUINO_AVR_SODAQ_MBILI) - _operatingVoltage = 3.3; - _batteryPin = A6; - _batteryMultiplier = 1.47; -#elif defined(ARDUINO_AVR_SODAQ_NDOGO) - _operatingVoltage = 3.3; - _batteryPin = 10; - _batteryMultiplier = 1.47; #elif defined(ARDUINO_SODAQ_ONE) || defined(ARDUINO_SODAQ_ONE_BETA) - _operatingVoltage = 3.3; - _batteryPin = 10; if (strcmp(_version, "v0.1") == 0) { _batteryMultiplier = 2; } else if (strcmp(_version, "v0.2") == 0) { @@ -69,15 +39,10 @@ ProcessorStats::ProcessorStats(const char* version, _batteryMultiplier = -1 } #elif defined(ARDUINO_SODAQ_AUTONOMO) - _operatingVoltage = 3.3; - _batteryMultiplier = 1.47; if (strcmp(_version, "v0.1") == 0) _batteryPin = 48; else _batteryPin = 33; -#else - _batteryPin = -1; - _batteryMultiplier = -1; #endif } diff --git a/src/sensors/ProcessorStats.h b/src/sensors/ProcessorStats.h index 16d35e0ab..0381b01e9 100644 --- a/src/sensors/ProcessorStats.h +++ b/src/sensors/ProcessorStats.h @@ -62,6 +62,9 @@ // Include the debugging config #include "ModSensorDebugConfig.h" +// Include the known processors for default values +#include "KnownProcessors.h" + // Define the print label[s] for the debugger #ifdef MS_PROCESSORSTATS_DEBUG #define MS_DEBUGGING_STD "ProcessorStats" @@ -76,6 +79,32 @@ #include "VariableBase.h" #include "SensorBase.h" +// Print warnings if expected processor defines are missing + +#ifndef LOGGER_BOARD +#define LOGGER_BOARD "Unknown" +#pragma message "Warning: LOGGER_BOARD is not defined for this processor.\n" \ + "The board name can be added by editing KnownProcessors.h." +#endif + +#ifndef BATTERY_PIN +#define BATTERY_PIN -1 +#pragma message \ + "Warning: BATTERY_PIN is not defined for this processor.\n" \ + "If your processor does not have a built-in pin for measuring the battery voltage," \ + "or you have specified a different pin in your code, you can ignore this message\n." \ + "The battery pin can be added by editing KnownProcessors.h." +#endif + +#ifndef BATTERY_MULTIPLIER +#define BATTERY_MULTIPLIER -1 +#pragma message \ + "Warning: BATTERY_MULTIPLIER is not defined for this processor.\n" \ + "If your processor does not have a built-in pin for measuring the battery voltage," \ + "or you have specified the multiplier in your code, you can ignore this message\n." \ + "The battery multiplier can be added by editing KnownProcessors.h." +#endif + /** @ingroup sensor_processor */ /**@{*/ @@ -234,106 +263,6 @@ #define PROCESSOR_RESET_DEFAULT_CODE "ResetCode" /**@}*/ -/** - * @def LOGGER_BOARD - * @brief Pretty text for the board name derived from the board's compiler - * define. - */ - -// EnviroDIY boards -#if defined(ARDUINO_AVR_ENVIRODIY_MAYFLY) -#define LOGGER_BOARD "EnviroDIY Mayfly" -#elif defined(ENVIRODIY_STONEFLY_M4) -#define LOGGER_BOARD "EnviroDIY Stonefly" - -// Sodaq boards -#elif defined(ARDUINO_SODAQ_EXPLORER) -#define LOGGER_BOARD "SODAQ ExpLoRer" -#elif defined(ARDUINO_SODAQ_AUTONOMO) -#define LOGGER_BOARD "SODAQ Autonomo" -#elif defined(ARDUINO_SODAQ_ONE_BETA) -#define LOGGER_BOARD "SODAQ ONE Beta" -#elif defined(ARDUINO_SODAQ_ONE) -#define LOGGER_BOARD "SODAQ ONE" -#elif defined(ARDUINO_AVR_SODAQ_MBILI) -#define LOGGER_BOARD "SODAQ Mbili" -#elif defined(ARDUINO_AVR_SODAQ_NDOGO) -#define LOGGER_BOARD "SODAQ Ndogo" -#elif defined(ARDUINO_AVR_SODAQ_TATU) -#define LOGGER_BOARD "SODAQ Tatu" -#elif defined(ARDUINO_AVR_SODAQ_MOJA) -#define LOGGER_BOARD "SODAQ Moja" - -// Adafruit boards -#elif defined(ARDUINO_AVR_FEATHER328P) -#define LOGGER_BOARD "Feather 328p" -#elif defined(ARDUINO_AVR_FEATHER32U4) -#define LOGGER_BOARD "Feather 32u4" -#elif defined(ARDUINO_SAMD_FEATHER_M0_EXPRESS) || \ - defined(ADAFRUIT_FEATHER_M0_EXPRESS) -#define LOGGER_BOARD "Feather M0 Express" -#elif defined(ARDUINO_SAMD_FEATHER_M0) || defined(ADAFRUIT_FEATHER_M0) -#define LOGGER_BOARD "Feather M0" -#elif defined(ADAFRUIT_GRAND_CENTRAL_M4) -#define LOGGER_BOARD "Grand Central" -#elif defined(ADAFRUIT_FEATHER_M4_ADALOGGER) -#define LOGGER_BOARD "Feather M4 Adalogger" -#elif defined(ARDUINO_FEATHER_M4_CAN) || defined(ADAFRUIT_FEATHER_M4_CAN) -#define LOGGER_BOARD "Feather M4 CAN" -#elif defined(ARDUINO_FEATHER_M4) || defined(ADAFRUIT_FEATHER_M4_EXPRESS) -#define LOGGER_BOARD "Feather M4" - -// Arduino boards -#elif defined(ARDUINO_AVR_ADK) -#define LOGGER_BOARD "Mega Adk" -// Bluetooth -#elif defined(ARDUINO_AVR_BT) -#define LOGGER_BOARD "Bt" -#elif defined(ARDUINO_AVR_DUEMILANOVE) -#define LOGGER_BOARD "Duemilanove" -#elif defined(ARDUINO_AVR_ESPLORA) -#define LOGGER_BOARD "Esplora" -#elif defined(ARDUINO_AVR_ETHERNET) -#define LOGGER_BOARD "Ethernet" -#elif defined(ARDUINO_AVR_FIO) -#define LOGGER_BOARD "Fio" -#elif defined(ARDUINO_AVR_GEMMA) -#define LOGGER_BOARD "Gemma" -#elif defined(ARDUINO_AVR_LEONARDO) -#define LOGGER_BOARD "Leonardo" -#elif defined(ARDUINO_AVR_LILYPAD) -#define LOGGER_BOARD "Lilypad" -#elif defined(ARDUINO_AVR_LILYPAD_USB) -#define LOGGER_BOARD "Lilypad Usb" -#elif defined(ARDUINO_AVR_MEGA) -#define LOGGER_BOARD "Mega" -#elif defined(ARDUINO_AVR_MEGA2560) -#define LOGGER_BOARD "Mega 2560" -#elif defined(ARDUINO_AVR_MICRO) -#define LOGGER_BOARD "Micro" -#elif defined(ARDUINO_AVR_MINI) -#define LOGGER_BOARD "Mini" -#elif defined(ARDUINO_AVR_NANO) -#define LOGGER_BOARD "Nano" -#elif defined(ARDUINO_AVR_NG) -#define LOGGER_BOARD "NG" -#elif defined(ARDUINO_AVR_PRO) -#define LOGGER_BOARD "Pro" -#elif defined(ARDUINO_AVR_ROBOT_CONTROL) -#define LOGGER_BOARD "Robot Ctrl" -#elif defined(ARDUINO_AVR_ROBOT_MOTOR) -#define LOGGER_BOARD "Robot Motor" -#elif defined(ARDUINO_AVR_UNO) -#define LOGGER_BOARD "Uno" -#elif defined(ARDUINO_AVR_YUN) -#define LOGGER_BOARD "Yun" -#elif defined(ARDUINO_SAMD_ZERO) -#define LOGGER_BOARD "Zero" - -#else -#define LOGGER_BOARD "Unknown" -#endif - // The main class for the Processor // Only need a sleep and wake since these DON'T use the default of powering @@ -407,8 +336,10 @@ class ProcessorStats : public Sensor { * voltage measurement! */ ProcessorStats(const char* boardName, const char* version, - int8_t batteryPin, float batteryMultiplier, - float operatingVoltage, uint8_t measurementsToAverage = 1); + int8_t batteryPin = BATTERY_PIN, + float batteryMultiplier = BATTERY_MULTIPLIER, + float operatingVoltage = OPERATING_VOLTAGE, + uint8_t measurementsToAverage = 1); /** * @brief Destroy the Processor Stats object */ From e54d9a71e99a25c605c1989defcc4a3bdec346f4 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Wed, 1 Oct 2025 11:56:52 -0400 Subject: [PATCH 054/533] Add new sensor to the menu example Signed-off-by: Sara Damiano --- examples/menu_a_la_carte/menu_a_la_carte.ino | 36 +++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/examples/menu_a_la_carte/menu_a_la_carte.ino b/examples/menu_a_la_carte/menu_a_la_carte.ino index d4ce028ec..05cd6a80c 100644 --- a/examples/menu_a_la_carte/menu_a_la_carte.ino +++ b/examples/menu_a_la_carte/menu_a_la_carte.ino @@ -1633,6 +1633,32 @@ Variable* ads1x15Volt = #endif +#if defined(BUILD_SENSOR_PROCESSOR_ANALOG) +// ========================================================================== +// External Voltage via Processor ADC +// ========================================================================== +/** Start [processor_analog] */ +#include + +// NOTE: Use -1 for any pins that don't apply or aren't being used. +const int8_t externalAnalogPowerPin = sensorPowerPin; // Power pin +const int8_t externalAnalogDataPin = A0; // The ADS channel of interest +const float externalAnalogMultipler = + 5.58; // Gain setting if using a voltage divider +const uint8_t eaReadsToAvg = 1; // Only read one sample + +// Create an External Voltage sensor object +ProcessorAnalog extAnalog(externalAnalogPowerPin, externalAnalogDataPin, + externalAnalogMultipler, OPERATING_VOLTAGE, + eaReadsToAvg); + +// Create a voltage variable pointer +Variable* extBatteryVolts = new ProcessorAnalog_Voltage( + &extAnalog, "12345678-abcd-1234-ef00-1234567890ab"); +/** End [processor_analog] */ +#endif + + #if defined(BUILD_SENSOR_FREESCALE_MPL115A2) // ========================================================================== // Freescale Semiconductor MPL115A2 Barometer @@ -3095,6 +3121,9 @@ Variable* variableList[] = { #if defined(BUILD_SENSOR_TIADS1X15) ads1x15Volt, #endif +#if defined(BUILD_SENSOR_PROCESSOR_ANALOG) + extAnalog, +#endif #if defined(BUILD_SENSOR_FREESCALE_MPL115A2) mplTemp, mplPress, @@ -3581,9 +3610,14 @@ float getBatteryVoltage() { void setup() { /** Start [setup_flashing_led] */ // Blink the LEDs to show the board is on and starting up - greenRedFlash(3, 35); + greenRedFlash(3, 100); /** End [setup_flashing_led] */ + // IMMEDIATELY set up the watchdog timer for 5 minutes + // The watchdog interval will be reset in the data logger's begin() + // function. + extendedWatchDog::setupWatchDog(static_cast(5 * 60)); + /** Start [setup_wait] */ // Wait for USB connection to be established by PC // NOTE: Only use this when debugging - if not connected to a PC, this adds an From 0062b2086a749c7d6d85f494aed4275707f97236 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Wed, 1 Oct 2025 12:10:19 -0400 Subject: [PATCH 055/533] Don't test Mayfly examples on non-Mayflies Signed-off-by: Sara Damiano --- continuous_integration/generate_job_matrix.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/continuous_integration/generate_job_matrix.py b/continuous_integration/generate_job_matrix.py index 45d4fc56a..f5bd77bd7 100644 --- a/continuous_integration/generate_job_matrix.py +++ b/continuous_integration/generate_job_matrix.py @@ -308,6 +308,9 @@ def snake_to_camel(snake_str): if example == "data_saving": # skip this one until I get it updated pass + elif "mayfly" in example.lower() and pio_env != "mayfly": + # skip mayfly examples on non-mayfly builds + pass else: command_list.extend( create_logged_command( From 32220ad60f449224578bb0aed6b1a751a2074a1b Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Wed, 1 Oct 2025 12:13:26 -0400 Subject: [PATCH 056/533] Skip DRWI except on Mayfly and Stonefly Signed-off-by: Sara Damiano --- continuous_integration/generate_job_matrix.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/continuous_integration/generate_job_matrix.py b/continuous_integration/generate_job_matrix.py index f5bd77bd7..3914f6910 100644 --- a/continuous_integration/generate_job_matrix.py +++ b/continuous_integration/generate_job_matrix.py @@ -311,6 +311,11 @@ def snake_to_camel(snake_str): elif "mayfly" in example.lower() and pio_env != "mayfly": # skip mayfly examples on non-mayfly builds pass + elif "drwi" in example.lower() and ( + pio_env != "mayfly" and pio_env != "stonefly" + ): + # skip drwi examples on non-EnviroDIY processor builds + pass else: command_list.extend( create_logged_command( From 1c09b3bc33c6b074b268806bd356b67e96ef23d9 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Wed, 1 Oct 2025 12:27:28 -0400 Subject: [PATCH 057/533] Add to walk through Signed-off-by: Sara Damiano --- examples/menu_a_la_carte/ReadMe.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/examples/menu_a_la_carte/ReadMe.md b/examples/menu_a_la_carte/ReadMe.md index 9807faa6d..a7b8d2a81 100644 --- a/examples/menu_a_la_carte/ReadMe.md +++ b/examples/menu_a_la_carte/ReadMe.md @@ -79,6 +79,7 @@ ___ - [Decagon CTD-10 Conductivity, Temperature, and Depth Sensor](#decagon-ctd-10-conductivity-temperature-and-depth-sensor) - [Decagon ES2 Conductivity and Temperature Sensor](#decagon-es2-conductivity-and-temperature-sensor) - [Everlight ALS-PT19 Ambient Light Sensor](#everlight-als-pt19-ambient-light-sensor) + - [External Voltage via Processor ADC](#external-voltage-via-processor-adc) - [External Voltage via TI ADS1x15](#external-voltage-via-ti-ads1x15) - [Freescale Semiconductor MPL115A2 Miniature I2C Digital Barometer](#freescale-semiconductor-mpl115a2-miniature-i2c-digital-barometer) - [Geolux HydroCam Camera](#geolux-hydrocam-camera) @@ -832,6 +833,18 @@ ___ ___ +### External Voltage via Processor ADC + +The Arduino pin controlling power on/off, the analog data pin on the processor, and the multiplier for a voltage dividor are required for the sensor constructor. +If your processor operating voltage is not correctly in KnownProcessors.h, you must input it is the fourth argument; otherwise you can enter `OPERATING_VOLTAGE` for the voltage defined in KnownProcessors.h. +The number of measurements to average, if more than one is desired, goes as the fifth argument. + +@see @ref sensor_processor_analog + + + +___ + ### External Voltage via TI ADS1x15 The Arduino pin controlling power on/off and the analog data channel *on the TI ADS1115* are required for the sensor constructor. From 5520bd74bbb50ad96019dc58437c06b4a4685103 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Wed, 1 Oct 2025 12:30:49 -0400 Subject: [PATCH 058/533] Fix sensor/variable mixup Signed-off-by: Sara Damiano --- examples/menu_a_la_carte/menu_a_la_carte.ino | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/menu_a_la_carte/menu_a_la_carte.ino b/examples/menu_a_la_carte/menu_a_la_carte.ino index 05cd6a80c..34e1a310c 100644 --- a/examples/menu_a_la_carte/menu_a_la_carte.ino +++ b/examples/menu_a_la_carte/menu_a_la_carte.ino @@ -1643,17 +1643,17 @@ Variable* ads1x15Volt = // NOTE: Use -1 for any pins that don't apply or aren't being used. const int8_t externalAnalogPowerPin = sensorPowerPin; // Power pin const int8_t externalAnalogDataPin = A0; // The ADS channel of interest -const float externalAnalogMultipler = +const float externalAnalogMultiplier = 5.58; // Gain setting if using a voltage divider const uint8_t eaReadsToAvg = 1; // Only read one sample // Create an External Voltage sensor object ProcessorAnalog extAnalog(externalAnalogPowerPin, externalAnalogDataPin, - externalAnalogMultipler, OPERATING_VOLTAGE, + externalAnalogMultiplier, OPERATING_VOLTAGE, eaReadsToAvg); // Create a voltage variable pointer -Variable* extBatteryVolts = new ProcessorAnalog_Voltage( +Variable* extAnalogyVolts = new ProcessorAnalog_Voltage( &extAnalog, "12345678-abcd-1234-ef00-1234567890ab"); /** End [processor_analog] */ #endif @@ -3122,7 +3122,7 @@ Variable* variableList[] = { ads1x15Volt, #endif #if defined(BUILD_SENSOR_PROCESSOR_ANALOG) - extAnalog, + extAnalogyVolts, #endif #if defined(BUILD_SENSOR_FREESCALE_MPL115A2) mplTemp, From afb1ee1a8d82581483590683cd800de7ff15cfd3 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Fri, 24 Oct 2025 12:42:46 -0400 Subject: [PATCH 059/533] Grammar fix; bump some dependencies Signed-off-by: Sara Damiano --- ChangeLog.md | 4 ++-- continuous_integration/dependencies.json | 4 ++-- examples/example_dependencies.json | 2 +- library.json | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/ChangeLog.md b/ChangeLog.md index dc1ab4a18..737a0baf8 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -59,12 +59,12 @@ These values should generally be set in the specific sensor constructors and onl - Remove the unused `_maxSamplesToAverage` parameter of the VariableArray and the `countMaxToAverage()` function which set the parameter. - Removed unnecessary copy doc calls for inherited functions and properties. -- Removed all overrides of the powerUp and powerDown functions that are no-longer needed since all sensors have two power pins built in. +- Removed all overrides of the powerUp and powerDown functions that are no longer needed since all sensors have two power pins built in. ### Fixed - Fixed major bug where sensors with two power pins where either was shared with another sensor may be turned off inappropriately when one of the other sensors was turned off. -- Correctly retry NIST sync on XBees which a not-sane timestamp is return. +- Correctly retry NIST sync on XBees when a not-sane timestamp is returned. *** diff --git a/continuous_integration/dependencies.json b/continuous_integration/dependencies.json index 253bb11e3..837f5befc 100644 --- a/continuous_integration/dependencies.json +++ b/continuous_integration/dependencies.json @@ -1,5 +1,5 @@ { - "action_cache_version": 40, + "action_cache_version": 41, "dependencies": [ { "name": "EnviroDIY_DS3231", @@ -234,7 +234,7 @@ "owner": "milesburton", "library id": "54", "url": "https://github.com/milesburton/Arduino-Temperature-Control-Library", - "version": "~4.0.4", + "version": "~4.0.5", "note": "DallasTemperature - Arduino Library for Dallas Temperature ICs (DS18B20, DS18S20, DS1822, DS1820)", "authors": [ "Guil Barros", diff --git a/examples/example_dependencies.json b/examples/example_dependencies.json index d3f5f117e..845e95456 100644 --- a/examples/example_dependencies.json +++ b/examples/example_dependencies.json @@ -26,7 +26,7 @@ "name": "Adafruit NeoPixel", "owner": "adafruit", "url": "https://github.com/adafruit/Adafruit_NeoPixel", - "version": "~1.15.1", + "version": "~1.15.2", "note": "Adafruit NeoPixel, for boards with a built in NeoPixel", "authors": ["Adafruit"], "frameworks": "arduino" diff --git a/library.json b/library.json index 3b60a2372..5622757a3 100644 --- a/library.json +++ b/library.json @@ -256,7 +256,7 @@ "owner": "milesburton", "library id": "54", "url": "https://github.com/milesburton/Arduino-Temperature-Control-Library", - "version": "~4.0.4", + "version": "~4.0.5", "note": "DallasTemperature - Arduino Library for Dallas Temperature ICs (DS18B20, DS18S20, DS1822, DS1820)", "authors": ["Guil Barros", "Miles Burton", "Rob Tillart", "Tim Nuewsome"], "frameworks": "arduino" From bad28f08381aa36ea34ec79e1b73067d202de7c2 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Fri, 24 Oct 2025 12:51:09 -0400 Subject: [PATCH 060/533] Fix case from getinitialShortIntervals to getInitialShortIntervals Signed-off-by: Sara Damiano --- src/LoggerBase.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/LoggerBase.h b/src/LoggerBase.h index 17d65dac4..bf35e2f64 100644 --- a/src/LoggerBase.h +++ b/src/LoggerBase.h @@ -240,7 +240,7 @@ class Logger { * @return The number of 1-minute intervals at the start before logging * on the regular logging interval */ - int16_t getinitialShortIntervals() { + int16_t getInitialShortIntervals() { return _remainingShortIntervals; } From afc9e45a9bbda2fec8719caa2c55619f8f6c17a7 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Fri, 24 Oct 2025 12:52:58 -0400 Subject: [PATCH 061/533] Apply code rabbit suggestions Signed-off-by: Sara Damiano --- continuous_integration/generate_job_matrix.py | 33 ++++++++----------- src/sensors/SensirionSHT4x.cpp | 1 + 2 files changed, 15 insertions(+), 19 deletions(-) diff --git a/continuous_integration/generate_job_matrix.py b/continuous_integration/generate_job_matrix.py index 3914f6910..05b2a5b97 100644 --- a/continuous_integration/generate_job_matrix.py +++ b/continuous_integration/generate_job_matrix.py @@ -2,7 +2,6 @@ # %% import json import shutil -import re from typing import List from platformio.project.config import ProjectConfig import re @@ -305,26 +304,22 @@ def snake_to_camel(snake_str): for compiler, command_list in zip( compilers, [arduino_ex_commands, pio_ex_commands] ): + # Skip examples that need to be updated or don't apply if example == "data_saving": - # skip this one until I get it updated - pass - elif "mayfly" in example.lower() and pio_env != "mayfly": - # skip mayfly examples on non-mayfly builds - pass - elif "drwi" in example.lower() and ( - pio_env != "mayfly" and pio_env != "stonefly" - ): - # skip drwi examples on non-EnviroDIY processor builds - pass - else: - command_list.extend( - create_logged_command( - compiler=compiler, - group_title=example, - code_subfolder=example, - pio_env=pio_env, - ) + continue # skip until updated + if "mayfly" in example.lower() and pio_env != "mayfly": + continue # skip mayfly examples on non-mayfly builds + if "drwi" in example.lower() and pio_env not in ["mayfly", "stonefly"]: + continue # skip drwi examples on non-EnviroDIY processor builds + + command_list.extend( + create_logged_command( + compiler=compiler, + group_title=example, + code_subfolder=example, + pio_env=pio_env, ) + ) arduino_job_matrix.append( { diff --git a/src/sensors/SensirionSHT4x.cpp b/src/sensors/SensirionSHT4x.cpp index 743d5776e..108f2054b 100644 --- a/src/sensors/SensirionSHT4x.cpp +++ b/src/sensors/SensirionSHT4x.cpp @@ -116,6 +116,7 @@ bool SensirionSHT4x::addSingleMeasurementResult(void) { MS_DBG(F(" Temp:"), temp_val, F("°C")); MS_DBG(F(" Humidity:"), humid_val, '%'); + if (ret_val && !isnan(temp_val) && !isnan(humid_val)) { verifyAndAddMeasurementResult(SHT4X_TEMP_VAR_NUM, temp_val); verifyAndAddMeasurementResult(SHT4X_HUMIDITY_VAR_NUM, humid_val); From f999a688f518f7c29b5c861c95f1791b72a7cb89 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Fri, 24 Oct 2025 14:19:38 -0400 Subject: [PATCH 062/533] Spelling fix Signed-off-by: Sara Damiano --- examples/menu_a_la_carte/ReadMe.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/menu_a_la_carte/ReadMe.md b/examples/menu_a_la_carte/ReadMe.md index a7b8d2a81..738342553 100644 --- a/examples/menu_a_la_carte/ReadMe.md +++ b/examples/menu_a_la_carte/ReadMe.md @@ -835,7 +835,7 @@ ___ ### External Voltage via Processor ADC -The Arduino pin controlling power on/off, the analog data pin on the processor, and the multiplier for a voltage dividor are required for the sensor constructor. +The Arduino pin controlling power on/off, the analog data pin on the processor, and the multiplier for a voltage divider are required for the sensor constructor. If your processor operating voltage is not correctly in KnownProcessors.h, you must input it is the fourth argument; otherwise you can enter `OPERATING_VOLTAGE` for the voltage defined in KnownProcessors.h. The number of measurements to average, if more than one is desired, goes as the fifth argument. From d49e5d0e39d36eeaa34aa568d018565188856f39 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Fri, 24 Oct 2025 14:20:23 -0400 Subject: [PATCH 063/533] Clarify ADS channel instead of pin, fix spelling Signed-off-by: Sara Damiano --- examples/menu_a_la_carte/menu_a_la_carte.ino | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/menu_a_la_carte/menu_a_la_carte.ino b/examples/menu_a_la_carte/menu_a_la_carte.ino index 34e1a310c..413432eff 100644 --- a/examples/menu_a_la_carte/menu_a_la_carte.ino +++ b/examples/menu_a_la_carte/menu_a_la_carte.ino @@ -1642,18 +1642,18 @@ Variable* ads1x15Volt = // NOTE: Use -1 for any pins that don't apply or aren't being used. const int8_t externalAnalogPowerPin = sensorPowerPin; // Power pin -const int8_t externalAnalogDataPin = A0; // The ADS channel of interest +const int8_t externalAnalogDataChannel = A0; // The ADS channel of interest const float externalAnalogMultiplier = 5.58; // Gain setting if using a voltage divider const uint8_t eaReadsToAvg = 1; // Only read one sample // Create an External Voltage sensor object -ProcessorAnalog extAnalog(externalAnalogPowerPin, externalAnalogDataPin, +ProcessorAnalog extAnalog(externalAnalogPowerPin, externalAnalogDataChannel, externalAnalogMultiplier, OPERATING_VOLTAGE, eaReadsToAvg); // Create a voltage variable pointer -Variable* extAnalogyVolts = new ProcessorAnalog_Voltage( +Variable* extAnalogVolts = new ProcessorAnalog_Voltage( &extAnalog, "12345678-abcd-1234-ef00-1234567890ab"); /** End [processor_analog] */ #endif @@ -3122,7 +3122,7 @@ Variable* variableList[] = { ads1x15Volt, #endif #if defined(BUILD_SENSOR_PROCESSOR_ANALOG) - extAnalogyVolts, + extAnalogVolts, #endif #if defined(BUILD_SENSOR_FREESCALE_MPL115A2) mplTemp, From 3bc90252cd44064c02753cbabf904ae0b91fe13a Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Fri, 24 Oct 2025 14:21:11 -0400 Subject: [PATCH 064/533] Add max values and out-of-range debug print Signed-off-by: Sara Damiano --- src/sensors/FreescaleMPL115A2.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/sensors/FreescaleMPL115A2.cpp b/src/sensors/FreescaleMPL115A2.cpp index ca968796f..d017538f1 100644 --- a/src/sensors/FreescaleMPL115A2.cpp +++ b/src/sensors/FreescaleMPL115A2.cpp @@ -77,10 +77,13 @@ bool FreescaleMPL115A2::addSingleMeasurementResult(void) { MS_DBG(F(" Temperature:"), temp); MS_DBG(F(" Pressure:"), press); - if (!isnan(temp) && !isnan(press) && press <= 115.0 && temp >= -40.0) { + if (!isnan(temp) && !isnan(press) && press >= 50.0 && press <= 115.0 && + temp >= -40.0 && temp <= 105.0) { verifyAndAddMeasurementResult(MPL115A2_TEMP_VAR_NUM, temp); verifyAndAddMeasurementResult(MPL115A2_PRESSURE_VAR_NUM, press); success = true; + } else { + MS_DBG(F(" Values outside expected range or invalid")); } // Return success value when finished From f73547ab3f562c072c48756087aea3376b9b04fc Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Fri, 24 Oct 2025 14:21:41 -0400 Subject: [PATCH 065/533] Return bump measurement when SD fails for consistency with other returns Signed-off-by: Sara Damiano --- src/sensors/GeoluxHydroCam.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/sensors/GeoluxHydroCam.cpp b/src/sensors/GeoluxHydroCam.cpp index 7273e6a93..76a99f2ec 100644 --- a/src/sensors/GeoluxHydroCam.cpp +++ b/src/sensors/GeoluxHydroCam.cpp @@ -203,7 +203,9 @@ bool GeoluxHydroCam::addSingleMeasurementResult(void) { // Initialise the SD card // skip everything else if there's no SD card, otherwise it might hang - if (!_baseLogger->initializeSDCard()) return false; + if (!_baseLogger->initializeSDCard()) { + return bumpMeasurementAttemptCount(false); + } // Create and then open the file in write mode if (imgFile.open(filename.c_str(), O_CREAT | O_WRITE | O_AT_END)) { From f5106a771f4f442ab5106f65eaa906eac87aa2d4 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Fri, 24 Oct 2025 14:22:23 -0400 Subject: [PATCH 066/533] Add default case for invalid mux config Signed-off-by: Sara Damiano --- src/sensors/TurnerTurbidityPlus.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/sensors/TurnerTurbidityPlus.cpp b/src/sensors/TurnerTurbidityPlus.cpp index bdbea215b..fcf1cda3e 100644 --- a/src/sensors/TurnerTurbidityPlus.cpp +++ b/src/sensors/TurnerTurbidityPlus.cpp @@ -148,6 +148,10 @@ bool TurnerTurbidityPlus::addSingleMeasurementResult(void) { adcCounts = ads.readADC_Differential_2_3(); break; } + default: { + MS_DBG(F(" Invalid differential mux configuration")); + return bumpMeasurementAttemptCount(false); + } } // Convert ADC counts value to voltage (V) adcVoltage = ads.computeVolts(adcCounts); From 3cd086ab1a482ab8d0bda85c4a3e0cad20292a38 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Fri, 24 Oct 2025 14:22:56 -0400 Subject: [PATCH 067/533] Clarify what's unique about the wake function and why. Signed-off-by: Sara Damiano --- src/sensors/YosemitechParent.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/sensors/YosemitechParent.h b/src/sensors/YosemitechParent.h index 82d0fd2e4..a8a6e9655 100644 --- a/src/sensors/YosemitechParent.h +++ b/src/sensors/YosemitechParent.h @@ -223,6 +223,17 @@ class YosemitechParent : public Sensor { * @return True if the setup was successful. */ bool setup(void) override; + /** + * @brief Wakes the sensor, starts measurements, and activates brushes. + * + * Unlike base Sensor::wake(), this starts measurements and activates the + * brushes (where applicable). Yosemitech sensors do not start to stabilize + * until after starting measurements. So we activate the sensor as part of + * the wake and then must wait the stabilization time + 1 measurement time + * before requesting the first result. + * + * @return True if the wake function completed successfully. + */ bool wake(void) override; /** * @brief Puts the sensor to sleep, if necessary. From 86b432d7a05956a29e7a387bf15fa2cb21ad3af3 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Fri, 24 Oct 2025 14:23:20 -0400 Subject: [PATCH 068/533] Add comments on which timing functions to use Signed-off-by: Sara Damiano --- src/SensorBase.h | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/SensorBase.h b/src/SensorBase.h index 9be8150e3..1810b83f3 100644 --- a/src/SensorBase.h +++ b/src/SensorBase.h @@ -449,7 +449,14 @@ class Sensor { * Verifies that the power is on and updates the #_sensorStatus. This also * sets the #_millisSensorActivated timestamp. * - * @note This does NOT include any wait for sensor readiness. + * @note This does NOT include any wait time for sensor warm-up/readiness. + * Between powering the sensor and calling the wake function, most sensors + * have a required warm up time. Use the separate isWarmedUp() function to + * check if the sensor is warmed up and use waitForWarmUp() to hold until + * the sensor is warmed up if needed. The warm up time required for each + * sensor is held in the _warmUpTime_ms variable. For *most* sensors, the + * warm up is complete when millis() - _millisPowerOn > _warmUpTime_ms. The + * _millisPowerOn variable is set in the powerUp() function. * * @return True if the wake function completed successfully. */ @@ -472,7 +479,14 @@ class Sensor { * #_sensorStatus. * * @note This function does NOT include any waiting for the sensor to be - * warmed up or stable! + * warmed up or stable. Between waking and starting measurements, most + * sensors have a required stabilization time. Use the separate isStable() + * function to check if the sensor ready to start a measurement and use + * waitForStability() to hold until the sensor is ready if needed. The + * stabilization time required for each sensor is held in the + * _stabilizationTime_ms variable. For *most* sensors, the warm up is + * complete when millis() - _millisSensorActivated > _stabilizationTime_ms. + * The _millisSensorActivated variable is set in the wake() function. * * @return True if the start measurement function completed * successfully. From e36a66e3c2f8c2cb20686a6edb72f503b88dd428 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Fri, 24 Oct 2025 14:24:45 -0400 Subject: [PATCH 069/533] Added error check in sensor array creation, simplify canPowerDown logic using code rabbit suggestions. Signed-off-by: Sara Damiano --- src/VariableArray.cpp | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/VariableArray.cpp b/src/VariableArray.cpp index e7970e93f..41165e025 100644 --- a/src/VariableArray.cpp +++ b/src/VariableArray.cpp @@ -301,9 +301,19 @@ bool VariableArray::completeUpdate(bool powerUp, bool wake, bool sleep, uint8_t addedSensors = 0; for (uint8_t i = 0; i < _variableCount; i++) { if (isLastVarFromSensor(i)) { + if (addedSensors >= _sensorCount) { + MS_DBG(F("ERROR: More unique sensors found than expected!")); + return false; + } sensorList[addedSensors++] = arrayOfVars[i]->parentSensor; } } + if (addedSensors != _sensorCount) { + MS_DBG(F("ERROR: Expected"), _sensorCount, F("sensors but found"), + addedSensors); + return false; + } + #if defined(MS_VARIABLEARRAY_DEBUG) || defined(MS_VARIABLEARRAY_DEBUG_DEEP) for (uint8_t i = 0; i < _sensorCount; i++) { MS_DBG(F(" Sensor"), i, F("is"), @@ -456,7 +466,8 @@ bool VariableArray::completeUpdate(bool powerUp, bool wake, bool sleep, // NOTE: We are NOT checking if the sleep command succeeded! // Cut the power, if ready, to this sensors and all that // share the pin - bool canPowerDown = false; + bool canPowerDown = true; // assume we can power down + // unless we find a conflict for (uint8_t k = 0; k < _sensorCount; k++) { if (((sensorList[i]->getPowerPin() >= 0 && (sensorList[i]->getPowerPin() == @@ -475,10 +486,6 @@ bool VariableArray::completeUpdate(bool powerUp, bool wake, bool sleep, // still needs to take // measurements break; - } else { - canPowerDown = - true; // no other sensors on this pin need to - // take measurements } } if (canPowerDown) { sensorList[i]->powerDown(); } From bbc22398351996f30aee17fc8a24bc2597f35538 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Fri, 24 Oct 2025 14:25:04 -0400 Subject: [PATCH 070/533] Spelling fix Signed-off-by: Sara Damiano --- ChangeLog.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/ChangeLog.md b/ChangeLog.md index 737a0baf8..70ae05388 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -14,8 +14,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm - **BREAKING** Changed capitalization of `setInitialShortIntervals(#)` function - Previously the 'i' of initial was not capitalized. -- Made the enabling and disabling of the watch dog the very first and very last steps of sleep to keep the watchdog enabled through the whole getting ready for bed and waking up process. -- **ANB pH** Changed timing slightly and simplified timing logic. +- Made the enabling and disabling of the watchdog the very first and very last steps of sleep to keep the watchdog enabled through the whole getting ready for bed and waking up process.- **ANB pH** Changed timing slightly and simplified timing logic. - Bumped several dependencies - including crucial bug fixes to SensorModbusMaster. - Re-wrote most of the logic for looping variables within the complete update function of the VariableArray. - Simplified the `addSingleMeasurementResult()` function of all sensors to use an internal function to help set the bits and timing values and to quit sooner if the measurement was not started successfully. From de8c446a3ef3f5f09947a7986f032bd4d35b1bd9 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Fri, 24 Oct 2025 14:25:45 -0400 Subject: [PATCH 071/533] Added notes about when startSingleMeasurement is called for concurrent and non-concurring SDI-12 Signed-off-by: Sara Damiano --- src/sensors/SDI12Sensors.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/sensors/SDI12Sensors.cpp b/src/sensors/SDI12Sensors.cpp index bf2192cd4..6c313e5e0 100644 --- a/src/sensors/SDI12Sensors.cpp +++ b/src/sensors/SDI12Sensors.cpp @@ -708,6 +708,9 @@ bool SDI12Sensors::getResults(bool verify_crc) { #ifndef MS_SDI12_NON_CONCURRENT +// This function is using concurrent measurements, so the MEASUREMENT_SUCCESSFUL +// bit was set in the specialized startSingleMeasurement function based on +// whether the response to the SDI-12 start measurement command. bool SDI12Sensors::addSingleMeasurementResult(void) { // Immediately quit if the measurement was not successfully started if (!getStatusBit(MEASUREMENT_SUCCESSFUL)) { @@ -719,7 +722,12 @@ bool SDI12Sensors::addSingleMeasurementResult(void) { // Return success value when finished return bumpMeasurementAttemptCount(success); } -#else +#else // concurrent measurement disabled +// This is for non-concurrent measurements, so this function must both start the +// measurement and get results at once. For non-concurrent measurements, the +// MEASUREMENT_SUCCESSFUL bit is set in the generic sensor +// startSingleMeasurement function from sensor base, which only verifies that +// the sensor is awake and capable of starting measurements. bool SDI12Sensors::addSingleMeasurementResult(void) { // Immediately quit if the measurement was not successfully started if (!getStatusBit(MEASUREMENT_SUCCESSFUL)) { @@ -745,7 +753,7 @@ bool SDI12Sensors::addSingleMeasurementResult(void) { MS_DBG(F(" NON-concurrent measurement started.")); // Update the time that a measurement was requested _millisMeasurementRequested = millis(); - // Set the status bit for measurement start success (bit 6) + // Re-set the status bit for measurement start success (bit 6) setStatusBit(MEASUREMENT_SUCCESSFUL); // Since this is not a concurrent measurement, we must sit around From 2cc1ce75512e1aee3ecf78d79678df3208758ffb Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Fri, 24 Oct 2025 14:26:19 -0400 Subject: [PATCH 072/533] Added default analog resolution at code rabbit's suggestion Signed-off-by: Sara Damiano --- src/sensors/ProcessorAnalog.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/sensors/ProcessorAnalog.h b/src/sensors/ProcessorAnalog.h index 178e60745..bf5907595 100644 --- a/src/sensors/ProcessorAnalog.h +++ b/src/sensors/ProcessorAnalog.h @@ -149,6 +149,9 @@ /// @brief Decimals places in string representation; a 3.3V processor at 10-bit /// resolution should have 3 [3.3V / 1024 ~= 0.0032] . #define PROCESSOR_ANALOG_RESOLUTION 3 +#else +// Default to 10-bit behavior if not specified +#define PROCESSOR_ANALOG_RESOLUTION 3 #endif /**@}*/ From 7c9df45e0f4c15f316bcc2c8a94161d1eba789f1 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Fri, 24 Oct 2025 14:31:10 -0400 Subject: [PATCH 073/533] Fix hard-call to Wire; thanks code rabbit Signed-off-by: Sara Damiano --- src/sensors/RainCounterI2C.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/sensors/RainCounterI2C.cpp b/src/sensors/RainCounterI2C.cpp index 56413e66c..b655a945a 100644 --- a/src/sensors/RainCounterI2C.cpp +++ b/src/sensors/RainCounterI2C.cpp @@ -106,14 +106,19 @@ bool RainCounterI2C::addSingleMeasurementResult(void) { static_cast(4))) { MS_DBG(getSensorNameAndLocation(), F("is reporting:")); - uint8_t SerialBuffer[4]; // Create a byte array of 4 bytes - uint8_t byte_in = 0; // Start iterator for reading Bytes - while (Wire.available()) { // slave may send less than requested - SerialBuffer[byte_in] = Wire.read(); + // Create a byte array of 4 bytes to hold incoming data + uint8_t SerialBuffer[4] = {0, 0, 0, 0}; + uint8_t byte_in = 0; // Start iterator for reading Bytes + while (_i2c->available() && byte_in < 4) { + SerialBuffer[byte_in] = _i2c->read(); MS_DBG(F(" SerialBuffer["), byte_in, F("] = "), SerialBuffer[byte_in]); byte_in++; // increment by 1 } + if (byte_in < 1) { + MS_DBG(F(" No data bytes received")); + return bumpMeasurementAttemptCount(false); + } // Concatenate bytes into uint32_t by bit-shifting // https://thewanderingengineer.com/2015/05/06/sending-16-bit-and-32-bit-numbers-with-arduino-i2c/# From 4972b52923bb7d92f5f36dbdc8d297d356b37c76 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Fri, 24 Oct 2025 14:33:01 -0400 Subject: [PATCH 074/533] Doc fixes Signed-off-by: Sara Damiano --- src/sensors/TIINA219.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/sensors/TIINA219.h b/src/sensors/TIINA219.h index 86761802c..73c259b77 100644 --- a/src/sensors/TIINA219.h +++ b/src/sensors/TIINA219.h @@ -175,7 +175,7 @@ * {{ @ref TIINA219_Voltage::TIINA219_Voltage }} */ /**@{*/ -/// @brief Decimals places in string representation; bus voltage should have 4 - +/// @brief Decimals places in string representation; bus voltage should have 3 - /// resolution is 0.001V. #define INA219_BUS_VOLTAGE_RESOLUTION 3 /// @brief Sensor variable number; bus voltage is stored in sensorValues[1]. @@ -238,7 +238,7 @@ class TIINA219 : public Sensor { * Use -1 if it is continuously powered. * - The INA219 requires input voltage of 3.0-5.5V, which can be turned off * between measurements. - * @param i2cAddressHex The I2C address of the BME280; can be any number + * @param i2cAddressHex The I2C address of the INA219; can be any number * between 0x40 and 0x4F. The default value is 0x40. * @param measurementsToAverage The number of measurements to take and * average before giving a "final" result from the sensor; optional with a @@ -255,7 +255,7 @@ class TIINA219 : public Sensor { * Use -1 if it is continuously powered. * - The INA219 requires input voltage of 3.0-5.5V, which can be turned off * between measurements. - * @param i2cAddressHex The I2C address of the BME280; can be any number + * @param i2cAddressHex The I2C address of the INA219; can be any number * between 0x40 and 0x4F. The default value is 0x40. * @param measurementsToAverage The number of measurements to take and * average before giving a "final" result from the sensor; optional with a From 1480e5df2657dabf1de8129eb6df68ec73d463fa Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Fri, 24 Oct 2025 14:34:26 -0400 Subject: [PATCH 075/533] Added debug message for no returns Signed-off-by: Sara Damiano --- src/sensors/SensirionSHT4x.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/sensors/SensirionSHT4x.cpp b/src/sensors/SensirionSHT4x.cpp index 108f2054b..c5f3de31b 100644 --- a/src/sensors/SensirionSHT4x.cpp +++ b/src/sensors/SensirionSHT4x.cpp @@ -116,6 +116,11 @@ bool SensirionSHT4x::addSingleMeasurementResult(void) { MS_DBG(F(" Temp:"), temp_val, F("°C")); MS_DBG(F(" Humidity:"), humid_val, '%'); + if (!ret_val) { + MS_DBG(F(" getEvent failed; no values read!")); + } else if (isnan(temp_val) || isnan(humid_val)) { + MS_DBG(F(" Invalid measurement values")); + } if (ret_val && !isnan(temp_val) && !isnan(humid_val)) { verifyAndAddMeasurementResult(SHT4X_TEMP_VAR_NUM, temp_val); From 4a349b8d1b481110de7139279a2edcb64fddeae6 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Fri, 24 Oct 2025 14:37:11 -0400 Subject: [PATCH 076/533] Formatting; move debug message Signed-off-by: Sara Damiano --- src/sensors/TallyCounterI2C.cpp | 6 +++--- src/sensors/TallyCounterI2C.h | 3 ++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/sensors/TallyCounterI2C.cpp b/src/sensors/TallyCounterI2C.cpp index fd935a81d..b55ecc3c4 100644 --- a/src/sensors/TallyCounterI2C.cpp +++ b/src/sensors/TallyCounterI2C.cpp @@ -76,8 +76,6 @@ bool TallyCounterI2C::addSingleMeasurementResult(void) { bool success = false; int16_t events = -9999; // Number of events - MS_DBG(getSensorNameAndLocation(), F("is reporting:")); - // Read values // Read data from counter before clear @@ -87,9 +85,11 @@ bool TallyCounterI2C::addSingleMeasurementResult(void) { // Assume that if negative a failed response // May also return a very negative temp when receiving a bad response if (events < 0) { - MS_DBG(F("All values 0 or bad, assuming sensor non-response!")); + MS_DBG(getSensorNameAndLocation(), + F("returns all values 0 or bad, assuming sensor non-response!")); events = -9999; } else { + MS_DBG(getSensorNameAndLocation(), F("is reporting:")); verifyAndAddMeasurementResult(TALLY_EVENTS_VAR_NUM, events); success = true; } diff --git a/src/sensors/TallyCounterI2C.h b/src/sensors/TallyCounterI2C.h index 95c517514..8fd4bfcc2 100644 --- a/src/sensors/TallyCounterI2C.h +++ b/src/sensors/TallyCounterI2C.h @@ -215,7 +215,8 @@ class TallyCounterI2C : public Sensor { * * @return True if the setup was successful. */ - bool setup(void) override; + bool setup(void) override; + String getSensorLocation(void) override; // bool startSingleMeasurement(void) override; // for forced mode From 889e678aaa029cfb304bddd383bcbfaafbf984a1 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Fri, 24 Oct 2025 14:39:14 -0400 Subject: [PATCH 077/533] Soften note, per code rabbit Signed-off-by: Sara Damiano --- src/sensors/MaximDS3231.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/sensors/MaximDS3231.cpp b/src/sensors/MaximDS3231.cpp index 556452d17..2f3aa8909 100644 --- a/src/sensors/MaximDS3231.cpp +++ b/src/sensors/MaximDS3231.cpp @@ -46,7 +46,8 @@ bool MaximDS3231::startSingleMeasurement(void) { MS_DBG(F("Forcing new temperature reading by DS3231")); rtc.convertTemperature(false); - // NOTE: There's no possibility of failure here - we always return true. + // NOTE: There's no way of knowing if there's a failure here so we always + // return true. // There's no condition where we would need to bump the number of completed // measurement attempts here. return true; From a4220c2a4449b7a82963d786f11b3de400c5c038 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Fri, 24 Oct 2025 14:44:13 -0400 Subject: [PATCH 078/533] formatting Signed-off-by: Sara Damiano --- examples/menu_a_la_carte/menu_a_la_carte.ino | 2 +- src/sensors/BoschBME280.h | 3 ++- src/sensors/BoschBMP3xx.h | 3 ++- src/sensors/FreescaleMPL115A2.h | 3 ++- src/sensors/MaximDS18.h | 3 ++- src/sensors/MeaSpecMS5803.h | 3 ++- src/sensors/PaleoTerraRedox.h | 3 ++- src/sensors/RainCounterI2C.h | 3 ++- src/sensors/TIADS1x15.cpp | 1 + src/sensors/TIINA219.h | 3 ++- 10 files changed, 18 insertions(+), 9 deletions(-) diff --git a/examples/menu_a_la_carte/menu_a_la_carte.ino b/examples/menu_a_la_carte/menu_a_la_carte.ino index 413432eff..6465ce856 100644 --- a/examples/menu_a_la_carte/menu_a_la_carte.ino +++ b/examples/menu_a_la_carte/menu_a_la_carte.ino @@ -1641,7 +1641,7 @@ Variable* ads1x15Volt = #include // NOTE: Use -1 for any pins that don't apply or aren't being used. -const int8_t externalAnalogPowerPin = sensorPowerPin; // Power pin +const int8_t externalAnalogPowerPin = sensorPowerPin; // Power pin const int8_t externalAnalogDataChannel = A0; // The ADS channel of interest const float externalAnalogMultiplier = 5.58; // Gain setting if using a voltage divider diff --git a/src/sensors/BoschBME280.h b/src/sensors/BoschBME280.h index b9c963dbf..236c02555 100644 --- a/src/sensors/BoschBME280.h +++ b/src/sensors/BoschBME280.h @@ -331,7 +331,8 @@ class BoschBME280 : public Sensor { * * @return True if the setup was successful. */ - bool setup(void) override; + bool setup(void) override; + String getSensorLocation(void) override; // bool startSingleMeasurement(void) override; // for forced mode diff --git a/src/sensors/BoschBMP3xx.h b/src/sensors/BoschBMP3xx.h index 3a16862f7..5682575eb 100644 --- a/src/sensors/BoschBMP3xx.h +++ b/src/sensors/BoschBMP3xx.h @@ -452,7 +452,8 @@ class BoschBMP3xx : public Sensor { * * @return True if the setup was successful. */ - bool setup(void) override; + bool setup(void) override; + String getSensorLocation(void) override; bool startSingleMeasurement(void) override; diff --git a/src/sensors/FreescaleMPL115A2.h b/src/sensors/FreescaleMPL115A2.h index 6e0939de4..965ef99fa 100644 --- a/src/sensors/FreescaleMPL115A2.h +++ b/src/sensors/FreescaleMPL115A2.h @@ -233,7 +233,8 @@ class FreescaleMPL115A2 : public Sensor { * * @return True if the setup was successful. */ - bool setup(void) override; + bool setup(void) override; + String getSensorLocation(void) override; bool addSingleMeasurementResult(void) override; diff --git a/src/sensors/MaximDS18.h b/src/sensors/MaximDS18.h index 3e367d0b9..b6146e3fc 100644 --- a/src/sensors/MaximDS18.h +++ b/src/sensors/MaximDS18.h @@ -238,7 +238,8 @@ class MaximDS18 : public Sensor { * * @return True if the setup was successful. */ - bool setup(void) override; + bool setup(void) override; + String getSensorLocation(void) override; /** diff --git a/src/sensors/MeaSpecMS5803.h b/src/sensors/MeaSpecMS5803.h index 9c740b8cb..d98f7074d 100644 --- a/src/sensors/MeaSpecMS5803.h +++ b/src/sensors/MeaSpecMS5803.h @@ -249,7 +249,8 @@ class MeaSpecMS5803 : public Sensor { * * @return True if the setup was successful. */ - bool setup(void) override; + bool setup(void) override; + String getSensorLocation(void) override; bool addSingleMeasurementResult(void) override; diff --git a/src/sensors/PaleoTerraRedox.h b/src/sensors/PaleoTerraRedox.h index 6e8b6d962..6e26eeb0a 100644 --- a/src/sensors/PaleoTerraRedox.h +++ b/src/sensors/PaleoTerraRedox.h @@ -263,7 +263,8 @@ class PaleoTerraRedox : public Sensor { * * @return True if the setup was successful. */ - bool setup(void) override; + bool setup(void) override; + String getSensorLocation(void) override; bool addSingleMeasurementResult(void) override; diff --git a/src/sensors/RainCounterI2C.h b/src/sensors/RainCounterI2C.h index 991674293..edccf301e 100644 --- a/src/sensors/RainCounterI2C.h +++ b/src/sensors/RainCounterI2C.h @@ -282,7 +282,8 @@ class RainCounterI2C : public Sensor { * * @return True if the setup was successful. */ - bool setup(void) override; + bool setup(void) override; + String getSensorLocation(void) override; bool addSingleMeasurementResult(void) override; diff --git a/src/sensors/TIADS1x15.cpp b/src/sensors/TIADS1x15.cpp index 48a72f997..39909baf3 100644 --- a/src/sensors/TIADS1x15.cpp +++ b/src/sensors/TIADS1x15.cpp @@ -47,6 +47,7 @@ bool TIADS1x15::addSingleMeasurementResult(void) { if (!getStatusBit(MEASUREMENT_SUCCESSFUL)) { return bumpMeasurementAttemptCount(false); } + bool success = false; int16_t adcCounts = -9999; float adcVoltage = -9999; diff --git a/src/sensors/TIINA219.h b/src/sensors/TIINA219.h index 73c259b77..bdd7e7650 100644 --- a/src/sensors/TIINA219.h +++ b/src/sensors/TIINA219.h @@ -290,7 +290,8 @@ class TIINA219 : public Sensor { * * @return True if the setup was successful. */ - bool setup(void) override; + bool setup(void) override; + String getSensorLocation(void) override; bool addSingleMeasurementResult(void) override; From 633fa17a63440919d2f0420aad73a776edd86793 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Fri, 24 Oct 2025 14:46:04 -0400 Subject: [PATCH 079/533] Note about validity Signed-off-by: Sara Damiano --- src/sensors/RainCounterI2C.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sensors/RainCounterI2C.cpp b/src/sensors/RainCounterI2C.cpp index b655a945a..4ea9c297b 100644 --- a/src/sensors/RainCounterI2C.cpp +++ b/src/sensors/RainCounterI2C.cpp @@ -154,7 +154,7 @@ bool RainCounterI2C::addSingleMeasurementResult(void) { MS_DBG(F(" Rain:"), rain); MS_DBG(F(" Tips:"), tips); - if (rain != -9999 || tips != -9999) { + if (rain != -9999 || tips != -9999) { // if either is valid verifyAndAddMeasurementResult(BUCKET_RAIN_VAR_NUM, rain); verifyAndAddMeasurementResult(BUCKET_TIPS_VAR_NUM, tips); success = true; From bbec0556602a6e62cb2a6ccea78af2cf873ee77b Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Fri, 24 Oct 2025 14:50:23 -0400 Subject: [PATCH 080/533] Log unexpected code, ensure there is a result before parsing (thanks code rabbit) Signed-off-by: Sara Damiano --- src/sensors/AtlasParent.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/sensors/AtlasParent.cpp b/src/sensors/AtlasParent.cpp index cb9c698cf..3b83908c0 100644 --- a/src/sensors/AtlasParent.cpp +++ b/src/sensors/AtlasParent.cpp @@ -168,11 +168,12 @@ bool AtlasParent::addSingleMeasurementResult(void) { MS_DBG(F(" No Data")); break; - default: break; + default: MS_DBG(F(" Unexpected response code:"), code); break; } // If the response code is successful, parse the remaining results if (success) { for (uint8_t i = 0; i < _numReturnedValues; i++) { + if (_i2c->available() == 0) { break; } float result = _i2c->parseFloat(); if (isnan(result)) { result = -9999; } if (result < -1020) { result = -9999; } From 3e7af586f13ded4e677915f4e0bcf15dec599d78 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Fri, 24 Oct 2025 14:52:43 -0400 Subject: [PATCH 081/533] Align range with comments Signed-off-by: Sara Damiano --- src/sensors/MeaSpecMS5803.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/sensors/MeaSpecMS5803.cpp b/src/sensors/MeaSpecMS5803.cpp index de5f91b00..0a85c9693 100644 --- a/src/sensors/MeaSpecMS5803.cpp +++ b/src/sensors/MeaSpecMS5803.cpp @@ -75,8 +75,8 @@ bool MeaSpecMS5803::addSingleMeasurementResult(void) { MS_DBG(F(" Temperature:"), temp); MS_DBG(F(" Pressure:"), press); - if (!isnan(temp) && !isnan(press) && temp > -50 && temp < 95 && - press != 0) { + if (!isnan(temp) && !isnan(press) && temp >= -40.0 && temp <= 85.0 && + press != 0.0) { // Temperature Range is -40°C to +85°C // Pressure returns 0 when disconnected, which is highly unlikely to be // a real value. From d4a034d2db724950823c52d24380184033d729fa Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Fri, 24 Oct 2025 14:55:06 -0400 Subject: [PATCH 082/533] Fix || Signed-off-by: Sara Damiano --- src/sensors/RainCounterI2C.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sensors/RainCounterI2C.h b/src/sensors/RainCounterI2C.h index edccf301e..0a191b775 100644 --- a/src/sensors/RainCounterI2C.h +++ b/src/sensors/RainCounterI2C.h @@ -236,7 +236,7 @@ class RainCounterI2C : public Sensor { RainCounterI2C(int8_t dataPin, int8_t clockPin, uint8_t i2cAddressHex = 0x08, float rainPerTip = 0.2); #endif -#if !defined(MS_RAIN_SOFTWAREWIRE) | defined DOXYGEN +#if !defined(MS_RAIN_SOFTWAREWIRE) || defined DOXYGEN /** * @brief Construct a new Rain Counter I2C object using a secondary * *hardware* I2C instance. From 5106a5479229e95b783cf2c5db836819a22707d0 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Fri, 24 Oct 2025 14:58:02 -0400 Subject: [PATCH 083/533] Rearrange debugging outputs Signed-off-by: Sara Damiano --- src/sensors/BoschBMP3xx.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/sensors/BoschBMP3xx.cpp b/src/sensors/BoschBMP3xx.cpp index 3837b0ae0..2dd9d90c8 100644 --- a/src/sensors/BoschBMP3xx.cpp +++ b/src/sensors/BoschBMP3xx.cpp @@ -270,7 +270,8 @@ bool BoschBMP3xx::startSingleMeasurement(void) { _millisMeasurementRequested = millis(); } - // NOTE: There's no possibility of failure here - we always return true. + // NOTE: There's no way of knowing of a failure here so we always return + // true. // There's no condition where we would need to bump the number of completed // measurement attempts here. return true; @@ -288,18 +289,20 @@ bool BoschBMP3xx::addSingleMeasurementResult(void) { float press = -9999; float alt = -9999; - MS_DBG(getSensorNameAndLocation(), F("is reporting:")); // Read values success = bmp_internal.getMeasurements(temp, press, alt); - MS_DBG(F(" Temperature:"), temp, F("°C")); - MS_DBG(F(" Barometric Pressure:"), press, F("Pa")); - MS_DBG(F(" Calculated Altitude:"), alt, F("m ASL")); if (success) { + MS_DBG(getSensorNameAndLocation(), F("is reporting:")); + MS_DBG(F(" Temperature:"), temp, F("°C")); + MS_DBG(F(" Barometric Pressure:"), press, F("Pa")); + MS_DBG(F(" Calculated Altitude:"), alt, F("m ASL")); verifyAndAddMeasurementResult(BMP3XX_TEMP_VAR_NUM, temp); verifyAndAddMeasurementResult(BMP3XX_PRESSURE_VAR_NUM, press); verifyAndAddMeasurementResult(BMP3XX_ALTITUDE_VAR_NUM, alt); + } else { + MS_DBG(F("Failed to read data from"), getSensorNameAndLocation()); } // Return success value when finished From 350073082c51ccda0f9ea0a6dfaed0088427e900 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Fri, 24 Oct 2025 15:09:46 -0400 Subject: [PATCH 084/533] Add to-do note Signed-off-by: Sara Damiano --- src/sensors/TurnerTurbidityPlus.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/sensors/TurnerTurbidityPlus.h b/src/sensors/TurnerTurbidityPlus.h index 1a620993d..3870f90d6 100644 --- a/src/sensors/TurnerTurbidityPlus.h +++ b/src/sensors/TurnerTurbidityPlus.h @@ -311,6 +311,8 @@ class TurnerTurbidityPlus : public Sensor { /** * @brief The programmable gain amplification to set on the ADS 1x15, * default is GAIN_DEFAULT (0). + * + * @todo Determine gain automatically based on the board voltage? */ adsGain_t _PGA_gain; /** From bcd0c49cf6197f3dd021c5fea8fc4d5b84046cb8 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Fri, 24 Oct 2025 15:10:05 -0400 Subject: [PATCH 085/533] Remove un-necessary underflow prevention Signed-off-by: Sara Damiano --- src/sensors/EverlightALSPT19.cpp | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/src/sensors/EverlightALSPT19.cpp b/src/sensors/EverlightALSPT19.cpp index 3b8001adf..e4b37a95b 100644 --- a/src/sensors/EverlightALSPT19.cpp +++ b/src/sensors/EverlightALSPT19.cpp @@ -56,19 +56,21 @@ bool EverlightALSPT19::addSingleMeasurementResult(void) { uint32_t sensor_adc = analogRead(_dataPin); MS_DEEP_DBG(" ADC Bits:", sensor_adc); - if (0 == sensor_adc) { - // Prevent underflow, can never be outside of PROCESSOR_ADC_RANGE - sensor_adc = 1; + if (sensor_adc == 0) { + volt_val = 0.0; + current_val = 0.0; + lux_val = 0.0; + } else { + // convert bits to volts + volt_val = (_supplyVoltage / static_cast(PROCESSOR_ADC_MAX)) * + static_cast(sensor_adc); + // convert volts to current + // resistance is entered in kΩ and we want µA + current_val = (volt_val / (_loadResistor * 1000)) * 1e6; + // convert current to illuminance + // from sensor datasheet, typical 200µA current for 1000 Lux + lux_val = current_val * (1000. / 200.); } - // convert bits to volts - volt_val = (_supplyVoltage / static_cast(PROCESSOR_ADC_MAX)) * - static_cast(sensor_adc); - // convert volts to current - // resistance is entered in kΩ and we want µA - current_val = (volt_val / (_loadResistor * 1000)) * 1e6; - // convert current to illuminance - // from sensor datasheet, typical 200µA current for 1000 Lux - lux_val = current_val * (1000. / 200.); MS_DBG(F(" Voltage:"), volt_val, F("V")); MS_DBG(F(" Current:"), current_val, F("µA")); From 10e8470af8298b8c1027381f1f2ac27aa76670ac Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Fri, 24 Oct 2025 15:10:19 -0400 Subject: [PATCH 086/533] Comment about success Signed-off-by: Sara Damiano --- src/sensors/TIINA219.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/sensors/TIINA219.cpp b/src/sensors/TIINA219.cpp index 115320ea8..b8fac19d3 100644 --- a/src/sensors/TIINA219.cpp +++ b/src/sensors/TIINA219.cpp @@ -89,6 +89,7 @@ bool TIINA219::addSingleMeasurementResult(void) { busV_V = ina219_phy.getBusVoltage_V(); power_mW = ina219_phy.getPower_mW(); + // Only success if none of the values are NaN success = !isnan(current_mA) && !isnan(busV_V) && !isnan(power_mW); MS_DBG(F(" Current [mA]:"), current_mA); From 92173c23f1b4672be3b4fce7f0ec208d209b9397 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Fri, 24 Oct 2025 15:12:01 -0400 Subject: [PATCH 087/533] Fix type of data pin Signed-off-by: Sara Damiano --- src/sensors/ProcessorAnalog.cpp | 2 +- src/sensors/ProcessorAnalog.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/sensors/ProcessorAnalog.cpp b/src/sensors/ProcessorAnalog.cpp index eacd5e8b4..6a5941e7f 100644 --- a/src/sensors/ProcessorAnalog.cpp +++ b/src/sensors/ProcessorAnalog.cpp @@ -14,7 +14,7 @@ // The constructor - need the power pin, the data pin, the voltage divider // value, and the operating voltage -ProcessorAnalog::ProcessorAnalog(int8_t powerPin, uint8_t dataPin, +ProcessorAnalog::ProcessorAnalog(int8_t powerPin, int8_t dataPin, float voltageMultiplier, float operatingVoltage, uint8_t measurementsToAverage) diff --git a/src/sensors/ProcessorAnalog.h b/src/sensors/ProcessorAnalog.h index bf5907595..493a7513c 100644 --- a/src/sensors/ProcessorAnalog.h +++ b/src/sensors/ProcessorAnalog.h @@ -191,7 +191,7 @@ class ProcessorAnalog : public Sensor { * average before giving a "final" result from the sensor; optional with a * default value of 1. */ - ProcessorAnalog(int8_t powerPin, uint8_t dataPin, float voltageMultiplier, + ProcessorAnalog(int8_t powerPin, int8_t dataPin, float voltageMultiplier, float operatingVoltage = OPERATING_VOLTAGE, uint8_t measurementsToAverage = 1); /** From b393a1de00bbc51959b315c6a929f679681ca440 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Fri, 24 Oct 2025 15:14:31 -0400 Subject: [PATCH 088/533] include counts in debugging Signed-off-by: Sara Damiano --- src/sensors/TurnerCyclops.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/sensors/TurnerCyclops.cpp b/src/sensors/TurnerCyclops.cpp index 021ef2cb8..7392e5874 100644 --- a/src/sensors/TurnerCyclops.cpp +++ b/src/sensors/TurnerCyclops.cpp @@ -90,7 +90,8 @@ bool TurnerCyclops::addSingleMeasurementResult(void) { adcCounts = ads.readADC_SingleEnded(_adsChannel); // Convert ADC raw counts value to voltage (V) adcVoltage = ads.computeVolts(adcCounts); - MS_DBG(F(" ads.readADC_SingleEnded("), _adsChannel, F("):"), adcVoltage); + MS_DBG(F(" ads.readADC_SingleEnded("), _adsChannel, F("):"), adcCounts, + '=', adcVoltage); if (adcVoltage < 3.6 && adcVoltage > -0.3) { // Skip results out of range From 9a35520e2baace2cb7f4528c1f2b4d830ffebe00 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Fri, 24 Oct 2025 15:18:03 -0400 Subject: [PATCH 089/533] Note on failure Signed-off-by: Sara Damiano --- src/sensors/ProcessorStats.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/sensors/ProcessorStats.cpp b/src/sensors/ProcessorStats.cpp index 2c0afca2d..242f5d45c 100644 --- a/src/sensors/ProcessorStats.cpp +++ b/src/sensors/ProcessorStats.cpp @@ -203,6 +203,9 @@ String ProcessorStats::getLastResetCause() { bool ProcessorStats::addSingleMeasurementResult(void) { + // NOTE: We don't need to check if a measurement was started successfully + // because there is no way for it to fail! + float sensorValue_battery = getBatteryVoltage(); verifyAndAddMeasurementResult(PROCESSOR_BATTERY_VAR_NUM, sensorValue_battery); From c7dc2d3909215b6f614dc16f95e13929ca93d159 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Fri, 24 Oct 2025 15:20:53 -0400 Subject: [PATCH 090/533] Specify directory for KnownProcessors.h Signed-off-by: Sara Damiano --- src/sensors/EverlightALSPT19.h | 2 +- src/sensors/ProcessorAnalog.h | 2 +- src/sensors/ProcessorStats.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/sensors/EverlightALSPT19.h b/src/sensors/EverlightALSPT19.h index 53fcedb12..db94b1a00 100644 --- a/src/sensors/EverlightALSPT19.h +++ b/src/sensors/EverlightALSPT19.h @@ -48,7 +48,7 @@ #include "ModSensorConfig.h" // Include the known processors for default values -#include "KnownProcessors.h" +#include "sensors/KnownProcessors.h" // Include the debugging config #include "ModSensorDebugConfig.h" diff --git a/src/sensors/ProcessorAnalog.h b/src/sensors/ProcessorAnalog.h index 493a7513c..7b03acd80 100644 --- a/src/sensors/ProcessorAnalog.h +++ b/src/sensors/ProcessorAnalog.h @@ -61,7 +61,7 @@ #include "ModSensorDebugConfig.h" // Include the known processors for default values -#include "KnownProcessors.h" +#include "sensors/KnownProcessors.h" // Define the print label[s] for the debugger #ifdef MS_PROCESSOR_ANALOG_DEBUG diff --git a/src/sensors/ProcessorStats.h b/src/sensors/ProcessorStats.h index 0381b01e9..7876ac320 100644 --- a/src/sensors/ProcessorStats.h +++ b/src/sensors/ProcessorStats.h @@ -63,7 +63,7 @@ #include "ModSensorDebugConfig.h" // Include the known processors for default values -#include "KnownProcessors.h" +#include "sensors/KnownProcessors.h" // Define the print label[s] for the debugger #ifdef MS_PROCESSORSTATS_DEBUG From 6c311598db1d18551668b6e8f993f11d6b9c2391 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Fri, 24 Oct 2025 15:21:09 -0400 Subject: [PATCH 091/533] Fix comment Signed-off-by: Sara Damiano --- src/LoggerBase.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/LoggerBase.cpp b/src/LoggerBase.cpp index 731ad0add..7f82e4e60 100644 --- a/src/LoggerBase.cpp +++ b/src/LoggerBase.cpp @@ -1619,8 +1619,8 @@ void Logger::benchTestingMode(bool sleepBeforeReturning) { extendedWatchDog::resetWatchDog(); // Update the values from all attached sensors - // NOTE: NOT using complete update because we want the sensors to be - // left on between iterations in testing mode. + // NOTE: Use completeUpdate with all flags false so sensors stay + // powered and awake between iterations in testing mode. _internalArray->completeUpdate(false, false, false, false); // Print out the current logger time PRINTOUT(F("Current logger time is"), From d6bf41bbe74aa9b48774cc7bb54661c4c0c335b8 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Fri, 24 Oct 2025 15:24:08 -0400 Subject: [PATCH 092/533] Confirm there are more than 2 values, just in casse Signed-off-by: Sara Damiano --- src/sensors/YosemitechParent.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/sensors/YosemitechParent.cpp b/src/sensors/YosemitechParent.cpp index 7be425f6d..bd9bbfb21 100644 --- a/src/sensors/YosemitechParent.cpp +++ b/src/sensors/YosemitechParent.cpp @@ -242,7 +242,9 @@ bool YosemitechParent::addSingleMeasurementResult(void) { // Put values into the array verifyAndAddMeasurementResult(0, parmValue); verifyAndAddMeasurementResult(1, tempValue); - verifyAndAddMeasurementResult(2, thirdValue); + if (_numReturnedValues > 2) { + verifyAndAddMeasurementResult(2, thirdValue); + } } break; } From e5a69e4954f7be0d8e1509d86f632fe475249773 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Fri, 24 Oct 2025 15:25:25 -0400 Subject: [PATCH 093/533] Remove badly copied docs Signed-off-by: Sara Damiano --- src/sensors/ProcessorAnalog.h | 7 ------- 1 file changed, 7 deletions(-) diff --git a/src/sensors/ProcessorAnalog.h b/src/sensors/ProcessorAnalog.h index 7b03acd80..372d2bf35 100644 --- a/src/sensors/ProcessorAnalog.h +++ b/src/sensors/ProcessorAnalog.h @@ -169,13 +169,6 @@ class ProcessorAnalog : public Sensor { * @brief Construct a new Processor Analog object - need the power pin and * the data pin on the processor. * - * The gain value and number of measurements to average are optional. If - * nothing is given a 1x gain is used. - * - * @note ModularSensors only supports connecting the ADS1x15 to the primary - * hardware I2C instance defined in the Arduino core. Connecting the ADS to - * a secondary hardware or software I2C instance is *not* supported! - * * @param powerPin The pin on the mcu controlling power to the sensor * Use -1 if it is continuously powered. * @param dataPin The processor ADC port pin to read the voltage from the EC From 721b5e3a8f24b49d96d90dd0835e8d7a8f8fcba9 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Fri, 24 Oct 2025 15:30:18 -0400 Subject: [PATCH 094/533] Added comment about wake check Signed-off-by: Sara Damiano --- src/VariableArray.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/VariableArray.cpp b/src/VariableArray.cpp index 41165e025..647f8d82e 100644 --- a/src/VariableArray.cpp +++ b/src/VariableArray.cpp @@ -351,6 +351,10 @@ bool VariableArray::completeUpdate(bool powerUp, bool wake, bool sleep, } // If attempts were made to wake the sensor, but they failed... + // NOTE: We check if the wake was successful even if the wake + // parameter is false because we need to know the sensor wake failed + // before attempting readings even if the user called wake somewhere + // else. if (sensorList[i]->getStatusBit(Sensor::WAKE_ATTEMPTED) == 1 && sensorList[i]->getStatusBit(Sensor::WAKE_SUCCESSFUL) == 0) { MS_DBG(i, F("--->>"), sName, From aefbdc8bba5fa0ce7d038c53c93e6ce9f56bda51 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Fri, 24 Oct 2025 15:46:18 -0400 Subject: [PATCH 095/533] Check that the ads begin returns true Signed-off-by: Sara Damiano --- src/sensors/AlphasenseCO2.cpp | 7 +++++-- src/sensors/ApogeeSQ212.cpp | 7 +++++-- src/sensors/CampbellOBS3.cpp | 7 +++++-- src/sensors/TIADS1x15.cpp | 7 +++++-- src/sensors/TurnerCyclops.cpp | 7 +++++-- src/sensors/TurnerTurbidityPlus.cpp | 7 +++++-- 6 files changed, 30 insertions(+), 12 deletions(-) diff --git a/src/sensors/AlphasenseCO2.cpp b/src/sensors/AlphasenseCO2.cpp index cb866d10c..889e57924 100644 --- a/src/sensors/AlphasenseCO2.cpp +++ b/src/sensors/AlphasenseCO2.cpp @@ -78,8 +78,11 @@ bool AlphasenseCO2::addSingleMeasurementResult(void) { // Sensor return range is 0-2.5V, but the next gain option is 2x which // only allows up to 2.048V ads.setGain(GAIN_ONE); - // Begin ADC - ads.begin(_i2cAddress); + // Begin ADC, returns true if anything was detected at the address + if (!ads.begin(_i2cAddress)) { + MS_DBG(F(" ADC initialization failed")); + return bumpMeasurementAttemptCount(false); + } // Read Analog to Digital Converter (ADC) // Taking this reading includes the 8ms conversion delay. diff --git a/src/sensors/ApogeeSQ212.cpp b/src/sensors/ApogeeSQ212.cpp index 4fcb07c8d..cdc0f2800 100644 --- a/src/sensors/ApogeeSQ212.cpp +++ b/src/sensors/ApogeeSQ212.cpp @@ -77,8 +77,11 @@ bool ApogeeSQ212::addSingleMeasurementResult(void) { // Sensor return range is 0-2.5V, but the next gain option is 2x which only // allows up to 2.048V ads.setGain(GAIN_ONE); - // Begin ADC - ads.begin(_i2cAddress); + // Begin ADC, returns true if anything was detected at the address + if (!ads.begin(_i2cAddress)) { + MS_DBG(F(" ADC initialization failed")); + return bumpMeasurementAttemptCount(false); + } // Read Analog to Digital Converter (ADC) // Taking this reading includes the 8ms conversion delay. diff --git a/src/sensors/CampbellOBS3.cpp b/src/sensors/CampbellOBS3.cpp index ceabaec4e..ac0b91e82 100644 --- a/src/sensors/CampbellOBS3.cpp +++ b/src/sensors/CampbellOBS3.cpp @@ -77,8 +77,11 @@ bool CampbellOBS3::addSingleMeasurementResult(void) { // Sensor return range is 0-2.5V, but the next gain option is 2x which // only allows up to 2.048V ads.setGain(GAIN_ONE); - // Begin ADC - ads.begin(_i2cAddress); + // Begin ADC, returns true if anything was detected at the address + if (!ads.begin(_i2cAddress)) { + MS_DBG(F(" ADC initialization failed")); + return bumpMeasurementAttemptCount(false); + } // Print out the calibration curve MS_DBG(F(" Input calibration Curve:"), _x2_coeff_A, F("x^2 +"), diff --git a/src/sensors/TIADS1x15.cpp b/src/sensors/TIADS1x15.cpp index 39909baf3..9be6336e8 100644 --- a/src/sensors/TIADS1x15.cpp +++ b/src/sensors/TIADS1x15.cpp @@ -75,8 +75,11 @@ bool TIADS1x15::addSingleMeasurementResult(void) { // Bump the gain up to 1x = +/- 4.096V range ads.setGain(GAIN_ONE); - // Begin ADC - ads.begin(_i2cAddress); + // Begin ADC, returns true if anything was detected at the address + if (!ads.begin(_i2cAddress)) { + MS_DBG(F(" ADC initialization failed")); + return bumpMeasurementAttemptCount(false); + } // Read Analog to Digital Converter (ADC) // Taking this reading includes the 8ms conversion delay. diff --git a/src/sensors/TurnerCyclops.cpp b/src/sensors/TurnerCyclops.cpp index 7392e5874..471b10fe6 100644 --- a/src/sensors/TurnerCyclops.cpp +++ b/src/sensors/TurnerCyclops.cpp @@ -77,8 +77,11 @@ bool TurnerCyclops::addSingleMeasurementResult(void) { // Sensor return range is 0-2.5V, but the next gain option is 2x which // only allows up to 2.048V ads.setGain(GAIN_ONE); - // Begin ADC - ads.begin(_i2cAddress); + // Begin ADC, returns true if anything was detected at the address + if (!ads.begin(_i2cAddress)) { + MS_DBG(F(" ADC initialization failed")); + return bumpMeasurementAttemptCount(false); + } // Print out the calibration curve MS_DBG(F(" Input calibration Curve:"), _volt_std, F("V at"), _conc_std, diff --git a/src/sensors/TurnerTurbidityPlus.cpp b/src/sensors/TurnerTurbidityPlus.cpp index fcf1cda3e..102b0d5f8 100644 --- a/src/sensors/TurnerTurbidityPlus.cpp +++ b/src/sensors/TurnerTurbidityPlus.cpp @@ -121,8 +121,11 @@ bool TurnerTurbidityPlus::addSingleMeasurementResult(void) { // - 2/3 gain +/- 6.144V range (limited to VDD +0.3V max) ads.setGain(_PGA_gain); - // Begin ADC - ads.begin(_i2cAddress); + // Begin ADC, returns true if anything was detected at the address + if (!ads.begin(_i2cAddress)) { + MS_DBG(F(" ADC initialization failed")); + return bumpMeasurementAttemptCount(false); + } // Print out the calibration curve MS_DBG(F(" Input calibration Curve:"), _volt_std, F("V at"), _conc_std, From d7b5a14b3760f87ffd8aba27e7d1d5bbfb6ab3dc Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Fri, 24 Oct 2025 15:49:27 -0400 Subject: [PATCH 096/533] Initialize all local values Signed-off-by: Sara Damiano --- src/sensors/GroPointParent.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/sensors/GroPointParent.cpp b/src/sensors/GroPointParent.cpp index 6723b955c..8bd9be5d4 100644 --- a/src/sensors/GroPointParent.cpp +++ b/src/sensors/GroPointParent.cpp @@ -171,9 +171,12 @@ bool GroPointParent::addSingleMeasurementResult(void) { bool success = false; bool successT = false; // Initialize moisture variables for each probe segment - float M1, M2, M3, M4, M5, M6, M7, M8 = -9999; + float M1 = -9999, M2 = -9999, M3 = -9999, M4 = -9999, M5 = -9999, + M6 = -9999, M7 = -9999, M8 = -9999; // Initialize temperature variables for each probe sensor - float T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13 = -9999; + float T1 = -9999, T2 = -9999, T3 = -9999, T4 = -9999, T5 = -9999, + T6 = -9999, T7 = -9999, T8 = -9999, T9 = -9999, T10 = -9999, + T11 = -9999, T12 = -9999, T13 = -9999; switch (_model) { case GPLP8: { From 8dcf320bb6cd33fa72055ec7141b7f65abf528e6 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Fri, 24 Oct 2025 15:51:05 -0400 Subject: [PATCH 097/533] Check again for NaN Signed-off-by: Sara Damiano --- src/sensors/KellerParent.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/sensors/KellerParent.cpp b/src/sensors/KellerParent.cpp index 8e283ea5b..4fd23cc9e 100644 --- a/src/sensors/KellerParent.cpp +++ b/src/sensors/KellerParent.cpp @@ -115,8 +115,9 @@ bool KellerParent::addSingleMeasurementResult(void) { MS_DBG(F(" Temp_C:"), waterTemperatureC); MS_DBG(F(" Height_m:"), waterDepthM); - success &= (waterPressureBar != -9999 && waterTemperatureC != -9999 && - waterDepthM != -9999); + success &= (!isnan(waterPressureBar) && waterPressureBar != -9999 && + !isnan(waterTemperatureC) && waterTemperatureC != -9999 && + !isnan(waterDepthM) && waterDepthM != -9999); if (success) { // Put values into the array From 84549ade5515e477dcd1cb767aa99784ad9f432a Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Fri, 24 Oct 2025 15:55:30 -0400 Subject: [PATCH 098/533] Check for transmission success, replace magic number with define Signed-off-by: Sara Damiano --- src/sensors/PaleoTerraRedox.cpp | 4 +++- src/sensors/PaleoTerraRedox.h | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/sensors/PaleoTerraRedox.cpp b/src/sensors/PaleoTerraRedox.cpp index 014585924..8b9c48ab2 100644 --- a/src/sensors/PaleoTerraRedox.cpp +++ b/src/sensors/PaleoTerraRedox.cpp @@ -114,8 +114,10 @@ bool PaleoTerraRedox::addSingleMeasurementResult(void) { _i2c->write(0b10001100); // initiate conversion, One-Shot mode, 18 // bits, PGA x1 i2c_status = _i2c->endTransmission(); + // fail if transmission error + if (i2c_status != 0) { return bumpMeasurementAttemptCount(false); } - delay(300); + delay(PTR_CONVERSION_WAIT_TIME_MS); _i2c->requestFrom(int(_i2cAddressHex), 4); // Get 4 bytes from device diff --git a/src/sensors/PaleoTerraRedox.h b/src/sensors/PaleoTerraRedox.h index 6e26eeb0a..74c7705ef 100644 --- a/src/sensors/PaleoTerraRedox.h +++ b/src/sensors/PaleoTerraRedox.h @@ -127,6 +127,8 @@ /// @brief Sensor::_measurementTime_ms; the PaleoTerra redox sensor takes 67ms /// to complete a measurement. #define PTR_MEASUREMENT_TIME_MS 67 +/// @brief The time to wait after starting a conversion before data is ready. +#define PTR_CONVERSION_WAIT_TIME_MS 300 /**@}*/ /** From 0e62dee3e3ab0e0bf92bdaf6ebb8b9614ec45f78 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Fri, 24 Oct 2025 15:57:00 -0400 Subject: [PATCH 099/533] Fix data pin/multiplier check logic Signed-off-by: Sara Damiano --- src/sensors/ProcessorAnalog.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sensors/ProcessorAnalog.cpp b/src/sensors/ProcessorAnalog.cpp index 6a5941e7f..c6e71267a 100644 --- a/src/sensors/ProcessorAnalog.cpp +++ b/src/sensors/ProcessorAnalog.cpp @@ -34,7 +34,7 @@ bool ProcessorAnalog::addSingleMeasurementResult(void) { if (!getStatusBit(MEASUREMENT_SUCCESSFUL)) { return bumpMeasurementAttemptCount(false); } - if (_dataPin < 0 && _voltageMultiplier <= 0) { + if (_dataPin < 0 || _voltageMultiplier <= 0) { MS_DBG(F("No analog pin or voltage divider specified!")); return bumpMeasurementAttemptCount(false); } From a0848e078f2c792226c3b24e6140147388109ace Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Fri, 24 Oct 2025 15:58:12 -0400 Subject: [PATCH 100/533] Fix comment Signed-off-by: Sara Damiano --- src/sensors/ProcessorAnalog.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sensors/ProcessorAnalog.h b/src/sensors/ProcessorAnalog.h index 372d2bf35..d6790dea3 100644 --- a/src/sensors/ProcessorAnalog.h +++ b/src/sensors/ProcessorAnalog.h @@ -224,7 +224,7 @@ class ProcessorAnalog_Voltage : public Variable { * @param uuid A universally unique identifier (UUID or GUID) for the * variable; optional with the default value of an empty string. * @param varCode A short code to help identify the variable in files; - * optional with a default value of "extVoltage". + * optional with a default value of "analogVoltage". */ explicit ProcessorAnalog_Voltage( ProcessorAnalog* parentSense, const char* uuid = "", From ded249610706cb908d34cd8defb749f195452c29 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Fri, 24 Oct 2025 15:59:39 -0400 Subject: [PATCH 101/533] Remove isnan() check on int as check is for floats/doubles Signed-off-by: Sara Damiano --- src/sensors/TallyCounterI2C.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/sensors/TallyCounterI2C.cpp b/src/sensors/TallyCounterI2C.cpp index b55ecc3c4..c13289cf5 100644 --- a/src/sensors/TallyCounterI2C.cpp +++ b/src/sensors/TallyCounterI2C.cpp @@ -80,7 +80,6 @@ bool TallyCounterI2C::addSingleMeasurementResult(void) { // Read data from counter before clear events = counter_internal.Peek(); - if (isnan(events)) events = -9999; // Assume that if negative a failed response // May also return a very negative temp when receiving a bad response From 5b15d5c139c8c5ed8281ab90a3b275150612fe03 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Fri, 24 Oct 2025 16:03:08 -0400 Subject: [PATCH 102/533] Check for valid calibration Signed-off-by: Sara Damiano --- src/sensors/TurnerTurbidityPlus.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/sensors/TurnerTurbidityPlus.cpp b/src/sensors/TurnerTurbidityPlus.cpp index 102b0d5f8..32d077d23 100644 --- a/src/sensors/TurnerTurbidityPlus.cpp +++ b/src/sensors/TurnerTurbidityPlus.cpp @@ -130,6 +130,10 @@ bool TurnerTurbidityPlus::addSingleMeasurementResult(void) { // Print out the calibration curve MS_DBG(F(" Input calibration Curve:"), _volt_std, F("V at"), _conc_std, F(". "), _volt_blank, F("V blank.")); + if (_volt_std == _volt_blank) { + MS_DBG(F("Invalid calibration: point voltage equals blank voltage")); + return bumpMeasurementAttemptCount(false); + } // Read Analog to Digital Converter (ADC) // Taking this reading includes the 8ms conversion delay. From 1a8ec4042733c83921b3f5d5ec760b967a98225f Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Fri, 24 Oct 2025 16:08:14 -0400 Subject: [PATCH 103/533] Update changelog Signed-off-by: Sara Damiano --- ChangeLog.md | 1 + 1 file changed, 1 insertion(+) diff --git a/ChangeLog.md b/ChangeLog.md index 70ae05388..7fc3b49b5 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -28,6 +28,7 @@ This was probably a hold-over from incorrect implementation and calling of the c Also added optional arguments to the `completeUpdate()` function to allow users to specify if the sensors should be powered/woken. - The `updateAllSensors()` function is now deprecated. Use `completeUpdate(false, false, false, false)` instead. +- Applied many suggestions from Code Rabbit AI. ### Added From 1d5ad5741a42261663de2f2a8e5e3c8a4b58da62 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Fri, 24 Oct 2025 16:16:14 -0400 Subject: [PATCH 104/533] Remove isStable and confirm a valid status code as part of wake. Signed-off-by: Sara Damiano --- src/sensors/ANBpH.cpp | 62 +++---------------------------------------- src/sensors/ANBpH.h | 45 +++++++++++++++---------------- 2 files changed, 26 insertions(+), 81 deletions(-) diff --git a/src/sensors/ANBpH.cpp b/src/sensors/ANBpH.cpp index c0de12482..815d83915 100644 --- a/src/sensors/ANBpH.cpp +++ b/src/sensors/ANBpH.cpp @@ -18,6 +18,7 @@ ANBpH::ANBpH(byte modbusAddress, Stream* stream, int8_t powerPin, ANB_PH_STABILIZATION_TIME_MS, ANB_PH_2ND_VALUE_LOW_SALT, powerPin, -1, measurementsToAverage, ANB_PH_INC_CALC_VARIABLES), _anb_sensor(modbusAddress, stream, enablePin), + _modbusAddress(modbusAddress), _stream(stream), _RS485EnablePin(enablePin) { #ifdef MS_ANB_SENSORS_PH_DEBUG_DEEP @@ -185,9 +186,6 @@ bool ANBpH::setup(void) { } -// This confirms that the sensor is really giving modbus responses so nothing -// further happens if not. - It's a "check if it's awake" function rather than a -// "wake it up" function. bool ANBpH::wake(void) { // Sensor::wake() checks if the power pin is on and sets the wake timestamp // and status bits. If it returns false, there's no reason to go on. @@ -195,7 +193,7 @@ bool ANBpH::wake(void) { MS_DEEP_DBG(F("Checking for modbus response confirming"), getSensorNameAndLocation(), F("is awake")); - bool is_ready = isSensorReady(&anbSensor::gotModbusResponse, + bool is_ready = isSensorReady(&anbSensor::isSensorReady, ANB_PH_MINIMUM_REQUEST_SPACING, _millisPowerOn); if (!is_ready) { @@ -261,7 +259,7 @@ bool ANBpH::sleep(void) { return true; } - // Send the command to begin taking readings, trying up to 5 times + // Send the command to stop taking readings, trying up to 5 times bool success = false; uint8_t ntries = 0; MS_DBG(F("Stop Measurement on"), getSensorNameAndLocation()); @@ -426,7 +424,7 @@ bool ANBpH::isWarmedUp(bool debug) { getSensorNameAndLocation(), F("timed out after power up.")); return true; // timeout } else if (elapsed_since_power_on > _warmUpTime_ms) { - bool is_ready = isSensorReady(&anbSensor::gotModbusResponse, + bool is_ready = isSensorReady(&anbSensor::isSensorReady, ANB_PH_MINIMUM_REQUEST_SPACING, _millisPowerOn); if (is_ready) { @@ -441,58 +439,6 @@ bool ANBpH::isWarmedUp(bool debug) { } } - -// This checks to see if enough time has passed for stability -bool ANBpH::isStable(bool debug) { -#if defined(MS_ANB_SENSORS_PH_DEBUG_DEEP) || defined(MS_SENSORBASE_DEBUG) - debug = true; -#endif - // If the sensor failed to activate, it will never stabilize, so the - // stabilization time is essentially already passed - if (!getStatusBit(WAKE_SUCCESSFUL)) { - if (debug) { - MS_DBG(getSensorNameAndLocation(), - F("is not active and cannot stabilize!")); - } - return true; - } - - // If we're taking a repeat measurement, we may have already waited for - // stabilization after the initial wake, so we can skip this wait. - if (_retryAttemptsMade != 0) { - if (debug) { - MS_DBG(getSensorNameAndLocation(), - F("is retrying and doesn't need to stabilize again.")); - } - return true; - } - - uint32_t elapsed_since_wake_up = millis() - _millisSensorActivated; - uint32_t minTime = _stabilizationTime_ms; - uint32_t maxTime = ANB_PH_STABILIZATION_TIME_MAX; - // If the sensor has been activated and enough time has elapsed, it's stable - if (elapsed_since_wake_up > maxTime) { - MS_DBG(F("It's been"), elapsed_since_wake_up, F("ms, and"), - getSensorNameAndLocation(), - F("timed out waiting for a valid status code.")); - return true; // timeout - } else if (elapsed_since_wake_up > minTime) { - bool is_ready = isSensorReady(&anbSensor::isSensorReady, - ANB_PH_MINIMUM_REQUEST_SPACING, - _millisSensorActivated); - if (is_ready) { - MS_DBG(F("It's been"), elapsed_since_wake_up, F("ms, and"), - getSensorNameAndLocation(), - F("gave a valid status code, indicating it's ready to " - "start a measurement.")); - } - return is_ready; - } else { - // Wait at least the minimum readiness time - return false; - } -} - uint32_t ANBpH::getStartMeasurementWindow(void) { if (_powerPin >= 0 && _retryAttemptsMade == 0) { if (_salinityMode == ANBSalinityMode::HIGH_SALINITY) { diff --git a/src/sensors/ANBpH.h b/src/sensors/ANBpH.h index 147f4f4d7..58b5cb04c 100644 --- a/src/sensors/ANBpH.h +++ b/src/sensors/ANBpH.h @@ -144,25 +144,24 @@ * This is the time for communication to begin. */ #define ANB_PH_WARM_UP_TIME_MS 5400L -/// @brief The maximum time to wait for a modbus response. +/// @brief The maximum time to wait for a non-error modbus response. #define ANB_PH_WARM_UP_TIME_MAX 10000L /// @brief Sensor::_stabilizationTime_ms; the ANB pH sensor does not need to -/// stabilize, but we use this time as the check for ready time. -#define ANB_PH_STABILIZATION_TIME_MS 50 -/// @brief The maximum time to wait for ready to measure. -#define ANB_PH_STABILIZATION_TIME_MAX 5000L +/// stabilize - the stabilization and referencing time is included in the time +/// before the first value. +#define ANB_PH_STABILIZATION_TIME_MS 0L -/// @brief The minimum time for the first value in high salinity (documented min -/// time of 129s). +/// @brief The minimum time for the first value in high salinity (check 5 +/// seconds before the documented min time of 129s). /// @note If the immersion sensor is enabled and the sensor is not immersed, a /// failure response may be returned sooner -#define ANB_PH_1ST_VALUE_HIGH_SALT 120000L +#define ANB_PH_1ST_VALUE_HIGH_SALT 124000L /// @brief The maximum time for the first value in high salinity (documented max /// time of 238s for a long interval delay + 10s). #define ANB_PH_1ST_VALUE_HIGH_SALT_MAX 248000L /// @brief The minimum time for the first value in low salinity (documented min -/// time is 184s, but I got responses at 160s). +/// time is 184s, but I got responses at 160s so we check 1s before that). /// @note If the immersion sensor is enabled and the sensor is not immersed, a /// failure response may be returned sooner #define ANB_PH_1ST_VALUE_LOW_SALT 159000L @@ -511,6 +510,18 @@ class ANBpH : public Sensor { * @return True if the setup was successful. */ bool setup(void) override; + /** + * @brief Confirms that the sensor is giving a valid status code in response + * to modbus commands, re-sets the RTC, and starts measurements. + * + * Unlike base Sensor::wake(), this starts measurements (scanning). ANB pH + * sensors have a built-in stabilization and referencing time before they + * report the first value so when we start scanning, we're starting the wait + * for stabilization and then must wait the (very long) "first measurement" + * time before requesting the first result. + * + * @return True if the the sensor if the sensor started scanning. + */ bool wake(void) override; bool sleep(void) override; @@ -520,24 +531,12 @@ class ANBpH : public Sensor { * @copydoc Sensor::isWarmedUp(bool debug) * * For the ANB pH sensor, this waits for both the power-on warm up and for a - * valid response from the sensor to a Modbus command. - * - * @note The timing here is probably not very variable. - */ - bool isWarmedUp(bool debug = false) override; - - /** - * @brief Check whether or not enough time has passed between the sensor - * responding to any modbus command to giving a valid status code - which - * indicates that it's ready to take a measurement. - * - * @param debug True to output the result to the debugging Serial - * @return True indicates that enough time has passed that the sensor is + * valid status code response from the sensor - which indicates that it's * ready to take a measurement. * * @note The timing here is probably not very variable. */ - bool isStable(bool debug = false) override; + bool isWarmedUp(bool debug = false) override; /** * @brief Check whether or not the pH sensor has completed a measurement. From ecd7da47933015e006b8bb2ca3fcccebfaa10585 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Fri, 24 Oct 2025 16:18:01 -0400 Subject: [PATCH 105/533] Decrease successful temperatures to range of sensor Signed-off-by: Sara Damiano --- src/sensors/FreescaleMPL115A2.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sensors/FreescaleMPL115A2.cpp b/src/sensors/FreescaleMPL115A2.cpp index d017538f1..a2aba9106 100644 --- a/src/sensors/FreescaleMPL115A2.cpp +++ b/src/sensors/FreescaleMPL115A2.cpp @@ -78,7 +78,7 @@ bool FreescaleMPL115A2::addSingleMeasurementResult(void) { MS_DBG(F(" Pressure:"), press); if (!isnan(temp) && !isnan(press) && press >= 50.0 && press <= 115.0 && - temp >= -40.0 && temp <= 105.0) { + temp >= -20.0 && temp <= 85.0) { verifyAndAddMeasurementResult(MPL115A2_TEMP_VAR_NUM, temp); verifyAndAddMeasurementResult(MPL115A2_PRESSURE_VAR_NUM, press); success = true; From 8377afd97e49daeeb1296e2240c62edb910abf20 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Fri, 24 Oct 2025 16:26:25 -0400 Subject: [PATCH 106/533] Remove confusing comment, add to-do on voltage Signed-off-by: Sara Damiano --- src/sensors/AlphasenseCO2.cpp | 3 ++- src/sensors/ApogeeSQ212.cpp | 3 ++- src/sensors/CampbellOBS3.cpp | 3 ++- src/sensors/TIADS1x15.cpp | 3 ++- src/sensors/TurnerCyclops.cpp | 3 ++- src/sensors/TurnerTurbidityPlus.cpp | 1 - 6 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/sensors/AlphasenseCO2.cpp b/src/sensors/AlphasenseCO2.cpp index 889e57924..458ef95a7 100644 --- a/src/sensors/AlphasenseCO2.cpp +++ b/src/sensors/AlphasenseCO2.cpp @@ -93,8 +93,9 @@ bool AlphasenseCO2::addSingleMeasurementResult(void) { MS_DBG(F(" ads.readADC_Differential_2_3() converted to volts:"), adcVoltage); + // @todo Verify the voltage range for the CO2 sensor + // Here we are using the range of the ADS when it is powered at 3.3V if (adcVoltage < 3.6 && adcVoltage > -0.3) { - // Skip results out of range // Convert voltage to current (mA) - assuming a 250 Ohm resistor is in // series co2Current = (adcVoltage / 250) * 1000; diff --git a/src/sensors/ApogeeSQ212.cpp b/src/sensors/ApogeeSQ212.cpp index cdc0f2800..ec9266ec6 100644 --- a/src/sensors/ApogeeSQ212.cpp +++ b/src/sensors/ApogeeSQ212.cpp @@ -91,8 +91,9 @@ bool ApogeeSQ212::addSingleMeasurementResult(void) { adcVoltage = ads.computeVolts(adcCounts); MS_DBG(F(" ads.readADC_SingleEnded("), _adsChannel, F("):"), adcVoltage); + // @todo Verify the voltage range for the SQ-212 sensor + // Here we are using the range of the ADS when it is powered at 3.3V if (adcVoltage < 3.6 && adcVoltage > -0.3) { - // Skip results out of range // Apogee SQ-212 Calibration Factor = 1.0 μmol m-2 s-1 per mV calibResult = 1000 * adcVoltage * SQ212_CALIBRATION_FACTOR; MS_DBG(F(" calibResult:"), calibResult); diff --git a/src/sensors/CampbellOBS3.cpp b/src/sensors/CampbellOBS3.cpp index ac0b91e82..63c8f7697 100644 --- a/src/sensors/CampbellOBS3.cpp +++ b/src/sensors/CampbellOBS3.cpp @@ -95,8 +95,9 @@ bool CampbellOBS3::addSingleMeasurementResult(void) { adcVoltage = ads.computeVolts(adcCounts); MS_DBG(F(" ads.readADC_SingleEnded("), _adsChannel, F("):"), adcVoltage); + // @todo Verify the voltage range for the OBS3 sensor - + // Here we are using the range of the ADS when it is powered at 3.3V if (adcVoltage < 3.6 && adcVoltage > -0.3) { - // Skip results out of range // Apply the unique calibration curve for the given sensor calibResult = (_x2_coeff_A * sq(adcVoltage)) + (_x1_coeff_B * adcVoltage) + _x0_coeff_C; diff --git a/src/sensors/TIADS1x15.cpp b/src/sensors/TIADS1x15.cpp index 9be6336e8..68d8fc411 100644 --- a/src/sensors/TIADS1x15.cpp +++ b/src/sensors/TIADS1x15.cpp @@ -89,8 +89,9 @@ bool TIADS1x15::addSingleMeasurementResult(void) { adcVoltage = ads.computeVolts(adcCounts); MS_DBG(F(" ads.readADC_SingleEnded("), _adsChannel, F("):"), adcVoltage); + // @todo Verify the range based on the actual power supplied to the ADS. + // Here we are using the range of the ADS when it is powered at 3.3V if (adcVoltage < 3.6 && adcVoltage > -0.3) { - // Skip results out of range // Apply the gain calculation, with a default gain of 10 V/V Gain calibResult = adcVoltage * _gain; MS_DBG(F(" calibResult:"), calibResult); diff --git a/src/sensors/TurnerCyclops.cpp b/src/sensors/TurnerCyclops.cpp index 471b10fe6..1aeefc7ee 100644 --- a/src/sensors/TurnerCyclops.cpp +++ b/src/sensors/TurnerCyclops.cpp @@ -96,8 +96,9 @@ bool TurnerCyclops::addSingleMeasurementResult(void) { MS_DBG(F(" ads.readADC_SingleEnded("), _adsChannel, F("):"), adcCounts, '=', adcVoltage); + // @todo Verify the voltage range for the Cyclops sensor + // Here we are using the range of the ADS when it is powered at 3.3V if (adcVoltage < 3.6 && adcVoltage > -0.3) { - // Skip results out of range // Apply the unique calibration curve for the given sensor calibResult = (_conc_std / (_volt_std - _volt_blank)) * (adcVoltage - _volt_blank); diff --git a/src/sensors/TurnerTurbidityPlus.cpp b/src/sensors/TurnerTurbidityPlus.cpp index 32d077d23..4ad5c073b 100644 --- a/src/sensors/TurnerTurbidityPlus.cpp +++ b/src/sensors/TurnerTurbidityPlus.cpp @@ -167,7 +167,6 @@ bool TurnerTurbidityPlus::addSingleMeasurementResult(void) { // The ADS1X15 outputs a max value corresponding to Vcc + 0.3V if (adcVoltage < 5.3 && adcVoltage > -0.3) { - // Skip results out of range // Apply the unique calibration curve for the given sensor calibResult = (_conc_std / (_volt_std - _volt_blank)) * (adcVoltage - _volt_blank); From 697bbcef4bbff59924bf1d4176dc109ab0b7cd4e Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Fri, 24 Oct 2025 16:26:33 -0400 Subject: [PATCH 107/533] Fix typo Signed-off-by: Sara Damiano --- src/sensors/MaximDS3231.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/sensors/MaximDS3231.cpp b/src/sensors/MaximDS3231.cpp index 2f3aa8909..b80efbd78 100644 --- a/src/sensors/MaximDS3231.cpp +++ b/src/sensors/MaximDS3231.cpp @@ -56,8 +56,7 @@ bool MaximDS3231::startSingleMeasurement(void) { bool MaximDS3231::addSingleMeasurementResult(void) { // NOTE: This can't fail! If it does we have much bigger problems because - // that means we can't get the timeand the whole system is not working. - + // that means we can't get the time and the whole system is not working. // get the temperature value MS_DBG(getSensorNameAndLocation(), F("is reporting:")); float tempVal = rtc.getTemperature(); From cb78bfacf6c9bfb3a47a4a6c1b4f6a1481ea52ee Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Fri, 24 Oct 2025 16:29:37 -0400 Subject: [PATCH 108/533] Close file even when no transfer Signed-off-by: Sara Damiano --- src/sensors/GeoluxHydroCam.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/sensors/GeoluxHydroCam.cpp b/src/sensors/GeoluxHydroCam.cpp index 76a99f2ec..ef4a93f18 100644 --- a/src/sensors/GeoluxHydroCam.cpp +++ b/src/sensors/GeoluxHydroCam.cpp @@ -254,6 +254,10 @@ bool GeoluxHydroCam::addSingleMeasurementResult(void) { verifyAndAddMeasurementResult(HYDROCAM_SIZE_VAR_NUM, bytes_transferred); verifyAndAddMeasurementResult(HYDROCAM_ERROR_VAR_NUM, byte_error); + } else { + MS_DBG(F("Image transfer failed, so not writing any data to SD card.")); + // Close the image file + imgFile.close(); } // Return success value when finished From 3cfc07feb410b009180a970d92fd7858b3ca270a Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Fri, 24 Oct 2025 16:29:54 -0400 Subject: [PATCH 109/533] use epsilon Signed-off-by: Sara Damiano --- src/sensors/TurnerTurbidityPlus.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/sensors/TurnerTurbidityPlus.cpp b/src/sensors/TurnerTurbidityPlus.cpp index 4ad5c073b..c82556c1c 100644 --- a/src/sensors/TurnerTurbidityPlus.cpp +++ b/src/sensors/TurnerTurbidityPlus.cpp @@ -130,7 +130,8 @@ bool TurnerTurbidityPlus::addSingleMeasurementResult(void) { // Print out the calibration curve MS_DBG(F(" Input calibration Curve:"), _volt_std, F("V at"), _conc_std, F(". "), _volt_blank, F("V blank.")); - if (_volt_std == _volt_blank) { + const float epsilon = 1e-6; // Adjust based on expected precision + if (fabs(_volt_std - _volt_blank) < epsilon) { MS_DBG(F("Invalid calibration: point voltage equals blank voltage")); return bumpMeasurementAttemptCount(false); } From 5e08e82d688498204c1607c2dccca272f18912a3 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Fri, 24 Oct 2025 16:30:05 -0400 Subject: [PATCH 110/533] fix typo Signed-off-by: Sara Damiano --- src/sensors/ANBpH.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sensors/ANBpH.h b/src/sensors/ANBpH.h index 58b5cb04c..cec8f82f4 100644 --- a/src/sensors/ANBpH.h +++ b/src/sensors/ANBpH.h @@ -520,7 +520,7 @@ class ANBpH : public Sensor { * for stabilization and then must wait the (very long) "first measurement" * time before requesting the first result. * - * @return True if the the sensor if the sensor started scanning. + * @return True if the sensor started scanning. */ bool wake(void) override; bool sleep(void) override; From 4f85b4959265a9cbcd505b47c2eaee33df6ad785 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Mon, 27 Oct 2025 10:10:33 -0400 Subject: [PATCH 111/533] Update ChangeLog.md Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --- ChangeLog.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ChangeLog.md b/ChangeLog.md index 7fc3b49b5..0115c8eb9 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -14,7 +14,8 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm - **BREAKING** Changed capitalization of `setInitialShortIntervals(#)` function - Previously the 'i' of initial was not capitalized. -- Made the enabling and disabling of the watchdog the very first and very last steps of sleep to keep the watchdog enabled through the whole getting ready for bed and waking up process.- **ANB pH** Changed timing slightly and simplified timing logic. +- Made the enabling and disabling of the watchdog the very first and very last steps of sleep to keep the watchdog enabled through the whole getting ready for bed and waking up process. +- **ANB pH** Changed timing slightly and simplified timing logic. - Bumped several dependencies - including crucial bug fixes to SensorModbusMaster. - Re-wrote most of the logic for looping variables within the complete update function of the VariableArray. - Simplified the `addSingleMeasurementResult()` function of all sensors to use an internal function to help set the bits and timing values and to quit sooner if the measurement was not started successfully. From 9912b1666b0e71e9f79033b6d851465d1243420f Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Mon, 27 Oct 2025 10:11:11 -0400 Subject: [PATCH 112/533] Update examples/menu_a_la_carte/ReadMe.md Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --- examples/menu_a_la_carte/ReadMe.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/menu_a_la_carte/ReadMe.md b/examples/menu_a_la_carte/ReadMe.md index 738342553..b091de98a 100644 --- a/examples/menu_a_la_carte/ReadMe.md +++ b/examples/menu_a_la_carte/ReadMe.md @@ -836,7 +836,7 @@ ___ ### External Voltage via Processor ADC The Arduino pin controlling power on/off, the analog data pin on the processor, and the multiplier for a voltage divider are required for the sensor constructor. -If your processor operating voltage is not correctly in KnownProcessors.h, you must input it is the fourth argument; otherwise you can enter `OPERATING_VOLTAGE` for the voltage defined in KnownProcessors.h. +If your processor operating voltage is not correctly in KnownProcessors.h, you must input it as the fourth argument; otherwise you can enter `OPERATING_VOLTAGE` for the voltage defined in KnownProcessors.h. The number of measurements to average, if more than one is desired, goes as the fifth argument. @see @ref sensor_processor_analog From bf8b7772c9291f9ee794427d89da4b91bf5835d9 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Mon, 27 Oct 2025 10:14:30 -0400 Subject: [PATCH 113/533] Update src/sensors/TallyCounterI2C.cpp Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --- src/sensors/TallyCounterI2C.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/sensors/TallyCounterI2C.cpp b/src/sensors/TallyCounterI2C.cpp index c13289cf5..90a6f36e1 100644 --- a/src/sensors/TallyCounterI2C.cpp +++ b/src/sensors/TallyCounterI2C.cpp @@ -81,8 +81,8 @@ bool TallyCounterI2C::addSingleMeasurementResult(void) { events = counter_internal.Peek(); - // Assume that if negative a failed response - // May also return a very negative temp when receiving a bad response + // Assume that if negative, it indicates a failed response + // May also return a very negative value when receiving a bad response if (events < 0) { MS_DBG(getSensorNameAndLocation(), F("returns all values 0 or bad, assuming sensor non-response!")); From 4c1561705ef0bb59c6a0120fba58ac4e580ab2d5 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Mon, 27 Oct 2025 10:16:57 -0400 Subject: [PATCH 114/533] Update resolution comment Signed-off-by: Sara Damiano --- src/sensors/TIINA219.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sensors/TIINA219.h b/src/sensors/TIINA219.h index bdd7e7650..6254adfa2 100644 --- a/src/sensors/TIINA219.h +++ b/src/sensors/TIINA219.h @@ -176,7 +176,7 @@ */ /**@{*/ /// @brief Decimals places in string representation; bus voltage should have 3 - -/// resolution is 0.001V. +/// resolution is 0.004V. #define INA219_BUS_VOLTAGE_RESOLUTION 3 /// @brief Sensor variable number; bus voltage is stored in sensorValues[1]. #define INA219_BUS_VOLTAGE_VAR_NUM 1 From eb9d08ed3eee46c660a6f31dd2b6501221c5b128 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Mon, 27 Oct 2025 10:19:25 -0400 Subject: [PATCH 115/533] add check for invalid calibration Signed-off-by: Sara Damiano --- src/sensors/TurnerCyclops.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/sensors/TurnerCyclops.cpp b/src/sensors/TurnerCyclops.cpp index 1aeefc7ee..9a3ad9a1d 100644 --- a/src/sensors/TurnerCyclops.cpp +++ b/src/sensors/TurnerCyclops.cpp @@ -86,6 +86,11 @@ bool TurnerCyclops::addSingleMeasurementResult(void) { // Print out the calibration curve MS_DBG(F(" Input calibration Curve:"), _volt_std, F("V at"), _conc_std, F(". "), _volt_blank, F("V blank.")); + const float epsilon = 1e-6; // Adjust based on expected precision + if (fabs(_volt_std - _volt_blank) < epsilon) { + MS_DBG(F("Invalid calibration: point voltage equals blank voltage")); + return bumpMeasurementAttemptCount(false); + } // Read Analog to Digital Converter (ADC) // Taking this reading includes the 8ms conversion delay. From 923f142646aaf82ea6ec97a5ee4c1d7785a2c969 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Mon, 27 Oct 2025 10:28:55 -0400 Subject: [PATCH 116/533] Change success logic again Signed-off-by: Sara Damiano --- src/sensors/RainCounterI2C.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sensors/RainCounterI2C.cpp b/src/sensors/RainCounterI2C.cpp index 4ea9c297b..88a2ed47a 100644 --- a/src/sensors/RainCounterI2C.cpp +++ b/src/sensors/RainCounterI2C.cpp @@ -154,7 +154,7 @@ bool RainCounterI2C::addSingleMeasurementResult(void) { MS_DBG(F(" Rain:"), rain); MS_DBG(F(" Tips:"), tips); - if (rain != -9999 || tips != -9999) { // if either is valid + if (rain != -9999 && tips != -9999) { // if both are valid verifyAndAddMeasurementResult(BUCKET_RAIN_VAR_NUM, rain); verifyAndAddMeasurementResult(BUCKET_TIPS_VAR_NUM, tips); success = true; From eb77fa6c25fc298381ceaa8c58da3eaf8ee5674c Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Mon, 27 Oct 2025 10:29:07 -0400 Subject: [PATCH 117/533] Add a note about conversion wait Signed-off-by: Sara Damiano --- src/sensors/PaleoTerraRedox.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/sensors/PaleoTerraRedox.cpp b/src/sensors/PaleoTerraRedox.cpp index 8b9c48ab2..72699837a 100644 --- a/src/sensors/PaleoTerraRedox.cpp +++ b/src/sensors/PaleoTerraRedox.cpp @@ -117,6 +117,7 @@ bool PaleoTerraRedox::addSingleMeasurementResult(void) { // fail if transmission error if (i2c_status != 0) { return bumpMeasurementAttemptCount(false); } + // wait for the conversion to complete delay(PTR_CONVERSION_WAIT_TIME_MS); _i2c->requestFrom(int(_i2cAddressHex), From 46abb5ec0ef483e29a990f92f809bc403985e80e Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Mon, 27 Oct 2025 10:30:11 -0400 Subject: [PATCH 118/533] Add missing semicolon Signed-off-by: Sara Damiano --- src/sensors/ProcessorStats.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sensors/ProcessorStats.cpp b/src/sensors/ProcessorStats.cpp index 242f5d45c..253b4f4f5 100644 --- a/src/sensors/ProcessorStats.cpp +++ b/src/sensors/ProcessorStats.cpp @@ -36,7 +36,7 @@ ProcessorStats::ProcessorStats(const char* version, } else if (strcmp(_version, "v0.2") == 0) { _batteryMultiplier = 1.47; } else { - _batteryMultiplier = -1 + _batteryMultiplier = -1; } #elif defined(ARDUINO_SODAQ_AUTONOMO) if (strcmp(_version, "v0.1") == 0) From a82a2f1637c2cc6ad5c702fa871efdc4eff7f51b Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Mon, 27 Oct 2025 10:31:46 -0400 Subject: [PATCH 119/533] Fix var num comments Signed-off-by: Sara Damiano --- src/sensors/BoschBMP3xx.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/sensors/BoschBMP3xx.h b/src/sensors/BoschBMP3xx.h index 5682575eb..c8c911102 100644 --- a/src/sensors/BoschBMP3xx.h +++ b/src/sensors/BoschBMP3xx.h @@ -291,7 +291,7 @@ /// datasheet](https://github.com/EnviroDIY/ModularSensors/wiki/Sensor-Datasheets/Bosch-BMP390-Datasheet.pdf) /// for resolution at all bandwidths. #define BMP3XX_PRESSURE_RESOLUTION 3 -/// @brief Sensor variable number; pressure is stored in sensorValues[2]. +/// @brief Sensor variable number; pressure is stored in sensorValues[1]. #define BMP3XX_PRESSURE_VAR_NUM 1 /// @brief Variable name in /// [ODM2 controlled vocabulary](http://vocabulary.odm2.org/variablename/); @@ -316,7 +316,7 @@ /// @brief Decimals places in string representation; altitude should have 0 - /// resolution is 1m. #define BMP3XX_ALTITUDE_RESOLUTION 0 -/// @brief Sensor variable number; altitude is stored in sensorValues[3]. +/// @brief Sensor variable number; altitude is stored in sensorValues[2]. #define BMP3XX_ALTITUDE_VAR_NUM 2 /// @brief Variable name in /// [ODM2 controlled vocabulary](http://vocabulary.odm2.org/variablename/); From eb930ed168f0a18f5959e8380cf646fbc0cb6dd8 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Mon, 27 Oct 2025 10:32:37 -0400 Subject: [PATCH 120/533] Fix comment on default value Signed-off-by: Sara Damiano --- src/sensors/YosemitechParent.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sensors/YosemitechParent.h b/src/sensors/YosemitechParent.h index a8a6e9655..505b7c9b6 100644 --- a/src/sensors/YosemitechParent.h +++ b/src/sensors/YosemitechParent.h @@ -168,7 +168,7 @@ class YosemitechParent : public Sensor { * average before giving a "final" result from the sensor; optional with a * default value of 1. * @param model The model of Yosemitech sensor. - * @param sensName The name of the sensor. Defaults to "SDI12-Sensor". + * @param sensName The name of the sensor. Defaults to "Yosemitech-Sensor". * @param numVariables The number of variable results returned by the * sensor. Defaults to 2. * @param warmUpTime_ms The time in ms between when the sensor is powered on From d582aec07be6edce78e5125c57b05d36ba232fb5 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Mon, 27 Oct 2025 10:33:54 -0400 Subject: [PATCH 121/533] Fix var num comments Signed-off-by: Sara Damiano --- src/sensors/ANBpH.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/sensors/ANBpH.h b/src/sensors/ANBpH.h index cec8f82f4..006dd0fe0 100644 --- a/src/sensors/ANBpH.h +++ b/src/sensors/ANBpH.h @@ -368,7 +368,7 @@ // clang-format on /// @brief Decimals places in string representation; the health code has 0. #define ANB_PH_HEALTH_CODE_RESOLUTION 0 -/// @brief Sensor variable number; health code is stored in sensorValues[4] +/// @brief Sensor variable number; health code is stored in sensorValues[5] #define ANB_PH_HEALTH_CODE_VAR_NUM 5 /// @brief Variable name in /// [ODM2 controlled vocabulary](http://vocabulary.odm2.org/variablename/); @@ -404,7 +404,7 @@ // clang-format on /// @brief Decimals places in string representation; the diagnostic code has 0. #define ANB_PH_DIAGNOSTIC_CODE_RESOLUTION 0 -/// @brief Sensor variable number; diagnostic code is stored in sensorValues[4] +/// @brief Sensor variable number; diagnostic code is stored in sensorValues[6] #define ANB_PH_DIAGNOSTIC_CODE_VAR_NUM 6 /// @brief Variable name in /// [ODM2 controlled vocabulary](http://vocabulary.odm2.org/variablename/); @@ -441,7 +441,7 @@ // clang-format on /// @brief Decimals places in string representation; the error code has 0. #define ANB_PH_STATUS_CODE_RESOLUTION 0 -/// @brief Sensor variable number; error code is stored in sensorValues[4] +/// @brief Sensor variable number; error code is stored in sensorValues[7] #define ANB_PH_STATUS_CODE_VAR_NUM 7 /// @brief Variable name in /// [ODM2 controlled vocabulary](http://vocabulary.odm2.org/variablename/); From 8e022b6426e2237c1c8eb1dd9623dcbb0b39c7c4 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Mon, 27 Oct 2025 10:38:28 -0400 Subject: [PATCH 122/533] Rename processor analog variables Signed-off-by: Sara Damiano --- examples/menu_a_la_carte/menu_a_la_carte.ino | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/examples/menu_a_la_carte/menu_a_la_carte.ino b/examples/menu_a_la_carte/menu_a_la_carte.ino index 6465ce856..86fd3c242 100644 --- a/examples/menu_a_la_carte/menu_a_la_carte.ino +++ b/examples/menu_a_la_carte/menu_a_la_carte.ino @@ -1622,7 +1622,7 @@ const float dividerGain = 10; // Gain setting if using a voltage divider const uint8_t evADSi2c_addr = 0x48; // The I2C address of the ADS1115 ADC const uint8_t VoltReadsToAvg = 1; // Only read one sample -// Create an External Voltage sensor object +// Create an TI ADS1x15 sensor object TIADS1x15 ads1x15(ADSPower, ADSChannel, dividerGain, evADSi2c_addr, VoltReadsToAvg); @@ -1641,15 +1641,15 @@ Variable* ads1x15Volt = #include // NOTE: Use -1 for any pins that don't apply or aren't being used. -const int8_t externalAnalogPowerPin = sensorPowerPin; // Power pin -const int8_t externalAnalogDataChannel = A0; // The ADS channel of interest -const float externalAnalogMultiplier = +const int8_t processorAnalogPowerPin = sensorPowerPin; // Power pin +const int8_t processorAnalogDataPin = A0; // Analog input pin (processor ADC) +const float processorAnalogMultiplier = 5.58; // Gain setting if using a voltage divider const uint8_t eaReadsToAvg = 1; // Only read one sample -// Create an External Voltage sensor object -ProcessorAnalog extAnalog(externalAnalogPowerPin, externalAnalogDataChannel, - externalAnalogMultiplier, OPERATING_VOLTAGE, +// Create an Processor Analog sensor object +ProcessorAnalog extAnalog(processorAnalogPowerPin, processorAnalogDataPin, + processorAnalogMultiplier, OPERATING_VOLTAGE, eaReadsToAvg); // Create a voltage variable pointer From b76a03296fc0c7e4ee4f4493ad7da56ea340e719 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Mon, 27 Oct 2025 10:39:59 -0400 Subject: [PATCH 123/533] Verify that PaleoTerra receives 4 bytes Signed-off-by: Sara Damiano --- src/sensors/PaleoTerraRedox.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/sensors/PaleoTerraRedox.cpp b/src/sensors/PaleoTerraRedox.cpp index 72699837a..4a236534d 100644 --- a/src/sensors/PaleoTerraRedox.cpp +++ b/src/sensors/PaleoTerraRedox.cpp @@ -122,6 +122,7 @@ bool PaleoTerraRedox::addSingleMeasurementResult(void) { _i2c->requestFrom(int(_i2cAddressHex), 4); // Get 4 bytes from device + if (_i2c->available() != 4) { return bumpMeasurementAttemptCount(false); } byte res1 = _i2c->read(); byte res2 = _i2c->read(); byte res3 = _i2c->read(); From c3fbb871ff24dc9ffb1164c64558f2afb285aa19 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Mon, 27 Oct 2025 10:48:22 -0400 Subject: [PATCH 124/533] Fix Alphasense CO2 to use the entered differential pin config Signed-off-by: Sara Damiano --- src/sensors/AlphasenseCO2.cpp | 30 +++++++++++++++++++++++++---- src/sensors/TurnerTurbidityPlus.cpp | 4 ++-- 2 files changed, 28 insertions(+), 6 deletions(-) diff --git a/src/sensors/AlphasenseCO2.cpp b/src/sensors/AlphasenseCO2.cpp index 458ef95a7..63819268b 100644 --- a/src/sensors/AlphasenseCO2.cpp +++ b/src/sensors/AlphasenseCO2.cpp @@ -37,7 +37,8 @@ String AlphasenseCO2::getSensorLocation(void) { String sensorLocation = F("ADS1015_0x"); #endif sensorLocation += String(_i2cAddress, HEX); - sensorLocation += F("; differential between channels 2 and 3"); + sensorLocation += F("_adsDiffMux"); + sensorLocation += String(_adsDiffMux); return sensorLocation; } @@ -87,11 +88,32 @@ bool AlphasenseCO2::addSingleMeasurementResult(void) { // Read Analog to Digital Converter (ADC) // Taking this reading includes the 8ms conversion delay. // Measure the voltage differential across the two voltage pins - adcCounts = ads.readADC_Differential_2_3(); + switch (_adsDiffMux) { + case DIFF_MUX_0_1: { + adcCounts = ads.readADC_Differential_0_1(); + break; + } + case DIFF_MUX_0_3: { + adcCounts = ads.readADC_Differential_0_3(); + break; + } + case DIFF_MUX_1_3: { + adcCounts = ads.readADC_Differential_1_3(); + break; + } + case DIFF_MUX_2_3: { + adcCounts = ads.readADC_Differential_2_3(); + break; + } + default: { + MS_DBG(F(" Invalid differential mux configuration")); + return bumpMeasurementAttemptCount(false); + } + } // Convert ADC counts value to voltage (V) adcVoltage = ads.computeVolts(adcCounts); - MS_DBG(F(" ads.readADC_Differential_2_3() converted to volts:"), - adcVoltage); + MS_DBG(F(" ads.readADC_Differential("), _adsDiffMux, F("):"), + String(adcVoltage, 3)); // @todo Verify the voltage range for the CO2 sensor // Here we are using the range of the ADS when it is powered at 3.3V diff --git a/src/sensors/TurnerTurbidityPlus.cpp b/src/sensors/TurnerTurbidityPlus.cpp index c82556c1c..e2fe3ab8c 100644 --- a/src/sensors/TurnerTurbidityPlus.cpp +++ b/src/sensors/TurnerTurbidityPlus.cpp @@ -103,8 +103,8 @@ bool TurnerTurbidityPlus::addSingleMeasurementResult(void) { MS_DBG(getSensorNameAndLocation(), F("is reporting:")); // Create an auxiliary ADD object -// We create and set up the ADC object here so that each sensor using -// the ADC may set the gain appropriately without effecting others. +// We create and set up the ADC object here so that each sensor using the ADC +// may set the gain appropriately without effecting others. #ifndef MS_USE_ADS1015 Adafruit_ADS1115 ads; // Use this for the 16-bit version #else From 93c520f62fabef00d6830436eaba8e77b982dadb Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Mon, 27 Oct 2025 10:53:05 -0400 Subject: [PATCH 125/533] Modify some TI ADC debug comments Signed-off-by: Sara Damiano --- src/sensors/AlphasenseCO2.cpp | 3 ++- src/sensors/ApogeeSQ212.cpp | 6 ++++-- src/sensors/CampbellOBS3.cpp | 6 ++++-- src/sensors/TIADS1x15.cpp | 6 ++++-- src/sensors/TurnerCyclops.cpp | 5 +++-- src/sensors/TurnerTurbidityPlus.cpp | 5 +++-- 6 files changed, 20 insertions(+), 11 deletions(-) diff --git a/src/sensors/AlphasenseCO2.cpp b/src/sensors/AlphasenseCO2.cpp index 63819268b..df9b14fd6 100644 --- a/src/sensors/AlphasenseCO2.cpp +++ b/src/sensors/AlphasenseCO2.cpp @@ -81,7 +81,8 @@ bool AlphasenseCO2::addSingleMeasurementResult(void) { ads.setGain(GAIN_ONE); // Begin ADC, returns true if anything was detected at the address if (!ads.begin(_i2cAddress)) { - MS_DBG(F(" ADC initialization failed")); + MS_DBG(F(" ADC initialization failed at 0x"), + String(_i2cAddress, HEX)); return bumpMeasurementAttemptCount(false); } diff --git a/src/sensors/ApogeeSQ212.cpp b/src/sensors/ApogeeSQ212.cpp index ec9266ec6..be81eb715 100644 --- a/src/sensors/ApogeeSQ212.cpp +++ b/src/sensors/ApogeeSQ212.cpp @@ -79,7 +79,8 @@ bool ApogeeSQ212::addSingleMeasurementResult(void) { ads.setGain(GAIN_ONE); // Begin ADC, returns true if anything was detected at the address if (!ads.begin(_i2cAddress)) { - MS_DBG(F(" ADC initialization failed")); + MS_DBG(F(" ADC initialization failed at 0x"), + String(_i2cAddress, HEX)); return bumpMeasurementAttemptCount(false); } @@ -89,7 +90,8 @@ bool ApogeeSQ212::addSingleMeasurementResult(void) { adcCounts = ads.readADC_SingleEnded(_adsChannel); // Convert ADC raw counts value to voltage (V) adcVoltage = ads.computeVolts(adcCounts); - MS_DBG(F(" ads.readADC_SingleEnded("), _adsChannel, F("):"), adcVoltage); + MS_DBG(F(" ads.readADC_SingleEnded("), _adsChannel, F("):"), adcCounts, + '=', adcVoltage); // @todo Verify the voltage range for the SQ-212 sensor // Here we are using the range of the ADS when it is powered at 3.3V diff --git a/src/sensors/CampbellOBS3.cpp b/src/sensors/CampbellOBS3.cpp index 63c8f7697..363fbc2c5 100644 --- a/src/sensors/CampbellOBS3.cpp +++ b/src/sensors/CampbellOBS3.cpp @@ -79,7 +79,8 @@ bool CampbellOBS3::addSingleMeasurementResult(void) { ads.setGain(GAIN_ONE); // Begin ADC, returns true if anything was detected at the address if (!ads.begin(_i2cAddress)) { - MS_DBG(F(" ADC initialization failed")); + MS_DBG(F(" ADC initialization failed at 0x"), + String(_i2cAddress, HEX)); return bumpMeasurementAttemptCount(false); } @@ -93,7 +94,8 @@ bool CampbellOBS3::addSingleMeasurementResult(void) { adcCounts = ads.readADC_SingleEnded(_adsChannel); // Convert ADC raw counts value to voltage (V) adcVoltage = ads.computeVolts(adcCounts); - MS_DBG(F(" ads.readADC_SingleEnded("), _adsChannel, F("):"), adcVoltage); + MS_DBG(F(" ads.readADC_SingleEnded("), _adsChannel, F("):"), adcCounts, + '=', adcVoltage); // @todo Verify the voltage range for the OBS3 sensor - // Here we are using the range of the ADS when it is powered at 3.3V diff --git a/src/sensors/TIADS1x15.cpp b/src/sensors/TIADS1x15.cpp index 68d8fc411..03cbd64b6 100644 --- a/src/sensors/TIADS1x15.cpp +++ b/src/sensors/TIADS1x15.cpp @@ -77,7 +77,8 @@ bool TIADS1x15::addSingleMeasurementResult(void) { ads.setGain(GAIN_ONE); // Begin ADC, returns true if anything was detected at the address if (!ads.begin(_i2cAddress)) { - MS_DBG(F(" ADC initialization failed")); + MS_DBG(F(" ADC initialization failed at 0x"), + String(_i2cAddress, HEX)); return bumpMeasurementAttemptCount(false); } @@ -87,7 +88,8 @@ bool TIADS1x15::addSingleMeasurementResult(void) { adcCounts = ads.readADC_SingleEnded(_adsChannel); // Convert ADC raw counts value to voltage (V) adcVoltage = ads.computeVolts(adcCounts); - MS_DBG(F(" ads.readADC_SingleEnded("), _adsChannel, F("):"), adcVoltage); + MS_DBG(F(" ads.readADC_SingleEnded("), _adsChannel, F("):"), adcCounts, + '=', adcVoltage); // @todo Verify the range based on the actual power supplied to the ADS. // Here we are using the range of the ADS when it is powered at 3.3V diff --git a/src/sensors/TurnerCyclops.cpp b/src/sensors/TurnerCyclops.cpp index 9a3ad9a1d..950d0c024 100644 --- a/src/sensors/TurnerCyclops.cpp +++ b/src/sensors/TurnerCyclops.cpp @@ -79,14 +79,15 @@ bool TurnerCyclops::addSingleMeasurementResult(void) { ads.setGain(GAIN_ONE); // Begin ADC, returns true if anything was detected at the address if (!ads.begin(_i2cAddress)) { - MS_DBG(F(" ADC initialization failed")); + MS_DBG(F(" ADC initialization failed at 0x"), + String(_i2cAddress, HEX)); return bumpMeasurementAttemptCount(false); } // Print out the calibration curve MS_DBG(F(" Input calibration Curve:"), _volt_std, F("V at"), _conc_std, F(". "), _volt_blank, F("V blank.")); - const float epsilon = 1e-6; // Adjust based on expected precision + const float epsilon = 1e-4f; // tune to expected sensor precision if (fabs(_volt_std - _volt_blank) < epsilon) { MS_DBG(F("Invalid calibration: point voltage equals blank voltage")); return bumpMeasurementAttemptCount(false); diff --git a/src/sensors/TurnerTurbidityPlus.cpp b/src/sensors/TurnerTurbidityPlus.cpp index e2fe3ab8c..05a250a42 100644 --- a/src/sensors/TurnerTurbidityPlus.cpp +++ b/src/sensors/TurnerTurbidityPlus.cpp @@ -123,14 +123,15 @@ bool TurnerTurbidityPlus::addSingleMeasurementResult(void) { ads.setGain(_PGA_gain); // Begin ADC, returns true if anything was detected at the address if (!ads.begin(_i2cAddress)) { - MS_DBG(F(" ADC initialization failed")); + MS_DBG(F(" ADC initialization failed at 0x"), + String(_i2cAddress, HEX)); return bumpMeasurementAttemptCount(false); } // Print out the calibration curve MS_DBG(F(" Input calibration Curve:"), _volt_std, F("V at"), _conc_std, F(". "), _volt_blank, F("V blank.")); - const float epsilon = 1e-6; // Adjust based on expected precision + const float epsilon = 1e-4f; // tune to expected sensor precision if (fabs(_volt_std - _volt_blank) < epsilon) { MS_DBG(F("Invalid calibration: point voltage equals blank voltage")); return bumpMeasurementAttemptCount(false); From 34f4abb05dddc5ff8cd33698b42d4cca68ed7024 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Mon, 27 Oct 2025 10:54:09 -0400 Subject: [PATCH 126/533] Update comment Signed-off-by: Sara Damiano --- src/sensors/ANBpH.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/sensors/ANBpH.h b/src/sensors/ANBpH.h index 006dd0fe0..5ccfb481c 100644 --- a/src/sensors/ANBpH.h +++ b/src/sensors/ANBpH.h @@ -170,12 +170,12 @@ #define ANB_PH_1ST_VALUE_LOW_SALT_MAX 265000L /// @brief The minimum time for the 2nd or subsequent values in high -/// salinity (documented new output time of 10.5s) +/// salinity (documented new output time of 10.5s, add 100ms buffer). /// @warning After the first reading, the sensor will *always* say the sensor is /// ready! But there will not be a **new** value available before this time. #define ANB_PH_2ND_VALUE_HIGH_SALT 10600L /// @brief The minimum time for the 2nd or subsequent values in low -/// salinity (documented new output time of 14s). +/// salinity (documented new output time of 14s, add 100ms buffer). /// @warning After the first reading, the sensor will *always* say the sensor is /// ready! But there will not be a **new** value available before this time. #define ANB_PH_2ND_VALUE_LOW_SALT 14100L From 2728cfae7f6b3f1a2ad27db989c66ef5dbcdf2d5 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Mon, 27 Oct 2025 11:05:35 -0400 Subject: [PATCH 127/533] Update src/sensors/TIINA219.h Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --- src/sensors/TIINA219.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sensors/TIINA219.h b/src/sensors/TIINA219.h index 6254adfa2..ad2ae8a0e 100644 --- a/src/sensors/TIINA219.h +++ b/src/sensors/TIINA219.h @@ -34,7 +34,7 @@ * of this sensor can be increased to increase sensitivity (at the expense of * range) but this library assumes the maximum range. * - * Communications between the INA219 and the mcu is managed by the + * Communications between the INA219 and the mcu are managed by the * [Adafruit INA219 Library](https://github.com/adafruit/Adafruit_INA219) * * @note Software I2C is *not* supported for the INA219. From ded39fe1fc11a8ccfacb507d872e91ba3cc6f9e7 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Mon, 27 Oct 2025 11:57:33 -0400 Subject: [PATCH 128/533] Grammar fix Signed-off-by: Sara Damiano --- examples/menu_a_la_carte/menu_a_la_carte.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/menu_a_la_carte/menu_a_la_carte.ino b/examples/menu_a_la_carte/menu_a_la_carte.ino index 86fd3c242..47e2e79d4 100644 --- a/examples/menu_a_la_carte/menu_a_la_carte.ino +++ b/examples/menu_a_la_carte/menu_a_la_carte.ino @@ -1622,7 +1622,7 @@ const float dividerGain = 10; // Gain setting if using a voltage divider const uint8_t evADSi2c_addr = 0x48; // The I2C address of the ADS1115 ADC const uint8_t VoltReadsToAvg = 1; // Only read one sample -// Create an TI ADS1x15 sensor object +// Create a TI ADS1x15 sensor object TIADS1x15 ads1x15(ADSPower, ADSChannel, dividerGain, evADSi2c_addr, VoltReadsToAvg); From 971078b9a5d2357503340cdbe0c992ecdcc7d696 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Mon, 27 Oct 2025 12:07:50 -0400 Subject: [PATCH 129/533] Add delay to waits Signed-off-by: Sara Damiano --- examples/data_saving/data_saving.ino | 2 +- examples/logging_to_MMW/logging_to_MMW.ino | 2 +- examples/menu_a_la_carte/menu_a_la_carte.ino | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/data_saving/data_saving.ino b/examples/data_saving/data_saving.ino index 94eec7aac..bb88b17a6 100644 --- a/examples/data_saving/data_saving.ino +++ b/examples/data_saving/data_saving.ino @@ -394,7 +394,7 @@ void setup() { // NOTE: Only use this when debugging - if not connected to a PC, this adds an // unnecessary startup delay #if defined(SERIAL_PORT_USBVIRTUAL) - while (!SERIAL_PORT_USBVIRTUAL && (millis() < 10000L)) {} + while (!SERIAL_PORT_USBVIRTUAL && (millis() < 10000L)) { delay(10); } #endif // Start the primary serial connection diff --git a/examples/logging_to_MMW/logging_to_MMW.ino b/examples/logging_to_MMW/logging_to_MMW.ino index ea41053c4..b0e2a3c8e 100644 --- a/examples/logging_to_MMW/logging_to_MMW.ino +++ b/examples/logging_to_MMW/logging_to_MMW.ino @@ -257,7 +257,7 @@ void setup() { // NOTE: Only use this when debugging - if not connected to a PC, this adds an // unnecessary startup delay #if defined(SERIAL_PORT_USBVIRTUAL) - while (!SERIAL_PORT_USBVIRTUAL && (millis() < 10000L)) {} + while (!SERIAL_PORT_USBVIRTUAL && (millis() < 10000L)) { delay(10); } #endif // Print a start-up note to the first serial port diff --git a/examples/menu_a_la_carte/menu_a_la_carte.ino b/examples/menu_a_la_carte/menu_a_la_carte.ino index 47e2e79d4..eab056a0f 100644 --- a/examples/menu_a_la_carte/menu_a_la_carte.ino +++ b/examples/menu_a_la_carte/menu_a_la_carte.ino @@ -3623,7 +3623,7 @@ void setup() { // NOTE: Only use this when debugging - if not connected to a PC, this adds an // unnecessary startup delay #if defined(SERIAL_PORT_USBVIRTUAL) - while (!SERIAL_PORT_USBVIRTUAL && (millis() < 10000L)) {} + while (!SERIAL_PORT_USBVIRTUAL && (millis() < 10000L)) { delay(10); } greenRedFlash(3, 10); #endif /** End [setup_wait] */ From 2abf25bb412bb09091468046784794c5dd5d2d10 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Mon, 27 Oct 2025 12:18:41 -0400 Subject: [PATCH 130/533] Update some docs Signed-off-by: Sara Damiano --- ChangeLog.md | 3 +++ examples/menu_a_la_carte/ReadMe.md | 2 +- src/SensorBase.h | 8 ++++---- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/ChangeLog.md b/ChangeLog.md index 0115c8eb9..1cda67754 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -29,6 +29,9 @@ This was probably a hold-over from incorrect implementation and calling of the c Also added optional arguments to the `completeUpdate()` function to allow users to specify if the sensors should be powered/woken. - The `updateAllSensors()` function is now deprecated. Use `completeUpdate(false, false, false, false)` instead. + - Previously the `updateAllSensors()` function asked all sensors to update their values, skipping all power, wake, and sleep steps while the `completeUpdate()` function duplicated that functionality and added the power, wake, and sleep. +The two functions have been consolidated into one function with four arguments, one each for power on, wake, sleep, and power off. +To achieve the same functionality as the old `updateAllSensors()` function (ie, only updating values), set all of the arguments to false. - Applied many suggestions from Code Rabbit AI. ### Added diff --git a/examples/menu_a_la_carte/ReadMe.md b/examples/menu_a_la_carte/ReadMe.md index b091de98a..d2073b5b8 100644 --- a/examples/menu_a_la_carte/ReadMe.md +++ b/examples/menu_a_la_carte/ReadMe.md @@ -836,7 +836,7 @@ ___ ### External Voltage via Processor ADC The Arduino pin controlling power on/off, the analog data pin on the processor, and the multiplier for a voltage divider are required for the sensor constructor. -If your processor operating voltage is not correctly in KnownProcessors.h, you must input it as the fourth argument; otherwise you can enter `OPERATING_VOLTAGE` for the voltage defined in KnownProcessors.h. +If your processor operating voltage is not defined in KnownProcessors.h, you must input it as the fourth argument; otherwise you can enter the value `OPERATING_VOLTAGE` to use the voltage defined in KnownProcessors.h. The number of measurements to average, if more than one is desired, goes as the fifth argument. @see @ref sensor_processor_analog diff --git a/src/SensorBase.h b/src/SensorBase.h index 1810b83f3..922015631 100644 --- a/src/SensorBase.h +++ b/src/SensorBase.h @@ -302,8 +302,8 @@ class Sensor { * ready for sensor communication. * * Bit 3 - * - 0 => Activation/wake attempt made - * - 1 => No activation/wake attempt made + * - 0 => No Activation/wake attempt made + * - 1 => Activation/wake attempt made * - check _millisSensorActivated or bit 4 to see if wake() attempt was * successful * - a failed activation attempt will give _millisSensorActivated = 0 @@ -315,8 +315,8 @@ class Sensor { * a measurement. * * Bit 5 - * - 0 => Start measurement requested attempt made - * - 1 => No measurements have been requested + * - 0 => No measurements have been requested + * - 1 => Start measurement requested attempt made * - check _millisMeasurementRequested or bit 6 to see if * startSingleMeasurement() attempt was successful * - a failed request attempt will give _millisMeasurementRequested = 0 From 0c9d1591a842f21e0b0b5f2417c491f5ae0881ae Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Mon, 27 Oct 2025 12:18:55 -0400 Subject: [PATCH 131/533] Print more debugging Signed-off-by: Sara Damiano --- src/sensors/MaximDS18.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/sensors/MaximDS18.cpp b/src/sensors/MaximDS18.cpp index e33fcfeba..9a38e4bfd 100644 --- a/src/sensors/MaximDS18.cpp +++ b/src/sensors/MaximDS18.cpp @@ -199,8 +199,10 @@ bool MaximDS18::addSingleMeasurementResult(void) { // Put value into the array verifyAndAddMeasurementResult(DS18_TEMP_VAR_NUM, result); success = true; + } else { + MS_DBG(F(" Invalid measurement received from"), + getSensorNameAndLocation()); } - MS_DBG(F(" Temperature:"), result, F("°C")); // Return success value when finished return bumpMeasurementAttemptCount(success); From c9bf6c85319db70ae72da4af6a1cb965d807eea6 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Tue, 3 Feb 2026 15:47:17 -0500 Subject: [PATCH 132/533] Bump some dependencies Signed-off-by: Sara Damiano --- continuous_integration/dependencies.json | 10 +++++----- library.json | 8 ++++---- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/continuous_integration/dependencies.json b/continuous_integration/dependencies.json index 837f5befc..15976c555 100644 --- a/continuous_integration/dependencies.json +++ b/continuous_integration/dependencies.json @@ -1,5 +1,5 @@ { - "action_cache_version": 41, + "action_cache_version": 42, "dependencies": [ { "name": "EnviroDIY_DS3231", @@ -116,7 +116,7 @@ "name": "Adafruit ADS1X15", "owner": "adafruit", "url": "https://github.com/adafruit/Adafruit_ADS1X15", - "version": "~2.6.0", + "version": "~2.6.2", "note": "Driver for TI's ADS1X15: 12 and 16-bit Differential or Single-Ended ADC with PGA and Comparator.", "authors": [ "Adafruit" @@ -234,7 +234,7 @@ "owner": "milesburton", "library id": "54", "url": "https://github.com/milesburton/Arduino-Temperature-Control-Library", - "version": "~4.0.5", + "version": "~4.0.6", "note": "DallasTemperature - Arduino Library for Dallas Temperature ICs (DS18B20, DS18S20, DS1822, DS1820)", "authors": [ "Guil Barros", @@ -350,7 +350,7 @@ "name": "fast_math", "owner": "robtillaart", "url": "https://github.com/RobTillaart/fast_math", - "version": "~0.2.4", + "version": "~0.2.5", "note": "Arduino library for fast math algorithms.", "authors": [ "Rob Tillaart" @@ -362,7 +362,7 @@ "name": "ANBSensorsModbus", "owner": "envirodiy", "url": "https://github.com/EnviroDIY/ANBSensorsModbus", - "version": "~0.2.6", + "version": "~0.4.1", "note": "A library for communicating with pH sensors manufactured by ANB Sensors using Modbus.", "authors": [ "Sara Damiano" diff --git a/library.json b/library.json index 5622757a3..cb0d41a87 100644 --- a/library.json +++ b/library.json @@ -154,7 +154,7 @@ "name": "Adafruit ADS1X15", "owner": "adafruit", "url": "https://github.com/adafruit/Adafruit_ADS1X15", - "version": "~2.6.0", + "version": "~2.6.2", "note": "Driver for TI's ADS1X15: 12 and 16-bit Differential or Single-Ended ADC with PGA and Comparator.", "authors": ["Adafruit"], "frameworks": "arduino" @@ -256,7 +256,7 @@ "owner": "milesburton", "library id": "54", "url": "https://github.com/milesburton/Arduino-Temperature-Control-Library", - "version": "~4.0.5", + "version": "~4.0.6", "note": "DallasTemperature - Arduino Library for Dallas Temperature ICs (DS18B20, DS18S20, DS1822, DS1820)", "authors": ["Guil Barros", "Miles Burton", "Rob Tillart", "Tim Nuewsome"], "frameworks": "arduino" @@ -345,7 +345,7 @@ "name": "fast_math", "owner": "robtillaart", "url": "https://github.com/RobTillaart/fast_math", - "version": "~0.2.4", + "version": "~0.2.5", "note": "Arduino library for fast math algorithms.", "authors": ["Rob Tillaart"], "frameworks": "*", @@ -355,7 +355,7 @@ "name": "ANBSensorsModbus", "owner": "envirodiy", "url": "https://github.com/EnviroDIY/ANBSensorsModbus", - "version": "~0.2.6", + "version": "~0.4.1", "note": "A library for communicating with pH sensors manufactured by ANB Sensors using Modbus.", "authors": ["Sara Damiano"], "frameworks": "arduino" From 320cd76804f5e045c5e21241239f30ecb1692ee6 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Wed, 4 Feb 2026 11:27:26 -0500 Subject: [PATCH 133/533] Bump dependencies again Signed-off-by: Sara Damiano --- continuous_integration/dependencies.json | 4 ++-- examples/example_dependencies.json | 2 +- library.json | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/continuous_integration/dependencies.json b/continuous_integration/dependencies.json index 15976c555..9e8c4c2c2 100644 --- a/continuous_integration/dependencies.json +++ b/continuous_integration/dependencies.json @@ -1,5 +1,5 @@ { - "action_cache_version": 42, + "action_cache_version": 43, "dependencies": [ { "name": "EnviroDIY_DS3231", @@ -293,7 +293,7 @@ "owner": "envirodiy", "library id": "1824", "url": "https://github.com/EnviroDIY/SensorModbusMaster", - "version": "~1.6.6", + "version": "~1.7.0", "note": "EnviroDIY SensorModbusMaster - Arduino library for communicating via modbus with the Arduino acting as the modbus master.", "authors": [ "Sara Damiano" diff --git a/examples/example_dependencies.json b/examples/example_dependencies.json index 845e95456..68194758b 100644 --- a/examples/example_dependencies.json +++ b/examples/example_dependencies.json @@ -26,7 +26,7 @@ "name": "Adafruit NeoPixel", "owner": "adafruit", "url": "https://github.com/adafruit/Adafruit_NeoPixel", - "version": "~1.15.2", + "version": "~1.15.3", "note": "Adafruit NeoPixel, for boards with a built in NeoPixel", "authors": ["Adafruit"], "frameworks": "arduino" diff --git a/library.json b/library.json index cb0d41a87..e1c9c1549 100644 --- a/library.json +++ b/library.json @@ -299,7 +299,7 @@ "owner": "envirodiy", "library id": "1824", "url": "https://github.com/EnviroDIY/SensorModbusMaster", - "version": "~1.6.6", + "version": "~1.7.0", "note": "EnviroDIY SensorModbusMaster - Arduino library for communicating via modbus with the Arduino acting as the modbus master.", "authors": ["Sara Damiano"], "frameworks": "arduino" From 3f576e8a0a1eef1d89e6afc848fb4162c012092e Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Wed, 4 Feb 2026 15:33:10 -0500 Subject: [PATCH 134/533] Bump dependencies again Signed-off-by: Sara Damiano --- continuous_integration/dependencies.json | 8 ++++---- library.json | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/continuous_integration/dependencies.json b/continuous_integration/dependencies.json index 9e8c4c2c2..83a7b33b5 100644 --- a/continuous_integration/dependencies.json +++ b/continuous_integration/dependencies.json @@ -1,5 +1,5 @@ { - "action_cache_version": 43, + "action_cache_version": 44, "dependencies": [ { "name": "EnviroDIY_DS3231", @@ -305,7 +305,7 @@ "owner": "envirodiy", "library id": "5439", "url": "https://github.com/EnviroDIY/KellerModbus", - "version": "~0.2.6", + "version": "~0.2.7", "note": "Arduino library for communication with Keller pressure and water level sensors via Modbus.", "authors": [ "Anthony Aufdenkampe" @@ -316,7 +316,7 @@ "owner": "envirodiy", "library id": "2078", "url": "https://github.com/EnviroDIY/YosemitechModbus", - "version": "~0.5.3", + "version": "~0.5.4", "note": "Arduino library for communication with Yosemitech sensors via Modbus.", "authors": [ "Sara Damiano", @@ -328,7 +328,7 @@ "name": "GroPointModbus", "owner": "envirodiy", "url": "https://github.com/EnviroDIY/GroPointModbus", - "version": "~0.1.4", + "version": "~0.1.5", "note": "A library to use an Arduino as a master to control and communicate via modbus with GroPoint soil moisture sensors.", "authors": [ "Anthony Aufdenkampe" diff --git a/library.json b/library.json index e1c9c1549..d664fa95a 100644 --- a/library.json +++ b/library.json @@ -309,7 +309,7 @@ "owner": "envirodiy", "library id": "5439", "url": "https://github.com/EnviroDIY/KellerModbus", - "version": "~0.2.6", + "version": "~0.2.7", "note": "Arduino library for communication with Keller pressure and water level sensors via Modbus.", "authors": ["Anthony Aufdenkampe"] }, @@ -318,7 +318,7 @@ "owner": "envirodiy", "library id": "2078", "url": "https://github.com/EnviroDIY/YosemitechModbus", - "version": "~0.5.3", + "version": "~0.5.4", "note": "Arduino library for communication with Yosemitech sensors via Modbus.", "authors": ["Sara Damiano", "Anthony Aufdenkampe"], "frameworks": "arduino" @@ -327,7 +327,7 @@ "name": "GroPointModbus", "owner": "envirodiy", "url": "https://github.com/EnviroDIY/GroPointModbus", - "version": "~0.1.4", + "version": "~0.1.5", "note": "A library to use an Arduino as a master to control and communicate via modbus with GroPoint soil moisture sensors.", "authors": ["Anthony Aufdenkampe"], "frameworks": "arduino" From d96711d5d5c535cdbddc974288b5e7140edecbc1 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Thu, 12 Feb 2026 14:34:17 -0500 Subject: [PATCH 135/533] Removed text referring to the EnviroDIY Data Sharing Portal Signed-off-by: Sara Damiano --- README.md | 2 +- examples/AWS_IoT_Core/AWS_IoT_Core.ino | 4 ++-- .../EnviroDIY_Monitoring_Kit.ino | 4 ++-- .../DRWI_CitizenScience/DRWI_2G/DRWI_2G.ino | 4 ++-- .../DRWI_DigiLTE/DRWI_DigiLTE.ino | 4 ++-- .../DRWI_Mayfly1/DRWI_Mayfly1.ino | 4 ++-- .../DRWI_Mayfly1_WiFi/DRWI_Mayfly1_WiFi.ino | 6 +++--- .../DRWI_NoCellular/ReadMe.md | 2 +- .../DRWI_SIM7080LTE/DRWI_SIM7080LTE.ino | 4 ++-- .../baro_rho_correction.ino | 8 ++++---- examples/data_saving/data_saving.ino | 8 ++++---- examples/logging_to_MMW/logging_to_MMW.ino | 8 ++++---- examples/menu_a_la_carte/ReadMe.md | 6 +++--- examples/menu_a_la_carte/menu_a_la_carte.ino | 20 ++++++++++--------- 14 files changed, 43 insertions(+), 41 deletions(-) diff --git a/README.md b/README.md index 110051def..2b083368f 100644 --- a/README.md +++ b/README.md @@ -106,7 +106,7 @@ For some generalized information about attaching sensors to an Arduino style boa ## Data Endpoints Within ModularSensors, the "dataPublisher" objects add the functionality to send data to remote web services. -The currently supported services are the [Monitor My Watershed data portal](http://data.envirodiy.org/), [ThingSpeak](https://thingspeak.com/), the [Ubidots IoT platform](https://ubidots.com), [Amazon Web Services IoT Core](https://aws.amazon.com/iot-core/), and [Amazon Web Services Simple Storage Service (S3)](https://aws.amazon.com/s3/). +The currently supported services are the [Monitor My Watershed data portal](https://monitormywatershed.org/), [ThingSpeak](https://thingspeak.com/), the [Ubidots IoT platform](https://ubidots.com), [Amazon Web Services IoT Core](https://aws.amazon.com/iot-core/), and [Amazon Web Services Simple Storage Service (S3)](https://aws.amazon.com/s3/). - [Monitor My Watershed/EnviroDIY Data Portal](https://envirodiy.github.io/ModularSensors/class_enviro_d_i_y_publisher.html) - [ThingSpeak](https://envirodiy.github.io/ModularSensors/class_thing_speak_publisher.html) diff --git a/examples/AWS_IoT_Core/AWS_IoT_Core.ino b/examples/AWS_IoT_Core/AWS_IoT_Core.ino index 265cbc10f..f9a4fcc0b 100644 --- a/examples/AWS_IoT_Core/AWS_IoT_Core.ino +++ b/examples/AWS_IoT_Core/AWS_IoT_Core.ino @@ -132,7 +132,7 @@ EspressifESP32 modem = modemESP; // ========================================================================== // Using the Processor as a Sensor // ========================================================================== -/** Start [processor_stats] */ +/** Start [processor_sensor] */ #include // Create the main processor chip "sensor" - for general metadata @@ -144,7 +144,7 @@ const char* mcuBoardVersion = "v1.1"; const char* mcuBoardVersion = "unknown"; #endif ProcessorStats mcuBoard(mcuBoardVersion, 5); -/** End [processor_stats] */ +/** End [processor_sensor] */ // ========================================================================== diff --git a/examples/EnviroDIY_Monitoring_Kit/EnviroDIY_Monitoring_Kit.ino b/examples/EnviroDIY_Monitoring_Kit/EnviroDIY_Monitoring_Kit.ino index be408b56a..90e243bf3 100644 --- a/examples/EnviroDIY_Monitoring_Kit/EnviroDIY_Monitoring_Kit.ino +++ b/examples/EnviroDIY_Monitoring_Kit/EnviroDIY_Monitoring_Kit.ino @@ -343,9 +343,9 @@ VariableArray varArray(variableCount, variableList, UUIDs); // A Publisher to Monitor My Watershed // ========================================================================== /** Start [monitor_my_watershed_publisher] */ -// Create a data publisher for the Monitor My Watershed/EnviroDIY POST endpoint +// Create a data publisher for the Monitor My Watershed POST endpoint #include -EnviroDIYPublisher EnviroDIYPost(dataLogger, registrationToken); +EnviroDIYPublisher MonitorMWPost(dataLogger, registrationToken); /** End [monitor_my_watershed_publisher] */ #endif diff --git a/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_2G/DRWI_2G.ino b/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_2G/DRWI_2G.ino index 1371dd8eb..22a27ac7d 100644 --- a/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_2G/DRWI_2G.ino +++ b/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_2G/DRWI_2G.ino @@ -226,9 +226,9 @@ Logger dataLogger(LoggerID, loggingInterval, &varArray); // Creating Data Publisher[s] // ========================================================================== /** Start [publishers] */ -// Create a data publisher for the Monitor My Watershed/EnviroDIY POST endpoint +// Create a data publisher for the Monitor My Watershed POST endpoint #include -EnviroDIYPublisher EnviroDIYPost(dataLogger, registrationToken, +EnviroDIYPublisher MonitorMWPost(dataLogger, registrationToken, samplingFeature); /** End [publishers] */ diff --git a/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_DigiLTE/DRWI_DigiLTE.ino b/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_DigiLTE/DRWI_DigiLTE.ino index eb0826a08..ca7d10acc 100644 --- a/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_DigiLTE/DRWI_DigiLTE.ino +++ b/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_DigiLTE/DRWI_DigiLTE.ino @@ -246,9 +246,9 @@ Logger dataLogger(LoggerID, loggingInterval, &varArray); // Creating Data Publisher[s] // ========================================================================== /** Start [publishers] */ -// Create a data publisher for the Monitor My Watershed/EnviroDIY POST endpoint +// Create a data publisher for the Monitor My Watershed POST endpoint #include -EnviroDIYPublisher EnviroDIYPost(dataLogger, registrationToken, +EnviroDIYPublisher MonitorMWPost(dataLogger, registrationToken, samplingFeature); /** End [publishers] */ diff --git a/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_Mayfly1/DRWI_Mayfly1.ino b/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_Mayfly1/DRWI_Mayfly1.ino index dad595122..5cec2378d 100644 --- a/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_Mayfly1/DRWI_Mayfly1.ino +++ b/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_Mayfly1/DRWI_Mayfly1.ino @@ -252,9 +252,9 @@ Logger dataLogger(LoggerID, loggingInterval, &varArray); // Creating Data Publisher[s] // ========================================================================== /** Start [publishers] */ -// Create a data publisher for the Monitor My Watershed/EnviroDIY POST endpoint +// Create a data publisher for the Monitor My Watershed POST endpoint #include -EnviroDIYPublisher EnviroDIYPost(dataLogger, registrationToken, +EnviroDIYPublisher MonitorMWPost(dataLogger, registrationToken, samplingFeature); /** End [publishers] */ diff --git a/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_Mayfly1_WiFi/DRWI_Mayfly1_WiFi.ino b/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_Mayfly1_WiFi/DRWI_Mayfly1_WiFi.ino index f269711ce..3a125062e 100644 --- a/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_Mayfly1_WiFi/DRWI_Mayfly1_WiFi.ino +++ b/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_Mayfly1_WiFi/DRWI_Mayfly1_WiFi.ino @@ -227,9 +227,9 @@ Logger dataLogger(LoggerID, loggingInterval, &varArray); // Creating Data Publisher[s] // ========================================================================== /** Start [publishers] */ -// Create a data publisher for the Monitor My Watershed/EnviroDIY POST endpoint +// Create a data publisher for the Monitor My Watershed POST endpoint #include -EnviroDIYPublisher EnviroDIYPost(dataLogger, registrationToken, +EnviroDIYPublisher MonitorMWPost(dataLogger, registrationToken, samplingFeature); /** End [publishers] */ @@ -308,7 +308,7 @@ void setup() { // Begin the logger dataLogger.begin(); - EnviroDIYPost.begin(dataLogger, registrationToken, samplingFeature); + MonitorMWPost.begin(dataLogger, registrationToken, samplingFeature); // Note: Please change these battery voltages to match your battery // Set up the sensors, except at lowest battery level diff --git a/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_NoCellular/ReadMe.md b/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_NoCellular/ReadMe.md index 04845e7da..2e3942fd1 100644 --- a/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_NoCellular/ReadMe.md +++ b/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_NoCellular/ReadMe.md @@ -9,7 +9,7 @@ The exact hardware configuration used in this example: - Hydros21 CTD sensor - Campbell OBS3+ turbidity sensor -Before using this example, you must register a site and sensors at the data portal (). +Before using this example, you must register a site and sensors on [Monitor My Watershed](https://monitormywatershed.org). After you have registered the site and sensors, the portal will generate a registration token and universally unique identifier (UUID) for each site and further UUID's for each variable. You will need to copy all of those UUID values into your sketch to replace the `12345678-abcd-1234-ef00-1234567890ab` place holders in this example. __You should register even if your logger will not be sending live data.__ This ensures that the data file your logger writes will be ready to immediately upload to the portal. diff --git a/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_SIM7080LTE/DRWI_SIM7080LTE.ino b/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_SIM7080LTE/DRWI_SIM7080LTE.ino index ac8ca717b..496a5e2ab 100644 --- a/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_SIM7080LTE/DRWI_SIM7080LTE.ino +++ b/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_SIM7080LTE/DRWI_SIM7080LTE.ino @@ -253,9 +253,9 @@ Logger dataLogger(LoggerID, loggingInterval, &varArray); // Creating Data Publisher[s] // ========================================================================== /** Start [publishers] */ -// Create a data publisher for the Monitor My Watershed/EnviroDIY POST endpoint +// Create a data publisher for the Monitor My Watershed POST endpoint #include -EnviroDIYPublisher EnviroDIYPost(dataLogger, registrationToken, +EnviroDIYPublisher MonitorMWPost(dataLogger, registrationToken, samplingFeature); /** End [publishers] */ diff --git a/examples/baro_rho_correction/baro_rho_correction.ino b/examples/baro_rho_correction/baro_rho_correction.ino index 35fc65681..2ef8ca2f0 100644 --- a/examples/baro_rho_correction/baro_rho_correction.ino +++ b/examples/baro_rho_correction/baro_rho_correction.ino @@ -352,17 +352,17 @@ Logger dataLogger(LoggerID, loggingInterval, &varArray); // Creating Data Publisher[s] // ========================================================================== /** Start [publishers] */ -// A Publisher to Monitor My Watershed / EnviroDIY Data Sharing Portal +// A Publisher to Monitor My Watershed // Device registration and sampling feature information can be obtained after -// registration at https://monitormywatershed.org or https://data.envirodiy.org +// registration at https://monitormywatershed.org const char* registrationToken = "12345678-abcd-1234-ef00-1234567890ab"; // Device registration token const char* samplingFeature = "12345678-abcd-1234-ef00-1234567890ab"; // Sampling feature UUID -// Create a data publisher for the Monitor My Watershed/EnviroDIY POST endpoint +// Create a data publisher for the Monitor My Watershed POST endpoint #include -EnviroDIYPublisher EnviroDIYPost(dataLogger, registrationToken, +EnviroDIYPublisher MonitorMWPost(dataLogger, registrationToken, samplingFeature); /** End [publishers] */ diff --git a/examples/data_saving/data_saving.ino b/examples/data_saving/data_saving.ino index bb88b17a6..54ce5b75b 100644 --- a/examples/data_saving/data_saving.ino +++ b/examples/data_saving/data_saving.ino @@ -343,18 +343,18 @@ Logger loggerToGo(LoggerID, loggingInterval, &arrayToGo); // Creating Data Publisher[s] // ========================================================================== /** Start [publishers] */ -// Create a publisher to Monitor My Watershed / EnviroDIY Data Sharing Portal +// Create a publisher to Monitor My Watershed // Device registration and sampling feature information can be obtained after -// registration at https://monitormywatershed.org or https://data.envirodiy.org +// registration at https://monitormywatershed.org const char* registrationToken = "12345678-abcd-1234-ef00-1234567890ab"; // Device registration token const char* samplingFeature = "12345678-abcd-1234-ef00-1234567890ab"; // Sampling feature UUID -// Create a data publisher for the Monitor My Watershed/EnviroDIY POST endpoint +// Create a data publisher for the Monitor My Watershed POST endpoint // This is only attached to the logger with the shorter variable array #include -EnviroDIYPublisher EnviroDIYPost(loggerToGo, registrationToken, +EnviroDIYPublisher MonitorMWPost(loggerToGo, registrationToken, samplingFeature); /** End [publishers] */ diff --git a/examples/logging_to_MMW/logging_to_MMW.ino b/examples/logging_to_MMW/logging_to_MMW.ino index b0e2a3c8e..0315d7d9f 100644 --- a/examples/logging_to_MMW/logging_to_MMW.ino +++ b/examples/logging_to_MMW/logging_to_MMW.ino @@ -204,17 +204,17 @@ Logger dataLogger(LoggerID, loggingInterval, &varArray); // Creating Data Publisher[s] // ========================================================================== /** Start [publishers] */ -// A Publisher to Monitor My Watershed / EnviroDIY Data Sharing Portal +// A Publisher to Monitor My Watershed // Device registration and sampling feature information can be obtained after -// registration at https://monitormywatershed.org or https://data.envirodiy.org +// registration at https://monitormywatershed.org const char* registrationToken = "12345678-abcd-1234-ef00-1234567890ab"; // Device registration token const char* samplingFeature = "12345678-abcd-1234-ef00-1234567890ab"; // Sampling feature UUID -// Create a data publisher for the Monitor My Watershed/EnviroDIY POST endpoint +// Create a data publisher for the Monitor My Watershed POST endpoint #include -EnviroDIYPublisher EnviroDIYPost(dataLogger, registrationToken, +EnviroDIYPublisher MonitorMWPost(dataLogger, registrationToken, samplingFeature); /** End [publishers] */ diff --git a/examples/menu_a_la_carte/ReadMe.md b/examples/menu_a_la_carte/ReadMe.md index d2073b5b8..191ce26a4 100644 --- a/examples/menu_a_la_carte/ReadMe.md +++ b/examples/menu_a_la_carte/ReadMe.md @@ -1315,13 +1315,13 @@ ___ Here we set up all three possible data publishers and link all of them to the same Logger object. -#### Monitor My Watershed +#### Monitor My Watershed -To publish data to the Monitor My Watershed / EnviroDIY Data Sharing Portal first you must register yourself as a user at or . +To publish data to the Monitor My Watershed first you must register yourself as a user at . Then you must register your site. After registering your site, a sampling feature and registration token for that site should be visible on the site page. - + ___ diff --git a/examples/menu_a_la_carte/menu_a_la_carte.ino b/examples/menu_a_la_carte/menu_a_la_carte.ino index eab056a0f..90ead9f0c 100644 --- a/examples/menu_a_la_carte/menu_a_la_carte.ino +++ b/examples/menu_a_la_carte/menu_a_la_carte.ino @@ -960,7 +960,7 @@ Variable* modemTemperature = // ========================================================================== // Using the Processor as a Sensor // ========================================================================== -/** Start [processor_stats] */ +/** Start [processor_sensor] */ #include // Create the main processor chip "sensor" - for general metadata @@ -983,12 +983,13 @@ Variable* mcuBoardSampNo = new ProcessorStats_SampleNumber( &mcuBoard, "12345678-abcd-1234-ef00-1234567890ab"); Variable* mcuBoardReset = new ProcessorStats_ResetCode( &mcuBoard, "12345678-abcd-1234-ef00-1234567890ab"); -/** End [processor_stats] */ +/** End [processor_sensor] */ #if defined(MS_USE_DS3231) // ========================================================================== // Maxim DS3231 RTC (Real Time Clock) +// Built in on Mayfly 0.x and 1.x // ========================================================================== /** Start [maxim_ds3231] */ #include @@ -3343,14 +3344,14 @@ VariableArray varArray(variableCount, variableList); #endif -#if defined(BUILD_PUB_ENVIRO_DIY_PUBLISHER) && \ +#if defined(BUILD_PUB_MONITOR_MW_PUBLISHER) && \ (!defined(BUILD_MODEM_NO_MODEM) && defined(BUILD_HAS_MODEM)) // ========================================================================== -// A Publisher to Monitor My Watershed / EnviroDIY Data Sharing Portal +// A Publisher to Monitor My Watershed // ========================================================================== -/** Start [enviro_diy_publisher] */ +/** Start [monitor_my_watershed_publisher] */ // Device registration and sampling feature information can be obtained after -// registration at https://monitormywatershed.org or https://data.envirodiy.org +// registration at https://monitormywatershed.org const char* registrationToken = "12345678-abcd-1234-ef00-1234567890ab"; // Device registration token // NOTE: Because we already set the sampling feature with the logger @@ -3358,10 +3359,10 @@ const char* registrationToken = // const char* samplingFeature = "12345678-abcd-1234-ef00-1234567890ab"; // // Sampling feature UUID -// Create a data publisher for the Monitor My Watershed/EnviroDIY POST endpoint +// Create a data publisher for the Monitor My Watershed POST endpoint #include -EnviroDIYPublisher EnviroDIYPost(dataLogger, registrationToken); -/** End [enviro_diy_publisher] */ +EnviroDIYPublisher MonitorMWPost(dataLogger, registrationToken); +/** End [monitor_my_watershed_publisher] */ #endif @@ -3979,6 +3980,7 @@ void loop() { mcuBoard.sensorValues[PROCESSOR_BATTERY_VAR_NUM], F("V) going back to sleep.")); dataLogger.systemSleep(); +#if !defined(BUILD_MODEM_NO_MODEM) && defined(BUILD_HAS_MODEM) } else if (getBatteryVoltage() < 3.55) { // At moderate voltage, log data but don't send it over the modem PRINTOUT(F("Battery at"), From 7daac8dc9c2fcfc52fb46e488a362a4b0fd9c5fc Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Thu, 12 Feb 2026 14:39:04 -0500 Subject: [PATCH 136/533] Fix monitoring kit example Signed-off-by: Sara Damiano --- .../EnviroDIY_Monitoring_Kit/EnviroDIY_Monitoring_Kit.ino | 8 ++++---- examples/EnviroDIY_Monitoring_Kit/ReadMe.md | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/examples/EnviroDIY_Monitoring_Kit/EnviroDIY_Monitoring_Kit.ino b/examples/EnviroDIY_Monitoring_Kit/EnviroDIY_Monitoring_Kit.ino index 90e243bf3..e27c6d5f3 100644 --- a/examples/EnviroDIY_Monitoring_Kit/EnviroDIY_Monitoring_Kit.ino +++ b/examples/EnviroDIY_Monitoring_Kit/EnviroDIY_Monitoring_Kit.ino @@ -15,6 +15,9 @@ * @m_examplenavigation{example_envirodiy_monitoring_kit,} * ======================================================================= */ +// The Arduino library is needed for every Arduino program. +#include + // ========================================================================== // Configuration for the EnviroDIY Monitoring Station Kit // ========================================================================== @@ -127,9 +130,6 @@ const char* samplingFeature = "12345678-abcd-1234-ef00-1234567890ab"; // Sampli // Include the libraries required for any data logger // ========================================================================== /** Start [includes] */ -// The Arduino library is needed for every Arduino program. -#include - // Include the main header for ModularSensors #include /** End [includes] */ @@ -442,7 +442,7 @@ void setup() { PRINTOUT(F("Setting logging interval to"), loggingInterval, F("minutes")); dataLogger.setLoggingInterval(loggingInterval); PRINTOUT(F("Setting number of initial 1 minute intervals to 10")); - dataLogger.setinitialShortIntervals(10); + dataLogger.setInitialShortIntervals(10); // Attach the variable array to the logger PRINTOUT(F("Attaching the variable array")); dataLogger.setVariableArray(&varArray); diff --git a/examples/EnviroDIY_Monitoring_Kit/ReadMe.md b/examples/EnviroDIY_Monitoring_Kit/ReadMe.md index 9158c2371..42b820081 100644 --- a/examples/EnviroDIY_Monitoring_Kit/ReadMe.md +++ b/examples/EnviroDIY_Monitoring_Kit/ReadMe.md @@ -73,7 +73,7 @@ Customize the sketch for the version of the kit that you have: cellular, wifi, o #### Select the Connection Type -In lines 28 and 29, select no more than one of the "bee" types that you will be using. +In lines 31 and 32, select no more than one of the "bee" types that you will be using. - Activate the modem you wish to use by _removing_ any slashes (```//```) before the bee module you will use. - The line should start with ```#define``` @@ -111,7 +111,7 @@ You can leave the configuration for the connection type you're not using as is. ### Set Data Logging Options -Customize your data logging options in lines 42 to 53 of the example. +Customize your data logging options in lines 45-56 of the example. #### Set the logger ID @@ -148,7 +148,7 @@ const int8_t timeZone = -5; // Eastern Standard Time - Go back to the web page for your site on [Monitor My Watershed](http://monitormywatershed.org/) - Find and click the white "View Token UUID List" button above the small map on your site page. -- Paste the copied UUIDs into your sketch, _replacing_ lines 91-106. +- Paste the copied UUIDs into your sketch, _replacing_ lines 93-108. ```cpp // --------------------- Beginning of Token UUID List --------------------- From ee65870cf8d96b3f36008760401d1bb57fa01a9d Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Thu, 12 Feb 2026 16:32:45 -0500 Subject: [PATCH 137/533] walk path for subfolders in examples Signed-off-by: Sara Damiano --- continuous_integration/generate_job_matrix.py | 23 +++++++++++++------ 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/continuous_integration/generate_job_matrix.py b/continuous_integration/generate_job_matrix.py index 05b2a5b97..a3b8de97a 100644 --- a/continuous_integration/generate_job_matrix.py +++ b/continuous_integration/generate_job_matrix.py @@ -29,6 +29,7 @@ workspace_path = os.path.abspath(os.path.realpath(workspace_dir)) print(f"Workspace Path: {workspace_path}") + # %% # The examples directory examples_dir = "./examples/" @@ -101,12 +102,20 @@ pio_to_acli = json.load(f) # Find all of the non-menu examples -non_menu_examples = [ - f - for f in os.listdir(examples_path) - if os.path.isdir(os.path.join(examples_path, f)) - and f not in [".history", "logger_test", "archive", "tests", menu_example_name] -] +examples_to_build = [] +for root, subdirs, files in os.walk(examples_path): + for filename in files: + file_path = os.path.join(root, filename) + if filename == os.path.split(root)[-1] + ".ino" and root not in [ + ".history", + "logger_test", + "archive", + "tests", + menu_example_name, + ]: + examples_to_build.append(os.path.relpath(root, workspace_path)) + if use_verbose: + print(f"::debug::\t- example: {filename} (full path: {file_path})") # %% # read configurations based on existing files and environment variables @@ -427,7 +436,7 @@ def extend_pio_config(added_envs): "NO_SENSORS", ] all_publisher_flags = [ - "BUILD_PUB_ENVIRO_DIY_PUBLISHER", + "BUILD_PUB_MONITOR_MW_PUBLISHER", ] From e4d74fdf359ad3816c7634929b2d035290529126 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Thu, 12 Feb 2026 16:33:52 -0500 Subject: [PATCH 138/533] Rename MonitorMyWatershedPublisher Signed-off-by: Sara Damiano --- .../{EnviroDIYPublisher.cpp => MonitorMyWatershedPublisher.cpp} | 0 .../{EnviroDIYPublisher.h => MonitorMyWatershedPublisher.h} | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename src/publishers/{EnviroDIYPublisher.cpp => MonitorMyWatershedPublisher.cpp} (100%) rename src/publishers/{EnviroDIYPublisher.h => MonitorMyWatershedPublisher.h} (100%) diff --git a/src/publishers/EnviroDIYPublisher.cpp b/src/publishers/MonitorMyWatershedPublisher.cpp similarity index 100% rename from src/publishers/EnviroDIYPublisher.cpp rename to src/publishers/MonitorMyWatershedPublisher.cpp diff --git a/src/publishers/EnviroDIYPublisher.h b/src/publishers/MonitorMyWatershedPublisher.h similarity index 100% rename from src/publishers/EnviroDIYPublisher.h rename to src/publishers/MonitorMyWatershedPublisher.h From fdafb96286836953bf8cf90ba88af481ea6447b2 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Thu, 12 Feb 2026 17:24:25 -0500 Subject: [PATCH 139/533] Rename EnviroDIYPublisher to MonitorMyWatershedPublisher Signed-off-by: Sara Damiano --- ChangeLog.md | 6 +- README.md | 4 +- build-menu-configurations.ps1 | 2 +- docs/Getting-Started/Getting-Started.md | 2 +- .../EnviroDIY_Monitoring_Kit.ino | 4 +- examples/EnviroDIY_Monitoring_Kit/ReadMe.md | 2 +- .../DRWI_CitizenScience/DRWI_2G/DRWI_2G.ino | 4 +- .../DRWI_CitizenScience/DRWI_2G/ReadMe.md | 4 +- .../DRWI_DigiLTE/DRWI_DigiLTE.ino | 6 +- .../DRWI_DigiLTE/ReadMe.md | 4 +- .../DRWI_Mayfly1/DRWI_Mayfly1.ino | 6 +- .../DRWI_Mayfly1/ReadMe.md | 2 +- .../DRWI_Mayfly1_WiFi/DRWI_Mayfly1_WiFi.ino | 6 +- .../DRWI_NoCellular/ReadMe.md | 4 +- .../DRWI_SIM7080LTE/DRWI_SIM7080LTE.ino | 6 +- .../simple_logging_LearnEnviroDIY/ReadMe.md | 2 +- examples/ReadMe.md | 12 +- examples/baro_rho_correction/ReadMe.md | 4 +- .../baro_rho_correction.ino | 6 +- examples/data_saving/ReadMe.md | 6 +- examples/data_saving/data_saving.ino | 9 +- examples/logging_to_MMW/ReadMe.md | 12 +- examples/logging_to_MMW/logging_to_MMW.ino | 6 +- examples/menu_a_la_carte/ReadMe.md | 4 +- examples/menu_a_la_carte/menu_a_la_carte.ino | 4 +- examples/menu_a_la_carte/platformio.ini | 2 +- examples/simple_logging/ReadMe.md | 2 +- library.json | 2 +- library.properties | 2 +- src/LoggerBase.cpp | 4 +- src/LoggerBase.h | 4 +- src/ModSensorDebugConfig.h | 2 +- src/publishers/AWS_IoT_Publisher.h | 12 +- .../MonitorMyWatershedPublisher.cpp | 127 ++++++------- src/publishers/MonitorMyWatershedPublisher.h | 174 +++++++++--------- src/publishers/ThingSpeakPublisher.cpp | 2 +- src/publishers/UbidotsPublisher.cpp | 10 +- src/publishers/UbidotsPublisher.h | 4 +- 38 files changed, 239 insertions(+), 235 deletions(-) diff --git a/ChangeLog.md b/ChangeLog.md index 1fdd29f43..9ea4f009c 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -16,6 +16,9 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm - Previously the 'i' of initial was not capitalized. - Made the enabling and disabling of the watchdog the very first and very last steps of sleep to keep the watchdog enabled through the whole getting ready for bed and waking up process. - **ANB pH** Changed timing slightly and simplified timing logic. +- **Renamed** The EnviroDIYPublisher has been renamed the MonitorMyWatershedPublisher. +This reflects changes to the website from years ago. +There is a shell file and typedef to maintain backwards compatibility. - Bumped several dependencies - including crucial bug fixes to SensorModbusMaster. - Re-wrote most of the logic for looping variables within the complete update function of the VariableArray. - Simplified the `addSingleMeasurementResult()` function of all sensors to use an internal function to help set the bits and timing values and to quit sooner if the measurement was not started successfully. @@ -33,7 +36,6 @@ Use `completeUpdate(false, false, false, false)` instead. The two functions have been consolidated into one function with four arguments, one each for power on, wake, sleep, and power off. To achieve the same functionality as the old `updateAllSensors()` function (ie, only updating values), set all of the arguments to false. - Applied many suggestions from Code Rabbit AI. - - Moved outdated examples to a new "Outdated" folder, with a subfolder for the DRWI examples ### Added @@ -60,12 +62,14 @@ These values should generally be set in the specific sensor constructors and onl - **NEW SENSOR** Added a new sensor for simple analog voltage using the built-in processor ADC - Added KnownProcessors.h and moved defines values for supported built-in sensors on known processors to that file. - This affects ProcessorStats and the Everlight ALS PT-19. +- Added a new example specific to the [EnviroDIY Monitoring Station Kit](https://www.envirodiy.org/product/envirodiy-monitoring-station-kit/). ### Removed - Remove the unused `_maxSamplesToAverage` parameter of the VariableArray and the `countMaxToAverage()` function which set the parameter. - Removed unnecessary copy doc calls for inherited functions and properties. - Removed all overrides of the powerUp and powerDown functions that are no longer needed since all sensors have two power pins built in. +- Removed references to the EnviroDIY data portal. ### Fixed diff --git a/README.md b/README.md index 2b083368f..832b1a797 100644 --- a/README.md +++ b/README.md @@ -106,9 +106,9 @@ For some generalized information about attaching sensors to an Arduino style boa ## Data Endpoints Within ModularSensors, the "dataPublisher" objects add the functionality to send data to remote web services. -The currently supported services are the [Monitor My Watershed data portal](https://monitormywatershed.org/), [ThingSpeak](https://thingspeak.com/), the [Ubidots IoT platform](https://ubidots.com), [Amazon Web Services IoT Core](https://aws.amazon.com/iot-core/), and [Amazon Web Services Simple Storage Service (S3)](https://aws.amazon.com/s3/). +The currently supported services are [Monitor My Watershed](https://monitormywatershed.org/), [ThingSpeak](https://thingspeak.com/), the [Ubidots IoT platform](https://ubidots.com), [Amazon Web Services IoT Core](https://aws.amazon.com/iot-core/), and [Amazon Web Services Simple Storage Service (S3)](https://aws.amazon.com/s3/). -- [Monitor My Watershed/EnviroDIY Data Portal](https://envirodiy.github.io/ModularSensors/class_enviro_d_i_y_publisher.html) +- [Monitor My Watershed](https://envirodiy.github.io/ModularSensors/class_monitor_my_watershed_publisher.html) - [ThingSpeak](https://envirodiy.github.io/ModularSensors/class_thing_speak_publisher.html) - [Ubidots IoT platform](https://envirodiy.github.io/ModularSensors/class_ubidots_publisher.html) - [AWS IoT Core](https://envirodiy.github.io/ModularSensors/class_a_w_s___io_t___publisher.html) diff --git a/build-menu-configurations.ps1 b/build-menu-configurations.ps1 index 523bf4bb0..e606d30a6 100644 --- a/build-menu-configurations.ps1 +++ b/build-menu-configurations.ps1 @@ -145,7 +145,7 @@ Foreach ($sensorFlag in $sensorFlags) } $publisherFlag = @(` - 'BUILD_PUB_ENVIRO_DIY_PUBLISHER', ` + 'BUILD_PUB_MONITOR_MW_PUBLISHER', ` 'BUILD_PUB_DREAM_HOST_PUBLISHER', ` 'BUILD_PUB_THING_SPEAK_PUBLISHER') diff --git a/docs/Getting-Started/Getting-Started.md b/docs/Getting-Started/Getting-Started.md index 2a7db7f80..01224dcae 100644 --- a/docs/Getting-Started/Getting-Started.md +++ b/docs/Getting-Started/Getting-Started.md @@ -146,7 +146,7 @@ This showcases both how to use two different logging instances and how to use so - [data_saving](https://github.com/EnviroDIY/ModularSensors/tree/master/examples/) - This is another double logger example, but in this case, both loggers are going at the same interval and the only difference between the loggers is the list of variables. There are two sets of variables, all coming from Yosemitech sensors. -Because each sensor outputs temperature and we don't want to waste cellular data sending out multiple nearly identical temperature values, we have one logger that logs every possible variable result to the SD card and another logger that sends only unique results to the EnviroDIY data portal. +Because each sensor outputs temperature and we don't want to waste cellular data sending out multiple nearly identical temperature values, we have one logger that logs every possible variable result to the SD card and another logger that sends only unique results to Monitor My Watershed. This example also shows how to stop power draw from an RS485 adapter with automatic flow detection. ## Deploying your Station diff --git a/examples/EnviroDIY_Monitoring_Kit/EnviroDIY_Monitoring_Kit.ino b/examples/EnviroDIY_Monitoring_Kit/EnviroDIY_Monitoring_Kit.ino index e27c6d5f3..ff2b3cb38 100644 --- a/examples/EnviroDIY_Monitoring_Kit/EnviroDIY_Monitoring_Kit.ino +++ b/examples/EnviroDIY_Monitoring_Kit/EnviroDIY_Monitoring_Kit.ino @@ -344,8 +344,8 @@ VariableArray varArray(variableCount, variableList, UUIDs); // ========================================================================== /** Start [monitor_my_watershed_publisher] */ // Create a data publisher for the Monitor My Watershed POST endpoint -#include -EnviroDIYPublisher MonitorMWPost(dataLogger, registrationToken); +#include +MonitorMyWatershedPublisher MonitorMWPost(dataLogger, registrationToken); /** End [monitor_my_watershed_publisher] */ #endif diff --git a/examples/EnviroDIY_Monitoring_Kit/ReadMe.md b/examples/EnviroDIY_Monitoring_Kit/ReadMe.md index 42b820081..c6f1cf808 100644 --- a/examples/EnviroDIY_Monitoring_Kit/ReadMe.md +++ b/examples/EnviroDIY_Monitoring_Kit/ReadMe.md @@ -5,7 +5,7 @@ Example sketch to be used with the [EnviroDIY Monitoring Station Kit](https://ww This example uses the sensors and equipment included with (or recommended for) the [EnviroDIY Monitoring Station Kit](https://www.envirodiy.org/product/envirodiy-monitoring-station-kit/). It includes code for a Mayfly 1.x, a [Meter Hydros 21](https://metergroup.com/products/hydros-21/) and either a [SIM7080G-based EnviroDIY LTEbee](https://www.envirodiy.org/product/envirodiy-lte-bee/) or an [EnviroDIY ESP32 Bee](https://www.envirodiy.org/product/envirodiy-esp32-bee-wifi-bluetooth/) for communication. This examples also makes use of the on-board light, temperature, and humidity sensors on the Mayfly 1.x. -The results are saved to the SD card and posted to the Monitor My Watershed data portal. +The results are saved to the SD card and posted to Monitor My Watershed. > [!NOTE] > The Meter Hydros 21 is **not** included in the [EnviroDIY Monitoring Station Kit](https://www.envirodiy.org/product/envirodiy-monitoring-station-kit/) and must be purchased separately from Meter Group or one of their distributors. diff --git a/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_2G/DRWI_2G.ino b/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_2G/DRWI_2G.ino index 22a27ac7d..ca272a346 100644 --- a/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_2G/DRWI_2G.ino +++ b/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_2G/DRWI_2G.ino @@ -227,8 +227,8 @@ Logger dataLogger(LoggerID, loggingInterval, &varArray); // ========================================================================== /** Start [publishers] */ // Create a data publisher for the Monitor My Watershed POST endpoint -#include -EnviroDIYPublisher MonitorMWPost(dataLogger, registrationToken, +#include +MonitorMyWatershedPublisher MonitorMWPost(dataLogger, registrationToken, samplingFeature); /** End [publishers] */ diff --git a/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_2G/ReadMe.md b/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_2G/ReadMe.md index eccc55ddf..98a5f510b 100644 --- a/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_2G/ReadMe.md +++ b/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_2G/ReadMe.md @@ -39,7 +39,7 @@ _______ ### Prepare and set up PlatformIO -- Register a site and sensors at the Monitor My Watershed/EnviroDIY data portal () +- Register a site and sensors on [Monitor My Watershed](https://monitormywatershed.org/) - Create a new PlatformIO project - Replace the contents of the platformio.ini for your new project with the [platformio.ini](https://raw.githubusercontent.com/EnviroDIY/ModularSensors/master/examples/DRWI_CitSci/platformio.ini) file in the examples/DRWI_CitSci folder on GitHub. - It is important that your PlatformIO configuration has the lib_ldf_mode and build flags set as they are in the example. @@ -90,7 +90,7 @@ CampbellOBS3 osb3high(OBS3Power, OBSHighADSChannel, OBSHigh_A, OBSHigh_B, OBSHig ### Set the universally universal identifiers (UUID) for each variable -- Go back to the web page for your site at the Monitor My Watershed/EnviroDIY data portal () +- Go back to the web page for your site on [Monitor My Watershed](https://monitormywatershed.org/) - Find and click the white "View Token UUID List" button above the small map on your site page - **VERY CAREFULLY** check that the variables are in exactly the same order as in the variable array: diff --git a/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_DigiLTE/DRWI_DigiLTE.ino b/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_DigiLTE/DRWI_DigiLTE.ino index ca7d10acc..4c25ba7ed 100644 --- a/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_DigiLTE/DRWI_DigiLTE.ino +++ b/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_DigiLTE/DRWI_DigiLTE.ino @@ -247,9 +247,9 @@ Logger dataLogger(LoggerID, loggingInterval, &varArray); // ========================================================================== /** Start [publishers] */ // Create a data publisher for the Monitor My Watershed POST endpoint -#include -EnviroDIYPublisher MonitorMWPost(dataLogger, registrationToken, - samplingFeature); +#include +MonitorMyWatershedPublisher MonitorMWPost(dataLogger, registrationToken, + samplingFeature); /** End [publishers] */ diff --git a/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_DigiLTE/ReadMe.md b/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_DigiLTE/ReadMe.md index 153b4e735..bd7d63054 100644 --- a/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_DigiLTE/ReadMe.md +++ b/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_DigiLTE/ReadMe.md @@ -40,7 +40,7 @@ _______ ### Prepare and set up PlatformIO -- Register a site and sensors at the Monitor My Watershed/EnviroDIY data portal () +- Register a site and sensors on [Monitor My Watershed](https://monitormywatershed.org/) - Create a new PlatformIO project - Replace the contents of the platformio.ini for your new project with the [platformio.ini](https://raw.githubusercontent.com/EnviroDIY/ModularSensors/master/examples/DRWI_DigiLTE/platformio.ini) file in the examples/DRWI_DigiLTE folder on GitHub. @@ -93,7 +93,7 @@ CampbellOBS3 osb3high(OBS3Power, OBSHighADSChannel, OBSHigh_A, OBSHigh_B, OBSHig ### Set the universally universal identifiers (UUID) for each variable -- Go back to the web page for your site at the Monitor My Watershed/EnviroDIY data portal () +- Go back to the web page for your site on [Monitor My Watershed](https://monitormywatershed.org/) - Find and click the white "View Token UUID List" button above the small map on your site page - **VERY CAREFULLY** check that the variables are in exactly the same order as in the variable array: diff --git a/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_Mayfly1/DRWI_Mayfly1.ino b/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_Mayfly1/DRWI_Mayfly1.ino index 5cec2378d..901f08100 100644 --- a/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_Mayfly1/DRWI_Mayfly1.ino +++ b/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_Mayfly1/DRWI_Mayfly1.ino @@ -253,9 +253,9 @@ Logger dataLogger(LoggerID, loggingInterval, &varArray); // ========================================================================== /** Start [publishers] */ // Create a data publisher for the Monitor My Watershed POST endpoint -#include -EnviroDIYPublisher MonitorMWPost(dataLogger, registrationToken, - samplingFeature); +#include +MonitorMyWatershedPublisher MonitorMWPost(dataLogger, registrationToken, + samplingFeature); /** End [publishers] */ diff --git a/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_Mayfly1/ReadMe.md b/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_Mayfly1/ReadMe.md index 2c2d733d7..521ee44f3 100644 --- a/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_Mayfly1/ReadMe.md +++ b/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_Mayfly1/ReadMe.md @@ -2,7 +2,7 @@ Example sketch for using the EnviroDIY SIM7080G LTE cellular module with an EnviroDIY Mayfly Data Logger. -This example uses the sensors and equipment used by most groups participating in the DRWI (Delaware River Watershed Initiative) Citizen Science project with the Stroud Water Research Center. It includes a Meter Hydros 21 (CTD) and a SIM7080G-based EnviroDIY LTEbee for communication. This examples also makes use of the on-board light, temperature, and humidity sensors on the Mayfly 1.x. The results are saved to the SD card and posted to the Monitor My Watershed data portal. Only to be used with newer Mayfly v1.0 and v1.1 boards. +This example uses the sensors and equipment used by most groups participating in the DRWI (Delaware River Watershed Initiative) Citizen Science project with the Stroud Water Research Center. It includes a Meter Hydros 21 (CTD) and a SIM7080G-based EnviroDIY LTEbee for communication. This examples also makes use of the on-board light, temperature, and humidity sensors on the Mayfly 1.x. The results are saved to the SD card and posted to Monitor My Watershed. Only to be used with newer Mayfly v1.0 and v1.1 boards. The exact hardware configuration used in this example: diff --git a/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_Mayfly1_WiFi/DRWI_Mayfly1_WiFi.ino b/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_Mayfly1_WiFi/DRWI_Mayfly1_WiFi.ino index 3a125062e..2bede798e 100644 --- a/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_Mayfly1_WiFi/DRWI_Mayfly1_WiFi.ino +++ b/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_Mayfly1_WiFi/DRWI_Mayfly1_WiFi.ino @@ -228,9 +228,9 @@ Logger dataLogger(LoggerID, loggingInterval, &varArray); // ========================================================================== /** Start [publishers] */ // Create a data publisher for the Monitor My Watershed POST endpoint -#include -EnviroDIYPublisher MonitorMWPost(dataLogger, registrationToken, - samplingFeature); +#include +MonitorMyWatershedPublisher MonitorMWPost(dataLogger, registrationToken, + samplingFeature); /** End [publishers] */ diff --git a/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_NoCellular/ReadMe.md b/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_NoCellular/ReadMe.md index 2e3942fd1..ffaaf97be 100644 --- a/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_NoCellular/ReadMe.md +++ b/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_NoCellular/ReadMe.md @@ -44,7 +44,7 @@ _______ ### Prepare and set up PlatformIO -- Register a site and sensors at the Monitor My Watershed/EnviroDIY data portal () +- Register a site and sensors on [Monitor My Watershed](https://monitormywatershed.org/) - Create a new PlatformIO project - Replace the contents of the platformio.ini for your new project with the [platformio.ini](https://raw.githubusercontent.com/EnviroDIY/ModularSensors/master/examples/DRWI_NoCellular/platformio.ini) file in the examples/DRWI_NoCellular folder on GitHub. - It is important that your PlatformIO configuration has the lib_ldf_mode and build flags set as they are in the example. @@ -95,7 +95,7 @@ CampbellOBS3 osb3high(OBS3Power, OBSHighADSChannel, OBSHigh_A, OBSHigh_B, OBSHig ### Set the universally universal identifiers (UUID) for each variable -- Go back to the web page for your site at the Monitor My Watershed/EnviroDIY data portal () +- Go back to the web page for your site on [Monitor My Watershed](https://monitormywatershed.org/) - Find and click the white "View Token UUID List" button above the small map on your site page - __VERY CAREFULLY__ check that the variables are in exactly the same order as in the variable array: diff --git a/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_SIM7080LTE/DRWI_SIM7080LTE.ino b/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_SIM7080LTE/DRWI_SIM7080LTE.ino index 496a5e2ab..126af0fec 100644 --- a/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_SIM7080LTE/DRWI_SIM7080LTE.ino +++ b/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_SIM7080LTE/DRWI_SIM7080LTE.ino @@ -254,9 +254,9 @@ Logger dataLogger(LoggerID, loggingInterval, &varArray); // ========================================================================== /** Start [publishers] */ // Create a data publisher for the Monitor My Watershed POST endpoint -#include -EnviroDIYPublisher MonitorMWPost(dataLogger, registrationToken, - samplingFeature); +#include +MonitorMyWatershedPublisher MonitorMWPost(dataLogger, registrationToken, + samplingFeature); /** End [publishers] */ diff --git a/examples/OutdatedExamples/simple_logging_LearnEnviroDIY/ReadMe.md b/examples/OutdatedExamples/simple_logging_LearnEnviroDIY/ReadMe.md index f897d56f7..ea2d11259 100644 --- a/examples/OutdatedExamples/simple_logging_LearnEnviroDIY/ReadMe.md +++ b/examples/OutdatedExamples/simple_logging_LearnEnviroDIY/ReadMe.md @@ -6,7 +6,7 @@ The processor then goes to sleep between readings. This example calls on two of the sensors available in this library. The example may be run exactly as written. -This is the example you should use to deploy a logger somewhere where you don't want or have access to a way of streaming live data and you won't want to upload data to the Monitor My Watershed data portal. +This is the example you should use to deploy a logger somewhere where you don't want or have access to a way of streaming live data and you won't want to upload data to Monitor My Watershed. _______ diff --git a/examples/ReadMe.md b/examples/ReadMe.md index 46d755b20..d2bef16a3 100644 --- a/examples/ReadMe.md +++ b/examples/ReadMe.md @@ -59,7 +59,7 @@ ___ ### Publishing to Monitor My Watershed -The logging to Monitor My Watershed example uses a Digi XBee in transparent mode to publish data live from a BME280 and Maxim DS18 to the Monitor My Watershed data portal. +The logging to Monitor My Watershed example uses a Digi XBee in transparent mode to publish data live from a BME280 and Maxim DS18 to Monitor My Watershed. - [Instructions for the logging to Monitor My Watershed example](https://envirodiy.github.io/ModularSensors/example_mmw.html) - [The logging to Monitor My Watershed example on GitHub](https://github.com/EnviroDIY/ModularSensors/tree/master/examples/logging_to_MMW) @@ -102,7 +102,7 @@ This showcases both how to use two different logging instances and how to use so The data saving example is another double logger example, but in this case, both loggers are going at the same interval and the only difference between the loggers is the list of variables. There are two sets of variables, all coming from Yosemitech sensors. -Because each sensor outputs temperature and we don't want to waste cellular data sending out multiple nearly identical temperature values, we have one logger that logs every possible variable result to the SD card and another logger that sends only unique results to the EnviroDIY data portal. +Because each sensor outputs temperature and we don't want to waste cellular data sending out multiple nearly identical temperature values, we have one logger that logs every possible variable result to the SD card and another logger that sends only unique results to Monitor My Watershed. This example also shows how to stop power draw from an RS485 adapter with automatic flow detection. - [Instructions for the data saving example](https://envirodiy.github.io/ModularSensors/example_data_saving.html) @@ -146,7 +146,7 @@ ___ The DRWI Mayfly 1.x LTE example uses the sensors and equipment used by most groups participating in the DRWI (Delaware River Watershed Initiative) Citizen Science project with the Stroud Water Research Center. It includes a Meter Hydros 21 (CTD) and a SIM7080G-based EnviroDIY LTEbee for communication. This examples also makes use of the on-board light, temperature, and humidity sensors on the Mayfly 1.x. -The results are saved to the SD card and posted to the Monitor My Watershed data portal. Only to be used with newer Mayfly v1.0 and v1.1 boards. +The results are saved to the SD card and posted to Monitor My Watershed. Only to be used with newer Mayfly v1.0 and v1.1 boards. - [Instructions for the Mayfly 1.x LTE DRWI Citizen Science example](https://envirodiy.github.io/ModularSensors/example_drwi_mayfly1.html) - [The LTEG DRWI Citizen Science example on GitHub](https://github.com/EnviroDIY/ModularSensors/tree/master/examples/OutdatedHardware/DRWI_CitizenScience/DRWI_Mayfly1) @@ -164,7 +164,7 @@ The exclusion of the modem and publisher simplifies the code from the other DRWI The 2G DRWI Citizen Science example uses the sensors and equipment found on older stations used in the DRWI Citizen Science project prior to 2020. The 2G GPRSbee boards no longer function in the USA, so this code should not be used and is only provided to archival and reference purposes. It includes a Meter Hydros 21 (formerly know as a Decagon CTD), a Campbell OBS3+, and a Sodaq GPRSBee for communication. -The results are saved to the SD card and posted to the Monitor My Watershed data portal. +The results are saved to the SD card and posted to Monitor My Watershed. The only difference between this and the other cellular DRWI examples is the type of modem used. - [Instructions for the 2G DRWI Citizen Science example](https://envirodiy.github.io/ModularSensors/example_drwi_2g.html) @@ -174,7 +174,7 @@ The only difference between this and the other cellular DRWI examples is the typ The DRWI Digi LTE example uses the sensors and equipment common to older stations (2016-2020) deployed by groups participating in the DRWI Citizen Science project with the Stroud Water Research Center. It includes a Meter Hydros 21 (formerly know as a Decagon CTD), a Campbell OBS3+, and a Digi XBee3 LTE-M for communication. -The results are saved to the SD card and posted to the Monitor My Watershed data portal. +The results are saved to the SD card and posted to Monitor My Watershed. The only difference between this and the other cellular DRWI examples is the type of modem used. - [Instructions for the Digi LTE DRWI Citizen Science example](https://envirodiy.github.io/ModularSensors/example_drwi_digilte.html) @@ -184,7 +184,7 @@ The only difference between this and the other cellular DRWI examples is the typ The DRWI EnviroDIY LTEbee example uses the sensors and equipment common to newer stations (2016-2020) deployed by groups participating in the DRWI Citizen Science project with the Stroud Water Research Center. It includes a Meter Hydros 21 (CTD), a Campbell OBS3+, (Turbidity) and a SIM7080G-based EnviroDIY LTEbee for communication. -The results are saved to the SD card and posted to the Monitor My Watershed data portal. +The results are saved to the SD card and posted to Monitor My Watershed. The only difference between this and the other cellular DRWI examples below is the type of modem used. - [Instructions for the EnviroDIY LTEbee DRWI Citizen Science example](https://envirodiy.github.io/ModularSensors/example_drwi_ediylte.html) diff --git a/examples/baro_rho_correction/ReadMe.md b/examples/baro_rho_correction/ReadMe.md index 118500af3..2ac1ad0b4 100644 --- a/examples/baro_rho_correction/ReadMe.md +++ b/examples/baro_rho_correction/ReadMe.md @@ -35,7 +35,7 @@ _______ ### Prepare and set up PlatformIO -- Register a site and sensors at the Monitor My Watershed/EnviroDIY data portal () +- Register a site and sensors on [Monitor My Watershed](https://monitormywatershed.org/) - Create a new PlatformIO project - Replace the contents of the platformio.ini for your new project with the [platformio.ini](https://raw.githubusercontent.com/EnviroDIY/ModularSensors/master/examples/baro_rho_correction/platformio.ini) file in the examples/baro_rho_correction folder on GitHub. - It is important that your PlatformIO configuration has the lib_ldf_mode and build flags set as they are in the example. @@ -56,7 +56,7 @@ const char *LoggerID = "XXXX"; ### Set the universally universal identifiers (UUID) for each variable -- Go back to the web page for your site at the Monitor My Watershed/EnviroDIY data portal () +- Go back to the web page for your site on [Monitor My Watershed](https://monitormywatershed.org/) - For each variable, find the dummy UUID (`"12345678-abcd-1234-ef00-1234567890ab"`) and replace it with the real UUID for the variable. ### Upload! diff --git a/examples/baro_rho_correction/baro_rho_correction.ino b/examples/baro_rho_correction/baro_rho_correction.ino index 2ef8ca2f0..30e3837d6 100644 --- a/examples/baro_rho_correction/baro_rho_correction.ino +++ b/examples/baro_rho_correction/baro_rho_correction.ino @@ -361,9 +361,9 @@ const char* samplingFeature = "12345678-abcd-1234-ef00-1234567890ab"; // Sampling feature UUID // Create a data publisher for the Monitor My Watershed POST endpoint -#include -EnviroDIYPublisher MonitorMWPost(dataLogger, registrationToken, - samplingFeature); +#include +MonitorMyWatershedPublisher MonitorMWPost(dataLogger, registrationToken, + samplingFeature); /** End [publishers] */ diff --git a/examples/data_saving/ReadMe.md b/examples/data_saving/ReadMe.md index 43dae2ebc..55b0e0ccd 100644 --- a/examples/data_saving/ReadMe.md +++ b/examples/data_saving/ReadMe.md @@ -2,7 +2,7 @@ This is another double logger example, but in this case, both loggers are going at the same interval and the only difference between the loggers is the list of variables. There are two sets of variables, all coming from Yosemitech sensors. -Because each sensor outputs temperature and we don't want to waste cellular data sending out multiple nearly identical temperature values, we have one logger that logs every possible variable result to the SD card and another logger that sends only unique results to the EnviroDIY data portal. +Because each sensor outputs temperature and we don't want to waste cellular data sending out multiple nearly identical temperature values, we have one logger that logs every possible variable result to the SD card and another logger that sends only unique results to [Monitor My Watershed](https://monitormywatershed.org/). The modem used in this example is a SIM800 based Sodaq GPRSBee r6. @@ -43,7 +43,7 @@ _______ ### Prepare and set up PlatformIO -- Register a site and sensors at the Monitor My Watershed/EnviroDIY data portal () +- Register a site and sensors on [Monitor My Watershed](https://monitormywatershed.org/) - Create a new PlatformIO project - Replace the contents of the platformio.ini for your new project with the [platformio.ini](https://raw.githubusercontent.com/EnviroDIY/ModularSensors/master/examples/data_saving/platformio.ini) file in the examples/data_saving folder on GitHub. - It is important that your PlatformIO configuration has the lib_ldf_mode and build flags set as they are in the example. @@ -64,7 +64,7 @@ const char *LoggerID = "XXXX"; ### Set the universally universal identifiers (UUID) for each variable -- Go back to the web page for your site at the Monitor My Watershed/EnviroDIY data portal () +- Go back to the web page for your site on [Monitor My Watershed](https://monitormywatershed.org/) - For each variable, find the dummy UUID (`"12345678-abcd-1234-ef00-1234567890ab"`) and replace it with the real UUID for the variable. ### Upload! diff --git a/examples/data_saving/data_saving.ino b/examples/data_saving/data_saving.ino index 54ce5b75b..067d92192 100644 --- a/examples/data_saving/data_saving.ino +++ b/examples/data_saving/data_saving.ino @@ -353,9 +353,9 @@ const char* samplingFeature = // Create a data publisher for the Monitor My Watershed POST endpoint // This is only attached to the logger with the shorter variable array -#include -EnviroDIYPublisher MonitorMWPost(loggerToGo, registrationToken, - samplingFeature); +#include +MonitorMyWatershedPublisher MonitorMWPost(loggerToGo, registrationToken, + samplingFeature); /** End [publishers] */ @@ -447,7 +447,8 @@ void setup() { loggerAllVars.setLoggerPins(wakePin, sdCardSSPin, sdCardPwrPin, buttonPin, greenLED); - // Set up the connection information with EnviroDIY for both loggers + // Set up the connection information with Monitor My Watershed for both + // loggers // Doing this for both loggers ensures that the header of the csv will have // the tokens in it loggerAllVars.setSamplingFeatureUUID(samplingFeature); diff --git a/examples/logging_to_MMW/ReadMe.md b/examples/logging_to_MMW/ReadMe.md index b4a9384b3..2be4aedea 100644 --- a/examples/logging_to_MMW/ReadMe.md +++ b/examples/logging_to_MMW/ReadMe.md @@ -1,4 +1,4 @@ -# Sending Data to Monitor My Watershed/EnviroDIY +# Sending Data to Monitor My Watershed This sketch reduces menu_a_la_carte.ino to provide an example of how to log to from two sensors, the BME280 and DS18. To complete the set up for logging to the web portal, the UUIDs for the site and each variable would need to be added to the sketch. @@ -6,7 +6,7 @@ The settings for other data portals were removed from the example. The modem settings were left unchanged because the sketch will test successfully without modem connection (wait patiently, it takes a few minutes). -This is the example you should use to deploy a logger with a modem to stream live data to the Monitor My Watershed data portal. +This is the example you should use to deploy a logger with a modem to stream live data to Monitor My Watershed. _______ @@ -16,7 +16,7 @@ _______ -- [Sending Data to Monitor My Watershed/EnviroDIY](#sending-data-to-monitor-my-watershedenvirodiy) +- [Sending Data to Monitor My Watershed](#sending-data-to-monitor-my-watershed) - [Unique Features of the Monitor My Watershed Example](#unique-features-of-the-monitor-my-watershed-example) - [To Use this Example](#to-use-this-example) - [Prepare and set up PlatformIO](#prepare-and-set-up-platformio) @@ -30,14 +30,14 @@ _______ ## Unique Features of the Monitor My Watershed Example -- A single logger publishes data to the Monitor My Watershed data portal. +- A single logger publishes data to Monitor My Watershed. - Uses a cellular Digi XBee or XBee3 ## To Use this Example ### Prepare and set up PlatformIO -- Register a site and sensors at the Monitor My Watershed/EnviroDIY data portal () +- Register a site and sensors on [Monitor My Watershed](https://monitormywatershed.org/) - Create a new PlatformIO project - Replace the contents of the platformio.ini for your new project with the [platformio.ini](https://raw.githubusercontent.com/EnviroDIY/ModularSensors/master/examples/logging_to_MMW/platformio.ini) file in the examples/logging_to_MMW folder on GitHub. - It is important that your PlatformIO configuration has the lib_ldf_mode and build flags set as they are in the example. @@ -58,7 +58,7 @@ const char *LoggerID = "XXXX"; ### Set the universally universal identifiers (UUID) for each variable -- Go back to the web page for your site at the Monitor My Watershed/EnviroDIY data portal () +- Go back to the web page for your site on [Monitor My Watershed](https://monitormywatershed.org/) - For each variable, find the dummy UUID (`"12345678-abcd-1234-ef00-1234567890ab"`) and replace it with the real UUID for the variable. ### Upload! diff --git a/examples/logging_to_MMW/logging_to_MMW.ino b/examples/logging_to_MMW/logging_to_MMW.ino index 0315d7d9f..4c7236c07 100644 --- a/examples/logging_to_MMW/logging_to_MMW.ino +++ b/examples/logging_to_MMW/logging_to_MMW.ino @@ -213,9 +213,9 @@ const char* samplingFeature = "12345678-abcd-1234-ef00-1234567890ab"; // Sampling feature UUID // Create a data publisher for the Monitor My Watershed POST endpoint -#include -EnviroDIYPublisher MonitorMWPost(dataLogger, registrationToken, - samplingFeature); +#include +MonitorMyWatershedPublisher MonitorMWPost(dataLogger, registrationToken, + samplingFeature); /** End [publishers] */ diff --git a/examples/menu_a_la_carte/ReadMe.md b/examples/menu_a_la_carte/ReadMe.md index 191ce26a4..6503ceaca 100644 --- a/examples/menu_a_la_carte/ReadMe.md +++ b/examples/menu_a_la_carte/ReadMe.md @@ -1290,7 +1290,7 @@ Here we use the `new` keyword to create multiple variables and get pointers to t #### Creating Variables and Pasting UUIDs from MonitorMyWatershed -If you are sending data to monitor my watershed, it is much easier to create the variables in an array and then to paste the UUID's all together as copied from the "View Token UUID List" link for a site. +If you are sending data to Monitor My Watershed, it is much easier to create the variables in an array and then to paste the UUID's all together as copied from the "View Token UUID List" link for a site. If using this method, be very, very, very careful to make sure the order of your variables exactly matches the order of your UUID's. @@ -1609,7 +1609,7 @@ All together, this gives: If you need more help in writing a complex loop, the [double_logger example program](https://github.com/EnviroDIY/ModularSensors/tree/master/examples/double_logger) demonstrates using a custom loop function in order to log two different groups of sensors at different logging intervals. -The [data_saving example program](https://github.com/EnviroDIY/ModularSensors/tree/master/examples/data_saving) shows using a custom loop in order to save cellular data by saving data from many variables on the SD card, but only sending a portion of the data to the EnviroDIY data portal. +The [data_saving example program](https://github.com/EnviroDIY/ModularSensors/tree/master/examples/data_saving) shows using a custom loop in order to save cellular data by saving data from many variables on the SD card, but only sending a portion of the data to [Monitor My Watershed](https://monitormywatershed.org/). diff --git a/examples/menu_a_la_carte/menu_a_la_carte.ino b/examples/menu_a_la_carte/menu_a_la_carte.ino index 90ead9f0c..9518182b0 100644 --- a/examples/menu_a_la_carte/menu_a_la_carte.ino +++ b/examples/menu_a_la_carte/menu_a_la_carte.ino @@ -3360,8 +3360,8 @@ const char* registrationToken = // Sampling feature UUID // Create a data publisher for the Monitor My Watershed POST endpoint -#include -EnviroDIYPublisher MonitorMWPost(dataLogger, registrationToken); +#include +MonitorMyWatershedPublisher MonitorMWPost(dataLogger, registrationToken); /** End [monitor_my_watershed_publisher] */ #endif diff --git a/examples/menu_a_la_carte/platformio.ini b/examples/menu_a_la_carte/platformio.ini index b2888d268..273cc67a4 100644 --- a/examples/menu_a_la_carte/platformio.ini +++ b/examples/menu_a_la_carte/platformio.ini @@ -37,7 +37,7 @@ build_flags = ; -D BUILD_MODEM_DIGI_XBEE_CELLULAR_TRANSPARENT ; Turn on first time w/ a Digi LTE-M module ; -D MS_LOGGERBASE_DEBUG ; -D MS_DATAPUBLISHERBASE_DEBUG - ; -D MS_ENVIRODIYPUBLISHER_DEBUG + ; -D MS_MONITORMYWATERSHEDPUBLISHER_DEBUG lib_deps = envirodiy/EnviroDIY_ModularSensors ; ^^ Use this when working from a tagged release of the library diff --git a/examples/simple_logging/ReadMe.md b/examples/simple_logging/ReadMe.md index 63733c728..59139d763 100644 --- a/examples/simple_logging/ReadMe.md +++ b/examples/simple_logging/ReadMe.md @@ -4,7 +4,7 @@ This shows the simplest use of a "logger" object. That is, creating an array of variable objects and then creating a logger object that utilizes those variables to update all of the variable results together and save the data to a SD card. The processor then goes to sleep between readings. -This is the example you should use to deploy a logger somewhere where you don't want or have access to a way of streaming live data and you won't want to upload data to the Monitor My Watershed data portal. +This is the example you should use to deploy a logger somewhere where you don't want or have access to a way of streaming live data and you won't want to upload data to Monitor My Watershed. _______ diff --git a/library.json b/library.json index d664fa95a..f3c67979c 100644 --- a/library.json +++ b/library.json @@ -1,7 +1,7 @@ { "name": "EnviroDIY_ModularSensors", "version": "0.37.0", - "description": "A library that allows access to multiple sensors through a unified interface. This allows the user to simply access many sensors to log the data or send the data to data repositories like the EnviroDIY data portal.", + "description": "A library that allows access to multiple sensors through a unified interface. This allows the user to simply access many sensors to log the data or send the data to data repositories like Monitor My Watershed.", "keywords": "modular, sensor, sensors, datalogger, logger, low power, sleeping, EnviroDIY, ModularSensors, Mayfly, WikiWatershed, Monitor My Watershed, ThingSpeak", "platforms": ["atmelavr", "atmelsam"], "frameworks": "arduino", diff --git a/library.properties b/library.properties index 08e144776..fd7658c57 100644 --- a/library.properties +++ b/library.properties @@ -3,7 +3,7 @@ version=0.37.0 author=Sara Damiano , Shannon Hicks maintainer=Sara Damiano sentence=A library that allows access to multiple sensors through a unified interface. -paragraph=This allows the user to simply access many sensors to log the data or send the data to data repositories like the EnviroDIY data portal. +paragraph=This allows the user to simply access many sensors to log the data or send the data to data repositories like Monitor My Watershed. category=Sensors url=https://github.com/EnviroDIY/ModularSensors architectures=avr,samd diff --git a/src/LoggerBase.cpp b/src/LoggerBase.cpp index 7f82e4e60..12dd69cd8 100644 --- a/src/LoggerBase.cpp +++ b/src/LoggerBase.cpp @@ -653,7 +653,7 @@ bool Logger::isRTCSane(void) { // This sets static variables for the date/time - this is needed so that all -// data outputs (SD, EnviroDIY, serial printing, etc) print the same time +// data outputs (SD, publishers, serial printing, etc) print the same time // for updating the sensors - even though the routines to update the sensors // and to output the data may take several seconds. // It is not currently possible to output the instantaneous time an individual @@ -1275,7 +1275,7 @@ void Logger::printFileHeader(Stream* stream) { stream->print(F("Data Logger File: ")); stream->println(_fileName); - // Adding the sampling feature UUID (only applies to EnviroDIY logger) + // Adding the sampling feature UUID if (strlen(_samplingFeatureUUID) > 1) { stream->print(F("Sampling Feature UUID: ")); stream->print(_samplingFeatureUUID); diff --git a/src/LoggerBase.h b/src/LoggerBase.h index bf35e2f64..3e30be8d2 100644 --- a/src/LoggerBase.h +++ b/src/LoggerBase.h @@ -958,7 +958,7 @@ class Logger { /** * @brief Set static variables for the date/time * - * This is needed so that all data outputs (SD, EnviroDIY, serial printing, + * This is needed so that all data outputs (SD, publishers, serial printing, * etc) print the same time for updating the sensors - even though the * routines to update the sensors and to output the data may take several * seconds. It is not currently possible to output the instantaneous time @@ -980,7 +980,7 @@ class Logger { * That is the value saved in the static variable markedLocalUnixTime. * * This should be used in conjunction with markTime() to ensure that all - * data outputs from a single data update session (SD, EnviroDIY, serial + * data outputs from a single data update session (SD, publishers, serial * printing, etc) have the same timestamp even though the update routine may * take several (or many) seconds. * diff --git a/src/ModSensorDebugConfig.h b/src/ModSensorDebugConfig.h index 5c805be65..5e8bb477b 100644 --- a/src/ModSensorDebugConfig.h +++ b/src/ModSensorDebugConfig.h @@ -59,7 +59,7 @@ // #define MS_DATAPUBLISHERBASE_DEBUG // #define MS_DATAPUBLISHERBASE_DEBUG_DEEP -// #define MS_ENVIRODIYPUBLISHER_DEBUG +// #define MS_MONITORMYWATERSHEDPUBLISHER_DEBUG // #define MS_THINGSPEAKPUBLISHER_DEBUG // #define MS_UBIDOTSPUBLISHER_DEBUG // #define MS_DREAMHOSTPUBLISHER_DEBUG diff --git a/src/publishers/AWS_IoT_Publisher.h b/src/publishers/AWS_IoT_Publisher.h index 4f4a71b5e..17a4a17c8 100644 --- a/src/publishers/AWS_IoT_Publisher.h +++ b/src/publishers/AWS_IoT_Publisher.h @@ -124,8 +124,7 @@ class AWS_IoT_Publisher : public dataPublisher { * file * @param clientCertName The name of your client certificate file * @param clientKeyName The name of your client private key file - * @param samplingFeatureUUID The sampling feature UUID for the site on the - * Monitor My Watershed data portal. + * @param samplingFeatureUUID The sampling feature UUID * @param sendEveryX Interval (in units of the logging interval) between * attempted data transmissions. NOTE: not implemented by this publisher! * @@ -164,8 +163,7 @@ class AWS_IoT_Publisher : public dataPublisher { * Allows the use of any type of client and multiple clients tied to a * single TinyGSM modem instance * @param awsIoTEndpoint The endpoint for your AWS IoT instance - * @param samplingFeatureUUID The sampling feature UUID for the site on the - * Monitor My Watershed data portal. + * @param samplingFeatureUUID The sampling feature UUID * @param sendEveryX Interval (in units of the logging interval) between * attempted data transmissions. NOTE: not implemented by this publisher! */ @@ -389,8 +387,7 @@ class AWS_IoT_Publisher : public dataPublisher { /** * @copydoc dataPublisher::begin(Logger& baseLogger, Client* inClient) * @param awsIoTEndpoint The endpoint for your AWS IoT instance - * @param samplingFeatureUUID The sampling feature UUID for the site on the - * Monitor My Watershed data portal. + * @param samplingFeatureUUID The sampling feature UUID */ void begin(Logger& baseLogger, Client* inClient, const char* awsIoTEndpoint, const char* samplingFeatureUUID); @@ -407,8 +404,7 @@ class AWS_IoT_Publisher : public dataPublisher { * file * @param clientCertName The name of your client certificate file * @param clientKeyName The name of your client private key file - * @param samplingFeatureUUID The sampling feature UUID for the site on the - * Monitor My Watershed data portal. + * @param samplingFeatureUUID The sampling feature UUID */ void begin(Logger& baseLogger, const char* awsIoTEndpoint, const char* caCertName, const char* clientCertName, diff --git a/src/publishers/MonitorMyWatershedPublisher.cpp b/src/publishers/MonitorMyWatershedPublisher.cpp index a5895eae6..59a8aa956 100644 --- a/src/publishers/MonitorMyWatershedPublisher.cpp +++ b/src/publishers/MonitorMyWatershedPublisher.cpp @@ -1,58 +1,61 @@ /** - * @file EnviroDIYPublisher.cpp + * @file MonitorMyWatershedPublisher.cpp * @copyright Stroud Water Research Center * Part of the EnviroDIY ModularSensors library for Arduino. * This library is published under the BSD-3 license. * @author Sara Geleskie Damiano * @author Thomas Watson * - * @brief Implements the EnviroDIYPublisher class. + * @brief Implements the MonitorMyWatershedPublisher class. */ -#include "EnviroDIYPublisher.h" +#include "MonitorMyWatershedPublisher.h" // ============================================================================ -// Functions for the EnviroDIY data portal receivers. +// Functions for Monitor My Watershed // ============================================================================ // Constant values for post requests // I want to refer to these more than once while ensuring there is only one copy // in memory -const char* EnviroDIYPublisher::tokenHeader = "\r\nTOKEN: "; -const char* EnviroDIYPublisher::contentLengthHeader = "\r\nContent-Length: "; -const char* EnviroDIYPublisher::contentTypeHeader = +const char* MonitorMyWatershedPublisher::tokenHeader = "\r\nTOKEN: "; +const char* MonitorMyWatershedPublisher::contentLengthHeader = + "\r\nContent-Length: "; +const char* MonitorMyWatershedPublisher::contentTypeHeader = "\r\nContent-Type: application/json\r\n\r\n"; -const char* EnviroDIYPublisher::samplingFeatureTag = "{\"sampling_feature\":\""; -const char* EnviroDIYPublisher::timestampTag = "\",\"timestamp\":"; +const char* MonitorMyWatershedPublisher::samplingFeatureTag = + "{\"sampling_feature\":\""; +const char* MonitorMyWatershedPublisher::timestampTag = "\",\"timestamp\":"; // Constructors -EnviroDIYPublisher::EnviroDIYPublisher() : dataPublisher() { +MonitorMyWatershedPublisher::MonitorMyWatershedPublisher() : dataPublisher() { setHost("monitormywatershed.org"); setPath("/api/data-stream/"); setPort(80); } -EnviroDIYPublisher::EnviroDIYPublisher(Logger& baseLogger, int sendEveryX) +MonitorMyWatershedPublisher::MonitorMyWatershedPublisher(Logger& baseLogger, + int sendEveryX) : dataPublisher(baseLogger, sendEveryX) { _logBuffer.setNumVariables(_baseLogger->getArrayVarCount()); setHost("monitormywatershed.org"); setPath("/api/data-stream/"); setPort(80); } -EnviroDIYPublisher::EnviroDIYPublisher(Logger& baseLogger, Client* inClient, - int sendEveryX) +MonitorMyWatershedPublisher::MonitorMyWatershedPublisher(Logger& baseLogger, + Client* inClient, + int sendEveryX) : dataPublisher(baseLogger, inClient, sendEveryX) { _logBuffer.setNumVariables(_baseLogger->getArrayVarCount()); setHost("monitormywatershed.org"); setPath("/api/data-stream/"); setPort(80); } -EnviroDIYPublisher::EnviroDIYPublisher(Logger& baseLogger, - const char* registrationToken, - const char* samplingFeatureUUID, - int sendEveryX) +MonitorMyWatershedPublisher::MonitorMyWatershedPublisher( + Logger& baseLogger, const char* registrationToken, + const char* samplingFeatureUUID, int sendEveryX) : dataPublisher(baseLogger, sendEveryX) { setToken(registrationToken); _baseLogger->setSamplingFeatureUUID(samplingFeatureUUID); @@ -61,9 +64,8 @@ EnviroDIYPublisher::EnviroDIYPublisher(Logger& baseLogger, setPath("/api/data-stream/"); setPort(80); } -EnviroDIYPublisher::EnviroDIYPublisher(Logger& baseLogger, - const char* registrationToken, - int sendEveryX) +MonitorMyWatershedPublisher::MonitorMyWatershedPublisher( + Logger& baseLogger, const char* registrationToken, int sendEveryX) : dataPublisher(baseLogger, sendEveryX) { setToken(registrationToken); _logBuffer.setNumVariables(_baseLogger->getArrayVarCount()); @@ -71,10 +73,9 @@ EnviroDIYPublisher::EnviroDIYPublisher(Logger& baseLogger, setPath("/api/data-stream/"); setPort(80); } -EnviroDIYPublisher::EnviroDIYPublisher(Logger& baseLogger, Client* inClient, - const char* registrationToken, - const char* samplingFeatureUUID, - int sendEveryX) +MonitorMyWatershedPublisher::MonitorMyWatershedPublisher( + Logger& baseLogger, Client* inClient, const char* registrationToken, + const char* samplingFeatureUUID, int sendEveryX) : dataPublisher(baseLogger, inClient, sendEveryX) { setToken(registrationToken); _baseLogger->setSamplingFeatureUUID(samplingFeatureUUID); @@ -83,9 +84,9 @@ EnviroDIYPublisher::EnviroDIYPublisher(Logger& baseLogger, Client* inClient, setPath("/api/data-stream/"); setPort(80); } -EnviroDIYPublisher::EnviroDIYPublisher(Logger& baseLogger, Client* inClient, - const char* registrationToken, - int sendEveryX) +MonitorMyWatershedPublisher::MonitorMyWatershedPublisher( + Logger& baseLogger, Client* inClient, const char* registrationToken, + int sendEveryX) : dataPublisher(baseLogger, inClient, sendEveryX) { setToken(registrationToken); _logBuffer.setNumVariables(_baseLogger->getArrayVarCount()); @@ -94,47 +95,47 @@ EnviroDIYPublisher::EnviroDIYPublisher(Logger& baseLogger, Client* inClient, setPort(80); } // Destructor -EnviroDIYPublisher::~EnviroDIYPublisher() {} +MonitorMyWatershedPublisher::~MonitorMyWatershedPublisher() {} // Returns the data destination -String EnviroDIYPublisher::getHost(void) { - return String(enviroDIYHost); +String MonitorMyWatershedPublisher::getHost(void) { + return String(monitorMWHost); } // Returns the data destination -void EnviroDIYPublisher::setHost(const char* host) { - enviroDIYHost = host; +void MonitorMyWatershedPublisher::setHost(const char* host) { + monitorMWHost = host; } // Returns the data destination -String EnviroDIYPublisher::getPath(void) { - return String(enviroDIYPath); +String MonitorMyWatershedPublisher::getPath(void) { + return String(monitorMWPath); } // Returns the data destination -void EnviroDIYPublisher::setPath(const char* endpoint) { - enviroDIYPath = endpoint; +void MonitorMyWatershedPublisher::setPath(const char* endpoint) { + monitorMWPath = endpoint; } // Returns the data destination -int EnviroDIYPublisher::getPort(void) { - return enviroDIYPort; +int MonitorMyWatershedPublisher::getPort(void) { + return monitorMWPort; } // Returns the data destination -void EnviroDIYPublisher::setPort(int port) { - enviroDIYPort = port; +void MonitorMyWatershedPublisher::setPort(int port) { + monitorMWPort = port; } -void EnviroDIYPublisher::setToken(const char* registrationToken) { +void MonitorMyWatershedPublisher::setToken(const char* registrationToken) { _registrationToken = registrationToken; } // Calculates how long the JSON will be -uint16_t EnviroDIYPublisher::calculateJsonSize() { +uint16_t MonitorMyWatershedPublisher::calculateJsonSize() { uint8_t variables = _logBuffer.getNumVariables(); int records = _logBuffer.getNumRecords(); MS_DBG(F("Number of records in log buffer:"), records); @@ -181,30 +182,30 @@ uint16_t EnviroDIYPublisher::calculateJsonSize() { // A way to set members in the begin to use with a bare constructor -void EnviroDIYPublisher::begin(Logger& baseLogger, Client* inClient, - const char* registrationToken, - const char* samplingFeatureUUID) { +void MonitorMyWatershedPublisher::begin(Logger& baseLogger, Client* inClient, + const char* registrationToken, + const char* samplingFeatureUUID) { setToken(registrationToken); dataPublisher::begin(baseLogger, inClient); _baseLogger->setSamplingFeatureUUID(samplingFeatureUUID); _logBuffer.setNumVariables(_baseLogger->getArrayVarCount()); } -void EnviroDIYPublisher::begin(Logger& baseLogger, - const char* registrationToken, - const char* samplingFeatureUUID) { +void MonitorMyWatershedPublisher::begin(Logger& baseLogger, + const char* registrationToken, + const char* samplingFeatureUUID) { setToken(registrationToken); dataPublisher::begin(baseLogger); _baseLogger->setSamplingFeatureUUID(samplingFeatureUUID); _logBuffer.setNumVariables(_baseLogger->getArrayVarCount()); } -void EnviroDIYPublisher::begin(Logger& baseLogger, - const char* registrationToken) { +void MonitorMyWatershedPublisher::begin(Logger& baseLogger, + const char* registrationToken) { setToken(registrationToken); dataPublisher::begin(baseLogger); _logBuffer.setNumVariables(_baseLogger->getArrayVarCount()); } -bool EnviroDIYPublisher::connectionNeeded(void) { +bool MonitorMyWatershedPublisher::connectionNeeded(void) { // compute the send interval, reducing it as the buffer gets more full so we // have less of a chance of losing data int interval = _sendEveryX; @@ -248,11 +249,11 @@ bool EnviroDIYPublisher::connectionNeeded(void) { return atSendInterval || initialTransmission; } -// This utilizes an attached modem to make a TCP connection to the -// EnviroDIY/ODM2DataSharingPortal and then streams out a post request over that -// connection. -// The return is the http status code of the response. -int16_t EnviroDIYPublisher::publishData(Client* outClient, bool forceFlush) { +// This utilizes an attached modem to make a TCP connection to Monitor My +// Watershed and then streams out a post request over that connection. The +// return is the http status code of the response. +int16_t MonitorMyWatershedPublisher::publishData(Client* outClient, + bool forceFlush) { // work around for strange construction order: make sure the number of // variables listed in the log buffer matches the number of variables in the // logger @@ -301,7 +302,7 @@ int16_t EnviroDIYPublisher::publishData(Client* outClient, bool forceFlush) { } } -int16_t EnviroDIYPublisher::flushDataBuffer(Client* outClient) { +int16_t MonitorMyWatershedPublisher::flushDataBuffer(Client* outClient) { // Create a buffer for the portions of the request and response char tempBuffer[37] = ""; uint16_t did_respond = 0; @@ -313,21 +314,21 @@ int16_t EnviroDIYPublisher::flushDataBuffer(Client* outClient) { return 0; } - // Open a TCP/IP connection to the EnviroDIY Data Portal (WebSDL) + // Open a TCP/IP connection to Monitor My Watershed MS_DBG(F("Connecting client")); MS_START_DEBUG_TIMER; - if (outClient->connect(enviroDIYHost, enviroDIYPort)) { + if (outClient->connect(monitorMWHost, monitorMWPort)) { MS_DBG(F("Client connected after"), MS_PRINT_DEBUG_TIMER, F("ms")); txBufferInit(outClient); // copy the initial post header into the tx buffer txBufferAppend(postHeader); - txBufferAppend(enviroDIYPath); + txBufferAppend(monitorMWPath); txBufferAppend(HTTPtag); // add the rest of the HTTP POST headers to the outgoing buffer txBufferAppend(hostHeader); - txBufferAppend(enviroDIYHost); + txBufferAppend(monitorMWHost); txBufferAppend(tokenHeader); txBufferAppend(_registrationToken); @@ -426,8 +427,8 @@ int16_t EnviroDIYPublisher::flushDataBuffer(Client* outClient) { outClient->stop(); MS_DBG(F("Client stopped after"), MS_PRINT_DEBUG_TIMER, F("ms")); } else { - PRINTOUT(F("\n -- Unable to Establish Connection to EnviroDIY Data " - "Portal --")); + PRINTOUT(F( + "\n -- Unable to Establish Connection to Monitor My Watershed --")); } if (responseCode == 201) { diff --git a/src/publishers/MonitorMyWatershedPublisher.h b/src/publishers/MonitorMyWatershedPublisher.h index 462e8a378..d9d03da16 100644 --- a/src/publishers/MonitorMyWatershedPublisher.h +++ b/src/publishers/MonitorMyWatershedPublisher.h @@ -1,19 +1,18 @@ /** - * @file EnviroDIYPublisher.h + * @file MonitorMyWatershedPublisher.h * @copyright Stroud Water Research Center * Part of the EnviroDIY ModularSensors library for Arduino. * This library is published under the BSD-3 license. * @author Sara Geleskie Damiano * @author Thomas Watson * - * @brief Contains the EnviroDIYPublisher subclass of dataPublisher for - * publishing data to the Monitor My Watershed/EnviroDIY data portal at - * http://data.enviroDIY.org + * @brief Contains the MonitorMyWatershedPublisher subclass of dataPublisher for + * publishing data to Monitor My Watershed at https://monitormywatershed.org/ */ // Header Guards -#ifndef SRC_PUBLISHERS_ENVIRODIYPUBLISHER_H_ -#define SRC_PUBLISHERS_ENVIRODIYPUBLISHER_H_ +#ifndef SRC_PUBLISHERS_MONITORMYWATERSHEDPUBLISHER_H_ +#define SRC_PUBLISHERS_MONITORMYWATERSHEDPUBLISHER_H_ // Include the library config before anything else #include "ModSensorConfig.h" @@ -22,8 +21,8 @@ #include "ModSensorDebugConfig.h" // Define the print label[s] for the debugger -#ifdef MS_ENVIRODIYPUBLISHER_DEBUG -#define MS_DEBUGGING_STD "EnviroDIYPublisher" +#ifdef MS_MONITORMYWATERSHEDPUBLISHER_DEBUG +#define MS_DEBUGGING_STD "MonitorMyWatershedPublisher" #endif // Include the debugger @@ -37,24 +36,25 @@ // ============================================================================ -// Functions for the EnviroDIY data portal receivers. +// Functions for Monitor My Watershed // ============================================================================ /** - * @brief The EnviroDIYPublisher subclass of dataPublisher for publishing data - * to the Monitor My Watershed/EnviroDIY data portal at - * https://monitormywatershed.org/ (formerly at http://data.enviroDIY.org). + * @brief The MonitorMyWatershedPublisher subclass of dataPublisher for + * publishing data to Monitor My Watershed at https://monitormywatershed.org/ + * (formerly at http://data.enviroDIY.org). * * @ingroup the_publishers */ -class EnviroDIYPublisher : public dataPublisher { +class MonitorMyWatershedPublisher : public dataPublisher { public: // Constructors /** - * @brief Construct a new EnviroDIY Publisher object with no members set. + * @brief Construct a new Monitor My Watershed Publisher object with no + * members set. */ - EnviroDIYPublisher(); + MonitorMyWatershedPublisher(); /** - * @brief Construct a new EnviroDIY Publisher object + * @brief Construct a new Monitor My Watershed Publisher object * * @note If a client is never specified, the publisher will attempt to * create and use a client on a LoggerModem instance tied to the attached @@ -64,9 +64,10 @@ class EnviroDIYPublisher : public dataPublisher { * @param sendEveryX Interval (in units of the logging interval) between * attempted data transmissions. */ - explicit EnviroDIYPublisher(Logger& baseLogger, int sendEveryX = 1); + explicit MonitorMyWatershedPublisher(Logger& baseLogger, + int sendEveryX = 1); /** - * @brief Construct a new EnviroDIY Publisher object + * @brief Construct a new Monitor My Watershed Publisher object * * @param baseLogger The logger supplying the data to be published * @param inClient An Arduino client instance to use to print data to. @@ -75,110 +76,115 @@ class EnviroDIYPublisher : public dataPublisher { * @param sendEveryX Interval (in units of the logging interval) between * attempted data transmissions. */ - EnviroDIYPublisher(Logger& baseLogger, Client* inClient, - int sendEveryX = 1); + MonitorMyWatershedPublisher(Logger& baseLogger, Client* inClient, + int sendEveryX = 1); /** - * @brief Construct a new EnviroDIY Publisher object + * @brief Construct a new Monitor My Watershed Publisher object * * @param baseLogger The logger supplying the data to be published - * @param registrationToken The registration token for the site on the - * Monitor My Watershed data portal. - * @param samplingFeatureUUID The sampling feature UUID for the site on the - * Monitor My Watershed data portal. + * @param registrationToken The registration token for the site on Monitor + * My Watershed. + * @param samplingFeatureUUID The sampling feature UUID for the site on + * Monitor My Watershed. * @param sendEveryX Interval (in units of the logging interval) between * attempted data transmissions. */ - EnviroDIYPublisher(Logger& baseLogger, const char* registrationToken, - const char* samplingFeatureUUID, int sendEveryX = 1); + MonitorMyWatershedPublisher(Logger& baseLogger, + const char* registrationToken, + const char* samplingFeatureUUID, + int sendEveryX = 1); /** - * @brief Construct a new EnviroDIY Publisher object + * @brief Construct a new Monitor My Watershed Publisher object * * @param baseLogger The logger supplying the data to be published - * @param registrationToken The registration token for the site on the - * Monitor My Watershed data portal. + * @param registrationToken The registration token for the site on Monitor + * My Watershed. * @param sendEveryX Interval (in units of the logging interval) between * attempted data transmissions. */ - EnviroDIYPublisher(Logger& baseLogger, const char* registrationToken, - int sendEveryX = 1); + MonitorMyWatershedPublisher(Logger& baseLogger, + const char* registrationToken, + int sendEveryX = 1); /** - * @brief Construct a new EnviroDIY Publisher object + * @brief Construct a new Monitor My Watershed Publisher object * * @param baseLogger The logger supplying the data to be published * @param inClient An Arduino client instance to use to print data to. * Allows the use of any type of client and multiple clients tied to a * single TinyGSM modem instance - * @param registrationToken The registration token for the site on the - * Monitor My Watershed data portal. - * @param samplingFeatureUUID The sampling feature UUID for the site on the - * Monitor My Watershed data portal. + * @param registrationToken The registration token for the site on Monitor + * My Watershed. + * @param samplingFeatureUUID The sampling feature UUID for the site on + * Monitor My Watershed. * @param sendEveryX Interval (in units of the logging interval) between * attempted data transmissions. */ - EnviroDIYPublisher(Logger& baseLogger, Client* inClient, - const char* registrationToken, - const char* samplingFeatureUUID, int sendEveryX = 1); + MonitorMyWatershedPublisher(Logger& baseLogger, Client* inClient, + const char* registrationToken, + const char* samplingFeatureUUID, + int sendEveryX = 1); /** - * @brief Construct a new EnviroDIY Publisher object + * @brief Construct a new Monitor My Watershed Publisher object * * @param baseLogger The logger supplying the data to be published * @param inClient An Arduino client instance to use to print data to. * Allows the use of any type of client and multiple clients tied to a * single TinyGSM modem instance - * @param registrationToken The registration token for the site on the - * Monitor My Watershed data portal. + * @param registrationToken The registration token for the site on Monitor + * My Watershed. * @param sendEveryX Interval (in units of the logging interval) between * attempted data transmissions. */ - EnviroDIYPublisher(Logger& baseLogger, Client* inClient, - const char* registrationToken, int sendEveryX = 1); + MonitorMyWatershedPublisher(Logger& baseLogger, Client* inClient, + const char* registrationToken, + int sendEveryX = 1); /** - * @brief Destroy the EnviroDIY Publisher object + * @brief Destroy the Monitor My Watershed Publisher object */ - virtual ~EnviroDIYPublisher(); + virtual ~MonitorMyWatershedPublisher(); // Returns the data destination String getEndpoint(void) override { - return String(enviroDIYHost) + String(enviroDIYPath); + return String(monitorMWHost) + String(monitorMWPath); } /** - * @brief Get the EnviroDIY/Monitor My Watershed web host + * @brief Get the Monitor My Watershed web host * - * @return The EnviroDIY/Monitor My Watershed web host + * @return The Monitor My Watershed web host */ String getHost(void); /** - * @brief Set the EnviroDIY/Monitor My Watershed web host + * @brief Set the Monitor My Watershed web host * - * @param host The EnviroDIY/Monitor My Watershed web host + * @param host The Monitor My Watershed web host */ void setHost(const char* host); /** - * @brief Get the EnviroDIY/Monitor My Watershed API path + * @brief Get the Monitor My Watershed API path * - * @return The EnviroDIY/Monitor My Watershed API path + * @return The Monitor My Watershed API path */ String getPath(void); /** - * @brief Set the EnviroDIY/Monitor My Watershed API path + * @brief Set the Monitor My Watershed API path * - * @param endpoint The EnviroDIY/Monitor My Watershed API path + * @param endpoint The Monitor My Watershed API path */ void setPath(const char* endpoint); /** - * @brief Get the EnviroDIY/Monitor My Watershed API port + * @brief Get the Monitor My Watershed API port * - * @return The EnviroDIY/Monitor My Watershed API port + * @return The Monitor My Watershed API port */ int getPort(void); /** - * @brief Set the EnviroDIY/Monitor My Watershed API port + * @brief Set the Monitor My Watershed API port * - * @param port The EnviroDIY/Monitor My Watershed API port + * @param port The Monitor My Watershed API port */ void setPort(int port); @@ -186,8 +192,8 @@ class EnviroDIYPublisher : public dataPublisher { /** * @brief Set the site registration token * - * @param registrationToken The registration token for the site on the - * Monitor My Watershed data portal. + * @param registrationToken The registration token for the site on Monitor + * My Watershed. */ void setToken(const char* registrationToken); @@ -201,26 +207,26 @@ class EnviroDIYPublisher : public dataPublisher { /** * @copydoc dataPublisher::begin(Logger& baseLogger, Client* inClient) - * @param registrationToken The registration token for the site on the - * Monitor My Watershed data portal. - * @param samplingFeatureUUID The sampling feature UUID for the site on the - * Monitor My Watershed data portal. + * @param registrationToken The registration token for the site on Monitor + * My Watershed. + * @param samplingFeatureUUID The sampling feature UUID for the site on + * Monitor My Watershed. */ void begin(Logger& baseLogger, Client* inClient, const char* registrationToken, const char* samplingFeatureUUID); /** * @copydoc dataPublisher::begin(Logger& baseLogger) - * @param registrationToken The registration token for the site on the - * Monitor My Watershed data portal. - * @param samplingFeatureUUID The sampling feature UUID for the site on the - * Monitor My Watershed data portal. + * @param registrationToken The registration token for the site on Monitor + * My Watershed. + * @param samplingFeatureUUID The sampling feature UUID for the site on + * Monitor My Watershed. */ void begin(Logger& baseLogger, const char* registrationToken, const char* samplingFeatureUUID); /** * @copydoc dataPublisher::begin(Logger& baseLogger) - * @param registrationToken The registration token for the site on the - * Monitor My Watershed data portal. + * @param registrationToken The registration token for the site on Monitor + * My Watershed. */ void begin(Logger& baseLogger, const char* registrationToken); @@ -233,9 +239,8 @@ class EnviroDIYPublisher : public dataPublisher { bool connectionNeeded(void) override; /** - * @brief Utilize an attached modem to open a a TCP connection to the - * EnviroDIY/ODM2DataSharingPortal and then stream out a post request over - * that connection. + * @brief Utilize an attached modem to open a a TCP connection to Monitor My + * Watershed and then stream out a post request over that connection. * * This depends on an internet connection already having been made and a * client being available. @@ -251,22 +256,22 @@ class EnviroDIYPublisher : public dataPublisher { protected: /** - * @anchor envirodiy_post_vars - * @name Portions of the POST request to EnviroDIY + * @anchor monitormw_post_vars + * @name Portions of the POST request to Monitor My Watershed * * @{ */ - const char* enviroDIYPath; ///< The api path - const char* enviroDIYHost; ///< The host name - int enviroDIYPort; ///< The host port + const char* monitorMWPath; ///< The api path + const char* monitorMWHost; ///< The host name + int monitorMWPort; ///< The host port static const char* tokenHeader; ///< The token header text static const char* contentLengthHeader; ///< The content length header text static const char* contentTypeHeader; ///< The content type header text /**@}*/ /** - * @anchor envirodiy_json_vars - * @name Portions of the JSON object for EnviroDIY + * @anchor monitormw_json_vars + * @name Portions of the JSON object for Monitor My Watershed * * @{ */ @@ -303,10 +308,9 @@ class EnviroDIYPublisher : public dataPublisher { private: /** - * @brief Internal reference to the EnviroDIY/Monitor My Watershed - * registration token. + * @brief Internal reference to the Monitor My Watershed registration token. */ const char* _registrationToken = nullptr; }; -#endif // SRC_PUBLISHERS_ENVIRODIYPUBLISHER_H_ +#endif // SRC_PUBLISHERS_MONITORMYWATERSHEDPUBLISHER_H_ diff --git a/src/publishers/ThingSpeakPublisher.cpp b/src/publishers/ThingSpeakPublisher.cpp index 81a224de7..a3c51b7a3 100644 --- a/src/publishers/ThingSpeakPublisher.cpp +++ b/src/publishers/ThingSpeakPublisher.cpp @@ -12,7 +12,7 @@ // ============================================================================ -// Functions for the EnviroDIY data portal receivers. +// Functions for ThingSpeak // ============================================================================ // Constant values for MQTT publish diff --git a/src/publishers/UbidotsPublisher.cpp b/src/publishers/UbidotsPublisher.cpp index 262e03d49..d8beecba1 100644 --- a/src/publishers/UbidotsPublisher.cpp +++ b/src/publishers/UbidotsPublisher.cpp @@ -106,11 +106,9 @@ void UbidotsPublisher::begin(Logger& baseLogger, } -// This utilizes an attached modem to make a TCP connection to the -// EnviroDIY/ODM2DataSharingPortal and then streams out a post request -// over that connection. -// The return is the http status code of the response. -// int16_t EnviroDIYPublisher::postDataEnviroDIY(void) +// This utilizes an attached modem to make a TCP connection to Ubidots and then +// streams out a post request over that connection. The return is the http +// status code of the response. int16_t UbidotsPublisher::publishData(Client* outClient, bool) { // Create a buffer for the portions of the request and response char tempBuffer[12] = ""; @@ -119,7 +117,7 @@ int16_t UbidotsPublisher::publishData(Client* outClient, bool) { if (_baseLogger->getSamplingFeatureUUID() == nullptr || strlen(_baseLogger->getSamplingFeatureUUID()) == 0) { PRINTOUT(F("A sampling feature UUID must be set before publishing data " - "to Monitor My Watershed!.")); + "to Ubidots!.")); return 0; } diff --git a/src/publishers/UbidotsPublisher.h b/src/publishers/UbidotsPublisher.h index e1efbc010..f383fa29e 100644 --- a/src/publishers/UbidotsPublisher.h +++ b/src/publishers/UbidotsPublisher.h @@ -35,7 +35,7 @@ // ============================================================================ -// Functions for the EnviroDIY data portal receivers. +// Functions for Ubidots // ============================================================================ /** * @brief The UbidotsPublisher subclass of dataPublisher for publishing data @@ -108,7 +108,7 @@ class UbidotsPublisher : public dataPublisher { const char* authenticationToken, const char* deviceID, int sendEveryX = 1); /** - * @brief Destroy the EnviroDIY Publisher object + * @brief Destroy the Ubidots Publisher object */ virtual ~UbidotsPublisher(); From fdc8f0f3847c738c58ac4eb1d46da148fa6a0054 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Thu, 12 Feb 2026 17:24:43 -0500 Subject: [PATCH 140/533] Add chunk for no modem Signed-off-by: Sara Damiano --- examples/menu_a_la_carte/menu_a_la_carte.ino | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/examples/menu_a_la_carte/menu_a_la_carte.ino b/examples/menu_a_la_carte/menu_a_la_carte.ino index 9518182b0..90a09e191 100644 --- a/examples/menu_a_la_carte/menu_a_la_carte.ino +++ b/examples/menu_a_la_carte/menu_a_la_carte.ino @@ -3994,6 +3994,16 @@ void loop() { F("V; high enough to log and publish data")); dataLogger.logDataAndPublish(); } +#else + } else { + // If the battery is good enough to log, log the data but we have no + // modem so we can't publish + PRINTOUT(F("Battery at"), + mcuBoard.sensorValues[PROCESSOR_BATTERY_VAR_NUM], + F("V; high enough to log data")); + dataLogger.logData(); + } +#endif } /** End [simple_loop] */ From 35d79d6ee2eb9253858fb84a24027ecd62a9742c Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Thu, 12 Feb 2026 17:58:24 -0500 Subject: [PATCH 141/533] Fix docs for new example Signed-off-by: Sara Damiano --- examples/EnviroDIY_Monitoring_Kit/ReadMe.md | 12 ++++++------ examples/ReadMe.md | 13 +++++++++++++ examples/examples.dox | 8 +++++--- examples/menu_a_la_carte/ReadMe.md | 4 ++-- src/sensors/ProcessorStats.h | 4 ++-- 5 files changed, 28 insertions(+), 13 deletions(-) diff --git a/examples/EnviroDIY_Monitoring_Kit/ReadMe.md b/examples/EnviroDIY_Monitoring_Kit/ReadMe.md index c6f1cf808..fa842de02 100644 --- a/examples/EnviroDIY_Monitoring_Kit/ReadMe.md +++ b/examples/EnviroDIY_Monitoring_Kit/ReadMe.md @@ -75,10 +75,10 @@ Customize the sketch for the version of the kit that you have: cellular, wifi, o In lines 31 and 32, select no more than one of the "bee" types that you will be using. -- Activate the modem you wish to use by _removing_ any slashes (```//```) before the bee module you will use. - - The line should start with ```#define``` -- Add two slashes (```//```) in front of the modem you are NOT using. -- If you are not using any internet connection, put two slashes (```//```) in front of both lines. +- Activate the modem you wish to use by _removing_ any slashes (`//`) before the bee module you will use. + - The line should start with `#define` +- Add two slashes (`//`) in front of the modem you are NOT using. +- If you are not using any internet connection, put two slashes (`//`) in front of both lines. ```cpp #define USE_WIFI_BEE @@ -87,10 +87,10 @@ In lines 31 and 32, select no more than one of the "bee" types that you will be #### Add Connection Info -Replace the ```your_..``` with the appropriate APN or SSID and password for your network. +Replace the `your_..` with the appropriate APN or SSID and password for your network. Your APN is assigned by your SIM card provider. -If you are using a Hologram SIM card (recommended with the kit) the APN is ```"hologram"```. +If you are using a Hologram SIM card (recommended with the kit) the APN is `"hologram"`. The SSID is the name of the wifi network. diff --git a/examples/ReadMe.md b/examples/ReadMe.md index d2bef16a3..59a8920c4 100644 --- a/examples/ReadMe.md +++ b/examples/ReadMe.md @@ -21,6 +21,8 @@ ___ - [Minimizing Cell Data Usage](#minimizing-cell-data-usage) - [Everything at Once - a la carte](#everything-at-once---a-la-carte) - [Menu a la carte](#menu-a-la-carte) + - [EnviroDIY Sensor Stations](#envirodiy-sensor-stations) + - [The EnviroDIY Sensor Station Kit](#the-envirodiy-sensor-station-kit) - [Examples for Outdated Hardware](#examples-for-outdated-hardware) - [Simple Logging for the Learn EnviroDIY course](#simple-logging-for-the-learn-envirodiy-course) - [DRWI Citizen Science](#drwi-citizen-science) @@ -127,6 +129,17 @@ This example is *NOT* intended to be run in its entirety ___ +## EnviroDIY Sensor Stations + +### The EnviroDIY Sensor Station Kit + +The The EnviroDIY Sensor Station Kit is designed to be used with the [EnviroDIY Monitoring Station Kit](https://www.envirodiy.org/product/envirodiy-monitoring-station-kit/). + +- [Instructions for the EnviroDIY sensor station kit example](https://envirodiy.github.io/ModularSensors/example_envirodiy_monitoring_kit.html) +- [The EnviroDIY sensor station kit example on GitHub](https://github.com/EnviroDIY/ModularSensors/tree/master/examples/example_envirodiy_monitoring_kit) + +___ + ## Examples for Outdated Hardware ### Simple Logging for the Learn EnviroDIY course diff --git a/examples/examples.dox b/examples/examples.dox index f069abcd1..3f5dd55d7 100644 --- a/examples/examples.dox +++ b/examples/examples.dox @@ -66,15 +66,17 @@ /** @page page_the_examples -@subpage examples_outdated "DELETE THIS LINK" +@subpage page_examples_outdated "DELETE THIS LINK" -@page examples_outdated Examples for Outdated Hardware +@page page_examples_outdated Examples for Outdated Hardware [Examples for Outdated Hardware](@ref examples_outdated) @subpage example_learn_envirodiy "DELETE THIS LINK" +*/ + /** -@page examples_outdated +@page page_examples_outdated @subpage page_examples_drwi "DELETE THIS LINK" diff --git a/examples/menu_a_la_carte/ReadMe.md b/examples/menu_a_la_carte/ReadMe.md index 6503ceaca..36f53c62b 100644 --- a/examples/menu_a_la_carte/ReadMe.md +++ b/examples/menu_a_la_carte/ReadMe.md @@ -600,7 +600,7 @@ ___ ## Sensors and Measured Variables -### The processor as a sensor +### The processor as a sensor Set options and create the objects for using the processor as a sensor to report battery level, processor free ram, and sample number. @@ -612,7 +612,7 @@ The number of "samples" taken will increase by one for each time another process @see @ref sensor_processor - + ___ diff --git a/src/sensors/ProcessorStats.h b/src/sensors/ProcessorStats.h index 7876ac320..d1a771e92 100644 --- a/src/sensors/ProcessorStats.h +++ b/src/sensors/ProcessorStats.h @@ -46,9 +46,9 @@ * ___ * @section sensor_processor_sensor_examples Example Code * The processor is used as a sensor in all of the examples, including the - * @menulink{processor_stats} example. + * @menulink{processor_sensor} example. * - * @menusnip{processor_stats} + * @menusnip{processor_sensor} */ /* clang-format on */ From 390becfd28f6feef04fba16e057ece1a010ca13e Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Thu, 12 Feb 2026 18:04:55 -0500 Subject: [PATCH 142/533] Fix snippet tags and build flags Signed-off-by: Sara Damiano --- build-menu-configurations.ps1 | 2 +- continuous_integration/generate_job_matrix.py | 2 +- examples/AWS_IoT_Core/AWS_IoT_Core.ino | 4 ++-- .../EnviroDIY_Monitoring_Kit/EnviroDIY_Monitoring_Kit.ino | 4 ++-- .../DRWI_CitizenScience/DRWI_2G/DRWI_2G.ino | 4 ++-- .../DRWI_CitizenScience/DRWI_DigiLTE/DRWI_DigiLTE.ino | 4 ++-- .../DRWI_CitizenScience/DRWI_Mayfly1/DRWI_Mayfly1.ino | 4 ++-- .../DRWI_Mayfly1_WiFi/DRWI_Mayfly1_WiFi.ino | 4 ++-- .../DRWI_CitizenScience/DRWI_NoCellular/DRWI_NoCellular.ino | 4 ++-- .../DRWI_CitizenScience/DRWI_SIM7080LTE/DRWI_SIM7080LTE.ino | 4 ++-- .../simple_logging_LearnEnviroDIY.ino | 4 ++-- examples/baro_rho_correction/baro_rho_correction.ino | 4 ++-- examples/data_saving/data_saving.ino | 4 ++-- examples/double_logger/double_logger.ino | 4 ++-- examples/logging_to_MMW/logging_to_MMW.ino | 4 ++-- examples/logging_to_ThingSpeak/logging_to_ThingSpeak.ino | 4 ++-- examples/menu_a_la_carte/menu_a_la_carte.ino | 6 +++--- examples/simple_logging/simple_logging.ino | 4 ++-- 18 files changed, 35 insertions(+), 35 deletions(-) diff --git a/build-menu-configurations.ps1 b/build-menu-configurations.ps1 index e606d30a6..c7ba51de9 100644 --- a/build-menu-configurations.ps1 +++ b/build-menu-configurations.ps1 @@ -145,7 +145,7 @@ Foreach ($sensorFlag in $sensorFlags) } $publisherFlag = @(` - 'BUILD_PUB_MONITOR_MW_PUBLISHER', ` + 'BUILD_PUB_MONITOR_MY_WATERSHED_PUBLISHER', ` 'BUILD_PUB_DREAM_HOST_PUBLISHER', ` 'BUILD_PUB_THING_SPEAK_PUBLISHER') diff --git a/continuous_integration/generate_job_matrix.py b/continuous_integration/generate_job_matrix.py index a3b8de97a..bf38c8b77 100644 --- a/continuous_integration/generate_job_matrix.py +++ b/continuous_integration/generate_job_matrix.py @@ -436,7 +436,7 @@ def extend_pio_config(added_envs): "NO_SENSORS", ] all_publisher_flags = [ - "BUILD_PUB_MONITOR_MW_PUBLISHER", + "BUILD_PUB_MONITOR_MY_WATERSHED_PUBLISHER", ] diff --git a/examples/AWS_IoT_Core/AWS_IoT_Core.ino b/examples/AWS_IoT_Core/AWS_IoT_Core.ino index f9a4fcc0b..265cbc10f 100644 --- a/examples/AWS_IoT_Core/AWS_IoT_Core.ino +++ b/examples/AWS_IoT_Core/AWS_IoT_Core.ino @@ -132,7 +132,7 @@ EspressifESP32 modem = modemESP; // ========================================================================== // Using the Processor as a Sensor // ========================================================================== -/** Start [processor_sensor] */ +/** Start [processor_stats] */ #include // Create the main processor chip "sensor" - for general metadata @@ -144,7 +144,7 @@ const char* mcuBoardVersion = "v1.1"; const char* mcuBoardVersion = "unknown"; #endif ProcessorStats mcuBoard(mcuBoardVersion, 5); -/** End [processor_sensor] */ +/** End [processor_stats] */ // ========================================================================== diff --git a/examples/EnviroDIY_Monitoring_Kit/EnviroDIY_Monitoring_Kit.ino b/examples/EnviroDIY_Monitoring_Kit/EnviroDIY_Monitoring_Kit.ino index ff2b3cb38..70d57e4e7 100644 --- a/examples/EnviroDIY_Monitoring_Kit/EnviroDIY_Monitoring_Kit.ino +++ b/examples/EnviroDIY_Monitoring_Kit/EnviroDIY_Monitoring_Kit.ino @@ -236,13 +236,13 @@ SIMComSIM7080 modem = modem7080; // ========================================================================== // Using the Processor as a Sensor // ========================================================================== -/** Start [processor_sensor] */ +/** Start [processor_stats] */ #include // Create the main processor chip "sensor" - for general metadata const char* mcuBoardVersion = "v1.1"; ProcessorStats mcuBoard(mcuBoardVersion, 5); -/** End [processor_sensor] */ +/** End [processor_stats] */ // ========================================================================== diff --git a/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_2G/DRWI_2G.ino b/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_2G/DRWI_2G.ino index ca272a346..0094f6723 100644 --- a/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_2G/DRWI_2G.ino +++ b/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_2G/DRWI_2G.ino @@ -96,13 +96,13 @@ Sodaq2GBeeR6 modem = modem2GB; // ========================================================================== // Using the Processor as a Sensor // ========================================================================== -/** Start [processor_sensor] */ +/** Start [processor_stats] */ #include // Create the main processor chip "sensor" - for general metadata const char* mcuBoardVersion = "v0.5b"; ProcessorStats mcuBoard(mcuBoardVersion); -/** End [processor_sensor] */ +/** End [processor_stats] */ // ========================================================================== diff --git a/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_DigiLTE/DRWI_DigiLTE.ino b/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_DigiLTE/DRWI_DigiLTE.ino index 4c25ba7ed..cce098eec 100644 --- a/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_DigiLTE/DRWI_DigiLTE.ino +++ b/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_DigiLTE/DRWI_DigiLTE.ino @@ -104,13 +104,13 @@ DigiXBeeCellularTransparent modem = modemXBCT; // ========================================================================== // Using the Processor as a Sensor // ========================================================================== -/** Start [processor_sensor] */ +/** Start [processor_stats] */ #include // Create the main processor chip "sensor" - for general metadata const char* mcuBoardVersion = "v0.5b"; ProcessorStats mcuBoard(mcuBoardVersion); -/** End [processor_sensor] */ +/** End [processor_stats] */ // ========================================================================== diff --git a/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_Mayfly1/DRWI_Mayfly1.ino b/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_Mayfly1/DRWI_Mayfly1.ino index 901f08100..d370764fa 100644 --- a/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_Mayfly1/DRWI_Mayfly1.ino +++ b/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_Mayfly1/DRWI_Mayfly1.ino @@ -110,13 +110,13 @@ SIMComSIM7080 modem = modem7080; // ========================================================================== // Using the Processor as a Sensor // ========================================================================== -/** Start [processor_sensor] */ +/** Start [processor_stats] */ #include // Create the main processor chip "sensor" - for general metadata const char* mcuBoardVersion = "v1.1"; ProcessorStats mcuBoard(mcuBoardVersion); -/** End [processor_sensor] */ +/** End [processor_stats] */ // ========================================================================== diff --git a/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_Mayfly1_WiFi/DRWI_Mayfly1_WiFi.ino b/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_Mayfly1_WiFi/DRWI_Mayfly1_WiFi.ino index 2bede798e..39beff0eb 100644 --- a/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_Mayfly1_WiFi/DRWI_Mayfly1_WiFi.ino +++ b/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_Mayfly1_WiFi/DRWI_Mayfly1_WiFi.ino @@ -103,13 +103,13 @@ EspressifESP32 modem = modemESP; // ========================================================================== // Using the Processor as a Sensor // ========================================================================== -/** Start [processor_sensor] */ +/** Start [processor_stats] */ #include // Create the main processor chip "sensor" - for general metadata const char* mcuBoardVersion = "v1.1"; ProcessorStats mcuBoard(mcuBoardVersion); -/** End [processor_sensor] */ +/** End [processor_stats] */ // ========================================================================== diff --git a/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_NoCellular/DRWI_NoCellular.ino b/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_NoCellular/DRWI_NoCellular.ino index 77a0a0f40..6c22ddd7a 100644 --- a/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_NoCellular/DRWI_NoCellular.ino +++ b/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_NoCellular/DRWI_NoCellular.ino @@ -55,13 +55,13 @@ const int8_t sensorPowerPin = 22; // MCU pin controlling main sensor power // ========================================================================== // Using the Processor as a Sensor // ========================================================================== -/** Start [processor_sensor] */ +/** Start [processor_stats] */ #include // Create the main processor chip "sensor" - for general metadata const char* mcuBoardVersion = "v1.1"; ProcessorStats mcuBoard(mcuBoardVersion); -/** End [processor_sensor] */ +/** End [processor_stats] */ // ========================================================================== diff --git a/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_SIM7080LTE/DRWI_SIM7080LTE.ino b/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_SIM7080LTE/DRWI_SIM7080LTE.ino index 126af0fec..b4d0589ea 100644 --- a/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_SIM7080LTE/DRWI_SIM7080LTE.ino +++ b/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_SIM7080LTE/DRWI_SIM7080LTE.ino @@ -111,13 +111,13 @@ SIMComSIM7080 modem = modem7080; // ========================================================================== // Using the Processor as a Sensor // ========================================================================== -/** Start [processor_sensor] */ +/** Start [processor_stats] */ #include // Create the main processor chip "sensor" - for general metadata const char* mcuBoardVersion = "v1.1"; ProcessorStats mcuBoard(mcuBoardVersion); -/** End [processor_sensor] */ +/** End [processor_stats] */ // ========================================================================== diff --git a/examples/OutdatedExamples/simple_logging_LearnEnviroDIY/simple_logging_LearnEnviroDIY.ino b/examples/OutdatedExamples/simple_logging_LearnEnviroDIY/simple_logging_LearnEnviroDIY.ino index 5493f6868..0d66d565b 100644 --- a/examples/OutdatedExamples/simple_logging_LearnEnviroDIY/simple_logging_LearnEnviroDIY.ino +++ b/examples/OutdatedExamples/simple_logging_LearnEnviroDIY/simple_logging_LearnEnviroDIY.ino @@ -57,13 +57,13 @@ const int8_t sensorPowerPin = 22; // MCU pin controlling main sensor power // ========================================================================== // Using the Processor as a Sensor // ========================================================================== -/** Start [processor_sensor] */ +/** Start [processor_stats] */ #include // Create the main processor chip "sensor" - for general metadata const char* mcuBoardVersion = "v1.1"; ProcessorStats mcuBoard(mcuBoardVersion); -/** End [processor_sensor] */ +/** End [processor_stats] */ // ========================================================================== diff --git a/examples/baro_rho_correction/baro_rho_correction.ino b/examples/baro_rho_correction/baro_rho_correction.ino index 30e3837d6..af426a659 100644 --- a/examples/baro_rho_correction/baro_rho_correction.ino +++ b/examples/baro_rho_correction/baro_rho_correction.ino @@ -109,7 +109,7 @@ Variable* modemSignalPct = new Modem_SignalPercent( // ========================================================================== // Using the Processor as a Sensor // ========================================================================== -/** Start [processor_sensor] */ +/** Start [processor_stats] */ #include // Create the main processor chip "sensor" - for general metadata @@ -124,7 +124,7 @@ Variable* mcuBoardAvailableRAM = new ProcessorStats_FreeRam( &mcuBoard, "12345678-abcd-1234-ef00-1234567890ab"); Variable* mcuBoardSampNo = new ProcessorStats_SampleNumber( &mcuBoard, "12345678-abcd-1234-ef00-1234567890ab"); -/** End [processor_sensor] */ +/** End [processor_stats] */ // ========================================================================== diff --git a/examples/data_saving/data_saving.ino b/examples/data_saving/data_saving.ino index 067d92192..308727b5b 100644 --- a/examples/data_saving/data_saving.ino +++ b/examples/data_saving/data_saving.ino @@ -147,7 +147,7 @@ Variable* modemSignalPct = // ========================================================================== // Using the Processor as a Sensor // ========================================================================== -/** Start [processor_sensor] */ +/** Start [processor_stats] */ #include // Create the main processor chip "sensor" - for general metadata @@ -162,7 +162,7 @@ Variable* mcuBoardAvailableRAM = new ProcessorStats_FreeRam( &mcuBoard, "12345678-abcd-1234-ef00-1234567890ab"); Variable* mcuBoardSampNo = new ProcessorStats_SampleNumber( &mcuBoard, "12345678-abcd-1234-ef00-1234567890ab"); -/** End [processor_sensor] */ +/** End [processor_stats] */ // ========================================================================== diff --git a/examples/double_logger/double_logger.ino b/examples/double_logger/double_logger.ino index 12e6fb49c..903d6e01e 100644 --- a/examples/double_logger/double_logger.ino +++ b/examples/double_logger/double_logger.ino @@ -103,13 +103,13 @@ DigiXBeeWifi modem = modemXBWF; // ========================================================================== // Using the Processor as a Sensor // ========================================================================== -/** Start [processor_sensor] */ +/** Start [processor_stats] */ #include // Create the main processor chip "sensor" - for general metadata const char* mcuBoardVersion = "v1.1"; ProcessorStats mcuBoard(mcuBoardVersion); -/** End [processor_sensor] */ +/** End [processor_stats] */ // ========================================================================== diff --git a/examples/logging_to_MMW/logging_to_MMW.ino b/examples/logging_to_MMW/logging_to_MMW.ino index 4c7236c07..94bab98e9 100644 --- a/examples/logging_to_MMW/logging_to_MMW.ino +++ b/examples/logging_to_MMW/logging_to_MMW.ino @@ -105,13 +105,13 @@ DigiXBeeCellularTransparent modem = modemXBCT; // ========================================================================== // Using the Processor as a Sensor // ========================================================================== -/** Start [processor_sensor] */ +/** Start [processor_stats] */ #include // Create the main processor chip "sensor" - for general metadata const char* mcuBoardVersion = "v1.1"; ProcessorStats mcuBoard(mcuBoardVersion); -/** End [processor_sensor] */ +/** End [processor_stats] */ // ========================================================================== diff --git a/examples/logging_to_ThingSpeak/logging_to_ThingSpeak.ino b/examples/logging_to_ThingSpeak/logging_to_ThingSpeak.ino index 709050edf..31b37f2bd 100644 --- a/examples/logging_to_ThingSpeak/logging_to_ThingSpeak.ino +++ b/examples/logging_to_ThingSpeak/logging_to_ThingSpeak.ino @@ -102,13 +102,13 @@ EspressifESP8266 modem = modemESP; // ========================================================================== // Using the Processor as a Sensor // ========================================================================== -/** Start [processor_sensor] */ +/** Start [processor_stats] */ #include // Create the main processor chip "sensor" - for general metadata const char* mcuBoardVersion = "v1.1"; ProcessorStats mcuBoard(mcuBoardVersion); -/** End [processor_sensor] */ +/** End [processor_stats] */ // ========================================================================== diff --git a/examples/menu_a_la_carte/menu_a_la_carte.ino b/examples/menu_a_la_carte/menu_a_la_carte.ino index 90a09e191..909af5af6 100644 --- a/examples/menu_a_la_carte/menu_a_la_carte.ino +++ b/examples/menu_a_la_carte/menu_a_la_carte.ino @@ -960,7 +960,7 @@ Variable* modemTemperature = // ========================================================================== // Using the Processor as a Sensor // ========================================================================== -/** Start [processor_sensor] */ +/** Start [processor_stats] */ #include // Create the main processor chip "sensor" - for general metadata @@ -983,7 +983,7 @@ Variable* mcuBoardSampNo = new ProcessorStats_SampleNumber( &mcuBoard, "12345678-abcd-1234-ef00-1234567890ab"); Variable* mcuBoardReset = new ProcessorStats_ResetCode( &mcuBoard, "12345678-abcd-1234-ef00-1234567890ab"); -/** End [processor_sensor] */ +/** End [processor_stats] */ #if defined(MS_USE_DS3231) @@ -3344,7 +3344,7 @@ VariableArray varArray(variableCount, variableList); #endif -#if defined(BUILD_PUB_MONITOR_MW_PUBLISHER) && \ +#if defined(BUILD_PUB_MONITOR_MY_WATERSHED_PUBLISHER) && \ (!defined(BUILD_MODEM_NO_MODEM) && defined(BUILD_HAS_MODEM)) // ========================================================================== // A Publisher to Monitor My Watershed diff --git a/examples/simple_logging/simple_logging.ino b/examples/simple_logging/simple_logging.ino index 5d47ad7c7..889f9fe47 100644 --- a/examples/simple_logging/simple_logging.ino +++ b/examples/simple_logging/simple_logging.ino @@ -57,13 +57,13 @@ const int8_t sensorPowerPin = 22; // MCU pin controlling main sensor power // ========================================================================== // Using the Processor as a Sensor // ========================================================================== -/** Start [processor_sensor] */ +/** Start [processor_stats] */ #include // Create the main processor chip "sensor" - for general metadata const char* mcuBoardVersion = "v1.1"; ProcessorStats mcuBoard(mcuBoardVersion); -/** End [processor_sensor] */ +/** End [processor_stats] */ // ========================================================================== From 5fd5c31931222c5ab210774a3160ed50b05de39d Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Thu, 12 Feb 2026 18:06:28 -0500 Subject: [PATCH 143/533] Fix job matrix script Signed-off-by: Sara Damiano --- continuous_integration/generate_job_matrix.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/continuous_integration/generate_job_matrix.py b/continuous_integration/generate_job_matrix.py index bf38c8b77..8d1c9292d 100644 --- a/continuous_integration/generate_job_matrix.py +++ b/continuous_integration/generate_job_matrix.py @@ -102,7 +102,7 @@ pio_to_acli = json.load(f) # Find all of the non-menu examples -examples_to_build = [] +non_menu_examples = [] for root, subdirs, files in os.walk(examples_path): for filename in files: file_path = os.path.join(root, filename) @@ -113,7 +113,7 @@ "tests", menu_example_name, ]: - examples_to_build.append(os.path.relpath(root, workspace_path)) + non_menu_examples.append(os.path.relpath(root, workspace_path)) if use_verbose: print(f"::debug::\t- example: {filename} (full path: {file_path})") From e81b7ce3c699cb49429d3a176f24e6f82c31e40c Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Thu, 12 Feb 2026 18:08:39 -0500 Subject: [PATCH 144/533] Another snipppet tag fix Signed-off-by: Sara Damiano --- examples/menu_a_la_carte/ReadMe.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/menu_a_la_carte/ReadMe.md b/examples/menu_a_la_carte/ReadMe.md index 36f53c62b..6503ceaca 100644 --- a/examples/menu_a_la_carte/ReadMe.md +++ b/examples/menu_a_la_carte/ReadMe.md @@ -600,7 +600,7 @@ ___ ## Sensors and Measured Variables -### The processor as a sensor +### The processor as a sensor Set options and create the objects for using the processor as a sensor to report battery level, processor free ram, and sample number. @@ -612,7 +612,7 @@ The number of "samples" taken will increase by one for each time another process @see @ref sensor_processor - + ___ From cc6a5c4a86ac0970dc4587bcd7e051482f84163e Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Thu, 12 Feb 2026 18:15:14 -0500 Subject: [PATCH 145/533] Another job matrix fix Signed-off-by: Sara Damiano --- continuous_integration/generate_job_matrix.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/continuous_integration/generate_job_matrix.py b/continuous_integration/generate_job_matrix.py index 8d1c9292d..03f18fbdc 100644 --- a/continuous_integration/generate_job_matrix.py +++ b/continuous_integration/generate_job_matrix.py @@ -113,7 +113,7 @@ "tests", menu_example_name, ]: - non_menu_examples.append(os.path.relpath(root, workspace_path)) + non_menu_examples.append(os.path.realpath(root)) if use_verbose: print(f"::debug::\t- example: {filename} (full path: {file_path})") From ce073318f253120e2ac48ad814eba36ebb827b48 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Thu, 12 Feb 2026 18:17:31 -0500 Subject: [PATCH 146/533] Yet another snippet tag fix Signed-off-by: Sara Damiano --- src/sensors/ProcessorStats.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/sensors/ProcessorStats.h b/src/sensors/ProcessorStats.h index d1a771e92..baa3ccf47 100644 --- a/src/sensors/ProcessorStats.h +++ b/src/sensors/ProcessorStats.h @@ -40,15 +40,15 @@ * - [Atmel ATmega16U4 32U4 Datasheet Summary](https://github.com/EnviroDIY/ModularSensors/wiki/Processor-Datasheets/Atmel-ATmega16U4-32U4-Datasheet-Summary.pdf) * - [Atmel ATmega16U4 32U4 Datasheet](https://github.com/EnviroDIY/ModularSensors/wiki/Processor-Datasheets/Atmel-ATmega16U4-32U4-Datasheet.pdf) * - * @section sensor_processor_sensor_ctor Sensor Constructor + * @section sensor_processor_stats_ctor Sensor Constructor * {{ @ref ProcessorStats::ProcessorStats }} * * ___ - * @section sensor_processor_sensor_examples Example Code + * @section sensor_processor_stats_examples Example Code * The processor is used as a sensor in all of the examples, including the - * @menulink{processor_sensor} example. + * @menulink{processor_stats} example. * - * @menusnip{processor_sensor} + * @menusnip{processor_stats} */ /* clang-format on */ @@ -122,7 +122,7 @@ /**@}*/ /** - * @anchor sensor_processor_sensor_timing + * @anchor sensor_processor_stats_timing * @name Sensor Timing * The sensor timing for the processor/mcu * - Timing variables do not apply to the processor in the same way they do to From c23379af0303f952d2ed8feb66781c1817c6fb3e Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Thu, 12 Feb 2026 18:20:10 -0500 Subject: [PATCH 147/533] Skip "data_saving" properly Signed-off-by: Sara Damiano --- continuous_integration/generate_job_matrix.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/continuous_integration/generate_job_matrix.py b/continuous_integration/generate_job_matrix.py index 03f18fbdc..9b7204da9 100644 --- a/continuous_integration/generate_job_matrix.py +++ b/continuous_integration/generate_job_matrix.py @@ -314,7 +314,7 @@ def snake_to_camel(snake_str): compilers, [arduino_ex_commands, pio_ex_commands] ): # Skip examples that need to be updated or don't apply - if example == "data_saving": + if "data_saving" in example.lower(): continue # skip until updated if "mayfly" in example.lower() and pio_env != "mayfly": continue # skip mayfly examples on non-mayfly builds From 3e333b3343ed14f29c53a24ac9557e826a7a02c8 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Fri, 13 Feb 2026 10:14:02 -0500 Subject: [PATCH 148/533] Remove the non-functional data-saving example Signed-off-by: Sara Damiano --- docs/FAQ/Power-Parasites.md | 2 - docs/Getting-Started/Getting-Started.md | 2 - examples/ReadMe.md | 10 - examples/data_saving/ReadMe.md | 82 ---- examples/data_saving/data_saving.ino | 617 ------------------------ examples/data_saving/platformio.ini | 40 -- examples/examples.dox | 2 - examples/menu_a_la_carte/ReadMe.md | 1 - 8 files changed, 756 deletions(-) delete mode 100644 examples/data_saving/ReadMe.md delete mode 100644 examples/data_saving/data_saving.ino delete mode 100644 examples/data_saving/platformio.ini diff --git a/docs/FAQ/Power-Parasites.md b/docs/FAQ/Power-Parasites.md index f0754c968..34ee0d4c1 100644 --- a/docs/FAQ/Power-Parasites.md +++ b/docs/FAQ/Power-Parasites.md @@ -21,5 +21,3 @@ This means I2C parasitic power draw is best solved via hardware, not software. - Use a generic opto-isolator or other type of isolator on both the SCL and SDA lines - In this future, this library _may_ offer the option of using software I2C, which would allow you to use the same technique as is currently usable to stop serial parasitic draw. Until such an update happens, however, hardware solutions are required. - -The ["data_saving"](@todo add link to loop of data saving example) example shows setting ending a serial stream and setting pins low to prevent an RS485 adapter from drawing power during sleep. diff --git a/docs/Getting-Started/Getting-Started.md b/docs/Getting-Started/Getting-Started.md index 01224dcae..5270fe4c9 100644 --- a/docs/Getting-Started/Getting-Started.md +++ b/docs/Getting-Started/Getting-Started.md @@ -143,8 +143,6 @@ It also includes a Meter Hydros 21 (formerly know as a Decagon CTD) and a Campbe - [double_logger](https://github.com/EnviroDIY/ModularSensors/tree/master/examples/double_logger) - This is a more complicated example using two different logger instances to log data at two different intervals, in this case, an AM3215 logging every minute, while checking the battery voltage only every 5 minutes. This showcases both how to use two different logging instances and how to use some of the functions to set up your own logging loop rather than using the logData() function. -- [data_saving](https://github.com/EnviroDIY/ModularSensors/tree/master/examples/) - - This is another double logger example, but in this case, both loggers are going at the same interval and the only difference between the loggers is the list of variables. There are two sets of variables, all coming from Yosemitech sensors. Because each sensor outputs temperature and we don't want to waste cellular data sending out multiple nearly identical temperature values, we have one logger that logs every possible variable result to the SD card and another logger that sends only unique results to Monitor My Watershed. This example also shows how to stop power draw from an RS485 adapter with automatic flow detection. diff --git a/examples/ReadMe.md b/examples/ReadMe.md index 59a8920c4..85c8c5b41 100644 --- a/examples/ReadMe.md +++ b/examples/ReadMe.md @@ -100,16 +100,6 @@ This showcases both how to use two different logging instances and how to use so - [Instructions for the double logger example](https://envirodiy.github.io/ModularSensors/example_double_log.html) - [The double logger example on GitHub](https://github.com/EnviroDIY/ModularSensors/tree/master/examples/double_logger) -### Minimizing Cell Data Usage - -The data saving example is another double logger example, but in this case, both loggers are going at the same interval and the only difference between the loggers is the list of variables. -There are two sets of variables, all coming from Yosemitech sensors. -Because each sensor outputs temperature and we don't want to waste cellular data sending out multiple nearly identical temperature values, we have one logger that logs every possible variable result to the SD card and another logger that sends only unique results to Monitor My Watershed. -This example also shows how to stop power draw from an RS485 adapter with automatic flow detection. - -- [Instructions for the data saving example](https://envirodiy.github.io/ModularSensors/example_data_saving.html) -- [The data saving example on GitHub](https://github.com/EnviroDIY/ModularSensors/tree/master/examples/data_saving) - ___ ## Everything at Once - a la carte diff --git a/examples/data_saving/ReadMe.md b/examples/data_saving/ReadMe.md deleted file mode 100644 index 55b0e0ccd..000000000 --- a/examples/data_saving/ReadMe.md +++ /dev/null @@ -1,82 +0,0 @@ -# Minimizing Cellular Data Use - -This is another double logger example, but in this case, both loggers are going at the same interval and the only difference between the loggers is the list of variables. -There are two sets of variables, all coming from Yosemitech sensors. -Because each sensor outputs temperature and we don't want to waste cellular data sending out multiple nearly identical temperature values, we have one logger that logs every possible variable result to the SD card and another logger that sends only unique results to [Monitor My Watershed](https://monitormywatershed.org/). - -The modem used in this example is a SIM800 based Sodaq GPRSBee r6. - -The sensors used in this example are Yosemitech Y504 Dissolved Oxygen Sensor, Yosemitech Y511 Turbidity Sensor with Wiper, Yosemitech Y514 Chlorophyll Sensor, and Yosemitech Y520 Conductivity Sensor. - -_______ - - - - - - - -- [Minimizing Cellular Data Use](#minimizing-cellular-data-use) - - [Unique Features of the Data Saving Example](#unique-features-of-the-data-saving-example) - - [To Use this Example](#to-use-this-example) - - [Prepare and set up PlatformIO](#prepare-and-set-up-platformio) - - [Set the logger ID](#set-the-logger-id) - - [Set the universally universal identifiers (UUID) for each variable](#set-the-universally-universal-identifiers-uuid-for-each-variable) - - [Upload!](#upload) - - - -_______ - -## Unique Features of the Data Saving Example - -- Uses AltSoftSerial to create an additional serial port for RS485 communication. -- All variables are created and named with their parent sensor (as opposed to being created within the variable array). -- Two different variable arrays and loggers are created and used. - - Many of the same variables are used in both arrays. - - Only one of the loggers publishes data. -- The `loop` function is expanded into its components rather than using the `logData` functions. - - This demonstrates *how* to write the loop out, without using the `logData` functions. - - It also shows how to forcibly set serial pins `LOW` at the start and end of the loop in order to prevent power loss through an RS485 adapter. - -## To Use this Example - -### Prepare and set up PlatformIO - -- Register a site and sensors on [Monitor My Watershed](https://monitormywatershed.org/) -- Create a new PlatformIO project -- Replace the contents of the platformio.ini for your new project with the [platformio.ini](https://raw.githubusercontent.com/EnviroDIY/ModularSensors/master/examples/data_saving/platformio.ini) file in the examples/data_saving folder on GitHub. - - It is important that your PlatformIO configuration has the lib_ldf_mode and build flags set as they are in the example. - - Without this, the program won't compile. -- Open [data_saving.ino](https://raw.githubusercontent.com/EnviroDIY/ModularSensors/master/examples/data_saving/data_saving.ino) and save it to your computer. - - After opening the link, you should be able to right click anywhere on the page and select "Save Page As". - - Move it into the src directory of your project. - - Delete main.cpp in that folder. - -### Set the logger ID - -- Change the "XXXX" in this section of code to the loggerID assigned by Stroud: - -```cpp -// Logger ID, also becomes the prefix for the name of the data file on SD card -const char *LoggerID = "XXXX"; -``` - -### Set the universally universal identifiers (UUID) for each variable - -- Go back to the web page for your site on [Monitor My Watershed](https://monitormywatershed.org/) -- For each variable, find the dummy UUID (`"12345678-abcd-1234-ef00-1234567890ab"`) and replace it with the real UUID for the variable. - -### Upload! - -- Test everything at home **before** deploying out in the wild! - -_______ - - - - - - - - diff --git a/examples/data_saving/data_saving.ino b/examples/data_saving/data_saving.ino deleted file mode 100644 index 308727b5b..000000000 --- a/examples/data_saving/data_saving.ino +++ /dev/null @@ -1,617 +0,0 @@ -/** ========================================================================= - * @example{lineno} data_saving.ino - * @copyright Stroud Water Research Center - * @license This example is published under the BSD-3 license. - * @author Sara Geleskie Damiano - * - * @brief Example publishing only a portion of the logged variables. - * - * See [the walkthrough page](@ref example_data_saving) for detailed - * instructions. - * - * @m_examplenavigation{example_data_saving,} - * ======================================================================= */ - -// ========================================================================== -// Defines for TinyGSM -// ========================================================================== -/** Start [defines] */ -#ifndef TINY_GSM_RX_BUFFER -#define TINY_GSM_RX_BUFFER 64 -#endif -#ifndef TINY_GSM_YIELD_MS -#define TINY_GSM_YIELD_MS 2 -#endif -/** End [defines] */ - - -// ========================================================================== -// Include the libraries required for any data logger -// ========================================================================== -/** Start [includes] */ -// The Arduino library is needed for every Arduino program. -#include - -// Include the main header for ModularSensors -#include -/** End [includes] */ - - -// ========================================================================== -// Creating Additional Serial Ports -// ========================================================================== -/** Start [serial_ports] */ -// The modem and a number of sensors communicate over UART/TTL - often called -// "serial". "Hardware" serial ports (automatically controlled by the MCU) are -// generally the most accurate and should be configured and used for as many -// peripherals as possible. In some cases (ie, modbus communication) many -// sensors can share the same serial port. - -// For AVR boards -#if !defined(ARDUINO_ARCH_SAMD) && !defined(ATMEGA2560) -// Unfortunately, most AVR boards have only one or two hardware serial ports, -// so we'll set up three types of extra software serial ports to use - -// AltSoftSerial by Paul Stoffregen -// (https://github.com/PaulStoffregen/AltSoftSerial) is the most accurate -// software serial port for AVR boards. AltSoftSerial can only be used on one -// set of pins on each board so only one AltSoftSerial port can be used. Not all -// AVR boards are supported by AltSoftSerial. -#include -AltSoftSerial altSoftSerial; -#endif // End software serial for avr boards - -#if defined(ARDUINO_SAMD_FEATHER_M0) -#include // Needed for SAMD pinPeripheral() function - -// Set up a 'new' UART using SERCOM1 -// The Rx will be on digital pin 11, which is SERCOM1's Pad #0 -// The Tx will be on digital pin 10, which is SERCOM1's Pad #2 -// NOTE: SERCOM1 is undefined on a "standard" Arduino Zero and many clones, -// but not all! Please check the variant.cpp file for you individual -// board! -Uart Serial2(&sercom1, 11, 10, SERCOM_RX_PAD_0, UART_TX_PAD_2); -// Hand over the interrupts to the sercom port -void SERCOM1_Handler() { - Serial2.IrqHandler(); -} -#define ENABLE_SERIAL2 - -#endif // End hardware serial on SAMD21 boards -/** End [serial_ports] */ - - -// ========================================================================== -// Data Logging Options -// ========================================================================== -/** Start [logging_options] */ -// The name of this program file -const char* sketchName = "data_saving.ino"; -// Logger ID, also becomes the prefix for the name of the data file on SD card -const char* LoggerID = "XXXXX"; -// How frequently (in minutes) to log data -const int8_t loggingInterval = 15; -// Your logger's timezone. -const int8_t timeZone = -5; // Eastern Standard Time -// NOTE: Daylight savings time will not be applied! Please use standard time! - -// Set the input and output pins for the logger -// NOTE: Use -1 for pins that do not apply -const int32_t serialBaud = 115200; // Baud rate for debugging -const int8_t greenLED = 8; // Pin for the green LED -const int8_t redLED = 9; // Pin for the red LED -const int8_t buttonPin = 21; // Pin for debugging mode (ie, button pin) -const int8_t wakePin = 31; // MCU interrupt/alarm pin to wake from sleep -// Mayfly 0.x, 1.x D31 = A7 -// Set the wake pin to -1 if you do not want the main processor to sleep. -// In a SAMD system where you are using the built-in rtc, set wakePin to 1 -const int8_t sdCardPwrPin = -1; // MCU SD card power pin -const int8_t sdCardSSPin = 12; // SD card chip select/slave select pin -const int8_t sensorPowerPin = 22; // MCU pin controlling main sensor power -/** End [logging_options] */ - - -// ========================================================================== -// Wifi/Cellular Modem Options -// ========================================================================== -/** Start [sodaq_2g_bee_r6] */ -// For the Sodaq 2GBee R6 and R7 based on the SIMCom SIM800 -// NOTE: The Sodaq GPRSBee doesn't expose the SIM800's reset pin -#include -// Create a reference to the serial port for the modem -HardwareSerial& modemSerial = Serial1; // Use hardware serial if possible -const int32_t modemBaud = 9600; // SIM800 does auto-bauding by default - -// Modem Pins - Describe the physical pin connection of your modem to your board -// NOTE: Use -1 for pins that do not apply -const int8_t modemVccPin = 23; // MCU pin controlling modem power -const int8_t modemStatusPin = 19; // MCU pin used to read modem status -const int8_t modemLEDPin = redLED; // MCU pin connected an LED to show modem - // status (-1 if unconnected) - -// Network connection information -const char* apn = "xxxxx"; // The APN for the gprs connection - -Sodaq2GBeeR6 modem2GB(&modemSerial, modemVccPin, modemStatusPin, apn); -// Create an extra reference to the modem by a generic name -Sodaq2GBeeR6 modem = modem2GB; - -// Create RSSI and signal strength variable pointers for the modem -Variable* modemRSSI = new Modem_RSSI(&modem, - "12345678-abcd-1234-ef00-1234567890ab"); -Variable* modemSignalPct = - new Modem_SignalPercent(&modem, "12345678-abcd-1234-ef00-1234567890ab"); -/** End [sodaq_2g_bee_r6] */ - - -// ========================================================================== -// Using the Processor as a Sensor -// ========================================================================== -/** Start [processor_stats] */ -#include - -// Create the main processor chip "sensor" - for general metadata -const char* mcuBoardVersion = "v1.1"; -ProcessorStats mcuBoard(mcuBoardVersion); - -// Create sample number, battery voltage, and free RAM variable pointers for the -// processor -Variable* mcuBoardBatt = new ProcessorStats_Battery( - &mcuBoard, "12345678-abcd-1234-ef00-1234567890ab"); -Variable* mcuBoardAvailableRAM = new ProcessorStats_FreeRam( - &mcuBoard, "12345678-abcd-1234-ef00-1234567890ab"); -Variable* mcuBoardSampNo = new ProcessorStats_SampleNumber( - &mcuBoard, "12345678-abcd-1234-ef00-1234567890ab"); -/** End [processor_stats] */ - - -// ========================================================================== -// Maxim DS3231 RTC (Real Time Clock) -// ========================================================================== -/** Start [ds3231] */ -#include - -// Create a DS3231 sensor object -MaximDS3231 ds3231(1); - -// Create a temperature variable pointer for the DS3231 -Variable* ds3231Temp = - new MaximDS3231_Temp(&ds3231, "12345678-abcd-1234-ef00-1234567890ab"); -/** End [ds3231] */ - - -// ========================================================================== -// Settings shared between Modbus sensors -// ========================================================================== -/** Start [modbus_shared] */ -// Create a reference to the serial port for modbus -#if defined(ENABLE_SERIAL2) || defined(ENVIRODIY_STONEFLY_M4) || \ - defined(ATMEGA2560) || defined(ARDUINO_AVR_MEGA2560) -HardwareSerial& modbusSerial = Serial2; // Use hardware serial if possible -#else -AltSoftSerial& modbusSerial = altSoftSerial; // For software serial -#endif - -// Define some pins that will be shared by all modbus sensors -const int8_t rs485AdapterPower = - sensorPowerPin; // RS485 adapter power pin (-1 if unconnected) -const int8_t modbusSensorPower = A3; // Sensor power pin -const int8_t rs485EnablePin = -1; // Adapter RE/DE pin (-1 if not applicable) -/** End [modbus_shared] */ - - -// ========================================================================== -// Yosemitech Y504 Dissolved Oxygen Sensor -// ========================================================================== -/** Start [Y504] */ -#include - -byte y504ModbusAddress = 0x04; // The modbus address of the Y504 -const uint8_t y504NumberReadings = 5; -// The manufacturer recommends averaging 10 readings, but we take 5 to minimize -// power consumption - -// Create a Yosemitech Y504 dissolved oxygen sensor object -YosemitechY504 y504(y504ModbusAddress, modbusSerial, rs485AdapterPower, - modbusSensorPower, rs485EnablePin, y504NumberReadings); - -// Create the dissolved oxygen percent, dissolved oxygen concentration, and -// temperature variable pointers for the Y504 -Variable* y504DOpct = - new YosemitechY504_DOpct(&y504, "12345678-abcd-1234-ef00-1234567890ab"); -Variable* y504DOmgL = - new YosemitechY504_DOmgL(&y504, "12345678-abcd-1234-ef00-1234567890ab"); -Variable* y504Temp = - new YosemitechY504_Temp(&y504, "12345678-abcd-1234-ef00-1234567890ab"); -/** End [Y504] */ - - -// ========================================================================== -// Yosemitech Y511 Turbidity Sensor with Wiper -// ========================================================================== -/** Start [Y511] */ -#include - -byte y511ModbusAddress = 0x1A; // The modbus address of the Y511 -const uint8_t y511NumberReadings = 5; -// The manufacturer recommends averaging 10 readings, but we take 5 to minimize -// power consumption - -// Create a Y511-A Turbidity sensor object -YosemitechY511 y511(y511ModbusAddress, modbusSerial, rs485AdapterPower, - modbusSensorPower, rs485EnablePin, y511NumberReadings); - -// Create turbidity and temperature variable pointers for the Y511 -Variable* y511Turb = - new YosemitechY511_Turbidity(&y511, "12345678-abcd-1234-ef00-1234567890ab"); -Variable* y511Temp = - new YosemitechY511_Temp(&y511, "12345678-abcd-1234-ef00-1234567890ab"); -/** End [Y511] */ - - -// ========================================================================== -// Yosemitech Y514 Chlorophyll Sensor -// ========================================================================== -/** Start [Y514] */ -#include - -byte y514ModbusAddress = 0x14; // The modbus address of the Y514 -const uint8_t y514NumberReadings = 5; -// The manufacturer recommends averaging 10 readings, but we take 5 to -// minimize power consumption - -// Create a Y514 chlorophyll sensor object -YosemitechY514 y514(y514ModbusAddress, modbusSerial, rs485AdapterPower, - modbusSensorPower, rs485EnablePin, y514NumberReadings); - -// Create chlorophyll concentration and temperature variable pointers for the -// Y514 -Variable* y514Chloro = new YosemitechY514_Chlorophyll( - &y514, "12345678-abcd-1234-ef00-1234567890ab"); -Variable* y514Temp = - new YosemitechY514_Temp(&y514, "12345678-abcd-1234-ef00-1234567890ab"); -/** End [Y514] */ - - -// ========================================================================== -// Yosemitech Y520 Conductivity Sensor -// ========================================================================== -/** Start [Y520] */ -#include - -byte y520ModbusAddress = 0x20; // The modbus address of the Y520 -const uint8_t y520NumberReadings = 5; -// The manufacturer recommends averaging 10 readings, but we take 5 to minimize -// power consumption - -// Create a Y520 conductivity sensor object -YosemitechY520 y520(y520ModbusAddress, modbusSerial, rs485AdapterPower, - modbusSensorPower, rs485EnablePin, y520NumberReadings); - -// Create specific conductance and temperature variable pointers for the Y520 -Variable* y520Cond = - new YosemitechY520_Cond(&y520, "12345678-abcd-1234-ef00-1234567890ab"); -Variable* y520Temp = - new YosemitechY520_Temp(&y520, "12345678-abcd-1234-ef00-1234567890ab"); -/** End [Y520] */ - - -// ========================================================================== -// Creating the Variable Array[s] and Filling with Variable Objects -// ========================================================================== -/** Start [variable_arrays] */ -// FORM2: Fill array with already created and named variable pointers -// We put ALL of the variable pointers into the first array -Variable* variableList_complete[] = { - mcuBoardSampNo, mcuBoardBatt, mcuBoardAvailableRAM, - ds3231Temp, y504DOpct, y504DOmgL, - y504Temp, y511Turb, y511Temp, - y514Chloro, y514Temp, y520Cond, - y520Temp, modemRSSI, modemSignalPct}; -// Count up the number of pointers in the array -int variableCount_complete = sizeof(variableList_complete) / - sizeof(variableList_complete[0]); -// Create the VariableArray object -VariableArray arrayComplete(variableCount_complete, variableList_complete); - - -// Put only the particularly interesting variables into a second array -// NOTE: We can the same variables into multiple arrays -Variable* variableList_toGo[] = {y504DOmgL, y504Temp, y511Turb, - y514Chloro, y520Cond, modemRSSI}; -// Count up the number of pointers in the array -int variableCount_toGo = sizeof(variableList_toGo) / - sizeof(variableList_toGo[0]); -// Create the VariableArray object -VariableArray arrayToGo(variableCount_toGo, variableList_toGo); -/** End [variable_arrays] */ - - -// ========================================================================== -// The Logger Object[s] -// ========================================================================== -/** Start [loggers] */ -// Create one new logger instance for the complete array -Logger loggerAllVars(LoggerID, loggingInterval, &arrayComplete); - -// Create "another" logger for the variables to go out over the internet -Logger loggerToGo(LoggerID, loggingInterval, &arrayToGo); -/** End [loggers] */ - - -// ========================================================================== -// Creating Data Publisher[s] -// ========================================================================== -/** Start [publishers] */ -// Create a publisher to Monitor My Watershed -// Device registration and sampling feature information can be obtained after -// registration at https://monitormywatershed.org -const char* registrationToken = - "12345678-abcd-1234-ef00-1234567890ab"; // Device registration token -const char* samplingFeature = - "12345678-abcd-1234-ef00-1234567890ab"; // Sampling feature UUID - -// Create a data publisher for the Monitor My Watershed POST endpoint -// This is only attached to the logger with the shorter variable array -#include -MonitorMyWatershedPublisher MonitorMWPost(loggerToGo, registrationToken, - samplingFeature); -/** End [publishers] */ - - -// ========================================================================== -// Working Functions -// ========================================================================== -/** Start [working_functions] */ -// Flashes the LED's on the primary board -void greenRedFlash(uint8_t numFlash = 4, uint8_t rate = 75) { - for (uint8_t i = 0; i < numFlash; i++) { - digitalWrite(greenLED, HIGH); - digitalWrite(redLED, LOW); - delay(rate); - digitalWrite(greenLED, LOW); - digitalWrite(redLED, HIGH); - delay(rate); - } - digitalWrite(redLED, LOW); -} - -// Reads the battery voltage -// NOTE: This will actually return the battery level from the previous update! -float getBatteryVoltage() { - if (mcuBoard.sensorValues[0] == -9999) mcuBoard.update(); - return mcuBoard.sensorValues[0]; -} -/** End [working_functions] */ - - -// ========================================================================== -// Arduino Setup Function -// ========================================================================== -/** Start [setup] */ -void setup() { -// Wait for USB connection to be established by PC -// NOTE: Only use this when debugging - if not connected to a PC, this adds an -// unnecessary startup delay -#if defined(SERIAL_PORT_USBVIRTUAL) - while (!SERIAL_PORT_USBVIRTUAL && (millis() < 10000L)) { delay(10); } -#endif - - // Start the primary serial connection - Serial.begin(serialBaud); - - // Print a start-up note to the first serial port - Serial.print(F("Now running ")); - Serial.print(sketchName); - Serial.print(F(" on Logger ")); - Serial.println(LoggerID); - Serial.println(); - - Serial.print(F("Using ModularSensors Library version ")); - Serial.println(MODULAR_SENSORS_VERSION); - - // Start the serial connection with the modem - modemSerial.begin(modemBaud); - - // Start the stream for the modbus sensors; all currently supported modbus - // sensors use 9600 baud - modbusSerial.begin(9600); - -// Assign pins SERCOM functionality for SAMD boards -// NOTE: This must happen *after* the various serial.begin statements -#if defined(ARDUINO_SAMD_FEATHER_M0) - // Serial2 - pinPeripheral(10, PIO_SERCOM); // Serial2 Tx/Dout = SERCOM1 Pad #2 - pinPeripheral(11, PIO_SERCOM); // Serial2 Rx/Din = SERCOM1 Pad #0 -#endif - // Set up pins for the LED's - pinMode(greenLED, OUTPUT); - digitalWrite(greenLED, LOW); - pinMode(redLED, OUTPUT); - digitalWrite(redLED, LOW); - // Blink the LEDs to show the board is on and starting up - greenRedFlash(); - - // Set the timezones for the logger/data and the RTC - // Logging in the given time zone - Logger::setLoggerTimeZone(timeZone); - // It is STRONGLY RECOMMENDED that you set the RTC to be in UTC (UTC+0) - loggerClock::setRTCOffset(0); - - // Attach the same modem to both loggers - // It is only needed for the logger that will be sending out data, but - // attaching it to both allows either logger to control NIST synchronization - loggerAllVars.attachModem(modem); - loggerToGo.attachModem(modem); - modem.setModemLED(modemLEDPin); - loggerAllVars.setLoggerPins(wakePin, sdCardSSPin, sdCardPwrPin, buttonPin, - greenLED); - - // Set up the connection information with Monitor My Watershed for both - // loggers - // Doing this for both loggers ensures that the header of the csv will have - // the tokens in it - loggerAllVars.setSamplingFeatureUUID(samplingFeature); - loggerToGo.setSamplingFeatureUUID(samplingFeature); - - // Note: Please change these battery voltages to match your battery - - // Set up the sensors, except at lowest battery level - // Like with the logger, because the variables are duplicated in the arrays, - // we only need to do this for the complete array. - if (getBatteryVoltage() > 3.4) { - Serial.println(F("Setting up sensors...")); - arrayComplete.setupSensors(); - } - - // Sync the clock if it isn't valid or we have battery to spare - if (getBatteryVoltage() > 3.55 || !loggerClock::isRTCSane()) { - // Synchronize the RTC with NIST - // This will also set up the modem - loggerAllVars.syncRTC(); - } - - // Create the log file, adding the default header to it - // Do this last so we have the best chance of getting the time correct and - // all sensor names correct - // Writing to the SD card can be power intensive, so if we're skipping - // the sensor setup we'll skip this too. - if (getBatteryVoltage() > 3.4) { - loggerAllVars.turnOnSDcard( - true); // true = wait for card to settle after power up - loggerAllVars.createLogFile(true); // true = write a new header - loggerAllVars.turnOffSDcard( - true); // true = wait for internal housekeeping after write - } - - // Call the processor sleep - Serial.println(F("Putting processor to sleep")); - loggerAllVars.systemSleep(); -} -/** End [setup] */ - - -// ========================================================================== -// Arduino Loop Function -// ========================================================================== -/** Start [loop] */ -// Use this long loop when you want to do something special -// Because of the way alarms work on the RTC, it will wake the processor and -// start the loop every minute exactly on the minute. -// The processor may also be woken up by another interrupt or level change on a -// pin - from a button or some other input. -// The "if" statements in the loop determine what will happen - whether the -// sensors update, testing mode starts, or it goes back to sleep. -void loop() { - // Reset the watchdog - extendedWatchDog::resetWatchDog(); - - // Assuming we were woken up by the clock, check if the current time is an - // even interval of the logging interval - // We're only doing anything at all if the battery is above 3.4V - if (loggerAllVars.checkInterval() && getBatteryVoltage() > 3.4) { - // Flag to notify that we're in already awake and logging a point - Logger::isLoggingNow = true; - extendedWatchDog::resetWatchDog(); - - // Print a line to show new reading - Serial.println(F("------------------------------------------")); - // Turn on the LED to show we're taking a reading - loggerAllVars.alertOn(); - // Power up the SD Card, but skip any waits after power up - loggerAllVars.turnOnSDcard(false); - extendedWatchDog::resetWatchDog(); - - // Start the stream for the modbus sensors - // Because RS485 adapters tend to "steal" current from the data pins - // we will explicitly start and end the serial connection in the loop. - modbusSerial.begin(9600); - - // Do a complete update on the "full" array. - // This this includes powering all of the sensors, getting updated - // values, and turing them back off. - // NOTE: The wake function for each sensor should force sensor setup - // to run if the sensor was not previously set up. - arrayComplete.completeUpdate(); - extendedWatchDog::resetWatchDog(); - - // End the stream for the modbus sensors - // Because RS485 adapters tend to "steal" current from the data pins - // we will explicitly start and end the serial connection in the loop. - modbusSerial.end(); - -#if defined(AltSoftSerial_h) - // Explicitly set the pin modes for the AltSoftSerial pins to make sure - // they're low - pinMode(5, OUTPUT); // On a Mayfly, pin D5 is the AltSoftSerial Tx pin - pinMode(6, OUTPUT); // On a Mayfly, pin D6 is the AltSoftSerial Rx pin - digitalWrite(5, LOW); - digitalWrite(6, LOW); -#endif - -#if defined(ARDUINO_SAMD_FEATHER_M0) - digitalWrite(10, LOW); - digitalWrite(11, LOW); -#endif - - // Create a csv data record and save it to the log file - loggerAllVars.logToSD(); - extendedWatchDog::resetWatchDog(); - - // Connect to the network - // Again, we're only doing this if the battery is doing well - if (getBatteryVoltage() > 3.55) { - if (modem.modemWake()) { - extendedWatchDog::resetWatchDog(); - if (modem.connectInternet()) { - extendedWatchDog::resetWatchDog(); - // Publish data to remotes - loggerToGo.publishDataToRemotes(); - modem.updateModemMetadata(); - - extendedWatchDog::resetWatchDog(); - // Sync the clock at noon - // NOTE: All loggers have the same clock, pick one - if (Logger::markedLocalUnixTime != 0 && - Logger::markedLocalUnixTime % 86400 == 43200) { - Serial.println(F("Running a daily clock sync...")); - loggerClock::setRTClock(modem.getNISTTime(), 0, - epochStart::unix_epoch); - } - - // Disconnect from the network - extendedWatchDog::resetWatchDog(); - modem.disconnectInternet(); - } - } - // Turn the modem off - extendedWatchDog::resetWatchDog(); - modem.modemSleepPowerDown(); - } - - // Cut power from the SD card - without additional housekeeping wait - loggerAllVars.turnOffSDcard(false); - extendedWatchDog::resetWatchDog(); - // Turn off the LED - loggerAllVars.alertOff(); - // Print a line to show reading ended - Serial.println(F("------------------------------------------\n")); - - // Unset flag - Logger::isLoggingNow = false; - } - - // Check if it was instead the testing interrupt that woke us up - // Want to enter the testing mode for the "complete" logger so we can see - // the data from _ALL_ sensors - // NOTE: The testingISR attached to the button at the end of the "setup()" - // function turns on the startTesting flag. So we know if that flag is set - // then we want to run the testing mode function. - if (Logger::startTesting) loggerAllVars.benchTestingMode(); - - // Call the processor sleep - // Only need to do this for one of the loggers - loggerAllVars.systemSleep(); -} - -/** End [loop] */ diff --git a/examples/data_saving/platformio.ini b/examples/data_saving/platformio.ini deleted file mode 100644 index dd636635e..000000000 --- a/examples/data_saving/platformio.ini +++ /dev/null @@ -1,40 +0,0 @@ -; PlatformIO Project Configuration File -; -; Build options: build flags, source filter -; Upload options: custom upload port, speed and extra flags -; Library options: dependencies, extra library storages -; Advanced options: extra scripting -; -; Please visit documentation for the other options and examples -; http://docs.platformio.org/page/projectconf.html - -[platformio] -description = ModularSensors example using two "loggers" to save cellular data - -[env:mayfly] -monitor_speed = 115200 -board = mayfly -platform = atmelavr -framework = arduino -lib_ldf_mode = deep+ -lib_ignore = - RTCZero - Adafruit NeoPixel - Adafruit GFX Library - Adafruit SSD1306 - Adafruit ADXL343 - Adafruit STMPE610 - Adafruit TouchScreen - Adafruit ILI9341 -build_flags = - -DSDI12_EXTERNAL_PCINT - -DNEOSWSERIAL_EXTERNAL_PCINT - -DMQTT_MAX_PACKET_SIZE=240 - -DTINY_GSM_RX_BUFFER=64 - -DTINY_GSM_YIELD_MS=2 -lib_deps = - envirodiy/EnviroDIY_ModularSensors -; ^^ Use this when working from an official release of the library -; https://github.com/EnviroDIY/ModularSensors.git#develop -; ^^ Use this when if you want to pull from the develop branch - https://github.com/PaulStoffregen/AltSoftSerial.git diff --git a/examples/examples.dox b/examples/examples.dox index 3f5dd55d7..d0a62d610 100644 --- a/examples/examples.dox +++ b/examples/examples.dox @@ -47,8 +47,6 @@ @subpage example_double_log "DELETE THIS LINK" -@subpage example_data_saving "DELETE THIS LINK" - */ /** diff --git a/examples/menu_a_la_carte/ReadMe.md b/examples/menu_a_la_carte/ReadMe.md index 6503ceaca..28cf8875c 100644 --- a/examples/menu_a_la_carte/ReadMe.md +++ b/examples/menu_a_la_carte/ReadMe.md @@ -1609,7 +1609,6 @@ All together, this gives: If you need more help in writing a complex loop, the [double_logger example program](https://github.com/EnviroDIY/ModularSensors/tree/master/examples/double_logger) demonstrates using a custom loop function in order to log two different groups of sensors at different logging intervals. -The [data_saving example program](https://github.com/EnviroDIY/ModularSensors/tree/master/examples/data_saving) shows using a custom loop in order to save cellular data by saving data from many variables on the SD card, but only sending a portion of the data to [Monitor My Watershed](https://monitormywatershed.org/). From ce621709fa1ba88123dfac59bcd4d31d7476d0af Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Fri, 13 Feb 2026 10:26:13 -0500 Subject: [PATCH 149/533] Added header with typedef for the EnviroDIYPublisher for backward compatibility for Signed-off-by: Sara Damiano --- src/publishers/EnviroDIYPublisher.h | 35 +++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 src/publishers/EnviroDIYPublisher.h diff --git a/src/publishers/EnviroDIYPublisher.h b/src/publishers/EnviroDIYPublisher.h new file mode 100644 index 000000000..11199c4c8 --- /dev/null +++ b/src/publishers/EnviroDIYPublisher.h @@ -0,0 +1,35 @@ +/** + * @file EnviroDIYPublisher.h + * @copyright Stroud Water Research Center + * Part of the EnviroDIY ModularSensors library for Arduino. + * This library is published under the BSD-3 license. + * @author Sara Geleskie Damiano + * + * @brief Contains the EnviroDIYPublisher subclass of dataPublisher for + * publishing data to the Monitor My Watershed/EnviroDIY data portal at + * http://data.enviroDIY.org + */ + +// Header Guards +#ifndef SRC_PUBLISHERS_ENVIRODIYPUBLISHER_H_ +#define SRC_PUBLISHERS_ENVIRODIYPUBLISHER_H_ + +// Include the Monitor My Watershed Publisher since the EnviroDIYPublisher is +// only a typedef reference to it for backward compatibility +#include "MonitorMyWatershedPublisher.h" + + +// ============================================================================ +// Functions for the EnviroDIY data portal receivers. +// ============================================================================ +/** + * @brief typedef for backwards compatibility; use the + * MonitorMyWatershedPublisher class in new code + * + * @ingroup the_publishers + * + * @m_deprecated_since{0,38,0} + */ +typedef MonitorMyWatershedPublisher EnviroDIYPublisher; + +#endif // SRC_PUBLISHERS_ENVIRODIYPUBLISHER_H_ From ddeb69caedd9791d5c5f7085639fd4f9cd0fcc9d Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Tue, 17 Feb 2026 11:00:00 -0500 Subject: [PATCH 150/533] Directly call specific Tiny GSM client files Signed-off-by: Sara Damiano --- continuous_integration/dependencies.json | 136 ++++++++++++++++----- src/modems/DigiXBee3GBypass.cpp | 10 +- src/modems/DigiXBee3GBypass.h | 4 +- src/modems/DigiXBeeCellularTransparent.cpp | 11 +- src/modems/DigiXBeeCellularTransparent.h | 4 +- src/modems/DigiXBeeLTEBypass.cpp | 10 +- src/modems/DigiXBeeLTEBypass.h | 4 +- src/modems/DigiXBeeWifi.cpp | 13 +- src/modems/DigiXBeeWifi.h | 4 +- src/modems/EspressifESP32.cpp | 10 +- src/modems/EspressifESP32.h | 4 +- src/modems/EspressifESP8266.cpp | 10 +- src/modems/EspressifESP8266.h | 4 +- src/modems/LoggerModemMacros.h | 99 ++++++++------- src/modems/QuectelBG96.cpp | 10 +- src/modems/QuectelBG96.h | 4 +- src/modems/SIMComSIM7000.cpp | 10 +- src/modems/SIMComSIM7000.h | 4 +- src/modems/SIMComSIM7080.cpp | 10 +- src/modems/SIMComSIM7080.h | 4 +- src/modems/SIMComSIM800.cpp | 10 +- src/modems/SIMComSIM800.h | 4 +- src/modems/SequansMonarch.cpp | 10 +- src/modems/SequansMonarch.h | 4 +- src/modems/SodaqUBeeR410M.cpp | 10 +- src/modems/SodaqUBeeR410M.h | 4 +- src/modems/SodaqUBeeU201.cpp | 10 +- src/modems/SodaqUBeeU201.h | 4 +- 28 files changed, 255 insertions(+), 166 deletions(-) diff --git a/continuous_integration/dependencies.json b/continuous_integration/dependencies.json index 7a65b33a7..6371fcbe7 100644 --- a/continuous_integration/dependencies.json +++ b/continuous_integration/dependencies.json @@ -1,5 +1,5 @@ { - "action_cache_version": 44, + "action_cache_version": 45, "dependencies": [ { "name": "EnviroDIY_DS3231", @@ -8,7 +8,10 @@ "url": "https://github.com/EnviroDIY/Sodaq_DS3231", "version": "~1.3.6", "note": "An Arduino library for the DS3231 RTC (Real Time Clock), based off of the Sodaq_DS3231 library.", - "authors": ["Kees Bakker", "Sara Damiano"], + "authors": [ + "Kees Bakker", + "Sara Damiano" + ], "frameworks": "arduino" }, { @@ -18,9 +21,13 @@ "url": "https://github.com/arduino-libraries/RTCZero", "version": "~1.6.0", "note": "Functions for using the processor real time clock in SAMD21 processors", - "authors": ["Arduino"], + "authors": [ + "Arduino" + ], "frameworks": "arduino", - "platforms": ["atmelsam"] + "platforms": [ + "atmelsam" + ] }, { "name": "SparkFun Qwiic RTC RV8803 Arduino Library", @@ -37,9 +44,14 @@ "url": "https://github.com/GreyGnome/EnableInterrupt", "version": "~1.1.0", "note": "GreyGnome's EnableInterrupt - Assign an interrupt to any supported pin on all Arduinos", - "authors": ["Mike 'GreyGnome' Schwager"], + "authors": [ + "Mike 'GreyGnome' Schwager" + ], "frameworks": "arduino", - "platforms": ["atmelavr", "atmelsam"] + "platforms": [ + "atmelavr", + "atmelsam" + ] }, { "name": "SdFat", @@ -48,16 +60,21 @@ "url": "https://github.com/greiman/SdFat", "version": "=2.3.0", "note": "SdFat - FAT16/FAT32 file system for SD cards.", - "authors": ["Bill Greiman"], + "authors": [ + "Bill Greiman" + ], "frameworks": "arduino" }, { "name": "TinyGSM", "owner": "vshymanskyy", - "version": "https://github.com/EnviroDIY/TinyGSM", + "version": "https://github.com/EnviroDIY/TinyGSM#one_rule", "version_note": "~0.13.0", "note": "A small Arduino library for GPRS modules.", - "authors": ["Volodymyr Shymanskyy", "Sara Damiano"], + "authors": [ + "Volodymyr Shymanskyy", + "Sara Damiano" + ], "frameworks": "arduino" }, { @@ -67,7 +84,9 @@ "url": "https://github.com/knolleary/pubsubclient", "version": "~2.8.0", "note": "A client library for MQTT messaging.", - "authors": ["Nick O'Leary"] + "authors": [ + "Nick O'Leary" + ] }, { "name": "Adafruit BusIO", @@ -76,7 +95,9 @@ "url": "https://github.com/adafruit/Adafruit_BusIO", "version": "~1.17.4", "note": "Adafruit BusIO, a dependency of other Adafruit libraries", - "authors": ["Adafruit"], + "authors": [ + "Adafruit" + ], "frameworks": "arduino" }, { @@ -86,7 +107,9 @@ "url": "https://github.com/adafruit/Adafruit_Sensor", "version": "~1.1.15", "note": "Adafruit's unified sensor library is used by their other libraries", - "authors": ["Adafruit"], + "authors": [ + "Adafruit" + ], "frameworks": "arduino" }, { @@ -95,7 +118,9 @@ "url": "https://github.com/adafruit/Adafruit_ADS1X15", "version": "~2.6.2", "note": "Driver for TI's ADS1X15: 12 and 16-bit Differential or Single-Ended ADC with PGA and Comparator.", - "authors": ["Adafruit"], + "authors": [ + "Adafruit" + ], "frameworks": "arduino" }, { @@ -105,7 +130,9 @@ "url": "https://github.com/adafruit/Adafruit_AM2315", "version": "~2.2.3", "note": "AOSong AM2315 I2C Temp/Humidity Sensor Library by Adafruit", - "authors": ["Adafruit"], + "authors": [ + "Adafruit" + ], "frameworks": "arduino" }, { @@ -115,7 +142,9 @@ "url": "https://github.com/adafruit/Adafruit_BME280_Library", "version": "~2.3.0", "note": "Bosch BME280 Temp/Humidity/Pressure Sensor Library by Adafruit", - "authors": ["Adafruit"], + "authors": [ + "Adafruit" + ], "frameworks": "arduino" }, { @@ -123,7 +152,9 @@ "owner": "MartinL1", "version": "~1.0.11", "note": "An Arduino compatible, non-blocking, I2C/SPI library for the Bosch BMP388 barometer.", - "authors": ["Martin Lindupp"], + "authors": [ + "Martin Lindupp" + ], "frameworks": "arduino" }, { @@ -133,7 +164,9 @@ "url": "https://github.com/adafruit/DHT-sensor-library", "version": "~1.4.6", "note": "AOSong DHT Sensor Library by Adafruit", - "authors": ["Adafruit"], + "authors": [ + "Adafruit" + ], "frameworks": "arduino" }, { @@ -143,7 +176,9 @@ "url": "https://github.com/adafruit/Adafruit_INA219", "version": "~1.2.3", "note": "This is a library for the Adafruit INA219 high side DC current sensor boards", - "authors": ["Adafruit"], + "authors": [ + "Adafruit" + ], "frameworks": "arduino" }, { @@ -153,7 +188,9 @@ "url": "https://github.com/adafruit/Adafruit_MPL115A2", "version": "~2.0.2", "note": "MPL115A2 Barometer Library by Adafruit", - "authors": ["Adafruit"], + "authors": [ + "Adafruit" + ], "frameworks": "arduino" }, { @@ -163,7 +200,9 @@ "url": "https://github.com/adafruit/Adafruit_SHT4X", "version": "~1.0.5", "note": "Sensirion SHT4x Library by Adafruit", - "authors": ["Adafruit"], + "authors": [ + "Adafruit" + ], "frameworks": "arduino" }, { @@ -197,7 +236,12 @@ "url": "https://github.com/milesburton/Arduino-Temperature-Control-Library", "version": "~4.0.6", "note": "DallasTemperature - Arduino Library for Dallas Temperature ICs (DS18B20, DS18S20, DS1822, DS1820)", - "authors": ["Guil Barros", "Miles Burton", "Rob Tillart", "Tim Nuewsome"], + "authors": [ + "Guil Barros", + "Miles Burton", + "Rob Tillart", + "Tim Nuewsome" + ], "frameworks": "arduino" }, { @@ -214,7 +258,10 @@ "Anthony Aufdenkampe" ], "frameworks": "arduino", - "platforms": ["atmelavr", "atmelsam"] + "platforms": [ + "atmelavr", + "atmelsam" + ] }, { "name": "MS5803", @@ -223,14 +270,22 @@ "url": "https://github.com/NorthernWidget/MS5803", "version": "~0.1.2", "note": "General interface to MS5803-series pressure transducers", - "authors": ["Bobby Schulz", "Andrew Wickert", "Chad Sandell", "Sara Damiano"] + "authors": [ + "Bobby Schulz", + "Andrew Wickert", + "Chad Sandell", + "Sara Damiano" + ] }, { "name": "Tally_Library_I2C", "version": "https://github.com/EnviroDIY/Tally_Library.git#Dev_I2C", "version_note": "Uses `Dev_I2C` feature branch", "note": "An Arduino library for interfacing to the Project Tally Event counter from NorthernWidget.", - "authors": ["Bobby Schulz", "Anthony Aufdenkampe"], + "authors": [ + "Bobby Schulz", + "Anthony Aufdenkampe" + ], "frameworks": "arduino" }, { @@ -240,7 +295,9 @@ "url": "https://github.com/EnviroDIY/SensorModbusMaster", "version": "~1.7.0", "note": "EnviroDIY SensorModbusMaster - Arduino library for communicating via modbus with the Arduino acting as the modbus master.", - "authors": ["Sara Damiano"], + "authors": [ + "Sara Damiano" + ], "frameworks": "arduino" }, { @@ -250,7 +307,9 @@ "url": "https://github.com/EnviroDIY/KellerModbus", "version": "~0.2.7", "note": "Arduino library for communication with Keller pressure and water level sensors via Modbus.", - "authors": ["Anthony Aufdenkampe"] + "authors": [ + "Anthony Aufdenkampe" + ] }, { "name": "YosemitechModbus", @@ -259,7 +318,10 @@ "url": "https://github.com/EnviroDIY/YosemitechModbus", "version": "~0.5.4", "note": "Arduino library for communication with Yosemitech sensors via Modbus.", - "authors": ["Sara Damiano", "Anthony Aufdenkampe"], + "authors": [ + "Sara Damiano", + "Anthony Aufdenkampe" + ], "frameworks": "arduino" }, { @@ -268,7 +330,9 @@ "url": "https://github.com/EnviroDIY/GroPointModbus", "version": "~0.1.5", "note": "A library to use an Arduino as a master to control and communicate via modbus with GroPoint soil moisture sensors.", - "authors": ["Anthony Aufdenkampe"], + "authors": [ + "Anthony Aufdenkampe" + ], "frameworks": "arduino" }, { @@ -277,7 +341,9 @@ "url": "https://github.com/EnviroDIY/GeoluxCamera", "version": "~0.1.3", "note": "Arduino library for communication with Geolux serial camera.", - "authors": ["Sara Damiano"], + "authors": [ + "Sara Damiano" + ], "frameworks": "arduino" }, { @@ -286,7 +352,9 @@ "url": "https://github.com/RobTillaart/fast_math", "version": "~0.2.5", "note": "Arduino library for fast math algorithms.", - "authors": ["Rob Tillaart"], + "authors": [ + "Rob Tillaart" + ], "frameworks": "*", "platforms": "*" }, @@ -294,9 +362,11 @@ "name": "ANBSensorsModbus", "owner": "envirodiy", "url": "https://github.com/EnviroDIY/ANBSensorsModbus", - "version": "~0.4.1", + "version": "~0.4.2", "note": "A library for communicating with pH sensors manufactured by ANB Sensors using Modbus.", - "authors": ["Sara Damiano"], + "authors": [ + "Sara Damiano" + ], "frameworks": "arduino" }, { @@ -305,4 +375,4 @@ "note": "Used for debugging modem streams and duplicating primary output stream" } ] -} +} \ No newline at end of file diff --git a/src/modems/DigiXBee3GBypass.cpp b/src/modems/DigiXBee3GBypass.cpp index f338f6804..977b091d6 100644 --- a/src/modems/DigiXBee3GBypass.cpp +++ b/src/modems/DigiXBee3GBypass.cpp @@ -38,12 +38,12 @@ MS_MODEM_CONNECT_INTERNET(DigiXBee3GBypass); MS_MODEM_DISCONNECT_INTERNET(DigiXBee3GBypass); MS_MODEM_IS_INTERNET_AVAILABLE(DigiXBee3GBypass); -MS_MODEM_CREATE_CLIENT(DigiXBee3GBypass); -MS_MODEM_DELETE_CLIENT(DigiXBee3GBypass); -MS_MODEM_CREATE_SECURE_CLIENT(DigiXBee3GBypass); -MS_MODEM_DELETE_SECURE_CLIENT(DigiXBee3GBypass); +MS_MODEM_CREATE_CLIENT(DigiXBee3GBypass, UBLOX); +MS_MODEM_DELETE_CLIENT(DigiXBee3GBypass, UBLOX); +MS_MODEM_CREATE_SECURE_CLIENT(DigiXBee3GBypass, UBLOX); +MS_MODEM_DELETE_SECURE_CLIENT(DigiXBee3GBypass, UBLOX); -MS_MODEM_GET_NIST_TIME(DigiXBee3GBypass); +MS_MODEM_GET_NIST_TIME(DigiXBee3GBypass, UBLOX); MS_MODEM_GET_MODEM_SIGNAL_QUALITY(DigiXBee3GBypass); MS_MODEM_GET_MODEM_BATTERY_DATA(DigiXBee3GBypass); diff --git a/src/modems/DigiXBee3GBypass.h b/src/modems/DigiXBee3GBypass.h index d6d03d529..bb980e8f8 100644 --- a/src/modems/DigiXBee3GBypass.h +++ b/src/modems/DigiXBee3GBypass.h @@ -73,7 +73,7 @@ #undef MS_DEBUGGING_DEEP // Include other in-library and external dependencies -#include "TinyGsmClient.h" +#include "TinyGsmClientUBLOX.h" #undef TINY_GSM_MODEM_HAS_WIFI #include "DigiXBee.h" @@ -163,7 +163,7 @@ class DigiXBee3GBypass : public DigiXBee { /** * @brief Public reference to the TinyGSM modem. */ - TinyGsm gsmModem; + TinyGsmUBLOX gsmModem; protected: bool isInternetAvailable(void) override; diff --git a/src/modems/DigiXBeeCellularTransparent.cpp b/src/modems/DigiXBeeCellularTransparent.cpp index 29f8669cb..0ea54307c 100644 --- a/src/modems/DigiXBeeCellularTransparent.cpp +++ b/src/modems/DigiXBeeCellularTransparent.cpp @@ -41,10 +41,10 @@ MS_MODEM_CONNECT_INTERNET(DigiXBeeCellularTransparent); MS_MODEM_DISCONNECT_INTERNET(DigiXBeeCellularTransparent); MS_MODEM_IS_INTERNET_AVAILABLE(DigiXBeeCellularTransparent); -MS_MODEM_CREATE_CLIENT(DigiXBeeCellularTransparent); -MS_MODEM_DELETE_CLIENT(DigiXBeeCellularTransparent); -MS_MODEM_CREATE_SECURE_CLIENT(DigiXBeeCellularTransparent); -MS_MODEM_DELETE_SECURE_CLIENT(DigiXBeeCellularTransparent); +MS_MODEM_CREATE_CLIENT(DigiXBeeCellularTransparent, XBee); +MS_MODEM_DELETE_CLIENT(DigiXBeeCellularTransparent, XBee); +MS_MODEM_CREATE_SECURE_CLIENT(DigiXBeeCellularTransparent, XBee); +MS_MODEM_DELETE_SECURE_CLIENT(DigiXBeeCellularTransparent, XBee); MS_MODEM_GET_MODEM_SIGNAL_QUALITY(DigiXBeeCellularTransparent); MS_MODEM_GET_MODEM_BATTERY_DATA(DigiXBeeCellularTransparent); @@ -219,7 +219,8 @@ uint32_t DigiXBeeCellularTransparent::getNISTTime(void) { /* This is the IP address of time-e-wwv.nist.gov */ /* XBee's address lookup falters on time.nist.gov */ IPAddress ip(132, 163, 97, 6); - TinyGsmClient gsmClient(gsmModem); /*create client, default mux*/ + TinyGsmXBee::GsmClientXBee gsmClient( + gsmModem); /*create client, default mux*/ connectionMade = gsmClient.connect(ip, 37, 15); /* Wait again so NIST doesn't refuse us! */ delay(4000L); diff --git a/src/modems/DigiXBeeCellularTransparent.h b/src/modems/DigiXBeeCellularTransparent.h index d05b34a7e..0f7604cf2 100644 --- a/src/modems/DigiXBeeCellularTransparent.h +++ b/src/modems/DigiXBeeCellularTransparent.h @@ -96,7 +96,7 @@ #undef MS_DEBUGGING_DEEP // Include other in-library and external dependencies -#include "TinyGsmClient.h" +#include "TinyGsmClientXBee.h" #undef TINY_GSM_MODEM_HAS_WIFI #include "DigiXBee.h" @@ -197,7 +197,7 @@ class DigiXBeeCellularTransparent : public DigiXBee { /** * @brief Public reference to the TinyGSM modem. */ - TinyGsm gsmModem; + TinyGsmXBee gsmModem; protected: bool isInternetAvailable(void) override; diff --git a/src/modems/DigiXBeeLTEBypass.cpp b/src/modems/DigiXBeeLTEBypass.cpp index b892e4fd1..e8477b61d 100644 --- a/src/modems/DigiXBeeLTEBypass.cpp +++ b/src/modems/DigiXBeeLTEBypass.cpp @@ -38,12 +38,12 @@ MS_MODEM_CONNECT_INTERNET(DigiXBeeLTEBypass); MS_MODEM_DISCONNECT_INTERNET(DigiXBeeLTEBypass); MS_MODEM_IS_INTERNET_AVAILABLE(DigiXBeeLTEBypass); -MS_MODEM_CREATE_CLIENT(DigiXBeeLTEBypass); -MS_MODEM_DELETE_CLIENT(DigiXBeeLTEBypass); -MS_MODEM_CREATE_SECURE_CLIENT(DigiXBeeLTEBypass); -MS_MODEM_DELETE_SECURE_CLIENT(DigiXBeeLTEBypass); +MS_MODEM_CREATE_CLIENT(DigiXBeeLTEBypass, SaraR4); +MS_MODEM_DELETE_CLIENT(DigiXBeeLTEBypass, SaraR4); +MS_MODEM_CREATE_SECURE_CLIENT(DigiXBeeLTEBypass, SaraR4); +MS_MODEM_DELETE_SECURE_CLIENT(DigiXBeeLTEBypass, SaraR4); -MS_MODEM_GET_NIST_TIME(DigiXBeeLTEBypass); +MS_MODEM_GET_NIST_TIME(DigiXBeeLTEBypass, SaraR4); MS_MODEM_GET_MODEM_SIGNAL_QUALITY(DigiXBeeLTEBypass); MS_MODEM_GET_MODEM_BATTERY_DATA(DigiXBeeLTEBypass); diff --git a/src/modems/DigiXBeeLTEBypass.h b/src/modems/DigiXBeeLTEBypass.h index 056bd15de..8ac75e1dc 100644 --- a/src/modems/DigiXBeeLTEBypass.h +++ b/src/modems/DigiXBeeLTEBypass.h @@ -89,7 +89,7 @@ #undef MS_DEBUGGING_DEEP // Include other in-library and external dependencies -#include "TinyGsmClient.h" +#include "TinyGsmClientSaraR4.h" #undef TINY_GSM_MODEM_HAS_WIFI #include "DigiXBee.h" @@ -178,7 +178,7 @@ class DigiXBeeLTEBypass : public DigiXBee { /** * @brief Public reference to the TinyGSM modem. */ - TinyGsm gsmModem; + TinyGsmSaraR4 gsmModem; protected: bool isInternetAvailable(void) override; diff --git a/src/modems/DigiXBeeWifi.cpp b/src/modems/DigiXBeeWifi.cpp index 6e3885b47..3988e6e99 100644 --- a/src/modems/DigiXBeeWifi.cpp +++ b/src/modems/DigiXBeeWifi.cpp @@ -87,10 +87,10 @@ bool DigiXBeeWifi::connectInternet(uint32_t maxConnectionTime) { } MS_MODEM_IS_INTERNET_AVAILABLE(DigiXBeeWifi); -MS_MODEM_CREATE_CLIENT(DigiXBeeWifi); -MS_MODEM_DELETE_CLIENT(DigiXBeeWifi); -MS_MODEM_CREATE_SECURE_CLIENT(DigiXBeeWifi); -MS_MODEM_DELETE_SECURE_CLIENT(DigiXBeeWifi); +MS_MODEM_CREATE_CLIENT(DigiXBeeWifi, XBee); +MS_MODEM_DELETE_CLIENT(DigiXBeeWifi, XBee); +MS_MODEM_CREATE_SECURE_CLIENT(DigiXBeeWifi, XBee); +MS_MODEM_DELETE_SECURE_CLIENT(DigiXBeeWifi, XBee); MS_MODEM_GET_MODEM_SIGNAL_QUALITY(DigiXBeeWifi); MS_MODEM_GET_MODEM_BATTERY_DATA(DigiXBeeWifi); @@ -352,7 +352,8 @@ bool DigiXBeeWifi::extraModemSetup(void) { void DigiXBeeWifi::disconnectInternet(void) { // Ensure Wifi XBee IP socket torn down by forcing connection to // localhost IP For A XBee S6B bug, then force restart. - TinyGsmClient gsmClient(gsmModem); // need to create again to force close + TinyGsmXBee::GsmClientXBee gsmClient( + gsmModem); // need to create again to force close String oldRemoteIp = gsmClient.remoteIP(); IPAddress newHostIp = IPAddress(127, 0, 0, 1); // localhost gsmClient.connect(newHostIp, 80); @@ -401,7 +402,7 @@ uint32_t DigiXBeeWifi::getNISTTime(void) { // NOTE: This "connect" only sets up the connection parameters, the TCP // socket isn't actually opened until we first send data (the '!' below) - TinyGsmClient gsmClient(gsmModem); + TinyGsmXBee::GsmClientXBee gsmClient(gsmModem); connectionMade = gsmClient.connect(nistIPs[i], TIME_PROTOCOL_PORT); // Need to send something before connection is made gsmClient.println('!'); diff --git a/src/modems/DigiXBeeWifi.h b/src/modems/DigiXBeeWifi.h index 1c2d63dcc..e4eb8fb16 100644 --- a/src/modems/DigiXBeeWifi.h +++ b/src/modems/DigiXBeeWifi.h @@ -69,7 +69,7 @@ #undef MS_DEBUGGING_DEEP // Include other in-library and external dependencies -#include "TinyGsmClient.h" +#include "TinyGsmClientXBee.h" #undef TINY_GSM_MODEM_HAS_GPRS #include "DigiXBee.h" @@ -173,7 +173,7 @@ class DigiXBeeWifi : public DigiXBee { /** * @brief Public reference to the TinyGSM modem. */ - TinyGsm gsmModem; + TinyGsmXBee gsmModem; protected: bool isInternetAvailable(void) override; diff --git a/src/modems/EspressifESP32.cpp b/src/modems/EspressifESP32.cpp index 8e5319ef5..c26e78e79 100644 --- a/src/modems/EspressifESP32.cpp +++ b/src/modems/EspressifESP32.cpp @@ -36,12 +36,12 @@ MS_MODEM_CONNECT_INTERNET(EspressifESP32, ESPRESSIF_RECONNECT_TIME_MS); MS_MODEM_DISCONNECT_INTERNET(EspressifESP32); MS_MODEM_IS_INTERNET_AVAILABLE(EspressifESP32); -MS_MODEM_CREATE_CLIENT(EspressifESP32); -MS_MODEM_DELETE_CLIENT(EspressifESP32); -MS_MODEM_CREATE_SECURE_CLIENT(EspressifESP32); -MS_MODEM_DELETE_SECURE_CLIENT(EspressifESP32); +MS_MODEM_CREATE_CLIENT(EspressifESP32, ESP32); +MS_MODEM_DELETE_CLIENT(EspressifESP32, ESP32); +MS_MODEM_CREATE_SECURE_CLIENT(EspressifESP32, ESP32); +MS_MODEM_DELETE_SECURE_CLIENT(EspressifESP32, ESP32); -MS_MODEM_GET_NIST_TIME(EspressifESP32); +MS_MODEM_GET_NIST_TIME(EspressifESP32, ESP32); MS_MODEM_GET_MODEM_SIGNAL_QUALITY(EspressifESP32); MS_MODEM_GET_MODEM_BATTERY_DATA(EspressifESP32); diff --git a/src/modems/EspressifESP32.h b/src/modems/EspressifESP32.h index 77b8edad4..63b1f1352 100644 --- a/src/modems/EspressifESP32.h +++ b/src/modems/EspressifESP32.h @@ -80,7 +80,7 @@ #undef MS_DEBUGGING_DEEP // Include other in-library and external dependencies -#include "TinyGsmClient.h" +#include "TinyGsmClientESP32.h" #include "Espressif.h" #ifdef MS_ESPRESSIFESP32_DEBUG_DEEP @@ -159,7 +159,7 @@ class EspressifESP32 : public Espressif { /** * @brief Public reference to the TinyGSM modem. */ - TinyGsm gsmModem; + TinyGsmESP32 gsmModem; protected: bool isInternetAvailable(void) override; diff --git a/src/modems/EspressifESP8266.cpp b/src/modems/EspressifESP8266.cpp index 40a9bc1be..742554d0b 100644 --- a/src/modems/EspressifESP8266.cpp +++ b/src/modems/EspressifESP8266.cpp @@ -36,12 +36,12 @@ MS_MODEM_CONNECT_INTERNET(EspressifESP8266, ESPRESSIF_RECONNECT_TIME_MS); MS_MODEM_DISCONNECT_INTERNET(EspressifESP8266); MS_MODEM_IS_INTERNET_AVAILABLE(EspressifESP8266); -MS_MODEM_CREATE_CLIENT(EspressifESP8266); -MS_MODEM_DELETE_CLIENT(EspressifESP8266); -MS_MODEM_CREATE_SECURE_CLIENT(EspressifESP8266); -MS_MODEM_DELETE_SECURE_CLIENT(EspressifESP8266); +MS_MODEM_CREATE_CLIENT(EspressifESP8266, ESP8266); +MS_MODEM_DELETE_CLIENT(EspressifESP8266, ESP8266); +MS_MODEM_CREATE_SECURE_CLIENT(EspressifESP8266, ESP8266); +MS_MODEM_DELETE_SECURE_CLIENT(EspressifESP8266, ESP8266); -MS_MODEM_GET_NIST_TIME(EspressifESP8266); +MS_MODEM_GET_NIST_TIME(EspressifESP8266, ESP8266); MS_MODEM_GET_MODEM_SIGNAL_QUALITY(EspressifESP8266); MS_MODEM_GET_MODEM_BATTERY_DATA(EspressifESP8266); diff --git a/src/modems/EspressifESP8266.h b/src/modems/EspressifESP8266.h index 631e602b3..ed53fca65 100644 --- a/src/modems/EspressifESP8266.h +++ b/src/modems/EspressifESP8266.h @@ -79,7 +79,7 @@ #undef MS_DEBUGGING_DEEP // Include other in-library and external dependencies -#include "TinyGsmClient.h" +#include "TinyGsmClientESP8266.h" #include "Espressif.h" #ifdef MS_ESPRESSIFESP8266_DEBUG_DEEP @@ -158,7 +158,7 @@ class EspressifESP8266 : public Espressif { /** * @brief Public reference to the TinyGSM modem. */ - TinyGsm gsmModem; + TinyGsmESP8266 gsmModem; protected: bool isInternetAvailable(void) override; diff --git a/src/modems/LoggerModemMacros.h b/src/modems/LoggerModemMacros.h index b732302f5..28b818999 100644 --- a/src/modems/LoggerModemMacros.h +++ b/src/modems/LoggerModemMacros.h @@ -433,15 +433,17 @@ * @brief Creates createClient functions for a specific modem subclass. * * @param specificModem The modem subclass + * @param TinyGSMType The type used for the TinyGSM modem * * @return The text of createClient functions specific to a single * modem subclass. */ -#define MS_MODEM_CREATE_CLIENT(specificModem) \ +#define MS_MODEM_CREATE_CLIENT(specificModem, TinyGSMType) \ Client* specificModem::createClient() { \ /* Use the new keyword to create a new client on the **heap** */ \ /* NOTE: Be sure to delete this object when you're done with it! */ \ - Client* newClient = new TinyGsmClient(gsmModem); \ + Client* newClient = \ + new TinyGsm##TinyGSMType::GsmClient##TinyGSMType(gsmModem); \ return newClient; \ } @@ -450,11 +452,12 @@ * clients. * * @param specificModem The modem subclass + * @param TinyGSMType The type used for the TinyGSM modem * * @return The text of createSecureClient functions specific to a single * modem subclass. */ -#define MS_MODEM_CREATE_NULL_SECURE_CLIENTS(specificModem) \ +#define MS_MODEM_CREATE_NULL_SECURE_CLIENTS(specificModem, TinyGSMType) \ Client* specificModem::createSecureClient( \ SSLAuthMode, SSLVersion, const char*, const char*, const char*) { \ return nullptr; \ @@ -473,90 +476,102 @@ * For modems that don't support SSL, this returns a nullptr. * * @param specificModem The modem subclass + * @param TinyGSMType The type used for the TinyGSM modem * * @return The text of createClient functions specific to a single * modem subclass. */ #if defined(TINY_GSM_MODEM_HAS_SSL) && defined(TINY_GSM_MODEM_CAN_SPECIFY_CERTS) -#define MS_MODEM_CREATE_SECURE_CLIENT(specificModem) \ +#define MS_MODEM_CREATE_SECURE_CLIENT(specificModem, TinyGSMType) \ Client* specificModem::createSecureClient() { \ /* Use the new keyword to create a new client on the **heap** */ \ /* NOTE: Be sure to delete this object when you're done with it! */ \ - Client* newClient = new TinyGsmClientSecure(gsmModem); \ + Client* newClient = \ + new TinyGsm##TinyGSMType::GsmClientSecure##TinyGSMType(gsmModem); \ return newClient; \ } \ Client* specificModem::createSecureClient( \ SSLAuthMode sslAuthMode, SSLVersion sslVersion, \ const char* CAcertName, const char* clientCertName, \ const char* clientKeyName) { \ - Client* newClient = new TinyGsmClientSecure( \ - gsmModem, sslAuthMode, sslVersion, CAcertName, clientCertName, \ - clientKeyName); \ + Client* newClient = \ + new TinyGsm##TinyGSMType::GsmClientSecure##TinyGSMType( \ + gsmModem, sslAuthMode, sslVersion, CAcertName, clientCertName, \ + clientKeyName); \ return newClient; \ } \ Client* specificModem::createSecureClient( \ const char* pskIdent, const char* psKey, SSLVersion sslVersion) { \ - Client* newClient = new TinyGsmClientSecure(gsmModem, pskIdent, psKey, \ - sslVersion); \ + Client* newClient = \ + new TinyGsm##TinyGSMType::GsmClientSecure##TinyGSMType( \ + gsmModem, pskIdent, psKey, sslVersion); \ return newClient; \ } \ Client* specificModem::createSecureClient(const char* pskTableName, \ SSLVersion sslVersion) { \ - Client* newClient = new TinyGsmClientSecure(gsmModem, pskTableName, \ - sslVersion); \ + Client* newClient = \ + new TinyGsm##TinyGSMType::GsmClientSecure##TinyGSMType( \ + gsmModem, pskTableName, sslVersion); \ return newClient; \ } #elif defined(TINY_GSM_MODEM_HAS_SSL) -#define MS_MODEM_CREATE_SECURE_CLIENT(specificModem) \ - Client* specificModem::createSecureClient() { \ - /* Use the new keyword to create a new client on the **heap** */ \ - /* NOTE: Be sure to delete this object when you're done with it! */ \ - Client* newClient = new TinyGsmClientSecure(gsmModem); \ - return newClient; \ - } \ - MS_MODEM_CREATE_NULL_SECURE_CLIENTS(specificModem) +#define MS_MODEM_CREATE_SECURE_CLIENT(specificModem, TinyGSMType) \ + Client* specificModem::createSecureClient() { \ + /* Use the new keyword to create a new client on the **heap** */ \ + /* NOTE: Be sure to delete this object when you're done with it! */ \ + Client* newClient = \ + new TinyGsm##TinyGSMType::GsmClientSecure##TinyGSMType(gsmModem); \ + return newClient; \ + } \ + MS_MODEM_CREATE_NULL_SECURE_CLIENTS(specificModem, TinyGSMType) #else -#define MS_MODEM_CREATE_SECURE_CLIENT(specificModem) \ - Client* specificModem::createSecureClient() { \ - return nullptr; \ - } \ - MS_MODEM_CREATE_NULL_SECURE_CLIENTS(specificModem) +#define MS_MODEM_CREATE_SECURE_CLIENT(specificModem, TinyGSMType) \ + Client* specificModem::createSecureClient() { \ + return nullptr; \ + } \ + MS_MODEM_CREATE_NULL_SECURE_CLIENTS(specificModem, TinyGSMType) #endif /** * @brief Creates a deleteClient function for a specific modem subclass. * * @param specificModem The modem subclass + * @param TinyGSMType The type used for the TinyGSM modem * * @return The text of deleteClient function specific to a single modem * subclass. */ -#define MS_MODEM_DELETE_CLIENT(specificModem) \ - void specificModem::deleteClient(Client* client) { \ - if (client != nullptr) { \ - TinyGsmClient* cast_pointer = static_cast(client); \ - delete cast_pointer; \ - } \ +#define MS_MODEM_DELETE_CLIENT(specificModem, TinyGSMType) \ + void specificModem::deleteClient(Client* client) { \ + if (client != nullptr) { \ + TinyGsm##TinyGSMType::GsmClient##TinyGSMType* cast_pointer = \ + static_cast( \ + client); \ + delete cast_pointer; \ + } \ } /** * @def MS_MODEM_DELETE_SECURE_CLIENT * @brief Creates a deleteClient function for a specific modem subclass. * * @param specificModem The modem subclass + * @param TinyGSMType The type used for the TinyGSM modem * * @return The text of deleteSecureClient function specific to a single modem * subclass. */ #if defined(TINY_GSM_MODEM_HAS_SSL) -#define MS_MODEM_DELETE_SECURE_CLIENT(specificModem) \ - void specificModem::deleteSecureClient(Client* client) { \ - if (client != nullptr) { \ - TinyGsmClientSecure* cast_pointer = \ - static_cast(client); \ - delete cast_pointer; \ - } \ +#define MS_MODEM_DELETE_SECURE_CLIENT(specificModem, TinyGSMType) \ + void specificModem::deleteSecureClient(Client* client) { \ + if (client != nullptr) { \ + TinyGsm##TinyGSMType::GsmClientSecure##TinyGSMType* cast_pointer = \ + static_cast< \ + TinyGsm##TinyGSMType::GsmClientSecure##TinyGSMType*>( \ + client); \ + delete cast_pointer; \ + } \ } #else -#define MS_MODEM_DELETE_SECURE_CLIENT(specificModem) \ +#define MS_MODEM_DELETE_SECURE_CLIENT(specificModem, TinyGSMType) \ void specificModem::deleteSecureClient(Client*) {} #endif @@ -590,12 +605,13 @@ * https://tf.nist.gov/tf-cgi/servers.cgi * * @param specificModem The modem subclass + * @param TinyGSMType The type used for the TinyGSM modem * * @return The text of a getNISTTime() function specific to a single modem * subclass. * */ -#define MS_MODEM_GET_NIST_TIME(specificModem) \ +#define MS_MODEM_GET_NIST_TIME(specificModem, TinyGSMType) \ uint32_t specificModem::getNISTTime(void) { \ /** Check for and bail if not connected to the internet. */ \ if (!isInternetAvailable()) { \ @@ -609,7 +625,8 @@ } \ \ /** Make TCP connection. */ \ - TinyGsmClient gsmClient(gsmModem); /*new client, default mux*/ \ + TinyGsm##TinyGSMType::GsmClient##TinyGSMType gsmClient( \ + gsmModem); /*new client, default mux*/ \ MS_DBG(F("\nConnecting to NIST daytime Server")); \ bool connectionMade = gsmClient.connect("time.nist.gov", \ TIME_PROTOCOL_PORT, 15); \ diff --git a/src/modems/QuectelBG96.cpp b/src/modems/QuectelBG96.cpp index 7e3bdbebc..215271117 100644 --- a/src/modems/QuectelBG96.cpp +++ b/src/modems/QuectelBG96.cpp @@ -41,12 +41,12 @@ MS_MODEM_CONNECT_INTERNET(QuectelBG96); MS_MODEM_DISCONNECT_INTERNET(QuectelBG96); MS_MODEM_IS_INTERNET_AVAILABLE(QuectelBG96); -MS_MODEM_CREATE_CLIENT(QuectelBG96); -MS_MODEM_DELETE_CLIENT(QuectelBG96); -MS_MODEM_CREATE_SECURE_CLIENT(QuectelBG96); -MS_MODEM_DELETE_SECURE_CLIENT(QuectelBG96); +MS_MODEM_CREATE_CLIENT(QuectelBG96, BG96); +MS_MODEM_DELETE_CLIENT(QuectelBG96, BG96); +MS_MODEM_CREATE_SECURE_CLIENT(QuectelBG96, BG96); +MS_MODEM_DELETE_SECURE_CLIENT(QuectelBG96, BG96); -MS_MODEM_GET_NIST_TIME(QuectelBG96); +MS_MODEM_GET_NIST_TIME(QuectelBG96, BG96); MS_MODEM_GET_MODEM_SIGNAL_QUALITY(QuectelBG96); MS_MODEM_GET_MODEM_BATTERY_DATA(QuectelBG96); diff --git a/src/modems/QuectelBG96.h b/src/modems/QuectelBG96.h index 902b94c7d..79e812704 100644 --- a/src/modems/QuectelBG96.h +++ b/src/modems/QuectelBG96.h @@ -88,7 +88,7 @@ #undef MS_DEBUGGING_DEEP // Include other in-library and external dependencies -#include "TinyGsmClient.h" +#include "TinyGsmClientBG96.h" #include "LoggerModem.h" #ifdef MS_QUECTELBG96_DEBUG_DEEP @@ -238,7 +238,7 @@ class QuectelBG96 : public loggerModem { /** * @brief Public reference to the TinyGSM modem. */ - TinyGsm gsmModem; + TinyGsmBG96 gsmModem; protected: bool isInternetAvailable(void) override; diff --git a/src/modems/SIMComSIM7000.cpp b/src/modems/SIMComSIM7000.cpp index c7fd33414..09dca62f8 100644 --- a/src/modems/SIMComSIM7000.cpp +++ b/src/modems/SIMComSIM7000.cpp @@ -41,12 +41,12 @@ MS_MODEM_CONNECT_INTERNET(SIMComSIM7000); MS_MODEM_DISCONNECT_INTERNET(SIMComSIM7000); MS_MODEM_IS_INTERNET_AVAILABLE(SIMComSIM7000); -MS_MODEM_CREATE_CLIENT(SIMComSIM7000); -MS_MODEM_DELETE_CLIENT(SIMComSIM7000); -MS_MODEM_CREATE_SECURE_CLIENT(SIMComSIM7000); -MS_MODEM_DELETE_SECURE_CLIENT(SIMComSIM7000); +MS_MODEM_CREATE_CLIENT(SIMComSIM7000, Sim7000SSL); +MS_MODEM_DELETE_CLIENT(SIMComSIM7000, Sim7000SSL); +MS_MODEM_CREATE_SECURE_CLIENT(SIMComSIM7000, Sim7000SSL); +MS_MODEM_DELETE_SECURE_CLIENT(SIMComSIM7000, Sim7000SSL); -MS_MODEM_GET_NIST_TIME(SIMComSIM7000); +MS_MODEM_GET_NIST_TIME(SIMComSIM7000, Sim7000SSL); MS_MODEM_GET_MODEM_SIGNAL_QUALITY(SIMComSIM7000); MS_MODEM_GET_MODEM_BATTERY_DATA(SIMComSIM7000); diff --git a/src/modems/SIMComSIM7000.h b/src/modems/SIMComSIM7000.h index e1533b661..26a2177e4 100644 --- a/src/modems/SIMComSIM7000.h +++ b/src/modems/SIMComSIM7000.h @@ -74,7 +74,7 @@ #undef MS_DEBUGGING_DEEP // Include other in-library and external dependencies -#include "TinyGsmClient.h" +#include "TinyGsmClientSIM7000SSL.h" #include "LoggerModem.h" #ifdef MS_SIMCOMSIM7000_DEBUG_DEEP @@ -224,7 +224,7 @@ class SIMComSIM7000 : public loggerModem { /** * @brief Public reference to the TinyGSM modem. */ - TinyGsm gsmModem; + TinyGsmSim7000SSL gsmModem; protected: bool isInternetAvailable(void) override; diff --git a/src/modems/SIMComSIM7080.cpp b/src/modems/SIMComSIM7080.cpp index 1cd681f0b..48bc7396c 100644 --- a/src/modems/SIMComSIM7080.cpp +++ b/src/modems/SIMComSIM7080.cpp @@ -71,12 +71,12 @@ MS_MODEM_CONNECT_INTERNET(SIMComSIM7080); MS_MODEM_DISCONNECT_INTERNET(SIMComSIM7080); MS_MODEM_IS_INTERNET_AVAILABLE(SIMComSIM7080); -MS_MODEM_CREATE_CLIENT(SIMComSIM7080); -MS_MODEM_DELETE_CLIENT(SIMComSIM7080); -MS_MODEM_CREATE_SECURE_CLIENT(SIMComSIM7080); -MS_MODEM_DELETE_SECURE_CLIENT(SIMComSIM7080); +MS_MODEM_CREATE_CLIENT(SIMComSIM7080, Sim7080); +MS_MODEM_DELETE_CLIENT(SIMComSIM7080, Sim7080); +MS_MODEM_CREATE_SECURE_CLIENT(SIMComSIM7080, Sim7080); +MS_MODEM_DELETE_SECURE_CLIENT(SIMComSIM7080, Sim7080); -MS_MODEM_GET_NIST_TIME(SIMComSIM7080); +MS_MODEM_GET_NIST_TIME(SIMComSIM7080, Sim7080); MS_MODEM_GET_MODEM_SIGNAL_QUALITY(SIMComSIM7080); MS_MODEM_GET_MODEM_BATTERY_DATA(SIMComSIM7080); diff --git a/src/modems/SIMComSIM7080.h b/src/modems/SIMComSIM7080.h index e6f9935ad..cacf8f4aa 100644 --- a/src/modems/SIMComSIM7080.h +++ b/src/modems/SIMComSIM7080.h @@ -66,7 +66,7 @@ #undef MS_DEBUGGING_DEEP // Include other in-library and external dependencies -#include "TinyGsmClient.h" +#include "TinyGsmClientSIM7080.h" #include "LoggerModem.h" #ifdef MS_SIMCOMSIM7080_DEBUG_DEEP @@ -219,7 +219,7 @@ class SIMComSIM7080 : public loggerModem { /** * @brief Public reference to the TinyGSM modem. */ - TinyGsm gsmModem; + TinyGsmSim7080 gsmModem; protected: bool isInternetAvailable(void) override; diff --git a/src/modems/SIMComSIM800.cpp b/src/modems/SIMComSIM800.cpp index 1f812baa3..a8ce4aa7c 100644 --- a/src/modems/SIMComSIM800.cpp +++ b/src/modems/SIMComSIM800.cpp @@ -41,12 +41,12 @@ MS_MODEM_CONNECT_INTERNET(SIMComSIM800); MS_MODEM_DISCONNECT_INTERNET(SIMComSIM800); MS_MODEM_IS_INTERNET_AVAILABLE(SIMComSIM800); -MS_MODEM_CREATE_CLIENT(SIMComSIM800); -MS_MODEM_DELETE_CLIENT(SIMComSIM800); -MS_MODEM_CREATE_SECURE_CLIENT(SIMComSIM800); -MS_MODEM_DELETE_SECURE_CLIENT(SIMComSIM800); +MS_MODEM_CREATE_CLIENT(SIMComSIM800, Sim800); +MS_MODEM_DELETE_CLIENT(SIMComSIM800, Sim800); +MS_MODEM_CREATE_SECURE_CLIENT(SIMComSIM800, Sim800); +MS_MODEM_DELETE_SECURE_CLIENT(SIMComSIM800, Sim800); -MS_MODEM_GET_NIST_TIME(SIMComSIM800); +MS_MODEM_GET_NIST_TIME(SIMComSIM800, Sim800); MS_MODEM_GET_MODEM_SIGNAL_QUALITY(SIMComSIM800); MS_MODEM_GET_MODEM_BATTERY_DATA(SIMComSIM800); diff --git a/src/modems/SIMComSIM800.h b/src/modems/SIMComSIM800.h index dfd722f0b..a9b38d248 100644 --- a/src/modems/SIMComSIM800.h +++ b/src/modems/SIMComSIM800.h @@ -78,7 +78,7 @@ #undef MS_DEBUGGING_DEEP // Include other in-library and external dependencies -#include "TinyGsmClient.h" +#include "TinyGsmClientSIM800.h" #include "LoggerModem.h" #ifdef MS_SIMCOMSIM800_DEBUG_DEEP @@ -226,7 +226,7 @@ class SIMComSIM800 : public loggerModem { /** * @brief Public reference to the TinyGSM modem. */ - TinyGsm gsmModem; + TinyGsmSim800 gsmModem; protected: bool isInternetAvailable(void) override; diff --git a/src/modems/SequansMonarch.cpp b/src/modems/SequansMonarch.cpp index 29b55972a..4b6a54b98 100644 --- a/src/modems/SequansMonarch.cpp +++ b/src/modems/SequansMonarch.cpp @@ -40,12 +40,12 @@ MS_MODEM_CONNECT_INTERNET(SequansMonarch); MS_MODEM_DISCONNECT_INTERNET(SequansMonarch); MS_MODEM_IS_INTERNET_AVAILABLE(SequansMonarch); -MS_MODEM_CREATE_CLIENT(SequansMonarch); -MS_MODEM_DELETE_CLIENT(SequansMonarch); -MS_MODEM_CREATE_SECURE_CLIENT(SequansMonarch); -MS_MODEM_DELETE_SECURE_CLIENT(SequansMonarch); +MS_MODEM_CREATE_CLIENT(SequansMonarch, SequansMonarch); +MS_MODEM_DELETE_CLIENT(SequansMonarch, SequansMonarch); +MS_MODEM_CREATE_SECURE_CLIENT(SequansMonarch, SequansMonarch); +MS_MODEM_DELETE_SECURE_CLIENT(SequansMonarch, SequansMonarch); -MS_MODEM_GET_NIST_TIME(SequansMonarch); +MS_MODEM_GET_NIST_TIME(SequansMonarch, SequansMonarch); MS_MODEM_GET_MODEM_SIGNAL_QUALITY(SequansMonarch); MS_MODEM_GET_MODEM_BATTERY_DATA(SequansMonarch); diff --git a/src/modems/SequansMonarch.h b/src/modems/SequansMonarch.h index cf8df5d26..867f3192e 100644 --- a/src/modems/SequansMonarch.h +++ b/src/modems/SequansMonarch.h @@ -79,7 +79,7 @@ #undef MS_DEBUGGING_DEEP // Include other in-library and external dependencies -#include "TinyGsmClient.h" +#include "TinyGsmClientSequansMonarch.h" #include "LoggerModem.h" #ifdef MS_SEQUANSMONARCH_DEBUG_DEEP @@ -257,7 +257,7 @@ class SequansMonarch : public loggerModem { /** * @brief Public reference to the TinyGSM modem. */ - TinyGsm gsmModem; + TinyGsmSequansMonarch gsmModem; protected: bool isInternetAvailable(void) override; diff --git a/src/modems/SodaqUBeeR410M.cpp b/src/modems/SodaqUBeeR410M.cpp index c538c93bc..df645eb9d 100644 --- a/src/modems/SodaqUBeeR410M.cpp +++ b/src/modems/SodaqUBeeR410M.cpp @@ -61,12 +61,12 @@ MS_MODEM_CONNECT_INTERNET(SodaqUBeeR410M); MS_MODEM_DISCONNECT_INTERNET(SodaqUBeeR410M); MS_MODEM_IS_INTERNET_AVAILABLE(SodaqUBeeR410M); -MS_MODEM_CREATE_CLIENT(SodaqUBeeR410M); -MS_MODEM_DELETE_CLIENT(SodaqUBeeR410M); -MS_MODEM_CREATE_SECURE_CLIENT(SodaqUBeeR410M); -MS_MODEM_DELETE_SECURE_CLIENT(SodaqUBeeR410M); +MS_MODEM_CREATE_CLIENT(SodaqUBeeR410M, SaraR4); +MS_MODEM_DELETE_CLIENT(SodaqUBeeR410M, SaraR4); +MS_MODEM_CREATE_SECURE_CLIENT(SodaqUBeeR410M, SaraR4); +MS_MODEM_DELETE_SECURE_CLIENT(SodaqUBeeR410M, SaraR4); -MS_MODEM_GET_NIST_TIME(SodaqUBeeR410M); +MS_MODEM_GET_NIST_TIME(SodaqUBeeR410M, SaraR4); MS_MODEM_GET_MODEM_SIGNAL_QUALITY(SodaqUBeeR410M); MS_MODEM_GET_MODEM_BATTERY_DATA(SodaqUBeeR410M); diff --git a/src/modems/SodaqUBeeR410M.h b/src/modems/SodaqUBeeR410M.h index 10636c50f..96b758544 100644 --- a/src/modems/SodaqUBeeR410M.h +++ b/src/modems/SodaqUBeeR410M.h @@ -135,7 +135,7 @@ #undef MS_DEBUGGING_DEEP // Include other in-library and external dependencies -#include "TinyGsmClient.h" +#include "TinyGsmClientSaraR4.h" #include "LoggerModem.h" #ifdef MS_SODAQUBEER410M_DEBUG_DEEP @@ -337,7 +337,7 @@ class SodaqUBeeR410M : public loggerModem { /** * @brief Public reference to the TinyGSM modem. */ - TinyGsm gsmModem; + TinyGsmSaraR4 gsmModem; #if F_CPU == 8000000L /** diff --git a/src/modems/SodaqUBeeU201.cpp b/src/modems/SodaqUBeeU201.cpp index 5e49c1243..3941b614a 100644 --- a/src/modems/SodaqUBeeU201.cpp +++ b/src/modems/SodaqUBeeU201.cpp @@ -40,12 +40,12 @@ MS_MODEM_CONNECT_INTERNET(SodaqUBeeU201); MS_MODEM_DISCONNECT_INTERNET(SodaqUBeeU201); MS_MODEM_IS_INTERNET_AVAILABLE(SodaqUBeeU201); -MS_MODEM_CREATE_CLIENT(SodaqUBeeU201); -MS_MODEM_DELETE_CLIENT(SodaqUBeeU201); -MS_MODEM_CREATE_SECURE_CLIENT(SodaqUBeeU201); -MS_MODEM_DELETE_SECURE_CLIENT(SodaqUBeeU201); +MS_MODEM_CREATE_CLIENT(SodaqUBeeU201, UBLOX); +MS_MODEM_DELETE_CLIENT(SodaqUBeeU201, UBLOX); +MS_MODEM_CREATE_SECURE_CLIENT(SodaqUBeeU201, UBLOX); +MS_MODEM_DELETE_SECURE_CLIENT(SodaqUBeeU201, UBLOX); -MS_MODEM_GET_NIST_TIME(SodaqUBeeU201); +MS_MODEM_GET_NIST_TIME(SodaqUBeeU201, UBLOX); MS_MODEM_GET_MODEM_SIGNAL_QUALITY(SodaqUBeeU201); MS_MODEM_GET_MODEM_BATTERY_DATA(SodaqUBeeU201); diff --git a/src/modems/SodaqUBeeU201.h b/src/modems/SodaqUBeeU201.h index e1daebbf9..475a0bef8 100644 --- a/src/modems/SodaqUBeeU201.h +++ b/src/modems/SodaqUBeeU201.h @@ -75,7 +75,7 @@ #undef MS_DEBUGGING_DEEP // Include other in-library and external dependencies -#include "TinyGsmClient.h" +#include "TinyGsmClientUBLOX.h" #include "LoggerModem.h" #ifdef MS_SODAQUBEEU201_DEBUG_DEEP @@ -232,7 +232,7 @@ class SodaqUBeeU201 : public loggerModem { /** * @brief Public reference to the TinyGSM modem. */ - TinyGsm gsmModem; + TinyGsmUBLOX gsmModem; protected: bool isInternetAvailable(void) override; From e92ba74436a71baae73d435a5579c267b972985d Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Tue, 17 Feb 2026 11:16:04 -0500 Subject: [PATCH 151/533] Use forceModemBaud function Signed-off-by: Sara Damiano --- .../EnviroDIY_Monitoring_Kit.ino | 35 +++++-------------- examples/menu_a_la_carte/menu_a_la_carte.ino | 31 ++++------------ 2 files changed, 14 insertions(+), 52 deletions(-) diff --git a/examples/EnviroDIY_Monitoring_Kit/EnviroDIY_Monitoring_Kit.ino b/examples/EnviroDIY_Monitoring_Kit/EnviroDIY_Monitoring_Kit.ino index 70d57e4e7..dcb80f5da 100644 --- a/examples/EnviroDIY_Monitoring_Kit/EnviroDIY_Monitoring_Kit.ino +++ b/examples/EnviroDIY_Monitoring_Kit/EnviroDIY_Monitoring_Kit.ino @@ -414,7 +414,7 @@ void setup() { /** Start [setup_serial_begins] */ // Start the serial connection with the modem #if defined(USE_CELLULAR_BEE) || defined(USE_WIFI_BEE) - PRINTOUT(F("Starting modem connection at"), modemBaud, F(" baud")); + PRINTOUT(F("Starting modem connection at"), modemBaud, F("baud")); modemSerial.begin(modemBaud); #endif @@ -491,17 +491,9 @@ void setup() { modem.modemWake(); // NOTE: This will also set up the modem // WARNING: PLEASE REMOVE AUTOBAUDING FOR PRODUCTION CODE! if (!modem.gsmModem.testAT()) { - PRINTOUT(F("Attempting autobauding..")); - uint32_t foundBaud = TinyGsmAutoBaud(modemSerial); - if (foundBaud != 0 || (modemBaud > 57600 && F_CPU == 8000000L)) { - PRINTOUT(F("Got modem response at baud of"), foundBaud, - F("Firing an attempt to change the baud rate to"), - modemBaud); - modem.gsmModem.sendAT(GF("+UART_DEF="), modemBaud, F(",8,1,0,0")); - modem.gsmModem.waitResponse(); - modemSerial.end(); - modemSerial.begin(modemBaud); - } + PRINTOUT(F("Attempting to force the modem baud rate.")); + modem.gsmModem.forceModemBaud(modemSerial, + static_cast(modemBaud)); } /** End [setup_esp] */ #endif @@ -514,21 +506,10 @@ void setup() { modem.modemWake(); // NOTE: This will also set up the modem // WARNING: PLEASE REMOVE AUTOBAUDING FOR PRODUCTION CODE! if (!modem.gsmModem.testAT()) { - PRINTOUT(F("Attempting autobauding..")); - uint32_t foundBaud = TinyGsmAutoBaud(modemSerial); - if (foundBaud != 0 && !(F_CPU <= 8000000L && foundBaud >= 115200) && - !(F_CPU <= 16000000L && foundBaud > 115200)) { - PRINTOUT(F("Got modem response at baud of"), foundBaud, - F("Firing an attempt to change the baud rate to"), - modemBaud); - modem.gsmModem.setBaud( - modemBaud); // Make sure we're *NOT* auto-bauding! - modem.gsmModem.waitResponse(); - modemSerial.end(); - modemSerial.begin(modemBaud); - } + PRINTOUT(F("Attempting to force the modem baud rate.")); + modem.gsmModem.forceModemBaud(modemSerial, + static_cast(modemBaud)); } - modem.gsmModem.setBaud(modemBaud); // Make sure we're *NOT* auto-bauding! modem.gsmModem.setNetworkMode(38); // set to LTE only // 2 Automatic // 13 GSM only @@ -538,7 +519,7 @@ void setup() { // 1 CAT-M // 2 NB-IoT // 3 CAT-M and NB-IoT - /** End [setup_sim7080] */ +/** End [setup_sim7080] */ #endif /** Start [setup_clock] */ diff --git a/examples/menu_a_la_carte/menu_a_la_carte.ino b/examples/menu_a_la_carte/menu_a_la_carte.ino index 909af5af6..27b10dbe6 100644 --- a/examples/menu_a_la_carte/menu_a_la_carte.ino +++ b/examples/menu_a_la_carte/menu_a_la_carte.ino @@ -3805,17 +3805,9 @@ void setup() { modem.modemWake(); // NOTE: This will also set up the modem // WARNING: PLEASE REMOVE AUTOBAUDING FOR PRODUCTION CODE! if (!modem.gsmModem.testAT()) { - PRINTOUT(F("Attempting autobauding..")); - uint32_t foundBaud = TinyGsmAutoBaud(modemSerial); - if (foundBaud != 0 || (modemBaud > 57600 && F_CPU == 8000000L)) { - PRINTOUT(F("Got modem response at baud of"), foundBaud, - F("Firing an attempt to change the baud rate to"), - modemBaud); - modem.gsmModem.sendAT(GF("+UART_DEF="), modemBaud, F(",8,1,0,0")); - modem.gsmModem.waitResponse(); - modemSerial.end(); - modemSerial.begin(modemBaud); - } + PRINTOUT(F("Attempting to force the modem baud rate.")); + modem.gsmModem.forceModemBaud(modemSerial, + static_cast(modemBaud)); } /** End [setup_esp] */ #endif @@ -3836,21 +3828,10 @@ void setup() { modem.modemWake(); // NOTE: This will also set up the modem // WARNING: PLEASE REMOVE AUTOBAUDING FOR PRODUCTION CODE! if (!modem.gsmModem.testAT()) { - PRINTOUT(F("Attempting autobauding..")); - uint32_t foundBaud = TinyGsmAutoBaud(modemSerial); - if (foundBaud != 0 && !(F_CPU <= 8000000L && foundBaud >= 115200) && - !(F_CPU <= 16000000L && foundBaud > 115200)) { - PRINTOUT(F("Got modem response at baud of"), foundBaud, - F("Firing an attempt to change the baud rate to"), - modemBaud); - modem.gsmModem.setBaud( - modemBaud); // Make sure we're *NOT* auto-bauding! - modem.gsmModem.waitResponse(); - modemSerial.end(); - modemSerial.begin(modemBaud); - } + PRINTOUT(F("Attempting to force the modem baud rate.")); + modem.gsmModem.forceModemBaud(modemSerial, + static_cast(modemBaud)); } - modem.gsmModem.setBaud(modemBaud); // Make sure we're *NOT* auto-bauding! modem.gsmModem.setNetworkMode(38); // set to LTE only // 2 Automatic // 13 GSM only From 24b74845e59b62ddd9408cb3843a28a93a746a6f Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Tue, 17 Feb 2026 11:16:17 -0500 Subject: [PATCH 152/533] Spelling Signed-off-by: Sara Damiano --- cspell.json | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/cspell.json b/cspell.json index 1f2c4d2dc..c4f7fcabd 100644 --- a/cspell.json +++ b/cspell.json @@ -222,6 +222,7 @@ "RSSI", "RUNSTBY", "SAMD", + "SARAR4", "sdamiano", "SDCARD", "SDHC", @@ -284,5 +285,11 @@ "µsec" ], "ignoreWords": [], - "ignorePaths": ["platformio.ini", "*doxyfile*", ".vscode"] + "ignorePaths": [ + "platformio.ini", + "*doxyfile*", + ".vscode", + "library.json", + "**/lib/**" + ] } From eef3dff5dce7bd685dfd2bc6ce9c34e5b1683b9c Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Tue, 17 Feb 2026 11:38:32 -0500 Subject: [PATCH 153/533] Remove all TinyGSM/MQTT related defines from examples. Including them in the sketch instead of the overall config can cause one-rule violations. Signed-off-by: Sara Damiano --- docs/Getting-Started/Getting-Started.md | 3 -- examples/AWS_IoT_Core/AWS_IoT_Core.ino | 15 ---------- .../EnviroDIY_Monitoring_Kit.ino | 13 -------- .../DRWI_CitizenScience/DRWI_2G/DRWI_2G.ino | 12 -------- .../DRWI_2G/platformio.ini | 3 -- .../DRWI_DigiLTE/DRWI_DigiLTE.ino | 12 -------- .../DRWI_Mayfly1/DRWI_Mayfly1.ino | 12 -------- .../DRWI_Mayfly1_WiFi/DRWI_Mayfly1_WiFi.ino | 12 -------- .../DRWI_NoCellular/platformio.ini | 3 -- .../DRWI_SIM7080LTE/DRWI_SIM7080LTE.ino | 12 -------- .../platformio.ini | 3 -- .../baro_rho_correction.ino | 13 -------- examples/baro_rho_correction/platformio.ini | 3 -- examples/double_logger/double_logger.ino | 12 -------- examples/double_logger/platformio.ini | 3 -- examples/logging_to_MMW/logging_to_MMW.ino | 12 -------- .../logging_to_ThingSpeak.ino | 12 -------- examples/logging_to_ThingSpeak/platformio.ini | 3 -- examples/menu_a_la_carte/ReadMe.md | 30 ++----------------- examples/menu_a_la_carte/menu_a_la_carte.ino | 12 -------- examples/menu_a_la_carte/platformio.ini | 3 -- examples/simple_logging/platformio.ini | 3 -- examples/single_sensor/platformio.ini | 3 -- extras/sdi12_address_change/platformio.ini | 3 -- src/ModSensorConfig.h | 12 ++++++++ 25 files changed, 14 insertions(+), 210 deletions(-) diff --git a/docs/Getting-Started/Getting-Started.md b/docs/Getting-Started/Getting-Started.md index 5270fe4c9..b05bc08df 100644 --- a/docs/Getting-Started/Getting-Started.md +++ b/docs/Getting-Started/Getting-Started.md @@ -102,9 +102,6 @@ lib_ldf_mode = deep+ build_flags = -DSDI12_EXTERNAL_PCINT -DNEOSWSERIAL_EXTERNAL_PCINT - -DMQTT_MAX_PACKET_SIZE=240 - -DTINY_GSM_RX_BUFFER=64 - -DTINY_GSM_YIELD_MS=2 ``` - Download the "ino" file for whatever example you think will be most similar to what you'll be doing. diff --git a/examples/AWS_IoT_Core/AWS_IoT_Core.ino b/examples/AWS_IoT_Core/AWS_IoT_Core.ino index 265cbc10f..bac3d1135 100644 --- a/examples/AWS_IoT_Core/AWS_IoT_Core.ino +++ b/examples/AWS_IoT_Core/AWS_IoT_Core.ino @@ -26,21 +26,6 @@ * @m_examplenavigation{example_aws_iot_core,} * ======================================================================= */ -// ========================================================================== -// Defines for TinyGSM -// ========================================================================== -/** Start [defines] */ -#ifndef TINY_GSM_RX_BUFFER -#define TINY_GSM_RX_BUFFER 64 -#endif -#ifndef TINY_GSM_YIELD_MS -#define TINY_GSM_YIELD_MS 2 -#endif -#ifndef MQTT_MAX_PACKET_SIZE -#define MQTT_MAX_PACKET_SIZE 1024 -#endif -/** End [defines] */ - // ========================================================================== // Include the libraries required for any data logger // ========================================================================== diff --git a/examples/EnviroDIY_Monitoring_Kit/EnviroDIY_Monitoring_Kit.ino b/examples/EnviroDIY_Monitoring_Kit/EnviroDIY_Monitoring_Kit.ino index dcb80f5da..3c876f012 100644 --- a/examples/EnviroDIY_Monitoring_Kit/EnviroDIY_Monitoring_Kit.ino +++ b/examples/EnviroDIY_Monitoring_Kit/EnviroDIY_Monitoring_Kit.ino @@ -113,19 +113,6 @@ const char* samplingFeature = "12345678-abcd-1234-ef00-1234567890ab"; // Sampli /** End [monitor_mw_uuids] */ -// ========================================================================== -// Defines for TinyGSM -// ========================================================================== -/** Start [defines] */ -#ifndef TINY_GSM_RX_BUFFER -#define TINY_GSM_RX_BUFFER 256 -#endif -#ifndef TINY_GSM_YIELD_MS -#define TINY_GSM_YIELD_MS 2 -#endif -/** End [defines] */ - - // ========================================================================== // Include the libraries required for any data logger // ========================================================================== diff --git a/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_2G/DRWI_2G.ino b/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_2G/DRWI_2G.ino index 0094f6723..d1a24e382 100644 --- a/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_2G/DRWI_2G.ino +++ b/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_2G/DRWI_2G.ino @@ -11,18 +11,6 @@ * @m_examplenavigation{example_drwi_2g,} * ======================================================================= */ -// ========================================================================== -// Defines for TinyGSM -// ========================================================================== -/** Start [defines] */ -#ifndef TINY_GSM_RX_BUFFER -#define TINY_GSM_RX_BUFFER 64 -#endif -#ifndef TINY_GSM_YIELD_MS -#define TINY_GSM_YIELD_MS 2 -#endif -/** End [defines] */ - // ========================================================================== // Include the libraries required for any data logger // ========================================================================== diff --git a/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_2G/platformio.ini b/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_2G/platformio.ini index 5fb25f094..da1f78fb1 100644 --- a/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_2G/platformio.ini +++ b/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_2G/platformio.ini @@ -29,9 +29,6 @@ lib_ignore = build_flags = -DSDI12_EXTERNAL_PCINT -DNEOSWSERIAL_EXTERNAL_PCINT - -DMQTT_MAX_PACKET_SIZE=240 - -DTINY_GSM_RX_BUFFER=64 - -DTINY_GSM_YIELD_MS=2 lib_deps = envirodiy/EnviroDIY_ModularSensors ; ^^ Use this when working from an official release of the library diff --git a/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_DigiLTE/DRWI_DigiLTE.ino b/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_DigiLTE/DRWI_DigiLTE.ino index cce098eec..ff04fb20e 100644 --- a/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_DigiLTE/DRWI_DigiLTE.ino +++ b/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_DigiLTE/DRWI_DigiLTE.ino @@ -12,18 +12,6 @@ * @m_examplenavigation{example_drwi_digilte,} * ======================================================================= */ -// ========================================================================== -// Defines for TinyGSM -// ========================================================================== -/** Start [defines] */ -#ifndef TINY_GSM_RX_BUFFER -#define TINY_GSM_RX_BUFFER 64 -#endif -#ifndef TINY_GSM_YIELD_MS -#define TINY_GSM_YIELD_MS 2 -#endif -/** End [defines] */ - // ========================================================================== // Include the libraries required for any data logger // ========================================================================== diff --git a/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_Mayfly1/DRWI_Mayfly1.ino b/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_Mayfly1/DRWI_Mayfly1.ino index d370764fa..f3c0149e7 100644 --- a/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_Mayfly1/DRWI_Mayfly1.ino +++ b/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_Mayfly1/DRWI_Mayfly1.ino @@ -18,18 +18,6 @@ * @m_examplenavigation{example_drwi_mayfly1,} * ======================================================================= */ -// ========================================================================== -// Defines for TinyGSM -// ========================================================================== -/** Start [defines] */ -#ifndef TINY_GSM_RX_BUFFER -#define TINY_GSM_RX_BUFFER 64 -#endif -#ifndef TINY_GSM_YIELD_MS -#define TINY_GSM_YIELD_MS 2 -#endif -/** End [defines] */ - // ========================================================================== // Include the libraries required for any data logger // ========================================================================== diff --git a/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_Mayfly1_WiFi/DRWI_Mayfly1_WiFi.ino b/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_Mayfly1_WiFi/DRWI_Mayfly1_WiFi.ino index 39beff0eb..6d467ace8 100644 --- a/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_Mayfly1_WiFi/DRWI_Mayfly1_WiFi.ino +++ b/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_Mayfly1_WiFi/DRWI_Mayfly1_WiFi.ino @@ -15,18 +15,6 @@ * @m_examplenavigation{example_drwi_mayfly1_wifi,} * ======================================================================= */ -// ========================================================================== -// Defines for TinyGSM -// ========================================================================== -/** Start [defines] */ -#ifndef TINY_GSM_RX_BUFFER -#define TINY_GSM_RX_BUFFER 256 -#endif -#ifndef TINY_GSM_YIELD_MS -#define TINY_GSM_YIELD_MS 2 -#endif -/** End [defines] */ - // ========================================================================== // Include the libraries required for any data logger // ========================================================================== diff --git a/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_NoCellular/platformio.ini b/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_NoCellular/platformio.ini index b54c81223..9db773578 100644 --- a/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_NoCellular/platformio.ini +++ b/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_NoCellular/platformio.ini @@ -29,9 +29,6 @@ lib_ignore = build_flags = -DSDI12_EXTERNAL_PCINT -DNEOSWSERIAL_EXTERNAL_PCINT - -DMQTT_MAX_PACKET_SIZE=240 - -DTINY_GSM_RX_BUFFER=64 - -DTINY_GSM_YIELD_MS=2 lib_deps = envirodiy/EnviroDIY_ModularSensors ; ^^ Use this when working from an official release of the library diff --git a/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_SIM7080LTE/DRWI_SIM7080LTE.ino b/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_SIM7080LTE/DRWI_SIM7080LTE.ino index b4d0589ea..e8c7bb0db 100644 --- a/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_SIM7080LTE/DRWI_SIM7080LTE.ino +++ b/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_SIM7080LTE/DRWI_SIM7080LTE.ino @@ -19,18 +19,6 @@ * @m_examplenavigation{example_drwi_ediylte,} * ======================================================================= */ -// ========================================================================== -// Defines for TinyGSM -// ========================================================================== -/** Start [defines] */ -#ifndef TINY_GSM_RX_BUFFER -#define TINY_GSM_RX_BUFFER 64 -#endif -#ifndef TINY_GSM_YIELD_MS -#define TINY_GSM_YIELD_MS 2 -#endif -/** End [defines] */ - // ========================================================================== // Include the libraries required for any data logger // ========================================================================== diff --git a/examples/OutdatedExamples/simple_logging_LearnEnviroDIY/platformio.ini b/examples/OutdatedExamples/simple_logging_LearnEnviroDIY/platformio.ini index 08d007b3e..921815d02 100644 --- a/examples/OutdatedExamples/simple_logging_LearnEnviroDIY/platformio.ini +++ b/examples/OutdatedExamples/simple_logging_LearnEnviroDIY/platformio.ini @@ -29,9 +29,6 @@ lib_ignore = build_flags = -DSDI12_EXTERNAL_PCINT -DNEOSWSERIAL_EXTERNAL_PCINT - -DMQTT_MAX_PACKET_SIZE=240 - -DTINY_GSM_RX_BUFFER=64 - -DTINY_GSM_YIELD_MS=2 lib_deps = envirodiy/EnviroDIY_ModularSensors ; ^^ Use this when working from an official release of the library diff --git a/examples/baro_rho_correction/baro_rho_correction.ino b/examples/baro_rho_correction/baro_rho_correction.ino index af426a659..0b8fac091 100644 --- a/examples/baro_rho_correction/baro_rho_correction.ino +++ b/examples/baro_rho_correction/baro_rho_correction.ino @@ -11,19 +11,6 @@ * @m_examplenavigation{example_baro_rho,} * ======================================================================= */ -// ========================================================================== -// Defines for TinyGSM -// NOTE: These only work with TinyGSM. -// ========================================================================== -/** Start [defines] */ -#ifndef TINY_GSM_RX_BUFFER -#define TINY_GSM_RX_BUFFER 64 -#endif -#ifndef TINY_GSM_YIELD_MS -#define TINY_GSM_YIELD_MS 2 -#endif -/** End [defines] */ - // ========================================================================== // Include the libraries required for any data logger diff --git a/examples/baro_rho_correction/platformio.ini b/examples/baro_rho_correction/platformio.ini index 92bde228c..06fed9f6b 100644 --- a/examples/baro_rho_correction/platformio.ini +++ b/examples/baro_rho_correction/platformio.ini @@ -30,9 +30,6 @@ lib_ignore = build_flags = -DSDI12_EXTERNAL_PCINT -DNEOSWSERIAL_EXTERNAL_PCINT - -DMQTT_MAX_PACKET_SIZE=240 - -DTINY_GSM_RX_BUFFER=64 - -DTINY_GSM_YIELD_MS=2 lib_deps = envirodiy/EnviroDIY_ModularSensors ; ^^ Use this when working from an official release of the library diff --git a/examples/double_logger/double_logger.ino b/examples/double_logger/double_logger.ino index 903d6e01e..838157108 100644 --- a/examples/double_logger/double_logger.ino +++ b/examples/double_logger/double_logger.ino @@ -12,18 +12,6 @@ * @m_examplenavigation{example_double_log,} * ======================================================================= */ -// ========================================================================== -// Defines for TinyGSM -// ========================================================================== -/** Start [defines] */ -#ifndef TINY_GSM_RX_BUFFER -#define TINY_GSM_RX_BUFFER 64 -#endif -#ifndef TINY_GSM_YIELD_MS -#define TINY_GSM_YIELD_MS 2 -#endif -/** End [defines] */ - // ========================================================================== // Include the libraries required for any data logger // ========================================================================== diff --git a/examples/double_logger/platformio.ini b/examples/double_logger/platformio.ini index 8f4230c1d..970bdd3d5 100644 --- a/examples/double_logger/platformio.ini +++ b/examples/double_logger/platformio.ini @@ -29,9 +29,6 @@ lib_ignore = build_flags = -DSDI12_EXTERNAL_PCINT -DNEOSWSERIAL_EXTERNAL_PCINT - -DMQTT_MAX_PACKET_SIZE=240 - -DTINY_GSM_RX_BUFFER=64 - -DTINY_GSM_YIELD_MS=2 lib_deps = envirodiy/EnviroDIY_ModularSensors ; ^^ Use this when working from an official release of the library diff --git a/examples/logging_to_MMW/logging_to_MMW.ino b/examples/logging_to_MMW/logging_to_MMW.ino index 94bab98e9..5a9554b3c 100644 --- a/examples/logging_to_MMW/logging_to_MMW.ino +++ b/examples/logging_to_MMW/logging_to_MMW.ino @@ -11,18 +11,6 @@ * @m_examplenavigation{example_mmw,} * ======================================================================= */ -// ========================================================================== -// Defines for TinyGSM -// ========================================================================== -/** Start [defines] */ -#ifndef TINY_GSM_RX_BUFFER -#define TINY_GSM_RX_BUFFER 64 -#endif -#ifndef TINY_GSM_YIELD_MS -#define TINY_GSM_YIELD_MS 2 -#endif -/** End [defines] */ - // ========================================================================== // Include the libraries required for any data logger // ========================================================================== diff --git a/examples/logging_to_ThingSpeak/logging_to_ThingSpeak.ino b/examples/logging_to_ThingSpeak/logging_to_ThingSpeak.ino index 31b37f2bd..285d52c85 100644 --- a/examples/logging_to_ThingSpeak/logging_to_ThingSpeak.ino +++ b/examples/logging_to_ThingSpeak/logging_to_ThingSpeak.ino @@ -12,18 +12,6 @@ * @m_examplenavigation{example_thingspeak,} * ======================================================================= */ -// ========================================================================== -// Defines for TinyGSM -// ========================================================================== -/** Start [defines] */ -#ifndef TINY_GSM_RX_BUFFER -#define TINY_GSM_RX_BUFFER 64 -#endif -#ifndef TINY_GSM_YIELD_MS -#define TINY_GSM_YIELD_MS 2 -#endif -/** End [defines] */ - // ========================================================================== // Include the libraries required for any data logger // ========================================================================== diff --git a/examples/logging_to_ThingSpeak/platformio.ini b/examples/logging_to_ThingSpeak/platformio.ini index 28ada0e2a..5c60bf4ee 100644 --- a/examples/logging_to_ThingSpeak/platformio.ini +++ b/examples/logging_to_ThingSpeak/platformio.ini @@ -29,9 +29,6 @@ lib_ignore = build_flags = -DSDI12_EXTERNAL_PCINT -DNEOSWSERIAL_EXTERNAL_PCINT - -DMQTT_MAX_PACKET_SIZE=240 - -DTINY_GSM_RX_BUFFER=64 - -DTINY_GSM_YIELD_MS=2 lib_deps = envirodiy/EnviroDIY_ModularSensors ; ^^ Use this when working from an official release of the library diff --git a/examples/menu_a_la_carte/ReadMe.md b/examples/menu_a_la_carte/ReadMe.md index 28cf8875c..f5f6b7d56 100644 --- a/examples/menu_a_la_carte/ReadMe.md +++ b/examples/menu_a_la_carte/ReadMe.md @@ -27,9 +27,7 @@ ___ - [Example showing all possible functionality](#example-showing-all-possible-functionality) - [Walking Through the Code](#walking-through-the-code) - - [Defines and Includes](#defines-and-includes) - - [Defines for the Arduino IDE](#defines-for-the-arduino-ide) - - [Library Includes](#library-includes) + - [Library Includes](#library-includes) - [Logger Settings](#logger-settings) - [Creating Extra Serial Ports](#creating-extra-serial-ports) - [AVR Boards](#avr-boards) @@ -160,31 +158,7 @@ ___ -## Defines and Includes - -### Defines for the Arduino IDE - -The top few lines of the examples set defines of buffer sizes and yields needed for the Arduino IDE. -That IDE read any defines within the top few lines and applies them as build flags for the processor. -This is *not* standard behavior for C++ (which is what Arduino code really is) - this is a unique aspect of the Arduino IDE. - - - -If you are using PlatformIO, you should instead set these as global build flags in your platformio.ini. -This is standard behavior for C++. - -```ini -build_flags = - -D SDI12_EXTERNAL_PCINT - -D NEOSWSERIAL_EXTERNAL_PCINT - -D MQTT_MAX_PACKET_SIZE=240 - -D TINY_GSM_RX_BUFFER=64 - -D TINY_GSM_YIELD_MS=2 -``` - -___ - -### Library Includes +## Library Includes Next, include the libraries needed for every program using ModularSensors. diff --git a/examples/menu_a_la_carte/menu_a_la_carte.ino b/examples/menu_a_la_carte/menu_a_la_carte.ino index 27b10dbe6..92d4cb002 100644 --- a/examples/menu_a_la_carte/menu_a_la_carte.ino +++ b/examples/menu_a_la_carte/menu_a_la_carte.ino @@ -17,18 +17,6 @@ // this makes sure the argument is expanded before converting to string #define STR(X) STR_(X) -// ========================================================================== -// Defines for TinyGSM -// ========================================================================== -/** Start [defines] */ -#ifndef TINY_GSM_RX_BUFFER -#define TINY_GSM_RX_BUFFER 64 -#endif -#ifndef TINY_GSM_YIELD_MS -#define TINY_GSM_YIELD_MS 2 -#endif -/** End [defines] */ - // ========================================================================== // Include the libraries required for any data logger diff --git a/examples/menu_a_la_carte/platformio.ini b/examples/menu_a_la_carte/platformio.ini index 273cc67a4..c55e718b3 100644 --- a/examples/menu_a_la_carte/platformio.ini +++ b/examples/menu_a_la_carte/platformio.ini @@ -29,9 +29,6 @@ lib_ignore = build_flags = -DSDI12_EXTERNAL_PCINT -DNEOSWSERIAL_EXTERNAL_PCINT - -DMQTT_MAX_PACKET_SIZE=240 - -DTINY_GSM_RX_BUFFER=64 - -DTINY_GSM_YIELD_MS=2 -DENABLE_SERIAL2 -DENABLE_SERIAL3 ; -D BUILD_MODEM_DIGI_XBEE_CELLULAR_TRANSPARENT ; Turn on first time w/ a Digi LTE-M module diff --git a/examples/simple_logging/platformio.ini b/examples/simple_logging/platformio.ini index 0b9f4778f..9a51f192c 100644 --- a/examples/simple_logging/platformio.ini +++ b/examples/simple_logging/platformio.ini @@ -29,9 +29,6 @@ lib_ignore = build_flags = -DSDI12_EXTERNAL_PCINT -DNEOSWSERIAL_EXTERNAL_PCINT - -DMQTT_MAX_PACKET_SIZE=240 - -DTINY_GSM_RX_BUFFER=64 - -DTINY_GSM_YIELD_MS=2 lib_deps = envirodiy/EnviroDIY_ModularSensors ; ^^ Use this when working from an official release of the library diff --git a/examples/single_sensor/platformio.ini b/examples/single_sensor/platformio.ini index d188380d5..13eee776b 100644 --- a/examples/single_sensor/platformio.ini +++ b/examples/single_sensor/platformio.ini @@ -29,9 +29,6 @@ lib_ignore = build_flags = -DSDI12_EXTERNAL_PCINT -DNEOSWSERIAL_EXTERNAL_PCINT - -DMQTT_MAX_PACKET_SIZE=240 - -DTINY_GSM_RX_BUFFER=64 - -DTINY_GSM_YIELD_MS=2 lib_deps = envirodiy/EnviroDIY_ModularSensors ; ^^ Use this when working from an official release of the library diff --git a/extras/sdi12_address_change/platformio.ini b/extras/sdi12_address_change/platformio.ini index 3c0cc96a2..bc5744755 100644 --- a/extras/sdi12_address_change/platformio.ini +++ b/extras/sdi12_address_change/platformio.ini @@ -30,9 +30,6 @@ lib_ignore = build_flags = -DSDI12_EXTERNAL_PCINT -DNEOSWSERIAL_EXTERNAL_PCINT - -DMQTT_MAX_PACKET_SIZE=240 - -DTINY_GSM_RX_BUFFER=64 - -DTINY_GSM_YIELD_MS=2 -DENABLE_SERIAL2 -DENABLE_SERIAL3 lib_deps = diff --git a/src/ModSensorConfig.h b/src/ModSensorConfig.h index 5484a612c..91cf7149a 100644 --- a/src/ModSensorConfig.h +++ b/src/ModSensorConfig.h @@ -271,6 +271,18 @@ #define TINY_GSM_RX_BUFFER 64 #endif +#ifndef TINY_GSM_YIELD_MS +/** + * @brief The number of milliseconds to yield to the GSM module when using + * TinyGSM. + * + * If you are using a slow baud rate to communicate with your module, this delay + * is set to prevent command responses from being spliced apart. This is + * especially important when using a faster processor. + */ +#define TINY_GSM_YIELD_MS 2 +#endif + #ifndef MS_MQTT_MAX_PACKET_SIZE /** * @brief Configure the size of the PubSubClient buffer for MQTT publishers. From b0a276f4e7b7fa0aef018802f76eb3d616e2e807 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Tue, 17 Feb 2026 12:14:19 -0500 Subject: [PATCH 154/533] Update changelog/dependencies Signed-off-by: Sara Damiano --- ChangeLog.md | 3 +++ continuous_integration/dependencies.json | 4 ++-- examples/example_dependencies.json | 2 +- library.json | 2 +- 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/ChangeLog.md b/ChangeLog.md index 9ea4f009c..2bf095881 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -37,6 +37,7 @@ The two functions have been consolidated into one function with four arguments, To achieve the same functionality as the old `updateAllSensors()` function (ie, only updating values), set all of the arguments to false. - Applied many suggestions from Code Rabbit AI. - Moved outdated examples to a new "Outdated" folder, with a subfolder for the DRWI examples +- When importing TinyGSM for the modem objects, the specific modem client headers are now imported directly rather than importing the TinyGsmClient.h header which defines typedefs for the sub-types. ### Added @@ -70,6 +71,8 @@ These values should generally be set in the specific sensor constructors and onl - Removed unnecessary copy doc calls for inherited functions and properties. - Removed all overrides of the powerUp and powerDown functions that are no longer needed since all sensors have two power pins built in. - Removed references to the EnviroDIY data portal. +- Removed all defines from examples sketches. +Defining values to be used by TinyGSM and/or the MQTT library here in addition to any defines in the ModSensorConfig.h or in a build configuration can lead to One Definition Rule violations because the define values are used when creating the classes from the templates in TinyGSM. ### Fixed diff --git a/continuous_integration/dependencies.json b/continuous_integration/dependencies.json index 6371fcbe7..b3dd52478 100644 --- a/continuous_integration/dependencies.json +++ b/continuous_integration/dependencies.json @@ -1,5 +1,5 @@ { - "action_cache_version": 45, + "action_cache_version": 46, "dependencies": [ { "name": "EnviroDIY_DS3231", @@ -68,7 +68,7 @@ { "name": "TinyGSM", "owner": "vshymanskyy", - "version": "https://github.com/EnviroDIY/TinyGSM#one_rule", + "version": "https://github.com/EnviroDIY/TinyGSM", "version_note": "~0.13.0", "note": "A small Arduino library for GPRS modules.", "authors": [ diff --git a/examples/example_dependencies.json b/examples/example_dependencies.json index 68194758b..ead9d87ef 100644 --- a/examples/example_dependencies.json +++ b/examples/example_dependencies.json @@ -26,7 +26,7 @@ "name": "Adafruit NeoPixel", "owner": "adafruit", "url": "https://github.com/adafruit/Adafruit_NeoPixel", - "version": "~1.15.3", + "version": "~1.15.4", "note": "Adafruit NeoPixel, for boards with a built in NeoPixel", "authors": ["Adafruit"], "frameworks": "arduino" diff --git a/library.json b/library.json index f3c67979c..da5cc2ff7 100644 --- a/library.json +++ b/library.json @@ -355,7 +355,7 @@ "name": "ANBSensorsModbus", "owner": "envirodiy", "url": "https://github.com/EnviroDIY/ANBSensorsModbus", - "version": "~0.4.1", + "version": "~0.4.2", "note": "A library for communicating with pH sensors manufactured by ANB Sensors using Modbus.", "authors": ["Sara Damiano"], "frameworks": "arduino" From de5c87a024376ae7dd064fae0ab2c2376167336e Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Tue, 17 Feb 2026 12:29:58 -0500 Subject: [PATCH 155/533] Fix modem baud in monitoring kit example Signed-off-by: Sara Damiano --- examples/EnviroDIY_Monitoring_Kit/EnviroDIY_Monitoring_Kit.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/EnviroDIY_Monitoring_Kit/EnviroDIY_Monitoring_Kit.ino b/examples/EnviroDIY_Monitoring_Kit/EnviroDIY_Monitoring_Kit.ino index 3c876f012..7ae601182 100644 --- a/examples/EnviroDIY_Monitoring_Kit/EnviroDIY_Monitoring_Kit.ino +++ b/examples/EnviroDIY_Monitoring_Kit/EnviroDIY_Monitoring_Kit.ino @@ -165,7 +165,7 @@ Logger dataLogger(LoggerID, samplingFeature, loggingInterval); // Create a reference to the serial port for the modem HardwareSerial& modemSerial = Serial1; // Use hardware serial if possible -const int32_t modemBaud = 115200; // Communication speed of the modem +int32_t modemBaud = 57600; // Communication speed of the modem // NOTE: This baud rate too fast for the Mayfly. We'll slow it down in the // setup. From 1715b16e3ec0e47263d37a72dfc1234654ba0155 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Thu, 12 Feb 2026 12:03:17 -0500 Subject: [PATCH 156/533] Add temporary hard coded pH sampling interval Signed-off-by: Sara Damiano --- src/sensors/ANBpH.cpp | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/sensors/ANBpH.cpp b/src/sensors/ANBpH.cpp index 815d83915..048046cd7 100644 --- a/src/sensors/ANBpH.cpp +++ b/src/sensors/ANBpH.cpp @@ -146,13 +146,17 @@ bool ANBpH::setup(void) { MS_DBG(F("..."), powerStyleSet ? F("success") : F("failed")); retVal &= powerStyleSet; - // Set sampling mode to continuous - // Since we are using controlled mode, continuous sampling means taking a - // measurement when asked, rather than at a set interval. - // The first pH measurement is returned significantly faster in continuous - // mode. - MS_DBG(F("Set sensor sampling mode to continuous...")); - bool intervalSet = _anb_sensor.setIntervalTime(0); + bool intervalSet = false; + if (_powerPin >= 0) { + // Set sampling interval to the expected sampling interval if the sensor + MS_DBG(F("Set sensor sampling interval to 15 minutes...")); + intervalSet = _anb_sensor.setIntervalTime(15); + } else { + // Set sampling interval to continuous if the sensor will be + // continuously powered (ie, a power style of ALWAYS_POWERED). + MS_DBG(F("Set sensor sampling interval to 0 (continuous)...")); + intervalSet = _anb_sensor.setIntervalTime(0); + } MS_DBG(F("..."), intervalSet ? F("success") : F("failed")); retVal &= intervalSet; From 5cc0aee971a55d83fbe1d7ea4274ed7ef7788619 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Tue, 17 Feb 2026 15:39:01 -0500 Subject: [PATCH 157/533] Correctly provide default value for power pin 2 for ANB pH and HydroCam Signed-off-by: Sara Damiano --- src/sensors/ANBpH.h | 10 ++++++---- src/sensors/GeoluxHydroCam.h | 6 ++++-- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/sensors/ANBpH.h b/src/sensors/ANBpH.h index 5ccfb481c..e135a38aa 100644 --- a/src/sensors/ANBpH.h +++ b/src/sensors/ANBpH.h @@ -486,11 +486,13 @@ class ANBpH : public Sensor { * average before giving a "final" result from the sensor; optional with a * default value of 1. */ - ANBpH(byte modbusAddress, Stream* stream, int8_t powerPin, int8_t powerPin2, - int8_t enablePin = -1, uint8_t measurementsToAverage = 1); + ANBpH(byte modbusAddress, Stream* stream, int8_t powerPin, + int8_t powerPin2 = -1, int8_t enablePin = -1, + uint8_t measurementsToAverage = 1); /// @copydoc ANBpH::ANBpH(byte, Stream*, int8_t, int8_t, int8_t, uint8_t) - ANBpH(byte modbusAddress, Stream& stream, int8_t powerPin, int8_t powerPin2, - int8_t enablePin = -1, uint8_t measurementsToAverage = 1); + ANBpH(byte modbusAddress, Stream& stream, int8_t powerPin, + int8_t powerPin2 = -1, int8_t enablePin = -1, + uint8_t measurementsToAverage = 1); /** * @brief Destroy the ANB pH object - no action taken */ diff --git a/src/sensors/GeoluxHydroCam.h b/src/sensors/GeoluxHydroCam.h index 317c533c0..899f6b1fe 100644 --- a/src/sensors/GeoluxHydroCam.h +++ b/src/sensors/GeoluxHydroCam.h @@ -268,14 +268,16 @@ class GeoluxHydroCam : public Sensor { * because the autofocus takes about 30s. Default false. */ GeoluxHydroCam(Stream* stream, int8_t powerPin, Logger& baseLogger, - int8_t powerPin2, const char* imageResolution = "1600x1200", + int8_t powerPin2 = -1, + const char* imageResolution = "1600x1200", const char* filePrefix = nullptr, bool alwaysAutoFocus = false); /** * @copydoc GeoluxHydroCam::GeoluxHydroCam */ GeoluxHydroCam(Stream& stream, int8_t powerPin, Logger& baseLogger, - int8_t powerPin2, const char* imageResolution = "1600x1200", + int8_t powerPin2 = -1, + const char* imageResolution = "1600x1200", const char* filePrefix = nullptr, bool alwaysAutoFocus = false); /** From 7fe098c66dd4b1e3bbdeecd6f32a75c3bdb95701 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Tue, 17 Feb 2026 16:21:27 -0500 Subject: [PATCH 158/533] Add the logging interval as a **required** parameter for the ANB pH sensor Signed-off-by: Sara Damiano --- ChangeLog.md | 5 ++++- src/sensors/ANBpH.cpp | 31 ++++++++++++++++++++++++------- src/sensors/ANBpH.h | 30 +++++++++++++++++++++++++----- 3 files changed, 53 insertions(+), 13 deletions(-) diff --git a/ChangeLog.md b/ChangeLog.md index 2bf095881..7ef597773 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -15,7 +15,10 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm - **BREAKING** Changed capitalization of `setInitialShortIntervals(#)` function - Previously the 'i' of initial was not capitalized. - Made the enabling and disabling of the watchdog the very first and very last steps of sleep to keep the watchdog enabled through the whole getting ready for bed and waking up process. -- **ANB pH** Changed timing slightly and simplified timing logic. +- **ANB pH** + - **BREAKING** The constructor has changed! +The logging interval has been added as a required parameter for the constructor! + - Changed timing slightly and simplified timing logic. - **Renamed** The EnviroDIYPublisher has been renamed the MonitorMyWatershedPublisher. This reflects changes to the website from years ago. There is a shell file and typedef to maintain backwards compatibility. diff --git a/src/sensors/ANBpH.cpp b/src/sensors/ANBpH.cpp index 048046cd7..9eabfb367 100644 --- a/src/sensors/ANBpH.cpp +++ b/src/sensors/ANBpH.cpp @@ -10,16 +10,17 @@ #include "ANBpH.h" -// The constructor - need the sensor type, modbus address, power pin, stream for -// data, and number of readings to average +// The constructor ANBpH::ANBpH(byte modbusAddress, Stream* stream, int8_t powerPin, - int8_t powerPin2, int8_t enablePin, uint8_t measurementsToAverage) + int16_t loggingIntervalMinutes, int8_t powerPin2, int8_t enablePin, + uint8_t measurementsToAverage) : Sensor("ANBpHSensor", ANB_PH_NUM_VARIABLES, ANB_PH_WARM_UP_TIME_MS, ANB_PH_STABILIZATION_TIME_MS, ANB_PH_2ND_VALUE_LOW_SALT, powerPin, -1, measurementsToAverage, ANB_PH_INC_CALC_VARIABLES), _anb_sensor(modbusAddress, stream, enablePin), _modbusAddress(modbusAddress), _stream(stream), + _loggingIntervalMinutes(loggingIntervalMinutes), _RS485EnablePin(enablePin) { #ifdef MS_ANB_SENSORS_PH_DEBUG_DEEP _anb_sensor.setDebugStream(&MS_SERIAL_OUTPUT); @@ -28,13 +29,15 @@ ANBpH::ANBpH(byte modbusAddress, Stream* stream, int8_t powerPin, setAllowedMeasurementRetries(5); } ANBpH::ANBpH(byte modbusAddress, Stream& stream, int8_t powerPin, - int8_t powerPin2, int8_t enablePin, uint8_t measurementsToAverage) + int16_t loggingIntervalMinutes, int8_t powerPin2, int8_t enablePin, + uint8_t measurementsToAverage) : Sensor("ANBpHSensor", ANB_PH_NUM_VARIABLES, ANB_PH_WARM_UP_TIME_MS, ANB_PH_STABILIZATION_TIME_MS, ANB_PH_2ND_VALUE_LOW_SALT, powerPin, -1, measurementsToAverage, ANB_PH_INC_CALC_VARIABLES), _anb_sensor(modbusAddress, stream, enablePin), _modbusAddress(modbusAddress), _stream(&stream), + _loggingIntervalMinutes(loggingIntervalMinutes), _RS485EnablePin(enablePin) { #ifdef MS_ANB_SENSORS_PH_DEBUG_DEEP _anb_sensor.setDebugStream(&MS_SERIAL_OUTPUT); @@ -146,11 +149,25 @@ bool ANBpH::setup(void) { MS_DBG(F("..."), powerStyleSet ? F("success") : F("failed")); retVal &= powerStyleSet; - bool intervalSet = false; + bool intervalSet = false; + uint16_t programmedInterval = _loggingIntervalMinutes; + if (_loggingIntervalMinutes < 10 && _loggingIntervalMinutes != 0) { + programmedInterval = 10; + MS_DBG(F("Requested interval of"), _loggingIntervalMinutes, + F("minutes is too short; using"), programmedInterval, + F("minutes.")); + } + if (_loggingIntervalMinutes > 240 && _loggingIntervalMinutes != 0) { + programmedInterval = 240; + MS_DBG(F("Requested interval of"), _loggingIntervalMinutes, + F("minutes is too long; using"), programmedInterval, + F("minutes.")); + } if (_powerPin >= 0) { // Set sampling interval to the expected sampling interval if the sensor - MS_DBG(F("Set sensor sampling interval to 15 minutes...")); - intervalSet = _anb_sensor.setIntervalTime(15); + MS_DBG(F("Set sensor sampling interval to"), programmedInterval, + F("minutes...")); + intervalSet = _anb_sensor.setIntervalTime(programmedInterval); } else { // Set sampling interval to continuous if the sensor will be // continuously powered (ie, a power style of ALWAYS_POWERED). diff --git a/src/sensors/ANBpH.h b/src/sensors/ANBpH.h index e135a38aa..f1dce425a 100644 --- a/src/sensors/ANBpH.h +++ b/src/sensors/ANBpH.h @@ -475,6 +475,10 @@ class ANBpH : public Sensor { * can be used. * @param powerPin The pin on the mcu controlling power to the ANB pH * sensor. Use -1 if it is continuously powered. + * @param loggingIntervalMinutes The logging interval in minutes. Even when + * the sensor is being powered off between readings, it needs to be told how + * often it will be powered on. This is not used if the sensor power is not + * being controlled by the mcu. Must be between 10 and 240 minutes. * @param powerPin2 The pin on the mcu controlling power to the RS485 * adapter, if it is different from that used to power the sensor. Use -1 * or omit if not applicable. @@ -485,14 +489,24 @@ class ANBpH : public Sensor { * @param measurementsToAverage The number of measurements to take and * average before giving a "final" result from the sensor; optional with a * default value of 1. + * + * @warning This library does _**NOT**_ verify that the logging interval set + * for this sensor matches the logging interval of the logger. The actual + * power on/off and measurement times will be based on the logging interval + * of the logger, so if these are not the same, the timing of the + * measurements may be very different than expected. I do not understand + * why the sensor needs to know the logging interval when it is powered off, + * but it does. I suspect it uses this to balance power across the various + * sensing elements to maximize the life of the sensor. */ ANBpH(byte modbusAddress, Stream* stream, int8_t powerPin, - int8_t powerPin2 = -1, int8_t enablePin = -1, - uint8_t measurementsToAverage = 1); - /// @copydoc ANBpH::ANBpH(byte, Stream*, int8_t, int8_t, int8_t, uint8_t) + int16_t loggingIntervalMinutes, int8_t powerPin2 = -1, + int8_t enablePin = -1, uint8_t measurementsToAverage = 1); + /// @copydoc ANBpH::ANBpH(byte, Stream*, int8_t, int16_t, int8_t, int8_t, + /// uint8_t) ANBpH(byte modbusAddress, Stream& stream, int8_t powerPin, - int8_t powerPin2 = -1, int8_t enablePin = -1, - uint8_t measurementsToAverage = 1); + int16_t loggingIntervalMinutes, int8_t powerPin2 = -1, + int8_t enablePin = -1, uint8_t measurementsToAverage = 1); /** * @brief Destroy the ANB pH object - no action taken */ @@ -595,6 +609,12 @@ class ANBpH : public Sensor { * ANB pH sensor. */ Stream* _stream; + /** + * @brief The logging interval in minutes. Even when the sensor is being + * powered off between readings, it needs to be told how often it will be + * powered on. + */ + int16_t _loggingIntervalMinutes; /** * @brief Private reference to the RS-485 adapter's flow direction control * pin. From 0ae4f286403eae969b0b50801bf294cdc8d679e0 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Tue, 17 Feb 2026 16:21:54 -0500 Subject: [PATCH 159/533] Fix setting the immersion sensor Signed-off-by: Sara Damiano --- src/sensors/ANBpH.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/sensors/ANBpH.cpp b/src/sensors/ANBpH.cpp index 9eabfb367..5ae42568b 100644 --- a/src/sensors/ANBpH.cpp +++ b/src/sensors/ANBpH.cpp @@ -182,8 +182,9 @@ bool ANBpH::setup(void) { // Set Immersion Rule MS_DBG(F("Set sensor immersion rule to"), - _immersionSensorEnabled ? "enabled" : "disabled", F("...")); - bool immersionSet = _anb_sensor.enableImmersionSensor(); + _immersionSensorEnabled ? F("enabled") : F("disabled"), F("...")); + bool immersionSet = + _anb_sensor.enableImmersionSensor(_immersionSensorEnabled); MS_DBG(F("..."), immersionSet ? F("success") : F("failed")); retVal &= immersionSet; From 2cc0cb0da3681df00029a613000e29215ccb911e Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Tue, 17 Feb 2026 16:50:35 -0500 Subject: [PATCH 160/533] Add code rabbit config Signed-off-by: Sara Damiano --- .coderabbit.yaml | 65 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 .coderabbit.yaml diff --git a/.coderabbit.yaml b/.coderabbit.yaml new file mode 100644 index 000000000..cca822a00 --- /dev/null +++ b/.coderabbit.yaml @@ -0,0 +1,65 @@ +# yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json +early_access: false +enable_free_tier: true +language: en +tone_instructions: '' +knowledge_base: + learnings: + scope: auto + issues: + scope: auto + jira: + project_keys: [] + linear: + team_keys: [] +chat: + auto_reply: true +reviews: + profile: chill + request_changes_workflow: false + high_level_summary: true + high_level_summary_placeholder: '@coderabbitai summary' + poem: false + review_status: true + collapse_walkthrough: true + path_filters: + - '!**/dependencies.json' + - '!**/cspell.json' + - '!**/platformio.ini' + path_instructions: + - path: '**/*.hpp' + instructions: >- + Review the C++ code, point out issues relative to principles of clean + code, expressiveness, and performance. + tools: + shellcheck: + enabled: true + ruff: + enabled: true + markdownlint: + enabled: true + github-checks: + enabled: true + timeout_ms: 90000 + languagetool: + enabled: true + disabled_rules: + - EN_UNPAIRED_BRACKETS + disabled_categories: + - TYPOS + - TYPOGRAPHY + - CASING + enabled_only: false + level: default + biome: + enabled: true + hadolint: + enabled: true + auto_review: + enabled: true + ignore_title_keywords: + - WIP + labels: [] + drafts: true + base_branches: + - master From 59b470d2b425767e6e888e68e30f4293b89ba256 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Tue, 17 Feb 2026 17:00:01 -0500 Subject: [PATCH 161/533] Add smudge filters Signed-off-by: Sara Damiano --- .gitattributes | 4 ++++ .gitignore | 1 + 2 files changed, 5 insertions(+) diff --git a/.gitattributes b/.gitattributes index d89fbb64c..95ddeb819 100644 --- a/.gitattributes +++ b/.gitattributes @@ -32,3 +32,7 @@ platformio.ini export-ignore # Shell Scripts *.sh export-ignore + +# filters +*.ino filter=smudgePasswords +ModSensorDebugConfig.h filter=disableDebug diff --git a/.gitignore b/.gitignore index e2342cb89..e041784b2 100644 --- a/.gitignore +++ b/.gitignore @@ -87,6 +87,7 @@ archive/ compile_tests/ logger_test*/ ex_one_offs/* +filters/* runDoxygen.bat docs/examples/* docs/examples.dox_x From 03b9ee7bf62be9fd277bfda185b2d8ec096e76df Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Tue, 17 Feb 2026 17:26:43 -0500 Subject: [PATCH 162/533] Fix pluralization of UUIDs Signed-off-by: Sara Damiano --- ChangeLog.md | 2 +- examples/AWS_IoT_Core/ReadMe.md | 4 ++-- .../EnviroDIY_Monitoring_Kit.ino | 6 +++--- .../DRWI_CitizenScience/DRWI_2G/DRWI_2G.ino | 6 +++--- .../DRWI_CitizenScience/DRWI_2G/ReadMe.md | 4 ++-- .../DRWI_DigiLTE/DRWI_DigiLTE.ino | 6 +++--- .../DRWI_CitizenScience/DRWI_DigiLTE/ReadMe.md | 4 ++-- .../DRWI_Mayfly1/DRWI_Mayfly1.ino | 6 +++--- .../DRWI_Mayfly1_WiFi/DRWI_Mayfly1_WiFi.ino | 4 ++-- .../DRWI_NoCellular/DRWI_NoCellular.ino | 4 ++-- .../DRWI_NoCellular/ReadMe.md | 6 +++--- .../DRWI_SIM7080LTE/DRWI_SIM7080LTE.ino | 6 +++--- examples/logging_to_ThingSpeak/ReadMe.md | 2 +- examples/menu_a_la_carte/ReadMe.md | 4 ++-- examples/menu_a_la_carte/menu_a_la_carte.ino | 6 +++--- src/LoggerBase.cpp | 2 +- src/VariableArray.cpp | 8 ++++---- src/VariableArray.h | 16 ++++++++-------- src/publishers/ThingSpeakPublisher.h | 2 +- 19 files changed, 49 insertions(+), 49 deletions(-) diff --git a/ChangeLog.md b/ChangeLog.md index 7ef597773..49f2b28fb 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -759,7 +759,7 @@ Watchdogs and More - A watch-dog timer has been implemented for both the AVR and SAMD21 (and 51) boards to restart the boards in case of failure during logging - The watch-dog is turned off during sleep to save power, so recovery is only possible if the failure is while the processor is awake. - Added support for Meter Teros 11 soil moisture and temperature sensor -- Implemented a function to verify that UUID's are at least correctly formed and unique - though it does not verify that they are valid. +- Implemented a function to verify that UUIDs are at least correctly formed and unique - though it does not verify that they are valid. - Pushing to the master branch of this repo will now also cause a re-run of the travis script that updates the EnviroDIY "Libraries" repository. - Added debugging variables to modems to track how long they are powered/active. diff --git a/examples/AWS_IoT_Core/ReadMe.md b/examples/AWS_IoT_Core/ReadMe.md index 182297934..ebc4837cd 100644 --- a/examples/AWS_IoT_Core/ReadMe.md +++ b/examples/AWS_IoT_Core/ReadMe.md @@ -61,9 +61,9 @@ Make sure there are quotation marks around the name string, as there are in the ### Set your Variable UUIDs -In lines 191-224, find and replace the text `"12345678-abcd-1234-ef00-1234567890ab` with the UUID's for each of your variables, if they have UUIDS. +In lines 191-224, find and replace the text `"12345678-abcd-1234-ef00-1234567890ab` with the UUIDs for each of your variables, if they have UUIDS. Make sure there are quotation marks around the name string, as there are in the example. -If you do not have UUID's for your variables, delete the string entirely, leaving empty quotes (`""`). +If you do not have UUIDs for your variables, delete the string entirely, leaving empty quotes (`""`). _______ diff --git a/examples/EnviroDIY_Monitoring_Kit/EnviroDIY_Monitoring_Kit.ino b/examples/EnviroDIY_Monitoring_Kit/EnviroDIY_Monitoring_Kit.ino index 7ae601182..90e270ec8 100644 --- a/examples/EnviroDIY_Monitoring_Kit/EnviroDIY_Monitoring_Kit.ino +++ b/examples/EnviroDIY_Monitoring_Kit/EnviroDIY_Monitoring_Kit.ino @@ -57,11 +57,11 @@ const int8_t timeZone = -5; // Eastern Standard Time // ========================================================================== -// UUID's and Registration Tokens for Monitor My Watershed +// UUIDs and Registration Tokens for Monitor My Watershed // ========================================================================== /** Start [monitor_mw_uuids] */ -// All UUID's, device registration, and sampling feature information can be +// All UUIDs, device registration, and sampling feature information can be // pasted directly from Monitor My Watershed. // To get the list, click the "View token UUID list" button on the upper right // of the site page. @@ -319,7 +319,7 @@ Variable* variableList[] = { // Count up the number of pointers in the array int variableCount = sizeof(variableList) / sizeof(variableList[0]); -// Create the VariableArray object and attach the UUID's +// Create the VariableArray object and attach the UUIDs VariableArray varArray(variableCount, variableList, UUIDs); /** End [variables_separate_uuids] */ // ========================================================================== diff --git a/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_2G/DRWI_2G.ino b/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_2G/DRWI_2G.ino index d1a24e382..e6076ec35 100644 --- a/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_2G/DRWI_2G.ino +++ b/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_2G/DRWI_2G.ino @@ -73,7 +73,7 @@ const int8_t modemLEDPin = redLED; // MCU pin connected an LED to show modem // status (-1 if unconnected) // Network connection information -const char* apn = "hologram"; // The APN for the gprs connection +const char* apn = "YourAPN"; // The APN for the gprs connection Sodaq2GBeeR6 modem2GB(&modemSerial, modemVccPin, modemStatusPin, apn); // Create an extra reference to the modem by a generic name @@ -168,13 +168,13 @@ Variable* variableList[] = { new Modem_RSSI(&modem), new Modem_SignalPercent(&modem)}; -// All UUID's, device registration, and sampling feature information can be +// All UUIDs, device registration, and sampling feature information can be // pasted directly from Monitor My Watershed. To get the list, click the "View // token UUID list" button on the upper right of the site page. // *** CAUTION --- CAUTION --- CAUTION --- CAUTION --- CAUTION *** // Check the order of your variables in the variable list!!! -// Be VERY certain that they match the order of your UUID's! +// Be VERY certain that they match the order of your UUIDs! // Rearrange the variables in the variable list if necessary to match! // *** CAUTION --- CAUTION --- CAUTION --- CAUTION --- CAUTION *** /* clang-format off */ diff --git a/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_2G/ReadMe.md b/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_2G/ReadMe.md index 98a5f510b..5dc3ea368 100644 --- a/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_2G/ReadMe.md +++ b/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_2G/ReadMe.md @@ -101,13 +101,13 @@ Variable* variableList[] = { ``` - If any of the variables are in a different order on the web page than in your code **reorder the variables in your code to match the website**. -- After you are completely certain that you have the order right in the variable section of your code use the teal "Copy" button on the website to copy the section of code containing all of the UUID's. +- After you are completely certain that you have the order right in the variable section of your code use the teal "Copy" button on the website to copy the section of code containing all of the UUIDs. - Paste the code from the website into your program in this section below the variable array ```cpp // *** CAUTION --- CAUTION --- CAUTION --- CAUTION --- CAUTION *** // Check the order of your variables in the variable list!!! -// Be VERY certain that they match the order of your UUID's! +// Be VERY certain that they match the order of your UUIDs! // Rearrange the variables in the variable list if necessary to match! // *** CAUTION --- CAUTION --- CAUTION --- CAUTION --- CAUTION *** /* clang-format off */ diff --git a/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_DigiLTE/DRWI_DigiLTE.ino b/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_DigiLTE/DRWI_DigiLTE.ino index ff04fb20e..fa478ca3d 100644 --- a/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_DigiLTE/DRWI_DigiLTE.ino +++ b/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_DigiLTE/DRWI_DigiLTE.ino @@ -79,7 +79,7 @@ const int8_t modemLEDPin = redLED; // MCU pin connected an LED to show modem // status (-1 if unconnected) // Network connection information -const char* apn = "hologram"; // The APN for the gprs connection +const char* apn = "YourAPN"; // The APN for the gprs connection DigiXBeeCellularTransparent modemXBCT(&modemSerial, modemVccPin, modemStatusPin, useCTSforStatus, modemResetPin, @@ -176,14 +176,14 @@ Variable* variableList[] = { new Modem_SignalPercent(&modem), }; -// All UUID's, device registration, and sampling feature information can be +// All UUIDs, device registration, and sampling feature information can be // pasted directly from Monitor My Watershed. // To get the list, click the "View token UUID list" button on the upper right // of the site page. // *** CAUTION --- CAUTION --- CAUTION --- CAUTION --- CAUTION *** // Check the order of your variables in the variable list!!! -// Be VERY certain that they match the order of your UUID's! +// Be VERY certain that they match the order of your UUIDs! // Rearrange the variables in the variable list ABOVE if necessary to match! // Do not change the order of the variables in the section below. // *** CAUTION --- CAUTION --- CAUTION --- CAUTION --- CAUTION *** diff --git a/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_DigiLTE/ReadMe.md b/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_DigiLTE/ReadMe.md index bd7d63054..9211ce41a 100644 --- a/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_DigiLTE/ReadMe.md +++ b/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_DigiLTE/ReadMe.md @@ -105,13 +105,13 @@ Variable* variableList[] = { ``` - If any of the variables are in a different order on the web page than in your code **reorder the variables in your code to match the website**. -- After you are completely certain that you have the order right in the variable section of your code use the teal "Copy" button on the website to copy the section of code containing all of the UUID's. +- After you are completely certain that you have the order right in the variable section of your code use the teal "Copy" button on the website to copy the section of code containing all of the UUIDs. - Paste the code from the website into your program in this section below the variable array ```cpp // *** CAUTION --- CAUTION --- CAUTION --- CAUTION --- CAUTION *** // Check the order of your variables in the variable list!!! -// Be VERY certain that they match the order of your UUID's! +// Be VERY certain that they match the order of your UUIDs! // Rearrange the variables in the variable list if necessary to match! // *** CAUTION --- CAUTION --- CAUTION --- CAUTION --- CAUTION *** /* clang-format off */ diff --git a/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_Mayfly1/DRWI_Mayfly1.ino b/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_Mayfly1/DRWI_Mayfly1.ino index f3c0149e7..5bf9acca3 100644 --- a/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_Mayfly1/DRWI_Mayfly1.ino +++ b/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_Mayfly1/DRWI_Mayfly1.ino @@ -84,7 +84,7 @@ const int8_t modemLEDPin = redLED; // MCU pin connected an LED to show modem // Network connection information const char* apn = - "hologram"; // APN connection name, typically Hologram unless you have a + "YourAPN"; // APN connection name, typically Hologram unless you have a // different provider's SIM card. Change as needed // Create the modem object @@ -183,14 +183,14 @@ Variable* variableList[] = { new Modem_SignalPercent(&modem), // Percent full scale (EnviroDIY_LTEB_SignalPercent) }; -// All UUID's, device registration, and sampling feature information can be +// All UUIDs, device registration, and sampling feature information can be // pasted directly from Monitor My Watershed. // To get the list, click the "View token UUID list" button on the upper right // of the site page. // *** CAUTION --- CAUTION --- CAUTION --- CAUTION --- CAUTION *** // Check the order of your variables in the variable list!!! -// Be VERY certain that they match the order of your UUID's! +// Be VERY certain that they match the order of your UUIDs! // Rearrange the variables in the variable list ABOVE if necessary to match! // Do not change the order of the variables in the section below. // *** CAUTION --- CAUTION --- CAUTION --- CAUTION --- CAUTION *** diff --git a/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_Mayfly1_WiFi/DRWI_Mayfly1_WiFi.ino b/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_Mayfly1_WiFi/DRWI_Mayfly1_WiFi.ino index 6d467ace8..78f44adc2 100644 --- a/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_Mayfly1_WiFi/DRWI_Mayfly1_WiFi.ino +++ b/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_Mayfly1_WiFi/DRWI_Mayfly1_WiFi.ino @@ -160,14 +160,14 @@ Variable* variableList[] = { new Modem_SignalPercent(&modem), // Percent full scale (EnviroDIY_LTEB_SignalPercent) }; -// All UUID's, device registration, and sampling feature information can be +// All UUIDs, device registration, and sampling feature information can be // pasted directly from Monitor My Watershed. // To get the list, click the "View token UUID list" button on the upper right // of the site page. // *** CAUTION --- CAUTION --- CAUTION --- CAUTION --- CAUTION *** // Check the order of your variables in the variable list!!! -// Be VERY certain that they match the order of your UUID's! +// Be VERY certain that they match the order of your UUIDs! // Rearrange the variables in the variable list ABOVE if necessary to match! // Do not change the order of the variables in the section below. // *** CAUTION --- CAUTION --- CAUTION --- CAUTION --- CAUTION *** diff --git a/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_NoCellular/DRWI_NoCellular.ino b/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_NoCellular/DRWI_NoCellular.ino index 6c22ddd7a..0185105c5 100644 --- a/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_NoCellular/DRWI_NoCellular.ino +++ b/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_NoCellular/DRWI_NoCellular.ino @@ -138,7 +138,7 @@ Variable* variableList[] = { new MaximDS3231_Temp(&ds3231), }; -// All UUID's, device registration, and sampling feature information can be +// All UUIDs, device registration, and sampling feature information can be // pasted directly from Monitor My Watershed. To get the list, click the "View // token UUID list" button on the upper right of the site page. // Even if not publishing live data, this is needed so the logger file will be @@ -146,7 +146,7 @@ Variable* variableList[] = { // *** CAUTION --- CAUTION --- CAUTION --- CAUTION --- CAUTION *** // Check the order of your variables in the variable list!!! -// Be VERY certain that they match the order of your UUID's! +// Be VERY certain that they match the order of your UUIDs! // Rearrange the variables in the variable list if necessary to match! // *** CAUTION --- CAUTION --- CAUTION --- CAUTION --- CAUTION *** /* clang-format off */ diff --git a/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_NoCellular/ReadMe.md b/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_NoCellular/ReadMe.md index ffaaf97be..b7c1089be 100644 --- a/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_NoCellular/ReadMe.md +++ b/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_NoCellular/ReadMe.md @@ -10,7 +10,7 @@ The exact hardware configuration used in this example: - Campbell OBS3+ turbidity sensor Before using this example, you must register a site and sensors on [Monitor My Watershed](https://monitormywatershed.org). -After you have registered the site and sensors, the portal will generate a registration token and universally unique identifier (UUID) for each site and further UUID's for each variable. +After you have registered the site and sensors, the portal will generate a registration token and universally unique identifier (UUID) for each site and further UUIDs for each variable. You will need to copy all of those UUID values into your sketch to replace the `12345678-abcd-1234-ef00-1234567890ab` place holders in this example. __You should register even if your logger will not be sending live data.__ This ensures that the data file your logger writes will be ready to immediately upload to the portal. @@ -106,13 +106,13 @@ Variable* variableList[] = { ``` - If any of the variables are in a different order on the web page than in your code __reorder the variables in your code to match the website__. -- After you are completely certain that you have the order right in the variable section of your code use the teal "Copy" button on the website to copy the section of code containing all of the UUID's. +- After you are completely certain that you have the order right in the variable section of your code use the teal "Copy" button on the website to copy the section of code containing all of the UUIDs. - Paste the code from the website into your program in this section below the variable array ```cpp // *** CAUTION --- CAUTION --- CAUTION --- CAUTION --- CAUTION *** // Check the order of your variables in the variable list!!! -// Be VERY certain that they match the order of your UUID's! +// Be VERY certain that they match the order of your UUIDs! // Rearrange the variables in the variable list if necessary to match! // *** CAUTION --- CAUTION --- CAUTION --- CAUTION --- CAUTION *** /* clang-format off */ diff --git a/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_SIM7080LTE/DRWI_SIM7080LTE.ino b/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_SIM7080LTE/DRWI_SIM7080LTE.ino index e8c7bb0db..c058bc268 100644 --- a/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_SIM7080LTE/DRWI_SIM7080LTE.ino +++ b/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_SIM7080LTE/DRWI_SIM7080LTE.ino @@ -85,7 +85,7 @@ const int8_t modemLEDPin = redLED; // MCU pin connected an LED to show modem // Network connection information const char* apn = - "hologram"; // APN connection name, typically Hologram unless you have a + "YourAPN"; // APN connection name, typically Hologram unless you have a // different provider's SIM card. Change as needed // Create the modem object @@ -183,14 +183,14 @@ Variable* variableList[] = { new Modem_SignalPercent(&modem), }; -// All UUID's, device registration, and sampling feature information can be +// All UUIDs, device registration, and sampling feature information can be // pasted directly from Monitor My Watershed. // To get the list, click the "View token UUID list" button on the upper right // of the site page. // *** CAUTION --- CAUTION --- CAUTION --- CAUTION --- CAUTION *** // Check the order of your variables in the variable list!!! -// Be VERY certain that they match the order of your UUID's! +// Be VERY certain that they match the order of your UUIDs! // Rearrange the variables in the variable list ABOVE if necessary to match! // Do not change the order of the variables in the section below. // *** CAUTION --- CAUTION --- CAUTION --- CAUTION --- CAUTION *** diff --git a/examples/logging_to_ThingSpeak/ReadMe.md b/examples/logging_to_ThingSpeak/ReadMe.md index 92d206b1c..728a9b582 100644 --- a/examples/logging_to_ThingSpeak/ReadMe.md +++ b/examples/logging_to_ThingSpeak/ReadMe.md @@ -66,7 +66,7 @@ If you want to send data to multiple channels, you must create individual logger - Order the variables in your variable array in the same order as your fields are on ThingSpeak. - This order is **crucial**. The results from the variables in the VariableArray will be sent to ThingSpeak in the order they are in the array; that is, the first variable in the array will be sent as Field1, the second as Field2, etc. - - Any UUID's or custom variable codes are ignored for ThingSpeak. + - Any UUIDs or custom variable codes are ignored for ThingSpeak. They will only appear in the header of your file on the SD card. - Find this information for your ThingSpeak account and channel and put it into logging_to_ThingSpeak.ino: diff --git a/examples/menu_a_la_carte/ReadMe.md b/examples/menu_a_la_carte/ReadMe.md index f5f6b7d56..c489c46e9 100644 --- a/examples/menu_a_la_carte/ReadMe.md +++ b/examples/menu_a_la_carte/ReadMe.md @@ -1264,8 +1264,8 @@ Here we use the `new` keyword to create multiple variables and get pointers to t #### Creating Variables and Pasting UUIDs from MonitorMyWatershed -If you are sending data to Monitor My Watershed, it is much easier to create the variables in an array and then to paste the UUID's all together as copied from the "View Token UUID List" link for a site. -If using this method, be very, very, very careful to make sure the order of your variables exactly matches the order of your UUID's. +If you are sending data to Monitor My Watershed, it is much easier to create the variables in an array and then to paste the UUIDs all together as copied from the "View Token UUID List" link for a site. +If using this method, be very, very, very careful to make sure the order of your variables exactly matches the order of your UUIDs. diff --git a/examples/menu_a_la_carte/menu_a_la_carte.ino b/examples/menu_a_la_carte/menu_a_la_carte.ino index 92d4cb002..09014a72d 100644 --- a/examples/menu_a_la_carte/menu_a_la_carte.ino +++ b/examples/menu_a_la_carte/menu_a_la_carte.ino @@ -2973,7 +2973,7 @@ VariableArray varArray(variableCount, variableList); #elif defined(BUILD_TEST_SEPARATE_UUIDS) /** Start [variables_separate_uuids] */ // Version 2: Create two separate arrays, on for the variables and a separate -// one for the UUID's, then give both as input to the variable array +// one for the UUIDs, then give both as input to the variable array // constructor. Be cautious when doing this though because order is CRUCIAL! Variable* variableList[] = { new ProcessorStats_SampleNumber(&mcuBoard), @@ -2992,7 +2992,7 @@ const char* UUIDs[] = { "12345678-abcd-1234-ef00-1234567890ab", "12345678-abcd-1234-ef00-1234567890ab", "12345678-abcd-1234-ef00-1234567890ab", - // ... The number of UUID's must match the number of variables! + // ... The number of UUIDs must match the number of variables! "12345678-abcd-1234-ef00-1234567890ab", "12345678-abcd-1234-ef00-1234567890ab", "12345678-abcd-1234-ef00-1234567890ab", @@ -3000,7 +3000,7 @@ const char* UUIDs[] = { }; // Count up the number of pointers in the array int variableCount = sizeof(variableList) / sizeof(variableList[0]); -// Create the VariableArray object and attach the UUID's +// Create the VariableArray object and attach the UUIDs VariableArray varArray(variableCount, variableList, UUIDs); /** End [variables_separate_uuids] */ // ========================================================================== diff --git a/src/LoggerBase.cpp b/src/LoggerBase.cpp index 12dd69cd8..8e4efa96e 100644 --- a/src/LoggerBase.cpp +++ b/src/LoggerBase.cpp @@ -1289,7 +1289,7 @@ void Logger::printFileHeader(Stream* stream) { // Next comes the ODM2 unit name STREAM_CSV_ROW(F("Result Unit:"), getVarUnitAtI(i)) // Next comes the variable UUIDs - // We'll only add UUID's if we see a UUID for the first variable + // We'll only add UUIDs if we see a UUID for the first variable if (getVarUUIDAtI(0) != nullptr && strlen(getVarUUIDAtI(0)) > 1) { STREAM_CSV_ROW(F("Result UUID:"), getVarUUIDAtI(i)) } diff --git a/src/VariableArray.cpp b/src/VariableArray.cpp index 647f8d82e..33e2a2fb9 100644 --- a/src/VariableArray.cpp +++ b/src/VariableArray.cpp @@ -72,7 +72,7 @@ uint8_t VariableArray::getSensorCount(void) { return numSensors; } -// This matches UUID's from an array of pointers to the variable array +// This matches UUIDs from an array of pointers to the variable array void VariableArray::matchUUIDs(const char* uuids[]) { for (uint8_t i = 0; i < _variableCount; i++) { arrayOfVars[i]->setVarUUID(uuids[i]); @@ -651,7 +651,7 @@ bool VariableArray::getSensorStatusBit(int arrayIndex, } -// Check that all variable have valid UUID's, if they are assigned +// Check that all variable have valid UUIDs, if they are assigned bool VariableArray::checkVariableUUIDs(void) { bool success = true; for (uint8_t i = 0; i < _variableCount; i++) { @@ -681,8 +681,8 @@ bool VariableArray::checkVariableUUIDs(void) { } } if (success) - PRINTOUT(F("All variable UUID's appear to be correctly formed.\n")); - // Print out all UUID's to check + PRINTOUT(F("All variable UUIDs appear to be correctly formed.\n")); + // Print out all UUIDs to check for (uint8_t i = 0; i < _variableCount; i++) { if (arrayOfVars[i]->getVarUUID() != nullptr && strlen(arrayOfVars[i]->getVarUUID()) > 0) { diff --git a/src/VariableArray.h b/src/VariableArray.h index 06ad47662..62c369bed 100644 --- a/src/VariableArray.h +++ b/src/VariableArray.h @@ -95,7 +95,7 @@ class VariableArray { * @param variableCount The number of variables in the array * @param variableList An array of pointers to variable objects. The * pointers may be to calculated or measured variable objects. - * @param uuids An array of UUID's. These are linked 1-to-1 with the + * @param uuids An array of UUIDs. These are linked 1-to-1 with the * variables by array position. */ VariableArray(uint8_t variableCount, Variable* variableList[], @@ -132,7 +132,7 @@ class VariableArray { * @param variableList An array of pointers to variable objects. The * pointers may be to calculated or measured variable objects. Supersedes * any value given in the constructor. - * @param uuids An array of UUID's. These are linked 1-to-1 with the + * @param uuids An array of UUIDs. These are linked 1-to-1 with the * variables by array position. */ void begin(uint8_t variableCount, Variable* variableList[], @@ -180,12 +180,12 @@ class VariableArray { uint8_t getSensorCount(void); /** - * @brief Match UUID's from the given variables in the variable array. + * @brief Match UUIDs from the given variables in the variable array. * - * This over-writes all UUID's previously assigned to every variable. The + * This over-writes all UUIDs previously assigned to every variable. The * match is 1-to-1 based on array position. * - * @param uuids An array of UUID's + * @param uuids An array of UUIDs */ void matchUUIDs(const char* uuids[]); @@ -304,11 +304,11 @@ class VariableArray { */ bool isLastVarFromSensor(int arrayIndex); /** - * @brief Check that all variable have valid UUID's, if they are assigned + * @brief Check that all variable have valid UUIDs, if they are assigned * - * @return True if all variables have valid UUID's. + * @return True if all variables have valid UUIDs. * - * @warning This does not check that the UUID's are the true UUID's for the + * @warning This does not check that the UUIDs are the true UUIDs for the * variables, just that the text is a validly formed UUID. */ bool checkVariableUUIDs(void); diff --git a/src/publishers/ThingSpeakPublisher.h b/src/publishers/ThingSpeakPublisher.h index a201dd014..c9a05ad11 100644 --- a/src/publishers/ThingSpeakPublisher.h +++ b/src/publishers/ThingSpeakPublisher.h @@ -45,7 +45,7 @@ * array attached to your logger is __crucial__. The results from the variables * in the VariableArray will be sent to ThingSpeak in the order they are in the * array; that is, the first variable in the array will be sent as Field1, the - * second as Field2, etc. Any UUID's or custom variable codes are ignored for + * second as Field2, etc. Any UUIDs or custom variable codes are ignored for * ThingSpeak. They will only appear in the header of your file on the SD card. * Giving a variable a custom variable code like "Field3" will **NOT** make that * variable field 3 on ThingSpeak. The third variable in the array will always From 935537f2f3e9d078c762bde191c476dab79619b2 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Tue, 17 Feb 2026 17:32:07 -0500 Subject: [PATCH 163/533] Remove trailing slashes on URLs Signed-off-by: Sara Damiano --- ChangeLog.md | 2 +- README.md | 2 +- .../OutdatedExamples/DRWI_CitizenScience/DRWI_2G/ReadMe.md | 4 ++-- .../DRWI_CitizenScience/DRWI_DigiLTE/ReadMe.md | 4 ++-- .../DRWI_CitizenScience/DRWI_NoCellular/ReadMe.md | 4 ++-- examples/baro_rho_correction/ReadMe.md | 4 ++-- examples/logging_to_MMW/ReadMe.md | 4 ++-- 7 files changed, 12 insertions(+), 12 deletions(-) diff --git a/ChangeLog.md b/ChangeLog.md index 49f2b28fb..3fef7cd4a 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -940,7 +940,7 @@ Bug fix and example re-working ### Fixed -- Fixes bug in sending data to the WikiWatershed / [Monitor My Watershed](https://monitormywatershed.org/) data sharing portal. +- Fixes bug in sending data to [Monitor My Watershed](https://monitormywatershed.org). *** diff --git a/README.md b/README.md index 832b1a797..00d9cc6e6 100644 --- a/README.md +++ b/README.md @@ -106,7 +106,7 @@ For some generalized information about attaching sensors to an Arduino style boa ## Data Endpoints Within ModularSensors, the "dataPublisher" objects add the functionality to send data to remote web services. -The currently supported services are [Monitor My Watershed](https://monitormywatershed.org/), [ThingSpeak](https://thingspeak.com/), the [Ubidots IoT platform](https://ubidots.com), [Amazon Web Services IoT Core](https://aws.amazon.com/iot-core/), and [Amazon Web Services Simple Storage Service (S3)](https://aws.amazon.com/s3/). +The currently supported services are [Monitor My Watershed](https://monitormywatershed.org), [ThingSpeak](https://thingspeak.com), the [Ubidots IoT platform](https://ubidots.com), [Amazon Web Services IoT Core](https://aws.amazon.com/iot-core), and [Amazon Web Services Simple Storage Service (S3)](https://aws.amazon.com/s3). - [Monitor My Watershed](https://envirodiy.github.io/ModularSensors/class_monitor_my_watershed_publisher.html) - [ThingSpeak](https://envirodiy.github.io/ModularSensors/class_thing_speak_publisher.html) diff --git a/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_2G/ReadMe.md b/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_2G/ReadMe.md index 5dc3ea368..19f39b34d 100644 --- a/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_2G/ReadMe.md +++ b/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_2G/ReadMe.md @@ -39,7 +39,7 @@ _______ ### Prepare and set up PlatformIO -- Register a site and sensors on [Monitor My Watershed](https://monitormywatershed.org/) +- Register a site and sensors on [Monitor My Watershed](https://monitormywatershed.org) - Create a new PlatformIO project - Replace the contents of the platformio.ini for your new project with the [platformio.ini](https://raw.githubusercontent.com/EnviroDIY/ModularSensors/master/examples/DRWI_CitSci/platformio.ini) file in the examples/DRWI_CitSci folder on GitHub. - It is important that your PlatformIO configuration has the lib_ldf_mode and build flags set as they are in the example. @@ -90,7 +90,7 @@ CampbellOBS3 osb3high(OBS3Power, OBSHighADSChannel, OBSHigh_A, OBSHigh_B, OBSHig ### Set the universally universal identifiers (UUID) for each variable -- Go back to the web page for your site on [Monitor My Watershed](https://monitormywatershed.org/) +- Go back to the web page for your site on [Monitor My Watershed](https://monitormywatershed.org) - Find and click the white "View Token UUID List" button above the small map on your site page - **VERY CAREFULLY** check that the variables are in exactly the same order as in the variable array: diff --git a/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_DigiLTE/ReadMe.md b/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_DigiLTE/ReadMe.md index 9211ce41a..4ef2a0703 100644 --- a/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_DigiLTE/ReadMe.md +++ b/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_DigiLTE/ReadMe.md @@ -40,7 +40,7 @@ _______ ### Prepare and set up PlatformIO -- Register a site and sensors on [Monitor My Watershed](https://monitormywatershed.org/) +- Register a site and sensors on [Monitor My Watershed](https://monitormywatershed.org) - Create a new PlatformIO project - Replace the contents of the platformio.ini for your new project with the [platformio.ini](https://raw.githubusercontent.com/EnviroDIY/ModularSensors/master/examples/DRWI_DigiLTE/platformio.ini) file in the examples/DRWI_DigiLTE folder on GitHub. @@ -93,7 +93,7 @@ CampbellOBS3 osb3high(OBS3Power, OBSHighADSChannel, OBSHigh_A, OBSHigh_B, OBSHig ### Set the universally universal identifiers (UUID) for each variable -- Go back to the web page for your site on [Monitor My Watershed](https://monitormywatershed.org/) +- Go back to the web page for your site on [Monitor My Watershed](https://monitormywatershed.org) - Find and click the white "View Token UUID List" button above the small map on your site page - **VERY CAREFULLY** check that the variables are in exactly the same order as in the variable array: diff --git a/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_NoCellular/ReadMe.md b/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_NoCellular/ReadMe.md index b7c1089be..a477c5edb 100644 --- a/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_NoCellular/ReadMe.md +++ b/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_NoCellular/ReadMe.md @@ -44,7 +44,7 @@ _______ ### Prepare and set up PlatformIO -- Register a site and sensors on [Monitor My Watershed](https://monitormywatershed.org/) +- Register a site and sensors on [Monitor My Watershed](https://monitormywatershed.org) - Create a new PlatformIO project - Replace the contents of the platformio.ini for your new project with the [platformio.ini](https://raw.githubusercontent.com/EnviroDIY/ModularSensors/master/examples/DRWI_NoCellular/platformio.ini) file in the examples/DRWI_NoCellular folder on GitHub. - It is important that your PlatformIO configuration has the lib_ldf_mode and build flags set as they are in the example. @@ -95,7 +95,7 @@ CampbellOBS3 osb3high(OBS3Power, OBSHighADSChannel, OBSHigh_A, OBSHigh_B, OBSHig ### Set the universally universal identifiers (UUID) for each variable -- Go back to the web page for your site on [Monitor My Watershed](https://monitormywatershed.org/) +- Go back to the web page for your site on [Monitor My Watershed](https://monitormywatershed.org) - Find and click the white "View Token UUID List" button above the small map on your site page - __VERY CAREFULLY__ check that the variables are in exactly the same order as in the variable array: diff --git a/examples/baro_rho_correction/ReadMe.md b/examples/baro_rho_correction/ReadMe.md index 2ac1ad0b4..d91d819ff 100644 --- a/examples/baro_rho_correction/ReadMe.md +++ b/examples/baro_rho_correction/ReadMe.md @@ -35,7 +35,7 @@ _______ ### Prepare and set up PlatformIO -- Register a site and sensors on [Monitor My Watershed](https://monitormywatershed.org/) +- Register a site and sensors on [Monitor My Watershed](https://monitormywatershed.org) - Create a new PlatformIO project - Replace the contents of the platformio.ini for your new project with the [platformio.ini](https://raw.githubusercontent.com/EnviroDIY/ModularSensors/master/examples/baro_rho_correction/platformio.ini) file in the examples/baro_rho_correction folder on GitHub. - It is important that your PlatformIO configuration has the lib_ldf_mode and build flags set as they are in the example. @@ -56,7 +56,7 @@ const char *LoggerID = "XXXX"; ### Set the universally universal identifiers (UUID) for each variable -- Go back to the web page for your site on [Monitor My Watershed](https://monitormywatershed.org/) +- Go back to the web page for your site on [Monitor My Watershed](https://monitormywatershed.org) - For each variable, find the dummy UUID (`"12345678-abcd-1234-ef00-1234567890ab"`) and replace it with the real UUID for the variable. ### Upload! diff --git a/examples/logging_to_MMW/ReadMe.md b/examples/logging_to_MMW/ReadMe.md index 2be4aedea..478c3292c 100644 --- a/examples/logging_to_MMW/ReadMe.md +++ b/examples/logging_to_MMW/ReadMe.md @@ -37,7 +37,7 @@ _______ ### Prepare and set up PlatformIO -- Register a site and sensors on [Monitor My Watershed](https://monitormywatershed.org/) +- Register a site and sensors on [Monitor My Watershed](https://monitormywatershed.org) - Create a new PlatformIO project - Replace the contents of the platformio.ini for your new project with the [platformio.ini](https://raw.githubusercontent.com/EnviroDIY/ModularSensors/master/examples/logging_to_MMW/platformio.ini) file in the examples/logging_to_MMW folder on GitHub. - It is important that your PlatformIO configuration has the lib_ldf_mode and build flags set as they are in the example. @@ -58,7 +58,7 @@ const char *LoggerID = "XXXX"; ### Set the universally universal identifiers (UUID) for each variable -- Go back to the web page for your site on [Monitor My Watershed](https://monitormywatershed.org/) +- Go back to the web page for your site on [Monitor My Watershed](https://monitormywatershed.org) - For each variable, find the dummy UUID (`"12345678-abcd-1234-ef00-1234567890ab"`) and replace it with the real UUID for the variable. ### Upload! From b8f8dea4335d7e742efa4d5c58524e1cbab4650c Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Tue, 17 Feb 2026 17:38:54 -0500 Subject: [PATCH 164/533] Code rabbit suggested loop fixes Signed-off-by: Sara Damiano --- continuous_integration/generate_job_matrix.py | 26 +++++++++++-------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/continuous_integration/generate_job_matrix.py b/continuous_integration/generate_job_matrix.py index 9b7204da9..e33601d3b 100644 --- a/continuous_integration/generate_job_matrix.py +++ b/continuous_integration/generate_job_matrix.py @@ -103,16 +103,19 @@ # Find all of the non-menu examples non_menu_examples = [] -for root, subdirs, files in os.walk(examples_path): +for root, _subdirs, files in os.walk(examples_path): + folder_name = os.path.basename(root) + if folder_name in { + ".history", + "logger_test", + "archive", + "tests", + menu_example_name, + }: + continue for filename in files: file_path = os.path.join(root, filename) - if filename == os.path.split(root)[-1] + ".ino" and root not in [ - ".history", - "logger_test", - "archive", - "tests", - menu_example_name, - ]: + if filename == f"{folder_name}.ino": non_menu_examples.append(os.path.realpath(root)) if use_verbose: print(f"::debug::\t- example: {filename} (full path: {file_path})") @@ -314,11 +317,12 @@ def snake_to_camel(snake_str): compilers, [arduino_ex_commands, pio_ex_commands] ): # Skip examples that need to be updated or don't apply - if "data_saving" in example.lower(): + example_name = os.path.basename(example).lower() + if "data_saving" in example_name: continue # skip until updated - if "mayfly" in example.lower() and pio_env != "mayfly": + if "mayfly" in example_name and pio_env != "mayfly": continue # skip mayfly examples on non-mayfly builds - if "drwi" in example.lower() and pio_env not in ["mayfly", "stonefly"]: + if "drwi" in example_name and pio_env not in ["mayfly", "stonefly"]: continue # skip drwi examples on non-EnviroDIY processor builds command_list.extend( From bf5de0d0a4035b7e8bdb692a1b2f3ed1860cd05e Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Tue, 17 Feb 2026 17:41:31 -0500 Subject: [PATCH 165/533] Updated comment Signed-off-by: Sara Damiano --- src/sensors/TallyCounterI2C.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sensors/TallyCounterI2C.cpp b/src/sensors/TallyCounterI2C.cpp index 90a6f36e1..eaed0e3d6 100644 --- a/src/sensors/TallyCounterI2C.cpp +++ b/src/sensors/TallyCounterI2C.cpp @@ -85,7 +85,7 @@ bool TallyCounterI2C::addSingleMeasurementResult(void) { // May also return a very negative value when receiving a bad response if (events < 0) { MS_DBG(getSensorNameAndLocation(), - F("returns all values 0 or bad, assuming sensor non-response!")); + F("returned negative value, assuming sensor non-response!")); events = -9999; } else { MS_DBG(getSensorNameAndLocation(), F("is reporting:")); From b657521ab237ca23a904e9efbd861eab0eb0ac26 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Tue, 17 Feb 2026 17:46:33 -0500 Subject: [PATCH 166/533] Better INA219 success verification (thanks CodeRabbit!) Signed-off-by: Sara Damiano --- src/sensors/TIINA219.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/sensors/TIINA219.cpp b/src/sensors/TIINA219.cpp index b8fac19d3..ced2e9298 100644 --- a/src/sensors/TIINA219.cpp +++ b/src/sensors/TIINA219.cpp @@ -49,12 +49,12 @@ bool TIINA219::setup(void) { waitForWarmUp(); } - ina219_phy.begin(_i2c); + bool success = ina219_phy.begin(_i2c); // Turn the power back off it it had been turned on if (!wasOn) { powerDown(); } - return true; + return success; } @@ -65,9 +65,9 @@ bool TIINA219::wake(void) { // Begin/Init needs to be rerun after every power-up to set the calibration // coefficient for the INA219 (see p21 of datasheet) - ina219_phy.begin(_i2c); + bool success = ina219_phy.begin(_i2c); - return true; + return success; } @@ -89,8 +89,9 @@ bool TIINA219::addSingleMeasurementResult(void) { busV_V = ina219_phy.getBusVoltage_V(); power_mW = ina219_phy.getPower_mW(); - // Only success if none of the values are NaN - success = !isnan(current_mA) && !isnan(busV_V) && !isnan(power_mW); + // Only success if I2C read succeeded and none of the values are NaN + success = ina219_phy.success() && !isnan(current_mA) && !isnan(busV_V) && + !isnan(power_mW); MS_DBG(F(" Current [mA]:"), current_mA); MS_DBG(F(" Bus Voltage [V]:"), busV_V); From 2905fd7c87a3d4e6034470129c0dc00dd879ea60 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Tue, 17 Feb 2026 17:48:32 -0500 Subject: [PATCH 167/533] Check success before multiplying conductivity (thanks CodeRabbit) Signed-off-by: Sara Damiano --- src/sensors/YosemitechParent.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/sensors/YosemitechParent.cpp b/src/sensors/YosemitechParent.cpp index bd9bbfb21..edc3cc48e 100644 --- a/src/sensors/YosemitechParent.cpp +++ b/src/sensors/YosemitechParent.cpp @@ -227,7 +227,9 @@ bool YosemitechParent::addSingleMeasurementResult(void) { success = _ysensor.getValues(parmValue, tempValue, thirdValue); // For conductivity, convert mS/cm to µS/cm - if (_model == Y520 && !isnan(parmValue)) parmValue *= 1000; + if (_model == Y520 && success && !isnan(parmValue)) { + parmValue *= 1000; + } MS_DBG(F(" "), _ysensor.getParameter(), ':', parmValue); MS_DBG(F(" Temp:"), tempValue); From e6ba518434e0c42fee8ad70c024a8b5ef51ec2ce Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Tue, 17 Feb 2026 17:58:05 -0500 Subject: [PATCH 168/533] Fix duplicate 'the's Signed-off-by: Sara Damiano --- .../OutdatedExamples/DRWI_CitizenScience/DRWI_2G/ReadMe.md | 2 +- .../DRWI_CitizenScience/DRWI_DigiLTE/ReadMe.md | 2 +- .../DRWI_CitizenScience/DRWI_NoCellular/ReadMe.md | 2 +- examples/ReadMe.md | 3 +-- src/LoggerBase.cpp | 2 +- src/LoggerBase.h | 2 +- src/LoggerModem.h | 4 ++-- src/ModSensorConfig.h | 2 +- src/VariableBase.h | 2 +- src/modems/SodaqUBeeR410M.h | 2 +- src/sensors/BoschBME280.h | 2 +- src/sensors/BoschBMP3xx.h | 2 +- src/sensors/SensirionSHT4x.h | 2 +- 13 files changed, 14 insertions(+), 15 deletions(-) diff --git a/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_2G/ReadMe.md b/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_2G/ReadMe.md index 19f39b34d..1eb6331b1 100644 --- a/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_2G/ReadMe.md +++ b/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_2G/ReadMe.md @@ -61,7 +61,7 @@ const char *LoggerID = "XXXX"; ### Set the calibration coefficients for the Campbell OBS3+ - The OBS3+ ships with a calibration certificate; you need this sheet! -- Change _**all**_ of the the `0.000E+00` and `1.000E+00` values in this section of code to the values on that calibration sheet. +- Change _**all**_ of the `0.000E+00` and `1.000E+00` values in this section of code to the values on that calibration sheet. Use numbers from the side of the calibration sheet that shows the calibration in _**volts**_. - The sketch will not compile if these values are not entered properly. - Do not change any values except those that are `0.000E+00` and `1.000E+00`! diff --git a/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_DigiLTE/ReadMe.md b/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_DigiLTE/ReadMe.md index 4ef2a0703..2d1e2f11d 100644 --- a/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_DigiLTE/ReadMe.md +++ b/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_DigiLTE/ReadMe.md @@ -64,7 +64,7 @@ const char *LoggerID = "XXXX"; - The OBS3+ ships with a calibration certificate; you need this sheet! -- Change _**all**_ of the the `0.000E+00` and `1.000E+00` values in this section of code to the values on that calibration sheet. +- Change _**all**_ of the `0.000E+00` and `1.000E+00` values in this section of code to the values on that calibration sheet. Use numbers from the side of the calibration sheet that shows the calibration in _**volts**_. - The sketch will not compile if these values are not entered properly. - Do not change any values except those that are `0.000E+00` and `1.000E+00`! diff --git a/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_NoCellular/ReadMe.md b/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_NoCellular/ReadMe.md index a477c5edb..18cb11334 100644 --- a/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_NoCellular/ReadMe.md +++ b/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_NoCellular/ReadMe.md @@ -66,7 +66,7 @@ const char *LoggerID = "XXXX"; ### Set the calibration coefficients for the Campbell OBS3+ - The OBS3+ ships with a calibration certificate; you need this sheet! -- Change *__all__* of the the `0.000E+00` and `1.000E+00` values in this section of code to the values on that calibration sheet. +- Change *__all__* of the `0.000E+00` and `1.000E+00` values in this section of code to the values on that calibration sheet. Use numbers from the side of the calibration sheet that shows the calibration in *__volts__*. - The sketch will not compile if these values are not entered properly. - Do not change any values except those that are `0.000E+00` and `1.000E+00`! diff --git a/examples/ReadMe.md b/examples/ReadMe.md index 85c8c5b41..fd9b17816 100644 --- a/examples/ReadMe.md +++ b/examples/ReadMe.md @@ -18,7 +18,6 @@ ___ - [Calculations and Complex Logging](#calculations-and-complex-logging) - [Barometric Pressure Correction](#barometric-pressure-correction) - [Multiple Logging Intervals](#multiple-logging-intervals) - - [Minimizing Cell Data Usage](#minimizing-cell-data-usage) - [Everything at Once - a la carte](#everything-at-once---a-la-carte) - [Menu a la carte](#menu-a-la-carte) - [EnviroDIY Sensor Stations](#envirodiy-sensor-stations) @@ -123,7 +122,7 @@ ___ ### The EnviroDIY Sensor Station Kit -The The EnviroDIY Sensor Station Kit is designed to be used with the [EnviroDIY Monitoring Station Kit](https://www.envirodiy.org/product/envirodiy-monitoring-station-kit/). +The EnviroDIY Sensor Station Kit is designed to be used with the [EnviroDIY Monitoring Station Kit](https://www.envirodiy.org/product/envirodiy-monitoring-station-kit/). - [Instructions for the EnviroDIY sensor station kit example](https://envirodiy.github.io/ModularSensors/example_envirodiy_monitoring_kit.html) - [The EnviroDIY sensor station kit example on GitHub](https://github.com/EnviroDIY/ModularSensors/tree/master/examples/example_envirodiy_monitoring_kit) diff --git a/src/LoggerBase.cpp b/src/LoggerBase.cpp index 8e4efa96e..5f125a85e 100644 --- a/src/LoggerBase.cpp +++ b/src/LoggerBase.cpp @@ -1294,7 +1294,7 @@ void Logger::printFileHeader(Stream* stream) { STREAM_CSV_ROW(F("Result UUID:"), getVarUUIDAtI(i)) } - // We'll finish up the the custom variable codes + // We'll finish up with the custom variable codes String dtRowHeader = F("Date and Time in UTC"); if (_loggerUTCOffset > 0) { dtRowHeader += '+' + _loggerUTCOffset; diff --git a/src/LoggerBase.h b/src/LoggerBase.h index 3e30be8d2..8e4c8b7c2 100644 --- a/src/LoggerBase.h +++ b/src/LoggerBase.h @@ -388,7 +388,7 @@ class Logger { * Because this sets the pin mode, this function should only be called * during the `setup()` or `loop()` portion of an Arduino program. * - * Once in testing mode, the logger will attempt to connect the the internet + * Once in testing mode, the logger will attempt to connect to the internet * and take 25 measurements spaced at 5 second intervals writing the results * to the main output destination (ie, Serial). Testing mode cannot be * entered while the logger is taking a scheduled measurement. No data is diff --git a/src/LoggerModem.h b/src/LoggerModem.h index 7eee5d6d6..8ad0dbc32 100644 --- a/src/LoggerModem.h +++ b/src/LoggerModem.h @@ -503,7 +503,7 @@ class loggerModem { /** * @anchor modem_pin_functions * @name Pin setting functions - * Functions to set or re-set the the pin numbers for the connection between + * Functions to set or re-set the pin numbers for the connection between * the modem module and the logger MCU. */ /**@{*/ @@ -988,7 +988,7 @@ class loggerModem { */ bool _statusLevel; /** - * @brief The digital pin number of the pin on the mcu attached the the hard + * @brief The digital pin number of the pin on the mcu attached the hard * or panic reset pin of the modem. * * Should be set to a negative number if the modem reset pin is not diff --git a/src/ModSensorConfig.h b/src/ModSensorConfig.h index 91cf7149a..892c09a7e 100644 --- a/src/ModSensorConfig.h +++ b/src/ModSensorConfig.h @@ -277,7 +277,7 @@ * TinyGSM. * * If you are using a slow baud rate to communicate with your module, this delay - * is set to prevent command responses from being spliced apart. This is + * is set to prevent command responses from being spliced apart. This is * especially important when using a faster processor. */ #define TINY_GSM_YIELD_MS 2 diff --git a/src/VariableBase.h b/src/VariableBase.h index ce3a0cf06..dac62be29 100644 --- a/src/VariableBase.h +++ b/src/VariableBase.h @@ -358,7 +358,7 @@ class Variable { */ void setVarUUID(const char* uuid); /** - * @brief Verify the the UUID is correctly formatted + * @brief Verify the UUID is correctly formatted * * @return True if the UUID is correctly formatted. * diff --git a/src/modems/SodaqUBeeR410M.h b/src/modems/SodaqUBeeR410M.h index 96b758544..b8873c4fb 100644 --- a/src/modems/SodaqUBeeR410M.h +++ b/src/modems/SodaqUBeeR410M.h @@ -219,7 +219,7 @@ * @brief The loggerModem subclass for the * [LTE-M](@ref modem_ubee_ltem) [Sodaq UBee](@ref modem_ublox) based on the * u-blox SARA R410M LTE-M cellular module. This can be also used for any other - * breakout of the the u-blox R4 or N4 series modules. + * breakout of the u-blox R4 or N4 series modules. */ class SodaqUBeeR410M : public loggerModem { public: diff --git a/src/sensors/BoschBME280.h b/src/sensors/BoschBME280.h index 236c02555..e3a45cfb1 100644 --- a/src/sensors/BoschBME280.h +++ b/src/sensors/BoschBME280.h @@ -340,7 +340,7 @@ class BoschBME280 : public Sensor { private: /** - * @brief Internal reference the the Adafruit BME object + * @brief Internal reference to the Adafruit BME object */ Adafruit_BME280 bme_internal; /** diff --git a/src/sensors/BoschBMP3xx.h b/src/sensors/BoschBMP3xx.h index c8c911102..b8c06fb17 100644 --- a/src/sensors/BoschBMP3xx.h +++ b/src/sensors/BoschBMP3xx.h @@ -461,7 +461,7 @@ class BoschBMP3xx : public Sensor { private: /** - * @brief Internal reference the the BMP388_DEV object + * @brief Internal reference to the BMP388_DEV object */ BMP388_DEV bmp_internal; diff --git a/src/sensors/SensirionSHT4x.h b/src/sensors/SensirionSHT4x.h index b81efded1..2df8188fe 100644 --- a/src/sensors/SensirionSHT4x.h +++ b/src/sensors/SensirionSHT4x.h @@ -290,7 +290,7 @@ class SensirionSHT4x : public Sensor { */ bool _useHeater; /** - * @brief Internal reference the the Adafruit BME object + * @brief Internal reference to the Adafruit SHT4x object */ Adafruit_SHT4x sht4x_internal; /** From f6b98f66919a8974f6ccbc1b6dfe569966295313 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Tue, 17 Feb 2026 17:58:21 -0500 Subject: [PATCH 169/533] Don't initialize i2c_status Signed-off-by: Sara Damiano --- src/sensors/PaleoTerraRedox.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sensors/PaleoTerraRedox.cpp b/src/sensors/PaleoTerraRedox.cpp index 4a236534d..e6514cbb3 100644 --- a/src/sensors/PaleoTerraRedox.cpp +++ b/src/sensors/PaleoTerraRedox.cpp @@ -108,7 +108,7 @@ bool PaleoTerraRedox::addSingleMeasurementResult(void) { float res = 0; // Calculated voltage in uV - byte i2c_status = -1; + byte i2c_status; _i2c->beginTransmission(_i2cAddressHex); _i2c->write(0b10001100); // initiate conversion, One-Shot mode, 18 From 5ad1274169e454e0d22b229326368ba633a7f7ed Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Tue, 17 Feb 2026 17:59:34 -0500 Subject: [PATCH 170/533] Remove stray * Signed-off-by: Sara Damiano --- src/sensors/ProcessorAnalog.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sensors/ProcessorAnalog.h b/src/sensors/ProcessorAnalog.h index d6790dea3..1c7ec5607 100644 --- a/src/sensors/ProcessorAnalog.h +++ b/src/sensors/ProcessorAnalog.h @@ -1,5 +1,5 @@ /** - * @file ProcessorAnalog.h * + * @file ProcessorAnalog.h * @copyright Stroud Water Research Center * Part of the EnviroDIY ModularSensors library for Arduino. * This library is published under the BSD-3 license. From ff37a3f7eb9a6bb91bc94bf083ccef6d33a878a1 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Tue, 17 Feb 2026 18:01:30 -0500 Subject: [PATCH 171/533] Only clear events on success Signed-off-by: Sara Damiano --- src/sensors/TallyCounterI2C.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/sensors/TallyCounterI2C.cpp b/src/sensors/TallyCounterI2C.cpp index eaed0e3d6..523b84e46 100644 --- a/src/sensors/TallyCounterI2C.cpp +++ b/src/sensors/TallyCounterI2C.cpp @@ -91,10 +91,10 @@ bool TallyCounterI2C::addSingleMeasurementResult(void) { MS_DBG(getSensorNameAndLocation(), F("is reporting:")); verifyAndAddMeasurementResult(TALLY_EVENTS_VAR_NUM, events); success = true; - } - // Clear count value - counter_internal.Clear(); + // Clear count value + counter_internal.Clear(); + } MS_DBG(F(" Events:"), events); From 8dca8e015f3825768f78d58b71ff0421eee7f09b Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Tue, 17 Feb 2026 18:04:09 -0500 Subject: [PATCH 172/533] Fix anb ph constructor in example Signed-off-by: Sara Damiano --- examples/menu_a_la_carte/menu_a_la_carte.ino | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/menu_a_la_carte/menu_a_la_carte.ino b/examples/menu_a_la_carte/menu_a_la_carte.ino index 09014a72d..378247645 100644 --- a/examples/menu_a_la_carte/menu_a_la_carte.ino +++ b/examples/menu_a_la_carte/menu_a_la_carte.ino @@ -1041,8 +1041,8 @@ const int8_t al485EnablePin = -1; // Adapter RE/DE pin const uint8_t anbNumberReadings = 1; // Create an ANB pH sensor object -ANBpH anbPH(anbModbusAddress, modbusSerial, anbPower, alAdapterPower, - al485EnablePin, anbNumberReadings); +ANBpH anbPH(anbModbusAddress, modbusSerial, anbPower, loggingInterval, + alAdapterPower, al485EnablePin, anbNumberReadings); // Create all of the variable pointers for the ANB pH sensor Variable* anbPHValue = new ANBpH_pH(&anbPH, From 74d2f75bb5e77f31701bddb1f9a7834622a215f5 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Tue, 17 Feb 2026 18:06:36 -0500 Subject: [PATCH 173/533] Update code rabbit config Signed-off-by: Sara Damiano --- .coderabbit.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.coderabbit.yaml b/.coderabbit.yaml index cca822a00..b107adc60 100644 --- a/.coderabbit.yaml +++ b/.coderabbit.yaml @@ -27,7 +27,7 @@ reviews: - '!**/cspell.json' - '!**/platformio.ini' path_instructions: - - path: '**/*.hpp' + - path: '**/*.h' instructions: >- Review the C++ code, point out issues relative to principles of clean code, expressiveness, and performance. From 886eeac6196f3373fdff82583ca6949fbbb1919e Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Tue, 17 Feb 2026 18:09:42 -0500 Subject: [PATCH 174/533] Grammar fix Signed-off-by: Sara Damiano --- examples/EnviroDIY_Monitoring_Kit/ReadMe.md | 2 +- .../DRWI_CitizenScience/DRWI_Mayfly1/ReadMe.md | 2 +- examples/ReadMe.md | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/EnviroDIY_Monitoring_Kit/ReadMe.md b/examples/EnviroDIY_Monitoring_Kit/ReadMe.md index fa842de02..3e076888a 100644 --- a/examples/EnviroDIY_Monitoring_Kit/ReadMe.md +++ b/examples/EnviroDIY_Monitoring_Kit/ReadMe.md @@ -4,7 +4,7 @@ Example sketch to be used with the [EnviroDIY Monitoring Station Kit](https://ww This example uses the sensors and equipment included with (or recommended for) the [EnviroDIY Monitoring Station Kit](https://www.envirodiy.org/product/envirodiy-monitoring-station-kit/). It includes code for a Mayfly 1.x, a [Meter Hydros 21](https://metergroup.com/products/hydros-21/) and either a [SIM7080G-based EnviroDIY LTEbee](https://www.envirodiy.org/product/envirodiy-lte-bee/) or an [EnviroDIY ESP32 Bee](https://www.envirodiy.org/product/envirodiy-esp32-bee-wifi-bluetooth/) for communication. -This examples also makes use of the on-board light, temperature, and humidity sensors on the Mayfly 1.x. +This example also makes use of the on-board light, temperature, and humidity sensors on the Mayfly 1.x. The results are saved to the SD card and posted to Monitor My Watershed. > [!NOTE] diff --git a/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_Mayfly1/ReadMe.md b/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_Mayfly1/ReadMe.md index 521ee44f3..8ec4726fb 100644 --- a/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_Mayfly1/ReadMe.md +++ b/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_Mayfly1/ReadMe.md @@ -2,7 +2,7 @@ Example sketch for using the EnviroDIY SIM7080G LTE cellular module with an EnviroDIY Mayfly Data Logger. -This example uses the sensors and equipment used by most groups participating in the DRWI (Delaware River Watershed Initiative) Citizen Science project with the Stroud Water Research Center. It includes a Meter Hydros 21 (CTD) and a SIM7080G-based EnviroDIY LTEbee for communication. This examples also makes use of the on-board light, temperature, and humidity sensors on the Mayfly 1.x. The results are saved to the SD card and posted to Monitor My Watershed. Only to be used with newer Mayfly v1.0 and v1.1 boards. +This example uses the sensors and equipment used by most groups participating in the DRWI (Delaware River Watershed Initiative) Citizen Science project with the Stroud Water Research Center. It includes a Meter Hydros 21 (CTD) and a SIM7080G-based EnviroDIY LTEbee for communication. This example also makes use of the on-board light, temperature, and humidity sensors on the Mayfly 1.x. The results are saved to the SD card and posted to Monitor My Watershed. Only to be used with newer Mayfly v1.0 and v1.1 boards. The exact hardware configuration used in this example: diff --git a/examples/ReadMe.md b/examples/ReadMe.md index fd9b17816..87cc029f5 100644 --- a/examples/ReadMe.md +++ b/examples/ReadMe.md @@ -108,7 +108,7 @@ ___ The "menu a la carte" example shows most of the functions of the library in one gigantic program. It has code in it for every possible sensor and modem and for both AVR and SAMD boards. It is also over 1500 lines long. -This examples is intended to be used like an a la carte menu of all possible options where you selected only the portions of code pertinent to you and delete everything else. +This example is intended to be used like an a la carte menu of all possible options where you selected only the portions of code pertinent to you and delete everything else. This example is *NOT* intended to be run in its entirety - [The menu a la carte walkthrough](https://envirodiy.github.io/ModularSensors/example_menu.html) @@ -147,7 +147,7 @@ ___ The DRWI Mayfly 1.x LTE example uses the sensors and equipment used by most groups participating in the DRWI (Delaware River Watershed Initiative) Citizen Science project with the Stroud Water Research Center. It includes a Meter Hydros 21 (CTD) and a SIM7080G-based EnviroDIY LTEbee for communication. -This examples also makes use of the on-board light, temperature, and humidity sensors on the Mayfly 1.x. +This example also makes use of the on-board light, temperature, and humidity sensors on the Mayfly 1.x. The results are saved to the SD card and posted to Monitor My Watershed. Only to be used with newer Mayfly v1.0 and v1.1 boards. - [Instructions for the Mayfly 1.x LTE DRWI Citizen Science example](https://envirodiy.github.io/ModularSensors/example_drwi_mayfly1.html) From ff44cf67a507372f7936aecd09f96fedf11c4f94 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Tue, 17 Feb 2026 18:10:41 -0500 Subject: [PATCH 175/533] Update brief Signed-off-by: Sara Damiano --- src/publishers/EnviroDIYPublisher.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/publishers/EnviroDIYPublisher.h b/src/publishers/EnviroDIYPublisher.h index 11199c4c8..5cd443ad6 100644 --- a/src/publishers/EnviroDIYPublisher.h +++ b/src/publishers/EnviroDIYPublisher.h @@ -5,9 +5,9 @@ * This library is published under the BSD-3 license. * @author Sara Geleskie Damiano * - * @brief Contains the EnviroDIYPublisher subclass of dataPublisher for - * publishing data to the Monitor My Watershed/EnviroDIY data portal at - * http://data.enviroDIY.org + * @brief Contains the EnviroDIYPublisher subclass of dataPublisher which is a + * typedef reference to the MonitorMyWatershedPublisher for backward + * compatibility. */ // Header Guards From 805e676234203477d4073a01344b2fe5b0772756 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Tue, 17 Feb 2026 18:11:23 -0500 Subject: [PATCH 176/533] Grammar fix Signed-off-by: Sara Damiano --- src/publishers/UbidotsPublisher.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/publishers/UbidotsPublisher.cpp b/src/publishers/UbidotsPublisher.cpp index d8beecba1..286995e7c 100644 --- a/src/publishers/UbidotsPublisher.cpp +++ b/src/publishers/UbidotsPublisher.cpp @@ -117,7 +117,7 @@ int16_t UbidotsPublisher::publishData(Client* outClient, bool) { if (_baseLogger->getSamplingFeatureUUID() == nullptr || strlen(_baseLogger->getSamplingFeatureUUID()) == 0) { PRINTOUT(F("A sampling feature UUID must be set before publishing data " - "to Ubidots!.")); + "to Ubidots!")); return 0; } From 55a11af115e9d8173ab0af7133feff62b6c1ba09 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Wed, 18 Feb 2026 11:07:56 -0500 Subject: [PATCH 177/533] Fix min/max timing calculation Signed-off-by: Sara Damiano --- src/sensors/GeoluxHydroCam.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/sensors/GeoluxHydroCam.cpp b/src/sensors/GeoluxHydroCam.cpp index ef4a93f18..87a270886 100644 --- a/src/sensors/GeoluxHydroCam.cpp +++ b/src/sensors/GeoluxHydroCam.cpp @@ -350,12 +350,12 @@ bool GeoluxHydroCam::isStable(bool debug) { } uint32_t elapsed_since_wake_up = millis() - _millisSensorActivated; - uint32_t minTime = _stabilizationTime_ms + _alwaysAutoFocus - ? HYDROCAM_AUTOFOCUS_TIME_MS + uint32_t minTime = _alwaysAutoFocus + ? HYDROCAM_AUTOFOCUS_TIME_MS + _stabilizationTime_ms + : 0L; + uint32_t maxTime = _alwaysAutoFocus + ? HYDROCAM_AUTOFOCUS_TIME_MAX + HYDROCAM_STABILIZATION_TIME_MAX : 0L; - uint32_t maxTime = HYDROCAM_STABILIZATION_TIME_MAX + _alwaysAutoFocus - ? HYDROCAM_AUTOFOCUS_TIME_MAX - : 0L; // If the sensor has been activated and enough time has elapsed, it's stable if (elapsed_since_wake_up > maxTime) { MS_DBG(F("It's been"), elapsed_since_wake_up, F("ms, and"), From 27a73bf9f7dc511dbbb9ea56cfc145e2983adcd8 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Wed, 18 Feb 2026 11:10:55 -0500 Subject: [PATCH 178/533] Remove outdated local build script Signed-off-by: Sara Damiano --- build-menu-configurations.ps1 | 181 ---------------------------------- 1 file changed, 181 deletions(-) delete mode 100644 build-menu-configurations.ps1 diff --git a/build-menu-configurations.ps1 b/build-menu-configurations.ps1 deleted file mode 100644 index c7ba51de9..000000000 --- a/build-menu-configurations.ps1 +++ /dev/null @@ -1,181 +0,0 @@ -$ErrorActionPreference = "Stop" - -mkdir temp -Force -mkdir temp/menu_a_la_carte -Force - -$pioCommand = "pio pkg install --library" -$pioCommand += ';$?' - -$pioResult = Invoke-Expression $pioCommand -if (("$pioResult".EndsWith('False')) -or (-not $pioResult)){ - Write-Host "----------------------------------------------------------------------------" -ForegroundColor Red - Write-Host "PlatformIO Library Installation Failed" -ForegroundColor Red - Write-Host "----------------------------------------------------------------------------" -ForegroundColor Red - Exit 1 -} - -$pioCommand = "pio pkg update" -$pioCommand += ';$?' - -$pioResult = Invoke-Expression $pioCommand -if (("$pioResult".EndsWith('False')) -or (-not $pioResult)){ - Write-Host "----------------------------------------------------------------------------" -ForegroundColor Red - Write-Host "PlatformIO Library Update Failed" -ForegroundColor Red - Write-Host "----------------------------------------------------------------------------" -ForegroundColor Red - Exit 1 -} - -$pioCommand = "pio run --project-conf=""continuous_integration/platformio.ini"" --verbose" -$pioCommand += ';$?' - -$modemFlags = @(` - 'BUILD_MODEM_DIGI_XBEE_CELLULAR_TRANSPARENT', ` - 'BUILD_MODEM_DIGI_XBEE_LTE_BYPASS', ` - 'BUILD_MODEM_DIGI_XBEE_3G_BYPASS', ` - 'BUILD_MODEM_DIGI_XBEE_WIFI', ` - 'BUILD_MODEM_ESPRESSIF_ESP8266', ` - 'BUILD_MODEM_QUECTEL_BG96', ` - 'BUILD_MODEM_SEQUANS_MONARCH', ` - 'BUILD_MODEM_SIM_COM_SIM800', ` - 'BUILD_MODEM_SIM_COM_SIM7000', ` - 'BUILD_MODEM_SODAQ2_G_BEE_R6', ` - 'BUILD_MODEM_SODAQ_UBEE_R410M', ` - 'BUILD_MODEM_SODAQ_UBEE_U201') - -Foreach ($modemFlag in $modemFlags) -{ - $tempFile = "temp/menu_a_la_carte/main.cpp" - if (Test-Path $tempFile) { - Remove-Item $tempFile - } - Write-Host "----------------------------------------------------------------------------" -ForegroundColor Cyan - Write-Host "----------------------------------------------------------------------------" -ForegroundColor Cyan - Write-Host "Modifying source for $modemFlag" -ForegroundColor Green - Write-Host "----------------------------------------------------------------------------" -ForegroundColor Cyan - Write-Host "----------------------------------------------------------------------------" -ForegroundColor Cyan - $originalMenu = Get-Content -Path "examples/menu_a_la_carte/menu_a_la_carte.ino" -Encoding UTF8 -Raw - $newHeading = "#define $modemFlag`n#define BUILD_TEST_PRE_NAMED_VARS`n" - $newHeading += $originalMenu - $newHeading | Add-Content -Path $tempFile -Encoding UTF8 - - # Write-Output "First few lines of source" - # Get-Content $tempFile | select -Skip 10 - - $pioResult = Invoke-Expression $pioCommand - if (("$pioResult".EndsWith('False')) -or (-not $pioResult)){ - Write-Host "----------------------------------------------------------------------------" -ForegroundColor Red - Write-Host "PlatformIO Build Failed" -ForegroundColor Red - Write-Host "----------------------------------------------------------------------------" -ForegroundColor Red - Remove-Item –path temp –recurse - Exit 1 - } -} - -$sensorFlags = @(` - 'BUILD_SENSOR_AO_SONG_AM2315', ` - 'BUILD_SENSOR_AO_SONG_DHT', ` - 'BUILD_SENSOR_APOGEE_SQ212', ` - 'BUILD_SENSOR_ATLAS_SCIENTIFIC_CO2', ` - 'BUILD_SENSOR_ATLAS_SCIENTIFIC_DO', ` - 'BUILD_SENSOR_ATLAS_SCIENTIFIC_ORP', ` - 'BUILD_SENSOR_ATLAS_SCIENTIFIC_PH', ` - 'BUILD_SENSOR_ATLAS_SCIENTIFIC_RTD', ` - 'BUILD_SENSOR_ATLAS_SCIENTIFIC_EC', ` - 'BUILD_SENSOR_BOSCH_BME280', ` - 'BUILD_SENSOR_CAMPBELL_OBS3', ` - 'BUILD_SENSOR_DECAGON_ES2', ` - 'BUILD_SENSOR_TIADS1X15', ` - 'BUILD_SENSOR_FREESCALE_MPL115A2', ` - 'BUILD_SENSOR_IN_SITU_RDO', ` - 'BUILD_SENSOR_IN_SITU_TROLL_SDI12A', ` - 'BUILD_SENSOR_KELLER_ACCULEVEL', ` - 'BUILD_SENSOR_KELLER_NANOLEVEL', ` - 'BUILD_SENSOR_MAX_BOTIX_SONAR', ` - 'BUILD_SENSOR_MAXIM_DS18', ` - 'BUILD_SENSOR_MEA_SPEC_MS5803', ` - 'BUILD_SENSOR_DECAGON_5TM', ` - 'BUILD_SENSOR_DECAGON_CTD', ` - 'BUILD_SENSOR_METER_TEROS11', ` - 'BUILD_SENSOR_PALEO_TERRA_REDOX', ` - 'BUILD_SENSOR_RAIN_COUNTER_I2C', ` - 'BUILD_SENSOR_TALLY_COUNTER_I2C', ` - 'BUILD_SENSOR_SENSIRION_SHT4X', ` - 'BUILD_SENSOR_TI_INA219', ` - 'BUILD_SENSOR_TURNER_CYCLOPS', ` - 'BUILD_SENSOR_ANALOG_ELEC_CONDUCTIVITY', ` - 'BUILD_SENSOR_YOSEMITECH_Y504', ` - 'BUILD_SENSOR_YOSEMITECH_Y510', ` - 'BUILD_SENSOR_YOSEMITECH_Y511', ` - 'BUILD_SENSOR_YOSEMITECH_Y514', ` - 'BUILD_SENSOR_YOSEMITECH_Y520', ` - 'BUILD_SENSOR_YOSEMITECH_Y532', ` - 'BUILD_SENSOR_YOSEMITECH_Y533', ` - 'BUILD_SENSOR_YOSEMITECH_Y551', ` - 'BUILD_SENSOR_YOSEMITECH_Y560', ` - 'BUILD_SENSOR_YOSEMITECH_Y4000', ` - 'BUILD_SENSOR_ZEBRA_TECH_D_OPTO') - -Foreach ($sensorFlag in $sensorFlags) -{ - $tempFile = "temp/menu_a_la_carte/main.cpp" - if (Test-Path $tempFile) { - Remove-Item $tempFile - } - Write-Host "----------------------------------------------------------------------------" -ForegroundColor Cyan - Write-Host "----------------------------------------------------------------------------" -ForegroundColor Cyan - Write-Host "Modifying source for $sensorFlag" -ForegroundColor Green - Write-Host "----------------------------------------------------------------------------" -ForegroundColor Cyan - Write-Host "----------------------------------------------------------------------------" -ForegroundColor Cyan - $originalMenu = Get-Content -Path "examples/menu_a_la_carte/menu_a_la_carte.ino" -Encoding UTF8 -Raw - $newHeading = "#define BUILD_MODEM_DIGI_XBEE_CELLULAR_TRANSPARENT`n#define BUILD_TEST_PRE_NAMED_VARS`n#define $sensorFlag`n" - $newHeading += $originalMenu - $newHeading | Add-Content -Path $tempFile -Encoding UTF8 - - # # Write-Output "First few lines of source" - # Get-Content $tempFile | select -Skip 10 - - $pioResult = Invoke-Expression $pioCommand - if (("$pioResult".EndsWith('False')) -or (-not $pioResult)){ - Write-Host "----------------------------------------------------------------------------" -ForegroundColor Red - Write-Host "PlatformIO Build Failed" -ForegroundColor Red - Write-Host "----------------------------------------------------------------------------" -ForegroundColor Red - Remove-Item –path temp –recurse - Exit 1 - } -} - -$publisherFlag = @(` - 'BUILD_PUB_MONITOR_MY_WATERSHED_PUBLISHER', ` - 'BUILD_PUB_DREAM_HOST_PUBLISHER', ` - 'BUILD_PUB_THING_SPEAK_PUBLISHER') - -Foreach ($publisherFlag in $publisherFlags) -{ - $tempFile = "temp/menu_a_la_carte/main.cpp" - if (Test-Path $tempFile) { - Remove-Item $tempFile - } - Write-Host "----------------------------------------------------------------------------" -ForegroundColor Cyan - Write-Host "----------------------------------------------------------------------------" -ForegroundColor Cyan - Write-Host "Modifying source for $publisherFlag" -ForegroundColor Green - Write-Host "----------------------------------------------------------------------------" -ForegroundColor Cyan - Write-Host "----------------------------------------------------------------------------" -ForegroundColor Cyan - $originalMenu = Get-Content -Path "examples/menu_a_la_carte/menu_a_la_carte.ino" -Encoding UTF8 -Raw - $newHeading = "#define BUILD_MODEM_DIGI_XBEE_CELLULAR_TRANSPARENT`n#define BUILD_TEST_PRE_NAMED_VARS`n#define $publisherFlag`n" - $newHeading += $originalMenu - $newHeading | Add-Content -Path $tempFile -Encoding UTF8 - - # Write-Output "First few lines of source" - # Get-Content $tempFile | select -Skip 10 - - $pioResult = Invoke-Expression $pioCommand - if (("$pioResult".EndsWith('False')) -or (-not $pioResult)){ - Write-Host "----------------------------------------------------------------------------" -ForegroundColor Red - Write-Host "PlatformIO Build Failed" -ForegroundColor Red - Write-Host "----------------------------------------------------------------------------" -ForegroundColor Red - Remove-Item –path temp –recurse - Exit 1 - } -} - -Remove-Item –path temp –recurse From 69896322376e220ec0c800c672efca54f193523a Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Wed, 18 Feb 2026 11:27:32 -0500 Subject: [PATCH 179/533] Separated clearing status/timing and clearing values into two functions Signed-off-by: Sara Damiano --- ChangeLog.md | 5 +++-- src/SensorBase.cpp | 13 +++++++++++-- src/SensorBase.h | 15 ++++++++++++++- src/VariableArray.cpp | 9 ++++++++- 4 files changed, 36 insertions(+), 6 deletions(-) diff --git a/ChangeLog.md b/ChangeLog.md index 3fef7cd4a..fb9dbd643 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -30,14 +30,14 @@ There is a shell file and typedef to maintain backwards compatibility. These resets were an awkward attempt to deal with bad values before feeding any bad values to the `verifyAndAddMeasurementResult()` function which was previously always called even if the sensor returned junk. This was probably a hold-over from incorrect implementation and calling of the clearValues function deep in the library history. - Also made the return from the `addSingleMeasurementResult()` function consistently false for a bad sensor response and true for a good one - where it's possible to tell the difference. -- The Sensor::clearValues() function now resets all timing and bits for the sensor in addition to setting all values in the value array to -9999. +- The Sensor::clearValues() function now resets the attempt and retry counts in addition to setting all values in the value array to -9999. - Re-wrote some of the logic of the `completeUpdate()` function. Also added optional arguments to the `completeUpdate()` function to allow users to specify if the sensors should be powered/woken. - The `updateAllSensors()` function is now deprecated. Use `completeUpdate(false, false, false, false)` instead. - Previously the `updateAllSensors()` function asked all sensors to update their values, skipping all power, wake, and sleep steps while the `completeUpdate()` function duplicated that functionality and added the power, wake, and sleep. The two functions have been consolidated into one function with four arguments, one each for power on, wake, sleep, and power off. -To achieve the same functionality as the old `updateAllSensors()` function (ie, only updating values), set all of the arguments to false. +To achieve the same functionality as the old `updateAllSensors()` function (ie, only updating values), set all the arguments to false. - Applied many suggestions from Code Rabbit AI. - Moved outdated examples to a new "Outdated" folder, with a subfolder for the DRWI examples - When importing TinyGSM for the modem objects, the specific modem client headers are now imported directly rather than importing the TinyGsmClient.h header which defines typedefs for the sub-types. @@ -63,6 +63,7 @@ These values should generally be set in the specific sensor constructors and onl - `getStabilizationTime()` - `setMeasurementTime(uint32_t measurementTime_ms)` - `getMeasurementTime()` +- Added the function `Sensor::clearStatus()` which resets all status bits except setup and error and resets all timing values to 0. - **NEW SENSOR** Added a new sensor for simple analog voltage using the built-in processor ADC - Added KnownProcessors.h and moved defines values for supported built-in sensors on known processors to that file. - This affects ProcessorStats and the Everlight ALS PT-19. diff --git a/src/SensorBase.cpp b/src/SensorBase.cpp index b4fee62f9..77a589bc4 100644 --- a/src/SensorBase.cpp +++ b/src/SensorBase.cpp @@ -363,7 +363,7 @@ void Sensor::notifyVariables(void) { } -// This function just empties the value array +// This function empties the value array and resets the measurement counts. void Sensor::clearValues(void) { MS_DBG(F("Clearing value array for"), getSensorNameAndLocation()); for (uint8_t i = 0; i < _numReturnedValues; i++) { @@ -373,6 +373,10 @@ void Sensor::clearValues(void) { // Reset measurement attempt counters _measurementAttemptsCompleted = 0; _retryAttemptsMade = 0; +} +// This clears all status bits except the setup and error bit and sets the +// timing values to 0. +void Sensor::clearStatus(void) { // reset all timing values _millisPowerOn = 0; _millisSensorActivated = 0; @@ -453,6 +457,10 @@ void Sensor::averageMeasurements(void) { bool Sensor::update(void) { bool ret_val = true; + // clear all of the status bits and timing values at the start of an update + // cycle + clearStatus(); + // Check if the power is on, turn it on if not bool wasOn = checkPowerOn(); if (!wasOn) { powerUp(); } @@ -468,7 +476,8 @@ bool Sensor::update(void) { // bail if the wake failed if (!ret_val) return ret_val; - // Clear values before starting loop + // Clear stale values and reset the measurement attempt and retry + // counts before starting new measurements. clearValues(); // Wait for the sensor to stabilize diff --git a/src/SensorBase.h b/src/SensorBase.h index 922015631..774c9b4ca 100644 --- a/src/SensorBase.h +++ b/src/SensorBase.h @@ -524,9 +524,22 @@ class Sensor { float sensorValues[MAX_NUMBER_VARS]; /** - * @brief Clear the values array - that is, sets all values to -9999. + * @brief Clear the values array and reset retry counts. + * + * This clears the values array by setting all values to -9999, setal all + * values in numberGoodMeasurementsMade to 0, and resets the attempt + * (#_measurementAttemptsCompleted) and retry (#_retryAttemptsMade) counts. */ void clearValues(); + /** + * @brief This clears all of the status bits and resets timing values. + * + * This clears all status bits except the setup bit (bit 0) - and the error + * bit (bit 7) - that is, it sets bits 1-6 to 0. It also sets all timing + * variables to 0. This is intended to be used at the start of an update + * cycle to clear any old values before beginning a cycle. + */ + void clearStatus(); /** * @brief Verify that a measurement is OK (ie, not -9999) before adding it * to the result array diff --git a/src/VariableArray.cpp b/src/VariableArray.cpp index 33e2a2fb9..0c4baefb8 100644 --- a/src/VariableArray.cpp +++ b/src/VariableArray.cpp @@ -321,7 +321,14 @@ bool VariableArray::completeUpdate(bool powerUp, bool wake, bool sleep, } #endif - // Clear the initial variable arrays + // Clear the timing and status bits + MS_DBG(F("----->> Clearing all timing and status bits before taking new " + "measurements. ...")); + for (uint8_t i = 0; i < _sensorCount; i++) { sensorList[i]->clearStatus(); } + MS_DBG(F(" ... Complete. <<-----")); + + // Clear the initial variable values arrays and reset the measurement + // attempt and retry counts. MS_DBG(F("----->> Clearing all results arrays before taking new " "measurements. ...")); for (uint8_t i = 0; i < _sensorCount; i++) { sensorList[i]->clearValues(); } From e74e902d65134e02b90b12ce56f1e16cf18dbf00 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Wed, 18 Feb 2026 11:42:52 -0500 Subject: [PATCH 180/533] Add pressure range check Signed-off-by: Sara Damiano --- src/sensors/MeaSpecMS5803.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/sensors/MeaSpecMS5803.cpp b/src/sensors/MeaSpecMS5803.cpp index 0a85c9693..720f8c4b0 100644 --- a/src/sensors/MeaSpecMS5803.cpp +++ b/src/sensors/MeaSpecMS5803.cpp @@ -76,10 +76,12 @@ bool MeaSpecMS5803::addSingleMeasurementResult(void) { MS_DBG(F(" Pressure:"), press); if (!isnan(temp) && !isnan(press) && temp >= -40.0 && temp <= 85.0 && - press != 0.0) { + press != 0.0 && press <= 14000.0) { // Temperature Range is -40°C to +85°C // Pressure returns 0 when disconnected, which is highly unlikely to be // a real value. + // Pressure range depends on the model, but the highest pressure model + // goes up to 14bar (14,000 mbar) verifyAndAddMeasurementResult(MS5803_TEMP_VAR_NUM, temp); verifyAndAddMeasurementResult(MS5803_PRESSURE_VAR_NUM, press); success = true; From 069e229bf84af82e739341e1fa6a5cf540092517 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Wed, 18 Feb 2026 11:43:27 -0500 Subject: [PATCH 181/533] Code rabbit suggestions on pH, fixing equality and clamping Signed-off-by: Sara Damiano --- src/sensors/ANBpH.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/sensors/ANBpH.cpp b/src/sensors/ANBpH.cpp index 5ae42568b..43a265e3a 100644 --- a/src/sensors/ANBpH.cpp +++ b/src/sensors/ANBpH.cpp @@ -151,6 +151,12 @@ bool ANBpH::setup(void) { bool intervalSet = false; uint16_t programmedInterval = _loggingIntervalMinutes; + if (_loggingIntervalMinutes == 0 && _powerPin >= 0) { + programmedInterval = 10; + MS_DBG(F("Requested interval of 0 minutes is invalid when power is " + "cycled; using"), + programmedInterval, F("minutes.")); + } if (_loggingIntervalMinutes < 10 && _loggingIntervalMinutes != 0) { programmedInterval = 10; MS_DBG(F("Requested interval of"), _loggingIntervalMinutes, @@ -371,7 +377,7 @@ bool ANBpH::addSingleMeasurementResult(void) { health == ANBHealthCode::NOT_IMMERSED); // Put values into the array - if it's a success or our last try - if (success || _retryAttemptsMade == _allowedMeasurementRetries - 1) { + if (success || _retryAttemptsMade >= _allowedMeasurementRetries) { verifyAndAddMeasurementResult(ANB_PH_PH_VAR_NUM, pH); verifyAndAddMeasurementResult(ANB_PH_TEMP_VAR_NUM, temp); verifyAndAddMeasurementResult(ANB_PH_SALINITY_VAR_NUM, sal); From c70b2b34e9655adb5ed5d53343e5598ef017fe63 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Wed, 18 Feb 2026 11:51:56 -0500 Subject: [PATCH 182/533] Moved undefined processor info warnings to KnownProcessors.h Signed-off-by: Sara Damiano --- src/sensors/KnownProcessors.h | 22 ++++++++++++++++++++++ src/sensors/ProcessorStats.cpp | 2 ++ src/sensors/ProcessorStats.h | 26 -------------------------- 3 files changed, 24 insertions(+), 26 deletions(-) diff --git a/src/sensors/KnownProcessors.h b/src/sensors/KnownProcessors.h index d6a7cde9f..9699db2d6 100644 --- a/src/sensors/KnownProcessors.h +++ b/src/sensors/KnownProcessors.h @@ -257,6 +257,11 @@ #endif // Print warnings if expected processor defines are missing +#ifndef LOGGER_BOARD +#define LOGGER_BOARD "Unknown" +#pragma message "Warning: LOGGER_BOARD is not defined for this processor.\n" \ + "The board name can be added by editing KnownProcessors.h." +#endif #ifndef OPERATING_VOLTAGE #define OPERATING_VOLTAGE 3.3 #pragma message \ @@ -264,5 +269,22 @@ "If you have specified the operating voltage in your code, you can ignore this message\n." \ "The operating voltage can be added by editing KnownProcessors.h." #endif +#ifndef BATTERY_PIN +#define BATTERY_PIN -1 +#pragma message \ + "Warning: BATTERY_PIN is not defined for this processor.\n" \ + "If your processor does not have a built-in pin for measuring the battery voltage," \ + "or you have specified a different pin in your code, you can ignore this message\n." \ + "The battery pin can be added by editing KnownProcessors.h." +#endif + +#ifndef BATTERY_MULTIPLIER +#define BATTERY_MULTIPLIER -1 +#pragma message \ + "Warning: BATTERY_MULTIPLIER is not defined for this processor.\n" \ + "If your processor does not have a built-in pin for measuring the battery voltage," \ + "or you have specified the multiplier in your code, you can ignore this message\n." \ + "The battery multiplier can be added by editing KnownProcessors.h." +#endif #endif diff --git a/src/sensors/ProcessorStats.cpp b/src/sensors/ProcessorStats.cpp index 253b4f4f5..db399c31e 100644 --- a/src/sensors/ProcessorStats.cpp +++ b/src/sensors/ProcessorStats.cpp @@ -31,6 +31,8 @@ ProcessorStats::ProcessorStats(const char* version, _batteryMultiplier = 1.47; } #elif defined(ARDUINO_SODAQ_ONE) || defined(ARDUINO_SODAQ_ONE_BETA) + // only versions v0.1 and v0.2 of the Sodaq One are supported, and they have + // different battery pins and multipliers if (strcmp(_version, "v0.1") == 0) { _batteryMultiplier = 2; } else if (strcmp(_version, "v0.2") == 0) { diff --git a/src/sensors/ProcessorStats.h b/src/sensors/ProcessorStats.h index baa3ccf47..23455510a 100644 --- a/src/sensors/ProcessorStats.h +++ b/src/sensors/ProcessorStats.h @@ -79,32 +79,6 @@ #include "VariableBase.h" #include "SensorBase.h" -// Print warnings if expected processor defines are missing - -#ifndef LOGGER_BOARD -#define LOGGER_BOARD "Unknown" -#pragma message "Warning: LOGGER_BOARD is not defined for this processor.\n" \ - "The board name can be added by editing KnownProcessors.h." -#endif - -#ifndef BATTERY_PIN -#define BATTERY_PIN -1 -#pragma message \ - "Warning: BATTERY_PIN is not defined for this processor.\n" \ - "If your processor does not have a built-in pin for measuring the battery voltage," \ - "or you have specified a different pin in your code, you can ignore this message\n." \ - "The battery pin can be added by editing KnownProcessors.h." -#endif - -#ifndef BATTERY_MULTIPLIER -#define BATTERY_MULTIPLIER -1 -#pragma message \ - "Warning: BATTERY_MULTIPLIER is not defined for this processor.\n" \ - "If your processor does not have a built-in pin for measuring the battery voltage," \ - "or you have specified the multiplier in your code, you can ignore this message\n." \ - "The battery multiplier can be added by editing KnownProcessors.h." -#endif - /** @ingroup sensor_processor */ /**@{*/ From 78195071260e98248032466fe06ded444c7a9825 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Wed, 18 Feb 2026 12:21:42 -0500 Subject: [PATCH 183/533] Unset status bits if INA219 fails in setup or wake Signed-off-by: Sara Damiano --- src/sensors/TIINA219.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/sensors/TIINA219.cpp b/src/sensors/TIINA219.cpp index ced2e9298..1ce09dad5 100644 --- a/src/sensors/TIINA219.cpp +++ b/src/sensors/TIINA219.cpp @@ -54,6 +54,12 @@ bool TIINA219::setup(void) { // Turn the power back off it it had been turned on if (!wasOn) { powerDown(); } + if (!success) { + // Set the status error bit (bit 7) + setStatusBit(ERROR_OCCURRED); + // UN-set the set-up bit (bit 0) since setup failed! + clearStatusBit(SETUP_SUCCESSFUL); + } return success; } @@ -66,6 +72,14 @@ bool TIINA219::wake(void) { // Begin/Init needs to be rerun after every power-up to set the calibration // coefficient for the INA219 (see p21 of datasheet) bool success = ina219_phy.begin(_i2c); + if (!success) { + // Set the status error bit (bit 7) + setStatusBit(ERROR_OCCURRED); + // Make sure that the wake time and wake success bit (bit 4) are + // unset + _millisSensorActivated = 0; + clearStatusBit(WAKE_SUCCESSFUL); + } return success; } From 8d4caf591ad110d8c7876ff21131aeae03d8fdd9 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Wed, 18 Feb 2026 12:22:11 -0500 Subject: [PATCH 184/533] Fix bad cast Signed-off-by: Sara Damiano --- src/sensors/MaxBotixSonar.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sensors/MaxBotixSonar.cpp b/src/sensors/MaxBotixSonar.cpp index f8e785c5a..e27cd02a9 100644 --- a/src/sensors/MaxBotixSonar.cpp +++ b/src/sensors/MaxBotixSonar.cpp @@ -169,7 +169,7 @@ bool MaxBotixSonar::addSingleMeasurementResult(void) { // Immediately ask for a result and let the stream timeout be our // "wait" for the measurement. - result = static_cast(_stream->parseInt()); + result = static_cast(_stream->parseInt()); _stream->read(); // To throw away the carriage return MS_DBG(F(" Sonar Range:"), result); rangeAttempts++; From 4b58ee5a733c5fee18cf6fd0024c1d907f93dee0 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Wed, 18 Feb 2026 12:32:46 -0500 Subject: [PATCH 185/533] Add guard for registration token, fix buffer-fullness threshold ordering Signed-off-by: Sara Damiano --- src/publishers/MonitorMyWatershedPublisher.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/publishers/MonitorMyWatershedPublisher.cpp b/src/publishers/MonitorMyWatershedPublisher.cpp index 59a8aa956..004917805 100644 --- a/src/publishers/MonitorMyWatershedPublisher.cpp +++ b/src/publishers/MonitorMyWatershedPublisher.cpp @@ -211,12 +211,12 @@ bool MonitorMyWatershedPublisher::connectionNeeded(void) { int interval = _sendEveryX; uint8_t percent = _logBuffer.getPercentFull(); MS_DBG(F("Buffer is"), percent, F("percent full")); - if (percent >= 50) { - interval /= 2; + if (percent >= 90) { + interval = 1; } else if (percent >= 75) { interval /= 4; - } else if (percent >= 90) { - interval = 1; + } else if (percent >= 50) { + interval /= 2; } // the programmed interval is about to be reached by the next record, or it @@ -313,6 +313,11 @@ int16_t MonitorMyWatershedPublisher::flushDataBuffer(Client* outClient) { "to Monitor My Watershed!.")); return 0; } + if (_registrationToken == nullptr || strlen(_registrationToken) == 0) { + PRINTOUT(F("A registration token must be set before publishing data " + "to Monitor My Watershed!.")); + return 0; + } // Open a TCP/IP connection to Monitor My Watershed MS_DBG(F("Connecting client")); From c1991283139f4d8e872ab1bdd8bbf60ca36c7746 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Wed, 18 Feb 2026 12:33:54 -0500 Subject: [PATCH 186/533] Fixed UUID acronym Signed-off-by: Sara Damiano --- examples/EnviroDIY_Monitoring_Kit/ReadMe.md | 4 ++-- .../OutdatedExamples/DRWI_CitizenScience/DRWI_2G/ReadMe.md | 4 ++-- .../DRWI_CitizenScience/DRWI_DigiLTE/ReadMe.md | 4 ++-- .../DRWI_CitizenScience/DRWI_NoCellular/ReadMe.md | 4 ++-- examples/baro_rho_correction/ReadMe.md | 4 ++-- examples/logging_to_MMW/ReadMe.md | 4 ++-- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/examples/EnviroDIY_Monitoring_Kit/ReadMe.md b/examples/EnviroDIY_Monitoring_Kit/ReadMe.md index 3e076888a..39f575603 100644 --- a/examples/EnviroDIY_Monitoring_Kit/ReadMe.md +++ b/examples/EnviroDIY_Monitoring_Kit/ReadMe.md @@ -40,7 +40,7 @@ _______ - [Set the logger ID](#set-the-logger-id) - [Set the logging interval](#set-the-logging-interval) - [Set the time zone](#set-the-time-zone) - - [Set the universally universal identifiers (UUID) for each variable](#set-the-universally-universal-identifiers-uuid-for-each-variable) + - [Set the universally unique identifiers (UUID) for each variable](#set-the-universally-unique-identifiers-uuid-for-each-variable) - [Upload!](#upload) @@ -144,7 +144,7 @@ Please use standard time! const int8_t timeZone = -5; // Eastern Standard Time ``` -### Set the universally universal identifiers (UUID) for each variable +### Set the universally unique identifiers (UUID) for each variable - Go back to the web page for your site on [Monitor My Watershed](http://monitormywatershed.org/) - Find and click the white "View Token UUID List" button above the small map on your site page. diff --git a/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_2G/ReadMe.md b/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_2G/ReadMe.md index 1eb6331b1..c0cba2f8d 100644 --- a/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_2G/ReadMe.md +++ b/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_2G/ReadMe.md @@ -23,7 +23,7 @@ _______ - [Prepare and set up PlatformIO](#prepare-and-set-up-platformio) - [Set the logger ID](#set-the-logger-id) - [Set the calibration coefficients for the Campbell OBS3+](#set-the-calibration-coefficients-for-the-campbell-obs3) - - [Set the universally universal identifiers (UUID) for each variable](#set-the-universally-universal-identifiers-uuid-for-each-variable) + - [Set the universally unique identifiers (UUID) for each variable](#set-the-universally-unique-identifiers-uuid-for-each-variable) - [Upload!](#upload) @@ -88,7 +88,7 @@ const float OBSHigh_C = 0.000E+00; // "C" value [*high* range] CampbellOBS3 osb3high(OBS3Power, OBSHighADSChannel, OBSHigh_A, OBSHigh_B, OBSHigh_C, ADSi2c_addr, OBS3numberReadings); ``` -### Set the universally universal identifiers (UUID) for each variable +### Set the universally unique identifiers (UUID) for each variable - Go back to the web page for your site on [Monitor My Watershed](https://monitormywatershed.org) - Find and click the white "View Token UUID List" button above the small map on your site page diff --git a/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_DigiLTE/ReadMe.md b/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_DigiLTE/ReadMe.md index 2d1e2f11d..e9faf4a9a 100644 --- a/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_DigiLTE/ReadMe.md +++ b/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_DigiLTE/ReadMe.md @@ -23,7 +23,7 @@ _______ - [Prepare and set up PlatformIO](#prepare-and-set-up-platformio) - [Set the logger ID](#set-the-logger-id) - [Set the calibration coefficients for the Campbell OBS3+](#set-the-calibration-coefficients-for-the-campbell-obs3) - - [Set the universally universal identifiers (UUID) for each variable](#set-the-universally-universal-identifiers-uuid-for-each-variable) + - [Set the universally unique identifiers (UUID) for each variable](#set-the-universally-unique-identifiers-uuid-for-each-variable) - [Upload!](#upload) @@ -91,7 +91,7 @@ const float OBSHigh_C = 0.000E+00; // "C" value [*high* range] CampbellOBS3 osb3high(OBS3Power, OBSHighADSChannel, OBSHigh_A, OBSHigh_B, OBSHigh_C, ADSi2c_addr, OBS3numberReadings); ``` -### Set the universally universal identifiers (UUID) for each variable +### Set the universally unique identifiers (UUID) for each variable - Go back to the web page for your site on [Monitor My Watershed](https://monitormywatershed.org) diff --git a/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_NoCellular/ReadMe.md b/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_NoCellular/ReadMe.md index 18cb11334..ad34b8af1 100644 --- a/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_NoCellular/ReadMe.md +++ b/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_NoCellular/ReadMe.md @@ -28,7 +28,7 @@ _______ - [Prepare and set up PlatformIO](#prepare-and-set-up-platformio) - [Set the logger ID](#set-the-logger-id) - [Set the calibration coefficients for the Campbell OBS3+](#set-the-calibration-coefficients-for-the-campbell-obs3) - - [Set the universally universal identifiers (UUID) for each variable](#set-the-universally-universal-identifiers-uuid-for-each-variable) + - [Set the universally unique identifiers (UUID) for each variable](#set-the-universally-unique-identifiers-uuid-for-each-variable) - [Upload!](#upload) @@ -93,7 +93,7 @@ const float OBSHigh_C = 0.000E+00; // "C" value [*high* range] CampbellOBS3 osb3high(OBS3Power, OBSHighADSChannel, OBSHigh_A, OBSHigh_B, OBSHigh_C, ADSi2c_addr, OBS3numberReadings); ``` -### Set the universally universal identifiers (UUID) for each variable +### Set the universally unique identifiers (UUID) for each variable - Go back to the web page for your site on [Monitor My Watershed](https://monitormywatershed.org) - Find and click the white "View Token UUID List" button above the small map on your site page diff --git a/examples/baro_rho_correction/ReadMe.md b/examples/baro_rho_correction/ReadMe.md index d91d819ff..e0f49870a 100644 --- a/examples/baro_rho_correction/ReadMe.md +++ b/examples/baro_rho_correction/ReadMe.md @@ -19,7 +19,7 @@ _______ - [To Use this Example](#to-use-this-example) - [Prepare and set up PlatformIO](#prepare-and-set-up-platformio) - [Set the logger ID](#set-the-logger-id) - - [Set the universally universal identifiers (UUID) for each variable](#set-the-universally-universal-identifiers-uuid-for-each-variable) + - [Set the universally unique identifiers (UUID) for each variable](#set-the-universally-unique-identifiers-uuid-for-each-variable) - [Upload!](#upload) @@ -54,7 +54,7 @@ _______ const char *LoggerID = "XXXX"; ``` -### Set the universally universal identifiers (UUID) for each variable +### Set the universally unique identifiers (UUID) for each variable - Go back to the web page for your site on [Monitor My Watershed](https://monitormywatershed.org) - For each variable, find the dummy UUID (`"12345678-abcd-1234-ef00-1234567890ab"`) and replace it with the real UUID for the variable. diff --git a/examples/logging_to_MMW/ReadMe.md b/examples/logging_to_MMW/ReadMe.md index 478c3292c..460b3eebf 100644 --- a/examples/logging_to_MMW/ReadMe.md +++ b/examples/logging_to_MMW/ReadMe.md @@ -21,7 +21,7 @@ _______ - [To Use this Example](#to-use-this-example) - [Prepare and set up PlatformIO](#prepare-and-set-up-platformio) - [Set the logger ID](#set-the-logger-id) - - [Set the universally universal identifiers (UUID) for each variable](#set-the-universally-universal-identifiers-uuid-for-each-variable) + - [Set the universally unique identifiers (UUID) for each variable](#set-the-universally-unique-identifiers-uuid-for-each-variable) - [Upload!](#upload) @@ -56,7 +56,7 @@ _______ const char *LoggerID = "XXXX"; ``` -### Set the universally universal identifiers (UUID) for each variable +### Set the universally unique identifiers (UUID) for each variable - Go back to the web page for your site on [Monitor My Watershed](https://monitormywatershed.org) - For each variable, find the dummy UUID (`"12345678-abcd-1234-ef00-1234567890ab"`) and replace it with the real UUID for the variable. From a43d9968fcb27ea43be538af55c033a86f4e45ed Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Wed, 18 Feb 2026 12:39:20 -0500 Subject: [PATCH 187/533] Properly initialize values Signed-off-by: Sara Damiano --- src/sensors/ANBpH.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/sensors/ANBpH.cpp b/src/sensors/ANBpH.cpp index 43a265e3a..c02d03af5 100644 --- a/src/sensors/ANBpH.cpp +++ b/src/sensors/ANBpH.cpp @@ -323,8 +323,12 @@ bool ANBpH::addSingleMeasurementResult(void) { return bumpMeasurementAttemptCount(false); } - bool success = false; - float pH, temp, sal, spcond, raw_cond = -9999; + bool success = false; + float pH = -9999; + float temp = -9999; + float sal = -9999; + float spcond = -9999; + float raw_cond = -9999; ANBHealthCode health = ANBHealthCode::UNKNOWN; ANBStatusCode status = ANBStatusCode::UNKNOWN; ANBDiagnosticCode diagnostic = ANBDiagnosticCode::UNKNOWN; From f829285b512323f4b814841c0652b6fbc5e904d5 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Wed, 18 Feb 2026 12:42:30 -0500 Subject: [PATCH 188/533] Add safer initializer Signed-off-by: Sara Damiano --- src/SensorBase.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SensorBase.h b/src/SensorBase.h index 774c9b4ca..b83ee40ba 100644 --- a/src/SensorBase.h +++ b/src/SensorBase.h @@ -675,7 +675,7 @@ class Sensor { * * @note SIGNED int, to allow negative numbers for unused pins */ - int8_t _powerPin2; + int8_t _powerPin2 = -1; /** * @brief The sensor name. */ From 365b283f14d7e4986d872414cd3eb10d8d94d409 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Wed, 18 Feb 2026 12:44:19 -0500 Subject: [PATCH 189/533] Fix macro conditional Signed-off-by: Sara Damiano --- src/sensors/PaleoTerraRedox.h | 2 +- src/sensors/RainCounterI2C.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/sensors/PaleoTerraRedox.h b/src/sensors/PaleoTerraRedox.h index 74c7705ef..89d20ad04 100644 --- a/src/sensors/PaleoTerraRedox.h +++ b/src/sensors/PaleoTerraRedox.h @@ -215,7 +215,7 @@ class PaleoTerraRedox : public Sensor { uint8_t i2cAddressHex = MCP3421_ADR, uint8_t measurementsToAverage = 1); #endif -#if !defined(MS_PALEOTERRA_SOFTWAREWIRE) | defined DOXYGEN +#if !defined(MS_PALEOTERRA_SOFTWAREWIRE) || defined(DOXYGEN) /** * @brief Construct a new PaleoTerra Redox object using a secondary * *hardware* I2C instance. diff --git a/src/sensors/RainCounterI2C.h b/src/sensors/RainCounterI2C.h index 0a191b775..ebd468e20 100644 --- a/src/sensors/RainCounterI2C.h +++ b/src/sensors/RainCounterI2C.h @@ -236,7 +236,7 @@ class RainCounterI2C : public Sensor { RainCounterI2C(int8_t dataPin, int8_t clockPin, uint8_t i2cAddressHex = 0x08, float rainPerTip = 0.2); #endif -#if !defined(MS_RAIN_SOFTWAREWIRE) || defined DOXYGEN +#if !defined(MS_RAIN_SOFTWAREWIRE) || defined(DOXYGEN) /** * @brief Construct a new Rain Counter I2C object using a secondary * *hardware* I2C instance. From 8b1af7e2183aa168f933760fe66176e965e49ce2 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Wed, 18 Feb 2026 12:46:34 -0500 Subject: [PATCH 190/533] Print adcCounts Signed-off-by: Sara Damiano --- src/sensors/AlphasenseCO2.cpp | 4 ++-- src/sensors/TurnerTurbidityPlus.cpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/sensors/AlphasenseCO2.cpp b/src/sensors/AlphasenseCO2.cpp index df9b14fd6..f07649202 100644 --- a/src/sensors/AlphasenseCO2.cpp +++ b/src/sensors/AlphasenseCO2.cpp @@ -113,8 +113,8 @@ bool AlphasenseCO2::addSingleMeasurementResult(void) { } // Convert ADC counts value to voltage (V) adcVoltage = ads.computeVolts(adcCounts); - MS_DBG(F(" ads.readADC_Differential("), _adsDiffMux, F("):"), - String(adcVoltage, 3)); + MS_DBG(F(" ads.readADC_Differential("), _adsDiffMux, F("):"), adcCounts, + '=', String(adcVoltage, 3)); // @todo Verify the voltage range for the CO2 sensor // Here we are using the range of the ADS when it is powered at 3.3V diff --git a/src/sensors/TurnerTurbidityPlus.cpp b/src/sensors/TurnerTurbidityPlus.cpp index 05a250a42..6683ebd9e 100644 --- a/src/sensors/TurnerTurbidityPlus.cpp +++ b/src/sensors/TurnerTurbidityPlus.cpp @@ -164,8 +164,8 @@ bool TurnerTurbidityPlus::addSingleMeasurementResult(void) { } // Convert ADC counts value to voltage (V) adcVoltage = ads.computeVolts(adcCounts); - MS_DBG(F(" ads.readADC_Differential("), _adsDiffMux, F("):"), - String(adcVoltage, 3)); + MS_DBG(F(" ads.readADC_Differential("), _adsDiffMux, F("):"), adcCounts, + '=', String(adcVoltage, 3)); // The ADS1X15 outputs a max value corresponding to Vcc + 0.3V if (adcVoltage < 5.3 && adcVoltage > -0.3) { From f438a1f450c316abce4edb00272e0028fa67c0da Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Wed, 18 Feb 2026 12:49:43 -0500 Subject: [PATCH 191/533] Use requestFrom result directly Signed-off-by: Sara Damiano --- src/sensors/PaleoTerraRedox.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/sensors/PaleoTerraRedox.cpp b/src/sensors/PaleoTerraRedox.cpp index e6514cbb3..3eb8a8040 100644 --- a/src/sensors/PaleoTerraRedox.cpp +++ b/src/sensors/PaleoTerraRedox.cpp @@ -120,9 +120,10 @@ bool PaleoTerraRedox::addSingleMeasurementResult(void) { // wait for the conversion to complete delay(PTR_CONVERSION_WAIT_TIME_MS); - _i2c->requestFrom(int(_i2cAddressHex), - 4); // Get 4 bytes from device - if (_i2c->available() != 4) { return bumpMeasurementAttemptCount(false); } + // Get 4 bytes from device + if (_i2c->requestFrom(int(_i2cAddressHex), 4) != 4) { + return bumpMeasurementAttemptCount(false); + } byte res1 = _i2c->read(); byte res2 = _i2c->read(); byte res3 = _i2c->read(); From 8be137a6d706028874467a7df5040a45c64e9b01 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Wed, 18 Feb 2026 13:14:36 -0500 Subject: [PATCH 192/533] Add backwards-compatibility shims Signed-off-by: Sara Damiano --- src/LoggerBase.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/LoggerBase.h b/src/LoggerBase.h index 8e4c8b7c2..7657579d6 100644 --- a/src/LoggerBase.h +++ b/src/LoggerBase.h @@ -243,6 +243,15 @@ class Logger { int16_t getInitialShortIntervals() { return _remainingShortIntervals; } + // Backwards-compatibility shims + /** @deprecated use setInitialShortIntervals */ + void setinitialShortIntervals(int16_t initialShortIntervals) { + setInitialShortIntervals(initialShortIntervals); + } + /** @deprecated use getInitialShortIntervals */ + int16_t getinitialShortIntervals() { + return getInitialShortIntervals(); + } /** * @brief Set the universally unique identifier (UUID or GUID) of the From 43e39da91e7c7f82ca142ba627dc281437af5de1 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Wed, 18 Feb 2026 13:28:36 -0500 Subject: [PATCH 193/533] Check for OK values Signed-off-by: Sara Damiano --- src/sensors/BoschBME280.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/sensors/BoschBME280.cpp b/src/sensors/BoschBME280.cpp index 87daa9d21..1680b73da 100644 --- a/src/sensors/BoschBME280.cpp +++ b/src/sensors/BoschBME280.cpp @@ -143,9 +143,11 @@ bool BoschBME280::addSingleMeasurementResult(void) { MS_DBG(F(" Barometric Pressure:"), press, F("Pa")); MS_DBG(F(" Calculated Altitude:"), alt, F("m ASL")); + bool values_ok = temp != -9999 && humid != -9999 && press != -9999 && + alt != -9999; // Assume that if all three are 0, really a failed response // May also return a very negative temp when receiving a bad response - if ((temp == 0 && press == 0 && humid == 0) || temp < -40) { + if (!values_ok || (temp == 0 && press == 0 && humid == 0) || temp < -40) { MS_DBG(F("All values 0 or bad, assuming sensor non-response!")); } else { verifyAndAddMeasurementResult(BME280_TEMP_VAR_NUM, temp); From 8f03ecbbd27ff0190d77243c417e8e22dc770971 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Wed, 18 Feb 2026 13:30:07 -0500 Subject: [PATCH 194/533] Fix TI model numbers Signed-off-by: Sara Damiano --- src/sensors/AlphasenseCO2.cpp | 4 ++-- src/sensors/ApogeeSQ212.cpp | 4 ++-- src/sensors/CampbellOBS3.cpp | 4 ++-- src/sensors/TIADS1x15.cpp | 4 ++-- src/sensors/TurnerCyclops.cpp | 4 ++-- src/sensors/TurnerTurbidityPlus.cpp | 4 ++-- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/sensors/AlphasenseCO2.cpp b/src/sensors/AlphasenseCO2.cpp index f07649202..70dd3388a 100644 --- a/src/sensors/AlphasenseCO2.cpp +++ b/src/sensors/AlphasenseCO2.cpp @@ -66,11 +66,11 @@ bool AlphasenseCO2::addSingleMeasurementResult(void) { Adafruit_ADS1015 ads; // Use this for the 12-bit version #endif // ADS Library default settings: - // - TI1115 (16 bit) + // - TI ADS1115 (16 bit) // - single-shot mode (powers down between conversions) // - 128 samples per second (8ms conversion time) // - 2/3 gain +/- 6.144V range (limited to VDD +0.3V max) - // - TI1015 (12 bit) + // - TI ADS1015 (12 bit) // - single-shot mode (powers down between conversions) // - 1600 samples per second (625µs conversion time) // - 2/3 gain +/- 6.144V range (limited to VDD +0.3V max) diff --git a/src/sensors/ApogeeSQ212.cpp b/src/sensors/ApogeeSQ212.cpp index be81eb715..a1180d876 100644 --- a/src/sensors/ApogeeSQ212.cpp +++ b/src/sensors/ApogeeSQ212.cpp @@ -64,11 +64,11 @@ bool ApogeeSQ212::addSingleMeasurementResult(void) { Adafruit_ADS1015 ads; // Use this for the 12-bit version #endif // ADS Library default settings: - // - TI1115 (16 bit) + // - TI ADS1115 (16 bit) // - single-shot mode (powers down between conversions) // - 128 samples per second (8ms conversion time) // - 2/3 gain +/- 6.144V range (limited to VDD +0.3V max) - // - TI1015 (12 bit) + // - TI ADS1015 (12 bit) // - single-shot mode (powers down between conversions) // - 1600 samples per second (625µs conversion time) // - 2/3 gain +/- 6.144V range (limited to VDD +0.3V max) diff --git a/src/sensors/CampbellOBS3.cpp b/src/sensors/CampbellOBS3.cpp index 363fbc2c5..35be5b15b 100644 --- a/src/sensors/CampbellOBS3.cpp +++ b/src/sensors/CampbellOBS3.cpp @@ -64,11 +64,11 @@ bool CampbellOBS3::addSingleMeasurementResult(void) { Adafruit_ADS1015 ads; // Use this for the 12-bit version #endif // ADS Library default settings: - // - TI1115 (16 bit) + // - TI ADS1115 (16 bit) // - single-shot mode (powers down between conversions) // - 128 samples per second (8ms conversion time) // - 2/3 gain +/- 6.144V range (limited to VDD +0.3V max) - // - TI1015 (12 bit) + // - TI ADS1015 (12 bit) // - single-shot mode (powers down between conversions) // - 1600 samples per second (625µs conversion time) // - 2/3 gain +/- 6.144V range (limited to VDD +0.3V max) diff --git a/src/sensors/TIADS1x15.cpp b/src/sensors/TIADS1x15.cpp index 03cbd64b6..597be1fce 100644 --- a/src/sensors/TIADS1x15.cpp +++ b/src/sensors/TIADS1x15.cpp @@ -64,11 +64,11 @@ bool TIADS1x15::addSingleMeasurementResult(void) { Adafruit_ADS1015 ads; // Use this for the 12-bit version #endif // ADS Library default settings: - // - TI1115 (16 bit) + // - TI ADS1115 (16 bit) // - single-shot mode (powers down between conversions) // - 128 samples per second (8ms conversion time) // - 2/3 gain +/- 6.144V range (limited to VDD +0.3V max) - // - TI1015 (12 bit) + // - TI ADS1015 (12 bit) // - single-shot mode (powers down between conversions) // - 1600 samples per second (625µs conversion time) // - 2/3 gain +/- 6.144V range (limited to VDD +0.3V max) diff --git a/src/sensors/TurnerCyclops.cpp b/src/sensors/TurnerCyclops.cpp index 950d0c024..6571f6659 100644 --- a/src/sensors/TurnerCyclops.cpp +++ b/src/sensors/TurnerCyclops.cpp @@ -64,11 +64,11 @@ bool TurnerCyclops::addSingleMeasurementResult(void) { Adafruit_ADS1015 ads; // Use this for the 12-bit version #endif // ADS Library default settings: - // - TI1115 (16 bit) + // - TI ADS1115 (16 bit) // - single-shot mode (powers down between conversions) // - 128 samples per second (8ms conversion time) // - 2/3 gain +/- 6.144V range (limited to VDD +0.3V max) - // - TI1015 (12 bit) + // - TI ADS1015 (12 bit) // - single-shot mode (powers down between conversions) // - 1600 samples per second (625µs conversion time) // - 2/3 gain +/- 6.144V range (limited to VDD +0.3V max) diff --git a/src/sensors/TurnerTurbidityPlus.cpp b/src/sensors/TurnerTurbidityPlus.cpp index 6683ebd9e..eb7752620 100644 --- a/src/sensors/TurnerTurbidityPlus.cpp +++ b/src/sensors/TurnerTurbidityPlus.cpp @@ -111,11 +111,11 @@ bool TurnerTurbidityPlus::addSingleMeasurementResult(void) { Adafruit_ADS1015 ads; // Use this for the 12-bit version #endif // ADS Library default settings: - // - TI1115 (16 bit) + // - TI ADS1115 (16 bit) // - single-shot mode (powers down between conversions) // - 128 samples per second (8ms conversion time) // - 2/3 gain +/- 6.144V range (limited to VDD +0.3V max) - // - TI1015 (12 bit) + // - TI ADS1015 (12 bit) // - single-shot mode (powers down between conversions) // - 1600 samples per second (625µs conversion time) // - 2/3 gain +/- 6.144V range (limited to VDD +0.3V max) From 9b1c4c6d9bb58dab1b59302e7661b77fa1fa8414 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Wed, 18 Feb 2026 13:30:35 -0500 Subject: [PATCH 195/533] Set failure on bad responses Signed-off-by: Sara Damiano --- src/sensors/AtlasParent.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/sensors/AtlasParent.cpp b/src/sensors/AtlasParent.cpp index 3b83908c0..418051608 100644 --- a/src/sensors/AtlasParent.cpp +++ b/src/sensors/AtlasParent.cpp @@ -173,10 +173,18 @@ bool AtlasParent::addSingleMeasurementResult(void) { // If the response code is successful, parse the remaining results if (success) { for (uint8_t i = 0; i < _numReturnedValues; i++) { - if (_i2c->available() == 0) { break; } + if (_i2c->available() == 0) { + MS_DBG(F(" Incomplete response; aborting parse")); + success = false; + break; + } float result = _i2c->parseFloat(); - if (isnan(result)) { result = -9999; } - if (result < -1020) { result = -9999; } + if (isnan(result) || result < -1020) { + result = -9999; + success = false; + MS_DBG(F(" Invalid response for result #"), i); + // Don't break - subsequent values may be ok + } MS_DBG(F(" Result #"), i, ':', result); verifyAndAddMeasurementResult(i, result); } From 2f63720f76a75b1344cc69cd7901b2d36b56ed44 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Wed, 18 Feb 2026 13:43:32 -0500 Subject: [PATCH 196/533] Re-ordered camera to not create empty files. Signed-off-by: Sara Damiano --- src/sensors/GeoluxHydroCam.cpp | 87 ++++++++++++++++------------------ 1 file changed, 42 insertions(+), 45 deletions(-) diff --git a/src/sensors/GeoluxHydroCam.cpp b/src/sensors/GeoluxHydroCam.cpp index 87a270886..9bc10e675 100644 --- a/src/sensors/GeoluxHydroCam.cpp +++ b/src/sensors/GeoluxHydroCam.cpp @@ -196,6 +196,14 @@ bool GeoluxHydroCam::addSingleMeasurementResult(void) { int32_t bytes_transferred = -9999; int32_t byte_error = -9999; + int32_t image_size = _camera.getImageSize(); + MS_DBG(F("Completed image is"), image_size, F("bytes.")); + if (image_size == 0) { + MS_DBG(F("Camera returned an image size of 0, which means the snapshot " + "failed!")); + return bumpMeasurementAttemptCount(false); + } + // set a new filename based on the current RTC time String filename = _baseLogger->generateFileName( true, HYDROCAM_FILE_EXTENSION, _filePrefix); @@ -204,61 +212,50 @@ bool GeoluxHydroCam::addSingleMeasurementResult(void) { // Initialise the SD card // skip everything else if there's no SD card, otherwise it might hang if (!_baseLogger->initializeSDCard()) { + MS_DBG(F("Failed initialize SD card, aborting!")); return bumpMeasurementAttemptCount(false); } // Create and then open the file in write mode if (imgFile.open(filename.c_str(), O_CREAT | O_WRITE | O_AT_END)) { MS_DBG(F("Created new file:"), filename); - success = true; } else { - MS_DBG(F("Failed to create the image file"), filename); - success = false; + MS_DBG(F("Failed to create the image file, aborting!")); + return bumpMeasurementAttemptCount(false); } - int32_t image_size = _camera.getImageSize(); - MS_DBG(F("Completed image is"), image_size, F("bytes.")); - success &= image_size != 0; + // dump anything in the camera stream, just in case + _camera.streamDump(); - if (success) { - // dump anything in the camera stream, just in case - _camera.streamDump(); - - // Disable the watch-dog timer to reduce interrupts during transfer - MS_DBG(F("Disabling the watchdog during file transfer")); - extendedWatchDog::disableWatchDog(); - - // transfer the image from the camera to a file on the SD card - MS_START_DEBUG_TIMER; - bytes_transferred = _camera.transferImage(imgFile, image_size); - byte_error = abs(bytes_transferred - image_size); - // Close the image file - imgFile.close(); - - // See how long it took us - MS_DBG(F("Wrote"), bytes_transferred, F("of expected"), image_size, - F("bytes to the SD card - a difference of"), byte_error, - F("bytes")); - MS_DBG(F("Total read/write time was"), MS_PRINT_DEBUG_TIMER, F("ms")); - - // Re-enable the watchdog - MS_DBG(F("Re-enabling the watchdog after file transfer")); - extendedWatchDog::enableWatchDog(); - - // Store the last image name - _filename = filename; - - success = bytes_transferred == image_size; - MS_DBG(F("Image transfer was a"), - success ? F("success") : F("failure")); - - verifyAndAddMeasurementResult(HYDROCAM_SIZE_VAR_NUM, bytes_transferred); - verifyAndAddMeasurementResult(HYDROCAM_ERROR_VAR_NUM, byte_error); - } else { - MS_DBG(F("Image transfer failed, so not writing any data to SD card.")); - // Close the image file - imgFile.close(); - } + // Disable the watch-dog timer to reduce interrupts during transfer + MS_DBG(F("Disabling the watchdog during file transfer")); + extendedWatchDog::disableWatchDog(); + + // transfer the image from the camera to a file on the SD card + MS_START_DEBUG_TIMER; + bytes_transferred = _camera.transferImage(imgFile, image_size); + byte_error = abs(bytes_transferred - image_size); + + // Close the image file after transfer + imgFile.close(); + + // See how long it took us + MS_DBG(F("Wrote"), bytes_transferred, F("of expected"), image_size, + F("bytes to the SD card - a difference of"), byte_error, F("bytes")); + MS_DBG(F("Total read/write time was"), MS_PRINT_DEBUG_TIMER, F("ms")); + + // Re-enable the watchdog + MS_DBG(F("Re-enabling the watchdog after file transfer")); + extendedWatchDog::enableWatchDog(); + + // Store the last image name - even if the transfer was incomplete + _filename = filename; + + success = bytes_transferred == image_size; + MS_DBG(F("Image transfer was a"), success ? F("success") : F("failure")); + + verifyAndAddMeasurementResult(HYDROCAM_SIZE_VAR_NUM, bytes_transferred); + verifyAndAddMeasurementResult(HYDROCAM_ERROR_VAR_NUM, byte_error); // Return success value when finished return bumpMeasurementAttemptCount(success); From 9473313613cbdbf44cbc6a0ec797571eecefef3c Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Wed, 18 Feb 2026 13:47:17 -0500 Subject: [PATCH 197/533] Allow partial values, fix file name Signed-off-by: Sara Damiano --- src/sensors/GroPointParent.cpp | 8 +++++--- src/sensors/GroPointParent.h | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/sensors/GroPointParent.cpp b/src/sensors/GroPointParent.cpp index 8bd9be5d4..bd6f270c1 100644 --- a/src/sensors/GroPointParent.cpp +++ b/src/sensors/GroPointParent.cpp @@ -207,7 +207,7 @@ bool GroPointParent::addSingleMeasurementResult(void) { } } - if (success && successT) { + if (success) { // Put values into the array verifyAndAddMeasurementResult(0, M1); verifyAndAddMeasurementResult(1, M2); @@ -217,7 +217,8 @@ bool GroPointParent::addSingleMeasurementResult(void) { verifyAndAddMeasurementResult(5, M6); verifyAndAddMeasurementResult(6, M7); verifyAndAddMeasurementResult(7, M8); - + } + if (successT) { verifyAndAddMeasurementResult(8, T1); verifyAndAddMeasurementResult(9, T2); verifyAndAddMeasurementResult(10, T3); @@ -233,7 +234,8 @@ bool GroPointParent::addSingleMeasurementResult(void) { verifyAndAddMeasurementResult(20, T13); } - // Return success value when finished + // Return success value when finished. Success requires both the moisture + // and temperature values to be successfully retrieved return bumpMeasurementAttemptCount((success && successT)); } diff --git a/src/sensors/GroPointParent.h b/src/sensors/GroPointParent.h index 506469f89..26351cb54 100644 --- a/src/sensors/GroPointParent.h +++ b/src/sensors/GroPointParent.h @@ -1,5 +1,5 @@ /** - * @file GroPointParent.cpp + * @file GroPointParent.h * @copyright Stroud Water Research Center * Part of the EnviroDIY ModularSensors library for Arduino. * This library is published under the BSD-3 license. From 22b1c0c3d556f290b3934e8d6bd12eb24f61ade5 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Wed, 18 Feb 2026 13:53:24 -0500 Subject: [PATCH 198/533] More complete check for processor analog config Signed-off-by: Sara Damiano --- src/sensors/ProcessorAnalog.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/sensors/ProcessorAnalog.cpp b/src/sensors/ProcessorAnalog.cpp index c6e71267a..c8396bc83 100644 --- a/src/sensors/ProcessorAnalog.cpp +++ b/src/sensors/ProcessorAnalog.cpp @@ -34,8 +34,13 @@ bool ProcessorAnalog::addSingleMeasurementResult(void) { if (!getStatusBit(MEASUREMENT_SUCCESSFUL)) { return bumpMeasurementAttemptCount(false); } - if (_dataPin < 0 || _voltageMultiplier <= 0) { - MS_DBG(F("No analog pin or voltage divider specified!")); + if (PROCESSOR_ADC_MAX <= 0) { + MS_DBG(F("Processor ADC max value is not set or invalid!")); + return bumpMeasurementAttemptCount(false); + } + if (_dataPin < 0 || _operatingVoltage <= 0 || _voltageMultiplier <= 0) { + MS_DBG(F("Missing one or more required parameters: analog pin, " + "operating voltage, or voltage divider!")); return bumpMeasurementAttemptCount(false); } From 637961b517fa56b9b42784489bd628aa56a7e082 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Wed, 18 Feb 2026 13:56:50 -0500 Subject: [PATCH 199/533] Initialize empty events Signed-off-by: Sara Damiano --- src/sensors/SensirionSHT4x.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/sensors/SensirionSHT4x.cpp b/src/sensors/SensirionSHT4x.cpp index c5f3de31b..d3e76c29c 100644 --- a/src/sensors/SensirionSHT4x.cpp +++ b/src/sensors/SensirionSHT4x.cpp @@ -105,8 +105,8 @@ bool SensirionSHT4x::addSingleMeasurementResult(void) { sht4x_internal.setHeater(SHT4X_NO_HEATER); // we need to create Adafruit "sensor events" to use the library - sensors_event_t temp_event; - sensors_event_t humidity_event; + sensors_event_t temp_event{}; + sensors_event_t humidity_event{}; ret_val = sht4x_internal.getEvent(&humidity_event, &temp_event); // get the values from the sensor events From 11118076193e76ac22c5bfb6cb5597618573ed07 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Wed, 18 Feb 2026 14:03:01 -0500 Subject: [PATCH 200/533] Apply voltage divider value Signed-off-by: Sara Damiano --- src/sensors/TurnerTurbidityPlus.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/sensors/TurnerTurbidityPlus.cpp b/src/sensors/TurnerTurbidityPlus.cpp index eb7752620..a0e868c5d 100644 --- a/src/sensors/TurnerTurbidityPlus.cpp +++ b/src/sensors/TurnerTurbidityPlus.cpp @@ -169,6 +169,9 @@ bool TurnerTurbidityPlus::addSingleMeasurementResult(void) { // The ADS1X15 outputs a max value corresponding to Vcc + 0.3V if (adcVoltage < 5.3 && adcVoltage > -0.3) { + // Apply voltage divider factor if using a voltage divider to step down + // the voltage + adcVoltage *= _voltageDividerFactor; // Apply the unique calibration curve for the given sensor calibResult = (_conc_std / (_volt_std - _volt_blank)) * (adcVoltage - _volt_blank); From c46d138dd4caabd444b9158decf6766d8545694b Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Wed, 18 Feb 2026 14:05:36 -0500 Subject: [PATCH 201/533] Fix or explain some things for code rabbit Signed-off-by: Sara Damiano --- .coderabbit.yaml | 4 ++++ ChangeLog.md | 5 +++-- docs/Getting-Started/Getting-Started.md | 1 - .../DRWI_Mayfly1_WiFi/DRWI_Mayfly1_WiFi.ino | 1 - src/LoggerModem.h | 2 +- src/ModSensorConfig.h | 8 +++++++- src/dataPublisherBase.h | 4 ++++ src/publishers/MonitorMyWatershedPublisher.h | 4 ++-- src/sensors/ANBpH.h | 3 ++- src/sensors/MaximDS3231.cpp | 7 ++++--- 10 files changed, 27 insertions(+), 12 deletions(-) diff --git a/.coderabbit.yaml b/.coderabbit.yaml index b107adc60..c31a663a5 100644 --- a/.coderabbit.yaml +++ b/.coderabbit.yaml @@ -31,6 +31,10 @@ reviews: instructions: >- Review the C++ code, point out issues relative to principles of clean code, expressiveness, and performance. + - path: '**/*.cpp' + instructions: >- + Review the C++ code, point out issues relative to principles of clean + code, expressiveness, and performance. tools: shellcheck: enabled: true diff --git a/ChangeLog.md b/ChangeLog.md index fb9dbd643..35f4e96fa 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -71,7 +71,7 @@ These values should generally be set in the specific sensor constructors and onl ### Removed -- Remove the unused `_maxSamplesToAverage` parameter of the VariableArray and the `countMaxToAverage()` function which set the parameter. +- Removed the unused `_maxSamplesToAverage` parameter of the VariableArray and the `countMaxToAverage()` function which set the parameter. - Removed unnecessary copy doc calls for inherited functions and properties. - Removed all overrides of the powerUp and powerDown functions that are no longer needed since all sensors have two power pins built in. - Removed references to the EnviroDIY data portal. @@ -212,7 +212,6 @@ If you do not want any output, define `MS_SILENT`. - Wire required adapters such that they are continuously powered. - If you must switch the power to both the sensor and an adapter and either the sensor power or the adapter power are shared with a pin that provides power to any other sensor, call the shared power pin the "sensor" power and the other the "adapter." - *** ## [0.36.0] @@ -1209,3 +1208,5 @@ Our first release of the modular sensors library to support easily logging data + + diff --git a/docs/Getting-Started/Getting-Started.md b/docs/Getting-Started/Getting-Started.md index b05bc08df..c98030585 100644 --- a/docs/Getting-Started/Getting-Started.md +++ b/docs/Getting-Started/Getting-Started.md @@ -142,7 +142,6 @@ It also includes a Meter Hydros 21 (formerly know as a Decagon CTD) and a Campbe This showcases both how to use two different logging instances and how to use some of the functions to set up your own logging loop rather than using the logData() function. There are two sets of variables, all coming from Yosemitech sensors. Because each sensor outputs temperature and we don't want to waste cellular data sending out multiple nearly identical temperature values, we have one logger that logs every possible variable result to the SD card and another logger that sends only unique results to Monitor My Watershed. -This example also shows how to stop power draw from an RS485 adapter with automatic flow detection. ## Deploying your Station diff --git a/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_Mayfly1_WiFi/DRWI_Mayfly1_WiFi.ino b/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_Mayfly1_WiFi/DRWI_Mayfly1_WiFi.ino index 78f44adc2..b360f1bd7 100644 --- a/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_Mayfly1_WiFi/DRWI_Mayfly1_WiFi.ino +++ b/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_Mayfly1_WiFi/DRWI_Mayfly1_WiFi.ino @@ -296,7 +296,6 @@ void setup() { // Begin the logger dataLogger.begin(); - MonitorMWPost.begin(dataLogger, registrationToken, samplingFeature); // Note: Please change these battery voltages to match your battery // Set up the sensors, except at lowest battery level diff --git a/src/LoggerModem.h b/src/LoggerModem.h index 8ad0dbc32..da28f36a1 100644 --- a/src/LoggerModem.h +++ b/src/LoggerModem.h @@ -988,7 +988,7 @@ class loggerModem { */ bool _statusLevel; /** - * @brief The digital pin number of the pin on the mcu attached the hard + * @brief The digital pin number of the pin on the mcu attached to the hard * or panic reset pin of the modem. * * Should be set to a negative number if the modem reset pin is not diff --git a/src/ModSensorConfig.h b/src/ModSensorConfig.h index 892c09a7e..4ed70f194 100644 --- a/src/ModSensorConfig.h +++ b/src/ModSensorConfig.h @@ -6,7 +6,13 @@ * @author Sara Geleskie Damiano * * @brief This file is used to configure the clock and other library - * settings/preferences for the Modular Sensors Library. + * settings/preferences for the Modular Sensors Library and some of the + * underlying libraries. + * + * @note This file must be include in every header file in the library - before + * including anything else - to ensure that the settings are applied + * consistently across all files and that compile time settings trickle down to + * the underlying libraries. * * For the Arduino IDE, this is the only way to configure these settings. If you * are using PlatformIO, you have the option of using this file or changing your diff --git a/src/dataPublisherBase.h b/src/dataPublisherBase.h index 73c4e2ec9..c37d60653 100644 --- a/src/dataPublisherBase.h +++ b/src/dataPublisherBase.h @@ -369,6 +369,10 @@ class dataPublisher { * memory leak because we cannot delete from the pointer because the * destructor for a client in the Arduino core isn't virtual. * + * @note The client must be deleted by the same type of modem that created + * it. This is unlikely to be an issue unless you're trying to use two + * modems on the same logger. + * * @param client The client to delete */ virtual void deleteClient(Client* client); diff --git a/src/publishers/MonitorMyWatershedPublisher.h b/src/publishers/MonitorMyWatershedPublisher.h index d9d03da16..5d7826f18 100644 --- a/src/publishers/MonitorMyWatershedPublisher.h +++ b/src/publishers/MonitorMyWatershedPublisher.h @@ -49,8 +49,8 @@ class MonitorMyWatershedPublisher : public dataPublisher { public: // Constructors /** - * @brief Construct a new Monitor My Watershed Publisher object with no - * members set. + * @brief Construct a new Monitor My Watershed Publisher object with only + * default values for the host, path, and port set.. */ MonitorMyWatershedPublisher(); /** diff --git a/src/sensors/ANBpH.h b/src/sensors/ANBpH.h index f1dce425a..e62de3289 100644 --- a/src/sensors/ANBpH.h +++ b/src/sensors/ANBpH.h @@ -478,7 +478,8 @@ class ANBpH : public Sensor { * @param loggingIntervalMinutes The logging interval in minutes. Even when * the sensor is being powered off between readings, it needs to be told how * often it will be powered on. This is not used if the sensor power is not - * being controlled by the mcu. Must be between 10 and 240 minutes. + * being controlled by the mcu. Must be between 10 and 240 minutes when + * power is cycled; use 0 only for always‑powered mode. * @param powerPin2 The pin on the mcu controlling power to the RS485 * adapter, if it is different from that used to power the sensor. Use -1 * or omit if not applicable. diff --git a/src/sensors/MaximDS3231.cpp b/src/sensors/MaximDS3231.cpp index b80efbd78..ad6ab0936 100644 --- a/src/sensors/MaximDS3231.cpp +++ b/src/sensors/MaximDS3231.cpp @@ -55,9 +55,10 @@ bool MaximDS3231::startSingleMeasurement(void) { bool MaximDS3231::addSingleMeasurementResult(void) { - // NOTE: This can't fail! If it does we have much bigger problems because - // that means we can't get the time and the whole system is not working. - // get the temperature value + // NOTE: If this fails we have much bigger problems than just a lost + // temperature value. That is, if I2C communication with the clock fails, + // the system is too broken to even ask for this temperature. There's no + // reason to check for failure here. MS_DBG(getSensorNameAndLocation(), F("is reporting:")); float tempVal = rtc.getTemperature(); MS_DBG(F(" Temp:"), tempVal, F("°C")); From be977e2cbe65aaa6720789bb042d009184ddb55a Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Wed, 18 Feb 2026 15:54:02 -0500 Subject: [PATCH 202/533] Fix doc error Signed-off-by: Sara Damiano --- src/LoggerBase.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/LoggerBase.h b/src/LoggerBase.h index 7657579d6..7bd643d16 100644 --- a/src/LoggerBase.h +++ b/src/LoggerBase.h @@ -244,11 +244,13 @@ class Logger { return _remainingShortIntervals; } // Backwards-compatibility shims - /** @deprecated use setInitialShortIntervals */ + /// @copydoc setInitialShortIntervals + /// @deprecated use setInitialShortIntervals void setinitialShortIntervals(int16_t initialShortIntervals) { setInitialShortIntervals(initialShortIntervals); } - /** @deprecated use getInitialShortIntervals */ + /// @copydoc getInitialShortIntervals + /// @deprecated use getInitialShortIntervals int16_t getinitialShortIntervals() { return getInitialShortIntervals(); } From 36d9acc71d01e92613f0ca2e4ed4ff137cfb17f1 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Wed, 18 Feb 2026 15:54:13 -0500 Subject: [PATCH 203/533] minor grammar fixes Signed-off-by: Sara Damiano --- docs/Further-Reading/Sleep-Configurations.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/docs/Further-Reading/Sleep-Configurations.md b/docs/Further-Reading/Sleep-Configurations.md index 5b2e6d3e8..62a030617 100644 --- a/docs/Further-Reading/Sleep-Configurations.md +++ b/docs/Further-Reading/Sleep-Configurations.md @@ -87,7 +87,7 @@ The 5 sleep modes are: ### Steps in Putting an AVR board to sleep -After completing the [steps for putting all boards to sleep](#steps-for-putting-all-boards-to-sleep) AVR boards finish their bedtime routine with these steps. +After completing the [steps for putting all boards to sleep](#steps-for-putting-all-boards-to-sleep), AVR boards finish their bedtime routine with these steps: - Disable the onboard USB if it exists (ie, for a Leonardo) - Freeze the USB clock, turn off the USB PLL, and then disable the USB. @@ -106,7 +106,7 @@ This means that the I2C/Serial/Timer/etc pins will still be active and powered u ### Steps in Resuming Activity for an AVR board -*Before* completing the [steps on wake for all boards](#steps-on-wake-for-all-boards) AVR boards start their wake routine with these steps. +*Before* completing the [steps on wake for all boards](#steps-on-wake-for-all-boards), AVR boards start their wake routine with these steps: - Temporarily disables interrupts, so no mistakes are made when writing to the processor registers. - Re-enable all power modules (ie, the processor module clocks) @@ -230,11 +230,11 @@ The numbers of all disabled peripherals are: - 18, 19, 20, 21, 22, 25, 26, 27, 28, 29, 30, - 31, 32, 33, 38, 39, 42, 43, 44, 45, 46, 47 -@see [The SAMD clock file](@ref samd51_clock_other_libraries) for a list of which peripherals each of these numbers pertain to. +See [The SAMD clock file](@ref samd51_clock_other_libraries) for a list of which peripherals each of these numbers pertain to. ### Steps in Putting an SAMD51 board to sleep -After completing the [steps for putting all boards to sleep](#steps-for-putting-all-boards-to-sleep) SAMD51 boards finish their bedtime routine with these steps. +After completing the [steps for putting all boards to sleep](#steps-for-putting-all-boards-to-sleep), SAMD51 boards finish their bedtime routine with these steps: - Detach any USB devices (ie, the built in USB drivers for communication with a PC) - This is skipped if the TinyUSB library is called for some reason. @@ -261,7 +261,7 @@ SRGD Note: I believe this only applies at power-on, but it's probably not a bad ### Steps in Resuming Activity for a SAMD51 board -*Before* completing the [steps on wake for all boards](#steps-on-wake-for-all-boards) SAMD51 boards start their wake routine with these steps. +*Before* completing the [steps on wake for all boards](#steps-on-wake-for-all-boards), SAMD51 boards start their wake routine with these steps: - Re-attach the USB for PC communication - Re-set the pin modes for the RTC wake pin, SD card SS pin, SD card power pin, button pin, and LED pin. @@ -283,7 +283,7 @@ The pin configurations for the SAMD21 are identical to those described above for ### Steps in Putting an SAMD21 board to sleep -After completing the [steps for putting all boards to sleep](#steps-for-putting-all-boards-to-sleep) SAMD21 boards finish their bedtime routine with these steps. +After completing the [steps for putting all boards to sleep](#steps-for-putting-all-boards-to-sleep), SAMD21 boards finish their bedtime routine with these steps: - Detach any USB devices (ie, the built in USB drivers for communication with a PC) - This is skipped if the TinyUSB library is called for some reason. @@ -303,7 +303,7 @@ To prevent this the SysTick interrupts are disabled before entering sleep mode. ### Steps in Resuming Activity for a SAMD21 board -*Before* completing the [steps on wake for all boards](#steps-on-wake-for-all-boards) SAMD21 boards start their wake routine with these steps. +*Before* completing the [steps on wake for all boards](#steps-on-wake-for-all-boards), SAMD21 boards start their wake routine with these steps: - Re-enable the systick interrupt - Re-attach the USB for PC communication From 2cd8f0913e084e39f8875bed494117b891cf1499 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Wed, 18 Feb 2026 16:43:37 -0500 Subject: [PATCH 204/533] Remove references to line numbers in example read me files and use consistent dummies for secret texts Signed-off-by: Sara Damiano --- examples/AWS_IoT_Core/AWS_IoT_Core.ino | 4 ++-- examples/AWS_IoT_Core/ReadMe.md | 10 ++++---- .../EnviroDIY_Monitoring_Kit.ino | 6 ++--- examples/EnviroDIY_Monitoring_Kit/ReadMe.md | 14 +++++------ .../DRWI_CitizenScience/DRWI_2G/DRWI_2G.ino | 2 +- .../DRWI_CitizenScience/DRWI_2G/ReadMe.md | 2 +- .../DRWI_DigiLTE/DRWI_DigiLTE.ino | 2 +- .../DRWI_DigiLTE/ReadMe.md | 2 +- .../DRWI_Mayfly1/DRWI_Mayfly1.ino | 2 +- .../DRWI_Mayfly1/ReadMe.md | 2 +- .../DRWI_Mayfly1_WiFi/DRWI_Mayfly1_WiFi.ino | 6 ++--- .../DRWI_Mayfly1_WiFi/ReadMe.md | 4 ++-- .../DRWI_NoCellular/DRWI_NoCellular.ino | 2 +- .../DRWI_NoCellular/ReadMe.md | 2 +- .../DRWI_SIM7080LTE/DRWI_SIM7080LTE.ino | 2 +- .../DRWI_SIM7080LTE/ReadMe.md | 2 +- .../simple_logging_LearnEnviroDIY/ReadMe.md | 2 +- .../simple_logging_LearnEnviroDIY.ino | 2 +- examples/baro_rho_correction/ReadMe.md | 4 ++-- .../baro_rho_correction.ino | 4 ++-- examples/double_logger/ReadMe.md | 4 ++-- examples/double_logger/double_logger.ino | 6 ++--- examples/logging_to_MMW/ReadMe.md | 4 ++-- examples/logging_to_MMW/logging_to_MMW.ino | 4 ++-- .../logging_to_ThingSpeak.ino | 6 ++--- examples/menu_a_la_carte/menu_a_la_carte.ino | 4 ++-- examples/simple_logging/ReadMe.md | 2 +- examples/simple_logging/simple_logging.ino | 2 +- extras/AWS_IoT_SetCertificates/ReadMe.md | 23 ++++++++----------- 29 files changed, 64 insertions(+), 67 deletions(-) diff --git a/examples/AWS_IoT_Core/AWS_IoT_Core.ino b/examples/AWS_IoT_Core/AWS_IoT_Core.ino index bac3d1135..bf960f329 100644 --- a/examples/AWS_IoT_Core/AWS_IoT_Core.ino +++ b/examples/AWS_IoT_Core/AWS_IoT_Core.ino @@ -99,8 +99,8 @@ const int8_t modemLEDPin = redLED; // MCU pin connected an LED to show modem status // Network connection information -const char* wifiId = "xxxxx"; // The WiFi access point -const char* wifiPwd = "xxxxx"; // The password for connecting to WiFi +const char* wifiId = "YourWiFiSSID"; // The WiFi access point +const char* wifiPwd = "YourWiFiPassword"; // The WiFi password // Create the loggerModem object EspressifESP32 modemESP(&modemSerial, modemVccPin, modemResetPin, wifiId, diff --git a/examples/AWS_IoT_Core/ReadMe.md b/examples/AWS_IoT_Core/ReadMe.md index ebc4837cd..c9e2ebc2a 100644 --- a/examples/AWS_IoT_Core/ReadMe.md +++ b/examples/AWS_IoT_Core/ReadMe.md @@ -39,29 +39,29 @@ TODO ### Set your AWS IoT Core Endpoint -In line 60, find and replace the text `YOUR_ENDPOINT-ats.iot.YOUR_REGION.amazonaws.com` with your real endpoint. +Find and replace the text `YOUR_ENDPOINT-ats.iot.YOUR_REGION.amazonaws.com` with your real endpoint. Make sure there are quotation marks around the endpoint string, as there are in the example. This must be the same value you used in the AWS_IoT_SetCertificates sketch. ### Set your Thing Name -In line 62, find and replace the text `YOUR_THING_NAME` with your assigned thing name. +Find and replace the text `YOUR_THING_NAME` with your assigned thing name. Make sure there are quotation marks around the name string, as there are in the example. This must be the same value you used in the AWS_IoT_SetCertificates sketch. ### Set your Sampling Feature (Site) ID -In line 70, find and replace the text `YOUR_SAMPLING_FEATURE_ID` with your assigned sampling feature ID or UUID. +Find and replace the text `YOUR_SAMPLING_FEATURE_ID` with your assigned sampling feature ID or UUID. Make sure there are quotation marks around the name string, as there are in the example. ### Set your WiFi Credentials -In lines 117-118, find and replace the text `xxxxx` with your wifi name (SSID) and your wifi password. +Find and replace the text `YourWiFiSSID` with your wifi name (SSID) and `YourWiFiPassword` with your wifi password. Make sure there are quotation marks around the name string, as there are in the example. ### Set your Variable UUIDs -In lines 191-224, find and replace the text `"12345678-abcd-1234-ef00-1234567890ab` with the UUIDs for each of your variables, if they have UUIDS. +In the section beginning with `Start [variable_arrays]`, find and replace the text `"12345678-abcd-1234-ef00-1234567890ab` with the UUIDs for each of your variables, if they have UUIDS. Make sure there are quotation marks around the name string, as there are in the example. If you do not have UUIDs for your variables, delete the string entirely, leaving empty quotes (`""`). diff --git a/examples/EnviroDIY_Monitoring_Kit/EnviroDIY_Monitoring_Kit.ino b/examples/EnviroDIY_Monitoring_Kit/EnviroDIY_Monitoring_Kit.ino index 90e270ec8..3774f5951 100644 --- a/examples/EnviroDIY_Monitoring_Kit/EnviroDIY_Monitoring_Kit.ino +++ b/examples/EnviroDIY_Monitoring_Kit/EnviroDIY_Monitoring_Kit.ino @@ -35,9 +35,9 @@ // APN for cellular connection #define CELLULAR_APN "add_your_cellular_apn" // WiFi access point name -#define WIFI_ID "your_wifi_ssid" +#define WIFI_ID "YourWiFiSSID" // WiFi password (WPA2) -#define WIFI_PASSWD "your_wifi_password" +#define WIFI_PASSWD "YourWiFiPassword" /** End [configuration] */ @@ -47,7 +47,7 @@ // ========================================================================== /** Start [logging_options] */ // Logger ID, also becomes the prefix for the name of the data file on SD card -const char* LoggerID = "XXXXX"; +const char* LoggerID = "YourLoggerID"; // How frequently (in minutes) to log data const int8_t loggingInterval = 15; // Your logger's timezone. diff --git a/examples/EnviroDIY_Monitoring_Kit/ReadMe.md b/examples/EnviroDIY_Monitoring_Kit/ReadMe.md index 39f575603..64bbcb175 100644 --- a/examples/EnviroDIY_Monitoring_Kit/ReadMe.md +++ b/examples/EnviroDIY_Monitoring_Kit/ReadMe.md @@ -73,7 +73,7 @@ Customize the sketch for the version of the kit that you have: cellular, wifi, o #### Select the Connection Type -In lines 31 and 32, select no more than one of the "bee" types that you will be using. +In the configuration section, select no more than one of the "bee" types that you will be using. - Activate the modem you wish to use by _removing_ any slashes (`//`) before the bee module you will use. - The line should start with `#define` @@ -87,7 +87,7 @@ In lines 31 and 32, select no more than one of the "bee" types that you will be #### Add Connection Info -Replace the `your_..` with the appropriate APN or SSID and password for your network. +Replace the `Your..` with the appropriate APN or SSID and password for your network. Your APN is assigned by your SIM card provider. If you are using a Hologram SIM card (recommended with the kit) the APN is `"hologram"`. @@ -104,14 +104,14 @@ You can leave the configuration for the connection type you're not using as is. // APN for cellular connection #define CELLULAR_APN "add_your_cellular_apn" // WiFi access point name -#define WIFI_ID "your_wifi_ssid" +#define WIFI_ID "YourWiFiSSID" // WiFi password (WPA2) -#define WIFI_PASSWD "your_wifi_password" +#define WIFI_PASSWD "YourWiFiPassword" ``` ### Set Data Logging Options -Customize your data logging options in lines 45-56 of the example. +Customize your data logging options in `Data Logging Options` section of the example. #### Set the logger ID @@ -119,7 +119,7 @@ We recommend using your logger's serial number as the logger ID. ```cpp // Logger ID, also becomes the prefix for the name of the data file on SD card -const char *LoggerID = "XXXX"; +const char *LoggerID = "YourLoggerID"; ``` #### Set the logging interval @@ -148,7 +148,7 @@ const int8_t timeZone = -5; // Eastern Standard Time - Go back to the web page for your site on [Monitor My Watershed](http://monitormywatershed.org/) - Find and click the white "View Token UUID List" button above the small map on your site page. -- Paste the copied UUIDs into your sketch, _replacing_ lines 93-108. +- Paste the copied UUIDs into your sketch, _replacing_ the text between `Beginning of Token UUID List` and `End of Token UUID List`. ```cpp // --------------------- Beginning of Token UUID List --------------------- diff --git a/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_2G/DRWI_2G.ino b/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_2G/DRWI_2G.ino index e6076ec35..dda5ea11c 100644 --- a/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_2G/DRWI_2G.ino +++ b/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_2G/DRWI_2G.ino @@ -30,7 +30,7 @@ // The name of this program file const char* sketchName = "DRWI_CitSci.ino"; // Logger ID, also becomes the prefix for the name of the data file on SD card -const char* LoggerID = "XXXXX"; +const char* LoggerID = "YourLoggerID"; // How frequently (in minutes) to log data const int8_t loggingInterval = 15; // Your logger's timezone. diff --git a/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_2G/ReadMe.md b/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_2G/ReadMe.md index c0cba2f8d..2b07d8101 100644 --- a/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_2G/ReadMe.md +++ b/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_2G/ReadMe.md @@ -55,7 +55,7 @@ _______ ```cpp // Logger ID, also becomes the prefix for the name of the data file on SD card -const char *LoggerID = "XXXX"; +const char *LoggerID = "YourLoggerID"; ``` ### Set the calibration coefficients for the Campbell OBS3+ diff --git a/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_DigiLTE/DRWI_DigiLTE.ino b/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_DigiLTE/DRWI_DigiLTE.ino index fa478ca3d..494852011 100644 --- a/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_DigiLTE/DRWI_DigiLTE.ino +++ b/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_DigiLTE/DRWI_DigiLTE.ino @@ -31,7 +31,7 @@ // The name of this program file const char* sketchName = "DRWI_DigiLTE.ino"; // Logger ID, also becomes the prefix for the name of the data file on SD card -const char* LoggerID = "XXXXX"; +const char* LoggerID = "YourLoggerID"; // How frequently (in minutes) to log data const int8_t loggingInterval = 15; // Your logger's timezone. diff --git a/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_DigiLTE/ReadMe.md b/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_DigiLTE/ReadMe.md index e9faf4a9a..305d5673a 100644 --- a/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_DigiLTE/ReadMe.md +++ b/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_DigiLTE/ReadMe.md @@ -57,7 +57,7 @@ _______ ```cpp // Logger ID, also becomes the prefix for the name of the data file on SD card -const char *LoggerID = "XXXX"; +const char *LoggerID = "YourLoggerID"; ``` ### Set the calibration coefficients for the Campbell OBS3+ diff --git a/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_Mayfly1/DRWI_Mayfly1.ino b/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_Mayfly1/DRWI_Mayfly1.ino index 5bf9acca3..ba9123dc1 100644 --- a/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_Mayfly1/DRWI_Mayfly1.ino +++ b/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_Mayfly1/DRWI_Mayfly1.ino @@ -37,7 +37,7 @@ // The name of this program file const char* sketchName = "DRWI_Mayfly1.ino"; // Logger ID, also becomes the prefix for the name of the data file on SD card -const char* LoggerID = "XXXXX"; +const char* LoggerID = "YourLoggerID"; // How frequently (in minutes) to log data const int8_t loggingInterval = 15; // Your logger's timezone. diff --git a/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_Mayfly1/ReadMe.md b/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_Mayfly1/ReadMe.md index 8ec4726fb..0ee05cd5e 100644 --- a/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_Mayfly1/ReadMe.md +++ b/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_Mayfly1/ReadMe.md @@ -10,7 +10,7 @@ The exact hardware configuration used in this example: - EnviroDIY SIM7080 LTE module (with Hologram SIM card) - Hydros21 CTD sensor -An EnviroDIY LTE SIM7080 module can be used with the older Mayfly v0.5b boards if you change line 101 (for modemVccPin) from 18 to -1. +An EnviroDIY LTE SIM7080 module can be used with the older Mayfly v0.5b boards if you change the modemVccPin from 18 to -1. This is because the Mayfly v1.x board has a separate 3.3v regulator to power the Bee socket and is controlled by turning pin 18 on or off. Mayfly v0.5b has the Bee socket constantly powered, therefore using "-1" is the proper setting for that line of code. diff --git a/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_Mayfly1_WiFi/DRWI_Mayfly1_WiFi.ino b/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_Mayfly1_WiFi/DRWI_Mayfly1_WiFi.ino index b360f1bd7..0d6121a45 100644 --- a/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_Mayfly1_WiFi/DRWI_Mayfly1_WiFi.ino +++ b/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_Mayfly1_WiFi/DRWI_Mayfly1_WiFi.ino @@ -34,7 +34,7 @@ // The name of this program file const char* sketchName = "DRWI_Mayfly1_WiFi.ino"; // Logger ID, also becomes the prefix for the name of the data file on SD card -const char* LoggerID = "XXXXX"; +const char* LoggerID = "YourLoggerID"; // How frequently (in minutes) to log data const int8_t loggingInterval = 15; // Your logger's timezone. @@ -77,8 +77,8 @@ const int8_t modemLEDPin = redLED; // MCU pin connected an LED to show modem // status // Network connection information -const char* wifiId = "xxxxx"; // WiFi access point name -const char* wifiPwd = "xxxxx"; // WiFi password (WPA2) +const char* wifiId = "YourWiFiSSID"; // WiFi access point name +const char* wifiPwd = "YourWiFiPassword"; // WiFi password (WPA2) // Create the modem object EspressifESP32 modemESP(&modemSerial, modemVccPin, modemResetPin, wifiId, diff --git a/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_Mayfly1_WiFi/ReadMe.md b/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_Mayfly1_WiFi/ReadMe.md index d6279c4e6..40ff8a82b 100644 --- a/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_Mayfly1_WiFi/ReadMe.md +++ b/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_Mayfly1_WiFi/ReadMe.md @@ -8,13 +8,13 @@ The exact hardware configuration used in this example: - EnviroDIY ESP32 WiFi module - Hydros21 CTD sensor -An EnviroDIY ESP32 WiFi module can also be used with the older Mayfly v0.5b boards if you change line 86 (for modemVccPin) from 18 to -1. +An EnviroDIY ESP32 WiFi module can also be used with the older Mayfly v0.5b boards if you change the modemVccPin from 18 to -1. This is because the Mayfly v1.x board has a separate 3.3v regulator to power the Bee socket and is controlled by turning pin 18 on or off. Mayfly v0.5b has the Bee socket constantly powered, therefore using "-1" is the proper setting for that line of code. Leave the modemVccPin as 18 for Mayfly version 1.0 and 1.1. The WiFi antenna is built into the ESP32 Bee - no external antenna is needed -Be sure to edit lines 92 and 93 to enter your Wifi access point name and password, and edit the UUID section beginning at line 200 with the correct UUIDs from your specific site on MonitorMyWatershed. +Find and replace `YourWiFiSSID` and `YourWiFiPassword` with your real SSID and password, and edit the UUID section between `Beginning of Token UUID List` and `End of Token UUID List` the correct UUIDs from your specific site on MonitorMyWatershed. _______ diff --git a/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_NoCellular/DRWI_NoCellular.ino b/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_NoCellular/DRWI_NoCellular.ino index 0185105c5..e74ff348a 100644 --- a/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_NoCellular/DRWI_NoCellular.ino +++ b/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_NoCellular/DRWI_NoCellular.ino @@ -31,7 +31,7 @@ // The name of this program file const char* sketchName = "DRWI_NoCellular.ino"; // Logger ID, also becomes the prefix for the name of the data file on SD card -const char* LoggerID = "XXXXX"; +const char* LoggerID = "YourLoggerID"; // How frequently (in minutes) to log data const int8_t loggingInterval = 15; // Your logger's timezone. diff --git a/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_NoCellular/ReadMe.md b/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_NoCellular/ReadMe.md index ad34b8af1..1cb0a0243 100644 --- a/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_NoCellular/ReadMe.md +++ b/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_NoCellular/ReadMe.md @@ -60,7 +60,7 @@ _______ ```cpp // Logger ID, also becomes the prefix for the name of the data file on SD card -const char *LoggerID = "XXXX"; +const char *LoggerID = "YourLoggerID"; ``` ### Set the calibration coefficients for the Campbell OBS3+ diff --git a/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_SIM7080LTE/DRWI_SIM7080LTE.ino b/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_SIM7080LTE/DRWI_SIM7080LTE.ino index c058bc268..0314d2700 100644 --- a/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_SIM7080LTE/DRWI_SIM7080LTE.ino +++ b/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_SIM7080LTE/DRWI_SIM7080LTE.ino @@ -38,7 +38,7 @@ // The name of this program file const char* sketchName = "DRWI_SIM7080LTE.ino"; // Logger ID, also becomes the prefix for the name of the data file on SD card -const char* LoggerID = "XXXXX"; +const char* LoggerID = "YourLoggerID"; // How frequently (in minutes) to log data const int8_t loggingInterval = 15; // Your logger's timezone. diff --git a/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_SIM7080LTE/ReadMe.md b/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_SIM7080LTE/ReadMe.md index d2631c2f9..cf0bb3238 100644 --- a/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_SIM7080LTE/ReadMe.md +++ b/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_SIM7080LTE/ReadMe.md @@ -9,7 +9,7 @@ The exact hardware configuration used in this example: - Hydros21 CTD sensor - Campbell Scientific OBS3+ Turbidity sensor -An EnviroDIY LTE SIM7080 module can be used with the older Mayfly v0.5b boards if you change line 101 (for modemVccPin) from 18 to -1. +An EnviroDIY LTE SIM7080 module can be used with the older Mayfly v0.5b boards if you change the modemVccPin from 18 to -1. This is because the Mayfly v1.0 board has a separate 3.3v regulator to power the Bee socket and is controlled by turning pin 18 on or off. Mayfly v0.5b has the Bee socket constantly powered, therefore using "-1" is the proper setting for that line of code. diff --git a/examples/OutdatedExamples/simple_logging_LearnEnviroDIY/ReadMe.md b/examples/OutdatedExamples/simple_logging_LearnEnviroDIY/ReadMe.md index ea2d11259..d4c813fef 100644 --- a/examples/OutdatedExamples/simple_logging_LearnEnviroDIY/ReadMe.md +++ b/examples/OutdatedExamples/simple_logging_LearnEnviroDIY/ReadMe.md @@ -49,7 +49,7 @@ _______ ```cpp // Logger ID, also becomes the prefix for the name of the data file on SD card -const char *LoggerID = "XXXX"; +const char *LoggerID = "YourLoggerID"; ``` ### Upload! diff --git a/examples/OutdatedExamples/simple_logging_LearnEnviroDIY/simple_logging_LearnEnviroDIY.ino b/examples/OutdatedExamples/simple_logging_LearnEnviroDIY/simple_logging_LearnEnviroDIY.ino index 0d66d565b..585203ea3 100644 --- a/examples/OutdatedExamples/simple_logging_LearnEnviroDIY/simple_logging_LearnEnviroDIY.ino +++ b/examples/OutdatedExamples/simple_logging_LearnEnviroDIY/simple_logging_LearnEnviroDIY.ino @@ -31,7 +31,7 @@ // The name of this program file const char* sketchName = "simple_logging.ino"; // Logger ID, also becomes the prefix for the name of the data file on SD card -const char* LoggerID = "XXXXX"; +const char* LoggerID = "YourLoggerID"; // How frequently (in minutes) to log data const int8_t loggingInterval = 15; // Your logger's timezone. diff --git a/examples/baro_rho_correction/ReadMe.md b/examples/baro_rho_correction/ReadMe.md index e0f49870a..9f33ac3e7 100644 --- a/examples/baro_rho_correction/ReadMe.md +++ b/examples/baro_rho_correction/ReadMe.md @@ -47,11 +47,11 @@ _______ ### Set the logger ID -- Change the "XXXX" in this section of code to the loggerID assigned by Stroud: +- Change the "YourLoggerID" in this section of code to the loggerID assigned by Stroud: ```cpp // Logger ID, also becomes the prefix for the name of the data file on SD card -const char *LoggerID = "XXXX"; +const char *LoggerID = "YourLoggerID"; ``` ### Set the universally unique identifiers (UUID) for each variable diff --git a/examples/baro_rho_correction/baro_rho_correction.ino b/examples/baro_rho_correction/baro_rho_correction.ino index 0b8fac091..4974769e6 100644 --- a/examples/baro_rho_correction/baro_rho_correction.ino +++ b/examples/baro_rho_correction/baro_rho_correction.ino @@ -31,7 +31,7 @@ // The name of this program file const char* sketchName = "baro_rho_correction.ino"; // Logger ID, also becomes the prefix for the name of the data file on SD card -const char* LoggerID = "XXXXX"; +const char* LoggerID = "YourLoggerID"; // How frequently (in minutes) to log data const int8_t loggingInterval = 15; // Your logger's timezone. @@ -78,7 +78,7 @@ const int8_t modemLEDPin = redLED; // MCU pin connected an LED to show modem // status // Network connection information -const char* apn = "xxxxx"; // APN for GPRS connection +const char* apn = "YourAPN"; // APN for GPRS connection // Create the modem object Sodaq2GBeeR6 modem2GB(&modemSerial, modemVccPin, modemStatusPin, apn); diff --git a/examples/double_logger/ReadMe.md b/examples/double_logger/ReadMe.md index 3094b7151..3641bcd5c 100644 --- a/examples/double_logger/ReadMe.md +++ b/examples/double_logger/ReadMe.md @@ -46,11 +46,11 @@ _______ ### Set the logger ID -- Change the "XXXX" in this section of code to the loggerID assigned by Stroud: +- Change the "YourLoggerID" in this section of code to the loggerID assigned by Stroud: ```cpp // Logger ID, also becomes the prefix for the name of the data file on SD card -const char *LoggerID = "XXXX"; +const char *LoggerID = "YourLoggerID"; ``` ### Upload! diff --git a/examples/double_logger/double_logger.ino b/examples/double_logger/double_logger.ino index 838157108..0537b2d03 100644 --- a/examples/double_logger/double_logger.ino +++ b/examples/double_logger/double_logger.ino @@ -31,7 +31,7 @@ // The name of this program file const char* sketchName = "double_logger.ino"; // Logger ID - we're only using one logger ID for both "loggers" -const char* LoggerID = "XXXXX"; +const char* LoggerID = "YourLoggerID"; // The TWO filenames for the different logging intervals const char* FileName5min = "Logger_5MinuteInterval.csv"; const char* FileName1min = "Logger_1MinuteInterval.csv"; @@ -77,8 +77,8 @@ const int8_t modemLEDPin = redLED; // MCU pin connected an LED to show modem // status (-1 if unconnected) // Network connection information -const char* wifiId = "xxxxx"; // WiFi access point, unnecessary for GPRS -const char* wifiPwd = "xxxxx"; // WiFi password, unnecessary for GPRS +const char* wifiId = "YourWiFiSSID"; // The WiFi access point +const char* wifiPwd = "YourWiFiPassword"; // The WiFi password DigiXBeeWifi modemXBWF(&modemSerial, modemVccPin, modemStatusPin, useCTSforStatus, modemResetPin, modemSleepRqPin, wifiId, diff --git a/examples/logging_to_MMW/ReadMe.md b/examples/logging_to_MMW/ReadMe.md index 460b3eebf..91cac8ff2 100644 --- a/examples/logging_to_MMW/ReadMe.md +++ b/examples/logging_to_MMW/ReadMe.md @@ -49,11 +49,11 @@ _______ ### Set the logger ID -- Change the "XXXX" in this section of code to the loggerID assigned by Stroud: +- Change the "YourLoggerID" in this section of code to the loggerID assigned by Stroud: ```cpp // Logger ID, also becomes the prefix for the name of the data file on SD card -const char *LoggerID = "XXXX"; +const char *LoggerID = "YourLoggerID"; ``` ### Set the universally unique identifiers (UUID) for each variable diff --git a/examples/logging_to_MMW/logging_to_MMW.ino b/examples/logging_to_MMW/logging_to_MMW.ino index 5a9554b3c..bb07a6147 100644 --- a/examples/logging_to_MMW/logging_to_MMW.ino +++ b/examples/logging_to_MMW/logging_to_MMW.ino @@ -30,7 +30,7 @@ // The name of this program file const char* sketchName = "logging_to MMW.ino"; // Logger ID, also becomes the prefix for the name of the data file on SD card -const char* LoggerID = "XXXXX"; +const char* LoggerID = "YourLoggerID"; // How frequently (in minutes) to log data const int8_t loggingInterval = 15; // Your logger's timezone. @@ -78,7 +78,7 @@ const int8_t modemLEDPin = redLED; // MCU pin connected an LED to show modem // status (-1 if unconnected) // Network connection information -const char* apn = "xxxxx"; // The APN for the gprs connection +const char* apn = "YourAPN"; // The APN for the gprs connection // NOTE: If possible, use the `STATUS/SLEEP_not` (XBee pin 13) for status, but // the `CTS` pin can also be used if necessary diff --git a/examples/logging_to_ThingSpeak/logging_to_ThingSpeak.ino b/examples/logging_to_ThingSpeak/logging_to_ThingSpeak.ino index 285d52c85..816aacbb8 100644 --- a/examples/logging_to_ThingSpeak/logging_to_ThingSpeak.ino +++ b/examples/logging_to_ThingSpeak/logging_to_ThingSpeak.ino @@ -31,7 +31,7 @@ // The name of this program file const char* sketchName = "logging_to_ThingSpeak.ino"; // Logger ID, also becomes the prefix for the name of the data file on SD card -const char* LoggerID = "XXXXX"; +const char* LoggerID = "YourLoggerID"; // How frequently (in minutes) to log data const int8_t loggingInterval = 15; // Your logger's timezone. @@ -76,8 +76,8 @@ const int8_t modemLEDPin = redLED; // MCU pin connected an LED to show modem status // Network connection information -const char* wifiId = "xxxxx"; // The WiFi access point -const char* wifiPwd = "xxxxx"; // The password for connecting to WiFi +const char* wifiId = "YourWiFiSSID"; // The WiFi access point +const char* wifiPwd = "YourWiFiPassword"; // The WiFi password // Create the loggerModem object EspressifESP8266 modemESP(&modemSerial, modemVccPin, modemResetPin, wifiId, diff --git a/examples/menu_a_la_carte/menu_a_la_carte.ino b/examples/menu_a_la_carte/menu_a_la_carte.ino index 378247645..f47a122bc 100644 --- a/examples/menu_a_la_carte/menu_a_la_carte.ino +++ b/examples/menu_a_la_carte/menu_a_la_carte.ino @@ -427,9 +427,9 @@ Logger dataLogger(LoggerID, samplingFeature, loggingInterval); // APN for cellular connection #define CELLULAR_APN "add_your_cellular_apn" // WiFi access point name -#define WIFI_ID "your_wifi_ssid" +#define WIFI_ID "YourWiFiSSID" // WiFi password (WPA2) -#define WIFI_PASSWD "your_wifi_password" +#define WIFI_PASSWD "YourWiFiPassword" #if defined(BUILD_MODEM_DIGI_XBEE_CELLULAR_TRANSPARENT) #define BUILD_HAS_MODEM diff --git a/examples/simple_logging/ReadMe.md b/examples/simple_logging/ReadMe.md index 59139d763..937d8a05c 100644 --- a/examples/simple_logging/ReadMe.md +++ b/examples/simple_logging/ReadMe.md @@ -44,7 +44,7 @@ _______ ```cpp // Logger ID, also becomes the prefix for the name of the data file on SD card -const char *LoggerID = "XXXX"; +const char *LoggerID = "YourLoggerID"; ``` ### Upload! diff --git a/examples/simple_logging/simple_logging.ino b/examples/simple_logging/simple_logging.ino index 889f9fe47..51d0d5350 100644 --- a/examples/simple_logging/simple_logging.ino +++ b/examples/simple_logging/simple_logging.ino @@ -31,7 +31,7 @@ // The name of this program file const char* sketchName = "simple_logging.ino"; // Logger ID, also becomes the prefix for the name of the data file on SD card -const char* LoggerID = "XXXXX"; +const char* LoggerID = "YourLoggerID"; // How frequently (in minutes) to log data const int8_t loggingInterval = 15; // Your logger's timezone. diff --git a/extras/AWS_IoT_SetCertificates/ReadMe.md b/extras/AWS_IoT_SetCertificates/ReadMe.md index 341b863ad..701456277 100644 --- a/extras/AWS_IoT_SetCertificates/ReadMe.md +++ b/extras/AWS_IoT_SetCertificates/ReadMe.md @@ -77,12 +77,12 @@ Unfortunately, the Stonefly cannot read the certificates from your computer, so #### Set your AWS IoT Core Endpoint -In line 11, find and replace the text `YOUR_ENDPOINT-ats.iot.YOUR_REGION.amazonaws.com` with your real endpoint. +Find and replace the text `YOUR_ENDPOINT-ats.iot.YOUR_REGION.amazonaws.com` with your real endpoint. Make sure there are quotation marks around the endpoint string, as there are in the example. #### Set your Thing Name -In line 13, find and replace the text `YOUR_THING_NAME` with your assigned thing name. +Find and replace the text `YOUR_THING_NAME` with your assigned thing name. Make sure there are quotation marks around the name string, as there are in the example. #### Set your AWS IoT Core Client Certificate @@ -99,7 +99,7 @@ On Windows: - Open the file anyway. Once you have the file open, it should look like a bunch of random characters sandwiched between the lines `-----BEGIN CERTIFICATE-----` and `-----END CERTIFICATE-----`. -Find and replace the text `paste the certificate here` in approximately line 47 of with the text of your certificate. +Find and replace the text `paste the certificate here` with the text of your certificate. Make sure that the text begins and ends with the lines `-----BEGIN CERTIFICATE-----` and `-----END CERTIFICATE-----` as it does in the example and in your certificate text. #### Set your AWS IoT Core Client Private Key @@ -108,12 +108,9 @@ From the required files mentioned above, find and open the file that *ends with* As before, you need to see the file in a text editor and you may get a security warning when you open it. Once you have the file open, it should look like a bunch of random characters sandwiched between the lines `-----BEGIN RSA PRIVATE KEY-----` and `-----END RSA PRIVATE KEY-----`. -Find and replace the text `paste the private key here` in approximately line 71 of with the text of your certificate. +Find and replace the text `paste the private key here` with the text of your certificate. Make sure that the text begins and ends with the lines `-----BEGIN RSA PRIVATE KEY-----` and `-----END RSA PRIVATE KEY-----` as it does in the example and in your certificate text. -> [!NOTE] -> The line number where the private key starts may change based on the length of the certificate pasted above it. - ### Customize the Set Certificates program This is the program the Stonefly will run to feed the certificates onto the modem. @@ -121,15 +118,15 @@ Since all of the private information went into the config file modified above, o #### Select your Modem -In lines 27-31 remove the slashes (`//`) before the modem that you want to use and add slashes to all of the others. +In the section beginning with `// Select your modem:` remove the slashes (`//`) before the modem that you want to use and add slashes to all of the others. #### Set your cellular APN or Wifi credentials -If you are using a cellular modem, in line 78, find and replace the text `hologram` with the APN for your SIM card. +If you are using a cellular modem, find and replace the text `YourAPN` with the APN for your SIM card. Make sure there are quotation marks around the APN string, as there are in the example. -If you are using a Hologram SIM, you don't need to change this. +If you are using a Hologram SIM, use the text `hologram`.. -If you are using a WiFi modem, in lines 83-84 find and replace `YourWiFiSSID` and `YourWiFiPassword` with your real SSID and password. +If you are using a WiFi modem, find and replace `YourWiFiSSID` and `YourWiFiPassword` with your real SSID and password. ## Upload to your Board @@ -177,8 +174,8 @@ There are some [tips in the Read Me](https://github.com/EnviroDIY/USGS_NGWOS/?ta If you see the message `failed to initialize modem`, there's a communication problem between the modem and the Arduino. If after the failure message and a delay you do see your modem serial number or firmware version after the message `Modem Info:`, you can ignore this error: it was a baud rate problem and the Arduino adjusted. If you don't get the modem info, there's something wrong. -If your SIM card requires a user name and password to unlock (uncommon), enter those in lines 79 and 80 of the ino file and recompile and re-upload. -Confirm that your wires between the Arduino and your modem are correct and you've set the correct port for `SerialAT` in line 45. +If your SIM card requires a user name and password to unlock (uncommon), enter those in as the `gprsUser` and `gprsUser` in the GPRS credentials section of the ino file and recompile and re-upload. +Confirm that your wires between the Arduino and your modem are correct and you've set the correct port for `SerialAT` in the line `#define SerialMon Serial`. Confirm that your modem has power and that any expected LED's are lit. ### The certificates fail to load on the modem From 58ae5530a2354c196824a2676ecb67fac592be7d Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Wed, 18 Feb 2026 16:45:04 -0500 Subject: [PATCH 205/533] Add default values Signed-off-by: Sara Damiano --- src/publishers/MonitorMyWatershedPublisher.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/publishers/MonitorMyWatershedPublisher.h b/src/publishers/MonitorMyWatershedPublisher.h index 5d7826f18..89da45bd4 100644 --- a/src/publishers/MonitorMyWatershedPublisher.h +++ b/src/publishers/MonitorMyWatershedPublisher.h @@ -261,10 +261,10 @@ class MonitorMyWatershedPublisher : public dataPublisher { * * @{ */ - const char* monitorMWPath; ///< The api path - const char* monitorMWHost; ///< The host name - int monitorMWPort; ///< The host port - static const char* tokenHeader; ///< The token header text + const char* monitorMWPath = nullptr; ///< The api path + const char* monitorMWHost = nullptr; ///< The host name + int monitorMWPort = 80; ///< The host port + static const char* tokenHeader; ///< The token header text static const char* contentLengthHeader; ///< The content length header text static const char* contentTypeHeader; ///< The content type header text /**@}*/ From 4df574aa5b3b0224e8818dc7b762b3c0386d02fe Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Wed, 18 Feb 2026 16:46:29 -0500 Subject: [PATCH 206/533] Reference other boards with ALS Signed-off-by: Sara Damiano --- src/sensors/EverlightALSPT19.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sensors/EverlightALSPT19.h b/src/sensors/EverlightALSPT19.h index db94b1a00..4e2dfbf8a 100644 --- a/src/sensors/EverlightALSPT19.h +++ b/src/sensors/EverlightALSPT19.h @@ -232,7 +232,7 @@ class EverlightALSPT19 : public Sensor { defined(BUILT_IN_ALS_LOADING_RESISTANCE) /** * @brief Construct a new EverlightALSPT19 object with pins and resistors - * for the EnviroDIY Mayfly 1.x. + * for boards with a built-in ALS-PT19 configured in KnownProcessors.h. * * This is a short-cut constructor to help users of our own board so they * can change the number of readings without changing other arguments or From b026480f1f4c389f1d8d9c46c4f0f6fa2aec0977 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Wed, 18 Feb 2026 16:57:09 -0500 Subject: [PATCH 207/533] Restructure keller success Signed-off-by: Sara Damiano --- src/sensors/KellerParent.cpp | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/src/sensors/KellerParent.cpp b/src/sensors/KellerParent.cpp index 4fd23cc9e..8beab639a 100644 --- a/src/sensors/KellerParent.cpp +++ b/src/sensors/KellerParent.cpp @@ -101,15 +101,21 @@ bool KellerParent::addSingleMeasurementResult(void) { MS_DBG(getSensorNameAndLocation(), F("is reporting:")); // Get Values - success = _ksensor.getValues(waterPressureBar, waterTemperatureC); - waterDepthM = _ksensor.calcWaterDepthM( - waterPressureBar, - waterTemperatureC); // float calcWaterDepthM(float - // waterPressureBar, float waterTemperatureC) - - // For waterPressureBar, convert bar to millibar - if (!isnan(waterPressureBar) && waterPressureBar != -9999) + // the getValues function in the KellerModbus library will *always* return + // true, but will set the value variables to -9999 if it fails to get a + // value. So we check for success by checking that the value variables are + // not -9999 or NaN. + _ksensor.getValues(waterPressureBar, waterTemperatureC); + success = (!isnan(waterPressureBar) && waterPressureBar != -9999 && + !isnan(waterTemperatureC) && waterTemperatureC != -9999); + + if (success) { + // calculate depth from pressure and temperature + waterDepthM = _ksensor.calcWaterDepthM(waterPressureBar, + waterTemperatureC); + // For waterPressureBar, convert bar to millibar waterPressure_mBar = 1000 * waterPressureBar; + } MS_DBG(F(" Pressure_mbar:"), waterPressure_mBar); MS_DBG(F(" Temp_C:"), waterTemperatureC); From 51ea15db3fa50681774f2a59756cd8ebc17c1766 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Wed, 18 Feb 2026 17:00:43 -0500 Subject: [PATCH 208/533] Comment on pin state Signed-off-by: Sara Damiano --- src/sensors/YosemitechParent.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/sensors/YosemitechParent.cpp b/src/sensors/YosemitechParent.cpp index edc3cc48e..148914137 100644 --- a/src/sensors/YosemitechParent.cpp +++ b/src/sensors/YosemitechParent.cpp @@ -80,6 +80,7 @@ bool YosemitechParent::wake(void) { // Sensor::wake() checks if the power pin is on and sets the wake timestamp // and status bits. If it returns false, there's no reason to go on. if (!Sensor::wake()) return false; + // reset pin mode, incase the pins were tri-stated during sleep if (_RS485EnablePin >= 0) { pinMode(_RS485EnablePin, OUTPUT); } // Send the command to begin taking readings, trying up to 5 times From 25fb8b22e7ad4d84968a2edf8a4ce72a122dcf1d Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Wed, 18 Feb 2026 17:04:26 -0500 Subject: [PATCH 209/533] check for nullptr Signed-off-by: Sara Damiano --- src/LoggerBase.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/LoggerBase.cpp b/src/LoggerBase.cpp index 5f125a85e..22c2f7559 100644 --- a/src/LoggerBase.cpp +++ b/src/LoggerBase.cpp @@ -1276,7 +1276,7 @@ void Logger::printFileHeader(Stream* stream) { stream->println(_fileName); // Adding the sampling feature UUID - if (strlen(_samplingFeatureUUID) > 1) { + if (_samplingFeatureUUID != nullptr && strlen(_samplingFeatureUUID) > 1) { stream->print(F("Sampling Feature UUID: ")); stream->print(_samplingFeatureUUID); stream->println(','); From ebefe6e2949b740e5b1a560fbe30b676ab0c7ea8 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Wed, 18 Feb 2026 17:08:22 -0500 Subject: [PATCH 210/533] Fix ADC comments Signed-off-by: Sara Damiano --- src/sensors/AlphasenseCO2.cpp | 2 +- src/sensors/ApogeeSQ212.cpp | 2 +- src/sensors/CampbellOBS3.cpp | 2 +- src/sensors/TIADS1x15.cpp | 2 +- src/sensors/TurnerCyclops.cpp | 2 +- src/sensors/TurnerTurbidityPlus.cpp | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/sensors/AlphasenseCO2.cpp b/src/sensors/AlphasenseCO2.cpp index 70dd3388a..8ad85ebf8 100644 --- a/src/sensors/AlphasenseCO2.cpp +++ b/src/sensors/AlphasenseCO2.cpp @@ -57,7 +57,7 @@ bool AlphasenseCO2::addSingleMeasurementResult(void) { MS_DBG(getSensorNameAndLocation(), F("is reporting:")); -// Create an auxiliary ADD object +// Create an auxiliary ADC object // We create and set up the ADC object here so that each sensor using the ADC // may set the gain appropriately without effecting others. #ifndef MS_USE_ADS1015 diff --git a/src/sensors/ApogeeSQ212.cpp b/src/sensors/ApogeeSQ212.cpp index a1180d876..78e950bb0 100644 --- a/src/sensors/ApogeeSQ212.cpp +++ b/src/sensors/ApogeeSQ212.cpp @@ -55,7 +55,7 @@ bool ApogeeSQ212::addSingleMeasurementResult(void) { MS_DBG(getSensorNameAndLocation(), F("is reporting:")); -// Create an auxiliary ADD object +// Create an auxiliary ADC object // We create and set up the ADC object here so that each sensor using // the ADC may set the gain appropriately without effecting others. #ifndef MS_USE_ADS1015 diff --git a/src/sensors/CampbellOBS3.cpp b/src/sensors/CampbellOBS3.cpp index 35be5b15b..ff98ce8af 100644 --- a/src/sensors/CampbellOBS3.cpp +++ b/src/sensors/CampbellOBS3.cpp @@ -55,7 +55,7 @@ bool CampbellOBS3::addSingleMeasurementResult(void) { MS_DBG(getSensorNameAndLocation(), F("is reporting:")); -// Create an auxiliary ADD object +// Create an auxiliary ADC object // We create and set up the ADC object here so that each sensor using // the ADC may set the gain appropriately without effecting others. #ifndef MS_USE_ADS1015 diff --git a/src/sensors/TIADS1x15.cpp b/src/sensors/TIADS1x15.cpp index 597be1fce..5fc05018c 100644 --- a/src/sensors/TIADS1x15.cpp +++ b/src/sensors/TIADS1x15.cpp @@ -55,7 +55,7 @@ bool TIADS1x15::addSingleMeasurementResult(void) { MS_DBG(getSensorNameAndLocation(), F("is reporting:")); -// Create an auxiliary ADD object +// Create an auxiliary ADC object // We create and set up the ADC object here so that each sensor using // the ADC may set the gain appropriately without effecting others. #ifndef MS_USE_ADS1015 diff --git a/src/sensors/TurnerCyclops.cpp b/src/sensors/TurnerCyclops.cpp index 6571f6659..892b949db 100644 --- a/src/sensors/TurnerCyclops.cpp +++ b/src/sensors/TurnerCyclops.cpp @@ -55,7 +55,7 @@ bool TurnerCyclops::addSingleMeasurementResult(void) { MS_DBG(getSensorNameAndLocation(), F("is reporting:")); -// Create an auxiliary ADD object +// Create an auxiliary ADC object // We create and set up the ADC object here so that each sensor using // the ADC may set the gain appropriately without effecting others. #ifndef MS_USE_ADS1015 diff --git a/src/sensors/TurnerTurbidityPlus.cpp b/src/sensors/TurnerTurbidityPlus.cpp index a0e868c5d..3fa76f50d 100644 --- a/src/sensors/TurnerTurbidityPlus.cpp +++ b/src/sensors/TurnerTurbidityPlus.cpp @@ -102,7 +102,7 @@ bool TurnerTurbidityPlus::addSingleMeasurementResult(void) { MS_DBG(getSensorNameAndLocation(), F("is reporting:")); -// Create an auxiliary ADD object +// Create an auxiliary ADC object // We create and set up the ADC object here so that each sensor using the ADC // may set the gain appropriately without effecting others. #ifndef MS_USE_ADS1015 From 85b48bb3325dd23a70825da49a79f7603381a61d Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Wed, 18 Feb 2026 17:10:43 -0500 Subject: [PATCH 211/533] Fix broken links Signed-off-by: Sara Damiano --- examples/ReadMe.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/examples/ReadMe.md b/examples/ReadMe.md index 87cc029f5..13ff562da 100644 --- a/examples/ReadMe.md +++ b/examples/ReadMe.md @@ -151,7 +151,7 @@ This example also makes use of the on-board light, temperature, and humidity sen The results are saved to the SD card and posted to Monitor My Watershed. Only to be used with newer Mayfly v1.0 and v1.1 boards. - [Instructions for the Mayfly 1.x LTE DRWI Citizen Science example](https://envirodiy.github.io/ModularSensors/example_drwi_mayfly1.html) -- [The LTEG DRWI Citizen Science example on GitHub](https://github.com/EnviroDIY/ModularSensors/tree/master/examples/OutdatedHardware/DRWI_CitizenScience/DRWI_Mayfly1) +- [The LTEG DRWI Citizen Science example on GitHub](https://github.com/EnviroDIY/ModularSensors/tree/master/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_Mayfly1) #### DRWI CitSci No Cellular @@ -160,7 +160,7 @@ It includes a Meter Hydros 21 (CTD) and a Campbell OBS3+ (Turbidity). The exclusion of the modem and publisher simplifies the code from the other DRWI examples and uses less power than running one of cellular versions without attaching the modem. - [Instructions for the no-cellular DRWI Citizen Science example](https://envirodiy.github.io/ModularSensors/example_drwi_no_cell.html) -- [The no-cellular DRWI Citizen Science example on GitHub](https://github.com/EnviroDIY/ModularSensors/tree/master/examples/OutdatedHardware/DRWI_CitizenScience/DRWI_NoCellular) +- [The no-cellular DRWI Citizen Science example on GitHub](https://github.com/EnviroDIY/ModularSensors/tree/master/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_NoCellular) #### DRWI CitSci (2G) @@ -170,7 +170,7 @@ The results are saved to the SD card and posted to Monitor My Watershed. The only difference between this and the other cellular DRWI examples is the type of modem used. - [Instructions for the 2G DRWI Citizen Science example](https://envirodiy.github.io/ModularSensors/example_drwi_2g.html) -- [The 2G DRWI Citizen Science example on GitHub](https://github.com/EnviroDIY/ModularSensors/tree/master/examples/OutdatedHardware/DRWI_CitizenScience/DRWI_CitSci) +- [The 2G DRWI Citizen Science example on GitHub](https://github.com/EnviroDIY/ModularSensors/tree/master/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_CitSci) #### DRWI Digi LTE @@ -180,7 +180,7 @@ The results are saved to the SD card and posted to Monitor My Watershed. The only difference between this and the other cellular DRWI examples is the type of modem used. - [Instructions for the Digi LTE DRWI Citizen Science example](https://envirodiy.github.io/ModularSensors/example_drwi_digilte.html) -- [The Digi LTE DRWI Citizen Science example on GitHub](https://github.com/EnviroDIY/ModularSensors/tree/master/examples/OutdatedHardware/DRWI_CitizenScience/DRWI_DigiLTE) +- [The Digi LTE DRWI Citizen Science example on GitHub](https://github.com/EnviroDIY/ModularSensors/tree/master/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_DigiLTE) #### DRWI EnviroDIY LTEbee @@ -190,4 +190,4 @@ The results are saved to the SD card and posted to Monitor My Watershed. The only difference between this and the other cellular DRWI examples below is the type of modem used. - [Instructions for the EnviroDIY LTEbee DRWI Citizen Science example](https://envirodiy.github.io/ModularSensors/example_drwi_ediylte.html) -- [The EnviroDIY LTE DRWI Citizen Science example on GitHub](https://github.com/EnviroDIY/ModularSensors/tree/master/examples/OutdatedHardware/DRWI_CitizenScience/DRWI_DigiLTE) +- [The EnviroDIY LTE DRWI Citizen Science example on GitHub](https://github.com/EnviroDIY/ModularSensors/tree/master/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_SIM7080LTE) From a3a7d8d3bddb0d50604ecebda58b18c40dc2cc76 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Wed, 18 Feb 2026 17:11:47 -0500 Subject: [PATCH 212/533] Delete text orphaned by removed example Signed-off-by: Sara Damiano --- docs/Getting-Started/Getting-Started.md | 3 --- 1 file changed, 3 deletions(-) diff --git a/docs/Getting-Started/Getting-Started.md b/docs/Getting-Started/Getting-Started.md index c98030585..abed77bff 100644 --- a/docs/Getting-Started/Getting-Started.md +++ b/docs/Getting-Started/Getting-Started.md @@ -139,9 +139,6 @@ It also includes a Meter Hydros 21 (formerly know as a Decagon CTD) and a Campbe - This example demonstrates how to work with calculated variables and calculates water depth by correcting the total pressure measured by a Measurement Specialties MS5803 with the atmospheric pressure measured by a Bosch BME280 environmental sensor and the temperature measured by a Maxim DS18 temperature probe. - [double_logger](https://github.com/EnviroDIY/ModularSensors/tree/master/examples/double_logger) - This is a more complicated example using two different logger instances to log data at two different intervals, in this case, an AM3215 logging every minute, while checking the battery voltage only every 5 minutes. -This showcases both how to use two different logging instances and how to use some of the functions to set up your own logging loop rather than using the logData() function. -There are two sets of variables, all coming from Yosemitech sensors. -Because each sensor outputs temperature and we don't want to waste cellular data sending out multiple nearly identical temperature values, we have one logger that logs every possible variable result to the SD card and another logger that sends only unique results to Monitor My Watershed. ## Deploying your Station From 29010498ac355628f365990a5e8069b8b530a603 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Wed, 18 Feb 2026 17:13:27 -0500 Subject: [PATCH 213/533] Fix capitalization Signed-off-by: Sara Damiano --- examples/AWS_IoT_Core/ReadMe.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/AWS_IoT_Core/ReadMe.md b/examples/AWS_IoT_Core/ReadMe.md index c9e2ebc2a..268c03b34 100644 --- a/examples/AWS_IoT_Core/ReadMe.md +++ b/examples/AWS_IoT_Core/ReadMe.md @@ -61,7 +61,7 @@ Make sure there are quotation marks around the name string, as there are in the ### Set your Variable UUIDs -In the section beginning with `Start [variable_arrays]`, find and replace the text `"12345678-abcd-1234-ef00-1234567890ab` with the UUIDs for each of your variables, if they have UUIDS. +In the section beginning with `Start [variable_arrays]`, find and replace the text `"12345678-abcd-1234-ef00-1234567890ab` with the UUIDs for each of your variables, if they have UUIDs. Make sure there are quotation marks around the name string, as there are in the example. If you do not have UUIDs for your variables, delete the string entirely, leaving empty quotes (`""`). From b2453e7df7081bd33815a5ed6e579567a4fee31f Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Wed, 18 Feb 2026 17:17:41 -0500 Subject: [PATCH 214/533] Validate voltage divider value Signed-off-by: Sara Damiano --- src/sensors/TurnerTurbidityPlus.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/sensors/TurnerTurbidityPlus.cpp b/src/sensors/TurnerTurbidityPlus.cpp index 3fa76f50d..e8492f110 100644 --- a/src/sensors/TurnerTurbidityPlus.cpp +++ b/src/sensors/TurnerTurbidityPlus.cpp @@ -169,9 +169,15 @@ bool TurnerTurbidityPlus::addSingleMeasurementResult(void) { // The ADS1X15 outputs a max value corresponding to Vcc + 0.3V if (adcVoltage < 5.3 && adcVoltage > -0.3) { - // Apply voltage divider factor if using a voltage divider to step down - // the voltage - adcVoltage *= _voltageDividerFactor; + if (_voltageDividerFactor > 0) { + // Apply voltage divider factor if using a voltage divider to step + // down the voltage + adcVoltage *= _voltageDividerFactor; + } else { + MS_DBG(F(" Invalid voltage divider factor:"), + _voltageDividerFactor, + F("Voltage divider will be ignored.")); + } // Apply the unique calibration curve for the given sensor calibResult = (_conc_std / (_volt_std - _volt_blank)) * (adcVoltage - _volt_blank); From ef6297ade191dfec20932727c8800af614da9c44 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Wed, 18 Feb 2026 17:19:55 -0500 Subject: [PATCH 215/533] Initialize events, reorder debug prints Signed-off-by: Sara Damiano --- src/sensors/SensirionSHT4x.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/sensors/SensirionSHT4x.cpp b/src/sensors/SensirionSHT4x.cpp index d3e76c29c..4a675fa33 100644 --- a/src/sensors/SensirionSHT4x.cpp +++ b/src/sensors/SensirionSHT4x.cpp @@ -113,15 +113,15 @@ bool SensirionSHT4x::addSingleMeasurementResult(void) { temp_val = temp_event.temperature; humid_val = humidity_event.relative_humidity; - MS_DBG(F(" Temp:"), temp_val, F("°C")); - MS_DBG(F(" Humidity:"), humid_val, '%'); - if (!ret_val) { MS_DBG(F(" getEvent failed; no values read!")); } else if (isnan(temp_val) || isnan(humid_val)) { MS_DBG(F(" Invalid measurement values")); } + MS_DBG(F(" Temp:"), temp_val, F("°C")); + MS_DBG(F(" Humidity:"), humid_val, '%'); + if (ret_val && !isnan(temp_val) && !isnan(humid_val)) { verifyAndAddMeasurementResult(SHT4X_TEMP_VAR_NUM, temp_val); verifyAndAddMeasurementResult(SHT4X_HUMIDITY_VAR_NUM, humid_val); @@ -162,8 +162,8 @@ bool SensirionSHT4x::sleep(void) { // case 1 second. Usually blocking steps are a problem, but in this case we // need the block because ModularSensors does not currently support a sleep // time like it supports a wake time. - sensors_event_t temp_event; - sensors_event_t humidity_event; + sensors_event_t temp_event{}; + sensors_event_t humidity_event{}; success = sht4x_internal.getEvent(&humidity_event, &temp_event); // Set the command back to no heat for the next measurement. From 48a878f1a473d01d6c676b9621e28701c7dbadfb Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Wed, 18 Feb 2026 17:20:47 -0500 Subject: [PATCH 216/533] Correct comment Signed-off-by: Sara Damiano --- src/sensors/FreescaleMPL115A2.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sensors/FreescaleMPL115A2.h b/src/sensors/FreescaleMPL115A2.h index 965ef99fa..4d6af6516 100644 --- a/src/sensors/FreescaleMPL115A2.h +++ b/src/sensors/FreescaleMPL115A2.h @@ -35,7 +35,7 @@ * is managed by the * [Adafruit MPL115A2 library](https://github.com/adafruit/Adafruit_MPL115A2). * - * @note Software I2C is *not* supported for the AM2315. + * @note Software I2C is *not* supported for the MPL115A2. * A secondary hardware I2C on a SAMD board is supported. * * @section sensor_mpl115a2_datasheet Sensor Datasheet From 54747a7d796b8225f553ba1f32131d133b482d7f Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Wed, 18 Feb 2026 17:21:55 -0500 Subject: [PATCH 217/533] Remove 'of' Signed-off-by: Sara Damiano --- examples/OutdatedExamples/DRWI_CitizenScience/DRWI_2G/ReadMe.md | 2 +- .../OutdatedExamples/DRWI_CitizenScience/DRWI_DigiLTE/ReadMe.md | 2 +- .../DRWI_CitizenScience/DRWI_NoCellular/ReadMe.md | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_2G/ReadMe.md b/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_2G/ReadMe.md index 2b07d8101..e214689ee 100644 --- a/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_2G/ReadMe.md +++ b/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_2G/ReadMe.md @@ -101,7 +101,7 @@ Variable* variableList[] = { ``` - If any of the variables are in a different order on the web page than in your code **reorder the variables in your code to match the website**. -- After you are completely certain that you have the order right in the variable section of your code use the teal "Copy" button on the website to copy the section of code containing all of the UUIDs. +- After you are completely certain that you have the order right in the variable section of your code use the teal "Copy" button on the website to copy the section of code containing all the UUIDs. - Paste the code from the website into your program in this section below the variable array ```cpp diff --git a/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_DigiLTE/ReadMe.md b/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_DigiLTE/ReadMe.md index 305d5673a..376ba3e5f 100644 --- a/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_DigiLTE/ReadMe.md +++ b/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_DigiLTE/ReadMe.md @@ -105,7 +105,7 @@ Variable* variableList[] = { ``` - If any of the variables are in a different order on the web page than in your code **reorder the variables in your code to match the website**. -- After you are completely certain that you have the order right in the variable section of your code use the teal "Copy" button on the website to copy the section of code containing all of the UUIDs. +- After you are completely certain that you have the order right in the variable section of your code use the teal "Copy" button on the website to copy the section of code containing all the UUIDs. - Paste the code from the website into your program in this section below the variable array ```cpp diff --git a/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_NoCellular/ReadMe.md b/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_NoCellular/ReadMe.md index 1cb0a0243..f03d99c2e 100644 --- a/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_NoCellular/ReadMe.md +++ b/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_NoCellular/ReadMe.md @@ -106,7 +106,7 @@ Variable* variableList[] = { ``` - If any of the variables are in a different order on the web page than in your code __reorder the variables in your code to match the website__. -- After you are completely certain that you have the order right in the variable section of your code use the teal "Copy" button on the website to copy the section of code containing all of the UUIDs. +- After you are completely certain that you have the order right in the variable section of your code use the teal "Copy" button on the website to copy the section of code containing all the UUIDs. - Paste the code from the website into your program in this section below the variable array ```cpp From 3dd6e076cf2903f475d7584596b710d0d9d60c97 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Wed, 18 Feb 2026 17:23:10 -0500 Subject: [PATCH 218/533] Grammar fix Signed-off-by: Sara Damiano --- src/ModSensorConfig.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ModSensorConfig.h b/src/ModSensorConfig.h index 4ed70f194..7fb93ef23 100644 --- a/src/ModSensorConfig.h +++ b/src/ModSensorConfig.h @@ -9,7 +9,7 @@ * settings/preferences for the Modular Sensors Library and some of the * underlying libraries. * - * @note This file must be include in every header file in the library - before + * @note This file must be included in every header file in the library - before * including anything else - to ensure that the settings are applied * consistently across all files and that compile time settings trickle down to * the underlying libraries. From 1c5ecac18939951597ffe2f8adb327b4d173c052 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Wed, 18 Feb 2026 17:37:49 -0500 Subject: [PATCH 219/533] Update examples/OutdatedExamples/DRWI_CitizenScience/DRWI_Mayfly1_WiFi/ReadMe.md Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --- .../DRWI_CitizenScience/DRWI_Mayfly1_WiFi/ReadMe.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_Mayfly1_WiFi/ReadMe.md b/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_Mayfly1_WiFi/ReadMe.md index 40ff8a82b..9c308bdae 100644 --- a/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_Mayfly1_WiFi/ReadMe.md +++ b/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_Mayfly1_WiFi/ReadMe.md @@ -14,7 +14,7 @@ Mayfly v0.5b has the Bee socket constantly powered, therefore using "-1" is the The WiFi antenna is built into the ESP32 Bee - no external antenna is needed -Find and replace `YourWiFiSSID` and `YourWiFiPassword` with your real SSID and password, and edit the UUID section between `Beginning of Token UUID List` and `End of Token UUID List` the correct UUIDs from your specific site on MonitorMyWatershed. +Find and replace `YourWiFiSSID` and `YourWiFiPassword` with your real SSID and password, and edit the UUID section between `Beginning of Token UUID List` and `End of Token UUID List` with the correct UUIDs from your specific site on MonitorMyWatershed. _______ From 334b82c68f652e66a5a39ff59a8ea14f59b4e0a9 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Wed, 18 Feb 2026 17:42:00 -0500 Subject: [PATCH 220/533] Correct max stabilization time Signed-off-by: Sara Damiano --- src/sensors/GeoluxHydroCam.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sensors/GeoluxHydroCam.cpp b/src/sensors/GeoluxHydroCam.cpp index 9bc10e675..46039b8fb 100644 --- a/src/sensors/GeoluxHydroCam.cpp +++ b/src/sensors/GeoluxHydroCam.cpp @@ -352,7 +352,7 @@ bool GeoluxHydroCam::isStable(bool debug) { : 0L; uint32_t maxTime = _alwaysAutoFocus ? HYDROCAM_AUTOFOCUS_TIME_MAX + HYDROCAM_STABILIZATION_TIME_MAX - : 0L; + : HYDROCAM_STABILIZATION_TIME_MAX; // If the sensor has been activated and enough time has elapsed, it's stable if (elapsed_since_wake_up > maxTime) { MS_DBG(F("It's been"), elapsed_since_wake_up, F("ms, and"), From 8db5dec0b9e2a39c5e7f160537db0f44332b4b9d Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Wed, 18 Feb 2026 17:45:35 -0500 Subject: [PATCH 221/533] Force pressure to be over 0 Signed-off-by: Sara Damiano --- src/sensors/MeaSpecMS5803.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sensors/MeaSpecMS5803.cpp b/src/sensors/MeaSpecMS5803.cpp index 720f8c4b0..c87a8ed41 100644 --- a/src/sensors/MeaSpecMS5803.cpp +++ b/src/sensors/MeaSpecMS5803.cpp @@ -76,7 +76,7 @@ bool MeaSpecMS5803::addSingleMeasurementResult(void) { MS_DBG(F(" Pressure:"), press); if (!isnan(temp) && !isnan(press) && temp >= -40.0 && temp <= 85.0 && - press != 0.0 && press <= 14000.0) { + press > 0.0 && press <= 14000.0) { // Temperature Range is -40°C to +85°C // Pressure returns 0 when disconnected, which is highly unlikely to be // a real value. From eb766318fc17c5715d364c8109fc650775dae167 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Wed, 18 Feb 2026 17:47:57 -0500 Subject: [PATCH 222/533] Typos and stuff Signed-off-by: Sara Damiano --- examples/ReadMe.md | 2 +- extras/AWS_IoT_SetCertificates/ReadMe.md | 2 +- src/publishers/MonitorMyWatershedPublisher.h | 4 ++-- src/publishers/UbidotsPublisher.h | 2 +- src/sensors/ProcessorAnalog.cpp | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/examples/ReadMe.md b/examples/ReadMe.md index 13ff562da..02e05c627 100644 --- a/examples/ReadMe.md +++ b/examples/ReadMe.md @@ -108,7 +108,7 @@ ___ The "menu a la carte" example shows most of the functions of the library in one gigantic program. It has code in it for every possible sensor and modem and for both AVR and SAMD boards. It is also over 1500 lines long. -This example is intended to be used like an a la carte menu of all possible options where you selected only the portions of code pertinent to you and delete everything else. +This example is intended to be used like an a la carte menu of all possible options where you select only the portions of code pertinent to you and delete everything else. This example is *NOT* intended to be run in its entirety - [The menu a la carte walkthrough](https://envirodiy.github.io/ModularSensors/example_menu.html) diff --git a/extras/AWS_IoT_SetCertificates/ReadMe.md b/extras/AWS_IoT_SetCertificates/ReadMe.md index 701456277..8c0e6cd66 100644 --- a/extras/AWS_IoT_SetCertificates/ReadMe.md +++ b/extras/AWS_IoT_SetCertificates/ReadMe.md @@ -174,7 +174,7 @@ There are some [tips in the Read Me](https://github.com/EnviroDIY/USGS_NGWOS/?ta If you see the message `failed to initialize modem`, there's a communication problem between the modem and the Arduino. If after the failure message and a delay you do see your modem serial number or firmware version after the message `Modem Info:`, you can ignore this error: it was a baud rate problem and the Arduino adjusted. If you don't get the modem info, there's something wrong. -If your SIM card requires a user name and password to unlock (uncommon), enter those in as the `gprsUser` and `gprsUser` in the GPRS credentials section of the ino file and recompile and re-upload. +If your SIM card requires a user name and password to unlock (uncommon), enter those in as the `gprsUser` and `gprsPass` in the GPRS credentials section of the ino file and recompile and re-upload. Confirm that your wires between the Arduino and your modem are correct and you've set the correct port for `SerialAT` in the line `#define SerialMon Serial`. Confirm that your modem has power and that any expected LED's are lit. diff --git a/src/publishers/MonitorMyWatershedPublisher.h b/src/publishers/MonitorMyWatershedPublisher.h index 89da45bd4..f41aa8420 100644 --- a/src/publishers/MonitorMyWatershedPublisher.h +++ b/src/publishers/MonitorMyWatershedPublisher.h @@ -50,7 +50,7 @@ class MonitorMyWatershedPublisher : public dataPublisher { // Constructors /** * @brief Construct a new Monitor My Watershed Publisher object with only - * default values for the host, path, and port set.. + * default values for the host, path, and port set. */ MonitorMyWatershedPublisher(); /** @@ -239,7 +239,7 @@ class MonitorMyWatershedPublisher : public dataPublisher { bool connectionNeeded(void) override; /** - * @brief Utilize an attached modem to open a a TCP connection to Monitor My + * @brief Utilize an attached modem to open a TCP connection to Monitor My * Watershed and then stream out a post request over that connection. * * This depends on an internet connection already having been made and a diff --git a/src/publishers/UbidotsPublisher.h b/src/publishers/UbidotsPublisher.h index f383fa29e..64fe9194e 100644 --- a/src/publishers/UbidotsPublisher.h +++ b/src/publishers/UbidotsPublisher.h @@ -166,7 +166,7 @@ class UbidotsPublisher : public dataPublisher { // Post Data to Ubidots /** - * @brief Utilize an attached modem to open a a TCP connection to the + * @brief Utilize an attached modem to open a TCP connection to the * Ubidots API and then stream out a post request over * that connection. * diff --git a/src/sensors/ProcessorAnalog.cpp b/src/sensors/ProcessorAnalog.cpp index c8396bc83..a473039dc 100644 --- a/src/sensors/ProcessorAnalog.cpp +++ b/src/sensors/ProcessorAnalog.cpp @@ -1,5 +1,5 @@ /** - * @file ProcessorAnalog.cpp * + * @file ProcessorAnalog.cpp * @copyright Stroud Water Research Center * Part of the EnviroDIY ModularSensors library for Arduino. * This library is published under the BSD-3 license. From 68048d76e1dff1408b6f6e70751b8b210860e550 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Wed, 18 Feb 2026 17:49:11 -0500 Subject: [PATCH 223/533] Spelling errors Signed-off-by: Sara Damiano --- docs/Further-Reading/Sleep-Configurations.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/Further-Reading/Sleep-Configurations.md b/docs/Further-Reading/Sleep-Configurations.md index 62a030617..d1a2c6d6c 100644 --- a/docs/Further-Reading/Sleep-Configurations.md +++ b/docs/Further-Reading/Sleep-Configurations.md @@ -186,7 +186,7 @@ RESETN is a dedicated pin. > [!NOTE] > You can disable pin tri-state by calling `Logger::disablePinTristate(true)`. -> You can re-enable pin tri-strate by calling `Logger::disablePinTristate(false)`. +> You can re-enable pin tri-state by calling `Logger::disablePinTristate(false)`. > No pin modes are **not** changed when the `disablePinTristate()` function is called, only when the `systemSleep()` function is called. To prevent power draw by any external pins during sleep, Modular Sensors sets all pins except the RTC interrupt pins to "tri-state." Tri-state means that for *all* pins: @@ -205,7 +205,7 @@ To prevent power draw by any external pins during sleep, Modular Sensors sets al > [!NOTE] > You can disable disabling peripherals by calling `Logger::disablePeripheralShutdown(true)`. -> You can re-enable pin tri-strate by calling `Logger::disablePeripheralShutdown(false)`. +> You can re-enable pin tri-state by calling `Logger::disablePeripheralShutdown(false)`. > No peripheral settings are changed when the `disablePeripheralShutdown()` function is called, only when the `systemSleep()` function is called. To decrease power use during sleep on the SAMD51, Modular Sensors explicitly disconnects all unused peripherals from the various clocks and and clock sources to prevent them from "[sleepwalking](https://onlinedocs.microchip.com/oxy/GUID-F5813793-E016-46F5-A9E2-718D8BCED496-en-US-14/GUID-FA7D618C-0F98-4A2C-9D24-669C4A3E3CA3.html)". From 482c74979dece8670352467a6760110f84fa37e1 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Wed, 18 Feb 2026 17:51:43 -0500 Subject: [PATCH 224/533] check success after each call Signed-off-by: Sara Damiano --- src/sensors/TIINA219.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/sensors/TIINA219.cpp b/src/sensors/TIINA219.cpp index 1ce09dad5..dd88926a8 100644 --- a/src/sensors/TIINA219.cpp +++ b/src/sensors/TIINA219.cpp @@ -100,11 +100,14 @@ bool TIINA219::addSingleMeasurementResult(void) { // Read values current_mA = ina219_phy.getCurrent_mA(); + success = ina219_phy.success(); busV_V = ina219_phy.getBusVoltage_V(); - power_mW = ina219_phy.getPower_mW(); + success &= ina219_phy.success(); + power_mW = ina219_phy.getPower_mW(); + success &= ina219_phy.success(); // Only success if I2C read succeeded and none of the values are NaN - success = ina219_phy.success() && !isnan(current_mA) && !isnan(busV_V) && + success = success && !isnan(current_mA) && !isnan(busV_V) && !isnan(power_mW); MS_DBG(F(" Current [mA]:"), current_mA); From d7b9234bbeb919264126c1910039ed1d639ea624 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Wed, 18 Feb 2026 21:09:01 -0500 Subject: [PATCH 225/533] Update examples/AWS_IoT_Core/ReadMe.md Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --- examples/AWS_IoT_Core/ReadMe.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/AWS_IoT_Core/ReadMe.md b/examples/AWS_IoT_Core/ReadMe.md index 268c03b34..255667037 100644 --- a/examples/AWS_IoT_Core/ReadMe.md +++ b/examples/AWS_IoT_Core/ReadMe.md @@ -56,7 +56,7 @@ Make sure there are quotation marks around the name string, as there are in the ### Set your WiFi Credentials -Find and replace the text `YourWiFiSSID` with your wifi name (SSID) and `YourWiFiPassword` with your wifi password. +Find and replace the text `YourWiFiSSID` with your WiFi name (SSID) and `YourWiFiPassword` with your WiFi password. Make sure there are quotation marks around the name string, as there are in the example. ### Set your Variable UUIDs From 476854bf92c0138c33e3e4e42d605481302cc5e0 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Thu, 19 Feb 2026 11:17:51 -0500 Subject: [PATCH 226/533] Correct gain documentation Signed-off-by: Sara Damiano --- src/sensors/TurnerTurbidityPlus.h | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/sensors/TurnerTurbidityPlus.h b/src/sensors/TurnerTurbidityPlus.h index 3870f90d6..1e0c5a4b0 100644 --- a/src/sensors/TurnerTurbidityPlus.h +++ b/src/sensors/TurnerTurbidityPlus.h @@ -310,7 +310,15 @@ class TurnerTurbidityPlus : public Sensor { uint8_t _i2cAddress; /** * @brief The programmable gain amplification to set on the ADS 1x15, - * default is GAIN_DEFAULT (0). + * default is GAIN_ONE (+/-4.096V range = Gain 1). + * + * Other gain options are: + * GAIN_TWOTHIRDS = +/-6.144V range = Gain 2/3, + * GAIN_ONE = +/-4.096V range = Gain 1, + * GAIN_TWO = +/-2.048V range = Gain 2, + * GAIN_FOUR = +/-1.024V range = Gain 4, + * GAIN_EIGHT = +/-0.512V range = Gain 8, + * GAIN_SIXTEEN = +/-0.256V range = Gain 16 * * @todo Determine gain automatically based on the board voltage? */ @@ -423,4 +431,7 @@ class TurnerTurbidityPlus_Turbidity : public Variable { ~TurnerTurbidityPlus_Turbidity() {} }; /**@}*/ + +// cspell:words GAIN_TWOTHIRDS + #endif // SRC_SENSORS_TURNERTURBIDITYPLUS_H_ From cc1eeb8bb1d2925a6a3b019e6ffc0f2f80651c10 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Thu, 19 Feb 2026 11:20:02 -0500 Subject: [PATCH 227/533] Clarify datapin per CodeRabbit suggestion Signed-off-by: Sara Damiano --- src/sensors/ProcessorAnalog.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/sensors/ProcessorAnalog.h b/src/sensors/ProcessorAnalog.h index 1c7ec5607..b9072683c 100644 --- a/src/sensors/ProcessorAnalog.h +++ b/src/sensors/ProcessorAnalog.h @@ -171,9 +171,9 @@ class ProcessorAnalog : public Sensor { * * @param powerPin The pin on the mcu controlling power to the sensor * Use -1 if it is continuously powered. - * @param dataPin The processor ADC port pin to read the voltage from the EC - * probe. Not all processor pins can be used as analog pins. Those usable - * as analog pins generally are numbered with an "A" in front of the number + * @param dataPin The processor ADC pin used to read the target voltage. Not + * all processor pins can be used as analog pins. Those usable as analog + * pins generally are numbered with an "A" in front of the number * - ie, A1. * @param voltageMultiplier Any multiplier needed to convert raw battery * readings from `analogRead()` into true battery values based on any From 83c4bb4bee0f2a6cd5761af1c2fc8f70e575dd4d Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Thu, 19 Feb 2026 11:21:16 -0500 Subject: [PATCH 228/533] Update src/sensors/GeoluxHydroCam.cpp Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --- src/sensors/GeoluxHydroCam.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sensors/GeoluxHydroCam.cpp b/src/sensors/GeoluxHydroCam.cpp index 46039b8fb..4b961a482 100644 --- a/src/sensors/GeoluxHydroCam.cpp +++ b/src/sensors/GeoluxHydroCam.cpp @@ -234,7 +234,7 @@ bool GeoluxHydroCam::addSingleMeasurementResult(void) { // transfer the image from the camera to a file on the SD card MS_START_DEBUG_TIMER; bytes_transferred = _camera.transferImage(imgFile, image_size); - byte_error = abs(bytes_transferred - image_size); + byte_error = labs(bytes_transferred - image_size); // Close the image file after transfer imgFile.close(); From 08e651fa1cffb55e060f32d7e9cbea2149bef3bd Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Thu, 19 Feb 2026 11:23:59 -0500 Subject: [PATCH 229/533] Fix punctuation Signed-off-by: Sara Damiano --- extras/AWS_IoT_SetCertificates/ReadMe.md | 2 +- src/modems/Sodaq2GBeeR6.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/extras/AWS_IoT_SetCertificates/ReadMe.md b/extras/AWS_IoT_SetCertificates/ReadMe.md index 8c0e6cd66..030da64b2 100644 --- a/extras/AWS_IoT_SetCertificates/ReadMe.md +++ b/extras/AWS_IoT_SetCertificates/ReadMe.md @@ -124,7 +124,7 @@ In the section beginning with `// Select your modem:` remove the slashes (`//`) If you are using a cellular modem, find and replace the text `YourAPN` with the APN for your SIM card. Make sure there are quotation marks around the APN string, as there are in the example. -If you are using a Hologram SIM, use the text `hologram`.. +If you are using a Hologram SIM, use the text `hologram`. If you are using a WiFi modem, find and replace `YourWiFiSSID` and `YourWiFiPassword` with your real SSID and password. diff --git a/src/modems/Sodaq2GBeeR6.h b/src/modems/Sodaq2GBeeR6.h index 97dd50e45..e7116ce63 100644 --- a/src/modems/Sodaq2GBeeR6.h +++ b/src/modems/Sodaq2GBeeR6.h @@ -106,7 +106,7 @@ * @brief The loggerModem subclass for the [Sodaq 2GBee](@ref modem_gprsbee) * revisions 6 and higher based on the SIMCOM SIM800H. * - * @note The Sodaq GPRSBee doesn't expose the SIM800's reset pin.. + * @note The Sodaq GPRSBee doesn't expose the SIM800's reset pin. * * @note The power pin of the SIM800 is wired to the XBee's `DTR` pin, the * `PWR_KEY` itself is not exposed - it is tied inversely to the power in to the From a0ed61701305c6eb0bc524cde4bee9fec99a5411 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Thu, 19 Feb 2026 11:33:31 -0500 Subject: [PATCH 230/533] docs clarification Signed-off-by: Sara Damiano --- .../OutdatedExamples/DRWI_CitizenScience/DRWI_2G/ReadMe.md | 3 ++- .../DRWI_CitizenScience/DRWI_DigiLTE/ReadMe.md | 3 ++- .../DRWI_CitizenScience/DRWI_NoCellular/ReadMe.md | 3 ++- .../OutdatedExamples/simple_logging_LearnEnviroDIY/ReadMe.md | 2 +- examples/baro_rho_correction/ReadMe.md | 2 +- examples/double_logger/ReadMe.md | 2 +- examples/logging_to_MMW/ReadMe.md | 2 +- examples/simple_logging/ReadMe.md | 2 +- 8 files changed, 11 insertions(+), 8 deletions(-) diff --git a/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_2G/ReadMe.md b/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_2G/ReadMe.md index e214689ee..fe6673dfa 100644 --- a/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_2G/ReadMe.md +++ b/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_2G/ReadMe.md @@ -51,7 +51,8 @@ _______ ### Set the logger ID -- Change the "XXXX" in this section of code to the loggerID assigned by Stroud: +- Change the text `YourLoggerID` in this section of code to your loggerID. +For most DRWI installations, the logger ID was assigned by the Stroud Water Research Center before the station was built. ```cpp // Logger ID, also becomes the prefix for the name of the data file on SD card diff --git a/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_DigiLTE/ReadMe.md b/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_DigiLTE/ReadMe.md index 376ba3e5f..7b97957e9 100644 --- a/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_DigiLTE/ReadMe.md +++ b/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_DigiLTE/ReadMe.md @@ -53,7 +53,8 @@ _______ ### Set the logger ID -- Change the "XXXX" in this section of code to the loggerID assigned by Stroud: +- Change the text `YourLoggerID` in this section of code to your loggerID. +For most DRWI installations, the logger ID was assigned by the Stroud Water Research Center before the station was built. ```cpp // Logger ID, also becomes the prefix for the name of the data file on SD card diff --git a/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_NoCellular/ReadMe.md b/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_NoCellular/ReadMe.md index f03d99c2e..88c1d534d 100644 --- a/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_NoCellular/ReadMe.md +++ b/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_NoCellular/ReadMe.md @@ -56,7 +56,8 @@ _______ ### Set the logger ID -- Change the "XXXX" in this section of code to the loggerID assigned by Stroud: +- Change the text `YourLoggerID` in this section of code to your loggerID. +For most DRWI installations, the logger ID was assigned by the Stroud Water Research Center before the station was built. ```cpp // Logger ID, also becomes the prefix for the name of the data file on SD card diff --git a/examples/OutdatedExamples/simple_logging_LearnEnviroDIY/ReadMe.md b/examples/OutdatedExamples/simple_logging_LearnEnviroDIY/ReadMe.md index d4c813fef..67c2101f1 100644 --- a/examples/OutdatedExamples/simple_logging_LearnEnviroDIY/ReadMe.md +++ b/examples/OutdatedExamples/simple_logging_LearnEnviroDIY/ReadMe.md @@ -45,7 +45,7 @@ _______ ### Set the logger ID -- Change the "XXXX" in this section of code to the loggerID assigned by Stroud: +- Change the text `YourLoggerID` in this section of code to your loggerID or serial number: ```cpp // Logger ID, also becomes the prefix for the name of the data file on SD card diff --git a/examples/baro_rho_correction/ReadMe.md b/examples/baro_rho_correction/ReadMe.md index 9f33ac3e7..a9dc2a777 100644 --- a/examples/baro_rho_correction/ReadMe.md +++ b/examples/baro_rho_correction/ReadMe.md @@ -47,7 +47,7 @@ _______ ### Set the logger ID -- Change the "YourLoggerID" in this section of code to the loggerID assigned by Stroud: +- Change the text `YourLoggerID` in this section of code to your loggerID or serial number: ```cpp // Logger ID, also becomes the prefix for the name of the data file on SD card diff --git a/examples/double_logger/ReadMe.md b/examples/double_logger/ReadMe.md index 3641bcd5c..b63adfa69 100644 --- a/examples/double_logger/ReadMe.md +++ b/examples/double_logger/ReadMe.md @@ -46,7 +46,7 @@ _______ ### Set the logger ID -- Change the "YourLoggerID" in this section of code to the loggerID assigned by Stroud: +- Change the text `YourLoggerID` in this section of code to your loggerID or serial number: ```cpp // Logger ID, also becomes the prefix for the name of the data file on SD card diff --git a/examples/logging_to_MMW/ReadMe.md b/examples/logging_to_MMW/ReadMe.md index 91cac8ff2..386775649 100644 --- a/examples/logging_to_MMW/ReadMe.md +++ b/examples/logging_to_MMW/ReadMe.md @@ -49,7 +49,7 @@ _______ ### Set the logger ID -- Change the "YourLoggerID" in this section of code to the loggerID assigned by Stroud: +- Change the text `YourLoggerID` in this section of code to your loggerID or serial number: ```cpp // Logger ID, also becomes the prefix for the name of the data file on SD card diff --git a/examples/simple_logging/ReadMe.md b/examples/simple_logging/ReadMe.md index 937d8a05c..5a2d35275 100644 --- a/examples/simple_logging/ReadMe.md +++ b/examples/simple_logging/ReadMe.md @@ -40,7 +40,7 @@ _______ ### Set the logger ID -- Change the "XXXX" in this section of code to the loggerID assigned by Stroud: +- Change the text `YourLoggerID` in this section of code to your loggerID or serial number: ```cpp // Logger ID, also becomes the prefix for the name of the data file on SD card From e24291cc87263e00d75e46e2f44fad630e25d6df Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Thu, 19 Feb 2026 11:35:34 -0500 Subject: [PATCH 231/533] Doc fix Signed-off-by: Sara Damiano --- docs/Further-Reading/Sleep-Configurations.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/Further-Reading/Sleep-Configurations.md b/docs/Further-Reading/Sleep-Configurations.md index d1a2c6d6c..037723256 100644 --- a/docs/Further-Reading/Sleep-Configurations.md +++ b/docs/Further-Reading/Sleep-Configurations.md @@ -205,7 +205,7 @@ To prevent power draw by any external pins during sleep, Modular Sensors sets al > [!NOTE] > You can disable disabling peripherals by calling `Logger::disablePeripheralShutdown(true)`. -> You can re-enable pin tri-state by calling `Logger::disablePeripheralShutdown(false)`. +> You can re-enable peripheral shutdown by calling `Logger::disablePeripheralShutdown(false)`. > No peripheral settings are changed when the `disablePeripheralShutdown()` function is called, only when the `systemSleep()` function is called. To decrease power use during sleep on the SAMD51, Modular Sensors explicitly disconnects all unused peripherals from the various clocks and and clock sources to prevent them from "[sleepwalking](https://onlinedocs.microchip.com/oxy/GUID-F5813793-E016-46F5-A9E2-718D8BCED496-en-US-14/GUID-FA7D618C-0F98-4A2C-9D24-669C4A3E3CA3.html)". From 5ad20ffecc4aa1e9806bebd640f9de7d6b355406 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Thu, 19 Feb 2026 11:46:39 -0500 Subject: [PATCH 232/533] Fix conditional tree Signed-off-by: Sara Damiano --- src/SensorBase.cpp | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/src/SensorBase.cpp b/src/SensorBase.cpp index 77a589bc4..b4784667f 100644 --- a/src/SensorBase.cpp +++ b/src/SensorBase.cpp @@ -393,18 +393,17 @@ void Sensor::clearStatus(void) { // averaged void Sensor::verifyAndAddMeasurementResult(uint8_t resultNumber, float resultValue) { + bool prevResultGood = (sensorValues[resultNumber] != -9999 && + !isnan(sensorValues[resultNumber])); + bool newResultGood = (resultValue != -9999 && !isnan(resultValue)); // If the new result is good and there was were only bad results, set the // result value as the new result and add 1 to the good result total - if ((sensorValues[resultNumber] == -9999 || - isnan(sensorValues[resultNumber])) && - (resultValue != -9999 && !isnan(resultValue))) { + if (!prevResultGood && newResultGood) { MS_DBG(F("Putting"), resultValue, F("in result array for variable"), resultNumber, F("from"), getSensorNameAndLocation()); sensorValues[resultNumber] = resultValue; numberGoodMeasurementsMade[resultNumber] += 1; - } else if ((sensorValues[resultNumber] == -9999 || - isnan(sensorValues[resultNumber])) && - (resultValue != -9999 && !isnan(resultValue))) { + } else if (prevResultGood && newResultGood) { // If the new result is good and there were already good results in // place add the new results to the total and add 1 to the good result // total @@ -412,15 +411,14 @@ void Sensor::verifyAndAddMeasurementResult(uint8_t resultNumber, resultNumber, F("from"), getSensorNameAndLocation()); sensorValues[resultNumber] += resultValue; numberGoodMeasurementsMade[resultNumber] += 1; - } else if (sensorValues[resultNumber] == -9999 && resultValue == -9999) { - // If the new result is bad and there were only bad results, do nothing + } else if (!prevResultGood && !newResultGood) { + // If the new result is bad and there were only bad results, only print + // debugging MS_DBG(F("Ignoring bad result for variable"), resultNumber, F("from"), getSensorNameAndLocation(), F("; no good results yet.")); - } else if ((sensorValues[resultNumber] == -9999 || - isnan(sensorValues[resultNumber])) && - resultValue == -9999) { - // If the new result is bad and there were already good results, do - // nothing + } else if (prevResultGood && !newResultGood) { + // If the new result is bad and there were already good results, only + // print debugging MS_DBG(F("Ignoring bad result for variable"), resultNumber, F("from"), getSensorNameAndLocation(), F("; good results already in array.")); From 577b61278b10c2d05dba4e58ea50e7b067c8380b Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Thu, 19 Feb 2026 11:48:01 -0500 Subject: [PATCH 233/533] Doc fix Signed-off-by: Sara Damiano --- extras/AWS_IoT_SetCertificates/ReadMe.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/extras/AWS_IoT_SetCertificates/ReadMe.md b/extras/AWS_IoT_SetCertificates/ReadMe.md index 030da64b2..f7c2378bb 100644 --- a/extras/AWS_IoT_SetCertificates/ReadMe.md +++ b/extras/AWS_IoT_SetCertificates/ReadMe.md @@ -108,8 +108,8 @@ From the required files mentioned above, find and open the file that *ends with* As before, you need to see the file in a text editor and you may get a security warning when you open it. Once you have the file open, it should look like a bunch of random characters sandwiched between the lines `-----BEGIN RSA PRIVATE KEY-----` and `-----END RSA PRIVATE KEY-----`. -Find and replace the text `paste the private key here` with the text of your certificate. -Make sure that the text begins and ends with the lines `-----BEGIN RSA PRIVATE KEY-----` and `-----END RSA PRIVATE KEY-----` as it does in the example and in your certificate text. +Find and replace the text `paste the private key here` with the text of your private key. +Make sure that the text begins and ends with the lines `-----BEGIN RSA PRIVATE KEY-----` and `-----END RSA PRIVATE KEY-----` as it does in the example and in your private key. ### Customize the Set Certificates program From 2639f8114addf525ee0147dfef7ff9b7f8c08192 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Thu, 19 Feb 2026 13:09:29 -0500 Subject: [PATCH 234/533] Improve status bit clearing logic Signed-off-by: Sara Damiano --- ChangeLog.md | 2 +- src/SensorBase.cpp | 64 +++++++++++++++++++++++++++++++++---------- src/SensorBase.h | 29 ++++++++++++++++++++ src/VariableArray.cpp | 49 +++++++++++++++++++++++++-------- 4 files changed, 116 insertions(+), 28 deletions(-) diff --git a/ChangeLog.md b/ChangeLog.md index 35f4e96fa..28cc8336f 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -63,7 +63,7 @@ These values should generally be set in the specific sensor constructors and onl - `getStabilizationTime()` - `setMeasurementTime(uint32_t measurementTime_ms)` - `getMeasurementTime()` -- Added the function `Sensor::clearStatus()` which resets all status bits except setup and error and resets all timing values to 0. +- Added the functions `Sensor::clearStatus()`,`Sensor::clearPowerStatus()`,`Sensor::clearWakeStatus()`,and `Sensor::clearMeasurementStatus()` which reset some or all of the sensor status bits and related timing variables. - **NEW SENSOR** Added a new sensor for simple analog voltage using the built-in processor ADC - Added KnownProcessors.h and moved defines values for supported built-in sensors on known processors to that file. - This affects ProcessorStats and the Everlight ALS PT-19. diff --git a/src/SensorBase.cpp b/src/SensorBase.cpp index b4784667f..af14ea69a 100644 --- a/src/SensorBase.cpp +++ b/src/SensorBase.cpp @@ -374,18 +374,38 @@ void Sensor::clearValues(void) { _measurementAttemptsCompleted = 0; _retryAttemptsMade = 0; } +// This clears power-related status bits and resets power timing. +void Sensor::clearPowerStatus(void) { + // Reset power timing value + _millisPowerOn = 0; + // Unset power status bits + clearStatusBits(POWER_ATTEMPTED, POWER_SUCCESSFUL); +} + +// This clears wake-related status bits and resets wake timing. +void Sensor::clearWakeStatus(void) { + // Reset wake timing value + _millisSensorActivated = 0; + // Unset wake status bits + clearStatusBits(WAKE_ATTEMPTED, WAKE_SUCCESSFUL); +} + +// This clears measurement-related status bits and resets measurement timing. +void Sensor::clearMeasurementStatus(void) { + // Reset measurement timing values + _millisMeasurementRequested = 0; + _millisMeasurementCompleted = 0; + // Unset measurement status bits + clearStatusBits(MEASUREMENT_ATTEMPTED, MEASUREMENT_SUCCESSFUL); +} + // This clears all status bits except the setup and error bit and sets the // timing values to 0. void Sensor::clearStatus(void) { - // reset all timing values - _millisPowerOn = 0; - _millisSensorActivated = 0; - _millisMeasurementRequested = 0; - _millisMeasurementCompleted = 0; - // Unset all status bits except setup (bit 0) and error (bit 7) - clearStatusBits(POWER_ATTEMPTED, POWER_SUCCESSFUL, WAKE_ATTEMPTED, - WAKE_SUCCESSFUL, MEASUREMENT_ATTEMPTED, - MEASUREMENT_SUCCESSFUL); + // Use the individual clear functions for better maintainability + clearPowerStatus(); + clearWakeStatus(); + clearMeasurementStatus(); } @@ -455,16 +475,23 @@ void Sensor::averageMeasurements(void) { bool Sensor::update(void) { bool ret_val = true; - // clear all of the status bits and timing values at the start of an update - // cycle - clearStatus(); - - // Check if the power is on, turn it on if not + // Check if the sensor power is on, turn it on if not + // NOTE: The check power on function does **not** check the status bits or + // timing values to check if the power is on, but instead checks the actual + // state of the power pin(s) to determine if the power is on. This means + // it's safe to clear the power bits before running this check. The check + // function will correctly reset the bits as necessary. + clearPowerStatus(); bool wasOn = checkPowerOn(); if (!wasOn) { powerUp(); } - // Check if it's awake/active, activate it if not + // Check if sensor is awake/active, activate it if not + // We're checking the wake status bits here, so don't clear them before this + // check! bool wasActive = getStatusBit(WAKE_SUCCESSFUL); + + // NOTE: Don't clear the wake bits/timing! + if (!wasActive) { // NOT yet awake // wait for the sensor to have been powered for long enough to respond @@ -474,6 +501,13 @@ bool Sensor::update(void) { // bail if the wake failed if (!ret_val) return ret_val; + // Clear measurement related status bits and timing values before starting + // measurements + // NOTE: These bits are set and checked **after** starting a measurement to + // confirm that the measurement was actually started, so it's safe to clear + // them before starting a measurement. + clearMeasurementStatus(); + // Clear stale values and reset the measurement attempt and retry // counts before starting new measurements. clearValues(); diff --git a/src/SensorBase.h b/src/SensorBase.h index b83ee40ba..039799925 100644 --- a/src/SensorBase.h +++ b/src/SensorBase.h @@ -540,6 +540,35 @@ class Sensor { * cycle to clear any old values before beginning a cycle. */ void clearStatus(); + /** + * @brief Clears power-related status bits and resets power timing. + * + * This clears the POWER_ATTEMPTED and POWER_SUCCESSFUL status bits and + * resets the _millisPowerOn timing variable to 0. This is useful when + * you need to clear only the power-related status without affecting + * wake or measurement status. + */ + void clearPowerStatus(); + /** + * @brief Clears wake-related status bits and resets wake timing. + * + * This clears the WAKE_ATTEMPTED and WAKE_SUCCESSFUL status bits and + * resets the _millisSensorActivated timing variable to 0. This is useful + * when you need to clear only the wake-related status without affecting + * power or measurement status. + */ + void clearWakeStatus(); + /** + * @brief Clears measurement-related status bits and resets measurement + * timing. + * + * This clears the MEASUREMENT_ATTEMPTED and MEASUREMENT_SUCCESSFUL status + * bits and resets both _millisMeasurementRequested and + * _millisMeasurementCompleted timing variables to 0. This is useful when + * you need to clear only the measurement-related status without affecting + * power or wake status. + */ + void clearMeasurementStatus(); /** * @brief Verify that a measurement is OK (ie, not -9999) before adding it * to the result array diff --git a/src/VariableArray.cpp b/src/VariableArray.cpp index 0c4baefb8..6787df660 100644 --- a/src/VariableArray.cpp +++ b/src/VariableArray.cpp @@ -321,11 +321,43 @@ bool VariableArray::completeUpdate(bool powerUp, bool wake, bool sleep, } #endif - // Clear the timing and status bits - MS_DBG(F("----->> Clearing all timing and status bits before taking new " - "measurements. ...")); - for (uint8_t i = 0; i < _sensorCount; i++) { sensorList[i]->clearStatus(); } - MS_DBG(F(" ... Complete. <<-----")); + if (powerUp) { + // CLear power status bits before powering on. The powerUp function + // will check the actual power state of the sensor and set the bits + // accordingly, so it's safe to clear them here before powering up. + MS_DEEP_DBG( + F("----->> Clearing all power status bits before taking new " + "measurements. ...")); + for (uint8_t i = 0; i < _sensorCount; i++) { + sensorList[i]->clearPowerStatus(); + } + MS_DEEP_DBG(F(" ... Complete. <<-----")); + + // power up all of the sensors together + MS_DBG(F("----->> Powering up all sensors together. ...")); + sensorsPowerUp(); + MS_DBG(F(" ... Complete. <<-----")); + } + + // NOTE: Don't clear the wake bits/timing! If the power up function found + // the sensor wasn't powered, it will have cleared the wake bits. If we + // clear the wake bits here before checking them, then we won't be able to + // tell if the sensor was already awake before this function was called. If + // this function is called with wake=false (ie, expecting the sensors to + // have been awoken elsewhere), then we need to be able to check if the wake + // was successful before attempting readings, so we need to keep the wake + // bits intact. + + // Clear all measurement related status bits and timing values before + // starting measurements. NOTE: These bits are set and checked **after** + // starting a measurement to confirm that the measurement was actually + // started, so it's safe to clear them before starting a measurement. + MS_DEEP_DBG(F("----->> Clearing all measurement status bits before taking " + "new measurements. ...")); + for (uint8_t i = 0; i < _sensorCount; i++) { + sensorList[i]->clearMeasurementStatus(); + } + MS_DEEP_DBG(F(" ... Complete. <<-----")); // Clear the initial variable values arrays and reset the measurement // attempt and retry counts. @@ -334,13 +366,6 @@ bool VariableArray::completeUpdate(bool powerUp, bool wake, bool sleep, for (uint8_t i = 0; i < _sensorCount; i++) { sensorList[i]->clearValues(); } MS_DBG(F(" ... Complete. <<-----")); - // power up all of the sensors together - if (powerUp) { - MS_DBG(F("----->> Powering up all sensors together. ...")); - sensorsPowerUp(); - MS_DBG(F(" ... Complete. <<-----")); - } - while (nSensorsCompleted < _sensorCount) { for (uint8_t i = 0; i < _sensorCount; i++) { uint8_t nReq = sensorList[i]->getNumberMeasurementsToAverage(); From 6fe1af9d81722904e758292a3a81b95bf2b0141a Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Thu, 19 Feb 2026 13:41:30 -0500 Subject: [PATCH 235/533] Add comments to the loop to check if a sensor can power down - but did not extract to a new function to avoid either passing the sensor list object or recreating it in the sub-function Signed-off-by: Sara Damiano --- src/VariableArray.cpp | 38 ++++++++++++++++++++++++-------------- 1 file changed, 24 insertions(+), 14 deletions(-) diff --git a/src/VariableArray.cpp b/src/VariableArray.cpp index 6787df660..b86dcf589 100644 --- a/src/VariableArray.cpp +++ b/src/VariableArray.cpp @@ -505,23 +505,32 @@ bool VariableArray::completeUpdate(bool powerUp, bool wake, bool sleep, bool canPowerDown = true; // assume we can power down // unless we find a conflict for (uint8_t k = 0; k < _sensorCount; k++) { - if (((sensorList[i]->getPowerPin() >= 0 && - (sensorList[i]->getPowerPin() == - sensorList[k]->getPowerPin() || - sensorList[i]->getPowerPin() == - sensorList[k]->getSecondaryPowerPin())) || - (sensorList[i]->getSecondaryPowerPin() >= 0 && - (sensorList[i]->getSecondaryPowerPin() == - sensorList[k]->getPowerPin() || - sensorList[i]->getSecondaryPowerPin() == - sensorList[k]->getSecondaryPowerPin()))) && + if (( + // Check if sensor i's primary pin matches + // either of sensor k's pins + (sensorList[i]->getPowerPin() >= 0 && + (sensorList[i]->getPowerPin() == + sensorList[k]->getPowerPin() || + sensorList[i]->getPowerPin() == + sensorList[k]->getSecondaryPowerPin())) + // Check if sensor i's secondary pin matches + // either of sensor k's pins + || + (sensorList[i]->getSecondaryPowerPin() >= 0 && + (sensorList[i]->getSecondaryPowerPin() == + sensorList[k]->getPowerPin() || + sensorList[i]->getSecondaryPowerPin() == + sensorList[k]->getSecondaryPowerPin()))) + // Check if sensor k still needs measurements + && (sensorList[k] ->getNumberCompleteMeasurementsAttempts() < sensorList[k]->getNumberMeasurementsToAverage())) { - canPowerDown = false; // another sensor on this pin - // still needs to take - // measurements - break; + // If sensors i and k share a primary power pin or a + // secondary power pin and sensor k still needs + // measurements, sensor i can't be powered down + canPowerDown = false; + break; // stop looping after finding a conflict } } if (canPowerDown) { sensorList[i]->powerDown(); } @@ -540,6 +549,7 @@ bool VariableArray::completeUpdate(bool powerUp, bool wake, bool sleep, "power pin still need to take measurements. " "Leaving power on pin"), sensorList[i]->getPowerPin(), F("ON. <<---")); + // Find and report which sensor still needs measurements for (uint8_t k = 0; k < _sensorCount; k++) { if (((sensorList[i]->getPowerPin() >= 0 && (sensorList[i]->getPowerPin() == From cee34eb04fd3abdb94e3295b67c31869a435e836 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Thu, 19 Feb 2026 14:03:47 -0500 Subject: [PATCH 236/533] Update docs Signed-off-by: Sara Damiano --- src/SensorBase.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/SensorBase.h b/src/SensorBase.h index 039799925..711143226 100644 --- a/src/SensorBase.h +++ b/src/SensorBase.h @@ -738,8 +738,8 @@ class Sensor { */ uint8_t _measurementsToAverage; /** - * @brief The number of measurements attempts by the sensor that have - * finished **since last power on**. + * @brief The number of measurement attempts completed in the current update + * cycle (reset by clearValues()). */ uint8_t _measurementAttemptsCompleted = 0; /** From eef1a9695793563581da244afb206432246d6708 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Thu, 19 Feb 2026 14:06:21 -0500 Subject: [PATCH 237/533] Scale max pressure to model Signed-off-by: Sara Damiano --- src/sensors/MeaSpecMS5803.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sensors/MeaSpecMS5803.cpp b/src/sensors/MeaSpecMS5803.cpp index c87a8ed41..7521c396a 100644 --- a/src/sensors/MeaSpecMS5803.cpp +++ b/src/sensors/MeaSpecMS5803.cpp @@ -76,7 +76,7 @@ bool MeaSpecMS5803::addSingleMeasurementResult(void) { MS_DBG(F(" Pressure:"), press); if (!isnan(temp) && !isnan(press) && temp >= -40.0 && temp <= 85.0 && - press > 0.0 && press <= 14000.0) { + press > 0.0 && press <= (_maxPressure * 1000.0)) { // Temperature Range is -40°C to +85°C // Pressure returns 0 when disconnected, which is highly unlikely to be // a real value. From 7e57479cae79d29543667d128da22936ea9e8fb4 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Thu, 19 Feb 2026 14:06:42 -0500 Subject: [PATCH 238/533] Update src/sensors/TurnerTurbidityPlus.cpp Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --- src/sensors/TurnerTurbidityPlus.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sensors/TurnerTurbidityPlus.cpp b/src/sensors/TurnerTurbidityPlus.cpp index e8492f110..f72436006 100644 --- a/src/sensors/TurnerTurbidityPlus.cpp +++ b/src/sensors/TurnerTurbidityPlus.cpp @@ -104,7 +104,7 @@ bool TurnerTurbidityPlus::addSingleMeasurementResult(void) { // Create an auxiliary ADC object // We create and set up the ADC object here so that each sensor using the ADC -// may set the gain appropriately without effecting others. +// may set the gain appropriately without affecting others. #ifndef MS_USE_ADS1015 Adafruit_ADS1115 ads; // Use this for the 16-bit version #else From 229678f903ed0129060ac362428fb58e3b0cb3c9 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Thu, 19 Feb 2026 14:28:53 -0500 Subject: [PATCH 239/533] Update developer instructions, create git filter setup scripts via AI Signed-off-by: Sara Damiano --- README.md | 2 +- docs/For-Developers/Developer-Setup.md | 186 +++++++++++++++---------- setupGitFilters.bat | 24 ++++ setupGitFilters.ps1 | 21 +++ 4 files changed, 159 insertions(+), 74 deletions(-) create mode 100644 setupGitFilters.bat create mode 100644 setupGitFilters.ps1 diff --git a/README.md b/README.md index 00d9cc6e6..81f0371f2 100644 --- a/README.md +++ b/README.md @@ -150,7 +150,7 @@ For information common to all modems and for tables of the proper class, baud ra Open an [issue](https://github.com/EnviroDIY/ModularSensors/issues) to suggest and discuss potential changes/additions. Feel free to open issues about any bugs you find or any sensors you would like to have added. -If you would like to directly help with the coding development of the library, there are some [tips here](https://envirodiy.github.io/ModularSensors/page_developer_setup.html) on how to set up PlatformIO so you can fork the library and test programs while in the library repo. +If you would like to directly help with the coding development of the library, there are some [tips and instructions here](https://envirodiy.github.io/ModularSensors/page_developer_setup.html) on how to set up PlatformIO so you can fork the library and test programs while in the library repo. Please *take time to familiarize yourself with the [terminology, classes and data structures](https://envirodiy.github.io/ModularSensors/page_library_terminology.html) this library uses*. This library is built to fully take advantage of Objecting Oriented Programing (OOP) approaches and is larger and more complicated than many Arduino libraries. There is doxygen-created documentation on our [github pages](https://envirodiy.github.io/ModularSensors/index.html) and an *enormous* number of comments and debugging printouts in the code itself to help you get going. diff --git a/docs/For-Developers/Developer-Setup.md b/docs/For-Developers/Developer-Setup.md index 72ac68cd6..0e0463f67 100644 --- a/docs/For-Developers/Developer-Setup.md +++ b/docs/For-Developers/Developer-Setup.md @@ -1,17 +1,63 @@ # Developer Setup + + + + + + +- [Developer Setup](#developer-setup) + - [Git Filter Setup](#git-filter-setup) + - [PlatformIO Setup](#platformio-setup) + - [Debugging](#debugging) + + + If you want to fork this repository and work with it, you'll need to set PlatformIO up a bit differently than you would to merely use this library. First, fork this repository into your own GitHub space. Clone it to your local computer. +## Git Filter Setup + +This repository uses Git filters to manage sensitive credentials and debug configurations. After cloning the repository, run one of the following setup scripts to configure the necessary Git filter drivers: + +**Windows Command Prompt:** +```batch +setupGitFilters.bat +``` + +**PowerShell:** +```powershell +.\setupGitFilters.ps1 +``` + +**Manual Setup:** +If you prefer to configure the filters manually, run these Git commands from the repository root: +```bash +git config --local filter.smudgePasswords.clean "powershell -ExecutionPolicy Bypass -File filters/cleanPasswords.ps1" +git config --local filter.smudgePasswords.smudge "powershell -ExecutionPolicy Bypass -File filters/smudgePasswords.ps1" +git config --local filter.disableDebug.clean "powershell -ExecutionPolicy Bypass -File filters/cleanDebugConfig.ps1" +git config --local filter.disableDebug.smudge "powershell -ExecutionPolicy Bypass -File filters/smudgeDebugConfig.ps1" +``` + +These filters provide the following functionality: +- **smudgePasswords** - Manages placeholder credentials in `.ino` example files during development and commits +- **disableDebug** - Automatically manages debug defines in `ModSensorDebugConfig.h` to keep them disabled in commits but enabled locally + + +## PlatformIO Setup + +The Arduino IDE is not a good tool for library development. +Use PlatformIO in VSCode instead. + Open the folder you've cloned this repo into with VSCode. Have PlatformIO create a new project for you, but instead of allowing it to create a new folder, select the folder you've already cloned this repo into. -Create a new source program to work with in a new directory. +Create a new source program to work with in a new directory (ie, a tests directory). This is the directory you should reference in the `src_dir` line of your platformio.ini. _Also add this directory to your .gitignore file_ so you can test and play with your code without publishing personal passwords or other messiness to the web. -I recommend you start with one of the programs in the compile_tests folder rather than one of the examples because the compiler test programs are _much_ more extensive and include all sensors and many modems in them. +I recommend you start with the menu a la carte example for development since it already contains all features and is tested for proper compilation with continuous integration tools. Set your platformio.ini configuration file up like this: @@ -30,64 +76,86 @@ src_dir = your_directory/your_source_code ; Default baud for all examples monitor_speed = 115200 framework = arduino -; To run code checks; cppcheck and clangtidy must be installed -check_tool = cppcheck, clangtidy -check_patterns = +; To run code checks; clangtidy must be installed +check_tool = clangtidy +check_src_filters = src extras examples check_flags = - cppcheck: --enable=all, --inline-suppr clangtidy: --checks=-* +check_skip_packages = yes ; deep search for dependencies, evaluating preprocessor conditionals lib_ldf_mode = deep+ +lib_compat_mode = soft ; look for the library directory lib_extra_dirs = . +; All these library dependencies must be listed out since we're in the library +; source code and won't read the dependencies from the library.json like a +; typical user would +lib_deps = + Adafruit BusIO=symlink://C:\Users\sdamiano\Documents\GitHub\EnviroDIY\ModularSensors\lib\Adafruit BusIO + Adafruit GFX Library=symlink://C:\Users\sdamiano\Documents\GitHub\EnviroDIY\ModularSensors\lib\Adafruit GFX Library + Adafruit MPL115A2=symlink://C:\Users\sdamiano\Documents\GitHub\EnviroDIY\ModularSensors\lib\Adafruit MPL115A2 + Adafruit NeoPixel=symlink://C:\Users\sdamiano\Documents\GitHub\EnviroDIY\ModularSensors\lib\Adafruit NeoPixel + Adafruit SH110X=symlink://C:\Users\sdamiano\Documents\GitHub\EnviroDIY\ModularSensors\lib\Adafruit SH110X + Adafruit SSD1306=symlink://C:\Users\sdamiano\Documents\GitHub\EnviroDIY\ModularSensors\lib\Adafruit SSD1306 + Adafruit Unified Sensor=symlink://C:\Users\sdamiano\Documents\GitHub\EnviroDIY\ModularSensors\lib\Adafruit Unified Sensor + AltSoftSerial=symlink://C:\Users\sdamiano\Documents\GitHub\EnviroDIY\ModularSensors\lib\AltSoftSerial + BMP388_DEV=symlink://C:\Users\sdamiano\Documents\GitHub\EnviroDIY\ModularSensors\lib\BMP388_DEV + DHT sensor library=symlink://C:\Users\sdamiano\Documents\GitHub\EnviroDIY\ModularSensors\lib\DHT sensor library + EnableInterrupt=symlink://C:\Users\sdamiano\Documents\GitHub\EnviroDIY\ModularSensors\lib\EnableInterrupt + EnviroDIY_DS3231=symlink://C:\Users\sdamiano\Documents\GitHub\EnviroDIY\ModularSensors\lib\EnviroDIY_DS3231 + GeoluxCamera=symlink://C:\Users\sdamiano\Documents\GitHub\EnviroDIY\ModularSensors\lib\GeoluxCamera + MS5803=symlink://C:\Users\sdamiano\Documents\GitHub\EnviroDIY\ModularSensors\lib\MS5803 + NeoSWSerial=symlink://C:\Users\sdamiano\Documents\GitHub\EnviroDIY\ModularSensors\lib\NeoSWSerial + OneWire=symlink://C:\Users\sdamiano\Documents\GitHub\EnviroDIY\ModularSensors\lib\OneWire + PubSubClient=symlink://C:\Users\sdamiano\Documents\GitHub\EnviroDIY\ModularSensors\lib\PubSubClient + RTCZero=symlink://C:\Users\sdamiano\Documents\GitHub\EnviroDIY\ModularSensors\lib\RTCZero + SDI-12=symlink://C:\Users\sdamiano\Documents\GitHub\EnviroDIY\ModularSensors\lib\SDI-12 + SDI-12_ExtInts=symlink://C:\Users\sdamiano\Documents\GitHub\EnviroDIY\ModularSensors\lib\SDI-12_ExtInts + SdFat=symlink://C:\Users\sdamiano\Documents\GitHub\EnviroDIY\ModularSensors\lib\SdFat + SensorModbusMaster=symlink://C:\Users\sdamiano\Documents\GitHub\EnviroDIY\ModularSensors\lib\SensorModbusMaster + SoftwareSerial_ExternalInts=symlink://C:\Users\sdamiano\Documents\GitHub\EnviroDIY\ModularSensors\lib\SoftwareSerial_ExternalInts + SoftwareWire=symlink://C:\Users\sdamiano\Documents\GitHub\EnviroDIY\ModularSensors\lib\SoftwareWire + SparkFun Qwiic RTC RV8803 Arduino Library=symlink://C:\Users\sdamiano\Documents\GitHub\EnviroDIY\ModularSensors\lib\SparkFun Qwiic RTC RV8803 Arduino Library + StreamDebugger=symlink://C:\Users\sdamiano\Documents\GitHub\EnviroDIY\ModularSensors\lib\StreamDebugger + Tally_Library_I2C=symlink://C:\Users\sdamiano\Documents\GitHub\EnviroDIY\ModularSensors\lib\Tally_Library_I2C + TinyGSM=symlink://C:\Users\sdamiano\Documents\GitHub\EnviroDIY\ModularSensors\lib\TinyGSM + YosemitechModbus=symlink://C:\Users\sdamiano\Documents\GitHub\EnviroDIY\ModularSensors\lib\YosemitechModbus + fast_math=symlink://C:\Users\sdamiano\Documents\GitHub\EnviroDIY\ModularSensors\lib\fast_math + ANBSensorsModbus=symlink://C:\Users\sdamiano\Documents\GitHub\EnviroDIY\ModularSensors\lib\ANBSensorsModbus + Adafruit ADS1X15=symlink://C:\Users\sdamiano\Documents\GitHub\EnviroDIY\ModularSensors\lib\Adafruit ADS1X15 + Adafruit AM2315=symlink://C:\Users\sdamiano\Documents\GitHub\EnviroDIY\ModularSensors\lib\Adafruit AM2315 + Adafruit BME280 Library=symlink://C:\Users\sdamiano\Documents\GitHub\EnviroDIY\ModularSensors\lib\Adafruit BME280 Library + Adafruit INA219=symlink://C:\Users\sdamiano\Documents\GitHub\EnviroDIY\ModularSensors\lib\Adafruit INA219 + Adafruit SHT4x Library=symlink://C:\Users\sdamiano\Documents\GitHub\EnviroDIY\ModularSensors\lib\Adafruit SHT4x Library + DallasTemperature=symlink://C:\Users\sdamiano\Documents\GitHub\EnviroDIY\ModularSensors\lib\DallasTemperature + GroPointModbus=symlink://C:\Users\sdamiano\Documents\GitHub\EnviroDIY\ModularSensors\lib\GroPointModbus + KellerModbus=symlink://C:\Users\sdamiano\Documents\GitHub\EnviroDIY\ModularSensors\lib\KellerModbus ; We have to ignore these folders or PlatformIO will double count all the dependencies lib_ignore = .git + .github + .history .pio .vscode - doc + archive + continuous_integration + docs examples - sensor_tests extras - Adafruit NeoPixel + ex_one_offs + filters + sensor_tests + tests Adafruit GFX Library + Adafruit SH110X Adafruit SSD1306 Adafruit ADXL343 Adafruit STMPE610 Adafruit TouchScreen Adafruit ILI9341 -; All these library dependencies must be listed out since we're in the library -; source code and won't read the dependencies from the library.json like a -; typical user would -lib_deps = - envirodiy/EnviroDIY_DS3231 - arduino-libraries/RTCZero - greygnome/EnableInterrupt - greiman/SdFat - vshymanskyy/TinyGSM - knolleary/PubSubClient - adafruit/Adafruit BusIO - adafruit/Adafruit Unified Sensor - https://github.com/soligen2010/Adafruit_ADS1X15.git - adafruit/Adafruit AM2315 - adafruit/Adafruit BME280 Library - adafruit/DHT sensor library - adafruit/Adafruit INA219 - adafruit/Adafruit MPL115A2 - adafruit/Adafruit SHT4x Library - MartinL1/BMP388_DEV - paulstoffregen/OneWire - milesburton/DallasTemperature - envirodiy/SDI-12 - northernwidget/MS5803 - https://github.com/EnviroDIY/Tally_Library.git#Dev_I2C - envirodiy/SensorModbusMaster - envirodiy/KellerModbus - envirodiy/YosemitechModbus - https://github.com/EnviroDIY/StreamDebugger.git ; The directories for the ModularSensors library source code src_filter = +<*> @@ -100,13 +168,10 @@ src_filter = +<../../src/utils> ; Some common build flags build_flags = + -Wall + -Wextra -D SDI12_EXTERNAL_PCINT -D NEOSWSERIAL_EXTERNAL_PCINT - -D MQTT_MAX_PACKET_SIZE=240 - -D TINY_GSM_RX_BUFFER=64 - -D TINY_GSM_YIELD_MS=2 -extra_scripts = pre:pioScripts/generate_compile_commands.py -targets = compiledb [env:mayfly] ; Find your COM port, enter it here, and remove the semicolon at the start of the line @@ -126,41 +191,16 @@ lib_ignore = ${env.lib_ignore} RTCZero Adafruit Zero DMA Library + SDI-12_ExtInts + Adafruit TinyUSB Library + ESP8266SdFat ; Any extra build flags you want build_flags = ${env.build_flags} - -D STANDARD_SERIAL_OUTPUT=Serial - -D DEBUGGING_SERIAL_OUTPUT=Serial - -D DEEP_DEBUGGING_SERIAL_OUTPUT=Serial -; when I'm uploading frequently, I disable verification of the write -upload_flags = - -V - - -[env:adafruit_feather_m0] -; Find your COM port, enter it here, and remove the semicolon at the start of the line -; upload_port = COM## -; monitor_port = COM## -platform = atmelsam -board = adafruit_feather_m0 -framework = arduino -; SAMD boards need RTCZero for the real time clock and sleeping -lib_deps = - ${env.lib_deps} - RTCZero -; Most of the software serial libraries won't compile. -; Use the SERCOM's; they're better anyway -lib_ignore = - ${env.lib_ignore} - SoftwareSerial_ExtInts - AltSoftSerial - NeoSWSerial - SoftwareWire -build_flags = - ${env.build_flags} -build_unflags = -D USE_TINYUSB ``` +## Debugging + While you're working on development, there is _extensive_ debugging text built into this library. More on that is in the [Code Debugging](https://github.com/EnviroDIY/ModularSensors/wiki/Code-Debugging) page. In fact, there is _so much_ debugging that turning it on universally through a build flag will cause the program to be too big to fit on a Mayfly and will likely crash a SAMD board's on-board USB drivers. diff --git a/setupGitFilters.bat b/setupGitFilters.bat new file mode 100644 index 000000000..fb37779a6 --- /dev/null +++ b/setupGitFilters.bat @@ -0,0 +1,24 @@ +@echo off +REM Setup script for Git filter drivers used in ModularSensors +REM This configures the smudgePasswords and disableDebug filters referenced in .gitattributes + +echo Setting up Git filter drivers for ModularSensors... + +REM Configure the smudgePasswords filter for .ino files +echo Configuring smudgePasswords filter... +git config --local filter.smudgePasswords.clean "powershell -ExecutionPolicy Bypass -File filters/cleanPasswords.ps1" +git config --local filter.smudgePasswords.smudge "powershell -ExecutionPolicy Bypass -File filters/smudgePasswords.ps1" + +REM Configure the disableDebug filter for ModSensorDebugConfig.h +echo Configuring disableDebug filter... +git config --local filter.disableDebug.clean "powershell -ExecutionPolicy Bypass -File filters/cleanDebugConfig.ps1" +git config --local filter.disableDebug.smudge "powershell -ExecutionPolicy Bypass -File filters/smudgeDebugConfig.ps1" + +echo. +echo Git filter drivers have been successfully configured! +echo. +echo Filters configured: +echo smudgePasswords - Manages credentials in .ino files +echo disableDebug - Manages debug defines in ModSensorDebugConfig.h +echo. +echo You may need to run "git checkout HEAD -- ." to apply filters to existing files. diff --git a/setupGitFilters.ps1 b/setupGitFilters.ps1 new file mode 100644 index 000000000..4e8bfbc5c --- /dev/null +++ b/setupGitFilters.ps1 @@ -0,0 +1,21 @@ +#!/usr/bin/env powershell +# Setup script for Git filter drivers used in ModularSensors +# This configures the smudgePasswords and disableDebug filters referenced in .gitattributes + +Write-Host "Setting up Git filter drivers for ModularSensors..." -ForegroundColor Green + +# Configure the smudgePasswords filter for .ino files +Write-Host "Configuring smudgePasswords filter..." -ForegroundColor Yellow +git config --local filter.smudgePasswords.clean "powershell -ExecutionPolicy Bypass -File filters/cleanPasswords.ps1" +git config --local filter.smudgePasswords.smudge "powershell -ExecutionPolicy Bypass -File filters/smudgePasswords.ps1" + +# Configure the disableDebug filter for ModSensorDebugConfig.h +Write-Host "Configuring disableDebug filter..." -ForegroundColor Yellow +git config --local filter.disableDebug.clean "powershell -ExecutionPolicy Bypass -File filters/cleanDebugConfig.ps1" +git config --local filter.disableDebug.smudge "powershell -ExecutionPolicy Bypass -File filters/smudgeDebugConfig.ps1" + +Write-Host "`nGit filter drivers have been successfully configured!" -ForegroundColor Green +Write-Host "`nFilters configured:" -ForegroundColor Cyan +Write-Host " smudgePasswords - Manages credentials in .ino files" -ForegroundColor White +Write-Host " disableDebug - Manages debug defines in ModSensorDebugConfig.h" -ForegroundColor White +Write-Host "`nYou may need to run 'git checkout HEAD -- .' to apply filters to existing files." -ForegroundColor Magenta From aa2afc184d148b85bc29ffde7751920071a3555c Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Thu, 19 Feb 2026 14:35:28 -0500 Subject: [PATCH 240/533] Update gitattributes to ignore setup scripts Signed-off-by: Sara Damiano --- .gitattributes | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.gitattributes b/.gitattributes index 95ddeb819..5ea14825c 100644 --- a/.gitattributes +++ b/.gitattributes @@ -27,6 +27,10 @@ .travis.yml export-ignore id_rsa.enc export-ignore +# Setup scripts +setupGitFilters.bat export-ignore +setupGitFilters.ps1 export-ignore + # Platformio platformio.ini export-ignore From c57d6e603ce7b4cacf1311312a484ab1bd1be148 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Thu, 19 Feb 2026 14:42:23 -0500 Subject: [PATCH 241/533] AI fix some CodeRabbit complaints Signed-off-by: Sara Damiano --- src/publishers/MonitorMyWatershedPublisher.cpp | 6 ++++++ src/publishers/MonitorMyWatershedPublisher.h | 10 ++++++++++ src/sensors/ANBpH.cpp | 2 +- src/sensors/MaxBotixSonar.cpp | 2 +- src/sensors/TurnerTurbidityPlus.cpp | 2 +- 5 files changed, 19 insertions(+), 3 deletions(-) diff --git a/src/publishers/MonitorMyWatershedPublisher.cpp b/src/publishers/MonitorMyWatershedPublisher.cpp index 004917805..e30afae85 100644 --- a/src/publishers/MonitorMyWatershedPublisher.cpp +++ b/src/publishers/MonitorMyWatershedPublisher.cpp @@ -143,6 +143,12 @@ uint16_t MonitorMyWatershedPublisher::calculateJsonSize() { MS_DBG(F("Number of variables in base logger:"), _baseLogger->getArrayVarCount()); + // Guard against underflow when records == 0 + if (records == 0) { + MS_DBG(F("No records to send, returning minimal JSON size")); + return 50; // Minimal size for empty JSON structure + } + uint16_t jsonLength = strlen(samplingFeatureTag); jsonLength += 36; // sampling feature UUID jsonLength += strlen(timestampTag); diff --git a/src/publishers/MonitorMyWatershedPublisher.h b/src/publishers/MonitorMyWatershedPublisher.h index f41aa8420..a8d6e6042 100644 --- a/src/publishers/MonitorMyWatershedPublisher.h +++ b/src/publishers/MonitorMyWatershedPublisher.h @@ -158,6 +158,11 @@ class MonitorMyWatershedPublisher : public dataPublisher { /** * @brief Set the Monitor My Watershed web host * + * @warning The caller must guarantee that the passed C-string remains + * valid for the lifetime of this object or until another call to setHost(). + * Do not pass temporary strings or stack-allocated C-strings that may + * be destroyed before all publish calls are complete. + * * @param host The Monitor My Watershed web host */ void setHost(const char* host); @@ -171,6 +176,11 @@ class MonitorMyWatershedPublisher : public dataPublisher { /** * @brief Set the Monitor My Watershed API path * + * @warning The caller must guarantee that the passed C-string remains + * valid for the lifetime of this object or until another call to setPath(). + * Do not pass temporary strings or stack-allocated C-strings that may + * be destroyed before all publish calls are complete. + * * @param endpoint The Monitor My Watershed API path */ void setPath(const char* endpoint); diff --git a/src/sensors/ANBpH.cpp b/src/sensors/ANBpH.cpp index c02d03af5..90be38267 100644 --- a/src/sensors/ANBpH.cpp +++ b/src/sensors/ANBpH.cpp @@ -609,7 +609,7 @@ bool ANBpH::setSensorRTC() { int8_t day = -1; int8_t month = -1; int16_t year = -1; - uint8_t tz_offset = -1; + uint8_t tz_offset = 0; // Neutral value, will be overwritten by getNowParts Logger::getNowParts(seconds, minutes, hours, day, month, year, tz_offset); #if defined(MS_ANB_SENSORS_PH_DEBUG_DEEP) char time_buff_l[20] = {'\0'}; diff --git a/src/sensors/MaxBotixSonar.cpp b/src/sensors/MaxBotixSonar.cpp index e27cd02a9..894d13bb3 100644 --- a/src/sensors/MaxBotixSonar.cpp +++ b/src/sensors/MaxBotixSonar.cpp @@ -152,7 +152,7 @@ bool MaxBotixSonar::addSingleMeasurementResult(void) { MS_DBG(getSensorNameAndLocation(), F("is reporting:")); uint8_t rangeAttempts = 0; - while (success == false && rangeAttempts < 25) { + while (!success && rangeAttempts < 25) { /// @todo unify retries with other sensors? // If the sonar is running on a trigger, activating the trigger // should in theory happen within the startSingleMeasurement diff --git a/src/sensors/TurnerTurbidityPlus.cpp b/src/sensors/TurnerTurbidityPlus.cpp index e8492f110..f72436006 100644 --- a/src/sensors/TurnerTurbidityPlus.cpp +++ b/src/sensors/TurnerTurbidityPlus.cpp @@ -104,7 +104,7 @@ bool TurnerTurbidityPlus::addSingleMeasurementResult(void) { // Create an auxiliary ADC object // We create and set up the ADC object here so that each sensor using the ADC -// may set the gain appropriately without effecting others. +// may set the gain appropriately without affecting others. #ifndef MS_USE_ADS1015 Adafruit_ADS1115 ads; // Use this for the 16-bit version #else From 907fa131846d8139cd11e9df49cd6c0f914f8c23 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Thu, 19 Feb 2026 15:08:59 -0500 Subject: [PATCH 242/533] Clean/smudge APN Signed-off-by: Sara Damiano --- .../EnviroDIY_Monitoring_Kit/EnviroDIY_Monitoring_Kit.ino | 2 +- examples/EnviroDIY_Monitoring_Kit/ReadMe.md | 6 +++--- examples/menu_a_la_carte/menu_a_la_carte.ino | 2 +- extras/LTExBee_FirstConnection/LTExBee_FirstConnection.ino | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/examples/EnviroDIY_Monitoring_Kit/EnviroDIY_Monitoring_Kit.ino b/examples/EnviroDIY_Monitoring_Kit/EnviroDIY_Monitoring_Kit.ino index 3774f5951..b466b4790 100644 --- a/examples/EnviroDIY_Monitoring_Kit/EnviroDIY_Monitoring_Kit.ino +++ b/examples/EnviroDIY_Monitoring_Kit/EnviroDIY_Monitoring_Kit.ino @@ -33,7 +33,7 @@ // Add your network information here. // APN for cellular connection -#define CELLULAR_APN "add_your_cellular_apn" +#define CELLULAR_APN "YourAPN" // WiFi access point name #define WIFI_ID "YourWiFiSSID" // WiFi password (WPA2) diff --git a/examples/EnviroDIY_Monitoring_Kit/ReadMe.md b/examples/EnviroDIY_Monitoring_Kit/ReadMe.md index 64bbcb175..086c866cc 100644 --- a/examples/EnviroDIY_Monitoring_Kit/ReadMe.md +++ b/examples/EnviroDIY_Monitoring_Kit/ReadMe.md @@ -87,10 +87,10 @@ In the configuration section, select no more than one of the "bee" types that yo #### Add Connection Info -Replace the `Your..` with the appropriate APN or SSID and password for your network. +Replace `YourAPN` or `YourWiFiSSID` and `YourWiFiPassword` with the appropriate APN or SSID and password for your network. Your APN is assigned by your SIM card provider. -If you are using a Hologram SIM card (recommended with the kit) the APN is `"hologram"`. +If you are using a Hologram SIM card (recommended with the kit) the APN is `hologram`. The SSID is the name of the wifi network. @@ -102,7 +102,7 @@ You can leave the configuration for the connection type you're not using as is. ```cpp // APN for cellular connection -#define CELLULAR_APN "add_your_cellular_apn" +#define CELLULAR_APN "YourAPN" // WiFi access point name #define WIFI_ID "YourWiFiSSID" // WiFi password (WPA2) diff --git a/examples/menu_a_la_carte/menu_a_la_carte.ino b/examples/menu_a_la_carte/menu_a_la_carte.ino index f47a122bc..4eb143a10 100644 --- a/examples/menu_a_la_carte/menu_a_la_carte.ino +++ b/examples/menu_a_la_carte/menu_a_la_carte.ino @@ -425,7 +425,7 @@ Logger dataLogger(LoggerID, samplingFeature, loggingInterval); // Network connection information // APN for cellular connection -#define CELLULAR_APN "add_your_cellular_apn" +#define CELLULAR_APN "YourAPN" // WiFi access point name #define WIFI_ID "YourWiFiSSID" // WiFi password (WPA2) diff --git a/extras/LTExBee_FirstConnection/LTExBee_FirstConnection.ino b/extras/LTExBee_FirstConnection/LTExBee_FirstConnection.ino index fbd762fe3..4432b5590 100644 --- a/extras/LTExBee_FirstConnection/LTExBee_FirstConnection.ino +++ b/extras/LTExBee_FirstConnection/LTExBee_FirstConnection.ino @@ -19,7 +19,7 @@ StreamDebugger debugger(Serial1, Serial); TinyGsm gsmModem(debugger); -const char* apn = "hologram"; +const char* apn = "YourAPN"; void setup() { // Set the reset pin HIGH to ensure the Bee does not continually reset From 565f12e7eec07db474170702c3701ec4debc5d8b Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Thu, 19 Feb 2026 16:26:09 -0500 Subject: [PATCH 243/533] nit-picky stuff Signed-off-by: Sara Damiano --- .gitattributes | 1 + examples/ReadMe.md | 2 +- setupGitFilters.bat | 8 ++++---- setupGitFilters.ps1 | 8 ++++---- src/SensorBase.h | 2 +- src/sensors/MaxBotixSonar.h | 4 +++- src/sensors/MaximDS3231.cpp | 8 +++++--- src/sensors/ProcessorStats.cpp | 21 +++++++++++++++------ src/sensors/TIINA219.cpp | 4 ++-- src/sensors/TurnerTurbidityPlus.cpp | 6 ++++++ 10 files changed, 42 insertions(+), 22 deletions(-) diff --git a/.gitattributes b/.gitattributes index 5ea14825c..1d35033a7 100644 --- a/.gitattributes +++ b/.gitattributes @@ -11,6 +11,7 @@ # Declare files that will always have CRLF line endings on checkout. *.sln text eol=crlf +*.bat text eol=crlf # Denote all files that are truly binary and should not be modified. *.png binary diff --git a/examples/ReadMe.md b/examples/ReadMe.md index 02e05c627..7627b9b28 100644 --- a/examples/ReadMe.md +++ b/examples/ReadMe.md @@ -151,7 +151,7 @@ This example also makes use of the on-board light, temperature, and humidity sen The results are saved to the SD card and posted to Monitor My Watershed. Only to be used with newer Mayfly v1.0 and v1.1 boards. - [Instructions for the Mayfly 1.x LTE DRWI Citizen Science example](https://envirodiy.github.io/ModularSensors/example_drwi_mayfly1.html) -- [The LTEG DRWI Citizen Science example on GitHub](https://github.com/EnviroDIY/ModularSensors/tree/master/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_Mayfly1) +- [The Mayfly 1.x LTE DRWI Citizen Science example on GitHub](https://github.com/EnviroDIY/ModularSensors/tree/master/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_Mayfly1) #### DRWI CitSci No Cellular diff --git a/setupGitFilters.bat b/setupGitFilters.bat index fb37779a6..29a61b3e2 100644 --- a/setupGitFilters.bat +++ b/setupGitFilters.bat @@ -6,13 +6,13 @@ echo Setting up Git filter drivers for ModularSensors... REM Configure the smudgePasswords filter for .ino files echo Configuring smudgePasswords filter... -git config --local filter.smudgePasswords.clean "powershell -ExecutionPolicy Bypass -File filters/cleanPasswords.ps1" -git config --local filter.smudgePasswords.smudge "powershell -ExecutionPolicy Bypass -File filters/smudgePasswords.ps1" +git config --local filter.smudgePasswords.clean "powershell -ExecutionPolicy RemoteSigned -File filters/cleanPasswords.ps1" +git config --local filter.smudgePasswords.smudge "powershell -ExecutionPolicy RemoteSigned -File filters/smudgePasswords.ps1" REM Configure the disableDebug filter for ModSensorDebugConfig.h echo Configuring disableDebug filter... -git config --local filter.disableDebug.clean "powershell -ExecutionPolicy Bypass -File filters/cleanDebugConfig.ps1" -git config --local filter.disableDebug.smudge "powershell -ExecutionPolicy Bypass -File filters/smudgeDebugConfig.ps1" +git config --local filter.disableDebug.clean "powershell -ExecutionPolicy RemoteSigned -File filters/cleanDebugConfig.ps1" +git config --local filter.disableDebug.smudge "powershell -ExecutionPolicy RemoteSigned -File filters/smudgeDebugConfig.ps1" echo. echo Git filter drivers have been successfully configured! diff --git a/setupGitFilters.ps1 b/setupGitFilters.ps1 index 4e8bfbc5c..e9f1b1b8f 100644 --- a/setupGitFilters.ps1 +++ b/setupGitFilters.ps1 @@ -6,13 +6,13 @@ Write-Host "Setting up Git filter drivers for ModularSensors..." -ForegroundColo # Configure the smudgePasswords filter for .ino files Write-Host "Configuring smudgePasswords filter..." -ForegroundColor Yellow -git config --local filter.smudgePasswords.clean "powershell -ExecutionPolicy Bypass -File filters/cleanPasswords.ps1" -git config --local filter.smudgePasswords.smudge "powershell -ExecutionPolicy Bypass -File filters/smudgePasswords.ps1" +git config --local filter.smudgePasswords.clean "powershell -ExecutionPolicy RemoteSigned -File filters/cleanPasswords.ps1" +git config --local filter.smudgePasswords.smudge "powershell -ExecutionPolicy RemoteSigned -File filters/smudgePasswords.ps1" # Configure the disableDebug filter for ModSensorDebugConfig.h Write-Host "Configuring disableDebug filter..." -ForegroundColor Yellow -git config --local filter.disableDebug.clean "powershell -ExecutionPolicy Bypass -File filters/cleanDebugConfig.ps1" -git config --local filter.disableDebug.smudge "powershell -ExecutionPolicy Bypass -File filters/smudgeDebugConfig.ps1" +git config --local filter.disableDebug.clean "powershell -ExecutionPolicy RemoteSigned -File filters/cleanDebugConfig.ps1" +git config --local filter.disableDebug.smudge "powershell -ExecutionPolicy RemoteSigned -File filters/smudgeDebugConfig.ps1" Write-Host "`nGit filter drivers have been successfully configured!" -ForegroundColor Green Write-Host "`nFilters configured:" -ForegroundColor Cyan diff --git a/src/SensorBase.h b/src/SensorBase.h index 711143226..507d32f1a 100644 --- a/src/SensorBase.h +++ b/src/SensorBase.h @@ -526,7 +526,7 @@ class Sensor { /** * @brief Clear the values array and reset retry counts. * - * This clears the values array by setting all values to -9999, setal all + * This clears the values array by setting all values to -9999, sets all * values in numberGoodMeasurementsMade to 0, and resets the attempt * (#_measurementAttemptsCompleted) and retry (#_retryAttemptsMade) counts. */ diff --git a/src/sensors/MaxBotixSonar.h b/src/sensors/MaxBotixSonar.h index e987174f4..447f2f560 100644 --- a/src/sensors/MaxBotixSonar.h +++ b/src/sensors/MaxBotixSonar.h @@ -147,7 +147,9 @@ /// up (0ms stabilization). #define HRXL_STABILIZATION_TIME_MS 0 /// @brief Sensor::_measurementTime_ms; the HRXL takes 166ms to complete a -/// measurement. +/// measurement. It outputs results at least every 166ms. +/// @note Because this sensor allows up to 25 retries if a measurement fails, +/// the actual time to get a measurement may be much longer than 166ms. #define HRXL_MEASUREMENT_TIME_MS 250 /**@}*/ diff --git a/src/sensors/MaximDS3231.cpp b/src/sensors/MaximDS3231.cpp index ad6ab0936..353e571c8 100644 --- a/src/sensors/MaximDS3231.cpp +++ b/src/sensors/MaximDS3231.cpp @@ -57,14 +57,16 @@ bool MaximDS3231::startSingleMeasurement(void) { bool MaximDS3231::addSingleMeasurementResult(void) { // NOTE: If this fails we have much bigger problems than just a lost // temperature value. That is, if I2C communication with the clock fails, - // the system is too broken to even ask for this temperature. There's no - // reason to check for failure here. + // the system is too broken to even ask for this temperature. MS_DBG(getSensorNameAndLocation(), F("is reporting:")); float tempVal = rtc.getTemperature(); MS_DBG(F(" Temp:"), tempVal, F("°C")); verifyAndAddMeasurementResult(DS3231_TEMP_VAR_NUM, tempVal); + // Check if temperature is valid before marking success + bool success = !isnan(tempVal); + // Return success value when finished - return bumpMeasurementAttemptCount(true); + return bumpMeasurementAttemptCount(success); } diff --git a/src/sensors/ProcessorStats.cpp b/src/sensors/ProcessorStats.cpp index db399c31e..a2ca2a321 100644 --- a/src/sensors/ProcessorStats.cpp +++ b/src/sensors/ProcessorStats.cpp @@ -27,21 +27,30 @@ ProcessorStats::ProcessorStats(const char* version, // multiplier is version dependent #if defined(ARDUINO_AVR_ENVIRODIY_MAYFLY) // fix battery multiplier for older Mayfly versions - if (strcmp(_version, "v0.3") == 0 || strcmp(_version, "v0.4") == 0) { + if (_version != nullptr && + (strcmp(_version, "v0.3") == 0 || strcmp(_version, "v0.4") == 0)) { _batteryMultiplier = 1.47; } #elif defined(ARDUINO_SODAQ_ONE) || defined(ARDUINO_SODAQ_ONE_BETA) // only versions v0.1 and v0.2 of the Sodaq One are supported, and they have // different battery pins and multipliers - if (strcmp(_version, "v0.1") == 0) { - _batteryMultiplier = 2; - } else if (strcmp(_version, "v0.2") == 0) { - _batteryMultiplier = 1.47; + if (_version != nullptr) { + if (strcmp(_version, "v0.1") == 0) { + _batteryMultiplier = 2; + } else if (strcmp(_version, "v0.2") == 0) { + _batteryMultiplier = 1.47; + } else { + MS_DBG(F("Unsupported Sodaq One version:"), _version, + F("- setting battery multiplier to -1")); + _batteryMultiplier = -1; + } } else { + MS_DBG(F("No Sodaq One version specified - setting battery multiplier " + "to -1")); _batteryMultiplier = -1; } #elif defined(ARDUINO_SODAQ_AUTONOMO) - if (strcmp(_version, "v0.1") == 0) + if (_version != nullptr && strcmp(_version, "v0.1") == 0) _batteryPin = 48; else _batteryPin = 33; diff --git a/src/sensors/TIINA219.cpp b/src/sensors/TIINA219.cpp index dd88926a8..76d0f367e 100644 --- a/src/sensors/TIINA219.cpp +++ b/src/sensors/TIINA219.cpp @@ -39,7 +39,7 @@ String TIINA219::getSensorLocation(void) { bool TIINA219::setup(void) { bool wasOn; - Sensor::setup(); // this will set pin modes and the setup status bit + bool setupSuccess = Sensor::setup(); // this will set pin modes and the setup status bit // This sensor needs power for setup! delay(10); @@ -49,7 +49,7 @@ bool TIINA219::setup(void) { waitForWarmUp(); } - bool success = ina219_phy.begin(_i2c); + bool success = setupSuccess && ina219_phy.begin(_i2c); // Turn the power back off it it had been turned on if (!wasOn) { powerDown(); } diff --git a/src/sensors/TurnerTurbidityPlus.cpp b/src/sensors/TurnerTurbidityPlus.cpp index f72436006..cfab0987e 100644 --- a/src/sensors/TurnerTurbidityPlus.cpp +++ b/src/sensors/TurnerTurbidityPlus.cpp @@ -174,6 +174,12 @@ bool TurnerTurbidityPlus::addSingleMeasurementResult(void) { // down the voltage adcVoltage *= _voltageDividerFactor; } else { + // If the voltage divider factor is not set to a positive value, + // print a debugging message and continue without applying a voltage + // divider factor. We continue because the voltage divider factor + // can be easily fixed in post-processing if the raw voltage value + // is available, and we don't want to lose the voltage reading if + // the voltage divider factor is just set incorrectly. MS_DBG(F(" Invalid voltage divider factor:"), _voltageDividerFactor, F("Voltage divider will be ignored.")); From 09c2096fa07c50231692be85563a6898230a9b3f Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Thu, 19 Feb 2026 16:26:52 -0500 Subject: [PATCH 244/533] Only get values if successfully got event Signed-off-by: Sara Damiano --- src/sensors/SensirionSHT4x.cpp | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/src/sensors/SensirionSHT4x.cpp b/src/sensors/SensirionSHT4x.cpp index 4a675fa33..fe052d85e 100644 --- a/src/sensors/SensirionSHT4x.cpp +++ b/src/sensors/SensirionSHT4x.cpp @@ -96,7 +96,6 @@ bool SensirionSHT4x::addSingleMeasurementResult(void) { bool success = false; float temp_val = -9999; float humid_val = -9999; - bool ret_val = false; MS_DBG(getSensorNameAndLocation(), F("is reporting:")); @@ -107,27 +106,26 @@ bool SensirionSHT4x::addSingleMeasurementResult(void) { // we need to create Adafruit "sensor events" to use the library sensors_event_t temp_event{}; sensors_event_t humidity_event{}; - ret_val = sht4x_internal.getEvent(&humidity_event, &temp_event); - - // get the values from the sensor events - temp_val = temp_event.temperature; - humid_val = humidity_event.relative_humidity; + success = sht4x_internal.getEvent(&humidity_event, &temp_event); - if (!ret_val) { + if (success) { + // if getEvent returns true, get values from the sensor + temp_val = temp_event.temperature; + humid_val = humidity_event.relative_humidity; + } else { MS_DBG(F(" getEvent failed; no values read!")); - } else if (isnan(temp_val) || isnan(humid_val)) { - MS_DBG(F(" Invalid measurement values")); } - MS_DBG(F(" Temp:"), temp_val, F("°C")); - MS_DBG(F(" Humidity:"), humid_val, '%'); - - if (ret_val && !isnan(temp_val) && !isnan(humid_val)) { + if (success && !isnan(temp_val) && !isnan(humid_val)) { verifyAndAddMeasurementResult(SHT4X_TEMP_VAR_NUM, temp_val); verifyAndAddMeasurementResult(SHT4X_HUMIDITY_VAR_NUM, humid_val); - success = true; + } else { + success = false; } + MS_DBG(F(" Temp:"), temp_val, F("°C")); + MS_DBG(F(" Humidity:"), humid_val, '%'); + // Return success value when finished return bumpMeasurementAttemptCount(success); } From 64b8b5d2b24f5510bfb47dcb0a2377748f181125 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Thu, 19 Feb 2026 16:27:46 -0500 Subject: [PATCH 245/533] Check power state if not powering sensors; Signed-off-by: Sara Damiano --- src/VariableArray.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/VariableArray.cpp b/src/VariableArray.cpp index b86dcf589..9354d1934 100644 --- a/src/VariableArray.cpp +++ b/src/VariableArray.cpp @@ -337,6 +337,17 @@ bool VariableArray::completeUpdate(bool powerUp, bool wake, bool sleep, MS_DBG(F("----->> Powering up all sensors together. ...")); sensorsPowerUp(); MS_DBG(F(" ... Complete. <<-----")); + } else { + // If this function isn't powering the sensors, check whether or not the + // sensors are actually powered on before trying to wake them or + // assuming they are awake. If the sensors are not powered, the + // checkPowerOn function will reset the power *and wake* bits so the + // wake check or wake function will work correctly. + MS_DBG(F("----->> Checking the power state of all sensor. ...")); + for (uint8_t i = 0; i < _sensorCount; i++) { + sensorList[i]->checkPowerOn(); + } + MS_DBG(F(" ... Complete. <<-----")); } // NOTE: Don't clear the wake bits/timing! If the power up function found From a695ab64122ba77acb6e324309a0bc8b9e1ae4dd Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Thu, 19 Feb 2026 16:32:04 -0500 Subject: [PATCH 246/533] If not waking sensors, exclude sensors that are not already awake outside the loop Signed-off-by: Sara Damiano --- src/VariableArray.cpp | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/VariableArray.cpp b/src/VariableArray.cpp index 9354d1934..6725293eb 100644 --- a/src/VariableArray.cpp +++ b/src/VariableArray.cpp @@ -393,13 +393,14 @@ bool VariableArray::completeUpdate(bool powerUp, bool wake, bool sleep, continue; } - // If attempts were made to wake the sensor, but they failed... - // NOTE: We check if the wake was successful even if the wake - // parameter is false because we need to know the sensor wake failed - // before attempting readings even if the user called wake somewhere - // else. - if (sensorList[i]->getStatusBit(Sensor::WAKE_ATTEMPTED) == 1 && - sensorList[i]->getStatusBit(Sensor::WAKE_SUCCESSFUL) == 0) { + // If attempts were made to wake the sensor, but they failed OR if + // we're not waking the sensor but it is not already awake or the + // previous wake attempts failed... + if ((sensorList[i]->getStatusBit(Sensor::WAKE_ATTEMPTED) == 1 && + sensorList[i]->getStatusBit(Sensor::WAKE_SUCCESSFUL) == 0) || + (!wake && + (sensorList[i]->getStatusBit(Sensor::WAKE_ATTEMPTED) == 0 || + sensorList[i]->getStatusBit(Sensor::WAKE_SUCCESSFUL) == 0))) { MS_DBG(i, F("--->>"), sName, F("failed to wake up! No measurements will be taken! " "<<---"), @@ -407,8 +408,8 @@ bool VariableArray::completeUpdate(bool powerUp, bool wake, bool sleep, // Set the number of measurements already complete equal to // whatever total number requested to ensure the sensor is // skipped in further loops. NOTE: These are protected members - // of the sensor class; we can only access them because the - // variableArray class is a friend of the sensor class. + // of the Sensor class; we can only access them because the + // VariableArray class is a friend of the Sensor class. sensorList[i]->_measurementAttemptsCompleted = sensorList[i]->_measurementsToAverage; } From 208776a0acfa5a5ac996620393143a9546ef2e14 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Thu, 19 Feb 2026 17:04:36 -0500 Subject: [PATCH 247/533] More AI fixes Signed-off-by: Sara Damiano --- continuous_integration/generate_job_matrix.py | 3 ++- .../simple_logging_LearnEnviroDIY/ReadMe.md | 2 +- examples/ReadMe.md | 2 +- examples/baro_rho_correction/ReadMe.md | 2 +- examples/double_logger/ReadMe.md | 2 +- examples/logging_to_MMW/ReadMe.md | 2 +- examples/menu_a_la_carte/ReadMe.md | 2 +- examples/simple_logging/ReadMe.md | 2 +- src/modems/DigiXBee3GBypass.cpp | 2 +- src/sensors/EverlightALSPT19.cpp | 2 +- src/sensors/MeaSpecMS5803.cpp | 3 +-- src/sensors/PaleoTerraRedox.cpp | 24 +++++++++---------- 12 files changed, 24 insertions(+), 24 deletions(-) diff --git a/continuous_integration/generate_job_matrix.py b/continuous_integration/generate_job_matrix.py index e33601d3b..56cf426ca 100644 --- a/continuous_integration/generate_job_matrix.py +++ b/continuous_integration/generate_job_matrix.py @@ -103,7 +103,7 @@ # Find all of the non-menu examples non_menu_examples = [] -for root, _subdirs, files in os.walk(examples_path): +for root, subdirs, files in os.walk(examples_path): folder_name = os.path.basename(root) if folder_name in { ".history", @@ -112,6 +112,7 @@ "tests", menu_example_name, }: + subdirs.clear() # Prevent os.walk from descending into excluded directories continue for filename in files: file_path = os.path.join(root, filename) diff --git a/examples/OutdatedExamples/simple_logging_LearnEnviroDIY/ReadMe.md b/examples/OutdatedExamples/simple_logging_LearnEnviroDIY/ReadMe.md index 67c2101f1..53207cc82 100644 --- a/examples/OutdatedExamples/simple_logging_LearnEnviroDIY/ReadMe.md +++ b/examples/OutdatedExamples/simple_logging_LearnEnviroDIY/ReadMe.md @@ -45,7 +45,7 @@ _______ ### Set the logger ID -- Change the text `YourLoggerID` in this section of code to your loggerID or serial number: +- Change the text `YourLoggerID` in this section of code to your logger ID or serial number: ```cpp // Logger ID, also becomes the prefix for the name of the data file on SD card diff --git a/examples/ReadMe.md b/examples/ReadMe.md index 7627b9b28..31d445112 100644 --- a/examples/ReadMe.md +++ b/examples/ReadMe.md @@ -108,7 +108,7 @@ ___ The "menu a la carte" example shows most of the functions of the library in one gigantic program. It has code in it for every possible sensor and modem and for both AVR and SAMD boards. It is also over 1500 lines long. -This example is intended to be used like an a la carte menu of all possible options where you select only the portions of code pertinent to you and delete everything else. +This example is intended to serve as an a la carte menu of all available options, allowing you to select only the portions of code pertinent to you and delete everything else. This example is *NOT* intended to be run in its entirety - [The menu a la carte walkthrough](https://envirodiy.github.io/ModularSensors/example_menu.html) diff --git a/examples/baro_rho_correction/ReadMe.md b/examples/baro_rho_correction/ReadMe.md index a9dc2a777..fad6bb7dd 100644 --- a/examples/baro_rho_correction/ReadMe.md +++ b/examples/baro_rho_correction/ReadMe.md @@ -47,7 +47,7 @@ _______ ### Set the logger ID -- Change the text `YourLoggerID` in this section of code to your loggerID or serial number: +- Change the text `YourLoggerID` in this section of code to your logger ID or serial number: ```cpp // Logger ID, also becomes the prefix for the name of the data file on SD card diff --git a/examples/double_logger/ReadMe.md b/examples/double_logger/ReadMe.md index b63adfa69..11398bf73 100644 --- a/examples/double_logger/ReadMe.md +++ b/examples/double_logger/ReadMe.md @@ -46,7 +46,7 @@ _______ ### Set the logger ID -- Change the text `YourLoggerID` in this section of code to your loggerID or serial number: +- Change the text `YourLoggerID` in this section of code to your logger ID or serial number: ```cpp // Logger ID, also becomes the prefix for the name of the data file on SD card diff --git a/examples/logging_to_MMW/ReadMe.md b/examples/logging_to_MMW/ReadMe.md index 386775649..5ff0e7f57 100644 --- a/examples/logging_to_MMW/ReadMe.md +++ b/examples/logging_to_MMW/ReadMe.md @@ -49,7 +49,7 @@ _______ ### Set the logger ID -- Change the text `YourLoggerID` in this section of code to your loggerID or serial number: +- Change the text `YourLoggerID` in this section of code to your logger ID or serial number: ```cpp // Logger ID, also becomes the prefix for the name of the data file on SD card diff --git a/examples/menu_a_la_carte/ReadMe.md b/examples/menu_a_la_carte/ReadMe.md index c489c46e9..cbe53588e 100644 --- a/examples/menu_a_la_carte/ReadMe.md +++ b/examples/menu_a_la_carte/ReadMe.md @@ -1265,7 +1265,7 @@ Here we use the `new` keyword to create multiple variables and get pointers to t #### Creating Variables and Pasting UUIDs from MonitorMyWatershed If you are sending data to Monitor My Watershed, it is much easier to create the variables in an array and then to paste the UUIDs all together as copied from the "View Token UUID List" link for a site. -If using this method, be very, very, very careful to make sure the order of your variables exactly matches the order of your UUIDs. +If using this method, be careful to ensure the order of your variables exactly matches the order of your UUIDs. diff --git a/examples/simple_logging/ReadMe.md b/examples/simple_logging/ReadMe.md index 5a2d35275..bd481bb2a 100644 --- a/examples/simple_logging/ReadMe.md +++ b/examples/simple_logging/ReadMe.md @@ -40,7 +40,7 @@ _______ ### Set the logger ID -- Change the text `YourLoggerID` in this section of code to your loggerID or serial number: +- Change the text `YourLoggerID` in this section of code to your logger ID or serial number: ```cpp // Logger ID, also becomes the prefix for the name of the data file on SD card diff --git a/src/modems/DigiXBee3GBypass.cpp b/src/modems/DigiXBee3GBypass.cpp index 977b091d6..31304f103 100644 --- a/src/modems/DigiXBee3GBypass.cpp +++ b/src/modems/DigiXBee3GBypass.cpp @@ -107,7 +107,7 @@ bool DigiXBee3GBypass::extraModemSetup(void) { /** Disassociate from the network for the lowest power deep sleep. */ MS_DBG(F("Setting Other Options...")); /** Disable remote manager and enable 2G fallback. */ - gsmModem.sendAT(GF("DO"), 02); + gsmModem.sendAT(GF("DO"), 2); success &= gsmModem.waitResponse(GF("OK\r")) == 1; /** Make sure airplane mode is off - bypass and airplane mode are * incompatible. */ diff --git a/src/sensors/EverlightALSPT19.cpp b/src/sensors/EverlightALSPT19.cpp index e4b37a95b..8f54bb331 100644 --- a/src/sensors/EverlightALSPT19.cpp +++ b/src/sensors/EverlightALSPT19.cpp @@ -17,7 +17,7 @@ EverlightALSPT19::EverlightALSPT19(int8_t powerPin, int8_t dataPin, : Sensor("Everlight ALS-PT19", ALSPT19_NUM_VARIABLES, ALSPT19_WARM_UP_TIME_MS, ALSPT19_STABILIZATION_TIME_MS, ALSPT19_MEASUREMENT_TIME_MS, powerPin, dataPin, - measurementsToAverage), + measurementsToAverage, ALSPT19_INC_CALC_VARIABLES), _supplyVoltage(supplyVoltage), _loadResistor(loadResistor) {} #if defined(BUILT_IN_ALS_POWER_PIN) && defined(BUILT_IN_ALS_DATA_PIN) && \ diff --git a/src/sensors/MeaSpecMS5803.cpp b/src/sensors/MeaSpecMS5803.cpp index 7521c396a..b66026b55 100644 --- a/src/sensors/MeaSpecMS5803.cpp +++ b/src/sensors/MeaSpecMS5803.cpp @@ -80,8 +80,7 @@ bool MeaSpecMS5803::addSingleMeasurementResult(void) { // Temperature Range is -40°C to +85°C // Pressure returns 0 when disconnected, which is highly unlikely to be // a real value. - // Pressure range depends on the model, but the highest pressure model - // goes up to 14bar (14,000 mbar) + // Pressure range depends on the model; validation uses _maxPressure * 1000.0 verifyAndAddMeasurementResult(MS5803_TEMP_VAR_NUM, temp); verifyAndAddMeasurementResult(MS5803_PRESSURE_VAR_NUM, press); success = true; diff --git a/src/sensors/PaleoTerraRedox.cpp b/src/sensors/PaleoTerraRedox.cpp index 3eb8a8040..c3e50bcbc 100644 --- a/src/sensors/PaleoTerraRedox.cpp +++ b/src/sensors/PaleoTerraRedox.cpp @@ -130,19 +130,19 @@ bool PaleoTerraRedox::addSingleMeasurementResult(void) { config = _i2c->read(); res = 0; - int sign = bitRead(res1, 1); // one but least significant bit - if (sign == 1) { - res1 = ~res1; - res2 = ~res2; - res3 = ~res3; // two's complements - res = bitRead(res1, 0) * -1024; // 256 * 256 * 15.625 uV per LSB = 16 - res -= res2 * 4; - res -= res3 * 0.015625; - res -= 0.015625; + // Assemble the 18-bit raw sample from the three bytes + uint32_t rawSample = (static_cast(bitRead(res1, 0)) << 16) | + (static_cast(res2) << 8) | + static_cast(res3); + + // Check if this is a negative value (sign bit D17 is set) + if (bitRead(res1, 1)) { + // Sign-extend the 18-bit value to get correct negative magnitude + int32_t signedSample = rawSample | 0xFFFC0000; // Sign extend from bit 17 + res = signedSample * 0.015625; // 15.625 uV per LSB } else { - res = bitRead(res1, 0) * 1024; // 256 * 256 * 15.625 uV per LSB = 16 - res += res2 * 4; - res += res3 * 0.015625; + // Positive value + res = rawSample * 0.015625; // 15.625 uV per LSB } /// @todo ADD FAILURE CONDITIONS for PaleoTerraRedox!! From e424862add5684e1875de9a921d700f7e69c2e55 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Thu, 19 Feb 2026 17:36:46 -0500 Subject: [PATCH 248/533] More minor fixes Signed-off-by: Sara Damiano --- ChangeLog.md | 7 ++++--- examples/AWS_IoT_Core/ReadMe.md | 2 +- extras/AWS_IoT_SetCertificates/AWS_IoT_SetCertificates.ino | 2 +- extras/AWS_IoT_SetCertificates/ReadMe.md | 2 +- src/sensors/ProcessorStats.cpp | 2 +- 5 files changed, 8 insertions(+), 7 deletions(-) diff --git a/ChangeLog.md b/ChangeLog.md index 28cc8336f..9698842ea 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -12,8 +12,6 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm ### Changed -- **BREAKING** Changed capitalization of `setInitialShortIntervals(#)` function - - Previously the 'i' of initial was not capitalized. - Made the enabling and disabling of the watchdog the very first and very last steps of sleep to keep the watchdog enabled through the whole getting ready for bed and waking up process. - **ANB pH** - **BREAKING** The constructor has changed! @@ -22,6 +20,9 @@ The logging interval has been added as a required parameter for the constructor! - **Renamed** The EnviroDIYPublisher has been renamed the MonitorMyWatershedPublisher. This reflects changes to the website from years ago. There is a shell file and typedef to maintain backwards compatibility. +- Changed capitalization of `setInitialShortIntervals(#)` function + - Previously the 'i' of initial was not capitalized. + - The old `setinitialShortIntervals` remains available via compatibility shim in LoggerBase.h, so existing code is unaffected. - Bumped several dependencies - including crucial bug fixes to SensorModbusMaster. - Re-wrote most of the logic for looping variables within the complete update function of the VariableArray. - Simplified the `addSingleMeasurementResult()` function of all sensors to use an internal function to help set the bits and timing values and to quit sooner if the measurement was not started successfully. @@ -1209,4 +1210,4 @@ Our first release of the modular sensors library to support easily logging data - + diff --git a/examples/AWS_IoT_Core/ReadMe.md b/examples/AWS_IoT_Core/ReadMe.md index 255667037..b67d97abb 100644 --- a/examples/AWS_IoT_Core/ReadMe.md +++ b/examples/AWS_IoT_Core/ReadMe.md @@ -61,7 +61,7 @@ Make sure there are quotation marks around the name string, as there are in the ### Set your Variable UUIDs -In the section beginning with `Start [variable_arrays]`, find and replace the text `"12345678-abcd-1234-ef00-1234567890ab` with the UUIDs for each of your variables, if they have UUIDs. +In the section beginning with `Start [variable_arrays]`, find and replace the text `"12345678-abcd-1234-ef00-1234567890ab"` with the UUIDs for each of your variables, if they have UUIDs. Make sure there are quotation marks around the name string, as there are in the example. If you do not have UUIDs for your variables, delete the string entirely, leaving empty quotes (`""`). diff --git a/extras/AWS_IoT_SetCertificates/AWS_IoT_SetCertificates.ino b/extras/AWS_IoT_SetCertificates/AWS_IoT_SetCertificates.ino index 9c7df9e67..a3b0e77c5 100644 --- a/extras/AWS_IoT_SetCertificates/AWS_IoT_SetCertificates.ino +++ b/extras/AWS_IoT_SetCertificates/AWS_IoT_SetCertificates.ino @@ -47,7 +47,7 @@ // Set serial for AT commands (to the module) // Use Hardware Serial on Mega, Leonardo, Micro #ifndef __AVR_ATmega328P__ -#define SerialAT SerialBee +#define SerialAT Serial1 // or Software Serial on Uno, Nano #else diff --git a/extras/AWS_IoT_SetCertificates/ReadMe.md b/extras/AWS_IoT_SetCertificates/ReadMe.md index f7c2378bb..15e399c06 100644 --- a/extras/AWS_IoT_SetCertificates/ReadMe.md +++ b/extras/AWS_IoT_SetCertificates/ReadMe.md @@ -175,7 +175,7 @@ If you see the message `failed to initialize modem`, there's a communication pro If after the failure message and a delay you do see your modem serial number or firmware version after the message `Modem Info:`, you can ignore this error: it was a baud rate problem and the Arduino adjusted. If you don't get the modem info, there's something wrong. If your SIM card requires a user name and password to unlock (uncommon), enter those in as the `gprsUser` and `gprsPass` in the GPRS credentials section of the ino file and recompile and re-upload. -Confirm that your wires between the Arduino and your modem are correct and you've set the correct port for `SerialAT` in the line `#define SerialMon Serial`. +Confirm that your wires between the Arduino and your modem are correct and you've set the correct port for `SerialAT` in the line `#define SerialAT Serial1`. Confirm that your modem has power and that any expected LED's are lit. ### The certificates fail to load on the modem diff --git a/src/sensors/ProcessorStats.cpp b/src/sensors/ProcessorStats.cpp index a2ca2a321..d05c040f2 100644 --- a/src/sensors/ProcessorStats.cpp +++ b/src/sensors/ProcessorStats.cpp @@ -33,7 +33,7 @@ ProcessorStats::ProcessorStats(const char* version, } #elif defined(ARDUINO_SODAQ_ONE) || defined(ARDUINO_SODAQ_ONE_BETA) // only versions v0.1 and v0.2 of the Sodaq One are supported, and they have - // different battery pins and multipliers + // different battery multipliers (_batteryPin uses the default) if (_version != nullptr) { if (strcmp(_version, "v0.1") == 0) { _batteryMultiplier = 2; From df6e3578355c484ead1ad9c1f795424c74187233 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Thu, 19 Feb 2026 18:01:52 -0500 Subject: [PATCH 249/533] Fix spelling errors and typos Signed-off-by: Sara Damiano --- src/WatchDogs/WatchDogAVR.cpp | 4 +++- src/WatchDogs/WatchDogSAMD.cpp | 28 +++++++++++++++------------- src/WatchDogs/WatchDogSAMD.h | 8 +++++--- src/sensors/KnownProcessors.h | 2 ++ 4 files changed, 25 insertions(+), 17 deletions(-) diff --git a/src/WatchDogs/WatchDogAVR.cpp b/src/WatchDogs/WatchDogAVR.cpp index 32d34d062..6ebf9cabb 100644 --- a/src/WatchDogs/WatchDogAVR.cpp +++ b/src/WatchDogs/WatchDogAVR.cpp @@ -63,7 +63,7 @@ void extendedWatchDogAVR::enableWatchDog() { // Bit 3: WDE (Watchdog System Reset Enable) - 0 (Clear?) // Bits 2:0 Watchdog timer prescaler [WDP2:0] - see delay interval patterns - // maxium delay interval: + // maximum delay interval: // 0bxx1xx001 = 1048576 clock cycles = ~8 seconds @ 8MHz sei(); // re-enable interrupts @@ -124,4 +124,6 @@ ISR(WDT_vect) { } } +// cspell:words MCUSR WDTCSR WDCE WDRF WDIF WDIE WDT_vect + #endif diff --git a/src/WatchDogs/WatchDogSAMD.cpp b/src/WatchDogs/WatchDogSAMD.cpp index af6fb1361..96068e631 100644 --- a/src/WatchDogs/WatchDogSAMD.cpp +++ b/src/WatchDogs/WatchDogSAMD.cpp @@ -26,7 +26,7 @@ void extendedWatchDogSAMD::setupWatchDog(uint32_t resetTime_s) { extendedWatchDogSAMD::_barksUntilReset = _resetTime_s / MAXIMUM_WATCHDOG_PERIOD; MS_DEEP_DBG(F("WDT Reset time:"), _resetTime_s, - F(" Maximim time between barks"), MAXIMUM_WATCHDOG_PERIOD, + F(" Maximum time between barks"), MAXIMUM_WATCHDOG_PERIOD, F(" Barks until reset:"), _barksUntilReset); // Steps: @@ -38,7 +38,7 @@ void extendedWatchDogSAMD::setupWatchDog(uint32_t resetTime_s) { // - The WDT **cannot** be cleared until after the end of the // closed-window period. Attempting a clear during the closed window // causes a reset. - // - 0xB - 16384 clockcycles @ 1024hz = 16 seconds + // - 0xB - 16384 clock cycles @ 1024hz = 16 seconds // - Set the watchdog time-out period to the maximum value // - In windowed mode, the time-out period (or open window) starts at // the end of the closed window period @@ -48,9 +48,9 @@ void extendedWatchDogSAMD::setupWatchDog(uint32_t resetTime_s) { // is, because we're going to clear the watchdog or issue a reset as // soon as the early warning interrupt fires to tell us that the open // window has started. - // - 0xB - 16384 clockcycles @ 1024hz = 16 seconds + // - 0xB - 16384 clock cycles @ 1024hz = 16 seconds // - Set the watchdog early warning offset value to the minimum value. - // - 0x0 - 8 clockcycles @ 1024hz ~= 7.8ms + // - 0x0 - 8 clock cycles @ 1024hz ~= 7.8ms // - The early warning offset isn't relevant in windowed mode. // - Enable windowed mode @@ -110,20 +110,20 @@ void extendedWatchDogSAMD::enableWatchDog() { WDT->CONFIG.bit.PER = 0xB; // Period/Open window period // ^^ Use the maximum period for both windowed and normal mode - // 0xB = 16384 clockcycles @ 1024hz = 16 seconds + // 0xB = 16384 clock cycles @ 1024hz = 16 seconds WDT->CONFIG.bit.WINDOW = 0xB; // Closed window period // ^^ Use the maximum closed window period for windowed mode // This is irrelevant for normal mode - // 0xB = 16384 clockcycles @ 1024hz = 16 seconds + // 0xB = 16384 clock cycles @ 1024hz = 16 seconds WDT->EWCTRL.bit.EWOFFSET = 0xA; // Early Warning Offset // ^^ The Early Warning Offset bits define the number of GCLK_WDT clocks // before the interrupt is generated, relative to the start of the watchdog // time-out period. This must be less than the size of the watchdog period // or the interrupt will not be generated. - // Use the maximum offset for the longest time before the interrut in normal + // Use the maximum offset for the longest time before the interrupt in normal // mode. // This is irrelevant in windowed mode. - // 0xA = 8192 clockcycles @ 1024hz = 8 seconds + // 0xA = 8192 clock cycles @ 1024hz = 8 seconds // WDT->INTFLAG.bit.EW = 1; // Clear any pending interrupt flags WDT->INTENSET.bit.EW = 1; // Enable early warning interrupt @@ -237,7 +237,7 @@ void extendedWatchDogSAMD::configureClockGenerator() { GENERIC_CLOCK_GENERATOR_MS); GCLK->GENCTRL.reg = static_cast( GCLK_GENCTRL_ID(GENERIC_CLOCK_GENERATOR_MS) | // Select GCLK - GCLK_GENCTRL_GENEN | // Enable the generic clock clontrol + GCLK_GENCTRL_GENEN | // Enable the generic clock controller GCLK_GENCTRL_SRC_OSCULP32K | // Select the built-in ultra-low power // internal oscillator GCLK_GENCTRL_IDC | // improve duty cycle @@ -257,7 +257,7 @@ void extendedWatchDogSAMD::configureWDTClock() { //^^ SAMD21 // Per datasheet 16.6.3.3 the generic clock must be disabled before being // re-enabled with a new clock source setting. - MS_DEEP_DBG(F("Disabling WDT peripeheral clock for configuration")); + MS_DEEP_DBG(F("Disabling WDT peripheral clock for configuration")); // this will set all bits but the ID to 0, disabling everything // See https://github.com/arduino-libraries/ArduinoLowPower/issues/30 GCLK->CLKCTRL.reg = static_cast(GCLK_CLKCTRL_ID(GCM_WDT)); @@ -270,7 +270,7 @@ void extendedWatchDogSAMD::configureWDTClock() { GCLK->CLKCTRL.reg = static_cast( GCLK_CLKCTRL_GEN(GENERIC_CLOCK_GENERATOR_MS) | // Select generic clock // generator - GCLK_CLKCTRL_CLKEN | // Enable the generic clock clontrol + GCLK_CLKCTRL_CLKEN | // Enable the generic clock controller GCLK_CLKCTRL_ID(GCM_WDT)); // Feed the GCLK to the WDT waitForGCLKBitSync(); #endif @@ -327,7 +327,7 @@ void extendedWatchDogSAMD::configureEICClock() { // Per datasheet 16.6.3.3 the generic clock must be disabled before being // re-enabled with a new clock source setting. - MS_DEEP_DBG(F("Disabling EIC peripeheral clock for configuration")); + MS_DEEP_DBG(F("Disabling EIC peripheral clock for configuration")); // this will set all bits but the ID to 0, disabling everything // See https://github.com/arduino-libraries/ArduinoLowPower/issues/30 GCLK->CLKCTRL.reg = static_cast(GCLK_CLKCTRL_ID(GCM_EIC)); @@ -340,7 +340,7 @@ void extendedWatchDogSAMD::configureEICClock() { GCLK->CLKCTRL.reg = static_cast( GCLK_CLKCTRL_GEN(GENERIC_CLOCK_GENERATOR_MS) | // Select generic clock // generator - GCLK_CLKCTRL_CLKEN | // Enable the generic clock clontrol + GCLK_CLKCTRL_CLKEN | // Enable the generic clock controller GCLK_CLKCTRL_ID(GCM_EIC)); // Feed the GCLK to the EIC waitForGCLKBitSync(); @@ -427,5 +427,7 @@ void WDT_Handler(void) { } } +// cspell:words EWCTRL EWOFFSET INTENSET ULP32KOSC GCLK_GENCTRL_GENEN APBAMASK +// cspell:words GCLK_CLKCTRL_CLKEN irqn CKSEL #endif diff --git a/src/WatchDogs/WatchDogSAMD.h b/src/WatchDogs/WatchDogSAMD.h index d6d99c6fe..d85b0b491 100644 --- a/src/WatchDogs/WatchDogSAMD.h +++ b/src/WatchDogs/WatchDogSAMD.h @@ -42,7 +42,7 @@ * * For a SAMD board, we can get the longest possible time between interrupts by * using the maximum closed window period in "windowed" mode and setting the - * early warning interrupt that opens the window to occur at the mimimum + * early warning interrupt that opens the window to occur at the minimum * possible time before a reset fires. The maximum number of clock cycles for * the closed window period is 16384 cycles on both a SAMD21 and SAM(D/E)51. * @@ -50,7 +50,7 @@ * CLK_WDT_OSC clock sourced from the ULP32KOSC. * * On a SAMD21 the WDT can be clocked from any clock source with the maximum - * dividor depending on the selected clock generator. To save power, we force + * divider depending on the selected clock generator. To save power, we force * the SAMD21 to use the ULP32KOSC for the WDT and EIC. For simplicity of code, * we use a 32x divisor on the ULP32KOSC to match the SAM(D/E)51 1.024kHz * CLK_WDT_OSC. @@ -136,7 +136,7 @@ class extendedWatchDogSAMD { static void configureWDTClock(); /** * @brief Configure the peripheral clock for the external interrupt - * congtroller (EIC) - sourced from the generic clock generator + * controller (EIC) - sourced from the generic clock generator */ static void configureEICClock(); @@ -167,4 +167,6 @@ class extendedWatchDogSAMD { static uint32_t _resetTime_s; }; +// cspell:words ULP32KOSC + #endif // SRC_WATCHDOGS_WATCHDOGSAMD_H_ diff --git a/src/sensors/KnownProcessors.h b/src/sensors/KnownProcessors.h index 9699db2d6..aad16550b 100644 --- a/src/sensors/KnownProcessors.h +++ b/src/sensors/KnownProcessors.h @@ -287,4 +287,6 @@ "The battery multiplier can be added by editing KnownProcessors.h." #endif +// cspell:words Tatu Moja Adalogger Duemilanove Esplora Lilypad + #endif From 4aa8feca5fed95731612a3b4dba9281722c76725 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Thu, 19 Feb 2026 18:09:54 -0500 Subject: [PATCH 250/533] Fix links Signed-off-by: Sara Damiano --- docs/For-Developers/Developer-Setup.md | 81 ++++++++++++-------------- 1 file changed, 38 insertions(+), 43 deletions(-) diff --git a/docs/For-Developers/Developer-Setup.md b/docs/For-Developers/Developer-Setup.md index 0e0463f67..5018d56dc 100644 --- a/docs/For-Developers/Developer-Setup.md +++ b/docs/For-Developers/Developer-Setup.md @@ -90,49 +90,6 @@ lib_ldf_mode = deep+ lib_compat_mode = soft ; look for the library directory lib_extra_dirs = . -; All these library dependencies must be listed out since we're in the library -; source code and won't read the dependencies from the library.json like a -; typical user would -lib_deps = - Adafruit BusIO=symlink://C:\Users\sdamiano\Documents\GitHub\EnviroDIY\ModularSensors\lib\Adafruit BusIO - Adafruit GFX Library=symlink://C:\Users\sdamiano\Documents\GitHub\EnviroDIY\ModularSensors\lib\Adafruit GFX Library - Adafruit MPL115A2=symlink://C:\Users\sdamiano\Documents\GitHub\EnviroDIY\ModularSensors\lib\Adafruit MPL115A2 - Adafruit NeoPixel=symlink://C:\Users\sdamiano\Documents\GitHub\EnviroDIY\ModularSensors\lib\Adafruit NeoPixel - Adafruit SH110X=symlink://C:\Users\sdamiano\Documents\GitHub\EnviroDIY\ModularSensors\lib\Adafruit SH110X - Adafruit SSD1306=symlink://C:\Users\sdamiano\Documents\GitHub\EnviroDIY\ModularSensors\lib\Adafruit SSD1306 - Adafruit Unified Sensor=symlink://C:\Users\sdamiano\Documents\GitHub\EnviroDIY\ModularSensors\lib\Adafruit Unified Sensor - AltSoftSerial=symlink://C:\Users\sdamiano\Documents\GitHub\EnviroDIY\ModularSensors\lib\AltSoftSerial - BMP388_DEV=symlink://C:\Users\sdamiano\Documents\GitHub\EnviroDIY\ModularSensors\lib\BMP388_DEV - DHT sensor library=symlink://C:\Users\sdamiano\Documents\GitHub\EnviroDIY\ModularSensors\lib\DHT sensor library - EnableInterrupt=symlink://C:\Users\sdamiano\Documents\GitHub\EnviroDIY\ModularSensors\lib\EnableInterrupt - EnviroDIY_DS3231=symlink://C:\Users\sdamiano\Documents\GitHub\EnviroDIY\ModularSensors\lib\EnviroDIY_DS3231 - GeoluxCamera=symlink://C:\Users\sdamiano\Documents\GitHub\EnviroDIY\ModularSensors\lib\GeoluxCamera - MS5803=symlink://C:\Users\sdamiano\Documents\GitHub\EnviroDIY\ModularSensors\lib\MS5803 - NeoSWSerial=symlink://C:\Users\sdamiano\Documents\GitHub\EnviroDIY\ModularSensors\lib\NeoSWSerial - OneWire=symlink://C:\Users\sdamiano\Documents\GitHub\EnviroDIY\ModularSensors\lib\OneWire - PubSubClient=symlink://C:\Users\sdamiano\Documents\GitHub\EnviroDIY\ModularSensors\lib\PubSubClient - RTCZero=symlink://C:\Users\sdamiano\Documents\GitHub\EnviroDIY\ModularSensors\lib\RTCZero - SDI-12=symlink://C:\Users\sdamiano\Documents\GitHub\EnviroDIY\ModularSensors\lib\SDI-12 - SDI-12_ExtInts=symlink://C:\Users\sdamiano\Documents\GitHub\EnviroDIY\ModularSensors\lib\SDI-12_ExtInts - SdFat=symlink://C:\Users\sdamiano\Documents\GitHub\EnviroDIY\ModularSensors\lib\SdFat - SensorModbusMaster=symlink://C:\Users\sdamiano\Documents\GitHub\EnviroDIY\ModularSensors\lib\SensorModbusMaster - SoftwareSerial_ExternalInts=symlink://C:\Users\sdamiano\Documents\GitHub\EnviroDIY\ModularSensors\lib\SoftwareSerial_ExternalInts - SoftwareWire=symlink://C:\Users\sdamiano\Documents\GitHub\EnviroDIY\ModularSensors\lib\SoftwareWire - SparkFun Qwiic RTC RV8803 Arduino Library=symlink://C:\Users\sdamiano\Documents\GitHub\EnviroDIY\ModularSensors\lib\SparkFun Qwiic RTC RV8803 Arduino Library - StreamDebugger=symlink://C:\Users\sdamiano\Documents\GitHub\EnviroDIY\ModularSensors\lib\StreamDebugger - Tally_Library_I2C=symlink://C:\Users\sdamiano\Documents\GitHub\EnviroDIY\ModularSensors\lib\Tally_Library_I2C - TinyGSM=symlink://C:\Users\sdamiano\Documents\GitHub\EnviroDIY\ModularSensors\lib\TinyGSM - YosemitechModbus=symlink://C:\Users\sdamiano\Documents\GitHub\EnviroDIY\ModularSensors\lib\YosemitechModbus - fast_math=symlink://C:\Users\sdamiano\Documents\GitHub\EnviroDIY\ModularSensors\lib\fast_math - ANBSensorsModbus=symlink://C:\Users\sdamiano\Documents\GitHub\EnviroDIY\ModularSensors\lib\ANBSensorsModbus - Adafruit ADS1X15=symlink://C:\Users\sdamiano\Documents\GitHub\EnviroDIY\ModularSensors\lib\Adafruit ADS1X15 - Adafruit AM2315=symlink://C:\Users\sdamiano\Documents\GitHub\EnviroDIY\ModularSensors\lib\Adafruit AM2315 - Adafruit BME280 Library=symlink://C:\Users\sdamiano\Documents\GitHub\EnviroDIY\ModularSensors\lib\Adafruit BME280 Library - Adafruit INA219=symlink://C:\Users\sdamiano\Documents\GitHub\EnviroDIY\ModularSensors\lib\Adafruit INA219 - Adafruit SHT4x Library=symlink://C:\Users\sdamiano\Documents\GitHub\EnviroDIY\ModularSensors\lib\Adafruit SHT4x Library - DallasTemperature=symlink://C:\Users\sdamiano\Documents\GitHub\EnviroDIY\ModularSensors\lib\DallasTemperature - GroPointModbus=symlink://C:\Users\sdamiano\Documents\GitHub\EnviroDIY\ModularSensors\lib\GroPointModbus - KellerModbus=symlink://C:\Users\sdamiano\Documents\GitHub\EnviroDIY\ModularSensors\lib\KellerModbus ; We have to ignore these folders or PlatformIO will double count all the dependencies lib_ignore = .git @@ -156,6 +113,44 @@ lib_ignore = Adafruit STMPE610 Adafruit TouchScreen Adafruit ILI9341 +; All these library dependencies must be listed out since we're in the library +; source code and won't read the dependencies from the library.json like a +; typical user would +lib_deps = + envirodiy/EnviroDIY_DS3231@^1.3.6 + arduino-libraries/RTCZero@^1.6.0 + sparkfun/SparkFun Qwiic RTC RV8803 Arduino Library@^1.2.10 + greygnome/EnableInterrupt@^1.1.0 + greiman/SdFat@=2.3.0 + TinyGSM=https://github.com/EnviroDIY/TinyGSM + knolleary/PubSubClient@^2.8 + adafruit/Adafruit BusIO@^1.17.4 + adafruit/Adafruit Unified Sensor@^1.1.15 + adafruit/Adafruit ADS1X15@^2.6.2 + adafruit/Adafruit AM2315@^2.2.3 + adafruit/Adafruit BME280 Library@^2.3.0 + MartinL1/BMP388_DEV@^1.0.11 + adafruit/DHT sensor library@^1.4.6 + adafruit/Adafruit INA219@^1.2.3 + adafruit/Adafruit MPL115A2@^2.0.2 + adafruit/Adafruit SHT4x Library@^1.0.5 + paulstoffregen/OneWire@^2.3.8 + milesburton/DallasTemperature@^4.0.6 + envirodiy/SDI-12@^2.3.2 + SDI-12_ExtInts=https://github.com/EnviroDIY/Arduino-SDI-12#ExtInts + northernwidget/MS5803@^0.1.2 + Tally_Library_I2C=https://github.com/EnviroDIY/Tally_Library.git#Dev_I2C + envirodiy/SensorModbusMaster@^1.7.0 + envirodiy/KellerModbus@^0.2.7 + envirodiy/YosemitechModbus@^0.5.4 + envirodiy/GroPointModbus@^0.1.5 + envirodiy/GeoluxCamera@^0.1.3 + robtillaart/fast_math@^0.2.4 + envirodiy/ANBSensorsModbus@^0.4.2 + StreamDebugger=https://github.com/EnviroDIY/StreamDebugger.git + NeoSWSerial=https://github.com/SRGDamia1/NeoSWSerial.git + AltSoftSerial=https://github.com/PaulStoffregen/AltSoftSerial.git + SoftwareWire=https://github.com/Testato/SoftwareWire.git#v1.5.1 ; The directories for the ModularSensors library source code src_filter = +<*> From ec914e2ea58604651e3592c52addd4368e95f0c1 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Thu, 19 Feb 2026 18:10:12 -0500 Subject: [PATCH 251/533] Don't flush an empty buffer Signed-off-by: Sara Damiano --- src/publishers/MonitorMyWatershedPublisher.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/publishers/MonitorMyWatershedPublisher.cpp b/src/publishers/MonitorMyWatershedPublisher.cpp index e30afae85..aa7068b51 100644 --- a/src/publishers/MonitorMyWatershedPublisher.cpp +++ b/src/publishers/MonitorMyWatershedPublisher.cpp @@ -313,6 +313,12 @@ int16_t MonitorMyWatershedPublisher::flushDataBuffer(Client* outClient) { char tempBuffer[37] = ""; uint16_t did_respond = 0; int16_t responseCode = 0; + + // Early return if no records to send + if (_logBuffer.getNumRecords() == 0) { + MS_DBG(F("No records to send, returning without action")); + return 0; + } if (_baseLogger->getSamplingFeatureUUID() == nullptr || strlen(_baseLogger->getSamplingFeatureUUID()) == 0) { PRINTOUT(F("A sampling feature UUID must be set before publishing data " From 4c2549a0a4f3a51576b00f258cf103e0c2f5643f Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Thu, 19 Feb 2026 18:15:49 -0500 Subject: [PATCH 252/533] More minor doc fixes Signed-off-by: Sara Damiano --- docs/For-Developers/Developer-Setup.md | 9 ++++++--- .../DRWI_CitizenScience/DRWI_DigiLTE/ReadMe.md | 4 ++-- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/docs/For-Developers/Developer-Setup.md b/docs/For-Developers/Developer-Setup.md index 5018d56dc..fe2bdd2e3 100644 --- a/docs/For-Developers/Developer-Setup.md +++ b/docs/For-Developers/Developer-Setup.md @@ -23,17 +23,20 @@ Clone it to your local computer. This repository uses Git filters to manage sensitive credentials and debug configurations. After cloning the repository, run one of the following setup scripts to configure the necessary Git filter drivers: **Windows Command Prompt:** + ```batch setupGitFilters.bat ``` **PowerShell:** + ```powershell .\setupGitFilters.ps1 ``` **Manual Setup:** If you prefer to configure the filters manually, run these Git commands from the repository root: + ```bash git config --local filter.smudgePasswords.clean "powershell -ExecutionPolicy Bypass -File filters/cleanPasswords.ps1" git config --local filter.smudgePasswords.smudge "powershell -ExecutionPolicy Bypass -File filters/smudgePasswords.ps1" @@ -42,10 +45,10 @@ git config --local filter.disableDebug.smudge "powershell -ExecutionPolicy Bypas ``` These filters provide the following functionality: + - **smudgePasswords** - Manages placeholder credentials in `.ino` example files during development and commits - **disableDebug** - Automatically manages debug defines in `ModSensorDebugConfig.h` to keep them disabled in commits but enabled locally - ## PlatformIO Setup The Arduino IDE is not a good tool for library development. @@ -117,8 +120,8 @@ lib_ignore = ; source code and won't read the dependencies from the library.json like a ; typical user would lib_deps = - envirodiy/EnviroDIY_DS3231@^1.3.6 - arduino-libraries/RTCZero@^1.6.0 + envirodiy/EnviroDIY_DS3231@^1.3.6 + arduino-libraries/RTCZero@^1.6.0 sparkfun/SparkFun Qwiic RTC RV8803 Arduino Library@^1.2.10 greygnome/EnableInterrupt@^1.1.0 greiman/SdFat@=2.3.0 diff --git a/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_DigiLTE/ReadMe.md b/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_DigiLTE/ReadMe.md index 7b97957e9..6fdc178aa 100644 --- a/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_DigiLTE/ReadMe.md +++ b/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_DigiLTE/ReadMe.md @@ -23,7 +23,7 @@ _______ - [Prepare and set up PlatformIO](#prepare-and-set-up-platformio) - [Set the logger ID](#set-the-logger-id) - [Set the calibration coefficients for the Campbell OBS3+](#set-the-calibration-coefficients-for-the-campbell-obs3) - - [Set the universally unique identifiers (UUID) for each variable](#set-the-universally-unique-identifiers-uuid-for-each-variable) + - [Set the universally unique identifiers (UUIDs) for each variable](#set-the-universally-unique-identifiers-uuids-for-each-variable) - [Upload!](#upload) @@ -92,7 +92,7 @@ const float OBSHigh_C = 0.000E+00; // "C" value [*high* range] CampbellOBS3 osb3high(OBS3Power, OBSHighADSChannel, OBSHigh_A, OBSHigh_B, OBSHigh_C, ADSi2c_addr, OBS3numberReadings); ``` -### Set the universally unique identifiers (UUID) for each variable +### Set the universally unique identifiers (UUIDs) for each variable - Go back to the web page for your site on [Monitor My Watershed](https://monitormywatershed.org) From a4bf49c21ee99612bd3585b8674a3059c562d01a Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Fri, 20 Feb 2026 11:52:05 -0500 Subject: [PATCH 253/533] Never-ending doc and comment fixes Signed-off-by: Sara Damiano --- ChangeLog.md | 12 ++++++------ cspell.json | 1 + docs/Further-Reading/Sleep-Configurations.md | 2 +- .../EnviroDIY_Monitoring_Kit.ino | 8 ++++++-- .../DRWI_CitizenScience/DRWI_2G/ReadMe.md | 2 +- .../simple_logging_LearnEnviroDIY/ReadMe.md | 2 +- examples/ReadMe.md | 3 ++- src/VariableBase.h | 8 ++++---- src/WatchDogs/WatchDogSAMD.h | 4 ++-- 9 files changed, 24 insertions(+), 18 deletions(-) diff --git a/ChangeLog.md b/ChangeLog.md index 9698842ea..6e69c7f8a 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -72,12 +72,12 @@ These values should generally be set in the specific sensor constructors and onl ### Removed -- Removed the unused `_maxSamplesToAverage` parameter of the VariableArray and the `countMaxToAverage()` function which set the parameter. -- Removed unnecessary copy doc calls for inherited functions and properties. -- Removed all overrides of the powerUp and powerDown functions that are no longer needed since all sensors have two power pins built in. -- Removed references to the EnviroDIY data portal. -- Removed all defines from examples sketches. -Defining values to be used by TinyGSM and/or the MQTT library here in addition to any defines in the ModSensorConfig.h or in a build configuration can lead to One Definition Rule violations because the define values are used when creating the classes from the templates in TinyGSM. +- Unused `_maxSamplesToAverage` parameter of the VariableArray and the `countMaxToAverage()` function. +- Unnecessary copy doc calls for inherited functions and properties. +- All overrides of the powerUp and powerDown functions that are no longer needed since all sensors have two power pins built in. +- References to the EnviroDIY data portal. +- All defines from example sketches. + - Defining values to be used by TinyGSM and/or the MQTT library here in addition to any defines in ModSensorConfig.h or in a build configuration can lead to One Definition Rule violations because the define values are used when creating the classes from the templates in TinyGSM. ### Fixed diff --git a/cspell.json b/cspell.json index c4f7fcabd..c4dc0c6fa 100644 --- a/cspell.json +++ b/cspell.json @@ -173,6 +173,7 @@ "micromoles", "microsiemen", "microsiemens", + "microvolts", "milliamp", "milliwatt", "Modbus", diff --git a/docs/Further-Reading/Sleep-Configurations.md b/docs/Further-Reading/Sleep-Configurations.md index 037723256..48c3d8fcc 100644 --- a/docs/Further-Reading/Sleep-Configurations.md +++ b/docs/Further-Reading/Sleep-Configurations.md @@ -187,7 +187,7 @@ RESETN is a dedicated pin. > [!NOTE] > You can disable pin tri-state by calling `Logger::disablePinTristate(true)`. > You can re-enable pin tri-state by calling `Logger::disablePinTristate(false)`. -> No pin modes are **not** changed when the `disablePinTristate()` function is called, only when the `systemSleep()` function is called. +> Pin modes are not changed when `disablePinTristate()` is called; they are only changed when `systemSleep()` is called. To prevent power draw by any external pins during sleep, Modular Sensors sets all pins except the RTC interrupt pins to "tri-state." Tri-state means that for *all* pins: diff --git a/examples/EnviroDIY_Monitoring_Kit/EnviroDIY_Monitoring_Kit.ino b/examples/EnviroDIY_Monitoring_Kit/EnviroDIY_Monitoring_Kit.ino index b466b4790..b9913e126 100644 --- a/examples/EnviroDIY_Monitoring_Kit/EnviroDIY_Monitoring_Kit.ino +++ b/examples/EnviroDIY_Monitoring_Kit/EnviroDIY_Monitoring_Kit.ino @@ -476,8 +476,10 @@ void setup() { F("baud. This will fail if the baud is mismatched..")); modemSerial.begin(modemBaud); modem.modemWake(); // NOTE: This will also set up the modem - // WARNING: PLEASE REMOVE AUTOBAUDING FOR PRODUCTION CODE! + // WARNING: PLEASE REMOVE BAUD RATE DETECTION/FORCING FOR PRODUCTION CODE! if (!modem.gsmModem.testAT()) { + // If the AT command test fails, chances are it's a baud rate issue. Try + // to detect the baud rate and force the baud rate to the correct one. PRINTOUT(F("Attempting to force the modem baud rate.")); modem.gsmModem.forceModemBaud(modemSerial, static_cast(modemBaud)); @@ -491,8 +493,10 @@ void setup() { modem.setModemResetLevel(HIGH); // ModuleFun Bee inverts the signal PRINTOUT(F("Waking modem and setting Cellular Carrier Options...")); modem.modemWake(); // NOTE: This will also set up the modem - // WARNING: PLEASE REMOVE AUTOBAUDING FOR PRODUCTION CODE! + // WARNING: PLEASE REMOVE BAUD RATE DETECTION/FORCING FOR PRODUCTION CODE! if (!modem.gsmModem.testAT()) { + // If the AT command test fails, chances are it's a baud rate issue. Try + // to detect the baud rate and force the baud rate to the correct one. PRINTOUT(F("Attempting to force the modem baud rate.")); modem.gsmModem.forceModemBaud(modemSerial, static_cast(modemBaud)); diff --git a/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_2G/ReadMe.md b/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_2G/ReadMe.md index fe6673dfa..294a67313 100644 --- a/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_2G/ReadMe.md +++ b/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_2G/ReadMe.md @@ -51,7 +51,7 @@ _______ ### Set the logger ID -- Change the text `YourLoggerID` in this section of code to your loggerID. +- Change the text `YourLoggerID` in this section of code to your logger ID. For most DRWI installations, the logger ID was assigned by the Stroud Water Research Center before the station was built. ```cpp diff --git a/examples/OutdatedExamples/simple_logging_LearnEnviroDIY/ReadMe.md b/examples/OutdatedExamples/simple_logging_LearnEnviroDIY/ReadMe.md index 53207cc82..87500d61c 100644 --- a/examples/OutdatedExamples/simple_logging_LearnEnviroDIY/ReadMe.md +++ b/examples/OutdatedExamples/simple_logging_LearnEnviroDIY/ReadMe.md @@ -6,7 +6,7 @@ The processor then goes to sleep between readings. This example calls on two of the sensors available in this library. The example may be run exactly as written. -This is the example you should use to deploy a logger somewhere where you don't want or have access to a way of streaming live data and you won't want to upload data to Monitor My Watershed. +Use this example to deploy a logger when you cannot stream live data or do not want to upload data to Monitor My Watershed. _______ diff --git a/examples/ReadMe.md b/examples/ReadMe.md index 31d445112..2c5cabef1 100644 --- a/examples/ReadMe.md +++ b/examples/ReadMe.md @@ -164,7 +164,8 @@ The exclusion of the modem and publisher simplifies the code from the other DRWI #### DRWI CitSci (2G) -The 2G DRWI Citizen Science example uses the sensors and equipment found on older stations used in the DRWI Citizen Science project prior to 2020. The 2G GPRSbee boards no longer function in the USA, so this code should not be used and is only provided to archival and reference purposes. +The 2G DRWI Citizen Science example uses the sensors and equipment found on older stations used in the DRWI Citizen Science project before 2020. +The 2G GPRSbee boards no longer function in the USA, so this code should not be used and is only provided to archival and reference purposes. It includes a Meter Hydros 21 (formerly know as a Decagon CTD), a Campbell OBS3+, and a Sodaq GPRSBee for communication. The results are saved to the SD card and posted to Monitor My Watershed. The only difference between this and the other cellular DRWI examples is the type of modem used. diff --git a/src/VariableBase.h b/src/VariableBase.h index dac62be29..025f989d0 100644 --- a/src/VariableBase.h +++ b/src/VariableBase.h @@ -339,16 +339,16 @@ class Variable { void setVarCode(const char* varCode); // This gets/sets the variable UUID, if one has been assigned /** - * @brief Get the customized code for the variable + * @brief Get the variable's UUID as a String * - * @return The customized code for the variable + * @return The variable's UUID as a String */ String getVarUUIDString(void); // This gets/sets the variable UUID, if one has been assigned /** - * @brief Get the customized code for the variable + * @brief Get the variable's UUID as a C-style string * - * @return The customized code for the variable + * @return The variable's UUID as a const char* (or nullptr if not assigned) */ const char* getVarUUID(void); /** diff --git a/src/WatchDogs/WatchDogSAMD.h b/src/WatchDogs/WatchDogSAMD.h index d85b0b491..d43e030a0 100644 --- a/src/WatchDogs/WatchDogSAMD.h +++ b/src/WatchDogs/WatchDogSAMD.h @@ -146,11 +146,11 @@ class extendedWatchDogSAMD { static void clearWDTInterrupt(); /** - * @brief Wait for the WDT config bit sync to finish.+ + * @brief Wait for the WDT config bit sync to finish. */ static void inline waitForWDTBitSync(); /** - * @brief Wait for the GCLK config bit sync to finish.+ + * @brief Wait for the GCLK config bit sync to finish. */ static void inline waitForGCLKBitSync(); From 6c4c3f0a4360923caef7a17fd35151f9494c0b3f Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Fri, 20 Feb 2026 11:52:18 -0500 Subject: [PATCH 254/533] Correct stabiliztion time Signed-off-by: Sara Damiano --- src/sensors/GeoluxHydroCam.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sensors/GeoluxHydroCam.cpp b/src/sensors/GeoluxHydroCam.cpp index 4b961a482..b725c8cd3 100644 --- a/src/sensors/GeoluxHydroCam.cpp +++ b/src/sensors/GeoluxHydroCam.cpp @@ -349,7 +349,7 @@ bool GeoluxHydroCam::isStable(bool debug) { uint32_t elapsed_since_wake_up = millis() - _millisSensorActivated; uint32_t minTime = _alwaysAutoFocus ? HYDROCAM_AUTOFOCUS_TIME_MS + _stabilizationTime_ms - : 0L; + : _stabilizationTime_ms; uint32_t maxTime = _alwaysAutoFocus ? HYDROCAM_AUTOFOCUS_TIME_MAX + HYDROCAM_STABILIZATION_TIME_MAX : HYDROCAM_STABILIZATION_TIME_MAX; From 97283d67eb409399102e8cd90f8e487fd5a9b49b Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Fri, 20 Feb 2026 11:52:49 -0500 Subject: [PATCH 255/533] Really fix up the (no longer made) PTRedox Signed-off-by: Sara Damiano --- src/sensors/PaleoTerraRedox.cpp | 76 +++++++++++++++++++-------------- src/sensors/PaleoTerraRedox.h | 3 ++ 2 files changed, 47 insertions(+), 32 deletions(-) diff --git a/src/sensors/PaleoTerraRedox.cpp b/src/sensors/PaleoTerraRedox.cpp index c3e50bcbc..2296f5240 100644 --- a/src/sensors/PaleoTerraRedox.cpp +++ b/src/sensors/PaleoTerraRedox.cpp @@ -102,17 +102,24 @@ bool PaleoTerraRedox::addSingleMeasurementResult(void) { return bumpMeasurementAttemptCount(false); } - bool success = false; - - byte config = 0; // Data transfer values - - float res = 0; // Calculated voltage in uV + bool success = false; + byte config = 0; // Returned config + int32_t adcValue = 0; // Raw ADC value from the sensor + float res = -9999.0; // Calculated voltage in uV byte i2c_status; _i2c->beginTransmission(_i2cAddressHex); - _i2c->write(0b10001100); // initiate conversion, One-Shot mode, 18 - // bits, PGA x1 + // When writing config: + // - Bit 7: RDY (**1** = initiate conversion, 0 = no effect) + // - Bit 6-5: No effect on the MCP3421 (set both to 0) + // - Bit 4: O/C (1 = Continuous mode, **0** = One-Shot mode) + // - Bits 3-2: S1, S0 (00 = 12-bit/240 SPS, 01 = 14-bit/60 SPS, 10 = + // 16-bit/15 SPS, **11** = 18-bit/3.75 SPS) + // - Bits 1-0: G1, G0 (**00** = PGA x1, 01 = PGA x2, 10 = PGA x4, 11 = PGA + // x8) + _i2c->write( + 0b10001100); // initiate conversion, One-Shot mode, 18 bits, PGA x1 i2c_status = _i2c->endTransmission(); // fail if transmission error if (i2c_status != 0) { return bumpMeasurementAttemptCount(false); } @@ -124,34 +131,39 @@ bool PaleoTerraRedox::addSingleMeasurementResult(void) { if (_i2c->requestFrom(int(_i2cAddressHex), 4) != 4) { return bumpMeasurementAttemptCount(false); } - byte res1 = _i2c->read(); - byte res2 = _i2c->read(); - byte res3 = _i2c->read(); - config = _i2c->read(); - - res = 0; + // per the datasheet, in 18 bit mode: + // byte 1: [MMMMMM D17 D16 (1st data byte] + // byte 2: [ D15 ~ D8 (2nd data byte)] + // byte 3: [ D7 ~ D0 (3rd data byte)] + // byte 4: [config byte: RDY, C1, C0, O/C, S1, S0, G1, G0] + // NOTE: D17 is MSB (= sign bit), M is repeated MSB of the data byte. + byte res1 = _i2c->read(); // byte 1: [MMMMMM D17 D16] + byte res2 = _i2c->read(); // byte 2: [ D15 ~ D8 ] + byte res3 = _i2c->read(); // byte 3: [ D7 ~ D0 ] + config = _i2c->read(); // byte 4: [config byte] + + res = 0; // Assemble the 18-bit raw sample from the three bytes - uint32_t rawSample = (static_cast(bitRead(res1, 0)) << 16) | - (static_cast(res2) << 8) | - static_cast(res3); - - // Check if this is a negative value (sign bit D17 is set) - if (bitRead(res1, 1)) { - // Sign-extend the 18-bit value to get correct negative magnitude - int32_t signedSample = rawSample | 0xFFFC0000; // Sign extend from bit 17 - res = signedSample * 0.015625; // 15.625 uV per LSB - } else { - // Positive value - res = rawSample * 0.015625; // 15.625 uV per LSB + // Only use the lower 2 bits of res1 (D17 D16), ignore sign-extension bits + adcValue = ((res1 & 0x03) << 16) // extract D17 D16 and shift to position + | (res2 << 8) // shift res2 up to middle byte + | res3; // res3 is already in the right place as the LSB + + // Check if this is a negative value (sign bit 17 is set) + if (res1 & 0x02) { // Test bit 17 + // Sign-extend the 18-bit value to get correct negative magnitude + adcValue |= 0xFF000000; // Sign extend from bit 17 } - /// @todo ADD FAILURE CONDITIONS for PaleoTerraRedox!! - if (isnan(res)) - res = -9999; // list a failure if the sensor returns nan (not sure - // how this would happen, keep to be safe) - else if (res == 0 && i2c_status == 0 && config == 0) - res = -9999; // List a failure when the sensor is not connected - success = res != -9999; + // convert the raw ADC value to voltage in microvolts (uV) + res = adcValue * 0.015625; // 15.625 uV per LSB + + MS_DBG(F("Raw ADC reading in bits:"), adcValue); + MS_DBG(F("Config byte:"), config); + MS_DBG(F("Calculated voltage in uV:"), res); + + success = (!isnan(res)) && + !(adcValue == 0 && i2c_status == 0 && config == 0); if (success) { // Store the results in the sensorValues array verifyAndAddMeasurementResult(PTR_VOLTAGE_VAR_NUM, res); diff --git a/src/sensors/PaleoTerraRedox.h b/src/sensors/PaleoTerraRedox.h index 89d20ad04..1af1aab59 100644 --- a/src/sensors/PaleoTerraRedox.h +++ b/src/sensors/PaleoTerraRedox.h @@ -15,6 +15,9 @@ * This depends on Testato's * [SoftwareWire](https://github.com/Testato/SoftwareWire) library if software * I2C is needed. + * + * @note These sensors are no longer being produced, but this code is being + * maintained for users who have them in their monitoring kits. */ /* clang-format off */ /** From 8d3e9f282696e58fa5fac0ad6f5206c4d12f100c Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Fri, 20 Feb 2026 13:19:04 -0500 Subject: [PATCH 256/533] Add supply voltage as a parameter for the TI ADS Signed-off-by: Sara Damiano --- src/sensors/TIADS1x15.cpp | 34 +++++++++++++++++++++++++++++----- src/sensors/TIADS1x15.h | 26 +++++++++++++++++++++++++- 2 files changed, 54 insertions(+), 6 deletions(-) diff --git a/src/sensors/TIADS1x15.cpp b/src/sensors/TIADS1x15.cpp index 5fc05018c..9df50da6c 100644 --- a/src/sensors/TIADS1x15.cpp +++ b/src/sensors/TIADS1x15.cpp @@ -18,13 +18,15 @@ // The constructor - need the power pin the data pin, and gain if non standard TIADS1x15::TIADS1x15(int8_t powerPin, uint8_t adsChannel, float gain, - uint8_t i2cAddress, uint8_t measurementsToAverage) + uint8_t i2cAddress, uint8_t measurementsToAverage, + float adsSupplyVoltage_V) : Sensor("TIADS1x15", TIADS1X15_NUM_VARIABLES, TIADS1X15_WARM_UP_TIME_MS, TIADS1X15_STABILIZATION_TIME_MS, TIADS1X15_MEASUREMENT_TIME_MS, powerPin, -1, measurementsToAverage, TIADS1X15_INC_CALC_VARIABLES), _adsChannel(adsChannel), _gain(gain), - _i2cAddress(i2cAddress) {} + _i2cAddress(i2cAddress), + _adsSupplyVoltage_V(adsSupplyVoltage_V) {} // Destructor TIADS1x15::~TIADS1x15() {} @@ -91,16 +93,38 @@ bool TIADS1x15::addSingleMeasurementResult(void) { MS_DBG(F(" ads.readADC_SingleEnded("), _adsChannel, F("):"), adcCounts, '=', adcVoltage); - // @todo Verify the range based on the actual power supplied to the ADS. - // Here we are using the range of the ADS when it is powered at 3.3V - if (adcVoltage < 3.6 && adcVoltage > -0.3) { + // Verify the range based on the actual power supplied to the ADS. + // Valid range is approximately -0.3V to (supply voltage + 0.3V) with + // absolute maximum of 5.5V per datasheet + float minValidVoltage = -0.3; + float maxValidVoltage = _adsSupplyVoltage_V + 0.3; + if (maxValidVoltage > 5.5) { + maxValidVoltage = 5.5; // Absolute maximum per datasheet + } + + MS_DBG(F(" ADS supply voltage:"), _adsSupplyVoltage_V, F("V")); + MS_DBG(F(" Valid voltage range:"), minValidVoltage, F("V to"), + maxValidVoltage, F("V")); + + if (adcVoltage < maxValidVoltage && adcVoltage > minValidVoltage) { // Apply the gain calculation, with a default gain of 10 V/V Gain calibResult = adcVoltage * _gain; MS_DBG(F(" calibResult:"), calibResult); verifyAndAddMeasurementResult(TIADS1X15_VAR_NUM, calibResult); success = true; + } else { + MS_DBG(F(" ADC voltage "), adcVoltage, F("V out of valid range")); } // Return success value when finished return bumpMeasurementAttemptCount(success); } + +// Setter and getter methods for ADS supply voltage +void TIADS1x15::setADSSupplyVoltage(float adsSupplyVoltage_V) { + _adsSupplyVoltage_V = adsSupplyVoltage_V; +} + +float TIADS1x15::getADSSupplyVoltage(void) { + return _adsSupplyVoltage_V; +} diff --git a/src/sensors/TIADS1x15.h b/src/sensors/TIADS1x15.h index cdd54400d..5b3cbe780 100644 --- a/src/sensors/TIADS1x15.h +++ b/src/sensors/TIADS1x15.h @@ -146,6 +146,9 @@ // Include the debugging config #include "ModSensorDebugConfig.h" +// Include known processor settings for default operating voltage +#include "sensors/KnownProcessors.h" + // Define the print label[s] for the debugger #ifdef MS_TIADS1X15_DEBUG #define MS_DEBUGGING_STD "TIADS1x15" @@ -287,10 +290,13 @@ class TIADS1x15 : public Sensor { * @param measurementsToAverage The number of measurements to take and * average before giving a "final" result from the sensor; optional with a * default value of 1. + * @param adsSupplyVoltage_V The power supply voltage for the ADS1x15 in volts; + * defaults to the processor operating voltage from KnownProcessors.h */ TIADS1x15(int8_t powerPin, uint8_t adsChannel, float gain = 1, uint8_t i2cAddress = ADS1115_ADDRESS, - uint8_t measurementsToAverage = 1); + uint8_t measurementsToAverage = 1, + float adsSupplyVoltage_V = OPERATING_VOLTAGE); /** * @brief Destroy the External Voltage object */ @@ -300,6 +306,20 @@ class TIADS1x15 : public Sensor { bool addSingleMeasurementResult(void) override; + /** + * @brief Set the power supply voltage for the ADS1x15 + * + * @param adsSupplyVoltage_V The power supply voltage in volts (2.0-5.5V range) + */ + void setADSSupplyVoltage(float adsSupplyVoltage_V); + + /** + * @brief Get the power supply voltage for the ADS1x15 + * + * @return The power supply voltage in volts + */ + float getADSSupplyVoltage(void); + private: /** * @brief Internal reference to the ADS channel number of the device @@ -314,6 +334,10 @@ class TIADS1x15 : public Sensor { * @brief Internal reference to the I2C address of the TI-ADS1x15 */ uint8_t _i2cAddress; + /** + * @brief Internal reference to the power supply voltage of the TI-ADS1x15 + */ + float _adsSupplyVoltage_V; }; /** From 9d0eab86e4617cfda54e685e90eecdcfccd3009a Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Fri, 20 Feb 2026 13:37:36 -0500 Subject: [PATCH 257/533] Rename the gain to voltageMultipler because it really is for an external divider Signed-off-by: Sara Damiano --- examples/menu_a_la_carte/menu_a_la_carte.ino | 8 ++--- src/sensors/TIADS1x15.cpp | 35 ++++++++++---------- src/sensors/TIADS1x15.h | 31 +++++++++-------- 3 files changed, 39 insertions(+), 35 deletions(-) diff --git a/examples/menu_a_la_carte/menu_a_la_carte.ino b/examples/menu_a_la_carte/menu_a_la_carte.ino index 4eb143a10..49c58bde6 100644 --- a/examples/menu_a_la_carte/menu_a_la_carte.ino +++ b/examples/menu_a_la_carte/menu_a_la_carte.ino @@ -1607,12 +1607,12 @@ Variable* alsPt19Lux = new EverlightALSPT19_Illuminance( // NOTE: Use -1 for any pins that don't apply or aren't being used. const int8_t ADSPower = sensorPowerPin; // Power pin const int8_t ADSChannel = 2; // The ADS channel of interest -const float dividerGain = 10; // Gain setting if using a voltage divider -const uint8_t evADSi2c_addr = 0x48; // The I2C address of the ADS1115 ADC -const uint8_t VoltReadsToAvg = 1; // Only read one sample +const float voltageMultiplier = 10; // Voltage multiplier if using a voltage divider +const uint8_t evADSi2c_addr = 0x48; // The I2C address of the ADS1115 ADC +const uint8_t VoltReadsToAvg = 1; // Only read one sample // Create a TI ADS1x15 sensor object -TIADS1x15 ads1x15(ADSPower, ADSChannel, dividerGain, evADSi2c_addr, +TIADS1x15 ads1x15(ADSPower, ADSChannel, voltageMultiplier, evADSi2c_addr, VoltReadsToAvg); // Create a voltage variable pointer diff --git a/src/sensors/TIADS1x15.cpp b/src/sensors/TIADS1x15.cpp index 9df50da6c..a21f225ab 100644 --- a/src/sensors/TIADS1x15.cpp +++ b/src/sensors/TIADS1x15.cpp @@ -16,17 +16,18 @@ #include -// The constructor - need the power pin the data pin, and gain if non standard -TIADS1x15::TIADS1x15(int8_t powerPin, uint8_t adsChannel, float gain, - uint8_t i2cAddress, uint8_t measurementsToAverage, - float adsSupplyVoltage_V) +// The constructor - need the power pin the data pin, and voltage multiplier if +// non standard +TIADS1x15::TIADS1x15(int8_t powerPin, uint8_t adsChannel, + float voltageMultiplier, uint8_t i2cAddress, + uint8_t measurementsToAverage, float adsSupplyVoltage) : Sensor("TIADS1x15", TIADS1X15_NUM_VARIABLES, TIADS1X15_WARM_UP_TIME_MS, TIADS1X15_STABILIZATION_TIME_MS, TIADS1X15_MEASUREMENT_TIME_MS, powerPin, -1, measurementsToAverage, TIADS1X15_INC_CALC_VARIABLES), _adsChannel(adsChannel), - _gain(gain), + _voltageMultiplier(voltageMultiplier), _i2cAddress(i2cAddress), - _adsSupplyVoltage_V(adsSupplyVoltage_V) {} + _adsSupplyVoltage(adsSupplyVoltage) {} // Destructor TIADS1x15::~TIADS1x15() {} @@ -53,13 +54,13 @@ bool TIADS1x15::addSingleMeasurementResult(void) { bool success = false; int16_t adcCounts = -9999; float adcVoltage = -9999; - float calibResult = -9999; + float scaledResult = -9999; MS_DBG(getSensorNameAndLocation(), F("is reporting:")); // Create an auxiliary ADC object // We create and set up the ADC object here so that each sensor using -// the ADC may set the gain appropriately without effecting others. +// the ADC may set the internal gain appropriately without affecting others. #ifndef MS_USE_ADS1015 Adafruit_ADS1115 ads; // Use this for the 16-bit version #else @@ -97,20 +98,20 @@ bool TIADS1x15::addSingleMeasurementResult(void) { // Valid range is approximately -0.3V to (supply voltage + 0.3V) with // absolute maximum of 5.5V per datasheet float minValidVoltage = -0.3; - float maxValidVoltage = _adsSupplyVoltage_V + 0.3; + float maxValidVoltage = _adsSupplyVoltage + 0.3; if (maxValidVoltage > 5.5) { maxValidVoltage = 5.5; // Absolute maximum per datasheet } - MS_DBG(F(" ADS supply voltage:"), _adsSupplyVoltage_V, F("V")); + MS_DBG(F(" ADS supply voltage:"), _adsSupplyVoltage, F("V")); MS_DBG(F(" Valid voltage range:"), minValidVoltage, F("V to"), maxValidVoltage, F("V")); if (adcVoltage < maxValidVoltage && adcVoltage > minValidVoltage) { - // Apply the gain calculation, with a default gain of 10 V/V Gain - calibResult = adcVoltage * _gain; - MS_DBG(F(" calibResult:"), calibResult); - verifyAndAddMeasurementResult(TIADS1X15_VAR_NUM, calibResult); + // Apply the voltage multiplier scaling, with a default multiplier of 1 + scaledResult = adcVoltage * _voltageMultiplier; + MS_DBG(F(" scaledResult:"), scaledResult); + verifyAndAddMeasurementResult(TIADS1X15_VAR_NUM, scaledResult); success = true; } else { MS_DBG(F(" ADC voltage "), adcVoltage, F("V out of valid range")); @@ -121,10 +122,10 @@ bool TIADS1x15::addSingleMeasurementResult(void) { } // Setter and getter methods for ADS supply voltage -void TIADS1x15::setADSSupplyVoltage(float adsSupplyVoltage_V) { - _adsSupplyVoltage_V = adsSupplyVoltage_V; +void TIADS1x15::setADSSupplyVoltage(float adsSupplyVoltage) { + _adsSupplyVoltage = adsSupplyVoltage; } float TIADS1x15::getADSSupplyVoltage(void) { - return _adsSupplyVoltage_V; + return _adsSupplyVoltage; } diff --git a/src/sensors/TIADS1x15.h b/src/sensors/TIADS1x15.h index 5b3cbe780..bb0960993 100644 --- a/src/sensors/TIADS1x15.h +++ b/src/sensors/TIADS1x15.h @@ -112,8 +112,8 @@ * If you are working with an EnviroDIY Mayfly, the easiest voltage divider to * connect is the Grove voltage divider sold by seeed studio. The grove voltage * divider is a simple voltage divider designed to measure high external - * voltages on a low voltage ADC. This module employs a variable gain via two - * pairs of voltage dividers, and a unity gain amplification to reduce output + * voltages on a low voltage ADC. This module employs a variable voltage multiplier + * via two pairs of voltage dividers, and a unity gain amplification to reduce output * impedance of the module. * * @section sensor_ads1x15_datasheet Sensor Datasheet @@ -274,8 +274,9 @@ class TIADS1x15 : public Sensor { * @brief Construct a new External Voltage object - need the power pin and * the data channel on the ADS1x15. * - * The gain value, I2C address, and number of measurements to average are - * optional. If nothing is given a 1x gain is used. + * The voltage multiplier value, I2C address, and number of measurements to + * average are optional. If nothing is given a 1x voltage multiplier is + * used. * * @note ModularSensors only supports connecting the ADS1x15 to the primary * hardware I2C instance defined in the Arduino core. Connecting the ADS to @@ -284,19 +285,20 @@ class TIADS1x15 : public Sensor { * @param powerPin The pin on the mcu controlling power to the sensor * Use -1 if it is continuously powered. * @param adsChannel The ADS channel of interest (0-3). - * @param gain The gain multiplier, if a voltage divider is used. + * @param voltageMultiplier The voltage multiplier, if a voltage divider is + * used. * @param i2cAddress The I2C address of the ADS 1x15, default is 0x48 (ADDR * = GND) * @param measurementsToAverage The number of measurements to take and * average before giving a "final" result from the sensor; optional with a * default value of 1. - * @param adsSupplyVoltage_V The power supply voltage for the ADS1x15 in volts; - * defaults to the processor operating voltage from KnownProcessors.h + * @param adsSupplyVoltage The power supply voltage for the ADS1x15 in + * volts; defaults to the processor operating voltage from KnownProcessors.h */ - TIADS1x15(int8_t powerPin, uint8_t adsChannel, float gain = 1, + TIADS1x15(int8_t powerPin, uint8_t adsChannel, float voltageMultiplier = 1, uint8_t i2cAddress = ADS1115_ADDRESS, uint8_t measurementsToAverage = 1, - float adsSupplyVoltage_V = OPERATING_VOLTAGE); + float adsSupplyVoltage = OPERATING_VOLTAGE); /** * @brief Destroy the External Voltage object */ @@ -309,9 +311,10 @@ class TIADS1x15 : public Sensor { /** * @brief Set the power supply voltage for the ADS1x15 * - * @param adsSupplyVoltage_V The power supply voltage in volts (2.0-5.5V range) + * @param adsSupplyVoltage The power supply voltage in volts (2.0-5.5V + * range) */ - void setADSSupplyVoltage(float adsSupplyVoltage_V); + void setADSSupplyVoltage(float adsSupplyVoltage); /** * @brief Get the power supply voltage for the ADS1x15 @@ -327,9 +330,9 @@ class TIADS1x15 : public Sensor { */ uint8_t _adsChannel; /** - * @brief Internal reference to the gain setting for the TI-ADS1x15 + * @brief Internal reference to the voltage multiplier for the TI-ADS1x15 */ - float _gain; + float _voltageMultiplier; /** * @brief Internal reference to the I2C address of the TI-ADS1x15 */ @@ -337,7 +340,7 @@ class TIADS1x15 : public Sensor { /** * @brief Internal reference to the power supply voltage of the TI-ADS1x15 */ - float _adsSupplyVoltage_V; + float _adsSupplyVoltage; }; /** From 5444b5f49c08ecfca71fce33d7bdeac680366c54 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Fri, 20 Feb 2026 13:42:01 -0500 Subject: [PATCH 258/533] Update docs on range, accuracy, resolution Signed-off-by: Sara Damiano --- src/sensors/TIADS1x15.h | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/src/sensors/TIADS1x15.h b/src/sensors/TIADS1x15.h index bb0960993..f2e95f213 100644 --- a/src/sensors/TIADS1x15.h +++ b/src/sensors/TIADS1x15.h @@ -216,25 +216,20 @@ * @anchor sensor_ads1x15_volt * @name Voltage * The volt variable from a TI ADS1x15 analog-to-digital converter (ADC) - * - Range: - * - without voltage divider: 0 - 3.6V [when ADC is powered at 3.3V] - * - 1/gain = 3x: 0.3 ~ 12.9V - * - 1/gain = 10x: 1 ~ 43V + * - Range (with no external voltage divider): + * - 0 - min(4.096V, supply voltage + 0.3V) voltage + 0.3V) * - Accuracy: * - 16-bit ADC (ADS1115): < 0.25% (gain error), <0.25 LSB (offset error) * - 12-bit ADC (ADS1015, using build flag ```MS_USE_ADS1015```): < 0.15% * (gain error), <3 LSB (offset error) - * - Resolution: + * - Resolution (based on ADC's 4.096V internal reference with 1x gain and no + * external voltage divider): * - 16-bit ADC (ADS1115): * - @m_span{m-dim}@ref #TIADS1X15_RESOLUTION = 4@m_endspan - * - without voltage divider: 0.125 mV - * - 1/gain = 3x: 0.375 mV - * - 1/gain = 10x: 1.25 mV + * - 0.125 mV * - 12-bit ADC (ADS1015, using build flag ```MS_USE_ADS1015```): * - @m_span{m-dim}@ref #TIADS1X15_RESOLUTION = 1@m_endspan - * - without voltage divider: 2 mV - * - 1/gain = 3x: 6 mV - * - 1/gain = 10x: 20 mV * + * - 2 mV * * {{ @ref TIADS1x15_Voltage::TIADS1x15_Voltage }} */ From 75fb5f1b8615f108dfc813512396abe04dd27e7f Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Fri, 20 Feb 2026 13:49:49 -0500 Subject: [PATCH 259/533] Add parameter for the ads internal Signed-off-by: Sara Damiano --- examples/menu_a_la_carte/menu_a_la_carte.ino | 16 +++++----- src/sensors/TIADS1x15.cpp | 24 +++++++++----- src/sensors/TIADS1x15.h | 33 +++++++++++++++++--- 3 files changed, 54 insertions(+), 19 deletions(-) diff --git a/examples/menu_a_la_carte/menu_a_la_carte.ino b/examples/menu_a_la_carte/menu_a_la_carte.ino index 49c58bde6..c2fbe8e2d 100644 --- a/examples/menu_a_la_carte/menu_a_la_carte.ino +++ b/examples/menu_a_la_carte/menu_a_la_carte.ino @@ -1605,15 +1605,17 @@ Variable* alsPt19Lux = new EverlightALSPT19_Illuminance( #include // NOTE: Use -1 for any pins that don't apply or aren't being used. -const int8_t ADSPower = sensorPowerPin; // Power pin -const int8_t ADSChannel = 2; // The ADS channel of interest -const float voltageMultiplier = 10; // Voltage multiplier if using a voltage divider -const uint8_t evADSi2c_addr = 0x48; // The I2C address of the ADS1115 ADC -const uint8_t VoltReadsToAvg = 1; // Only read one sample +const int8_t ADSPower = sensorPowerPin; // Power pin +const int8_t ADSChannel = 2; // The ADS channel of interest +const float voltageMultiplier = + 10; // Voltage multiplier if using a voltage divider +const adsGain_t adsGain = GAIN_ONE; // The internal gain setting for the ADS +const uint8_t evADSi2c_addr = 0x48; // The I2C address of the ADS1115 ADC +const uint8_t VoltReadsToAvg = 1; // Only read one sample // Create a TI ADS1x15 sensor object -TIADS1x15 ads1x15(ADSPower, ADSChannel, voltageMultiplier, evADSi2c_addr, - VoltReadsToAvg); +TIADS1x15 ads1x15(ADSPower, ADSChannel, voltageMultiplier, adsGain, + evADSi2c_addr, VoltReadsToAvg); // Create a voltage variable pointer Variable* ads1x15Volt = diff --git a/src/sensors/TIADS1x15.cpp b/src/sensors/TIADS1x15.cpp index a21f225ab..a0e95fa91 100644 --- a/src/sensors/TIADS1x15.cpp +++ b/src/sensors/TIADS1x15.cpp @@ -19,13 +19,15 @@ // The constructor - need the power pin the data pin, and voltage multiplier if // non standard TIADS1x15::TIADS1x15(int8_t powerPin, uint8_t adsChannel, - float voltageMultiplier, uint8_t i2cAddress, - uint8_t measurementsToAverage, float adsSupplyVoltage) + float voltageMultiplier, adsGain_t adsGain, + uint8_t i2cAddress, uint8_t measurementsToAverage, + float adsSupplyVoltage) : Sensor("TIADS1x15", TIADS1X15_NUM_VARIABLES, TIADS1X15_WARM_UP_TIME_MS, TIADS1X15_STABILIZATION_TIME_MS, TIADS1X15_MEASUREMENT_TIME_MS, powerPin, -1, measurementsToAverage, TIADS1X15_INC_CALC_VARIABLES), _adsChannel(adsChannel), _voltageMultiplier(voltageMultiplier), + _adsGain(adsGain), _i2cAddress(i2cAddress), _adsSupplyVoltage(adsSupplyVoltage) {} // Destructor @@ -51,9 +53,9 @@ bool TIADS1x15::addSingleMeasurementResult(void) { return bumpMeasurementAttemptCount(false); } - bool success = false; - int16_t adcCounts = -9999; - float adcVoltage = -9999; + bool success = false; + int16_t adcCounts = -9999; + float adcVoltage = -9999; float scaledResult = -9999; MS_DBG(getSensorNameAndLocation(), F("is reporting:")); @@ -76,8 +78,8 @@ bool TIADS1x15::addSingleMeasurementResult(void) { // - 1600 samples per second (625µs conversion time) // - 2/3 gain +/- 6.144V range (limited to VDD +0.3V max) - // Bump the gain up to 1x = +/- 4.096V range - ads.setGain(GAIN_ONE); + // Set the internal gain according to user configuration + ads.setGain(_adsGain); // Begin ADC, returns true if anything was detected at the address if (!ads.begin(_i2cAddress)) { MS_DBG(F(" ADC initialization failed at 0x"), @@ -129,3 +131,11 @@ void TIADS1x15::setADSSupplyVoltage(float adsSupplyVoltage) { float TIADS1x15::getADSSupplyVoltage(void) { return _adsSupplyVoltage; } + +void TIADS1x15::setADSGain(adsGain_t adsGain) { + _adsGain = adsGain; +} + +adsGain_t TIADS1x15::getADSGain(void) { + return _adsGain; +} diff --git a/src/sensors/TIADS1x15.h b/src/sensors/TIADS1x15.h index f2e95f213..0f3ac6b35 100644 --- a/src/sensors/TIADS1x15.h +++ b/src/sensors/TIADS1x15.h @@ -59,9 +59,9 @@ * use the fork instead. * * @section analog_ads1x15_specs Specifications - * @note *In all cases, we assume that the ADS1x15 is powered at 3.3V and set the ADC's internal gain to 1x. + * @note *In all cases, we assume that the ADS1x15 is powered at 3.3V by default with configurable internal gain settings. * - * This divides the bit resolution over the range of 0-4.096V. + * The default gain setting is 1x (GAIN_ONE) which divides the bit resolution over the range of 0-4.096V. * - Response time: < 1ms * - Resample time: 860 samples per second (~1.2ms) * - Range: @@ -162,6 +162,7 @@ // Include other in-library and external dependencies #include "VariableBase.h" #include "SensorBase.h" +#include /** @ingroup sensor_ads1x15 */ /**@{*/ @@ -282,6 +283,8 @@ class TIADS1x15 : public Sensor { * @param adsChannel The ADS channel of interest (0-3). * @param voltageMultiplier The voltage multiplier, if a voltage divider is * used. + * @param adsGain The internal gain setting of the ADS1x15; defaults to + * GAIN_ONE for +/- 4.096V range * @param i2cAddress The I2C address of the ADS 1x15, default is 0x48 (ADDR * = GND) * @param measurementsToAverage The number of measurements to take and @@ -291,9 +294,10 @@ class TIADS1x15 : public Sensor { * volts; defaults to the processor operating voltage from KnownProcessors.h */ TIADS1x15(int8_t powerPin, uint8_t adsChannel, float voltageMultiplier = 1, - uint8_t i2cAddress = ADS1115_ADDRESS, - uint8_t measurementsToAverage = 1, - float adsSupplyVoltage = OPERATING_VOLTAGE); + adsGain_t adsGain = GAIN_ONE, + uint8_t i2cAddress = ADS1115_ADDRESS, + uint8_t measurementsToAverage = 1, + float adsSupplyVoltage = OPERATING_VOLTAGE); /** * @brief Destroy the External Voltage object */ @@ -318,6 +322,21 @@ class TIADS1x15 : public Sensor { */ float getADSSupplyVoltage(void); + /** + * @brief Set the internal gain setting for the ADS1x15 + * + * @param adsGain The internal gain setting (GAIN_TWOTHIRDS, GAIN_ONE, + * GAIN_TWO, GAIN_FOUR, GAIN_EIGHT, GAIN_SIXTEEN) + */ + void setADSGain(adsGain_t adsGain); + + /** + * @brief Get the internal gain setting for the ADS1x15 + * + * @return The internal gain setting + */ + adsGain_t getADSGain(void); + private: /** * @brief Internal reference to the ADS channel number of the device @@ -328,6 +347,10 @@ class TIADS1x15 : public Sensor { * @brief Internal reference to the voltage multiplier for the TI-ADS1x15 */ float _voltageMultiplier; + /** + * @brief Internal reference to the internal gain setting of the TI-ADS1x15 + */ + adsGain_t _adsGain; /** * @brief Internal reference to the I2C address of the TI-ADS1x15 */ From 09554887426785671a48a4142b2366bcd7a3cdcd Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Fri, 20 Feb 2026 13:52:47 -0500 Subject: [PATCH 260/533] Add setters and getters for the voltage multiplier Signed-off-by: Sara Damiano --- src/sensors/ProcessorAnalog.cpp | 8 ++++++++ src/sensors/ProcessorAnalog.h | 16 ++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/src/sensors/ProcessorAnalog.cpp b/src/sensors/ProcessorAnalog.cpp index a473039dc..38d2b2392 100644 --- a/src/sensors/ProcessorAnalog.cpp +++ b/src/sensors/ProcessorAnalog.cpp @@ -65,3 +65,11 @@ bool ProcessorAnalog::addSingleMeasurementResult(void) { verifyAndAddMeasurementResult(PROCESSOR_ANALOG_VAR_NUM, sensorValue_analog); return bumpMeasurementAttemptCount(true); } + +void ProcessorAnalog::setVoltageMultiplier(float voltageMultiplier) { + _voltageMultiplier = voltageMultiplier; +} + +float ProcessorAnalog::getVoltageMultiplier(void) { + return _voltageMultiplier; +} diff --git a/src/sensors/ProcessorAnalog.h b/src/sensors/ProcessorAnalog.h index b9072683c..877e5ab98 100644 --- a/src/sensors/ProcessorAnalog.h +++ b/src/sensors/ProcessorAnalog.h @@ -194,6 +194,22 @@ class ProcessorAnalog : public Sensor { bool addSingleMeasurementResult(void) override; + /** + * @brief Set the voltage multiplier for the processor analog sensor + * + * @param voltageMultiplier Any multiplier needed to convert raw readings + * from analogRead() into true voltage values based on any resistors or + * voltage dividers + */ + void setVoltageMultiplier(float voltageMultiplier); + + /** + * @brief Get the voltage multiplier for the processor analog sensor + * + * @return The voltage multiplier value + */ + float getVoltageMultiplier(void); + private: float _voltageMultiplier; ///< Internal reference to any multiplier needed ///< to convert raw battery readings into true From 0d4b821813795ebeb2dc34ec2ed67d676cd688ec Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Fri, 20 Feb 2026 13:59:13 -0500 Subject: [PATCH 261/533] Make a separate function for getting the voltage Signed-off-by: Sara Damiano --- src/sensors/TIADS1x15.cpp | 26 +++++++++++++++++++------- src/sensors/TIADS1x15.h | 9 +++++++++ 2 files changed, 28 insertions(+), 7 deletions(-) diff --git a/src/sensors/TIADS1x15.cpp b/src/sensors/TIADS1x15.cpp index a0e95fa91..530d06099 100644 --- a/src/sensors/TIADS1x15.cpp +++ b/src/sensors/TIADS1x15.cpp @@ -53,13 +53,25 @@ bool TIADS1x15::addSingleMeasurementResult(void) { return bumpMeasurementAttemptCount(false); } + MS_DBG(getSensorNameAndLocation(), F("is reporting:")); + + float resultValue = -9999; + bool success = readVoltageSingleEnded(resultValue); + + if (success) { + verifyAndAddMeasurementResult(TIADS1X15_VAR_NUM, resultValue); + } + + // Return success value when finished + return bumpMeasurementAttemptCount(success); +} + +bool TIADS1x15::readVoltageSingleEnded(float& resultValue) { bool success = false; int16_t adcCounts = -9999; float adcVoltage = -9999; float scaledResult = -9999; - MS_DBG(getSensorNameAndLocation(), F("is reporting:")); - // Create an auxiliary ADC object // We create and set up the ADC object here so that each sensor using // the ADC may set the internal gain appropriately without affecting others. @@ -84,7 +96,7 @@ bool TIADS1x15::addSingleMeasurementResult(void) { if (!ads.begin(_i2cAddress)) { MS_DBG(F(" ADC initialization failed at 0x"), String(_i2cAddress, HEX)); - return bumpMeasurementAttemptCount(false); + return false; } // Read Analog to Digital Converter (ADC) @@ -113,14 +125,14 @@ bool TIADS1x15::addSingleMeasurementResult(void) { // Apply the voltage multiplier scaling, with a default multiplier of 1 scaledResult = adcVoltage * _voltageMultiplier; MS_DBG(F(" scaledResult:"), scaledResult); - verifyAndAddMeasurementResult(TIADS1X15_VAR_NUM, scaledResult); - success = true; + resultValue = scaledResult; + success = true; } else { MS_DBG(F(" ADC voltage "), adcVoltage, F("V out of valid range")); + resultValue = -9999; } - // Return success value when finished - return bumpMeasurementAttemptCount(success); + return success; } // Setter and getter methods for ADS supply voltage diff --git a/src/sensors/TIADS1x15.h b/src/sensors/TIADS1x15.h index 0f3ac6b35..d234e6274 100644 --- a/src/sensors/TIADS1x15.h +++ b/src/sensors/TIADS1x15.h @@ -337,6 +337,15 @@ class TIADS1x15 : public Sensor { */ adsGain_t getADSGain(void); + protected: + /** + * @brief Read a single-ended voltage measurement from the ADS1x15 + * + * @param resultValue Reference to store the resulting voltage measurement + * @return True if the voltage reading was successful and within valid range + */ + virtual bool readVoltageSingleEnded(float& resultValue); + private: /** * @brief Internal reference to the ADS channel number of the device From 93fab7e64d68e3af29b964f348787e5a8a21f545 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Fri, 20 Feb 2026 14:06:03 -0500 Subject: [PATCH 262/533] support differential readings Signed-off-by: Sara Damiano --- src/sensors/TIADS1x15.cpp | 114 +++++++++++++++++++++++++++++++++++++- src/sensors/TIADS1x15.h | 52 ++++++++++++++++- 2 files changed, 162 insertions(+), 4 deletions(-) diff --git a/src/sensors/TIADS1x15.cpp b/src/sensors/TIADS1x15.cpp index 530d06099..a8192a5df 100644 --- a/src/sensors/TIADS1x15.cpp +++ b/src/sensors/TIADS1x15.cpp @@ -26,6 +26,24 @@ TIADS1x15::TIADS1x15(int8_t powerPin, uint8_t adsChannel, TIADS1X15_STABILIZATION_TIME_MS, TIADS1X15_MEASUREMENT_TIME_MS, powerPin, -1, measurementsToAverage, TIADS1X15_INC_CALC_VARIABLES), _adsChannel(adsChannel), + _isDifferential(false), + _adsDiffMux(TIADS1X15_DIFF_MUX_0_1), // Default value, not used + _voltageMultiplier(voltageMultiplier), + _adsGain(adsGain), + _i2cAddress(i2cAddress), + _adsSupplyVoltage(adsSupplyVoltage) {} + +// Constructor for differential measurements +TIADS1x15::TIADS1x15(int8_t powerPin, tiads1x15_adsDiffMux_t adsDiffMux, + float voltageMultiplier, adsGain_t adsGain, + uint8_t i2cAddress, uint8_t measurementsToAverage, + float adsSupplyVoltage) + : Sensor("TIADS1x15", TIADS1X15_NUM_VARIABLES, TIADS1X15_WARM_UP_TIME_MS, + TIADS1X15_STABILIZATION_TIME_MS, TIADS1X15_MEASUREMENT_TIME_MS, + powerPin, -1, measurementsToAverage, TIADS1X15_INC_CALC_VARIABLES), + _adsChannel(0), // Not used for differential + _isDifferential(true), + _adsDiffMux(adsDiffMux), _voltageMultiplier(voltageMultiplier), _adsGain(adsGain), _i2cAddress(i2cAddress), @@ -41,8 +59,26 @@ String TIADS1x15::getSensorLocation(void) { String sensorLocation = F("ADS1015_0x"); #endif sensorLocation += String(_i2cAddress, HEX); - sensorLocation += F("_Channel"); - sensorLocation += String(_adsChannel); + if (_isDifferential) { + sensorLocation += F("_Diff"); + switch (_adsDiffMux) { + case TIADS1X15_DIFF_MUX_0_1: + sensorLocation += F("0_1"); + break; + case TIADS1X15_DIFF_MUX_0_3: + sensorLocation += F("0_3"); + break; + case TIADS1X15_DIFF_MUX_1_3: + sensorLocation += F("1_3"); + break; + case TIADS1X15_DIFF_MUX_2_3: + sensorLocation += F("2_3"); + break; + } + } else { + sensorLocation += F("_Channel"); + sensorLocation += String(_adsChannel); + } return sensorLocation; } @@ -56,7 +92,14 @@ bool TIADS1x15::addSingleMeasurementResult(void) { MS_DBG(getSensorNameAndLocation(), F("is reporting:")); float resultValue = -9999; - bool success = readVoltageSingleEnded(resultValue); + bool success = false; + + // Use differential or single-ended reading based on configuration + if (_isDifferential) { + success = readVoltageDifferential(resultValue); + } else { + success = readVoltageSingleEnded(resultValue); + } if (success) { verifyAndAddMeasurementResult(TIADS1X15_VAR_NUM, resultValue); @@ -135,6 +178,71 @@ bool TIADS1x15::readVoltageSingleEnded(float& resultValue) { return success; } +bool TIADS1x15::readVoltageDifferential(float& resultValue) { + bool success = false; + int16_t adcCounts = -9999; + float adcVoltage = -9999; + float scaledResult = -9999; + +// Create an auxiliary ADC object +#ifndef MS_USE_ADS1015 + Adafruit_ADS1115 ads; +#else + Adafruit_ADS1015 ads; +#endif + + // Set the internal gain according to user configuration + ads.setGain(_adsGain); + + if (!ads.begin(_i2cAddress)) { + MS_DBG(F(" ADC initialization failed at 0x"), + String(_i2cAddress, HEX)); + return false; + } + + // Read differential voltage based on mux configuration + switch (_adsDiffMux) { + case TIADS1X15_DIFF_MUX_0_1: + adcCounts = ads.readADC_Differential_0_1(); + break; + case TIADS1X15_DIFF_MUX_0_3: + adcCounts = ads.readADC_Differential_0_3(); + break; + case TIADS1X15_DIFF_MUX_1_3: + adcCounts = ads.readADC_Differential_1_3(); + break; + case TIADS1X15_DIFF_MUX_2_3: + adcCounts = ads.readADC_Differential_2_3(); + break; + default: + MS_DBG(F(" Invalid differential mux configuration")); + return false; + } + + // Convert counts to voltage + adcVoltage = ads.computeVolts(adcCounts); + MS_DBG(F(" Differential ADC counts:"), adcCounts, F(" voltage:"), adcVoltage); + + // Validate range + float minValidVoltage = -0.3; + float maxValidVoltage = _adsSupplyVoltage + 0.3; + if (maxValidVoltage > 5.5) { + maxValidVoltage = 5.5; + } + + if (adcVoltage < maxValidVoltage && adcVoltage > minValidVoltage) { + scaledResult = adcVoltage * _voltageMultiplier; + MS_DBG(F(" scaledResult:"), scaledResult); + resultValue = scaledResult; + success = true; + } else { + MS_DBG(F(" ADC voltage out of valid range")); + resultValue = -9999; + } + + return success; +} + // Setter and getter methods for ADS supply voltage void TIADS1x15::setADSSupplyVoltage(float adsSupplyVoltage) { _adsSupplyVoltage = adsSupplyVoltage; diff --git a/src/sensors/TIADS1x15.h b/src/sensors/TIADS1x15.h index d234e6274..7de9d7af8 100644 --- a/src/sensors/TIADS1x15.h +++ b/src/sensors/TIADS1x15.h @@ -189,6 +189,16 @@ #define ADS1115_ADDRESS 0x48 /**@}*/ +/** + * @brief Enum for the pins used for differential voltages. + */ +typedef enum : uint16_t { + TIADS1X15_DIFF_MUX_0_1, ///< differential across pins 0 and 1 + TIADS1X15_DIFF_MUX_0_3, ///< differential across pins 0 and 3 + TIADS1X15_DIFF_MUX_1_3, ///< differential across pins 1 and 3 + TIADS1X15_DIFF_MUX_2_3 ///< differential across pins 2 and 3 +} tiads1x15_adsDiffMux_t; + /** * @anchor sensor_ads1x15_timing * @name Sensor Timing @@ -298,6 +308,30 @@ class TIADS1x15 : public Sensor { uint8_t i2cAddress = ADS1115_ADDRESS, uint8_t measurementsToAverage = 1, float adsSupplyVoltage = OPERATING_VOLTAGE); + /** + * @brief Construct a new TIADS1x15 object for differential measurements + * + * @param powerPin The pin on the mcu controlling power to the sensor + * Use -1 if it is continuously powered. + * @param adsDiffMux The differential pin configuration for voltage + * measurement + * @param voltageMultiplier The voltage multiplier, if a voltage divider is + * used. + * @param adsGain The internal gain setting of the ADS1x15; defaults to + * GAIN_ONE for +/- 4.096V range + * @param i2cAddress The I2C address of the ADS 1x15, default is 0x48 (ADDR + * = GND) + * @param measurementsToAverage The number of measurements to take and + * average before giving a "final" result from the sensor; optional with a + * default value of 1. + * @param adsSupplyVoltage The power supply voltage for the ADS1x15 in + * volts; defaults to the processor operating voltage from KnownProcessors.h + */ + TIADS1x15(int8_t powerPin, tiads1x15_adsDiffMux_t adsDiffMux, + float voltageMultiplier = 1, adsGain_t adsGain = GAIN_ONE, + uint8_t i2cAddress = ADS1115_ADDRESS, + uint8_t measurementsToAverage = 1, + float adsSupplyVoltage = OPERATING_VOLTAGE); /** * @brief Destroy the External Voltage object */ @@ -346,12 +380,28 @@ class TIADS1x15 : public Sensor { */ virtual bool readVoltageSingleEnded(float& resultValue); + /** + * @brief Read a differential voltage measurement from the ADS1x15 + * + * @param resultValue Reference to store the resulting voltage measurement + * @return True if the voltage reading was successful and within valid range + */ + virtual bool readVoltageDifferential(float& resultValue); + private: /** * @brief Internal reference to the ADS channel number of the device - * attached to the TI-ADS1x15 + * attached to the TI-ADS1x15 (used for single-ended measurements) */ uint8_t _adsChannel; + /** + * @brief Internal reference to whether we are using differential mode + */ + bool _isDifferential; + /** + * @brief Internal reference to the differential mux configuration + */ + tiads1x15_adsDiffMux_t _adsDiffMux; /** * @brief Internal reference to the voltage multiplier for the TI-ADS1x15 */ From fa3404c2dcdadf45265a01a5523307b12c8bd1d1 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Fri, 20 Feb 2026 14:08:52 -0500 Subject: [PATCH 263/533] separate voltage reading function in processor analog Signed-off-by: Sara Damiano --- src/sensors/ProcessorAnalog.cpp | 32 ++++++++++++++++++++++++-------- src/sensors/ProcessorAnalog.h | 9 +++++++++ 2 files changed, 33 insertions(+), 8 deletions(-) diff --git a/src/sensors/ProcessorAnalog.cpp b/src/sensors/ProcessorAnalog.cpp index 38d2b2392..6cbc16f6b 100644 --- a/src/sensors/ProcessorAnalog.cpp +++ b/src/sensors/ProcessorAnalog.cpp @@ -34,19 +34,32 @@ bool ProcessorAnalog::addSingleMeasurementResult(void) { if (!getStatusBit(MEASUREMENT_SUCCESSFUL)) { return bumpMeasurementAttemptCount(false); } + + MS_DBG(getSensorNameAndLocation(), F("is reporting:")); + + float resultValue = -9999; + bool success = readVoltageSingleEnded(resultValue); + + if (success) { + verifyAndAddMeasurementResult(PROCESSOR_ANALOG_VAR_NUM, resultValue); + } + + // Return success value when finished + return bumpMeasurementAttemptCount(success); +} + +bool ProcessorAnalog::readVoltageSingleEnded(float& resultValue) { + // Validate parameters if (PROCESSOR_ADC_MAX <= 0) { MS_DBG(F("Processor ADC max value is not set or invalid!")); - return bumpMeasurementAttemptCount(false); + return false; } if (_dataPin < 0 || _operatingVoltage <= 0 || _voltageMultiplier <= 0) { MS_DBG(F("Missing one or more required parameters: analog pin, " "operating voltage, or voltage divider!")); - return bumpMeasurementAttemptCount(false); + return false; } - MS_DBG(getSensorNameAndLocation(), F("is reporting:")); - - float sensorValue_analog = -9999; // Get the analog voltage MS_DBG(F("Getting analog voltage from pin"), _dataPin); pinMode(_dataPin, INPUT); @@ -55,15 +68,18 @@ bool ProcessorAnalog::addSingleMeasurementResult(void) { analogRead(_dataPin); // another priming reading float rawAnalog = analogRead(_dataPin); MS_DBG(F("Raw analog pin reading in bits:"), rawAnalog); + // convert bits to volts - sensorValue_analog = + float sensorValue_analog = (_operatingVoltage / static_cast(PROCESSOR_ADC_MAX)) * _voltageMultiplier * rawAnalog; MS_DBG(F("Voltage:"), sensorValue_analog); + + resultValue = sensorValue_analog; + // NOTE: We don't actually have any criteria for if the reading was any // good or not, so we mark it as successful no matter what. - verifyAndAddMeasurementResult(PROCESSOR_ANALOG_VAR_NUM, sensorValue_analog); - return bumpMeasurementAttemptCount(true); + return true; } void ProcessorAnalog::setVoltageMultiplier(float voltageMultiplier) { diff --git a/src/sensors/ProcessorAnalog.h b/src/sensors/ProcessorAnalog.h index 877e5ab98..b8fc58b13 100644 --- a/src/sensors/ProcessorAnalog.h +++ b/src/sensors/ProcessorAnalog.h @@ -210,6 +210,15 @@ class ProcessorAnalog : public Sensor { */ float getVoltageMultiplier(void); + protected: + /** + * @brief Read a single-ended voltage measurement from the processor ADC + * + * @param resultValue Reference to store the resulting voltage measurement + * @return True if the voltage reading was successful + */ + virtual bool readVoltageSingleEnded(float& resultValue); + private: float _voltageMultiplier; ///< Internal reference to any multiplier needed ///< to convert raw battery readings into true From e3b4426ae79ce4a3643c69d00d6d2f0beb88b478 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Fri, 20 Feb 2026 14:25:22 -0500 Subject: [PATCH 264/533] convert to enum class Signed-off-by: Sara Damiano --- src/sensors/TIADS1x15.cpp | 29 +++++++++++++++-------------- src/sensors/TIADS1x15.h | 4 ++-- 2 files changed, 17 insertions(+), 16 deletions(-) diff --git a/src/sensors/TIADS1x15.cpp b/src/sensors/TIADS1x15.cpp index a8192a5df..3515f7cb5 100644 --- a/src/sensors/TIADS1x15.cpp +++ b/src/sensors/TIADS1x15.cpp @@ -27,7 +27,9 @@ TIADS1x15::TIADS1x15(int8_t powerPin, uint8_t adsChannel, powerPin, -1, measurementsToAverage, TIADS1X15_INC_CALC_VARIABLES), _adsChannel(adsChannel), _isDifferential(false), - _adsDiffMux(TIADS1X15_DIFF_MUX_0_1), // Default value, not used + _adsDiffMux( + tiads1x15_adsDiffMux_t::TIADS1X15_DIFF_MUX_0_1), // Default value, + // not used _voltageMultiplier(voltageMultiplier), _adsGain(adsGain), _i2cAddress(i2cAddress), @@ -62,16 +64,16 @@ String TIADS1x15::getSensorLocation(void) { if (_isDifferential) { sensorLocation += F("_Diff"); switch (_adsDiffMux) { - case TIADS1X15_DIFF_MUX_0_1: + case tiads1x15_adsDiffMux_t::TIADS1X15_DIFF_MUX_0_1: sensorLocation += F("0_1"); break; - case TIADS1X15_DIFF_MUX_0_3: + case tiads1x15_adsDiffMux_t::TIADS1X15_DIFF_MUX_0_3: sensorLocation += F("0_3"); break; - case TIADS1X15_DIFF_MUX_1_3: + case tiads1x15_adsDiffMux_t::TIADS1X15_DIFF_MUX_1_3: sensorLocation += F("1_3"); break; - case TIADS1X15_DIFF_MUX_2_3: + case tiads1x15_adsDiffMux_t::TIADS1X15_DIFF_MUX_2_3: sensorLocation += F("2_3"); break; } @@ -149,8 +151,7 @@ bool TIADS1x15::readVoltageSingleEnded(float& resultValue) { // Convert ADC raw counts value to voltage (V) adcVoltage = ads.computeVolts(adcCounts); MS_DBG(F(" ads.readADC_SingleEnded("), _adsChannel, F("):"), adcCounts, - '=', adcVoltage); - + F(" voltage:"), adcVoltage); // Verify the range based on the actual power supplied to the ADS. // Valid range is approximately -0.3V to (supply voltage + 0.3V) with // absolute maximum of 5.5V per datasheet @@ -164,7 +165,7 @@ bool TIADS1x15::readVoltageSingleEnded(float& resultValue) { MS_DBG(F(" Valid voltage range:"), minValidVoltage, F("V to"), maxValidVoltage, F("V")); - if (adcVoltage < maxValidVoltage && adcVoltage > minValidVoltage) { + if (adcVoltage <= maxValidVoltage && adcVoltage >= minValidVoltage) { // Apply the voltage multiplier scaling, with a default multiplier of 1 scaledResult = adcVoltage * _voltageMultiplier; MS_DBG(F(" scaledResult:"), scaledResult); @@ -193,7 +194,7 @@ bool TIADS1x15::readVoltageDifferential(float& resultValue) { // Set the internal gain according to user configuration ads.setGain(_adsGain); - + if (!ads.begin(_i2cAddress)) { MS_DBG(F(" ADC initialization failed at 0x"), String(_i2cAddress, HEX)); @@ -202,23 +203,23 @@ bool TIADS1x15::readVoltageDifferential(float& resultValue) { // Read differential voltage based on mux configuration switch (_adsDiffMux) { - case TIADS1X15_DIFF_MUX_0_1: + case tiads1x15_adsDiffMux_t::TIADS1X15_DIFF_MUX_0_1: adcCounts = ads.readADC_Differential_0_1(); break; - case TIADS1X15_DIFF_MUX_0_3: + case tiads1x15_adsDiffMux_t::TIADS1X15_DIFF_MUX_0_3: adcCounts = ads.readADC_Differential_0_3(); break; - case TIADS1X15_DIFF_MUX_1_3: + case tiads1x15_adsDiffMux_t::TIADS1X15_DIFF_MUX_1_3: adcCounts = ads.readADC_Differential_1_3(); break; - case TIADS1X15_DIFF_MUX_2_3: + case tiads1x15_adsDiffMux_t::TIADS1X15_DIFF_MUX_2_3: adcCounts = ads.readADC_Differential_2_3(); break; default: MS_DBG(F(" Invalid differential mux configuration")); return false; } - + // Convert counts to voltage adcVoltage = ads.computeVolts(adcCounts); MS_DBG(F(" Differential ADC counts:"), adcCounts, F(" voltage:"), adcVoltage); diff --git a/src/sensors/TIADS1x15.h b/src/sensors/TIADS1x15.h index 7de9d7af8..d0cda913e 100644 --- a/src/sensors/TIADS1x15.h +++ b/src/sensors/TIADS1x15.h @@ -192,12 +192,12 @@ /** * @brief Enum for the pins used for differential voltages. */ -typedef enum : uint16_t { +enum class tiads1x15_adsDiffMux_t : uint16_t { TIADS1X15_DIFF_MUX_0_1, ///< differential across pins 0 and 1 TIADS1X15_DIFF_MUX_0_3, ///< differential across pins 0 and 3 TIADS1X15_DIFF_MUX_1_3, ///< differential across pins 1 and 3 TIADS1X15_DIFF_MUX_2_3 ///< differential across pins 2 and 3 -} tiads1x15_adsDiffMux_t; +}; /** * @anchor sensor_ads1x15_timing From 84e102c3d400ed5b4503d60430e21c3ff5b6ecc7 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Fri, 20 Feb 2026 14:25:39 -0500 Subject: [PATCH 265/533] correct differential validation Signed-off-by: Sara Damiano --- src/sensors/TIADS1x15.cpp | 25 ++++++++++++++++++------- src/sensors/TIADS1x15.h | 14 ++++++++++---- 2 files changed, 28 insertions(+), 11 deletions(-) diff --git a/src/sensors/TIADS1x15.cpp b/src/sensors/TIADS1x15.cpp index 3515f7cb5..5f9adf9da 100644 --- a/src/sensors/TIADS1x15.cpp +++ b/src/sensors/TIADS1x15.cpp @@ -224,20 +224,31 @@ bool TIADS1x15::readVoltageDifferential(float& resultValue) { adcVoltage = ads.computeVolts(adcCounts); MS_DBG(F(" Differential ADC counts:"), adcCounts, F(" voltage:"), adcVoltage); - // Validate range - float minValidVoltage = -0.3; - float maxValidVoltage = _adsSupplyVoltage + 0.3; - if (maxValidVoltage > 5.5) { - maxValidVoltage = 5.5; + // Validate range - for differential measurements, use PGA full-scale range + // Based on gain setting rather than supply voltage + float fullScaleVoltage = 4.096; // Default for GAIN_ONE + switch (_adsGain) { + case GAIN_TWOTHIRDS: fullScaleVoltage = 6.144; break; + case GAIN_ONE: fullScaleVoltage = 4.096; break; + case GAIN_TWO: fullScaleVoltage = 2.048; break; + case GAIN_FOUR: fullScaleVoltage = 1.024; break; + case GAIN_EIGHT: fullScaleVoltage = 0.512; break; + case GAIN_SIXTEEN: fullScaleVoltage = 0.256; break; } + float minValidVoltage = -fullScaleVoltage; + float maxValidVoltage = fullScaleVoltage; + + MS_DBG(F(" ADS gain setting determines full-scale range")); + MS_DBG(F(" Valid differential voltage range:"), minValidVoltage, F("V to"), + maxValidVoltage, F("V")); - if (adcVoltage < maxValidVoltage && adcVoltage > minValidVoltage) { + if (adcVoltage <= maxValidVoltage && adcVoltage >= minValidVoltage) { scaledResult = adcVoltage * _voltageMultiplier; MS_DBG(F(" scaledResult:"), scaledResult); resultValue = scaledResult; success = true; } else { - MS_DBG(F(" ADC voltage out of valid range")); + MS_DBG(F(" Differential voltage out of valid range")); resultValue = -9999; } diff --git a/src/sensors/TIADS1x15.h b/src/sensors/TIADS1x15.h index d0cda913e..36fbbd619 100644 --- a/src/sensors/TIADS1x15.h +++ b/src/sensors/TIADS1x15.h @@ -65,9 +65,15 @@ * - Response time: < 1ms * - Resample time: 860 samples per second (~1.2ms) * - Range: - * - Range is determined by supply voltage - No more than VDD + 0.3 V r 5.5 V - * (whichever is smaller) must be applied to this device. - * - 0 - 3.6V [when ADC is powered at 3.3V] + * - Single-ended measurements: Limited by supply voltage (VDD + 0.3V max, absolute max 5.5V) + * - 0 - 3.6V [when ADC is powered at 3.3V] + * - Differential measurements: Limited by internal PGA full-scale range (gain-dependent) + * - GAIN_TWOTHIRDS = ±6.144V + * - GAIN_ONE = ±4.096V + * - GAIN_TWO = ±2.048V + * - GAIN_FOUR = ±1.024V + * - GAIN_EIGHT = ±0.512V + * - GAIN_SIXTEEN = ±0.256V * - Accuracy: * - 16-bit ADC (ADS1115): < 0.25% (gain error), <0.25 LSB (offset error) * - 12-bit ADC (ADS1015, using build flag ```MS_USE_ADS1015```): < 0.15% (gain error), <3 LSB (offset error) @@ -228,7 +234,7 @@ enum class tiads1x15_adsDiffMux_t : uint16_t { * @name Voltage * The volt variable from a TI ADS1x15 analog-to-digital converter (ADC) * - Range (with no external voltage divider): - * - 0 - min(4.096V, supply voltage + 0.3V) voltage + 0.3V) + * - 0 - min(4.096V, supply voltage + 0.3V) * - Accuracy: * - 16-bit ADC (ADS1115): < 0.25% (gain error), <0.25 LSB (offset error) * - 12-bit ADC (ADS1015, using build flag ```MS_USE_ADS1015```): < 0.15% From b2c69a78674dc385bfe2bf72e2c84d1e9fec6f15 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Fri, 20 Feb 2026 14:30:43 -0500 Subject: [PATCH 266/533] Validation fixes Signed-off-by: Sara Damiano --- src/sensors/TIADS1x15.cpp | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/sensors/TIADS1x15.cpp b/src/sensors/TIADS1x15.cpp index 5f9adf9da..7af4b4767 100644 --- a/src/sensors/TIADS1x15.cpp +++ b/src/sensors/TIADS1x15.cpp @@ -234,10 +234,15 @@ bool TIADS1x15::readVoltageDifferential(float& resultValue) { case GAIN_FOUR: fullScaleVoltage = 1.024; break; case GAIN_EIGHT: fullScaleVoltage = 0.512; break; case GAIN_SIXTEEN: fullScaleVoltage = 0.256; break; + default: + MS_DBG(F(" Unknown ADS gain value:"), _adsGain, + F(" using conservative 4.096V range")); + fullScaleVoltage = 4.096; // Conservative fallback + break; } float minValidVoltage = -fullScaleVoltage; float maxValidVoltage = fullScaleVoltage; - + MS_DBG(F(" ADS gain setting determines full-scale range")); MS_DBG(F(" Valid differential voltage range:"), minValidVoltage, F("V to"), maxValidVoltage, F("V")); @@ -257,7 +262,18 @@ bool TIADS1x15::readVoltageDifferential(float& resultValue) { // Setter and getter methods for ADS supply voltage void TIADS1x15::setADSSupplyVoltage(float adsSupplyVoltage) { - _adsSupplyVoltage = adsSupplyVoltage; + // Validate supply voltage range: 0.0V to 5.5V per datasheet + if (adsSupplyVoltage < 0.0) { + MS_DBG(F("ADS supply voltage "), adsSupplyVoltage, + F("V is below minimum, clamping to 0.0V")); + _adsSupplyVoltage = 0.0; + } else if (adsSupplyVoltage > 5.5) { + MS_DBG(F("ADS supply voltage "), adsSupplyVoltage, + F("V exceeds maximum, clamping to 5.5V")); + _adsSupplyVoltage = 5.5; + } else { + _adsSupplyVoltage = adsSupplyVoltage; + } } float TIADS1x15::getADSSupplyVoltage(void) { From 4608c17d66faced337dd5b6110a7878b7f1854b6 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Fri, 20 Feb 2026 14:56:21 -0500 Subject: [PATCH 267/533] Made TurnerTurbidityPlus a subclass of the TIADS1x15 Signed-off-by: Sara Damiano --- src/sensors/TurnerTurbidityPlus.cpp | 130 +++++++--------------------- src/sensors/TurnerTurbidityPlus.h | 53 ++---------- 2 files changed, 35 insertions(+), 148 deletions(-) diff --git a/src/sensors/TurnerTurbidityPlus.cpp b/src/sensors/TurnerTurbidityPlus.cpp index cfab0987e..81fd8b8a7 100644 --- a/src/sensors/TurnerTurbidityPlus.cpp +++ b/src/sensors/TurnerTurbidityPlus.cpp @@ -9,40 +9,36 @@ #include "TurnerTurbidityPlus.h" +#include "TIADS1x15.h" // The constructor - need the power pin, the data pin, and the calibration info TurnerTurbidityPlus::TurnerTurbidityPlus( - int8_t powerPin, int8_t wiperTriggerPin, ttp_adsDiffMux_t adsDiffMux, + int8_t powerPin, int8_t wiperTriggerPin, tiads1x15_adsDiffMux_t adsDiffMux, float conc_std, float volt_std, float volt_blank, uint8_t i2cAddress, adsGain_t PGA_gain, uint8_t measurementsToAverage, float voltageDividerFactor) - : Sensor("TurnerTurbidityPlus", TURBIDITY_PLUS_NUM_VARIABLES, - TURBIDITY_PLUS_WARM_UP_TIME_MS, - TURBIDITY_PLUS_STABILIZATION_TIME_MS, - TURBIDITY_PLUS_MEASUREMENT_TIME_MS, powerPin, -1, - measurementsToAverage), + : TIADS1x15(powerPin, adsDiffMux, voltageDividerFactor, PGA_gain, + i2cAddress, measurementsToAverage), _wiperTriggerPin(wiperTriggerPin), - _adsDiffMux(adsDiffMux), _conc_std(conc_std), _volt_std(volt_std), - _volt_blank(volt_blank), - _i2cAddress(i2cAddress), - _PGA_gain(PGA_gain), - _voltageDividerFactor(voltageDividerFactor) {} + _volt_blank(volt_blank) { + // Override timing settings for Turner-specific requirements + // These are protected members from the Sensor base class + _warmUpTime_ms = TURBIDITY_PLUS_WARM_UP_TIME_MS; + _stabilizationTime_ms = TURBIDITY_PLUS_STABILIZATION_TIME_MS; + _measurementTime_ms = TURBIDITY_PLUS_MEASUREMENT_TIME_MS; + // Note: _numReturnedValues and _sensorName are set in the parent class +} // Destructor TurnerTurbidityPlus::~TurnerTurbidityPlus() {} String TurnerTurbidityPlus::getSensorLocation(void) { -#ifndef MS_USE_ADS1015 - String sensorLocation = F("ADS1115_0x"); -#else - String sensorLocation = F("ADS1015_0x"); -#endif - sensorLocation += String(_i2cAddress, HEX); - sensorLocation += F("_adsDiffMux"); - sensorLocation += String(_adsDiffMux); + // Use TIADS1x15's location with Turner-specific identifier + String sensorLocation = TIADS1x15::getSensorLocation(); + sensorLocation += F("_TurnerTurb"); return sensorLocation; } @@ -64,7 +60,7 @@ void TurnerTurbidityPlus::runWiper() { bool TurnerTurbidityPlus::setup(void) { // Set up the wiper trigger pin, which is active-LOW. pinMode(_wiperTriggerPin, OUTPUT); - return Sensor::setup(); + return TIADS1x15::setup(); } bool TurnerTurbidityPlus::wake(void) { @@ -74,19 +70,19 @@ bool TurnerTurbidityPlus::wake(void) { // Run the wiper before taking a reading runWiper(); - return Sensor::wake(); + return TIADS1x15::wake(); } void TurnerTurbidityPlus::powerDown(void) { // Set the wiper trigger pin LOW to avoid power drain. digitalWrite(_wiperTriggerPin, LOW); - return Sensor::powerDown(); + return TIADS1x15::powerDown(); } void TurnerTurbidityPlus::powerUp(void) { // Set the wiper trigger pin HIGH to prepare for wiping. digitalWrite(_wiperTriggerPin, HIGH); - return Sensor::powerUp(); + return TIADS1x15::powerUp(); } bool TurnerTurbidityPlus::addSingleMeasurementResult(void) { @@ -95,39 +91,12 @@ bool TurnerTurbidityPlus::addSingleMeasurementResult(void) { return bumpMeasurementAttemptCount(false); } - bool success = false; - int16_t adcCounts = -9999; - float adcVoltage = -9999; - float calibResult = -9999; + bool success = false; + float adcVoltage = -9999; + float calibResult = -9999; MS_DBG(getSensorNameAndLocation(), F("is reporting:")); -// Create an auxiliary ADC object -// We create and set up the ADC object here so that each sensor using the ADC -// may set the gain appropriately without affecting others. -#ifndef MS_USE_ADS1015 - Adafruit_ADS1115 ads; // Use this for the 16-bit version -#else - Adafruit_ADS1015 ads; // Use this for the 12-bit version -#endif - // ADS Library default settings: - // - TI ADS1115 (16 bit) - // - single-shot mode (powers down between conversions) - // - 128 samples per second (8ms conversion time) - // - 2/3 gain +/- 6.144V range (limited to VDD +0.3V max) - // - TI ADS1015 (12 bit) - // - single-shot mode (powers down between conversions) - // - 1600 samples per second (625µs conversion time) - // - 2/3 gain +/- 6.144V range (limited to VDD +0.3V max) - - ads.setGain(_PGA_gain); - // Begin ADC, returns true if anything was detected at the address - if (!ads.begin(_i2cAddress)) { - MS_DBG(F(" ADC initialization failed at 0x"), - String(_i2cAddress, HEX)); - return bumpMeasurementAttemptCount(false); - } - // Print out the calibration curve MS_DBG(F(" Input calibration Curve:"), _volt_std, F("V at"), _conc_std, F(". "), _volt_blank, F("V blank.")); @@ -137,53 +106,12 @@ bool TurnerTurbidityPlus::addSingleMeasurementResult(void) { return bumpMeasurementAttemptCount(false); } - // Read Analog to Digital Converter (ADC) - // Taking this reading includes the 8ms conversion delay. - // Measure the voltage differential across the two voltage pins - switch (_adsDiffMux) { - case DIFF_MUX_0_1: { - adcCounts = ads.readADC_Differential_0_1(); - break; - } - case DIFF_MUX_0_3: { - adcCounts = ads.readADC_Differential_0_3(); - break; - } - case DIFF_MUX_1_3: { - adcCounts = ads.readADC_Differential_1_3(); - break; - } - case DIFF_MUX_2_3: { - adcCounts = ads.readADC_Differential_2_3(); - break; - } - default: { - MS_DBG(F(" Invalid differential mux configuration")); - return bumpMeasurementAttemptCount(false); - } - } - // Convert ADC counts value to voltage (V) - adcVoltage = ads.computeVolts(adcCounts); - MS_DBG(F(" ads.readADC_Differential("), _adsDiffMux, F("):"), adcCounts, - '=', String(adcVoltage, 3)); - - // The ADS1X15 outputs a max value corresponding to Vcc + 0.3V - if (adcVoltage < 5.3 && adcVoltage > -0.3) { - if (_voltageDividerFactor > 0) { - // Apply voltage divider factor if using a voltage divider to step - // down the voltage - adcVoltage *= _voltageDividerFactor; - } else { - // If the voltage divider factor is not set to a positive value, - // print a debugging message and continue without applying a voltage - // divider factor. We continue because the voltage divider factor - // can be easily fixed in post-processing if the raw voltage value - // is available, and we don't want to lose the voltage reading if - // the voltage divider factor is just set incorrectly. - MS_DBG(F(" Invalid voltage divider factor:"), - _voltageDividerFactor, - F("Voltage divider will be ignored.")); - } + // Use the TIADS1x15 differential voltage reading function + // Note: Voltage multiplier/divider is automatically applied by the parent + // class + if (readVoltageDifferential(adcVoltage)) { + MS_DBG(F(" Differential voltage (after voltage multiplier):"), + String(adcVoltage, 3), F("V")); // Apply the unique calibration curve for the given sensor calibResult = (_conc_std / (_volt_std - _volt_blank)) * (adcVoltage - _volt_blank); @@ -192,6 +120,8 @@ bool TurnerTurbidityPlus::addSingleMeasurementResult(void) { verifyAndAddMeasurementResult(TURBIDITY_PLUS_VOLTAGE_VAR_NUM, adcVoltage); success = true; + } else { + MS_DBG(F(" Failed to read differential voltage")); } // Return success value when finished diff --git a/src/sensors/TurnerTurbidityPlus.h b/src/sensors/TurnerTurbidityPlus.h index 1e0c5a4b0..8f3062772 100644 --- a/src/sensors/TurnerTurbidityPlus.h +++ b/src/sensors/TurnerTurbidityPlus.h @@ -63,7 +63,7 @@ // Include other in-library and external dependencies #include "VariableBase.h" -#include "SensorBase.h" +#include "TIADS1x15.h" #include /** @ingroup sensor_turbidity_plus */ @@ -84,25 +84,6 @@ #define TURBIDITY_PLUS_INC_CALC_VARIABLES 1 /**@}*/ -/** - * @anchor sensor__turbidity_plus_config - * @name Configuration Defines - * Defines to set the address of the ADD. - */ -/**@{*/ -/** - * @brief Enum for the pins used for differential voltages. - */ -typedef enum : uint16_t { - DIFF_MUX_0_1, ///< differential across pins 0 and 1 - DIFF_MUX_0_3, ///< differential across pins 0 and 3 - DIFF_MUX_1_3, ///< differential across pins 1 and 3 - DIFF_MUX_2_3 ///< differential across pins 2 and 3 -} ttp_adsDiffMux_t; -/// @brief The assumed address of the ADS1115, 1001 000 (ADDR = GND) -#define ADS1115_ADDRESS 0x48 -/**@}*/ - /** * @anchor sensor_turbidity_plus_timing * @name Sensor Timing @@ -195,7 +176,7 @@ typedef enum : uint16_t { * * @ingroup sensor_turbidity_plus */ -class TurnerTurbidityPlus : public Sensor { +class TurnerTurbidityPlus : public TIADS1x15 { public: // The constructor - need the power pin, the ADS1X15 data channel, and the // calibration info @@ -215,7 +196,7 @@ class TurnerTurbidityPlus : public Sensor { * @param wiperTriggerPin The pin on the mcu that triggers the sensor's * wiper. * @param adsDiffMux Which two pins _on the TI ADS1115_ that will measure - * differential voltage. See #ttp_adsDiffMux_t + * differential voltage. See #tiads1x15_adsDiffMux_t * @param conc_std The concentration of the standard used for a 1-point * sensor calibration. The concentration units should be the same as the * final measuring units. @@ -240,7 +221,7 @@ class TurnerTurbidityPlus : public Sensor { * requires a voltageDividerFactor of 2. The default value is 1. */ TurnerTurbidityPlus(int8_t powerPin, int8_t wiperTriggerPin, - ttp_adsDiffMux_t adsDiffMux, float conc_std, + tiads1x15_adsDiffMux_t adsDiffMux, float conc_std, float volt_std, float volt_blank, uint8_t i2cAddress = ADS1115_ADDRESS, adsGain_t PGA_gain = GAIN_ONE, @@ -282,11 +263,6 @@ class TurnerTurbidityPlus : public Sensor { * sensor's wiper. */ int8_t _wiperTriggerPin; - /** - * @brief Which two pins _on the TI ADS1115_ that will measure differential - * voltage from the Turbidity Plus. See #ttp_adsDiffMux_t - */ - ttp_adsDiffMux_t _adsDiffMux; /** * @brief The concentration of the standard used for a 1-point sensor * calibration. The concentration units should be the same as the final @@ -304,25 +280,6 @@ class TurnerTurbidityPlus : public Sensor { * be the final voltage *after* accounting for any voltage. */ float _volt_blank; - /** - * @brief Internal reference to the I2C address of the TI-ADS1x15 - */ - uint8_t _i2cAddress; - /** - * @brief The programmable gain amplification to set on the ADS 1x15, - * default is GAIN_ONE (+/-4.096V range = Gain 1). - * - * Other gain options are: - * GAIN_TWOTHIRDS = +/-6.144V range = Gain 2/3, - * GAIN_ONE = +/-4.096V range = Gain 1, - * GAIN_TWO = +/-2.048V range = Gain 2, - * GAIN_FOUR = +/-1.024V range = Gain 4, - * GAIN_EIGHT = +/-0.512V range = Gain 8, - * GAIN_SIXTEEN = +/-0.256V range = Gain 16 - * - * @todo Determine gain automatically based on the board voltage? - */ - adsGain_t _PGA_gain; /** * @brief For 3.3V processors like the Mayfly, The Turner's 0-5V output * signal must be shifted down to a maximum of 3.3V. This can be done either @@ -331,8 +288,8 @@ class TurnerTurbidityPlus : public Sensor { * voltageDividerFactor is used for the latter case: e.g., a divider that * uses 2 matched resistors will halve the voltage reading and requires a * voltageDividerFactor of 2. The default value is 1. + * Note: This functionality is now handled by the parent class's _voltageMultiplier. */ - float _voltageDividerFactor; }; From 452ae227133c3fc7f3e7b09528fb661ed72cd548 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Fri, 20 Feb 2026 15:08:04 -0500 Subject: [PATCH 268/533] Also made alphasenseco2 a subclass Signed-off-by: Sara Damiano --- examples/menu_a_la_carte/menu_a_la_carte.ino | 6 +- src/sensors/AlphasenseCO2.cpp | 115 +++++-------------- src/sensors/AlphasenseCO2.h | 30 +---- 3 files changed, 38 insertions(+), 113 deletions(-) diff --git a/examples/menu_a_la_carte/menu_a_la_carte.ino b/examples/menu_a_la_carte/menu_a_la_carte.ino index c2fbe8e2d..250f0bb94 100644 --- a/examples/menu_a_la_carte/menu_a_la_carte.ino +++ b/examples/menu_a_la_carte/menu_a_la_carte.ino @@ -1001,8 +1001,8 @@ Variable* ds3231Temp = // NOTE: Use -1 for any pins that don't apply or aren't being used. const int8_t AlphasenseCO2Power = sensorPowerPin; // Power pin -aco2_adsDiffMux_t AlphasenseDiffMux = - DIFF_MUX_2_3; // Differential voltage config +tiads1x15_adsDiffMux_t AlphasenseDiffMux = + tiads1x15_adsDiffMux_t::TIADS1X15_DIFF_MUX_2_3; // Differential voltage config const uint8_t AlphasenseCO2ADSi2c_addr = 0x48; // The I2C address of the ADS1115 ADC @@ -2301,7 +2301,7 @@ Variable* cyclopsRedChloro = new TurnerCyclops_RedChlorophyll( const int8_t turbidityPlusPower = sensorPowerPin; // Power pin const int8_t turbidityPlusWiper = relayPowerPin; // Wiper pin ttp_adsDiffMux_t turbidityPlusDiffMux = - DIFF_MUX_2_3; // Differential voltage config + tiads1x15_adsDiffMux_t::TIADS1X15_DIFF_MUX_2_3; // Differential voltage config const uint8_t turbidityPlusNumberReadings = 10; const uint8_t turbidityPlusADSi2c_addr = 0x48; // The I2C address of the ADS1115 ADC diff --git a/src/sensors/AlphasenseCO2.cpp b/src/sensors/AlphasenseCO2.cpp index 8ad85ebf8..2521bab9b 100644 --- a/src/sensors/AlphasenseCO2.cpp +++ b/src/sensors/AlphasenseCO2.cpp @@ -12,33 +12,32 @@ #include "AlphasenseCO2.h" -#include +#include "TIADS1x15.h" -// The constructor - need the power pin and the data pin -AlphasenseCO2::AlphasenseCO2(int8_t powerPin, aco2_adsDiffMux_t adsDiffMux, +// The constructor - need the power pin and the differential mux configuration +AlphasenseCO2::AlphasenseCO2(int8_t powerPin, tiads1x15_adsDiffMux_t adsDiffMux, uint8_t i2cAddress, uint8_t measurementsToAverage) - : Sensor("AlphasenseCO2", ALPHASENSE_CO2_NUM_VARIABLES, - ALPHASENSE_CO2_WARM_UP_TIME_MS, - ALPHASENSE_CO2_STABILIZATION_TIME_MS, - ALPHASENSE_CO2_MEASUREMENT_TIME_MS, powerPin, -1, - measurementsToAverage, ALPHASENSE_CO2_INC_CALC_VARIABLES), - _adsDiffMux(adsDiffMux), - _i2cAddress(i2cAddress) {} - + : TIADS1x15(powerPin, adsDiffMux, 1.0, GAIN_ONE, i2cAddress, + measurementsToAverage) { + // Override timing settings for Alphasense CO2-specific requirements + _warmUpTime_ms = ALPHASENSE_CO2_WARM_UP_TIME_MS; + _stabilizationTime_ms = ALPHASENSE_CO2_STABILIZATION_TIME_MS; + _measurementTime_ms = ALPHASENSE_CO2_MEASUREMENT_TIME_MS; + // Set the number of variables returned + _numReturnedValues = ALPHASENSE_CO2_NUM_VARIABLES; + _incCalcValues = ALPHASENSE_CO2_INC_CALC_VARIABLES; + // Set the sensor name + _sensorName = "AlphasenseCO2"; +} // Destructor AlphasenseCO2::~AlphasenseCO2() {} String AlphasenseCO2::getSensorLocation(void) { -#ifndef MS_USE_ADS1015 - String sensorLocation = F("ADS1115_0x"); -#else - String sensorLocation = F("ADS1015_0x"); -#endif - sensorLocation += String(_i2cAddress, HEX); - sensorLocation += F("_adsDiffMux"); - sensorLocation += String(_adsDiffMux); + // Use TIADS1x15's location with Alphasense CO2-specific identifier + String sensorLocation = TIADS1x15::getSensorLocation(); + sensorLocation += F("_AlphasenseCO2"); return sensorLocation; } @@ -49,79 +48,21 @@ bool AlphasenseCO2::addSingleMeasurementResult(void) { return bumpMeasurementAttemptCount(false); } - bool success = false; - int16_t adcCounts = -9999; - float adcVoltage = -9999; - float co2Current = -9999; - float calibResult = -9999; + bool success = false; + float adcVoltage = -9999; + float co2Current = -9999; + float calibResult = -9999; MS_DBG(getSensorNameAndLocation(), F("is reporting:")); -// Create an auxiliary ADC object -// We create and set up the ADC object here so that each sensor using the ADC -// may set the gain appropriately without effecting others. -#ifndef MS_USE_ADS1015 - Adafruit_ADS1115 ads; // Use this for the 16-bit version -#else - Adafruit_ADS1015 ads; // Use this for the 12-bit version -#endif - // ADS Library default settings: - // - TI ADS1115 (16 bit) - // - single-shot mode (powers down between conversions) - // - 128 samples per second (8ms conversion time) - // - 2/3 gain +/- 6.144V range (limited to VDD +0.3V max) - // - TI ADS1015 (12 bit) - // - single-shot mode (powers down between conversions) - // - 1600 samples per second (625µs conversion time) - // - 2/3 gain +/- 6.144V range (limited to VDD +0.3V max) - - // Bump the gain up to 1x = +/- 4.096V range - // Sensor return range is 0-2.5V, but the next gain option is 2x which - // only allows up to 2.048V - ads.setGain(GAIN_ONE); - // Begin ADC, returns true if anything was detected at the address - if (!ads.begin(_i2cAddress)) { - MS_DBG(F(" ADC initialization failed at 0x"), - String(_i2cAddress, HEX)); - return bumpMeasurementAttemptCount(false); - } - - // Read Analog to Digital Converter (ADC) - // Taking this reading includes the 8ms conversion delay. - // Measure the voltage differential across the two voltage pins - switch (_adsDiffMux) { - case DIFF_MUX_0_1: { - adcCounts = ads.readADC_Differential_0_1(); - break; - } - case DIFF_MUX_0_3: { - adcCounts = ads.readADC_Differential_0_3(); - break; - } - case DIFF_MUX_1_3: { - adcCounts = ads.readADC_Differential_1_3(); - break; - } - case DIFF_MUX_2_3: { - adcCounts = ads.readADC_Differential_2_3(); - break; - } - default: { - MS_DBG(F(" Invalid differential mux configuration")); - return bumpMeasurementAttemptCount(false); - } - } - // Convert ADC counts value to voltage (V) - adcVoltage = ads.computeVolts(adcCounts); - MS_DBG(F(" ads.readADC_Differential("), _adsDiffMux, F("):"), adcCounts, - '=', String(adcVoltage, 3)); - - // @todo Verify the voltage range for the CO2 sensor - // Here we are using the range of the ADS when it is powered at 3.3V - if (adcVoltage < 3.6 && adcVoltage > -0.3) { + // Use the TIADS1x15 differential voltage reading function + // The voltage multiplier and gain settings are handled by the parent class + if (readVoltageDifferential(adcVoltage)) { + MS_DBG(F(" Differential voltage:"), String(adcVoltage, 3), F("V")); // Convert voltage to current (mA) - assuming a 250 Ohm resistor is in // series co2Current = (adcVoltage / 250) * 1000; + MS_DBG(F(" co2Current:"), calibResult); // Convert current to ppm (using a formula recommended by the sensor // manufacturer) calibResult = 312.5 * co2Current - 1250; @@ -130,6 +71,8 @@ bool AlphasenseCO2::addSingleMeasurementResult(void) { verifyAndAddMeasurementResult(ALPHASENSE_CO2_VOLTAGE_VAR_NUM, adcVoltage); success = true; + } else { + MS_DBG(F(" Failed to read differential voltage")); } // Return success value when finished diff --git a/src/sensors/AlphasenseCO2.h b/src/sensors/AlphasenseCO2.h index 998647536..e61273ae5 100644 --- a/src/sensors/AlphasenseCO2.h +++ b/src/sensors/AlphasenseCO2.h @@ -91,7 +91,8 @@ // Include other in-library and external dependencies #include "VariableBase.h" -#include "SensorBase.h" +#include "TIADS1x15.h" +#include /** @ingroup sensor_alphasense_co2 */ /**@{*/ @@ -124,17 +125,6 @@ */ #define ALPHASENSE_CO2_CALIBRATION_FACTOR 1 #endif -/** - * @brief Enum for the pins used for differential voltages. - */ -typedef enum : uint16_t { - DIFF_MUX_0_1, ///< differential across pins 0 and 1 - DIFF_MUX_0_3, ///< differential across pins 0 and 3 - DIFF_MUX_1_3, ///< differential across pins 1 and 3 - DIFF_MUX_2_3 ///< differential across pins 2 and 3 -} aco2_adsDiffMux_t; -/// @brief The assumed address of the ADS1115, 1001 000 (ADDR = GND) -#define ADS1115_ADDRESS 0x48 /**@}*/ /** @@ -247,7 +237,7 @@ typedef enum : uint16_t { * * @ingroup sensor_alphasense_co2 */ -class AlphasenseCO2 : public Sensor { +class AlphasenseCO2 : public TIADS1x15 { public: /** * @brief Construct a new Alphasense IRC-A1 CO2 object - need the power pin @@ -263,7 +253,7 @@ class AlphasenseCO2 : public Sensor { * - The Alphasense CO2 sensor requires 2-5 V DC; current draw 20-60 mA * - The ADS1115 requires 2.0-5.5V but is assumed to be powered at 3.3V * @param adsDiffMux Which two pins _on the TI ADS1115_ that will measure - * differential voltage. See #aco2_adsDiffMux_t. + * differential voltage. See tiads1x15_adsDiffMux_t. * @param i2cAddress The I2C address of the ADS 1x15, default is 0x48 (ADDR * = GND) * @param measurementsToAverage The number of measurements to take and @@ -273,7 +263,7 @@ class AlphasenseCO2 : public Sensor { * its power controlled by the same pin as the Alphasense CO2 sensor. This * library does not support any other configuration. */ - AlphasenseCO2(int8_t powerPin, aco2_adsDiffMux_t adsDiffMux = DIFF_MUX_2_3, + AlphasenseCO2(int8_t powerPin, tiads1x15_adsDiffMux_t adsDiffMux = tiads1x15_adsDiffMux_t::TIADS1X15_DIFF_MUX_2_3, uint8_t i2cAddress = ADS1115_ADDRESS, uint8_t measurementsToAverage = 7); /** @@ -292,15 +282,7 @@ class AlphasenseCO2 : public Sensor { bool addSingleMeasurementResult(void) override; private: - /** - * @brief Which two pins _on the TI ADS1115_ that will measure differential - * voltage from the Turbidity Plus. See #aco2_adsDiffMux_t - */ - aco2_adsDiffMux_t _adsDiffMux; - /** - * @brief Internal reference to the I2C address of the TI-ADS1x15 - */ - uint8_t _i2cAddress; + // All differential mux and I2C address functionality is now handled by the parent TIADS1x15 class }; From 3cb54bad20a127ffac8e3644a88fef1ea219e775 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Fri, 20 Feb 2026 15:16:00 -0500 Subject: [PATCH 269/533] override variable counts and sensor name correctly Signed-off-by: Sara Damiano --- src/SensorBase.h | 2 +- src/sensors/AlphasenseCO2.cpp | 2 +- src/sensors/TurnerTurbidityPlus.cpp | 9 ++++++--- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/SensorBase.h b/src/SensorBase.h index 507d32f1a..24fbeffb1 100644 --- a/src/SensorBase.h +++ b/src/SensorBase.h @@ -716,7 +716,7 @@ class Sensor { * calculated within the library for the sensor. The @ref _incCalcValues * are *included* in this total. */ - const uint8_t _numReturnedValues; + uint8_t _numReturnedValues; /** * @brief The number of included calculated variables from the sensor, if * any. diff --git a/src/sensors/AlphasenseCO2.cpp b/src/sensors/AlphasenseCO2.cpp index 2521bab9b..b19c93197 100644 --- a/src/sensors/AlphasenseCO2.cpp +++ b/src/sensors/AlphasenseCO2.cpp @@ -24,7 +24,7 @@ AlphasenseCO2::AlphasenseCO2(int8_t powerPin, tiads1x15_adsDiffMux_t adsDiffMux, _warmUpTime_ms = ALPHASENSE_CO2_WARM_UP_TIME_MS; _stabilizationTime_ms = ALPHASENSE_CO2_STABILIZATION_TIME_MS; _measurementTime_ms = ALPHASENSE_CO2_MEASUREMENT_TIME_MS; - // Set the number of variables returned + // Override variable counts from parent class defaults _numReturnedValues = ALPHASENSE_CO2_NUM_VARIABLES; _incCalcValues = ALPHASENSE_CO2_INC_CALC_VARIABLES; // Set the sensor name diff --git a/src/sensors/TurnerTurbidityPlus.cpp b/src/sensors/TurnerTurbidityPlus.cpp index 81fd8b8a7..acd55a82c 100644 --- a/src/sensors/TurnerTurbidityPlus.cpp +++ b/src/sensors/TurnerTurbidityPlus.cpp @@ -29,7 +29,11 @@ TurnerTurbidityPlus::TurnerTurbidityPlus( _warmUpTime_ms = TURBIDITY_PLUS_WARM_UP_TIME_MS; _stabilizationTime_ms = TURBIDITY_PLUS_STABILIZATION_TIME_MS; _measurementTime_ms = TURBIDITY_PLUS_MEASUREMENT_TIME_MS; - // Note: _numReturnedValues and _sensorName are set in the parent class + // Override variable counts from parent class defaults + _numReturnedValues = TURBIDITY_PLUS_NUM_VARIABLES; + _incCalcValues = TURBIDITY_PLUS_INC_CALC_VARIABLES; + // Set the sensor name + _sensorName = "TurnerTurbidityPlus"; } // Destructor TurnerTurbidityPlus::~TurnerTurbidityPlus() {} @@ -107,8 +111,7 @@ bool TurnerTurbidityPlus::addSingleMeasurementResult(void) { } // Use the TIADS1x15 differential voltage reading function - // Note: Voltage multiplier/divider is automatically applied by the parent - // class + // The voltage multiplier and gain settings are handled by the parent class if (readVoltageDifferential(adcVoltage)) { MS_DBG(F(" Differential voltage (after voltage multiplier):"), String(adcVoltage, 3), F("V")); From fdeebd0924bcce5474d3c72c2c957be12d465f8e Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Fri, 20 Feb 2026 15:31:13 -0500 Subject: [PATCH 270/533] Add configuration defines Signed-off-by: Sara Damiano --- src/sensors/AlphasenseCO2.cpp | 17 ++++++++-------- src/sensors/AlphasenseCO2.h | 38 +++++++++++++++++++++++++++-------- 2 files changed, 39 insertions(+), 16 deletions(-) diff --git a/src/sensors/AlphasenseCO2.cpp b/src/sensors/AlphasenseCO2.cpp index b19c93197..74a26a583 100644 --- a/src/sensors/AlphasenseCO2.cpp +++ b/src/sensors/AlphasenseCO2.cpp @@ -18,8 +18,8 @@ // The constructor - need the power pin and the differential mux configuration AlphasenseCO2::AlphasenseCO2(int8_t powerPin, tiads1x15_adsDiffMux_t adsDiffMux, uint8_t i2cAddress, uint8_t measurementsToAverage) - : TIADS1x15(powerPin, adsDiffMux, 1.0, GAIN_ONE, i2cAddress, - measurementsToAverage) { + : TIADS1x15(powerPin, adsDiffMux, ALPHASENSE_CO2_VOLTAGE_MULTIPLIER, + GAIN_ONE, i2cAddress, measurementsToAverage) { // Override timing settings for Alphasense CO2-specific requirements _warmUpTime_ms = ALPHASENSE_CO2_WARM_UP_TIME_MS; _stabilizationTime_ms = ALPHASENSE_CO2_STABILIZATION_TIME_MS; @@ -59,13 +59,14 @@ bool AlphasenseCO2::addSingleMeasurementResult(void) { // The voltage multiplier and gain settings are handled by the parent class if (readVoltageDifferential(adcVoltage)) { MS_DBG(F(" Differential voltage:"), String(adcVoltage, 3), F("V")); - // Convert voltage to current (mA) - assuming a 250 Ohm resistor is in - // series - co2Current = (adcVoltage / 250) * 1000; - MS_DBG(F(" co2Current:"), calibResult); - // Convert current to ppm (using a formula recommended by the sensor + // Convert voltage to current (mA) - using series sense resistor + co2Current = (adcVoltage / ALPHASENSE_CO2_SENSE_RESISTOR_OHM) * 1000; + MS_DBG(F(" co2Current:"), + co2Current); // Convert current to ppm (using a formula + // recommended by the sensor // manufacturer) - calibResult = 312.5 * co2Current - 1250; + calibResult = ALPHASENSE_CO2_MFG_SCALE * co2Current - + ALPHASENSE_CO2_MFG_OFFSET; MS_DBG(F(" calibResult:"), calibResult); verifyAndAddMeasurementResult(ALPHASENSE_CO2_VAR_NUM, calibResult); verifyAndAddMeasurementResult(ALPHASENSE_CO2_VOLTAGE_VAR_NUM, diff --git a/src/sensors/AlphasenseCO2.h b/src/sensors/AlphasenseCO2.h index e61273ae5..270dc3c07 100644 --- a/src/sensors/AlphasenseCO2.h +++ b/src/sensors/AlphasenseCO2.h @@ -55,8 +55,14 @@ * @section sensor_alphasense_co2_flags Build flags * - ```-D MS_USE_ADS1015``` * - switches from the 16-bit ADS1115 to the 12 bit ADS1015 - * - ```-D ALPHASENSE_CO2_CALIBRATION_FACTOR=x``` - * - Changes the calibration factor from 1 to x + * - ```-D ALPHASENSE_CO2_SENSE_RESISTOR_OHM=x``` + * - Changes the sense resistor value from 250.0 ohms to x ohms + * - ```-D ALPHASENSE_CO2_MFG_SCALE=x``` + * - Changes the manufacturer scale factor from 312.5 ppm/mA to x ppm/mA + * - ```-D ALPHASENSE_CO2_MFG_OFFSET=x``` + * - Changes the manufacturer offset from 1250.0 ppm to x ppm + * - ```-D ALPHASENSE_CO2_VOLTAGE_MULTIPLIER=x``` + * - Changes the voltage multiplier from 1.0 to x * * @section sensor_alphasense_co2_ctor Sensor Constructor * {{ @ref AlphasenseCO2::AlphasenseCO2 }} @@ -111,19 +117,35 @@ /**@}*/ /** - * @anchor sensor__alphasense_co2_config + * @anchor sensor_alphasense_co2_config * @name Configuration Defines * Defines to set the calibration of the Alphasense CO2 sensor and the address * of the ADD. */ /**@{*/ -#if !defined(ALPHASENSE_CO2_CALIBRATION_FACTOR) || defined(DOXYGEN) +#if !defined(ALPHASENSE_CO2_SENSE_RESISTOR_OHM) || defined(DOXYGEN) /** - * @brief The calibration factor between output in volts and CO2 - * (microeinsteinPerSquareMeterPerSecond) 1 µmol mˉ² sˉ¹ per mV (reciprocal of - * sensitivity) + * @brief Sense resistor value in ohms for current conversion */ -#define ALPHASENSE_CO2_CALIBRATION_FACTOR 1 +#define ALPHASENSE_CO2_SENSE_RESISTOR_OHM 250.0 +#endif +#if !defined(ALPHASENSE_CO2_MFG_SCALE) || defined(DOXYGEN) +/** + * @brief Manufacturer scale factor for CO2 conversion (ppm/mA) + */ +#define ALPHASENSE_CO2_MFG_SCALE 312.5 +#endif +#if !defined(ALPHASENSE_CO2_MFG_OFFSET) || defined(DOXYGEN) +/** + * @brief Manufacturer offset for CO2 conversion (ppm) + */ +#define ALPHASENSE_CO2_MFG_OFFSET 1250.0 +#endif +#if !defined(ALPHASENSE_CO2_VOLTAGE_MULTIPLIER) || defined(DOXYGEN) +/** + * @brief Voltage multiplier for direct voltage reading + */ +#define ALPHASENSE_CO2_VOLTAGE_MULTIPLIER 1.0 #endif /**@}*/ From 3b3f6f492db4035a2e6b79fbeda0a1eb22ea5960 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Fri, 20 Feb 2026 15:39:01 -0500 Subject: [PATCH 271/533] More magic numbers to defines Signed-off-by: Sara Damiano --- src/sensors/TurnerTurbidityPlus.cpp | 8 +++---- src/sensors/TurnerTurbidityPlus.h | 34 ++++++++++++++++++++++++----- 2 files changed, 32 insertions(+), 10 deletions(-) diff --git a/src/sensors/TurnerTurbidityPlus.cpp b/src/sensors/TurnerTurbidityPlus.cpp index acd55a82c..6add4eba1 100644 --- a/src/sensors/TurnerTurbidityPlus.cpp +++ b/src/sensors/TurnerTurbidityPlus.cpp @@ -52,12 +52,12 @@ void TurnerTurbidityPlus::runWiper() { // without pausing for ~540ms between them. MS_DBG(F("Turn TurbidityPlus wiper on"), getSensorLocation()); digitalWrite(_wiperTriggerPin, LOW); - delay(50); + delay(TURBIDITY_PLUS_WIPER_TRIGGER_PULSE_MS); digitalWrite(_wiperTriggerPin, HIGH); // It takes ~7.5 sec for a rotation to complete. Wait for that to finish // before continuing, otherwise the sensor will get powered off before wipe // completes, and any reading taken during wiper cycle is invalid. - delay(8000); + delay(TURBIDITY_PLUS_WIPER_ROTATION_WAIT_MS); MS_DBG(F("TurbidityPlus wiper cycle should be finished")); } @@ -80,13 +80,13 @@ bool TurnerTurbidityPlus::wake(void) { void TurnerTurbidityPlus::powerDown(void) { // Set the wiper trigger pin LOW to avoid power drain. digitalWrite(_wiperTriggerPin, LOW); - return TIADS1x15::powerDown(); + TIADS1x15::powerDown(); } void TurnerTurbidityPlus::powerUp(void) { // Set the wiper trigger pin HIGH to prepare for wiping. digitalWrite(_wiperTriggerPin, HIGH); - return TIADS1x15::powerUp(); + TIADS1x15::powerUp(); } bool TurnerTurbidityPlus::addSingleMeasurementResult(void) { diff --git a/src/sensors/TurnerTurbidityPlus.h b/src/sensors/TurnerTurbidityPlus.h index 8f3062772..fb8ac206d 100644 --- a/src/sensors/TurnerTurbidityPlus.h +++ b/src/sensors/TurnerTurbidityPlus.h @@ -29,6 +29,10 @@ * @section sensor_turbidity_plus_flags Build flags * - ```-D MS_USE_ADS1015``` * - switches from the 16-bit ADS1115 to the 12 bit ADS1015 + * - ```-D TURBIDITY_PLUS_WIPER_TRIGGER_PULSE_MS=x``` + * - Changes the wiper trigger pulse duration from 50 ms to x ms + * - ```-D TURBIDITY_PLUS_WIPER_ROTATION_WAIT_MS=x``` + * - Changes the wiper rotation wait time from 8000 ms to x ms * * @section sensor_turbidity_plus_ctor Sensor Constructor * {{ @ref TurnerTurbidityPlus::TurnerTurbidityPlus }} @@ -84,6 +88,26 @@ #define TURBIDITY_PLUS_INC_CALC_VARIABLES 1 /**@}*/ +/** + * @anchor sensor_turbidity_plus_config + * @name Configuration Defines + * Defines to set the timing configuration of the Turner Turbidity Plus sensor. + */ +/**@{*/ +#if !defined(TURBIDITY_PLUS_WIPER_TRIGGER_PULSE_MS) || defined(DOXYGEN) +/** + * @brief Wiper trigger pulse duration in milliseconds + */ +#define TURBIDITY_PLUS_WIPER_TRIGGER_PULSE_MS 50 +#endif +#if !defined(TURBIDITY_PLUS_WIPER_ROTATION_WAIT_MS) || defined(DOXYGEN) +/** + * @brief Wait time for wiper rotation to complete in milliseconds + */ +#define TURBIDITY_PLUS_WIPER_ROTATION_WAIT_MS 8000 +#endif +/**@}*/ + /** * @anchor sensor_turbidity_plus_timing * @name Sensor Timing @@ -161,15 +185,14 @@ #ifdef MS_USE_ADS1015 /// @brief Decimals places in string representation; voltage should have 1. /// - Resolution: -/// - 16-bit ADC (ADS1115): 0.125 mV +/// - 12-bit ADC (ADS1015): 2 mV #define TURBIDITY_PLUS_VOLTAGE_RESOLUTION 1 #else /// @brief Decimals places in string representation; voltage should have 4. /// - Resolution: -/// - 12-bit ADC (ADS1015, using build flag ```MS_USE_ADS1015```): 2 mV +/// - 16-bit ADC (ADS1115): 0.125 mV #define TURBIDITY_PLUS_VOLTAGE_RESOLUTION 4 -#endif -/**@}*/ +#endif /**@}*/ /** * @brief The Sensor sub-class for the [Turner Turbidity Plus turbidity * sensor](@ref sensor_turbidity_plus). @@ -205,8 +228,7 @@ class TurnerTurbidityPlus : public TIADS1x15 { * dividers or gain settings. * @param volt_blank The voltage (in volts) measured for a blank. This * voltage should be the final voltage *after* accounting for any voltage - * @param i2cAddress The I2C address of the ADS 1x15, default is 0x48 (ADDR - * = GND) + * dividers or gain settings. * = GND) * @param PGA_gain The programmable gain amplification to set on the * ADS 1x15, default is GAIN_ONE (0-4.096V). * @param measurementsToAverage The number of measurements to take and From 787ff32eef5676a084269a889fa8d9b69693277e Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Fri, 20 Feb 2026 15:39:52 -0500 Subject: [PATCH 272/533] Remove orphan docs Signed-off-by: Sara Damiano --- src/sensors/TurnerTurbidityPlus.h | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/src/sensors/TurnerTurbidityPlus.h b/src/sensors/TurnerTurbidityPlus.h index fb8ac206d..5fbe88084 100644 --- a/src/sensors/TurnerTurbidityPlus.h +++ b/src/sensors/TurnerTurbidityPlus.h @@ -302,16 +302,6 @@ class TurnerTurbidityPlus : public TIADS1x15 { * be the final voltage *after* accounting for any voltage. */ float _volt_blank; - /** - * @brief For 3.3V processors like the Mayfly, The Turner's 0-5V output - * signal must be shifted down to a maximum of 3.3V. This can be done either - * either with a level-shifting chip (e.g. Adafruit BSS38), OR by connecting - * the Turner's output signal via a voltage divider. This - * voltageDividerFactor is used for the latter case: e.g., a divider that - * uses 2 matched resistors will halve the voltage reading and requires a - * voltageDividerFactor of 2. The default value is 1. - * Note: This functionality is now handled by the parent class's _voltageMultiplier. - */ }; From e8aa79da0406ab8c2c94ddf0664dec49473f7ded Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Mon, 23 Feb 2026 15:34:00 -0500 Subject: [PATCH 273/533] Create a base class for Analog Voltages (with a lot of AI input) Signed-off-by: Sara Damiano --- src/sensors/AnalogVoltageBase.h | 178 +++++++++++++++++++++++++++++ src/sensors/ProcessorAnalog.cpp | 29 +++-- src/sensors/ProcessorAnalog.h | 82 ++++++++------ src/sensors/TIADS1x15.cpp | 172 +++++++++++++++------------- src/sensors/TIADS1x15.h | 195 ++++++++++++++++++++------------ 5 files changed, 453 insertions(+), 203 deletions(-) create mode 100644 src/sensors/AnalogVoltageBase.h diff --git a/src/sensors/AnalogVoltageBase.h b/src/sensors/AnalogVoltageBase.h new file mode 100644 index 000000000..111e55495 --- /dev/null +++ b/src/sensors/AnalogVoltageBase.h @@ -0,0 +1,178 @@ +/** + * @file AnalogVoltageBase.h + * @copyright Stroud Water Research Center + * Part of the EnviroDIY ModularSensors library for Arduino. + * This library is published under the BSD-3 license. + * @author Sara Geleskie Damiano + * + * @brief Contains the AnalogVoltageBase abstract class for providing a unified + * interface for analog voltage reading sensors. + * + * This abstract base class provides a common interface for sensors that can + * read single-ended analog voltages, either through external ADCs (like TI + * ADS1x15) or built-in processor ADCs. + */ + +// Header Guards +#ifndef SRC_SENSORS_ANALOGVOLTAGEBASE_H_ +#define SRC_SENSORS_ANALOGVOLTAGEBASE_H_ + +// Include the library config before anything else +#include "ModSensorConfig.h" + +// Include the debugging config +#include "ModSensorDebugConfig.h" + +// Include the known processors for default values +#include "KnownProcessors.h" + +/** + * @brief Abstract base class for analog voltage reading systems. + * + * This class provides a unified interface for analog voltage reading, + * whether from external ADCs (like TI ADS1x15) or processor built-in ADCs. + * Classes that inherit from this base must implement the + * readVoltageSingleEnded method to provide their specific voltage reading + * implementation. + */ +class AnalogVoltageBase { + public: + /** + * @brief Construct a new AnalogVoltageBase object + * + * @param analogChannel The analog channel/pin for voltage readings + * @param voltageMultiplier The voltage multiplier for any voltage dividers + * @param supplyVoltage The supply/operating voltage for the analog system + * @param analogDifferentialChannel The second channel for differential + * measurements (-1 if not used) + */ + AnalogVoltageBase(int8_t analogChannel, float voltageMultiplier = 1.0, + float supplyVoltage = OPERATING_VOLTAGE, + int8_t analogDifferentialChannel = -1) + : _analogChannel(analogChannel), + _voltageMultiplier(voltageMultiplier), + _supplyVoltage(supplyVoltage), + _analogDifferentialChannel(analogDifferentialChannel) {} + + /** + * @brief Destroy the AnalogVoltageBase object + */ + virtual ~AnalogVoltageBase() = default; + + /** + * @brief Set the voltage multiplier for voltage divider calculations + * + * @param voltageMultiplier The multiplier value for voltage scaling + */ + void setVoltageMultiplier(float voltageMultiplier) { + _voltageMultiplier = voltageMultiplier; + } + + /** + * @brief Get the voltage multiplier value + * + * @return The current voltage multiplier + */ + float getVoltageMultiplier(void) { + return _voltageMultiplier; + } + + /** + * @brief Set the supply voltage for the analog system + * + * @param supplyVoltage The supply voltage in volts + */ + virtual void setSupplyVoltage(float supplyVoltage) { + _supplyVoltage = supplyVoltage; + } + + /** + * @brief Get the supply voltage for the analog system + * + * @return The current supply voltage in volts + */ + float getSupplyVoltage(void) { + return _supplyVoltage; + } + + /** + * @brief Check if this instance is configured for differential measurements + * + * @return True if both analog channels are valid pins (>=0) for + * differential measurements + */ + bool isDifferential(void) const { + return (_analogChannel >= 0 && _analogDifferentialChannel >= 0); + } + + /** + * @brief Read a single-ended voltage measurement + * + * This pure virtual function must be implemented by derived classes to + * provide their specific method of reading analog voltages. + * + * @param resultValue Reference to store the resulting voltage measurement + * @return True if the voltage reading was successful and within valid range + */ + virtual bool readVoltageSingleEnded(float& resultValue) = 0; + + /** + * @brief Read a differential voltage measurement + * + * This virtual function provides a default implementation for differential + * voltage readings. Derived classes can override this to provide their + * specific differential reading implementation. + * + * @param resultValue Reference to store the resulting voltage measurement + * @return True if the voltage reading was successful and within valid range + */ + virtual bool readVoltageDifferential(float& resultValue) { + resultValue = -9999.0; + return false; + } + + /** + * @brief Get the sensor location string + * + * This pure virtual function must be implemented by derived classes to + * provide their specific sensor location identification string. + * + * @return A string describing the sensor location + */ + virtual String getSensorLocation(void) = 0; + + protected: + /** + * @brief Internal reference to the analog channel/pin + * + * For TIADS1x15: ADS channel (0-3) + * For ProcessorAnalog: processor ADC pin number + */ + int8_t _analogChannel; + + /** + * @brief Internal reference to the voltage multiplier + * + * Multiplier to apply for voltage divider calculations + */ + float _voltageMultiplier; + + /** + * @brief Internal reference to the supply voltage + * + * For TIADS1x15: the ADS supply voltage + * For ProcessorAnalog: the processor operating voltage + */ + float _supplyVoltage; + + /** + * @brief Internal reference to the second analog channel for differential + * measurements + * + * For TIADS1x15: second ADS channel for differential readings (-1 if not + * used) For ProcessorAnalog: not used (-1) + */ + int8_t _analogDifferentialChannel; +}; + +#endif // SRC_SENSORS_ANALOGVOLTAGEBASE_H_ diff --git a/src/sensors/ProcessorAnalog.cpp b/src/sensors/ProcessorAnalog.cpp index 6cbc16f6b..ba3ee79bf 100644 --- a/src/sensors/ProcessorAnalog.cpp +++ b/src/sensors/ProcessorAnalog.cpp @@ -23,8 +23,7 @@ ProcessorAnalog::ProcessorAnalog(int8_t powerPin, int8_t dataPin, PROCESSOR_ANALOG_STABILIZATION_TIME_MS, PROCESSOR_ANALOG_MEASUREMENT_TIME_MS, powerPin, dataPin, measurementsToAverage, PROCESSOR_ANALOG_INC_CALC_VARIABLES), - _voltageMultiplier(voltageMultiplier), - _operatingVoltage(operatingVoltage) {} + ProcessorAnalogBase(dataPin, voltageMultiplier, operatingVoltage) {} // Destructor ProcessorAnalog::~ProcessorAnalog() {} @@ -48,30 +47,30 @@ bool ProcessorAnalog::addSingleMeasurementResult(void) { return bumpMeasurementAttemptCount(success); } -bool ProcessorAnalog::readVoltageSingleEnded(float& resultValue) { +bool ProcessorAnalogBase::readVoltageSingleEnded(float& resultValue) { // Validate parameters if (PROCESSOR_ADC_MAX <= 0) { MS_DBG(F("Processor ADC max value is not set or invalid!")); return false; } - if (_dataPin < 0 || _operatingVoltage <= 0 || _voltageMultiplier <= 0) { + if (_analogChannel < 0 || _supplyVoltage <= 0 || _voltageMultiplier <= 0) { MS_DBG(F("Missing one or more required parameters: analog pin, " "operating voltage, or voltage divider!")); return false; } // Get the analog voltage - MS_DBG(F("Getting analog voltage from pin"), _dataPin); - pinMode(_dataPin, INPUT); - analogRead(_dataPin); // priming reading + MS_DBG(F("Getting analog voltage from pin"), _analogChannel); + pinMode(_analogChannel, INPUT); + analogRead(_analogChannel); // priming reading // The return value from analogRead() is IN BITS NOT IN VOLTS!! - analogRead(_dataPin); // another priming reading - float rawAnalog = analogRead(_dataPin); + analogRead(_analogChannel); // another priming reading + float rawAnalog = analogRead(_analogChannel); MS_DBG(F("Raw analog pin reading in bits:"), rawAnalog); // convert bits to volts float sensorValue_analog = - (_operatingVoltage / static_cast(PROCESSOR_ADC_MAX)) * + (_supplyVoltage / static_cast(PROCESSOR_ADC_MAX)) * _voltageMultiplier * rawAnalog; MS_DBG(F("Voltage:"), sensorValue_analog); @@ -82,10 +81,8 @@ bool ProcessorAnalog::readVoltageSingleEnded(float& resultValue) { return true; } -void ProcessorAnalog::setVoltageMultiplier(float voltageMultiplier) { - _voltageMultiplier = voltageMultiplier; -} - -float ProcessorAnalog::getVoltageMultiplier(void) { - return _voltageMultiplier; +String ProcessorAnalogBase::getSensorLocation(void) { + String sensorLocation = F("ProcessorAnalog_Pin"); + sensorLocation += String(_analogChannel); + return sensorLocation; } diff --git a/src/sensors/ProcessorAnalog.h b/src/sensors/ProcessorAnalog.h index b8fc58b13..ee6124159 100644 --- a/src/sensors/ProcessorAnalog.h +++ b/src/sensors/ProcessorAnalog.h @@ -76,6 +76,7 @@ // Include other in-library and external dependencies #include "VariableBase.h" #include "SensorBase.h" +#include "AnalogVoltageBase.h" /** @ingroup sensor_processor_analog */ /**@{*/ @@ -155,6 +156,52 @@ #endif /**@}*/ +/** + * @brief Processor analog base class that inherits from AnalogVoltageBase + * + * This class provides processor-specific analog functionality on top of + * the generic AnalogVoltageBase class. It handles processor ADC configuration + * and maintains the data pin information for analog readings. + */ +class ProcessorAnalogBase : public AnalogVoltageBase { + public: + /** + * @brief Construct a new ProcessorAnalogBase object + * + * @param dataPin The processor ADC pin used to read the target voltage. Not + * all processor pins can be used as analog pins. Those usable as analog + * pins generally are numbered with an "A" in front of the number - ie, A1. + * @param voltageMultiplier Any multiplier needed to convert raw battery + * readings from `analogRead()` into true battery values based on any + * resistors or voltage dividers + * @param operatingVoltage The processor's operating voltage; most + * likely 3.3 or 5. + */ + ProcessorAnalogBase(int8_t dataPin, float voltageMultiplier, + float operatingVoltage = OPERATING_VOLTAGE) + : AnalogVoltageBase(dataPin, voltageMultiplier, operatingVoltage, -1) {} + + /** + * @brief Destroy the ProcessorAnalogBase object + */ + virtual ~ProcessorAnalogBase() = default; + + /** + * @brief Read a single-ended voltage measurement from the processor ADC + * + * @param resultValue Reference to store the resulting voltage measurement + * @return True if the voltage reading was successful + */ + bool readVoltageSingleEnded(float& resultValue) override; + + /** + * @brief Get the sensor location string + * + * @return A string describing the processor analog pin location + */ + String getSensorLocation(void) override; +}; + /* clang-format off */ /** * @brief The Sensor sub-class for the @@ -163,7 +210,7 @@ * @ingroup sensor_processor_analog */ /* clang-format on */ -class ProcessorAnalog : public Sensor { +class ProcessorAnalog : public Sensor, public ProcessorAnalogBase { public: /** * @brief Construct a new Processor Analog object - need the power pin and @@ -193,39 +240,6 @@ class ProcessorAnalog : public Sensor { ~ProcessorAnalog(); bool addSingleMeasurementResult(void) override; - - /** - * @brief Set the voltage multiplier for the processor analog sensor - * - * @param voltageMultiplier Any multiplier needed to convert raw readings - * from analogRead() into true voltage values based on any resistors or - * voltage dividers - */ - void setVoltageMultiplier(float voltageMultiplier); - - /** - * @brief Get the voltage multiplier for the processor analog sensor - * - * @return The voltage multiplier value - */ - float getVoltageMultiplier(void); - - protected: - /** - * @brief Read a single-ended voltage measurement from the processor ADC - * - * @param resultValue Reference to store the resulting voltage measurement - * @return True if the voltage reading was successful - */ - virtual bool readVoltageSingleEnded(float& resultValue); - - private: - float _voltageMultiplier; ///< Internal reference to any multiplier needed - ///< to convert raw battery readings into true - ///< battery values based on any resistors or - ///< voltage dividers - float _operatingVoltage; ///< Internal reference to processor's operating - ///< voltage }; diff --git a/src/sensors/TIADS1x15.cpp b/src/sensors/TIADS1x15.cpp index 7af4b4767..88ed4b701 100644 --- a/src/sensors/TIADS1x15.cpp +++ b/src/sensors/TIADS1x15.cpp @@ -24,66 +24,54 @@ TIADS1x15::TIADS1x15(int8_t powerPin, uint8_t adsChannel, float adsSupplyVoltage) : Sensor("TIADS1x15", TIADS1X15_NUM_VARIABLES, TIADS1X15_WARM_UP_TIME_MS, TIADS1X15_STABILIZATION_TIME_MS, TIADS1X15_MEASUREMENT_TIME_MS, - powerPin, -1, measurementsToAverage, TIADS1X15_INC_CALC_VARIABLES), - _adsChannel(adsChannel), - _isDifferential(false), - _adsDiffMux( - tiads1x15_adsDiffMux_t::TIADS1X15_DIFF_MUX_0_1), // Default value, - // not used - _voltageMultiplier(voltageMultiplier), - _adsGain(adsGain), - _i2cAddress(i2cAddress), - _adsSupplyVoltage(adsSupplyVoltage) {} + powerPin, adsChannel, measurementsToAverage, + TIADS1X15_INC_CALC_VARIABLES), + TIADS1x15Base(adsChannel, voltageMultiplier, adsGain, i2cAddress, + adsSupplyVoltage) { + // Validate ADS1x15 channel range + if (adsChannel > 3) { + // Invalid channel, clamp to valid range + _analogChannel = 3; + } +} // Constructor for differential measurements -TIADS1x15::TIADS1x15(int8_t powerPin, tiads1x15_adsDiffMux_t adsDiffMux, +TIADS1x15::TIADS1x15(int8_t powerPin, uint8_t adsChannel1, uint8_t adsChannel2, float voltageMultiplier, adsGain_t adsGain, uint8_t i2cAddress, uint8_t measurementsToAverage, float adsSupplyVoltage) : Sensor("TIADS1x15", TIADS1X15_NUM_VARIABLES, TIADS1X15_WARM_UP_TIME_MS, TIADS1X15_STABILIZATION_TIME_MS, TIADS1X15_MEASUREMENT_TIME_MS, powerPin, -1, measurementsToAverage, TIADS1X15_INC_CALC_VARIABLES), - _adsChannel(0), // Not used for differential - _isDifferential(true), - _adsDiffMux(adsDiffMux), - _voltageMultiplier(voltageMultiplier), - _adsGain(adsGain), - _i2cAddress(i2cAddress), - _adsSupplyVoltage(adsSupplyVoltage) {} + TIADS1x15Base(adsChannel1, adsChannel2, voltageMultiplier, adsGain, i2cAddress, + adsSupplyVoltage) {} // Destructor TIADS1x15::~TIADS1x15() {} -String TIADS1x15::getSensorLocation(void) { +String TIADS1x15Base::getSensorLocation(void) { #ifndef MS_USE_ADS1015 String sensorLocation = F("ADS1115_0x"); #else String sensorLocation = F("ADS1015_0x"); #endif sensorLocation += String(_i2cAddress, HEX); - if (_isDifferential) { + if (isDifferential()) { sensorLocation += F("_Diff"); - switch (_adsDiffMux) { - case tiads1x15_adsDiffMux_t::TIADS1X15_DIFF_MUX_0_1: - sensorLocation += F("0_1"); - break; - case tiads1x15_adsDiffMux_t::TIADS1X15_DIFF_MUX_0_3: - sensorLocation += F("0_3"); - break; - case tiads1x15_adsDiffMux_t::TIADS1X15_DIFF_MUX_1_3: - sensorLocation += F("1_3"); - break; - case tiads1x15_adsDiffMux_t::TIADS1X15_DIFF_MUX_2_3: - sensorLocation += F("2_3"); - break; - } + sensorLocation += String(_analogChannel); + sensorLocation += F("_"); + sensorLocation += String(_analogDifferentialChannel); } else { sensorLocation += F("_Channel"); - sensorLocation += String(_adsChannel); + sensorLocation += String(_analogChannel); } return sensorLocation; } +String TIADS1x15::getSensorLocation(void) { + return TIADS1x15Base::getSensorLocation(); +} + bool TIADS1x15::addSingleMeasurementResult(void) { // Immediately quit if the measurement was not successfully started @@ -97,7 +85,7 @@ bool TIADS1x15::addSingleMeasurementResult(void) { bool success = false; // Use differential or single-ended reading based on configuration - if (_isDifferential) { + if (isDifferential()) { success = readVoltageDifferential(resultValue); } else { success = readVoltageSingleEnded(resultValue); @@ -111,7 +99,7 @@ bool TIADS1x15::addSingleMeasurementResult(void) { return bumpMeasurementAttemptCount(success); } -bool TIADS1x15::readVoltageSingleEnded(float& resultValue) { +bool TIADS1x15Base::readVoltageSingleEnded(float& resultValue) { bool success = false; int16_t adcCounts = -9999; float adcVoltage = -9999; @@ -145,23 +133,30 @@ bool TIADS1x15::readVoltageSingleEnded(float& resultValue) { } // Read Analog to Digital Converter (ADC) + // Validate ADS1x15 channel range for single-ended measurements + if (_analogChannel < 0 || _analogChannel > 3) { + MS_DBG(F(" Invalid ADS1x15 channel "), _analogChannel, + F(", valid range is 0-3")); + return false; + } + // Taking this reading includes the 8ms conversion delay. // Measure the ADC raw count - adcCounts = ads.readADC_SingleEnded(_adsChannel); + adcCounts = ads.readADC_SingleEnded(_analogChannel); // Convert ADC raw counts value to voltage (V) adcVoltage = ads.computeVolts(adcCounts); - MS_DBG(F(" ads.readADC_SingleEnded("), _adsChannel, F("):"), adcCounts, + MS_DBG(F(" ads.readADC_SingleEnded("), _analogChannel, F("):"), adcCounts, F(" voltage:"), adcVoltage); // Verify the range based on the actual power supplied to the ADS. // Valid range is approximately -0.3V to (supply voltage + 0.3V) with // absolute maximum of 5.5V per datasheet float minValidVoltage = -0.3; - float maxValidVoltage = _adsSupplyVoltage + 0.3; + float maxValidVoltage = _supplyVoltage + 0.3; if (maxValidVoltage > 5.5) { maxValidVoltage = 5.5; // Absolute maximum per datasheet } - MS_DBG(F(" ADS supply voltage:"), _adsSupplyVoltage, F("V")); + MS_DBG(F(" ADS supply voltage:"), _supplyVoltage, F("V")); MS_DBG(F(" Valid voltage range:"), minValidVoltage, F("V to"), maxValidVoltage, F("V")); @@ -179,7 +174,7 @@ bool TIADS1x15::readVoltageSingleEnded(float& resultValue) { return success; } -bool TIADS1x15::readVoltageDifferential(float& resultValue) { +bool TIADS1x15Base::readVoltageDifferential(float& resultValue) { bool success = false; int16_t adcCounts = -9999; float adcVoltage = -9999; @@ -201,23 +196,28 @@ bool TIADS1x15::readVoltageDifferential(float& resultValue) { return false; } - // Read differential voltage based on mux configuration - switch (_adsDiffMux) { - case tiads1x15_adsDiffMux_t::TIADS1X15_DIFF_MUX_0_1: - adcCounts = ads.readADC_Differential_0_1(); - break; - case tiads1x15_adsDiffMux_t::TIADS1X15_DIFF_MUX_0_3: - adcCounts = ads.readADC_Differential_0_3(); - break; - case tiads1x15_adsDiffMux_t::TIADS1X15_DIFF_MUX_1_3: - adcCounts = ads.readADC_Differential_1_3(); - break; - case tiads1x15_adsDiffMux_t::TIADS1X15_DIFF_MUX_2_3: - adcCounts = ads.readADC_Differential_2_3(); - break; - default: - MS_DBG(F(" Invalid differential mux configuration")); - return false; + // Validate differential channel combination + if (!isValidDifferentialPair(_analogChannel, _analogDifferentialChannel)) { + MS_DBG(F(" Invalid differential channel pair: "), _analogChannel, + F("-"), _analogDifferentialChannel); + return false; + } + + // Read differential voltage based on channel configuration + uint8_t ch1 = _analogChannel; + uint8_t ch2 = _analogDifferentialChannel; + + if ((ch1 == 0 && ch2 == 1) || (ch1 == 1 && ch2 == 0)) { + adcCounts = ads.readADC_Differential_0_1(); + } else if ((ch1 == 0 && ch2 == 3) || (ch1 == 3 && ch2 == 0)) { + adcCounts = ads.readADC_Differential_0_3(); + } else if ((ch1 == 1 && ch2 == 3) || (ch1 == 3 && ch2 == 1)) { + adcCounts = ads.readADC_Differential_1_3(); + } else if ((ch1 == 2 && ch2 == 3) || (ch1 == 3 && ch2 == 2)) { + adcCounts = ads.readADC_Differential_2_3(); + } else { + MS_DBG(F(" Unsupported differential channel combination")); + return false; } // Convert counts to voltage @@ -260,30 +260,44 @@ bool TIADS1x15::readVoltageDifferential(float& resultValue) { return success; } -// Setter and getter methods for ADS supply voltage -void TIADS1x15::setADSSupplyVoltage(float adsSupplyVoltage) { - // Validate supply voltage range: 0.0V to 5.5V per datasheet - if (adsSupplyVoltage < 0.0) { - MS_DBG(F("ADS supply voltage "), adsSupplyVoltage, - F("V is below minimum, clamping to 0.0V")); - _adsSupplyVoltage = 0.0; - } else if (adsSupplyVoltage > 5.5) { - MS_DBG(F("ADS supply voltage "), adsSupplyVoltage, - F("V exceeds maximum, clamping to 5.5V")); - _adsSupplyVoltage = 5.5; - } else { - _adsSupplyVoltage = adsSupplyVoltage; - } -} - -float TIADS1x15::getADSSupplyVoltage(void) { - return _adsSupplyVoltage; +// Validation function for differential channel pairs +bool TIADS1x15Base::isValidDifferentialPair(uint8_t channel1, + uint8_t channel2) { + // Valid combinations are: 0-1, 0-3, 1-3, or 2-3 + if ((channel1 == 0 && channel2 == 1) || (channel1 == 1 && channel2 == 0)) + return true; + if ((channel1 == 0 && channel2 == 3) || (channel1 == 3 && channel2 == 0)) + return true; + if ((channel1 == 1 && channel2 == 3) || (channel1 == 3 && channel2 == 1)) + return true; + if ((channel1 == 2 && channel2 == 3) || (channel1 == 3 && channel2 == 2)) + return true; + return false; } -void TIADS1x15::setADSGain(adsGain_t adsGain) { +// Setter and getter methods for ADS gain +void TIADS1x15Base::setADSGain(adsGain_t adsGain) { _adsGain = adsGain; } -adsGain_t TIADS1x15::getADSGain(void) { +adsGain_t TIADS1x15Base::getADSGain(void) { return _adsGain; } + +// Override setSupplyVoltage in TIADS1x15 to validate range +void TIADS1x15::setSupplyVoltage(float supplyVoltage) { + // Validate supply voltage range: 0.0V to 5.5V per datasheet + if (supplyVoltage < 0.0) { + MS_DBG(F("ADS supply voltage "), supplyVoltage, + F("V is below minimum, clamping to 0.0V")); + _supplyVoltage = 0.0; + } else if (supplyVoltage > 5.5) { + MS_DBG(F("ADS supply voltage "), supplyVoltage, + F("V exceeds maximum, clamping to 5.5V")); + _supplyVoltage = 5.5; + } else { + _supplyVoltage = supplyVoltage; + } +} + +// cspell:words TWOTHIRDS diff --git a/src/sensors/TIADS1x15.h b/src/sensors/TIADS1x15.h index 36fbbd619..cd0f0ee0a 100644 --- a/src/sensors/TIADS1x15.h +++ b/src/sensors/TIADS1x15.h @@ -168,6 +168,7 @@ // Include other in-library and external dependencies #include "VariableBase.h" #include "SensorBase.h" +#include "AnalogVoltageBase.h" #include /** @ingroup sensor_ads1x15 */ @@ -272,6 +273,118 @@ enum class tiads1x15_adsDiffMux_t : uint16_t { #endif /**@}*/ +/** + * @brief TI ADS1x15 base class that inherits from AnalogVoltageBase + * + * This class provides ADS1x15-specific analog functionality on top of + * the generic AnalogVoltageBase class. It handles ADS configuration, + * I2C communication, and differential/single-ended measurement modes. + */ +class TIADS1x15Base : public AnalogVoltageBase { + public: + /** + * @brief Check if the two channels form a valid differential pair + * + * @param channel1 First channel (0-3) + * @param channel2 Second channel (0-3) + * @return True if the combination is valid (0-1, 0-3, 1-3, or 2-3) + */ + static bool isValidDifferentialPair(uint8_t channel1, uint8_t channel2); + + /** + * @brief Construct a new TIADS1x15Base object for single-ended measurements + * + * @param adsChannel The ADS channel of interest (0-3). + * @param voltageMultiplier The voltage multiplier for any voltage dividers + * @param adsGain The internal gain setting of the ADS1x15 + * @param i2cAddress The I2C address of the ADS 1x15 + * @param adsSupplyVoltage The power supply voltage for the ADS1x15 in volts + */ + TIADS1x15Base(uint8_t adsChannel, float voltageMultiplier, + adsGain_t adsGain, uint8_t i2cAddress, + float adsSupplyVoltage) + : AnalogVoltageBase(adsChannel, voltageMultiplier, adsSupplyVoltage, -1), + _adsGain(adsGain), + _i2cAddress(i2cAddress) {} + + /** + * @brief Construct a new TIADS1x15Base object for differential measurements + * + * @param adsChannel1 The first ADS channel for differential measurement (0-3) + * @param adsChannel2 The second ADS channel for differential measurement (0-3) + * @param voltageMultiplier The voltage multiplier for any voltage dividers + * @param adsGain The internal gain setting of the ADS1x15 + * @param i2cAddress The I2C address of the ADS 1x15 + * @param adsSupplyVoltage The power supply voltage for the ADS1x15 in volts + */ + TIADS1x15Base(uint8_t adsChannel1, uint8_t adsChannel2, float voltageMultiplier, + adsGain_t adsGain, uint8_t i2cAddress, + float adsSupplyVoltage) + : AnalogVoltageBase(adsChannel1, voltageMultiplier, adsSupplyVoltage, adsChannel2), + _adsGain(adsGain), + _i2cAddress(i2cAddress) { + // Validate differential channel combinations + if (!isValidDifferentialPair(adsChannel1, adsChannel2)) { + // Default to 0-1 if invalid combination + _analogChannel = 0; + _analogDifferentialChannel = 1; + } + } + + /** + * @brief Destroy the TIADS1x15Base object + */ + virtual ~TIADS1x15Base() = default; + + /** + * @brief Read a single-ended voltage measurement from the ADS1x15 + * + * @param resultValue Reference to store the resulting voltage measurement + * @return True if the voltage reading was successful + */ + bool readVoltageSingleEnded(float& resultValue) override; + + /** + * @brief Read a differential voltage measurement from the ADS1x15 + * + * @param resultValue Reference to store the resulting voltage measurement + * @return True if the voltage reading was successful and within valid range + */ + bool readVoltageDifferential(float& resultValue) override; + + /** + * @brief Get the sensor location string + * + * @return A string describing the ADS1x15 sensor location + */ + String getSensorLocation(void) override; + + /** + * @brief Set the internal gain setting for the ADS1x15 + * + * @param adsGain The internal gain setting (GAIN_TWOTHIRDS, GAIN_ONE, + * GAIN_TWO, GAIN_FOUR, GAIN_EIGHT, GAIN_SIXTEEN) + */ + void setADSGain(adsGain_t adsGain); + + /** + * @brief Get the internal gain setting for the ADS1x15 + * + * @return The internal gain setting + */ + adsGain_t getADSGain(void); + + protected: + /** + * @brief Internal reference to the internal gain setting of the TI-ADS1x15 + */ + adsGain_t _adsGain; + /** + * @brief Internal reference to the I2C address of the TI-ADS1x15 + */ + uint8_t _i2cAddress; +}; + /* clang-format off */ /** * @brief The Sensor sub-class for the @@ -280,7 +393,7 @@ enum class tiads1x15_adsDiffMux_t : uint16_t { * @ingroup sensor_ads1x15 */ /* clang-format on */ -class TIADS1x15 : public Sensor { +class TIADS1x15 : public Sensor, public TIADS1x15Base { public: /** * @brief Construct a new External Voltage object - need the power pin and @@ -319,8 +432,9 @@ class TIADS1x15 : public Sensor { * * @param powerPin The pin on the mcu controlling power to the sensor * Use -1 if it is continuously powered. - * @param adsDiffMux The differential pin configuration for voltage - * measurement + * @param adsChannel1 The first ADS channel for differential measurement (0-3) + * @param adsChannel2 The second ADS channel for differential measurement (0-3) + * Valid combinations are: 0-1, 0-3, 1-3, or 2-3 * @param voltageMultiplier The voltage multiplier, if a voltage divider is * used. * @param adsGain The internal gain setting of the ADS1x15; defaults to @@ -333,7 +447,7 @@ class TIADS1x15 : public Sensor { * @param adsSupplyVoltage The power supply voltage for the ADS1x15 in * volts; defaults to the processor operating voltage from KnownProcessors.h */ - TIADS1x15(int8_t powerPin, tiads1x15_adsDiffMux_t adsDiffMux, + TIADS1x15(int8_t powerPin, uint8_t adsChannel1, uint8_t adsChannel2, float voltageMultiplier = 1, adsGain_t adsGain = GAIN_ONE, uint8_t i2cAddress = ADS1115_ADDRESS, uint8_t measurementsToAverage = 1, @@ -350,80 +464,13 @@ class TIADS1x15 : public Sensor { /** * @brief Set the power supply voltage for the ADS1x15 * - * @param adsSupplyVoltage The power supply voltage in volts (2.0-5.5V + * @param supplyVoltage The power supply voltage in volts (2.0-5.5V * range) */ - void setADSSupplyVoltage(float adsSupplyVoltage); - - /** - * @brief Get the power supply voltage for the ADS1x15 - * - * @return The power supply voltage in volts - */ - float getADSSupplyVoltage(void); - - /** - * @brief Set the internal gain setting for the ADS1x15 - * - * @param adsGain The internal gain setting (GAIN_TWOTHIRDS, GAIN_ONE, - * GAIN_TWO, GAIN_FOUR, GAIN_EIGHT, GAIN_SIXTEEN) - */ - void setADSGain(adsGain_t adsGain); - - /** - * @brief Get the internal gain setting for the ADS1x15 - * - * @return The internal gain setting - */ - adsGain_t getADSGain(void); - - protected: - /** - * @brief Read a single-ended voltage measurement from the ADS1x15 - * - * @param resultValue Reference to store the resulting voltage measurement - * @return True if the voltage reading was successful and within valid range - */ - virtual bool readVoltageSingleEnded(float& resultValue); - - /** - * @brief Read a differential voltage measurement from the ADS1x15 - * - * @param resultValue Reference to store the resulting voltage measurement - * @return True if the voltage reading was successful and within valid range - */ - virtual bool readVoltageDifferential(float& resultValue); + void setSupplyVoltage(float supplyVoltage) override; private: - /** - * @brief Internal reference to the ADS channel number of the device - * attached to the TI-ADS1x15 (used for single-ended measurements) - */ - uint8_t _adsChannel; - /** - * @brief Internal reference to whether we are using differential mode - */ - bool _isDifferential; - /** - * @brief Internal reference to the differential mux configuration - */ - tiads1x15_adsDiffMux_t _adsDiffMux; - /** - * @brief Internal reference to the voltage multiplier for the TI-ADS1x15 - */ - float _voltageMultiplier; - /** - * @brief Internal reference to the internal gain setting of the TI-ADS1x15 - */ - adsGain_t _adsGain; - /** - * @brief Internal reference to the I2C address of the TI-ADS1x15 - */ - uint8_t _i2cAddress; - /** - * @brief Internal reference to the power supply voltage of the TI-ADS1x15 - */ - float _adsSupplyVoltage; + // No additional private members - all ADS-specific parameters are now in TIADS1x15Base }; /** From a3d0b94b0849a6dbcc77b650b85d01f9dd625ec9 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Mon, 23 Feb 2026 15:39:12 -0500 Subject: [PATCH 274/533] Rerordered Signed-off-by: Sara Damiano --- src/sensors/ProcessorAnalog.cpp | 76 ++++++++++-------- src/sensors/TIADS1x15.cpp | 133 +++++++++++++++++--------------- 2 files changed, 112 insertions(+), 97 deletions(-) diff --git a/src/sensors/ProcessorAnalog.cpp b/src/sensors/ProcessorAnalog.cpp index ba3ee79bf..90fe933e0 100644 --- a/src/sensors/ProcessorAnalog.cpp +++ b/src/sensors/ProcessorAnalog.cpp @@ -12,40 +12,9 @@ #include "ProcessorAnalog.h" -// The constructor - need the power pin, the data pin, the voltage divider -// value, and the operating voltage -ProcessorAnalog::ProcessorAnalog(int8_t powerPin, int8_t dataPin, - float voltageMultiplier, - float operatingVoltage, - uint8_t measurementsToAverage) - : Sensor("ProcessorAnalog", PROCESSOR_ANALOG_NUM_VARIABLES, - PROCESSOR_ANALOG_WARM_UP_TIME_MS, - PROCESSOR_ANALOG_STABILIZATION_TIME_MS, - PROCESSOR_ANALOG_MEASUREMENT_TIME_MS, powerPin, dataPin, - measurementsToAverage, PROCESSOR_ANALOG_INC_CALC_VARIABLES), - ProcessorAnalogBase(dataPin, voltageMultiplier, operatingVoltage) {} -// Destructor -ProcessorAnalog::~ProcessorAnalog() {} - - -bool ProcessorAnalog::addSingleMeasurementResult(void) { - // Immediately quit if the measurement was not successfully started - if (!getStatusBit(MEASUREMENT_SUCCESSFUL)) { - return bumpMeasurementAttemptCount(false); - } - - MS_DBG(getSensorNameAndLocation(), F("is reporting:")); - - float resultValue = -9999; - bool success = readVoltageSingleEnded(resultValue); - - if (success) { - verifyAndAddMeasurementResult(PROCESSOR_ANALOG_VAR_NUM, resultValue); - } - - // Return success value when finished - return bumpMeasurementAttemptCount(success); -} +// ============================================================================ +// ProcessorAnalogBase Functions +// ============================================================================ bool ProcessorAnalogBase::readVoltageSingleEnded(float& resultValue) { // Validate parameters @@ -86,3 +55,42 @@ String ProcessorAnalogBase::getSensorLocation(void) { sensorLocation += String(_analogChannel); return sensorLocation; } + +// ============================================================================ +// ProcessorAnalog Functions +// ============================================================================ + +// The constructor - need the power pin, the data pin, the voltage divider +// value, and the operating voltage +ProcessorAnalog::ProcessorAnalog(int8_t powerPin, int8_t dataPin, + float voltageMultiplier, + float operatingVoltage, + uint8_t measurementsToAverage) + : Sensor("ProcessorAnalog", PROCESSOR_ANALOG_NUM_VARIABLES, + PROCESSOR_ANALOG_WARM_UP_TIME_MS, + PROCESSOR_ANALOG_STABILIZATION_TIME_MS, + PROCESSOR_ANALOG_MEASUREMENT_TIME_MS, powerPin, dataPin, + measurementsToAverage, PROCESSOR_ANALOG_INC_CALC_VARIABLES), + ProcessorAnalogBase(dataPin, voltageMultiplier, operatingVoltage) {} + +// Destructor +ProcessorAnalog::~ProcessorAnalog() {} + +bool ProcessorAnalog::addSingleMeasurementResult(void) { + // Immediately quit if the measurement was not successfully started + if (!getStatusBit(MEASUREMENT_SUCCESSFUL)) { + return bumpMeasurementAttemptCount(false); + } + + MS_DBG(getSensorNameAndLocation(), F("is reporting:")); + + float resultValue = -9999; + bool success = readVoltageSingleEnded(resultValue); + + if (success) { + verifyAndAddMeasurementResult(PROCESSOR_ANALOG_VAR_NUM, resultValue); + } + + // Return success value when finished + return bumpMeasurementAttemptCount(success); +} diff --git a/src/sensors/TIADS1x15.cpp b/src/sensors/TIADS1x15.cpp index 88ed4b701..f6e4fe904 100644 --- a/src/sensors/TIADS1x15.cpp +++ b/src/sensors/TIADS1x15.cpp @@ -16,38 +16,9 @@ #include -// The constructor - need the power pin the data pin, and voltage multiplier if -// non standard -TIADS1x15::TIADS1x15(int8_t powerPin, uint8_t adsChannel, - float voltageMultiplier, adsGain_t adsGain, - uint8_t i2cAddress, uint8_t measurementsToAverage, - float adsSupplyVoltage) - : Sensor("TIADS1x15", TIADS1X15_NUM_VARIABLES, TIADS1X15_WARM_UP_TIME_MS, - TIADS1X15_STABILIZATION_TIME_MS, TIADS1X15_MEASUREMENT_TIME_MS, - powerPin, adsChannel, measurementsToAverage, - TIADS1X15_INC_CALC_VARIABLES), - TIADS1x15Base(adsChannel, voltageMultiplier, adsGain, i2cAddress, - adsSupplyVoltage) { - // Validate ADS1x15 channel range - if (adsChannel > 3) { - // Invalid channel, clamp to valid range - _analogChannel = 3; - } -} - -// Constructor for differential measurements -TIADS1x15::TIADS1x15(int8_t powerPin, uint8_t adsChannel1, uint8_t adsChannel2, - float voltageMultiplier, adsGain_t adsGain, - uint8_t i2cAddress, uint8_t measurementsToAverage, - float adsSupplyVoltage) - : Sensor("TIADS1x15", TIADS1X15_NUM_VARIABLES, TIADS1X15_WARM_UP_TIME_MS, - TIADS1X15_STABILIZATION_TIME_MS, TIADS1X15_MEASUREMENT_TIME_MS, - powerPin, -1, measurementsToAverage, TIADS1X15_INC_CALC_VARIABLES), - TIADS1x15Base(adsChannel1, adsChannel2, voltageMultiplier, adsGain, i2cAddress, - adsSupplyVoltage) {} -// Destructor -TIADS1x15::~TIADS1x15() {} - +// ============================================================================ +// TIADS1x15Base Functions +// ============================================================================ String TIADS1x15Base::getSensorLocation(void) { #ifndef MS_USE_ADS1015 @@ -68,37 +39,6 @@ String TIADS1x15Base::getSensorLocation(void) { return sensorLocation; } -String TIADS1x15::getSensorLocation(void) { - return TIADS1x15Base::getSensorLocation(); -} - - -bool TIADS1x15::addSingleMeasurementResult(void) { - // Immediately quit if the measurement was not successfully started - if (!getStatusBit(MEASUREMENT_SUCCESSFUL)) { - return bumpMeasurementAttemptCount(false); - } - - MS_DBG(getSensorNameAndLocation(), F("is reporting:")); - - float resultValue = -9999; - bool success = false; - - // Use differential or single-ended reading based on configuration - if (isDifferential()) { - success = readVoltageDifferential(resultValue); - } else { - success = readVoltageSingleEnded(resultValue); - } - - if (success) { - verifyAndAddMeasurementResult(TIADS1X15_VAR_NUM, resultValue); - } - - // Return success value when finished - return bumpMeasurementAttemptCount(success); -} - bool TIADS1x15Base::readVoltageSingleEnded(float& resultValue) { bool success = false; int16_t adcCounts = -9999; @@ -284,6 +224,73 @@ adsGain_t TIADS1x15Base::getADSGain(void) { return _adsGain; } +// ============================================================================ +// TIADS1x15 Functions +// ============================================================================ + +// The constructor - need the power pin the data pin, and voltage multiplier if +// non standard +TIADS1x15::TIADS1x15(int8_t powerPin, uint8_t adsChannel, + float voltageMultiplier, adsGain_t adsGain, + uint8_t i2cAddress, uint8_t measurementsToAverage, + float adsSupplyVoltage) + : Sensor("TIADS1x15", TIADS1X15_NUM_VARIABLES, TIADS1X15_WARM_UP_TIME_MS, + TIADS1X15_STABILIZATION_TIME_MS, TIADS1X15_MEASUREMENT_TIME_MS, + powerPin, adsChannel, measurementsToAverage, + TIADS1X15_INC_CALC_VARIABLES), + TIADS1x15Base(adsChannel, voltageMultiplier, adsGain, i2cAddress, + adsSupplyVoltage) { + // Validate ADS1x15 channel range + if (adsChannel > 3) { + // Invalid channel, clamp to valid range + _analogChannel = 3; + } +} + +// Constructor for differential measurements +TIADS1x15::TIADS1x15(int8_t powerPin, uint8_t adsChannel1, uint8_t adsChannel2, + float voltageMultiplier, adsGain_t adsGain, + uint8_t i2cAddress, uint8_t measurementsToAverage, + float adsSupplyVoltage) + : Sensor("TIADS1x15", TIADS1X15_NUM_VARIABLES, TIADS1X15_WARM_UP_TIME_MS, + TIADS1X15_STABILIZATION_TIME_MS, TIADS1X15_MEASUREMENT_TIME_MS, + powerPin, -1, measurementsToAverage, TIADS1X15_INC_CALC_VARIABLES), + TIADS1x15Base(adsChannel1, adsChannel2, voltageMultiplier, adsGain, + i2cAddress, adsSupplyVoltage) {} + +// Destructor +TIADS1x15::~TIADS1x15() {} + +String TIADS1x15::getSensorLocation(void) { + return TIADS1x15Base::getSensorLocation(); +} + +bool TIADS1x15::addSingleMeasurementResult(void) { + // Immediately quit if the measurement was not successfully started + if (!getStatusBit(MEASUREMENT_SUCCESSFUL)) { + return bumpMeasurementAttemptCount(false); + } + + MS_DBG(getSensorNameAndLocation(), F("is reporting:")); + + float resultValue = -9999; + bool success = false; + + // Use differential or single-ended reading based on configuration + if (isDifferential()) { + success = readVoltageDifferential(resultValue); + } else { + success = readVoltageSingleEnded(resultValue); + } + + if (success) { + verifyAndAddMeasurementResult(TIADS1X15_VAR_NUM, resultValue); + } + + // Return success value when finished + return bumpMeasurementAttemptCount(success); +} + // Override setSupplyVoltage in TIADS1x15 to validate range void TIADS1x15::setSupplyVoltage(float supplyVoltage) { // Validate supply voltage range: 0.0V to 5.5V per datasheet From 22a5ae846b2ccd1e8846cc793631e7e48872b00c Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Mon, 23 Feb 2026 15:59:06 -0500 Subject: [PATCH 275/533] Fixed some types Signed-off-by: Sara Damiano --- src/sensors/AnalogVoltageBase.h | 4 +- src/sensors/ProcessorAnalog.cpp | 2 +- src/sensors/TIADS1x15.cpp | 87 +++++++++++++++++++++------------ src/sensors/TIADS1x15.h | 49 +++++++++++-------- 4 files changed, 86 insertions(+), 56 deletions(-) diff --git a/src/sensors/AnalogVoltageBase.h b/src/sensors/AnalogVoltageBase.h index 111e55495..c3f37b139 100644 --- a/src/sensors/AnalogVoltageBase.h +++ b/src/sensors/AnalogVoltageBase.h @@ -73,7 +73,7 @@ class AnalogVoltageBase { * * @return The current voltage multiplier */ - float getVoltageMultiplier(void) { + float getVoltageMultiplier(void) const { return _voltageMultiplier; } @@ -91,7 +91,7 @@ class AnalogVoltageBase { * * @return The current supply voltage in volts */ - float getSupplyVoltage(void) { + float getSupplyVoltage(void) const { return _supplyVoltage; } diff --git a/src/sensors/ProcessorAnalog.cpp b/src/sensors/ProcessorAnalog.cpp index 90fe933e0..3cc933b07 100644 --- a/src/sensors/ProcessorAnalog.cpp +++ b/src/sensors/ProcessorAnalog.cpp @@ -52,7 +52,7 @@ bool ProcessorAnalogBase::readVoltageSingleEnded(float& resultValue) { String ProcessorAnalogBase::getSensorLocation(void) { String sensorLocation = F("ProcessorAnalog_Pin"); - sensorLocation += String(_analogChannel); + sensorLocation += String((int)_analogChannel); return sensorLocation; } diff --git a/src/sensors/TIADS1x15.cpp b/src/sensors/TIADS1x15.cpp index f6e4fe904..a7d9e002f 100644 --- a/src/sensors/TIADS1x15.cpp +++ b/src/sensors/TIADS1x15.cpp @@ -74,12 +74,11 @@ bool TIADS1x15Base::readVoltageSingleEnded(float& resultValue) { // Read Analog to Digital Converter (ADC) // Validate ADS1x15 channel range for single-ended measurements - if (_analogChannel < 0 || _analogChannel > 3) { + if (_analogChannel > 3) { MS_DBG(F(" Invalid ADS1x15 channel "), _analogChannel, F(", valid range is 0-3")); return false; } - // Taking this reading includes the 8ms conversion delay. // Measure the ADC raw count adcCounts = ads.readADC_SingleEnded(_analogChannel); @@ -144,36 +143,39 @@ bool TIADS1x15Base::readVoltageDifferential(float& resultValue) { } // Read differential voltage based on channel configuration - uint8_t ch1 = _analogChannel; - uint8_t ch2 = _analogDifferentialChannel; - - if ((ch1 == 0 && ch2 == 1) || (ch1 == 1 && ch2 == 0)) { + // NOTE: Only canonical ordered pairs are supported (lower channel number + // first) to ensure consistent polarity. Pairs like (1,0) are NOT supported + // - use (0,1) instead. + if (_analogChannel == 0 && _analogDifferentialChannel == 1) { adcCounts = ads.readADC_Differential_0_1(); - } else if ((ch1 == 0 && ch2 == 3) || (ch1 == 3 && ch2 == 0)) { + } else if (_analogChannel == 0 && _analogDifferentialChannel == 3) { adcCounts = ads.readADC_Differential_0_3(); - } else if ((ch1 == 1 && ch2 == 3) || (ch1 == 3 && ch2 == 1)) { + } else if (_analogChannel == 1 && _analogDifferentialChannel == 3) { adcCounts = ads.readADC_Differential_1_3(); - } else if ((ch1 == 2 && ch2 == 3) || (ch1 == 3 && ch2 == 2)) { + } else if (_analogChannel == 2 && _analogDifferentialChannel == 3) { adcCounts = ads.readADC_Differential_2_3(); } else { - MS_DBG(F(" Unsupported differential channel combination")); + MS_DBG(F(" Unsupported differential channel combination: "), + _analogChannel, F("-"), _analogDifferentialChannel); + MS_DBG(F(" Use canonical ordered pairs: 0-1, 0-3, 1-3, or 2-3")); return false; } // Convert counts to voltage adcVoltage = ads.computeVolts(adcCounts); - MS_DBG(F(" Differential ADC counts:"), adcCounts, F(" voltage:"), adcVoltage); + MS_DBG(F(" Differential ADC counts:"), adcCounts, F(" voltage:"), + adcVoltage); // Validate range - for differential measurements, use PGA full-scale range // Based on gain setting rather than supply voltage float fullScaleVoltage = 4.096; // Default for GAIN_ONE switch (_adsGain) { case GAIN_TWOTHIRDS: fullScaleVoltage = 6.144; break; - case GAIN_ONE: fullScaleVoltage = 4.096; break; - case GAIN_TWO: fullScaleVoltage = 2.048; break; - case GAIN_FOUR: fullScaleVoltage = 1.024; break; - case GAIN_EIGHT: fullScaleVoltage = 0.512; break; - case GAIN_SIXTEEN: fullScaleVoltage = 0.256; break; + case GAIN_ONE: fullScaleVoltage = 4.096; break; + case GAIN_TWO: fullScaleVoltage = 2.048; break; + case GAIN_FOUR: fullScaleVoltage = 1.024; break; + case GAIN_EIGHT: fullScaleVoltage = 0.512; break; + case GAIN_SIXTEEN: fullScaleVoltage = 0.256; break; default: MS_DBG(F(" Unknown ADS gain value:"), _adsGain, F(" using conservative 4.096V range")); @@ -191,7 +193,7 @@ bool TIADS1x15Base::readVoltageDifferential(float& resultValue) { scaledResult = adcVoltage * _voltageMultiplier; MS_DBG(F(" scaledResult:"), scaledResult); resultValue = scaledResult; - success = true; + success = true; } else { MS_DBG(F(" Differential voltage out of valid range")); resultValue = -9999; @@ -201,17 +203,17 @@ bool TIADS1x15Base::readVoltageDifferential(float& resultValue) { } // Validation function for differential channel pairs -bool TIADS1x15Base::isValidDifferentialPair(uint8_t channel1, - uint8_t channel2) { - // Valid combinations are: 0-1, 0-3, 1-3, or 2-3 - if ((channel1 == 0 && channel2 == 1) || (channel1 == 1 && channel2 == 0)) - return true; - if ((channel1 == 0 && channel2 == 3) || (channel1 == 3 && channel2 == 0)) - return true; - if ((channel1 == 1 && channel2 == 3) || (channel1 == 3 && channel2 == 1)) - return true; - if ((channel1 == 2 && channel2 == 3) || (channel1 == 3 && channel2 == 2)) - return true; +bool TIADS1x15Base::isValidDifferentialPair(int8_t channel1, int8_t channel2) { + // Only canonical ordered pairs are valid (lower channel number first) + // This ensures consistent polarity: channel1 is positive, channel2 is + // negative Valid combinations are: 0-1, 0-3, 1-3, or 2-3 (in that order + // only) + if (channel1 >= channel2) return false; // Reject reversed or equal pairs + + if (channel1 == 0 && channel2 == 1) return true; + if (channel1 == 0 && channel2 == 3) return true; + if (channel1 == 1 && channel2 == 3) return true; + if (channel1 == 2 && channel2 == 3) return true; return false; } @@ -230,7 +232,7 @@ adsGain_t TIADS1x15Base::getADSGain(void) { // The constructor - need the power pin the data pin, and voltage multiplier if // non standard -TIADS1x15::TIADS1x15(int8_t powerPin, uint8_t adsChannel, +TIADS1x15::TIADS1x15(int8_t powerPin, int8_t adsChannel, float voltageMultiplier, adsGain_t adsGain, uint8_t i2cAddress, uint8_t measurementsToAverage, float adsSupplyVoltage) @@ -245,10 +247,13 @@ TIADS1x15::TIADS1x15(int8_t powerPin, uint8_t adsChannel, // Invalid channel, clamp to valid range _analogChannel = 3; } + // NOTE: We CANNOT print a warning here about invalid channel because the + // Serial object may not be initialized yet, and we don't want to cause a + // crash. } // Constructor for differential measurements -TIADS1x15::TIADS1x15(int8_t powerPin, uint8_t adsChannel1, uint8_t adsChannel2, +TIADS1x15::TIADS1x15(int8_t powerPin, int8_t adsChannel1, int8_t adsChannel2, float voltageMultiplier, adsGain_t adsGain, uint8_t i2cAddress, uint8_t measurementsToAverage, float adsSupplyVoltage) @@ -256,7 +261,25 @@ TIADS1x15::TIADS1x15(int8_t powerPin, uint8_t adsChannel1, uint8_t adsChannel2, TIADS1X15_STABILIZATION_TIME_MS, TIADS1X15_MEASUREMENT_TIME_MS, powerPin, -1, measurementsToAverage, TIADS1X15_INC_CALC_VARIABLES), TIADS1x15Base(adsChannel1, adsChannel2, voltageMultiplier, adsGain, - i2cAddress, adsSupplyVoltage) {} + i2cAddress, adsSupplyVoltage) { + // Validate that channels are in canonical order (lower number first) + if (adsChannel1 >= adsChannel2) { + // Force canonical ordering to prevent undefined behavior + if (adsChannel1 < adsChannel2) { + _analogChannel = adsChannel1; + _analogDifferentialChannel = adsChannel2; + } else { + _analogChannel = adsChannel2; + _analogDifferentialChannel = adsChannel1; + } + } + // NOTE: We CANNOT print a warning here about invalid channel combinations + // because the Serial object may not be initialized yet, and we don't want + // to cause a crash. Calling any function that uses Serial here will cause + // a crash if Serial is not initialized, and we don't want to risk that in + // the constructor. Instead, we will just clamp to a valid default pair of + // channels (0-1) if the combination is invalid. +} // Destructor TIADS1x15::~TIADS1x15() {} @@ -307,4 +330,4 @@ void TIADS1x15::setSupplyVoltage(float supplyVoltage) { } } -// cspell:words TWOTHIRDS +// cspell:words GAIN_TWOTHIRDS diff --git a/src/sensors/TIADS1x15.h b/src/sensors/TIADS1x15.h index cd0f0ee0a..88c53afeb 100644 --- a/src/sensors/TIADS1x15.h +++ b/src/sensors/TIADS1x15.h @@ -289,7 +289,7 @@ class TIADS1x15Base : public AnalogVoltageBase { * @param channel2 Second channel (0-3) * @return True if the combination is valid (0-1, 0-3, 1-3, or 2-3) */ - static bool isValidDifferentialPair(uint8_t channel1, uint8_t channel2); + static bool isValidDifferentialPair(int8_t channel1, int8_t channel2); /** * @brief Construct a new TIADS1x15Base object for single-ended measurements @@ -300,35 +300,41 @@ class TIADS1x15Base : public AnalogVoltageBase { * @param i2cAddress The I2C address of the ADS 1x15 * @param adsSupplyVoltage The power supply voltage for the ADS1x15 in volts */ - TIADS1x15Base(uint8_t adsChannel, float voltageMultiplier, - adsGain_t adsGain, uint8_t i2cAddress, - float adsSupplyVoltage) - : AnalogVoltageBase(adsChannel, voltageMultiplier, adsSupplyVoltage, -1), + TIADS1x15Base(int8_t adsChannel, float voltageMultiplier, adsGain_t adsGain, + uint8_t i2cAddress, float adsSupplyVoltage) + : AnalogVoltageBase(adsChannel, voltageMultiplier, adsSupplyVoltage, + -1), _adsGain(adsGain), _i2cAddress(i2cAddress) {} /** * @brief Construct a new TIADS1x15Base object for differential measurements * - * @param adsChannel1 The first ADS channel for differential measurement (0-3) - * @param adsChannel2 The second ADS channel for differential measurement (0-3) + * @param adsChannel1 The first ADS channel for differential measurement + * (0-3) + * @param adsChannel2 The second ADS channel for differential measurement + * (0-3) * @param voltageMultiplier The voltage multiplier for any voltage dividers * @param adsGain The internal gain setting of the ADS1x15 * @param i2cAddress The I2C address of the ADS 1x15 * @param adsSupplyVoltage The power supply voltage for the ADS1x15 in volts */ - TIADS1x15Base(uint8_t adsChannel1, uint8_t adsChannel2, float voltageMultiplier, - adsGain_t adsGain, uint8_t i2cAddress, - float adsSupplyVoltage) - : AnalogVoltageBase(adsChannel1, voltageMultiplier, adsSupplyVoltage, adsChannel2), + TIADS1x15Base(int8_t adsChannel1, int8_t adsChannel2, + float voltageMultiplier, adsGain_t adsGain, + uint8_t i2cAddress, float adsSupplyVoltage) + : AnalogVoltageBase(adsChannel1, voltageMultiplier, adsSupplyVoltage, + adsChannel2), _adsGain(adsGain), _i2cAddress(i2cAddress) { // Validate differential channel combinations if (!isValidDifferentialPair(adsChannel1, adsChannel2)) { // Default to 0-1 if invalid combination - _analogChannel = 0; + _analogChannel = 0; _analogDifferentialChannel = 1; } + // NOTE: We CANNOT print a warning here about invalid channel clamping + // because the Serial object may not be initialized yet, and we don't + // want to cause a crash. } /** @@ -372,7 +378,7 @@ class TIADS1x15Base : public AnalogVoltageBase { * * @return The internal gain setting */ - adsGain_t getADSGain(void); + adsGain_t getADSGain(void) const; protected: /** @@ -422,7 +428,7 @@ class TIADS1x15 : public Sensor, public TIADS1x15Base { * @param adsSupplyVoltage The power supply voltage for the ADS1x15 in * volts; defaults to the processor operating voltage from KnownProcessors.h */ - TIADS1x15(int8_t powerPin, uint8_t adsChannel, float voltageMultiplier = 1, + TIADS1x15(int8_t powerPin, int8_t adsChannel, float voltageMultiplier = 1, adsGain_t adsGain = GAIN_ONE, uint8_t i2cAddress = ADS1115_ADDRESS, uint8_t measurementsToAverage = 1, @@ -432,9 +438,10 @@ class TIADS1x15 : public Sensor, public TIADS1x15Base { * * @param powerPin The pin on the mcu controlling power to the sensor * Use -1 if it is continuously powered. - * @param adsChannel1 The first ADS channel for differential measurement (0-3) - * @param adsChannel2 The second ADS channel for differential measurement (0-3) - * Valid combinations are: 0-1, 0-3, 1-3, or 2-3 + * @param adsChannel1 The first ADS channel for differential measurement + * (0-3) + * @param adsChannel2 The second ADS channel for differential measurement + * (0-3) Valid combinations are: 0-1, 0-3, 1-3, or 2-3 * @param voltageMultiplier The voltage multiplier, if a voltage divider is * used. * @param adsGain The internal gain setting of the ADS1x15; defaults to @@ -447,7 +454,7 @@ class TIADS1x15 : public Sensor, public TIADS1x15Base { * @param adsSupplyVoltage The power supply voltage for the ADS1x15 in * volts; defaults to the processor operating voltage from KnownProcessors.h */ - TIADS1x15(int8_t powerPin, uint8_t adsChannel1, uint8_t adsChannel2, + TIADS1x15(int8_t powerPin, int8_t adsChannel1, int8_t adsChannel2, float voltageMultiplier = 1, adsGain_t adsGain = GAIN_ONE, uint8_t i2cAddress = ADS1115_ADDRESS, uint8_t measurementsToAverage = 1, @@ -468,9 +475,6 @@ class TIADS1x15 : public Sensor, public TIADS1x15Base { * range) */ void setSupplyVoltage(float supplyVoltage) override; - - private: - // No additional private members - all ADS-specific parameters are now in TIADS1x15Base }; /** @@ -534,4 +538,7 @@ class TIADS1x15_Voltage : public Variable { typedef TIADS1x15_Voltage ExternalVoltage_Volt; /**@}*/ + +// cspell:words GAIN_TWOTHIRDS + #endif // SRC_SENSORS_TIADS1X15_H_ From 4912f55fff4a15e4affcfff9b82b4a1b0766594a Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Mon, 23 Feb 2026 16:28:40 -0500 Subject: [PATCH 276/533] Revert some type changes move implementation to cpp files, don't validate in ctor Signed-off-by: Sara Damiano --- src/sensors/ProcessorAnalog.cpp | 19 +++++--- src/sensors/ProcessorAnalog.h | 3 +- src/sensors/TIADS1x15.cpp | 81 ++++++++++++++++++++------------ src/sensors/TIADS1x15.h | 82 +++++++++++++++++---------------- 4 files changed, 109 insertions(+), 76 deletions(-) diff --git a/src/sensors/ProcessorAnalog.cpp b/src/sensors/ProcessorAnalog.cpp index 3cc933b07..19e7a0174 100644 --- a/src/sensors/ProcessorAnalog.cpp +++ b/src/sensors/ProcessorAnalog.cpp @@ -12,6 +12,16 @@ #include "ProcessorAnalog.h" +// ============================================================================ +// ProcessorAnalogBase Constructor +// ============================================================================ + +ProcessorAnalogBase::ProcessorAnalogBase(int8_t dataPin, + float voltageMultiplier, + float operatingVoltage) + : AnalogVoltageBase(dataPin, voltageMultiplier, operatingVoltage, -1) {} + + // ============================================================================ // ProcessorAnalogBase Functions // ============================================================================ @@ -38,12 +48,9 @@ bool ProcessorAnalogBase::readVoltageSingleEnded(float& resultValue) { MS_DBG(F("Raw analog pin reading in bits:"), rawAnalog); // convert bits to volts - float sensorValue_analog = - (_supplyVoltage / static_cast(PROCESSOR_ADC_MAX)) * + resultValue = (_supplyVoltage / static_cast(PROCESSOR_ADC_MAX)) * _voltageMultiplier * rawAnalog; - MS_DBG(F("Voltage:"), sensorValue_analog); - - resultValue = sensorValue_analog; + MS_DBG(F("Voltage:"), resultValue); // NOTE: We don't actually have any criteria for if the reading was any // good or not, so we mark it as successful no matter what. @@ -52,7 +59,7 @@ bool ProcessorAnalogBase::readVoltageSingleEnded(float& resultValue) { String ProcessorAnalogBase::getSensorLocation(void) { String sensorLocation = F("ProcessorAnalog_Pin"); - sensorLocation += String((int)_analogChannel); + sensorLocation += String(static_cast(_analogChannel)); return sensorLocation; } diff --git a/src/sensors/ProcessorAnalog.h b/src/sensors/ProcessorAnalog.h index ee6124159..7450a44fd 100644 --- a/src/sensors/ProcessorAnalog.h +++ b/src/sensors/ProcessorAnalog.h @@ -178,8 +178,7 @@ class ProcessorAnalogBase : public AnalogVoltageBase { * likely 3.3 or 5. */ ProcessorAnalogBase(int8_t dataPin, float voltageMultiplier, - float operatingVoltage = OPERATING_VOLTAGE) - : AnalogVoltageBase(dataPin, voltageMultiplier, operatingVoltage, -1) {} + float operatingVoltage = OPERATING_VOLTAGE); /** * @brief Destroy the ProcessorAnalogBase object diff --git a/src/sensors/TIADS1x15.cpp b/src/sensors/TIADS1x15.cpp index a7d9e002f..b4604d8f8 100644 --- a/src/sensors/TIADS1x15.cpp +++ b/src/sensors/TIADS1x15.cpp @@ -13,7 +13,42 @@ #include "TIADS1x15.h" -#include + + +// ============================================================================ +// TIADS1x15Base Constructors +// ============================================================================ + +// Constructor for single-ended measurements +TIADS1x15Base::TIADS1x15Base(uint8_t adsChannel, float voltageMultiplier, + adsGain_t adsGain, uint8_t i2cAddress, + float adsSupplyVoltage) + : AnalogVoltageBase(adsChannel, voltageMultiplier, adsSupplyVoltage, -1), + _adsGain(adsGain), + _i2cAddress(i2cAddress) { + // NOTE: We DO NOT validate the channel numbers in this constructor! We + // CANNOT print a warning here about invalid channel because the Serial + // object may not be initialized yet, and we don't want to cause a crash. + // The readVoltageSingleEnded and readVoltageDifferential functions will + // handle validation and return false if the channel configuration is + // invalid, but we can't do that here in the constructor +} + +// Constructor for differential measurements +TIADS1x15Base::TIADS1x15Base(uint8_t adsChannel1, uint8_t adsChannel2, + float voltageMultiplier, adsGain_t adsGain, + uint8_t i2cAddress, float adsSupplyVoltage) + : AnalogVoltageBase(adsChannel1, voltageMultiplier, adsSupplyVoltage, + adsChannel2), + _adsGain(adsGain), + _i2cAddress(i2cAddress) { + // NOTE: We DO NOT validate the channel numbers and pairings in this + // constructor! We CANNOT print a warning here about invalid channel + // because the Serial object may not be initialized yet, and we don't want + // to cause a crash. The readVoltageSingleEnded and readVoltageDifferential + // functions will handle validation and return false if the channel + // configuration is invalid, but we can't do that here in the constructor +} // ============================================================================ @@ -203,7 +238,8 @@ bool TIADS1x15Base::readVoltageDifferential(float& resultValue) { } // Validation function for differential channel pairs -bool TIADS1x15Base::isValidDifferentialPair(int8_t channel1, int8_t channel2) { +bool TIADS1x15Base::isValidDifferentialPair(uint8_t channel1, + uint8_t channel2) { // Only canonical ordered pairs are valid (lower channel number first) // This ensures consistent polarity: channel1 is positive, channel2 is // negative Valid combinations are: 0-1, 0-3, 1-3, or 2-3 (in that order @@ -222,7 +258,7 @@ void TIADS1x15Base::setADSGain(adsGain_t adsGain) { _adsGain = adsGain; } -adsGain_t TIADS1x15Base::getADSGain(void) { +adsGain_t TIADS1x15Base::getADSGain(void) const { return _adsGain; } @@ -232,7 +268,7 @@ adsGain_t TIADS1x15Base::getADSGain(void) { // The constructor - need the power pin the data pin, and voltage multiplier if // non standard -TIADS1x15::TIADS1x15(int8_t powerPin, int8_t adsChannel, +TIADS1x15::TIADS1x15(int8_t powerPin, uint8_t adsChannel, float voltageMultiplier, adsGain_t adsGain, uint8_t i2cAddress, uint8_t measurementsToAverage, float adsSupplyVoltage) @@ -242,18 +278,16 @@ TIADS1x15::TIADS1x15(int8_t powerPin, int8_t adsChannel, TIADS1X15_INC_CALC_VARIABLES), TIADS1x15Base(adsChannel, voltageMultiplier, adsGain, i2cAddress, adsSupplyVoltage) { - // Validate ADS1x15 channel range - if (adsChannel > 3) { - // Invalid channel, clamp to valid range - _analogChannel = 3; - } - // NOTE: We CANNOT print a warning here about invalid channel because the - // Serial object may not be initialized yet, and we don't want to cause a - // crash. + // NOTE: We DO NOT validate the channel numbers in this constructor! We + // CANNOT print a warning here about invalid channel because the Serial + // object may not be initialized yet, and we don't want to cause a crash. + // The readVoltageSingleEnded and readVoltageDifferential functions will + // handle validation and return false if the channel configuration is + // invalid, but we can't do that here in the constructor } // Constructor for differential measurements -TIADS1x15::TIADS1x15(int8_t powerPin, int8_t adsChannel1, int8_t adsChannel2, +TIADS1x15::TIADS1x15(int8_t powerPin, uint8_t adsChannel1, uint8_t adsChannel2, float voltageMultiplier, adsGain_t adsGain, uint8_t i2cAddress, uint8_t measurementsToAverage, float adsSupplyVoltage) @@ -262,23 +296,12 @@ TIADS1x15::TIADS1x15(int8_t powerPin, int8_t adsChannel1, int8_t adsChannel2, powerPin, -1, measurementsToAverage, TIADS1X15_INC_CALC_VARIABLES), TIADS1x15Base(adsChannel1, adsChannel2, voltageMultiplier, adsGain, i2cAddress, adsSupplyVoltage) { - // Validate that channels are in canonical order (lower number first) - if (adsChannel1 >= adsChannel2) { - // Force canonical ordering to prevent undefined behavior - if (adsChannel1 < adsChannel2) { - _analogChannel = adsChannel1; - _analogDifferentialChannel = adsChannel2; - } else { - _analogChannel = adsChannel2; - _analogDifferentialChannel = adsChannel1; - } - } - // NOTE: We CANNOT print a warning here about invalid channel combinations + // NOTE: We DO NOT validate the channel numbers and pairings in this + // constructor! We CANNOT print a warning here about invalid channel // because the Serial object may not be initialized yet, and we don't want - // to cause a crash. Calling any function that uses Serial here will cause - // a crash if Serial is not initialized, and we don't want to risk that in - // the constructor. Instead, we will just clamp to a valid default pair of - // channels (0-1) if the combination is invalid. + // to cause a crash. The readVoltageSingleEnded and readVoltageDifferential + // functions will handle validation and return false if the channel + // configuration is invalid, but we can't do that here in the constructor } // Destructor diff --git a/src/sensors/TIADS1x15.h b/src/sensors/TIADS1x15.h index 88c53afeb..fc8ee9476 100644 --- a/src/sensors/TIADS1x15.h +++ b/src/sensors/TIADS1x15.h @@ -282,60 +282,42 @@ enum class tiads1x15_adsDiffMux_t : uint16_t { */ class TIADS1x15Base : public AnalogVoltageBase { public: - /** - * @brief Check if the two channels form a valid differential pair - * - * @param channel1 First channel (0-3) - * @param channel2 Second channel (0-3) - * @return True if the combination is valid (0-1, 0-3, 1-3, or 2-3) - */ - static bool isValidDifferentialPair(int8_t channel1, int8_t channel2); /** * @brief Construct a new TIADS1x15Base object for single-ended measurements * - * @param adsChannel The ADS channel of interest (0-3). + * @param adsChannel The ADS channel of interest (0-3, physical channel + * only). * @param voltageMultiplier The voltage multiplier for any voltage dividers * @param adsGain The internal gain setting of the ADS1x15 * @param i2cAddress The I2C address of the ADS 1x15 * @param adsSupplyVoltage The power supply voltage for the ADS1x15 in volts + * + * @note adsChannel uses uint8_t to match Adafruit_ADS1X15 expectations. + * Negative sentinels are handled internally where needed. */ - TIADS1x15Base(int8_t adsChannel, float voltageMultiplier, adsGain_t adsGain, - uint8_t i2cAddress, float adsSupplyVoltage) - : AnalogVoltageBase(adsChannel, voltageMultiplier, adsSupplyVoltage, - -1), - _adsGain(adsGain), - _i2cAddress(i2cAddress) {} + TIADS1x15Base(uint8_t adsChannel, float voltageMultiplier, + adsGain_t adsGain, uint8_t i2cAddress, + float adsSupplyVoltage); /** * @brief Construct a new TIADS1x15Base object for differential measurements * * @param adsChannel1 The first ADS channel for differential measurement - * (0-3) + * (0-3, physical channel only) * @param adsChannel2 The second ADS channel for differential measurement - * (0-3) + * (0-3, physical channel only) * @param voltageMultiplier The voltage multiplier for any voltage dividers * @param adsGain The internal gain setting of the ADS1x15 * @param i2cAddress The I2C address of the ADS 1x15 * @param adsSupplyVoltage The power supply voltage for the ADS1x15 in volts + * + * @note Channel parameters use uint8_t to match Adafruit_ADS1X15 + * expectations. Negative sentinels are handled internally where needed. */ - TIADS1x15Base(int8_t adsChannel1, int8_t adsChannel2, + TIADS1x15Base(uint8_t adsChannel1, uint8_t adsChannel2, float voltageMultiplier, adsGain_t adsGain, - uint8_t i2cAddress, float adsSupplyVoltage) - : AnalogVoltageBase(adsChannel1, voltageMultiplier, adsSupplyVoltage, - adsChannel2), - _adsGain(adsGain), - _i2cAddress(i2cAddress) { - // Validate differential channel combinations - if (!isValidDifferentialPair(adsChannel1, adsChannel2)) { - // Default to 0-1 if invalid combination - _analogChannel = 0; - _analogDifferentialChannel = 1; - } - // NOTE: We CANNOT print a warning here about invalid channel clamping - // because the Serial object may not be initialized yet, and we don't - // want to cause a crash. - } + uint8_t i2cAddress, float adsSupplyVoltage); /** * @brief Destroy the TIADS1x15Base object @@ -380,6 +362,19 @@ class TIADS1x15Base : public AnalogVoltageBase { */ adsGain_t getADSGain(void) const; + /** + * @brief Check if the two channels form a valid differential pair + * + * @param channel1 First channel (0-3, physical ADS channel indices only) + * @param channel2 Second channel (0-3, physical ADS channel indices only) + * @return True if the combination is valid (0-1, 0-3, 1-3, or 2-3) + * + * @note This function expects uint8_t to match + * Adafruit_ADS1X15::readADC_SingleEnded(uint8_t) and avoid sign-extension + * issues. Negative sentinel values are handled internally. + */ + static bool isValidDifferentialPair(uint8_t channel1, uint8_t channel2); + protected: /** * @brief Internal reference to the internal gain setting of the TI-ADS1x15 @@ -415,7 +410,8 @@ class TIADS1x15 : public Sensor, public TIADS1x15Base { * * @param powerPin The pin on the mcu controlling power to the sensor * Use -1 if it is continuously powered. - * @param adsChannel The ADS channel of interest (0-3). + * @param adsChannel The ADS channel of interest (0-3, physical channel + * only). * @param voltageMultiplier The voltage multiplier, if a voltage divider is * used. * @param adsGain The internal gain setting of the ADS1x15; defaults to @@ -427,8 +423,12 @@ class TIADS1x15 : public Sensor, public TIADS1x15Base { * default value of 1. * @param adsSupplyVoltage The power supply voltage for the ADS1x15 in * volts; defaults to the processor operating voltage from KnownProcessors.h + * + * @note adsChannel uses uint8_t to match + * Adafruit_ADS1X15::readADC_SingleEnded(uint8_t) and avoid sign-extension + * issues. */ - TIADS1x15(int8_t powerPin, int8_t adsChannel, float voltageMultiplier = 1, + TIADS1x15(int8_t powerPin, uint8_t adsChannel, float voltageMultiplier = 1, adsGain_t adsGain = GAIN_ONE, uint8_t i2cAddress = ADS1115_ADDRESS, uint8_t measurementsToAverage = 1, @@ -439,9 +439,10 @@ class TIADS1x15 : public Sensor, public TIADS1x15Base { * @param powerPin The pin on the mcu controlling power to the sensor * Use -1 if it is continuously powered. * @param adsChannel1 The first ADS channel for differential measurement - * (0-3) + * (0-3, physical channel only) * @param adsChannel2 The second ADS channel for differential measurement - * (0-3) Valid combinations are: 0-1, 0-3, 1-3, or 2-3 + * (0-3, physical channel only) Valid combinations are: 0-1, 0-3, 1-3, or + * 2-3 * @param voltageMultiplier The voltage multiplier, if a voltage divider is * used. * @param adsGain The internal gain setting of the ADS1x15; defaults to @@ -453,8 +454,11 @@ class TIADS1x15 : public Sensor, public TIADS1x15Base { * default value of 1. * @param adsSupplyVoltage The power supply voltage for the ADS1x15 in * volts; defaults to the processor operating voltage from KnownProcessors.h + * + * @note Channel parameters use uint8_t to match Adafruit_ADS1X15 + * expectations and avoid sign-extension issues. */ - TIADS1x15(int8_t powerPin, int8_t adsChannel1, int8_t adsChannel2, + TIADS1x15(int8_t powerPin, uint8_t adsChannel1, uint8_t adsChannel2, float voltageMultiplier = 1, adsGain_t adsGain = GAIN_ONE, uint8_t i2cAddress = ADS1115_ADDRESS, uint8_t measurementsToAverage = 1, @@ -462,7 +466,7 @@ class TIADS1x15 : public Sensor, public TIADS1x15Base { /** * @brief Destroy the External Voltage object */ - ~TIADS1x15(); + ~TIADS1x15() override; String getSensorLocation(void) override; From b2a4294f87cbcc7f9980302a06d9225e2d401e30 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Mon, 23 Feb 2026 16:32:04 -0500 Subject: [PATCH 277/533] More ctor defaults Signed-off-by: Sara Damiano --- src/sensors/ProcessorAnalog.h | 11 ++++++----- src/sensors/TIADS1x15.h | 15 +++++++++------ 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/src/sensors/ProcessorAnalog.h b/src/sensors/ProcessorAnalog.h index 7450a44fd..c6f44b92a 100644 --- a/src/sensors/ProcessorAnalog.h +++ b/src/sensors/ProcessorAnalog.h @@ -177,8 +177,8 @@ class ProcessorAnalogBase : public AnalogVoltageBase { * @param operatingVoltage The processor's operating voltage; most * likely 3.3 or 5. */ - ProcessorAnalogBase(int8_t dataPin, float voltageMultiplier, - float operatingVoltage = OPERATING_VOLTAGE); + explicit ProcessorAnalogBase(int8_t dataPin, float voltageMultiplier = 1.0, + float operatingVoltage = OPERATING_VOLTAGE); /** * @brief Destroy the ProcessorAnalogBase object @@ -230,9 +230,10 @@ class ProcessorAnalog : public Sensor, public ProcessorAnalogBase { * average before giving a "final" result from the sensor; optional with a * default value of 1. */ - ProcessorAnalog(int8_t powerPin, int8_t dataPin, float voltageMultiplier, - float operatingVoltage = OPERATING_VOLTAGE, - uint8_t measurementsToAverage = 1); + explicit ProcessorAnalog(int8_t powerPin, int8_t dataPin, + float voltageMultiplier = 1.0, + float operatingVoltage = OPERATING_VOLTAGE, + uint8_t measurementsToAverage = 1); /** * @brief Destroy the Processor Analog object */ diff --git a/src/sensors/TIADS1x15.h b/src/sensors/TIADS1x15.h index fc8ee9476..0d2fe79d1 100644 --- a/src/sensors/TIADS1x15.h +++ b/src/sensors/TIADS1x15.h @@ -296,9 +296,10 @@ class TIADS1x15Base : public AnalogVoltageBase { * @note adsChannel uses uint8_t to match Adafruit_ADS1X15 expectations. * Negative sentinels are handled internally where needed. */ - TIADS1x15Base(uint8_t adsChannel, float voltageMultiplier, - adsGain_t adsGain, uint8_t i2cAddress, - float adsSupplyVoltage); + explicit TIADS1x15Base(uint8_t adsChannel, float voltageMultiplier = 1.0, + adsGain_t adsGain = GAIN_ONE, + uint8_t i2cAddress = ADS1115_ADDRESS, + float adsSupplyVoltage = OPERATING_VOLTAGE); /** * @brief Construct a new TIADS1x15Base object for differential measurements @@ -315,9 +316,11 @@ class TIADS1x15Base : public AnalogVoltageBase { * @note Channel parameters use uint8_t to match Adafruit_ADS1X15 * expectations. Negative sentinels are handled internally where needed. */ - TIADS1x15Base(uint8_t adsChannel1, uint8_t adsChannel2, - float voltageMultiplier, adsGain_t adsGain, - uint8_t i2cAddress, float adsSupplyVoltage); + explicit TIADS1x15Base(uint8_t adsChannel1, uint8_t adsChannel2, + float voltageMultiplier = 1.0, + adsGain_t adsGain = GAIN_ONE, + uint8_t i2cAddress = ADS1115_ADDRESS, + float adsSupplyVoltage = OPERATING_VOLTAGE); /** * @brief Destroy the TIADS1x15Base object From 88a988b1179578290fbf39f3825544540ac99783 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Mon, 23 Feb 2026 16:48:35 -0500 Subject: [PATCH 278/533] clamp supply voltage Signed-off-by: Sara Damiano --- src/sensors/TIADS1x15.cpp | 37 ++++++++++++++++++++++++------------- src/sensors/TIADS1x15.h | 6 +++--- 2 files changed, 27 insertions(+), 16 deletions(-) diff --git a/src/sensors/TIADS1x15.cpp b/src/sensors/TIADS1x15.cpp index b4604d8f8..c64d68a59 100644 --- a/src/sensors/TIADS1x15.cpp +++ b/src/sensors/TIADS1x15.cpp @@ -26,12 +26,19 @@ TIADS1x15Base::TIADS1x15Base(uint8_t adsChannel, float voltageMultiplier, : AnalogVoltageBase(adsChannel, voltageMultiplier, adsSupplyVoltage, -1), _adsGain(adsGain), _i2cAddress(i2cAddress) { - // NOTE: We DO NOT validate the channel numbers in this constructor! We - // CANNOT print a warning here about invalid channel because the Serial - // object may not be initialized yet, and we don't want to cause a crash. - // The readVoltageSingleEnded and readVoltageDifferential functions will - // handle validation and return false if the channel configuration is - // invalid, but we can't do that here in the constructor + // Clamp supply voltage to valid ADS1x15 range: 0.0V to 5.5V per datasheet + // This clamp is done silently! + if (_supplyVoltage < 0.0f) { + _supplyVoltage = 0.0f; + } else if (_supplyVoltage > 5.5f) { + _supplyVoltage = 5.5f; + } + // NOTE: We DO NOT clamp or validate the channel numbers in this + // constructor! We CANNOT print a warning here about invalid channel + // because the Serial object may not be initialized yet, and we don't want + // to cause a crash. The readVoltageSingleEnded and readVoltageDifferential + // functions will handle validation and return false if the channel + // configuration is invalid, but we can't do that here in the constructor } // Constructor for differential measurements @@ -42,7 +49,14 @@ TIADS1x15Base::TIADS1x15Base(uint8_t adsChannel1, uint8_t adsChannel2, adsChannel2), _adsGain(adsGain), _i2cAddress(i2cAddress) { - // NOTE: We DO NOT validate the channel numbers and pairings in this + // Clamp supply voltage to valid ADS1x15 range: 0.0V to 5.5V per datasheet + // This clamp is done silently! + if (_supplyVoltage < 0.0f) { + _supplyVoltage = 0.0f; + } else if (_supplyVoltage > 5.5f) { + _supplyVoltage = 5.5f; + } + // NOTE: We DO NOT clamp orvalidate the channel numbers and pairings in this // constructor! We CANNOT print a warning here about invalid channel // because the Serial object may not be initialized yet, and we don't want // to cause a crash. The readVoltageSingleEnded and readVoltageDifferential @@ -203,7 +217,7 @@ bool TIADS1x15Base::readVoltageDifferential(float& resultValue) { // Validate range - for differential measurements, use PGA full-scale range // Based on gain setting rather than supply voltage - float fullScaleVoltage = 4.096; // Default for GAIN_ONE + float fullScaleVoltage; switch (_adsGain) { case GAIN_TWOTHIRDS: fullScaleVoltage = 6.144; break; case GAIN_ONE: fullScaleVoltage = 4.096; break; @@ -246,11 +260,8 @@ bool TIADS1x15Base::isValidDifferentialPair(uint8_t channel1, // only) if (channel1 >= channel2) return false; // Reject reversed or equal pairs - if (channel1 == 0 && channel2 == 1) return true; - if (channel1 == 0 && channel2 == 3) return true; - if (channel1 == 1 && channel2 == 3) return true; - if (channel1 == 2 && channel2 == 3) return true; - return false; + return (channel1 == 0 && (channel2 == 1 || channel2 == 3)) || + (channel1 == 1 && channel2 == 3) || (channel1 == 2 && channel2 == 3); } // Setter and getter methods for ADS gain diff --git a/src/sensors/TIADS1x15.h b/src/sensors/TIADS1x15.h index 0d2fe79d1..663640543 100644 --- a/src/sensors/TIADS1x15.h +++ b/src/sensors/TIADS1x15.h @@ -372,9 +372,9 @@ class TIADS1x15Base : public AnalogVoltageBase { * @param channel2 Second channel (0-3, physical ADS channel indices only) * @return True if the combination is valid (0-1, 0-3, 1-3, or 2-3) * - * @note This function expects uint8_t to match - * Adafruit_ADS1X15::readADC_SingleEnded(uint8_t) and avoid sign-extension - * issues. Negative sentinel values are handled internally. + * @note Channel parameters use uint8_t to be consistent with the + * Adafruit_ADS1X15 channel type convention and to avoid sign-extension + * when computing hardware MUX configuration values internally. */ static bool isValidDifferentialPair(uint8_t channel1, uint8_t channel2); From 9ff51108216cacd752eda9814a777bc80cc4ca51 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Mon, 23 Feb 2026 16:50:09 -0500 Subject: [PATCH 279/533] Made readVoltageDifferential pure virtual Signed-off-by: Sara Damiano --- src/sensors/AnalogVoltageBase.h | 15 +++++++-------- src/sensors/ProcessorAnalog.cpp | 6 ++++++ src/sensors/ProcessorAnalog.h | 11 +++++++++++ 3 files changed, 24 insertions(+), 8 deletions(-) diff --git a/src/sensors/AnalogVoltageBase.h b/src/sensors/AnalogVoltageBase.h index c3f37b139..f78fe6cb9 100644 --- a/src/sensors/AnalogVoltageBase.h +++ b/src/sensors/AnalogVoltageBase.h @@ -64,7 +64,7 @@ class AnalogVoltageBase { * * @param voltageMultiplier The multiplier value for voltage scaling */ - void setVoltageMultiplier(float voltageMultiplier) { + virtual void setVoltageMultiplier(float voltageMultiplier) { _voltageMultiplier = voltageMultiplier; } @@ -119,17 +119,16 @@ class AnalogVoltageBase { /** * @brief Read a differential voltage measurement * - * This virtual function provides a default implementation for differential - * voltage readings. Derived classes can override this to provide their - * specific differential reading implementation. + * This pure virtual function must be implemented by derived classes to + * provide their specific method of reading differential voltages. + * + * If the sensor does not support differential measurements, this function + * should set the resultValue to -9999.0 and return false. * * @param resultValue Reference to store the resulting voltage measurement * @return True if the voltage reading was successful and within valid range */ - virtual bool readVoltageDifferential(float& resultValue) { - resultValue = -9999.0; - return false; - } + virtual bool readVoltageDifferential(float& resultValue) = 0; /** * @brief Get the sensor location string diff --git a/src/sensors/ProcessorAnalog.cpp b/src/sensors/ProcessorAnalog.cpp index 19e7a0174..e7686c38d 100644 --- a/src/sensors/ProcessorAnalog.cpp +++ b/src/sensors/ProcessorAnalog.cpp @@ -63,6 +63,12 @@ String ProcessorAnalogBase::getSensorLocation(void) { return sensorLocation; } +bool ProcessorAnalogBase::readVoltageDifferential(float& resultValue) { + // ProcessorAnalog does not support differential measurements + resultValue = -9999.0; + return false; +} + // ============================================================================ // ProcessorAnalog Functions // ============================================================================ diff --git a/src/sensors/ProcessorAnalog.h b/src/sensors/ProcessorAnalog.h index c6f44b92a..945117c43 100644 --- a/src/sensors/ProcessorAnalog.h +++ b/src/sensors/ProcessorAnalog.h @@ -193,6 +193,17 @@ class ProcessorAnalogBase : public AnalogVoltageBase { */ bool readVoltageSingleEnded(float& resultValue) override; + /** + * @brief Read a differential voltage measurement from the processor ADC + * + * ProcessorAnalog does not support differential measurements, so this + * always returns false. + * + * @param resultValue Reference to store the resulting voltage measurement + * @return Always false (differential not supported) + */ + bool readVoltageDifferential(float& resultValue) override; + /** * @brief Get the sensor location string * From 1c159a12abd08a816d1bfba4ee1702e8bf92cfc7 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Mon, 23 Feb 2026 17:08:41 -0500 Subject: [PATCH 280/533] Apply new analog voltage base to turner cyclops Signed-off-by: Sara Damiano --- src/sensors/TurnerCyclops.cpp | 136 ++++++++++++++++++---------------- src/sensors/TurnerCyclops.h | 99 ++++++++++++++++++------- 2 files changed, 147 insertions(+), 88 deletions(-) diff --git a/src/sensors/TurnerCyclops.cpp b/src/sensors/TurnerCyclops.cpp index 892b949db..4b3aa9c9a 100644 --- a/src/sensors/TurnerCyclops.cpp +++ b/src/sensors/TurnerCyclops.cpp @@ -10,35 +10,80 @@ #include "TurnerCyclops.h" +#include "TIADS1x15.h" +#include "ProcessorAnalog.h" #include -// The constructor - need the power pin, the data pin, and the calibration info -TurnerCyclops::TurnerCyclops(int8_t powerPin, uint8_t adsChannel, +// Primary constructor using AnalogVoltageBase abstraction +TurnerCyclops::TurnerCyclops(int8_t powerPin, + AnalogVoltageBase* analogVoltageReader, float conc_std, float volt_std, float volt_blank, - uint8_t i2cAddress, uint8_t measurementsToAverage) + uint8_t measurementsToAverage) : Sensor("TurnerCyclops", CYCLOPS_NUM_VARIABLES, CYCLOPS_WARM_UP_TIME_MS, CYCLOPS_STABILIZATION_TIME_MS, CYCLOPS_MEASUREMENT_TIME_MS, powerPin, -1, measurementsToAverage, CYCLOPS_INC_CALC_VARIABLES), - _adsChannel(adsChannel), + _analogVoltageReader(analogVoltageReader), _conc_std(conc_std), _volt_std(volt_std), _volt_blank(volt_blank), - _i2cAddress(i2cAddress) {} + _ownsVoltageReader(false) {} + +// Constructor that creates a TIADS1x15 object internally +TurnerCyclops::TurnerCyclops(int8_t powerPin, int8_t adsChannel, float conc_std, + float volt_std, float volt_blank, + float voltageMultiplier, adsGain_t adsGain, + uint8_t i2cAddress, uint8_t measurementsToAverage, + float adsSupplyVoltage) + : Sensor("TurnerCyclops", CYCLOPS_NUM_VARIABLES, CYCLOPS_WARM_UP_TIME_MS, + CYCLOPS_STABILIZATION_TIME_MS, CYCLOPS_MEASUREMENT_TIME_MS, + powerPin, -1, measurementsToAverage, CYCLOPS_INC_CALC_VARIABLES), + _analogVoltageReader(nullptr), + _conc_std(conc_std), + _volt_std(volt_std), + _volt_blank(volt_blank), + _ownsVoltageReader(true) { + // Create a TIADS1x15 object for analog voltage reading + _analogVoltageReader = + new TIADS1x15(powerPin, adsChannel, voltageMultiplier, adsGain, + i2cAddress, measurementsToAverage, adsSupplyVoltage); +} + +// Constructor that creates a ProcessorAnalog object internally +TurnerCyclops::TurnerCyclops(int8_t powerPin, int8_t dataPin, float conc_std, + float volt_std, float volt_blank, + float voltageMultiplier, float operatingVoltage, + uint8_t measurementsToAverage) + : Sensor("TurnerCyclops", CYCLOPS_NUM_VARIABLES, CYCLOPS_WARM_UP_TIME_MS, + CYCLOPS_STABILIZATION_TIME_MS, CYCLOPS_MEASUREMENT_TIME_MS, + powerPin, -1, measurementsToAverage, CYCLOPS_INC_CALC_VARIABLES), + _analogVoltageReader(nullptr), + _conc_std(conc_std), + _volt_std(volt_std), + _volt_blank(volt_blank), + _ownsVoltageReader(true) { + // Create a ProcessorAnalog object for analog voltage reading + _analogVoltageReader = + new ProcessorAnalog(powerPin, dataPin, voltageMultiplier, + operatingVoltage, measurementsToAverage); +} // Destructor -TurnerCyclops::~TurnerCyclops() {} +TurnerCyclops::~TurnerCyclops() { + // Clean up owned voltage reader if created by legacy constructor + if (_ownsVoltageReader && _analogVoltageReader != nullptr) { + delete _analogVoltageReader; + _analogVoltageReader = nullptr; + } +} String TurnerCyclops::getSensorLocation(void) { -#ifndef MS_USE_ADS1015 - String sensorLocation = F("ADS1115_0x"); -#else - String sensorLocation = F("ADS1015_0x"); -#endif - sensorLocation += String(_i2cAddress, HEX); - sensorLocation += F("_Channel"); - sensorLocation += String(_adsChannel); - return sensorLocation; + if (_analogVoltageReader != nullptr) { + return _analogVoltageReader->getSensorLocation(); + } else { + // Fallback for cases where voltage reader is not set + return F("TurnerCyclops_UnknownLocation"); + } } @@ -48,43 +93,13 @@ bool TurnerCyclops::addSingleMeasurementResult(void) { return bumpMeasurementAttemptCount(false); } - bool success = false; - int16_t adcCounts = -9999; - float adcVoltage = -9999; - float calibResult = -9999; - - MS_DBG(getSensorNameAndLocation(), F("is reporting:")); - -// Create an auxiliary ADC object -// We create and set up the ADC object here so that each sensor using -// the ADC may set the gain appropriately without effecting others. -#ifndef MS_USE_ADS1015 - Adafruit_ADS1115 ads; // Use this for the 16-bit version -#else - Adafruit_ADS1015 ads; // Use this for the 12-bit version -#endif - // ADS Library default settings: - // - TI ADS1115 (16 bit) - // - single-shot mode (powers down between conversions) - // - 128 samples per second (8ms conversion time) - // - 2/3 gain +/- 6.144V range (limited to VDD +0.3V max) - // - TI ADS1015 (12 bit) - // - single-shot mode (powers down between conversions) - // - 1600 samples per second (625µs conversion time) - // - 2/3 gain +/- 6.144V range (limited to VDD +0.3V max) - - // Bump the gain up to 1x = +/- 4.096V range - // Sensor return range is 0-2.5V, but the next gain option is 2x which - // only allows up to 2.048V - ads.setGain(GAIN_ONE); - // Begin ADC, returns true if anything was detected at the address - if (!ads.begin(_i2cAddress)) { - MS_DBG(F(" ADC initialization failed at 0x"), - String(_i2cAddress, HEX)); + // Ensure we have a valid voltage reader + if (_analogVoltageReader == nullptr) { + MS_DBG(F(" No analog voltage reader configured!")); return bumpMeasurementAttemptCount(false); } - // Print out the calibration curve + // Print out the calibration curve and check that it is valid MS_DBG(F(" Input calibration Curve:"), _volt_std, F("V at"), _conc_std, F(". "), _volt_blank, F("V blank.")); const float epsilon = 1e-4f; // tune to expected sensor precision @@ -93,25 +108,22 @@ bool TurnerCyclops::addSingleMeasurementResult(void) { return bumpMeasurementAttemptCount(false); } - // Read Analog to Digital Converter (ADC) - // Taking this reading includes the 8ms conversion delay. - // Measure the ADC raw count - adcCounts = ads.readADC_SingleEnded(_adsChannel); - // Convert ADC raw counts value to voltage (V) - adcVoltage = ads.computeVolts(adcCounts); - MS_DBG(F(" ads.readADC_SingleEnded("), _adsChannel, F("):"), adcCounts, - '=', adcVoltage); - - // @todo Verify the voltage range for the Cyclops sensor - // Here we are using the range of the ADS when it is powered at 3.3V - if (adcVoltage < 3.6 && adcVoltage > -0.3) { + bool success = false; + float adcVoltage = -9999; + float calibResult = -9999; + + MS_DBG(getSensorNameAndLocation(), F("is reporting:")); + + // Use the abstracted voltage reading method + success = _analogVoltageReader->readVoltageSingleEnded(adcVoltage); + + if (success) { // Apply the unique calibration curve for the given sensor calibResult = (_conc_std / (_volt_std - _volt_blank)) * (adcVoltage - _volt_blank); MS_DBG(F(" calibResult:"), calibResult); verifyAndAddMeasurementResult(CYCLOPS_VAR_NUM, calibResult); verifyAndAddMeasurementResult(CYCLOPS_VOLTAGE_VAR_NUM, adcVoltage); - success = true; } // Return success value when finished diff --git a/src/sensors/TurnerCyclops.h b/src/sensors/TurnerCyclops.h index c5ef7503c..22b2fb97e 100644 --- a/src/sensors/TurnerCyclops.h +++ b/src/sensors/TurnerCyclops.h @@ -101,6 +101,25 @@ * possible. All gain settings and voltage dividers should be in place for * the calibration. * + * The units to use for the calibration point depend on the parameter being measured, + * as listed in the table below. + * + * | ID | Variable | Units | + * | --- | ---------------------------- | ----------------------------------- | + * | C | TurnerCyclops_Chlorophyll | micrograms per Liter (µg/L) | + * | R | TurnerCyclops_Rhodamine | parts per billion (ppb) | + * | F | TurnerCyclops_Fluorescein | parts per billion (ppb) | + * | P | TurnerCyclops_Phycocyanin | parts per billion (ppb) | + * | E | TurnerCyclops_Phycoerythrin | parts per billion (ppb) | + * | U | TurnerCyclops_CDOM | parts per billion (ppb) | + * | O | TurnerCyclops_CrudeOil | parts per billion (ppb) | + * | B | TurnerCyclops_Brighteners | parts per billion (ppb) | + * | T | TurnerCyclops_Turbidity | nephelometric turbidity units (NTU) | + * | A | TurnerCyclops_PTSA | parts per billion (ppb) | + * | G | TurnerCyclops_BTEX | parts per million (ppm) | + * | L | TurnerCyclops_Tryptophan | parts per billion (ppb) | + * | D | TurnerCyclops_RedChlorophyll | micrograms per Liter (µg/L) | + * * Before applying any calibration, the analog output from the Cyclops-7F * must be converted into a high resolution digital signal. See the * [ADS1115 page](@ref analog_group) for details on the conversion. @@ -135,6 +154,9 @@ // Include the debugging config #include "ModSensorDebugConfig.h" +// Include known processor settings for default operating voltage +#include "sensors/KnownProcessors.h" + // Define the print label[s] for the debugger #ifdef MS_TURNERCYCLOPS_DEBUG #define MS_DEBUGGING_STD "TurnerCyclops" @@ -148,6 +170,8 @@ // Include other in-library and external dependencies #include "VariableBase.h" #include "SensorBase.h" +#include "AnalogVoltageBase.h" +#include // Sensor Specific Defines /** @ingroup sensor_cyclops */ @@ -283,7 +307,6 @@ class TurnerCyclops : public Sensor { public: // The constructor - need the power pin, the ADS1X15 data channel, and the // calibration info - /* clang-format off */ /** * @brief Construct a new Turner Cyclops object - need the power pin, the * ADS1X15 data channel, and the calibration info. @@ -298,43 +321,65 @@ class TurnerCyclops : public Sensor { * assumes the ADS is powered with 3.3V. * - The Cyclops-7F itself requires a 3-15V power supply, which can be * turned off between measurements. - * @param adsChannel The analog data channel _on the TI ADS1115_ that the - * Cyclops is connected to (0-3). + * @param analogVoltageReader Pointer to an AnalogVoltageBase object (e.g., + * TIADS1x15 or ProcessorAnalog) that will be used to read the analog + * voltage from the sensor * @param conc_std The concentration of the standard used for a 1-point * sensor calibration. The concentration units should be the same as the * final measuring units. - * | ID | Variable | Units | - * | --- | ---------------------------- | ----------------------------------- | - * | C | TurnerCyclops_Chlorophyll | micrograms per Liter (µg/L) | - * | R | TurnerCyclops_Rhodamine | parts per billion (ppb) | - * | F | TurnerCyclops_Fluorescein | parts per billion (ppb) | - * | P | TurnerCyclops_Phycocyanin | parts per billion (ppb) | - * | E | TurnerCyclops_Phycoerythrin | parts per billion (ppb) | - * | U | TurnerCyclops_CDOM | parts per billion (ppb) | - * | O | TurnerCyclops_CrudeOil | parts per billion (ppb) | - * | B | TurnerCyclops_Brighteners | parts per billion (ppb) | - * | T | TurnerCyclops_Turbidity | nephelometric turbidity units (NTU) | - * | A | TurnerCyclops_PTSA | parts per billion (ppb) | - * | G | TurnerCyclops_BTEX | parts per million (ppm) | - * | L | TurnerCyclops_Tryptophan | parts per billion (ppb) | - * | D | TurnerCyclops_RedChlorophyll | micrograms per Liter (µg/L) | * @param volt_std The voltage (in volts) measured for the conc_std. This * voltage should be the final voltage *after* accounting for any voltage * dividers or gain settings. * @param volt_blank The voltage (in volts) measured for a blank. This * voltage should be the final voltage *after* accounting for any voltage * dividers or gain settings. - * @param i2cAddress The I2C address of the ADS 1x15, default is 0x48 (ADDR - * = GND) * @param measurementsToAverage The number of measurements to take and * average before giving a "final" result from the sensor; optional with a * default value of 1. */ - /* clang-format on */ + TurnerCyclops(int8_t powerPin, AnalogVoltageBase* analogVoltageReader, + float conc_std, float volt_std, float volt_blank, + uint8_t measurementsToAverage = 1); + + /** + * @brief Construct a new Turner Cyclops object using TIADS1x15 - creates + * an internal TIADS1x15 object for reading analog voltages + * + * @param powerPin The pin on the mcu controlling power to the Cyclops-7F + * @param adsChannel The ADS channel (0-3) connected to the sensor + * @param conc_std The concentration of the standard for calibration + * @param volt_std The voltage measured for the conc_std + * @param volt_blank The voltage measured for a blank + * @param voltageMultiplier The voltage multiplier for voltage dividers + * @param adsGain The internal gain setting of the ADS1x15 + * @param i2cAddress The I2C address of the ADS1x15 + * @param measurementsToAverage Number of measurements to average + * @param adsSupplyVoltage The power supply voltage for the ADS1x15 + */ TurnerCyclops(int8_t powerPin, uint8_t adsChannel, float conc_std, float volt_std, float volt_blank, uint8_t i2cAddress = ADS1115_ADDRESS, - uint8_t measurementsToAverage = 1); + uint8_t measurementsToAverage = 1, + float voltageMultiplier = 1.0, adsGain_t adsGain = GAIN_ONE, + float adsSupplyVoltage = OPERATING_VOLTAGE); + + /** + * @brief Construct a new Turner Cyclops object using ProcessorAnalog - + * creates an internal ProcessorAnalog object for reading analog voltages + * + * @param powerPin The pin on the mcu controlling power to the Cyclops-7F + * @param dataPin The processor ADC pin connected to the sensor + * @param conc_std The concentration of the standard for calibration + * @param volt_std The voltage measured for the conc_std + * @param volt_blank The voltage measured for a blank + * @param voltageMultiplier The voltage multiplier for voltage dividers + * @param operatingVoltage The processor's operating voltage + * @param measurementsToAverage Number of measurements to average + */ + TurnerCyclops(int8_t powerPin, int8_t dataPin, float conc_std, + float volt_std, float volt_blank, + uint8_t measurementsToAverage = 1, float voltageMultiplier, + float operatingVoltage = OPERATING_VOLTAGE); /** * @brief Destroy the Turner Cyclops object */ @@ -346,9 +391,9 @@ class TurnerCyclops : public Sensor { private: /** - * @brief Internal reference to the ADS channel number of the Turner Cyclops + * @brief Internal reference to the analog voltage reading object */ - uint8_t _adsChannel; + AnalogVoltageBase* _analogVoltageReader; /** * @brief The concentration of the standard used for a 1-point sensor * calibration. The concentration units should be the same as the final @@ -368,9 +413,11 @@ class TurnerCyclops : public Sensor { */ float _volt_blank; /** - * @brief Internal reference to the I2C address of the TI-ADS1x15 + * @brief Internal flag to indicate if a _analogVoltageReader was created + * when this object was instantiated so that it can be properly deleted in + * the destructor if needed. */ - uint8_t _i2cAddress; + bool _ownsVoltageReader; }; From 60c083a4bbfc82e494306b1dddf23401d2839378 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Mon, 23 Feb 2026 17:35:49 -0500 Subject: [PATCH 281/533] Apply to OBS3 Signed-off-by: Sara Damiano --- src/sensors/CampbellOBS3.cpp | 131 +++++++++++++++++++---------------- src/sensors/CampbellOBS3.h | 62 ++++++++++++++--- 2 files changed, 125 insertions(+), 68 deletions(-) diff --git a/src/sensors/CampbellOBS3.cpp b/src/sensors/CampbellOBS3.cpp index ff98ce8af..1a5608562 100644 --- a/src/sensors/CampbellOBS3.cpp +++ b/src/sensors/CampbellOBS3.cpp @@ -10,35 +10,80 @@ #include "CampbellOBS3.h" +#include "TIADS1x15.h" +#include "ProcessorAnalog.h" #include -// The constructor - need the power pin, the data pin, and the calibration info +// Primary constructor using AnalogVoltageBase abstraction +CampbellOBS3::CampbellOBS3(int8_t powerPin, + AnalogVoltageBase* analogVoltageReader, + float x2_coeff_A, float x1_coeff_B, float x0_coeff_C, + uint8_t measurementsToAverage) + : Sensor("CampbellOBS3", OBS3_NUM_VARIABLES, OBS3_WARM_UP_TIME_MS, + OBS3_STABILIZATION_TIME_MS, OBS3_MEASUREMENT_TIME_MS, powerPin, -1, + measurementsToAverage, OBS3_INC_CALC_VARIABLES), + _analogVoltageReader(analogVoltageReader), + _ownsVoltageReader(false), + _x2_coeff_A(x2_coeff_A), + _x1_coeff_B(x1_coeff_B), + _x0_coeff_C(x0_coeff_C) {} + +// Constructor that creates a TIADS1x15 object internally CampbellOBS3::CampbellOBS3(int8_t powerPin, uint8_t adsChannel, float x2_coeff_A, float x1_coeff_B, float x0_coeff_C, - uint8_t i2cAddress, uint8_t measurementsToAverage) + uint8_t measurementsToAverage, + float voltageMultiplier, adsGain_t adsGain, + uint8_t i2cAddress, float adsSupplyVoltage) + : Sensor("CampbellOBS3", OBS3_NUM_VARIABLES, OBS3_WARM_UP_TIME_MS, + OBS3_STABILIZATION_TIME_MS, OBS3_MEASUREMENT_TIME_MS, powerPin, -1, + measurementsToAverage, OBS3_INC_CALC_VARIABLES), + _analogVoltageReader(nullptr), + _ownsVoltageReader(true), + _x2_coeff_A(x2_coeff_A), + _x1_coeff_B(x1_coeff_B), + _x0_coeff_C(x0_coeff_C) { + // Create a TIADS1x15 object for analog voltage reading + _analogVoltageReader = + new TIADS1x15(powerPin, adsChannel, voltageMultiplier, adsGain, + i2cAddress, measurementsToAverage, adsSupplyVoltage); +} + +// Constructor that creates a ProcessorAnalog object internally +CampbellOBS3::CampbellOBS3(int8_t powerPin, int8_t dataPin, float x2_coeff_A, + float x1_coeff_B, float x0_coeff_C, + float voltageMultiplier, float operatingVoltage, + uint8_t measurementsToAverage) : Sensor("CampbellOBS3", OBS3_NUM_VARIABLES, OBS3_WARM_UP_TIME_MS, OBS3_STABILIZATION_TIME_MS, OBS3_MEASUREMENT_TIME_MS, powerPin, -1, measurementsToAverage, OBS3_INC_CALC_VARIABLES), - _adsChannel(adsChannel), + _analogVoltageReader(nullptr), + _ownsVoltageReader(true), _x2_coeff_A(x2_coeff_A), _x1_coeff_B(x1_coeff_B), - _x0_coeff_C(x0_coeff_C), - _i2cAddress(i2cAddress) {} + _x0_coeff_C(x0_coeff_C) { + // Create a ProcessorAnalog object for analog voltage reading + _analogVoltageReader = + new ProcessorAnalog(powerPin, dataPin, voltageMultiplier, + operatingVoltage, measurementsToAverage); +} // Destructor -CampbellOBS3::~CampbellOBS3() {} +CampbellOBS3::~CampbellOBS3() { + // Clean up owned voltage reader if created by constructor + if (_ownsVoltageReader && _analogVoltageReader != nullptr) { + delete _analogVoltageReader; + _analogVoltageReader = nullptr; + } +} String CampbellOBS3::getSensorLocation(void) { -#ifndef MS_USE_ADS1015 - String sensorLocation = F("ADS1115_0x"); -#else - String sensorLocation = F("ADS1015_0x"); -#endif - sensorLocation += String(_i2cAddress, HEX); - sensorLocation += F("_Channel"); - sensorLocation += String(_adsChannel); - return sensorLocation; + if (_analogVoltageReader != nullptr) { + return _analogVoltageReader->getSensorLocation(); + } else { + // Fallback for cases where voltage reader is not set + return F("CampbellOBS3_UnknownLocation"); + } } @@ -48,65 +93,35 @@ bool CampbellOBS3::addSingleMeasurementResult(void) { return bumpMeasurementAttemptCount(false); } + // Ensure we have a valid voltage reader + if (_analogVoltageReader == nullptr) { + MS_DBG(F(" No analog voltage reader configured!")); + return bumpMeasurementAttemptCount(false); + } + bool success = false; - int16_t adcCounts = -9999; float adcVoltage = -9999; float calibResult = -9999; MS_DBG(getSensorNameAndLocation(), F("is reporting:")); -// Create an auxiliary ADC object -// We create and set up the ADC object here so that each sensor using -// the ADC may set the gain appropriately without effecting others. -#ifndef MS_USE_ADS1015 - Adafruit_ADS1115 ads; // Use this for the 16-bit version -#else - Adafruit_ADS1015 ads; // Use this for the 12-bit version -#endif - // ADS Library default settings: - // - TI ADS1115 (16 bit) - // - single-shot mode (powers down between conversions) - // - 128 samples per second (8ms conversion time) - // - 2/3 gain +/- 6.144V range (limited to VDD +0.3V max) - // - TI ADS1015 (12 bit) - // - single-shot mode (powers down between conversions) - // - 1600 samples per second (625µs conversion time) - // - 2/3 gain +/- 6.144V range (limited to VDD +0.3V max) - - // Bump the gain up to 1x = +/- 4.096V range - // Sensor return range is 0-2.5V, but the next gain option is 2x which - // only allows up to 2.048V - ads.setGain(GAIN_ONE); - // Begin ADC, returns true if anything was detected at the address - if (!ads.begin(_i2cAddress)) { - MS_DBG(F(" ADC initialization failed at 0x"), - String(_i2cAddress, HEX)); - return bumpMeasurementAttemptCount(false); - } - // Print out the calibration curve MS_DBG(F(" Input calibration Curve:"), _x2_coeff_A, F("x^2 +"), _x1_coeff_B, F("x +"), _x0_coeff_C); - // Read Analog to Digital Converter (ADC) - // Taking this reading includes the 8ms conversion delay. - // Measure the ADC raw count - adcCounts = ads.readADC_SingleEnded(_adsChannel); - // Convert ADC raw counts value to voltage (V) - adcVoltage = ads.computeVolts(adcCounts); - MS_DBG(F(" ads.readADC_SingleEnded("), _adsChannel, F("):"), adcCounts, - '=', adcVoltage); - - // @todo Verify the voltage range for the OBS3 sensor - - // Here we are using the range of the ADS when it is powered at 3.3V - if (adcVoltage < 3.6 && adcVoltage > -0.3) { + // Use the abstracted voltage reading method + success = _analogVoltageReader->readVoltageSingleEnded(adcVoltage); + + if (success) { // Apply the unique calibration curve for the given sensor calibResult = (_x2_coeff_A * sq(adcVoltage)) + (_x1_coeff_B * adcVoltage) + _x0_coeff_C; MS_DBG(F(" calibResult:"), calibResult); verifyAndAddMeasurementResult(OBS3_TURB_VAR_NUM, calibResult); verifyAndAddMeasurementResult(OBS3_VOLTAGE_VAR_NUM, adcVoltage); - success = true; + + } else { + MS_DBG(F(" Failed to read voltage from analog voltage reader")); } // Return success value when finished diff --git a/src/sensors/CampbellOBS3.h b/src/sensors/CampbellOBS3.h index 8a7febd11..03750d753 100644 --- a/src/sensors/CampbellOBS3.h +++ b/src/sensors/CampbellOBS3.h @@ -88,6 +88,7 @@ // Include other in-library and external dependencies #include "VariableBase.h" #include "SensorBase.h" +#include "AnalogVoltageBase.h" /** @ingroup sensor_obs3 */ /**@{*/ @@ -244,8 +245,24 @@ /* clang-format on */ class CampbellOBS3 : public Sensor { public: - // The constructor - need the power pin, the ADS1X15 data channel, and the - // calibration info + /** + * @brief Construct a new Campbell OBS3 object using a pre-configured + * AnalogVoltageBase + * + * @param powerPin The pin on the mcu controlling power to the OBS3+ + * Use -1 if it is continuously powered. + * @param analogVoltageReader Pointer to an AnalogVoltageBase object for + * voltage readings + * @param x2_coeff_A The x2 (A) coefficient for calibration _in volts_ + * @param x1_coeff_B The x (B) coefficient for calibration _in volts_ + * @param x0_coeff_C The x0 (C) coefficient for calibration _in volts_ + * @param measurementsToAverage Number of measurements to average + * (default=1) + */ + CampbellOBS3(int8_t powerPin, AnalogVoltageBase* analogVoltageReader, + float x2_coeff_A, float x1_coeff_B, float x0_coeff_C, + uint8_t measurementsToAverage = 1); + /** * @brief Construct a new Campbell OBS3 object - need the power pin, the * ADS1X15 data channel, and the calibration info. @@ -265,15 +282,41 @@ class CampbellOBS3 : public Sensor { * @param x2_coeff_A The x2 (A) coefficient for the calibration _in volts_ * @param x1_coeff_B The x (B) coefficient for the calibration _in volts_ * @param x0_coeff_C The x0 (C) coefficient for the calibration _in volts_ + * @param voltageMultiplier The voltage multiplier for voltage dividers + * (default=1) + * @param adsGain The internal gain setting (default=GAIN_ONE) * @param i2cAddress The I2C address of the ADS 1x15, default is 0x48 (ADDR * = GND) * @param measurementsToAverage The number of measurements to take and * average before giving a "final" result from the sensor; optional with a * default value of 1. + * @param adsSupplyVoltage ADS supply voltage in volts (default=3.3V) */ CampbellOBS3(int8_t powerPin, uint8_t adsChannel, float x2_coeff_A, float x1_coeff_B, float x0_coeff_C, - uint8_t i2cAddress = ADS1115_ADDRESS, + uint8_t i2cAddress = ADS1115_ADDRESS, + float voltageMultiplier = 1.0, adsGain_t adsGain = GAIN_ONE, + uint8_t measurementsToAverage = 1, + float adsSupplyVoltage = 3.3); + + /** + * @brief Construct a new Campbell OBS3 object using processor ADC + * + * @param powerPin The pin on the mcu controlling power to the OBS3+ + * Use -1 if it is continuously powered. + * @param dataPin The processor ADC pin for voltage readings + * @param x2_coeff_A The x2 (A) coefficient for calibration _in volts_ + * @param x1_coeff_B The x (B) coefficient for calibration _in volts_ + * @param x0_coeff_C The x0 (C) coefficient for calibration _in volts_ + * @param voltageMultiplier The voltage multiplier for voltage dividers + * (default=1) + * @param operatingVoltage Processor operating voltage (default=3.3V) + * @param measurementsToAverage Number of measurements to average + * (default=1) + */ + CampbellOBS3(int8_t powerPin, int8_t dataPin, float x2_coeff_A, + float x1_coeff_B, float x0_coeff_C, + float voltageMultiplier = 1.0, float operatingVoltage = 3.3, uint8_t measurementsToAverage = 1); /** * @brief Destroy the Campbell OBS3 object @@ -286,17 +329,16 @@ class CampbellOBS3 : public Sensor { private: /** - * @brief Internal reference to the ADS channel number of the Campbell OBS - * 3+ + * @brief Internal reference to the analog voltage reading object */ - uint8_t _adsChannel; + AnalogVoltageBase* _analogVoltageReader; + /** + * @brief Internal flag indicating if this instance owns the voltage reader + */ + bool _ownsVoltageReader; float _x2_coeff_A; ///< Internal reference to the x^2 coefficient float _x1_coeff_B; ///< Internal reference to the x coefficient float _x0_coeff_C; ///< Internal reference to the x^0 coefficient - /** - * @brief Internal reference to the I2C address of the TI-ADS1x15 - */ - uint8_t _i2cAddress; }; From c183b43d61530b0caabc497db53b9513e6a24aea Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Mon, 23 Feb 2026 17:56:29 -0500 Subject: [PATCH 282/533] Remove redundant defines of ADS1115_ADDRESS Signed-off-by: Sara Damiano --- src/ModSensorConfig.h | 9 +++++++++ src/sensors/ApogeeSQ212.h | 5 +---- src/sensors/CampbellOBS3.cpp | 1 - src/sensors/CampbellOBS3.h | 13 ++----------- src/sensors/TIADS1x15.h | 22 ++++++---------------- src/sensors/TurnerCyclops.cpp | 13 +++++++------ src/sensors/TurnerCyclops.h | 12 +----------- 7 files changed, 26 insertions(+), 49 deletions(-) diff --git a/src/ModSensorConfig.h b/src/ModSensorConfig.h index 7fb93ef23..941955608 100644 --- a/src/ModSensorConfig.h +++ b/src/ModSensorConfig.h @@ -140,6 +140,9 @@ // GroPoint Profile GPLP-8 has 8 Moisture and 13 Temperature values #endif +//============================================================== +// Analog voltage configuration +//============================================================== #ifndef MS_PROCESSOR_ADC_RESOLUTION /** * @brief Select or adjust the processor analog resolution. @@ -226,6 +229,12 @@ #error The processor ADC reference type must be defined! #endif // MS_PROCESSOR_ADC_REFERENCE_MODE #endif // ARDUINO_ARCH_SAMD + + +#ifndef MS_DEFAULT_ADS1X15_ADDRESS || defined(DOXYGEN) +/// @brief The assumed address of the ADS1115 or ADS1015, 1001 000 (ADDR = GND) +#define MS_DEFAULT_ADS1X15_ADDRESS 0x48 +#endif //============================================================== diff --git a/src/sensors/ApogeeSQ212.h b/src/sensors/ApogeeSQ212.h index acd839dce..f275cf033 100644 --- a/src/sensors/ApogeeSQ212.h +++ b/src/sensors/ApogeeSQ212.h @@ -126,9 +126,6 @@ */ #define SQ212_CALIBRATION_FACTOR 1 #endif - -/// The assumed address of the ADS1115, 1001 000 (ADDR = GND) -#define ADS1115_ADDRESS 0x48 /**@}*/ /** @@ -266,7 +263,7 @@ class ApogeeSQ212 : public Sensor { * not support any other configuration. */ ApogeeSQ212(int8_t powerPin, uint8_t adsChannel, - uint8_t i2cAddress = ADS1115_ADDRESS, + uint8_t i2cAddress = MS_DEFAULT_ADS1X15_ADDRESS, uint8_t measurementsToAverage = 1); /** * @brief Destroy the ApogeeSQ212 object - no action needed diff --git a/src/sensors/CampbellOBS3.cpp b/src/sensors/CampbellOBS3.cpp index 1a5608562..b0ada54f7 100644 --- a/src/sensors/CampbellOBS3.cpp +++ b/src/sensors/CampbellOBS3.cpp @@ -12,7 +12,6 @@ #include "CampbellOBS3.h" #include "TIADS1x15.h" #include "ProcessorAnalog.h" -#include // Primary constructor using AnalogVoltageBase abstraction diff --git a/src/sensors/CampbellOBS3.h b/src/sensors/CampbellOBS3.h index 03750d753..7f14d861e 100644 --- a/src/sensors/CampbellOBS3.h +++ b/src/sensors/CampbellOBS3.h @@ -89,6 +89,7 @@ #include "VariableBase.h" #include "SensorBase.h" #include "AnalogVoltageBase.h" +#include /** @ingroup sensor_obs3 */ /**@{*/ @@ -113,16 +114,6 @@ #define OBS3_INC_CALC_VARIABLES 1 /**@}*/ -/** - * @anchor sensor_obs3_config - * @name Configuration Defines - * Defines to set the address of the ADD. - */ -/**@{*/ -/// @brief The assumed address of the ADS1115, 1001 000 (ADDR = GND) -#define ADS1115_ADDRESS 0x48 -/**@}*/ - /** * @anchor sensor_obs3_timing * @name Sensor Timing @@ -294,7 +285,7 @@ class CampbellOBS3 : public Sensor { */ CampbellOBS3(int8_t powerPin, uint8_t adsChannel, float x2_coeff_A, float x1_coeff_B, float x0_coeff_C, - uint8_t i2cAddress = ADS1115_ADDRESS, + uint8_t i2cAddress = MS_DEFAULT_ADS1X15_ADDRESS, float voltageMultiplier = 1.0, adsGain_t adsGain = GAIN_ONE, uint8_t measurementsToAverage = 1, float adsSupplyVoltage = 3.3); diff --git a/src/sensors/TIADS1x15.h b/src/sensors/TIADS1x15.h index 663640543..b588fb5f2 100644 --- a/src/sensors/TIADS1x15.h +++ b/src/sensors/TIADS1x15.h @@ -186,16 +186,6 @@ #define TIADS1X15_INC_CALC_VARIABLES 0 /**@}*/ -/** - * @anchor sensor_ads1x15_config - * @name Configuration Defines - * Defines to help configure the address of the ADD - */ -/**@{*/ -/// @brief The assumed address of the ADS1115, 1001 000 (ADDR = GND) -#define ADS1115_ADDRESS 0x48 -/**@}*/ - /** * @brief Enum for the pins used for differential voltages. */ @@ -297,8 +287,8 @@ class TIADS1x15Base : public AnalogVoltageBase { * Negative sentinels are handled internally where needed. */ explicit TIADS1x15Base(uint8_t adsChannel, float voltageMultiplier = 1.0, - adsGain_t adsGain = GAIN_ONE, - uint8_t i2cAddress = ADS1115_ADDRESS, + adsGain_t adsGain = GAIN_ONE, + uint8_t i2cAddress = MS_DEFAULT_ADS1X15_ADDRESS, float adsSupplyVoltage = OPERATING_VOLTAGE); /** @@ -319,8 +309,8 @@ class TIADS1x15Base : public AnalogVoltageBase { explicit TIADS1x15Base(uint8_t adsChannel1, uint8_t adsChannel2, float voltageMultiplier = 1.0, adsGain_t adsGain = GAIN_ONE, - uint8_t i2cAddress = ADS1115_ADDRESS, - float adsSupplyVoltage = OPERATING_VOLTAGE); + uint8_t i2cAddress = MS_DEFAULT_ADS1X15_ADDRESS, + float adsSupplyVoltage = OPERATING_VOLTAGE); /** * @brief Destroy the TIADS1x15Base object @@ -433,7 +423,7 @@ class TIADS1x15 : public Sensor, public TIADS1x15Base { */ TIADS1x15(int8_t powerPin, uint8_t adsChannel, float voltageMultiplier = 1, adsGain_t adsGain = GAIN_ONE, - uint8_t i2cAddress = ADS1115_ADDRESS, + uint8_t i2cAddress = MS_DEFAULT_ADS1X15_ADDRESS, uint8_t measurementsToAverage = 1, float adsSupplyVoltage = OPERATING_VOLTAGE); /** @@ -463,7 +453,7 @@ class TIADS1x15 : public Sensor, public TIADS1x15Base { */ TIADS1x15(int8_t powerPin, uint8_t adsChannel1, uint8_t adsChannel2, float voltageMultiplier = 1, adsGain_t adsGain = GAIN_ONE, - uint8_t i2cAddress = ADS1115_ADDRESS, + uint8_t i2cAddress = MS_DEFAULT_ADS1X15_ADDRESS, uint8_t measurementsToAverage = 1, float adsSupplyVoltage = OPERATING_VOLTAGE); /** diff --git a/src/sensors/TurnerCyclops.cpp b/src/sensors/TurnerCyclops.cpp index 4b3aa9c9a..c7d48339d 100644 --- a/src/sensors/TurnerCyclops.cpp +++ b/src/sensors/TurnerCyclops.cpp @@ -12,7 +12,6 @@ #include "TurnerCyclops.h" #include "TIADS1x15.h" #include "ProcessorAnalog.h" -#include // Primary constructor using AnalogVoltageBase abstraction @@ -30,10 +29,10 @@ TurnerCyclops::TurnerCyclops(int8_t powerPin, _ownsVoltageReader(false) {} // Constructor that creates a TIADS1x15 object internally -TurnerCyclops::TurnerCyclops(int8_t powerPin, int8_t adsChannel, float conc_std, - float volt_std, float volt_blank, - float voltageMultiplier, adsGain_t adsGain, +TurnerCyclops::TurnerCyclops(int8_t powerPin, uint8_t adsChannel, + float conc_std, float volt_std, float volt_blank, uint8_t i2cAddress, uint8_t measurementsToAverage, + float voltageMultiplier, adsGain_t adsGain, float adsSupplyVoltage) : Sensor("TurnerCyclops", CYCLOPS_NUM_VARIABLES, CYCLOPS_WARM_UP_TIME_MS, CYCLOPS_STABILIZATION_TIME_MS, CYCLOPS_MEASUREMENT_TIME_MS, @@ -52,8 +51,8 @@ TurnerCyclops::TurnerCyclops(int8_t powerPin, int8_t adsChannel, float conc_std, // Constructor that creates a ProcessorAnalog object internally TurnerCyclops::TurnerCyclops(int8_t powerPin, int8_t dataPin, float conc_std, float volt_std, float volt_blank, - float voltageMultiplier, float operatingVoltage, - uint8_t measurementsToAverage) + uint8_t measurementsToAverage, + float voltageMultiplier, float operatingVoltage) : Sensor("TurnerCyclops", CYCLOPS_NUM_VARIABLES, CYCLOPS_WARM_UP_TIME_MS, CYCLOPS_STABILIZATION_TIME_MS, CYCLOPS_MEASUREMENT_TIME_MS, powerPin, -1, measurementsToAverage, CYCLOPS_INC_CALC_VARIABLES), @@ -124,6 +123,8 @@ bool TurnerCyclops::addSingleMeasurementResult(void) { MS_DBG(F(" calibResult:"), calibResult); verifyAndAddMeasurementResult(CYCLOPS_VAR_NUM, calibResult); verifyAndAddMeasurementResult(CYCLOPS_VOLTAGE_VAR_NUM, adcVoltage); + } else { + MS_DBG(F(" Failed to read voltage from analog voltage reader")); } // Return success value when finished diff --git a/src/sensors/TurnerCyclops.h b/src/sensors/TurnerCyclops.h index 22b2fb97e..751f57bd5 100644 --- a/src/sensors/TurnerCyclops.h +++ b/src/sensors/TurnerCyclops.h @@ -199,16 +199,6 @@ #define CYCLOPS_INC_CALC_VARIABLES 1 /**@}*/ -/** - * @anchor sensor_cyclops_config - * @name Configuration Defines - * Defines to help configure the address of the ADD used by the Cyclops - */ -/**@{*/ -/// @brief The assumed address of the ADS1115, 1001 000 (ADDR = GND) -#define ADS1115_ADDRESS 0x48 -/**@}*/ - /** * @anchor sensor_cyclops_timing * @name Sensor Timing @@ -358,7 +348,7 @@ class TurnerCyclops : public Sensor { */ TurnerCyclops(int8_t powerPin, uint8_t adsChannel, float conc_std, float volt_std, float volt_blank, - uint8_t i2cAddress = ADS1115_ADDRESS, + uint8_t i2cAddress = MS_DEFAULT_ADS1X15_ADDRESS, uint8_t measurementsToAverage = 1, float voltageMultiplier = 1.0, adsGain_t adsGain = GAIN_ONE, float adsSupplyVoltage = OPERATING_VOLTAGE); From aba71a75aa30624dd07b91624fe32120da3c4fe0 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Tue, 24 Feb 2026 09:36:29 -0500 Subject: [PATCH 283/533] Minor docs and grammar Signed-off-by: Sara Damiano --- src/sensors/ProcessorAnalog.h | 3 ++- src/sensors/TIADS1x15.cpp | 4 ++-- src/sensors/TurnerTurbidityPlus.h | 4 ++-- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/sensors/ProcessorAnalog.h b/src/sensors/ProcessorAnalog.h index 945117c43..d064cf0fe 100644 --- a/src/sensors/ProcessorAnalog.h +++ b/src/sensors/ProcessorAnalog.h @@ -199,7 +199,8 @@ class ProcessorAnalogBase : public AnalogVoltageBase { * ProcessorAnalog does not support differential measurements, so this * always returns false. * - * @param resultValue Reference to store the resulting voltage measurement + * @param resultValue Reference to store the resulting voltage measurement. + * This will be set to -9999.0 to indicate an invalid reading. * @return Always false (differential not supported) */ bool readVoltageDifferential(float& resultValue) override; diff --git a/src/sensors/TIADS1x15.cpp b/src/sensors/TIADS1x15.cpp index c64d68a59..8aff6125a 100644 --- a/src/sensors/TIADS1x15.cpp +++ b/src/sensors/TIADS1x15.cpp @@ -56,8 +56,8 @@ TIADS1x15Base::TIADS1x15Base(uint8_t adsChannel1, uint8_t adsChannel2, } else if (_supplyVoltage > 5.5f) { _supplyVoltage = 5.5f; } - // NOTE: We DO NOT clamp orvalidate the channel numbers and pairings in this - // constructor! We CANNOT print a warning here about invalid channel + // NOTE: We DO NOT clamp or validate the channel numbers and pairings in + // this constructor! We CANNOT print a warning here about invalid channel // because the Serial object may not be initialized yet, and we don't want // to cause a crash. The readVoltageSingleEnded and readVoltageDifferential // functions will handle validation and return false if the channel diff --git a/src/sensors/TurnerTurbidityPlus.h b/src/sensors/TurnerTurbidityPlus.h index 5fbe88084..e114c2baa 100644 --- a/src/sensors/TurnerTurbidityPlus.h +++ b/src/sensors/TurnerTurbidityPlus.h @@ -245,8 +245,8 @@ class TurnerTurbidityPlus : public TIADS1x15 { TurnerTurbidityPlus(int8_t powerPin, int8_t wiperTriggerPin, tiads1x15_adsDiffMux_t adsDiffMux, float conc_std, float volt_std, float volt_blank, - uint8_t i2cAddress = ADS1115_ADDRESS, - adsGain_t PGA_gain = GAIN_ONE, + uint8_t i2cAddress = MS_DEFAULT_ADS1X15_ADDRESS, + adsGain_t PGA_gain = GAIN_ONE, uint8_t measurementsToAverage = 1, float voltageDividerFactor = 1); /** From e5f29063b2320c40e858dcca64629b75afa143e1 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Tue, 24 Feb 2026 10:25:53 -0500 Subject: [PATCH 284/533] Moved analog channels from a class param to fxn param Signed-off-by: Sara Damiano --- src/sensors/AnalogVoltageBase.h | 53 +++++----------- src/sensors/ProcessorAnalog.cpp | 32 +++++----- src/sensors/ProcessorAnalog.h | 19 +++--- src/sensors/TIADS1x15.cpp | 108 +++++++++++++------------------- src/sensors/TIADS1x15.h | 85 ++++++++++++------------- 5 files changed, 125 insertions(+), 172 deletions(-) diff --git a/src/sensors/AnalogVoltageBase.h b/src/sensors/AnalogVoltageBase.h index f78fe6cb9..253096db7 100644 --- a/src/sensors/AnalogVoltageBase.h +++ b/src/sensors/AnalogVoltageBase.h @@ -40,19 +40,13 @@ class AnalogVoltageBase { /** * @brief Construct a new AnalogVoltageBase object * - * @param analogChannel The analog channel/pin for voltage readings * @param voltageMultiplier The voltage multiplier for any voltage dividers * @param supplyVoltage The supply/operating voltage for the analog system - * @param analogDifferentialChannel The second channel for differential - * measurements (-1 if not used) */ - AnalogVoltageBase(int8_t analogChannel, float voltageMultiplier = 1.0, - float supplyVoltage = OPERATING_VOLTAGE, - int8_t analogDifferentialChannel = -1) - : _analogChannel(analogChannel), - _voltageMultiplier(voltageMultiplier), - _supplyVoltage(supplyVoltage), - _analogDifferentialChannel(analogDifferentialChannel) {} + AnalogVoltageBase(float voltageMultiplier = 1.0, + float supplyVoltage = OPERATING_VOLTAGE) + : _voltageMultiplier(voltageMultiplier), + _supplyVoltage(supplyVoltage) {} /** * @brief Destroy the AnalogVoltageBase object @@ -95,26 +89,18 @@ class AnalogVoltageBase { return _supplyVoltage; } - /** - * @brief Check if this instance is configured for differential measurements - * - * @return True if both analog channels are valid pins (>=0) for - * differential measurements - */ - bool isDifferential(void) const { - return (_analogChannel >= 0 && _analogDifferentialChannel >= 0); - } - /** * @brief Read a single-ended voltage measurement * * This pure virtual function must be implemented by derived classes to * provide their specific method of reading analog voltages. * + * @param analogChannel The analog channel/pin for voltage readings * @param resultValue Reference to store the resulting voltage measurement * @return True if the voltage reading was successful and within valid range */ - virtual bool readVoltageSingleEnded(float& resultValue) = 0; + virtual bool readVoltageSingleEnded(int8_t analogChannel, + float& resultValue) = 0; /** * @brief Read a differential voltage measurement @@ -125,10 +111,16 @@ class AnalogVoltageBase { * If the sensor does not support differential measurements, this function * should set the resultValue to -9999.0 and return false. * + * @param analogChannel The primary analog channel for differential + * measurement + * @param analogReferenceChannel The secondary (reference) analog channel + * for differential measurement * @param resultValue Reference to store the resulting voltage measurement * @return True if the voltage reading was successful and within valid range */ - virtual bool readVoltageDifferential(float& resultValue) = 0; + virtual bool readVoltageDifferential(int8_t analogChannel, + int8_t analogReferenceChannel, + float& resultValue) = 0; /** * @brief Get the sensor location string @@ -141,14 +133,6 @@ class AnalogVoltageBase { virtual String getSensorLocation(void) = 0; protected: - /** - * @brief Internal reference to the analog channel/pin - * - * For TIADS1x15: ADS channel (0-3) - * For ProcessorAnalog: processor ADC pin number - */ - int8_t _analogChannel; - /** * @brief Internal reference to the voltage multiplier * @@ -163,15 +147,6 @@ class AnalogVoltageBase { * For ProcessorAnalog: the processor operating voltage */ float _supplyVoltage; - - /** - * @brief Internal reference to the second analog channel for differential - * measurements - * - * For TIADS1x15: second ADS channel for differential readings (-1 if not - * used) For ProcessorAnalog: not used (-1) - */ - int8_t _analogDifferentialChannel; }; #endif // SRC_SENSORS_ANALOGVOLTAGEBASE_H_ diff --git a/src/sensors/ProcessorAnalog.cpp b/src/sensors/ProcessorAnalog.cpp index e7686c38d..e4e8d6639 100644 --- a/src/sensors/ProcessorAnalog.cpp +++ b/src/sensors/ProcessorAnalog.cpp @@ -16,35 +16,35 @@ // ProcessorAnalogBase Constructor // ============================================================================ -ProcessorAnalogBase::ProcessorAnalogBase(int8_t dataPin, - float voltageMultiplier, - float operatingVoltage) - : AnalogVoltageBase(dataPin, voltageMultiplier, operatingVoltage, -1) {} +ProcessorAnalogBase::ProcessorAnalogBase(float voltageMultiplier, + float operatingVoltage) + : AnalogVoltageBase(voltageMultiplier, operatingVoltage) {} // ============================================================================ // ProcessorAnalogBase Functions // ============================================================================ -bool ProcessorAnalogBase::readVoltageSingleEnded(float& resultValue) { +bool ProcessorAnalogBase::readVoltageSingleEnded(int8_t analogChannel, + float& resultValue) { // Validate parameters if (PROCESSOR_ADC_MAX <= 0) { MS_DBG(F("Processor ADC max value is not set or invalid!")); return false; } - if (_analogChannel < 0 || _supplyVoltage <= 0 || _voltageMultiplier <= 0) { + if (analogChannel < 0 || _supplyVoltage <= 0 || _voltageMultiplier <= 0) { MS_DBG(F("Missing one or more required parameters: analog pin, " "operating voltage, or voltage divider!")); return false; } // Get the analog voltage - MS_DBG(F("Getting analog voltage from pin"), _analogChannel); - pinMode(_analogChannel, INPUT); - analogRead(_analogChannel); // priming reading + MS_DBG(F("Getting analog voltage from pin"), analogChannel); + pinMode(analogChannel, INPUT); + analogRead(analogChannel); // priming reading // The return value from analogRead() is IN BITS NOT IN VOLTS!! - analogRead(_analogChannel); // another priming reading - float rawAnalog = analogRead(_analogChannel); + analogRead(analogChannel); // another priming reading + float rawAnalog = analogRead(analogChannel); MS_DBG(F("Raw analog pin reading in bits:"), rawAnalog); // convert bits to volts @@ -58,12 +58,12 @@ bool ProcessorAnalogBase::readVoltageSingleEnded(float& resultValue) { } String ProcessorAnalogBase::getSensorLocation(void) { - String sensorLocation = F("ProcessorAnalog_Pin"); - sensorLocation += String(static_cast(_analogChannel)); + String sensorLocation = F("ProcessorAnalog"); return sensorLocation; } -bool ProcessorAnalogBase::readVoltageDifferential(float& resultValue) { +bool ProcessorAnalogBase::readVoltageDifferential(int8_t, int8_t, + float& resultValue) { // ProcessorAnalog does not support differential measurements resultValue = -9999.0; return false; @@ -84,7 +84,7 @@ ProcessorAnalog::ProcessorAnalog(int8_t powerPin, int8_t dataPin, PROCESSOR_ANALOG_STABILIZATION_TIME_MS, PROCESSOR_ANALOG_MEASUREMENT_TIME_MS, powerPin, dataPin, measurementsToAverage, PROCESSOR_ANALOG_INC_CALC_VARIABLES), - ProcessorAnalogBase(dataPin, voltageMultiplier, operatingVoltage) {} + ProcessorAnalogBase(voltageMultiplier, operatingVoltage) {} // Destructor ProcessorAnalog::~ProcessorAnalog() {} @@ -98,7 +98,7 @@ bool ProcessorAnalog::addSingleMeasurementResult(void) { MS_DBG(getSensorNameAndLocation(), F("is reporting:")); float resultValue = -9999; - bool success = readVoltageSingleEnded(resultValue); + bool success = readVoltageSingleEnded(_dataPin, resultValue); if (success) { verifyAndAddMeasurementResult(PROCESSOR_ANALOG_VAR_NUM, resultValue); diff --git a/src/sensors/ProcessorAnalog.h b/src/sensors/ProcessorAnalog.h index d064cf0fe..a1c7b2fc7 100644 --- a/src/sensors/ProcessorAnalog.h +++ b/src/sensors/ProcessorAnalog.h @@ -168,17 +168,14 @@ class ProcessorAnalogBase : public AnalogVoltageBase { /** * @brief Construct a new ProcessorAnalogBase object * - * @param dataPin The processor ADC pin used to read the target voltage. Not - * all processor pins can be used as analog pins. Those usable as analog - * pins generally are numbered with an "A" in front of the number - ie, A1. * @param voltageMultiplier Any multiplier needed to convert raw battery * readings from `analogRead()` into true battery values based on any * resistors or voltage dividers * @param operatingVoltage The processor's operating voltage; most * likely 3.3 or 5. */ - explicit ProcessorAnalogBase(int8_t dataPin, float voltageMultiplier = 1.0, - float operatingVoltage = OPERATING_VOLTAGE); + explicit ProcessorAnalogBase(float voltageMultiplier = 1.0, + float operatingVoltage = OPERATING_VOLTAGE); /** * @brief Destroy the ProcessorAnalogBase object @@ -188,10 +185,13 @@ class ProcessorAnalogBase : public AnalogVoltageBase { /** * @brief Read a single-ended voltage measurement from the processor ADC * + * @param analogChannel The processor ADC pin used to read the target + * voltage * @param resultValue Reference to store the resulting voltage measurement * @return True if the voltage reading was successful */ - bool readVoltageSingleEnded(float& resultValue) override; + bool readVoltageSingleEnded(int8_t analogChannel, + float& resultValue) override; /** * @brief Read a differential voltage measurement from the processor ADC @@ -199,11 +199,16 @@ class ProcessorAnalogBase : public AnalogVoltageBase { * ProcessorAnalog does not support differential measurements, so this * always returns false. * + * @param analogChannel The primary analog channel (ignored) + * @param analogReferenceChannel The secondary (reference) analog channel + * (ignored) * @param resultValue Reference to store the resulting voltage measurement. * This will be set to -9999.0 to indicate an invalid reading. * @return Always false (differential not supported) */ - bool readVoltageDifferential(float& resultValue) override; + bool readVoltageDifferential(int8_t analogChannel, + int8_t analogReferenceChannel, + float& resultValue) override; /** * @brief Get the sensor location string diff --git a/src/sensors/TIADS1x15.cpp b/src/sensors/TIADS1x15.cpp index 8aff6125a..f4da0389e 100644 --- a/src/sensors/TIADS1x15.cpp +++ b/src/sensors/TIADS1x15.cpp @@ -19,34 +19,10 @@ // TIADS1x15Base Constructors // ============================================================================ -// Constructor for single-ended measurements -TIADS1x15Base::TIADS1x15Base(uint8_t adsChannel, float voltageMultiplier, - adsGain_t adsGain, uint8_t i2cAddress, - float adsSupplyVoltage) - : AnalogVoltageBase(adsChannel, voltageMultiplier, adsSupplyVoltage, -1), - _adsGain(adsGain), - _i2cAddress(i2cAddress) { - // Clamp supply voltage to valid ADS1x15 range: 0.0V to 5.5V per datasheet - // This clamp is done silently! - if (_supplyVoltage < 0.0f) { - _supplyVoltage = 0.0f; - } else if (_supplyVoltage > 5.5f) { - _supplyVoltage = 5.5f; - } - // NOTE: We DO NOT clamp or validate the channel numbers in this - // constructor! We CANNOT print a warning here about invalid channel - // because the Serial object may not be initialized yet, and we don't want - // to cause a crash. The readVoltageSingleEnded and readVoltageDifferential - // functions will handle validation and return false if the channel - // configuration is invalid, but we can't do that here in the constructor -} - -// Constructor for differential measurements -TIADS1x15Base::TIADS1x15Base(uint8_t adsChannel1, uint8_t adsChannel2, - float voltageMultiplier, adsGain_t adsGain, +// Constructor +TIADS1x15Base::TIADS1x15Base(float voltageMultiplier, adsGain_t adsGain, uint8_t i2cAddress, float adsSupplyVoltage) - : AnalogVoltageBase(adsChannel1, voltageMultiplier, adsSupplyVoltage, - adsChannel2), + : AnalogVoltageBase(voltageMultiplier, adsSupplyVoltage), _adsGain(adsGain), _i2cAddress(i2cAddress) { // Clamp supply voltage to valid ADS1x15 range: 0.0V to 5.5V per datasheet @@ -56,12 +32,6 @@ TIADS1x15Base::TIADS1x15Base(uint8_t adsChannel1, uint8_t adsChannel2, } else if (_supplyVoltage > 5.5f) { _supplyVoltage = 5.5f; } - // NOTE: We DO NOT clamp or validate the channel numbers and pairings in - // this constructor! We CANNOT print a warning here about invalid channel - // because the Serial object may not be initialized yet, and we don't want - // to cause a crash. The readVoltageSingleEnded and readVoltageDifferential - // functions will handle validation and return false if the channel - // configuration is invalid, but we can't do that here in the constructor } @@ -76,19 +46,11 @@ String TIADS1x15Base::getSensorLocation(void) { String sensorLocation = F("ADS1015_0x"); #endif sensorLocation += String(_i2cAddress, HEX); - if (isDifferential()) { - sensorLocation += F("_Diff"); - sensorLocation += String(_analogChannel); - sensorLocation += F("_"); - sensorLocation += String(_analogDifferentialChannel); - } else { - sensorLocation += F("_Channel"); - sensorLocation += String(_analogChannel); - } return sensorLocation; } -bool TIADS1x15Base::readVoltageSingleEnded(float& resultValue) { +bool TIADS1x15Base::readVoltageSingleEnded(int8_t analogChannel, + float& resultValue) { bool success = false; int16_t adcCounts = -9999; float adcVoltage = -9999; @@ -123,17 +85,17 @@ bool TIADS1x15Base::readVoltageSingleEnded(float& resultValue) { // Read Analog to Digital Converter (ADC) // Validate ADS1x15 channel range for single-ended measurements - if (_analogChannel > 3) { - MS_DBG(F(" Invalid ADS1x15 channel "), _analogChannel, + if (analogChannel > 3) { + MS_DBG(F(" Invalid ADS1x15 channel "), analogChannel, F(", valid range is 0-3")); return false; } // Taking this reading includes the 8ms conversion delay. // Measure the ADC raw count - adcCounts = ads.readADC_SingleEnded(_analogChannel); + adcCounts = ads.readADC_SingleEnded(analogChannel); // Convert ADC raw counts value to voltage (V) adcVoltage = ads.computeVolts(adcCounts); - MS_DBG(F(" ads.readADC_SingleEnded("), _analogChannel, F("):"), adcCounts, + MS_DBG(F(" ads.readADC_SingleEnded("), analogChannel, F("):"), adcCounts, F(" voltage:"), adcVoltage); // Verify the range based on the actual power supplied to the ADS. // Valid range is approximately -0.3V to (supply voltage + 0.3V) with @@ -162,7 +124,9 @@ bool TIADS1x15Base::readVoltageSingleEnded(float& resultValue) { return success; } -bool TIADS1x15Base::readVoltageDifferential(float& resultValue) { +bool TIADS1x15Base::readVoltageDifferential(int8_t analogChannel, + int8_t analogReferenceChannel, + float& resultValue) { bool success = false; int16_t adcCounts = -9999; float adcVoltage = -9999; @@ -185,9 +149,9 @@ bool TIADS1x15Base::readVoltageDifferential(float& resultValue) { } // Validate differential channel combination - if (!isValidDifferentialPair(_analogChannel, _analogDifferentialChannel)) { - MS_DBG(F(" Invalid differential channel pair: "), _analogChannel, - F("-"), _analogDifferentialChannel); + if (!isValidDifferentialPair(analogChannel, analogReferenceChannel)) { + MS_DBG(F(" Invalid differential channel pair: "), analogChannel, + F("-"), analogReferenceChannel); return false; } @@ -195,17 +159,17 @@ bool TIADS1x15Base::readVoltageDifferential(float& resultValue) { // NOTE: Only canonical ordered pairs are supported (lower channel number // first) to ensure consistent polarity. Pairs like (1,0) are NOT supported // - use (0,1) instead. - if (_analogChannel == 0 && _analogDifferentialChannel == 1) { + if (analogChannel == 0 && analogReferenceChannel == 1) { adcCounts = ads.readADC_Differential_0_1(); - } else if (_analogChannel == 0 && _analogDifferentialChannel == 3) { + } else if (analogChannel == 0 && analogReferenceChannel == 3) { adcCounts = ads.readADC_Differential_0_3(); - } else if (_analogChannel == 1 && _analogDifferentialChannel == 3) { + } else if (analogChannel == 1 && analogReferenceChannel == 3) { adcCounts = ads.readADC_Differential_1_3(); - } else if (_analogChannel == 2 && _analogDifferentialChannel == 3) { + } else if (analogChannel == 2 && analogReferenceChannel == 3) { adcCounts = ads.readADC_Differential_2_3(); } else { MS_DBG(F(" Unsupported differential channel combination: "), - _analogChannel, F("-"), _analogDifferentialChannel); + analogChannel, F("-"), analogReferenceChannel); MS_DBG(F(" Use canonical ordered pairs: 0-1, 0-3, 1-3, or 2-3")); return false; } @@ -279,7 +243,7 @@ adsGain_t TIADS1x15Base::getADSGain(void) const { // The constructor - need the power pin the data pin, and voltage multiplier if // non standard -TIADS1x15::TIADS1x15(int8_t powerPin, uint8_t adsChannel, +TIADS1x15::TIADS1x15(int8_t powerPin, int8_t adsChannel, float voltageMultiplier, adsGain_t adsGain, uint8_t i2cAddress, uint8_t measurementsToAverage, float adsSupplyVoltage) @@ -287,8 +251,8 @@ TIADS1x15::TIADS1x15(int8_t powerPin, uint8_t adsChannel, TIADS1X15_STABILIZATION_TIME_MS, TIADS1X15_MEASUREMENT_TIME_MS, powerPin, adsChannel, measurementsToAverage, TIADS1X15_INC_CALC_VARIABLES), - TIADS1x15Base(adsChannel, voltageMultiplier, adsGain, i2cAddress, - adsSupplyVoltage) { + TIADS1x15Base(voltageMultiplier, adsGain, i2cAddress, adsSupplyVoltage), + _adsDifferentialChannel(-1) { // NOTE: We DO NOT validate the channel numbers in this constructor! We // CANNOT print a warning here about invalid channel because the Serial // object may not be initialized yet, and we don't want to cause a crash. @@ -298,15 +262,16 @@ TIADS1x15::TIADS1x15(int8_t powerPin, uint8_t adsChannel, } // Constructor for differential measurements -TIADS1x15::TIADS1x15(int8_t powerPin, uint8_t adsChannel1, uint8_t adsChannel2, +TIADS1x15::TIADS1x15(int8_t powerPin, int8_t adsChannel1, uint8_t adsChannel2, float voltageMultiplier, adsGain_t adsGain, uint8_t i2cAddress, uint8_t measurementsToAverage, float adsSupplyVoltage) : Sensor("TIADS1x15", TIADS1X15_NUM_VARIABLES, TIADS1X15_WARM_UP_TIME_MS, TIADS1X15_STABILIZATION_TIME_MS, TIADS1X15_MEASUREMENT_TIME_MS, - powerPin, -1, measurementsToAverage, TIADS1X15_INC_CALC_VARIABLES), - TIADS1x15Base(adsChannel1, adsChannel2, voltageMultiplier, adsGain, - i2cAddress, adsSupplyVoltage) { + powerPin, adsChannel1, measurementsToAverage, + TIADS1X15_INC_CALC_VARIABLES), + TIADS1x15Base(voltageMultiplier, adsGain, i2cAddress, adsSupplyVoltage), + _adsDifferentialChannel(adsChannel2) { // NOTE: We DO NOT validate the channel numbers and pairings in this // constructor! We CANNOT print a warning here about invalid channel // because the Serial object may not be initialized yet, and we don't want @@ -319,7 +284,17 @@ TIADS1x15::TIADS1x15(int8_t powerPin, uint8_t adsChannel1, uint8_t adsChannel2, TIADS1x15::~TIADS1x15() {} String TIADS1x15::getSensorLocation(void) { - return TIADS1x15Base::getSensorLocation(); + String sensorLocation = TIADS1x15Base::getSensorLocation(); + if (isDifferential()) { + sensorLocation += F("_Diff"); + sensorLocation += String(_dataPin); + sensorLocation += F("_"); + sensorLocation += String(_adsDifferentialChannel); + } else { + sensorLocation += F("_Channel"); + sensorLocation += String(_dataPin); + } + return sensorLocation; } bool TIADS1x15::addSingleMeasurementResult(void) { @@ -335,9 +310,10 @@ bool TIADS1x15::addSingleMeasurementResult(void) { // Use differential or single-ended reading based on configuration if (isDifferential()) { - success = readVoltageDifferential(resultValue); + success = readVoltageDifferential(_dataPin, _adsDifferentialChannel, + resultValue); } else { - success = readVoltageSingleEnded(resultValue); + success = readVoltageSingleEnded(_dataPin, resultValue); } if (success) { diff --git a/src/sensors/TIADS1x15.h b/src/sensors/TIADS1x15.h index b588fb5f2..fc7d30360 100644 --- a/src/sensors/TIADS1x15.h +++ b/src/sensors/TIADS1x15.h @@ -274,40 +274,14 @@ class TIADS1x15Base : public AnalogVoltageBase { public: /** - * @brief Construct a new TIADS1x15Base object for single-ended measurements + * @brief Construct a new TIADS1x15Base object * - * @param adsChannel The ADS channel of interest (0-3, physical channel - * only). * @param voltageMultiplier The voltage multiplier for any voltage dividers * @param adsGain The internal gain setting of the ADS1x15 * @param i2cAddress The I2C address of the ADS 1x15 * @param adsSupplyVoltage The power supply voltage for the ADS1x15 in volts - * - * @note adsChannel uses uint8_t to match Adafruit_ADS1X15 expectations. - * Negative sentinels are handled internally where needed. */ - explicit TIADS1x15Base(uint8_t adsChannel, float voltageMultiplier = 1.0, - adsGain_t adsGain = GAIN_ONE, - uint8_t i2cAddress = MS_DEFAULT_ADS1X15_ADDRESS, - float adsSupplyVoltage = OPERATING_VOLTAGE); - - /** - * @brief Construct a new TIADS1x15Base object for differential measurements - * - * @param adsChannel1 The first ADS channel for differential measurement - * (0-3, physical channel only) - * @param adsChannel2 The second ADS channel for differential measurement - * (0-3, physical channel only) - * @param voltageMultiplier The voltage multiplier for any voltage dividers - * @param adsGain The internal gain setting of the ADS1x15 - * @param i2cAddress The I2C address of the ADS 1x15 - * @param adsSupplyVoltage The power supply voltage for the ADS1x15 in volts - * - * @note Channel parameters use uint8_t to match Adafruit_ADS1X15 - * expectations. Negative sentinels are handled internally where needed. - */ - explicit TIADS1x15Base(uint8_t adsChannel1, uint8_t adsChannel2, - float voltageMultiplier = 1.0, + explicit TIADS1x15Base(float voltageMultiplier = 1.0, adsGain_t adsGain = GAIN_ONE, uint8_t i2cAddress = MS_DEFAULT_ADS1X15_ADDRESS, float adsSupplyVoltage = OPERATING_VOLTAGE); @@ -320,18 +294,27 @@ class TIADS1x15Base : public AnalogVoltageBase { /** * @brief Read a single-ended voltage measurement from the ADS1x15 * + * @param analogChannel The ADS channel of interest (0-3, physical channel + * only) * @param resultValue Reference to store the resulting voltage measurement * @return True if the voltage reading was successful */ - bool readVoltageSingleEnded(float& resultValue) override; + bool readVoltageSingleEnded(int8_t analogChannel, + float& resultValue) override; /** * @brief Read a differential voltage measurement from the ADS1x15 * + * @param analogChannel The first ADS channel for differential measurement + * (0-3, physical channel only) + * @param analogReferenceChannel The second (reference) ADS channel for + * differential measurement (0-3, physical channel only) * @param resultValue Reference to store the resulting voltage measurement * @return True if the voltage reading was successful and within valid range */ - bool readVoltageDifferential(float& resultValue) override; + bool readVoltageDifferential(int8_t analogChannel, + int8_t analogReferenceChannel, + float& resultValue) override; /** * @brief Get the sensor location string @@ -416,12 +399,8 @@ class TIADS1x15 : public Sensor, public TIADS1x15Base { * default value of 1. * @param adsSupplyVoltage The power supply voltage for the ADS1x15 in * volts; defaults to the processor operating voltage from KnownProcessors.h - * - * @note adsChannel uses uint8_t to match - * Adafruit_ADS1X15::readADC_SingleEnded(uint8_t) and avoid sign-extension - * issues. */ - TIADS1x15(int8_t powerPin, uint8_t adsChannel, float voltageMultiplier = 1, + TIADS1x15(int8_t powerPin, int8_t adsChannel, float voltageMultiplier = 1, adsGain_t adsGain = GAIN_ONE, uint8_t i2cAddress = MS_DEFAULT_ADS1X15_ADDRESS, uint8_t measurementsToAverage = 1, @@ -431,11 +410,11 @@ class TIADS1x15 : public Sensor, public TIADS1x15Base { * * @param powerPin The pin on the mcu controlling power to the sensor * Use -1 if it is continuously powered. - * @param adsChannel1 The first ADS channel for differential measurement - * (0-3, physical channel only) - * @param adsChannel2 The second ADS channel for differential measurement - * (0-3, physical channel only) Valid combinations are: 0-1, 0-3, 1-3, or - * 2-3 + * @param adsChannel1 The first (measurement) ADS channel for differential + * measurement (0-3, physical channel only) + * @param adsChannel2 The second (reference) ADS channel for differential + * measurement (0-3, physical channel only) Valid combinations are: 0-1, + * 0-3, 1-3, or 2-3 * @param voltageMultiplier The voltage multiplier, if a voltage divider is * used. * @param adsGain The internal gain setting of the ADS1x15; defaults to @@ -447,11 +426,8 @@ class TIADS1x15 : public Sensor, public TIADS1x15Base { * default value of 1. * @param adsSupplyVoltage The power supply voltage for the ADS1x15 in * volts; defaults to the processor operating voltage from KnownProcessors.h - * - * @note Channel parameters use uint8_t to match Adafruit_ADS1X15 - * expectations and avoid sign-extension issues. */ - TIADS1x15(int8_t powerPin, uint8_t adsChannel1, uint8_t adsChannel2, + TIADS1x15(int8_t powerPin, int8_t adsChannel1, uint8_t adsChannel2, float voltageMultiplier = 1, adsGain_t adsGain = GAIN_ONE, uint8_t i2cAddress = MS_DEFAULT_ADS1X15_ADDRESS, uint8_t measurementsToAverage = 1, @@ -472,6 +448,27 @@ class TIADS1x15 : public Sensor, public TIADS1x15Base { * range) */ void setSupplyVoltage(float supplyVoltage) override; + + protected: + /** + * @brief Internal reference to the secondary (reference) analog channel for + * differential measurements + * + * For single-ended measurements: -1 (not used) + * For differential measurements: the second ADS channel (0-3) + */ + int8_t _adsDifferentialChannel; + + /** + * @brief Helper function to check if this sensor is configured for + * differential measurements + * + * @return True if this sensor uses differential measurements, false for + * single-ended + */ + bool isDifferential() const { + return _adsDifferentialChannel != -1; + } }; /** From 492e3b5f7cffd871c8d819bce6810be06a97ad74 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Tue, 24 Feb 2026 10:38:57 -0500 Subject: [PATCH 285/533] Types and nitpicky stuff Signed-off-by: Sara Damiano --- src/ModSensorConfig.h | 7 +++---- src/sensors/AnalogVoltageBase.h | 7 ++++++- src/sensors/ProcessorAnalog.cpp | 5 +++-- src/sensors/ProcessorAnalog.h | 4 ++-- src/sensors/TIADS1x15.cpp | 2 +- src/sensors/TIADS1x15.h | 4 ++-- 6 files changed, 17 insertions(+), 12 deletions(-) diff --git a/src/ModSensorConfig.h b/src/ModSensorConfig.h index 941955608..979225923 100644 --- a/src/ModSensorConfig.h +++ b/src/ModSensorConfig.h @@ -228,13 +228,12 @@ #if !defined(MS_PROCESSOR_ADC_REFERENCE_MODE) #error The processor ADC reference type must be defined! #endif // MS_PROCESSOR_ADC_REFERENCE_MODE -#endif // ARDUINO_ARCH_SAMD +#endif // !defined(MS_PROCESSOR_ADC_REFERENCE_MODE) || defined(DOXYGEN) - -#ifndef MS_DEFAULT_ADS1X15_ADDRESS || defined(DOXYGEN) +#if !defined(MS_DEFAULT_ADS1X15_ADDRESS) || defined(DOXYGEN) /// @brief The assumed address of the ADS1115 or ADS1015, 1001 000 (ADDR = GND) #define MS_DEFAULT_ADS1X15_ADDRESS 0x48 -#endif +#endif // MS_DEFAULT_ADS1X15_ADDRESS //============================================================== diff --git a/src/sensors/AnalogVoltageBase.h b/src/sensors/AnalogVoltageBase.h index 253096db7..cc3df49cd 100644 --- a/src/sensors/AnalogVoltageBase.h +++ b/src/sensors/AnalogVoltageBase.h @@ -57,9 +57,14 @@ class AnalogVoltageBase { * @brief Set the voltage multiplier for voltage divider calculations * * @param voltageMultiplier The multiplier value for voltage scaling + * + * @note The multiplier must be positive (> 0). Values <= 0 will be + * automatically clamped to 0.001 to prevent division-by-zero errors + * and maintain valid voltage calculations. */ virtual void setVoltageMultiplier(float voltageMultiplier) { - _voltageMultiplier = voltageMultiplier; + // Clamp to minimum value to prevent division-by-zero and invalid readings + _voltageMultiplier = (voltageMultiplier > 0.0f) ? voltageMultiplier : 0.001f; } /** diff --git a/src/sensors/ProcessorAnalog.cpp b/src/sensors/ProcessorAnalog.cpp index e4e8d6639..46fda8976 100644 --- a/src/sensors/ProcessorAnalog.cpp +++ b/src/sensors/ProcessorAnalog.cpp @@ -62,8 +62,9 @@ String ProcessorAnalogBase::getSensorLocation(void) { return sensorLocation; } -bool ProcessorAnalogBase::readVoltageDifferential(int8_t, int8_t, - float& resultValue) { +bool ProcessorAnalogBase::readVoltageDifferential( + int8_t /*analogChannel*/, int8_t /*analogReferenceChannel*/, + float& resultValue) { // ProcessorAnalog does not support differential measurements resultValue = -9999.0; return false; diff --git a/src/sensors/ProcessorAnalog.h b/src/sensors/ProcessorAnalog.h index a1c7b2fc7..8cb62364b 100644 --- a/src/sensors/ProcessorAnalog.h +++ b/src/sensors/ProcessorAnalog.h @@ -206,8 +206,8 @@ class ProcessorAnalogBase : public AnalogVoltageBase { * This will be set to -9999.0 to indicate an invalid reading. * @return Always false (differential not supported) */ - bool readVoltageDifferential(int8_t analogChannel, - int8_t analogReferenceChannel, + bool readVoltageDifferential(int8_t /*analogChannel*/, + int8_t /*analogReferenceChannel*/, float& resultValue) override; /** diff --git a/src/sensors/TIADS1x15.cpp b/src/sensors/TIADS1x15.cpp index f4da0389e..0aceae200 100644 --- a/src/sensors/TIADS1x15.cpp +++ b/src/sensors/TIADS1x15.cpp @@ -262,7 +262,7 @@ TIADS1x15::TIADS1x15(int8_t powerPin, int8_t adsChannel, } // Constructor for differential measurements -TIADS1x15::TIADS1x15(int8_t powerPin, int8_t adsChannel1, uint8_t adsChannel2, +TIADS1x15::TIADS1x15(int8_t powerPin, int8_t adsChannel1, int8_t adsChannel2, float voltageMultiplier, adsGain_t adsGain, uint8_t i2cAddress, uint8_t measurementsToAverage, float adsSupplyVoltage) diff --git a/src/sensors/TIADS1x15.h b/src/sensors/TIADS1x15.h index fc7d30360..c6cf26c58 100644 --- a/src/sensors/TIADS1x15.h +++ b/src/sensors/TIADS1x15.h @@ -427,7 +427,7 @@ class TIADS1x15 : public Sensor, public TIADS1x15Base { * @param adsSupplyVoltage The power supply voltage for the ADS1x15 in * volts; defaults to the processor operating voltage from KnownProcessors.h */ - TIADS1x15(int8_t powerPin, int8_t adsChannel1, uint8_t adsChannel2, + TIADS1x15(int8_t powerPin, int8_t adsChannel1, int8_t adsChannel2, float voltageMultiplier = 1, adsGain_t adsGain = GAIN_ONE, uint8_t i2cAddress = MS_DEFAULT_ADS1X15_ADDRESS, uint8_t measurementsToAverage = 1, @@ -457,7 +457,7 @@ class TIADS1x15 : public Sensor, public TIADS1x15Base { * For single-ended measurements: -1 (not used) * For differential measurements: the second ADS channel (0-3) */ - int8_t _adsDifferentialChannel; + int8_t _adsDifferentialChannel = -1; /** * @brief Helper function to check if this sensor is configured for From c8f915f322f3ca9c6e6c03520348a88fa34e41e3 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Tue, 24 Feb 2026 10:54:43 -0500 Subject: [PATCH 286/533] Revert a bunch of subclass changes while I think about them Signed-off-by: Sara Damiano --- examples/menu_a_la_carte/menu_a_la_carte.ino | 6 +- src/sensors/AlphasenseCO2.cpp | 123 ++++++++++++----- src/sensors/AlphasenseCO2.h | 31 ++++- src/sensors/CampbellOBS3.cpp | 132 ++++++++---------- src/sensors/CampbellOBS3.h | 63 ++------- src/sensors/TurnerCyclops.cpp | 137 +++++++++---------- src/sensors/TurnerCyclops.h | 63 ++------- src/sensors/TurnerTurbidityPlus.cpp | 133 +++++++++++++----- src/sensors/TurnerTurbidityPlus.h | 55 +++++++- 9 files changed, 408 insertions(+), 335 deletions(-) diff --git a/examples/menu_a_la_carte/menu_a_la_carte.ino b/examples/menu_a_la_carte/menu_a_la_carte.ino index 250f0bb94..c2fbe8e2d 100644 --- a/examples/menu_a_la_carte/menu_a_la_carte.ino +++ b/examples/menu_a_la_carte/menu_a_la_carte.ino @@ -1001,8 +1001,8 @@ Variable* ds3231Temp = // NOTE: Use -1 for any pins that don't apply or aren't being used. const int8_t AlphasenseCO2Power = sensorPowerPin; // Power pin -tiads1x15_adsDiffMux_t AlphasenseDiffMux = - tiads1x15_adsDiffMux_t::TIADS1X15_DIFF_MUX_2_3; // Differential voltage config +aco2_adsDiffMux_t AlphasenseDiffMux = + DIFF_MUX_2_3; // Differential voltage config const uint8_t AlphasenseCO2ADSi2c_addr = 0x48; // The I2C address of the ADS1115 ADC @@ -2301,7 +2301,7 @@ Variable* cyclopsRedChloro = new TurnerCyclops_RedChlorophyll( const int8_t turbidityPlusPower = sensorPowerPin; // Power pin const int8_t turbidityPlusWiper = relayPowerPin; // Wiper pin ttp_adsDiffMux_t turbidityPlusDiffMux = - tiads1x15_adsDiffMux_t::TIADS1X15_DIFF_MUX_2_3; // Differential voltage config + DIFF_MUX_2_3; // Differential voltage config const uint8_t turbidityPlusNumberReadings = 10; const uint8_t turbidityPlusADSi2c_addr = 0x48; // The I2C address of the ADS1115 ADC diff --git a/src/sensors/AlphasenseCO2.cpp b/src/sensors/AlphasenseCO2.cpp index 74a26a583..2bdcc89f1 100644 --- a/src/sensors/AlphasenseCO2.cpp +++ b/src/sensors/AlphasenseCO2.cpp @@ -12,32 +12,33 @@ #include "AlphasenseCO2.h" -#include "TIADS1x15.h" +#include -// The constructor - need the power pin and the differential mux configuration -AlphasenseCO2::AlphasenseCO2(int8_t powerPin, tiads1x15_adsDiffMux_t adsDiffMux, +// The constructor - need the power pin and the data pin +AlphasenseCO2::AlphasenseCO2(int8_t powerPin, aco2_adsDiffMux_t adsDiffMux, uint8_t i2cAddress, uint8_t measurementsToAverage) - : TIADS1x15(powerPin, adsDiffMux, ALPHASENSE_CO2_VOLTAGE_MULTIPLIER, - GAIN_ONE, i2cAddress, measurementsToAverage) { - // Override timing settings for Alphasense CO2-specific requirements - _warmUpTime_ms = ALPHASENSE_CO2_WARM_UP_TIME_MS; - _stabilizationTime_ms = ALPHASENSE_CO2_STABILIZATION_TIME_MS; - _measurementTime_ms = ALPHASENSE_CO2_MEASUREMENT_TIME_MS; - // Override variable counts from parent class defaults - _numReturnedValues = ALPHASENSE_CO2_NUM_VARIABLES; - _incCalcValues = ALPHASENSE_CO2_INC_CALC_VARIABLES; - // Set the sensor name - _sensorName = "AlphasenseCO2"; -} + : Sensor("AlphasenseCO2", ALPHASENSE_CO2_NUM_VARIABLES, + ALPHASENSE_CO2_WARM_UP_TIME_MS, + ALPHASENSE_CO2_STABILIZATION_TIME_MS, + ALPHASENSE_CO2_MEASUREMENT_TIME_MS, powerPin, -1, + measurementsToAverage, ALPHASENSE_CO2_INC_CALC_VARIABLES), + _adsDiffMux(adsDiffMux), + _i2cAddress(i2cAddress) {} + // Destructor AlphasenseCO2::~AlphasenseCO2() {} String AlphasenseCO2::getSensorLocation(void) { - // Use TIADS1x15's location with Alphasense CO2-specific identifier - String sensorLocation = TIADS1x15::getSensorLocation(); - sensorLocation += F("_AlphasenseCO2"); +#ifndef MS_USE_ADS1015 + String sensorLocation = F("ADS1115_0x"); +#else + String sensorLocation = F("ADS1015_0x"); +#endif + sensorLocation += String(_i2cAddress, HEX); + sensorLocation += F("_adsDiffMux"); + sensorLocation += String(_adsDiffMux); return sensorLocation; } @@ -48,22 +49,82 @@ bool AlphasenseCO2::addSingleMeasurementResult(void) { return bumpMeasurementAttemptCount(false); } - bool success = false; - float adcVoltage = -9999; - float co2Current = -9999; - float calibResult = -9999; + bool success = false; + int16_t adcCounts = -9999; + float adcVoltage = -9999; + float co2Current = -9999; + float calibResult = -9999; MS_DBG(getSensorNameAndLocation(), F("is reporting:")); - // Use the TIADS1x15 differential voltage reading function - // The voltage multiplier and gain settings are handled by the parent class - if (readVoltageDifferential(adcVoltage)) { - MS_DBG(F(" Differential voltage:"), String(adcVoltage, 3), F("V")); - // Convert voltage to current (mA) - using series sense resistor +// Create an auxiliary ADD object +// We create and set up the ADC object here so that each sensor using the ADC +// may set the gain appropriately without effecting others. +#ifndef MS_USE_ADS1015 + Adafruit_ADS1115 ads; // Use this for the 16-bit version +#else + Adafruit_ADS1015 ads; // Use this for the 12-bit version +#endif + // ADS Library default settings: + // - TI ADS1115 (16 bit) + // - single-shot mode (powers down between conversions) + // - 128 samples per second (8ms conversion time) + // - 2/3 gain +/- 6.144V range (limited to VDD +0.3V max) + // - TI ADS1015 (12 bit) + // - single-shot mode (powers down between conversions) + // - 1600 samples per second (625µs conversion time) + // - 2/3 gain +/- 6.144V range (limited to VDD +0.3V max) + + // Bump the gain up to 1x = +/- 4.096V range + // Sensor return range is 0-2.5V, but the next gain option is 2x which + // only allows up to 2.048V + ads.setGain(GAIN_ONE); + // Begin ADC, returns true if anything was detected at the address + if (!ads.begin(_i2cAddress)) { + MS_DBG(F(" ADC initialization failed at 0x"), + String(_i2cAddress, HEX)); + return bumpMeasurementAttemptCount(false); + } + + // Read Analog to Digital Converter (ADC) + // Taking this reading includes the 8ms conversion delay. + // Measure the voltage differential across the two voltage pins + switch (_adsDiffMux) { + case DIFF_MUX_0_1: { + adcCounts = ads.readADC_Differential_0_1(); + break; + } + case DIFF_MUX_0_3: { + adcCounts = ads.readADC_Differential_0_3(); + break; + } + case DIFF_MUX_1_3: { + adcCounts = ads.readADC_Differential_1_3(); + break; + } + case DIFF_MUX_2_3: { + adcCounts = ads.readADC_Differential_2_3(); + break; + } + default: { + MS_DBG(F(" Invalid differential mux configuration")); + return bumpMeasurementAttemptCount(false); + } + } + // Convert ADC counts value to voltage (V) + adcVoltage = ads.computeVolts(adcCounts); + MS_DBG(F(" ads.readADC_Differential("), _adsDiffMux, F("):"), adcCounts, + '=', String(adcVoltage, 3)); + + // @todo Verify the voltage range for the CO2 sensor + // Here we are using the range of the ADS when it is powered at 3.3V + if (adcVoltage < 3.6 && adcVoltage > -0.3) { + // Convert voltage to current (mA) - assuming a 250 Ohm resistor is in + // series co2Current = (adcVoltage / ALPHASENSE_CO2_SENSE_RESISTOR_OHM) * 1000; - MS_DBG(F(" co2Current:"), - co2Current); // Convert current to ppm (using a formula - // recommended by the sensor + MS_DBG(F(" co2Current:"), co2Current); + + // Convert current to ppm (using a formula recommended by the sensor // manufacturer) calibResult = ALPHASENSE_CO2_MFG_SCALE * co2Current - ALPHASENSE_CO2_MFG_OFFSET; @@ -72,8 +133,6 @@ bool AlphasenseCO2::addSingleMeasurementResult(void) { verifyAndAddMeasurementResult(ALPHASENSE_CO2_VOLTAGE_VAR_NUM, adcVoltage); success = true; - } else { - MS_DBG(F(" Failed to read differential voltage")); } // Return success value when finished diff --git a/src/sensors/AlphasenseCO2.h b/src/sensors/AlphasenseCO2.h index 270dc3c07..a3c3bf860 100644 --- a/src/sensors/AlphasenseCO2.h +++ b/src/sensors/AlphasenseCO2.h @@ -97,8 +97,7 @@ // Include other in-library and external dependencies #include "VariableBase.h" -#include "TIADS1x15.h" -#include +#include "SensorBase.h" /** @ingroup sensor_alphasense_co2 */ /**@{*/ @@ -149,6 +148,16 @@ #endif /**@}*/ +/** + * @brief Enum for the pins used for differential voltages. + */ +typedef enum : uint16_t { + DIFF_MUX_0_1, ///< differential across pins 0 and 1 + DIFF_MUX_0_3, ///< differential across pins 0 and 3 + DIFF_MUX_1_3, ///< differential across pins 1 and 3 + DIFF_MUX_2_3 ///< differential across pins 2 and 3 +} aco2_adsDiffMux_t; + /** * @anchor sensor_alphasense_co2_timing * @name Sensor Timing @@ -259,7 +268,7 @@ * * @ingroup sensor_alphasense_co2 */ -class AlphasenseCO2 : public TIADS1x15 { +class AlphasenseCO2 : public Sensor { public: /** * @brief Construct a new Alphasense IRC-A1 CO2 object - need the power pin @@ -275,7 +284,7 @@ class AlphasenseCO2 : public TIADS1x15 { * - The Alphasense CO2 sensor requires 2-5 V DC; current draw 20-60 mA * - The ADS1115 requires 2.0-5.5V but is assumed to be powered at 3.3V * @param adsDiffMux Which two pins _on the TI ADS1115_ that will measure - * differential voltage. See tiads1x15_adsDiffMux_t. + * differential voltage. See #aco2_adsDiffMux_t. * @param i2cAddress The I2C address of the ADS 1x15, default is 0x48 (ADDR * = GND) * @param measurementsToAverage The number of measurements to take and @@ -285,8 +294,8 @@ class AlphasenseCO2 : public TIADS1x15 { * its power controlled by the same pin as the Alphasense CO2 sensor. This * library does not support any other configuration. */ - AlphasenseCO2(int8_t powerPin, tiads1x15_adsDiffMux_t adsDiffMux = tiads1x15_adsDiffMux_t::TIADS1X15_DIFF_MUX_2_3, - uint8_t i2cAddress = ADS1115_ADDRESS, + AlphasenseCO2(int8_t powerPin, aco2_adsDiffMux_t adsDiffMux = DIFF_MUX_2_3, + uint8_t i2cAddress = MS_DEFAULT_ADS1X15_ADDRESS, uint8_t measurementsToAverage = 7); /** * @brief Destroy the AlphasenseCO2 object - no action needed @@ -304,7 +313,15 @@ class AlphasenseCO2 : public TIADS1x15 { bool addSingleMeasurementResult(void) override; private: - // All differential mux and I2C address functionality is now handled by the parent TIADS1x15 class + /** + * @brief Which two pins _on the TI ADS1115_ that will measure differential + * voltage from the Turbidity Plus. See #aco2_adsDiffMux_t + */ + aco2_adsDiffMux_t _adsDiffMux; + /** + * @brief Internal reference to the I2C address of the TI-ADS1x15 + */ + uint8_t _i2cAddress; }; diff --git a/src/sensors/CampbellOBS3.cpp b/src/sensors/CampbellOBS3.cpp index b0ada54f7..ff98ce8af 100644 --- a/src/sensors/CampbellOBS3.cpp +++ b/src/sensors/CampbellOBS3.cpp @@ -10,79 +10,35 @@ #include "CampbellOBS3.h" -#include "TIADS1x15.h" -#include "ProcessorAnalog.h" +#include -// Primary constructor using AnalogVoltageBase abstraction -CampbellOBS3::CampbellOBS3(int8_t powerPin, - AnalogVoltageBase* analogVoltageReader, - float x2_coeff_A, float x1_coeff_B, float x0_coeff_C, - uint8_t measurementsToAverage) - : Sensor("CampbellOBS3", OBS3_NUM_VARIABLES, OBS3_WARM_UP_TIME_MS, - OBS3_STABILIZATION_TIME_MS, OBS3_MEASUREMENT_TIME_MS, powerPin, -1, - measurementsToAverage, OBS3_INC_CALC_VARIABLES), - _analogVoltageReader(analogVoltageReader), - _ownsVoltageReader(false), - _x2_coeff_A(x2_coeff_A), - _x1_coeff_B(x1_coeff_B), - _x0_coeff_C(x0_coeff_C) {} - -// Constructor that creates a TIADS1x15 object internally +// The constructor - need the power pin, the data pin, and the calibration info CampbellOBS3::CampbellOBS3(int8_t powerPin, uint8_t adsChannel, float x2_coeff_A, float x1_coeff_B, float x0_coeff_C, - uint8_t measurementsToAverage, - float voltageMultiplier, adsGain_t adsGain, - uint8_t i2cAddress, float adsSupplyVoltage) - : Sensor("CampbellOBS3", OBS3_NUM_VARIABLES, OBS3_WARM_UP_TIME_MS, - OBS3_STABILIZATION_TIME_MS, OBS3_MEASUREMENT_TIME_MS, powerPin, -1, - measurementsToAverage, OBS3_INC_CALC_VARIABLES), - _analogVoltageReader(nullptr), - _ownsVoltageReader(true), - _x2_coeff_A(x2_coeff_A), - _x1_coeff_B(x1_coeff_B), - _x0_coeff_C(x0_coeff_C) { - // Create a TIADS1x15 object for analog voltage reading - _analogVoltageReader = - new TIADS1x15(powerPin, adsChannel, voltageMultiplier, adsGain, - i2cAddress, measurementsToAverage, adsSupplyVoltage); -} - -// Constructor that creates a ProcessorAnalog object internally -CampbellOBS3::CampbellOBS3(int8_t powerPin, int8_t dataPin, float x2_coeff_A, - float x1_coeff_B, float x0_coeff_C, - float voltageMultiplier, float operatingVoltage, - uint8_t measurementsToAverage) + uint8_t i2cAddress, uint8_t measurementsToAverage) : Sensor("CampbellOBS3", OBS3_NUM_VARIABLES, OBS3_WARM_UP_TIME_MS, OBS3_STABILIZATION_TIME_MS, OBS3_MEASUREMENT_TIME_MS, powerPin, -1, measurementsToAverage, OBS3_INC_CALC_VARIABLES), - _analogVoltageReader(nullptr), - _ownsVoltageReader(true), + _adsChannel(adsChannel), _x2_coeff_A(x2_coeff_A), _x1_coeff_B(x1_coeff_B), - _x0_coeff_C(x0_coeff_C) { - // Create a ProcessorAnalog object for analog voltage reading - _analogVoltageReader = - new ProcessorAnalog(powerPin, dataPin, voltageMultiplier, - operatingVoltage, measurementsToAverage); -} + _x0_coeff_C(x0_coeff_C), + _i2cAddress(i2cAddress) {} // Destructor -CampbellOBS3::~CampbellOBS3() { - // Clean up owned voltage reader if created by constructor - if (_ownsVoltageReader && _analogVoltageReader != nullptr) { - delete _analogVoltageReader; - _analogVoltageReader = nullptr; - } -} +CampbellOBS3::~CampbellOBS3() {} String CampbellOBS3::getSensorLocation(void) { - if (_analogVoltageReader != nullptr) { - return _analogVoltageReader->getSensorLocation(); - } else { - // Fallback for cases where voltage reader is not set - return F("CampbellOBS3_UnknownLocation"); - } +#ifndef MS_USE_ADS1015 + String sensorLocation = F("ADS1115_0x"); +#else + String sensorLocation = F("ADS1015_0x"); +#endif + sensorLocation += String(_i2cAddress, HEX); + sensorLocation += F("_Channel"); + sensorLocation += String(_adsChannel); + return sensorLocation; } @@ -92,35 +48,65 @@ bool CampbellOBS3::addSingleMeasurementResult(void) { return bumpMeasurementAttemptCount(false); } - // Ensure we have a valid voltage reader - if (_analogVoltageReader == nullptr) { - MS_DBG(F(" No analog voltage reader configured!")); - return bumpMeasurementAttemptCount(false); - } - bool success = false; + int16_t adcCounts = -9999; float adcVoltage = -9999; float calibResult = -9999; MS_DBG(getSensorNameAndLocation(), F("is reporting:")); +// Create an auxiliary ADC object +// We create and set up the ADC object here so that each sensor using +// the ADC may set the gain appropriately without effecting others. +#ifndef MS_USE_ADS1015 + Adafruit_ADS1115 ads; // Use this for the 16-bit version +#else + Adafruit_ADS1015 ads; // Use this for the 12-bit version +#endif + // ADS Library default settings: + // - TI ADS1115 (16 bit) + // - single-shot mode (powers down between conversions) + // - 128 samples per second (8ms conversion time) + // - 2/3 gain +/- 6.144V range (limited to VDD +0.3V max) + // - TI ADS1015 (12 bit) + // - single-shot mode (powers down between conversions) + // - 1600 samples per second (625µs conversion time) + // - 2/3 gain +/- 6.144V range (limited to VDD +0.3V max) + + // Bump the gain up to 1x = +/- 4.096V range + // Sensor return range is 0-2.5V, but the next gain option is 2x which + // only allows up to 2.048V + ads.setGain(GAIN_ONE); + // Begin ADC, returns true if anything was detected at the address + if (!ads.begin(_i2cAddress)) { + MS_DBG(F(" ADC initialization failed at 0x"), + String(_i2cAddress, HEX)); + return bumpMeasurementAttemptCount(false); + } + // Print out the calibration curve MS_DBG(F(" Input calibration Curve:"), _x2_coeff_A, F("x^2 +"), _x1_coeff_B, F("x +"), _x0_coeff_C); - // Use the abstracted voltage reading method - success = _analogVoltageReader->readVoltageSingleEnded(adcVoltage); - - if (success) { + // Read Analog to Digital Converter (ADC) + // Taking this reading includes the 8ms conversion delay. + // Measure the ADC raw count + adcCounts = ads.readADC_SingleEnded(_adsChannel); + // Convert ADC raw counts value to voltage (V) + adcVoltage = ads.computeVolts(adcCounts); + MS_DBG(F(" ads.readADC_SingleEnded("), _adsChannel, F("):"), adcCounts, + '=', adcVoltage); + + // @todo Verify the voltage range for the OBS3 sensor - + // Here we are using the range of the ADS when it is powered at 3.3V + if (adcVoltage < 3.6 && adcVoltage > -0.3) { // Apply the unique calibration curve for the given sensor calibResult = (_x2_coeff_A * sq(adcVoltage)) + (_x1_coeff_B * adcVoltage) + _x0_coeff_C; MS_DBG(F(" calibResult:"), calibResult); verifyAndAddMeasurementResult(OBS3_TURB_VAR_NUM, calibResult); verifyAndAddMeasurementResult(OBS3_VOLTAGE_VAR_NUM, adcVoltage); - - } else { - MS_DBG(F(" Failed to read voltage from analog voltage reader")); + success = true; } // Return success value when finished diff --git a/src/sensors/CampbellOBS3.h b/src/sensors/CampbellOBS3.h index 7f14d861e..2b8d324e5 100644 --- a/src/sensors/CampbellOBS3.h +++ b/src/sensors/CampbellOBS3.h @@ -88,8 +88,6 @@ // Include other in-library and external dependencies #include "VariableBase.h" #include "SensorBase.h" -#include "AnalogVoltageBase.h" -#include /** @ingroup sensor_obs3 */ /**@{*/ @@ -236,24 +234,8 @@ /* clang-format on */ class CampbellOBS3 : public Sensor { public: - /** - * @brief Construct a new Campbell OBS3 object using a pre-configured - * AnalogVoltageBase - * - * @param powerPin The pin on the mcu controlling power to the OBS3+ - * Use -1 if it is continuously powered. - * @param analogVoltageReader Pointer to an AnalogVoltageBase object for - * voltage readings - * @param x2_coeff_A The x2 (A) coefficient for calibration _in volts_ - * @param x1_coeff_B The x (B) coefficient for calibration _in volts_ - * @param x0_coeff_C The x0 (C) coefficient for calibration _in volts_ - * @param measurementsToAverage Number of measurements to average - * (default=1) - */ - CampbellOBS3(int8_t powerPin, AnalogVoltageBase* analogVoltageReader, - float x2_coeff_A, float x1_coeff_B, float x0_coeff_C, - uint8_t measurementsToAverage = 1); - + // The constructor - need the power pin, the ADS1X15 data channel, and the + // calibration info /** * @brief Construct a new Campbell OBS3 object - need the power pin, the * ADS1X15 data channel, and the calibration info. @@ -273,41 +255,15 @@ class CampbellOBS3 : public Sensor { * @param x2_coeff_A The x2 (A) coefficient for the calibration _in volts_ * @param x1_coeff_B The x (B) coefficient for the calibration _in volts_ * @param x0_coeff_C The x0 (C) coefficient for the calibration _in volts_ - * @param voltageMultiplier The voltage multiplier for voltage dividers - * (default=1) - * @param adsGain The internal gain setting (default=GAIN_ONE) * @param i2cAddress The I2C address of the ADS 1x15, default is 0x48 (ADDR * = GND) * @param measurementsToAverage The number of measurements to take and * average before giving a "final" result from the sensor; optional with a * default value of 1. - * @param adsSupplyVoltage ADS supply voltage in volts (default=3.3V) */ CampbellOBS3(int8_t powerPin, uint8_t adsChannel, float x2_coeff_A, float x1_coeff_B, float x0_coeff_C, - uint8_t i2cAddress = MS_DEFAULT_ADS1X15_ADDRESS, - float voltageMultiplier = 1.0, adsGain_t adsGain = GAIN_ONE, - uint8_t measurementsToAverage = 1, - float adsSupplyVoltage = 3.3); - - /** - * @brief Construct a new Campbell OBS3 object using processor ADC - * - * @param powerPin The pin on the mcu controlling power to the OBS3+ - * Use -1 if it is continuously powered. - * @param dataPin The processor ADC pin for voltage readings - * @param x2_coeff_A The x2 (A) coefficient for calibration _in volts_ - * @param x1_coeff_B The x (B) coefficient for calibration _in volts_ - * @param x0_coeff_C The x0 (C) coefficient for calibration _in volts_ - * @param voltageMultiplier The voltage multiplier for voltage dividers - * (default=1) - * @param operatingVoltage Processor operating voltage (default=3.3V) - * @param measurementsToAverage Number of measurements to average - * (default=1) - */ - CampbellOBS3(int8_t powerPin, int8_t dataPin, float x2_coeff_A, - float x1_coeff_B, float x0_coeff_C, - float voltageMultiplier = 1.0, float operatingVoltage = 3.3, + uint8_t i2cAddress = MS_DEFAULT_ADS1X15_ADDRESS, uint8_t measurementsToAverage = 1); /** * @brief Destroy the Campbell OBS3 object @@ -320,16 +276,17 @@ class CampbellOBS3 : public Sensor { private: /** - * @brief Internal reference to the analog voltage reading object + * @brief Internal reference to the ADS channel number of the Campbell OBS + * 3+ */ - AnalogVoltageBase* _analogVoltageReader; - /** - * @brief Internal flag indicating if this instance owns the voltage reader - */ - bool _ownsVoltageReader; + uint8_t _adsChannel; float _x2_coeff_A; ///< Internal reference to the x^2 coefficient float _x1_coeff_B; ///< Internal reference to the x coefficient float _x0_coeff_C; ///< Internal reference to the x^0 coefficient + /** + * @brief Internal reference to the I2C address of the TI-ADS1x15 + */ + uint8_t _i2cAddress; }; diff --git a/src/sensors/TurnerCyclops.cpp b/src/sensors/TurnerCyclops.cpp index c7d48339d..892b949db 100644 --- a/src/sensors/TurnerCyclops.cpp +++ b/src/sensors/TurnerCyclops.cpp @@ -10,79 +10,35 @@ #include "TurnerCyclops.h" -#include "TIADS1x15.h" -#include "ProcessorAnalog.h" +#include -// Primary constructor using AnalogVoltageBase abstraction -TurnerCyclops::TurnerCyclops(int8_t powerPin, - AnalogVoltageBase* analogVoltageReader, - float conc_std, float volt_std, float volt_blank, - uint8_t measurementsToAverage) - : Sensor("TurnerCyclops", CYCLOPS_NUM_VARIABLES, CYCLOPS_WARM_UP_TIME_MS, - CYCLOPS_STABILIZATION_TIME_MS, CYCLOPS_MEASUREMENT_TIME_MS, - powerPin, -1, measurementsToAverage, CYCLOPS_INC_CALC_VARIABLES), - _analogVoltageReader(analogVoltageReader), - _conc_std(conc_std), - _volt_std(volt_std), - _volt_blank(volt_blank), - _ownsVoltageReader(false) {} - -// Constructor that creates a TIADS1x15 object internally +// The constructor - need the power pin, the data pin, and the calibration info TurnerCyclops::TurnerCyclops(int8_t powerPin, uint8_t adsChannel, float conc_std, float volt_std, float volt_blank, - uint8_t i2cAddress, uint8_t measurementsToAverage, - float voltageMultiplier, adsGain_t adsGain, - float adsSupplyVoltage) + uint8_t i2cAddress, uint8_t measurementsToAverage) : Sensor("TurnerCyclops", CYCLOPS_NUM_VARIABLES, CYCLOPS_WARM_UP_TIME_MS, CYCLOPS_STABILIZATION_TIME_MS, CYCLOPS_MEASUREMENT_TIME_MS, powerPin, -1, measurementsToAverage, CYCLOPS_INC_CALC_VARIABLES), - _analogVoltageReader(nullptr), + _adsChannel(adsChannel), _conc_std(conc_std), _volt_std(volt_std), _volt_blank(volt_blank), - _ownsVoltageReader(true) { - // Create a TIADS1x15 object for analog voltage reading - _analogVoltageReader = - new TIADS1x15(powerPin, adsChannel, voltageMultiplier, adsGain, - i2cAddress, measurementsToAverage, adsSupplyVoltage); -} - -// Constructor that creates a ProcessorAnalog object internally -TurnerCyclops::TurnerCyclops(int8_t powerPin, int8_t dataPin, float conc_std, - float volt_std, float volt_blank, - uint8_t measurementsToAverage, - float voltageMultiplier, float operatingVoltage) - : Sensor("TurnerCyclops", CYCLOPS_NUM_VARIABLES, CYCLOPS_WARM_UP_TIME_MS, - CYCLOPS_STABILIZATION_TIME_MS, CYCLOPS_MEASUREMENT_TIME_MS, - powerPin, -1, measurementsToAverage, CYCLOPS_INC_CALC_VARIABLES), - _analogVoltageReader(nullptr), - _conc_std(conc_std), - _volt_std(volt_std), - _volt_blank(volt_blank), - _ownsVoltageReader(true) { - // Create a ProcessorAnalog object for analog voltage reading - _analogVoltageReader = - new ProcessorAnalog(powerPin, dataPin, voltageMultiplier, - operatingVoltage, measurementsToAverage); -} + _i2cAddress(i2cAddress) {} // Destructor -TurnerCyclops::~TurnerCyclops() { - // Clean up owned voltage reader if created by legacy constructor - if (_ownsVoltageReader && _analogVoltageReader != nullptr) { - delete _analogVoltageReader; - _analogVoltageReader = nullptr; - } -} +TurnerCyclops::~TurnerCyclops() {} String TurnerCyclops::getSensorLocation(void) { - if (_analogVoltageReader != nullptr) { - return _analogVoltageReader->getSensorLocation(); - } else { - // Fallback for cases where voltage reader is not set - return F("TurnerCyclops_UnknownLocation"); - } +#ifndef MS_USE_ADS1015 + String sensorLocation = F("ADS1115_0x"); +#else + String sensorLocation = F("ADS1015_0x"); +#endif + sensorLocation += String(_i2cAddress, HEX); + sensorLocation += F("_Channel"); + sensorLocation += String(_adsChannel); + return sensorLocation; } @@ -92,13 +48,43 @@ bool TurnerCyclops::addSingleMeasurementResult(void) { return bumpMeasurementAttemptCount(false); } - // Ensure we have a valid voltage reader - if (_analogVoltageReader == nullptr) { - MS_DBG(F(" No analog voltage reader configured!")); + bool success = false; + int16_t adcCounts = -9999; + float adcVoltage = -9999; + float calibResult = -9999; + + MS_DBG(getSensorNameAndLocation(), F("is reporting:")); + +// Create an auxiliary ADC object +// We create and set up the ADC object here so that each sensor using +// the ADC may set the gain appropriately without effecting others. +#ifndef MS_USE_ADS1015 + Adafruit_ADS1115 ads; // Use this for the 16-bit version +#else + Adafruit_ADS1015 ads; // Use this for the 12-bit version +#endif + // ADS Library default settings: + // - TI ADS1115 (16 bit) + // - single-shot mode (powers down between conversions) + // - 128 samples per second (8ms conversion time) + // - 2/3 gain +/- 6.144V range (limited to VDD +0.3V max) + // - TI ADS1015 (12 bit) + // - single-shot mode (powers down between conversions) + // - 1600 samples per second (625µs conversion time) + // - 2/3 gain +/- 6.144V range (limited to VDD +0.3V max) + + // Bump the gain up to 1x = +/- 4.096V range + // Sensor return range is 0-2.5V, but the next gain option is 2x which + // only allows up to 2.048V + ads.setGain(GAIN_ONE); + // Begin ADC, returns true if anything was detected at the address + if (!ads.begin(_i2cAddress)) { + MS_DBG(F(" ADC initialization failed at 0x"), + String(_i2cAddress, HEX)); return bumpMeasurementAttemptCount(false); } - // Print out the calibration curve and check that it is valid + // Print out the calibration curve MS_DBG(F(" Input calibration Curve:"), _volt_std, F("V at"), _conc_std, F(". "), _volt_blank, F("V blank.")); const float epsilon = 1e-4f; // tune to expected sensor precision @@ -107,24 +93,25 @@ bool TurnerCyclops::addSingleMeasurementResult(void) { return bumpMeasurementAttemptCount(false); } - bool success = false; - float adcVoltage = -9999; - float calibResult = -9999; - - MS_DBG(getSensorNameAndLocation(), F("is reporting:")); - - // Use the abstracted voltage reading method - success = _analogVoltageReader->readVoltageSingleEnded(adcVoltage); - - if (success) { + // Read Analog to Digital Converter (ADC) + // Taking this reading includes the 8ms conversion delay. + // Measure the ADC raw count + adcCounts = ads.readADC_SingleEnded(_adsChannel); + // Convert ADC raw counts value to voltage (V) + adcVoltage = ads.computeVolts(adcCounts); + MS_DBG(F(" ads.readADC_SingleEnded("), _adsChannel, F("):"), adcCounts, + '=', adcVoltage); + + // @todo Verify the voltage range for the Cyclops sensor + // Here we are using the range of the ADS when it is powered at 3.3V + if (adcVoltage < 3.6 && adcVoltage > -0.3) { // Apply the unique calibration curve for the given sensor calibResult = (_conc_std / (_volt_std - _volt_blank)) * (adcVoltage - _volt_blank); MS_DBG(F(" calibResult:"), calibResult); verifyAndAddMeasurementResult(CYCLOPS_VAR_NUM, calibResult); verifyAndAddMeasurementResult(CYCLOPS_VOLTAGE_VAR_NUM, adcVoltage); - } else { - MS_DBG(F(" Failed to read voltage from analog voltage reader")); + success = true; } // Return success value when finished diff --git a/src/sensors/TurnerCyclops.h b/src/sensors/TurnerCyclops.h index 751f57bd5..eca4f7399 100644 --- a/src/sensors/TurnerCyclops.h +++ b/src/sensors/TurnerCyclops.h @@ -154,9 +154,6 @@ // Include the debugging config #include "ModSensorDebugConfig.h" -// Include known processor settings for default operating voltage -#include "sensors/KnownProcessors.h" - // Define the print label[s] for the debugger #ifdef MS_TURNERCYCLOPS_DEBUG #define MS_DEBUGGING_STD "TurnerCyclops" @@ -170,8 +167,6 @@ // Include other in-library and external dependencies #include "VariableBase.h" #include "SensorBase.h" -#include "AnalogVoltageBase.h" -#include // Sensor Specific Defines /** @ingroup sensor_cyclops */ @@ -311,9 +306,8 @@ class TurnerCyclops : public Sensor { * assumes the ADS is powered with 3.3V. * - The Cyclops-7F itself requires a 3-15V power supply, which can be * turned off between measurements. - * @param analogVoltageReader Pointer to an AnalogVoltageBase object (e.g., - * TIADS1x15 or ProcessorAnalog) that will be used to read the analog - * voltage from the sensor + * @param adsChannel The analog data channel _on the TI ADS1115_ that the + * Cyclops is connected to (0-3). * @param conc_std The concentration of the standard used for a 1-point * sensor calibration. The concentration units should be the same as the * final measuring units. @@ -323,53 +317,16 @@ class TurnerCyclops : public Sensor { * @param volt_blank The voltage (in volts) measured for a blank. This * voltage should be the final voltage *after* accounting for any voltage * dividers or gain settings. + * @param i2cAddress The I2C address of the ADS 1x15, default is 0x48 (ADDR + * = GND) * @param measurementsToAverage The number of measurements to take and * average before giving a "final" result from the sensor; optional with a * default value of 1. */ - TurnerCyclops(int8_t powerPin, AnalogVoltageBase* analogVoltageReader, - float conc_std, float volt_std, float volt_blank, - uint8_t measurementsToAverage = 1); - - /** - * @brief Construct a new Turner Cyclops object using TIADS1x15 - creates - * an internal TIADS1x15 object for reading analog voltages - * - * @param powerPin The pin on the mcu controlling power to the Cyclops-7F - * @param adsChannel The ADS channel (0-3) connected to the sensor - * @param conc_std The concentration of the standard for calibration - * @param volt_std The voltage measured for the conc_std - * @param volt_blank The voltage measured for a blank - * @param voltageMultiplier The voltage multiplier for voltage dividers - * @param adsGain The internal gain setting of the ADS1x15 - * @param i2cAddress The I2C address of the ADS1x15 - * @param measurementsToAverage Number of measurements to average - * @param adsSupplyVoltage The power supply voltage for the ADS1x15 - */ TurnerCyclops(int8_t powerPin, uint8_t adsChannel, float conc_std, float volt_std, float volt_blank, uint8_t i2cAddress = MS_DEFAULT_ADS1X15_ADDRESS, - uint8_t measurementsToAverage = 1, - float voltageMultiplier = 1.0, adsGain_t adsGain = GAIN_ONE, - float adsSupplyVoltage = OPERATING_VOLTAGE); - - /** - * @brief Construct a new Turner Cyclops object using ProcessorAnalog - - * creates an internal ProcessorAnalog object for reading analog voltages - * - * @param powerPin The pin on the mcu controlling power to the Cyclops-7F - * @param dataPin The processor ADC pin connected to the sensor - * @param conc_std The concentration of the standard for calibration - * @param volt_std The voltage measured for the conc_std - * @param volt_blank The voltage measured for a blank - * @param voltageMultiplier The voltage multiplier for voltage dividers - * @param operatingVoltage The processor's operating voltage - * @param measurementsToAverage Number of measurements to average - */ - TurnerCyclops(int8_t powerPin, int8_t dataPin, float conc_std, - float volt_std, float volt_blank, - uint8_t measurementsToAverage = 1, float voltageMultiplier, - float operatingVoltage = OPERATING_VOLTAGE); + uint8_t measurementsToAverage = 1); /** * @brief Destroy the Turner Cyclops object */ @@ -381,9 +338,9 @@ class TurnerCyclops : public Sensor { private: /** - * @brief Internal reference to the analog voltage reading object + * @brief Internal reference to the ADS channel number of the Turner Cyclops */ - AnalogVoltageBase* _analogVoltageReader; + uint8_t _adsChannel; /** * @brief The concentration of the standard used for a 1-point sensor * calibration. The concentration units should be the same as the final @@ -403,11 +360,9 @@ class TurnerCyclops : public Sensor { */ float _volt_blank; /** - * @brief Internal flag to indicate if a _analogVoltageReader was created - * when this object was instantiated so that it can be properly deleted in - * the destructor if needed. + * @brief Internal reference to the I2C address of the TI-ADS1x15 */ - bool _ownsVoltageReader; + uint8_t _i2cAddress; }; diff --git a/src/sensors/TurnerTurbidityPlus.cpp b/src/sensors/TurnerTurbidityPlus.cpp index 6add4eba1..a1c8794df 100644 --- a/src/sensors/TurnerTurbidityPlus.cpp +++ b/src/sensors/TurnerTurbidityPlus.cpp @@ -9,40 +9,40 @@ #include "TurnerTurbidityPlus.h" -#include "TIADS1x15.h" // The constructor - need the power pin, the data pin, and the calibration info TurnerTurbidityPlus::TurnerTurbidityPlus( - int8_t powerPin, int8_t wiperTriggerPin, tiads1x15_adsDiffMux_t adsDiffMux, + int8_t powerPin, int8_t wiperTriggerPin, ttp_adsDiffMux_t adsDiffMux, float conc_std, float volt_std, float volt_blank, uint8_t i2cAddress, adsGain_t PGA_gain, uint8_t measurementsToAverage, float voltageDividerFactor) - : TIADS1x15(powerPin, adsDiffMux, voltageDividerFactor, PGA_gain, - i2cAddress, measurementsToAverage), + : Sensor("TurnerTurbidityPlus", TURBIDITY_PLUS_NUM_VARIABLES, + TURBIDITY_PLUS_WARM_UP_TIME_MS, + TURBIDITY_PLUS_STABILIZATION_TIME_MS, + TURBIDITY_PLUS_MEASUREMENT_TIME_MS, powerPin, -1, + measurementsToAverage), _wiperTriggerPin(wiperTriggerPin), + _adsDiffMux(adsDiffMux), _conc_std(conc_std), _volt_std(volt_std), - _volt_blank(volt_blank) { - // Override timing settings for Turner-specific requirements - // These are protected members from the Sensor base class - _warmUpTime_ms = TURBIDITY_PLUS_WARM_UP_TIME_MS; - _stabilizationTime_ms = TURBIDITY_PLUS_STABILIZATION_TIME_MS; - _measurementTime_ms = TURBIDITY_PLUS_MEASUREMENT_TIME_MS; - // Override variable counts from parent class defaults - _numReturnedValues = TURBIDITY_PLUS_NUM_VARIABLES; - _incCalcValues = TURBIDITY_PLUS_INC_CALC_VARIABLES; - // Set the sensor name - _sensorName = "TurnerTurbidityPlus"; -} + _volt_blank(volt_blank), + _i2cAddress(i2cAddress), + _PGA_gain(PGA_gain), + _voltageDividerFactor(voltageDividerFactor) {} // Destructor TurnerTurbidityPlus::~TurnerTurbidityPlus() {} String TurnerTurbidityPlus::getSensorLocation(void) { - // Use TIADS1x15's location with Turner-specific identifier - String sensorLocation = TIADS1x15::getSensorLocation(); - sensorLocation += F("_TurnerTurb"); +#ifndef MS_USE_ADS1015 + String sensorLocation = F("ADS1115_0x"); +#else + String sensorLocation = F("ADS1015_0x"); +#endif + sensorLocation += String(_i2cAddress, HEX); + sensorLocation += F("_adsDiffMux"); + sensorLocation += String(_adsDiffMux); return sensorLocation; } @@ -64,7 +64,7 @@ void TurnerTurbidityPlus::runWiper() { bool TurnerTurbidityPlus::setup(void) { // Set up the wiper trigger pin, which is active-LOW. pinMode(_wiperTriggerPin, OUTPUT); - return TIADS1x15::setup(); + return Sensor::setup(); } bool TurnerTurbidityPlus::wake(void) { @@ -74,19 +74,19 @@ bool TurnerTurbidityPlus::wake(void) { // Run the wiper before taking a reading runWiper(); - return TIADS1x15::wake(); + return Sensor::wake(); } void TurnerTurbidityPlus::powerDown(void) { // Set the wiper trigger pin LOW to avoid power drain. digitalWrite(_wiperTriggerPin, LOW); - TIADS1x15::powerDown(); + return Sensor::powerDown(); } void TurnerTurbidityPlus::powerUp(void) { // Set the wiper trigger pin HIGH to prepare for wiping. digitalWrite(_wiperTriggerPin, HIGH); - TIADS1x15::powerUp(); + return Sensor::powerUp(); } bool TurnerTurbidityPlus::addSingleMeasurementResult(void) { @@ -95,12 +95,39 @@ bool TurnerTurbidityPlus::addSingleMeasurementResult(void) { return bumpMeasurementAttemptCount(false); } - bool success = false; - float adcVoltage = -9999; - float calibResult = -9999; + bool success = false; + int16_t adcCounts = -9999; + float adcVoltage = -9999; + float calibResult = -9999; MS_DBG(getSensorNameAndLocation(), F("is reporting:")); +// Create an auxiliary ADC object +// We create and set up the ADC object here so that each sensor using the ADC +// may set the gain appropriately without affecting others. +#ifndef MS_USE_ADS1015 + Adafruit_ADS1115 ads; // Use this for the 16-bit version +#else + Adafruit_ADS1015 ads; // Use this for the 12-bit version +#endif + // ADS Library default settings: + // - TI ADS1115 (16 bit) + // - single-shot mode (powers down between conversions) + // - 128 samples per second (8ms conversion time) + // - 2/3 gain +/- 6.144V range (limited to VDD +0.3V max) + // - TI ADS1015 (12 bit) + // - single-shot mode (powers down between conversions) + // - 1600 samples per second (625µs conversion time) + // - 2/3 gain +/- 6.144V range (limited to VDD +0.3V max) + + ads.setGain(_PGA_gain); + // Begin ADC, returns true if anything was detected at the address + if (!ads.begin(_i2cAddress)) { + MS_DBG(F(" ADC initialization failed at 0x"), + String(_i2cAddress, HEX)); + return bumpMeasurementAttemptCount(false); + } + // Print out the calibration curve MS_DBG(F(" Input calibration Curve:"), _volt_std, F("V at"), _conc_std, F(". "), _volt_blank, F("V blank.")); @@ -110,11 +137,53 @@ bool TurnerTurbidityPlus::addSingleMeasurementResult(void) { return bumpMeasurementAttemptCount(false); } - // Use the TIADS1x15 differential voltage reading function - // The voltage multiplier and gain settings are handled by the parent class - if (readVoltageDifferential(adcVoltage)) { - MS_DBG(F(" Differential voltage (after voltage multiplier):"), - String(adcVoltage, 3), F("V")); + // Read Analog to Digital Converter (ADC) + // Taking this reading includes the 8ms conversion delay. + // Measure the voltage differential across the two voltage pins + switch (_adsDiffMux) { + case DIFF_MUX_0_1: { + adcCounts = ads.readADC_Differential_0_1(); + break; + } + case DIFF_MUX_0_3: { + adcCounts = ads.readADC_Differential_0_3(); + break; + } + case DIFF_MUX_1_3: { + adcCounts = ads.readADC_Differential_1_3(); + break; + } + case DIFF_MUX_2_3: { + adcCounts = ads.readADC_Differential_2_3(); + break; + } + default: { + MS_DBG(F(" Invalid differential mux configuration")); + return bumpMeasurementAttemptCount(false); + } + } + // Convert ADC counts value to voltage (V) + adcVoltage = ads.computeVolts(adcCounts); + MS_DBG(F(" ads.readADC_Differential("), _adsDiffMux, F("):"), adcCounts, + '=', String(adcVoltage, 3)); + + // The ADS1X15 outputs a max value corresponding to Vcc + 0.3V + if (adcVoltage < 5.3 && adcVoltage > -0.3) { + if (_voltageDividerFactor > 0) { + // Apply voltage divider factor if using a voltage divider to step + // down the voltage + adcVoltage *= _voltageDividerFactor; + } else { + // If the voltage divider factor is not set to a positive value, + // print a debugging message and continue without applying a voltage + // divider factor. We continue because the voltage divider factor + // can be easily fixed in post-processing if the raw voltage value + // is available, and we don't want to lose the voltage reading if + // the voltage divider factor is just set incorrectly. + MS_DBG(F(" Invalid voltage divider factor:"), + _voltageDividerFactor, + F("Voltage divider will be ignored.")); + } // Apply the unique calibration curve for the given sensor calibResult = (_conc_std / (_volt_std - _volt_blank)) * (adcVoltage - _volt_blank); @@ -123,8 +192,6 @@ bool TurnerTurbidityPlus::addSingleMeasurementResult(void) { verifyAndAddMeasurementResult(TURBIDITY_PLUS_VOLTAGE_VAR_NUM, adcVoltage); success = true; - } else { - MS_DBG(F(" Failed to read differential voltage")); } // Return success value when finished diff --git a/src/sensors/TurnerTurbidityPlus.h b/src/sensors/TurnerTurbidityPlus.h index e114c2baa..278d5c935 100644 --- a/src/sensors/TurnerTurbidityPlus.h +++ b/src/sensors/TurnerTurbidityPlus.h @@ -67,7 +67,7 @@ // Include other in-library and external dependencies #include "VariableBase.h" -#include "TIADS1x15.h" +#include "SensorBase.h" #include /** @ingroup sensor_turbidity_plus */ @@ -108,6 +108,16 @@ #endif /**@}*/ +/** + * @brief Enum for the pins used for differential voltages. + */ +typedef enum : uint16_t { + DIFF_MUX_0_1, ///< differential across pins 0 and 1 + DIFF_MUX_0_3, ///< differential across pins 0 and 3 + DIFF_MUX_1_3, ///< differential across pins 1 and 3 + DIFF_MUX_2_3 ///< differential across pins 2 and 3 +} ttp_adsDiffMux_t; + /** * @anchor sensor_turbidity_plus_timing * @name Sensor Timing @@ -199,7 +209,7 @@ * * @ingroup sensor_turbidity_plus */ -class TurnerTurbidityPlus : public TIADS1x15 { +class TurnerTurbidityPlus : public Sensor { public: // The constructor - need the power pin, the ADS1X15 data channel, and the // calibration info @@ -219,7 +229,7 @@ class TurnerTurbidityPlus : public TIADS1x15 { * @param wiperTriggerPin The pin on the mcu that triggers the sensor's * wiper. * @param adsDiffMux Which two pins _on the TI ADS1115_ that will measure - * differential voltage. See #tiads1x15_adsDiffMux_t + * differential voltage. See #ttp_adsDiffMux_t * @param conc_std The concentration of the standard used for a 1-point * sensor calibration. The concentration units should be the same as the * final measuring units. @@ -228,7 +238,8 @@ class TurnerTurbidityPlus : public TIADS1x15 { * dividers or gain settings. * @param volt_blank The voltage (in volts) measured for a blank. This * voltage should be the final voltage *after* accounting for any voltage - * dividers or gain settings. * = GND) + * @param i2cAddress The I2C address of the ADS 1x15, default is 0x48 (ADDR + * = GND) * @param PGA_gain The programmable gain amplification to set on the * ADS 1x15, default is GAIN_ONE (0-4.096V). * @param measurementsToAverage The number of measurements to take and @@ -243,7 +254,7 @@ class TurnerTurbidityPlus : public TIADS1x15 { * requires a voltageDividerFactor of 2. The default value is 1. */ TurnerTurbidityPlus(int8_t powerPin, int8_t wiperTriggerPin, - tiads1x15_adsDiffMux_t adsDiffMux, float conc_std, + ttp_adsDiffMux_t adsDiffMux, float conc_std, float volt_std, float volt_blank, uint8_t i2cAddress = MS_DEFAULT_ADS1X15_ADDRESS, adsGain_t PGA_gain = GAIN_ONE, @@ -285,6 +296,11 @@ class TurnerTurbidityPlus : public TIADS1x15 { * sensor's wiper. */ int8_t _wiperTriggerPin; + /** + * @brief Which two pins _on the TI ADS1115_ that will measure differential + * voltage from the Turbidity Plus. See #ttp_adsDiffMux_t + */ + ttp_adsDiffMux_t _adsDiffMux; /** * @brief The concentration of the standard used for a 1-point sensor * calibration. The concentration units should be the same as the final @@ -302,6 +318,35 @@ class TurnerTurbidityPlus : public TIADS1x15 { * be the final voltage *after* accounting for any voltage. */ float _volt_blank; + /** + * @brief Internal reference to the I2C address of the TI-ADS1x15 + */ + uint8_t _i2cAddress; + /** + * @brief The programmable gain amplification to set on the ADS 1x15, + * default is GAIN_ONE (+/-4.096V range = Gain 1). + * + * Other gain options are: + * GAIN_TWOTHIRDS = +/-6.144V range = Gain 2/3, + * GAIN_ONE = +/-4.096V range = Gain 1, + * GAIN_TWO = +/-2.048V range = Gain 2, + * GAIN_FOUR = +/-1.024V range = Gain 4, + * GAIN_EIGHT = +/-0.512V range = Gain 8, + * GAIN_SIXTEEN = +/-0.256V range = Gain 16 + * + * @todo Determine gain automatically based on the board voltage? + */ + adsGain_t _PGA_gain; + /** + * @brief For 3.3V processors like the Mayfly, The Turner's 0-5V output + * signal must be shifted down to a maximum of 3.3V. This can be done either + * either with a level-shifting chip (e.g. Adafruit BSS38), OR by connecting + * the Turner's output signal via a voltage divider. This + * voltageDividerFactor is used for the latter case: e.g., a divider that + * uses 2 matched resistors will halve the voltage reading and requires a + * voltageDividerFactor of 2. The default value is 1. + */ + float _voltageDividerFactor; }; From 28ddd7b46b2fc6bae0fcf16a9c99112fe9d7137a Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Tue, 24 Feb 2026 11:15:58 -0500 Subject: [PATCH 287/533] Comment change Signed-off-by: Sara Damiano --- src/ModSensorConfig.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ModSensorConfig.h b/src/ModSensorConfig.h index 979225923..82f63f79e 100644 --- a/src/ModSensorConfig.h +++ b/src/ModSensorConfig.h @@ -157,7 +157,7 @@ */ #if defined(__AVR__) || defined(ARDUINO_ARCH_AVR) #define MS_PROCESSOR_ADC_RESOLUTION 10 -#else +#elif defined(ARDUINO_ARCH_SAMD) #define MS_PROCESSOR_ADC_RESOLUTION 12 #endif #if !defined(MS_PROCESSOR_ADC_RESOLUTION) @@ -233,7 +233,7 @@ #if !defined(MS_DEFAULT_ADS1X15_ADDRESS) || defined(DOXYGEN) /// @brief The assumed address of the ADS1115 or ADS1015, 1001 000 (ADDR = GND) #define MS_DEFAULT_ADS1X15_ADDRESS 0x48 -#endif // MS_DEFAULT_ADS1X15_ADDRESS +#endif // !defined(MS_DEFAULT_ADS1X15_ADDRESS) || defined(DOXYGEN) //============================================================== From 7b8bb9c064c1d0387c878e31fe1112c4f28945fc Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Tue, 24 Feb 2026 12:11:36 -0500 Subject: [PATCH 288/533] Refactor SQ212, OBS3, and Cyclops to allow either processor or ADS1x15 analog Signed-off-by: Sara Damiano --- src/sensors/ApogeeSQ212.cpp | 108 +++++++++++++++----------------- src/sensors/ApogeeSQ212.h | 45 +++++++------- src/sensors/CampbellOBS3.cpp | 112 +++++++++++++++------------------- src/sensors/CampbellOBS3.h | 48 +++++++-------- src/sensors/TurnerCyclops.cpp | 112 +++++++++++++++------------------- src/sensors/TurnerCyclops.h | 37 ++++++----- 6 files changed, 212 insertions(+), 250 deletions(-) diff --git a/src/sensors/ApogeeSQ212.cpp b/src/sensors/ApogeeSQ212.cpp index 78e950bb0..650ce2ec7 100644 --- a/src/sensors/ApogeeSQ212.cpp +++ b/src/sensors/ApogeeSQ212.cpp @@ -13,32 +13,45 @@ #include "ApogeeSQ212.h" -#include +#include "TIADS1x15.h" // The constructor - need the power pin and the data pin -ApogeeSQ212::ApogeeSQ212(int8_t powerPin, uint8_t adsChannel, - uint8_t i2cAddress, uint8_t measurementsToAverage) +ApogeeSQ212::ApogeeSQ212(int8_t powerPin, uint8_t analogChannel, + uint8_t measurementsToAverage, + AnalogVoltageBase* analogVoltageReader) : Sensor("ApogeeSQ212", SQ212_NUM_VARIABLES, SQ212_WARM_UP_TIME_MS, SQ212_STABILIZATION_TIME_MS, SQ212_MEASUREMENT_TIME_MS, powerPin, - -1, measurementsToAverage, SQ212_INC_CALC_VARIABLES), - _adsChannel(adsChannel), - _i2cAddress(i2cAddress) {} + analogChannel, measurementsToAverage, SQ212_INC_CALC_VARIABLES) { + // If no analog voltage reader was provided, create a default one + if (analogVoltageReader == nullptr) { + _analogVoltageReader = new TIADS1x15Base(); + _ownsAnalogVoltageReader = true; + } else { + _analogVoltageReader = analogVoltageReader; + _ownsAnalogVoltageReader = false; + } +} // Destructor -ApogeeSQ212::~ApogeeSQ212() {} +ApogeeSQ212::~ApogeeSQ212() { + // Clean up the analog voltage reader if we created it + if (_ownsAnalogVoltageReader && _analogVoltageReader != nullptr) { + delete _analogVoltageReader; + _analogVoltageReader = nullptr; + } +} String ApogeeSQ212::getSensorLocation(void) { -#ifndef MS_USE_ADS1015 - String sensorLocation = F("ADS1115_0x"); -#else - String sensorLocation = F("ADS1015_0x"); -#endif - sensorLocation += String(_i2cAddress, HEX); - sensorLocation += F("_Channel"); - sensorLocation += String(_adsChannel); - return sensorLocation; + if (_analogVoltageReader != nullptr) { + return _analogVoltageReader->getSensorLocation() + F("_Channel") + + String(_dataPin); + } else { + String sensorLocation = F("Unknown_AnalogVoltageReader_Channel"); + sensorLocation += String(_dataPin); + return sensorLocation; + } } @@ -48,6 +61,13 @@ bool ApogeeSQ212::addSingleMeasurementResult(void) { return bumpMeasurementAttemptCount(false); } + // Check if we have a valid analog voltage reader + if (_analogVoltageReader == nullptr) { + MS_DBG(getSensorNameAndLocation(), + F("No analog voltage reader available")); + return bumpMeasurementAttemptCount(false); + } + bool success = false; int16_t adcCounts = -9999; float adcVoltage = -9999; @@ -55,53 +75,23 @@ bool ApogeeSQ212::addSingleMeasurementResult(void) { MS_DBG(getSensorNameAndLocation(), F("is reporting:")); -// Create an auxiliary ADC object -// We create and set up the ADC object here so that each sensor using -// the ADC may set the gain appropriately without effecting others. -#ifndef MS_USE_ADS1015 - Adafruit_ADS1115 ads; // Use this for the 16-bit version -#else - Adafruit_ADS1015 ads; // Use this for the 12-bit version -#endif - // ADS Library default settings: - // - TI ADS1115 (16 bit) - // - single-shot mode (powers down between conversions) - // - 128 samples per second (8ms conversion time) - // - 2/3 gain +/- 6.144V range (limited to VDD +0.3V max) - // - TI ADS1015 (12 bit) - // - single-shot mode (powers down between conversions) - // - 1600 samples per second (625µs conversion time) - // - 2/3 gain +/- 6.144V range (limited to VDD +0.3V max) - - // Bump the gain up to 1x = +/- 4.096V range - // Sensor return range is 0-2.5V, but the next gain option is 2x which only - // allows up to 2.048V - ads.setGain(GAIN_ONE); - // Begin ADC, returns true if anything was detected at the address - if (!ads.begin(_i2cAddress)) { - MS_DBG(F(" ADC initialization failed at 0x"), - String(_i2cAddress, HEX)); - return bumpMeasurementAttemptCount(false); - } - - // Read Analog to Digital Converter (ADC) - // Taking this reading includes the 8ms conversion delay. - // Measure the ADC raw count - adcCounts = ads.readADC_SingleEnded(_adsChannel); - // Convert ADC raw counts value to voltage (V) - adcVoltage = ads.computeVolts(adcCounts); - MS_DBG(F(" ads.readADC_SingleEnded("), _adsChannel, F("):"), adcCounts, - '=', adcVoltage); - - // @todo Verify the voltage range for the SQ-212 sensor - // Here we are using the range of the ADS when it is powered at 3.3V - if (adcVoltage < 3.6 && adcVoltage > -0.3) { - // Apogee SQ-212 Calibration Factor = 1.0 μmol m-2 s-1 per mV + // Read voltage using the AnalogVoltageBase interface + success = _analogVoltageReader->readVoltageSingleEnded(_dataPin, + adcVoltage); + + if (success) { + // Apply the calibration factor. + // The Apogee SQ-212 is factory calibrated with a calibration factor + // of 1.0 μmol m-2 s-1 per mV. If the user wants to use a custom value, + // it must be set as a preprocessor definition when compiling the + // library, e.g. by adding -DSQ212_CALIBRATION_FACTOR=0.95 to the + // compiler flags. calibResult = 1000 * adcVoltage * SQ212_CALIBRATION_FACTOR; MS_DBG(F(" calibResult:"), calibResult); verifyAndAddMeasurementResult(SQ212_PAR_VAR_NUM, calibResult); verifyAndAddMeasurementResult(SQ212_VOLTAGE_VAR_NUM, adcVoltage); - success = true; + } else { + MS_DBG(F(" Failed to get valid voltage from analog reader")); } // Return success value when finished diff --git a/src/sensors/ApogeeSQ212.h b/src/sensors/ApogeeSQ212.h index f275cf033..fda8f91d5 100644 --- a/src/sensors/ApogeeSQ212.h +++ b/src/sensors/ApogeeSQ212.h @@ -95,6 +95,7 @@ // Include other in-library and external dependencies #include "VariableBase.h" #include "SensorBase.h" +#include "AnalogVoltageBase.h" /** @ingroup sensor_sq212 */ /**@{*/ @@ -241,7 +242,9 @@ class ApogeeSQ212 : public Sensor { public: /** * @brief Construct a new Apogee SQ-212 object - need the power pin and the - * data channel on the ADS1x15. + * analog data channel. By default, this constructor will use a new + * TIADS1x15Base object with all default values for voltage readings, but a + * pointer to a custom AnalogVoltageBase object can be passed in if desired. * * @note ModularSensors only supports connecting the ADS1x15 to the primary * hardware I2C instance defined in the Arduino core. Connecting the ADS to @@ -250,45 +253,39 @@ class ApogeeSQ212 : public Sensor { * @param powerPin The pin on the mcu controlling power to the Apogee * SQ-212. Use -1 if it is continuously powered. * - The SQ-212 requires 3.3 to 24 V DC; current draw 10 µA - * - The ADS1115 requires 2.0-5.5V but is assumed to be powered at 3.3V - * @param adsChannel The analog data channel the Apogee SQ-212 is connected - * to _on the TI ADS1115_ (0-3). - * @param i2cAddress The I2C address of the ADS 1x15, default is 0x48 (ADDR - * = GND) + * @param analogChannel The analog data channel or processor pin that the + * OBS3 is connected to. The significance of the channel number depends on + * the specific AnalogVoltageBase implementation used for voltage readings. + * For example, with the TI ADS1x15, this would be the ADC channel (0-3) + * that the sensor is connected to. * @param measurementsToAverage The number of measurements to take and * average before giving a "final" result from the sensor; optional with a * default value of 1. + * @param analogVoltageReader Pointer to an AnalogVoltageBase object for + * voltage measurements; optional with a default of a new TIADS1x15Base + * object. * @note The ADS is expected to be either continuously powered or have * its power controlled by the same pin as the SQ-212. This library does * not support any other configuration. */ - ApogeeSQ212(int8_t powerPin, uint8_t adsChannel, - uint8_t i2cAddress = MS_DEFAULT_ADS1X15_ADDRESS, - uint8_t measurementsToAverage = 1); + ApogeeSQ212(int8_t powerPin, uint8_t analogChannel, + uint8_t measurementsToAverage = 1, + AnalogVoltageBase* analogVoltageReader = nullptr); /** - * @brief Destroy the ApogeeSQ212 object - no action needed + * @brief Destroy the ApogeeSQ212 object */ ~ApogeeSQ212(); - /** - * @brief Report the I1C address of the ADS and the channel that the SQ-212 - * is attached to. - * - * @return Text describing how the sensor is attached to the mcu. - */ String getSensorLocation(void) override; bool addSingleMeasurementResult(void) override; private: - /** - * @brief Internal reference to the ADS channel number of the Apogee SQ-212 - */ - uint8_t _adsChannel; - /** - * @brief Internal reference to the I2C address of the TI-ADS1x15 - */ - uint8_t _i2cAddress; + AnalogVoltageBase* + _analogVoltageReader; ///< Pointer to analog voltage reader + bool _ownsAnalogVoltageReader; ///< Flag to track if this object owns the + ///< analog voltage reader and should delete + ///< it in the destructor }; diff --git a/src/sensors/CampbellOBS3.cpp b/src/sensors/CampbellOBS3.cpp index ff98ce8af..564d1f307 100644 --- a/src/sensors/CampbellOBS3.cpp +++ b/src/sensors/CampbellOBS3.cpp @@ -10,35 +10,49 @@ #include "CampbellOBS3.h" -#include +#include "TIADS1x15.h" // The constructor - need the power pin, the data pin, and the calibration info -CampbellOBS3::CampbellOBS3(int8_t powerPin, uint8_t adsChannel, +CampbellOBS3::CampbellOBS3(int8_t powerPin, uint8_t analogChannel, float x2_coeff_A, float x1_coeff_B, float x0_coeff_C, - uint8_t i2cAddress, uint8_t measurementsToAverage) + uint8_t measurementsToAverage, + AnalogVoltageBase* analogVoltageReader) : Sensor("CampbellOBS3", OBS3_NUM_VARIABLES, OBS3_WARM_UP_TIME_MS, - OBS3_STABILIZATION_TIME_MS, OBS3_MEASUREMENT_TIME_MS, powerPin, -1, - measurementsToAverage, OBS3_INC_CALC_VARIABLES), - _adsChannel(adsChannel), + OBS3_STABILIZATION_TIME_MS, OBS3_MEASUREMENT_TIME_MS, powerPin, + analogChannel, measurementsToAverage, OBS3_INC_CALC_VARIABLES), _x2_coeff_A(x2_coeff_A), _x1_coeff_B(x1_coeff_B), - _x0_coeff_C(x0_coeff_C), - _i2cAddress(i2cAddress) {} + _x0_coeff_C(x0_coeff_C) { + // If no analog voltage reader was provided, create a default one + if (analogVoltageReader == nullptr) { + _analogVoltageReader = new TIADS1x15Base(); + _ownsAnalogVoltageReader = true; + } else { + _analogVoltageReader = analogVoltageReader; + _ownsAnalogVoltageReader = false; + } +} + // Destructor -CampbellOBS3::~CampbellOBS3() {} +CampbellOBS3::~CampbellOBS3() { + // Clean up the analog voltage reader if we created it + if (_ownsAnalogVoltageReader && _analogVoltageReader != nullptr) { + delete _analogVoltageReader; + _analogVoltageReader = nullptr; + } +} String CampbellOBS3::getSensorLocation(void) { -#ifndef MS_USE_ADS1015 - String sensorLocation = F("ADS1115_0x"); -#else - String sensorLocation = F("ADS1015_0x"); -#endif - sensorLocation += String(_i2cAddress, HEX); - sensorLocation += F("_Channel"); - sensorLocation += String(_adsChannel); - return sensorLocation; + if (_analogVoltageReader != nullptr) { + return _analogVoltageReader->getSensorLocation() + F("_Channel") + + String(_dataPin); + } else { + String sensorLocation = F("Unknown_AnalogVoltageReader_Channel"); + sensorLocation += String(_dataPin); + return sensorLocation; + } } @@ -48,65 +62,35 @@ bool CampbellOBS3::addSingleMeasurementResult(void) { return bumpMeasurementAttemptCount(false); } - bool success = false; - int16_t adcCounts = -9999; - float adcVoltage = -9999; - float calibResult = -9999; - - MS_DBG(getSensorNameAndLocation(), F("is reporting:")); - -// Create an auxiliary ADC object -// We create and set up the ADC object here so that each sensor using -// the ADC may set the gain appropriately without effecting others. -#ifndef MS_USE_ADS1015 - Adafruit_ADS1115 ads; // Use this for the 16-bit version -#else - Adafruit_ADS1015 ads; // Use this for the 12-bit version -#endif - // ADS Library default settings: - // - TI ADS1115 (16 bit) - // - single-shot mode (powers down between conversions) - // - 128 samples per second (8ms conversion time) - // - 2/3 gain +/- 6.144V range (limited to VDD +0.3V max) - // - TI ADS1015 (12 bit) - // - single-shot mode (powers down between conversions) - // - 1600 samples per second (625µs conversion time) - // - 2/3 gain +/- 6.144V range (limited to VDD +0.3V max) - - // Bump the gain up to 1x = +/- 4.096V range - // Sensor return range is 0-2.5V, but the next gain option is 2x which - // only allows up to 2.048V - ads.setGain(GAIN_ONE); - // Begin ADC, returns true if anything was detected at the address - if (!ads.begin(_i2cAddress)) { - MS_DBG(F(" ADC initialization failed at 0x"), - String(_i2cAddress, HEX)); + // Check if we have a valid analog voltage reader + if (_analogVoltageReader == nullptr) { + MS_DBG(getSensorNameAndLocation(), + F("No analog voltage reader available")); return bumpMeasurementAttemptCount(false); } + bool success = false; + float adcVoltage = -9999; + float calibResult = -9999; + + MS_DBG(getSensorNameAndLocation(), F("is reporting:")); + // Print out the calibration curve MS_DBG(F(" Input calibration Curve:"), _x2_coeff_A, F("x^2 +"), _x1_coeff_B, F("x +"), _x0_coeff_C); - // Read Analog to Digital Converter (ADC) - // Taking this reading includes the 8ms conversion delay. - // Measure the ADC raw count - adcCounts = ads.readADC_SingleEnded(_adsChannel); - // Convert ADC raw counts value to voltage (V) - adcVoltage = ads.computeVolts(adcCounts); - MS_DBG(F(" ads.readADC_SingleEnded("), _adsChannel, F("):"), adcCounts, - '=', adcVoltage); - - // @todo Verify the voltage range for the OBS3 sensor - - // Here we are using the range of the ADS when it is powered at 3.3V - if (adcVoltage < 3.6 && adcVoltage > -0.3) { + // Read voltage using the AnalogVoltageBase interface + success = _analogVoltageReader->readVoltageSingleEnded(_dataPin, + adcVoltage); + if (success) { // Apply the unique calibration curve for the given sensor calibResult = (_x2_coeff_A * sq(adcVoltage)) + (_x1_coeff_B * adcVoltage) + _x0_coeff_C; MS_DBG(F(" calibResult:"), calibResult); verifyAndAddMeasurementResult(OBS3_TURB_VAR_NUM, calibResult); verifyAndAddMeasurementResult(OBS3_VOLTAGE_VAR_NUM, adcVoltage); - success = true; + } else { + MS_DBG(F(" Failed to get valid voltage from analog reader")); } // Return success value when finished diff --git a/src/sensors/CampbellOBS3.h b/src/sensors/CampbellOBS3.h index 2b8d324e5..8d530ad9f 100644 --- a/src/sensors/CampbellOBS3.h +++ b/src/sensors/CampbellOBS3.h @@ -88,6 +88,7 @@ // Include other in-library and external dependencies #include "VariableBase.h" #include "SensorBase.h" +#include "AnalogVoltageBase.h" /** @ingroup sensor_obs3 */ /**@{*/ @@ -234,11 +235,12 @@ /* clang-format on */ class CampbellOBS3 : public Sensor { public: - // The constructor - need the power pin, the ADS1X15 data channel, and the - // calibration info /** * @brief Construct a new Campbell OBS3 object - need the power pin, the - * ADS1X15 data channel, and the calibration info. + * analog data channel, and the calibration info. By default, this + * constructor will use a new TIADS1x15Base object with all default values + * for voltage readings, but a pointer to a custom AnalogVoltageBase object + * can be passed in if desired. * * @note ModularSensors only supports connecting the ADS1x15 to the primary * hardware I2C instance defined in the Arduino core. Connecting the ADS to @@ -246,25 +248,27 @@ class CampbellOBS3 : public Sensor { * * @param powerPin The pin on the mcu controlling power to the OBS3+ * Use -1 if it is continuously powered. - * - The ADS1x15 requires an input voltage of 2.0-5.5V, but this library - * assumes the ADS is powered with 3.3V. * - The OBS-3 itself requires a 5-15V power supply, which can be turned off * between measurements. - * @param adsChannel The analog data channel _on the TI ADS1115_ that the - * OBS3 is connected to (0-3). + * @param analogChannel The analog data channel or processor pin that the + * OBS3 is connected to. The significance of the channel number depends on + * the specific AnalogVoltageBase implementation used for voltage readings. + * For example, with the TI ADS1x15, this would be the ADC channel (0-3) + * that the sensor is connected to. * @param x2_coeff_A The x2 (A) coefficient for the calibration _in volts_ * @param x1_coeff_B The x (B) coefficient for the calibration _in volts_ * @param x0_coeff_C The x0 (C) coefficient for the calibration _in volts_ - * @param i2cAddress The I2C address of the ADS 1x15, default is 0x48 (ADDR - * = GND) * @param measurementsToAverage The number of measurements to take and * average before giving a "final" result from the sensor; optional with a * default value of 1. + * @param analogVoltageReader Pointer to an AnalogVoltageBase object for + * voltage measurements; optional with a default of a new TIADS1x15Base + * object. */ - CampbellOBS3(int8_t powerPin, uint8_t adsChannel, float x2_coeff_A, + CampbellOBS3(int8_t powerPin, uint8_t analogChannel, float x2_coeff_A, float x1_coeff_B, float x0_coeff_C, - uint8_t i2cAddress = MS_DEFAULT_ADS1X15_ADDRESS, - uint8_t measurementsToAverage = 1); + uint8_t measurementsToAverage = 1, + AnalogVoltageBase* analogVoltageReader = nullptr); /** * @brief Destroy the Campbell OBS3 object */ @@ -275,18 +279,14 @@ class CampbellOBS3 : public Sensor { bool addSingleMeasurementResult(void) override; private: - /** - * @brief Internal reference to the ADS channel number of the Campbell OBS - * 3+ - */ - uint8_t _adsChannel; - float _x2_coeff_A; ///< Internal reference to the x^2 coefficient - float _x1_coeff_B; ///< Internal reference to the x coefficient - float _x0_coeff_C; ///< Internal reference to the x^0 coefficient - /** - * @brief Internal reference to the I2C address of the TI-ADS1x15 - */ - uint8_t _i2cAddress; + float _x2_coeff_A; ///< Internal reference to the x^2 coefficient + float _x1_coeff_B; ///< Internal reference to the x coefficient + float _x0_coeff_C; ///< Internal reference to the x^0 coefficient + AnalogVoltageBase* + _analogVoltageReader; ///< Pointer to analog voltage reader + bool _ownsAnalogVoltageReader; ///< Flag to track if this object owns the + ///< analog voltage reader and should delete + ///< it in the destructor }; diff --git a/src/sensors/TurnerCyclops.cpp b/src/sensors/TurnerCyclops.cpp index 892b949db..f23792929 100644 --- a/src/sensors/TurnerCyclops.cpp +++ b/src/sensors/TurnerCyclops.cpp @@ -10,35 +10,50 @@ #include "TurnerCyclops.h" -#include +#include "TIADS1x15.h" // The constructor - need the power pin, the data pin, and the calibration info -TurnerCyclops::TurnerCyclops(int8_t powerPin, uint8_t adsChannel, +TurnerCyclops::TurnerCyclops(int8_t powerPin, uint8_t analogChannel, float conc_std, float volt_std, float volt_blank, - uint8_t i2cAddress, uint8_t measurementsToAverage) + uint8_t measurementsToAverage, + AnalogVoltageBase* analogVoltageReader) : Sensor("TurnerCyclops", CYCLOPS_NUM_VARIABLES, CYCLOPS_WARM_UP_TIME_MS, CYCLOPS_STABILIZATION_TIME_MS, CYCLOPS_MEASUREMENT_TIME_MS, - powerPin, -1, measurementsToAverage, CYCLOPS_INC_CALC_VARIABLES), - _adsChannel(adsChannel), + powerPin, analogChannel, measurementsToAverage, + CYCLOPS_INC_CALC_VARIABLES), _conc_std(conc_std), _volt_std(volt_std), - _volt_blank(volt_blank), - _i2cAddress(i2cAddress) {} + _volt_blank(volt_blank) { + // If no analog voltage reader was provided, create a default one + if (analogVoltageReader == nullptr) { + _analogVoltageReader = new TIADS1x15Base(); + _ownsAnalogVoltageReader = true; + } else { + _analogVoltageReader = analogVoltageReader; + _ownsAnalogVoltageReader = false; + } +} + // Destructor -TurnerCyclops::~TurnerCyclops() {} +TurnerCyclops::~TurnerCyclops() { + // Clean up the analog voltage reader if we created it + if (_ownsAnalogVoltageReader && _analogVoltageReader != nullptr) { + delete _analogVoltageReader; + _analogVoltageReader = nullptr; + } +} String TurnerCyclops::getSensorLocation(void) { -#ifndef MS_USE_ADS1015 - String sensorLocation = F("ADS1115_0x"); -#else - String sensorLocation = F("ADS1015_0x"); -#endif - sensorLocation += String(_i2cAddress, HEX); - sensorLocation += F("_Channel"); - sensorLocation += String(_adsChannel); - return sensorLocation; + if (_analogVoltageReader != nullptr) { + return _analogVoltageReader->getSensorLocation() + F("_Channel") + + String(_dataPin); + } else { + String sensorLocation = F("Unknown_AnalogVoltageReader_Channel"); + sensorLocation += String(_dataPin); + return sensorLocation; + } } @@ -48,42 +63,19 @@ bool TurnerCyclops::addSingleMeasurementResult(void) { return bumpMeasurementAttemptCount(false); } - bool success = false; - int16_t adcCounts = -9999; - float adcVoltage = -9999; - float calibResult = -9999; - - MS_DBG(getSensorNameAndLocation(), F("is reporting:")); - -// Create an auxiliary ADC object -// We create and set up the ADC object here so that each sensor using -// the ADC may set the gain appropriately without effecting others. -#ifndef MS_USE_ADS1015 - Adafruit_ADS1115 ads; // Use this for the 16-bit version -#else - Adafruit_ADS1015 ads; // Use this for the 12-bit version -#endif - // ADS Library default settings: - // - TI ADS1115 (16 bit) - // - single-shot mode (powers down between conversions) - // - 128 samples per second (8ms conversion time) - // - 2/3 gain +/- 6.144V range (limited to VDD +0.3V max) - // - TI ADS1015 (12 bit) - // - single-shot mode (powers down between conversions) - // - 1600 samples per second (625µs conversion time) - // - 2/3 gain +/- 6.144V range (limited to VDD +0.3V max) - - // Bump the gain up to 1x = +/- 4.096V range - // Sensor return range is 0-2.5V, but the next gain option is 2x which - // only allows up to 2.048V - ads.setGain(GAIN_ONE); - // Begin ADC, returns true if anything was detected at the address - if (!ads.begin(_i2cAddress)) { - MS_DBG(F(" ADC initialization failed at 0x"), - String(_i2cAddress, HEX)); + // Check if we have a valid analog voltage reader + if (_analogVoltageReader == nullptr) { + MS_DBG(getSensorNameAndLocation(), + F("No analog voltage reader available")); return bumpMeasurementAttemptCount(false); } + bool success = false; + float adcVoltage = -9999; + float calibResult = -9999; + + MS_DBG(getSensorNameAndLocation(), F("is reporting:")); + // Print out the calibration curve MS_DBG(F(" Input calibration Curve:"), _volt_std, F("V at"), _conc_std, F(". "), _volt_blank, F("V blank.")); @@ -93,25 +85,19 @@ bool TurnerCyclops::addSingleMeasurementResult(void) { return bumpMeasurementAttemptCount(false); } - // Read Analog to Digital Converter (ADC) - // Taking this reading includes the 8ms conversion delay. - // Measure the ADC raw count - adcCounts = ads.readADC_SingleEnded(_adsChannel); - // Convert ADC raw counts value to voltage (V) - adcVoltage = ads.computeVolts(adcCounts); - MS_DBG(F(" ads.readADC_SingleEnded("), _adsChannel, F("):"), adcCounts, - '=', adcVoltage); - - // @todo Verify the voltage range for the Cyclops sensor - // Here we are using the range of the ADS when it is powered at 3.3V - if (adcVoltage < 3.6 && adcVoltage > -0.3) { + // Read voltage using the AnalogVoltageBase interface + success = _analogVoltageReader->readVoltageSingleEnded(_dataPin, + adcVoltage); + if (success) { // Apply the unique calibration curve for the given sensor calibResult = (_conc_std / (_volt_std - _volt_blank)) * (adcVoltage - _volt_blank); MS_DBG(F(" calibResult:"), calibResult); verifyAndAddMeasurementResult(CYCLOPS_VAR_NUM, calibResult); verifyAndAddMeasurementResult(CYCLOPS_VOLTAGE_VAR_NUM, adcVoltage); - success = true; + + } else { + MS_DBG(F(" Failed to get valid voltage from analog reader")); } // Return success value when finished diff --git a/src/sensors/TurnerCyclops.h b/src/sensors/TurnerCyclops.h index eca4f7399..e18f56a00 100644 --- a/src/sensors/TurnerCyclops.h +++ b/src/sensors/TurnerCyclops.h @@ -167,6 +167,7 @@ // Include other in-library and external dependencies #include "VariableBase.h" #include "SensorBase.h" +#include "AnalogVoltageBase.h" // Sensor Specific Defines /** @ingroup sensor_cyclops */ @@ -294,7 +295,10 @@ class TurnerCyclops : public Sensor { // calibration info /** * @brief Construct a new Turner Cyclops object - need the power pin, the - * ADS1X15 data channel, and the calibration info. + * analog data channel, and the calibration info. By default, this + * constructor will use a new TIADS1x15Base object with all default values + * for voltage readings, but a pointer to a custom AnalogVoltageBase object + * can be passed in if desired. * * @note ModularSensors only supports connecting the ADS1x15 to the primary * hardware I2C instance defined in the Arduino core. Connecting the ADS to @@ -306,8 +310,11 @@ class TurnerCyclops : public Sensor { * assumes the ADS is powered with 3.3V. * - The Cyclops-7F itself requires a 3-15V power supply, which can be * turned off between measurements. - * @param adsChannel The analog data channel _on the TI ADS1115_ that the - * Cyclops is connected to (0-3). + * @param analogChannel The analog data channel or processor pin that the + * OBS3 is connected to. The significance of the channel number depends on + * the specific AnalogVoltageBase implementation used for voltage readings. + * For example, with the TI ADS1x15, this would be the ADC channel (0-3) + * that the sensor is connected to. * @param conc_std The concentration of the standard used for a 1-point * sensor calibration. The concentration units should be the same as the * final measuring units. @@ -317,16 +324,17 @@ class TurnerCyclops : public Sensor { * @param volt_blank The voltage (in volts) measured for a blank. This * voltage should be the final voltage *after* accounting for any voltage * dividers or gain settings. - * @param i2cAddress The I2C address of the ADS 1x15, default is 0x48 (ADDR - * = GND) * @param measurementsToAverage The number of measurements to take and * average before giving a "final" result from the sensor; optional with a * default value of 1. + * @param analogVoltageReader Pointer to an AnalogVoltageBase object for + * voltage measurements; optional with a default of a new TIADS1x15Base + * object. */ - TurnerCyclops(int8_t powerPin, uint8_t adsChannel, float conc_std, + TurnerCyclops(int8_t powerPin, uint8_t analogChannel, float conc_std, float volt_std, float volt_blank, - uint8_t i2cAddress = MS_DEFAULT_ADS1X15_ADDRESS, - uint8_t measurementsToAverage = 1); + uint8_t measurementsToAverage = 1, + AnalogVoltageBase* analogVoltageReader = nullptr); /** * @brief Destroy the Turner Cyclops object */ @@ -337,10 +345,6 @@ class TurnerCyclops : public Sensor { bool addSingleMeasurementResult(void) override; private: - /** - * @brief Internal reference to the ADS channel number of the Turner Cyclops - */ - uint8_t _adsChannel; /** * @brief The concentration of the standard used for a 1-point sensor * calibration. The concentration units should be the same as the final @@ -359,10 +363,11 @@ class TurnerCyclops : public Sensor { * settings. */ float _volt_blank; - /** - * @brief Internal reference to the I2C address of the TI-ADS1x15 - */ - uint8_t _i2cAddress; + AnalogVoltageBase* + _analogVoltageReader; ///< Pointer to analog voltage reader + bool _ownsAnalogVoltageReader; ///< Flag to track if this object owns the + ///< analog voltage reader and should delete + ///< it in the destructor }; From 3d92c05d7fe7425fbf73aa9683d4d5d45481b03a Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Tue, 24 Feb 2026 12:57:48 -0500 Subject: [PATCH 289/533] Use the AnalogVoltageBase for differential measurements for the AlphasenseCO2 and TurnerTurbidityPlus Signed-off-by: Sara Damiano --- src/sensors/AlphasenseCO2.cpp | 133 +++++++++--------------- src/sensors/AlphasenseCO2.h | 69 +++++++------ src/sensors/ApogeeSQ212.h | 8 +- src/sensors/CampbellOBS3.h | 9 +- src/sensors/TIADS1x15.h | 10 -- src/sensors/TurnerCyclops.h | 9 +- src/sensors/TurnerTurbidityPlus.cpp | 151 ++++++++++------------------ src/sensors/TurnerTurbidityPlus.h | 115 +++++++++------------ 8 files changed, 199 insertions(+), 305 deletions(-) diff --git a/src/sensors/AlphasenseCO2.cpp b/src/sensors/AlphasenseCO2.cpp index 2bdcc89f1..ff3a9ba8a 100644 --- a/src/sensors/AlphasenseCO2.cpp +++ b/src/sensors/AlphasenseCO2.cpp @@ -12,34 +12,51 @@ #include "AlphasenseCO2.h" -#include +#include "TIADS1x15.h" // The constructor - need the power pin and the data pin -AlphasenseCO2::AlphasenseCO2(int8_t powerPin, aco2_adsDiffMux_t adsDiffMux, - uint8_t i2cAddress, uint8_t measurementsToAverage) +AlphasenseCO2::AlphasenseCO2(int8_t powerPin, int8_t analogChannel, + int8_t analogReferenceChannel, + uint8_t measurementsToAverage, + AnalogVoltageBase* analogVoltageReader) : Sensor("AlphasenseCO2", ALPHASENSE_CO2_NUM_VARIABLES, ALPHASENSE_CO2_WARM_UP_TIME_MS, ALPHASENSE_CO2_STABILIZATION_TIME_MS, - ALPHASENSE_CO2_MEASUREMENT_TIME_MS, powerPin, -1, + ALPHASENSE_CO2_MEASUREMENT_TIME_MS, powerPin, analogChannel, measurementsToAverage, ALPHASENSE_CO2_INC_CALC_VARIABLES), - _adsDiffMux(adsDiffMux), - _i2cAddress(i2cAddress) {} + + _analogReferenceChannel(analogReferenceChannel) { + // If no analog voltage reader was provided, create a default one + if (analogVoltageReader == nullptr) { + _analogVoltageReader = new TIADS1x15Base(); + _ownsAnalogVoltageReader = true; + } else { + _analogVoltageReader = analogVoltageReader; + _ownsAnalogVoltageReader = false; + } +} // Destructor -AlphasenseCO2::~AlphasenseCO2() {} +AlphasenseCO2::~AlphasenseCO2() { + // Clean up the analog voltage reader if we created it + if (_ownsAnalogVoltageReader && _analogVoltageReader != nullptr) { + delete _analogVoltageReader; + _analogVoltageReader = nullptr; + } +} String AlphasenseCO2::getSensorLocation(void) { -#ifndef MS_USE_ADS1015 - String sensorLocation = F("ADS1115_0x"); -#else - String sensorLocation = F("ADS1015_0x"); -#endif - sensorLocation += String(_i2cAddress, HEX); - sensorLocation += F("_adsDiffMux"); - sensorLocation += String(_adsDiffMux); - return sensorLocation; + if (_analogVoltageReader != nullptr) { + return _analogVoltageReader->getSensorLocation() + F("_Diff_") + + String(_dataPin) + F("_") + String(_analogReferenceChannel); + } else { + String sensorLocation = F("Unknown_AnalogVoltageReader_Diff_"); + sensorLocation += String(_dataPin) + F("_") + + String(_analogReferenceChannel); + return sensorLocation; + } } @@ -49,76 +66,25 @@ bool AlphasenseCO2::addSingleMeasurementResult(void) { return bumpMeasurementAttemptCount(false); } - bool success = false; - int16_t adcCounts = -9999; - float adcVoltage = -9999; - float co2Current = -9999; - float calibResult = -9999; + // Check if we have a valid analog voltage reader + if (_analogVoltageReader == nullptr) { + MS_DBG(getSensorNameAndLocation(), + F("No analog voltage reader available")); + return bumpMeasurementAttemptCount(false); + } + + bool success = false; + float adcVoltage = -9999; + float co2Current = -9999; + float calibResult = -9999; MS_DBG(getSensorNameAndLocation(), F("is reporting:")); -// Create an auxiliary ADD object -// We create and set up the ADC object here so that each sensor using the ADC -// may set the gain appropriately without effecting others. -#ifndef MS_USE_ADS1015 - Adafruit_ADS1115 ads; // Use this for the 16-bit version -#else - Adafruit_ADS1015 ads; // Use this for the 12-bit version -#endif - // ADS Library default settings: - // - TI ADS1115 (16 bit) - // - single-shot mode (powers down between conversions) - // - 128 samples per second (8ms conversion time) - // - 2/3 gain +/- 6.144V range (limited to VDD +0.3V max) - // - TI ADS1015 (12 bit) - // - single-shot mode (powers down between conversions) - // - 1600 samples per second (625µs conversion time) - // - 2/3 gain +/- 6.144V range (limited to VDD +0.3V max) - - // Bump the gain up to 1x = +/- 4.096V range - // Sensor return range is 0-2.5V, but the next gain option is 2x which - // only allows up to 2.048V - ads.setGain(GAIN_ONE); - // Begin ADC, returns true if anything was detected at the address - if (!ads.begin(_i2cAddress)) { - MS_DBG(F(" ADC initialization failed at 0x"), - String(_i2cAddress, HEX)); - return bumpMeasurementAttemptCount(false); - } + // Read differential voltage using the AnalogVoltageBase interface + success = _analogVoltageReader->readVoltageDifferential( + _dataPin, _analogReferenceChannel, adcVoltage); - // Read Analog to Digital Converter (ADC) - // Taking this reading includes the 8ms conversion delay. - // Measure the voltage differential across the two voltage pins - switch (_adsDiffMux) { - case DIFF_MUX_0_1: { - adcCounts = ads.readADC_Differential_0_1(); - break; - } - case DIFF_MUX_0_3: { - adcCounts = ads.readADC_Differential_0_3(); - break; - } - case DIFF_MUX_1_3: { - adcCounts = ads.readADC_Differential_1_3(); - break; - } - case DIFF_MUX_2_3: { - adcCounts = ads.readADC_Differential_2_3(); - break; - } - default: { - MS_DBG(F(" Invalid differential mux configuration")); - return bumpMeasurementAttemptCount(false); - } - } - // Convert ADC counts value to voltage (V) - adcVoltage = ads.computeVolts(adcCounts); - MS_DBG(F(" ads.readADC_Differential("), _adsDiffMux, F("):"), adcCounts, - '=', String(adcVoltage, 3)); - - // @todo Verify the voltage range for the CO2 sensor - // Here we are using the range of the ADS when it is powered at 3.3V - if (adcVoltage < 3.6 && adcVoltage > -0.3) { + if (success) { // Convert voltage to current (mA) - assuming a 250 Ohm resistor is in // series co2Current = (adcVoltage / ALPHASENSE_CO2_SENSE_RESISTOR_OHM) * 1000; @@ -132,7 +98,8 @@ bool AlphasenseCO2::addSingleMeasurementResult(void) { verifyAndAddMeasurementResult(ALPHASENSE_CO2_VAR_NUM, calibResult); verifyAndAddMeasurementResult(ALPHASENSE_CO2_VOLTAGE_VAR_NUM, adcVoltage); - success = true; + } else { + MS_DBG(F(" Failed to read differential voltage from analog reader")); } // Return success value when finished diff --git a/src/sensors/AlphasenseCO2.h b/src/sensors/AlphasenseCO2.h index a3c3bf860..62c5a62f0 100644 --- a/src/sensors/AlphasenseCO2.h +++ b/src/sensors/AlphasenseCO2.h @@ -98,6 +98,7 @@ // Include other in-library and external dependencies #include "VariableBase.h" #include "SensorBase.h" +#include "AnalogVoltageBase.h" /** @ingroup sensor_alphasense_co2 */ /**@{*/ @@ -148,16 +149,6 @@ #endif /**@}*/ -/** - * @brief Enum for the pins used for differential voltages. - */ -typedef enum : uint16_t { - DIFF_MUX_0_1, ///< differential across pins 0 and 1 - DIFF_MUX_0_3, ///< differential across pins 0 and 3 - DIFF_MUX_1_3, ///< differential across pins 1 and 3 - DIFF_MUX_2_3 ///< differential across pins 2 and 3 -} aco2_adsDiffMux_t; - /** * @anchor sensor_alphasense_co2_timing * @name Sensor Timing @@ -272,8 +263,11 @@ class AlphasenseCO2 : public Sensor { public: /** * @brief Construct a new Alphasense IRC-A1 CO2 object - need the power pin - * and the on the ADS1x15. Designed to read differential voltage between ads - * channels 2 and 3 + * and the analog data and reference channels. + * + * By default, this constructor will use a new TIADS1x15Base object with all + * default values for voltage readings, but a pointer to a custom + * AnalogVoltageBase object can be passed in if desired. * * @note ModularSensors only supports connecting the ADS1x15 to the primary * hardware I2C instance defined in the Arduino core. Connecting the ADS to @@ -282,46 +276,51 @@ class AlphasenseCO2 : public Sensor { * @param powerPin The pin on the mcu controlling power to the * Alphasense CO2 sensor. Use -1 if it is continuously powered. * - The Alphasense CO2 sensor requires 2-5 V DC; current draw 20-60 mA - * - The ADS1115 requires 2.0-5.5V but is assumed to be powered at 3.3V - * @param adsDiffMux Which two pins _on the TI ADS1115_ that will measure - * differential voltage. See #aco2_adsDiffMux_t. - * @param i2cAddress The I2C address of the ADS 1x15, default is 0x48 (ADDR - * = GND) + * @param analogChannel The primary analog channel for differential + * measurement + * @param analogReferenceChannel The secondary (reference) analog channel + * for differential measurement * @param measurementsToAverage The number of measurements to take and * average before giving a "final" result from the sensor; optional with a - * default value of 7 [seconds], which is one period of the cycle. + * default value of 7. + * @param analogVoltageReader Pointer to an AnalogVoltageBase object for + * voltage measurements; optional with a default of a new TIADS1x15Base + * object. * @note The ADS is expected to be either continuously powered or have * its power controlled by the same pin as the Alphasense CO2 sensor. This * library does not support any other configuration. + * + * @warning In library versions 0.37.0 and earlier, a different constructor + * was used that required an enum object instead of two different analog + * channel inputs for the differential voltage measurement. If you are using + * code from a previous version of the library, make sure to update your + * code to use the new constructor and provide the correct analog channel + * inputs for the differential voltage measurement. */ - AlphasenseCO2(int8_t powerPin, aco2_adsDiffMux_t adsDiffMux = DIFF_MUX_2_3, - uint8_t i2cAddress = MS_DEFAULT_ADS1X15_ADDRESS, - uint8_t measurementsToAverage = 7); + AlphasenseCO2(int8_t powerPin, int8_t analogChannel, + int8_t analogReferenceChannel, + uint8_t measurementsToAverage = 7, + AnalogVoltageBase* analogVoltageReader = nullptr); /** - * @brief Destroy the AlphasenseCO2 object - no action needed + * @brief Destroy the AlphasenseCO2 object */ ~AlphasenseCO2(); - /** - * @brief Report the I1C address of the ADS and the channel that the - * Alphasense CO2 sensor is attached to. - * - * @return **String** Text describing how the sensor is attached to the mcu. - */ String getSensorLocation(void) override; bool addSingleMeasurementResult(void) override; private: + /** - * @brief Which two pins _on the TI ADS1115_ that will measure differential - * voltage from the Turbidity Plus. See #aco2_adsDiffMux_t - */ - aco2_adsDiffMux_t _adsDiffMux; - /** - * @brief Internal reference to the I2C address of the TI-ADS1x15 + * @brief The second (reference) pin for differential voltage measurements. */ - uint8_t _i2cAddress; + int8_t _analogReferenceChannel; + AnalogVoltageBase* + _analogVoltageReader; ///< Pointer to analog voltage reader + bool _ownsAnalogVoltageReader; ///< Flag to track if this object owns the + ///< analog voltage reader and should delete + ///< it in the destructor }; diff --git a/src/sensors/ApogeeSQ212.h b/src/sensors/ApogeeSQ212.h index fda8f91d5..bc66e213d 100644 --- a/src/sensors/ApogeeSQ212.h +++ b/src/sensors/ApogeeSQ212.h @@ -242,9 +242,11 @@ class ApogeeSQ212 : public Sensor { public: /** * @brief Construct a new Apogee SQ-212 object - need the power pin and the - * analog data channel. By default, this constructor will use a new - * TIADS1x15Base object with all default values for voltage readings, but a - * pointer to a custom AnalogVoltageBase object can be passed in if desired. + * analog data channel. + * + * By default, this constructor will use a new TIADS1x15Base object with all + * default values for voltage readings, but a pointer to a custom + * AnalogVoltageBase object can be passed in if desired. * * @note ModularSensors only supports connecting the ADS1x15 to the primary * hardware I2C instance defined in the Arduino core. Connecting the ADS to diff --git a/src/sensors/CampbellOBS3.h b/src/sensors/CampbellOBS3.h index 8d530ad9f..5827fb122 100644 --- a/src/sensors/CampbellOBS3.h +++ b/src/sensors/CampbellOBS3.h @@ -237,10 +237,11 @@ class CampbellOBS3 : public Sensor { public: /** * @brief Construct a new Campbell OBS3 object - need the power pin, the - * analog data channel, and the calibration info. By default, this - * constructor will use a new TIADS1x15Base object with all default values - * for voltage readings, but a pointer to a custom AnalogVoltageBase object - * can be passed in if desired. + * analog data channel, and the calibration info. + * + * By default, this constructor will use a new TIADS1x15Base object with all + * default values for voltage readings, but a pointer to a custom + * AnalogVoltageBase object can be passed in if desired. * * @note ModularSensors only supports connecting the ADS1x15 to the primary * hardware I2C instance defined in the Arduino core. Connecting the ADS to diff --git a/src/sensors/TIADS1x15.h b/src/sensors/TIADS1x15.h index c6cf26c58..e1bb8f522 100644 --- a/src/sensors/TIADS1x15.h +++ b/src/sensors/TIADS1x15.h @@ -186,16 +186,6 @@ #define TIADS1X15_INC_CALC_VARIABLES 0 /**@}*/ -/** - * @brief Enum for the pins used for differential voltages. - */ -enum class tiads1x15_adsDiffMux_t : uint16_t { - TIADS1X15_DIFF_MUX_0_1, ///< differential across pins 0 and 1 - TIADS1X15_DIFF_MUX_0_3, ///< differential across pins 0 and 3 - TIADS1X15_DIFF_MUX_1_3, ///< differential across pins 1 and 3 - TIADS1X15_DIFF_MUX_2_3 ///< differential across pins 2 and 3 -}; - /** * @anchor sensor_ads1x15_timing * @name Sensor Timing diff --git a/src/sensors/TurnerCyclops.h b/src/sensors/TurnerCyclops.h index e18f56a00..c4ce76dcf 100644 --- a/src/sensors/TurnerCyclops.h +++ b/src/sensors/TurnerCyclops.h @@ -295,10 +295,11 @@ class TurnerCyclops : public Sensor { // calibration info /** * @brief Construct a new Turner Cyclops object - need the power pin, the - * analog data channel, and the calibration info. By default, this - * constructor will use a new TIADS1x15Base object with all default values - * for voltage readings, but a pointer to a custom AnalogVoltageBase object - * can be passed in if desired. + * analog data channel, and the calibration info. + * + * By default, this constructor will use a new TIADS1x15Base object with all + * default values for voltage readings, but a pointer to a custom + * AnalogVoltageBase object can be passed in if desired. * * @note ModularSensors only supports connecting the ADS1x15 to the primary * hardware I2C instance defined in the Arduino core. Connecting the ADS to diff --git a/src/sensors/TurnerTurbidityPlus.cpp b/src/sensors/TurnerTurbidityPlus.cpp index a1c8794df..e2216a78a 100644 --- a/src/sensors/TurnerTurbidityPlus.cpp +++ b/src/sensors/TurnerTurbidityPlus.cpp @@ -9,41 +9,55 @@ #include "TurnerTurbidityPlus.h" +#include "TIADS1x15.h" // The constructor - need the power pin, the data pin, and the calibration info TurnerTurbidityPlus::TurnerTurbidityPlus( - int8_t powerPin, int8_t wiperTriggerPin, ttp_adsDiffMux_t adsDiffMux, - float conc_std, float volt_std, float volt_blank, uint8_t i2cAddress, - adsGain_t PGA_gain, uint8_t measurementsToAverage, - float voltageDividerFactor) + int8_t powerPin, int8_t wiperTriggerPin, int8_t analogChannel, + int8_t analogReferenceChannel, float conc_std, float volt_std, + float volt_blank, uint8_t measurementsToAverage, + AnalogVoltageBase* analogVoltageReader) : Sensor("TurnerTurbidityPlus", TURBIDITY_PLUS_NUM_VARIABLES, TURBIDITY_PLUS_WARM_UP_TIME_MS, TURBIDITY_PLUS_STABILIZATION_TIME_MS, - TURBIDITY_PLUS_MEASUREMENT_TIME_MS, powerPin, -1, + TURBIDITY_PLUS_MEASUREMENT_TIME_MS, powerPin, analogChannel, measurementsToAverage), _wiperTriggerPin(wiperTriggerPin), - _adsDiffMux(adsDiffMux), _conc_std(conc_std), _volt_std(volt_std), _volt_blank(volt_blank), - _i2cAddress(i2cAddress), - _PGA_gain(PGA_gain), - _voltageDividerFactor(voltageDividerFactor) {} + _analogReferenceChannel(analogReferenceChannel) { + // If no analog voltage reader was provided, create a default one + if (analogVoltageReader == nullptr) { + _analogVoltageReader = new TIADS1x15Base(); + _ownsAnalogVoltageReader = true; + } else { + _analogVoltageReader = analogVoltageReader; + _ownsAnalogVoltageReader = false; + } +} + // Destructor -TurnerTurbidityPlus::~TurnerTurbidityPlus() {} +TurnerTurbidityPlus::~TurnerTurbidityPlus() { + // Clean up the analog voltage reader if we created it + if (_ownsAnalogVoltageReader && _analogVoltageReader != nullptr) { + delete _analogVoltageReader; + _analogVoltageReader = nullptr; + } +} String TurnerTurbidityPlus::getSensorLocation(void) { -#ifndef MS_USE_ADS1015 - String sensorLocation = F("ADS1115_0x"); -#else - String sensorLocation = F("ADS1015_0x"); -#endif - sensorLocation += String(_i2cAddress, HEX); - sensorLocation += F("_adsDiffMux"); - sensorLocation += String(_adsDiffMux); - return sensorLocation; + if (_analogVoltageReader != nullptr) { + return _analogVoltageReader->getSensorLocation() + F("_Diff_") + + String(_dataPin) + F("_") + String(_analogReferenceChannel); + } else { + String sensorLocation = F("Unknown_AnalogVoltageReader_Diff_"); + sensorLocation += String(_dataPin) + F("_") + + String(_analogReferenceChannel); + return sensorLocation; + } } void TurnerTurbidityPlus::runWiper() { @@ -80,13 +94,13 @@ bool TurnerTurbidityPlus::wake(void) { void TurnerTurbidityPlus::powerDown(void) { // Set the wiper trigger pin LOW to avoid power drain. digitalWrite(_wiperTriggerPin, LOW); - return Sensor::powerDown(); + Sensor::powerDown(); } void TurnerTurbidityPlus::powerUp(void) { // Set the wiper trigger pin HIGH to prepare for wiping. digitalWrite(_wiperTriggerPin, HIGH); - return Sensor::powerUp(); + Sensor::powerUp(); } bool TurnerTurbidityPlus::addSingleMeasurementResult(void) { @@ -95,39 +109,19 @@ bool TurnerTurbidityPlus::addSingleMeasurementResult(void) { return bumpMeasurementAttemptCount(false); } - bool success = false; - int16_t adcCounts = -9999; - float adcVoltage = -9999; - float calibResult = -9999; - - MS_DBG(getSensorNameAndLocation(), F("is reporting:")); - -// Create an auxiliary ADC object -// We create and set up the ADC object here so that each sensor using the ADC -// may set the gain appropriately without affecting others. -#ifndef MS_USE_ADS1015 - Adafruit_ADS1115 ads; // Use this for the 16-bit version -#else - Adafruit_ADS1015 ads; // Use this for the 12-bit version -#endif - // ADS Library default settings: - // - TI ADS1115 (16 bit) - // - single-shot mode (powers down between conversions) - // - 128 samples per second (8ms conversion time) - // - 2/3 gain +/- 6.144V range (limited to VDD +0.3V max) - // - TI ADS1015 (12 bit) - // - single-shot mode (powers down between conversions) - // - 1600 samples per second (625µs conversion time) - // - 2/3 gain +/- 6.144V range (limited to VDD +0.3V max) - - ads.setGain(_PGA_gain); - // Begin ADC, returns true if anything was detected at the address - if (!ads.begin(_i2cAddress)) { - MS_DBG(F(" ADC initialization failed at 0x"), - String(_i2cAddress, HEX)); + // Check if we have a valid analog voltage reader + if (_analogVoltageReader == nullptr) { + MS_DBG(getSensorNameAndLocation(), + F("No analog voltage reader available")); return bumpMeasurementAttemptCount(false); } + bool success = false; + float adcVoltage = -9999; + float calibResult = -9999; + + MS_DBG(getSensorNameAndLocation(), F("is reporting:")); + // Print out the calibration curve MS_DBG(F(" Input calibration Curve:"), _volt_std, F("V at"), _conc_std, F(". "), _volt_blank, F("V blank.")); @@ -137,53 +131,11 @@ bool TurnerTurbidityPlus::addSingleMeasurementResult(void) { return bumpMeasurementAttemptCount(false); } - // Read Analog to Digital Converter (ADC) - // Taking this reading includes the 8ms conversion delay. - // Measure the voltage differential across the two voltage pins - switch (_adsDiffMux) { - case DIFF_MUX_0_1: { - adcCounts = ads.readADC_Differential_0_1(); - break; - } - case DIFF_MUX_0_3: { - adcCounts = ads.readADC_Differential_0_3(); - break; - } - case DIFF_MUX_1_3: { - adcCounts = ads.readADC_Differential_1_3(); - break; - } - case DIFF_MUX_2_3: { - adcCounts = ads.readADC_Differential_2_3(); - break; - } - default: { - MS_DBG(F(" Invalid differential mux configuration")); - return bumpMeasurementAttemptCount(false); - } - } - // Convert ADC counts value to voltage (V) - adcVoltage = ads.computeVolts(adcCounts); - MS_DBG(F(" ads.readADC_Differential("), _adsDiffMux, F("):"), adcCounts, - '=', String(adcVoltage, 3)); - - // The ADS1X15 outputs a max value corresponding to Vcc + 0.3V - if (adcVoltage < 5.3 && adcVoltage > -0.3) { - if (_voltageDividerFactor > 0) { - // Apply voltage divider factor if using a voltage divider to step - // down the voltage - adcVoltage *= _voltageDividerFactor; - } else { - // If the voltage divider factor is not set to a positive value, - // print a debugging message and continue without applying a voltage - // divider factor. We continue because the voltage divider factor - // can be easily fixed in post-processing if the raw voltage value - // is available, and we don't want to lose the voltage reading if - // the voltage divider factor is just set incorrectly. - MS_DBG(F(" Invalid voltage divider factor:"), - _voltageDividerFactor, - F("Voltage divider will be ignored.")); - } + // Read differential voltage using the AnalogVoltageBase interface + success = _analogVoltageReader->readVoltageDifferential( + _dataPin, _analogReferenceChannel, adcVoltage); + + if (success) { // Apply the unique calibration curve for the given sensor calibResult = (_conc_std / (_volt_std - _volt_blank)) * (adcVoltage - _volt_blank); @@ -191,7 +143,8 @@ bool TurnerTurbidityPlus::addSingleMeasurementResult(void) { verifyAndAddMeasurementResult(TURBIDITY_PLUS_VAR_NUM, calibResult); verifyAndAddMeasurementResult(TURBIDITY_PLUS_VOLTAGE_VAR_NUM, adcVoltage); - success = true; + } else { + MS_DBG(F(" Failed to read differential voltage from analog reader")); } // Return success value when finished diff --git a/src/sensors/TurnerTurbidityPlus.h b/src/sensors/TurnerTurbidityPlus.h index 278d5c935..dc3907db5 100644 --- a/src/sensors/TurnerTurbidityPlus.h +++ b/src/sensors/TurnerTurbidityPlus.h @@ -68,6 +68,7 @@ // Include other in-library and external dependencies #include "VariableBase.h" #include "SensorBase.h" +#include "AnalogVoltageBase.h" #include /** @ingroup sensor_turbidity_plus */ @@ -108,16 +109,6 @@ #endif /**@}*/ -/** - * @brief Enum for the pins used for differential voltages. - */ -typedef enum : uint16_t { - DIFF_MUX_0_1, ///< differential across pins 0 and 1 - DIFF_MUX_0_3, ///< differential across pins 0 and 3 - DIFF_MUX_1_3, ///< differential across pins 1 and 3 - DIFF_MUX_2_3 ///< differential across pins 2 and 3 -} ttp_adsDiffMux_t; - /** * @anchor sensor_turbidity_plus_timing * @name Sensor Timing @@ -211,11 +202,13 @@ typedef enum : uint16_t { */ class TurnerTurbidityPlus : public Sensor { public: - // The constructor - need the power pin, the ADS1X15 data channel, and the - // calibration info /** * @brief Construct a new Turner Turbidity Plus object - need the power pin, - * the ADS1X15 data channel, and the calibration info. + * the analog data and reference channels, and the calibration info. + * + * By default, this constructor will use a new TIADS1x15Base object with all + * default values for voltage readings, but a pointer to a custom + * AnalogVoltageBase object can be passed in if desired. * * @note ModularSensors only supports connecting the ADS1x15 to the primary * hardware I2C instance defined in the Arduino core. Connecting the ADS to @@ -223,13 +216,14 @@ class TurnerTurbidityPlus : public Sensor { * * @param powerPin The pin on the mcu controlling power to the Turbidity * Plus Use -1 if it is continuously powered. - * - The ADS1x15 requires an input voltage of 2.0-5.5V - * - The Turbidity Plus itself requires a 3-15V power supply, which can be - * turned off between measurements. + * - The Turbidity Plus requires a 3-15V power supply, which can be turned + * off between measurements. * @param wiperTriggerPin The pin on the mcu that triggers the sensor's * wiper. - * @param adsDiffMux Which two pins _on the TI ADS1115_ that will measure - * differential voltage. See #ttp_adsDiffMux_t + * @param analogChannel The primary analog channel for differential + * measurement + * @param analogReferenceChannel The secondary (reference) analog channel + * for differential measurement * @param conc_std The concentration of the standard used for a 1-point * sensor calibration. The concentration units should be the same as the * final measuring units. @@ -238,28 +232,39 @@ class TurnerTurbidityPlus : public Sensor { * dividers or gain settings. * @param volt_blank The voltage (in volts) measured for a blank. This * voltage should be the final voltage *after* accounting for any voltage - * @param i2cAddress The I2C address of the ADS 1x15, default is 0x48 (ADDR - * = GND) - * @param PGA_gain The programmable gain amplification to set on the - * ADS 1x15, default is GAIN_ONE (0-4.096V). + * dividers or gain settings. * @param measurementsToAverage The number of measurements to take and * average before giving a "final" result from the sensor; optional with a * default value of 1. - * @param voltageDividerFactor For 3.3V processors like the Mayfly, The - * Turner's 0-5V output signal must be shifted down to a maximum of 3.3V. - * This can be done either either with a level-shifting chip (e.g. Adafruit - * BSS38), OR by connecting the Turner's output signal via a voltage - * divider. This voltageDividerFactor is used for the latter case: e.g., a - * divider that uses 2 matched resistors will halve the voltage reading and - * requires a voltageDividerFactor of 2. The default value is 1. + * @param analogVoltageReader Pointer to an AnalogVoltageBase object for + * voltage measurements; optional with a default of a new TIADS1x15Base + * object. + * + * @attention For 3.3V processors like the Mayfly, The Turner's 0-5V output + * signal must be shifted down to a maximum of 3.3V. This can be done either + * either with a level-shifting chip (e.g. Adafruit BSS38), OR by connecting + * the Turner's output signal via a voltage divider. By default, the + * TurnerTurbidityPlus object does **NOT** include any level-shifting or + * voltage dividers. To have a voltage divider applied correctly, you must + * supply a pointer to a custom AnalogVoltageBase object that applies the + * voltage divider to the raw voltage readings. For example, if you are + * using a simple voltage divider with two equal resistors, you would need + * to use an AnalogVoltageBase object that multiplies the raw voltage + * readings by 2 to account for the halving of the signal by the voltage + * divider. + * + * @warning In library versions 0.37.0 and earlier, a different constructor + * was used that required an enum object instead of two different analog + * channel inputs for the differential voltage measurement. If you are using + * code from a previous version of the library, make sure to update your + * code to use the new constructor and provide the correct analog channel + * inputs for the differential voltage measurement. */ TurnerTurbidityPlus(int8_t powerPin, int8_t wiperTriggerPin, - ttp_adsDiffMux_t adsDiffMux, float conc_std, - float volt_std, float volt_blank, - uint8_t i2cAddress = MS_DEFAULT_ADS1X15_ADDRESS, - adsGain_t PGA_gain = GAIN_ONE, - uint8_t measurementsToAverage = 1, - float voltageDividerFactor = 1); + int8_t analogChannel, int8_t analogReferenceChannel, + float conc_std, float volt_std, float volt_blank, + uint8_t measurementsToAverage = 1, + AnalogVoltageBase* analogVoltageReader = nullptr); /** * @brief Destroy the Turner Turbidity Plus object */ @@ -296,11 +301,6 @@ class TurnerTurbidityPlus : public Sensor { * sensor's wiper. */ int8_t _wiperTriggerPin; - /** - * @brief Which two pins _on the TI ADS1115_ that will measure differential - * voltage from the Turbidity Plus. See #ttp_adsDiffMux_t - */ - ttp_adsDiffMux_t _adsDiffMux; /** * @brief The concentration of the standard used for a 1-point sensor * calibration. The concentration units should be the same as the final @@ -318,35 +318,16 @@ class TurnerTurbidityPlus : public Sensor { * be the final voltage *after* accounting for any voltage. */ float _volt_blank; + /** - * @brief Internal reference to the I2C address of the TI-ADS1x15 - */ - uint8_t _i2cAddress; - /** - * @brief The programmable gain amplification to set on the ADS 1x15, - * default is GAIN_ONE (+/-4.096V range = Gain 1). - * - * Other gain options are: - * GAIN_TWOTHIRDS = +/-6.144V range = Gain 2/3, - * GAIN_ONE = +/-4.096V range = Gain 1, - * GAIN_TWO = +/-2.048V range = Gain 2, - * GAIN_FOUR = +/-1.024V range = Gain 4, - * GAIN_EIGHT = +/-0.512V range = Gain 8, - * GAIN_SIXTEEN = +/-0.256V range = Gain 16 - * - * @todo Determine gain automatically based on the board voltage? - */ - adsGain_t _PGA_gain; - /** - * @brief For 3.3V processors like the Mayfly, The Turner's 0-5V output - * signal must be shifted down to a maximum of 3.3V. This can be done either - * either with a level-shifting chip (e.g. Adafruit BSS38), OR by connecting - * the Turner's output signal via a voltage divider. This - * voltageDividerFactor is used for the latter case: e.g., a divider that - * uses 2 matched resistors will halve the voltage reading and requires a - * voltageDividerFactor of 2. The default value is 1. + * @brief The second (reference) pin for differential voltage measurements. */ - float _voltageDividerFactor; + int8_t _analogReferenceChannel; + AnalogVoltageBase* + _analogVoltageReader; ///< Pointer to analog voltage reader + bool _ownsAnalogVoltageReader; ///< Flag to track if this object owns the + ///< analog voltage reader and should delete + ///< it in the destructor }; From c0f7c9e82d534f0b74c30a07e15e546657b96fef Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Tue, 24 Feb 2026 13:48:25 -0500 Subject: [PATCH 290/533] More description of ADS I2C addresses Signed-off-by: Sara Damiano --- src/ModSensorConfig.h | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/ModSensorConfig.h b/src/ModSensorConfig.h index 82f63f79e..083688e1c 100644 --- a/src/ModSensorConfig.h +++ b/src/ModSensorConfig.h @@ -231,7 +231,17 @@ #endif // !defined(MS_PROCESSOR_ADC_REFERENCE_MODE) || defined(DOXYGEN) #if !defined(MS_DEFAULT_ADS1X15_ADDRESS) || defined(DOXYGEN) -/// @brief The assumed address of the ADS1115 or ADS1015, 1001 000 (ADDR = GND) +/** + * @brief The default I²C address of the ADS1115 or ADS1015 external ADC. + * + * Valid addresses depend on the ADDR pin connection: + * - `0x48` – ADDR to GND (default) + * - `0x49` – ADDR to VDD + * - `0x4A` – ADDR to SDA + * - `0x4B` – ADDR to SCL + * + * Override with a build flag: `-DMS_DEFAULT_ADS1X15_ADDRESS=0x49` + */ #define MS_DEFAULT_ADS1X15_ADDRESS 0x48 #endif // !defined(MS_DEFAULT_ADS1X15_ADDRESS) || defined(DOXYGEN) //============================================================== From 2f91e6eaa4db9f7e02e305c032399c6bddb58e53 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Tue, 24 Feb 2026 13:55:41 -0500 Subject: [PATCH 291/533] Update ctor docs and delete copy and move ctors Signed-off-by: Sara Damiano --- src/sensors/AlphasenseCO2.h | 18 ++++++++++------ src/sensors/ApogeeSQ212.h | 36 +++++++++++++++++++------------ src/sensors/CampbellOBS3.h | 27 +++++++++++++---------- src/sensors/TurnerCyclops.h | 29 ++++++++++++++----------- src/sensors/TurnerTurbidityPlus.h | 21 +++++++++++------- 5 files changed, 79 insertions(+), 52 deletions(-) diff --git a/src/sensors/AlphasenseCO2.h b/src/sensors/AlphasenseCO2.h index 62c5a62f0..410f250cf 100644 --- a/src/sensors/AlphasenseCO2.h +++ b/src/sensors/AlphasenseCO2.h @@ -269,10 +269,6 @@ class AlphasenseCO2 : public Sensor { * default values for voltage readings, but a pointer to a custom * AnalogVoltageBase object can be passed in if desired. * - * @note ModularSensors only supports connecting the ADS1x15 to the primary - * hardware I2C instance defined in the Arduino core. Connecting the ADS to - * a secondary hardware or software I2C instance is *not* supported! - * * @param powerPin The pin on the mcu controlling power to the * Alphasense CO2 sensor. Use -1 if it is continuously powered. * - The Alphasense CO2 sensor requires 2-5 V DC; current draw 20-60 mA @@ -284,8 +280,9 @@ class AlphasenseCO2 : public Sensor { * average before giving a "final" result from the sensor; optional with a * default value of 7. * @param analogVoltageReader Pointer to an AnalogVoltageBase object for - * voltage measurements; optional with a default of a new TIADS1x15Base - * object. + * voltage measurements. Pass nullptr (the default) to have the constructor + * internally create and own a TIADS1x15Base instance. + * * @note The ADS is expected to be either continuously powered or have * its power controlled by the same pin as the Alphasense CO2 sensor. This * library does not support any other configuration. @@ -306,6 +303,15 @@ class AlphasenseCO2 : public Sensor { */ ~AlphasenseCO2(); + // Delete copy constructor and copy assignment operator to prevent shallow + // copies + AlphasenseCO2(const AlphasenseCO2&) = delete; + AlphasenseCO2& operator=(const AlphasenseCO2&) = delete; + + // Delete move constructor and move assignment operator + AlphasenseCO2(AlphasenseCO2&&) = delete; + AlphasenseCO2& operator=(AlphasenseCO2&&) = delete; + String getSensorLocation(void) override; bool addSingleMeasurementResult(void) override; diff --git a/src/sensors/ApogeeSQ212.h b/src/sensors/ApogeeSQ212.h index bc66e213d..ab04fbb48 100644 --- a/src/sensors/ApogeeSQ212.h +++ b/src/sensors/ApogeeSQ212.h @@ -248,27 +248,26 @@ class ApogeeSQ212 : public Sensor { * default values for voltage readings, but a pointer to a custom * AnalogVoltageBase object can be passed in if desired. * - * @note ModularSensors only supports connecting the ADS1x15 to the primary - * hardware I2C instance defined in the Arduino core. Connecting the ADS to - * a secondary hardware or software I2C instance is *not* supported! - * * @param powerPin The pin on the mcu controlling power to the Apogee * SQ-212. Use -1 if it is continuously powered. * - The SQ-212 requires 3.3 to 24 V DC; current draw 10 µA - * @param analogChannel The analog data channel or processor pin that the - * OBS3 is connected to. The significance of the channel number depends on - * the specific AnalogVoltageBase implementation used for voltage readings. - * For example, with the TI ADS1x15, this would be the ADC channel (0-3) - * that the sensor is connected to. + * @param analogChannel The analog data channel or processor pin for voltage + * measurements. The significance of the channel number depends on the + * specific AnalogVoltageBase implementation used for voltage readings. For + * example, with the TI ADS1x15, this would be the ADC channel (0-3) that + * the sensor is connected to. * @param measurementsToAverage The number of measurements to take and * average before giving a "final" result from the sensor; optional with a * default value of 1. * @param analogVoltageReader Pointer to an AnalogVoltageBase object for - * voltage measurements; optional with a default of a new TIADS1x15Base - * object. - * @note The ADS is expected to be either continuously powered or have - * its power controlled by the same pin as the SQ-212. This library does - * not support any other configuration. + * voltage measurements. Pass nullptr (the default) to have the constructor + * allocate a TIADS1x15Base object automatically (owned and deleted by this + * instance). If a non-null pointer is supplied, the caller retains + * ownership and must ensure its lifetime exceeds that of this object. + * + * @note The ADS is expected to be either continuously powered or have its + * power controlled by the same pin as the SQ-212. This library does not + * support any other configuration. */ ApogeeSQ212(int8_t powerPin, uint8_t analogChannel, uint8_t measurementsToAverage = 1, @@ -278,6 +277,15 @@ class ApogeeSQ212 : public Sensor { */ ~ApogeeSQ212(); + // Delete copy constructor and copy assignment operator to prevent shallow + // copies + ApogeeSQ212(const ApogeeSQ212&) = delete; + ApogeeSQ212& operator=(const ApogeeSQ212&) = delete; + + // Delete move constructor and move assignment operator + ApogeeSQ212(ApogeeSQ212&&) = delete; + ApogeeSQ212& operator=(ApogeeSQ212&&) = delete; + String getSensorLocation(void) override; bool addSingleMeasurementResult(void) override; diff --git a/src/sensors/CampbellOBS3.h b/src/sensors/CampbellOBS3.h index 5827fb122..326e384f3 100644 --- a/src/sensors/CampbellOBS3.h +++ b/src/sensors/CampbellOBS3.h @@ -243,19 +243,15 @@ class CampbellOBS3 : public Sensor { * default values for voltage readings, but a pointer to a custom * AnalogVoltageBase object can be passed in if desired. * - * @note ModularSensors only supports connecting the ADS1x15 to the primary - * hardware I2C instance defined in the Arduino core. Connecting the ADS to - * a secondary hardware or software I2C instance is *not* supported! - * * @param powerPin The pin on the mcu controlling power to the OBS3+ * Use -1 if it is continuously powered. * - The OBS-3 itself requires a 5-15V power supply, which can be turned off * between measurements. - * @param analogChannel The analog data channel or processor pin that the - * OBS3 is connected to. The significance of the channel number depends on - * the specific AnalogVoltageBase implementation used for voltage readings. - * For example, with the TI ADS1x15, this would be the ADC channel (0-3) - * that the sensor is connected to. + * @param analogChannel The analog data channel or processor pin for voltage + * measurements. The significance of the channel number depends on the + * specific AnalogVoltageBase implementation used for voltage readings. For + * example, with the TI ADS1x15, this would be the ADC channel (0-3) that + * the sensor is connected to. * @param x2_coeff_A The x2 (A) coefficient for the calibration _in volts_ * @param x1_coeff_B The x (B) coefficient for the calibration _in volts_ * @param x0_coeff_C The x0 (C) coefficient for the calibration _in volts_ @@ -263,8 +259,8 @@ class CampbellOBS3 : public Sensor { * average before giving a "final" result from the sensor; optional with a * default value of 1. * @param analogVoltageReader Pointer to an AnalogVoltageBase object for - * voltage measurements; optional with a default of a new TIADS1x15Base - * object. + * voltage measurements. Pass nullptr (the default) to have the constructor + * internally create and own a TIADS1x15Base instance. */ CampbellOBS3(int8_t powerPin, uint8_t analogChannel, float x2_coeff_A, float x1_coeff_B, float x0_coeff_C, @@ -275,6 +271,15 @@ class CampbellOBS3 : public Sensor { */ ~CampbellOBS3(); + // Delete copy constructor and copy assignment operator to prevent shallow + // copies + CampbellOBS3(const CampbellOBS3&) = delete; + CampbellOBS3& operator=(const CampbellOBS3&) = delete; + + // Delete move constructor and move assignment operator + CampbellOBS3(CampbellOBS3&&) = delete; + CampbellOBS3& operator=(CampbellOBS3&&) = delete; + String getSensorLocation(void) override; bool addSingleMeasurementResult(void) override; diff --git a/src/sensors/TurnerCyclops.h b/src/sensors/TurnerCyclops.h index c4ce76dcf..a14ddcb26 100644 --- a/src/sensors/TurnerCyclops.h +++ b/src/sensors/TurnerCyclops.h @@ -301,21 +301,15 @@ class TurnerCyclops : public Sensor { * default values for voltage readings, but a pointer to a custom * AnalogVoltageBase object can be passed in if desired. * - * @note ModularSensors only supports connecting the ADS1x15 to the primary - * hardware I2C instance defined in the Arduino core. Connecting the ADS to - * a secondary hardware or software I2C instance is *not* supported! - * * @param powerPin The pin on the mcu controlling power to the Cyclops-7F * Use -1 if it is continuously powered. - * - The ADS1x15 requires an input voltage of 2.0-5.5V, but this library - * assumes the ADS is powered with 3.3V. * - The Cyclops-7F itself requires a 3-15V power supply, which can be * turned off between measurements. - * @param analogChannel The analog data channel or processor pin that the - * OBS3 is connected to. The significance of the channel number depends on - * the specific AnalogVoltageBase implementation used for voltage readings. - * For example, with the TI ADS1x15, this would be the ADC channel (0-3) - * that the sensor is connected to. + * @param analogChannel The analog data channel or processor pin for voltage + * measurements. The significance of the channel number depends on the + * specific AnalogVoltageBase implementation used for voltage readings. For + * example, with the TI ADS1x15, this would be the ADC channel (0-3) that + * the sensor is connected to. * @param conc_std The concentration of the standard used for a 1-point * sensor calibration. The concentration units should be the same as the * final measuring units. @@ -329,8 +323,8 @@ class TurnerCyclops : public Sensor { * average before giving a "final" result from the sensor; optional with a * default value of 1. * @param analogVoltageReader Pointer to an AnalogVoltageBase object for - * voltage measurements; optional with a default of a new TIADS1x15Base - * object. + * voltage measurements. Pass nullptr (the default) to have the constructor + * internally create and own a TIADS1x15Base instance. */ TurnerCyclops(int8_t powerPin, uint8_t analogChannel, float conc_std, float volt_std, float volt_blank, @@ -341,6 +335,15 @@ class TurnerCyclops : public Sensor { */ ~TurnerCyclops(); + // Delete copy constructor and copy assignment operator to prevent shallow + // copies + TurnerCyclops(const TurnerCyclops&) = delete; + TurnerCyclops& operator=(const TurnerCyclops&) = delete; + + // Delete move constructor and move assignment operator + TurnerCyclops(TurnerCyclops&&) = delete; + TurnerCyclops& operator=(TurnerCyclops&&) = delete; + String getSensorLocation(void) override; bool addSingleMeasurementResult(void) override; diff --git a/src/sensors/TurnerTurbidityPlus.h b/src/sensors/TurnerTurbidityPlus.h index dc3907db5..f6bf72997 100644 --- a/src/sensors/TurnerTurbidityPlus.h +++ b/src/sensors/TurnerTurbidityPlus.h @@ -210,10 +210,6 @@ class TurnerTurbidityPlus : public Sensor { * default values for voltage readings, but a pointer to a custom * AnalogVoltageBase object can be passed in if desired. * - * @note ModularSensors only supports connecting the ADS1x15 to the primary - * hardware I2C instance defined in the Arduino core. Connecting the ADS to - * a secondary hardware or software I2C instance is *not* supported! - * * @param powerPin The pin on the mcu controlling power to the Turbidity * Plus Use -1 if it is continuously powered. * - The Turbidity Plus requires a 3-15V power supply, which can be turned @@ -237,13 +233,13 @@ class TurnerTurbidityPlus : public Sensor { * average before giving a "final" result from the sensor; optional with a * default value of 1. * @param analogVoltageReader Pointer to an AnalogVoltageBase object for - * voltage measurements; optional with a default of a new TIADS1x15Base - * object. + * voltage measurements. Pass nullptr (the default) to have the constructor + * internally create and own a TIADS1x15Base instance. * * @attention For 3.3V processors like the Mayfly, The Turner's 0-5V output * signal must be shifted down to a maximum of 3.3V. This can be done either - * either with a level-shifting chip (e.g. Adafruit BSS38), OR by connecting - * the Turner's output signal via a voltage divider. By default, the + * with a level-shifting chip (e.g. Adafruit BSS38), OR by connecting the + * Turner's output signal via a voltage divider. By default, the * TurnerTurbidityPlus object does **NOT** include any level-shifting or * voltage dividers. To have a voltage divider applied correctly, you must * supply a pointer to a custom AnalogVoltageBase object that applies the @@ -270,6 +266,15 @@ class TurnerTurbidityPlus : public Sensor { */ ~TurnerTurbidityPlus(); + // Delete copy constructor and copy assignment operator to prevent shallow + // copies + TurnerTurbidityPlus(const TurnerTurbidityPlus&) = delete; + TurnerTurbidityPlus& operator=(const TurnerTurbidityPlus&) = delete; + + // Delete move constructor and move assignment operator + TurnerTurbidityPlus(TurnerTurbidityPlus&&) = delete; + TurnerTurbidityPlus& operator=(TurnerTurbidityPlus&&) = delete; + String getSensorLocation(void) override; /** From 4df6330694e0343fd2f52a359bed9b4c3653376d Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Tue, 24 Feb 2026 13:56:53 -0500 Subject: [PATCH 292/533] Change string construction Signed-off-by: Sara Damiano --- src/sensors/AlphasenseCO2.cpp | 13 +++++++++---- src/sensors/TurnerTurbidityPlus.cpp | 13 +++++++++---- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/src/sensors/AlphasenseCO2.cpp b/src/sensors/AlphasenseCO2.cpp index ff3a9ba8a..f395cead5 100644 --- a/src/sensors/AlphasenseCO2.cpp +++ b/src/sensors/AlphasenseCO2.cpp @@ -49,12 +49,17 @@ AlphasenseCO2::~AlphasenseCO2() { String AlphasenseCO2::getSensorLocation(void) { if (_analogVoltageReader != nullptr) { - return _analogVoltageReader->getSensorLocation() + F("_Diff_") + - String(_dataPin) + F("_") + String(_analogReferenceChannel); + String sensorLocation = _analogVoltageReader->getSensorLocation(); + sensorLocation += F("_Diff_"); + sensorLocation += String(_dataPin); + sensorLocation += F("_"); + sensorLocation += String(_analogReferenceChannel); + return sensorLocation; } else { String sensorLocation = F("Unknown_AnalogVoltageReader_Diff_"); - sensorLocation += String(_dataPin) + F("_") + - String(_analogReferenceChannel); + sensorLocation += String(_dataPin); + sensorLocation += F("_"); + sensorLocation += String(_analogReferenceChannel); return sensorLocation; } } diff --git a/src/sensors/TurnerTurbidityPlus.cpp b/src/sensors/TurnerTurbidityPlus.cpp index e2216a78a..9e771eb26 100644 --- a/src/sensors/TurnerTurbidityPlus.cpp +++ b/src/sensors/TurnerTurbidityPlus.cpp @@ -50,12 +50,17 @@ TurnerTurbidityPlus::~TurnerTurbidityPlus() { String TurnerTurbidityPlus::getSensorLocation(void) { if (_analogVoltageReader != nullptr) { - return _analogVoltageReader->getSensorLocation() + F("_Diff_") + - String(_dataPin) + F("_") + String(_analogReferenceChannel); + String sensorLocation = _analogVoltageReader->getSensorLocation(); + sensorLocation += F("_Diff_"); + sensorLocation += String(_dataPin); + sensorLocation += F("_"); + sensorLocation += String(_analogReferenceChannel); + return sensorLocation; } else { String sensorLocation = F("Unknown_AnalogVoltageReader_Diff_"); - sensorLocation += String(_dataPin) + F("_") + - String(_analogReferenceChannel); + sensorLocation += String(_dataPin); + sensorLocation += F("_"); + sensorLocation += String(_analogReferenceChannel); return sensorLocation; } } From 28aa02115c23f2faa5ce9476907f24d79ae6377e Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Tue, 24 Feb 2026 13:58:08 -0500 Subject: [PATCH 293/533] update includes Signed-off-by: Sara Damiano --- src/sensors/EverlightALSPT19.h | 2 +- src/sensors/ProcessorAnalog.h | 2 +- src/sensors/ProcessorStats.h | 2 +- src/sensors/TIADS1x15.h | 2 +- src/sensors/TurnerTurbidityPlus.h | 4 ++-- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/sensors/EverlightALSPT19.h b/src/sensors/EverlightALSPT19.h index 4e2dfbf8a..5f67b61ed 100644 --- a/src/sensors/EverlightALSPT19.h +++ b/src/sensors/EverlightALSPT19.h @@ -48,7 +48,7 @@ #include "ModSensorConfig.h" // Include the known processors for default values -#include "sensors/KnownProcessors.h" +#include "KnownProcessors.h" // Include the debugging config #include "ModSensorDebugConfig.h" diff --git a/src/sensors/ProcessorAnalog.h b/src/sensors/ProcessorAnalog.h index 8cb62364b..0d61f650e 100644 --- a/src/sensors/ProcessorAnalog.h +++ b/src/sensors/ProcessorAnalog.h @@ -61,7 +61,7 @@ #include "ModSensorDebugConfig.h" // Include the known processors for default values -#include "sensors/KnownProcessors.h" +#include "KnownProcessors.h" // Define the print label[s] for the debugger #ifdef MS_PROCESSOR_ANALOG_DEBUG diff --git a/src/sensors/ProcessorStats.h b/src/sensors/ProcessorStats.h index 23455510a..a57e542e2 100644 --- a/src/sensors/ProcessorStats.h +++ b/src/sensors/ProcessorStats.h @@ -63,7 +63,7 @@ #include "ModSensorDebugConfig.h" // Include the known processors for default values -#include "sensors/KnownProcessors.h" +#include "KnownProcessors.h" // Define the print label[s] for the debugger #ifdef MS_PROCESSORSTATS_DEBUG diff --git a/src/sensors/TIADS1x15.h b/src/sensors/TIADS1x15.h index e1bb8f522..8a9500860 100644 --- a/src/sensors/TIADS1x15.h +++ b/src/sensors/TIADS1x15.h @@ -153,7 +153,7 @@ #include "ModSensorDebugConfig.h" // Include known processor settings for default operating voltage -#include "sensors/KnownProcessors.h" +#include "KnownProcessors.h" // Define the print label[s] for the debugger #ifdef MS_TIADS1X15_DEBUG diff --git a/src/sensors/TurnerTurbidityPlus.h b/src/sensors/TurnerTurbidityPlus.h index f6bf72997..fcebc4764 100644 --- a/src/sensors/TurnerTurbidityPlus.h +++ b/src/sensors/TurnerTurbidityPlus.h @@ -69,7 +69,6 @@ #include "VariableBase.h" #include "SensorBase.h" #include "AnalogVoltageBase.h" -#include /** @ingroup sensor_turbidity_plus */ /**@{*/ @@ -193,7 +192,8 @@ /// - Resolution: /// - 16-bit ADC (ADS1115): 0.125 mV #define TURBIDITY_PLUS_VOLTAGE_RESOLUTION 4 -#endif /**@}*/ +#endif +/**@}*/ /** * @brief The Sensor sub-class for the [Turner Turbidity Plus turbidity * sensor](@ref sensor_turbidity_plus). From dca3e7b27b935af8a2d83223cd4f95e91c8e7569 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Tue, 24 Feb 2026 14:00:23 -0500 Subject: [PATCH 294/533] Add f tag to some floats Signed-off-by: Sara Damiano --- examples/menu_a_la_carte/menu_a_la_carte.ino | 2 +- src/sensors/ProcessorAnalog.cpp | 2 ++ src/sensors/ProcessorAnalog.h | 4 ++-- src/sensors/TIADS1x15.cpp | 8 ++++---- src/sensors/TIADS1x15.h | 2 +- 5 files changed, 10 insertions(+), 8 deletions(-) diff --git a/examples/menu_a_la_carte/menu_a_la_carte.ino b/examples/menu_a_la_carte/menu_a_la_carte.ino index c2fbe8e2d..7989d618d 100644 --- a/examples/menu_a_la_carte/menu_a_la_carte.ino +++ b/examples/menu_a_la_carte/menu_a_la_carte.ino @@ -1608,7 +1608,7 @@ Variable* alsPt19Lux = new EverlightALSPT19_Illuminance( const int8_t ADSPower = sensorPowerPin; // Power pin const int8_t ADSChannel = 2; // The ADS channel of interest const float voltageMultiplier = - 10; // Voltage multiplier if using a voltage divider + 10.0f; // Voltage multiplier if using a voltage divider const adsGain_t adsGain = GAIN_ONE; // The internal gain setting for the ADS const uint8_t evADSi2c_addr = 0x48; // The I2C address of the ADS1115 ADC const uint8_t VoltReadsToAvg = 1; // Only read one sample diff --git a/src/sensors/ProcessorAnalog.cpp b/src/sensors/ProcessorAnalog.cpp index 46fda8976..c64027ebc 100644 --- a/src/sensors/ProcessorAnalog.cpp +++ b/src/sensors/ProcessorAnalog.cpp @@ -30,11 +30,13 @@ bool ProcessorAnalogBase::readVoltageSingleEnded(int8_t analogChannel, // Validate parameters if (PROCESSOR_ADC_MAX <= 0) { MS_DBG(F("Processor ADC max value is not set or invalid!")); + resultValue = -9999.0f; return false; } if (analogChannel < 0 || _supplyVoltage <= 0 || _voltageMultiplier <= 0) { MS_DBG(F("Missing one or more required parameters: analog pin, " "operating voltage, or voltage divider!")); + resultValue = -9999.0f; return false; } diff --git a/src/sensors/ProcessorAnalog.h b/src/sensors/ProcessorAnalog.h index 0d61f650e..b82ebd933 100644 --- a/src/sensors/ProcessorAnalog.h +++ b/src/sensors/ProcessorAnalog.h @@ -174,7 +174,7 @@ class ProcessorAnalogBase : public AnalogVoltageBase { * @param operatingVoltage The processor's operating voltage; most * likely 3.3 or 5. */ - explicit ProcessorAnalogBase(float voltageMultiplier = 1.0, + explicit ProcessorAnalogBase(float voltageMultiplier = 1.0f, float operatingVoltage = OPERATING_VOLTAGE); /** @@ -248,7 +248,7 @@ class ProcessorAnalog : public Sensor, public ProcessorAnalogBase { * default value of 1. */ explicit ProcessorAnalog(int8_t powerPin, int8_t dataPin, - float voltageMultiplier = 1.0, + float voltageMultiplier = 1.0f, float operatingVoltage = OPERATING_VOLTAGE, uint8_t measurementsToAverage = 1); /** diff --git a/src/sensors/TIADS1x15.cpp b/src/sensors/TIADS1x15.cpp index 0aceae200..cda94083a 100644 --- a/src/sensors/TIADS1x15.cpp +++ b/src/sensors/TIADS1x15.cpp @@ -327,14 +327,14 @@ bool TIADS1x15::addSingleMeasurementResult(void) { // Override setSupplyVoltage in TIADS1x15 to validate range void TIADS1x15::setSupplyVoltage(float supplyVoltage) { // Validate supply voltage range: 0.0V to 5.5V per datasheet - if (supplyVoltage < 0.0) { + if (supplyVoltage < 0.0f) { MS_DBG(F("ADS supply voltage "), supplyVoltage, F("V is below minimum, clamping to 0.0V")); - _supplyVoltage = 0.0; - } else if (supplyVoltage > 5.5) { + _supplyVoltage = 0.0f; + } else if (supplyVoltage > 5.5f) { MS_DBG(F("ADS supply voltage "), supplyVoltage, F("V exceeds maximum, clamping to 5.5V")); - _supplyVoltage = 5.5; + _supplyVoltage = 5.5f; } else { _supplyVoltage = supplyVoltage; } diff --git a/src/sensors/TIADS1x15.h b/src/sensors/TIADS1x15.h index 8a9500860..1e70f9fdb 100644 --- a/src/sensors/TIADS1x15.h +++ b/src/sensors/TIADS1x15.h @@ -271,7 +271,7 @@ class TIADS1x15Base : public AnalogVoltageBase { * @param i2cAddress The I2C address of the ADS 1x15 * @param adsSupplyVoltage The power supply voltage for the ADS1x15 in volts */ - explicit TIADS1x15Base(float voltageMultiplier = 1.0, + explicit TIADS1x15Base(float voltageMultiplier = 1.0f, adsGain_t adsGain = GAIN_ONE, uint8_t i2cAddress = MS_DEFAULT_ADS1X15_ADDRESS, float adsSupplyVoltage = OPERATING_VOLTAGE); From 62cc33371650240813dbe470b90b68d7a233bff9 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Tue, 24 Feb 2026 14:01:34 -0500 Subject: [PATCH 295/533] Decrease variable scope Signed-off-by: Sara Damiano --- src/sensors/AlphasenseCO2.cpp | 13 ++++++------- src/sensors/ApogeeSQ212.cpp | 8 +++----- src/sensors/CampbellOBS3.cpp | 5 ++--- src/sensors/TurnerCyclops.cpp | 5 ++--- src/sensors/TurnerTurbidityPlus.cpp | 9 ++++----- 5 files changed, 17 insertions(+), 23 deletions(-) diff --git a/src/sensors/AlphasenseCO2.cpp b/src/sensors/AlphasenseCO2.cpp index f395cead5..b88c0b518 100644 --- a/src/sensors/AlphasenseCO2.cpp +++ b/src/sensors/AlphasenseCO2.cpp @@ -78,10 +78,8 @@ bool AlphasenseCO2::addSingleMeasurementResult(void) { return bumpMeasurementAttemptCount(false); } - bool success = false; - float adcVoltage = -9999; - float co2Current = -9999; - float calibResult = -9999; + bool success = false; + float adcVoltage = -9999; MS_DBG(getSensorNameAndLocation(), F("is reporting:")); @@ -92,17 +90,18 @@ bool AlphasenseCO2::addSingleMeasurementResult(void) { if (success) { // Convert voltage to current (mA) - assuming a 250 Ohm resistor is in // series - co2Current = (adcVoltage / ALPHASENSE_CO2_SENSE_RESISTOR_OHM) * 1000; + float co2Current = (adcVoltage / ALPHASENSE_CO2_SENSE_RESISTOR_OHM) * + 1000; MS_DBG(F(" co2Current:"), co2Current); // Convert current to ppm (using a formula recommended by the sensor // manufacturer) - calibResult = ALPHASENSE_CO2_MFG_SCALE * co2Current - + float calibResult = ALPHASENSE_CO2_MFG_SCALE * co2Current - ALPHASENSE_CO2_MFG_OFFSET; MS_DBG(F(" calibResult:"), calibResult); - verifyAndAddMeasurementResult(ALPHASENSE_CO2_VAR_NUM, calibResult); verifyAndAddMeasurementResult(ALPHASENSE_CO2_VOLTAGE_VAR_NUM, adcVoltage); + verifyAndAddMeasurementResult(ALPHASENSE_CO2_VAR_NUM, calibResult); } else { MS_DBG(F(" Failed to read differential voltage from analog reader")); } diff --git a/src/sensors/ApogeeSQ212.cpp b/src/sensors/ApogeeSQ212.cpp index 650ce2ec7..777772930 100644 --- a/src/sensors/ApogeeSQ212.cpp +++ b/src/sensors/ApogeeSQ212.cpp @@ -68,10 +68,8 @@ bool ApogeeSQ212::addSingleMeasurementResult(void) { return bumpMeasurementAttemptCount(false); } - bool success = false; - int16_t adcCounts = -9999; - float adcVoltage = -9999; - float calibResult = -9999; + bool success = false; + float adcVoltage = -9999.0f; MS_DBG(getSensorNameAndLocation(), F("is reporting:")); @@ -86,7 +84,7 @@ bool ApogeeSQ212::addSingleMeasurementResult(void) { // it must be set as a preprocessor definition when compiling the // library, e.g. by adding -DSQ212_CALIBRATION_FACTOR=0.95 to the // compiler flags. - calibResult = 1000 * adcVoltage * SQ212_CALIBRATION_FACTOR; + float calibResult = 1000 * adcVoltage * SQ212_CALIBRATION_FACTOR; MS_DBG(F(" calibResult:"), calibResult); verifyAndAddMeasurementResult(SQ212_PAR_VAR_NUM, calibResult); verifyAndAddMeasurementResult(SQ212_VOLTAGE_VAR_NUM, adcVoltage); diff --git a/src/sensors/CampbellOBS3.cpp b/src/sensors/CampbellOBS3.cpp index 564d1f307..e8f049b77 100644 --- a/src/sensors/CampbellOBS3.cpp +++ b/src/sensors/CampbellOBS3.cpp @@ -70,8 +70,7 @@ bool CampbellOBS3::addSingleMeasurementResult(void) { } bool success = false; - float adcVoltage = -9999; - float calibResult = -9999; + float adcVoltage = -9999.0f; MS_DBG(getSensorNameAndLocation(), F("is reporting:")); @@ -84,7 +83,7 @@ bool CampbellOBS3::addSingleMeasurementResult(void) { adcVoltage); if (success) { // Apply the unique calibration curve for the given sensor - calibResult = (_x2_coeff_A * sq(adcVoltage)) + + float calibResult = (_x2_coeff_A * sq(adcVoltage)) + (_x1_coeff_B * adcVoltage) + _x0_coeff_C; MS_DBG(F(" calibResult:"), calibResult); verifyAndAddMeasurementResult(OBS3_TURB_VAR_NUM, calibResult); diff --git a/src/sensors/TurnerCyclops.cpp b/src/sensors/TurnerCyclops.cpp index f23792929..63b7f67e9 100644 --- a/src/sensors/TurnerCyclops.cpp +++ b/src/sensors/TurnerCyclops.cpp @@ -71,8 +71,7 @@ bool TurnerCyclops::addSingleMeasurementResult(void) { } bool success = false; - float adcVoltage = -9999; - float calibResult = -9999; + float adcVoltage = -9999.0f; MS_DBG(getSensorNameAndLocation(), F("is reporting:")); @@ -90,7 +89,7 @@ bool TurnerCyclops::addSingleMeasurementResult(void) { adcVoltage); if (success) { // Apply the unique calibration curve for the given sensor - calibResult = (_conc_std / (_volt_std - _volt_blank)) * + float calibResult = (_conc_std / (_volt_std - _volt_blank)) * (adcVoltage - _volt_blank); MS_DBG(F(" calibResult:"), calibResult); verifyAndAddMeasurementResult(CYCLOPS_VAR_NUM, calibResult); diff --git a/src/sensors/TurnerTurbidityPlus.cpp b/src/sensors/TurnerTurbidityPlus.cpp index 9e771eb26..66f6370d7 100644 --- a/src/sensors/TurnerTurbidityPlus.cpp +++ b/src/sensors/TurnerTurbidityPlus.cpp @@ -121,9 +121,8 @@ bool TurnerTurbidityPlus::addSingleMeasurementResult(void) { return bumpMeasurementAttemptCount(false); } - bool success = false; - float adcVoltage = -9999; - float calibResult = -9999; + bool success = false; + float adcVoltage = -9999; MS_DBG(getSensorNameAndLocation(), F("is reporting:")); @@ -142,12 +141,12 @@ bool TurnerTurbidityPlus::addSingleMeasurementResult(void) { if (success) { // Apply the unique calibration curve for the given sensor - calibResult = (_conc_std / (_volt_std - _volt_blank)) * + float calibResult = (_conc_std / (_volt_std - _volt_blank)) * (adcVoltage - _volt_blank); MS_DBG(F(" calibResult:"), String(calibResult, 3)); - verifyAndAddMeasurementResult(TURBIDITY_PLUS_VAR_NUM, calibResult); verifyAndAddMeasurementResult(TURBIDITY_PLUS_VOLTAGE_VAR_NUM, adcVoltage); + verifyAndAddMeasurementResult(TURBIDITY_PLUS_VAR_NUM, calibResult); } else { MS_DBG(F(" Failed to read differential voltage from analog reader")); } From 650302e55a8b9ec3ef769d76bf5787cd8ff47e05 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Tue, 24 Feb 2026 14:01:59 -0500 Subject: [PATCH 296/533] Made default voltage multiplier 1.0f Signed-off-by: Sara Damiano --- src/sensors/AnalogVoltageBase.h | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/src/sensors/AnalogVoltageBase.h b/src/sensors/AnalogVoltageBase.h index cc3df49cd..79d136cdb 100644 --- a/src/sensors/AnalogVoltageBase.h +++ b/src/sensors/AnalogVoltageBase.h @@ -43,9 +43,10 @@ class AnalogVoltageBase { * @param voltageMultiplier The voltage multiplier for any voltage dividers * @param supplyVoltage The supply/operating voltage for the analog system */ - AnalogVoltageBase(float voltageMultiplier = 1.0, + AnalogVoltageBase(float voltageMultiplier = 1.0f, float supplyVoltage = OPERATING_VOLTAGE) - : _voltageMultiplier(voltageMultiplier), + : _voltageMultiplier((voltageMultiplier > 0.0f) ? voltageMultiplier + : 1.0f), _supplyVoltage(supplyVoltage) {} /** @@ -57,14 +58,15 @@ class AnalogVoltageBase { * @brief Set the voltage multiplier for voltage divider calculations * * @param voltageMultiplier The multiplier value for voltage scaling - * - * @note The multiplier must be positive (> 0). Values <= 0 will be - * automatically clamped to 0.001 to prevent division-by-zero errors - * and maintain valid voltage calculations. + * + * @note The multiplier must be positive (> 0). Values <= 0 will be + * set to 1 to prevent division-by-zero errors and maintain valid voltage + * calculations. */ virtual void setVoltageMultiplier(float voltageMultiplier) { - // Clamp to minimum value to prevent division-by-zero and invalid readings - _voltageMultiplier = (voltageMultiplier > 0.0f) ? voltageMultiplier : 0.001f; + // If the input voltage multiplier is not positive, set it to 1. + _voltageMultiplier = (voltageMultiplier > 0.0f) ? voltageMultiplier + : 1.0f; } /** @@ -82,9 +84,8 @@ class AnalogVoltageBase { * @param supplyVoltage The supply voltage in volts */ virtual void setSupplyVoltage(float supplyVoltage) { - _supplyVoltage = supplyVoltage; + if (supplyVoltage > 0.0f) { _supplyVoltage = supplyVoltage; } } - /** * @brief Get the supply voltage for the analog system * From f63435088e112d8ad62121e52a2a4bafeca2b0bf Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Tue, 24 Feb 2026 14:02:33 -0500 Subject: [PATCH 297/533] Disambiguate getSensorLocation Signed-off-by: Sara Damiano --- src/sensors/ProcessorAnalog.cpp | 4 ++++ src/sensors/ProcessorAnalog.h | 2 ++ 2 files changed, 6 insertions(+) diff --git a/src/sensors/ProcessorAnalog.cpp b/src/sensors/ProcessorAnalog.cpp index c64027ebc..f3815e9ff 100644 --- a/src/sensors/ProcessorAnalog.cpp +++ b/src/sensors/ProcessorAnalog.cpp @@ -92,6 +92,10 @@ ProcessorAnalog::ProcessorAnalog(int8_t powerPin, int8_t dataPin, // Destructor ProcessorAnalog::~ProcessorAnalog() {} +String ProcessorAnalog::getSensorLocation() { + return ProcessorAnalogBase::getSensorLocation(); +} + bool ProcessorAnalog::addSingleMeasurementResult(void) { // Immediately quit if the measurement was not successfully started if (!getStatusBit(MEASUREMENT_SUCCESSFUL)) { diff --git a/src/sensors/ProcessorAnalog.h b/src/sensors/ProcessorAnalog.h index b82ebd933..d8d59a54e 100644 --- a/src/sensors/ProcessorAnalog.h +++ b/src/sensors/ProcessorAnalog.h @@ -256,6 +256,8 @@ class ProcessorAnalog : public Sensor, public ProcessorAnalogBase { */ ~ProcessorAnalog(); + String getSensorLocation() override; + bool addSingleMeasurementResult(void) override; }; From e7d704f0161f0d873bfc8f576e03304156a95767 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Tue, 24 Feb 2026 14:45:47 -0500 Subject: [PATCH 298/533] float tags Signed-off-by: Sara Damiano --- src/sensors/TIADS1x15.cpp | 44 ++++++++++++++++++--------------------- 1 file changed, 20 insertions(+), 24 deletions(-) diff --git a/src/sensors/TIADS1x15.cpp b/src/sensors/TIADS1x15.cpp index cda94083a..6a0ad3c8b 100644 --- a/src/sensors/TIADS1x15.cpp +++ b/src/sensors/TIADS1x15.cpp @@ -53,8 +53,8 @@ bool TIADS1x15Base::readVoltageSingleEnded(int8_t analogChannel, float& resultValue) { bool success = false; int16_t adcCounts = -9999; - float adcVoltage = -9999; - float scaledResult = -9999; + float adcVoltage = -9999.0f; + float scaledResult = -9999.0f; // Create an auxiliary ADC object // We create and set up the ADC object here so that each sensor using @@ -100,10 +100,10 @@ bool TIADS1x15Base::readVoltageSingleEnded(int8_t analogChannel, // Verify the range based on the actual power supplied to the ADS. // Valid range is approximately -0.3V to (supply voltage + 0.3V) with // absolute maximum of 5.5V per datasheet - float minValidVoltage = -0.3; - float maxValidVoltage = _supplyVoltage + 0.3; - if (maxValidVoltage > 5.5) { - maxValidVoltage = 5.5; // Absolute maximum per datasheet + float minValidVoltage = -0.3f; + float maxValidVoltage = _supplyVoltage + 0.3f; + if (maxValidVoltage > 5.5f) { + maxValidVoltage = 5.5f; // Absolute maximum per datasheet } MS_DBG(F(" ADS supply voltage:"), _supplyVoltage, F("V")); @@ -118,7 +118,7 @@ bool TIADS1x15Base::readVoltageSingleEnded(int8_t analogChannel, success = true; } else { MS_DBG(F(" ADC voltage "), adcVoltage, F("V out of valid range")); - resultValue = -9999; + resultValue = -9999.0f; } return success; @@ -129,8 +129,8 @@ bool TIADS1x15Base::readVoltageDifferential(int8_t analogChannel, float& resultValue) { bool success = false; int16_t adcCounts = -9999; - float adcVoltage = -9999; - float scaledResult = -9999; + float adcVoltage = -9999.0f; + float scaledResult = -9999.0f; // Create an auxiliary ADC object #ifndef MS_USE_ADS1015 @@ -150,8 +150,9 @@ bool TIADS1x15Base::readVoltageDifferential(int8_t analogChannel, // Validate differential channel combination if (!isValidDifferentialPair(analogChannel, analogReferenceChannel)) { - MS_DBG(F(" Invalid differential channel pair: "), analogChannel, - F("-"), analogReferenceChannel); + MS_DBG(F(" Unsupported differential channel combination: "), + analogChannel, F("-"), analogReferenceChannel); + MS_DBG(F(" Use canonical ordered pairs: 0-1, 0-3, 1-3, or 2-3")); return false; } @@ -167,11 +168,6 @@ bool TIADS1x15Base::readVoltageDifferential(int8_t analogChannel, adcCounts = ads.readADC_Differential_1_3(); } else if (analogChannel == 2 && analogReferenceChannel == 3) { adcCounts = ads.readADC_Differential_2_3(); - } else { - MS_DBG(F(" Unsupported differential channel combination: "), - analogChannel, F("-"), analogReferenceChannel); - MS_DBG(F(" Use canonical ordered pairs: 0-1, 0-3, 1-3, or 2-3")); - return false; } // Convert counts to voltage @@ -183,16 +179,16 @@ bool TIADS1x15Base::readVoltageDifferential(int8_t analogChannel, // Based on gain setting rather than supply voltage float fullScaleVoltage; switch (_adsGain) { - case GAIN_TWOTHIRDS: fullScaleVoltage = 6.144; break; - case GAIN_ONE: fullScaleVoltage = 4.096; break; - case GAIN_TWO: fullScaleVoltage = 2.048; break; - case GAIN_FOUR: fullScaleVoltage = 1.024; break; - case GAIN_EIGHT: fullScaleVoltage = 0.512; break; - case GAIN_SIXTEEN: fullScaleVoltage = 0.256; break; + case GAIN_TWOTHIRDS: fullScaleVoltage = 6.144f; break; + case GAIN_ONE: fullScaleVoltage = 4.096f; break; + case GAIN_TWO: fullScaleVoltage = 2.048f; break; + case GAIN_FOUR: fullScaleVoltage = 1.024f; break; + case GAIN_EIGHT: fullScaleVoltage = 0.512f; break; + case GAIN_SIXTEEN: fullScaleVoltage = 0.256f; break; default: MS_DBG(F(" Unknown ADS gain value:"), _adsGain, F(" using conservative 4.096V range")); - fullScaleVoltage = 4.096; // Conservative fallback + fullScaleVoltage = 4.096f; // Conservative fallback break; } float minValidVoltage = -fullScaleVoltage; @@ -209,7 +205,7 @@ bool TIADS1x15Base::readVoltageDifferential(int8_t analogChannel, success = true; } else { MS_DBG(F(" Differential voltage out of valid range")); - resultValue = -9999; + resultValue = -9999.0f; } return success; From adc82fabefa53cfd6bf07754f8a4b682caba7c6a Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Tue, 24 Feb 2026 14:46:20 -0500 Subject: [PATCH 299/533] use OPERATING_VOLTAGE for invalid supply voltage Signed-off-by: Sara Damiano --- src/sensors/AnalogVoltageBase.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/sensors/AnalogVoltageBase.h b/src/sensors/AnalogVoltageBase.h index 79d136cdb..200e931b6 100644 --- a/src/sensors/AnalogVoltageBase.h +++ b/src/sensors/AnalogVoltageBase.h @@ -84,7 +84,8 @@ class AnalogVoltageBase { * @param supplyVoltage The supply voltage in volts */ virtual void setSupplyVoltage(float supplyVoltage) { - if (supplyVoltage > 0.0f) { _supplyVoltage = supplyVoltage; } + _supplyVoltage = (supplyVoltage > 0.0f) ? supplyVoltage + : OPERATING_VOLTAGE; } /** * @brief Get the supply voltage for the analog system From 762c7caea9aa9fe0568ec3c603e0828ff51e99b2 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Tue, 24 Feb 2026 14:46:48 -0500 Subject: [PATCH 300/533] restructure string creation Signed-off-by: Sara Damiano --- src/sensors/ApogeeSQ212.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/sensors/ApogeeSQ212.cpp b/src/sensors/ApogeeSQ212.cpp index 777772930..4c5f0eb4f 100644 --- a/src/sensors/ApogeeSQ212.cpp +++ b/src/sensors/ApogeeSQ212.cpp @@ -45,8 +45,10 @@ ApogeeSQ212::~ApogeeSQ212() { String ApogeeSQ212::getSensorLocation(void) { if (_analogVoltageReader != nullptr) { - return _analogVoltageReader->getSensorLocation() + F("_Channel") + - String(_dataPin); + String sensorLocation = _analogVoltageReader->getSensorLocation(); + sensorLocation += F("_Channel"); + sensorLocation += String(_dataPin); + return sensorLocation; } else { String sensorLocation = F("Unknown_AnalogVoltageReader_Channel"); sensorLocation += String(_dataPin); From 1a9ad47bbc8e0774453ae3e779d029e987956a03 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Tue, 24 Feb 2026 14:48:21 -0500 Subject: [PATCH 301/533] Use AnalogVoltageBase for AlalogEC and ALS Signed-off-by: Sara Damiano --- src/sensors/AnalogElecConductivity.cpp | 133 ++++++++++++++----------- src/sensors/AnalogElecConductivity.h | 32 +++--- src/sensors/EverlightALSPT19.cpp | 117 ++++++++++++++-------- src/sensors/EverlightALSPT19.h | 33 ++++-- 4 files changed, 197 insertions(+), 118 deletions(-) diff --git a/src/sensors/AnalogElecConductivity.cpp b/src/sensors/AnalogElecConductivity.cpp index addf41fbc..12c92b05e 100644 --- a/src/sensors/AnalogElecConductivity.cpp +++ b/src/sensors/AnalogElecConductivity.cpp @@ -11,67 +11,54 @@ */ #include "AnalogElecConductivity.h" +#include "ProcessorAnalog.h" // For Mayfly version; the battery resistor depends on it -AnalogElecConductivity::AnalogElecConductivity(int8_t powerPin, int8_t dataPin, - float Rseries_ohms, - float sensorEC_Konst, - uint8_t measurementsToAverage) +AnalogElecConductivity::AnalogElecConductivity( + int8_t powerPin, int8_t dataPin, float Rseries_ohms, float sensorEC_Konst, + uint8_t measurementsToAverage, AnalogVoltageBase* analogVoltageReader) : Sensor("AnalogElecConductivity", ANALOGELECCONDUCTIVITY_NUM_VARIABLES, ANALOGELECCONDUCTIVITY_WARM_UP_TIME_MS, ANALOGELECCONDUCTIVITY_STABILIZATION_TIME_MS, ANALOGELECCONDUCTIVITY_MEASUREMENT_TIME_MS, powerPin, dataPin, measurementsToAverage, ANALOGELECCONDUCTIVITY_INC_CALC_VARIABLES), _Rseries_ohms(Rseries_ohms), - _sensorEC_Konst(sensorEC_Konst) {} -// Destructor -AnalogElecConductivity::~AnalogElecConductivity() {} - -String AnalogElecConductivity::getSensorLocation(void) { - String sensorLocation = F("anlgEc Proc Data/Pwr"); - sensorLocation += String(_dataPin) + "/" + String(_powerPin); - return sensorLocation; + _sensorEC_Konst(sensorEC_Konst) { + // If no analog voltage reader was provided, create a default one + if (analogVoltageReader == nullptr) { + _analogVoltageReader = new ProcessorAnalogBase(); + _ownsAnalogVoltageReader = true; + } else { + _analogVoltageReader = analogVoltageReader; + _ownsAnalogVoltageReader = false; + } } - -float AnalogElecConductivity::readEC() { - return readEC(_dataPin); +// Destructor +AnalogElecConductivity::~AnalogElecConductivity() { + // Clean up the analog voltage reader if we created it + if (_ownsAnalogVoltageReader && _analogVoltageReader != nullptr) { + delete _analogVoltageReader; + _analogVoltageReader = nullptr; + } } -float AnalogElecConductivity::readEC(uint8_t analogPinNum) { - uint32_t sensorEC_adc; - float Rwater_ohms; // literal value of water - float EC_uScm = -9999; // units are uS per cm - - // First measure the analog voltage. - // The return value from analogRead() is IN BITS NOT IN VOLTS!! - // Take a priming reading. - // First reading will be low - discard - analogRead(analogPinNum); - // Take the reading we'll keep - sensorEC_adc = analogRead(analogPinNum); - MS_DEEP_DBG("adc bits=", sensorEC_adc); - - if (0 == sensorEC_adc) { - // Prevent underflow, can never be outside of PROCESSOR_ADC_RANGE - sensorEC_adc = 1; +String AnalogElecConductivity::getSensorLocation(void) { + if (_analogVoltageReader != nullptr) { + String sensorLocation = _analogVoltageReader->getSensorLocation(); + sensorLocation += F("_anlgEc_"); + sensorLocation += String(_dataPin); + sensorLocation += F("_Pwr"); + sensorLocation += String(_powerPin); + return sensorLocation; + } else { + String sensorLocation = F("Unknown_AnalogVoltageReader_anlgEc_"); + sensorLocation += String(_dataPin); + sensorLocation += F("_Pwr"); + sensorLocation += String(_powerPin); + return sensorLocation; } - - // Estimate Resistance of Liquid - - // see the header for an explanation of this calculation - Rwater_ohms = _Rseries_ohms / - ((static_cast(PROCESSOR_ADC_RANGE) / - static_cast(sensorEC_adc)) - - 1); - MS_DEEP_DBG("ohms=", Rwater_ohms); - - // Convert to EC - EC_uScm = 1000000 / (Rwater_ohms * _sensorEC_Konst); - MS_DEEP_DBG("cond=", EC_uScm); - - return EC_uScm; } @@ -81,18 +68,52 @@ bool AnalogElecConductivity::addSingleMeasurementResult(void) { return bumpMeasurementAttemptCount(false); } - float sensorEC_uScm = -9999; + // Check if we have a valid analog voltage reader + if (_analogVoltageReader == nullptr) { + MS_DBG(getSensorNameAndLocation(), + F("No analog voltage reader available")); + return bumpMeasurementAttemptCount(false); + } - MS_DBG(getSensorNameAndLocation(), F("is reporting:")); + bool success = false; + float adcVoltage = -9999.0f; - sensorEC_uScm = readEC(_dataPin); - MS_DBG(F("Water EC (uSm/cm)"), sensorEC_uScm); + MS_DBG(getSensorNameAndLocation(), F("is reporting:")); - // NOTE: We don't actually have any criteria for if the reading was any good - // or not, so we mark it as successful no matter what. - verifyAndAddMeasurementResult(ANALOGELECCONDUCTIVITY_EC_VAR_NUM, - sensorEC_uScm); - return bumpMeasurementAttemptCount(true); + // Read the analog voltage using the AnalogVoltageBase interface + success = _analogVoltageReader->readVoltageSingleEnded(_dataPin, + adcVoltage); + + if (success) { + // Estimate Resistance of Liquid + // see the header for an explanation of this calculation + // Convert voltage back to ADC equivalent for existing calculation + float supplyVoltage = _analogVoltageReader->getSupplyVoltage(); + float adcRatio = adcVoltage / supplyVoltage; + + if (adcRatio >= 1.0) { + // Prevent division issues when voltage reaches supply voltage + adcRatio = 0.999; + } + + float Rwater_ohms = _Rseries_ohms * adcRatio / (1.0 - adcRatio); + MS_DBG(F(" Resistance:"), Rwater_ohms, F("ohms")); + + // Convert to EC + float EC_uScm = -9999.0f; // units are uS per cm + if (Rwater_ohms > 0) { + EC_uScm = 1000000.0f / (Rwater_ohms * _sensorEC_Konst); + MS_DBG(F("Water EC (uSm/cm)"), EC_uScm); + verifyAndAddMeasurementResult(ANALOGELECCONDUCTIVITY_EC_VAR_NUM, + EC_uScm); + } else { + MS_DBG(F(" Invalid resistance; cannot calculate EC")); + success = false; + } + } else { + MS_DBG(F(" Failed to get valid voltage from analog reader")); + } + return bumpMeasurementAttemptCount(success); } // cSpell:ignore AnalogElecConductivity Rseries_ohms sensorEC_Konst Rwater_ohms diff --git a/src/sensors/AnalogElecConductivity.h b/src/sensors/AnalogElecConductivity.h index e575e037f..c4720f9b5 100644 --- a/src/sensors/AnalogElecConductivity.h +++ b/src/sensors/AnalogElecConductivity.h @@ -288,13 +288,23 @@ class AnalogElecConductivity : public Sensor { AnalogElecConductivity(int8_t powerPin, int8_t dataPin, float Rseries_ohms = RSERIES_OHMS_DEF, float sensorEC_Konst = SENSOREC_KONST_DEF, - uint8_t measurementsToAverage = 1); + uint8_t measurementsToAverage = 1, + AnalogVoltageBase* analogVoltageReader = nullptr); /** * @brief Destroy the AnalogElecConductivity object - no action needed. */ ~AnalogElecConductivity(); + // Delete copy constructor and copy assignment operator to prevent shallow + // copies + AnalogElecConductivity(const AnalogElecConductivity&) = delete; + AnalogElecConductivity& operator=(const AnalogElecConductivity&) = delete; + + // Delete move constructor and move assignment operator + AnalogElecConductivity(AnalogElecConductivity&&) = delete; + AnalogElecConductivity& operator=(AnalogElecConductivity&&) = delete; + /** * @brief Report the sensor info. * @@ -318,21 +328,6 @@ class AnalogElecConductivity : public Sensor { _Rseries_ohms = sourceResistance_ohms; } - /** - * @brief reads the calculated EC from an analog pin using the analog pin - * number set in the constructor. - * - * @return The electrical conductance value - */ - float readEC(void); - /** - * @brief reads the calculated EC from an analog pin. - * - * @param analogPinNum Analog port pin number - * @return The electrical conductance value - */ - float readEC(uint8_t analogPinNum); - private: /// @brief The resistance of the circuit resistor plus any series port /// resistance @@ -340,6 +335,11 @@ class AnalogElecConductivity : public Sensor { /// @brief the cell constant for the circuit float _sensorEC_Konst = SENSOREC_KONST_DEF; + AnalogVoltageBase* + _analogVoltageReader; ///< Pointer to analog voltage reader + bool _ownsAnalogVoltageReader; ///< Flag to track if this object owns the + ///< analog voltage reader and should delete + ///< it in the destructor }; /** diff --git a/src/sensors/EverlightALSPT19.cpp b/src/sensors/EverlightALSPT19.cpp index 8f54bb331..8efbf0eaf 100644 --- a/src/sensors/EverlightALSPT19.cpp +++ b/src/sensors/EverlightALSPT19.cpp @@ -9,30 +9,74 @@ */ #include "EverlightALSPT19.h" +#include "ProcessorAnalog.h" EverlightALSPT19::EverlightALSPT19(int8_t powerPin, int8_t dataPin, float supplyVoltage, float loadResistor, - uint8_t measurementsToAverage) + uint8_t measurementsToAverage, + AnalogVoltageBase* analogVoltageReader) : Sensor("Everlight ALS-PT19", ALSPT19_NUM_VARIABLES, ALSPT19_WARM_UP_TIME_MS, ALSPT19_STABILIZATION_TIME_MS, ALSPT19_MEASUREMENT_TIME_MS, powerPin, dataPin, measurementsToAverage, ALSPT19_INC_CALC_VARIABLES), _supplyVoltage(supplyVoltage), - _loadResistor(loadResistor) {} -#if defined(BUILT_IN_ALS_POWER_PIN) && defined(BUILT_IN_ALS_DATA_PIN) && \ - defined(BUILT_IN_ALS_SUPPLY_VOLTAGE) && \ - defined(BUILT_IN_ALS_LOADING_RESISTANCE) -EverlightALSPT19::EverlightALSPT19(uint8_t measurementsToAverage) + _loadResistor(loadResistor) { + // If no analog voltage reader was provided, create a default one + if (analogVoltageReader == nullptr) { + _analogVoltageReader = new ProcessorAnalogBase(); + _ownsAnalogVoltageReader = true; + } else { + _analogVoltageReader = analogVoltageReader; + _ownsAnalogVoltageReader = false; + } +} +#if (defined(BUILT_IN_ALS_POWER_PIN) && defined(BUILT_IN_ALS_DATA_PIN) && \ + defined(BUILT_IN_ALS_SUPPLY_VOLTAGE) && \ + defined(BUILT_IN_ALS_LOADING_RESISTANCE)) || \ + defined(DOXYGEN) +EverlightALSPT19::EverlightALSPT19(uint8_t measurementsToAverage, + AnalogVoltageBase* analogVoltageReader) : Sensor("Everlight ALS-PT19", ALSPT19_NUM_VARIABLES, ALSPT19_WARM_UP_TIME_MS, ALSPT19_STABILIZATION_TIME_MS, ALSPT19_MEASUREMENT_TIME_MS, BUILT_IN_ALS_POWER_PIN, BUILT_IN_ALS_DATA_PIN, measurementsToAverage, ALSPT19_INC_CALC_VARIABLES), _supplyVoltage(BUILT_IN_ALS_SUPPLY_VOLTAGE), - _loadResistor(BUILT_IN_ALS_LOADING_RESISTANCE) {} + _loadResistor(BUILT_IN_ALS_LOADING_RESISTANCE) { + // If no analog voltage reader was provided, create a default one + if (analogVoltageReader == nullptr) { + _analogVoltageReader = new ProcessorAnalogBase(); + _ownsAnalogVoltageReader = true; + } else { + _analogVoltageReader = analogVoltageReader; + _ownsAnalogVoltageReader = false; + } +} #endif -EverlightALSPT19::~EverlightALSPT19() {} + +// Destructor +EverlightALSPT19::~EverlightALSPT19() { + // Clean up the analog voltage reader if we created it + if (_ownsAnalogVoltageReader && _analogVoltageReader != nullptr) { + delete _analogVoltageReader; + _analogVoltageReader = nullptr; + } +} + + +String EverlightALSPT19::getSensorLocation(void) { + if (_analogVoltageReader != nullptr) { + String sensorLocation = _analogVoltageReader->getSensorLocation(); + sensorLocation += F("_"); + sensorLocation += String(_dataPin); + return sensorLocation; + } else { + String sensorLocation = F("Unknown_AnalogVoltageReader_"); + sensorLocation += String(_dataPin); + return sensorLocation; + } +} bool EverlightALSPT19::addSingleMeasurementResult(void) { @@ -41,45 +85,38 @@ bool EverlightALSPT19::addSingleMeasurementResult(void) { return bumpMeasurementAttemptCount(false); } - float volt_val = -9999; - float current_val = -9999; - float lux_val = -9999; + // Check if we have a valid analog voltage reader + if (_analogVoltageReader == nullptr) { + MS_DBG(getSensorNameAndLocation(), + F("No analog voltage reader available")); + return bumpMeasurementAttemptCount(false); + } + + bool success = false; + float adcVoltage = -9999.0f; MS_DBG(getSensorNameAndLocation(), F("is reporting:")); - // First measure the analog voltage. - // The return value from analogRead() is IN BITS NOT IN VOLTS!! - // Take a priming reading. - // First reading will be low - discard - analogRead(_dataPin); - // Take the reading we'll keep - uint32_t sensor_adc = analogRead(_dataPin); - MS_DEEP_DBG(" ADC Bits:", sensor_adc); + // Read the analog voltage using the AnalogVoltageBase interface + success = _analogVoltageReader->readVoltageSingleEnded(_dataPin, + adcVoltage); - if (sensor_adc == 0) { - volt_val = 0.0; - current_val = 0.0; - lux_val = 0.0; - } else { - // convert bits to volts - volt_val = (_supplyVoltage / static_cast(PROCESSOR_ADC_MAX)) * - static_cast(sensor_adc); + if (success) { // convert volts to current // resistance is entered in kΩ and we want µA - current_val = (volt_val / (_loadResistor * 1000)) * 1e6; + float current_val = (adcVoltage / (_loadResistor * 1000)) * 1e6; + MS_DBG(F(" Current:"), current_val, F("µA")); + // convert current to illuminance // from sensor datasheet, typical 200µA current for 1000 Lux - lux_val = current_val * (1000. / 200.); - } - - MS_DBG(F(" Voltage:"), volt_val, F("V")); - MS_DBG(F(" Current:"), current_val, F("µA")); - MS_DBG(F(" Illuminance:"), lux_val, F("lux")); + float calibResult = current_val * (1000. / 200.); + MS_DBG(F(" Illuminance:"), calibResult, F("lux")); - // NOTE: We don't actually have any criteria for if the reading was any - // good or not, so we mark it as successful no matter what. - verifyAndAddMeasurementResult(ALSPT19_VOLTAGE_VAR_NUM, volt_val); - verifyAndAddMeasurementResult(ALSPT19_CURRENT_VAR_NUM, current_val); - verifyAndAddMeasurementResult(ALSPT19_ILLUMINANCE_VAR_NUM, lux_val); - return bumpMeasurementAttemptCount(true); + verifyAndAddMeasurementResult(ALSPT19_VOLTAGE_VAR_NUM, adcVoltage); + verifyAndAddMeasurementResult(ALSPT19_CURRENT_VAR_NUM, current_val); + verifyAndAddMeasurementResult(ALSPT19_ILLUMINANCE_VAR_NUM, calibResult); + } else { + MS_DBG(F(" Failed to get valid voltage from analog reader")); + } + return bumpMeasurementAttemptCount(success); } diff --git a/src/sensors/EverlightALSPT19.h b/src/sensors/EverlightALSPT19.h index 5f67b61ed..bf590c2b0 100644 --- a/src/sensors/EverlightALSPT19.h +++ b/src/sensors/EverlightALSPT19.h @@ -219,17 +219,22 @@ class EverlightALSPT19 : public Sensor { * as analog pins generally are numbered with an "A" in front of the number * - ie, A1. * @param supplyVoltage The power supply voltage (in volts) of the ALS-PT19. + * This does not have to be the same as the board operating voltage or the + * supply voltage of the analog AnalogVoltageBase reader, but it is needed + * to calculate the current and illuminance. * @param loadResistor The size of the loading resistor, in kilaohms (kΩ). * @param measurementsToAverage The number of measurements to take and * average before giving a "final" result from the sensor; optional with a * default value of 10. */ EverlightALSPT19(int8_t powerPin, int8_t dataPin, float supplyVoltage, - float loadResistor, uint8_t measurementsToAverage = 10); + float loadResistor, uint8_t measurementsToAverage = 10, + AnalogVoltageBase* analogVoltageReader = nullptr); -#if defined(BUILT_IN_ALS_POWER_PIN) && defined(BUILT_IN_ALS_DATA_PIN) && \ - defined(BUILT_IN_ALS_SUPPLY_VOLTAGE) && \ - defined(BUILT_IN_ALS_LOADING_RESISTANCE) +#if (defined(BUILT_IN_ALS_POWER_PIN) && defined(BUILT_IN_ALS_DATA_PIN) && \ + defined(BUILT_IN_ALS_SUPPLY_VOLTAGE) && \ + defined(BUILT_IN_ALS_LOADING_RESISTANCE)) || \ + defined(DOXYGEN) /** * @brief Construct a new EverlightALSPT19 object with pins and resistors * for boards with a built-in ALS-PT19 configured in KnownProcessors.h. @@ -242,14 +247,25 @@ class EverlightALSPT19 : public Sensor { * average before giving a "final" result from the sensor; optional with a * default value of 10. */ - explicit EverlightALSPT19(uint8_t measurementsToAverage = 10); + explicit EverlightALSPT19(uint8_t measurementsToAverage = 10, + AnalogVoltageBase* analogVoltageReader = nullptr); #endif /** * @brief Destroy the EverlightALSPT19 object - no action needed. */ ~EverlightALSPT19(); - bool addSingleMeasurementResult(void) override; + // Delete copy constructor and copy assignment operator to prevent shallow + // copies + EverlightALSPT19(const EverlightALSPT19&) = delete; + EverlightALSPT19& operator=(const EverlightALSPT19&) = delete; + + // Delete move constructor and move assignment operator + EverlightALSPT19(EverlightALSPT19&&) = delete; + EverlightALSPT19& operator=(EverlightALSPT19&&) = delete; + + String getSensorLocation(void) override; + bool addSingleMeasurementResult(void) override; private: /** @@ -260,6 +276,11 @@ class EverlightALSPT19 : public Sensor { * @brief The loading resistance */ float _loadResistor; + AnalogVoltageBase* + _analogVoltageReader; ///< Pointer to analog voltage reader + bool _ownsAnalogVoltageReader; ///< Flag to track if this object owns the + ///< analog voltage reader and should delete + ///< it in the destructor }; From 74e7b62f8ac50213641714488f7eb945322c51b9 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Tue, 24 Feb 2026 14:52:16 -0500 Subject: [PATCH 302/533] Comment change Signed-off-by: Sara Damiano --- src/sensors/AlphasenseCO2.h | 10 +++++----- src/sensors/AnalogElecConductivity.h | 10 +++++----- src/sensors/ApogeeSQ212.h | 10 +++++----- src/sensors/CampbellOBS3.h | 10 +++++----- src/sensors/EverlightALSPT19.h | 10 +++++----- src/sensors/TurnerCyclops.h | 10 +++++----- src/sensors/TurnerTurbidityPlus.h | 10 +++++----- 7 files changed, 35 insertions(+), 35 deletions(-) diff --git a/src/sensors/AlphasenseCO2.h b/src/sensors/AlphasenseCO2.h index 410f250cf..8445b6ffa 100644 --- a/src/sensors/AlphasenseCO2.h +++ b/src/sensors/AlphasenseCO2.h @@ -322,11 +322,11 @@ class AlphasenseCO2 : public Sensor { * @brief The second (reference) pin for differential voltage measurements. */ int8_t _analogReferenceChannel; - AnalogVoltageBase* - _analogVoltageReader; ///< Pointer to analog voltage reader - bool _ownsAnalogVoltageReader; ///< Flag to track if this object owns the - ///< analog voltage reader and should delete - ///< it in the destructor + /// @brief Pointer to analog voltage reader + AnalogVoltageBase* _analogVoltageReader; + /// @brief Flag to track if this object owns the analog voltage reader and + /// should delete it in the destructor + bool _ownsAnalogVoltageReader; }; diff --git a/src/sensors/AnalogElecConductivity.h b/src/sensors/AnalogElecConductivity.h index c4720f9b5..e16507c8e 100644 --- a/src/sensors/AnalogElecConductivity.h +++ b/src/sensors/AnalogElecConductivity.h @@ -335,11 +335,11 @@ class AnalogElecConductivity : public Sensor { /// @brief the cell constant for the circuit float _sensorEC_Konst = SENSOREC_KONST_DEF; - AnalogVoltageBase* - _analogVoltageReader; ///< Pointer to analog voltage reader - bool _ownsAnalogVoltageReader; ///< Flag to track if this object owns the - ///< analog voltage reader and should delete - ///< it in the destructor + /// @brief Pointer to analog voltage reader + AnalogVoltageBase* _analogVoltageReader; + /// @brief Flag to track if this object owns the analog voltage reader and + /// should delete it in the destructor + bool _ownsAnalogVoltageReader; }; /** diff --git a/src/sensors/ApogeeSQ212.h b/src/sensors/ApogeeSQ212.h index ab04fbb48..297cdff05 100644 --- a/src/sensors/ApogeeSQ212.h +++ b/src/sensors/ApogeeSQ212.h @@ -291,11 +291,11 @@ class ApogeeSQ212 : public Sensor { bool addSingleMeasurementResult(void) override; private: - AnalogVoltageBase* - _analogVoltageReader; ///< Pointer to analog voltage reader - bool _ownsAnalogVoltageReader; ///< Flag to track if this object owns the - ///< analog voltage reader and should delete - ///< it in the destructor + /// @brief Pointer to analog voltage reader + AnalogVoltageBase* _analogVoltageReader; + /// @brief Flag to track if this object owns the analog voltage reader and + /// should delete it in the destructor + bool _ownsAnalogVoltageReader; }; diff --git a/src/sensors/CampbellOBS3.h b/src/sensors/CampbellOBS3.h index 326e384f3..f53e5659f 100644 --- a/src/sensors/CampbellOBS3.h +++ b/src/sensors/CampbellOBS3.h @@ -288,11 +288,11 @@ class CampbellOBS3 : public Sensor { float _x2_coeff_A; ///< Internal reference to the x^2 coefficient float _x1_coeff_B; ///< Internal reference to the x coefficient float _x0_coeff_C; ///< Internal reference to the x^0 coefficient - AnalogVoltageBase* - _analogVoltageReader; ///< Pointer to analog voltage reader - bool _ownsAnalogVoltageReader; ///< Flag to track if this object owns the - ///< analog voltage reader and should delete - ///< it in the destructor + /// @brief Pointer to analog voltage reader + AnalogVoltageBase* _analogVoltageReader; + /// @brief Flag to track if this object owns the analog voltage reader and + /// should delete it in the destructor + bool _ownsAnalogVoltageReader; }; diff --git a/src/sensors/EverlightALSPT19.h b/src/sensors/EverlightALSPT19.h index bf590c2b0..646cb5082 100644 --- a/src/sensors/EverlightALSPT19.h +++ b/src/sensors/EverlightALSPT19.h @@ -276,11 +276,11 @@ class EverlightALSPT19 : public Sensor { * @brief The loading resistance */ float _loadResistor; - AnalogVoltageBase* - _analogVoltageReader; ///< Pointer to analog voltage reader - bool _ownsAnalogVoltageReader; ///< Flag to track if this object owns the - ///< analog voltage reader and should delete - ///< it in the destructor + /// @brief Pointer to analog voltage reader + AnalogVoltageBase* _analogVoltageReader; + /// @brief Flag to track if this object owns the analog voltage reader and + /// should delete it in the destructor + bool _ownsAnalogVoltageReader; }; diff --git a/src/sensors/TurnerCyclops.h b/src/sensors/TurnerCyclops.h index a14ddcb26..a2e766278 100644 --- a/src/sensors/TurnerCyclops.h +++ b/src/sensors/TurnerCyclops.h @@ -367,11 +367,11 @@ class TurnerCyclops : public Sensor { * settings. */ float _volt_blank; - AnalogVoltageBase* - _analogVoltageReader; ///< Pointer to analog voltage reader - bool _ownsAnalogVoltageReader; ///< Flag to track if this object owns the - ///< analog voltage reader and should delete - ///< it in the destructor + /// @brief Pointer to analog voltage reader + AnalogVoltageBase* _analogVoltageReader; + /// @brief Flag to track if this object owns the analog voltage reader and + /// should delete it in the destructor + bool _ownsAnalogVoltageReader; }; diff --git a/src/sensors/TurnerTurbidityPlus.h b/src/sensors/TurnerTurbidityPlus.h index fcebc4764..d7599992a 100644 --- a/src/sensors/TurnerTurbidityPlus.h +++ b/src/sensors/TurnerTurbidityPlus.h @@ -328,11 +328,11 @@ class TurnerTurbidityPlus : public Sensor { * @brief The second (reference) pin for differential voltage measurements. */ int8_t _analogReferenceChannel; - AnalogVoltageBase* - _analogVoltageReader; ///< Pointer to analog voltage reader - bool _ownsAnalogVoltageReader; ///< Flag to track if this object owns the - ///< analog voltage reader and should delete - ///< it in the destructor + /// @brief Pointer to analog voltage reader + AnalogVoltageBase* _analogVoltageReader; + /// @brief Flag to track if this object owns the analog voltage reader and + /// should delete it in the destructor + bool _ownsAnalogVoltageReader; }; From fb8ae847fd087b01fbc91853ca742eb8c91ade56 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Tue, 24 Feb 2026 15:14:07 -0500 Subject: [PATCH 303/533] Some comments and float tags Signed-off-by: Sara Damiano --- examples/menu_a_la_carte/menu_a_la_carte.ino | 3 ++- src/sensors/AnalogElecConductivity.cpp | 2 +- src/sensors/AnalogElecConductivity.h | 3 +++ src/sensors/AnalogVoltageBase.h | 12 +++++++----- src/sensors/EverlightALSPT19.h | 5 ++++- src/sensors/ProcessorAnalog.cpp | 2 +- src/sensors/TIADS1x15.cpp | 2 +- src/sensors/TurnerTurbidityPlus.h | 2 +- 8 files changed, 20 insertions(+), 11 deletions(-) diff --git a/examples/menu_a_la_carte/menu_a_la_carte.ino b/examples/menu_a_la_carte/menu_a_la_carte.ino index 7989d618d..d545706dc 100644 --- a/examples/menu_a_la_carte/menu_a_la_carte.ino +++ b/examples/menu_a_la_carte/menu_a_la_carte.ino @@ -1608,7 +1608,8 @@ Variable* alsPt19Lux = new EverlightALSPT19_Illuminance( const int8_t ADSPower = sensorPowerPin; // Power pin const int8_t ADSChannel = 2; // The ADS channel of interest const float voltageMultiplier = - 10.0f; // Voltage multiplier if using a voltage divider + 10.0f; // Voltage multiplier: 1.0f for direct connection, (R_top + R_bottom) / R_bottom for voltage divider + // Default 10.0f assumes specific divider; change to 1.0f for direct ADS connection const adsGain_t adsGain = GAIN_ONE; // The internal gain setting for the ADS const uint8_t evADSi2c_addr = 0x48; // The I2C address of the ADS1115 ADC const uint8_t VoltReadsToAvg = 1; // Only read one sample diff --git a/src/sensors/AnalogElecConductivity.cpp b/src/sensors/AnalogElecConductivity.cpp index 12c92b05e..3874b12f6 100644 --- a/src/sensors/AnalogElecConductivity.cpp +++ b/src/sensors/AnalogElecConductivity.cpp @@ -103,7 +103,7 @@ bool AnalogElecConductivity::addSingleMeasurementResult(void) { float EC_uScm = -9999.0f; // units are uS per cm if (Rwater_ohms > 0) { EC_uScm = 1000000.0f / (Rwater_ohms * _sensorEC_Konst); - MS_DBG(F("Water EC (uSm/cm)"), EC_uScm); + MS_DBG(F("Water EC (uS/cm)"), EC_uScm); verifyAndAddMeasurementResult(ANALOGELECCONDUCTIVITY_EC_VAR_NUM, EC_uScm); } else { diff --git a/src/sensors/AnalogElecConductivity.h b/src/sensors/AnalogElecConductivity.h index e16507c8e..e33f9ec95 100644 --- a/src/sensors/AnalogElecConductivity.h +++ b/src/sensors/AnalogElecConductivity.h @@ -284,6 +284,9 @@ class AnalogElecConductivity : public Sensor { * typical standard sized lamp-type plug. * @param measurementsToAverage The number of measurements to average; * optional with default value of 1. + * @param analogVoltageReader Pointer to an AnalogVoltageBase object for + * voltage measurements; optional with a default of a new ProcessorAnalogBase + * object. The private member _analogVoltageReader will store this pointer. */ AnalogElecConductivity(int8_t powerPin, int8_t dataPin, float Rseries_ohms = RSERIES_OHMS_DEF, diff --git a/src/sensors/AnalogVoltageBase.h b/src/sensors/AnalogVoltageBase.h index 200e931b6..6c3b6aac2 100644 --- a/src/sensors/AnalogVoltageBase.h +++ b/src/sensors/AnalogVoltageBase.h @@ -31,9 +31,11 @@ * * This class provides a unified interface for analog voltage reading, * whether from external ADCs (like TI ADS1x15) or processor built-in ADCs. - * Classes that inherit from this base must implement the - * readVoltageSingleEnded method to provide their specific voltage reading - * implementation. + * Classes that inherit from this base must implement three pure virtual + * methods: + * - readVoltageSingleEnded() for single-ended voltage measurements, + * - readVoltageDifferential() for differential voltage measurements, and + * - getSensorLocation() to provide sensor location identification. */ class AnalogVoltageBase { public: @@ -141,14 +143,14 @@ class AnalogVoltageBase { protected: /** - * @brief Internal reference to the voltage multiplier + * @brief Stored voltage multiplier value * * Multiplier to apply for voltage divider calculations */ float _voltageMultiplier; /** - * @brief Internal reference to the supply voltage + * @brief Stored supply voltage value * * For TIADS1x15: the ADS supply voltage * For ProcessorAnalog: the processor operating voltage diff --git a/src/sensors/EverlightALSPT19.h b/src/sensors/EverlightALSPT19.h index 646cb5082..74da64463 100644 --- a/src/sensors/EverlightALSPT19.h +++ b/src/sensors/EverlightALSPT19.h @@ -251,7 +251,10 @@ class EverlightALSPT19 : public Sensor { AnalogVoltageBase* analogVoltageReader = nullptr); #endif /** - * @brief Destroy the EverlightALSPT19 object - no action needed. + * @brief Destroy the EverlightALSPT19 object. + * + * Conditionally deletes the _analogVoltageReader member if the ownership + * flag _ownsAnalogVoltageReader is true, otherwise leaves it unmodified. */ ~EverlightALSPT19(); diff --git a/src/sensors/ProcessorAnalog.cpp b/src/sensors/ProcessorAnalog.cpp index f3815e9ff..cd61cc7fe 100644 --- a/src/sensors/ProcessorAnalog.cpp +++ b/src/sensors/ProcessorAnalog.cpp @@ -68,7 +68,7 @@ bool ProcessorAnalogBase::readVoltageDifferential( int8_t /*analogChannel*/, int8_t /*analogReferenceChannel*/, float& resultValue) { // ProcessorAnalog does not support differential measurements - resultValue = -9999.0; + resultValue = -9999.0f; return false; } diff --git a/src/sensors/TIADS1x15.cpp b/src/sensors/TIADS1x15.cpp index 6a0ad3c8b..b61d186a4 100644 --- a/src/sensors/TIADS1x15.cpp +++ b/src/sensors/TIADS1x15.cpp @@ -301,7 +301,7 @@ bool TIADS1x15::addSingleMeasurementResult(void) { MS_DBG(getSensorNameAndLocation(), F("is reporting:")); - float resultValue = -9999; + float resultValue = -9999.0f; bool success = false; // Use differential or single-ended reading based on configuration diff --git a/src/sensors/TurnerTurbidityPlus.h b/src/sensors/TurnerTurbidityPlus.h index d7599992a..37fae701c 100644 --- a/src/sensors/TurnerTurbidityPlus.h +++ b/src/sensors/TurnerTurbidityPlus.h @@ -238,7 +238,7 @@ class TurnerTurbidityPlus : public Sensor { * * @attention For 3.3V processors like the Mayfly, The Turner's 0-5V output * signal must be shifted down to a maximum of 3.3V. This can be done either - * with a level-shifting chip (e.g. Adafruit BSS38), OR by connecting the + * with a level-shifting chip (e.g. Adafruit BSS138), OR by connecting the * Turner's output signal via a voltage divider. By default, the * TurnerTurbidityPlus object does **NOT** include any level-shifting or * voltage dividers. To have a voltage divider applied correctly, you must From cd5319ac947ca723c21b26d93b78f82aeed47dea Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Tue, 24 Feb 2026 15:14:25 -0500 Subject: [PATCH 304/533] const number values Signed-off-by: Sara Damiano --- src/SensorBase.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/SensorBase.h b/src/SensorBase.h index 24fbeffb1..4f4c04d09 100644 --- a/src/SensorBase.h +++ b/src/SensorBase.h @@ -716,7 +716,7 @@ class Sensor { * calculated within the library for the sensor. The @ref _incCalcValues * are *included* in this total. */ - uint8_t _numReturnedValues; + const uint8_t _numReturnedValues; /** * @brief The number of included calculated variables from the sensor, if * any. @@ -726,7 +726,7 @@ class Sensor { * from any calculated variables that are created on-the-fly and depend on * multiple other sensors. */ - uint8_t _incCalcValues; + const uint8_t _incCalcValues; /** * @brief The number of measurements from the sensor to average. * From 2219914981c304f30d03d00a6d9326e50a74f67b Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Tue, 24 Feb 2026 15:15:56 -0500 Subject: [PATCH 305/533] Verify _analogVoltageReader was created Signed-off-by: Sara Damiano --- src/sensors/AlphasenseCO2.cpp | 8 ++++++-- src/sensors/AnalogElecConductivity.cpp | 8 ++++++-- src/sensors/ApogeeSQ212.cpp | 6 +++++- src/sensors/CampbellOBS3.cpp | 8 ++++++-- src/sensors/EverlightALSPT19.cpp | 14 +++++++++++--- src/sensors/TurnerCyclops.cpp | 6 +++++- src/sensors/TurnerTurbidityPlus.cpp | 8 ++++++-- 7 files changed, 45 insertions(+), 13 deletions(-) diff --git a/src/sensors/AlphasenseCO2.cpp b/src/sensors/AlphasenseCO2.cpp index b88c0b518..d87eade3e 100644 --- a/src/sensors/AlphasenseCO2.cpp +++ b/src/sensors/AlphasenseCO2.cpp @@ -29,8 +29,12 @@ AlphasenseCO2::AlphasenseCO2(int8_t powerPin, int8_t analogChannel, _analogReferenceChannel(analogReferenceChannel) { // If no analog voltage reader was provided, create a default one if (analogVoltageReader == nullptr) { - _analogVoltageReader = new TIADS1x15Base(); - _ownsAnalogVoltageReader = true; + _analogVoltageReader = new TIADS1x15Base(); + if (_analogVoltageReader != nullptr) { + _ownsAnalogVoltageReader = true; + } else { + _ownsAnalogVoltageReader = false; + } } else { _analogVoltageReader = analogVoltageReader; _ownsAnalogVoltageReader = false; diff --git a/src/sensors/AnalogElecConductivity.cpp b/src/sensors/AnalogElecConductivity.cpp index 3874b12f6..34703de29 100644 --- a/src/sensors/AnalogElecConductivity.cpp +++ b/src/sensors/AnalogElecConductivity.cpp @@ -26,8 +26,12 @@ AnalogElecConductivity::AnalogElecConductivity( _sensorEC_Konst(sensorEC_Konst) { // If no analog voltage reader was provided, create a default one if (analogVoltageReader == nullptr) { - _analogVoltageReader = new ProcessorAnalogBase(); - _ownsAnalogVoltageReader = true; + _analogVoltageReader = new ProcessorAnalogBase(); + if (_analogVoltageReader != nullptr) { + _ownsAnalogVoltageReader = true; + } else { + _ownsAnalogVoltageReader = false; + } } else { _analogVoltageReader = analogVoltageReader; _ownsAnalogVoltageReader = false; diff --git a/src/sensors/ApogeeSQ212.cpp b/src/sensors/ApogeeSQ212.cpp index 4c5f0eb4f..ee440ddb7 100644 --- a/src/sensors/ApogeeSQ212.cpp +++ b/src/sensors/ApogeeSQ212.cpp @@ -26,7 +26,11 @@ ApogeeSQ212::ApogeeSQ212(int8_t powerPin, uint8_t analogChannel, // If no analog voltage reader was provided, create a default one if (analogVoltageReader == nullptr) { _analogVoltageReader = new TIADS1x15Base(); - _ownsAnalogVoltageReader = true; + if (_analogVoltageReader != nullptr) { + _ownsAnalogVoltageReader = true; + } else { + _ownsAnalogVoltageReader = false; + } } else { _analogVoltageReader = analogVoltageReader; _ownsAnalogVoltageReader = false; diff --git a/src/sensors/CampbellOBS3.cpp b/src/sensors/CampbellOBS3.cpp index e8f049b77..1b82c290f 100644 --- a/src/sensors/CampbellOBS3.cpp +++ b/src/sensors/CampbellOBS3.cpp @@ -26,8 +26,12 @@ CampbellOBS3::CampbellOBS3(int8_t powerPin, uint8_t analogChannel, _x0_coeff_C(x0_coeff_C) { // If no analog voltage reader was provided, create a default one if (analogVoltageReader == nullptr) { - _analogVoltageReader = new TIADS1x15Base(); - _ownsAnalogVoltageReader = true; + _analogVoltageReader = new TIADS1x15Base(); + if (_analogVoltageReader != nullptr) { + _ownsAnalogVoltageReader = true; + } else { + _ownsAnalogVoltageReader = false; + } } else { _analogVoltageReader = analogVoltageReader; _ownsAnalogVoltageReader = false; diff --git a/src/sensors/EverlightALSPT19.cpp b/src/sensors/EverlightALSPT19.cpp index 8efbf0eaf..c453118d2 100644 --- a/src/sensors/EverlightALSPT19.cpp +++ b/src/sensors/EverlightALSPT19.cpp @@ -24,8 +24,12 @@ EverlightALSPT19::EverlightALSPT19(int8_t powerPin, int8_t dataPin, _loadResistor(loadResistor) { // If no analog voltage reader was provided, create a default one if (analogVoltageReader == nullptr) { - _analogVoltageReader = new ProcessorAnalogBase(); - _ownsAnalogVoltageReader = true; + _analogVoltageReader = new ProcessorAnalogBase(); + if (_analogVoltageReader != nullptr) { + _ownsAnalogVoltageReader = true; + } else { + _ownsAnalogVoltageReader = false; + } } else { _analogVoltageReader = analogVoltageReader; _ownsAnalogVoltageReader = false; @@ -47,7 +51,11 @@ EverlightALSPT19::EverlightALSPT19(uint8_t measurementsToAverage, // If no analog voltage reader was provided, create a default one if (analogVoltageReader == nullptr) { _analogVoltageReader = new ProcessorAnalogBase(); - _ownsAnalogVoltageReader = true; + if (_analogVoltageReader != nullptr) { + _ownsAnalogVoltageReader = true; + } else { + _ownsAnalogVoltageReader = false; + } } else { _analogVoltageReader = analogVoltageReader; _ownsAnalogVoltageReader = false; diff --git a/src/sensors/TurnerCyclops.cpp b/src/sensors/TurnerCyclops.cpp index 63b7f67e9..348c15bd1 100644 --- a/src/sensors/TurnerCyclops.cpp +++ b/src/sensors/TurnerCyclops.cpp @@ -28,7 +28,11 @@ TurnerCyclops::TurnerCyclops(int8_t powerPin, uint8_t analogChannel, // If no analog voltage reader was provided, create a default one if (analogVoltageReader == nullptr) { _analogVoltageReader = new TIADS1x15Base(); - _ownsAnalogVoltageReader = true; + if (_analogVoltageReader != nullptr) { + _ownsAnalogVoltageReader = true; + } else { + _ownsAnalogVoltageReader = false; + } } else { _analogVoltageReader = analogVoltageReader; _ownsAnalogVoltageReader = false; diff --git a/src/sensors/TurnerTurbidityPlus.cpp b/src/sensors/TurnerTurbidityPlus.cpp index 66f6370d7..c3814ad00 100644 --- a/src/sensors/TurnerTurbidityPlus.cpp +++ b/src/sensors/TurnerTurbidityPlus.cpp @@ -30,8 +30,12 @@ TurnerTurbidityPlus::TurnerTurbidityPlus( _analogReferenceChannel(analogReferenceChannel) { // If no analog voltage reader was provided, create a default one if (analogVoltageReader == nullptr) { - _analogVoltageReader = new TIADS1x15Base(); - _ownsAnalogVoltageReader = true; + _analogVoltageReader = new TIADS1x15Base(); + if (_analogVoltageReader != nullptr) { + _ownsAnalogVoltageReader = true; + } else { + _ownsAnalogVoltageReader = false; + } } else { _analogVoltageReader = analogVoltageReader; _ownsAnalogVoltageReader = false; From e287f7855f844cfbeed6d3a4c4710b1e6e33e916 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Tue, 24 Feb 2026 15:16:34 -0500 Subject: [PATCH 306/533] Forward declaration Signed-off-by: Sara Damiano --- src/sensors/AnalogElecConductivity.h | 3 +++ src/sensors/EverlightALSPT19.h | 2 ++ 2 files changed, 5 insertions(+) diff --git a/src/sensors/AnalogElecConductivity.h b/src/sensors/AnalogElecConductivity.h index e33f9ec95..a5e1911f5 100644 --- a/src/sensors/AnalogElecConductivity.h +++ b/src/sensors/AnalogElecConductivity.h @@ -260,6 +260,9 @@ #define ANALOGELECCONDUCTIVITY_EC_DEFAULT_CODE "anlgEc" /**@}*/ +// Forward declaration +class AnalogVoltageBase; + /** * @brief Class for the analog [Electrical Conductivity monitor](@ref * sensor_analog_cond) diff --git a/src/sensors/EverlightALSPT19.h b/src/sensors/EverlightALSPT19.h index 74da64463..04cf4a911 100644 --- a/src/sensors/EverlightALSPT19.h +++ b/src/sensors/EverlightALSPT19.h @@ -199,6 +199,8 @@ #define ALSPT19_ILLUMINANCE_DEFAULT_CODE "ALSPT19Lux" /**@}*/ +// Forward declaration +class AnalogVoltageBase; /* clang-format off */ /** From e2d3a9f391275ecdbacb9c057c63d915c86145d2 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Tue, 24 Feb 2026 15:17:02 -0500 Subject: [PATCH 307/533] Validate channel Signed-off-by: Sara Damiano --- src/sensors/TIADS1x15.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sensors/TIADS1x15.cpp b/src/sensors/TIADS1x15.cpp index b61d186a4..116d12a80 100644 --- a/src/sensors/TIADS1x15.cpp +++ b/src/sensors/TIADS1x15.cpp @@ -85,7 +85,7 @@ bool TIADS1x15Base::readVoltageSingleEnded(int8_t analogChannel, // Read Analog to Digital Converter (ADC) // Validate ADS1x15 channel range for single-ended measurements - if (analogChannel > 3) { + if (analogChannel < 0 || analogChannel > 3) { MS_DBG(F(" Invalid ADS1x15 channel "), analogChannel, F(", valid range is 0-3")); return false; From d735cd9c3a3481410680f1004ee9584c605ba05e Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Tue, 24 Feb 2026 15:17:21 -0500 Subject: [PATCH 308/533] validate supply voltage Signed-off-by: Sara Damiano --- src/sensors/AnalogVoltageBase.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/sensors/AnalogVoltageBase.h b/src/sensors/AnalogVoltageBase.h index 6c3b6aac2..ec1aa8f5d 100644 --- a/src/sensors/AnalogVoltageBase.h +++ b/src/sensors/AnalogVoltageBase.h @@ -49,7 +49,8 @@ class AnalogVoltageBase { float supplyVoltage = OPERATING_VOLTAGE) : _voltageMultiplier((voltageMultiplier > 0.0f) ? voltageMultiplier : 1.0f), - _supplyVoltage(supplyVoltage) {} + _supplyVoltage((supplyVoltage > 0.0f) ? supplyVoltage + : OPERATING_VOLTAGE) {} /** * @brief Destroy the AnalogVoltageBase object From bf9137d83839ac1527881369e9996d78521db6e9 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Tue, 24 Feb 2026 15:21:59 -0500 Subject: [PATCH 309/533] default values Signed-off-by: Sara Damiano --- src/sensors/AlphasenseCO2.h | 4 ++-- src/sensors/AnalogElecConductivity.h | 4 ++-- src/sensors/ApogeeSQ212.h | 4 ++-- src/sensors/CampbellOBS3.h | 4 ++-- src/sensors/EverlightALSPT19.h | 6 +++--- src/sensors/TurnerCyclops.h | 4 ++-- src/sensors/TurnerTurbidityPlus.h | 4 ++-- 7 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/sensors/AlphasenseCO2.h b/src/sensors/AlphasenseCO2.h index 8445b6ffa..e17f60b62 100644 --- a/src/sensors/AlphasenseCO2.h +++ b/src/sensors/AlphasenseCO2.h @@ -323,10 +323,10 @@ class AlphasenseCO2 : public Sensor { */ int8_t _analogReferenceChannel; /// @brief Pointer to analog voltage reader - AnalogVoltageBase* _analogVoltageReader; + AnalogVoltageBase* _analogVoltageReader = nullptr; /// @brief Flag to track if this object owns the analog voltage reader and /// should delete it in the destructor - bool _ownsAnalogVoltageReader; + bool _ownsAnalogVoltageReader = false; }; diff --git a/src/sensors/AnalogElecConductivity.h b/src/sensors/AnalogElecConductivity.h index a5e1911f5..d644232f4 100644 --- a/src/sensors/AnalogElecConductivity.h +++ b/src/sensors/AnalogElecConductivity.h @@ -342,10 +342,10 @@ class AnalogElecConductivity : public Sensor { /// @brief the cell constant for the circuit float _sensorEC_Konst = SENSOREC_KONST_DEF; /// @brief Pointer to analog voltage reader - AnalogVoltageBase* _analogVoltageReader; + AnalogVoltageBase* _analogVoltageReader = nullptr; /// @brief Flag to track if this object owns the analog voltage reader and /// should delete it in the destructor - bool _ownsAnalogVoltageReader; + bool _ownsAnalogVoltageReader = false; }; /** diff --git a/src/sensors/ApogeeSQ212.h b/src/sensors/ApogeeSQ212.h index 297cdff05..817c3fd5a 100644 --- a/src/sensors/ApogeeSQ212.h +++ b/src/sensors/ApogeeSQ212.h @@ -292,10 +292,10 @@ class ApogeeSQ212 : public Sensor { private: /// @brief Pointer to analog voltage reader - AnalogVoltageBase* _analogVoltageReader; + AnalogVoltageBase* _analogVoltageReader = nullptr; /// @brief Flag to track if this object owns the analog voltage reader and /// should delete it in the destructor - bool _ownsAnalogVoltageReader; + bool _ownsAnalogVoltageReader = false; }; diff --git a/src/sensors/CampbellOBS3.h b/src/sensors/CampbellOBS3.h index f53e5659f..191e6245c 100644 --- a/src/sensors/CampbellOBS3.h +++ b/src/sensors/CampbellOBS3.h @@ -289,10 +289,10 @@ class CampbellOBS3 : public Sensor { float _x1_coeff_B; ///< Internal reference to the x coefficient float _x0_coeff_C; ///< Internal reference to the x^0 coefficient /// @brief Pointer to analog voltage reader - AnalogVoltageBase* _analogVoltageReader; + AnalogVoltageBase* _analogVoltageReader = nullptr; /// @brief Flag to track if this object owns the analog voltage reader and /// should delete it in the destructor - bool _ownsAnalogVoltageReader; + bool _ownsAnalogVoltageReader = false; }; diff --git a/src/sensors/EverlightALSPT19.h b/src/sensors/EverlightALSPT19.h index 04cf4a911..6c66d2df8 100644 --- a/src/sensors/EverlightALSPT19.h +++ b/src/sensors/EverlightALSPT19.h @@ -254,7 +254,7 @@ class EverlightALSPT19 : public Sensor { #endif /** * @brief Destroy the EverlightALSPT19 object. - * + * * Conditionally deletes the _analogVoltageReader member if the ownership * flag _ownsAnalogVoltageReader is true, otherwise leaves it unmodified. */ @@ -282,10 +282,10 @@ class EverlightALSPT19 : public Sensor { */ float _loadResistor; /// @brief Pointer to analog voltage reader - AnalogVoltageBase* _analogVoltageReader; + AnalogVoltageBase* _analogVoltageReader = nullptr; /// @brief Flag to track if this object owns the analog voltage reader and /// should delete it in the destructor - bool _ownsAnalogVoltageReader; + bool _ownsAnalogVoltageReader = false; }; diff --git a/src/sensors/TurnerCyclops.h b/src/sensors/TurnerCyclops.h index a2e766278..e602fcc93 100644 --- a/src/sensors/TurnerCyclops.h +++ b/src/sensors/TurnerCyclops.h @@ -368,10 +368,10 @@ class TurnerCyclops : public Sensor { */ float _volt_blank; /// @brief Pointer to analog voltage reader - AnalogVoltageBase* _analogVoltageReader; + AnalogVoltageBase* _analogVoltageReader = nullptr; /// @brief Flag to track if this object owns the analog voltage reader and /// should delete it in the destructor - bool _ownsAnalogVoltageReader; + bool _ownsAnalogVoltageReader = false; }; diff --git a/src/sensors/TurnerTurbidityPlus.h b/src/sensors/TurnerTurbidityPlus.h index 37fae701c..3257d68c5 100644 --- a/src/sensors/TurnerTurbidityPlus.h +++ b/src/sensors/TurnerTurbidityPlus.h @@ -329,10 +329,10 @@ class TurnerTurbidityPlus : public Sensor { */ int8_t _analogReferenceChannel; /// @brief Pointer to analog voltage reader - AnalogVoltageBase* _analogVoltageReader; + AnalogVoltageBase* _analogVoltageReader = nullptr; /// @brief Flag to track if this object owns the analog voltage reader and /// should delete it in the destructor - bool _ownsAnalogVoltageReader; + bool _ownsAnalogVoltageReader = false; }; From d45e1499d4fb18d0d0c2fda0c3cb879a0fcbf4da Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Tue, 24 Feb 2026 15:25:03 -0500 Subject: [PATCH 310/533] Remove stupid check Signed-off-by: Sara Damiano --- src/sensors/AlphasenseCO2.cpp | 8 ++------ src/sensors/AnalogElecConductivity.cpp | 8 ++------ src/sensors/ApogeeSQ212.cpp | 6 +----- src/sensors/CampbellOBS3.cpp | 12 ++++-------- src/sensors/EverlightALSPT19.cpp | 14 +++----------- src/sensors/TurnerCyclops.cpp | 10 +++------- src/sensors/TurnerTurbidityPlus.cpp | 8 ++------ 7 files changed, 17 insertions(+), 49 deletions(-) diff --git a/src/sensors/AlphasenseCO2.cpp b/src/sensors/AlphasenseCO2.cpp index d87eade3e..b88c0b518 100644 --- a/src/sensors/AlphasenseCO2.cpp +++ b/src/sensors/AlphasenseCO2.cpp @@ -29,12 +29,8 @@ AlphasenseCO2::AlphasenseCO2(int8_t powerPin, int8_t analogChannel, _analogReferenceChannel(analogReferenceChannel) { // If no analog voltage reader was provided, create a default one if (analogVoltageReader == nullptr) { - _analogVoltageReader = new TIADS1x15Base(); - if (_analogVoltageReader != nullptr) { - _ownsAnalogVoltageReader = true; - } else { - _ownsAnalogVoltageReader = false; - } + _analogVoltageReader = new TIADS1x15Base(); + _ownsAnalogVoltageReader = true; } else { _analogVoltageReader = analogVoltageReader; _ownsAnalogVoltageReader = false; diff --git a/src/sensors/AnalogElecConductivity.cpp b/src/sensors/AnalogElecConductivity.cpp index 34703de29..3874b12f6 100644 --- a/src/sensors/AnalogElecConductivity.cpp +++ b/src/sensors/AnalogElecConductivity.cpp @@ -26,12 +26,8 @@ AnalogElecConductivity::AnalogElecConductivity( _sensorEC_Konst(sensorEC_Konst) { // If no analog voltage reader was provided, create a default one if (analogVoltageReader == nullptr) { - _analogVoltageReader = new ProcessorAnalogBase(); - if (_analogVoltageReader != nullptr) { - _ownsAnalogVoltageReader = true; - } else { - _ownsAnalogVoltageReader = false; - } + _analogVoltageReader = new ProcessorAnalogBase(); + _ownsAnalogVoltageReader = true; } else { _analogVoltageReader = analogVoltageReader; _ownsAnalogVoltageReader = false; diff --git a/src/sensors/ApogeeSQ212.cpp b/src/sensors/ApogeeSQ212.cpp index ee440ddb7..4c5f0eb4f 100644 --- a/src/sensors/ApogeeSQ212.cpp +++ b/src/sensors/ApogeeSQ212.cpp @@ -26,11 +26,7 @@ ApogeeSQ212::ApogeeSQ212(int8_t powerPin, uint8_t analogChannel, // If no analog voltage reader was provided, create a default one if (analogVoltageReader == nullptr) { _analogVoltageReader = new TIADS1x15Base(); - if (_analogVoltageReader != nullptr) { - _ownsAnalogVoltageReader = true; - } else { - _ownsAnalogVoltageReader = false; - } + _ownsAnalogVoltageReader = true; } else { _analogVoltageReader = analogVoltageReader; _ownsAnalogVoltageReader = false; diff --git a/src/sensors/CampbellOBS3.cpp b/src/sensors/CampbellOBS3.cpp index 1b82c290f..f3264bd9a 100644 --- a/src/sensors/CampbellOBS3.cpp +++ b/src/sensors/CampbellOBS3.cpp @@ -26,12 +26,8 @@ CampbellOBS3::CampbellOBS3(int8_t powerPin, uint8_t analogChannel, _x0_coeff_C(x0_coeff_C) { // If no analog voltage reader was provided, create a default one if (analogVoltageReader == nullptr) { - _analogVoltageReader = new TIADS1x15Base(); - if (_analogVoltageReader != nullptr) { - _ownsAnalogVoltageReader = true; - } else { - _ownsAnalogVoltageReader = false; - } + _analogVoltageReader = new TIADS1x15Base(); + _ownsAnalogVoltageReader = true; } else { _analogVoltageReader = analogVoltageReader; _ownsAnalogVoltageReader = false; @@ -73,8 +69,8 @@ bool CampbellOBS3::addSingleMeasurementResult(void) { return bumpMeasurementAttemptCount(false); } - bool success = false; - float adcVoltage = -9999.0f; + bool success = false; + float adcVoltage = -9999.0f; MS_DBG(getSensorNameAndLocation(), F("is reporting:")); diff --git a/src/sensors/EverlightALSPT19.cpp b/src/sensors/EverlightALSPT19.cpp index c453118d2..8efbf0eaf 100644 --- a/src/sensors/EverlightALSPT19.cpp +++ b/src/sensors/EverlightALSPT19.cpp @@ -24,12 +24,8 @@ EverlightALSPT19::EverlightALSPT19(int8_t powerPin, int8_t dataPin, _loadResistor(loadResistor) { // If no analog voltage reader was provided, create a default one if (analogVoltageReader == nullptr) { - _analogVoltageReader = new ProcessorAnalogBase(); - if (_analogVoltageReader != nullptr) { - _ownsAnalogVoltageReader = true; - } else { - _ownsAnalogVoltageReader = false; - } + _analogVoltageReader = new ProcessorAnalogBase(); + _ownsAnalogVoltageReader = true; } else { _analogVoltageReader = analogVoltageReader; _ownsAnalogVoltageReader = false; @@ -51,11 +47,7 @@ EverlightALSPT19::EverlightALSPT19(uint8_t measurementsToAverage, // If no analog voltage reader was provided, create a default one if (analogVoltageReader == nullptr) { _analogVoltageReader = new ProcessorAnalogBase(); - if (_analogVoltageReader != nullptr) { - _ownsAnalogVoltageReader = true; - } else { - _ownsAnalogVoltageReader = false; - } + _ownsAnalogVoltageReader = true; } else { _analogVoltageReader = analogVoltageReader; _ownsAnalogVoltageReader = false; diff --git a/src/sensors/TurnerCyclops.cpp b/src/sensors/TurnerCyclops.cpp index 348c15bd1..210398bf1 100644 --- a/src/sensors/TurnerCyclops.cpp +++ b/src/sensors/TurnerCyclops.cpp @@ -28,11 +28,7 @@ TurnerCyclops::TurnerCyclops(int8_t powerPin, uint8_t analogChannel, // If no analog voltage reader was provided, create a default one if (analogVoltageReader == nullptr) { _analogVoltageReader = new TIADS1x15Base(); - if (_analogVoltageReader != nullptr) { - _ownsAnalogVoltageReader = true; - } else { - _ownsAnalogVoltageReader = false; - } + _ownsAnalogVoltageReader = true; } else { _analogVoltageReader = analogVoltageReader; _ownsAnalogVoltageReader = false; @@ -74,8 +70,8 @@ bool TurnerCyclops::addSingleMeasurementResult(void) { return bumpMeasurementAttemptCount(false); } - bool success = false; - float adcVoltage = -9999.0f; + bool success = false; + float adcVoltage = -9999.0f; MS_DBG(getSensorNameAndLocation(), F("is reporting:")); diff --git a/src/sensors/TurnerTurbidityPlus.cpp b/src/sensors/TurnerTurbidityPlus.cpp index c3814ad00..66f6370d7 100644 --- a/src/sensors/TurnerTurbidityPlus.cpp +++ b/src/sensors/TurnerTurbidityPlus.cpp @@ -30,12 +30,8 @@ TurnerTurbidityPlus::TurnerTurbidityPlus( _analogReferenceChannel(analogReferenceChannel) { // If no analog voltage reader was provided, create a default one if (analogVoltageReader == nullptr) { - _analogVoltageReader = new TIADS1x15Base(); - if (_analogVoltageReader != nullptr) { - _ownsAnalogVoltageReader = true; - } else { - _ownsAnalogVoltageReader = false; - } + _analogVoltageReader = new TIADS1x15Base(); + _ownsAnalogVoltageReader = true; } else { _analogVoltageReader = analogVoltageReader; _ownsAnalogVoltageReader = false; From 416464b8f4d6969fbf7c5b4e14cfd2f25a65ff31 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Tue, 24 Feb 2026 16:04:24 -0500 Subject: [PATCH 311/533] Remove un-necessary null checks Signed-off-by: Sara Damiano --- src/sensors/AlphasenseCO2.cpp | 26 +++++++++++-------------- src/sensors/AnalogElecConductivity.cpp | 27 ++++++++++++-------------- src/sensors/ApogeeSQ212.cpp | 15 +++++--------- src/sensors/CampbellOBS3.cpp | 13 +++++-------- src/sensors/EverlightALSPT19.cpp | 15 +++++--------- src/sensors/TurnerCyclops.cpp | 13 +++++-------- src/sensors/TurnerTurbidityPlus.cpp | 21 +++++++------------- 7 files changed, 50 insertions(+), 80 deletions(-) diff --git a/src/sensors/AlphasenseCO2.cpp b/src/sensors/AlphasenseCO2.cpp index b88c0b518..3cafba89b 100644 --- a/src/sensors/AlphasenseCO2.cpp +++ b/src/sensors/AlphasenseCO2.cpp @@ -48,20 +48,13 @@ AlphasenseCO2::~AlphasenseCO2() { String AlphasenseCO2::getSensorLocation(void) { - if (_analogVoltageReader != nullptr) { - String sensorLocation = _analogVoltageReader->getSensorLocation(); - sensorLocation += F("_Diff_"); - sensorLocation += String(_dataPin); - sensorLocation += F("_"); - sensorLocation += String(_analogReferenceChannel); - return sensorLocation; - } else { - String sensorLocation = F("Unknown_AnalogVoltageReader_Diff_"); - sensorLocation += String(_dataPin); - sensorLocation += F("_"); - sensorLocation += String(_analogReferenceChannel); - return sensorLocation; - } + // NOTE: The constructor guarantees that _analogVoltageReader is not null + String sensorLocation = _analogVoltageReader->getSensorLocation(); + sensorLocation += F("_Diff_"); + sensorLocation += String(_dataPin); + sensorLocation += F("_"); + sensorLocation += String(_analogReferenceChannel); + return sensorLocation; } @@ -83,7 +76,10 @@ bool AlphasenseCO2::addSingleMeasurementResult(void) { MS_DBG(getSensorNameAndLocation(), F("is reporting:")); - // Read differential voltage using the AnalogVoltageBase interface + // Read the differential voltage using the AnalogVoltageBase interface + // NOTE: All implementations of the AnalogVoltageBase class validate both + // the input channel and the resulting voltage, so we can trust that a + // successful read will give us a valid voltage value to work with. success = _analogVoltageReader->readVoltageDifferential( _dataPin, _analogReferenceChannel, adcVoltage); diff --git a/src/sensors/AnalogElecConductivity.cpp b/src/sensors/AnalogElecConductivity.cpp index 3874b12f6..9deb0eb1b 100644 --- a/src/sensors/AnalogElecConductivity.cpp +++ b/src/sensors/AnalogElecConductivity.cpp @@ -45,20 +45,13 @@ AnalogElecConductivity::~AnalogElecConductivity() { String AnalogElecConductivity::getSensorLocation(void) { - if (_analogVoltageReader != nullptr) { - String sensorLocation = _analogVoltageReader->getSensorLocation(); - sensorLocation += F("_anlgEc_"); - sensorLocation += String(_dataPin); - sensorLocation += F("_Pwr"); - sensorLocation += String(_powerPin); - return sensorLocation; - } else { - String sensorLocation = F("Unknown_AnalogVoltageReader_anlgEc_"); - sensorLocation += String(_dataPin); - sensorLocation += F("_Pwr"); - sensorLocation += String(_powerPin); - return sensorLocation; - } + // NOTE: The constructor guarantees that _analogVoltageReader is not null + String sensorLocation = _analogVoltageReader->getSensorLocation(); + sensorLocation += F("_anlgEc_"); + sensorLocation += String(_dataPin); + sensorLocation += F("_Pwr"); + sensorLocation += String(_powerPin); + return sensorLocation; } @@ -80,7 +73,11 @@ bool AnalogElecConductivity::addSingleMeasurementResult(void) { MS_DBG(getSensorNameAndLocation(), F("is reporting:")); - // Read the analog voltage using the AnalogVoltageBase interface + // Read the single-ended analog voltage using the AnalogVoltageBase + // interface. + // NOTE: All implementations of the AnalogVoltageBase class validate both + // the input channel and the resulting voltage, so we can trust that a + // successful read will give us a valid voltage value to work with. success = _analogVoltageReader->readVoltageSingleEnded(_dataPin, adcVoltage); diff --git a/src/sensors/ApogeeSQ212.cpp b/src/sensors/ApogeeSQ212.cpp index 4c5f0eb4f..adf9e6872 100644 --- a/src/sensors/ApogeeSQ212.cpp +++ b/src/sensors/ApogeeSQ212.cpp @@ -44,16 +44,11 @@ ApogeeSQ212::~ApogeeSQ212() { String ApogeeSQ212::getSensorLocation(void) { - if (_analogVoltageReader != nullptr) { - String sensorLocation = _analogVoltageReader->getSensorLocation(); - sensorLocation += F("_Channel"); - sensorLocation += String(_dataPin); - return sensorLocation; - } else { - String sensorLocation = F("Unknown_AnalogVoltageReader_Channel"); - sensorLocation += String(_dataPin); - return sensorLocation; - } + // NOTE: The constructor guarantees that _analogVoltageReader is not null + String sensorLocation = _analogVoltageReader->getSensorLocation(); + sensorLocation += F("_Channel"); + sensorLocation += String(_dataPin); + return sensorLocation; } diff --git a/src/sensors/CampbellOBS3.cpp b/src/sensors/CampbellOBS3.cpp index f3264bd9a..10913bc66 100644 --- a/src/sensors/CampbellOBS3.cpp +++ b/src/sensors/CampbellOBS3.cpp @@ -45,14 +45,11 @@ CampbellOBS3::~CampbellOBS3() { String CampbellOBS3::getSensorLocation(void) { - if (_analogVoltageReader != nullptr) { - return _analogVoltageReader->getSensorLocation() + F("_Channel") + - String(_dataPin); - } else { - String sensorLocation = F("Unknown_AnalogVoltageReader_Channel"); - sensorLocation += String(_dataPin); - return sensorLocation; - } + // NOTE: The constructor guarantees that _analogVoltageReader is not null + String sensorLocation = _analogVoltageReader->getSensorLocation(); + sensorLocation += F("_Channel"); + sensorLocation += String(_dataPin); + return sensorLocation; } diff --git a/src/sensors/EverlightALSPT19.cpp b/src/sensors/EverlightALSPT19.cpp index 8efbf0eaf..c0833bcd0 100644 --- a/src/sensors/EverlightALSPT19.cpp +++ b/src/sensors/EverlightALSPT19.cpp @@ -66,16 +66,11 @@ EverlightALSPT19::~EverlightALSPT19() { String EverlightALSPT19::getSensorLocation(void) { - if (_analogVoltageReader != nullptr) { - String sensorLocation = _analogVoltageReader->getSensorLocation(); - sensorLocation += F("_"); - sensorLocation += String(_dataPin); - return sensorLocation; - } else { - String sensorLocation = F("Unknown_AnalogVoltageReader_"); - sensorLocation += String(_dataPin); - return sensorLocation; - } + // NOTE: The constructor guarantees that _analogVoltageReader is not null + String sensorLocation = _analogVoltageReader->getSensorLocation(); + sensorLocation += F("_"); + sensorLocation += String(_dataPin); + return sensorLocation; } diff --git a/src/sensors/TurnerCyclops.cpp b/src/sensors/TurnerCyclops.cpp index 210398bf1..9d52d0991 100644 --- a/src/sensors/TurnerCyclops.cpp +++ b/src/sensors/TurnerCyclops.cpp @@ -46,14 +46,11 @@ TurnerCyclops::~TurnerCyclops() { String TurnerCyclops::getSensorLocation(void) { - if (_analogVoltageReader != nullptr) { - return _analogVoltageReader->getSensorLocation() + F("_Channel") + - String(_dataPin); - } else { - String sensorLocation = F("Unknown_AnalogVoltageReader_Channel"); - sensorLocation += String(_dataPin); - return sensorLocation; - } + // NOTE: The constructor guarantees that _analogVoltageReader is not null + String sensorLocation = _analogVoltageReader->getSensorLocation(); + sensorLocation += F("_Channel"); + sensorLocation += String(_dataPin); + return sensorLocation; } diff --git a/src/sensors/TurnerTurbidityPlus.cpp b/src/sensors/TurnerTurbidityPlus.cpp index 66f6370d7..3de6d614b 100644 --- a/src/sensors/TurnerTurbidityPlus.cpp +++ b/src/sensors/TurnerTurbidityPlus.cpp @@ -49,20 +49,13 @@ TurnerTurbidityPlus::~TurnerTurbidityPlus() { String TurnerTurbidityPlus::getSensorLocation(void) { - if (_analogVoltageReader != nullptr) { - String sensorLocation = _analogVoltageReader->getSensorLocation(); - sensorLocation += F("_Diff_"); - sensorLocation += String(_dataPin); - sensorLocation += F("_"); - sensorLocation += String(_analogReferenceChannel); - return sensorLocation; - } else { - String sensorLocation = F("Unknown_AnalogVoltageReader_Diff_"); - sensorLocation += String(_dataPin); - sensorLocation += F("_"); - sensorLocation += String(_analogReferenceChannel); - return sensorLocation; - } + // NOTE: The constructor guarantees that _analogVoltageReader is not null + String sensorLocation = _analogVoltageReader->getSensorLocation(); + sensorLocation += F("_Diff_"); + sensorLocation += String(_dataPin); + sensorLocation += F("_"); + sensorLocation += String(_analogReferenceChannel); + return sensorLocation; } void TurnerTurbidityPlus::runWiper() { From b518c3cc4326be9afdff1edf6eed9e3977516410 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Tue, 24 Feb 2026 16:59:35 -0500 Subject: [PATCH 312/533] Update some comments Signed-off-by: Sara Damiano --- src/sensors/AlphasenseCO2.h | 13 ++++--------- src/sensors/AnalogElecConductivity.h | 6 ++++-- src/sensors/ApogeeSQ212.cpp | 6 +++++- src/sensors/ApogeeSQ212.h | 4 ---- src/sensors/CampbellOBS3.cpp | 6 +++++- src/sensors/CampbellOBS3.h | 2 -- src/sensors/EverlightALSPT19.cpp | 6 +++++- src/sensors/EverlightALSPT19.h | 10 ++++++++++ src/sensors/TIADS1x15.h | 1 + src/sensors/TurnerCyclops.cpp | 6 +++++- src/sensors/TurnerCyclops.h | 8 +++----- src/sensors/TurnerTurbidityPlus.cpp | 5 ++++- src/sensors/TurnerTurbidityPlus.h | 6 +++--- 13 files changed, 49 insertions(+), 30 deletions(-) diff --git a/src/sensors/AlphasenseCO2.h b/src/sensors/AlphasenseCO2.h index e17f60b62..5264d3e83 100644 --- a/src/sensors/AlphasenseCO2.h +++ b/src/sensors/AlphasenseCO2.h @@ -15,8 +15,6 @@ * Carbon Dioxide (CO2) sensor. This library will almost certainly also work * with the Alphasense IRC-AT CO2 sensor (which uses a thermopile detector), * although the warmup and stabilization times might be different. - * - * This depends on the Adafruit ADS1X15 v2.x library. */ /* clang-format off */ /** @@ -119,8 +117,7 @@ /** * @anchor sensor_alphasense_co2_config * @name Configuration Defines - * Defines to set the calibration of the Alphasense CO2 sensor and the address - * of the ADD. + * Defines to set the calibration of the Alphasense CO2 sensor. */ /**@{*/ #if !defined(ALPHASENSE_CO2_SENSE_RESISTOR_OHM) || defined(DOXYGEN) @@ -281,11 +278,9 @@ class AlphasenseCO2 : public Sensor { * default value of 7. * @param analogVoltageReader Pointer to an AnalogVoltageBase object for * voltage measurements. Pass nullptr (the default) to have the constructor - * internally create and own a TIADS1x15Base instance. - * - * @note The ADS is expected to be either continuously powered or have - * its power controlled by the same pin as the Alphasense CO2 sensor. This - * library does not support any other configuration. + * internally create and own a TIADS1x15Base instance. If a non-null + * pointer is supplied, the caller retains ownership and must ensure its + * lifetime exceeds that of this object. * * @warning In library versions 0.37.0 and earlier, a different constructor * was used that required an enum object instead of two different analog diff --git a/src/sensors/AnalogElecConductivity.h b/src/sensors/AnalogElecConductivity.h index d644232f4..eee13ca52 100644 --- a/src/sensors/AnalogElecConductivity.h +++ b/src/sensors/AnalogElecConductivity.h @@ -288,8 +288,10 @@ class AnalogElecConductivity : public Sensor { * @param measurementsToAverage The number of measurements to average; * optional with default value of 1. * @param analogVoltageReader Pointer to an AnalogVoltageBase object for - * voltage measurements; optional with a default of a new ProcessorAnalogBase - * object. The private member _analogVoltageReader will store this pointer. + * voltage measurements. Pass nullptr (the default) to have the constructor + * internally create and own a ProcessorAnalogBase instance. If a non-null + * pointer is supplied, the caller retains ownership and must ensure its + * lifetime exceeds that of this object. */ AnalogElecConductivity(int8_t powerPin, int8_t dataPin, float Rseries_ohms = RSERIES_OHMS_DEF, diff --git a/src/sensors/ApogeeSQ212.cpp b/src/sensors/ApogeeSQ212.cpp index adf9e6872..af165cfd4 100644 --- a/src/sensors/ApogeeSQ212.cpp +++ b/src/sensors/ApogeeSQ212.cpp @@ -70,7 +70,11 @@ bool ApogeeSQ212::addSingleMeasurementResult(void) { MS_DBG(getSensorNameAndLocation(), F("is reporting:")); - // Read voltage using the AnalogVoltageBase interface + // Read the single-ended analog voltage using the AnalogVoltageBase + // interface. + // NOTE: All implementations of the AnalogVoltageBase class validate both + // the input channel and the resulting voltage, so we can trust that a + // successful read will give us a valid voltage value to work with. success = _analogVoltageReader->readVoltageSingleEnded(_dataPin, adcVoltage); diff --git a/src/sensors/ApogeeSQ212.h b/src/sensors/ApogeeSQ212.h index 817c3fd5a..600a7ed97 100644 --- a/src/sensors/ApogeeSQ212.h +++ b/src/sensors/ApogeeSQ212.h @@ -264,10 +264,6 @@ class ApogeeSQ212 : public Sensor { * allocate a TIADS1x15Base object automatically (owned and deleted by this * instance). If a non-null pointer is supplied, the caller retains * ownership and must ensure its lifetime exceeds that of this object. - * - * @note The ADS is expected to be either continuously powered or have its - * power controlled by the same pin as the SQ-212. This library does not - * support any other configuration. */ ApogeeSQ212(int8_t powerPin, uint8_t analogChannel, uint8_t measurementsToAverage = 1, diff --git a/src/sensors/CampbellOBS3.cpp b/src/sensors/CampbellOBS3.cpp index 10913bc66..e31c1c747 100644 --- a/src/sensors/CampbellOBS3.cpp +++ b/src/sensors/CampbellOBS3.cpp @@ -75,7 +75,11 @@ bool CampbellOBS3::addSingleMeasurementResult(void) { MS_DBG(F(" Input calibration Curve:"), _x2_coeff_A, F("x^2 +"), _x1_coeff_B, F("x +"), _x0_coeff_C); - // Read voltage using the AnalogVoltageBase interface + // Read the single-ended analog voltage using the AnalogVoltageBase + // interface. + // NOTE: All implementations of the AnalogVoltageBase class validate both + // the input channel and the resulting voltage, so we can trust that a + // successful read will give us a valid voltage value to work with. success = _analogVoltageReader->readVoltageSingleEnded(_dataPin, adcVoltage); if (success) { diff --git a/src/sensors/CampbellOBS3.h b/src/sensors/CampbellOBS3.h index 191e6245c..ed97804b7 100644 --- a/src/sensors/CampbellOBS3.h +++ b/src/sensors/CampbellOBS3.h @@ -9,8 +9,6 @@ * CampbellOBS3_Turbidity and CampbellOBS3_Voltage. * * These are used for the Campbell Scientific OBS-3+. - * - * This depends on the Adafruit ADS1X15 v2.x library */ /* clang-format off */ /** diff --git a/src/sensors/EverlightALSPT19.cpp b/src/sensors/EverlightALSPT19.cpp index c0833bcd0..73f7d3242 100644 --- a/src/sensors/EverlightALSPT19.cpp +++ b/src/sensors/EverlightALSPT19.cpp @@ -92,7 +92,11 @@ bool EverlightALSPT19::addSingleMeasurementResult(void) { MS_DBG(getSensorNameAndLocation(), F("is reporting:")); - // Read the analog voltage using the AnalogVoltageBase interface + // Read the single-ended analog voltage using the AnalogVoltageBase + // interface. + // NOTE: All implementations of the AnalogVoltageBase class validate both + // the input channel and the resulting voltage, so we can trust that a + // successful read will give us a valid voltage value to work with. success = _analogVoltageReader->readVoltageSingleEnded(_dataPin, adcVoltage); diff --git a/src/sensors/EverlightALSPT19.h b/src/sensors/EverlightALSPT19.h index 6c66d2df8..e3e4a3967 100644 --- a/src/sensors/EverlightALSPT19.h +++ b/src/sensors/EverlightALSPT19.h @@ -228,6 +228,11 @@ class EverlightALSPT19 : public Sensor { * @param measurementsToAverage The number of measurements to take and * average before giving a "final" result from the sensor; optional with a * default value of 10. + * @param analogVoltageReader Pointer to an AnalogVoltageBase object for + * voltage measurements. Pass nullptr (the default) to have the constructor + * internally create and own a ProcessorAnalogBase instance. If a non-null + * pointer is supplied, the caller retains ownership and must ensure its + * lifetime exceeds that of this object. */ EverlightALSPT19(int8_t powerPin, int8_t dataPin, float supplyVoltage, float loadResistor, uint8_t measurementsToAverage = 10, @@ -248,6 +253,11 @@ class EverlightALSPT19 : public Sensor { * @param measurementsToAverage The number of measurements to take and * average before giving a "final" result from the sensor; optional with a * default value of 10. + * @param analogVoltageReader Pointer to an AnalogVoltageBase object for + * voltage measurements. Pass nullptr (the default) to have the constructor + * internally create and own a ProcessorAnalogBase instance. If a non-null + * pointer is supplied, the caller retains ownership and must ensure its + * lifetime exceeds that of this object. */ explicit EverlightALSPT19(uint8_t measurementsToAverage = 10, AnalogVoltageBase* analogVoltageReader = nullptr); diff --git a/src/sensors/TIADS1x15.h b/src/sensors/TIADS1x15.h index 1e70f9fdb..928a2dcd0 100644 --- a/src/sensors/TIADS1x15.h +++ b/src/sensors/TIADS1x15.h @@ -62,6 +62,7 @@ * @note *In all cases, we assume that the ADS1x15 is powered at 3.3V by default with configurable internal gain settings. * * The default gain setting is 1x (GAIN_ONE) which divides the bit resolution over the range of 0-4.096V. + * In single-ended mode the actual ceiling is min(FSR, VDD + 0.3V) — typically 3.6V at 3.3V supply. * - Response time: < 1ms * - Resample time: 860 samples per second (~1.2ms) * - Range: diff --git a/src/sensors/TurnerCyclops.cpp b/src/sensors/TurnerCyclops.cpp index 9d52d0991..a9f5056e9 100644 --- a/src/sensors/TurnerCyclops.cpp +++ b/src/sensors/TurnerCyclops.cpp @@ -81,7 +81,11 @@ bool TurnerCyclops::addSingleMeasurementResult(void) { return bumpMeasurementAttemptCount(false); } - // Read voltage using the AnalogVoltageBase interface + // Read the single-ended analog voltage using the AnalogVoltageBase + // interface. + // NOTE: All implementations of the AnalogVoltageBase class validate both + // the input channel and the resulting voltage, so we can trust that a + // successful read will give us a valid voltage value to work with. success = _analogVoltageReader->readVoltageSingleEnded(_dataPin, adcVoltage); if (success) { diff --git a/src/sensors/TurnerCyclops.h b/src/sensors/TurnerCyclops.h index e602fcc93..126d0da63 100644 --- a/src/sensors/TurnerCyclops.h +++ b/src/sensors/TurnerCyclops.h @@ -9,8 +9,6 @@ * TurnerCyclops_Turbidity and TurnerCyclops_Voltage. * * These are used for the Turner Scientific Cyclops-7F. - * - * This depends on the Adafruit ADS1X15 v2.x library */ /* clang-format off */ /** @@ -291,8 +289,6 @@ /* clang-format on */ class TurnerCyclops : public Sensor { public: - // The constructor - need the power pin, the ADS1X15 data channel, and the - // calibration info /** * @brief Construct a new Turner Cyclops object - need the power pin, the * analog data channel, and the calibration info. @@ -324,7 +320,9 @@ class TurnerCyclops : public Sensor { * default value of 1. * @param analogVoltageReader Pointer to an AnalogVoltageBase object for * voltage measurements. Pass nullptr (the default) to have the constructor - * internally create and own a TIADS1x15Base instance. + * internally create and own a TIADS1x15Base instance. If a non-null + * pointer is supplied, the caller retains ownership and must ensure its + * lifetime exceeds that of this object. */ TurnerCyclops(int8_t powerPin, uint8_t analogChannel, float conc_std, float volt_std, float volt_blank, diff --git a/src/sensors/TurnerTurbidityPlus.cpp b/src/sensors/TurnerTurbidityPlus.cpp index 3de6d614b..292a9495a 100644 --- a/src/sensors/TurnerTurbidityPlus.cpp +++ b/src/sensors/TurnerTurbidityPlus.cpp @@ -128,7 +128,10 @@ bool TurnerTurbidityPlus::addSingleMeasurementResult(void) { return bumpMeasurementAttemptCount(false); } - // Read differential voltage using the AnalogVoltageBase interface + // Read the differential voltage using the AnalogVoltageBase interface. + // NOTE: All implementations of the AnalogVoltageBase class validate both + // the input channel and the resulting voltage, so we can trust that a + // successful read will give us a valid voltage value to work with. success = _analogVoltageReader->readVoltageDifferential( _dataPin, _analogReferenceChannel, adcVoltage); diff --git a/src/sensors/TurnerTurbidityPlus.h b/src/sensors/TurnerTurbidityPlus.h index 3257d68c5..52aa44f11 100644 --- a/src/sensors/TurnerTurbidityPlus.h +++ b/src/sensors/TurnerTurbidityPlus.h @@ -10,8 +10,6 @@ * subclasses TurnerTurbidityPlus_Turbidity and TurnerTurbidityPlus_Voltage. * * These are used for the Turner Turbidity Plus. - * - * This depends on the Adafruit ADS1X15 v2.x library. */ /** * @defgroup sensor_turbidity_plus Turner Turbidity Plus @@ -234,7 +232,9 @@ class TurnerTurbidityPlus : public Sensor { * default value of 1. * @param analogVoltageReader Pointer to an AnalogVoltageBase object for * voltage measurements. Pass nullptr (the default) to have the constructor - * internally create and own a TIADS1x15Base instance. + * internally create and own a TIADS1x15Base instance. If a non-null + * pointer is supplied, the caller retains ownership and must ensure its + * lifetime exceeds that of this object. * * @attention For 3.3V processors like the Mayfly, The Turner's 0-5V output * signal must be shifted down to a maximum of 3.3V. This can be done either From e6204729c242532d16129604857922bc181385d2 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Tue, 24 Feb 2026 17:05:27 -0500 Subject: [PATCH 313/533] Consistent types for analog channels Signed-off-by: Sara Damiano --- src/sensors/ApogeeSQ212.cpp | 2 +- src/sensors/ApogeeSQ212.h | 4 +--- src/sensors/CampbellOBS3.cpp | 2 +- src/sensors/CampbellOBS3.h | 6 ++++-- src/sensors/TIADS1x15.cpp | 3 +-- src/sensors/TIADS1x15.h | 2 +- src/sensors/TurnerCyclops.cpp | 2 +- src/sensors/TurnerCyclops.h | 2 +- 8 files changed, 11 insertions(+), 12 deletions(-) diff --git a/src/sensors/ApogeeSQ212.cpp b/src/sensors/ApogeeSQ212.cpp index af165cfd4..061046f4d 100644 --- a/src/sensors/ApogeeSQ212.cpp +++ b/src/sensors/ApogeeSQ212.cpp @@ -17,7 +17,7 @@ // The constructor - need the power pin and the data pin -ApogeeSQ212::ApogeeSQ212(int8_t powerPin, uint8_t analogChannel, +ApogeeSQ212::ApogeeSQ212(int8_t powerPin, int8_t analogChannel, uint8_t measurementsToAverage, AnalogVoltageBase* analogVoltageReader) : Sensor("ApogeeSQ212", SQ212_NUM_VARIABLES, SQ212_WARM_UP_TIME_MS, diff --git a/src/sensors/ApogeeSQ212.h b/src/sensors/ApogeeSQ212.h index 600a7ed97..e566709ce 100644 --- a/src/sensors/ApogeeSQ212.h +++ b/src/sensors/ApogeeSQ212.h @@ -12,8 +12,6 @@ * ApogeeSQ212_PAR and ApogeeSQ212_Voltage. * * These are used for the Apogee SQ-212 quantum light sensor. - * - * This depends on the Adafruit ADS1X15 v2.x library. */ /* clang-format off */ /** @@ -265,7 +263,7 @@ class ApogeeSQ212 : public Sensor { * instance). If a non-null pointer is supplied, the caller retains * ownership and must ensure its lifetime exceeds that of this object. */ - ApogeeSQ212(int8_t powerPin, uint8_t analogChannel, + ApogeeSQ212(int8_t powerPin, int8_t analogChannel, uint8_t measurementsToAverage = 1, AnalogVoltageBase* analogVoltageReader = nullptr); /** diff --git a/src/sensors/CampbellOBS3.cpp b/src/sensors/CampbellOBS3.cpp index e31c1c747..cef4098b1 100644 --- a/src/sensors/CampbellOBS3.cpp +++ b/src/sensors/CampbellOBS3.cpp @@ -14,7 +14,7 @@ // The constructor - need the power pin, the data pin, and the calibration info -CampbellOBS3::CampbellOBS3(int8_t powerPin, uint8_t analogChannel, +CampbellOBS3::CampbellOBS3(int8_t powerPin, int8_t analogChannel, float x2_coeff_A, float x1_coeff_B, float x0_coeff_C, uint8_t measurementsToAverage, AnalogVoltageBase* analogVoltageReader) diff --git a/src/sensors/CampbellOBS3.h b/src/sensors/CampbellOBS3.h index ed97804b7..73a314dfe 100644 --- a/src/sensors/CampbellOBS3.h +++ b/src/sensors/CampbellOBS3.h @@ -258,9 +258,11 @@ class CampbellOBS3 : public Sensor { * default value of 1. * @param analogVoltageReader Pointer to an AnalogVoltageBase object for * voltage measurements. Pass nullptr (the default) to have the constructor - * internally create and own a TIADS1x15Base instance. + * internally create and own a TIADS1x15Base instance. If a non-null + * pointer is supplied, the caller retains ownership and must ensure its + * lifetime exceeds that of this object. */ - CampbellOBS3(int8_t powerPin, uint8_t analogChannel, float x2_coeff_A, + CampbellOBS3(int8_t powerPin, int8_t analogChannel, float x2_coeff_A, float x1_coeff_B, float x0_coeff_C, uint8_t measurementsToAverage = 1, AnalogVoltageBase* analogVoltageReader = nullptr); diff --git a/src/sensors/TIADS1x15.cpp b/src/sensors/TIADS1x15.cpp index 116d12a80..be020f61f 100644 --- a/src/sensors/TIADS1x15.cpp +++ b/src/sensors/TIADS1x15.cpp @@ -212,8 +212,7 @@ bool TIADS1x15Base::readVoltageDifferential(int8_t analogChannel, } // Validation function for differential channel pairs -bool TIADS1x15Base::isValidDifferentialPair(uint8_t channel1, - uint8_t channel2) { +bool TIADS1x15Base::isValidDifferentialPair(int8_t channel1, int8_t channel2) { // Only canonical ordered pairs are valid (lower channel number first) // This ensures consistent polarity: channel1 is positive, channel2 is // negative Valid combinations are: 0-1, 0-3, 1-3, or 2-3 (in that order diff --git a/src/sensors/TIADS1x15.h b/src/sensors/TIADS1x15.h index 928a2dcd0..7073d074f 100644 --- a/src/sensors/TIADS1x15.h +++ b/src/sensors/TIADS1x15.h @@ -340,7 +340,7 @@ class TIADS1x15Base : public AnalogVoltageBase { * Adafruit_ADS1X15 channel type convention and to avoid sign-extension * when computing hardware MUX configuration values internally. */ - static bool isValidDifferentialPair(uint8_t channel1, uint8_t channel2); + static bool isValidDifferentialPair(int8_t channel1, int8_t channel2); protected: /** diff --git a/src/sensors/TurnerCyclops.cpp b/src/sensors/TurnerCyclops.cpp index a9f5056e9..fe453434a 100644 --- a/src/sensors/TurnerCyclops.cpp +++ b/src/sensors/TurnerCyclops.cpp @@ -14,7 +14,7 @@ // The constructor - need the power pin, the data pin, and the calibration info -TurnerCyclops::TurnerCyclops(int8_t powerPin, uint8_t analogChannel, +TurnerCyclops::TurnerCyclops(int8_t powerPin, int8_t analogChannel, float conc_std, float volt_std, float volt_blank, uint8_t measurementsToAverage, AnalogVoltageBase* analogVoltageReader) diff --git a/src/sensors/TurnerCyclops.h b/src/sensors/TurnerCyclops.h index 126d0da63..f669e2e47 100644 --- a/src/sensors/TurnerCyclops.h +++ b/src/sensors/TurnerCyclops.h @@ -324,7 +324,7 @@ class TurnerCyclops : public Sensor { * pointer is supplied, the caller retains ownership and must ensure its * lifetime exceeds that of this object. */ - TurnerCyclops(int8_t powerPin, uint8_t analogChannel, float conc_std, + TurnerCyclops(int8_t powerPin, int8_t analogChannel, float conc_std, float volt_std, float volt_blank, uint8_t measurementsToAverage = 1, AnalogVoltageBase* analogVoltageReader = nullptr); From 1efc54d649d1f4457080788486afe2965524a84e Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Tue, 24 Feb 2026 17:05:51 -0500 Subject: [PATCH 314/533] float tag Signed-off-by: Sara Damiano --- src/sensors/ProcessorAnalog.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sensors/ProcessorAnalog.cpp b/src/sensors/ProcessorAnalog.cpp index cd61cc7fe..07840f605 100644 --- a/src/sensors/ProcessorAnalog.cpp +++ b/src/sensors/ProcessorAnalog.cpp @@ -104,7 +104,7 @@ bool ProcessorAnalog::addSingleMeasurementResult(void) { MS_DBG(getSensorNameAndLocation(), F("is reporting:")); - float resultValue = -9999; + float resultValue = -9999.0f; bool success = readVoltageSingleEnded(_dataPin, resultValue); if (success) { From d32c696d5218ac7c412642033c60b72b3e23d632 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Tue, 24 Feb 2026 17:22:06 -0500 Subject: [PATCH 315/533] Check for valid load resistor Signed-off-by: Sara Damiano --- src/sensors/EverlightALSPT19.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/sensors/EverlightALSPT19.cpp b/src/sensors/EverlightALSPT19.cpp index 73f7d3242..ef1488f70 100644 --- a/src/sensors/EverlightALSPT19.cpp +++ b/src/sensors/EverlightALSPT19.cpp @@ -87,6 +87,12 @@ bool EverlightALSPT19::addSingleMeasurementResult(void) { return bumpMeasurementAttemptCount(false); } + // Check if we have a valid load resistor + if (_loadResistor <= 0) { + MS_DBG(getSensorNameAndLocation(), F("Invalid load resistor value")); + return bumpMeasurementAttemptCount(false); + } + bool success = false; float adcVoltage = -9999.0f; From d1e28aaee274c9b4610e7a11e91242c367e7153d Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Tue, 24 Feb 2026 18:10:48 -0500 Subject: [PATCH 316/533] Clarify use of supply voltage, clamp after saturation, use defines for calibration values Signed-off-by: Sara Damiano --- src/sensors/EverlightALSPT19.cpp | 22 +++++++++++--- src/sensors/EverlightALSPT19.h | 51 ++++++++++++++++++++++++-------- 2 files changed, 57 insertions(+), 16 deletions(-) diff --git a/src/sensors/EverlightALSPT19.cpp b/src/sensors/EverlightALSPT19.cpp index ef1488f70..26de6c1c9 100644 --- a/src/sensors/EverlightALSPT19.cpp +++ b/src/sensors/EverlightALSPT19.cpp @@ -13,14 +13,15 @@ EverlightALSPT19::EverlightALSPT19(int8_t powerPin, int8_t dataPin, - float supplyVoltage, float loadResistor, + float alsSupplyVoltage, float loadResistor, uint8_t measurementsToAverage, AnalogVoltageBase* analogVoltageReader) : Sensor("Everlight ALS-PT19", ALSPT19_NUM_VARIABLES, ALSPT19_WARM_UP_TIME_MS, ALSPT19_STABILIZATION_TIME_MS, ALSPT19_MEASUREMENT_TIME_MS, powerPin, dataPin, measurementsToAverage, ALSPT19_INC_CALC_VARIABLES), - _supplyVoltage(supplyVoltage), + _alsSupplyVoltage((alsSupplyVoltage > 0.0f) ? alsSupplyVoltage + : OPERATING_VOLTAGE), _loadResistor(loadResistor) { // If no analog voltage reader was provided, create a default one if (analogVoltageReader == nullptr) { @@ -42,7 +43,7 @@ EverlightALSPT19::EverlightALSPT19(uint8_t measurementsToAverage, ALSPT19_MEASUREMENT_TIME_MS, BUILT_IN_ALS_POWER_PIN, BUILT_IN_ALS_DATA_PIN, measurementsToAverage, ALSPT19_INC_CALC_VARIABLES), - _supplyVoltage(BUILT_IN_ALS_SUPPLY_VOLTAGE), + _alsSupplyVoltage(BUILT_IN_ALS_SUPPLY_VOLTAGE), _loadResistor(BUILT_IN_ALS_LOADING_RESISTANCE) { // If no analog voltage reader was provided, create a default one if (analogVoltageReader == nullptr) { @@ -107,6 +108,19 @@ bool EverlightALSPT19::addSingleMeasurementResult(void) { adcVoltage); if (success) { + // From the datasheet: + // The output voltage V(out) is the product of photocurrent I(PH) and + // loading resistor R(L): + // - V(out) = I(PH) * R(L) + // At saturation: + // - V(out) = Vcc-0.4V + if (adcVoltage > _alsSupplyVoltage - 0.4) { + MS_DBG(getSensorNameAndLocation(), + F("Light sensor has reached saturation! Clamping current " + "and illumination values!")); + adcVoltage = _alsSupplyVoltage - 0.4; + } + // convert volts to current // resistance is entered in kΩ and we want µA float current_val = (adcVoltage / (_loadResistor * 1000)) * 1e6; @@ -114,7 +128,7 @@ bool EverlightALSPT19::addSingleMeasurementResult(void) { // convert current to illuminance // from sensor datasheet, typical 200µA current for 1000 Lux - float calibResult = current_val * (1000. / 200.); + float calibResult = current_val * (1000. / ALSPT19_CURRENT_PER_LUX); MS_DBG(F(" Illuminance:"), calibResult, F("lux")); verifyAndAddMeasurementResult(ALSPT19_VOLTAGE_VAR_NUM, adcVoltage); diff --git a/src/sensors/EverlightALSPT19.h b/src/sensors/EverlightALSPT19.h index e3e4a3967..2e0b86c0d 100644 --- a/src/sensors/EverlightALSPT19.h +++ b/src/sensors/EverlightALSPT19.h @@ -28,6 +28,11 @@ * @section sensor_alspt19_datasheet Sensor Datasheet * [Datasheet](https://github.com/EnviroDIY/ModularSensors/wiki/Sensor-Datasheets/Everlight-ALS-PT19.pdf) * + * @section sensor_analog_cond_flags Build flags + * - `-D ALSPT19_CURRENT_PER_LUX=##` + * - used to set current equivalent to 1000lux, which is used to calculate + * lux from the sensor + * * @section sensor_alspt19_ctor Sensor Constructors * {{ @ref EverlightALSPT19::EverlightALSPT19(uint8_t) }} * {{ @ref EverlightALSPT19::EverlightALSPT19(int8_t, int8_t, float, float, uint8_t) }} @@ -88,6 +93,32 @@ #define ALSPT19_INC_CALC_VARIABLES 2 /**@}*/ +/** + * @anchor sensor_alspt19_config + * @name Configuration Defines + * Defines to for the ALS calibration between current and lux. + */ +/**@{*/ +#if !defined(ALSPT19_CURRENT_PER_LUX) || defined(DOXYGEN) +/** + * @brief The default current (in µA) that is equivalent to 1000 lux of + * illuminance. + * + * Extrapolating from plots in the sensor datasheet + * - Incandescent light: ~5,000µA for 10,000 lux (500 for 1000) + * - Fluorescent light: ~1,500µA for 10,000 lux (150 for 1000) + * - 6500K white LED: 150µA for 1000 Lux + * + * @attention The default of 200.0f has been used by this library, but I'm + * unclear the origin of this number. + * + * @todo Find the source of the calibration of typical 200µA current for 1000 + * Lux, which doesn't appear to align with the datasheet. + */ +#define ALSPT19_CURRENT_PER_LUX 200.0f +#endif // ALSPT19_CURRENT_PER_LUX +/**@}*/ + /** * @anchor sensor_alspt19_timing * @name Sensor Timing @@ -220,10 +251,10 @@ class EverlightALSPT19 : public Sensor { * probe. Not all processor pins can be used as analog pins. Those usable * as analog pins generally are numbered with an "A" in front of the number * - ie, A1. - * @param supplyVoltage The power supply voltage (in volts) of the ALS-PT19. - * This does not have to be the same as the board operating voltage or the - * supply voltage of the analog AnalogVoltageBase reader, but it is needed - * to calculate the current and illuminance. + * @param alsSupplyVoltage The power supply voltage (in volts) of the + * ALS-PT19. This does not have to be the same as the board operating + * voltage or the supply voltage of the analog AnalogVoltageBase reader. + * This is used to clamp the light values when the sensor is over-saturated. * @param loadResistor The size of the loading resistor, in kilaohms (kΩ). * @param measurementsToAverage The number of measurements to take and * average before giving a "final" result from the sensor; optional with a @@ -234,7 +265,7 @@ class EverlightALSPT19 : public Sensor { * pointer is supplied, the caller retains ownership and must ensure its * lifetime exceeds that of this object. */ - EverlightALSPT19(int8_t powerPin, int8_t dataPin, float supplyVoltage, + EverlightALSPT19(int8_t powerPin, int8_t dataPin, float alsSupplyVoltage, float loadResistor, uint8_t measurementsToAverage = 10, AnalogVoltageBase* analogVoltageReader = nullptr); @@ -283,13 +314,9 @@ class EverlightALSPT19 : public Sensor { bool addSingleMeasurementResult(void) override; private: - /** - * @brief The power supply voltage - */ - float _supplyVoltage; - /** - * @brief The loading resistance - */ + /// @brief The PT-19 power supply voltage + float _alsSupplyVoltage; + /// @brief The loading resistance float _loadResistor; /// @brief Pointer to analog voltage reader AnalogVoltageBase* _analogVoltageReader = nullptr; From d6c5b9d2eafb26158a5fec2c847453e667bb7d7d Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Tue, 24 Feb 2026 18:21:20 -0500 Subject: [PATCH 317/533] Move to initializer Signed-off-by: Sara Damiano --- src/sensors/AlphasenseCO2.cpp | 15 +++++-------- src/sensors/AnalogElecConductivity.cpp | 15 +++++-------- src/sensors/ApogeeSQ212.cpp | 15 +++++-------- src/sensors/CampbellOBS3.cpp | 15 +++++-------- src/sensors/EverlightALSPT19.cpp | 29 ++++++++------------------ src/sensors/TurnerCyclops.cpp | 15 +++++-------- src/sensors/TurnerTurbidityPlus.cpp | 15 +++++-------- 7 files changed, 39 insertions(+), 80 deletions(-) diff --git a/src/sensors/AlphasenseCO2.cpp b/src/sensors/AlphasenseCO2.cpp index 3cafba89b..980a23af7 100644 --- a/src/sensors/AlphasenseCO2.cpp +++ b/src/sensors/AlphasenseCO2.cpp @@ -26,16 +26,11 @@ AlphasenseCO2::AlphasenseCO2(int8_t powerPin, int8_t analogChannel, ALPHASENSE_CO2_MEASUREMENT_TIME_MS, powerPin, analogChannel, measurementsToAverage, ALPHASENSE_CO2_INC_CALC_VARIABLES), - _analogReferenceChannel(analogReferenceChannel) { - // If no analog voltage reader was provided, create a default one - if (analogVoltageReader == nullptr) { - _analogVoltageReader = new TIADS1x15Base(); - _ownsAnalogVoltageReader = true; - } else { - _analogVoltageReader = analogVoltageReader; - _ownsAnalogVoltageReader = false; - } -} + _analogReferenceChannel(analogReferenceChannel), + // If no analog voltage reader was provided, create a default one + _analogVoltageReader(analogVoltageReader ? analogVoltageReader + : new TIADS1x15Base()), + _ownsAnalogVoltageReader(analogVoltageReader == nullptr) {} // Destructor AlphasenseCO2::~AlphasenseCO2() { diff --git a/src/sensors/AnalogElecConductivity.cpp b/src/sensors/AnalogElecConductivity.cpp index 9deb0eb1b..8ed7fe726 100644 --- a/src/sensors/AnalogElecConductivity.cpp +++ b/src/sensors/AnalogElecConductivity.cpp @@ -23,16 +23,11 @@ AnalogElecConductivity::AnalogElecConductivity( ANALOGELECCONDUCTIVITY_MEASUREMENT_TIME_MS, powerPin, dataPin, measurementsToAverage, ANALOGELECCONDUCTIVITY_INC_CALC_VARIABLES), _Rseries_ohms(Rseries_ohms), - _sensorEC_Konst(sensorEC_Konst) { - // If no analog voltage reader was provided, create a default one - if (analogVoltageReader == nullptr) { - _analogVoltageReader = new ProcessorAnalogBase(); - _ownsAnalogVoltageReader = true; - } else { - _analogVoltageReader = analogVoltageReader; - _ownsAnalogVoltageReader = false; - } -} + _sensorEC_Konst(sensorEC_Konst), + // If no analog voltage reader was provided, create a default one + _analogVoltageReader(analogVoltageReader ? analogVoltageReader + : new ProcessorAnalogBase()), + _ownsAnalogVoltageReader(analogVoltageReader == nullptr) {} // Destructor AnalogElecConductivity::~AnalogElecConductivity() { diff --git a/src/sensors/ApogeeSQ212.cpp b/src/sensors/ApogeeSQ212.cpp index 061046f4d..991556aab 100644 --- a/src/sensors/ApogeeSQ212.cpp +++ b/src/sensors/ApogeeSQ212.cpp @@ -22,16 +22,11 @@ ApogeeSQ212::ApogeeSQ212(int8_t powerPin, int8_t analogChannel, AnalogVoltageBase* analogVoltageReader) : Sensor("ApogeeSQ212", SQ212_NUM_VARIABLES, SQ212_WARM_UP_TIME_MS, SQ212_STABILIZATION_TIME_MS, SQ212_MEASUREMENT_TIME_MS, powerPin, - analogChannel, measurementsToAverage, SQ212_INC_CALC_VARIABLES) { - // If no analog voltage reader was provided, create a default one - if (analogVoltageReader == nullptr) { - _analogVoltageReader = new TIADS1x15Base(); - _ownsAnalogVoltageReader = true; - } else { - _analogVoltageReader = analogVoltageReader; - _ownsAnalogVoltageReader = false; - } -} + analogChannel, measurementsToAverage, SQ212_INC_CALC_VARIABLES), + // If no analog voltage reader was provided, create a default one + _analogVoltageReader(analogVoltageReader ? analogVoltageReader + : new TIADS1x15Base()), + _ownsAnalogVoltageReader(analogVoltageReader == nullptr) {} // Destructor ApogeeSQ212::~ApogeeSQ212() { diff --git a/src/sensors/CampbellOBS3.cpp b/src/sensors/CampbellOBS3.cpp index cef4098b1..29f6080cb 100644 --- a/src/sensors/CampbellOBS3.cpp +++ b/src/sensors/CampbellOBS3.cpp @@ -23,16 +23,11 @@ CampbellOBS3::CampbellOBS3(int8_t powerPin, int8_t analogChannel, analogChannel, measurementsToAverage, OBS3_INC_CALC_VARIABLES), _x2_coeff_A(x2_coeff_A), _x1_coeff_B(x1_coeff_B), - _x0_coeff_C(x0_coeff_C) { - // If no analog voltage reader was provided, create a default one - if (analogVoltageReader == nullptr) { - _analogVoltageReader = new TIADS1x15Base(); - _ownsAnalogVoltageReader = true; - } else { - _analogVoltageReader = analogVoltageReader; - _ownsAnalogVoltageReader = false; - } -} + _x0_coeff_C(x0_coeff_C), + // If no analog voltage reader was provided, create a default one + _analogVoltageReader(analogVoltageReader ? analogVoltageReader + : new TIADS1x15Base()), + _ownsAnalogVoltageReader(analogVoltageReader == nullptr) {} // Destructor CampbellOBS3::~CampbellOBS3() { diff --git a/src/sensors/EverlightALSPT19.cpp b/src/sensors/EverlightALSPT19.cpp index 26de6c1c9..26d1d39a7 100644 --- a/src/sensors/EverlightALSPT19.cpp +++ b/src/sensors/EverlightALSPT19.cpp @@ -22,16 +22,11 @@ EverlightALSPT19::EverlightALSPT19(int8_t powerPin, int8_t dataPin, measurementsToAverage, ALSPT19_INC_CALC_VARIABLES), _alsSupplyVoltage((alsSupplyVoltage > 0.0f) ? alsSupplyVoltage : OPERATING_VOLTAGE), - _loadResistor(loadResistor) { - // If no analog voltage reader was provided, create a default one - if (analogVoltageReader == nullptr) { - _analogVoltageReader = new ProcessorAnalogBase(); - _ownsAnalogVoltageReader = true; - } else { - _analogVoltageReader = analogVoltageReader; - _ownsAnalogVoltageReader = false; - } -} + _loadResistor(loadResistor), + // If no analog voltage reader was provided, create a default one + _analogVoltageReader(analogVoltageReader ? analogVoltageReader + : new ProcessorAnalogBase()), + _ownsAnalogVoltageReader(analogVoltageReader == nullptr) {} #if (defined(BUILT_IN_ALS_POWER_PIN) && defined(BUILT_IN_ALS_DATA_PIN) && \ defined(BUILT_IN_ALS_SUPPLY_VOLTAGE) && \ defined(BUILT_IN_ALS_LOADING_RESISTANCE)) || \ @@ -44,16 +39,10 @@ EverlightALSPT19::EverlightALSPT19(uint8_t measurementsToAverage, BUILT_IN_ALS_DATA_PIN, measurementsToAverage, ALSPT19_INC_CALC_VARIABLES), _alsSupplyVoltage(BUILT_IN_ALS_SUPPLY_VOLTAGE), - _loadResistor(BUILT_IN_ALS_LOADING_RESISTANCE) { - // If no analog voltage reader was provided, create a default one - if (analogVoltageReader == nullptr) { - _analogVoltageReader = new ProcessorAnalogBase(); - _ownsAnalogVoltageReader = true; - } else { - _analogVoltageReader = analogVoltageReader; - _ownsAnalogVoltageReader = false; - } -} + _loadResistor(BUILT_IN_ALS_LOADING_RESISTANCE), + _analogVoltageReader(analogVoltageReader ? analogVoltageReader + : new ProcessorAnalogBase()), + _ownsAnalogVoltageReader(analogVoltageReader == nullptr) {} #endif // Destructor diff --git a/src/sensors/TurnerCyclops.cpp b/src/sensors/TurnerCyclops.cpp index fe453434a..5efb95b0f 100644 --- a/src/sensors/TurnerCyclops.cpp +++ b/src/sensors/TurnerCyclops.cpp @@ -24,16 +24,11 @@ TurnerCyclops::TurnerCyclops(int8_t powerPin, int8_t analogChannel, CYCLOPS_INC_CALC_VARIABLES), _conc_std(conc_std), _volt_std(volt_std), - _volt_blank(volt_blank) { - // If no analog voltage reader was provided, create a default one - if (analogVoltageReader == nullptr) { - _analogVoltageReader = new TIADS1x15Base(); - _ownsAnalogVoltageReader = true; - } else { - _analogVoltageReader = analogVoltageReader; - _ownsAnalogVoltageReader = false; - } -} + _volt_blank(volt_blank), + // If no analog voltage reader was provided, create a default one + _analogVoltageReader(analogVoltageReader ? analogVoltageReader + : new TIADS1x15Base()), + _ownsAnalogVoltageReader(analogVoltageReader == nullptr) {} // Destructor TurnerCyclops::~TurnerCyclops() { diff --git a/src/sensors/TurnerTurbidityPlus.cpp b/src/sensors/TurnerTurbidityPlus.cpp index 292a9495a..9204fb721 100644 --- a/src/sensors/TurnerTurbidityPlus.cpp +++ b/src/sensors/TurnerTurbidityPlus.cpp @@ -27,16 +27,11 @@ TurnerTurbidityPlus::TurnerTurbidityPlus( _conc_std(conc_std), _volt_std(volt_std), _volt_blank(volt_blank), - _analogReferenceChannel(analogReferenceChannel) { - // If no analog voltage reader was provided, create a default one - if (analogVoltageReader == nullptr) { - _analogVoltageReader = new TIADS1x15Base(); - _ownsAnalogVoltageReader = true; - } else { - _analogVoltageReader = analogVoltageReader; - _ownsAnalogVoltageReader = false; - } -} + _analogReferenceChannel(analogReferenceChannel), + // If no analog voltage reader was provided, create a default one + _analogVoltageReader(analogVoltageReader ? analogVoltageReader + : new TIADS1x15Base()), + _ownsAnalogVoltageReader(analogVoltageReader == nullptr) {} // Destructor TurnerTurbidityPlus::~TurnerTurbidityPlus() { From 01d1c51e5320249aa71727cc9d450bb8a331d091 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Tue, 24 Feb 2026 18:35:59 -0500 Subject: [PATCH 318/533] docs and comments Signed-off-by: Sara Damiano --- examples/menu_a_la_carte/menu_a_la_carte.ino | 5 +++-- src/sensors/AnalogElecConductivity.cpp | 2 ++ src/sensors/AnalogElecConductivity.h | 4 +++- src/sensors/EverlightALSPT19.h | 8 ++++---- src/sensors/ProcessorAnalog.cpp | 4 ++-- src/sensors/TIADS1x15.cpp | 10 +++++++++- src/sensors/TIADS1x15.h | 6 +++--- 7 files changed, 26 insertions(+), 13 deletions(-) diff --git a/examples/menu_a_la_carte/menu_a_la_carte.ino b/examples/menu_a_la_carte/menu_a_la_carte.ino index d545706dc..5492f5c29 100644 --- a/examples/menu_a_la_carte/menu_a_la_carte.ino +++ b/examples/menu_a_la_carte/menu_a_la_carte.ino @@ -1608,8 +1608,9 @@ Variable* alsPt19Lux = new EverlightALSPT19_Illuminance( const int8_t ADSPower = sensorPowerPin; // Power pin const int8_t ADSChannel = 2; // The ADS channel of interest const float voltageMultiplier = - 10.0f; // Voltage multiplier: 1.0f for direct connection, (R_top + R_bottom) / R_bottom for voltage divider - // Default 10.0f assumes specific divider; change to 1.0f for direct ADS connection + 1.0f; // Voltage multiplier for an external voltage divider +// use 1.0f for direct connection +// use (R_top + R_bottom) / R_bottom for voltage divider const adsGain_t adsGain = GAIN_ONE; // The internal gain setting for the ADS const uint8_t evADSi2c_addr = 0x48; // The I2C address of the ADS1115 ADC const uint8_t VoltReadsToAvg = 1; // Only read one sample diff --git a/src/sensors/AnalogElecConductivity.cpp b/src/sensors/AnalogElecConductivity.cpp index 8ed7fe726..77a177029 100644 --- a/src/sensors/AnalogElecConductivity.cpp +++ b/src/sensors/AnalogElecConductivity.cpp @@ -80,6 +80,8 @@ bool AnalogElecConductivity::addSingleMeasurementResult(void) { // Estimate Resistance of Liquid // see the header for an explanation of this calculation // Convert voltage back to ADC equivalent for existing calculation + // NOTE: The supplyVoltage is already clamped by the + // _analogVoltageReader float supplyVoltage = _analogVoltageReader->getSupplyVoltage(); float adcRatio = adcVoltage / supplyVoltage; diff --git a/src/sensors/AnalogElecConductivity.h b/src/sensors/AnalogElecConductivity.h index eee13ca52..97ca823f3 100644 --- a/src/sensors/AnalogElecConductivity.h +++ b/src/sensors/AnalogElecConductivity.h @@ -300,7 +300,9 @@ class AnalogElecConductivity : public Sensor { AnalogVoltageBase* analogVoltageReader = nullptr); /** - * @brief Destroy the AnalogElecConductivity object - no action needed. + * @brief Destroy the AnalogElecConductivity object. + * + * Deletes the internal analog voltage reader if this object owns it. */ ~AnalogElecConductivity(); diff --git a/src/sensors/EverlightALSPT19.h b/src/sensors/EverlightALSPT19.h index 2e0b86c0d..f825c72be 100644 --- a/src/sensors/EverlightALSPT19.h +++ b/src/sensors/EverlightALSPT19.h @@ -28,14 +28,14 @@ * @section sensor_alspt19_datasheet Sensor Datasheet * [Datasheet](https://github.com/EnviroDIY/ModularSensors/wiki/Sensor-Datasheets/Everlight-ALS-PT19.pdf) * - * @section sensor_analog_cond_flags Build flags + * @section sensor_alspt19_config_flags Build flags * - `-D ALSPT19_CURRENT_PER_LUX=##` * - used to set current equivalent to 1000lux, which is used to calculate * lux from the sensor * * @section sensor_alspt19_ctor Sensor Constructors - * {{ @ref EverlightALSPT19::EverlightALSPT19(uint8_t) }} - * {{ @ref EverlightALSPT19::EverlightALSPT19(int8_t, int8_t, float, float, uint8_t) }} + * {{ @ref EverlightALSPT19::EverlightALSPT19(uint8_t, AnalogVoltageBase*) }} + * {{ @ref EverlightALSPT19::EverlightALSPT19(int8_t, int8_t, float, float, uint8_t, AnalogVoltageBase*) }} * * @section sensor_alspt19_examples Example Code * @@ -96,7 +96,7 @@ /** * @anchor sensor_alspt19_config * @name Configuration Defines - * Defines to for the ALS calibration between current and lux. + * Define for the ALS calibration between current and lux. */ /**@{*/ #if !defined(ALSPT19_CURRENT_PER_LUX) || defined(DOXYGEN) diff --git a/src/sensors/ProcessorAnalog.cpp b/src/sensors/ProcessorAnalog.cpp index 07840f605..04d4944d0 100644 --- a/src/sensors/ProcessorAnalog.cpp +++ b/src/sensors/ProcessorAnalog.cpp @@ -34,8 +34,8 @@ bool ProcessorAnalogBase::readVoltageSingleEnded(int8_t analogChannel, return false; } if (analogChannel < 0 || _supplyVoltage <= 0 || _voltageMultiplier <= 0) { - MS_DBG(F("Missing one or more required parameters: analog pin, " - "operating voltage, or voltage divider!")); + MS_DBG(F("Invalid configuration: analog channel, supply voltage, " + "or voltage multiplier is not set!")); resultValue = -9999.0f; return false; } diff --git a/src/sensors/TIADS1x15.cpp b/src/sensors/TIADS1x15.cpp index be020f61f..e91daa3f9 100644 --- a/src/sensors/TIADS1x15.cpp +++ b/src/sensors/TIADS1x15.cpp @@ -26,7 +26,9 @@ TIADS1x15Base::TIADS1x15Base(float voltageMultiplier, adsGain_t adsGain, _adsGain(adsGain), _i2cAddress(i2cAddress) { // Clamp supply voltage to valid ADS1x15 range: 0.0V to 5.5V per datasheet - // This clamp is done silently! + // NOTE: This clamp is intentionally silent — Serial/MS_DBG is NOT safe to + // call during construction (the Serial object may not be initialized yet on + // Arduino targets). Use setSupplyVoltage() at runtime for logged clamping. if (_supplyVoltage < 0.0f) { _supplyVoltage = 0.0f; } else if (_supplyVoltage > 5.5f) { @@ -168,6 +170,12 @@ bool TIADS1x15Base::readVoltageDifferential(int8_t analogChannel, adcCounts = ads.readADC_Differential_1_3(); } else if (analogChannel == 2 && analogReferenceChannel == 3) { adcCounts = ads.readADC_Differential_2_3(); + } else { + // Should never reach here; isValidDifferentialPair must have been + // widened without updating this dispatch table. + MS_DBG(F( + " Internal error: unhandled differential pair after validation")); + return false; } // Convert counts to voltage diff --git a/src/sensors/TIADS1x15.h b/src/sensors/TIADS1x15.h index 7073d074f..1ee38a856 100644 --- a/src/sensors/TIADS1x15.h +++ b/src/sensors/TIADS1x15.h @@ -336,9 +336,9 @@ class TIADS1x15Base : public AnalogVoltageBase { * @param channel2 Second channel (0-3, physical ADS channel indices only) * @return True if the combination is valid (0-1, 0-3, 1-3, or 2-3) * - * @note Channel parameters use uint8_t to be consistent with the - * Adafruit_ADS1X15 channel type convention and to avoid sign-extension - * when computing hardware MUX configuration values internally. + * @note Channel parameters use int8_t, consistent with the rest of the + * ModularSensors channel conventions. Negative values indicate invalid + * channels. */ static bool isValidDifferentialPair(int8_t channel1, int8_t channel2); From 2584b629e87e10807f253e2e364dfda109de9928 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Tue, 24 Feb 2026 18:38:11 -0500 Subject: [PATCH 319/533] Revert "Remove un-necessary null checks" This reverts commit 416464b8f4d6969fbf7c5b4e14cfd2f25a65ff31. --- src/sensors/AlphasenseCO2.cpp | 26 ++++++++++++++----------- src/sensors/AnalogElecConductivity.cpp | 27 ++++++++++++++------------ src/sensors/ApogeeSQ212.cpp | 15 +++++++++----- src/sensors/CampbellOBS3.cpp | 13 ++++++++----- src/sensors/EverlightALSPT19.cpp | 15 +++++++++----- src/sensors/TurnerCyclops.cpp | 13 ++++++++----- src/sensors/TurnerTurbidityPlus.cpp | 21 +++++++++++++------- 7 files changed, 80 insertions(+), 50 deletions(-) diff --git a/src/sensors/AlphasenseCO2.cpp b/src/sensors/AlphasenseCO2.cpp index 980a23af7..c471a2573 100644 --- a/src/sensors/AlphasenseCO2.cpp +++ b/src/sensors/AlphasenseCO2.cpp @@ -43,13 +43,20 @@ AlphasenseCO2::~AlphasenseCO2() { String AlphasenseCO2::getSensorLocation(void) { - // NOTE: The constructor guarantees that _analogVoltageReader is not null - String sensorLocation = _analogVoltageReader->getSensorLocation(); - sensorLocation += F("_Diff_"); - sensorLocation += String(_dataPin); - sensorLocation += F("_"); - sensorLocation += String(_analogReferenceChannel); - return sensorLocation; + if (_analogVoltageReader != nullptr) { + String sensorLocation = _analogVoltageReader->getSensorLocation(); + sensorLocation += F("_Diff_"); + sensorLocation += String(_dataPin); + sensorLocation += F("_"); + sensorLocation += String(_analogReferenceChannel); + return sensorLocation; + } else { + String sensorLocation = F("Unknown_AnalogVoltageReader_Diff_"); + sensorLocation += String(_dataPin); + sensorLocation += F("_"); + sensorLocation += String(_analogReferenceChannel); + return sensorLocation; + } } @@ -71,10 +78,7 @@ bool AlphasenseCO2::addSingleMeasurementResult(void) { MS_DBG(getSensorNameAndLocation(), F("is reporting:")); - // Read the differential voltage using the AnalogVoltageBase interface - // NOTE: All implementations of the AnalogVoltageBase class validate both - // the input channel and the resulting voltage, so we can trust that a - // successful read will give us a valid voltage value to work with. + // Read differential voltage using the AnalogVoltageBase interface success = _analogVoltageReader->readVoltageDifferential( _dataPin, _analogReferenceChannel, adcVoltage); diff --git a/src/sensors/AnalogElecConductivity.cpp b/src/sensors/AnalogElecConductivity.cpp index 77a177029..74eb32ad2 100644 --- a/src/sensors/AnalogElecConductivity.cpp +++ b/src/sensors/AnalogElecConductivity.cpp @@ -40,13 +40,20 @@ AnalogElecConductivity::~AnalogElecConductivity() { String AnalogElecConductivity::getSensorLocation(void) { - // NOTE: The constructor guarantees that _analogVoltageReader is not null - String sensorLocation = _analogVoltageReader->getSensorLocation(); - sensorLocation += F("_anlgEc_"); - sensorLocation += String(_dataPin); - sensorLocation += F("_Pwr"); - sensorLocation += String(_powerPin); - return sensorLocation; + if (_analogVoltageReader != nullptr) { + String sensorLocation = _analogVoltageReader->getSensorLocation(); + sensorLocation += F("_anlgEc_"); + sensorLocation += String(_dataPin); + sensorLocation += F("_Pwr"); + sensorLocation += String(_powerPin); + return sensorLocation; + } else { + String sensorLocation = F("Unknown_AnalogVoltageReader_anlgEc_"); + sensorLocation += String(_dataPin); + sensorLocation += F("_Pwr"); + sensorLocation += String(_powerPin); + return sensorLocation; + } } @@ -68,11 +75,7 @@ bool AnalogElecConductivity::addSingleMeasurementResult(void) { MS_DBG(getSensorNameAndLocation(), F("is reporting:")); - // Read the single-ended analog voltage using the AnalogVoltageBase - // interface. - // NOTE: All implementations of the AnalogVoltageBase class validate both - // the input channel and the resulting voltage, so we can trust that a - // successful read will give us a valid voltage value to work with. + // Read the analog voltage using the AnalogVoltageBase interface success = _analogVoltageReader->readVoltageSingleEnded(_dataPin, adcVoltage); diff --git a/src/sensors/ApogeeSQ212.cpp b/src/sensors/ApogeeSQ212.cpp index 991556aab..1fb3ca150 100644 --- a/src/sensors/ApogeeSQ212.cpp +++ b/src/sensors/ApogeeSQ212.cpp @@ -39,11 +39,16 @@ ApogeeSQ212::~ApogeeSQ212() { String ApogeeSQ212::getSensorLocation(void) { - // NOTE: The constructor guarantees that _analogVoltageReader is not null - String sensorLocation = _analogVoltageReader->getSensorLocation(); - sensorLocation += F("_Channel"); - sensorLocation += String(_dataPin); - return sensorLocation; + if (_analogVoltageReader != nullptr) { + String sensorLocation = _analogVoltageReader->getSensorLocation(); + sensorLocation += F("_Channel"); + sensorLocation += String(_dataPin); + return sensorLocation; + } else { + String sensorLocation = F("Unknown_AnalogVoltageReader_Channel"); + sensorLocation += String(_dataPin); + return sensorLocation; + } } diff --git a/src/sensors/CampbellOBS3.cpp b/src/sensors/CampbellOBS3.cpp index 29f6080cb..0a28ff0cc 100644 --- a/src/sensors/CampbellOBS3.cpp +++ b/src/sensors/CampbellOBS3.cpp @@ -40,11 +40,14 @@ CampbellOBS3::~CampbellOBS3() { String CampbellOBS3::getSensorLocation(void) { - // NOTE: The constructor guarantees that _analogVoltageReader is not null - String sensorLocation = _analogVoltageReader->getSensorLocation(); - sensorLocation += F("_Channel"); - sensorLocation += String(_dataPin); - return sensorLocation; + if (_analogVoltageReader != nullptr) { + return _analogVoltageReader->getSensorLocation() + F("_Channel") + + String(_dataPin); + } else { + String sensorLocation = F("Unknown_AnalogVoltageReader_Channel"); + sensorLocation += String(_dataPin); + return sensorLocation; + } } diff --git a/src/sensors/EverlightALSPT19.cpp b/src/sensors/EverlightALSPT19.cpp index 26d1d39a7..3a0e568aa 100644 --- a/src/sensors/EverlightALSPT19.cpp +++ b/src/sensors/EverlightALSPT19.cpp @@ -56,11 +56,16 @@ EverlightALSPT19::~EverlightALSPT19() { String EverlightALSPT19::getSensorLocation(void) { - // NOTE: The constructor guarantees that _analogVoltageReader is not null - String sensorLocation = _analogVoltageReader->getSensorLocation(); - sensorLocation += F("_"); - sensorLocation += String(_dataPin); - return sensorLocation; + if (_analogVoltageReader != nullptr) { + String sensorLocation = _analogVoltageReader->getSensorLocation(); + sensorLocation += F("_"); + sensorLocation += String(_dataPin); + return sensorLocation; + } else { + String sensorLocation = F("Unknown_AnalogVoltageReader_"); + sensorLocation += String(_dataPin); + return sensorLocation; + } } diff --git a/src/sensors/TurnerCyclops.cpp b/src/sensors/TurnerCyclops.cpp index 5efb95b0f..6e3b19bc6 100644 --- a/src/sensors/TurnerCyclops.cpp +++ b/src/sensors/TurnerCyclops.cpp @@ -41,11 +41,14 @@ TurnerCyclops::~TurnerCyclops() { String TurnerCyclops::getSensorLocation(void) { - // NOTE: The constructor guarantees that _analogVoltageReader is not null - String sensorLocation = _analogVoltageReader->getSensorLocation(); - sensorLocation += F("_Channel"); - sensorLocation += String(_dataPin); - return sensorLocation; + if (_analogVoltageReader != nullptr) { + return _analogVoltageReader->getSensorLocation() + F("_Channel") + + String(_dataPin); + } else { + String sensorLocation = F("Unknown_AnalogVoltageReader_Channel"); + sensorLocation += String(_dataPin); + return sensorLocation; + } } diff --git a/src/sensors/TurnerTurbidityPlus.cpp b/src/sensors/TurnerTurbidityPlus.cpp index 9204fb721..7efe98419 100644 --- a/src/sensors/TurnerTurbidityPlus.cpp +++ b/src/sensors/TurnerTurbidityPlus.cpp @@ -44,13 +44,20 @@ TurnerTurbidityPlus::~TurnerTurbidityPlus() { String TurnerTurbidityPlus::getSensorLocation(void) { - // NOTE: The constructor guarantees that _analogVoltageReader is not null - String sensorLocation = _analogVoltageReader->getSensorLocation(); - sensorLocation += F("_Diff_"); - sensorLocation += String(_dataPin); - sensorLocation += F("_"); - sensorLocation += String(_analogReferenceChannel); - return sensorLocation; + if (_analogVoltageReader != nullptr) { + String sensorLocation = _analogVoltageReader->getSensorLocation(); + sensorLocation += F("_Diff_"); + sensorLocation += String(_dataPin); + sensorLocation += F("_"); + sensorLocation += String(_analogReferenceChannel); + return sensorLocation; + } else { + String sensorLocation = F("Unknown_AnalogVoltageReader_Diff_"); + sensorLocation += String(_dataPin); + sensorLocation += F("_"); + sensorLocation += String(_analogReferenceChannel); + return sensorLocation; + } } void TurnerTurbidityPlus::runWiper() { From 000ea79e082ab2f4fdcf9ba239fde78aff6efb80 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Tue, 24 Feb 2026 19:10:44 -0500 Subject: [PATCH 320/533] Fix some comments, float tags, magic numbers Signed-off-by: Sara Damiano --- src/ModSensorConfig.h | 30 ++++++------- src/sensors/AlphasenseCO2.cpp | 1 - src/sensors/AlphasenseCO2.h | 6 +-- src/sensors/AnalogElecConductivity.cpp | 5 ++- src/sensors/AnalogElecConductivity.h | 48 ++++++++++++++------ src/sensors/AnalogVoltageBase.h | 6 ++- src/sensors/ApogeeSQ212.cpp | 3 +- src/sensors/ApogeeSQ212.h | 6 +-- src/sensors/CampbellOBS3.cpp | 1 - src/sensors/CampbellOBS3.h | 12 ++--- src/sensors/EverlightALSPT19.cpp | 17 +++---- src/sensors/EverlightALSPT19.h | 4 +- src/sensors/ProcessorAnalog.h | 10 ++--- src/sensors/TIADS1x15.cpp | 13 +++--- src/sensors/TIADS1x15.h | 61 +++++++++++++++----------- src/sensors/TurnerCyclops.cpp | 1 - src/sensors/TurnerCyclops.h | 20 ++++----- src/sensors/TurnerTurbidityPlus.cpp | 3 +- src/sensors/TurnerTurbidityPlus.h | 6 +-- 19 files changed, 140 insertions(+), 113 deletions(-) diff --git a/src/ModSensorConfig.h b/src/ModSensorConfig.h index 083688e1c..e3de5096a 100644 --- a/src/ModSensorConfig.h +++ b/src/ModSensorConfig.h @@ -43,6 +43,21 @@ // This is for sensors that use the external ADC for analog voltage // measurements. // #define MS_USE_ADS1015 + +#if !defined(MS_DEFAULT_ADS1X15_ADDRESS) || defined(DOXYGEN) +/** + * @brief The default I²C address of the ADS1115 or ADS1015 external ADC. + * + * Valid addresses depend on the ADDR pin connection: + * - `0x48` – ADDR to GND (default) + * - `0x49` – ADDR to VDD + * - `0x4A` – ADDR to SDA + * - `0x4B` – ADDR to SCL + * + * Override with a build flag: `-DMS_DEFAULT_ADS1X15_ADDRESS=0x49` + */ +#define MS_DEFAULT_ADS1X15_ADDRESS 0x48 +#endif // !defined(MS_DEFAULT_ADS1X15_ADDRESS) || defined(DOXYGEN) //============================================================== //============================================================== @@ -229,21 +244,6 @@ #error The processor ADC reference type must be defined! #endif // MS_PROCESSOR_ADC_REFERENCE_MODE #endif // !defined(MS_PROCESSOR_ADC_REFERENCE_MODE) || defined(DOXYGEN) - -#if !defined(MS_DEFAULT_ADS1X15_ADDRESS) || defined(DOXYGEN) -/** - * @brief The default I²C address of the ADS1115 or ADS1015 external ADC. - * - * Valid addresses depend on the ADDR pin connection: - * - `0x48` – ADDR to GND (default) - * - `0x49` – ADDR to VDD - * - `0x4A` – ADDR to SDA - * - `0x4B` – ADDR to SCL - * - * Override with a build flag: `-DMS_DEFAULT_ADS1X15_ADDRESS=0x49` - */ -#define MS_DEFAULT_ADS1X15_ADDRESS 0x48 -#endif // !defined(MS_DEFAULT_ADS1X15_ADDRESS) || defined(DOXYGEN) //============================================================== diff --git a/src/sensors/AlphasenseCO2.cpp b/src/sensors/AlphasenseCO2.cpp index c471a2573..c972a79db 100644 --- a/src/sensors/AlphasenseCO2.cpp +++ b/src/sensors/AlphasenseCO2.cpp @@ -37,7 +37,6 @@ AlphasenseCO2::~AlphasenseCO2() { // Clean up the analog voltage reader if we created it if (_ownsAnalogVoltageReader && _analogVoltageReader != nullptr) { delete _analogVoltageReader; - _analogVoltageReader = nullptr; } } diff --git a/src/sensors/AlphasenseCO2.h b/src/sensors/AlphasenseCO2.h index 5264d3e83..c43212fe1 100644 --- a/src/sensors/AlphasenseCO2.h +++ b/src/sensors/AlphasenseCO2.h @@ -262,9 +262,9 @@ class AlphasenseCO2 : public Sensor { * @brief Construct a new Alphasense IRC-A1 CO2 object - need the power pin * and the analog data and reference channels. * - * By default, this constructor will use a new TIADS1x15Base object with all - * default values for voltage readings, but a pointer to a custom - * AnalogVoltageBase object can be passed in if desired. + * By default, this constructor will internally create a default + * AnalogVoltageBase implementation for voltage readings, but a pointer to + * a custom AnalogVoltageBase object can be passed in if desired. * * @param powerPin The pin on the mcu controlling power to the * Alphasense CO2 sensor. Use -1 if it is continuously powered. diff --git a/src/sensors/AnalogElecConductivity.cpp b/src/sensors/AnalogElecConductivity.cpp index 74eb32ad2..235246bd6 100644 --- a/src/sensors/AnalogElecConductivity.cpp +++ b/src/sensors/AnalogElecConductivity.cpp @@ -34,7 +34,6 @@ AnalogElecConductivity::~AnalogElecConductivity() { // Clean up the analog voltage reader if we created it if (_ownsAnalogVoltageReader && _analogVoltageReader != nullptr) { delete _analogVoltageReader; - _analogVoltageReader = nullptr; } } @@ -90,7 +89,9 @@ bool AnalogElecConductivity::addSingleMeasurementResult(void) { if (adcRatio >= 1.0) { // Prevent division issues when voltage reaches supply voltage - adcRatio = 0.999; + MS_DBG(F(" ADC ratio clamped from"), adcRatio, F("to"), + ANALOGELECCONDUCTIVITY_ADC_MAX_RATIO); + adcRatio = ANALOGELECCONDUCTIVITY_ADC_MAX_RATIO; } float Rwater_ohms = _Rseries_ohms * adcRatio / (1.0 - adcRatio); diff --git a/src/sensors/AnalogElecConductivity.h b/src/sensors/AnalogElecConductivity.h index 97ca823f3..eea38e277 100644 --- a/src/sensors/AnalogElecConductivity.h +++ b/src/sensors/AnalogElecConductivity.h @@ -116,6 +116,15 @@ * - `-D MS_PROCESSOR_ADC_REFERENCE_MODE=xxx` * - used to set the processor ADC value reference mode * - @see #MS_PROCESSOR_ADC_REFERENCE_MODE + * - `-D ANALOGELECCONDUCTIVITY_RSERIES_OHMS=###` + * - used to set the default resistance of the measuring resistor in ohms + * - @see #ANALOGELECCONDUCTIVITY_RSERIES_OHMS + * - `-D ANALOGELECCONDUCTIVITY_KONST=x.x` + * - used to set the cell constant for EC measurements + * - @see #ANALOGELECCONDUCTIVITY_KONST + * - `-D ANALOGELECCONDUCTIVITY_ADC_MAX_RATIO=x.xxx` + * - used to set the maximum ADC ratio to prevent division by zero + * - @see #ANALOGELECCONDUCTIVITY_ADC_MAX_RATIO * * @section sensor_analog_cond_ctor Sensor Constructor * {{ @ref AnalogElecConductivity::AnalogElecConductivity }} @@ -185,15 +194,15 @@ * conductivity sensor depending on the processor and ADC in use. */ /**@{*/ -#if !defined(RSERIES_OHMS_DEF) || defined(DOXYGEN) +#if !defined(ANALOGELECCONDUCTIVITY_RSERIES_OHMS) || defined(DOXYGEN) /** * @brief The default resistance (in ohms) of the measuring resistor. * This should not be less than 300 ohms when measuring EC in water. */ -#define RSERIES_OHMS_DEF 499 -#endif // RSERIES_OHMS_DEF +#define ANALOGELECCONDUCTIVITY_RSERIES_OHMS 499 +#endif // ANALOGELECCONDUCTIVITY_RSERIES_OHMS -#if !defined(SENSOREC_KONST_DEF) || defined(DOXYGEN) +#if !defined(ANALOGELECCONDUCTIVITY_KONST) || defined(DOXYGEN) /** * @brief Cell Constant For EC Measurements. * @@ -205,8 +214,20 @@ * and fluid to get a better estimate for K. * Default to 1.0, and can be set at startup. */ -#define SENSOREC_KONST_DEF 1.0 -#endif // SENSOREC_KONST_DEF +#define ANALOGELECCONDUCTIVITY_KONST 1.0 +#endif // ANALOGELECCONDUCTIVITY_KONST + +#if !defined(ANALOGELECCONDUCTIVITY_ADC_MAX_RATIO) || defined(DOXYGEN) +/** + * @brief Maximum ADC ratio to prevent division by zero in resistance + * calculation. + * + * This value clamps the ADC ratio when the measured voltage approaches the + * supply voltage, preventing division by zero in the water resistance + * calculation. Must be less than 1.0. + */ +#define ANALOGELECCONDUCTIVITY_ADC_MAX_RATIO 0.999f +#endif // ANALOGELECCONDUCTIVITY_ADC_MAX_RATIO /**@}*/ /** @@ -293,11 +314,12 @@ class AnalogElecConductivity : public Sensor { * pointer is supplied, the caller retains ownership and must ensure its * lifetime exceeds that of this object. */ - AnalogElecConductivity(int8_t powerPin, int8_t dataPin, - float Rseries_ohms = RSERIES_OHMS_DEF, - float sensorEC_Konst = SENSOREC_KONST_DEF, - uint8_t measurementsToAverage = 1, - AnalogVoltageBase* analogVoltageReader = nullptr); + AnalogElecConductivity( + int8_t powerPin, int8_t dataPin, + float Rseries_ohms = ANALOGELECCONDUCTIVITY_RSERIES_OHMS, + float sensorEC_Konst = ANALOGELECCONDUCTIVITY_KONST, + uint8_t measurementsToAverage = 1, + AnalogVoltageBase* analogVoltageReader = nullptr); /** * @brief Destroy the AnalogElecConductivity object. @@ -341,10 +363,10 @@ class AnalogElecConductivity : public Sensor { private: /// @brief The resistance of the circuit resistor plus any series port /// resistance - float _Rseries_ohms = RSERIES_OHMS_DEF; + float _Rseries_ohms = ANALOGELECCONDUCTIVITY_RSERIES_OHMS; /// @brief the cell constant for the circuit - float _sensorEC_Konst = SENSOREC_KONST_DEF; + float _sensorEC_Konst = ANALOGELECCONDUCTIVITY_KONST; /// @brief Pointer to analog voltage reader AnalogVoltageBase* _analogVoltageReader = nullptr; /// @brief Flag to track if this object owns the analog voltage reader and diff --git a/src/sensors/AnalogVoltageBase.h b/src/sensors/AnalogVoltageBase.h index ec1aa8f5d..1ef8d1ea3 100644 --- a/src/sensors/AnalogVoltageBase.h +++ b/src/sensors/AnalogVoltageBase.h @@ -47,7 +47,11 @@ class AnalogVoltageBase { */ AnalogVoltageBase(float voltageMultiplier = 1.0f, float supplyVoltage = OPERATING_VOLTAGE) - : _voltageMultiplier((voltageMultiplier > 0.0f) ? voltageMultiplier + : // NOTE: These clamps are intentionally silent — Serial/MS_DBG is NOT + // safe to call during construction (the Serial object may not be + // initialized yet on Arduino targets). Use setSupplyVoltage() at + // runtime for logged clamping. + _voltageMultiplier((voltageMultiplier > 0.0f) ? voltageMultiplier : 1.0f), _supplyVoltage((supplyVoltage > 0.0f) ? supplyVoltage : OPERATING_VOLTAGE) {} diff --git a/src/sensors/ApogeeSQ212.cpp b/src/sensors/ApogeeSQ212.cpp index 1fb3ca150..804d7ec1e 100644 --- a/src/sensors/ApogeeSQ212.cpp +++ b/src/sensors/ApogeeSQ212.cpp @@ -33,7 +33,6 @@ ApogeeSQ212::~ApogeeSQ212() { // Clean up the analog voltage reader if we created it if (_ownsAnalogVoltageReader && _analogVoltageReader != nullptr) { delete _analogVoltageReader; - _analogVoltageReader = nullptr; } } @@ -85,7 +84,7 @@ bool ApogeeSQ212::addSingleMeasurementResult(void) { // it must be set as a preprocessor definition when compiling the // library, e.g. by adding -DSQ212_CALIBRATION_FACTOR=0.95 to the // compiler flags. - float calibResult = 1000 * adcVoltage * SQ212_CALIBRATION_FACTOR; + float calibResult = 1000.0f * adcVoltage * SQ212_CALIBRATION_FACTOR; MS_DBG(F(" calibResult:"), calibResult); verifyAndAddMeasurementResult(SQ212_PAR_VAR_NUM, calibResult); verifyAndAddMeasurementResult(SQ212_VOLTAGE_VAR_NUM, adcVoltage); diff --git a/src/sensors/ApogeeSQ212.h b/src/sensors/ApogeeSQ212.h index e566709ce..0ce984681 100644 --- a/src/sensors/ApogeeSQ212.h +++ b/src/sensors/ApogeeSQ212.h @@ -242,9 +242,9 @@ class ApogeeSQ212 : public Sensor { * @brief Construct a new Apogee SQ-212 object - need the power pin and the * analog data channel. * - * By default, this constructor will use a new TIADS1x15Base object with all - * default values for voltage readings, but a pointer to a custom - * AnalogVoltageBase object can be passed in if desired. + * By default, this constructor will internally create a default + * AnalogVoltageBase implementation for voltage readings, but a pointer to + * a custom AnalogVoltageBase object can be passed in if desired. * * @param powerPin The pin on the mcu controlling power to the Apogee * SQ-212. Use -1 if it is continuously powered. diff --git a/src/sensors/CampbellOBS3.cpp b/src/sensors/CampbellOBS3.cpp index 0a28ff0cc..217ad340e 100644 --- a/src/sensors/CampbellOBS3.cpp +++ b/src/sensors/CampbellOBS3.cpp @@ -34,7 +34,6 @@ CampbellOBS3::~CampbellOBS3() { // Clean up the analog voltage reader if we created it if (_ownsAnalogVoltageReader && _analogVoltageReader != nullptr) { delete _analogVoltageReader; - _analogVoltageReader = nullptr; } } diff --git a/src/sensors/CampbellOBS3.h b/src/sensors/CampbellOBS3.h index 73a314dfe..b330a5988 100644 --- a/src/sensors/CampbellOBS3.h +++ b/src/sensors/CampbellOBS3.h @@ -237,9 +237,9 @@ class CampbellOBS3 : public Sensor { * @brief Construct a new Campbell OBS3 object - need the power pin, the * analog data channel, and the calibration info. * - * By default, this constructor will use a new TIADS1x15Base object with all - * default values for voltage readings, but a pointer to a custom - * AnalogVoltageBase object can be passed in if desired. + * By default, this constructor will internally create a default + * AnalogVoltageBase implementation for voltage readings, but a pointer to + * a custom AnalogVoltageBase object can be passed in if desired. * * @param powerPin The pin on the mcu controlling power to the OBS3+ * Use -1 if it is continuously powered. @@ -285,9 +285,9 @@ class CampbellOBS3 : public Sensor { bool addSingleMeasurementResult(void) override; private: - float _x2_coeff_A; ///< Internal reference to the x^2 coefficient - float _x1_coeff_B; ///< Internal reference to the x coefficient - float _x0_coeff_C; ///< Internal reference to the x^0 coefficient + float _x2_coeff_A; ///< The x^2 (A) calibration coefficient + float _x1_coeff_B; ///< The x^1 (B) calibration coefficient + float _x0_coeff_C; ///< The x^0 (C) calibration coefficient /// @brief Pointer to analog voltage reader AnalogVoltageBase* _analogVoltageReader = nullptr; /// @brief Flag to track if this object owns the analog voltage reader and diff --git a/src/sensors/EverlightALSPT19.cpp b/src/sensors/EverlightALSPT19.cpp index 3a0e568aa..fb0d7bd42 100644 --- a/src/sensors/EverlightALSPT19.cpp +++ b/src/sensors/EverlightALSPT19.cpp @@ -33,16 +33,10 @@ EverlightALSPT19::EverlightALSPT19(int8_t powerPin, int8_t dataPin, defined(DOXYGEN) EverlightALSPT19::EverlightALSPT19(uint8_t measurementsToAverage, AnalogVoltageBase* analogVoltageReader) - : Sensor("Everlight ALS-PT19", ALSPT19_NUM_VARIABLES, - ALSPT19_WARM_UP_TIME_MS, ALSPT19_STABILIZATION_TIME_MS, - ALSPT19_MEASUREMENT_TIME_MS, BUILT_IN_ALS_POWER_PIN, - BUILT_IN_ALS_DATA_PIN, measurementsToAverage, - ALSPT19_INC_CALC_VARIABLES), - _alsSupplyVoltage(BUILT_IN_ALS_SUPPLY_VOLTAGE), - _loadResistor(BUILT_IN_ALS_LOADING_RESISTANCE), - _analogVoltageReader(analogVoltageReader ? analogVoltageReader - : new ProcessorAnalogBase()), - _ownsAnalogVoltageReader(analogVoltageReader == nullptr) {} + : EverlightALSPT19(BUILT_IN_ALS_POWER_PIN, BUILT_IN_ALS_DATA_PIN, + BUILT_IN_ALS_SUPPLY_VOLTAGE, + BUILT_IN_ALS_LOADING_RESISTANCE, measurementsToAverage, + analogVoltageReader) {} #endif // Destructor @@ -50,7 +44,6 @@ EverlightALSPT19::~EverlightALSPT19() { // Clean up the analog voltage reader if we created it if (_ownsAnalogVoltageReader && _analogVoltageReader != nullptr) { delete _analogVoltageReader; - _analogVoltageReader = nullptr; } } @@ -122,7 +115,7 @@ bool EverlightALSPT19::addSingleMeasurementResult(void) { // convert current to illuminance // from sensor datasheet, typical 200µA current for 1000 Lux - float calibResult = current_val * (1000. / ALSPT19_CURRENT_PER_LUX); + float calibResult = current_val * (1000.0f / ALSPT19_CURRENT_PER_LUX); MS_DBG(F(" Illuminance:"), calibResult, F("lux")); verifyAndAddMeasurementResult(ALSPT19_VOLTAGE_VAR_NUM, adcVoltage); diff --git a/src/sensors/EverlightALSPT19.h b/src/sensors/EverlightALSPT19.h index f825c72be..a1fa8bbb8 100644 --- a/src/sensors/EverlightALSPT19.h +++ b/src/sensors/EverlightALSPT19.h @@ -315,9 +315,9 @@ class EverlightALSPT19 : public Sensor { private: /// @brief The PT-19 power supply voltage - float _alsSupplyVoltage; + float _alsSupplyVoltage = 0.0f; /// @brief The loading resistance - float _loadResistor; + float _loadResistor = 0.0f; /// @brief Pointer to analog voltage reader AnalogVoltageBase* _analogVoltageReader = nullptr; /// @brief Flag to track if this object owns the analog voltage reader and diff --git a/src/sensors/ProcessorAnalog.h b/src/sensors/ProcessorAnalog.h index d8d59a54e..1c5228de3 100644 --- a/src/sensors/ProcessorAnalog.h +++ b/src/sensors/ProcessorAnalog.h @@ -247,16 +247,16 @@ class ProcessorAnalog : public Sensor, public ProcessorAnalogBase { * average before giving a "final" result from the sensor; optional with a * default value of 1. */ - explicit ProcessorAnalog(int8_t powerPin, int8_t dataPin, - float voltageMultiplier = 1.0f, - float operatingVoltage = OPERATING_VOLTAGE, - uint8_t measurementsToAverage = 1); + ProcessorAnalog(int8_t powerPin, int8_t dataPin, + float voltageMultiplier = 1.0f, + float operatingVoltage = OPERATING_VOLTAGE, + uint8_t measurementsToAverage = 1); /** * @brief Destroy the Processor Analog object */ ~ProcessorAnalog(); - String getSensorLocation() override; + String getSensorLocation(void) override; bool addSingleMeasurementResult(void) override; }; diff --git a/src/sensors/TIADS1x15.cpp b/src/sensors/TIADS1x15.cpp index e91daa3f9..0b23d8793 100644 --- a/src/sensors/TIADS1x15.cpp +++ b/src/sensors/TIADS1x15.cpp @@ -24,7 +24,8 @@ TIADS1x15Base::TIADS1x15Base(float voltageMultiplier, adsGain_t adsGain, uint8_t i2cAddress, float adsSupplyVoltage) : AnalogVoltageBase(voltageMultiplier, adsSupplyVoltage), _adsGain(adsGain), - _i2cAddress(i2cAddress) { + _i2cAddress(i2cAddress), + _adsDifferentialChannel(-1) { // Clamp supply voltage to valid ADS1x15 range: 0.0V to 5.5V per datasheet // NOTE: This clamp is intentionally silent — Serial/MS_DBG is NOT safe to // call during construction (the Serial object may not be initialized yet on @@ -254,8 +255,9 @@ TIADS1x15::TIADS1x15(int8_t powerPin, int8_t adsChannel, TIADS1X15_STABILIZATION_TIME_MS, TIADS1X15_MEASUREMENT_TIME_MS, powerPin, adsChannel, measurementsToAverage, TIADS1X15_INC_CALC_VARIABLES), - TIADS1x15Base(voltageMultiplier, adsGain, i2cAddress, adsSupplyVoltage), - _adsDifferentialChannel(-1) { + TIADS1x15Base(voltageMultiplier, adsGain, i2cAddress, adsSupplyVoltage) { + // Set for single-ended measurements + setDifferentialChannel(-1); // NOTE: We DO NOT validate the channel numbers in this constructor! We // CANNOT print a warning here about invalid channel because the Serial // object may not be initialized yet, and we don't want to cause a crash. @@ -273,8 +275,9 @@ TIADS1x15::TIADS1x15(int8_t powerPin, int8_t adsChannel1, int8_t adsChannel2, TIADS1X15_STABILIZATION_TIME_MS, TIADS1X15_MEASUREMENT_TIME_MS, powerPin, adsChannel1, measurementsToAverage, TIADS1X15_INC_CALC_VARIABLES), - TIADS1x15Base(voltageMultiplier, adsGain, i2cAddress, adsSupplyVoltage), - _adsDifferentialChannel(adsChannel2) { + TIADS1x15Base(voltageMultiplier, adsGain, i2cAddress, adsSupplyVoltage) { + // Set for differential measurements + setDifferentialChannel(adsChannel2); // NOTE: We DO NOT validate the channel numbers and pairings in this // constructor! We CANNOT print a warning here about invalid channel // because the Serial object may not be initialized yet, and we don't want diff --git a/src/sensors/TIADS1x15.h b/src/sensors/TIADS1x15.h index 1ee38a856..c66f2f409 100644 --- a/src/sensors/TIADS1x15.h +++ b/src/sensors/TIADS1x15.h @@ -351,6 +351,36 @@ class TIADS1x15Base : public AnalogVoltageBase { * @brief Internal reference to the I2C address of the TI-ADS1x15 */ uint8_t _i2cAddress; + + /** + * @brief Internal reference to the secondary (reference) analog channel for + * differential measurements + * + * For single-ended measurements: -1 (not used) + * For differential measurements: the second ADS channel (0-3) + */ + int8_t _adsDifferentialChannel = -1; + + /** + * @brief Helper function to check if this sensor is configured for + * differential measurements + * + * @return True if this sensor uses differential measurements, false for + * single-ended + */ + bool isDifferential() const { + return _adsDifferentialChannel != -1; + } + + /** + * @brief Set the differential channel for differential measurements + * + * @param differentialChannel The secondary (reference) channel for + * differential measurements (0-3), or -1 for single-ended + */ + void setDifferentialChannel(int8_t differentialChannel) { + _adsDifferentialChannel = differentialChannel; + } }; /* clang-format off */ @@ -391,11 +421,11 @@ class TIADS1x15 : public Sensor, public TIADS1x15Base { * @param adsSupplyVoltage The power supply voltage for the ADS1x15 in * volts; defaults to the processor operating voltage from KnownProcessors.h */ - TIADS1x15(int8_t powerPin, int8_t adsChannel, float voltageMultiplier = 1, - adsGain_t adsGain = GAIN_ONE, - uint8_t i2cAddress = MS_DEFAULT_ADS1X15_ADDRESS, - uint8_t measurementsToAverage = 1, - float adsSupplyVoltage = OPERATING_VOLTAGE); + TIADS1x15(int8_t powerPin, int8_t adsChannel, + float voltageMultiplier = 1.0f, adsGain_t adsGain = GAIN_ONE, + uint8_t i2cAddress = MS_DEFAULT_ADS1X15_ADDRESS, + uint8_t measurementsToAverage = 1, + float adsSupplyVoltage = OPERATING_VOLTAGE); /** * @brief Construct a new TIADS1x15 object for differential measurements * @@ -439,27 +469,6 @@ class TIADS1x15 : public Sensor, public TIADS1x15Base { * range) */ void setSupplyVoltage(float supplyVoltage) override; - - protected: - /** - * @brief Internal reference to the secondary (reference) analog channel for - * differential measurements - * - * For single-ended measurements: -1 (not used) - * For differential measurements: the second ADS channel (0-3) - */ - int8_t _adsDifferentialChannel = -1; - - /** - * @brief Helper function to check if this sensor is configured for - * differential measurements - * - * @return True if this sensor uses differential measurements, false for - * single-ended - */ - bool isDifferential() const { - return _adsDifferentialChannel != -1; - } }; /** diff --git a/src/sensors/TurnerCyclops.cpp b/src/sensors/TurnerCyclops.cpp index 6e3b19bc6..be0732dd9 100644 --- a/src/sensors/TurnerCyclops.cpp +++ b/src/sensors/TurnerCyclops.cpp @@ -35,7 +35,6 @@ TurnerCyclops::~TurnerCyclops() { // Clean up the analog voltage reader if we created it if (_ownsAnalogVoltageReader && _analogVoltageReader != nullptr) { delete _analogVoltageReader; - _analogVoltageReader = nullptr; } } diff --git a/src/sensors/TurnerCyclops.h b/src/sensors/TurnerCyclops.h index f669e2e47..9a17ea2fb 100644 --- a/src/sensors/TurnerCyclops.h +++ b/src/sensors/TurnerCyclops.h @@ -104,19 +104,19 @@ * * | ID | Variable | Units | * | --- | ---------------------------- | ----------------------------------- | + * | U | TurnerCyclops_CDOM | parts per billion (ppb) | * | C | TurnerCyclops_Chlorophyll | micrograms per Liter (µg/L) | - * | R | TurnerCyclops_Rhodamine | parts per billion (ppb) | + * | D | TurnerCyclops_RedChlorophyll | micrograms per Liter (µg/L) | * | F | TurnerCyclops_Fluorescein | parts per billion (ppb) | - * | P | TurnerCyclops_Phycocyanin | parts per billion (ppb) | - * | E | TurnerCyclops_Phycoerythrin | parts per billion (ppb) | - * | U | TurnerCyclops_CDOM | parts per billion (ppb) | * | O | TurnerCyclops_CrudeOil | parts per billion (ppb) | + * | G | TurnerCyclops_BTEX | parts per million (ppm) | * | B | TurnerCyclops_Brighteners | parts per billion (ppb) | - * | T | TurnerCyclops_Turbidity | nephelometric turbidity units (NTU) | + * | P | TurnerCyclops_Phycocyanin | parts per billion (ppb) | + * | E | TurnerCyclops_Phycoerythrin | parts per billion (ppb) | * | A | TurnerCyclops_PTSA | parts per billion (ppb) | - * | G | TurnerCyclops_BTEX | parts per million (ppm) | + * | R | TurnerCyclops_Rhodamine | parts per billion (ppb) | * | L | TurnerCyclops_Tryptophan | parts per billion (ppb) | - * | D | TurnerCyclops_RedChlorophyll | micrograms per Liter (µg/L) | + * | T | TurnerCyclops_Turbidity | nephelometric turbidity units (NTU) | * * Before applying any calibration, the analog output from the Cyclops-7F * must be converted into a high resolution digital signal. See the @@ -293,9 +293,9 @@ class TurnerCyclops : public Sensor { * @brief Construct a new Turner Cyclops object - need the power pin, the * analog data channel, and the calibration info. * - * By default, this constructor will use a new TIADS1x15Base object with all - * default values for voltage readings, but a pointer to a custom - * AnalogVoltageBase object can be passed in if desired. + * By default, this constructor will internally create a default + * AnalogVoltageBase implementation for voltage readings, but a pointer to + * a custom AnalogVoltageBase object can be passed in if desired. * * @param powerPin The pin on the mcu controlling power to the Cyclops-7F * Use -1 if it is continuously powered. diff --git a/src/sensors/TurnerTurbidityPlus.cpp b/src/sensors/TurnerTurbidityPlus.cpp index 7efe98419..3263460f4 100644 --- a/src/sensors/TurnerTurbidityPlus.cpp +++ b/src/sensors/TurnerTurbidityPlus.cpp @@ -38,7 +38,6 @@ TurnerTurbidityPlus::~TurnerTurbidityPlus() { // Clean up the analog voltage reader if we created it if (_ownsAnalogVoltageReader && _analogVoltageReader != nullptr) { delete _analogVoltageReader; - _analogVoltageReader = nullptr; } } @@ -117,7 +116,7 @@ bool TurnerTurbidityPlus::addSingleMeasurementResult(void) { } bool success = false; - float adcVoltage = -9999; + float adcVoltage = -9999.0f; MS_DBG(getSensorNameAndLocation(), F("is reporting:")); diff --git a/src/sensors/TurnerTurbidityPlus.h b/src/sensors/TurnerTurbidityPlus.h index 52aa44f11..0377e4856 100644 --- a/src/sensors/TurnerTurbidityPlus.h +++ b/src/sensors/TurnerTurbidityPlus.h @@ -204,9 +204,9 @@ class TurnerTurbidityPlus : public Sensor { * @brief Construct a new Turner Turbidity Plus object - need the power pin, * the analog data and reference channels, and the calibration info. * - * By default, this constructor will use a new TIADS1x15Base object with all - * default values for voltage readings, but a pointer to a custom - * AnalogVoltageBase object can be passed in if desired. + * By default, this constructor will internally create a default + * AnalogVoltageBase implementation for voltage readings, but a pointer to + * a custom AnalogVoltageBase object can be passed in if desired. * * @param powerPin The pin on the mcu controlling power to the Turbidity * Plus Use -1 if it is continuously powered. From 27c47daa364a182adcf3a5fae69ef90453615817 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Wed, 25 Feb 2026 09:20:34 -0500 Subject: [PATCH 321/533] Fix analog voltage conversion Signed-off-by: Sara Damiano --- src/sensors/ProcessorAnalog.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/sensors/ProcessorAnalog.cpp b/src/sensors/ProcessorAnalog.cpp index 04d4944d0..9a1ce1952 100644 --- a/src/sensors/ProcessorAnalog.cpp +++ b/src/sensors/ProcessorAnalog.cpp @@ -50,7 +50,8 @@ bool ProcessorAnalogBase::readVoltageSingleEnded(int8_t analogChannel, MS_DBG(F("Raw analog pin reading in bits:"), rawAnalog); // convert bits to volts - resultValue = (_supplyVoltage / static_cast(PROCESSOR_ADC_MAX)) * + // Use (PROCESSOR_ADC_MAX + 1) as divisor for correct 2^n scaling + resultValue = (_supplyVoltage / static_cast(PROCESSOR_ADC_MAX + 1)) * _voltageMultiplier * rawAnalog; MS_DBG(F("Voltage:"), resultValue); From 63b58f126c8a3ecf34c1183e383b537294510efd Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Wed, 25 Feb 2026 09:21:04 -0500 Subject: [PATCH 322/533] combine TIADS1x15 constructors Signed-off-by: Sara Damiano --- src/sensors/TIADS1x15.cpp | 26 +++---------------------- src/sensors/TIADS1x15.h | 41 ++++++++++----------------------------- 2 files changed, 13 insertions(+), 54 deletions(-) diff --git a/src/sensors/TIADS1x15.cpp b/src/sensors/TIADS1x15.cpp index 0b23d8793..8a7a721f5 100644 --- a/src/sensors/TIADS1x15.cpp +++ b/src/sensors/TIADS1x15.cpp @@ -250,34 +250,14 @@ adsGain_t TIADS1x15Base::getADSGain(void) const { TIADS1x15::TIADS1x15(int8_t powerPin, int8_t adsChannel, float voltageMultiplier, adsGain_t adsGain, uint8_t i2cAddress, uint8_t measurementsToAverage, - float adsSupplyVoltage) + float adsSupplyVoltage, int8_t differentialChannel) : Sensor("TIADS1x15", TIADS1X15_NUM_VARIABLES, TIADS1X15_WARM_UP_TIME_MS, TIADS1X15_STABILIZATION_TIME_MS, TIADS1X15_MEASUREMENT_TIME_MS, powerPin, adsChannel, measurementsToAverage, TIADS1X15_INC_CALC_VARIABLES), TIADS1x15Base(voltageMultiplier, adsGain, i2cAddress, adsSupplyVoltage) { - // Set for single-ended measurements - setDifferentialChannel(-1); - // NOTE: We DO NOT validate the channel numbers in this constructor! We - // CANNOT print a warning here about invalid channel because the Serial - // object may not be initialized yet, and we don't want to cause a crash. - // The readVoltageSingleEnded and readVoltageDifferential functions will - // handle validation and return false if the channel configuration is - // invalid, but we can't do that here in the constructor -} - -// Constructor for differential measurements -TIADS1x15::TIADS1x15(int8_t powerPin, int8_t adsChannel1, int8_t adsChannel2, - float voltageMultiplier, adsGain_t adsGain, - uint8_t i2cAddress, uint8_t measurementsToAverage, - float adsSupplyVoltage) - : Sensor("TIADS1x15", TIADS1X15_NUM_VARIABLES, TIADS1X15_WARM_UP_TIME_MS, - TIADS1X15_STABILIZATION_TIME_MS, TIADS1X15_MEASUREMENT_TIME_MS, - powerPin, adsChannel1, measurementsToAverage, - TIADS1X15_INC_CALC_VARIABLES), - TIADS1x15Base(voltageMultiplier, adsGain, i2cAddress, adsSupplyVoltage) { - // Set for differential measurements - setDifferentialChannel(adsChannel2); + // Set differential channel configuration + setDifferentialChannel(differentialChannel); // NOTE: We DO NOT validate the channel numbers and pairings in this // constructor! We CANNOT print a warning here about invalid channel // because the Serial object may not be initialized yet, and we don't want diff --git a/src/sensors/TIADS1x15.h b/src/sensors/TIADS1x15.h index c66f2f409..08a4197e0 100644 --- a/src/sensors/TIADS1x15.h +++ b/src/sensors/TIADS1x15.h @@ -394,8 +394,8 @@ class TIADS1x15Base : public AnalogVoltageBase { class TIADS1x15 : public Sensor, public TIADS1x15Base { public: /** - * @brief Construct a new External Voltage object - need the power pin and - * the data channel on the ADS1x15. + * @brief Construct a new TIADS1x15 object for single-ended or differential + * voltage measurements * * The voltage multiplier value, I2C address, and number of measurements to * average are optional. If nothing is given a 1x voltage multiplier is @@ -408,7 +408,8 @@ class TIADS1x15 : public Sensor, public TIADS1x15Base { * @param powerPin The pin on the mcu controlling power to the sensor * Use -1 if it is continuously powered. * @param adsChannel The ADS channel of interest (0-3, physical channel - * only). + * only). For differential measurements, this is the first (positive) + * channel. * @param voltageMultiplier The voltage multiplier, if a voltage divider is * used. * @param adsGain The internal gain setting of the ADS1x15; defaults to @@ -420,39 +421,17 @@ class TIADS1x15 : public Sensor, public TIADS1x15Base { * default value of 1. * @param adsSupplyVoltage The power supply voltage for the ADS1x15 in * volts; defaults to the processor operating voltage from KnownProcessors.h + * @param differentialChannel The second (reference/negative) ADS channel + * for differential measurement (0-3, physical channel only). Valid pairs + * are: 0-1, 0-3, 1-3, or 2-3. Use -1 (default) for single-ended + * measurements. */ TIADS1x15(int8_t powerPin, int8_t adsChannel, float voltageMultiplier = 1.0f, adsGain_t adsGain = GAIN_ONE, uint8_t i2cAddress = MS_DEFAULT_ADS1X15_ADDRESS, uint8_t measurementsToAverage = 1, - float adsSupplyVoltage = OPERATING_VOLTAGE); - /** - * @brief Construct a new TIADS1x15 object for differential measurements - * - * @param powerPin The pin on the mcu controlling power to the sensor - * Use -1 if it is continuously powered. - * @param adsChannel1 The first (measurement) ADS channel for differential - * measurement (0-3, physical channel only) - * @param adsChannel2 The second (reference) ADS channel for differential - * measurement (0-3, physical channel only) Valid combinations are: 0-1, - * 0-3, 1-3, or 2-3 - * @param voltageMultiplier The voltage multiplier, if a voltage divider is - * used. - * @param adsGain The internal gain setting of the ADS1x15; defaults to - * GAIN_ONE for +/- 4.096V range - * @param i2cAddress The I2C address of the ADS 1x15, default is 0x48 (ADDR - * = GND) - * @param measurementsToAverage The number of measurements to take and - * average before giving a "final" result from the sensor; optional with a - * default value of 1. - * @param adsSupplyVoltage The power supply voltage for the ADS1x15 in - * volts; defaults to the processor operating voltage from KnownProcessors.h - */ - TIADS1x15(int8_t powerPin, int8_t adsChannel1, int8_t adsChannel2, - float voltageMultiplier = 1, adsGain_t adsGain = GAIN_ONE, - uint8_t i2cAddress = MS_DEFAULT_ADS1X15_ADDRESS, - uint8_t measurementsToAverage = 1, - float adsSupplyVoltage = OPERATING_VOLTAGE); + float adsSupplyVoltage = OPERATING_VOLTAGE, + int8_t differentialChannel = -1); /** * @brief Destroy the External Voltage object */ From 1e11b92702ec91f72d350829f86a81437e1cc84f Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Wed, 25 Feb 2026 10:50:51 -0500 Subject: [PATCH 323/533] Channel docs Signed-off-by: Sara Damiano --- cspell.json | 2 +- src/sensors/AlphasenseCO2.h | 8 ++++++-- src/sensors/AnalogElecConductivity.cpp | 4 ++-- src/sensors/ApogeeSQ212.h | 3 ++- src/sensors/CampbellOBS3.h | 3 ++- src/sensors/EverlightALSPT19.h | 2 +- src/sensors/ProcessorAnalog.h | 3 ++- src/sensors/TIADS1x15.h | 17 +++++++++++------ src/sensors/TurnerTurbidityPlus.h | 12 ++++++++---- 9 files changed, 35 insertions(+), 19 deletions(-) diff --git a/cspell.json b/cspell.json index c4dc0c6fa..805eb56f2 100644 --- a/cspell.json +++ b/cspell.json @@ -158,7 +158,7 @@ "IMEI", "IMSI", "INSITU", - "kilaohms", + "kiloohms", "LOGGERBASE", "LOGGERMODEM", "LTEBee", diff --git a/src/sensors/AlphasenseCO2.h b/src/sensors/AlphasenseCO2.h index c43212fe1..ef279be1b 100644 --- a/src/sensors/AlphasenseCO2.h +++ b/src/sensors/AlphasenseCO2.h @@ -270,9 +270,13 @@ class AlphasenseCO2 : public Sensor { * Alphasense CO2 sensor. Use -1 if it is continuously powered. * - The Alphasense CO2 sensor requires 2-5 V DC; current draw 20-60 mA * @param analogChannel The primary analog channel for differential - * measurement + * measurement. Negative or invalid channel numbers or parings between the + * analogChannel and analogReferenceChannel are not clamped and will cause + * the reading to fail and emit a warning. * @param analogReferenceChannel The secondary (reference) analog channel - * for differential measurement + * for differential measurement. Negative or invalid channel numbers or + * parings between the analogChannel and analogReferenceChannel are not + * clamped and will cause the reading to fail and emit a warning. * @param measurementsToAverage The number of measurements to take and * average before giving a "final" result from the sensor; optional with a * default value of 7. diff --git a/src/sensors/AnalogElecConductivity.cpp b/src/sensors/AnalogElecConductivity.cpp index 235246bd6..7d3c593ec 100644 --- a/src/sensors/AnalogElecConductivity.cpp +++ b/src/sensors/AnalogElecConductivity.cpp @@ -82,8 +82,8 @@ bool AnalogElecConductivity::addSingleMeasurementResult(void) { // Estimate Resistance of Liquid // see the header for an explanation of this calculation // Convert voltage back to ADC equivalent for existing calculation - // NOTE: The supplyVoltage is already clamped by the - // _analogVoltageReader + // NOTE: The supplyVoltage is validated and clamped by the + // _analogVoltageReader and cannot be 0. float supplyVoltage = _analogVoltageReader->getSupplyVoltage(); float adcRatio = adcVoltage / supplyVoltage; diff --git a/src/sensors/ApogeeSQ212.h b/src/sensors/ApogeeSQ212.h index 0ce984681..b21c61399 100644 --- a/src/sensors/ApogeeSQ212.h +++ b/src/sensors/ApogeeSQ212.h @@ -253,7 +253,8 @@ class ApogeeSQ212 : public Sensor { * measurements. The significance of the channel number depends on the * specific AnalogVoltageBase implementation used for voltage readings. For * example, with the TI ADS1x15, this would be the ADC channel (0-3) that - * the sensor is connected to. + * the sensor is connected to. Negative or invalid channel numbers are not + * clamped and will cause the reading to fail and emit a warning. * @param measurementsToAverage The number of measurements to take and * average before giving a "final" result from the sensor; optional with a * default value of 1. diff --git a/src/sensors/CampbellOBS3.h b/src/sensors/CampbellOBS3.h index b330a5988..47196ea7b 100644 --- a/src/sensors/CampbellOBS3.h +++ b/src/sensors/CampbellOBS3.h @@ -249,7 +249,8 @@ class CampbellOBS3 : public Sensor { * measurements. The significance of the channel number depends on the * specific AnalogVoltageBase implementation used for voltage readings. For * example, with the TI ADS1x15, this would be the ADC channel (0-3) that - * the sensor is connected to. + * the sensor is connected to. Negative or invalid channel numbers are not + * clamped and will cause the reading to fail and emit a warning. * @param x2_coeff_A The x2 (A) coefficient for the calibration _in volts_ * @param x1_coeff_B The x (B) coefficient for the calibration _in volts_ * @param x0_coeff_C The x0 (C) coefficient for the calibration _in volts_ diff --git a/src/sensors/EverlightALSPT19.h b/src/sensors/EverlightALSPT19.h index a1fa8bbb8..13d05ce39 100644 --- a/src/sensors/EverlightALSPT19.h +++ b/src/sensors/EverlightALSPT19.h @@ -255,7 +255,7 @@ class EverlightALSPT19 : public Sensor { * ALS-PT19. This does not have to be the same as the board operating * voltage or the supply voltage of the analog AnalogVoltageBase reader. * This is used to clamp the light values when the sensor is over-saturated. - * @param loadResistor The size of the loading resistor, in kilaohms (kΩ). + * @param loadResistor The size of the loading resistor, in kiloohms (kΩ). * @param measurementsToAverage The number of measurements to take and * average before giving a "final" result from the sensor; optional with a * default value of 10. diff --git a/src/sensors/ProcessorAnalog.h b/src/sensors/ProcessorAnalog.h index 1c5228de3..a10dbfefc 100644 --- a/src/sensors/ProcessorAnalog.h +++ b/src/sensors/ProcessorAnalog.h @@ -186,7 +186,8 @@ class ProcessorAnalogBase : public AnalogVoltageBase { * @brief Read a single-ended voltage measurement from the processor ADC * * @param analogChannel The processor ADC pin used to read the target - * voltage + * voltage. Negative or invalid channel numbers are not clamped and will + * cause the reading to fail and emit a warning. * @param resultValue Reference to store the resulting voltage measurement * @return True if the voltage reading was successful */ diff --git a/src/sensors/TIADS1x15.h b/src/sensors/TIADS1x15.h index 08a4197e0..145151735 100644 --- a/src/sensors/TIADS1x15.h +++ b/src/sensors/TIADS1x15.h @@ -286,7 +286,8 @@ class TIADS1x15Base : public AnalogVoltageBase { * @brief Read a single-ended voltage measurement from the ADS1x15 * * @param analogChannel The ADS channel of interest (0-3, physical channel - * only) + * only). Negative or invalid channel numbers are not clamped and will + * cause the reading to fail and emit a warning. * @param resultValue Reference to store the resulting voltage measurement * @return True if the voltage reading was successful */ @@ -296,10 +297,14 @@ class TIADS1x15Base : public AnalogVoltageBase { /** * @brief Read a differential voltage measurement from the ADS1x15 * - * @param analogChannel The first ADS channel for differential measurement - * (0-3, physical channel only) - * @param analogReferenceChannel The second (reference) ADS channel for - * differential measurement (0-3, physical channel only) + * @param analogChannel The primary analog channel for differential + * measurement. Negative or invalid channel numbers or parings between the + * analogChannel and analogReferenceChannel are not clamped and will cause + * the reading to fail and emit a warning. + * @param analogReferenceChannel The secondary (reference) analog channel + * for differential measurement. Negative or invalid channel numbers or + * parings between the analogChannel and analogReferenceChannel are not + * clamped and will cause the reading to fail and emit a warning. * @param resultValue Reference to store the resulting voltage measurement * @return True if the voltage reading was successful and within valid range */ @@ -375,7 +380,7 @@ class TIADS1x15Base : public AnalogVoltageBase { /** * @brief Set the differential channel for differential measurements * - * @param differentialChannel The secondary (reference) channel for + * @param differentialChannel The secondary (reference) channel for * differential measurements (0-3), or -1 for single-ended */ void setDifferentialChannel(int8_t differentialChannel) { diff --git a/src/sensors/TurnerTurbidityPlus.h b/src/sensors/TurnerTurbidityPlus.h index 0377e4856..eeb64b73f 100644 --- a/src/sensors/TurnerTurbidityPlus.h +++ b/src/sensors/TurnerTurbidityPlus.h @@ -37,8 +37,8 @@ * * ___ * @section sensor_turbidity_plus_examples Example Code - * The Alphasense CO2 sensor is used in the @menulink{turner_turbidity_plus} - * example. + * The Turner Turbidity Plus sensor is used in the + * @menulink{turner_turbidity_plus} example. * * @menusnip{turner_turbidity_plus} */ @@ -215,9 +215,13 @@ class TurnerTurbidityPlus : public Sensor { * @param wiperTriggerPin The pin on the mcu that triggers the sensor's * wiper. * @param analogChannel The primary analog channel for differential - * measurement + * measurement. Negative or invalid channel numbers or parings between the + * analogChannel and analogReferenceChannel are not clamped and will cause + * the reading to fail and emit a warning. * @param analogReferenceChannel The secondary (reference) analog channel - * for differential measurement + * for differential measurement. Negative or invalid channel numbers or + * parings between the analogChannel and analogReferenceChannel are not + * clamped and will cause the reading to fail and emit a warning. * @param conc_std The concentration of the standard used for a 1-point * sensor calibration. The concentration units should be the same as the * final measuring units. From 2432a52635d0180a41a0f22efe8d18bdb930cce7 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Wed, 25 Feb 2026 10:51:17 -0500 Subject: [PATCH 324/533] Float tags Signed-off-by: Sara Damiano --- src/sensors/AlphasenseCO2.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/sensors/AlphasenseCO2.h b/src/sensors/AlphasenseCO2.h index ef279be1b..8cea150fc 100644 --- a/src/sensors/AlphasenseCO2.h +++ b/src/sensors/AlphasenseCO2.h @@ -124,25 +124,25 @@ /** * @brief Sense resistor value in ohms for current conversion */ -#define ALPHASENSE_CO2_SENSE_RESISTOR_OHM 250.0 +#define ALPHASENSE_CO2_SENSE_RESISTOR_OHM 250.0f #endif #if !defined(ALPHASENSE_CO2_MFG_SCALE) || defined(DOXYGEN) /** * @brief Manufacturer scale factor for CO2 conversion (ppm/mA) */ -#define ALPHASENSE_CO2_MFG_SCALE 312.5 +#define ALPHASENSE_CO2_MFG_SCALE 312.5f #endif #if !defined(ALPHASENSE_CO2_MFG_OFFSET) || defined(DOXYGEN) /** * @brief Manufacturer offset for CO2 conversion (ppm) */ -#define ALPHASENSE_CO2_MFG_OFFSET 1250.0 +#define ALPHASENSE_CO2_MFG_OFFSET 1250.0f #endif #if !defined(ALPHASENSE_CO2_VOLTAGE_MULTIPLIER) || defined(DOXYGEN) /** * @brief Voltage multiplier for direct voltage reading */ -#define ALPHASENSE_CO2_VOLTAGE_MULTIPLIER 1.0 +#define ALPHASENSE_CO2_VOLTAGE_MULTIPLIER 1.0f #endif /**@}*/ From e94b62f5df1c65049db7c68e47d9564d5d013879 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Wed, 25 Feb 2026 10:51:53 -0500 Subject: [PATCH 325/533] Add debugging Signed-off-by: Sara Damiano --- src/sensors/AnalogVoltageBase.h | 40 +++++++++++++++++++++++++++------ 1 file changed, 33 insertions(+), 7 deletions(-) diff --git a/src/sensors/AnalogVoltageBase.h b/src/sensors/AnalogVoltageBase.h index 1ef8d1ea3..5d9bf00d1 100644 --- a/src/sensors/AnalogVoltageBase.h +++ b/src/sensors/AnalogVoltageBase.h @@ -26,6 +26,16 @@ // Include the known processors for default values #include "KnownProcessors.h" +// Define the print label[s] for the debugger +#ifdef MS_ANALOGVOLTAGEBASE_DEBUG +#define MS_DEBUGGING_STD "AnalogVoltageBase" +#endif + +// Include the debugger +#include "ModSensorDebugger.h" +// Undefine the debugger label[s] +#undef MS_DEBUGGING_STD + /** * @brief Abstract base class for analog voltage reading systems. * @@ -72,8 +82,13 @@ class AnalogVoltageBase { */ virtual void setVoltageMultiplier(float voltageMultiplier) { // If the input voltage multiplier is not positive, set it to 1. - _voltageMultiplier = (voltageMultiplier > 0.0f) ? voltageMultiplier - : 1.0f; + if (voltageMultiplier <= 0.0f) { + MS_DBG(F("Invalid voltage multiplier "), voltageMultiplier, + F(", clamping to 1.0")); + _voltageMultiplier = 1.0f; + } else { + _voltageMultiplier = voltageMultiplier; + } } /** @@ -91,8 +106,13 @@ class AnalogVoltageBase { * @param supplyVoltage The supply voltage in volts */ virtual void setSupplyVoltage(float supplyVoltage) { - _supplyVoltage = (supplyVoltage > 0.0f) ? supplyVoltage - : OPERATING_VOLTAGE; + if (supplyVoltage <= 0.0f) { + MS_DBG(F("Invalid supply voltage "), supplyVoltage, + F(", clamping to "), OPERATING_VOLTAGE, F("V")); + _supplyVoltage = OPERATING_VOLTAGE; + } else { + _supplyVoltage = supplyVoltage; + } } /** * @brief Get the supply voltage for the analog system @@ -109,7 +129,9 @@ class AnalogVoltageBase { * This pure virtual function must be implemented by derived classes to * provide their specific method of reading analog voltages. * - * @param analogChannel The analog channel/pin for voltage readings + * @param analogChannel The analog channel/pin for voltage readings. + * Negative or invalid channel numbers are not clamped and will cause the + * reading to fail and emit a warning. * @param resultValue Reference to store the resulting voltage measurement * @return True if the voltage reading was successful and within valid range */ @@ -126,9 +148,13 @@ class AnalogVoltageBase { * should set the resultValue to -9999.0 and return false. * * @param analogChannel The primary analog channel for differential - * measurement + * measurement. Negative or invalid channel numbers or parings between the + * analogChannel and analogReferenceChannel are not clamped and will cause + * the reading to fail and emit a warning. * @param analogReferenceChannel The secondary (reference) analog channel - * for differential measurement + * for differential measurement. Negative or invalid channel numbers or + * parings between the analogChannel and analogReferenceChannel are not + * clamped and will cause the reading to fail and emit a warning. * @param resultValue Reference to store the resulting voltage measurement * @return True if the voltage reading was successful and within valid range */ From 29f5a04e34155abfc73daaafcce14a6bfac47f6c Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Wed, 25 Feb 2026 10:52:19 -0500 Subject: [PATCH 326/533] make epsilon a define Signed-off-by: Sara Damiano --- src/sensors/TurnerCyclops.cpp | 3 +-- src/sensors/TurnerCyclops.h | 26 +++++++++++++++++++++++++- 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/src/sensors/TurnerCyclops.cpp b/src/sensors/TurnerCyclops.cpp index be0732dd9..1a83919e0 100644 --- a/src/sensors/TurnerCyclops.cpp +++ b/src/sensors/TurnerCyclops.cpp @@ -72,8 +72,7 @@ bool TurnerCyclops::addSingleMeasurementResult(void) { // Print out the calibration curve MS_DBG(F(" Input calibration Curve:"), _volt_std, F("V at"), _conc_std, F(". "), _volt_blank, F("V blank.")); - const float epsilon = 1e-4f; // tune to expected sensor precision - if (fabs(_volt_std - _volt_blank) < epsilon) { + if (fabs(_volt_std - _volt_blank) < CYCLOPS_CALIBRATION_EPSILON) { MS_DBG(F("Invalid calibration: point voltage equals blank voltage")); return bumpMeasurementAttemptCount(false); } diff --git a/src/sensors/TurnerCyclops.h b/src/sensors/TurnerCyclops.h index 9a17ea2fb..b492fd30a 100644 --- a/src/sensors/TurnerCyclops.h +++ b/src/sensors/TurnerCyclops.h @@ -130,6 +130,8 @@ * @section sensor_cyclops_flags Build flags * - ```-D MS_USE_ADS1015``` * - switches from the 16-bit ADS1115 to the 12 bit ADS1015 + * - `-D CYCLOPS_CALIBRATION_EPSILON=x.xf` + * - Sets the tolerance for validating the calibration values * * @section sensor_cyclops_ctor Sensor Constructor * {{ @ref TurnerCyclops::TurnerCyclops }} @@ -171,6 +173,27 @@ /** @ingroup sensor_cyclops */ /**@{*/ +/** + * @anchor sensor_cyclops_config + * @name Configuration Parameters + * Configuration parameters for the Turner Cyclops-7F sensor + */ +/**@{*/ +/** + * @brief Minimum voltage difference threshold for calibration validation + * + * This epsilon value is used to validate that the calibration standard voltage + * and blank voltage are sufficiently different to provide a meaningful + * calibration. If the absolute difference between these voltages is less than + * this threshold, the calibration is considered invalid. + * + * @note This should be tuned to match the expected precision of the sensor + * and ADC system. A value of 1e-4f (0.0001V or 0.1mV) is appropriate for + * most high-precision ADC configurations. + */ +#define CYCLOPS_CALIBRATION_EPSILON 1e-4f +/**@}*/ + /** * @anchor sensor_cyclops_var_counts * @name Sensor Variable Counts @@ -305,7 +328,8 @@ class TurnerCyclops : public Sensor { * measurements. The significance of the channel number depends on the * specific AnalogVoltageBase implementation used for voltage readings. For * example, with the TI ADS1x15, this would be the ADC channel (0-3) that - * the sensor is connected to. + * the sensor is connected to. Negative or invalid channel numbers are not + * clamped and will cause the reading to fail and emit a warning. * @param conc_std The concentration of the standard used for a 1-point * sensor calibration. The concentration units should be the same as the * final measuring units. From 5e19ee39488de58a63ddd14a1edea3fb5d3bee50 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Wed, 25 Feb 2026 10:52:54 -0500 Subject: [PATCH 327/533] float casts Signed-off-by: Sara Damiano --- src/sensors/ProcessorAnalog.cpp | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/sensors/ProcessorAnalog.cpp b/src/sensors/ProcessorAnalog.cpp index 9a1ce1952..bce811e18 100644 --- a/src/sensors/ProcessorAnalog.cpp +++ b/src/sensors/ProcessorAnalog.cpp @@ -27,14 +27,16 @@ ProcessorAnalogBase::ProcessorAnalogBase(float voltageMultiplier, bool ProcessorAnalogBase::readVoltageSingleEnded(int8_t analogChannel, float& resultValue) { + // Compile-time validation of ADC configuration + static_assert(PROCESSOR_ADC_MAX > 0, + "PROCESSOR_ADC_MAX must be greater than 0. Check " + "MS_PROCESSOR_ADC_RESOLUTION configuration."); + // Validate parameters - if (PROCESSOR_ADC_MAX <= 0) { - MS_DBG(F("Processor ADC max value is not set or invalid!")); - resultValue = -9999.0f; - return false; - } - if (analogChannel < 0 || _supplyVoltage <= 0 || _voltageMultiplier <= 0) { - MS_DBG(F("Invalid configuration: analog channel, supply voltage, " + if (analogChannel < 0 || analogChannel > 100 || _supplyVoltage <= 0 || + _voltageMultiplier <= 0) { + MS_DBG(F("Invalid configuration: analog channel (must be 0-100), " + "supply voltage, " "or voltage multiplier is not set!")); resultValue = -9999.0f; return false; @@ -51,7 +53,8 @@ bool ProcessorAnalogBase::readVoltageSingleEnded(int8_t analogChannel, // convert bits to volts // Use (PROCESSOR_ADC_MAX + 1) as divisor for correct 2^n scaling - resultValue = (_supplyVoltage / static_cast(PROCESSOR_ADC_MAX + 1)) * + resultValue = + (_supplyVoltage / (static_cast(PROCESSOR_ADC_MAX) + 1.0f)) * _voltageMultiplier * rawAnalog; MS_DBG(F("Voltage:"), resultValue); From dbe3d7fbdc11ab8457d6649a8c9b6632f0773c15 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Wed, 25 Feb 2026 11:19:38 -0500 Subject: [PATCH 328/533] Validation, spelling, move diff channel out of TIADS1x15Base Signed-off-by: Sara Damiano --- src/sensors/AlphasenseCO2.h | 4 +- src/sensors/AnalogElecConductivity.cpp | 6 +++ src/sensors/AnalogVoltageBase.h | 7 ++- src/sensors/EverlightALSPT19.cpp | 3 +- src/sensors/ProcessorAnalog.cpp | 5 +- src/sensors/ProcessorAnalog.h | 5 -- src/sensors/TIADS1x15.cpp | 50 ++++++++++---------- src/sensors/TIADS1x15.h | 64 +++++++++----------------- src/sensors/TurnerCyclops.h | 2 + src/sensors/TurnerTurbidityPlus.h | 4 +- 10 files changed, 70 insertions(+), 80 deletions(-) diff --git a/src/sensors/AlphasenseCO2.h b/src/sensors/AlphasenseCO2.h index 8cea150fc..2c0853b64 100644 --- a/src/sensors/AlphasenseCO2.h +++ b/src/sensors/AlphasenseCO2.h @@ -270,12 +270,12 @@ class AlphasenseCO2 : public Sensor { * Alphasense CO2 sensor. Use -1 if it is continuously powered. * - The Alphasense CO2 sensor requires 2-5 V DC; current draw 20-60 mA * @param analogChannel The primary analog channel for differential - * measurement. Negative or invalid channel numbers or parings between the + * measurement. Negative or invalid channel numbers or pairings between the * analogChannel and analogReferenceChannel are not clamped and will cause * the reading to fail and emit a warning. * @param analogReferenceChannel The secondary (reference) analog channel * for differential measurement. Negative or invalid channel numbers or - * parings between the analogChannel and analogReferenceChannel are not + * pairings between the analogChannel and analogReferenceChannel are not * clamped and will cause the reading to fail and emit a warning. * @param measurementsToAverage The number of measurements to take and * average before giving a "final" result from the sensor; optional with a diff --git a/src/sensors/AnalogElecConductivity.cpp b/src/sensors/AnalogElecConductivity.cpp index 7d3c593ec..d8524b40a 100644 --- a/src/sensors/AnalogElecConductivity.cpp +++ b/src/sensors/AnalogElecConductivity.cpp @@ -69,6 +69,12 @@ bool AnalogElecConductivity::addSingleMeasurementResult(void) { return bumpMeasurementAttemptCount(false); } + // Check if we have a valid load resistor + if (_sensorEC_Konst <= 0) { + MS_DBG(getSensorNameAndLocation(), F("Invalid cell constant")); + return bumpMeasurementAttemptCount(false); + } + bool success = false; float adcVoltage = -9999.0f; diff --git a/src/sensors/AnalogVoltageBase.h b/src/sensors/AnalogVoltageBase.h index 5d9bf00d1..c1b51ad9c 100644 --- a/src/sensors/AnalogVoltageBase.h +++ b/src/sensors/AnalogVoltageBase.h @@ -104,6 +104,9 @@ class AnalogVoltageBase { * @brief Set the supply voltage for the analog system * * @param supplyVoltage The supply voltage in volts + * + * @note The supply voltage must be positive (> 0). Values <= 0 will be + * clamped to OPERATING_VOLTAGE to maintain a valid reference. */ virtual void setSupplyVoltage(float supplyVoltage) { if (supplyVoltage <= 0.0f) { @@ -148,12 +151,12 @@ class AnalogVoltageBase { * should set the resultValue to -9999.0 and return false. * * @param analogChannel The primary analog channel for differential - * measurement. Negative or invalid channel numbers or parings between the + * measurement. Negative or invalid channel numbers or pairings between the * analogChannel and analogReferenceChannel are not clamped and will cause * the reading to fail and emit a warning. * @param analogReferenceChannel The secondary (reference) analog channel * for differential measurement. Negative or invalid channel numbers or - * parings between the analogChannel and analogReferenceChannel are not + * pairings between the analogChannel and analogReferenceChannel are not * clamped and will cause the reading to fail and emit a warning. * @param resultValue Reference to store the resulting voltage measurement * @return True if the voltage reading was successful and within valid range diff --git a/src/sensors/EverlightALSPT19.cpp b/src/sensors/EverlightALSPT19.cpp index fb0d7bd42..e384eccc1 100644 --- a/src/sensors/EverlightALSPT19.cpp +++ b/src/sensors/EverlightALSPT19.cpp @@ -95,6 +95,8 @@ bool EverlightALSPT19::addSingleMeasurementResult(void) { adcVoltage); if (success) { + verifyAndAddMeasurementResult(ALSPT19_VOLTAGE_VAR_NUM, adcVoltage); + // From the datasheet: // The output voltage V(out) is the product of photocurrent I(PH) and // loading resistor R(L): @@ -118,7 +120,6 @@ bool EverlightALSPT19::addSingleMeasurementResult(void) { float calibResult = current_val * (1000.0f / ALSPT19_CURRENT_PER_LUX); MS_DBG(F(" Illuminance:"), calibResult, F("lux")); - verifyAndAddMeasurementResult(ALSPT19_VOLTAGE_VAR_NUM, adcVoltage); verifyAndAddMeasurementResult(ALSPT19_CURRENT_VAR_NUM, current_val); verifyAndAddMeasurementResult(ALSPT19_ILLUMINANCE_VAR_NUM, calibResult); } else { diff --git a/src/sensors/ProcessorAnalog.cpp b/src/sensors/ProcessorAnalog.cpp index bce811e18..68cf798f8 100644 --- a/src/sensors/ProcessorAnalog.cpp +++ b/src/sensors/ProcessorAnalog.cpp @@ -97,7 +97,10 @@ ProcessorAnalog::ProcessorAnalog(int8_t powerPin, int8_t dataPin, ProcessorAnalog::~ProcessorAnalog() {} String ProcessorAnalog::getSensorLocation() { - return ProcessorAnalogBase::getSensorLocation(); + String sensorLocation = ProcessorAnalogBase::getSensorLocation(); + sensorLocation += F("_Pin"); + sensorLocation += String(_dataPin); + return sensorLocation; } bool ProcessorAnalog::addSingleMeasurementResult(void) { diff --git a/src/sensors/ProcessorAnalog.h b/src/sensors/ProcessorAnalog.h index a10dbfefc..974799006 100644 --- a/src/sensors/ProcessorAnalog.h +++ b/src/sensors/ProcessorAnalog.h @@ -211,11 +211,6 @@ class ProcessorAnalogBase : public AnalogVoltageBase { int8_t /*analogReferenceChannel*/, float& resultValue) override; - /** - * @brief Get the sensor location string - * - * @return A string describing the processor analog pin location - */ String getSensorLocation(void) override; }; diff --git a/src/sensors/TIADS1x15.cpp b/src/sensors/TIADS1x15.cpp index 8a7a721f5..d7ced86b4 100644 --- a/src/sensors/TIADS1x15.cpp +++ b/src/sensors/TIADS1x15.cpp @@ -24,8 +24,7 @@ TIADS1x15Base::TIADS1x15Base(float voltageMultiplier, adsGain_t adsGain, uint8_t i2cAddress, float adsSupplyVoltage) : AnalogVoltageBase(voltageMultiplier, adsSupplyVoltage), _adsGain(adsGain), - _i2cAddress(i2cAddress), - _adsDifferentialChannel(-1) { + _i2cAddress(i2cAddress) { // Clamp supply voltage to valid ADS1x15 range: 0.0V to 5.5V per datasheet // NOTE: This clamp is intentionally silent — Serial/MS_DBG is NOT safe to // call during construction (the Serial object may not be initialized yet on @@ -241,6 +240,22 @@ adsGain_t TIADS1x15Base::getADSGain(void) const { return _adsGain; } +// Override setSupplyVoltage in TIADS1x15Base to validate ADS range +void TIADS1x15Base::setSupplyVoltage(float supplyVoltage) { + // Validate supply voltage range: 0.0V to 5.5V per datasheet + if (supplyVoltage < 0.0f) { + MS_DBG(F("ADS supply voltage "), supplyVoltage, + F("V is below minimum, clamping to 0.0V")); + _supplyVoltage = 0.0f; + } else if (supplyVoltage > 5.5f) { + MS_DBG(F("ADS supply voltage "), supplyVoltage, + F("V exceeds maximum, clamping to 5.5V")); + _supplyVoltage = 5.5f; + } else { + _supplyVoltage = supplyVoltage; + } +} + // ============================================================================ // TIADS1x15 Functions // ============================================================================ @@ -250,14 +265,13 @@ adsGain_t TIADS1x15Base::getADSGain(void) const { TIADS1x15::TIADS1x15(int8_t powerPin, int8_t adsChannel, float voltageMultiplier, adsGain_t adsGain, uint8_t i2cAddress, uint8_t measurementsToAverage, - float adsSupplyVoltage, int8_t differentialChannel) + float adsSupplyVoltage, int8_t analogReferenceChannel) : Sensor("TIADS1x15", TIADS1X15_NUM_VARIABLES, TIADS1X15_WARM_UP_TIME_MS, TIADS1X15_STABILIZATION_TIME_MS, TIADS1X15_MEASUREMENT_TIME_MS, powerPin, adsChannel, measurementsToAverage, TIADS1X15_INC_CALC_VARIABLES), - TIADS1x15Base(voltageMultiplier, adsGain, i2cAddress, adsSupplyVoltage) { - // Set differential channel configuration - setDifferentialChannel(differentialChannel); + TIADS1x15Base(voltageMultiplier, adsGain, i2cAddress, adsSupplyVoltage), + _analogReferenceChannel(analogReferenceChannel) { // NOTE: We DO NOT validate the channel numbers and pairings in this // constructor! We CANNOT print a warning here about invalid channel // because the Serial object may not be initialized yet, and we don't want @@ -271,11 +285,11 @@ TIADS1x15::~TIADS1x15() {} String TIADS1x15::getSensorLocation(void) { String sensorLocation = TIADS1x15Base::getSensorLocation(); - if (isDifferential()) { + if (isValidDifferentialPair(_dataPin, _analogReferenceChannel)) { sensorLocation += F("_Diff"); sensorLocation += String(_dataPin); sensorLocation += F("_"); - sensorLocation += String(_adsDifferentialChannel); + sensorLocation += String(_analogReferenceChannel); } else { sensorLocation += F("_Channel"); sensorLocation += String(_dataPin); @@ -295,8 +309,8 @@ bool TIADS1x15::addSingleMeasurementResult(void) { bool success = false; // Use differential or single-ended reading based on configuration - if (isDifferential()) { - success = readVoltageDifferential(_dataPin, _adsDifferentialChannel, + if (isValidDifferentialPair(_dataPin, _analogReferenceChannel)) { + success = readVoltageDifferential(_dataPin, _analogReferenceChannel, resultValue); } else { success = readVoltageSingleEnded(_dataPin, resultValue); @@ -310,20 +324,4 @@ bool TIADS1x15::addSingleMeasurementResult(void) { return bumpMeasurementAttemptCount(success); } -// Override setSupplyVoltage in TIADS1x15 to validate range -void TIADS1x15::setSupplyVoltage(float supplyVoltage) { - // Validate supply voltage range: 0.0V to 5.5V per datasheet - if (supplyVoltage < 0.0f) { - MS_DBG(F("ADS supply voltage "), supplyVoltage, - F("V is below minimum, clamping to 0.0V")); - _supplyVoltage = 0.0f; - } else if (supplyVoltage > 5.5f) { - MS_DBG(F("ADS supply voltage "), supplyVoltage, - F("V exceeds maximum, clamping to 5.5V")); - _supplyVoltage = 5.5f; - } else { - _supplyVoltage = supplyVoltage; - } -} - // cspell:words GAIN_TWOTHIRDS diff --git a/src/sensors/TIADS1x15.h b/src/sensors/TIADS1x15.h index 145151735..3b702e2f4 100644 --- a/src/sensors/TIADS1x15.h +++ b/src/sensors/TIADS1x15.h @@ -298,12 +298,12 @@ class TIADS1x15Base : public AnalogVoltageBase { * @brief Read a differential voltage measurement from the ADS1x15 * * @param analogChannel The primary analog channel for differential - * measurement. Negative or invalid channel numbers or parings between the + * measurement. Negative or invalid channel numbers or pairings between the * analogChannel and analogReferenceChannel are not clamped and will cause * the reading to fail and emit a warning. * @param analogReferenceChannel The secondary (reference) analog channel * for differential measurement. Negative or invalid channel numbers or - * parings between the analogChannel and analogReferenceChannel are not + * pairings between the analogChannel and analogReferenceChannel are not * clamped and will cause the reading to fail and emit a warning. * @param resultValue Reference to store the resulting voltage measurement * @return True if the voltage reading was successful and within valid range @@ -347,6 +347,16 @@ class TIADS1x15Base : public AnalogVoltageBase { */ static bool isValidDifferentialPair(int8_t channel1, int8_t channel2); + /** + * @brief Set the supply voltage for the ADS1x15 + * + * @param supplyVoltage The supply voltage in volts + * + * @note Valid range is 0.0V to 5.5V per ADS1x15 datasheet. Values outside + * this range will be clamped with debug logging. + */ + void setSupplyVoltage(float supplyVoltage) override; + protected: /** * @brief Internal reference to the internal gain setting of the TI-ADS1x15 @@ -356,36 +366,6 @@ class TIADS1x15Base : public AnalogVoltageBase { * @brief Internal reference to the I2C address of the TI-ADS1x15 */ uint8_t _i2cAddress; - - /** - * @brief Internal reference to the secondary (reference) analog channel for - * differential measurements - * - * For single-ended measurements: -1 (not used) - * For differential measurements: the second ADS channel (0-3) - */ - int8_t _adsDifferentialChannel = -1; - - /** - * @brief Helper function to check if this sensor is configured for - * differential measurements - * - * @return True if this sensor uses differential measurements, false for - * single-ended - */ - bool isDifferential() const { - return _adsDifferentialChannel != -1; - } - - /** - * @brief Set the differential channel for differential measurements - * - * @param differentialChannel The secondary (reference) channel for - * differential measurements (0-3), or -1 for single-ended - */ - void setDifferentialChannel(int8_t differentialChannel) { - _adsDifferentialChannel = differentialChannel; - } }; /* clang-format off */ @@ -426,17 +406,17 @@ class TIADS1x15 : public Sensor, public TIADS1x15Base { * default value of 1. * @param adsSupplyVoltage The power supply voltage for the ADS1x15 in * volts; defaults to the processor operating voltage from KnownProcessors.h - * @param differentialChannel The second (reference/negative) ADS channel + * @param analogReferenceChannel The second (reference/negative) ADS channel * for differential measurement (0-3, physical channel only). Valid pairs * are: 0-1, 0-3, 1-3, or 2-3. Use -1 (default) for single-ended * measurements. */ TIADS1x15(int8_t powerPin, int8_t adsChannel, float voltageMultiplier = 1.0f, adsGain_t adsGain = GAIN_ONE, - uint8_t i2cAddress = MS_DEFAULT_ADS1X15_ADDRESS, - uint8_t measurementsToAverage = 1, - float adsSupplyVoltage = OPERATING_VOLTAGE, - int8_t differentialChannel = -1); + uint8_t i2cAddress = MS_DEFAULT_ADS1X15_ADDRESS, + uint8_t measurementsToAverage = 1, + float adsSupplyVoltage = OPERATING_VOLTAGE, + int8_t analogReferenceChannel = -1); /** * @brief Destroy the External Voltage object */ @@ -446,13 +426,15 @@ class TIADS1x15 : public Sensor, public TIADS1x15Base { bool addSingleMeasurementResult(void) override; + private: /** - * @brief Set the power supply voltage for the ADS1x15 + * @brief Internal reference to the secondary (reference) analog channel for + * differential measurements * - * @param supplyVoltage The power supply voltage in volts (2.0-5.5V - * range) + * For single-ended measurements: -1 (not used) + * For differential measurements: the second ADS channel (0-3) */ - void setSupplyVoltage(float supplyVoltage) override; + int8_t _analogReferenceChannel = -1; }; /** diff --git a/src/sensors/TurnerCyclops.h b/src/sensors/TurnerCyclops.h index b492fd30a..b8b5e0c8e 100644 --- a/src/sensors/TurnerCyclops.h +++ b/src/sensors/TurnerCyclops.h @@ -179,6 +179,7 @@ * Configuration parameters for the Turner Cyclops-7F sensor */ /**@{*/ +#if !defined(CYCLOPS_CALIBRATION_EPSILON) || defined(DOXYGEN) /** * @brief Minimum voltage difference threshold for calibration validation * @@ -192,6 +193,7 @@ * most high-precision ADC configurations. */ #define CYCLOPS_CALIBRATION_EPSILON 1e-4f +#endif // !defined(CYCLOPS_CALIBRATION_EPSILON) || defined(DOXYGEN) /**@}*/ /** diff --git a/src/sensors/TurnerTurbidityPlus.h b/src/sensors/TurnerTurbidityPlus.h index eeb64b73f..7e8d4b3c4 100644 --- a/src/sensors/TurnerTurbidityPlus.h +++ b/src/sensors/TurnerTurbidityPlus.h @@ -215,12 +215,12 @@ class TurnerTurbidityPlus : public Sensor { * @param wiperTriggerPin The pin on the mcu that triggers the sensor's * wiper. * @param analogChannel The primary analog channel for differential - * measurement. Negative or invalid channel numbers or parings between the + * measurement. Negative or invalid channel numbers or pairings between the * analogChannel and analogReferenceChannel are not clamped and will cause * the reading to fail and emit a warning. * @param analogReferenceChannel The secondary (reference) analog channel * for differential measurement. Negative or invalid channel numbers or - * parings between the analogChannel and analogReferenceChannel are not + * pairings between the analogChannel and analogReferenceChannel are not * clamped and will cause the reading to fail and emit a warning. * @param conc_std The concentration of the standard used for a 1-point * sensor calibration. The concentration units should be the same as the From 5f69ba41d7c98243e19824cb79004270624f9998 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Wed, 25 Feb 2026 11:27:22 -0500 Subject: [PATCH 329/533] Fix variable sizing Signed-off-by: Sara Damiano --- src/sensors/PaleoTerraRedox.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/sensors/PaleoTerraRedox.cpp b/src/sensors/PaleoTerraRedox.cpp index 2296f5240..52155f8a5 100644 --- a/src/sensors/PaleoTerraRedox.cpp +++ b/src/sensors/PaleoTerraRedox.cpp @@ -145,9 +145,10 @@ bool PaleoTerraRedox::addSingleMeasurementResult(void) { res = 0; // Assemble the 18-bit raw sample from the three bytes // Only use the lower 2 bits of res1 (D17 D16), ignore sign-extension bits - adcValue = ((res1 & 0x03) << 16) // extract D17 D16 and shift to position - | (res2 << 8) // shift res2 up to middle byte - | res3; // res3 is already in the right place as the LSB + // Cast to uint32_t to ensure sufficient bit width for left shift operations + adcValue = (((uint32_t)(res1 & 0x03)) << 16) // extract D17 D16 and shift to position + | (((uint32_t)res2) << 8) // shift res2 up to middle byte + | ((uint32_t)res3); // res3 is already in the right place as the LSB // Check if this is a negative value (sign bit 17 is set) if (res1 & 0x02) { // Test bit 17 From 6dc77623d17e7cbc4872f780a7becde3ec6bba6e Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Wed, 25 Feb 2026 12:07:05 -0500 Subject: [PATCH 330/533] Define for PROCESSOR_ANALOG_MAX_CHANNEL Signed-off-by: Sara Damiano --- src/ModSensorConfig.h | 3 +++ src/sensors/ProcessorAnalog.cpp | 12 +++++++----- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/ModSensorConfig.h b/src/ModSensorConfig.h index e3de5096a..b2f07eb4e 100644 --- a/src/ModSensorConfig.h +++ b/src/ModSensorConfig.h @@ -186,6 +186,9 @@ /// @brief The maximum possible range of the ADC - the resolution shifted up one /// bit. #define PROCESSOR_ADC_RANGE (1 << MS_PROCESSOR_ADC_RESOLUTION) +/// @brief The maximum analog channel number supported by the processor ADC. +/// This conservative limit accommodates various Arduino platforms (Uno, Mega, etc.) +#define PROCESSOR_ANALOG_MAX_CHANNEL 100 #if !defined(MS_PROCESSOR_ADC_REFERENCE_MODE) || defined(DOXYGEN) #if defined(ARDUINO_ARCH_AVR) || defined(DOXYGEN) diff --git a/src/sensors/ProcessorAnalog.cpp b/src/sensors/ProcessorAnalog.cpp index 68cf798f8..0b1bffe26 100644 --- a/src/sensors/ProcessorAnalog.cpp +++ b/src/sensors/ProcessorAnalog.cpp @@ -33,10 +33,11 @@ bool ProcessorAnalogBase::readVoltageSingleEnded(int8_t analogChannel, "MS_PROCESSOR_ADC_RESOLUTION configuration."); // Validate parameters - if (analogChannel < 0 || analogChannel > 100 || _supplyVoltage <= 0 || - _voltageMultiplier <= 0) { - MS_DBG(F("Invalid configuration: analog channel (must be 0-100), " - "supply voltage, " + if (analogChannel < 0 || analogChannel > PROCESSOR_ANALOG_MAX_CHANNEL || + _supplyVoltage <= 0 || _voltageMultiplier <= 0) { + MS_DBG(F("Invalid configuration: analog channel (must be 0-"), + PROCESSOR_ANALOG_MAX_CHANNEL, + F("), supply voltage, " "or voltage multiplier is not set!")); resultValue = -9999.0f; return false; @@ -48,7 +49,8 @@ bool ProcessorAnalogBase::readVoltageSingleEnded(int8_t analogChannel, analogRead(analogChannel); // priming reading // The return value from analogRead() is IN BITS NOT IN VOLTS!! analogRead(analogChannel); // another priming reading - float rawAnalog = analogRead(analogChannel); + int rawAdc = analogRead(analogChannel); + float rawAnalog = static_cast(rawAdc); MS_DBG(F("Raw analog pin reading in bits:"), rawAnalog); // convert bits to volts From 01b6515d2a505fcfb0fa4f63ecbdca49869c1c0e Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Wed, 25 Feb 2026 12:10:35 -0500 Subject: [PATCH 331/533] Refactor getSensorLocation for analog to getAnalogLocation depending on input channels Signed-off-by: Sara Damiano --- src/sensors/AlphasenseCO2.cpp | 14 +++---------- src/sensors/AnalogElecConductivity.cpp | 17 ++++++--------- src/sensors/AnalogVoltageBase.h | 13 +++++++++--- src/sensors/ApogeeSQ212.cpp | 9 ++------ src/sensors/CampbellOBS3.cpp | 7 ++----- src/sensors/EverlightALSPT19.cpp | 9 ++------ src/sensors/ProcessorAnalog.cpp | 14 +++++++------ src/sensors/ProcessorAnalog.h | 3 ++- src/sensors/TIADS1x15.cpp | 29 +++++++++++++------------- src/sensors/TIADS1x15.h | 8 ++----- src/sensors/TurnerCyclops.cpp | 7 ++----- src/sensors/TurnerTurbidityPlus.cpp | 14 +++---------- 12 files changed, 57 insertions(+), 87 deletions(-) diff --git a/src/sensors/AlphasenseCO2.cpp b/src/sensors/AlphasenseCO2.cpp index c972a79db..9f5844466 100644 --- a/src/sensors/AlphasenseCO2.cpp +++ b/src/sensors/AlphasenseCO2.cpp @@ -43,18 +43,10 @@ AlphasenseCO2::~AlphasenseCO2() { String AlphasenseCO2::getSensorLocation(void) { if (_analogVoltageReader != nullptr) { - String sensorLocation = _analogVoltageReader->getSensorLocation(); - sensorLocation += F("_Diff_"); - sensorLocation += String(_dataPin); - sensorLocation += F("_"); - sensorLocation += String(_analogReferenceChannel); - return sensorLocation; + return _analogVoltageReader->getAnalogLocation(_dataPin, + _analogReferenceChannel); } else { - String sensorLocation = F("Unknown_AnalogVoltageReader_Diff_"); - sensorLocation += String(_dataPin); - sensorLocation += F("_"); - sensorLocation += String(_analogReferenceChannel); - return sensorLocation; + return String("Unknown_AnalogVoltageReader"); } } diff --git a/src/sensors/AnalogElecConductivity.cpp b/src/sensors/AnalogElecConductivity.cpp index d8524b40a..8f5755129 100644 --- a/src/sensors/AnalogElecConductivity.cpp +++ b/src/sensors/AnalogElecConductivity.cpp @@ -39,20 +39,15 @@ AnalogElecConductivity::~AnalogElecConductivity() { String AnalogElecConductivity::getSensorLocation(void) { + String sensorLocation; if (_analogVoltageReader != nullptr) { - String sensorLocation = _analogVoltageReader->getSensorLocation(); - sensorLocation += F("_anlgEc_"); - sensorLocation += String(_dataPin); - sensorLocation += F("_Pwr"); - sensorLocation += String(_powerPin); - return sensorLocation; + sensorLocation = _analogVoltageReader->getAnalogLocation(_dataPin); } else { - String sensorLocation = F("Unknown_AnalogVoltageReader_anlgEc_"); - sensorLocation += String(_dataPin); - sensorLocation += F("_Pwr"); - sensorLocation += String(_powerPin); - return sensorLocation; + sensorLocation = F("Unknown_AnalogVoltageReader"); } + sensorLocation += F("_Pwr"); + sensorLocation += String(_powerPin); + return sensorLocation; } diff --git a/src/sensors/AnalogVoltageBase.h b/src/sensors/AnalogVoltageBase.h index c1b51ad9c..a59874939 100644 --- a/src/sensors/AnalogVoltageBase.h +++ b/src/sensors/AnalogVoltageBase.h @@ -166,14 +166,21 @@ class AnalogVoltageBase { float& resultValue) = 0; /** - * @brief Get the sensor location string + * @brief Construct a String describing the analog sensor location from the + * input channels. * * This pure virtual function must be implemented by derived classes to * provide their specific sensor location identification string. * - * @return A string describing the sensor location + * @param analogChannel The primary analog channel for differential + * measurement. + * @param analogReferenceChannel The secondary (reference) analog channel + * for differential measurement. Optional with a default of -1. + * + * @return A string describing the analog sensor location */ - virtual String getSensorLocation(void) = 0; + virtual String getAnalogLocation(int8_t analogChannel, + int8_t analogReferenceChannel = -1) = 0; protected: /** diff --git a/src/sensors/ApogeeSQ212.cpp b/src/sensors/ApogeeSQ212.cpp index 804d7ec1e..33b0d2c39 100644 --- a/src/sensors/ApogeeSQ212.cpp +++ b/src/sensors/ApogeeSQ212.cpp @@ -39,14 +39,9 @@ ApogeeSQ212::~ApogeeSQ212() { String ApogeeSQ212::getSensorLocation(void) { if (_analogVoltageReader != nullptr) { - String sensorLocation = _analogVoltageReader->getSensorLocation(); - sensorLocation += F("_Channel"); - sensorLocation += String(_dataPin); - return sensorLocation; + return _analogVoltageReader->getAnalogLocation(_dataPin); } else { - String sensorLocation = F("Unknown_AnalogVoltageReader_Channel"); - sensorLocation += String(_dataPin); - return sensorLocation; + return String("Unknown_AnalogVoltageReader"); } } diff --git a/src/sensors/CampbellOBS3.cpp b/src/sensors/CampbellOBS3.cpp index 217ad340e..6057a3d62 100644 --- a/src/sensors/CampbellOBS3.cpp +++ b/src/sensors/CampbellOBS3.cpp @@ -40,12 +40,9 @@ CampbellOBS3::~CampbellOBS3() { String CampbellOBS3::getSensorLocation(void) { if (_analogVoltageReader != nullptr) { - return _analogVoltageReader->getSensorLocation() + F("_Channel") + - String(_dataPin); + return _analogVoltageReader->getAnalogLocation(_dataPin); } else { - String sensorLocation = F("Unknown_AnalogVoltageReader_Channel"); - sensorLocation += String(_dataPin); - return sensorLocation; + return String("Unknown_AnalogVoltageReader"); } } diff --git a/src/sensors/EverlightALSPT19.cpp b/src/sensors/EverlightALSPT19.cpp index e384eccc1..8c7a70bdc 100644 --- a/src/sensors/EverlightALSPT19.cpp +++ b/src/sensors/EverlightALSPT19.cpp @@ -50,14 +50,9 @@ EverlightALSPT19::~EverlightALSPT19() { String EverlightALSPT19::getSensorLocation(void) { if (_analogVoltageReader != nullptr) { - String sensorLocation = _analogVoltageReader->getSensorLocation(); - sensorLocation += F("_"); - sensorLocation += String(_dataPin); - return sensorLocation; + return _analogVoltageReader->getAnalogLocation(_dataPin); } else { - String sensorLocation = F("Unknown_AnalogVoltageReader_"); - sensorLocation += String(_dataPin); - return sensorLocation; + return String("Unknown_AnalogVoltageReader"); } } diff --git a/src/sensors/ProcessorAnalog.cpp b/src/sensors/ProcessorAnalog.cpp index 0b1bffe26..550fc8806 100644 --- a/src/sensors/ProcessorAnalog.cpp +++ b/src/sensors/ProcessorAnalog.cpp @@ -65,8 +65,13 @@ bool ProcessorAnalogBase::readVoltageSingleEnded(int8_t analogChannel, return true; } -String ProcessorAnalogBase::getSensorLocation(void) { - String sensorLocation = F("ProcessorAnalog"); +String +ProcessorAnalogBase::getAnalogLocation(int8_t analogChannel, + int8_t /*analogReferenceChannel*/) { + String sensorLocation; + sensorLocation += F("ProcessorAnalog"); + sensorLocation += F("_Pin"); + sensorLocation += String(analogChannel); return sensorLocation; } @@ -99,10 +104,7 @@ ProcessorAnalog::ProcessorAnalog(int8_t powerPin, int8_t dataPin, ProcessorAnalog::~ProcessorAnalog() {} String ProcessorAnalog::getSensorLocation() { - String sensorLocation = ProcessorAnalogBase::getSensorLocation(); - sensorLocation += F("_Pin"); - sensorLocation += String(_dataPin); - return sensorLocation; + return ProcessorAnalogBase::getAnalogLocation(_dataPin); } bool ProcessorAnalog::addSingleMeasurementResult(void) { diff --git a/src/sensors/ProcessorAnalog.h b/src/sensors/ProcessorAnalog.h index 974799006..be4edc7a6 100644 --- a/src/sensors/ProcessorAnalog.h +++ b/src/sensors/ProcessorAnalog.h @@ -211,7 +211,8 @@ class ProcessorAnalogBase : public AnalogVoltageBase { int8_t /*analogReferenceChannel*/, float& resultValue) override; - String getSensorLocation(void) override; + String getAnalogLocation(int8_t analogChannel, + int8_t analogReferenceChannel = -1) override; }; /* clang-format off */ diff --git a/src/sensors/TIADS1x15.cpp b/src/sensors/TIADS1x15.cpp index d7ced86b4..653fdc768 100644 --- a/src/sensors/TIADS1x15.cpp +++ b/src/sensors/TIADS1x15.cpp @@ -41,13 +41,24 @@ TIADS1x15Base::TIADS1x15Base(float voltageMultiplier, adsGain_t adsGain, // TIADS1x15Base Functions // ============================================================================ -String TIADS1x15Base::getSensorLocation(void) { +String TIADS1x15Base::getAnalogLocation(int8_t analogChannel, + int8_t analogReferenceChannel) { + String sensorLocation; #ifndef MS_USE_ADS1015 - String sensorLocation = F("ADS1115_0x"); + sensorLocation += F("ADS1115_0x"); #else - String sensorLocation = F("ADS1015_0x"); + sensorLocation += F("ADS1015_0x"); #endif sensorLocation += String(_i2cAddress, HEX); + if (!isValidDifferentialPair(analogChannel, analogReferenceChannel)) { + sensorLocation += F("_Diff_"); + sensorLocation += String(analogChannel); + sensorLocation += F("_"); + sensorLocation += String(analogReferenceChannel); + } else { + sensorLocation += F("_Channel"); + sensorLocation += String(analogChannel); + } return sensorLocation; } @@ -284,17 +295,7 @@ TIADS1x15::TIADS1x15(int8_t powerPin, int8_t adsChannel, TIADS1x15::~TIADS1x15() {} String TIADS1x15::getSensorLocation(void) { - String sensorLocation = TIADS1x15Base::getSensorLocation(); - if (isValidDifferentialPair(_dataPin, _analogReferenceChannel)) { - sensorLocation += F("_Diff"); - sensorLocation += String(_dataPin); - sensorLocation += F("_"); - sensorLocation += String(_analogReferenceChannel); - } else { - sensorLocation += F("_Channel"); - sensorLocation += String(_dataPin); - } - return sensorLocation; + return TIADS1x15Base::getAnalogLocation(_dataPin, _analogReferenceChannel); } bool TIADS1x15::addSingleMeasurementResult(void) { diff --git a/src/sensors/TIADS1x15.h b/src/sensors/TIADS1x15.h index 3b702e2f4..da55c3c1b 100644 --- a/src/sensors/TIADS1x15.h +++ b/src/sensors/TIADS1x15.h @@ -312,12 +312,8 @@ class TIADS1x15Base : public AnalogVoltageBase { int8_t analogReferenceChannel, float& resultValue) override; - /** - * @brief Get the sensor location string - * - * @return A string describing the ADS1x15 sensor location - */ - String getSensorLocation(void) override; + String getAnalogLocation(int8_t analogChannel, + int8_t analogReferenceChannel = -1) override; /** * @brief Set the internal gain setting for the ADS1x15 diff --git a/src/sensors/TurnerCyclops.cpp b/src/sensors/TurnerCyclops.cpp index 1a83919e0..4c043ec7d 100644 --- a/src/sensors/TurnerCyclops.cpp +++ b/src/sensors/TurnerCyclops.cpp @@ -41,12 +41,9 @@ TurnerCyclops::~TurnerCyclops() { String TurnerCyclops::getSensorLocation(void) { if (_analogVoltageReader != nullptr) { - return _analogVoltageReader->getSensorLocation() + F("_Channel") + - String(_dataPin); + return _analogVoltageReader->getAnalogLocation(_dataPin); } else { - String sensorLocation = F("Unknown_AnalogVoltageReader_Channel"); - sensorLocation += String(_dataPin); - return sensorLocation; + return String("Unknown_AnalogVoltageReader"); } } diff --git a/src/sensors/TurnerTurbidityPlus.cpp b/src/sensors/TurnerTurbidityPlus.cpp index 3263460f4..d9a9df655 100644 --- a/src/sensors/TurnerTurbidityPlus.cpp +++ b/src/sensors/TurnerTurbidityPlus.cpp @@ -44,18 +44,10 @@ TurnerTurbidityPlus::~TurnerTurbidityPlus() { String TurnerTurbidityPlus::getSensorLocation(void) { if (_analogVoltageReader != nullptr) { - String sensorLocation = _analogVoltageReader->getSensorLocation(); - sensorLocation += F("_Diff_"); - sensorLocation += String(_dataPin); - sensorLocation += F("_"); - sensorLocation += String(_analogReferenceChannel); - return sensorLocation; + return _analogVoltageReader->getAnalogLocation(_dataPin, + _analogReferenceChannel); } else { - String sensorLocation = F("Unknown_AnalogVoltageReader_Diff_"); - sensorLocation += String(_dataPin); - sensorLocation += F("_"); - sensorLocation += String(_analogReferenceChannel); - return sensorLocation; + return String("Unknown_AnalogVoltageReader"); } } From b43db516034f15bcff98b0401ab673b58235845f Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Wed, 25 Feb 2026 12:33:22 -0500 Subject: [PATCH 332/533] Validation, docs, float tags Signed-off-by: Sara Damiano --- examples/menu_a_la_carte/menu_a_la_carte.ino | 12 +++++++----- src/ModSensorConfig.h | 12 +++++++++--- src/sensors/AlphasenseCO2.cpp | 2 +- src/sensors/AlphasenseCO2.h | 4 +--- src/sensors/AnalogElecConductivity.cpp | 11 ++++++----- src/sensors/AnalogElecConductivity.h | 10 ++++++++-- src/sensors/AnalogVoltageBase.h | 2 +- src/sensors/ApogeeSQ212.h | 2 -- src/sensors/CampbellOBS3.h | 4 ---- src/sensors/EverlightALSPT19.cpp | 4 ++-- src/sensors/PaleoTerraRedox.cpp | 8 +++++--- src/sensors/ProcessorAnalog.cpp | 10 ++++------ src/sensors/ProcessorAnalog.h | 8 ++++---- src/sensors/TIADS1x15.cpp | 8 +++++++- src/sensors/TIADS1x15.h | 18 +++++++++--------- src/sensors/TurnerCyclops.h | 4 +--- src/sensors/TurnerTurbidityPlus.cpp | 3 +-- src/sensors/TurnerTurbidityPlus.h | 4 ---- 18 files changed, 66 insertions(+), 60 deletions(-) diff --git a/examples/menu_a_la_carte/menu_a_la_carte.ino b/examples/menu_a_la_carte/menu_a_la_carte.ino index 5492f5c29..1fcd420e8 100644 --- a/examples/menu_a_la_carte/menu_a_la_carte.ino +++ b/examples/menu_a_la_carte/menu_a_la_carte.ino @@ -1611,12 +1611,14 @@ const float voltageMultiplier = 1.0f; // Voltage multiplier for an external voltage divider // use 1.0f for direct connection // use (R_top + R_bottom) / R_bottom for voltage divider -const adsGain_t adsGain = GAIN_ONE; // The internal gain setting for the ADS -const uint8_t evADSi2c_addr = 0x48; // The I2C address of the ADS1115 ADC -const uint8_t VoltReadsToAvg = 1; // Only read one sample +const adsGain_t adsPGAGain = GAIN_ONE; // The internal gain setting for the ADS +// GAIN_ONE => +/-4.096V range; use GAIN_TWOTHIRDS (+/-6.144V) for inputs +// > 4.096V GAIN_TWO => +/-2.048V, GAIN_FOUR => +/-1.024V, etc. +const uint8_t evADSi2c_addr = 0x48; // The I2C address of the ADS1115 ADC +const uint8_t VoltReadsToAvg = 1; // Only read one sample // Create a TI ADS1x15 sensor object -TIADS1x15 ads1x15(ADSPower, ADSChannel, voltageMultiplier, adsGain, +TIADS1x15 ads1x15(ADSPower, ADSChannel, voltageMultiplier, adsPGAGain, evADSi2c_addr, VoltReadsToAvg); // Create a voltage variable pointer @@ -4126,4 +4128,4 @@ void loop() { // cspell: ignore RDOSDI TROLLSDI acculev nanolev TMSDI ELEC fivetm tallyi // cspell: ignore kmph TIINA Chloro Fluoroscein PTSA BTEX ECpwrPin anlg spcond // cspell: ignore Relia NEOPIXEL RESTAPI autobauding xbeec -// cspell: ignore CFUN UMNOPROF URAT PHEC +// cspell: ignore CFUN UMNOPROF URAT PHEC GAIN_TWOTHIRDS diff --git a/src/ModSensorConfig.h b/src/ModSensorConfig.h index b2f07eb4e..023d12aef 100644 --- a/src/ModSensorConfig.h +++ b/src/ModSensorConfig.h @@ -186,10 +186,16 @@ /// @brief The maximum possible range of the ADC - the resolution shifted up one /// bit. #define PROCESSOR_ADC_RANGE (1 << MS_PROCESSOR_ADC_RESOLUTION) -/// @brief The maximum analog channel number supported by the processor ADC. -/// This conservative limit accommodates various Arduino platforms (Uno, Mega, etc.) +#ifndef PROCESSOR_ANALOG_MAX_CHANNEL +/** + * @brief Upper bound used to sanity-check analog channel numbers at runtime. + * + * This is not a hardware limit but a validation ceiling that exceeds the + * largest channel index found on any supported Arduino platform (e.g. Mega: + * A0–A15). Override with -D PROCESSOR_ANALOG_MAX_CHANNEL= if needed. + */ #define PROCESSOR_ANALOG_MAX_CHANNEL 100 - +#endif // PROCESSOR_ANALOG_MAX_CHANNEL #if !defined(MS_PROCESSOR_ADC_REFERENCE_MODE) || defined(DOXYGEN) #if defined(ARDUINO_ARCH_AVR) || defined(DOXYGEN) /** diff --git a/src/sensors/AlphasenseCO2.cpp b/src/sensors/AlphasenseCO2.cpp index 9f5844466..dd1327c8c 100644 --- a/src/sensors/AlphasenseCO2.cpp +++ b/src/sensors/AlphasenseCO2.cpp @@ -82,7 +82,7 @@ bool AlphasenseCO2::addSingleMeasurementResult(void) { // Convert current to ppm (using a formula recommended by the sensor // manufacturer) - float calibResult = ALPHASENSE_CO2_MFG_SCALE * co2Current - + float calibResult = (ALPHASENSE_CO2_MFG_SCALE * co2Current) - ALPHASENSE_CO2_MFG_OFFSET; MS_DBG(F(" calibResult:"), calibResult); verifyAndAddMeasurementResult(ALPHASENSE_CO2_VOLTAGE_VAR_NUM, diff --git a/src/sensors/AlphasenseCO2.h b/src/sensors/AlphasenseCO2.h index 2c0853b64..5b3672f6b 100644 --- a/src/sensors/AlphasenseCO2.h +++ b/src/sensors/AlphasenseCO2.h @@ -51,8 +51,6 @@ * [Datasheet](https://www.alphasense.com/wp-content/uploads/2018/04/IRC-A1.pdf) * * @section sensor_alphasense_co2_flags Build flags - * - ```-D MS_USE_ADS1015``` - * - switches from the 16-bit ADS1115 to the 12 bit ADS1015 * - ```-D ALPHASENSE_CO2_SENSE_RESISTOR_OHM=x``` * - Changes the sense resistor value from 250.0 ohms to x ohms * - ```-D ALPHASENSE_CO2_MFG_SCALE=x``` @@ -104,7 +102,7 @@ /** * @anchor sensor_alphasense_co2_var_counts * @name Sensor Variable Counts - * The number of variables that can be returned by the Apogee SQ-212 + * The number of variables that can be returned by the Alphasense CO2 sensor */ /**@{*/ /// @brief Sensor::_numReturnedValues; the Alphasense CO2 sensor can report 2 diff --git a/src/sensors/AnalogElecConductivity.cpp b/src/sensors/AnalogElecConductivity.cpp index 8f5755129..b64e0677a 100644 --- a/src/sensors/AnalogElecConductivity.cpp +++ b/src/sensors/AnalogElecConductivity.cpp @@ -64,9 +64,10 @@ bool AnalogElecConductivity::addSingleMeasurementResult(void) { return bumpMeasurementAttemptCount(false); } - // Check if we have a valid load resistor - if (_sensorEC_Konst <= 0) { - MS_DBG(getSensorNameAndLocation(), F("Invalid cell constant")); + // Check if we have a resistance and cell constant + if (_Rseries_ohms <= 0 || _sensorEC_Konst <= 0) { + MS_DBG(getSensorNameAndLocation(), + F(" has an invalid cell constant or resistor value!")); return bumpMeasurementAttemptCount(false); } @@ -95,12 +96,12 @@ bool AnalogElecConductivity::addSingleMeasurementResult(void) { adcRatio = ANALOGELECCONDUCTIVITY_ADC_MAX_RATIO; } - float Rwater_ohms = _Rseries_ohms * adcRatio / (1.0 - adcRatio); + float Rwater_ohms = _Rseries_ohms * adcRatio / (1.0f - adcRatio); MS_DBG(F(" Resistance:"), Rwater_ohms, F("ohms")); // Convert to EC float EC_uScm = -9999.0f; // units are uS per cm - if (Rwater_ohms > 0) { + if (Rwater_ohms > 0.0f) { EC_uScm = 1000000.0f / (Rwater_ohms * _sensorEC_Konst); MS_DBG(F("Water EC (uS/cm)"), EC_uScm); verifyAndAddMeasurementResult(ANALOGELECCONDUCTIVITY_EC_VAR_NUM, diff --git a/src/sensors/AnalogElecConductivity.h b/src/sensors/AnalogElecConductivity.h index eea38e277..97984cf75 100644 --- a/src/sensors/AnalogElecConductivity.h +++ b/src/sensors/AnalogElecConductivity.h @@ -199,7 +199,7 @@ * @brief The default resistance (in ohms) of the measuring resistor. * This should not be less than 300 ohms when measuring EC in water. */ -#define ANALOGELECCONDUCTIVITY_RSERIES_OHMS 499 +#define ANALOGELECCONDUCTIVITY_RSERIES_OHMS 499.0f #endif // ANALOGELECCONDUCTIVITY_RSERIES_OHMS #if !defined(ANALOGELECCONDUCTIVITY_KONST) || defined(DOXYGEN) @@ -214,7 +214,7 @@ * and fluid to get a better estimate for K. * Default to 1.0, and can be set at startup. */ -#define ANALOGELECCONDUCTIVITY_KONST 1.0 +#define ANALOGELECCONDUCTIVITY_KONST 1.0f #endif // ANALOGELECCONDUCTIVITY_KONST #if !defined(ANALOGELECCONDUCTIVITY_ADC_MAX_RATIO) || defined(DOXYGEN) @@ -228,6 +228,12 @@ */ #define ANALOGELECCONDUCTIVITY_ADC_MAX_RATIO 0.999f #endif // ANALOGELECCONDUCTIVITY_ADC_MAX_RATIO + +// Compile-time validation of ADC maximum ratio constraint +static_assert( + ANALOGELECCONDUCTIVITY_ADC_MAX_RATIO > 0.0f && + ANALOGELECCONDUCTIVITY_ADC_MAX_RATIO < 1.0f, + "ANALOGELECCONDUCTIVITY_ADC_MAX_RATIO must be in the range (0.0, 1.0)"); /**@}*/ /** diff --git a/src/sensors/AnalogVoltageBase.h b/src/sensors/AnalogVoltageBase.h index a59874939..1bf31dea0 100644 --- a/src/sensors/AnalogVoltageBase.h +++ b/src/sensors/AnalogVoltageBase.h @@ -45,7 +45,7 @@ * methods: * - readVoltageSingleEnded() for single-ended voltage measurements, * - readVoltageDifferential() for differential voltage measurements, and - * - getSensorLocation() to provide sensor location identification. + * - getAnalogLocation() to provide sensor location identification. */ class AnalogVoltageBase { public: diff --git a/src/sensors/ApogeeSQ212.h b/src/sensors/ApogeeSQ212.h index b21c61399..a4ca103d3 100644 --- a/src/sensors/ApogeeSQ212.h +++ b/src/sensors/ApogeeSQ212.h @@ -54,8 +54,6 @@ * SQ-212-215 Manual.pdf) * * @section sensor_sq212_flags Build flags - * - ```-D MS_USE_ADS1015``` - * - switches from the 16-bit ADS1115 to the 12 bit ADS1015 * - ```-D SQ212_CALIBRATION_FACTOR=x``` * - Changes the calibration factor from 1 to x * diff --git a/src/sensors/CampbellOBS3.h b/src/sensors/CampbellOBS3.h index 47196ea7b..53f5447bf 100644 --- a/src/sensors/CampbellOBS3.h +++ b/src/sensors/CampbellOBS3.h @@ -48,10 +48,6 @@ * for the calibrated turbidity. To get both high and low range values, create * two sensor objects! * - * @section sensor_obs3_flags Build flags - * - ```-D MS_USE_ADS1015``` - * - switches from the 16-bit ADS1115 to the 12 bit ADS1015 - * * @section sensor_obs3_ctor Sensor Constructor * {{ @ref CampbellOBS3::CampbellOBS3 }} * diff --git a/src/sensors/EverlightALSPT19.cpp b/src/sensors/EverlightALSPT19.cpp index 8c7a70bdc..4706eaf71 100644 --- a/src/sensors/EverlightALSPT19.cpp +++ b/src/sensors/EverlightALSPT19.cpp @@ -98,11 +98,11 @@ bool EverlightALSPT19::addSingleMeasurementResult(void) { // - V(out) = I(PH) * R(L) // At saturation: // - V(out) = Vcc-0.4V - if (adcVoltage > _alsSupplyVoltage - 0.4) { + if (adcVoltage > _alsSupplyVoltage - 0.4f) { MS_DBG(getSensorNameAndLocation(), F("Light sensor has reached saturation! Clamping current " "and illumination values!")); - adcVoltage = _alsSupplyVoltage - 0.4; + adcVoltage = _alsSupplyVoltage - 0.4f; } // convert volts to current diff --git a/src/sensors/PaleoTerraRedox.cpp b/src/sensors/PaleoTerraRedox.cpp index 52155f8a5..1c3685c8b 100644 --- a/src/sensors/PaleoTerraRedox.cpp +++ b/src/sensors/PaleoTerraRedox.cpp @@ -146,9 +146,11 @@ bool PaleoTerraRedox::addSingleMeasurementResult(void) { // Assemble the 18-bit raw sample from the three bytes // Only use the lower 2 bits of res1 (D17 D16), ignore sign-extension bits // Cast to uint32_t to ensure sufficient bit width for left shift operations - adcValue = (((uint32_t)(res1 & 0x03)) << 16) // extract D17 D16 and shift to position - | (((uint32_t)res2) << 8) // shift res2 up to middle byte - | ((uint32_t)res3); // res3 is already in the right place as the LSB + adcValue = static_cast( + (((uint32_t)(res1 & 0x03)) + << 16) // extract D17 D16 and shift to position + | (((uint32_t)res2) << 8) // shift res2 up to middle byte + | ((uint32_t)res3)); // res3 is already in the right place as the LSB // Check if this is a negative value (sign bit 17 is set) if (res1 & 0x02) { // Test bit 17 diff --git a/src/sensors/ProcessorAnalog.cpp b/src/sensors/ProcessorAnalog.cpp index 550fc8806..249a8f3c7 100644 --- a/src/sensors/ProcessorAnalog.cpp +++ b/src/sensors/ProcessorAnalog.cpp @@ -35,10 +35,8 @@ bool ProcessorAnalogBase::readVoltageSingleEnded(int8_t analogChannel, // Validate parameters if (analogChannel < 0 || analogChannel > PROCESSOR_ANALOG_MAX_CHANNEL || _supplyVoltage <= 0 || _voltageMultiplier <= 0) { - MS_DBG(F("Invalid configuration: analog channel (must be 0-"), - PROCESSOR_ANALOG_MAX_CHANNEL, - F("), supply voltage, " - "or voltage multiplier is not set!")); + MS_DBG(F("Invalid configuration: either the analog channel, the supply " + "voltage, or the voltage multiplier is not set correctly!")); resultValue = -9999.0f; return false; } @@ -69,8 +67,7 @@ String ProcessorAnalogBase::getAnalogLocation(int8_t analogChannel, int8_t /*analogReferenceChannel*/) { String sensorLocation; - sensorLocation += F("ProcessorAnalog"); - sensorLocation += F("_Pin"); + sensorLocation += F("ProcessorAnalog_Pin"); sensorLocation += String(analogChannel); return sensorLocation; } @@ -79,6 +76,7 @@ bool ProcessorAnalogBase::readVoltageDifferential( int8_t /*analogChannel*/, int8_t /*analogReferenceChannel*/, float& resultValue) { // ProcessorAnalog does not support differential measurements + MS_DBG(F("ProcessorAnalog does not support differential measurements")); resultValue = -9999.0f; return false; } diff --git a/src/sensors/ProcessorAnalog.h b/src/sensors/ProcessorAnalog.h index be4edc7a6..0a85165ba 100644 --- a/src/sensors/ProcessorAnalog.h +++ b/src/sensors/ProcessorAnalog.h @@ -174,8 +174,8 @@ class ProcessorAnalogBase : public AnalogVoltageBase { * @param operatingVoltage The processor's operating voltage; most * likely 3.3 or 5. */ - explicit ProcessorAnalogBase(float voltageMultiplier = 1.0f, - float operatingVoltage = OPERATING_VOLTAGE); + ProcessorAnalogBase(float voltageMultiplier = 1.0f, + float operatingVoltage = OPERATING_VOLTAGE); /** * @brief Destroy the ProcessorAnalogBase object @@ -207,8 +207,8 @@ class ProcessorAnalogBase : public AnalogVoltageBase { * This will be set to -9999.0 to indicate an invalid reading. * @return Always false (differential not supported) */ - bool readVoltageDifferential(int8_t /*analogChannel*/, - int8_t /*analogReferenceChannel*/, + bool readVoltageDifferential(int8_t analogChannel, + int8_t analogReferenceChannel, float& resultValue) override; String getAnalogLocation(int8_t analogChannel, diff --git a/src/sensors/TIADS1x15.cpp b/src/sensors/TIADS1x15.cpp index 653fdc768..f0f059b0d 100644 --- a/src/sensors/TIADS1x15.cpp +++ b/src/sensors/TIADS1x15.cpp @@ -50,7 +50,7 @@ String TIADS1x15Base::getAnalogLocation(int8_t analogChannel, sensorLocation += F("ADS1015_0x"); #endif sensorLocation += String(_i2cAddress, HEX); - if (!isValidDifferentialPair(analogChannel, analogReferenceChannel)) { + if (isValidDifferentialPair(analogChannel, analogReferenceChannel)) { sensorLocation += F("_Diff_"); sensorLocation += String(analogChannel); sensorLocation += F("_"); @@ -313,6 +313,12 @@ bool TIADS1x15::addSingleMeasurementResult(void) { if (isValidDifferentialPair(_dataPin, _analogReferenceChannel)) { success = readVoltageDifferential(_dataPin, _analogReferenceChannel, resultValue); + if (_analogReferenceChannel >= 0 && _analogReferenceChannel <= 3) { + MS_DBG(F(" Warning: reference channel "), _analogReferenceChannel, + F(" set but pair is not a valid differential config;" + " falling back to single-ended on channel "), + _dataPin); + } } else { success = readVoltageSingleEnded(_dataPin, resultValue); } diff --git a/src/sensors/TIADS1x15.h b/src/sensors/TIADS1x15.h index da55c3c1b..81941eccb 100644 --- a/src/sensors/TIADS1x15.h +++ b/src/sensors/TIADS1x15.h @@ -61,20 +61,20 @@ * @section analog_ads1x15_specs Specifications * @note *In all cases, we assume that the ADS1x15 is powered at 3.3V by default with configurable internal gain settings. * - * The default gain setting is 1x (GAIN_ONE) which divides the bit resolution over the range of 0-4.096V. - * In single-ended mode the actual ceiling is min(FSR, VDD + 0.3V) — typically 3.6V at 3.3V supply. + * The default gain setting is 1x (GAIN_ONE) which provides a PGA full-scale range (±4.096V). + * In single-ended mode the actual ceiling is min(Full-Scale Range (FSR), VDD + 0.3V) — typically 3.6V at 3.3V supply. * - Response time: < 1ms * - Resample time: 860 samples per second (~1.2ms) * - Range: * - Single-ended measurements: Limited by supply voltage (VDD + 0.3V max, absolute max 5.5V) * - 0 - 3.6V [when ADC is powered at 3.3V] - * - Differential measurements: Limited by internal PGA full-scale range (gain-dependent) - * - GAIN_TWOTHIRDS = ±6.144V - * - GAIN_ONE = ±4.096V - * - GAIN_TWO = ±2.048V - * - GAIN_FOUR = ±1.024V - * - GAIN_EIGHT = ±0.512V - * - GAIN_SIXTEEN = ±0.256V + * - Differential measurements: Limited by PGA full-scale range (gain-dependent) + * - GAIN_TWOTHIRDS = ±6.144V PGA full-scale range + * - GAIN_ONE = ±4.096V PGA full-scale range + * - GAIN_TWO = ±2.048V PGA full-scale range + * - GAIN_FOUR = ±1.024V PGA full-scale range + * - GAIN_EIGHT = ±0.512V PGA full-scale range + * - GAIN_SIXTEEN = ±0.256V PGA full-scale range * - Accuracy: * - 16-bit ADC (ADS1115): < 0.25% (gain error), <0.25 LSB (offset error) * - 12-bit ADC (ADS1015, using build flag ```MS_USE_ADS1015```): < 0.15% (gain error), <3 LSB (offset error) diff --git a/src/sensors/TurnerCyclops.h b/src/sensors/TurnerCyclops.h index b8b5e0c8e..cc0fb0b89 100644 --- a/src/sensors/TurnerCyclops.h +++ b/src/sensors/TurnerCyclops.h @@ -120,7 +120,7 @@ * * Before applying any calibration, the analog output from the Cyclops-7F * must be converted into a high resolution digital signal. See the - * [ADS1115 page](@ref analog_group) for details on the conversion. + * [analog group](@ref analog_group) for details on supported ADC backends. * * @section sensor_cyclops_datasheet Sensor Datasheet * - [Main Information Page](https://www.turnerdesigns.com/cyclops-7f-submersible-fluorometer) @@ -128,8 +128,6 @@ * - [Manual](http://docs.turnerdesigns.com/t2/doc/manuals/998-2100.pdf) * * @section sensor_cyclops_flags Build flags - * - ```-D MS_USE_ADS1015``` - * - switches from the 16-bit ADS1115 to the 12 bit ADS1015 * - `-D CYCLOPS_CALIBRATION_EPSILON=x.xf` * - Sets the tolerance for validating the calibration values * diff --git a/src/sensors/TurnerTurbidityPlus.cpp b/src/sensors/TurnerTurbidityPlus.cpp index d9a9df655..2d1d21587 100644 --- a/src/sensors/TurnerTurbidityPlus.cpp +++ b/src/sensors/TurnerTurbidityPlus.cpp @@ -107,7 +107,6 @@ bool TurnerTurbidityPlus::addSingleMeasurementResult(void) { return bumpMeasurementAttemptCount(false); } - bool success = false; float adcVoltage = -9999.0f; MS_DBG(getSensorNameAndLocation(), F("is reporting:")); @@ -125,7 +124,7 @@ bool TurnerTurbidityPlus::addSingleMeasurementResult(void) { // NOTE: All implementations of the AnalogVoltageBase class validate both // the input channel and the resulting voltage, so we can trust that a // successful read will give us a valid voltage value to work with. - success = _analogVoltageReader->readVoltageDifferential( + bool success = _analogVoltageReader->readVoltageDifferential( _dataPin, _analogReferenceChannel, adcVoltage); if (success) { diff --git a/src/sensors/TurnerTurbidityPlus.h b/src/sensors/TurnerTurbidityPlus.h index 7e8d4b3c4..762a180de 100644 --- a/src/sensors/TurnerTurbidityPlus.h +++ b/src/sensors/TurnerTurbidityPlus.h @@ -25,8 +25,6 @@ * [Datasheet](http://docs.turnerdesigns.com/t2/doc/brochures/S-0210.pdf) * * @section sensor_turbidity_plus_flags Build flags - * - ```-D MS_USE_ADS1015``` - * - switches from the 16-bit ADS1115 to the 12 bit ADS1015 * - ```-D TURBIDITY_PLUS_WIPER_TRIGGER_PULSE_MS=x``` * - Changes the wiper trigger pulse duration from 50 ms to x ms * - ```-D TURBIDITY_PLUS_WIPER_ROTATION_WAIT_MS=x``` @@ -436,6 +434,4 @@ class TurnerTurbidityPlus_Turbidity : public Variable { }; /**@}*/ -// cspell:words GAIN_TWOTHIRDS - #endif // SRC_SENSORS_TURNERTURBIDITYPLUS_H_ From 54c795d458584409fbd6c9938251b46cc7efc271 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Wed, 25 Feb 2026 14:38:31 -0500 Subject: [PATCH 333/533] Forward declarations, demote success where possible Signed-off-by: Sara Damiano --- src/sensors/AlphasenseCO2.cpp | 3 +-- src/sensors/AlphasenseCO2.h | 4 +++- src/sensors/AnalogElecConductivity.cpp | 17 +++++++++++------ src/sensors/ApogeeSQ212.cpp | 5 ++--- src/sensors/ApogeeSQ212.h | 4 +++- src/sensors/CampbellOBS3.cpp | 5 ++--- src/sensors/CampbellOBS3.h | 4 +++- src/sensors/EverlightALSPT19.cpp | 7 +++---- src/sensors/TIADS1x15.cpp | 2 +- src/sensors/TurnerCyclops.cpp | 5 ++--- src/sensors/TurnerCyclops.h | 4 +++- src/sensors/TurnerTurbidityPlus.h | 4 +++- 12 files changed, 37 insertions(+), 27 deletions(-) diff --git a/src/sensors/AlphasenseCO2.cpp b/src/sensors/AlphasenseCO2.cpp index dd1327c8c..ba0401f75 100644 --- a/src/sensors/AlphasenseCO2.cpp +++ b/src/sensors/AlphasenseCO2.cpp @@ -64,13 +64,12 @@ bool AlphasenseCO2::addSingleMeasurementResult(void) { return bumpMeasurementAttemptCount(false); } - bool success = false; float adcVoltage = -9999; MS_DBG(getSensorNameAndLocation(), F("is reporting:")); // Read differential voltage using the AnalogVoltageBase interface - success = _analogVoltageReader->readVoltageDifferential( + bool success = _analogVoltageReader->readVoltageDifferential( _dataPin, _analogReferenceChannel, adcVoltage); if (success) { diff --git a/src/sensors/AlphasenseCO2.h b/src/sensors/AlphasenseCO2.h index 5b3672f6b..bbb8ae2f5 100644 --- a/src/sensors/AlphasenseCO2.h +++ b/src/sensors/AlphasenseCO2.h @@ -94,7 +94,9 @@ // Include other in-library and external dependencies #include "VariableBase.h" #include "SensorBase.h" -#include "AnalogVoltageBase.h" + +// Forward declaration +class AnalogVoltageBase; /** @ingroup sensor_alphasense_co2 */ /**@{*/ diff --git a/src/sensors/AnalogElecConductivity.cpp b/src/sensors/AnalogElecConductivity.cpp index b64e0677a..a4cd9ad5b 100644 --- a/src/sensors/AnalogElecConductivity.cpp +++ b/src/sensors/AnalogElecConductivity.cpp @@ -71,29 +71,34 @@ bool AnalogElecConductivity::addSingleMeasurementResult(void) { return bumpMeasurementAttemptCount(false); } - bool success = false; float adcVoltage = -9999.0f; MS_DBG(getSensorNameAndLocation(), F("is reporting:")); // Read the analog voltage using the AnalogVoltageBase interface - success = _analogVoltageReader->readVoltageSingleEnded(_dataPin, - adcVoltage); + bool success = _analogVoltageReader->readVoltageSingleEnded(_dataPin, + adcVoltage); if (success) { // Estimate Resistance of Liquid // see the header for an explanation of this calculation // Convert voltage back to ADC equivalent for existing calculation - // NOTE: The supplyVoltage is validated and clamped by the - // _analogVoltageReader and cannot be 0. float supplyVoltage = _analogVoltageReader->getSupplyVoltage(); - float adcRatio = adcVoltage / supplyVoltage; + if (supplyVoltage <= 0.0f) { + MS_DBG(F(" Invalid supply voltage from analog reader")); + return bumpMeasurementAttemptCount(false); + } + float adcRatio = adcVoltage / supplyVoltage; if (adcRatio >= 1.0) { // Prevent division issues when voltage reaches supply voltage MS_DBG(F(" ADC ratio clamped from"), adcRatio, F("to"), ANALOGELECCONDUCTIVITY_ADC_MAX_RATIO); adcRatio = ANALOGELECCONDUCTIVITY_ADC_MAX_RATIO; + } else if (adcRatio < 0.0f) { + MS_DBG(F(" Negative ADC ratio ("), adcRatio, + F("); negative supply or ADC voltage")); + return bumpMeasurementAttemptCount(false); } float Rwater_ohms = _Rseries_ohms * adcRatio / (1.0f - adcRatio); diff --git a/src/sensors/ApogeeSQ212.cpp b/src/sensors/ApogeeSQ212.cpp index 33b0d2c39..dfbde8ca8 100644 --- a/src/sensors/ApogeeSQ212.cpp +++ b/src/sensors/ApogeeSQ212.cpp @@ -59,7 +59,6 @@ bool ApogeeSQ212::addSingleMeasurementResult(void) { return bumpMeasurementAttemptCount(false); } - bool success = false; float adcVoltage = -9999.0f; MS_DBG(getSensorNameAndLocation(), F("is reporting:")); @@ -69,8 +68,8 @@ bool ApogeeSQ212::addSingleMeasurementResult(void) { // NOTE: All implementations of the AnalogVoltageBase class validate both // the input channel and the resulting voltage, so we can trust that a // successful read will give us a valid voltage value to work with. - success = _analogVoltageReader->readVoltageSingleEnded(_dataPin, - adcVoltage); + bool success = _analogVoltageReader->readVoltageSingleEnded(_dataPin, + adcVoltage); if (success) { // Apply the calibration factor. diff --git a/src/sensors/ApogeeSQ212.h b/src/sensors/ApogeeSQ212.h index a4ca103d3..ef4b21bb5 100644 --- a/src/sensors/ApogeeSQ212.h +++ b/src/sensors/ApogeeSQ212.h @@ -91,7 +91,9 @@ // Include other in-library and external dependencies #include "VariableBase.h" #include "SensorBase.h" -#include "AnalogVoltageBase.h" + +// Forward declaration +class AnalogVoltageBase; /** @ingroup sensor_sq212 */ /**@{*/ diff --git a/src/sensors/CampbellOBS3.cpp b/src/sensors/CampbellOBS3.cpp index 6057a3d62..2f5f7d4e8 100644 --- a/src/sensors/CampbellOBS3.cpp +++ b/src/sensors/CampbellOBS3.cpp @@ -60,7 +60,6 @@ bool CampbellOBS3::addSingleMeasurementResult(void) { return bumpMeasurementAttemptCount(false); } - bool success = false; float adcVoltage = -9999.0f; MS_DBG(getSensorNameAndLocation(), F("is reporting:")); @@ -74,8 +73,8 @@ bool CampbellOBS3::addSingleMeasurementResult(void) { // NOTE: All implementations of the AnalogVoltageBase class validate both // the input channel and the resulting voltage, so we can trust that a // successful read will give us a valid voltage value to work with. - success = _analogVoltageReader->readVoltageSingleEnded(_dataPin, - adcVoltage); + bool success = _analogVoltageReader->readVoltageSingleEnded(_dataPin, + adcVoltage); if (success) { // Apply the unique calibration curve for the given sensor float calibResult = (_x2_coeff_A * sq(adcVoltage)) + diff --git a/src/sensors/CampbellOBS3.h b/src/sensors/CampbellOBS3.h index 53f5447bf..6da63ae32 100644 --- a/src/sensors/CampbellOBS3.h +++ b/src/sensors/CampbellOBS3.h @@ -82,7 +82,9 @@ // Include other in-library and external dependencies #include "VariableBase.h" #include "SensorBase.h" -#include "AnalogVoltageBase.h" + +// Forward declaration +class AnalogVoltageBase; /** @ingroup sensor_obs3 */ /**@{*/ diff --git a/src/sensors/EverlightALSPT19.cpp b/src/sensors/EverlightALSPT19.cpp index 4706eaf71..8b1b4c18d 100644 --- a/src/sensors/EverlightALSPT19.cpp +++ b/src/sensors/EverlightALSPT19.cpp @@ -76,7 +76,6 @@ bool EverlightALSPT19::addSingleMeasurementResult(void) { return bumpMeasurementAttemptCount(false); } - bool success = false; float adcVoltage = -9999.0f; MS_DBG(getSensorNameAndLocation(), F("is reporting:")); @@ -86,8 +85,8 @@ bool EverlightALSPT19::addSingleMeasurementResult(void) { // NOTE: All implementations of the AnalogVoltageBase class validate both // the input channel and the resulting voltage, so we can trust that a // successful read will give us a valid voltage value to work with. - success = _analogVoltageReader->readVoltageSingleEnded(_dataPin, - adcVoltage); + bool success = _analogVoltageReader->readVoltageSingleEnded(_dataPin, + adcVoltage); if (success) { verifyAndAddMeasurementResult(ALSPT19_VOLTAGE_VAR_NUM, adcVoltage); @@ -107,7 +106,7 @@ bool EverlightALSPT19::addSingleMeasurementResult(void) { // convert volts to current // resistance is entered in kΩ and we want µA - float current_val = (adcVoltage / (_loadResistor * 1000)) * 1e6; + float current_val = (adcVoltage / (_loadResistor * 1000.0f)) * 1e6f; MS_DBG(F(" Current:"), current_val, F("µA")); // convert current to illuminance diff --git a/src/sensors/TIADS1x15.cpp b/src/sensors/TIADS1x15.cpp index f0f059b0d..06be713ab 100644 --- a/src/sensors/TIADS1x15.cpp +++ b/src/sensors/TIADS1x15.cpp @@ -313,13 +313,13 @@ bool TIADS1x15::addSingleMeasurementResult(void) { if (isValidDifferentialPair(_dataPin, _analogReferenceChannel)) { success = readVoltageDifferential(_dataPin, _analogReferenceChannel, resultValue); + } else { if (_analogReferenceChannel >= 0 && _analogReferenceChannel <= 3) { MS_DBG(F(" Warning: reference channel "), _analogReferenceChannel, F(" set but pair is not a valid differential config;" " falling back to single-ended on channel "), _dataPin); } - } else { success = readVoltageSingleEnded(_dataPin, resultValue); } diff --git a/src/sensors/TurnerCyclops.cpp b/src/sensors/TurnerCyclops.cpp index 4c043ec7d..1fba786f5 100644 --- a/src/sensors/TurnerCyclops.cpp +++ b/src/sensors/TurnerCyclops.cpp @@ -61,7 +61,6 @@ bool TurnerCyclops::addSingleMeasurementResult(void) { return bumpMeasurementAttemptCount(false); } - bool success = false; float adcVoltage = -9999.0f; MS_DBG(getSensorNameAndLocation(), F("is reporting:")); @@ -79,8 +78,8 @@ bool TurnerCyclops::addSingleMeasurementResult(void) { // NOTE: All implementations of the AnalogVoltageBase class validate both // the input channel and the resulting voltage, so we can trust that a // successful read will give us a valid voltage value to work with. - success = _analogVoltageReader->readVoltageSingleEnded(_dataPin, - adcVoltage); + bool success = _analogVoltageReader->readVoltageSingleEnded(_dataPin, + adcVoltage); if (success) { // Apply the unique calibration curve for the given sensor float calibResult = (_conc_std / (_volt_std - _volt_blank)) * diff --git a/src/sensors/TurnerCyclops.h b/src/sensors/TurnerCyclops.h index cc0fb0b89..1f8f4fbe7 100644 --- a/src/sensors/TurnerCyclops.h +++ b/src/sensors/TurnerCyclops.h @@ -165,7 +165,9 @@ // Include other in-library and external dependencies #include "VariableBase.h" #include "SensorBase.h" -#include "AnalogVoltageBase.h" + +// Forward declaration +class AnalogVoltageBase; // Sensor Specific Defines /** @ingroup sensor_cyclops */ diff --git a/src/sensors/TurnerTurbidityPlus.h b/src/sensors/TurnerTurbidityPlus.h index 762a180de..2a04c92e6 100644 --- a/src/sensors/TurnerTurbidityPlus.h +++ b/src/sensors/TurnerTurbidityPlus.h @@ -64,7 +64,9 @@ // Include other in-library and external dependencies #include "VariableBase.h" #include "SensorBase.h" -#include "AnalogVoltageBase.h" + +// Forward declaration +class AnalogVoltageBase; /** @ingroup sensor_turbidity_plus */ /**@{*/ From 35303c6a4e399a44ab3fee24b8b6fce1889f967d Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Wed, 25 Feb 2026 14:48:35 -0500 Subject: [PATCH 334/533] no -1 default for getAnalogLocation Signed-off-by: Sara Damiano --- src/sensors/AnalogElecConductivity.cpp | 2 +- src/sensors/AnalogVoltageBase.h | 7 ++++--- src/sensors/ApogeeSQ212.cpp | 2 +- src/sensors/CampbellOBS3.cpp | 2 +- src/sensors/EverlightALSPT19.cpp | 2 +- src/sensors/ProcessorAnalog.cpp | 2 +- src/sensors/ProcessorAnalog.h | 2 +- src/sensors/TIADS1x15.h | 2 +- src/sensors/TurnerCyclops.cpp | 2 +- 9 files changed, 12 insertions(+), 11 deletions(-) diff --git a/src/sensors/AnalogElecConductivity.cpp b/src/sensors/AnalogElecConductivity.cpp index a4cd9ad5b..814d40450 100644 --- a/src/sensors/AnalogElecConductivity.cpp +++ b/src/sensors/AnalogElecConductivity.cpp @@ -41,7 +41,7 @@ AnalogElecConductivity::~AnalogElecConductivity() { String AnalogElecConductivity::getSensorLocation(void) { String sensorLocation; if (_analogVoltageReader != nullptr) { - sensorLocation = _analogVoltageReader->getAnalogLocation(_dataPin); + sensorLocation = _analogVoltageReader->getAnalogLocation(_dataPin, -1); } else { sensorLocation = F("Unknown_AnalogVoltageReader"); } diff --git a/src/sensors/AnalogVoltageBase.h b/src/sensors/AnalogVoltageBase.h index 1bf31dea0..2c30615b9 100644 --- a/src/sensors/AnalogVoltageBase.h +++ b/src/sensors/AnalogVoltageBase.h @@ -172,15 +172,16 @@ class AnalogVoltageBase { * This pure virtual function must be implemented by derived classes to * provide their specific sensor location identification string. * - * @param analogChannel The primary analog channel for differential - * measurement. + * @param analogChannel The primary analog channel (primary channel for + * differential measurements, or the sole channel for single-ended + * measurements). * @param analogReferenceChannel The secondary (reference) analog channel * for differential measurement. Optional with a default of -1. * * @return A string describing the analog sensor location */ virtual String getAnalogLocation(int8_t analogChannel, - int8_t analogReferenceChannel = -1) = 0; + int8_t analogReferenceChannel) = 0; protected: /** diff --git a/src/sensors/ApogeeSQ212.cpp b/src/sensors/ApogeeSQ212.cpp index dfbde8ca8..4017a28f3 100644 --- a/src/sensors/ApogeeSQ212.cpp +++ b/src/sensors/ApogeeSQ212.cpp @@ -39,7 +39,7 @@ ApogeeSQ212::~ApogeeSQ212() { String ApogeeSQ212::getSensorLocation(void) { if (_analogVoltageReader != nullptr) { - return _analogVoltageReader->getAnalogLocation(_dataPin); + return _analogVoltageReader->getAnalogLocation(_dataPin, -1); } else { return String("Unknown_AnalogVoltageReader"); } diff --git a/src/sensors/CampbellOBS3.cpp b/src/sensors/CampbellOBS3.cpp index 2f5f7d4e8..ea24cc377 100644 --- a/src/sensors/CampbellOBS3.cpp +++ b/src/sensors/CampbellOBS3.cpp @@ -40,7 +40,7 @@ CampbellOBS3::~CampbellOBS3() { String CampbellOBS3::getSensorLocation(void) { if (_analogVoltageReader != nullptr) { - return _analogVoltageReader->getAnalogLocation(_dataPin); + return _analogVoltageReader->getAnalogLocation(_dataPin, -1); } else { return String("Unknown_AnalogVoltageReader"); } diff --git a/src/sensors/EverlightALSPT19.cpp b/src/sensors/EverlightALSPT19.cpp index 8b1b4c18d..4b953b711 100644 --- a/src/sensors/EverlightALSPT19.cpp +++ b/src/sensors/EverlightALSPT19.cpp @@ -50,7 +50,7 @@ EverlightALSPT19::~EverlightALSPT19() { String EverlightALSPT19::getSensorLocation(void) { if (_analogVoltageReader != nullptr) { - return _analogVoltageReader->getAnalogLocation(_dataPin); + return _analogVoltageReader->getAnalogLocation(_dataPin, -1); } else { return String("Unknown_AnalogVoltageReader"); } diff --git a/src/sensors/ProcessorAnalog.cpp b/src/sensors/ProcessorAnalog.cpp index 249a8f3c7..f3b9d3290 100644 --- a/src/sensors/ProcessorAnalog.cpp +++ b/src/sensors/ProcessorAnalog.cpp @@ -102,7 +102,7 @@ ProcessorAnalog::ProcessorAnalog(int8_t powerPin, int8_t dataPin, ProcessorAnalog::~ProcessorAnalog() {} String ProcessorAnalog::getSensorLocation() { - return ProcessorAnalogBase::getAnalogLocation(_dataPin); + return ProcessorAnalogBase::getAnalogLocation(_dataPin, -1); } bool ProcessorAnalog::addSingleMeasurementResult(void) { diff --git a/src/sensors/ProcessorAnalog.h b/src/sensors/ProcessorAnalog.h index 0a85165ba..22a791279 100644 --- a/src/sensors/ProcessorAnalog.h +++ b/src/sensors/ProcessorAnalog.h @@ -212,7 +212,7 @@ class ProcessorAnalogBase : public AnalogVoltageBase { float& resultValue) override; String getAnalogLocation(int8_t analogChannel, - int8_t analogReferenceChannel = -1) override; + int8_t analogReferenceChannel) override; }; /* clang-format off */ diff --git a/src/sensors/TIADS1x15.h b/src/sensors/TIADS1x15.h index 81941eccb..fc548c13e 100644 --- a/src/sensors/TIADS1x15.h +++ b/src/sensors/TIADS1x15.h @@ -313,7 +313,7 @@ class TIADS1x15Base : public AnalogVoltageBase { float& resultValue) override; String getAnalogLocation(int8_t analogChannel, - int8_t analogReferenceChannel = -1) override; + int8_t analogReferenceChannel) override; /** * @brief Set the internal gain setting for the ADS1x15 diff --git a/src/sensors/TurnerCyclops.cpp b/src/sensors/TurnerCyclops.cpp index 1fba786f5..bd5d3a1a8 100644 --- a/src/sensors/TurnerCyclops.cpp +++ b/src/sensors/TurnerCyclops.cpp @@ -41,7 +41,7 @@ TurnerCyclops::~TurnerCyclops() { String TurnerCyclops::getSensorLocation(void) { if (_analogVoltageReader != nullptr) { - return _analogVoltageReader->getAnalogLocation(_dataPin); + return _analogVoltageReader->getAnalogLocation(_dataPin, -1); } else { return String("Unknown_AnalogVoltageReader"); } From 56e02fbc79081753578ab483eb816c27faa61679 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Wed, 25 Feb 2026 15:18:57 -0500 Subject: [PATCH 335/533] Doc that default readers are for back compatibility Signed-off-by: Sara Damiano --- src/sensors/AlphasenseCO2.h | 9 +++++---- src/sensors/AnalogElecConductivity.h | 7 ++++--- src/sensors/AnalogVoltageBase.h | 2 +- src/sensors/ApogeeSQ212.h | 7 ++++--- src/sensors/CampbellOBS3.h | 7 ++++--- src/sensors/EverlightALSPT19.h | 14 ++++++++------ src/sensors/TurnerCyclops.h | 7 ++++--- src/sensors/TurnerTurbidityPlus.h | 7 ++++--- 8 files changed, 34 insertions(+), 26 deletions(-) diff --git a/src/sensors/AlphasenseCO2.h b/src/sensors/AlphasenseCO2.h index bbb8ae2f5..cd83f07c0 100644 --- a/src/sensors/AlphasenseCO2.h +++ b/src/sensors/AlphasenseCO2.h @@ -282,9 +282,10 @@ class AlphasenseCO2 : public Sensor { * default value of 7. * @param analogVoltageReader Pointer to an AnalogVoltageBase object for * voltage measurements. Pass nullptr (the default) to have the constructor - * internally create and own a TIADS1x15Base instance. If a non-null - * pointer is supplied, the caller retains ownership and must ensure its - * lifetime exceeds that of this object. + * internally create and own an analog voltage reader. For backward + * compatibility, the default reader uses a TI ADS1115 or ADS10115. If a + * non-null pointer is supplied, the caller retains ownership and must + * ensure its lifetime exceeds that of this object. * * @warning In library versions 0.37.0 and earlier, a different constructor * was used that required an enum object instead of two different analog @@ -320,7 +321,7 @@ class AlphasenseCO2 : public Sensor { /** * @brief The second (reference) pin for differential voltage measurements. */ - int8_t _analogReferenceChannel; + int8_t _analogReferenceChannel = -1; /// @brief Pointer to analog voltage reader AnalogVoltageBase* _analogVoltageReader = nullptr; /// @brief Flag to track if this object owns the analog voltage reader and diff --git a/src/sensors/AnalogElecConductivity.h b/src/sensors/AnalogElecConductivity.h index 97984cf75..15f9c9c41 100644 --- a/src/sensors/AnalogElecConductivity.h +++ b/src/sensors/AnalogElecConductivity.h @@ -316,9 +316,10 @@ class AnalogElecConductivity : public Sensor { * optional with default value of 1. * @param analogVoltageReader Pointer to an AnalogVoltageBase object for * voltage measurements. Pass nullptr (the default) to have the constructor - * internally create and own a ProcessorAnalogBase instance. If a non-null - * pointer is supplied, the caller retains ownership and must ensure its - * lifetime exceeds that of this object. + * internally create and own an analog voltage reader. For backward + * compatibility, the default reader uses the processor's internal ADC. If a + * non-null pointer is supplied, the caller retains ownership and must + * ensure its lifetime exceeds that of this object. */ AnalogElecConductivity( int8_t powerPin, int8_t dataPin, diff --git a/src/sensors/AnalogVoltageBase.h b/src/sensors/AnalogVoltageBase.h index 2c30615b9..4f1820485 100644 --- a/src/sensors/AnalogVoltageBase.h +++ b/src/sensors/AnalogVoltageBase.h @@ -176,7 +176,7 @@ class AnalogVoltageBase { * differential measurements, or the sole channel for single-ended * measurements). * @param analogReferenceChannel The secondary (reference) analog channel - * for differential measurement. Optional with a default of -1. + * for differential measurement. Use -1 for a single-ended analog sensor. * * @return A string describing the analog sensor location */ diff --git a/src/sensors/ApogeeSQ212.h b/src/sensors/ApogeeSQ212.h index ef4b21bb5..d7455b9c0 100644 --- a/src/sensors/ApogeeSQ212.h +++ b/src/sensors/ApogeeSQ212.h @@ -260,9 +260,10 @@ class ApogeeSQ212 : public Sensor { * default value of 1. * @param analogVoltageReader Pointer to an AnalogVoltageBase object for * voltage measurements. Pass nullptr (the default) to have the constructor - * allocate a TIADS1x15Base object automatically (owned and deleted by this - * instance). If a non-null pointer is supplied, the caller retains - * ownership and must ensure its lifetime exceeds that of this object. + * internally create and own an analog voltage reader. For backward + * compatibility, the default reader uses a TI ADS1115 or ADS10115. If a + * non-null pointer is supplied, the caller retains ownership and must + * ensure its lifetime exceeds that of this object. */ ApogeeSQ212(int8_t powerPin, int8_t analogChannel, uint8_t measurementsToAverage = 1, diff --git a/src/sensors/CampbellOBS3.h b/src/sensors/CampbellOBS3.h index 6da63ae32..6251138e7 100644 --- a/src/sensors/CampbellOBS3.h +++ b/src/sensors/CampbellOBS3.h @@ -257,9 +257,10 @@ class CampbellOBS3 : public Sensor { * default value of 1. * @param analogVoltageReader Pointer to an AnalogVoltageBase object for * voltage measurements. Pass nullptr (the default) to have the constructor - * internally create and own a TIADS1x15Base instance. If a non-null - * pointer is supplied, the caller retains ownership and must ensure its - * lifetime exceeds that of this object. + * internally create and own an analog voltage reader. For backward + * compatibility, the default reader uses a TI ADS1115 or ADS10115. If a + * non-null pointer is supplied, the caller retains ownership and must + * ensure its lifetime exceeds that of this object. */ CampbellOBS3(int8_t powerPin, int8_t analogChannel, float x2_coeff_A, float x1_coeff_B, float x0_coeff_C, diff --git a/src/sensors/EverlightALSPT19.h b/src/sensors/EverlightALSPT19.h index 13d05ce39..324b1ca3d 100644 --- a/src/sensors/EverlightALSPT19.h +++ b/src/sensors/EverlightALSPT19.h @@ -261,9 +261,10 @@ class EverlightALSPT19 : public Sensor { * default value of 10. * @param analogVoltageReader Pointer to an AnalogVoltageBase object for * voltage measurements. Pass nullptr (the default) to have the constructor - * internally create and own a ProcessorAnalogBase instance. If a non-null - * pointer is supplied, the caller retains ownership and must ensure its - * lifetime exceeds that of this object. + * internally create and own an analog voltage reader. For backward + * compatibility, the default reader uses the processor's internal ADC. If a + * non-null pointer is supplied, the caller retains ownership and must + * ensure its lifetime exceeds that of this object. */ EverlightALSPT19(int8_t powerPin, int8_t dataPin, float alsSupplyVoltage, float loadResistor, uint8_t measurementsToAverage = 10, @@ -286,9 +287,10 @@ class EverlightALSPT19 : public Sensor { * default value of 10. * @param analogVoltageReader Pointer to an AnalogVoltageBase object for * voltage measurements. Pass nullptr (the default) to have the constructor - * internally create and own a ProcessorAnalogBase instance. If a non-null - * pointer is supplied, the caller retains ownership and must ensure its - * lifetime exceeds that of this object. + * internally create and own an analog voltage reader. For backward + * compatibility, the default reader uses the processor's internal ADC. If a + * non-null pointer is supplied, the caller retains ownership and must + * ensure its lifetime exceeds that of this object. */ explicit EverlightALSPT19(uint8_t measurementsToAverage = 10, AnalogVoltageBase* analogVoltageReader = nullptr); diff --git a/src/sensors/TurnerCyclops.h b/src/sensors/TurnerCyclops.h index 1f8f4fbe7..20285a7ff 100644 --- a/src/sensors/TurnerCyclops.h +++ b/src/sensors/TurnerCyclops.h @@ -346,9 +346,10 @@ class TurnerCyclops : public Sensor { * default value of 1. * @param analogVoltageReader Pointer to an AnalogVoltageBase object for * voltage measurements. Pass nullptr (the default) to have the constructor - * internally create and own a TIADS1x15Base instance. If a non-null - * pointer is supplied, the caller retains ownership and must ensure its - * lifetime exceeds that of this object. + * internally create and own an analog voltage reader. For backward + * compatibility, the default reader uses a TI ADS1115 or ADS10115. If a + * non-null pointer is supplied, the caller retains ownership and must + * ensure its lifetime exceeds that of this object. */ TurnerCyclops(int8_t powerPin, int8_t analogChannel, float conc_std, float volt_std, float volt_blank, diff --git a/src/sensors/TurnerTurbidityPlus.h b/src/sensors/TurnerTurbidityPlus.h index 2a04c92e6..2e3e6598f 100644 --- a/src/sensors/TurnerTurbidityPlus.h +++ b/src/sensors/TurnerTurbidityPlus.h @@ -236,9 +236,10 @@ class TurnerTurbidityPlus : public Sensor { * default value of 1. * @param analogVoltageReader Pointer to an AnalogVoltageBase object for * voltage measurements. Pass nullptr (the default) to have the constructor - * internally create and own a TIADS1x15Base instance. If a non-null - * pointer is supplied, the caller retains ownership and must ensure its - * lifetime exceeds that of this object. + * internally create and own an analog voltage reader. For backward + * compatibility, the default reader uses a TI ADS1115 or ADS10115. If a + * non-null pointer is supplied, the caller retains ownership and must + * ensure its lifetime exceeds that of this object. * * @attention For 3.3V processors like the Mayfly, The Turner's 0-5V output * signal must be shifted down to a maximum of 3.3V. This can be done either From 2c320f913d645595ec85801993245de99934e8f6 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Wed, 25 Feb 2026 15:19:27 -0500 Subject: [PATCH 336/533] Rename macro Signed-off-by: Sara Damiano --- src/sensors/EverlightALSPT19.cpp | 2 +- src/sensors/EverlightALSPT19.h | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/sensors/EverlightALSPT19.cpp b/src/sensors/EverlightALSPT19.cpp index 4b953b711..7dae0e8a8 100644 --- a/src/sensors/EverlightALSPT19.cpp +++ b/src/sensors/EverlightALSPT19.cpp @@ -111,7 +111,7 @@ bool EverlightALSPT19::addSingleMeasurementResult(void) { // convert current to illuminance // from sensor datasheet, typical 200µA current for 1000 Lux - float calibResult = current_val * (1000.0f / ALSPT19_CURRENT_PER_LUX); + float calibResult = current_val * (1000.0f / ALSPT19_UA_PER_1000LUX); MS_DBG(F(" Illuminance:"), calibResult, F("lux")); verifyAndAddMeasurementResult(ALSPT19_CURRENT_VAR_NUM, current_val); diff --git a/src/sensors/EverlightALSPT19.h b/src/sensors/EverlightALSPT19.h index 324b1ca3d..a547832bb 100644 --- a/src/sensors/EverlightALSPT19.h +++ b/src/sensors/EverlightALSPT19.h @@ -29,7 +29,7 @@ * [Datasheet](https://github.com/EnviroDIY/ModularSensors/wiki/Sensor-Datasheets/Everlight-ALS-PT19.pdf) * * @section sensor_alspt19_config_flags Build flags - * - `-D ALSPT19_CURRENT_PER_LUX=##` + * - `-D ALSPT19_UA_PER_1000LUX=##` * - used to set current equivalent to 1000lux, which is used to calculate * lux from the sensor * @@ -99,7 +99,7 @@ * Define for the ALS calibration between current and lux. */ /**@{*/ -#if !defined(ALSPT19_CURRENT_PER_LUX) || defined(DOXYGEN) +#if !defined(ALSPT19_UA_PER_1000LUX) || defined(DOXYGEN) /** * @brief The default current (in µA) that is equivalent to 1000 lux of * illuminance. @@ -115,8 +115,8 @@ * @todo Find the source of the calibration of typical 200µA current for 1000 * Lux, which doesn't appear to align with the datasheet. */ -#define ALSPT19_CURRENT_PER_LUX 200.0f -#endif // ALSPT19_CURRENT_PER_LUX +#define ALSPT19_UA_PER_1000LUX 200.0f +#endif // !defined(ALSPT19_UA_PER_1000LUX) || defined(DOXYGEN) /**@}*/ /** From ca0da38b46b99682bf85d570ecc84af644061e66 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Wed, 25 Feb 2026 15:44:28 -0500 Subject: [PATCH 337/533] Refactor TIADS1x15Base to store and configure internal _ads, move params there when possible, make data rate settable Signed-off-by: Sara Damiano --- src/sensors/TIADS1x15.cpp | 138 ++++++++++++++++++-------------------- src/sensors/TIADS1x15.h | 37 ++++++++-- 2 files changed, 98 insertions(+), 77 deletions(-) diff --git a/src/sensors/TIADS1x15.cpp b/src/sensors/TIADS1x15.cpp index 06be713ab..65a60ee4c 100644 --- a/src/sensors/TIADS1x15.cpp +++ b/src/sensors/TIADS1x15.cpp @@ -21,9 +21,9 @@ // Constructor TIADS1x15Base::TIADS1x15Base(float voltageMultiplier, adsGain_t adsGain, - uint8_t i2cAddress, float adsSupplyVoltage) + uint8_t i2cAddress, float adsSupplyVoltage, + uint16_t adsDataRate) : AnalogVoltageBase(voltageMultiplier, adsSupplyVoltage), - _adsGain(adsGain), _i2cAddress(i2cAddress) { // Clamp supply voltage to valid ADS1x15 range: 0.0V to 5.5V per datasheet // NOTE: This clamp is intentionally silent — Serial/MS_DBG is NOT safe to @@ -34,6 +34,21 @@ TIADS1x15Base::TIADS1x15Base(float voltageMultiplier, adsGain_t adsGain, } else if (_supplyVoltage > 5.5f) { _supplyVoltage = 5.5f; } + // ADS Library default settings: + // - TI ADS1115 (16 bit) + // - single-shot mode (powers down between conversions) + // - 128 samples per second (8ms conversion time) + // - 2/3 gain +/- 6.144V range (limited to VDD +0.3V max) + // - TI ADS1015 (12 bit) + // - single-shot mode (powers down between conversions) + // - 1600 samples per second (625µs conversion time) + // - 2/3 gain +/- 6.144V range (limited to VDD +0.3V max) + + // Initialize the per-instance ADS driver + _ads.setGain(adsGain); + _ads.setDataRate(adsDataRate); + + _ads.begin(_i2cAddress); } @@ -69,30 +84,12 @@ bool TIADS1x15Base::readVoltageSingleEnded(int8_t analogChannel, float adcVoltage = -9999.0f; float scaledResult = -9999.0f; -// Create an auxiliary ADC object -// We create and set up the ADC object here so that each sensor using -// the ADC may set the internal gain appropriately without affecting others. -#ifndef MS_USE_ADS1015 - Adafruit_ADS1115 ads; // Use this for the 16-bit version -#else - Adafruit_ADS1015 ads; // Use this for the 12-bit version -#endif - // ADS Library default settings: - // - TI ADS1115 (16 bit) - // - single-shot mode (powers down between conversions) - // - 128 samples per second (8ms conversion time) - // - 2/3 gain +/- 6.144V range (limited to VDD +0.3V max) - // - TI ADS1015 (12 bit) - // - single-shot mode (powers down between conversions) - // - 1600 samples per second (625µs conversion time) - // - 2/3 gain +/- 6.144V range (limited to VDD +0.3V max) + // Use the per-instance ADS driver (gain configured in constructor) - // Set the internal gain according to user configuration - ads.setGain(_adsGain); - // Begin ADC, returns true if anything was detected at the address - if (!ads.begin(_i2cAddress)) { - MS_DBG(F(" ADC initialization failed at 0x"), - String(_i2cAddress, HEX)); + // Verify ADC is available (already initialized in constructor) + // Note: The ADS driver may return false if I2C communication fails + if (!_ads.begin(_i2cAddress)) { + MS_DBG(F(" ADC communication failed at 0x"), String(_i2cAddress, HEX)); return false; } @@ -105,21 +102,31 @@ bool TIADS1x15Base::readVoltageSingleEnded(int8_t analogChannel, } // Taking this reading includes the 8ms conversion delay. // Measure the ADC raw count - adcCounts = ads.readADC_SingleEnded(analogChannel); + adcCounts = _ads.readADC_SingleEnded(analogChannel); // Convert ADC raw counts value to voltage (V) - adcVoltage = ads.computeVolts(adcCounts); - MS_DBG(F(" ads.readADC_SingleEnded("), analogChannel, F("):"), adcCounts, + adcVoltage = _ads.computeVolts(adcCounts); + MS_DBG(F(" _ads.readADC_SingleEnded("), analogChannel, F("):"), adcCounts, F(" voltage:"), adcVoltage); - // Verify the range based on the actual power supplied to the ADS. - // Valid range is approximately -0.3V to (supply voltage + 0.3V) with - // absolute maximum of 5.5V per datasheet - float minValidVoltage = -0.3f; - float maxValidVoltage = _supplyVoltage + 0.3f; - if (maxValidVoltage > 5.5f) { - maxValidVoltage = 5.5f; // Absolute maximum per datasheet - } + + // Verify the range based on both PGA full-scale range and supply voltage + // For single-ended measurements, the valid range is constrained by: + // 1. PGA full-scale range (±FSR based on gain setting) + // 2. Supply voltage limits (approximately -0.3V to supply+0.3V) + // 3. Absolute maximum of 5.5V per datasheet + + float pgaFullScaleRange = _ads.getFsRange(); + float minValidVoltage = -0.3f; // Per datasheet + + // Take the minimum of PGA FSR and supply-based limit + float maxValidVoltage = pgaFullScaleRange; + float supplyBasedMax = _supplyVoltage + 0.3f; + if (supplyBasedMax < maxValidVoltage) { maxValidVoltage = supplyBasedMax; } + + // Apply absolute maximum per datasheet + if (maxValidVoltage > 5.5f) { maxValidVoltage = 5.5f; } MS_DBG(F(" ADS supply voltage:"), _supplyVoltage, F("V")); + MS_DBG(F(" PGA full-scale range:"), pgaFullScaleRange, F("V")); MS_DBG(F(" Valid voltage range:"), minValidVoltage, F("V to"), maxValidVoltage, F("V")); @@ -145,19 +152,10 @@ bool TIADS1x15Base::readVoltageDifferential(int8_t analogChannel, float adcVoltage = -9999.0f; float scaledResult = -9999.0f; -// Create an auxiliary ADC object -#ifndef MS_USE_ADS1015 - Adafruit_ADS1115 ads; -#else - Adafruit_ADS1015 ads; -#endif - - // Set the internal gain according to user configuration - ads.setGain(_adsGain); - - if (!ads.begin(_i2cAddress)) { - MS_DBG(F(" ADC initialization failed at 0x"), - String(_i2cAddress, HEX)); + // Use the per-instance ADS driver (configured in constructor) + // Verify ADC is available + if (!_ads.begin(_i2cAddress)) { + MS_DBG(F(" ADC communication failed at 0x"), String(_i2cAddress, HEX)); return false; } @@ -174,13 +172,13 @@ bool TIADS1x15Base::readVoltageDifferential(int8_t analogChannel, // first) to ensure consistent polarity. Pairs like (1,0) are NOT supported // - use (0,1) instead. if (analogChannel == 0 && analogReferenceChannel == 1) { - adcCounts = ads.readADC_Differential_0_1(); + adcCounts = _ads.readADC_Differential_0_1(); } else if (analogChannel == 0 && analogReferenceChannel == 3) { - adcCounts = ads.readADC_Differential_0_3(); + adcCounts = _ads.readADC_Differential_0_3(); } else if (analogChannel == 1 && analogReferenceChannel == 3) { - adcCounts = ads.readADC_Differential_1_3(); + adcCounts = _ads.readADC_Differential_1_3(); } else if (analogChannel == 2 && analogReferenceChannel == 3) { - adcCounts = ads.readADC_Differential_2_3(); + adcCounts = _ads.readADC_Differential_2_3(); } else { // Should never reach here; isValidDifferentialPair must have been // widened without updating this dispatch table. @@ -190,26 +188,13 @@ bool TIADS1x15Base::readVoltageDifferential(int8_t analogChannel, } // Convert counts to voltage - adcVoltage = ads.computeVolts(adcCounts); + adcVoltage = _ads.computeVolts(adcCounts); MS_DBG(F(" Differential ADC counts:"), adcCounts, F(" voltage:"), adcVoltage); // Validate range - for differential measurements, use PGA full-scale range // Based on gain setting rather than supply voltage - float fullScaleVoltage; - switch (_adsGain) { - case GAIN_TWOTHIRDS: fullScaleVoltage = 6.144f; break; - case GAIN_ONE: fullScaleVoltage = 4.096f; break; - case GAIN_TWO: fullScaleVoltage = 2.048f; break; - case GAIN_FOUR: fullScaleVoltage = 1.024f; break; - case GAIN_EIGHT: fullScaleVoltage = 0.512f; break; - case GAIN_SIXTEEN: fullScaleVoltage = 0.256f; break; - default: - MS_DBG(F(" Unknown ADS gain value:"), _adsGain, - F(" using conservative 4.096V range")); - fullScaleVoltage = 4.096f; // Conservative fallback - break; - } + float fullScaleVoltage = _ads.getFsRange(); float minValidVoltage = -fullScaleVoltage; float maxValidVoltage = fullScaleVoltage; @@ -244,11 +229,22 @@ bool TIADS1x15Base::isValidDifferentialPair(int8_t channel1, int8_t channel2) { // Setter and getter methods for ADS gain void TIADS1x15Base::setADSGain(adsGain_t adsGain) { - _adsGain = adsGain; + // Update the per-instance driver with new gain setting + _ads.setGain(adsGain); +} + +adsGain_t TIADS1x15Base::getADSGain(void) { + return _ads.getGain(); +} + +// Setter and getter methods for ADS data rate +void TIADS1x15Base::setADSDataRate(uint16_t adsDataRate) { + // Update the per-instance driver with new data rate setting + _ads.setDataRate(adsDataRate); } -adsGain_t TIADS1x15Base::getADSGain(void) const { - return _adsGain; +uint16_t TIADS1x15Base::getADSDataRate(void) { + return _ads.getDataRate(); } // Override setSupplyVoltage in TIADS1x15Base to validate ADS range diff --git a/src/sensors/TIADS1x15.h b/src/sensors/TIADS1x15.h index fc548c13e..eb600c0e5 100644 --- a/src/sensors/TIADS1x15.h +++ b/src/sensors/TIADS1x15.h @@ -271,11 +271,18 @@ class TIADS1x15Base : public AnalogVoltageBase { * @param adsGain The internal gain setting of the ADS1x15 * @param i2cAddress The I2C address of the ADS 1x15 * @param adsSupplyVoltage The power supply voltage for the ADS1x15 in volts + * @param adsDataRate The data rate for the ADS1x15 (samples per second) */ explicit TIADS1x15Base(float voltageMultiplier = 1.0f, adsGain_t adsGain = GAIN_ONE, uint8_t i2cAddress = MS_DEFAULT_ADS1X15_ADDRESS, - float adsSupplyVoltage = OPERATING_VOLTAGE); + float adsSupplyVoltage = OPERATING_VOLTAGE, +#ifndef MS_USE_ADS1015 + uint16_t adsDataRate = RATE_ADS1115_128SPS +#else + uint16_t adsDataRate = RATE_ADS1015_1600SPS +#endif + ); /** * @brief Destroy the TIADS1x15Base object @@ -328,7 +335,21 @@ class TIADS1x15Base : public AnalogVoltageBase { * * @return The internal gain setting */ - adsGain_t getADSGain(void) const; + adsGain_t getADSGain(void); + + /** + * @brief Set the data rate for the ADS1x15 + * + * @param adsDataRate The data rate setting (samples per second) + */ + void setADSDataRate(uint16_t adsDataRate); + + /** + * @brief Get the data rate for the ADS1x15 + * + * @return The data rate setting (samples per second) + */ + uint16_t getADSDataRate(void); /** * @brief Check if the two channels form a valid differential pair @@ -354,14 +375,18 @@ class TIADS1x15Base : public AnalogVoltageBase { void setSupplyVoltage(float supplyVoltage) override; protected: - /** - * @brief Internal reference to the internal gain setting of the TI-ADS1x15 - */ - adsGain_t _adsGain; /** * @brief Internal reference to the I2C address of the TI-ADS1x15 */ uint8_t _i2cAddress; + /** + * @brief Per-instance ADS1x15 driver to maintain separate I2C state + */ +#ifndef MS_USE_ADS1015 + Adafruit_ADS1115 _ads; // 16-bit version +#else + Adafruit_ADS1015 _ads; // 12-bit version +#endif }; /* clang-format off */ From a3aaf415064312c3081d093fc8c6a85080b8ea8b Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Wed, 25 Feb 2026 15:45:38 -0500 Subject: [PATCH 338/533] Have ProcessorAnalog and TIADS1x15 take pointers to simplify ctors Signed-off-by: Sara Damiano --- src/sensors/ProcessorAnalog.cpp | 29 +++++++++++++++++------- src/sensors/ProcessorAnalog.h | 28 +++++++++++++++-------- src/sensors/TIADS1x15.cpp | 31 +++++++++++++++++-------- src/sensors/TIADS1x15.h | 40 ++++++++++++++++----------------- 4 files changed, 81 insertions(+), 47 deletions(-) diff --git a/src/sensors/ProcessorAnalog.cpp b/src/sensors/ProcessorAnalog.cpp index f3b9d3290..b783d742a 100644 --- a/src/sensors/ProcessorAnalog.cpp +++ b/src/sensors/ProcessorAnalog.cpp @@ -88,21 +88,34 @@ bool ProcessorAnalogBase::readVoltageDifferential( // The constructor - need the power pin, the data pin, the voltage divider // value, and the operating voltage ProcessorAnalog::ProcessorAnalog(int8_t powerPin, int8_t dataPin, - float voltageMultiplier, - float operatingVoltage, - uint8_t measurementsToAverage) + uint8_t measurementsToAverage, + ProcessorAnalogBase* analogBase) : Sensor("ProcessorAnalog", PROCESSOR_ANALOG_NUM_VARIABLES, PROCESSOR_ANALOG_WARM_UP_TIME_MS, PROCESSOR_ANALOG_STABILIZATION_TIME_MS, PROCESSOR_ANALOG_MEASUREMENT_TIME_MS, powerPin, dataPin, - measurementsToAverage, PROCESSOR_ANALOG_INC_CALC_VARIABLES), - ProcessorAnalogBase(voltageMultiplier, operatingVoltage) {} + measurementsToAverage, PROCESSOR_ANALOG_INC_CALC_VARIABLES) { + // If no analog base provided, create one with default settings + if (analogBase == nullptr) { + _analogBase = new ProcessorAnalogBase(); + _ownsAnalogBase = true; + } else { + _analogBase = analogBase; + _ownsAnalogBase = false; + } +} // Destructor -ProcessorAnalog::~ProcessorAnalog() {} +ProcessorAnalog::~ProcessorAnalog() { + // Clean up the analog base object if we created it + if (_ownsAnalogBase && _analogBase != nullptr) { + delete _analogBase; + _analogBase = nullptr; + } +} String ProcessorAnalog::getSensorLocation() { - return ProcessorAnalogBase::getAnalogLocation(_dataPin, -1); + return _analogBase->getAnalogLocation(_dataPin, -1); } bool ProcessorAnalog::addSingleMeasurementResult(void) { @@ -114,7 +127,7 @@ bool ProcessorAnalog::addSingleMeasurementResult(void) { MS_DBG(getSensorNameAndLocation(), F("is reporting:")); float resultValue = -9999.0f; - bool success = readVoltageSingleEnded(_dataPin, resultValue); + bool success = _analogBase->readVoltageSingleEnded(_dataPin, resultValue); if (success) { verifyAndAddMeasurementResult(PROCESSOR_ANALOG_VAR_NUM, resultValue); diff --git a/src/sensors/ProcessorAnalog.h b/src/sensors/ProcessorAnalog.h index 22a791279..452c98a87 100644 --- a/src/sensors/ProcessorAnalog.h +++ b/src/sensors/ProcessorAnalog.h @@ -223,7 +223,7 @@ class ProcessorAnalogBase : public AnalogVoltageBase { * @ingroup sensor_processor_analog */ /* clang-format on */ -class ProcessorAnalog : public Sensor, public ProcessorAnalogBase { +class ProcessorAnalog : public Sensor { public: /** * @brief Construct a new Processor Analog object - need the power pin and @@ -235,19 +235,16 @@ class ProcessorAnalog : public Sensor, public ProcessorAnalogBase { * all processor pins can be used as analog pins. Those usable as analog * pins generally are numbered with an "A" in front of the number * - ie, A1. - * @param voltageMultiplier Any multiplier needed to convert raw battery - * readings from `analogRead()` into true battery values based on any - * resistors or voltage dividers - * @param operatingVoltage The processor's operating voltage; most - * likely 3.3 or 5. * @param measurementsToAverage The number of measurements to take and * average before giving a "final" result from the sensor; optional with a * default value of 1. + * @param analogBase Pointer to ProcessorAnalogBase object for analog + * functionality. If nullptr (default), creates a new ProcessorAnalogBase + * with default settings. */ ProcessorAnalog(int8_t powerPin, int8_t dataPin, - float voltageMultiplier = 1.0f, - float operatingVoltage = OPERATING_VOLTAGE, - uint8_t measurementsToAverage = 1); + uint8_t measurementsToAverage = 1, + ProcessorAnalogBase* analogBase = nullptr); /** * @brief Destroy the Processor Analog object */ @@ -256,6 +253,19 @@ class ProcessorAnalog : public Sensor, public ProcessorAnalogBase { String getSensorLocation(void) override; bool addSingleMeasurementResult(void) override; + + private: + /** + * @brief Pointer to the ProcessorAnalogBase object providing analog + * functionality + */ + ProcessorAnalogBase* _analogBase = nullptr; + + /** + * @brief Whether this object owns the _analogBase pointer and should delete + * it + */ + bool _ownsAnalogBase = false; }; diff --git a/src/sensors/TIADS1x15.cpp b/src/sensors/TIADS1x15.cpp index 65a60ee4c..0aa5f50a5 100644 --- a/src/sensors/TIADS1x15.cpp +++ b/src/sensors/TIADS1x15.cpp @@ -270,15 +270,22 @@ void TIADS1x15Base::setSupplyVoltage(float supplyVoltage) { // The constructor - need the power pin the data pin, and voltage multiplier if // non standard TIADS1x15::TIADS1x15(int8_t powerPin, int8_t adsChannel, - float voltageMultiplier, adsGain_t adsGain, - uint8_t i2cAddress, uint8_t measurementsToAverage, - float adsSupplyVoltage, int8_t analogReferenceChannel) + int8_t analogReferenceChannel, uint8_t measurementsToAverage, + TIADS1x15Base* adsBase) : Sensor("TIADS1x15", TIADS1X15_NUM_VARIABLES, TIADS1X15_WARM_UP_TIME_MS, TIADS1X15_STABILIZATION_TIME_MS, TIADS1X15_MEASUREMENT_TIME_MS, powerPin, adsChannel, measurementsToAverage, TIADS1X15_INC_CALC_VARIABLES), - TIADS1x15Base(voltageMultiplier, adsGain, i2cAddress, adsSupplyVoltage), _analogReferenceChannel(analogReferenceChannel) { + // If no ADS base provided, create one with default settings + if (adsBase == nullptr) { + _adsBase = new TIADS1x15Base(); + _ownsAdsBase = true; + } else { + _adsBase = adsBase; + _ownsAdsBase = false; + } + // NOTE: We DO NOT validate the channel numbers and pairings in this // constructor! We CANNOT print a warning here about invalid channel // because the Serial object may not be initialized yet, and we don't want @@ -288,10 +295,16 @@ TIADS1x15::TIADS1x15(int8_t powerPin, int8_t adsChannel, } // Destructor -TIADS1x15::~TIADS1x15() {} +TIADS1x15::~TIADS1x15() { + // Clean up the ADS base object if we created it + if (_ownsAdsBase && _adsBase != nullptr) { + delete _adsBase; + _adsBase = nullptr; + } +} String TIADS1x15::getSensorLocation(void) { - return TIADS1x15Base::getAnalogLocation(_dataPin, _analogReferenceChannel); + return _adsBase->getAnalogLocation(_dataPin, _analogReferenceChannel); } bool TIADS1x15::addSingleMeasurementResult(void) { @@ -306,8 +319,8 @@ bool TIADS1x15::addSingleMeasurementResult(void) { bool success = false; // Use differential or single-ended reading based on configuration - if (isValidDifferentialPair(_dataPin, _analogReferenceChannel)) { - success = readVoltageDifferential(_dataPin, _analogReferenceChannel, + if (_adsBase->isValidDifferentialPair(_dataPin, _analogReferenceChannel)) { + success = _adsBase->readVoltageDifferential(_dataPin, _analogReferenceChannel, resultValue); } else { if (_analogReferenceChannel >= 0 && _analogReferenceChannel <= 3) { @@ -316,7 +329,7 @@ bool TIADS1x15::addSingleMeasurementResult(void) { " falling back to single-ended on channel "), _dataPin); } - success = readVoltageSingleEnded(_dataPin, resultValue); + success = _adsBase->readVoltageSingleEnded(_dataPin, resultValue); } if (success) { diff --git a/src/sensors/TIADS1x15.h b/src/sensors/TIADS1x15.h index eb600c0e5..f150b8859 100644 --- a/src/sensors/TIADS1x15.h +++ b/src/sensors/TIADS1x15.h @@ -397,16 +397,12 @@ class TIADS1x15Base : public AnalogVoltageBase { * @ingroup sensor_ads1x15 */ /* clang-format on */ -class TIADS1x15 : public Sensor, public TIADS1x15Base { +class TIADS1x15 : public Sensor { public: /** * @brief Construct a new TIADS1x15 object for single-ended or differential * voltage measurements * - * The voltage multiplier value, I2C address, and number of measurements to - * average are optional. If nothing is given a 1x voltage multiplier is - * used. - * * @note ModularSensors only supports connecting the ADS1x15 to the primary * hardware I2C instance defined in the Arduino core. Connecting the ADS to * a secondary hardware or software I2C instance is *not* supported! @@ -416,28 +412,20 @@ class TIADS1x15 : public Sensor, public TIADS1x15Base { * @param adsChannel The ADS channel of interest (0-3, physical channel * only). For differential measurements, this is the first (positive) * channel. - * @param voltageMultiplier The voltage multiplier, if a voltage divider is - * used. - * @param adsGain The internal gain setting of the ADS1x15; defaults to - * GAIN_ONE for +/- 4.096V range - * @param i2cAddress The I2C address of the ADS 1x15, default is 0x48 (ADDR - * = GND) - * @param measurementsToAverage The number of measurements to take and - * average before giving a "final" result from the sensor; optional with a - * default value of 1. - * @param adsSupplyVoltage The power supply voltage for the ADS1x15 in - * volts; defaults to the processor operating voltage from KnownProcessors.h * @param analogReferenceChannel The second (reference/negative) ADS channel * for differential measurement (0-3, physical channel only). Valid pairs * are: 0-1, 0-3, 1-3, or 2-3. Use -1 (default) for single-ended * measurements. + * @param measurementsToAverage The number of measurements to take and + * average before giving a "final" result from the sensor; optional with a + * default value of 1. + * @param adsBase Pointer to TIADS1x15Base object for ADS functionality. + * If nullptr (default), creates a new TIADS1x15Base with default settings. */ TIADS1x15(int8_t powerPin, int8_t adsChannel, - float voltageMultiplier = 1.0f, adsGain_t adsGain = GAIN_ONE, - uint8_t i2cAddress = MS_DEFAULT_ADS1X15_ADDRESS, - uint8_t measurementsToAverage = 1, - float adsSupplyVoltage = OPERATING_VOLTAGE, - int8_t analogReferenceChannel = -1); + int8_t analogReferenceChannel = -1, + uint8_t measurementsToAverage = 1, + TIADS1x15Base* adsBase = nullptr); /** * @brief Destroy the External Voltage object */ @@ -456,6 +444,16 @@ class TIADS1x15 : public Sensor, public TIADS1x15Base { * For differential measurements: the second ADS channel (0-3) */ int8_t _analogReferenceChannel = -1; + + /** + * @brief Pointer to the TIADS1x15Base object providing ADS functionality + */ + TIADS1x15Base* _adsBase = nullptr; + + /** + * @brief Whether this object owns the _adsBase pointer and should delete it + */ + bool _ownsAdsBase = false; }; /** From 1b60ac61f293a0862e7e75018c3f6f8d875b11a5 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Wed, 25 Feb 2026 16:36:05 -0500 Subject: [PATCH 339/533] Use utility to make sure objects are really created and pointers are valid Signed-off-by: Sara Damiano --- src/sensors/AlphasenseCO2.cpp | 14 +++++---- src/sensors/AnalogElecConductivity.cpp | 14 +++++---- src/sensors/ApogeeSQ212.cpp | 14 +++++---- src/sensors/CampbellOBS3.cpp | 14 +++++---- src/sensors/EverlightALSPT19.cpp | 14 +++++---- src/sensors/ProcessorAnalog.cpp | 22 +++++++------- src/sensors/ProcessorAnalog.h | 30 ++++++++++++++----- src/sensors/TIADS1x15.cpp | 41 ++++++++++++++------------ src/sensors/TIADS1x15.h | 27 +++++++++++++---- src/sensors/TurnerCyclops.cpp | 14 +++++---- src/sensors/TurnerTurbidityPlus.cpp | 14 +++++---- 11 files changed, 139 insertions(+), 79 deletions(-) diff --git a/src/sensors/AlphasenseCO2.cpp b/src/sensors/AlphasenseCO2.cpp index ba0401f75..c6f2069ce 100644 --- a/src/sensors/AlphasenseCO2.cpp +++ b/src/sensors/AlphasenseCO2.cpp @@ -26,11 +26,15 @@ AlphasenseCO2::AlphasenseCO2(int8_t powerPin, int8_t analogChannel, ALPHASENSE_CO2_MEASUREMENT_TIME_MS, powerPin, analogChannel, measurementsToAverage, ALPHASENSE_CO2_INC_CALC_VARIABLES), - _analogReferenceChannel(analogReferenceChannel), - // If no analog voltage reader was provided, create a default one - _analogVoltageReader(analogVoltageReader ? analogVoltageReader - : new TIADS1x15Base()), - _ownsAnalogVoltageReader(analogVoltageReader == nullptr) {} + _analogReferenceChannel(analogReferenceChannel) { + // If no analog voltage reader was provided, create a default one + if (analogVoltageReader == nullptr) { + _analogVoltageReader = createTIADS1x15Base(_ownsAnalogVoltageReader); + } else { + _analogVoltageReader = analogVoltageReader; + _ownsAnalogVoltageReader = false; + } +} // Destructor AlphasenseCO2::~AlphasenseCO2() { diff --git a/src/sensors/AnalogElecConductivity.cpp b/src/sensors/AnalogElecConductivity.cpp index 814d40450..f554b942b 100644 --- a/src/sensors/AnalogElecConductivity.cpp +++ b/src/sensors/AnalogElecConductivity.cpp @@ -23,11 +23,15 @@ AnalogElecConductivity::AnalogElecConductivity( ANALOGELECCONDUCTIVITY_MEASUREMENT_TIME_MS, powerPin, dataPin, measurementsToAverage, ANALOGELECCONDUCTIVITY_INC_CALC_VARIABLES), _Rseries_ohms(Rseries_ohms), - _sensorEC_Konst(sensorEC_Konst), - // If no analog voltage reader was provided, create a default one - _analogVoltageReader(analogVoltageReader ? analogVoltageReader - : new ProcessorAnalogBase()), - _ownsAnalogVoltageReader(analogVoltageReader == nullptr) {} + _sensorEC_Konst(sensorEC_Konst) { + // If no analog voltage reader was provided, create a default one + if (analogVoltageReader == nullptr) { + _analogVoltageReader = createProcessorAnalogBase(_ownsAnalogVoltageReader); + } else { + _analogVoltageReader = analogVoltageReader; + _ownsAnalogVoltageReader = false; + } +} // Destructor AnalogElecConductivity::~AnalogElecConductivity() { diff --git a/src/sensors/ApogeeSQ212.cpp b/src/sensors/ApogeeSQ212.cpp index 4017a28f3..9c00e7892 100644 --- a/src/sensors/ApogeeSQ212.cpp +++ b/src/sensors/ApogeeSQ212.cpp @@ -22,11 +22,15 @@ ApogeeSQ212::ApogeeSQ212(int8_t powerPin, int8_t analogChannel, AnalogVoltageBase* analogVoltageReader) : Sensor("ApogeeSQ212", SQ212_NUM_VARIABLES, SQ212_WARM_UP_TIME_MS, SQ212_STABILIZATION_TIME_MS, SQ212_MEASUREMENT_TIME_MS, powerPin, - analogChannel, measurementsToAverage, SQ212_INC_CALC_VARIABLES), - // If no analog voltage reader was provided, create a default one - _analogVoltageReader(analogVoltageReader ? analogVoltageReader - : new TIADS1x15Base()), - _ownsAnalogVoltageReader(analogVoltageReader == nullptr) {} + analogChannel, measurementsToAverage, SQ212_INC_CALC_VARIABLES) { + // If no analog voltage reader was provided, create a default one + if (analogVoltageReader == nullptr) { + _analogVoltageReader = createTIADS1x15Base(_ownsAnalogVoltageReader); + } else { + _analogVoltageReader = analogVoltageReader; + _ownsAnalogVoltageReader = false; + } +} // Destructor ApogeeSQ212::~ApogeeSQ212() { diff --git a/src/sensors/CampbellOBS3.cpp b/src/sensors/CampbellOBS3.cpp index ea24cc377..b734d46e2 100644 --- a/src/sensors/CampbellOBS3.cpp +++ b/src/sensors/CampbellOBS3.cpp @@ -23,11 +23,15 @@ CampbellOBS3::CampbellOBS3(int8_t powerPin, int8_t analogChannel, analogChannel, measurementsToAverage, OBS3_INC_CALC_VARIABLES), _x2_coeff_A(x2_coeff_A), _x1_coeff_B(x1_coeff_B), - _x0_coeff_C(x0_coeff_C), - // If no analog voltage reader was provided, create a default one - _analogVoltageReader(analogVoltageReader ? analogVoltageReader - : new TIADS1x15Base()), - _ownsAnalogVoltageReader(analogVoltageReader == nullptr) {} + _x0_coeff_C(x0_coeff_C) { + // If no analog voltage reader was provided, create a default one + if (analogVoltageReader == nullptr) { + _analogVoltageReader = createTIADS1x15Base(_ownsAnalogVoltageReader); + } else { + _analogVoltageReader = analogVoltageReader; + _ownsAnalogVoltageReader = false; + } +} // Destructor CampbellOBS3::~CampbellOBS3() { diff --git a/src/sensors/EverlightALSPT19.cpp b/src/sensors/EverlightALSPT19.cpp index 7dae0e8a8..1123ab098 100644 --- a/src/sensors/EverlightALSPT19.cpp +++ b/src/sensors/EverlightALSPT19.cpp @@ -22,11 +22,15 @@ EverlightALSPT19::EverlightALSPT19(int8_t powerPin, int8_t dataPin, measurementsToAverage, ALSPT19_INC_CALC_VARIABLES), _alsSupplyVoltage((alsSupplyVoltage > 0.0f) ? alsSupplyVoltage : OPERATING_VOLTAGE), - _loadResistor(loadResistor), - // If no analog voltage reader was provided, create a default one - _analogVoltageReader(analogVoltageReader ? analogVoltageReader - : new ProcessorAnalogBase()), - _ownsAnalogVoltageReader(analogVoltageReader == nullptr) {} + _loadResistor(loadResistor) { + // If no analog voltage reader was provided, create a default one + if (analogVoltageReader == nullptr) { + _analogVoltageReader = createProcessorAnalogBase(_ownsAnalogVoltageReader); + } else { + _analogVoltageReader = analogVoltageReader; + _ownsAnalogVoltageReader = false; + } +} #if (defined(BUILT_IN_ALS_POWER_PIN) && defined(BUILT_IN_ALS_DATA_PIN) && \ defined(BUILT_IN_ALS_SUPPLY_VOLTAGE) && \ defined(BUILT_IN_ALS_LOADING_RESISTANCE)) || \ diff --git a/src/sensors/ProcessorAnalog.cpp b/src/sensors/ProcessorAnalog.cpp index b783d742a..f7c404677 100644 --- a/src/sensors/ProcessorAnalog.cpp +++ b/src/sensors/ProcessorAnalog.cpp @@ -89,33 +89,32 @@ bool ProcessorAnalogBase::readVoltageDifferential( // value, and the operating voltage ProcessorAnalog::ProcessorAnalog(int8_t powerPin, int8_t dataPin, uint8_t measurementsToAverage, - ProcessorAnalogBase* analogBase) + ProcessorAnalogBase* analogVoltageReader) : Sensor("ProcessorAnalog", PROCESSOR_ANALOG_NUM_VARIABLES, PROCESSOR_ANALOG_WARM_UP_TIME_MS, PROCESSOR_ANALOG_STABILIZATION_TIME_MS, PROCESSOR_ANALOG_MEASUREMENT_TIME_MS, powerPin, dataPin, measurementsToAverage, PROCESSOR_ANALOG_INC_CALC_VARIABLES) { // If no analog base provided, create one with default settings - if (analogBase == nullptr) { - _analogBase = new ProcessorAnalogBase(); - _ownsAnalogBase = true; + if (analogVoltageReader == nullptr) { + _analogVoltageReader = createProcessorAnalogBase(_ownsAnalogVoltageReader); } else { - _analogBase = analogBase; - _ownsAnalogBase = false; + _analogVoltageReader = analogVoltageReader; + _ownsAnalogVoltageReader = false; } } // Destructor ProcessorAnalog::~ProcessorAnalog() { // Clean up the analog base object if we created it - if (_ownsAnalogBase && _analogBase != nullptr) { - delete _analogBase; - _analogBase = nullptr; + if (_ownsAnalogVoltageReader && _analogVoltageReader != nullptr) { + delete _analogVoltageReader; + _analogVoltageReader = nullptr; } } String ProcessorAnalog::getSensorLocation() { - return _analogBase->getAnalogLocation(_dataPin, -1); + return _analogVoltageReader->getAnalogLocation(_dataPin, -1); } bool ProcessorAnalog::addSingleMeasurementResult(void) { @@ -127,7 +126,8 @@ bool ProcessorAnalog::addSingleMeasurementResult(void) { MS_DBG(getSensorNameAndLocation(), F("is reporting:")); float resultValue = -9999.0f; - bool success = _analogBase->readVoltageSingleEnded(_dataPin, resultValue); + bool success = _analogVoltageReader->readVoltageSingleEnded(_dataPin, + resultValue); if (success) { verifyAndAddMeasurementResult(PROCESSOR_ANALOG_VAR_NUM, resultValue); diff --git a/src/sensors/ProcessorAnalog.h b/src/sensors/ProcessorAnalog.h index 452c98a87..8ad792ee2 100644 --- a/src/sensors/ProcessorAnalog.h +++ b/src/sensors/ProcessorAnalog.h @@ -215,6 +215,20 @@ class ProcessorAnalogBase : public AnalogVoltageBase { int8_t analogReferenceChannel) override; }; +// Inline utility function implementation +inline ProcessorAnalogBase* +createProcessorAnalogBase(bool& ownsAnalogVoltageReader) { + ProcessorAnalogBase* reader = new ProcessorAnalogBase(); + // verify that the voltage reader was created successfully + // this could fail silently on no-exceptions Arduino targets + if (reader != nullptr) { + ownsAnalogVoltageReader = true; + } else { + ownsAnalogVoltageReader = false; + } + return reader; +} + /* clang-format off */ /** * @brief The Sensor sub-class for the @@ -238,13 +252,13 @@ class ProcessorAnalog : public Sensor { * @param measurementsToAverage The number of measurements to take and * average before giving a "final" result from the sensor; optional with a * default value of 1. - * @param analogBase Pointer to ProcessorAnalogBase object for analog - * functionality. If nullptr (default), creates a new ProcessorAnalogBase - * with default settings. + * @param analogVoltageReader Pointer to ProcessorAnalogBase object for + * analog functionality. If nullptr (default), creates a new + * ProcessorAnalogBase with default settings. */ ProcessorAnalog(int8_t powerPin, int8_t dataPin, uint8_t measurementsToAverage = 1, - ProcessorAnalogBase* analogBase = nullptr); + ProcessorAnalogBase* analogVoltageReader = nullptr); /** * @brief Destroy the Processor Analog object */ @@ -259,13 +273,13 @@ class ProcessorAnalog : public Sensor { * @brief Pointer to the ProcessorAnalogBase object providing analog * functionality */ - ProcessorAnalogBase* _analogBase = nullptr; + ProcessorAnalogBase* _analogVoltageReader = nullptr; /** - * @brief Whether this object owns the _analogBase pointer and should delete - * it + * @brief Whether this object owns the _analogVoltageReader pointer and + * should delete it */ - bool _ownsAnalogBase = false; + bool _ownsAnalogVoltageReader = false; }; diff --git a/src/sensors/TIADS1x15.cpp b/src/sensors/TIADS1x15.cpp index 0aa5f50a5..c2c72aee4 100644 --- a/src/sensors/TIADS1x15.cpp +++ b/src/sensors/TIADS1x15.cpp @@ -195,8 +195,8 @@ bool TIADS1x15Base::readVoltageDifferential(int8_t analogChannel, // Validate range - for differential measurements, use PGA full-scale range // Based on gain setting rather than supply voltage float fullScaleVoltage = _ads.getFsRange(); - float minValidVoltage = -fullScaleVoltage; - float maxValidVoltage = fullScaleVoltage; + float minValidVoltage = -fullScaleVoltage; + float maxValidVoltage = fullScaleVoltage; MS_DBG(F(" ADS gain setting determines full-scale range")); MS_DBG(F(" Valid differential voltage range:"), minValidVoltage, F("V to"), @@ -270,22 +270,22 @@ void TIADS1x15Base::setSupplyVoltage(float supplyVoltage) { // The constructor - need the power pin the data pin, and voltage multiplier if // non standard TIADS1x15::TIADS1x15(int8_t powerPin, int8_t adsChannel, - int8_t analogReferenceChannel, uint8_t measurementsToAverage, - TIADS1x15Base* adsBase) + int8_t analogReferenceChannel, + uint8_t measurementsToAverage, + TIADS1x15Base* analogVoltageReader) : Sensor("TIADS1x15", TIADS1X15_NUM_VARIABLES, TIADS1X15_WARM_UP_TIME_MS, TIADS1X15_STABILIZATION_TIME_MS, TIADS1X15_MEASUREMENT_TIME_MS, powerPin, adsChannel, measurementsToAverage, TIADS1X15_INC_CALC_VARIABLES), _analogReferenceChannel(analogReferenceChannel) { - // If no ADS base provided, create one with default settings - if (adsBase == nullptr) { - _adsBase = new TIADS1x15Base(); - _ownsAdsBase = true; + // If no analog voltage reader was provided, create a default one + if (analogVoltageReader == nullptr) { + _analogVoltageReader = createTIADS1x15Base(_ownsAnalogVoltageReader); } else { - _adsBase = adsBase; - _ownsAdsBase = false; + _analogVoltageReader = analogVoltageReader; + _ownsAnalogVoltageReader = false; } - + // NOTE: We DO NOT validate the channel numbers and pairings in this // constructor! We CANNOT print a warning here about invalid channel // because the Serial object may not be initialized yet, and we don't want @@ -297,14 +297,15 @@ TIADS1x15::TIADS1x15(int8_t powerPin, int8_t adsChannel, // Destructor TIADS1x15::~TIADS1x15() { // Clean up the ADS base object if we created it - if (_ownsAdsBase && _adsBase != nullptr) { - delete _adsBase; - _adsBase = nullptr; + if (_ownsAnalogVoltageReader && _analogVoltageReader != nullptr) { + delete _analogVoltageReader; + _analogVoltageReader = nullptr; } } String TIADS1x15::getSensorLocation(void) { - return _adsBase->getAnalogLocation(_dataPin, _analogReferenceChannel); + return _analogVoltageReader->getAnalogLocation(_dataPin, + _analogReferenceChannel); } bool TIADS1x15::addSingleMeasurementResult(void) { @@ -319,9 +320,10 @@ bool TIADS1x15::addSingleMeasurementResult(void) { bool success = false; // Use differential or single-ended reading based on configuration - if (_adsBase->isValidDifferentialPair(_dataPin, _analogReferenceChannel)) { - success = _adsBase->readVoltageDifferential(_dataPin, _analogReferenceChannel, - resultValue); + if (_analogVoltageReader->isValidDifferentialPair( + _dataPin, _analogReferenceChannel)) { + success = _analogVoltageReader->readVoltageDifferential( + _dataPin, _analogReferenceChannel, resultValue); } else { if (_analogReferenceChannel >= 0 && _analogReferenceChannel <= 3) { MS_DBG(F(" Warning: reference channel "), _analogReferenceChannel, @@ -329,7 +331,8 @@ bool TIADS1x15::addSingleMeasurementResult(void) { " falling back to single-ended on channel "), _dataPin); } - success = _adsBase->readVoltageSingleEnded(_dataPin, resultValue); + success = _analogVoltageReader->readVoltageSingleEnded(_dataPin, + resultValue); } if (success) { diff --git a/src/sensors/TIADS1x15.h b/src/sensors/TIADS1x15.h index f150b8859..e2cf9a0cb 100644 --- a/src/sensors/TIADS1x15.h +++ b/src/sensors/TIADS1x15.h @@ -389,6 +389,19 @@ class TIADS1x15Base : public AnalogVoltageBase { #endif }; +// Inline utility function implementation +inline TIADS1x15Base* createTIADS1x15Base(bool& ownsAnalogVoltageReader) { + TIADS1x15Base* reader = new TIADS1x15Base(); + // verify that the voltage reader was created successfully + // this could fail silently on no-exceptions Arduino targets + if (reader != nullptr) { + ownsAnalogVoltageReader = true; + } else { + ownsAnalogVoltageReader = false; + } + return reader; +} + /* clang-format off */ /** * @brief The Sensor sub-class for the @@ -419,13 +432,14 @@ class TIADS1x15 : public Sensor { * @param measurementsToAverage The number of measurements to take and * average before giving a "final" result from the sensor; optional with a * default value of 1. - * @param adsBase Pointer to TIADS1x15Base object for ADS functionality. - * If nullptr (default), creates a new TIADS1x15Base with default settings. + * @param analogVoltageReader Pointer to TIADS1x15Base object for ADS + * functionality. If nullptr (default), creates a new TIADS1x15Base with + * default settings. */ TIADS1x15(int8_t powerPin, int8_t adsChannel, int8_t analogReferenceChannel = -1, uint8_t measurementsToAverage = 1, - TIADS1x15Base* adsBase = nullptr); + TIADS1x15Base* analogVoltageReader = nullptr); /** * @brief Destroy the External Voltage object */ @@ -448,12 +462,13 @@ class TIADS1x15 : public Sensor { /** * @brief Pointer to the TIADS1x15Base object providing ADS functionality */ - TIADS1x15Base* _adsBase = nullptr; + TIADS1x15Base* _analogVoltageReader = nullptr; /** - * @brief Whether this object owns the _adsBase pointer and should delete it + * @brief Whether this object owns the _analogVoltageReader pointer and + * should delete it */ - bool _ownsAdsBase = false; + bool _ownsAnalogVoltageReader = false; }; /** diff --git a/src/sensors/TurnerCyclops.cpp b/src/sensors/TurnerCyclops.cpp index bd5d3a1a8..cd354a075 100644 --- a/src/sensors/TurnerCyclops.cpp +++ b/src/sensors/TurnerCyclops.cpp @@ -24,11 +24,15 @@ TurnerCyclops::TurnerCyclops(int8_t powerPin, int8_t analogChannel, CYCLOPS_INC_CALC_VARIABLES), _conc_std(conc_std), _volt_std(volt_std), - _volt_blank(volt_blank), - // If no analog voltage reader was provided, create a default one - _analogVoltageReader(analogVoltageReader ? analogVoltageReader - : new TIADS1x15Base()), - _ownsAnalogVoltageReader(analogVoltageReader == nullptr) {} + _volt_blank(volt_blank) { + // If no analog voltage reader was provided, create a default one + if (analogVoltageReader == nullptr) { + _analogVoltageReader = createTIADS1x15Base(_ownsAnalogVoltageReader); + } else { + _analogVoltageReader = analogVoltageReader; + _ownsAnalogVoltageReader = false; + } +} // Destructor TurnerCyclops::~TurnerCyclops() { diff --git a/src/sensors/TurnerTurbidityPlus.cpp b/src/sensors/TurnerTurbidityPlus.cpp index 2d1d21587..5d2b5cf14 100644 --- a/src/sensors/TurnerTurbidityPlus.cpp +++ b/src/sensors/TurnerTurbidityPlus.cpp @@ -27,11 +27,15 @@ TurnerTurbidityPlus::TurnerTurbidityPlus( _conc_std(conc_std), _volt_std(volt_std), _volt_blank(volt_blank), - _analogReferenceChannel(analogReferenceChannel), - // If no analog voltage reader was provided, create a default one - _analogVoltageReader(analogVoltageReader ? analogVoltageReader - : new TIADS1x15Base()), - _ownsAnalogVoltageReader(analogVoltageReader == nullptr) {} + _analogReferenceChannel(analogReferenceChannel) { + // If no analog voltage reader was provided, create a default one + if (analogVoltageReader == nullptr) { + _analogVoltageReader = createTIADS1x15Base(_ownsAnalogVoltageReader); + } else { + _analogVoltageReader = analogVoltageReader; + _ownsAnalogVoltageReader = false; + } +} // Destructor TurnerTurbidityPlus::~TurnerTurbidityPlus() { From 446a2e6549ddb0e80158b02d2d6f8fe09873bfc4 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Wed, 25 Feb 2026 16:54:24 -0500 Subject: [PATCH 340/533] Typos, reorder, null validate Signed-off-by: Sara Damiano --- src/sensors/AlphasenseCO2.h | 2 +- src/sensors/ApogeeSQ212.h | 2 +- src/sensors/CampbellOBS3.cpp | 8 ++++---- src/sensors/CampbellOBS3.h | 2 +- src/sensors/EverlightALSPT19.cpp | 3 +-- src/sensors/EverlightALSPT19.h | 2 +- src/sensors/ProcessorAnalog.cpp | 6 +++++- src/sensors/TIADS1x15.cpp | 14 +++++++++----- src/sensors/TurnerCyclops.cpp | 8 ++++---- src/sensors/TurnerCyclops.h | 2 +- src/sensors/TurnerTurbidityPlus.cpp | 8 ++++---- src/sensors/TurnerTurbidityPlus.h | 2 +- 12 files changed, 33 insertions(+), 26 deletions(-) diff --git a/src/sensors/AlphasenseCO2.h b/src/sensors/AlphasenseCO2.h index cd83f07c0..f1d703cd1 100644 --- a/src/sensors/AlphasenseCO2.h +++ b/src/sensors/AlphasenseCO2.h @@ -283,7 +283,7 @@ class AlphasenseCO2 : public Sensor { * @param analogVoltageReader Pointer to an AnalogVoltageBase object for * voltage measurements. Pass nullptr (the default) to have the constructor * internally create and own an analog voltage reader. For backward - * compatibility, the default reader uses a TI ADS1115 or ADS10115. If a + * compatibility, the default reader uses a TI ADS1115 or ADS1015. If a * non-null pointer is supplied, the caller retains ownership and must * ensure its lifetime exceeds that of this object. * diff --git a/src/sensors/ApogeeSQ212.h b/src/sensors/ApogeeSQ212.h index d7455b9c0..734ed443e 100644 --- a/src/sensors/ApogeeSQ212.h +++ b/src/sensors/ApogeeSQ212.h @@ -261,7 +261,7 @@ class ApogeeSQ212 : public Sensor { * @param analogVoltageReader Pointer to an AnalogVoltageBase object for * voltage measurements. Pass nullptr (the default) to have the constructor * internally create and own an analog voltage reader. For backward - * compatibility, the default reader uses a TI ADS1115 or ADS10115. If a + * compatibility, the default reader uses a TI ADS1115 or ADS1015. If a * non-null pointer is supplied, the caller retains ownership and must * ensure its lifetime exceeds that of this object. */ diff --git a/src/sensors/CampbellOBS3.cpp b/src/sensors/CampbellOBS3.cpp index b734d46e2..187e56e31 100644 --- a/src/sensors/CampbellOBS3.cpp +++ b/src/sensors/CampbellOBS3.cpp @@ -64,14 +64,14 @@ bool CampbellOBS3::addSingleMeasurementResult(void) { return bumpMeasurementAttemptCount(false); } - float adcVoltage = -9999.0f; - - MS_DBG(getSensorNameAndLocation(), F("is reporting:")); - // Print out the calibration curve MS_DBG(F(" Input calibration Curve:"), _x2_coeff_A, F("x^2 +"), _x1_coeff_B, F("x +"), _x0_coeff_C); + float adcVoltage = -9999.0f; + + MS_DBG(getSensorNameAndLocation(), F("is reporting:")); + // Read the single-ended analog voltage using the AnalogVoltageBase // interface. // NOTE: All implementations of the AnalogVoltageBase class validate both diff --git a/src/sensors/CampbellOBS3.h b/src/sensors/CampbellOBS3.h index 6251138e7..22e8fdc0e 100644 --- a/src/sensors/CampbellOBS3.h +++ b/src/sensors/CampbellOBS3.h @@ -258,7 +258,7 @@ class CampbellOBS3 : public Sensor { * @param analogVoltageReader Pointer to an AnalogVoltageBase object for * voltage measurements. Pass nullptr (the default) to have the constructor * internally create and own an analog voltage reader. For backward - * compatibility, the default reader uses a TI ADS1115 or ADS10115. If a + * compatibility, the default reader uses a TI ADS1115 or ADS1015. If a * non-null pointer is supplied, the caller retains ownership and must * ensure its lifetime exceeds that of this object. */ diff --git a/src/sensors/EverlightALSPT19.cpp b/src/sensors/EverlightALSPT19.cpp index 1123ab098..c2233d4c5 100644 --- a/src/sensors/EverlightALSPT19.cpp +++ b/src/sensors/EverlightALSPT19.cpp @@ -105,9 +105,8 @@ bool EverlightALSPT19::addSingleMeasurementResult(void) { MS_DBG(getSensorNameAndLocation(), F("Light sensor has reached saturation! Clamping current " "and illumination values!")); - adcVoltage = _alsSupplyVoltage - 0.4f; + adcVoltage = max(0.0f, _alsSupplyVoltage - 0.4f); } - // convert volts to current // resistance is entered in kΩ and we want µA float current_val = (adcVoltage / (_loadResistor * 1000.0f)) * 1e6f; diff --git a/src/sensors/EverlightALSPT19.h b/src/sensors/EverlightALSPT19.h index a547832bb..925b93c5a 100644 --- a/src/sensors/EverlightALSPT19.h +++ b/src/sensors/EverlightALSPT19.h @@ -253,7 +253,7 @@ class EverlightALSPT19 : public Sensor { * - ie, A1. * @param alsSupplyVoltage The power supply voltage (in volts) of the * ALS-PT19. This does not have to be the same as the board operating - * voltage or the supply voltage of the analog AnalogVoltageBase reader. + * voltage or the supply voltage of the AnalogVoltageBase reader. * This is used to clamp the light values when the sensor is over-saturated. * @param loadResistor The size of the loading resistor, in kiloohms (kΩ). * @param measurementsToAverage The number of measurements to take and diff --git a/src/sensors/ProcessorAnalog.cpp b/src/sensors/ProcessorAnalog.cpp index f7c404677..2afc3dbf7 100644 --- a/src/sensors/ProcessorAnalog.cpp +++ b/src/sensors/ProcessorAnalog.cpp @@ -114,7 +114,11 @@ ProcessorAnalog::~ProcessorAnalog() { } String ProcessorAnalog::getSensorLocation() { - return _analogVoltageReader->getAnalogLocation(_dataPin, -1); + if (_analogVoltageReader != nullptr) { + return _analogVoltageReader->getAnalogLocation(_dataPin, -1); + } else { + return String("Unknown_AnalogVoltageReader"); + } } bool ProcessorAnalog::addSingleMeasurementResult(void) { diff --git a/src/sensors/TIADS1x15.cpp b/src/sensors/TIADS1x15.cpp index c2c72aee4..c4424142c 100644 --- a/src/sensors/TIADS1x15.cpp +++ b/src/sensors/TIADS1x15.cpp @@ -304,8 +304,12 @@ TIADS1x15::~TIADS1x15() { } String TIADS1x15::getSensorLocation(void) { - return _analogVoltageReader->getAnalogLocation(_dataPin, - _analogReferenceChannel); + if (_analogVoltageReader != nullptr) { + return _analogVoltageReader->getAnalogLocation(_dataPin, + _analogReferenceChannel); + } else { + return String("Unknown_AnalogVoltageReader"); + } } bool TIADS1x15::addSingleMeasurementResult(void) { @@ -314,18 +318,18 @@ bool TIADS1x15::addSingleMeasurementResult(void) { return bumpMeasurementAttemptCount(false); } - MS_DBG(getSensorNameAndLocation(), F("is reporting:")); - float resultValue = -9999.0f; bool success = false; + MS_DBG(getSensorNameAndLocation(), F("is reporting:")); + // Use differential or single-ended reading based on configuration if (_analogVoltageReader->isValidDifferentialPair( _dataPin, _analogReferenceChannel)) { success = _analogVoltageReader->readVoltageDifferential( _dataPin, _analogReferenceChannel, resultValue); } else { - if (_analogReferenceChannel >= 0 && _analogReferenceChannel <= 3) { + if (_analogReferenceChannel >= 0) { MS_DBG(F(" Warning: reference channel "), _analogReferenceChannel, F(" set but pair is not a valid differential config;" " falling back to single-ended on channel "), diff --git a/src/sensors/TurnerCyclops.cpp b/src/sensors/TurnerCyclops.cpp index cd354a075..37e2cfc54 100644 --- a/src/sensors/TurnerCyclops.cpp +++ b/src/sensors/TurnerCyclops.cpp @@ -65,10 +65,6 @@ bool TurnerCyclops::addSingleMeasurementResult(void) { return bumpMeasurementAttemptCount(false); } - float adcVoltage = -9999.0f; - - MS_DBG(getSensorNameAndLocation(), F("is reporting:")); - // Print out the calibration curve MS_DBG(F(" Input calibration Curve:"), _volt_std, F("V at"), _conc_std, F(". "), _volt_blank, F("V blank.")); @@ -77,6 +73,10 @@ bool TurnerCyclops::addSingleMeasurementResult(void) { return bumpMeasurementAttemptCount(false); } + float adcVoltage = -9999.0f; + + MS_DBG(getSensorNameAndLocation(), F("is reporting:")); + // Read the single-ended analog voltage using the AnalogVoltageBase // interface. // NOTE: All implementations of the AnalogVoltageBase class validate both diff --git a/src/sensors/TurnerCyclops.h b/src/sensors/TurnerCyclops.h index 20285a7ff..1dcefb006 100644 --- a/src/sensors/TurnerCyclops.h +++ b/src/sensors/TurnerCyclops.h @@ -347,7 +347,7 @@ class TurnerCyclops : public Sensor { * @param analogVoltageReader Pointer to an AnalogVoltageBase object for * voltage measurements. Pass nullptr (the default) to have the constructor * internally create and own an analog voltage reader. For backward - * compatibility, the default reader uses a TI ADS1115 or ADS10115. If a + * compatibility, the default reader uses a TI ADS1115 or ADS1015. If a * non-null pointer is supplied, the caller retains ownership and must * ensure its lifetime exceeds that of this object. */ diff --git a/src/sensors/TurnerTurbidityPlus.cpp b/src/sensors/TurnerTurbidityPlus.cpp index 5d2b5cf14..4e116cfd2 100644 --- a/src/sensors/TurnerTurbidityPlus.cpp +++ b/src/sensors/TurnerTurbidityPlus.cpp @@ -111,10 +111,6 @@ bool TurnerTurbidityPlus::addSingleMeasurementResult(void) { return bumpMeasurementAttemptCount(false); } - float adcVoltage = -9999.0f; - - MS_DBG(getSensorNameAndLocation(), F("is reporting:")); - // Print out the calibration curve MS_DBG(F(" Input calibration Curve:"), _volt_std, F("V at"), _conc_std, F(". "), _volt_blank, F("V blank.")); @@ -124,6 +120,10 @@ bool TurnerTurbidityPlus::addSingleMeasurementResult(void) { return bumpMeasurementAttemptCount(false); } + float adcVoltage = -9999.0f; + + MS_DBG(getSensorNameAndLocation(), F("is reporting:")); + // Read the differential voltage using the AnalogVoltageBase interface. // NOTE: All implementations of the AnalogVoltageBase class validate both // the input channel and the resulting voltage, so we can trust that a diff --git a/src/sensors/TurnerTurbidityPlus.h b/src/sensors/TurnerTurbidityPlus.h index 2e3e6598f..10f6b80f7 100644 --- a/src/sensors/TurnerTurbidityPlus.h +++ b/src/sensors/TurnerTurbidityPlus.h @@ -237,7 +237,7 @@ class TurnerTurbidityPlus : public Sensor { * @param analogVoltageReader Pointer to an AnalogVoltageBase object for * voltage measurements. Pass nullptr (the default) to have the constructor * internally create and own an analog voltage reader. For backward - * compatibility, the default reader uses a TI ADS1115 or ADS10115. If a + * compatibility, the default reader uses a TI ADS1115 or ADS1015. If a * non-null pointer is supplied, the caller retains ownership and must * ensure its lifetime exceeds that of this object. * From b91793cc92507bd9fafda4f7490b8cb439f7c660 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Wed, 25 Feb 2026 17:01:07 -0500 Subject: [PATCH 341/533] Back to initializers Signed-off-by: Sara Damiano --- src/sensors/AlphasenseCO2.cpp | 7 +++---- src/sensors/AnalogElecConductivity.cpp | 10 +++++----- src/sensors/ApogeeSQ212.cpp | 7 +++---- src/sensors/CampbellOBS3.cpp | 7 +++---- src/sensors/EverlightALSPT19.cpp | 7 +++---- src/sensors/ProcessorAnalog.cpp | 10 +++++----- src/sensors/TIADS1x15.cpp | 7 +++---- src/sensors/TurnerCyclops.cpp | 7 +++---- src/sensors/TurnerTurbidityPlus.cpp | 7 +++---- 9 files changed, 31 insertions(+), 38 deletions(-) diff --git a/src/sensors/AlphasenseCO2.cpp b/src/sensors/AlphasenseCO2.cpp index c6f2069ce..816b1d7d3 100644 --- a/src/sensors/AlphasenseCO2.cpp +++ b/src/sensors/AlphasenseCO2.cpp @@ -26,13 +26,12 @@ AlphasenseCO2::AlphasenseCO2(int8_t powerPin, int8_t analogChannel, ALPHASENSE_CO2_MEASUREMENT_TIME_MS, powerPin, analogChannel, measurementsToAverage, ALPHASENSE_CO2_INC_CALC_VARIABLES), - _analogReferenceChannel(analogReferenceChannel) { + _analogReferenceChannel(analogReferenceChannel), + _analogVoltageReader(analogVoltageReader), + _ownsAnalogVoltageReader(analogVoltageReader == nullptr) { // If no analog voltage reader was provided, create a default one if (analogVoltageReader == nullptr) { _analogVoltageReader = createTIADS1x15Base(_ownsAnalogVoltageReader); - } else { - _analogVoltageReader = analogVoltageReader; - _ownsAnalogVoltageReader = false; } } diff --git a/src/sensors/AnalogElecConductivity.cpp b/src/sensors/AnalogElecConductivity.cpp index f554b942b..9ca854273 100644 --- a/src/sensors/AnalogElecConductivity.cpp +++ b/src/sensors/AnalogElecConductivity.cpp @@ -23,13 +23,13 @@ AnalogElecConductivity::AnalogElecConductivity( ANALOGELECCONDUCTIVITY_MEASUREMENT_TIME_MS, powerPin, dataPin, measurementsToAverage, ANALOGELECCONDUCTIVITY_INC_CALC_VARIABLES), _Rseries_ohms(Rseries_ohms), - _sensorEC_Konst(sensorEC_Konst) { + _sensorEC_Konst(sensorEC_Konst), + _analogVoltageReader(analogVoltageReader), + _ownsAnalogVoltageReader(analogVoltageReader == nullptr) { // If no analog voltage reader was provided, create a default one if (analogVoltageReader == nullptr) { - _analogVoltageReader = createProcessorAnalogBase(_ownsAnalogVoltageReader); - } else { - _analogVoltageReader = analogVoltageReader; - _ownsAnalogVoltageReader = false; + _analogVoltageReader = + createProcessorAnalogBase(_ownsAnalogVoltageReader); } } diff --git a/src/sensors/ApogeeSQ212.cpp b/src/sensors/ApogeeSQ212.cpp index 9c00e7892..798c042c8 100644 --- a/src/sensors/ApogeeSQ212.cpp +++ b/src/sensors/ApogeeSQ212.cpp @@ -22,13 +22,12 @@ ApogeeSQ212::ApogeeSQ212(int8_t powerPin, int8_t analogChannel, AnalogVoltageBase* analogVoltageReader) : Sensor("ApogeeSQ212", SQ212_NUM_VARIABLES, SQ212_WARM_UP_TIME_MS, SQ212_STABILIZATION_TIME_MS, SQ212_MEASUREMENT_TIME_MS, powerPin, - analogChannel, measurementsToAverage, SQ212_INC_CALC_VARIABLES) { + analogChannel, measurementsToAverage, SQ212_INC_CALC_VARIABLES), + _analogVoltageReader(analogVoltageReader), + _ownsAnalogVoltageReader(analogVoltageReader == nullptr) { // If no analog voltage reader was provided, create a default one if (analogVoltageReader == nullptr) { _analogVoltageReader = createTIADS1x15Base(_ownsAnalogVoltageReader); - } else { - _analogVoltageReader = analogVoltageReader; - _ownsAnalogVoltageReader = false; } } diff --git a/src/sensors/CampbellOBS3.cpp b/src/sensors/CampbellOBS3.cpp index 187e56e31..f7259f193 100644 --- a/src/sensors/CampbellOBS3.cpp +++ b/src/sensors/CampbellOBS3.cpp @@ -23,13 +23,12 @@ CampbellOBS3::CampbellOBS3(int8_t powerPin, int8_t analogChannel, analogChannel, measurementsToAverage, OBS3_INC_CALC_VARIABLES), _x2_coeff_A(x2_coeff_A), _x1_coeff_B(x1_coeff_B), - _x0_coeff_C(x0_coeff_C) { + _x0_coeff_C(x0_coeff_C), + _analogVoltageReader(analogVoltageReader), + _ownsAnalogVoltageReader(analogVoltageReader == nullptr) { // If no analog voltage reader was provided, create a default one if (analogVoltageReader == nullptr) { _analogVoltageReader = createTIADS1x15Base(_ownsAnalogVoltageReader); - } else { - _analogVoltageReader = analogVoltageReader; - _ownsAnalogVoltageReader = false; } } diff --git a/src/sensors/EverlightALSPT19.cpp b/src/sensors/EverlightALSPT19.cpp index c2233d4c5..0e0cfd464 100644 --- a/src/sensors/EverlightALSPT19.cpp +++ b/src/sensors/EverlightALSPT19.cpp @@ -22,13 +22,12 @@ EverlightALSPT19::EverlightALSPT19(int8_t powerPin, int8_t dataPin, measurementsToAverage, ALSPT19_INC_CALC_VARIABLES), _alsSupplyVoltage((alsSupplyVoltage > 0.0f) ? alsSupplyVoltage : OPERATING_VOLTAGE), - _loadResistor(loadResistor) { + _loadResistor(loadResistor), + _analogVoltageReader(analogVoltageReader), + _ownsAnalogVoltageReader(analogVoltageReader == nullptr) { // If no analog voltage reader was provided, create a default one if (analogVoltageReader == nullptr) { _analogVoltageReader = createProcessorAnalogBase(_ownsAnalogVoltageReader); - } else { - _analogVoltageReader = analogVoltageReader; - _ownsAnalogVoltageReader = false; } } #if (defined(BUILT_IN_ALS_POWER_PIN) && defined(BUILT_IN_ALS_DATA_PIN) && \ diff --git a/src/sensors/ProcessorAnalog.cpp b/src/sensors/ProcessorAnalog.cpp index 2afc3dbf7..16aac7815 100644 --- a/src/sensors/ProcessorAnalog.cpp +++ b/src/sensors/ProcessorAnalog.cpp @@ -94,13 +94,13 @@ ProcessorAnalog::ProcessorAnalog(int8_t powerPin, int8_t dataPin, PROCESSOR_ANALOG_WARM_UP_TIME_MS, PROCESSOR_ANALOG_STABILIZATION_TIME_MS, PROCESSOR_ANALOG_MEASUREMENT_TIME_MS, powerPin, dataPin, - measurementsToAverage, PROCESSOR_ANALOG_INC_CALC_VARIABLES) { + measurementsToAverage, PROCESSOR_ANALOG_INC_CALC_VARIABLES), + _analogVoltageReader(analogVoltageReader), + _ownsAnalogVoltageReader(analogVoltageReader == nullptr) { // If no analog base provided, create one with default settings if (analogVoltageReader == nullptr) { - _analogVoltageReader = createProcessorAnalogBase(_ownsAnalogVoltageReader); - } else { - _analogVoltageReader = analogVoltageReader; - _ownsAnalogVoltageReader = false; + _analogVoltageReader = + createProcessorAnalogBase(_ownsAnalogVoltageReader); } } diff --git a/src/sensors/TIADS1x15.cpp b/src/sensors/TIADS1x15.cpp index c4424142c..ca6e14635 100644 --- a/src/sensors/TIADS1x15.cpp +++ b/src/sensors/TIADS1x15.cpp @@ -277,13 +277,12 @@ TIADS1x15::TIADS1x15(int8_t powerPin, int8_t adsChannel, TIADS1X15_STABILIZATION_TIME_MS, TIADS1X15_MEASUREMENT_TIME_MS, powerPin, adsChannel, measurementsToAverage, TIADS1X15_INC_CALC_VARIABLES), - _analogReferenceChannel(analogReferenceChannel) { + _analogReferenceChannel(analogReferenceChannel), + _analogVoltageReader(analogVoltageReader), + _ownsAnalogVoltageReader(analogVoltageReader == nullptr) { // If no analog voltage reader was provided, create a default one if (analogVoltageReader == nullptr) { _analogVoltageReader = createTIADS1x15Base(_ownsAnalogVoltageReader); - } else { - _analogVoltageReader = analogVoltageReader; - _ownsAnalogVoltageReader = false; } // NOTE: We DO NOT validate the channel numbers and pairings in this diff --git a/src/sensors/TurnerCyclops.cpp b/src/sensors/TurnerCyclops.cpp index 37e2cfc54..b48edbd94 100644 --- a/src/sensors/TurnerCyclops.cpp +++ b/src/sensors/TurnerCyclops.cpp @@ -24,13 +24,12 @@ TurnerCyclops::TurnerCyclops(int8_t powerPin, int8_t analogChannel, CYCLOPS_INC_CALC_VARIABLES), _conc_std(conc_std), _volt_std(volt_std), - _volt_blank(volt_blank) { + _volt_blank(volt_blank), + _analogVoltageReader(analogVoltageReader), + _ownsAnalogVoltageReader(analogVoltageReader == nullptr) { // If no analog voltage reader was provided, create a default one if (analogVoltageReader == nullptr) { _analogVoltageReader = createTIADS1x15Base(_ownsAnalogVoltageReader); - } else { - _analogVoltageReader = analogVoltageReader; - _ownsAnalogVoltageReader = false; } } diff --git a/src/sensors/TurnerTurbidityPlus.cpp b/src/sensors/TurnerTurbidityPlus.cpp index 4e116cfd2..3f76b341c 100644 --- a/src/sensors/TurnerTurbidityPlus.cpp +++ b/src/sensors/TurnerTurbidityPlus.cpp @@ -27,13 +27,12 @@ TurnerTurbidityPlus::TurnerTurbidityPlus( _conc_std(conc_std), _volt_std(volt_std), _volt_blank(volt_blank), - _analogReferenceChannel(analogReferenceChannel) { + _analogReferenceChannel(analogReferenceChannel), + _analogVoltageReader(analogVoltageReader), + _ownsAnalogVoltageReader(analogVoltageReader == nullptr) { // If no analog voltage reader was provided, create a default one if (analogVoltageReader == nullptr) { _analogVoltageReader = createTIADS1x15Base(_ownsAnalogVoltageReader); - } else { - _analogVoltageReader = analogVoltageReader; - _ownsAnalogVoltageReader = false; } } From a66330151b87b5487794357f72aded4d06fabfb0 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Wed, 25 Feb 2026 17:37:41 -0500 Subject: [PATCH 342/533] Lots of small fixes Signed-off-by: Sara Damiano --- examples/menu_a_la_carte/menu_a_la_carte.ino | 2 -- src/ModSensorConfig.h | 12 +++++----- src/sensors/AlphasenseCO2.cpp | 2 +- src/sensors/AnalogElecConductivity.cpp | 2 +- src/sensors/AnalogVoltageBase.h | 7 +++--- src/sensors/ApogeeSQ212.cpp | 2 +- src/sensors/ApogeeSQ212.h | 7 +++--- src/sensors/CampbellOBS3.cpp | 2 +- src/sensors/CampbellOBS3.h | 6 ++--- src/sensors/EverlightALSPT19.cpp | 2 +- src/sensors/EverlightALSPT19.h | 2 +- src/sensors/ProcessorAnalog.cpp | 11 +++++++-- src/sensors/ProcessorAnalog.h | 6 +---- src/sensors/TIADS1x15.cpp | 25 +++++++++++++------- src/sensors/TIADS1x15.h | 6 +---- src/sensors/TurnerCyclops.cpp | 4 ++-- src/sensors/TurnerCyclops.h | 2 +- src/sensors/TurnerTurbidityPlus.cpp | 5 ++-- src/sensors/TurnerTurbidityPlus.h | 10 +++++++- 19 files changed, 65 insertions(+), 50 deletions(-) diff --git a/examples/menu_a_la_carte/menu_a_la_carte.ino b/examples/menu_a_la_carte/menu_a_la_carte.ino index 1fcd420e8..c9db0641e 100644 --- a/examples/menu_a_la_carte/menu_a_la_carte.ino +++ b/examples/menu_a_la_carte/menu_a_la_carte.ino @@ -1612,8 +1612,6 @@ const float voltageMultiplier = // use 1.0f for direct connection // use (R_top + R_bottom) / R_bottom for voltage divider const adsGain_t adsPGAGain = GAIN_ONE; // The internal gain setting for the ADS -// GAIN_ONE => +/-4.096V range; use GAIN_TWOTHIRDS (+/-6.144V) for inputs -// > 4.096V GAIN_TWO => +/-2.048V, GAIN_FOUR => +/-1.024V, etc. const uint8_t evADSi2c_addr = 0x48; // The I2C address of the ADS1115 ADC const uint8_t VoltReadsToAvg = 1; // Only read one sample diff --git a/src/ModSensorConfig.h b/src/ModSensorConfig.h index 023d12aef..97b507803 100644 --- a/src/ModSensorConfig.h +++ b/src/ModSensorConfig.h @@ -57,7 +57,7 @@ * Override with a build flag: `-DMS_DEFAULT_ADS1X15_ADDRESS=0x49` */ #define MS_DEFAULT_ADS1X15_ADDRESS 0x48 -#endif // !defined(MS_DEFAULT_ADS1X15_ADDRESS) || defined(DOXYGEN) +#endif //============================================================== //============================================================== @@ -186,16 +186,16 @@ /// @brief The maximum possible range of the ADC - the resolution shifted up one /// bit. #define PROCESSOR_ADC_RANGE (1 << MS_PROCESSOR_ADC_RESOLUTION) -#ifndef PROCESSOR_ANALOG_MAX_CHANNEL +#ifndef MS_PROCESSOR_ANALOG_MAX_CHANNEL /** * @brief Upper bound used to sanity-check analog channel numbers at runtime. * * This is not a hardware limit but a validation ceiling that exceeds the * largest channel index found on any supported Arduino platform (e.g. Mega: - * A0–A15). Override with -D PROCESSOR_ANALOG_MAX_CHANNEL= if needed. + * A0–A15). Override with -D MS_PROCESSOR_ANALOG_MAX_CHANNEL= if needed. */ -#define PROCESSOR_ANALOG_MAX_CHANNEL 100 -#endif // PROCESSOR_ANALOG_MAX_CHANNEL +#define MS_PROCESSOR_ANALOG_MAX_CHANNEL 100 +#endif // MS_PROCESSOR_ANALOG_MAX_CHANNEL #if !defined(MS_PROCESSOR_ADC_REFERENCE_MODE) || defined(DOXYGEN) #if defined(ARDUINO_ARCH_AVR) || defined(DOXYGEN) /** @@ -252,7 +252,7 @@ #if !defined(MS_PROCESSOR_ADC_REFERENCE_MODE) #error The processor ADC reference type must be defined! #endif // MS_PROCESSOR_ADC_REFERENCE_MODE -#endif // !defined(MS_PROCESSOR_ADC_REFERENCE_MODE) || defined(DOXYGEN) +#endif //============================================================== diff --git a/src/sensors/AlphasenseCO2.cpp b/src/sensors/AlphasenseCO2.cpp index 816b1d7d3..27d1873ea 100644 --- a/src/sensors/AlphasenseCO2.cpp +++ b/src/sensors/AlphasenseCO2.cpp @@ -49,7 +49,7 @@ String AlphasenseCO2::getSensorLocation(void) { return _analogVoltageReader->getAnalogLocation(_dataPin, _analogReferenceChannel); } else { - return String("Unknown_AnalogVoltageReader"); + return String(F("Unknown_AnalogVoltageReader")); } } diff --git a/src/sensors/AnalogElecConductivity.cpp b/src/sensors/AnalogElecConductivity.cpp index 9ca854273..5bb3ec267 100644 --- a/src/sensors/AnalogElecConductivity.cpp +++ b/src/sensors/AnalogElecConductivity.cpp @@ -94,7 +94,7 @@ bool AnalogElecConductivity::addSingleMeasurementResult(void) { } float adcRatio = adcVoltage / supplyVoltage; - if (adcRatio >= 1.0) { + if (adcRatio >= 1.0f) { // Prevent division issues when voltage reaches supply voltage MS_DBG(F(" ADC ratio clamped from"), adcRatio, F("to"), ANALOGELECCONDUCTIVITY_ADC_MAX_RATIO); diff --git a/src/sensors/AnalogVoltageBase.h b/src/sensors/AnalogVoltageBase.h index 4f1820485..a56611d06 100644 --- a/src/sensors/AnalogVoltageBase.h +++ b/src/sensors/AnalogVoltageBase.h @@ -82,7 +82,7 @@ class AnalogVoltageBase { */ virtual void setVoltageMultiplier(float voltageMultiplier) { // If the input voltage multiplier is not positive, set it to 1. - if (voltageMultiplier <= 0.0f) { + if (!(voltageMultiplier > 0.0f)) { // rejects NaN, -inf, and <= 0 MS_DBG(F("Invalid voltage multiplier "), voltageMultiplier, F(", clamping to 1.0")); _voltageMultiplier = 1.0f; @@ -109,7 +109,7 @@ class AnalogVoltageBase { * clamped to OPERATING_VOLTAGE to maintain a valid reference. */ virtual void setSupplyVoltage(float supplyVoltage) { - if (supplyVoltage <= 0.0f) { + if (!(supplyVoltage > 0.0f)) { // rejects NaN, -inf, and <= 0 MS_DBG(F("Invalid supply voltage "), supplyVoltage, F(", clamping to "), OPERATING_VOLTAGE, F("V")); _supplyVoltage = OPERATING_VOLTAGE; @@ -117,6 +117,7 @@ class AnalogVoltageBase { _supplyVoltage = supplyVoltage; } } + /** * @brief Get the supply voltage for the analog system * @@ -176,7 +177,7 @@ class AnalogVoltageBase { * differential measurements, or the sole channel for single-ended * measurements). * @param analogReferenceChannel The secondary (reference) analog channel - * for differential measurement. Use -1 for a single-ended analog sensor. + * for differential measurement. Set to -1 for a single-ended analog sensor. * * @return A string describing the analog sensor location */ diff --git a/src/sensors/ApogeeSQ212.cpp b/src/sensors/ApogeeSQ212.cpp index 798c042c8..b0a35a6f9 100644 --- a/src/sensors/ApogeeSQ212.cpp +++ b/src/sensors/ApogeeSQ212.cpp @@ -44,7 +44,7 @@ String ApogeeSQ212::getSensorLocation(void) { if (_analogVoltageReader != nullptr) { return _analogVoltageReader->getAnalogLocation(_dataPin, -1); } else { - return String("Unknown_AnalogVoltageReader"); + return String(F("Unknown_AnalogVoltageReader")); } } diff --git a/src/sensors/ApogeeSQ212.h b/src/sensors/ApogeeSQ212.h index 734ed443e..cfbc8c900 100644 --- a/src/sensors/ApogeeSQ212.h +++ b/src/sensors/ApogeeSQ212.h @@ -141,15 +141,16 @@ class AnalogVoltageBase; */ #define SQ212_WARM_UP_TIME_MS 2 /** - * @brief Sensor::_stabilizationTime_ms; the ADS1115 is stable after 2ms. + * @brief Sensor::_stabilizationTime_ms; the default ADS1115 voltage reader is + * stable after 2ms. * * The stabilization time of the SQ-212 itself is not known! * * @todo Measure stabilization time of the SQ-212 */ #define SQ212_STABILIZATION_TIME_MS 2 -/// @brief Sensor::_measurementTime_ms; ADS1115 takes almost 2ms to complete a -/// measurement (860/sec). +/// @brief Sensor::_measurementTime_ms; with the default ADS1115 voltage reader, +/// it takes almost 2ms to complete a measurement (860/sec). #define SQ212_MEASUREMENT_TIME_MS 2 /**@}*/ diff --git a/src/sensors/CampbellOBS3.cpp b/src/sensors/CampbellOBS3.cpp index f7259f193..2d97db2af 100644 --- a/src/sensors/CampbellOBS3.cpp +++ b/src/sensors/CampbellOBS3.cpp @@ -45,7 +45,7 @@ String CampbellOBS3::getSensorLocation(void) { if (_analogVoltageReader != nullptr) { return _analogVoltageReader->getAnalogLocation(_dataPin, -1); } else { - return String("Unknown_AnalogVoltageReader"); + return String(F("Unknown_AnalogVoltageReader")); } } diff --git a/src/sensors/CampbellOBS3.h b/src/sensors/CampbellOBS3.h index 22e8fdc0e..68f2bc58f 100644 --- a/src/sensors/CampbellOBS3.h +++ b/src/sensors/CampbellOBS3.h @@ -246,9 +246,9 @@ class CampbellOBS3 : public Sensor { * @param analogChannel The analog data channel or processor pin for voltage * measurements. The significance of the channel number depends on the * specific AnalogVoltageBase implementation used for voltage readings. For - * example, with the TI ADS1x15, this would be the ADC channel (0-3) that - * the sensor is connected to. Negative or invalid channel numbers are not - * clamped and will cause the reading to fail and emit a warning. + * example, with the default TI ADS1x15, this would be the ADC channel (0-3) + * that the sensor is connected to. Negative or invalid channel numbers are + * not clamped and will cause the reading to fail and emit a warning. * @param x2_coeff_A The x2 (A) coefficient for the calibration _in volts_ * @param x1_coeff_B The x (B) coefficient for the calibration _in volts_ * @param x0_coeff_C The x0 (C) coefficient for the calibration _in volts_ diff --git a/src/sensors/EverlightALSPT19.cpp b/src/sensors/EverlightALSPT19.cpp index 0e0cfd464..452a53628 100644 --- a/src/sensors/EverlightALSPT19.cpp +++ b/src/sensors/EverlightALSPT19.cpp @@ -55,7 +55,7 @@ String EverlightALSPT19::getSensorLocation(void) { if (_analogVoltageReader != nullptr) { return _analogVoltageReader->getAnalogLocation(_dataPin, -1); } else { - return String("Unknown_AnalogVoltageReader"); + return String(F("Unknown_AnalogVoltageReader")); } } diff --git a/src/sensors/EverlightALSPT19.h b/src/sensors/EverlightALSPT19.h index 925b93c5a..03a339bf1 100644 --- a/src/sensors/EverlightALSPT19.h +++ b/src/sensors/EverlightALSPT19.h @@ -116,7 +116,7 @@ * Lux, which doesn't appear to align with the datasheet. */ #define ALSPT19_UA_PER_1000LUX 200.0f -#endif // !defined(ALSPT19_UA_PER_1000LUX) || defined(DOXYGEN) +#endif /**@}*/ /** diff --git a/src/sensors/ProcessorAnalog.cpp b/src/sensors/ProcessorAnalog.cpp index 16aac7815..c7500df84 100644 --- a/src/sensors/ProcessorAnalog.cpp +++ b/src/sensors/ProcessorAnalog.cpp @@ -33,7 +33,7 @@ bool ProcessorAnalogBase::readVoltageSingleEnded(int8_t analogChannel, "MS_PROCESSOR_ADC_RESOLUTION configuration."); // Validate parameters - if (analogChannel < 0 || analogChannel > PROCESSOR_ANALOG_MAX_CHANNEL || + if (analogChannel < 0 || analogChannel > MS_PROCESSOR_ANALOG_MAX_CHANNEL || _supplyVoltage <= 0 || _voltageMultiplier <= 0) { MS_DBG(F("Invalid configuration: either the analog channel, the supply " "voltage, or the voltage multiplier is not set correctly!")); @@ -117,7 +117,7 @@ String ProcessorAnalog::getSensorLocation() { if (_analogVoltageReader != nullptr) { return _analogVoltageReader->getAnalogLocation(_dataPin, -1); } else { - return String("Unknown_AnalogVoltageReader"); + return String(F("Unknown_AnalogVoltageReader")); } } @@ -127,6 +127,13 @@ bool ProcessorAnalog::addSingleMeasurementResult(void) { return bumpMeasurementAttemptCount(false); } + // Check if we have a valid analog voltage reader + if (_analogVoltageReader == nullptr) { + MS_DBG(getSensorNameAndLocation(), + F("No analog voltage reader available")); + return bumpMeasurementAttemptCount(false); + } + MS_DBG(getSensorNameAndLocation(), F("is reporting:")); float resultValue = -9999.0f; diff --git a/src/sensors/ProcessorAnalog.h b/src/sensors/ProcessorAnalog.h index 8ad792ee2..6adb73408 100644 --- a/src/sensors/ProcessorAnalog.h +++ b/src/sensors/ProcessorAnalog.h @@ -221,11 +221,7 @@ createProcessorAnalogBase(bool& ownsAnalogVoltageReader) { ProcessorAnalogBase* reader = new ProcessorAnalogBase(); // verify that the voltage reader was created successfully // this could fail silently on no-exceptions Arduino targets - if (reader != nullptr) { - ownsAnalogVoltageReader = true; - } else { - ownsAnalogVoltageReader = false; - } + ownsAnalogVoltageReader = (reader != nullptr); return reader; } diff --git a/src/sensors/TIADS1x15.cpp b/src/sensors/TIADS1x15.cpp index ca6e14635..9e947eeeb 100644 --- a/src/sensors/TIADS1x15.cpp +++ b/src/sensors/TIADS1x15.cpp @@ -13,6 +13,7 @@ #include "TIADS1x15.h" +#include // ============================================================================ @@ -86,10 +87,10 @@ bool TIADS1x15Base::readVoltageSingleEnded(int8_t analogChannel, // Use the per-instance ADS driver (gain configured in constructor) - // Verify ADC is available (already initialized in constructor) - // Note: The ADS driver may return false if I2C communication fails - if (!_ads.begin(_i2cAddress)) { - MS_DBG(F(" ADC communication failed at 0x"), String(_i2cAddress, HEX)); + // Verify I2C connectivity with a lightweight probe + Wire.beginTransmission(_i2cAddress); + if (Wire.endTransmission() != 0) { + MS_DBG(F(" I2C communication failed at 0x"), String(_i2cAddress, HEX)); return false; } @@ -153,9 +154,10 @@ bool TIADS1x15Base::readVoltageDifferential(int8_t analogChannel, float scaledResult = -9999.0f; // Use the per-instance ADS driver (configured in constructor) - // Verify ADC is available - if (!_ads.begin(_i2cAddress)) { - MS_DBG(F(" ADC communication failed at 0x"), String(_i2cAddress, HEX)); + // Verify I2C connectivity with a lightweight probe + Wire.beginTransmission(_i2cAddress); + if (Wire.endTransmission() != 0) { + MS_DBG(F(" I2C communication failed at 0x"), String(_i2cAddress, HEX)); return false; } @@ -307,7 +309,7 @@ String TIADS1x15::getSensorLocation(void) { return _analogVoltageReader->getAnalogLocation(_dataPin, _analogReferenceChannel); } else { - return String("Unknown_AnalogVoltageReader"); + return String(F("Unknown_AnalogVoltageReader")); } } @@ -317,6 +319,13 @@ bool TIADS1x15::addSingleMeasurementResult(void) { return bumpMeasurementAttemptCount(false); } + // Check if we have a valid analog voltage reader + if (_analogVoltageReader == nullptr) { + MS_DBG(getSensorNameAndLocation(), + F("No analog voltage reader available")); + return bumpMeasurementAttemptCount(false); + } + float resultValue = -9999.0f; bool success = false; diff --git a/src/sensors/TIADS1x15.h b/src/sensors/TIADS1x15.h index e2cf9a0cb..3681dd66b 100644 --- a/src/sensors/TIADS1x15.h +++ b/src/sensors/TIADS1x15.h @@ -394,11 +394,7 @@ inline TIADS1x15Base* createTIADS1x15Base(bool& ownsAnalogVoltageReader) { TIADS1x15Base* reader = new TIADS1x15Base(); // verify that the voltage reader was created successfully // this could fail silently on no-exceptions Arduino targets - if (reader != nullptr) { - ownsAnalogVoltageReader = true; - } else { - ownsAnalogVoltageReader = false; - } + ownsAnalogVoltageReader = (reader != nullptr); return reader; } diff --git a/src/sensors/TurnerCyclops.cpp b/src/sensors/TurnerCyclops.cpp index b48edbd94..4cc1e9667 100644 --- a/src/sensors/TurnerCyclops.cpp +++ b/src/sensors/TurnerCyclops.cpp @@ -46,7 +46,7 @@ String TurnerCyclops::getSensorLocation(void) { if (_analogVoltageReader != nullptr) { return _analogVoltageReader->getAnalogLocation(_dataPin, -1); } else { - return String("Unknown_AnalogVoltageReader"); + return String(F("Unknown_AnalogVoltageReader")); } } @@ -67,7 +67,7 @@ bool TurnerCyclops::addSingleMeasurementResult(void) { // Print out the calibration curve MS_DBG(F(" Input calibration Curve:"), _volt_std, F("V at"), _conc_std, F(". "), _volt_blank, F("V blank.")); - if (fabs(_volt_std - _volt_blank) < CYCLOPS_CALIBRATION_EPSILON) { + if (fabsf(_volt_std - _volt_blank) < CYCLOPS_CALIBRATION_EPSILON) { MS_DBG(F("Invalid calibration: point voltage equals blank voltage")); return bumpMeasurementAttemptCount(false); } diff --git a/src/sensors/TurnerCyclops.h b/src/sensors/TurnerCyclops.h index 1dcefb006..335a426e1 100644 --- a/src/sensors/TurnerCyclops.h +++ b/src/sensors/TurnerCyclops.h @@ -193,7 +193,7 @@ class AnalogVoltageBase; * most high-precision ADC configurations. */ #define CYCLOPS_CALIBRATION_EPSILON 1e-4f -#endif // !defined(CYCLOPS_CALIBRATION_EPSILON) || defined(DOXYGEN) +#endif /**@}*/ /** diff --git a/src/sensors/TurnerTurbidityPlus.cpp b/src/sensors/TurnerTurbidityPlus.cpp index 3f76b341c..e6575f293 100644 --- a/src/sensors/TurnerTurbidityPlus.cpp +++ b/src/sensors/TurnerTurbidityPlus.cpp @@ -50,7 +50,7 @@ String TurnerTurbidityPlus::getSensorLocation(void) { return _analogVoltageReader->getAnalogLocation(_dataPin, _analogReferenceChannel); } else { - return String("Unknown_AnalogVoltageReader"); + return String(F("Unknown_AnalogVoltageReader")); } } @@ -113,8 +113,7 @@ bool TurnerTurbidityPlus::addSingleMeasurementResult(void) { // Print out the calibration curve MS_DBG(F(" Input calibration Curve:"), _volt_std, F("V at"), _conc_std, F(". "), _volt_blank, F("V blank.")); - const float epsilon = 1e-4f; // tune to expected sensor precision - if (fabs(_volt_std - _volt_blank) < epsilon) { + if (fabsf(_volt_std - _volt_blank) < TURBIDITY_PLUS_CALIBRATION_EPSILON) { MS_DBG(F("Invalid calibration: point voltage equals blank voltage")); return bumpMeasurementAttemptCount(false); } diff --git a/src/sensors/TurnerTurbidityPlus.h b/src/sensors/TurnerTurbidityPlus.h index 10f6b80f7..0b9808e91 100644 --- a/src/sensors/TurnerTurbidityPlus.h +++ b/src/sensors/TurnerTurbidityPlus.h @@ -29,6 +29,8 @@ * - Changes the wiper trigger pulse duration from 50 ms to x ms * - ```-D TURBIDITY_PLUS_WIPER_ROTATION_WAIT_MS=x``` * - Changes the wiper rotation wait time from 8000 ms to x ms + * - ```-D TURBIDITY_PLUS_CALIBRATION_EPSILON=x``` + * - Changes the calibration validation epsilon from 1e-4 to x * * @section sensor_turbidity_plus_ctor Sensor Constructor * {{ @ref TurnerTurbidityPlus::TurnerTurbidityPlus }} @@ -104,6 +106,12 @@ class AnalogVoltageBase; */ #define TURBIDITY_PLUS_WIPER_ROTATION_WAIT_MS 8000 #endif +#if !defined(TURBIDITY_PLUS_CALIBRATION_EPSILON) || defined(DOXYGEN) +/** + * @brief Epsilon value for calibration validation to detect invalid calibration curves + */ +#define TURBIDITY_PLUS_CALIBRATION_EPSILON 1e-4f +#endif /**@}*/ /** @@ -332,7 +340,7 @@ class TurnerTurbidityPlus : public Sensor { /** * @brief The second (reference) pin for differential voltage measurements. */ - int8_t _analogReferenceChannel; + int8_t _analogReferenceChannel = -1; /// @brief Pointer to analog voltage reader AnalogVoltageBase* _analogVoltageReader = nullptr; /// @brief Flag to track if this object owns the analog voltage reader and From 44e7f83e2f64f84300224547886415e439df4c25 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Wed, 25 Feb 2026 17:47:08 -0500 Subject: [PATCH 343/533] Doc fixes, add develop as a base-ish branch Signed-off-by: Sara Damiano --- .coderabbit.yaml | 1 + src/ModSensorConfig.h | 2 +- src/sensors/CampbellOBS3.h | 9 ++++++--- src/sensors/ProcessorAnalog.h | 19 +++++++++++++++++++ src/sensors/TIADS1x15.h | 18 ++++++++++++++++++ 5 files changed, 45 insertions(+), 4 deletions(-) diff --git a/.coderabbit.yaml b/.coderabbit.yaml index c31a663a5..05e153bf7 100644 --- a/.coderabbit.yaml +++ b/.coderabbit.yaml @@ -67,3 +67,4 @@ reviews: drafts: true base_branches: - master + - develop diff --git a/src/ModSensorConfig.h b/src/ModSensorConfig.h index 97b507803..d72c825b8 100644 --- a/src/ModSensorConfig.h +++ b/src/ModSensorConfig.h @@ -192,7 +192,7 @@ * * This is not a hardware limit but a validation ceiling that exceeds the * largest channel index found on any supported Arduino platform (e.g. Mega: - * A0–A15). Override with -D MS_PROCESSOR_ANALOG_MAX_CHANNEL= if needed. + * A0–A15). Override with -D MS_PROCESSOR_ANALOG_MAX_CHANNEL=x if needed. */ #define MS_PROCESSOR_ANALOG_MAX_CHANNEL 100 #endif // MS_PROCESSOR_ANALOG_MAX_CHANNEL diff --git a/src/sensors/CampbellOBS3.h b/src/sensors/CampbellOBS3.h index 68f2bc58f..71a067c81 100644 --- a/src/sensors/CampbellOBS3.h +++ b/src/sensors/CampbellOBS3.h @@ -285,9 +285,12 @@ class CampbellOBS3 : public Sensor { bool addSingleMeasurementResult(void) override; private: - float _x2_coeff_A; ///< The x^2 (A) calibration coefficient - float _x1_coeff_B; ///< The x^1 (B) calibration coefficient - float _x0_coeff_C; ///< The x^0 (C) calibration coefficient + /// @brief The x^2 (A) calibration coefficient + float _x2_coeff_A; + /// @brief The x^1 (B) calibration coefficient + float _x1_coeff_B; + /// @brief The x^0 (C) calibration coefficient + float _x0_coeff_C; /// @brief Pointer to analog voltage reader AnalogVoltageBase* _analogVoltageReader = nullptr; /// @brief Flag to track if this object owns the analog voltage reader and diff --git a/src/sensors/ProcessorAnalog.h b/src/sensors/ProcessorAnalog.h index 6adb73408..d9bf796d5 100644 --- a/src/sensors/ProcessorAnalog.h +++ b/src/sensors/ProcessorAnalog.h @@ -216,6 +216,25 @@ class ProcessorAnalogBase : public AnalogVoltageBase { }; // Inline utility function implementation +/** + * @brief Create a ProcessorAnalogBase analog voltage reader with ownership + * tracking + * + * This utility function safely creates a new ProcessorAnalogBase object with + * default settings and verifies it was created successfully. It handles the + * pattern of creating default analog voltage readers when none is provided to + * sensor constructors. + * + * @param[out] ownsAnalogVoltageReader Reference to bool that tracks ownership. + * Set to true if the reader was created successfully, false if creation + * failed. + * @return Pointer to created ProcessorAnalogBase object, or nullptr if creation + * failed + * + * @note This function is designed for use in sensor constructors that need a + * default analog voltage reader. The ownership flag should be used to determine + * whether the returned pointer needs to be deleted in the sensor's destructor. + */ inline ProcessorAnalogBase* createProcessorAnalogBase(bool& ownsAnalogVoltageReader) { ProcessorAnalogBase* reader = new ProcessorAnalogBase(); diff --git a/src/sensors/TIADS1x15.h b/src/sensors/TIADS1x15.h index 3681dd66b..a51f1c74a 100644 --- a/src/sensors/TIADS1x15.h +++ b/src/sensors/TIADS1x15.h @@ -390,6 +390,24 @@ class TIADS1x15Base : public AnalogVoltageBase { }; // Inline utility function implementation +/** + * @brief Create a TIADS1x15Base analog voltage reader with ownership tracking + * + * This utility function safely creates a new TIADS1x15Base object with default + * settings and verifies it was created successfully. It handles the pattern of + * creating default analog voltage readers when none is provided to sensor + * constructors. + * + * @param[out] ownsAnalogVoltageReader Reference to bool that tracks ownership. + * Set to true if the reader was created successfully, false if creation + * failed. + * @return Pointer to created TIADS1x15Base object, or nullptr if creation + * failed + * + * @note This function is designed for use in sensor constructors that need a + * default analog voltage reader. The ownership flag should be used to determine + * whether the returned pointer needs to be deleted in the sensor's destructor. + */ inline TIADS1x15Base* createTIADS1x15Base(bool& ownsAnalogVoltageReader) { TIADS1x15Base* reader = new TIADS1x15Base(); // verify that the voltage reader was created successfully From 3ac26595d10617bc306f869e6d8adaeec503a4df Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Thu, 26 Feb 2026 12:09:13 -0500 Subject: [PATCH 344/533] Updated change log, add some backwards compatibility warnings, fix some validation Signed-off-by: Sara Damiano --- ChangeLog.md | 158 ++++++++++++++++++++++++--- src/ModSensorConfig.h | 3 +- src/sensors/AlphasenseCO2.cpp | 6 + src/sensors/AlphasenseCO2.h | 2 + src/sensors/AnalogElecConductivity.h | 7 +- src/sensors/ApogeeSQ212.h | 8 ++ src/sensors/CampbellOBS3.h | 8 ++ src/sensors/EverlightALSPT19.cpp | 13 ++- src/sensors/PaleoTerraRedox.cpp | 2 +- src/sensors/TIADS1x15.cpp | 14 ++- src/sensors/TIADS1x15.h | 5 +- src/sensors/TurnerCyclops.h | 8 ++ src/sensors/TurnerTurbidityPlus.h | 2 + 13 files changed, 206 insertions(+), 30 deletions(-) diff --git a/ChangeLog.md b/ChangeLog.md index 6e69c7f8a..5d3f35c61 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -6,25 +6,112 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + + + + + + +- [ChangeLog](#changelog) + - [Unreleased](#unreleased) + - [0.37.0](#0370) + - [0.36.0](#0360) + - [0.35.1](#0351) + - [0.35.0](#0350) + - [\[0.34.1\]](#0341) + - [0.34.0](#0340) + - [0.33.4](#0334) + - [0.33.3](#0333) + - [0.33.2](#0332) + - [0.33.1 - 2022-04-11](#0331---2022-04-11) + - [0.33.0 - 2022-04-01](#0330---2022-04-01) + - [0.32.2 - 2021-11-23](#0322---2021-11-23) + - [0.32.0 - 2021-11-19](#0320---2021-11-19) + - [0.31.2 - 2021-11-03](#0312---2021-11-03) + - [0.31.0 - 2021-11-02](#0310---2021-11-02) + - [0.30.0 - 2021-07-06](#0300---2021-07-06) + - [0.29.1 - 2021-07-01](#0291---2021-07-01) + - [0.29.0 - 2021-05-19](#0290---2021-05-19) + - [0.28.5 - 2021-05-11](#0285---2021-05-11) + - [0.28.4 - 2021-05-05](#0284---2021-05-05) + - [0.28.3 - 2021-03-24](#0283---2021-03-24) + - [\[0.28.01\] - 2021-02-10](#02801---2021-02-10) + - [0.28.0 - 2021-02-10](#0280---2021-02-10) + - [0.27.8 - 2021-01-19](#0278---2021-01-19) + - [0.27.7 - 2021-01-19](#0277---2021-01-19) + - [0.27.6 - 2021-01-19](#0276---2021-01-19) + - [0.27.5 - 2020-12-15](#0275---2020-12-15) + - [0.25.0 - 2020-06-25](#0250---2020-06-25) + - [0.24.1 - 2020-03-02](#0241---2020-03-02) + - [0.23.13 - 2019-09-19](#02313---2019-09-19) + - [0.23.11 - 2019-09-11](#02311---2019-09-11) + - [0.22.5 - 2019-06-24](#0225---2019-06-24) + - [0.21.4 - 2019-05-02](#0214---2019-05-02) + - [0.21.3 - 2019-05-02](#0213---2019-05-02) + - [0.21.2 - 2019-03-19](#0212---2019-03-19) + - [0.21.0 - 2019-03-06](#0210---2019-03-06) + - [0.19.6 - 2019-02-27](#0196---2019-02-27) + - [0.19.3 - 2019-01-15](#0193---2019-01-15) + - [0.19.2 - 2018-12-22](#0192---2018-12-22) + - [0.17.2 - 2018-11-27](#0172---2018-11-27) + - [0.12.2 - 2018-09-25](#0122---2018-09-25) + - [0.11.6 - 2018-05-11](#0116---2018-05-11) + - [0.11.3 - 2018-05-03](#0113---2018-05-03) + - [0.9.0 - 2018-04-17](#090---2018-04-17) + - [0.6.10 - 2018-02-26](#0610---2018-02-26) + - [0.6.9 - 2018-02-26](#069---2018-02-26) + - [0.5.4-beta - 2018-01-18](#054-beta---2018-01-18) + - [\[0.3.0\]-beta - 2017-06-07](#030-beta---2017-06-07) + - [\[0.2.5\]-beta - 2017-05-31](#025-beta---2017-05-31) + - [\[0.2.4\]-beta - 2017-05-17](#024-beta---2017-05-17) + - [\[0.2.2\]-beta - 2017-05-09](#022-beta---2017-05-09) + + + *** ## [Unreleased] ### Changed -- Made the enabling and disabling of the watchdog the very first and very last steps of sleep to keep the watchdog enabled through the whole getting ready for bed and waking up process. -- **ANB pH** +#### Individual Sensors + +- **ANBpH** - **BREAKING** The constructor has changed! The logging interval has been added as a required parameter for the constructor! - Changed timing slightly and simplified timing logic. -- **Renamed** The EnviroDIYPublisher has been renamed the MonitorMyWatershedPublisher. -This reflects changes to the website from years ago. -There is a shell file and typedef to maintain backwards compatibility. -- Changed capitalization of `setInitialShortIntervals(#)` function - - Previously the 'i' of initial was not capitalized. - - The old `setinitialShortIntervals` remains available via compatibility shim in LoggerBase.h, so existing code is unaffected. -- Bumped several dependencies - including crucial bug fixes to SensorModbusMaster. -- Re-wrote most of the logic for looping variables within the complete update function of the VariableArray. +- **AlphasenseCO2** and **TurnerTurbidityPlus** + - **BREAKING** The constructors for both of these analog-based classes have changed! +Previously the constructor required an enum object for the supported differential channels. +The new constructor requires of two different analog channel numbers as inputs for the differential voltage measurement. +If you are using code from a previous version of the library, make sure to update your code to use the new constructor and provide the correct analog channel inputs for the differential voltage measurement. + - Moved resistor settings and calibration values into the following preprocessor defines that can be modified to tweak the library if necessary: + - `ALPHASENSE_CO2_SENSE_RESISTOR_OHM` (defaults to `250.0f`) + - `ALPHASENSE_CO2_MFG_SCALE` (defaults to `312.5f`) + - `ALPHASENSE_CO2_MFG_OFFSET` (defaults to `1250.0f`) + - `ALPHASENSE_CO2_VOLTAGE_MULTIPLIER` (defaults to `1.0f`) + - `TURBIDITY_PLUS_WIPER_TRIGGER_PULSE_MS` (defaults to `50`) + - `TURBIDITY_PLUS_WIPER_ROTATION_WAIT_MS` (defaults to `8000`) + - `TURBIDITY_PLUS_CALIBRATION_EPSILON` (defaults to `1e-4f`) +- **ApogeeSQ212**, **TIADS1x15**, **CampbellOBS3**, and **TurnerCyclops** + - *Potentially breaking* The constructors for all of these analog-based classes have changed! +Previously the I2C address of the ADS1x15 was an optional input parameter which came *before* the optional input parameter for the number of measurements to average. +The input parameter for the I2C address has been *removed* and the input for the number of measurements to average has been moved up in the order! +For users who used the default values, this will have no affect. +For users who provided both a custom I2C address and a custom number of measurements, this will cause a compiler error. +For uses who provided a custom I2C address *but not a custom number of measurements* this will cause a *silent failure* because the custom I2C address will be used as the measurement count and the default I2C address will be used. +Users who need a custom I2C address for the ADS1x15 must construct a TIADS1x15Base object with the correct address and pass a pointer to that object to the constructor. +- **AnalogElecConductivity** + - *Renamed* configuration defines to have the prefix `ANALOGELECCONDUCTIVITY` and moved other defaults to defines. +This affects the following defines: + - `ANALOGELECCONDUCTIVITY_RSERIES_OHMS` (formerly `RSERIES_OHMS_DEF`) + - `ANALOGELECCONDUCTIVITY_KONST` (formerly `SENSOREC_KONST_DEF`) + - `ANALOGELECCONDUCTIVITY_ADC_MAX_RATIO` (formerly a hardcoded value of `0.999f`) +- **EverlightALSPT19** + - Moved the calibration constant between current and lux to the `ALSPT19_UA_PER_1000LUX` preprocessor define. + +#### All Sensors + - Simplified the `addSingleMeasurementResult()` function of all sensors to use an internal function to help set the bits and timing values and to quit sooner if the measurement was not started successfully. - The `verifyAndAddMeasurementResult()` is now consistently used in all sensors and is only called when the sensor successfully returned a measurement response. - Also removed all places where sensor values were re-set to -9999 after a measurement failed and then that -9999 was sent to the `verifyAndAddMeasurementResult()` function. @@ -32,6 +119,23 @@ These resets were an awkward attempt to deal with bad values before feeding any This was probably a hold-over from incorrect implementation and calling of the clearValues function deep in the library history. - Also made the return from the `addSingleMeasurementResult()` function consistently false for a bad sensor response and true for a good one - where it's possible to tell the difference. - The Sensor::clearValues() function now resets the attempt and retry counts in addition to setting all values in the value array to -9999. + +#### Individual Publishers + +- *Renamed* The EnviroDIYPublisher has been renamed the MonitorMyWatershedPublisher. +This reflects changes to the website from years ago. +There is a shell file and typedef to maintain backwards compatibility. + +#### All Publishers + +- Changed capitalization of `setInitialShortIntervals(#)` function + - Previously the 'i' of initial was not capitalized. + - The old `setinitialShortIntervals` remains available via compatibility shim in LoggerBase.h, so existing code is unaffected. + +#### Loggers and Variable Arrays + +- Made the enabling and disabling of the watchdog the very first and very last steps of sleep to keep the watchdog enabled through the whole getting ready for bed and waking up process. +- Re-wrote most of the logic for looping variables within the complete update function of the VariableArray. - Re-wrote some of the logic of the `completeUpdate()` function. Also added optional arguments to the `completeUpdate()` function to allow users to specify if the sensors should be powered/woken. - The `updateAllSensors()` function is now deprecated. @@ -39,12 +143,25 @@ Use `completeUpdate(false, false, false, false)` instead. - Previously the `updateAllSensors()` function asked all sensors to update their values, skipping all power, wake, and sleep steps while the `completeUpdate()` function duplicated that functionality and added the power, wake, and sleep. The two functions have been consolidated into one function with four arguments, one each for power on, wake, sleep, and power off. To achieve the same functionality as the old `updateAllSensors()` function (ie, only updating values), set all the arguments to false. + +#### Library Wide + +- Bumped several dependencies - including crucial bug fixes to SensorModbusMaster. - Applied many suggestions from Code Rabbit AI. - Moved outdated examples to a new "Outdated" folder, with a subfolder for the DRWI examples - When importing TinyGSM for the modem objects, the specific modem client headers are now imported directly rather than importing the TinyGsmClient.h header which defines typedefs for the sub-types. +- Moved the define for the default address used for a TI ADS from multiple individual files to the ModSensorConfig and renamed to `MS_DEFAULT_ADS1X15_ADDRESS`. +- Within ModSensorConfig removed the default `MS_PROCESSOR_ADC_RESOLUTION` for all processors and clarified that the 12 bit default only applies to SAMD processors. +This is *not* breaking because only AVR and SAMD processors were supported anyway. ### Added +#### New Sensors + +- **NEW SENSOR** Added a new sensor for simple analog voltage using the built-in processor ADC + +#### Features for All Sensors + - **Added support for retrying measurements for all sensors**. - Each sensor now supports a number of possible retry attempts for when the sensor returns a bad or no value. The number of retry attempts can be set using the `setAllowedMeasurementRetries(uint8_t)` function. @@ -65,8 +182,21 @@ These values should generally be set in the specific sensor constructors and onl - `setMeasurementTime(uint32_t measurementTime_ms)` - `getMeasurementTime()` - Added the functions `Sensor::clearStatus()`,`Sensor::clearPowerStatus()`,`Sensor::clearWakeStatus()`,and `Sensor::clearMeasurementStatus()` which reset some or all of the sensor status bits and related timing variables. -- **NEW SENSOR** Added a new sensor for simple analog voltage using the built-in processor ADC -- Added KnownProcessors.h and moved defines values for supported built-in sensors on known processors to that file. +- Added an abstract AnalogVoltageBase class with two concrete classes for analog voltage measurements: ProcessorAnalogBase and TIADS1x15Base. +All supported analog sensors can now accept a pointer to an object of any concrete subclass of the AnalogVoltageBase class to use for raw voltage measurements. +By default the existing analog sensors will create an AnalogVoltageBase class object internally for whichever type of ADC (processor or ADS1x15) the sensor was originally coded to use. +This affects the following classes: + - AlphasenseCO2 + - AnalogElecConductivity + - ApogeeSQ212 + - CampbellOBS3 + - EverlightALSPT19 + - TurnerCyclops + - TurnerTurbidityPlus + +#### Library Wide + +- Added KnownProcessors.h and moved defines valued for supported built-in sensors on known processors to that file. - This affects ProcessorStats and the Everlight ALS PT-19. - Added a new example specific to the [EnviroDIY Monitoring Station Kit](https://www.envirodiy.org/product/envirodiy-monitoring-station-kit/). @@ -83,6 +213,8 @@ These values should generally be set in the specific sensor constructors and onl - Fixed major bug where sensors with two power pins where either was shared with another sensor may be turned off inappropriately when one of the other sensors was turned off. - Correctly retry NIST sync on XBees when a not-sane timestamp is returned. +- Improved ADC bit-width handling with explicit type casting for safer arithmetic operations. +Enhanced null-pointer validation and error handling across analog voltage reading paths. *** @@ -1210,4 +1342,4 @@ Our first release of the modular sensors library to support easily logging data - + diff --git a/src/ModSensorConfig.h b/src/ModSensorConfig.h index d72c825b8..f87d9c7cf 100644 --- a/src/ModSensorConfig.h +++ b/src/ModSensorConfig.h @@ -166,7 +166,8 @@ * higher than what your processor actually supports. This does **not** apply to * the TI ADS1115 or ADS1015 external ADS. * - * The default for AVR boards is 10 and for other boards is 12. + * The default for AVR boards is 10 and for SAMD boards is 12. The library + * currently only supports AVR and SAMD platforms. * * Future note: The ESP32 has a 12 bit ADC and the ESP8266 has a 10 bit ADC. */ diff --git a/src/sensors/AlphasenseCO2.cpp b/src/sensors/AlphasenseCO2.cpp index 27d1873ea..d3320644f 100644 --- a/src/sensors/AlphasenseCO2.cpp +++ b/src/sensors/AlphasenseCO2.cpp @@ -66,6 +66,12 @@ bool AlphasenseCO2::addSingleMeasurementResult(void) { F("No analog voltage reader available")); return bumpMeasurementAttemptCount(false); } + // validate the resistor value + if (ALPHASENSE_CO2_SENSE_RESISTOR_OHM <= 0) { + MS_DBG(F(" Error: Invalid sense resistor value"), + ALPHASENSE_CO2_SENSE_RESISTOR_OHM); + return bumpMeasurementAttemptCount(false); + } float adcVoltage = -9999; diff --git a/src/sensors/AlphasenseCO2.h b/src/sensors/AlphasenseCO2.h index f1d703cd1..fd9cbfd0e 100644 --- a/src/sensors/AlphasenseCO2.h +++ b/src/sensors/AlphasenseCO2.h @@ -320,6 +320,8 @@ class AlphasenseCO2 : public Sensor { /** * @brief The second (reference) pin for differential voltage measurements. + * + * @note The primary pin is stored as Sensor::_dataPin. */ int8_t _analogReferenceChannel = -1; /// @brief Pointer to analog voltage reader diff --git a/src/sensors/AnalogElecConductivity.h b/src/sensors/AnalogElecConductivity.h index 15f9c9c41..def30e0d7 100644 --- a/src/sensors/AnalogElecConductivity.h +++ b/src/sensors/AnalogElecConductivity.h @@ -308,10 +308,11 @@ class AnalogElecConductivity : public Sensor { * as analog pins generally are numbered with an "A" in front of the number * - ie, A1. * @param Rseries_ohms The resistance of the resistor series (R) in the - * line; optional with default value of 499. + * line; optional with default value of + * #ANALOGELECCONDUCTIVITY_RSERIES_OHMS (499). * @param sensorEC_Konst The cell constant for the sensing circuit; optional - * with default value of 2.88 - which is what has been measured for a - * typical standard sized lamp-type plug. + * with default value of #ANALOGELECCONDUCTIVITY_KONST (1.0f) - this should + * be calibrated for each specific sensing setup. * @param measurementsToAverage The number of measurements to average; * optional with default value of 1. * @param analogVoltageReader Pointer to an AnalogVoltageBase object for diff --git a/src/sensors/ApogeeSQ212.h b/src/sensors/ApogeeSQ212.h index cfbc8c900..636577018 100644 --- a/src/sensors/ApogeeSQ212.h +++ b/src/sensors/ApogeeSQ212.h @@ -265,6 +265,14 @@ class ApogeeSQ212 : public Sensor { * compatibility, the default reader uses a TI ADS1115 or ADS1015. If a * non-null pointer is supplied, the caller retains ownership and must * ensure its lifetime exceeds that of this object. + * + * @warning In library versions 0.37.0 and earlier, a different constructor + * was used that the I2C address of the ADS1x15 was an optional input + * parameter which came *before* the optional input parameter for the number + * of measurements to average. The input parameter for the I2C address has + * been *removed* and the input for the number of measurements to average + * has been moved up in the order! Please update your code to prevent a + * compiler error or a silent reading error. */ ApogeeSQ212(int8_t powerPin, int8_t analogChannel, uint8_t measurementsToAverage = 1, diff --git a/src/sensors/CampbellOBS3.h b/src/sensors/CampbellOBS3.h index 71a067c81..dc20e3359 100644 --- a/src/sensors/CampbellOBS3.h +++ b/src/sensors/CampbellOBS3.h @@ -261,6 +261,14 @@ class CampbellOBS3 : public Sensor { * compatibility, the default reader uses a TI ADS1115 or ADS1015. If a * non-null pointer is supplied, the caller retains ownership and must * ensure its lifetime exceeds that of this object. + * + * @warning In library versions 0.37.0 and earlier, a different constructor + * was used that the I2C address of the ADS1x15 was an optional input + * parameter which came *before* the optional input parameter for the number + * of measurements to average. The input parameter for the I2C address has + * been *removed* and the input for the number of measurements to average + * has been moved up in the order! Please update your code to prevent a + * compiler error or a silent reading error. */ CampbellOBS3(int8_t powerPin, int8_t analogChannel, float x2_coeff_A, float x1_coeff_B, float x0_coeff_C, diff --git a/src/sensors/EverlightALSPT19.cpp b/src/sensors/EverlightALSPT19.cpp index 452a53628..80ceeadd6 100644 --- a/src/sensors/EverlightALSPT19.cpp +++ b/src/sensors/EverlightALSPT19.cpp @@ -27,7 +27,8 @@ EverlightALSPT19::EverlightALSPT19(int8_t powerPin, int8_t dataPin, _ownsAnalogVoltageReader(analogVoltageReader == nullptr) { // If no analog voltage reader was provided, create a default one if (analogVoltageReader == nullptr) { - _analogVoltageReader = createProcessorAnalogBase(_ownsAnalogVoltageReader); + _analogVoltageReader = + createProcessorAnalogBase(_ownsAnalogVoltageReader); } } #if (defined(BUILT_IN_ALS_POWER_PIN) && defined(BUILT_IN_ALS_DATA_PIN) && \ @@ -72,12 +73,17 @@ bool EverlightALSPT19::addSingleMeasurementResult(void) { F("No analog voltage reader available")); return bumpMeasurementAttemptCount(false); } - // Check if we have a valid load resistor if (_loadResistor <= 0) { MS_DBG(getSensorNameAndLocation(), F("Invalid load resistor value")); return bumpMeasurementAttemptCount(false); } + // Check if we have a valid calibration constant + if (ALSPT19_UA_PER_1000LUX <= 0) { + MS_DBG(getSensorNameAndLocation(), + F("Invalid current-to-lux calibration factor")); + return bumpMeasurementAttemptCount(false); + } float adcVoltage = -9999.0f; @@ -110,13 +116,12 @@ bool EverlightALSPT19::addSingleMeasurementResult(void) { // resistance is entered in kΩ and we want µA float current_val = (adcVoltage / (_loadResistor * 1000.0f)) * 1e6f; MS_DBG(F(" Current:"), current_val, F("µA")); + verifyAndAddMeasurementResult(ALSPT19_CURRENT_VAR_NUM, current_val); // convert current to illuminance // from sensor datasheet, typical 200µA current for 1000 Lux float calibResult = current_val * (1000.0f / ALSPT19_UA_PER_1000LUX); MS_DBG(F(" Illuminance:"), calibResult, F("lux")); - - verifyAndAddMeasurementResult(ALSPT19_CURRENT_VAR_NUM, current_val); verifyAndAddMeasurementResult(ALSPT19_ILLUMINANCE_VAR_NUM, calibResult); } else { MS_DBG(F(" Failed to get valid voltage from analog reader")); diff --git a/src/sensors/PaleoTerraRedox.cpp b/src/sensors/PaleoTerraRedox.cpp index 1c3685c8b..1119b57e5 100644 --- a/src/sensors/PaleoTerraRedox.cpp +++ b/src/sensors/PaleoTerraRedox.cpp @@ -155,7 +155,7 @@ bool PaleoTerraRedox::addSingleMeasurementResult(void) { // Check if this is a negative value (sign bit 17 is set) if (res1 & 0x02) { // Test bit 17 // Sign-extend the 18-bit value to get correct negative magnitude - adcValue |= 0xFF000000; // Sign extend from bit 17 + adcValue |= 0xFFFC0000; // Sign extend from bit 17 (set all bits 18-31) } // convert the raw ADC value to voltage in microvolts (uV) diff --git a/src/sensors/TIADS1x15.cpp b/src/sensors/TIADS1x15.cpp index 9e947eeeb..2787d8bef 100644 --- a/src/sensors/TIADS1x15.cpp +++ b/src/sensors/TIADS1x15.cpp @@ -338,13 +338,15 @@ bool TIADS1x15::addSingleMeasurementResult(void) { _dataPin, _analogReferenceChannel, resultValue); } else { if (_analogReferenceChannel >= 0) { - MS_DBG(F(" Warning: reference channel "), _analogReferenceChannel, - F(" set but pair is not a valid differential config;" - " falling back to single-ended on channel "), - _dataPin); + // Differential was requested but pair is invalid - fail the measurement + MS_DBG(F(" Error: Invalid differential pair ("), _dataPin, F("-"), + _analogReferenceChannel, F("). Measurement failed.")); + success = false; + } else { + // No reference channel specified, use single-ended + success = _analogVoltageReader->readVoltageSingleEnded(_dataPin, + resultValue); } - success = _analogVoltageReader->readVoltageSingleEnded(_dataPin, - resultValue); } if (success) { diff --git a/src/sensors/TIADS1x15.h b/src/sensors/TIADS1x15.h index a51f1c74a..ac028c1db 100644 --- a/src/sensors/TIADS1x15.h +++ b/src/sensors/TIADS1x15.h @@ -465,11 +465,12 @@ class TIADS1x15 : public Sensor { private: /** - * @brief Internal reference to the secondary (reference) analog channel for - * differential measurements + * @brief The second (reference) pin for differential voltage measurements. * * For single-ended measurements: -1 (not used) * For differential measurements: the second ADS channel (0-3) + * + * @note The primary pin is stored as Sensor::_dataPin. */ int8_t _analogReferenceChannel = -1; diff --git a/src/sensors/TurnerCyclops.h b/src/sensors/TurnerCyclops.h index 335a426e1..6c6162f25 100644 --- a/src/sensors/TurnerCyclops.h +++ b/src/sensors/TurnerCyclops.h @@ -350,6 +350,14 @@ class TurnerCyclops : public Sensor { * compatibility, the default reader uses a TI ADS1115 or ADS1015. If a * non-null pointer is supplied, the caller retains ownership and must * ensure its lifetime exceeds that of this object. + * + * @warning In library versions 0.37.0 and earlier, a different constructor + * was used that the I2C address of the ADS1x15 was an optional input + * parameter which came *before* the optional input parameter for the number + * of measurements to average. The input parameter for the I2C address has + * been *removed* and the input for the number of measurements to average + * has been moved up in the order! Please update your code to prevent a + * compiler error or a silent reading error. */ TurnerCyclops(int8_t powerPin, int8_t analogChannel, float conc_std, float volt_std, float volt_blank, diff --git a/src/sensors/TurnerTurbidityPlus.h b/src/sensors/TurnerTurbidityPlus.h index 0b9808e91..0415977da 100644 --- a/src/sensors/TurnerTurbidityPlus.h +++ b/src/sensors/TurnerTurbidityPlus.h @@ -339,6 +339,8 @@ class TurnerTurbidityPlus : public Sensor { /** * @brief The second (reference) pin for differential voltage measurements. + * + * @note The primary pin is stored as Sensor::_dataPin. */ int8_t _analogReferenceChannel = -1; /// @brief Pointer to analog voltage reader From 932c282445f4d7fec65d4cee95b89349446bf464 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Thu, 26 Feb 2026 14:09:42 -0500 Subject: [PATCH 345/533] Spelling and grammar Signed-off-by: Sara Damiano --- ChangeLog.md | 6 +++--- cspell.json | 2 ++ 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/ChangeLog.md b/ChangeLog.md index 5d3f35c61..4d29be1e5 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -99,7 +99,7 @@ Previously the I2C address of the ADS1x15 was an optional input parameter which The input parameter for the I2C address has been *removed* and the input for the number of measurements to average has been moved up in the order! For users who used the default values, this will have no affect. For users who provided both a custom I2C address and a custom number of measurements, this will cause a compiler error. -For uses who provided a custom I2C address *but not a custom number of measurements* this will cause a *silent failure* because the custom I2C address will be used as the measurement count and the default I2C address will be used. +For users who provided a custom I2C address *but not a custom number of measurements* this will cause a *silent failure* because the custom I2C address will be used as the measurement count and the default I2C address will be used. Users who need a custom I2C address for the ADS1x15 must construct a TIADS1x15Base object with the correct address and pass a pointer to that object to the constructor. - **AnalogElecConductivity** - *Renamed* configuration defines to have the prefix `ANALOGELECCONDUCTIVITY` and moved other defaults to defines. @@ -151,7 +151,7 @@ To achieve the same functionality as the old `updateAllSensors()` function (ie, - Moved outdated examples to a new "Outdated" folder, with a subfolder for the DRWI examples - When importing TinyGSM for the modem objects, the specific modem client headers are now imported directly rather than importing the TinyGsmClient.h header which defines typedefs for the sub-types. - Moved the define for the default address used for a TI ADS from multiple individual files to the ModSensorConfig and renamed to `MS_DEFAULT_ADS1X15_ADDRESS`. -- Within ModSensorConfig removed the default `MS_PROCESSOR_ADC_RESOLUTION` for all processors and clarified that the 12 bit default only applies to SAMD processors. +- Within ModSensorConfig removed the default `MS_PROCESSOR_ADC_RESOLUTION` for all processors and clarified that the 12-bit default only applies to SAMD processors. This is *not* breaking because only AVR and SAMD processors were supported anyway. ### Added @@ -214,7 +214,7 @@ This affects the following classes: - Fixed major bug where sensors with two power pins where either was shared with another sensor may be turned off inappropriately when one of the other sensors was turned off. - Correctly retry NIST sync on XBees when a not-sane timestamp is returned. - Improved ADC bit-width handling with explicit type casting for safer arithmetic operations. -Enhanced null-pointer validation and error handling across analog voltage reading paths. +- Enhanced null-pointer validation and error handling across analog voltage reading paths. *** diff --git a/cspell.json b/cspell.json index 805eb56f2..e72a8745d 100644 --- a/cspell.json +++ b/cspell.json @@ -258,6 +258,8 @@ "tiads1x15", "TINYGSM", "TINYUSB", + "TurbHigh", + "TurbLow", "u_blox", "u-blox", "ubee", From 78888c6fd6576779a8a82b8aa86fe9a6ec0b8c5e Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Thu, 26 Feb 2026 14:10:02 -0500 Subject: [PATCH 346/533] Delete copy and move constructors Signed-off-by: Sara Damiano --- src/sensors/ProcessorAnalog.h | 9 +++++++++ src/sensors/TIADS1x15.h | 11 ++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/sensors/ProcessorAnalog.h b/src/sensors/ProcessorAnalog.h index d9bf796d5..b857e87c2 100644 --- a/src/sensors/ProcessorAnalog.h +++ b/src/sensors/ProcessorAnalog.h @@ -279,6 +279,15 @@ class ProcessorAnalog : public Sensor { */ ~ProcessorAnalog(); + // Delete copy constructor and copy assignment operator to prevent shallow + // copies + ProcessorAnalog(const ProcessorAnalog&) = delete; + ProcessorAnalog& operator=(const ProcessorAnalog&) = delete; + + // Delete move constructor and move assignment operator + ProcessorAnalog(ProcessorAnalog&&) = delete; + ProcessorAnalog& operator=(ProcessorAnalog&&) = delete; + String getSensorLocation(void) override; bool addSingleMeasurementResult(void) override; diff --git a/src/sensors/TIADS1x15.h b/src/sensors/TIADS1x15.h index ac028c1db..39cba5c2f 100644 --- a/src/sensors/TIADS1x15.h +++ b/src/sensors/TIADS1x15.h @@ -455,10 +455,19 @@ class TIADS1x15 : public Sensor { uint8_t measurementsToAverage = 1, TIADS1x15Base* analogVoltageReader = nullptr); /** - * @brief Destroy the External Voltage object + * @brief Destroy the TIADS1x15 object */ ~TIADS1x15() override; + // Delete copy constructor and copy assignment operator to prevent shallow + // copies + TIADS1x15(const TIADS1x15&) = delete; + TIADS1x15& operator=(const TIADS1x15&) = delete; + + // Delete move constructor and move assignment operator + TIADS1x15(TIADS1x15&&) = delete; + TIADS1x15& operator=(TIADS1x15&&) = delete; + String getSensorLocation(void) override; bool addSingleMeasurementResult(void) override; From e4f37e8529f2d63167317925cf8cdef0ae53563e Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Thu, 26 Feb 2026 14:19:31 -0500 Subject: [PATCH 347/533] Update examples Signed-off-by: Sara Damiano --- examples/AWS_IoT_Core/AWS_IoT_Core.ino | 6 +- .../DRWI_CitizenScience/DRWI_2G/DRWI_2G.ino | 7 +- .../DRWI_DigiLTE/DRWI_DigiLTE.ino | 5 +- .../DRWI_Mayfly1/DRWI_Mayfly1.ino | 2 +- .../DRWI_NoCellular/DRWI_NoCellular.ino | 5 +- .../DRWI_SIM7080LTE/DRWI_SIM7080LTE.ino | 7 +- .../baro_rho_correction.ino | 2 + examples/double_logger/double_logger.ino | 4 +- .../logging_to_ThingSpeak.ino | 9 +- examples/menu_a_la_carte/menu_a_la_carte.ino | 535 +++++++++++------- 10 files changed, 353 insertions(+), 229 deletions(-) diff --git a/examples/AWS_IoT_Core/AWS_IoT_Core.ino b/examples/AWS_IoT_Core/AWS_IoT_Core.ino index bf960f329..511bc2800 100644 --- a/examples/AWS_IoT_Core/AWS_IoT_Core.ino +++ b/examples/AWS_IoT_Core/AWS_IoT_Core.ino @@ -99,7 +99,7 @@ const int8_t modemLEDPin = redLED; // MCU pin connected an LED to show modem status // Network connection information -const char* wifiId = "YourWiFiSSID"; // The WiFi access point +const char* wifiId = "YourWiFiSSID"; // The WiFi access point const char* wifiPwd = "YourWiFiPassword"; // The WiFi password // Create the loggerModem object @@ -145,8 +145,8 @@ const int8_t alsData = A8; // The ALS PT-19 data pin #else const int8_t alsData = A4; // The ALS PT-19 data pin #endif -const int8_t alsSupply = 3.3; // The ALS PT-19 supply power voltage -const int8_t alsResistance = 10; // The ALS PT-19 loading resistance (in kΩ) +const float alsSupply = 3.3f; // The ALS PT-19 supply power voltage +const int8_t alsResistance = 10; // The ALS PT-19 loading resistance (in kΩ) const uint8_t alsNumberReadings = 10; // Create a Everlight ALS-PT19 sensor object diff --git a/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_2G/DRWI_2G.ino b/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_2G/DRWI_2G.ino index dda5ea11c..dcf7e3c6b 100644 --- a/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_2G/DRWI_2G.ino +++ b/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_2G/DRWI_2G.ino @@ -112,7 +112,6 @@ MaximDS3231 ds3231(1); const int8_t OBS3Power = sensorPowerPin; // Power pin (-1 if unconnected) const uint8_t OBS3NumberReadings = 10; -const uint8_t ADSi2c_addr = 0x48; // The I2C address of the ADS1115 ADC // Campbell OBS 3+ *Low* Range Calibration in Volts const int8_t OBSLowADSChannel = 0; // ADS channel for *low* range output const float OBSLow_A = 0.000E+00; // "A" value (X^2) [*low* range] @@ -121,7 +120,7 @@ const float OBSLow_C = 0.000E+00; // "C" value [*low* range] // Create a Campbell OBS3+ *low* range sensor object CampbellOBS3 osb3low(OBS3Power, OBSLowADSChannel, OBSLow_A, OBSLow_B, OBSLow_C, - ADSi2c_addr, OBS3NumberReadings); + OBS3NumberReadings); // Campbell OBS 3+ *High* Range Calibration in Volts @@ -132,7 +131,7 @@ const float OBSHigh_C = 0.000E+00; // "C" value [*high* range] // Create a Campbell OBS3+ *high* range sensor object CampbellOBS3 osb3high(OBS3Power, OBSHighADSChannel, OBSHigh_A, OBSHigh_B, - OBSHigh_C, ADSi2c_addr, OBS3NumberReadings); + OBSHigh_C, OBS3NumberReadings); /** End [obs3] */ @@ -217,7 +216,7 @@ Logger dataLogger(LoggerID, loggingInterval, &varArray); // Create a data publisher for the Monitor My Watershed POST endpoint #include MonitorMyWatershedPublisher MonitorMWPost(dataLogger, registrationToken, - samplingFeature); + samplingFeature); /** End [publishers] */ diff --git a/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_DigiLTE/DRWI_DigiLTE.ino b/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_DigiLTE/DRWI_DigiLTE.ino index 494852011..5b2ee90d3 100644 --- a/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_DigiLTE/DRWI_DigiLTE.ino +++ b/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_DigiLTE/DRWI_DigiLTE.ino @@ -120,7 +120,6 @@ MaximDS3231 ds3231(1); const int8_t OBS3Power = sensorPowerPin; // Power pin (-1 if unconnected) const uint8_t OBS3NumberReadings = 10; -const uint8_t ADSi2c_addr = 0x48; // The I2C address of the ADS1115 ADC // Campbell OBS 3+ *Low* Range Calibration in Volts const int8_t OBSLowADSChannel = 0; // ADS channel for *low* range output const float OBSLow_A = 0.000E+00; // "A" value (X^2) [*low* range] @@ -129,7 +128,7 @@ const float OBSLow_C = 0.000E+00; // "C" value [*low* range] // Create a Campbell OBS3+ *low* range sensor object CampbellOBS3 osb3low(OBS3Power, OBSLowADSChannel, OBSLow_A, OBSLow_B, OBSLow_C, - ADSi2c_addr, OBS3NumberReadings); + OBS3NumberReadings); // Campbell OBS 3+ *High* Range Calibration in Volts @@ -140,7 +139,7 @@ const float OBSHigh_C = 0.000E+00; // "C" value [*high* range] // Create a Campbell OBS3+ *high* range sensor object CampbellOBS3 osb3high(OBS3Power, OBSHighADSChannel, OBSHigh_A, OBSHigh_B, - OBSHigh_C, ADSi2c_addr, OBS3NumberReadings); + OBSHigh_C, OBS3NumberReadings); /** End [obs3] */ diff --git a/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_Mayfly1/DRWI_Mayfly1.ino b/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_Mayfly1/DRWI_Mayfly1.ino index ba9123dc1..7046785b3 100644 --- a/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_Mayfly1/DRWI_Mayfly1.ino +++ b/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_Mayfly1/DRWI_Mayfly1.ino @@ -85,7 +85,7 @@ const int8_t modemLEDPin = redLED; // MCU pin connected an LED to show modem // Network connection information const char* apn = "YourAPN"; // APN connection name, typically Hologram unless you have a - // different provider's SIM card. Change as needed + // different provider's SIM card. Change as needed // Create the modem object SIMComSIM7080 modem7080(&modemSerial, modemVccPin, modemStatusPin, diff --git a/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_NoCellular/DRWI_NoCellular.ino b/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_NoCellular/DRWI_NoCellular.ino index e74ff348a..66fc3fe75 100644 --- a/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_NoCellular/DRWI_NoCellular.ino +++ b/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_NoCellular/DRWI_NoCellular.ino @@ -83,7 +83,6 @@ MaximDS3231 ds3231(1); const int8_t OBS3Power = sensorPowerPin; // Power pin (-1 if unconnected) const uint8_t OBS3NumberReadings = 10; -const uint8_t ADSi2c_addr = 0x48; // The I2C address of the ADS1115 ADC // Campbell OBS 3+ *Low* Range Calibration in Volts const int8_t OBSLowADSChannel = 0; // ADS channel for *low* range output const float OBSLow_A = 0.000E+00; // "A" value (X^2) [*low* range] @@ -92,7 +91,7 @@ const float OBSLow_C = 0.000E+00; // "C" value [*low* range] // Create a Campbell OBS3+ *low* range sensor object CampbellOBS3 osb3low(OBS3Power, OBSLowADSChannel, OBSLow_A, OBSLow_B, OBSLow_C, - ADSi2c_addr, OBS3NumberReadings); + OBS3NumberReadings); // Campbell OBS 3+ *High* Range Calibration in Volts @@ -103,7 +102,7 @@ const float OBSHigh_C = 0.000E+00; // "C" value [*high* range] // Create a Campbell OBS3+ *high* range sensor object CampbellOBS3 osb3high(OBS3Power, OBSHighADSChannel, OBSHigh_A, OBSHigh_B, - OBSHigh_C, ADSi2c_addr, OBS3NumberReadings); + OBSHigh_C, OBS3NumberReadings); /** End [obs3] */ diff --git a/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_SIM7080LTE/DRWI_SIM7080LTE.ino b/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_SIM7080LTE/DRWI_SIM7080LTE.ino index 0314d2700..4f4b3ac4b 100644 --- a/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_SIM7080LTE/DRWI_SIM7080LTE.ino +++ b/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_SIM7080LTE/DRWI_SIM7080LTE.ino @@ -86,7 +86,7 @@ const int8_t modemLEDPin = redLED; // MCU pin connected an LED to show modem // Network connection information const char* apn = "YourAPN"; // APN connection name, typically Hologram unless you have a - // different provider's SIM card. Change as needed + // different provider's SIM card. Change as needed // Create the modem object SIMComSIM7080 modem7080(&modemSerial, modemVccPin, modemStatusPin, @@ -144,7 +144,6 @@ MeterHydros21 hydros(*hydrosSDI12address, SDI12Power, SDI12Data, const int8_t OBS3Power = sensorPowerPin; // Power pin (-1 if unconnected) const uint8_t OBS3NumberReadings = 10; -const uint8_t ADSi2c_addr = 0x48; // The I2C address of the ADS1115 ADC // Campbell OBS 3+ *Low* Range Calibration in Volts const int8_t OBSLowADSChannel = 0; // ADS channel for *low* range output const float OBSLow_A = 0.000E+00; // "A" value (X^2) [*low* range] @@ -153,7 +152,7 @@ const float OBSLow_C = 0.000E+00; // "C" value [*low* range] // Create a Campbell OBS3+ *low* range sensor object CampbellOBS3 osb3low(OBS3Power, OBSLowADSChannel, OBSLow_A, OBSLow_B, OBSLow_C, - ADSi2c_addr, OBS3NumberReadings); + OBS3NumberReadings); // Campbell OBS 3+ *High* Range Calibration in Volts @@ -164,7 +163,7 @@ const float OBSHigh_C = 0.000E+00; // "C" value [*high* range] // Create a Campbell OBS3+ *high* range sensor object CampbellOBS3 osb3high(OBS3Power, OBSHighADSChannel, OBSHigh_A, OBSHigh_B, - OBSHigh_C, ADSi2c_addr, OBS3NumberReadings); + OBSHigh_C, OBS3NumberReadings); /** End [obs3] */ diff --git a/examples/baro_rho_correction/baro_rho_correction.ino b/examples/baro_rho_correction/baro_rho_correction.ino index 4974769e6..82edd8db3 100644 --- a/examples/baro_rho_correction/baro_rho_correction.ino +++ b/examples/baro_rho_correction/baro_rho_correction.ino @@ -483,3 +483,5 @@ void loop() { } } /** End [loop] */ + +// cspell: words baro diff --git a/examples/double_logger/double_logger.ino b/examples/double_logger/double_logger.ino index 0537b2d03..1219147bc 100644 --- a/examples/double_logger/double_logger.ino +++ b/examples/double_logger/double_logger.ino @@ -77,7 +77,7 @@ const int8_t modemLEDPin = redLED; // MCU pin connected an LED to show modem // status (-1 if unconnected) // Network connection information -const char* wifiId = "YourWiFiSSID"; // The WiFi access point +const char* wifiId = "YourWiFiSSID"; // The WiFi access point const char* wifiPwd = "YourWiFiPassword"; // The WiFi password DigiXBeeWifi modemXBWF(&modemSerial, modemVccPin, modemStatusPin, @@ -360,3 +360,5 @@ void loop() { logger1min.systemSleep(); } /** End [loop] */ + +// cspell: words modemXBWF diff --git a/examples/logging_to_ThingSpeak/logging_to_ThingSpeak.ino b/examples/logging_to_ThingSpeak/logging_to_ThingSpeak.ino index 816aacbb8..9df2e7281 100644 --- a/examples/logging_to_ThingSpeak/logging_to_ThingSpeak.ino +++ b/examples/logging_to_ThingSpeak/logging_to_ThingSpeak.ino @@ -76,7 +76,7 @@ const int8_t modemLEDPin = redLED; // MCU pin connected an LED to show modem status // Network connection information -const char* wifiId = "YourWiFiSSID"; // The WiFi access point +const char* wifiId = "YourWiFiSSID"; // The WiFi access point const char* wifiPwd = "YourWiFiPassword"; // The WiFi password // Create the loggerModem object @@ -118,7 +118,6 @@ MaximDS3231 ds3231(1); const int8_t OBS3Power = sensorPowerPin; // Power pin (-1 if unconnected) const uint8_t OBS3NumberReadings = 10; -const uint8_t ADSi2c_addr = 0x48; // The I2C address of the ADS1115 ADC // Campbell OBS 3+ *Low* Range Calibration in Volts const int8_t OBSLowADSChannel = 0; // ADS channel for *low* range output const float OBSLow_A = 0.000E+00; // "A" value (X^2) [*low* range] @@ -127,7 +126,7 @@ const float OBSLow_C = 0.000E+00; // "C" value [*low* range] // Create a Campbell OBS3+ *low* range sensor object CampbellOBS3 osb3low(OBS3Power, OBSLowADSChannel, OBSLow_A, OBSLow_B, OBSLow_C, - ADSi2c_addr, OBS3NumberReadings); + OBS3NumberReadings); // Campbell OBS 3+ *High* Range Calibration in Volts @@ -138,7 +137,7 @@ const float OBSHigh_C = 0.000E+00; // "C" value [*high* range] // Create a Campbell OBS3+ *high* range sensor object CampbellOBS3 osb3high(OBS3Power, OBSHighADSChannel, OBSHigh_A, OBSHigh_B, - OBSHigh_C, ADSi2c_addr, OBS3NumberReadings); + OBSHigh_C, OBS3NumberReadings); /** End [obs3] */ @@ -350,3 +349,5 @@ void loop() { } } /** End [loop] */ + +// cSpell: words TurbHigh TurbLow setRESTAPIKey diff --git a/examples/menu_a_la_carte/menu_a_la_carte.ino b/examples/menu_a_la_carte/menu_a_la_carte.ino index c9db0641e..6c9330775 100644 --- a/examples/menu_a_la_carte/menu_a_la_carte.ino +++ b/examples/menu_a_la_carte/menu_a_la_carte.ino @@ -998,23 +998,35 @@ Variable* ds3231Temp = // ========================================================================== /** Start [alphasense_co2] */ #include +#include // NOTE: Use -1 for any pins that don't apply or aren't being used. -const int8_t AlphasenseCO2Power = sensorPowerPin; // Power pin -aco2_adsDiffMux_t AlphasenseDiffMux = - DIFF_MUX_2_3; // Differential voltage config -const uint8_t AlphasenseCO2ADSi2c_addr = - 0x48; // The I2C address of the ADS1115 ADC +const int8_t asCO2Power = sensorPowerPin; // Power pin +const int8_t asCO2Channel1 = 2; // First differential channel +const int8_t asCO2Channel2 = 3; // Second differential channel +const uint8_t asCO2Meas = 1; // Second differential channel // Create an Alphasense CO2 sensor object -AlphasenseCO2 alphasenseCO2(AlphasenseCO2Power, AlphasenseDiffMux, - AlphasenseCO2ADSi2c_addr); +AlphasenseCO2 alphasenseCO2(asCO2Power, asCO2Channel1, asCO2Channel2, + asCO2Meas); // Create PAR and raw voltage variable pointers for the CO2 Variable* asCO2 = new AlphasenseCO2_CO2(&alphasenseCO2, "12345678-abcd-1234-ef00-1234567890ab"); Variable* asco2voltage = new AlphasenseCO2_Voltage( &alphasenseCO2, "12345678-abcd-1234-ef00-1234567890ab"); + +// create a custom analog reader based on the TI ADS1115 (optional) +float AsCO2Multiplier = 1.0f; // factor for a voltage divider +adsGain_t AsCO2AdsGain = GAIN_ONE; // gain of the ADS1115 +float AsCO2adsSupply = 3.3f; // supply voltage of the ADS1115 +const uint8_t AsCO2i2c_addr = 0x48; // The I2C address of the ADS1115 ADC +TIADS1x15Base AsCO2ADS(AsCO2Multiplier, AsCO2AdsGain, AsCO2adsSupply, + AsCO2i2c_addr); + +// Create an Alphasense CO2 sensor object with the custom TIADS1x15Base +AlphasenseCO2 alphasenseCO2_c(asCO2Power, asCO2Channel1, asCO2Channel2, + asCO2Meas, &AsCO2ADS); /** End [alphasense_co2] */ #endif @@ -1035,14 +1047,14 @@ Variable* asco2voltage = new AlphasenseCO2_Voltage( // NOTE: Use -1 for any pins that don't apply or aren't being used. byte anbModbusAddress = 0x55; // The modbus address of ANB pH Sensor (0x55 is the default) -const int8_t anbPower = sensorPowerPin; // ANB pH Sensor power pin -const int8_t alAdapterPower = sensorPowerPin; // RS485 adapter power pin -const int8_t al485EnablePin = -1; // Adapter RE/DE pin -const uint8_t anbNumberReadings = 1; +const int8_t anbPower = sensorPowerPin; // ANB pH Sensor power pin +const int8_t alAdapterPower = sensorPowerPin; // RS485 adapter power pin +const int8_t al485EnablePin = -1; // Adapter RE/DE pin +const uint8_t anbNReadings = 1; // Create an ANB pH sensor object ANBpH anbPH(anbModbusAddress, modbusSerial, anbPower, loggingInterval, - alAdapterPower, al485EnablePin, anbNumberReadings); + alAdapterPower, al485EnablePin, anbNReadings); // Create all of the variable pointers for the ANB pH sensor Variable* anbPHValue = new ANBpH_pH(&anbPH, @@ -1120,20 +1132,32 @@ Variable* dhtHI = new AOSongDHT_HI(&dht, // ========================================================================== /** Start [apogee_sq212] */ #include +#include // NOTE: Use -1 for any pins that don't apply or aren't being used. -const int8_t SQ212Power = sensorPowerPin; // Power pin -const int8_t SQ212ADSChannel = 3; // The ADS channel for the SQ212 -const uint8_t SQ212ADSi2c_addr = 0x48; // The I2C address of the ADS1115 ADC +const int8_t sq212Power = sensorPowerPin; // Power pin +const int8_t sq212ADSChannel = 3; // The ADS channel for the SQ212 +const uint8_t sq212Readings = 1; // The ADS channel for the SQ212 -// Create an Apogee SQ212 sensor object -ApogeeSQ212 SQ212(SQ212Power, SQ212ADSChannel, SQ212ADSi2c_addr); +// Create an Apogee SQ212 sensor object with the default voltage reader +ApogeeSQ212 sq212(sq212Power, sq212ADSChannel); // Create PAR and raw voltage variable pointers for the SQ212 Variable* sq212PAR = - new ApogeeSQ212_PAR(&SQ212, "12345678-abcd-1234-ef00-1234567890ab"); + new ApogeeSQ212_PAR(&sq212, "12345678-abcd-1234-ef00-1234567890ab"); Variable* sq212voltage = - new ApogeeSQ212_Voltage(&SQ212, "12345678-abcd-1234-ef00-1234567890ab"); + new ApogeeSQ212_Voltage(&sq212, "12345678-abcd-1234-ef00-1234567890ab"); + +// create a custom analog reader based on the TI ADS1115 (optional) +float sq212Multiplier = 1.0f; // factor for a voltage divider +adsGain_t sq212AdsGain = GAIN_ONE; // gain of the ADS1115 +float sq212adsSupply = 3.3f; // supply voltage of the ADS1115 +const uint8_t sq212i2c_addr = 0x48; // The I2C address of the ADS1115 ADC +TIADS1x15Base sq212ADS(sq212Multiplier, sq212AdsGain, sq212adsSupply, + sq212i2c_addr); + +// Create an Apogee SQ212 sensor object with the custom TIADS1x15Base +ApogeeSQ212 sq212_c(sq212Power, sq212ADSChannel, sq212Readings, &sq212ADS); /** End [apogee_sq212] */ #endif @@ -1436,11 +1460,12 @@ Variable* clarivueError = new CampbellClariVUE10_ErrorCode( // ========================================================================== /** Start [campbell_obs3] */ #include +#include // NOTE: Use -1 for any pins that don't apply or aren't being used. -const int8_t OBS3Power = sensorPowerPin; // Power pin -const uint8_t OBS3NumberReadings = 10; -const uint8_t OBS3ADSi2c_addr = 0x48; // The I2C address of the ADS1115 ADC +const int8_t OBS3Power = sensorPowerPin; // Power pin +const uint8_t OBS3NReadings = 10; +const uint8_t OBS3AdsI2C_addr = 0x48; // The I2C address of the ADS1115 ADC const int8_t OBSLowADSChannel = 0; // ADS channel for *low* range output @@ -1451,7 +1476,7 @@ const float OBSLow_C = 0.000E+00; // "C" value [*low* range] // Create a Campbell OBS3+ *low* range sensor object CampbellOBS3 osb3low(OBS3Power, OBSLowADSChannel, OBSLow_A, OBSLow_B, OBSLow_C, - OBS3ADSi2c_addr, OBS3NumberReadings); + OBS3NReadings); // Create turbidity and voltage variable pointers for the low range of the OBS3 Variable* obs3TurbLow = new CampbellOBS3_Turbidity( @@ -1469,13 +1494,31 @@ const float OBSHigh_C = 0.000E+00; // "C" value [*high* range] // Create a Campbell OBS3+ *high* range sensor object CampbellOBS3 osb3high(OBS3Power, OBSHighADSChannel, OBSHigh_A, OBSHigh_B, - OBSHigh_C, OBS3ADSi2c_addr, OBS3NumberReadings); + OBSHigh_C, OBS3NReadings); // Create turbidity and voltage variable pointers for the high range of the OBS3 Variable* obs3TurbHigh = new CampbellOBS3_Turbidity( &osb3high, "12345678-abcd-1234-ef00-1234567890ab", "TurbHigh"); Variable* obs3VoltHigh = new CampbellOBS3_Voltage( &osb3high, "12345678-abcd-1234-ef00-1234567890ab", "TurbHighV"); + +// create a custom analog reader based on the TI ADS1115 (optional) +float OBS3Multiplier = 1.0f; // factor for a voltage divider +adsGain_t OBS3AdsGain = GAIN_ONE; // gain of the ADS1115 +float OBS3AdsSupplyVoltage = 3.3f; // supply voltage of the ADS1115 +const uint8_t OBS3AdsI2C_addr = 0x48; // The I2C address of the ADS1115 ADC +TIADS1x15Base OBSADS(OBS3Multiplier, OBS3AdsGain, OBS3AdsSupplyVoltage, + OBS3AdsI2C_addr); + +// Create a Campbell OBS3+ *low* range sensor object with the custom +// TIADS1x15Base +CampbellOBS3 osb3low_c(OBS3Power, OBSLowADSChannel, OBSLow_A, OBSLow_B, + OBSLow_C, OBS3NReadings, &OBSADS); + +// Create a Campbell OBS3+ *high* range sensor object with the custom +// TIADS1x15Base +CampbellOBS3 osb3high_c(OBS3Power, OBSHighADSChannel, OBSHigh_A, OBSHigh_B, + OBSHigh_C, OBS3NReadings, &OBSADS); /** End [campbell_obs3] */ #endif @@ -1517,13 +1560,13 @@ Variable* rainvueRainRateMax = new CampbellRainVUE10_RainRateMax( #include // NOTE: Use -1 for any pins that don't apply or aren't being used. -const char* CTDSDI12address = "1"; // The SDI-12 Address of the CTD -const uint8_t CTDNumberReadings = 6; // The number of readings to average -const int8_t CTDPower = sensorPowerPin; // Power pin -const int8_t CTDData = sdi12DataPin; // The SDI-12 data pin +const char* CTDSDI12address = "1"; // The SDI-12 Address of the CTD +const uint8_t CTDNReadings = 6; // The number of readings to average +const int8_t CTDPower = sensorPowerPin; // Power pin +const int8_t CTDData = sdi12DataPin; // The SDI-12 data pin // Create a Decagon CTD sensor object -DecagonCTD ctd(*CTDSDI12address, CTDPower, CTDData, CTDNumberReadings); +DecagonCTD ctd(*CTDSDI12address, CTDPower, CTDData, CTDNReadings); // Create conductivity, temperature, and depth variable pointers for the CTD Variable* ctdCond = new DecagonCTD_Cond(&ctd, @@ -1544,13 +1587,13 @@ Variable* ctdDepth = #include // NOTE: Use -1 for any pins that don't apply or aren't being used. -const char* ES2SDI12address = "3"; // The SDI-12 Address of the ES2 -const int8_t ES2Power = sensorPowerPin; // Power pin -const int8_t ES2Data = sdi12DataPin; // The SDI-12 data pin -const uint8_t ES2NumberReadings = 5; +const char* ES2SDI12address = "3"; // The SDI-12 Address of the ES2 +const int8_t ES2Power = sensorPowerPin; // Power pin +const int8_t ES2Data = sdi12DataPin; // The SDI-12 data pin +const uint8_t ES2NReadings = 5; // Create a Decagon ES2 sensor object -DecagonES2 es2(*ES2SDI12address, ES2Power, ES2Data, ES2NumberReadings); +DecagonES2 es2(*ES2SDI12address, ES2Power, ES2Data, ES2NReadings); // Create specific conductance and temperature variable pointers for the ES2 Variable* es2Cond = new DecagonES2_Cond(&es2, @@ -1567,6 +1610,7 @@ Variable* es2Temp = new DecagonES2_Temp(&es2, // ========================================================================== /** Start [everlight_alspt19] */ #include +#include // NOTE: Use -1 for any pins that don't apply or aren't being used. const int8_t alsPower = sensorPowerPin; // Power pin @@ -1577,14 +1621,15 @@ const int8_t alsData = A4; // The ALS PT-19 data pin #endif const int8_t alsSupply = 3.3; // The ALS PT-19 supply power voltage const int8_t alsResistance = 10; // The ALS PT-19 loading resistance (in kΩ) -const uint8_t alsNumberReadings = 10; +const uint8_t alsNReadings = 10; // Create a Everlight ALS-PT19 sensor object EverlightALSPT19 alsPt19(alsPower, alsData, alsSupply, alsResistance, - alsNumberReadings); + alsNReadings); -// For an EnviroDIY Mayfly, you can use the abbreviated version -// EverlightALSPT19 alsPt19(alsNumberReadings); +// For a board with ALS parameters set in KnownProcessors.h (ie, an EnviroDIY +// Mayfly or Stonefly), you can simply do: +// EverlightALSPT19 alsPt19_mf(alsNReadings); // Create voltage, current, and illuminance variable pointers for the ALS-PT19 Variable* alsPt19Volt = new EverlightALSPT19_Voltage( @@ -1592,7 +1637,17 @@ Variable* alsPt19Volt = new EverlightALSPT19_Voltage( Variable* alsPt19Current = new EverlightALSPT19_Current( &alsPt19, "12345678-abcd-1234-ef00-1234567890ab"); Variable* alsPt19Lux = new EverlightALSPT19_Illuminance( - &alsPt19, "12345678-abcd-1234-ef00-1234567890ab"); + &alsPt19, "b7cf9961-246a-4443-b57f-0526fecfea8f"); + +// create a custom analog reader based on the Processor ADC (optional) +float alsMultiplier = 1.0f; // factor for a voltage divider +float alsAdsSupply = 3.3f; // supply voltage of the Processor ADC +ProcessorAnalogBase alsADS(alsMultiplier, alsAdsSupply); + +// Create an Everlight ALS-PT19 sensor object with the custom +// ProcessorAnalogBase +EverlightALSPT19 alsPt19_c(alsPower, alsData, alsSupply, alsResistance, + alsNReadings, &alsADS); /** End [everlight_alspt19] */ #endif @@ -1605,19 +1660,32 @@ Variable* alsPt19Lux = new EverlightALSPT19_Illuminance( #include // NOTE: Use -1 for any pins that don't apply or aren't being used. -const int8_t ADSPower = sensorPowerPin; // Power pin -const int8_t ADSChannel = 2; // The ADS channel of interest -const float voltageMultiplier = - 1.0f; // Voltage multiplier for an external voltage divider -// use 1.0f for direct connection -// use (R_top + R_bottom) / R_bottom for voltage divider -const adsGain_t adsPGAGain = GAIN_ONE; // The internal gain setting for the ADS -const uint8_t evADSi2c_addr = 0x48; // The I2C address of the ADS1115 ADC -const uint8_t VoltReadsToAvg = 1; // Only read one sample - -// Create a TI ADS1x15 sensor object -TIADS1x15 ads1x15(ADSPower, ADSChannel, voltageMultiplier, adsPGAGain, - evADSi2c_addr, VoltReadsToAvg); +const int8_t evADSPower = sensorPowerPin; // Power pin +const int8_t evADSChannel1 = + 2; // The first ADS channel (or only for single-ended readings) +const int8_t evADSChannel2 = + 3; // The second ADS channel (for differential readings). Pass -1 for + // single-ended readings. +const uint8_t evReadsToAvg = 1; // Only read one sample + +// Create a single-ended External Voltage sensor object with the default +// TIADS1x15Base +TIADS1x15 ads1x15(evADSPower, evADSChannel1); +// Create a differential External Voltage sensor object with the default +// TIADS1x15Base +TIADS1x15 ads1x15_d(evADSPower, evADSChannel1, evADSChannel2); + +// create a custom ADS instance (optional) +float evVoltageMultiplier = 1.0f; // factor for a voltage divider +adsGain_t evAdsGain = GAIN_ONE; // gain of the ADS1115 +float evAdsSupplyVoltage = 3.3f; // supply voltage of the ADS1115 +const uint8_t evAdsI2C_addr = 0x48; // The I2C address of the ADS1115 ADC +TIADS1x15Base evADS(evVoltageMultiplier, evAdsGain, evAdsSupplyVoltage, + evAdsI2C_addr); + +// Create a single ended External Voltage sensor object with the custom +// TIADS1x15Base +TIADS1x15 ads1x15_c(evADSPower, evADSChannel1, -1, evReadsToAvg, &evADS); // Create a voltage variable pointer Variable* ads1x15Volt = @@ -1634,20 +1702,29 @@ Variable* ads1x15Volt = #include // NOTE: Use -1 for any pins that don't apply or aren't being used. -const int8_t processorAnalogPowerPin = sensorPowerPin; // Power pin -const int8_t processorAnalogDataPin = A0; // Analog input pin (processor ADC) -const float processorAnalogMultiplier = - 5.58; // Gain setting if using a voltage divider -const uint8_t eaReadsToAvg = 1; // Only read one sample - -// Create an Processor Analog sensor object -ProcessorAnalog extAnalog(processorAnalogPowerPin, processorAnalogDataPin, - processorAnalogMultiplier, OPERATING_VOLTAGE, - eaReadsToAvg); +const int8_t processorAnalogPowerPin = sensorPowerPin; // Power pin +const int8_t processorAnalogDataPin = A0; // Analog input pin (processor ADC) +const uint8_t processorAnalogNReadings = 1; // Only read one sample + +// Create a Processor Analog sensor object with the default ProcessorAnalogBase +ProcessorAnalog processorAnalog(processorAnalogPowerPin, processorAnalogDataPin, + processorAnalogNReadings); + +// create a custom analog reader based on the Processor ADC (optional) +float processorAnalogMultiplier = 1.0f; // factor for a voltage divider +float processorAnalogSupply = 3.3f; // supply voltage of the Processor ADC +ProcessorAnalogBase processorAnalogBaseCustom(processorAnalogMultiplier, + processorAnalogSupply); + +// Create a Processor Analog sensor object with the custom ProcessorAnalogBase +ProcessorAnalog processorAnalog_c(processorAnalogPowerPin, + processorAnalogDataPin, + processorAnalogNReadings, + &processorAnalogBaseCustom); // Create a voltage variable pointer -Variable* extAnalogVolts = new ProcessorAnalog_Voltage( - &extAnalog, "12345678-abcd-1234-ef00-1234567890ab"); +Variable* processorAnalogVolts = new ProcessorAnalog_Voltage( + &processorAnalog, "12345678-abcd-1234-ef00-1234567890ab"); /** End [processor_analog] */ #endif @@ -1719,16 +1796,16 @@ Variable* hydrocamByteError = new GeoluxHydroCam_ByteError( // NOTE: Use -1 for any pins that don't apply or aren't being used. byte gplp8ModbusAddress = 0x19; // The modbus address of the gplp8 // Raw Request >>> {0x19, 0x03, 0x00, 0xC8, 0x00, 0x01, 0x06, 0x2C} -const int8_t gplp8AdapterPower = sensorPowerPin; // RS485 adapter power pin -const int8_t gplp8SensorPower = relayPowerPin; // Sensor power pin -const int8_t gplp8EnablePin = -1; // Adapter RE/DE pin -const uint8_t gplp8NumberReadings = 1; +const int8_t gplp8AdapterPower = sensorPowerPin; // RS485 adapter power pin +const int8_t gplp8SensorPower = relayPowerPin; // Sensor power pin +const int8_t gplp8EnablePin = -1; // Adapter RE/DE pin +const uint8_t gplp8NReadings = 1; // The manufacturer recommends averaging 10 readings, but we take 5 to minimize // power consumption // Create a GroPoint Profile GPLP-8 sensor object GroPointGPLP8 gplp8(gplp8ModbusAddress, modbusSerial, gplp8AdapterPower, - gplp8SensorPower, gplp8EnablePin, gplp8NumberReadings); + gplp8SensorPower, gplp8EnablePin, gplp8NReadings); // Create moisture variable pointers for each segment of the GPLP-8 Variable* gplp8Moist1 = new GroPointGPLP8_Moist( @@ -1787,13 +1864,13 @@ Variable* gplp8Temp13 = new GroPointGPLP8_Temp( #include // NOTE: Use -1 for any pins that don't apply or aren't being used. -const char* RDOSDI12address = "5"; // The SDI-12 Address of the RDO PRO-X -const int8_t RDOPower = sensorPowerPin; // Power pin -const int8_t RDOData = sdi12DataPin; // The SDI-12 data pin -const uint8_t RDONumberReadings = 3; +const char* rdoSDI12address = "5"; // The SDI-12 Address of the RDO PRO-X +const int8_t rdoPower = sensorPowerPin; // Power pin +const int8_t rdoData = sdi12DataPin; // The SDI-12 data pin +const uint8_t rdoNReadings = 3; // Create an In-Situ RDO PRO-X dissolved oxygen sensor object -InSituRDO insituRDO(*RDOSDI12address, RDOPower, RDOData, RDONumberReadings); +InSituRDO insituRDO(*rdoSDI12address, rdoPower, rdoData, rdoNReadings); // Create dissolved oxygen percent, dissolved oxygen concentration, temperature, // and oxygen partial pressure variable pointers for the RDO PRO-X @@ -1817,16 +1894,16 @@ Variable* rdoO2pp = #include // NOTE: Use -1 for any pins that don't apply or aren't being used. -const char* TROLLSDI12address = +const char* trollSDI12address = "1"; // The SDI-12 Address of the Aqua/Level TROLL -const int8_t TROLLPower = +const int8_t trollPower = sensorPowerPin; // Pin to switch power on and off (-1 if unconnected) -const int8_t TROLLData = sdi12DataPin; // The SDI-12 data pin -const uint8_t TROLLNumberReadings = 2; // The number of readings to average +const int8_t trollData = sdi12DataPin; // The SDI-12 data pin +const uint8_t trollNReadings = 2; // The number of readings to average // Create an In-Situ TROLL sensor object -InSituTrollSdi12a insituTROLL(*TROLLSDI12address, TROLLPower, TROLLData, - TROLLNumberReadings); +InSituTrollSdi12a insituTROLL(*trollSDI12address, trollPower, trollData, + trollNReadings); // Create pressure, temperature, and depth variable pointers for the TROLL Variable* trollPressure = new InSituTrollSdi12a_Pressure( @@ -1857,13 +1934,12 @@ byte acculevelModbusAddress = 0x01; // The modbus address of KellerAcculevel const int8_t acculevelPower = relayPowerPin; // Acculevel Sensor power pin const int8_t alAdapterPower = sensorPowerPin; // RS485 adapter power pin const int8_t al485EnablePin = -1; // Adapter RE/DE pin -const uint8_t acculevelNumberReadings = 5; +const uint8_t acculevelNReadings = 5; // The manufacturer recommends taking and averaging a few readings // Create a Keller Acculevel sensor object KellerAcculevel acculevel(acculevelModbusAddress, modbusSerial, alAdapterPower, - acculevelPower, al485EnablePin, - acculevelNumberReadings); + acculevelPower, al485EnablePin, acculevelNReadings); // Create pressure, temperature, and height variable pointers for the Acculevel Variable* acculevPress = new KellerAcculevel_Pressure( @@ -1894,13 +1970,12 @@ byte nanolevelModbusAddress = 0x01; // The modbus address of KellerNanolevel const int8_t nlAdapterPower = sensorPowerPin; // RS485 adapter power pin const int8_t nanolevelPower = relayPowerPin; // Sensor power pin const int8_t nl485EnablePin = -1; // Adapter RE/DE pin -const uint8_t nanolevelNumberReadings = 5; +const uint8_t nanolevelNReadings = 5; // The manufacturer recommends taking and averaging a few readings // Create a Keller Nanolevel sensor object KellerNanolevel nanolevel(nanolevelModbusAddress, modbusSerial, nlAdapterPower, - nanolevelPower, nl485EnablePin, - nanolevelNumberReadings); + nanolevelPower, nl485EnablePin, nanolevelNReadings); // Create pressure, temperature, and height variable pointers for the Nanolevel Variable* nanolevPress = new KellerNanolevel_Pressure( @@ -1930,12 +2005,12 @@ Variable* nanolevHeight = new KellerNanolevel_Height( const int8_t SonarPower = sensorPowerPin; // Excite (power) pin const int8_t Sonar1Trigger = -1; // Trigger pin // Trigger should be a *unique* negative number if unconnected -const int16_t Sonar1MaxRange = 9999; // Maximum range of sonar -const uint8_t sonar1NumberReadings = 3; // The number of readings to average +const int16_t Sonar1MaxRange = 9999; // Maximum range of sonar +const uint8_t sonar1NReadings = 3; // The number of readings to average // Create a MaxBotix Sonar sensor object MaxBotixSonar sonar1(sonarSerial, SonarPower, Sonar1Trigger, Sonar1MaxRange, - sonar1NumberReadings); + sonar1NReadings); // Create an ultrasonic range variable pointer Variable* sonar1Range = @@ -1957,12 +2032,12 @@ Variable* sonar1Range = DeviceAddress OneWireAddress1 = {0x28, 0xFF, 0xBD, 0xBA, 0x81, 0x16, 0x03, 0x0C}; // NOTE: Use -1 for any pins that don't apply or aren't being used. -const int8_t OneWirePower = sensorPowerPin; // Power pin -const int8_t OneWireBus = A0; // OneWire Bus Pin -const int8_t ds18NumberReadings = 3; +const int8_t OneWirePower = sensorPowerPin; // Power pin +const int8_t OneWireBus = A0; // OneWire Bus Pin +const int8_t ds18NReadings = 3; // Create a Maxim DS18 sensor objects (use this form for a known address) -MaximDS18 ds18(OneWireAddress1, OneWirePower, OneWireBus, ds18NumberReadings); +MaximDS18 ds18(OneWireAddress1, OneWirePower, OneWireBus, ds18NReadings); // Create a Maxim DS18 sensor object (use this form for a single sensor on bus // with an unknown address) @@ -2039,13 +2114,13 @@ Variable* fivetmTemp = // NOTE: Use -1 for any pins that don't apply or aren't being used. const char* hydros21SDI12address = "1"; // The SDI-12 Address of the Hydros21 -const uint8_t hydros21NumberReadings = 6; // The number of readings to average -const int8_t hydros21Power = sensorPowerPin; // Power pin -const int8_t hydros21Data = sdi12DataPin; // The SDI-12 data pin +const uint8_t hydros21NReadings = 6; // The number of readings to average +const int8_t hydros21Power = sensorPowerPin; // Power pin +const int8_t hydros21Data = sdi12DataPin; // The SDI-12 data pin // Create a Decagon Hydros21 sensor object MeterHydros21 hydros21(*hydros21SDI12address, hydros21Power, hydros21Data, - hydros21NumberReadings); + hydros21NReadings); // Create conductivity, temperature, and depth variable pointers for the // Hydros21 @@ -2070,11 +2145,11 @@ Variable* hydros21Depth = const char* teros11SDI12address = "4"; // The SDI-12 Address of the Teros 11 const int8_t terosPower = sensorPowerPin; // Power pin const int8_t terosData = sdi12DataPin; // The SDI-12 data pin -const uint8_t teros11NumberReadings = 3; // The number of readings to average +const uint8_t teros11NReadings = 3; // The number of readings to average // Create a METER TEROS 11 sensor object MeterTeros11 teros11(*teros11SDI12address, terosPower, terosData, - teros11NumberReadings); + teros11NReadings); // Create the matric potential, volumetric water content, and temperature // variable pointers for the Teros 11 @@ -2236,11 +2311,13 @@ Variable* inaPower = new TIINA219_Power(&ina219, // ========================================================================== /** Start [turner_cyclops] */ #include +#include +#include // NOTE: Use -1 for any pins that don't apply or aren't being used. -const int8_t cyclopsPower = sensorPowerPin; // Power pin -const uint8_t cyclopsNumberReadings = 10; -const uint8_t cyclopsADSi2c_addr = 0x48; // The I2C address of the ADS1115 ADC +const int8_t cyclopsPower = sensorPowerPin; // Power pin +const uint8_t cyclopsNReadings = 10; +const uint8_t cyclopsAdsI2C_addr = 0x48; // The I2C address of the ADS1115 ADC const int8_t cyclopsADSChannel = 0; // ADS channel // Cyclops calibration information @@ -2253,8 +2330,7 @@ const float cyclopsBlankVolt = // Create a Turner Cyclops sensor object TurnerCyclops cyclops(cyclopsPower, cyclopsADSChannel, cyclopsStdConc, - cyclopsStdVolt, cyclopsBlankVolt, cyclopsADSi2c_addr, - cyclopsNumberReadings); + cyclopsStdVolt, cyclopsBlankVolt, cyclopsNReadings); // Create the voltage variable pointer - used for any type of Cyclops Variable* cyclopsVoltage = @@ -2288,6 +2364,29 @@ Variable* cyclopsTryptophan = new TurnerCyclops_Tryptophan( &cyclops, "12345678-abcd-1234-ef00-1234567890ab"); Variable* cyclopsRedChloro = new TurnerCyclops_RedChlorophyll( &cyclops, "12345678-abcd-1234-ef00-1234567890ab"); + +// create a custom analog reader based on the TI ADS1115 (optional) +float cyclopsMultiplier = 1.0f; // factor for a voltage divider +adsGain_t cyclopsAdsGain = GAIN_ONE; // gain of the ADS1115 +float cyclopsAdsSupplyVoltage = 3.3f; // supply voltage of the ADS1115 +const uint8_t cyclopsAdsI2C_addr = 0x48; // The I2C address of the ADS1115 ADC +TIADS1x15Base cyclopsADS(cyclopsMultiplier, cyclopsAdsGain, + cyclopsAdsSupplyVoltage, cyclopsAdsI2C_addr); + +// Create a Turner Cyclops sensor object with the custom ADS instance +TurnerCyclops cyclops_c(cyclopsPower, cyclopsADSChannel, cyclopsStdConc, + cyclopsStdVolt, cyclopsBlankVolt, cyclopsNReadings, + &cyclopsADS); + +// create a custom analog reader based on the Processor ADC (optional) +float cyclopsMultiplier2 = 1.0f; // factor for a voltage divider +float cyclopsSupply2 = 3.3f; // supply voltage of the Processor ADC +ProcessorAnalogBase cyclopsADS2(cyclopsMultiplier2, cyclopsSupply2); + +// Create a Turner Cyclops sensor object with the custom ADS instance +TurnerCyclops cyclops_c2(cyclopsPower, cyclopsADSChannel, cyclopsStdConc, + cyclopsStdVolt, cyclopsBlankVolt, cyclopsNReadings, + &cyclopsADS2); /** End [turner_cyclops] */ #endif @@ -2298,39 +2397,48 @@ Variable* cyclopsRedChloro = new TurnerCyclops_RedChlorophyll( // ========================================================================== /** Start [turner_turbidity_plus] */ #include +#include // NOTE: Use -1 for any pins that don't apply or aren't being used. -const int8_t turbidityPlusPower = sensorPowerPin; // Power pin -const int8_t turbidityPlusWiper = relayPowerPin; // Wiper pin -ttp_adsDiffMux_t turbidityPlusDiffMux = - DIFF_MUX_2_3; // Differential voltage config -const uint8_t turbidityPlusNumberReadings = 10; -const uint8_t turbidityPlusADSi2c_addr = - 0x48; // The I2C address of the ADS1115 ADC -adsGain_t turbidityPlusGain = GAIN_ONE; // The gain of the ADS -float tpVoltageDividerFactor = 1; // The factor for a voltage divider, if any +const int8_t ttPlusPower = sensorPowerPin; // Power pin +const int8_t ttPlusWiper = relayPowerPin; // Wiper pin +const int8_t ttPlusChannel1 = 2; // First differential channel +const int8_t ttPlusChannel2 = 3; // Second differential channel +const uint8_t ttPlusReadings = 10; // Turbidity Plus calibration information -const float turbidityPlusStdConc = 1.000; // Concentration of the standard used - // for a 1-point sensor calibration. -const float turbidityPlusStdVolt = +const float ttPlusStdConc = 1.000; // Concentration of the standard used + // for a 1-point sensor calibration. +const float ttPlusStdVolt = 1.000; // The voltage (in volts) measured for the conc_std. -const float turbidityPlusBlankVolt = +const float ttPlusBlankVolt = 0.000; // The voltage (in volts) measured for a blank. // Create a Turner Turbidity Plus sensor object -TurnerTurbidityPlus turbidityPlus(turbidityPlusPower, turbidityPlusWiper, - turbidityPlusDiffMux, turbidityPlusStdConc, - turbidityPlusStdVolt, turbidityPlusBlankVolt, - turbidityPlusADSi2c_addr, turbidityPlusGain, - turbidityPlusNumberReadings, - tpVoltageDividerFactor); +const uint8_t ttPlusReadings = 10; +TurnerTurbidityPlus turbidityPlus(ttPlusPower, ttPlusWiper, ttPlusChannel1, + ttPlusChannel2, ttPlusStdConc, ttPlusStdVolt, + ttPlusBlankVolt, ttPlusReadings); // Create the variable pointers Variable* turbidityPlusVoltage = new TurnerTurbidityPlus_Voltage( &turbidityPlus, "12345678-abcd-1234-ef00-1234567890ab"); Variable* turbidityPlusTurbidity = new TurnerTurbidityPlus_Turbidity( &turbidityPlus, "12345678-abcd-1234-ef00-1234567890ab"); + +// create a custom analog reader based on the TI ADS1115 (optional) +float ttPlusMultiplier = 1.0f; // factor for a voltage divider +adsGain_t ttPlusAdsGain = GAIN_ONE; // gain of the ADS1115 +float ttPlusAdsSupply = 3.3f; // supply voltage of the ADS1115 +const uint8_t ttPlusI2C_addr = 0x48; // The I2C address of the ADS1115 ADC +TIADS1x15Base ttPlusADS(ttPlusMultiplier, ttPlusAdsGain, ttPlusAdsSupply, + ttPlusI2C_addr); + +// Create a Turner Turbidity Plus sensor object with the custom TIADS1x15Base +TurnerTurbidityPlus turbidityPlus_c(ttPlusPower, ttPlusWiper, ttPlusChannel1, + ttPlusChannel2, ttPlusStdConc, + ttPlusStdVolt, ttPlusBlankVolt, + ttPlusReadings, &ttPlusADS); /** End [turner_turbidity_plus] */ #endif @@ -2341,16 +2449,18 @@ Variable* turbidityPlusTurbidity = new TurnerTurbidityPlus_Turbidity( // ========================================================================== /** Start [analog_elec_conductivity] */ #include +#include -const int8_t ECpwrPin = A4; // Power pin (-1 if continuously powered) -const int8_t ECdataPin1 = A0; // Data pin (must be an analog pin, ie A#) +const int8_t analogECPower = A4; // Power pin (-1 if continuously powered) +const int8_t analogECData = A0; // Data pin (must be an analog pin, ie A#) +const uint8_t analogECNReadings = 1; // The number of readings to average // Create an Analog Electrical Conductivity sensor object -AnalogElecConductivity analogEC_phy(ECpwrPin, ECdataPin1); +AnalogElecConductivity analogEC(analogECPower, analogECData); // Create a conductivity variable pointer for the analog sensor Variable* analogEc_cond = new AnalogElecConductivity_EC( - &analogEC_phy, "12345678-abcd-1234-ef00-1234567890ab"); + &analogEC, "12345678-abcd-1234-ef00-1234567890ab"); // Create a calculated variable for the temperature compensated conductivity // (that is, the specific conductance). For this example, we will use the @@ -2393,6 +2503,17 @@ Variable* analogEc_spcond = new Variable( calculateAnalogSpCond, analogSpCondResolution, analogSpCondName, analogSpCondUnit, analogSpCondCode, analogSpCondUUID); /** End [analog_elec_conductivity] */ + +// create a custom analog reader based on the Processor ADC (optional) +float analogECMultiplier = 1.0f; // factor for a voltage divider +float analogECSupply = 3.3f; // supply voltage of the Processor ADC +ProcessorAnalogBase analogECADS(analogECMultiplier, analogECSupply); + +// Create a Turner analogEC sensor object with the custom ADS instance +AnalogElecConductivity analogEC_c(analogECPower, analogECData, + ANALOGELECCONDUCTIVITY_RSERIES_OHMS, + ANALOGELECCONDUCTIVITY_KONST, + analogECNReadings, &analogECADS); #endif @@ -2443,17 +2564,17 @@ Variable* VegaPulsError = // for Additional Serial Ports" section // NOTE: Use -1 for any pins that don't apply or aren't being used. -byte y504ModbusAddress = 0x04; // The modbus address of the Y504 -const int8_t y504AdapterPower = sensorPowerPin; // RS485 adapter power pin -const int8_t y504SensorPower = relayPowerPin; // Sensor power pin -const int8_t y504EnablePin = -1; // Adapter RE/DE pin -const uint8_t y504NumberReadings = 5; +byte y504ModbusAddress = 0x04; // The modbus address of the Y504 +const int8_t y504AdapterPower = sensorPowerPin; // RS485 adapter power pin +const int8_t y504SensorPower = relayPowerPin; // Sensor power pin +const int8_t y504EnablePin = -1; // Adapter RE/DE pin +const uint8_t y504NReadings = 5; // The manufacturer recommends averaging 10 readings, but we take 5 to minimize // power consumption // Create a Yosemitech Y504 dissolved oxygen sensor object YosemitechY504 y504(y504ModbusAddress, modbusSerial, y504AdapterPower, - y504SensorPower, y504EnablePin, y504NumberReadings); + y504SensorPower, y504EnablePin, y504NReadings); // Create the dissolved oxygen percent, dissolved oxygen concentration, and // temperature variable pointers for the Y504 @@ -2481,17 +2602,17 @@ Variable* y504Temp = // for Additional Serial Ports" section // NOTE: Use -1 for any pins that don't apply or aren't being used. -byte y510ModbusAddress = 0x0B; // The modbus address of the Y510 -const int8_t y510AdapterPower = sensorPowerPin; // RS485 adapter power pin -const int8_t y510SensorPower = relayPowerPin; // Sensor power pin -const int8_t y510EnablePin = -1; // Adapter RE/DE pin -const uint8_t y510NumberReadings = 5; +byte y510ModbusAddress = 0x0B; // The modbus address of the Y510 +const int8_t y510AdapterPower = sensorPowerPin; // RS485 adapter power pin +const int8_t y510SensorPower = relayPowerPin; // Sensor power pin +const int8_t y510EnablePin = -1; // Adapter RE/DE pin +const uint8_t y510NReadings = 5; // The manufacturer recommends averaging 10 readings, but we take 5 to minimize // power consumption // Create a Y510-B Turbidity sensor object YosemitechY510 y510(y510ModbusAddress, modbusSerial, y510AdapterPower, - y510SensorPower, y510EnablePin, y510NumberReadings); + y510SensorPower, y510EnablePin, y510NReadings); // Create turbidity and temperature variable pointers for the Y510 Variable* y510Turb = @@ -2516,17 +2637,17 @@ Variable* y510Temp = // for Additional Serial Ports" section // NOTE: Use -1 for any pins that don't apply or aren't being used. -byte y511ModbusAddress = 0x1A; // The modbus address of the Y511 -const int8_t y511AdapterPower = sensorPowerPin; // RS485 adapter power pin -const int8_t y511SensorPower = relayPowerPin; // Sensor power pin -const int8_t y511EnablePin = -1; // Adapter RE/DE pin -const uint8_t y511NumberReadings = 5; +byte y511ModbusAddress = 0x1A; // The modbus address of the Y511 +const int8_t y511AdapterPower = sensorPowerPin; // RS485 adapter power pin +const int8_t y511SensorPower = relayPowerPin; // Sensor power pin +const int8_t y511EnablePin = -1; // Adapter RE/DE pin +const uint8_t y511NReadings = 5; // The manufacturer recommends averaging 10 readings, but we take 5 to minimize // power consumption // Create a Y511-A Turbidity sensor object YosemitechY511 y511(y511ModbusAddress, modbusSerial, y511AdapterPower, - y511SensorPower, y511EnablePin, y511NumberReadings); + y511SensorPower, y511EnablePin, y511NReadings); // Create turbidity and temperature variable pointers for the Y511 Variable* y511Turb = @@ -2551,17 +2672,17 @@ Variable* y511Temp = // for Additional Serial Ports" section // NOTE: Use -1 for any pins that don't apply or aren't being used. -byte y513ModbusAddress = 0x13; // The modbus address of the Y513 -const int8_t y513AdapterPower = sensorPowerPin; // RS485 adapter power pin -const int8_t y513SensorPower = relayPowerPin; // Sensor power pin -const int8_t y513EnablePin = -1; // Adapter RE/DE pin -const uint8_t y513NumberReadings = 5; +byte y513ModbusAddress = 0x13; // The modbus address of the Y513 +const int8_t y513AdapterPower = sensorPowerPin; // RS485 adapter power pin +const int8_t y513SensorPower = relayPowerPin; // Sensor power pin +const int8_t y513EnablePin = -1; // Adapter RE/DE pin +const uint8_t y513NReadings = 5; // The manufacturer recommends averaging 10 readings, but we take 5 to minimize // power consumption // Create a Y513 Blue Green Algae (BGA) sensor object YosemitechY513 y513(y513ModbusAddress, modbusSerial, y513AdapterPower, - y513SensorPower, y513EnablePin, y513NumberReadings); + y513SensorPower, y513EnablePin, y513NReadings); // Create Blue Green Algae (BGA) concentration and temperature variable // pointers for the Y513 @@ -2586,17 +2707,17 @@ Variable* y513Temp = // for Additional Serial Ports" section // NOTE: Use -1 for any pins that don't apply or aren't being used. -byte y514ModbusAddress = 0x14; // The modbus address of the Y514 -const int8_t y514AdapterPower = sensorPowerPin; // RS485 adapter power pin -const int8_t y514SensorPower = relayPowerPin; // Sensor power pin -const int8_t y514EnablePin = -1; // Adapter RE/DE pin -const uint8_t y514NumberReadings = 5; +byte y514ModbusAddress = 0x14; // The modbus address of the Y514 +const int8_t y514AdapterPower = sensorPowerPin; // RS485 adapter power pin +const int8_t y514SensorPower = relayPowerPin; // Sensor power pin +const int8_t y514EnablePin = -1; // Adapter RE/DE pin +const uint8_t y514NReadings = 5; // The manufacturer recommends averaging 10 readings, but we take 5 to minimize // power consumption // Create a Y514 chlorophyll sensor object YosemitechY514 y514(y514ModbusAddress, modbusSerial, y514AdapterPower, - y514SensorPower, y514EnablePin, y514NumberReadings); + y514SensorPower, y514EnablePin, y514NReadings); // Create chlorophyll concentration and temperature variable pointers for the // Y514 @@ -2622,17 +2743,17 @@ Variable* y514Temp = // for Additional Serial Ports" section // NOTE: Use -1 for any pins that don't apply or aren't being used. -byte y520ModbusAddress = 0x20; // The modbus address of the Y520 -const int8_t y520AdapterPower = sensorPowerPin; // RS485 adapter power pin -const int8_t y520SensorPower = relayPowerPin; // Sensor power pin -const int8_t y520EnablePin = -1; // Adapter RE/DE pin -const uint8_t y520NumberReadings = 5; +byte y520ModbusAddress = 0x20; // The modbus address of the Y520 +const int8_t y520AdapterPower = sensorPowerPin; // RS485 adapter power pin +const int8_t y520SensorPower = relayPowerPin; // Sensor power pin +const int8_t y520EnablePin = -1; // Adapter RE/DE pin +const uint8_t y520NReadings = 5; // The manufacturer recommends averaging 10 readings, but we take 5 to minimize // power consumption // Create a Y520 conductivity sensor object YosemitechY520 y520(y520ModbusAddress, modbusSerial, y520AdapterPower, - y520SensorPower, y520EnablePin, y520NumberReadings); + y520SensorPower, y520EnablePin, y520NReadings); // Create specific conductance and temperature variable pointers for the Y520 Variable* y520Cond = @@ -2657,16 +2778,16 @@ Variable* y520Temp = // for Additional Serial Ports" section // NOTE: Use -1 for any pins that don't apply or aren't being used. -byte y532ModbusAddress = 0x32; // The modbus address of the Y532 -const int8_t y532AdapterPower = sensorPowerPin; // RS485 adapter power pin -const int8_t y532SensorPower = relayPowerPin; // Sensor power pin -const int8_t y532EnablePin = 4; // Adapter RE/DE pin -const uint8_t y532NumberReadings = 1; +byte y532ModbusAddress = 0x32; // The modbus address of the Y532 +const int8_t y532AdapterPower = sensorPowerPin; // RS485 adapter power pin +const int8_t y532SensorPower = relayPowerPin; // Sensor power pin +const int8_t y532EnablePin = 4; // Adapter RE/DE pin +const uint8_t y532NReadings = 1; // The manufacturer actually doesn't mention averaging for this one // Create a Yosemitech Y532 pH sensor object YosemitechY532 y532(y532ModbusAddress, modbusSerial, y532AdapterPower, - y532SensorPower, y532EnablePin, y532NumberReadings); + y532SensorPower, y532EnablePin, y532NReadings); // Create pH, electrical potential, and temperature variable pointers for the // Y532 @@ -2694,16 +2815,16 @@ Variable* y532Temp = // for Additional Serial Ports" section // NOTE: Use -1 for any pins that don't apply or aren't being used. -byte y533ModbusAddress = 0x32; // The modbus address of the Y533 -const int8_t y533AdapterPower = sensorPowerPin; // RS485 adapter power pin -const int8_t y533SensorPower = relayPowerPin; // Sensor power pin -const int8_t y533EnablePin = 4; // Adapter RE/DE pin -const uint8_t y533NumberReadings = 1; +byte y533ModbusAddress = 0x32; // The modbus address of the Y533 +const int8_t y533AdapterPower = sensorPowerPin; // RS485 adapter power pin +const int8_t y533SensorPower = relayPowerPin; // Sensor power pin +const int8_t y533EnablePin = 4; // Adapter RE/DE pin +const uint8_t y533NReadings = 1; // The manufacturer actually doesn't mention averaging for this one // Create a Yosemitech Y533 ORP sensor object YosemitechY533 y533(y533ModbusAddress, modbusSerial, y533AdapterPower, - y533SensorPower, y533EnablePin, y533NumberReadings); + y533SensorPower, y533EnablePin, y533NReadings); // Create ORP and temperature variable pointers for the Y533 Variable* y533ORP = @@ -2728,17 +2849,17 @@ Variable* y533Temp = // for Additional Serial Ports" section // NOTE: Use -1 for any pins that don't apply or aren't being used. -byte y551ModbusAddress = 0x50; // The modbus address of the Y551 -const int8_t y551AdapterPower = sensorPowerPin; // RS485 adapter power pin -const int8_t y551SensorPower = relayPowerPin; // Sensor power pin -const int8_t y551EnablePin = -1; // Adapter RE/DE pin -const uint8_t y551NumberReadings = 5; +byte y551ModbusAddress = 0x50; // The modbus address of the Y551 +const int8_t y551AdapterPower = sensorPowerPin; // RS485 adapter power pin +const int8_t y551SensorPower = relayPowerPin; // Sensor power pin +const int8_t y551EnablePin = -1; // Adapter RE/DE pin +const uint8_t y551NReadings = 5; // The manufacturer recommends averaging 10 readings, but we take 5 to minimize // power consumption // Create a Y551 chemical oxygen demand sensor object YosemitechY551 y551(y551ModbusAddress, modbusSerial, y551AdapterPower, - y551SensorPower, y551EnablePin, y551NumberReadings); + y551SensorPower, y551EnablePin, y551NReadings); // Create COD, turbidity, and temperature variable pointers for the Y551 Variable* y551COD = @@ -2768,16 +2889,16 @@ Variable* y551Temp = byte y560ModbusAddress = 0x60; // The modbus address of the Y560. // NOTE: Hexidecimal 0x60 = 96 decimal used by Yosemitech SmartPC -const int8_t y560AdapterPower = sensorPowerPin; // RS485 adapter power pin -const int8_t y560SensorPower = relayPowerPin; // Sensor power pin -const int8_t y560EnablePin = -1; // Adapter RE/DE pin -const uint8_t y560NumberReadings = 3; +const int8_t y560AdapterPower = sensorPowerPin; // RS485 adapter power pin +const int8_t y560SensorPower = relayPowerPin; // Sensor power pin +const int8_t y560EnablePin = -1; // Adapter RE/DE pin +const uint8_t y560NReadings = 3; // The manufacturer recommends averaging 10 readings, but we take 5 to minimize // power consumption // Create a Y560 Ammonium Probe object YosemitechY560 y560(y560ModbusAddress, modbusSerial, y560AdapterPower, - y560SensorPower, y560EnablePin, y560NumberReadings); + y560SensorPower, y560EnablePin, y560NReadings); // Create COD, turbidity, and temperature variable pointers for the Y560 Variable* y560NH4_N = @@ -2804,17 +2925,17 @@ Variable* y560Temp = // for Additional Serial Ports" section // NOTE: Use -1 for any pins that don't apply or aren't being used. -byte y700ModbusAddress = 0x70; // The modbus address of the Y700 -const int8_t y700AdapterPower = sensorPowerPin; // RS485 adapter power pin -const int8_t y700SensorPower = relayPowerPin; // Sensor power pin -const int8_t y700EnablePin = -1; // Adapter RE/DE pin -const uint8_t y700NumberReadings = 5; +byte y700ModbusAddress = 0x70; // The modbus address of the Y700 +const int8_t y700AdapterPower = sensorPowerPin; // RS485 adapter power pin +const int8_t y700SensorPower = relayPowerPin; // Sensor power pin +const int8_t y700EnablePin = -1; // Adapter RE/DE pin +const uint8_t y700NReadings = 5; // The manufacturer recommends averaging 10 readings, but we take 5 to minimize // power consumption // Create a Y700 pressure sensor object YosemitechY700 y700(y700ModbusAddress, modbusSerial, y700AdapterPower, - y700SensorPower, y700EnablePin, y700NumberReadings); + y700SensorPower, y700EnablePin, y700NReadings); // Create pressure and temperature variable pointers for the Y700 Variable* y700Pres = @@ -2840,17 +2961,17 @@ Variable* y700Temp = // for Additional Serial Ports" section // NOTE: Use -1 for any pins that don't apply or aren't being used. -byte y4000ModbusAddress = 0x05; // The modbus address of the Y4000 -const int8_t y4000AdapterPower = sensorPowerPin; // RS485 adapter power pin -const int8_t y4000SensorPower = relayPowerPin; // Sensor power pin -const int8_t y4000EnablePin = -1; // Adapter RE/DE pin -const uint8_t y4000NumberReadings = 5; +byte y4000ModbusAddress = 0x05; // The modbus address of the Y4000 +const int8_t y4000AdapterPower = sensorPowerPin; // RS485 adapter power pin +const int8_t y4000SensorPower = relayPowerPin; // Sensor power pin +const int8_t y4000EnablePin = -1; // Adapter RE/DE pin +const uint8_t y4000NReadings = 5; // The manufacturer recommends averaging 10 readings, but we take 5 to minimize // power consumption // Create a Yosemitech Y4000 multi-parameter sensor object YosemitechY4000 y4000(y4000ModbusAddress, modbusSerial, y4000AdapterPower, - y4000SensorPower, y4000EnablePin, y4000NumberReadings); + y4000SensorPower, y4000EnablePin, y4000NReadings); // Create all of the variable pointers for the Y4000 Variable* y4000DO = @@ -3115,7 +3236,7 @@ Variable* variableList[] = { ads1x15Volt, #endif #if defined(BUILD_SENSOR_PROCESSOR_ANALOG) - extAnalogVolts, + processorAnalogVolts, #endif #if defined(BUILD_SENSOR_FREESCALE_MPL115A2) mplTemp, @@ -4120,10 +4241,12 @@ void loop() { /** End [complex_loop] */ -// cspell: ignore EDBG XBCT XBLTEB XBWF SVZM BatterymV Atlasp oversample -// cspell: ignore asco2voltage atlasGrav Hayashi emas PMID temperatureCoef -// cspell: ignore ClariVUESDI12address RainVUESDI12address Turb CTDSDI -// cspell: ignore RDOSDI TROLLSDI acculev nanolev TMSDI ELEC fivetm tallyi -// cspell: ignore kmph TIINA Chloro Fluoroscein PTSA BTEX ECpwrPin anlg spcond -// cspell: ignore Relia NEOPIXEL RESTAPI autobauding xbeec -// cspell: ignore CFUN UMNOPROF URAT PHEC GAIN_TWOTHIRDS +// cspell: words EDBG XBCT XBLTEB XBWF SVZM BatterymV Atlasp oversample +// cspell: words asco2voltage atlasGrav Hayashi emas PMID temperatureCoef +// cspell: words ClariVUESDI12address RainVUESDI12address Turb CTDSDI +// cspell: words RDOSDI TROLLSDI acculev nanolev TMSDI ELEC fivetm tallyi +// cspell: words kmph TIINA Chloro Fluoroscein PTSA BTEX analogECPower anlg +// cspell: words spcond Relia NEOPIXEL RESTAPI autobauding xbeec CFUN UMNOPROF +// cspell: words URAT PHEC GAIN_TWOTHIRDS anbPHEC OBSADS CTDNReadings rdoDOmgL +// cspell: words ANALOGELECCONDUCTIVITY_RSERIES_OHMS analogECADS +// cspell: words ANALOGELECCONDUCTIVITY_KONST From 293d6029b34334ba9b9beef2b3dcec9634da97b6 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Thu, 26 Feb 2026 14:38:22 -0500 Subject: [PATCH 348/533] Update examples again Signed-off-by: Sara Damiano --- examples/menu_a_la_carte/menu_a_la_carte.ino | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/examples/menu_a_la_carte/menu_a_la_carte.ino b/examples/menu_a_la_carte/menu_a_la_carte.ino index 6c9330775..0c23e67a4 100644 --- a/examples/menu_a_la_carte/menu_a_la_carte.ino +++ b/examples/menu_a_la_carte/menu_a_la_carte.ino @@ -1048,13 +1048,13 @@ AlphasenseCO2 alphasenseCO2_c(asCO2Power, asCO2Channel1, asCO2Channel2, byte anbModbusAddress = 0x55; // The modbus address of ANB pH Sensor (0x55 is the default) const int8_t anbPower = sensorPowerPin; // ANB pH Sensor power pin -const int8_t alAdapterPower = sensorPowerPin; // RS485 adapter power pin -const int8_t al485EnablePin = -1; // Adapter RE/DE pin +const int8_t anbAdapterPower = sensorPowerPin; // RS485 adapter power pin +const int8_t anb485EnablePin = -1; // Adapter RE/DE pin const uint8_t anbNReadings = 1; // Create an ANB pH sensor object ANBpH anbPH(anbModbusAddress, modbusSerial, anbPower, loggingInterval, - alAdapterPower, al485EnablePin, anbNReadings); + anbAdapterPower, anb485EnablePin, anbNReadings); // Create all of the variable pointers for the ANB pH sensor Variable* anbPHValue = new ANBpH_pH(&anbPH, @@ -1465,7 +1465,6 @@ Variable* clarivueError = new CampbellClariVUE10_ErrorCode( // NOTE: Use -1 for any pins that don't apply or aren't being used. const int8_t OBS3Power = sensorPowerPin; // Power pin const uint8_t OBS3NReadings = 10; -const uint8_t OBS3AdsI2C_addr = 0x48; // The I2C address of the ADS1115 ADC const int8_t OBSLowADSChannel = 0; // ADS channel for *low* range output @@ -2317,7 +2316,6 @@ Variable* inaPower = new TIINA219_Power(&ina219, // NOTE: Use -1 for any pins that don't apply or aren't being used. const int8_t cyclopsPower = sensorPowerPin; // Power pin const uint8_t cyclopsNReadings = 10; -const uint8_t cyclopsAdsI2C_addr = 0x48; // The I2C address of the ADS1115 ADC const int8_t cyclopsADSChannel = 0; // ADS channel // Cyclops calibration information @@ -2415,7 +2413,6 @@ const float ttPlusBlankVolt = 0.000; // The voltage (in volts) measured for a blank. // Create a Turner Turbidity Plus sensor object -const uint8_t ttPlusReadings = 10; TurnerTurbidityPlus turbidityPlus(ttPlusPower, ttPlusWiper, ttPlusChannel1, ttPlusChannel2, ttPlusStdConc, ttPlusStdVolt, ttPlusBlankVolt, ttPlusReadings); From 900d41b7220ede7522ef04999746ccd847efbb73 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Thu, 26 Feb 2026 15:12:03 -0500 Subject: [PATCH 349/533] Add functions to calculate analog resolution via AI Signed-off-by: Sara Damiano --- src/sensors/AnalogVoltageBase.h | 42 +++++++++++++++++++++++++++++ src/sensors/ProcessorAnalog.cpp | 32 ++++++++++++++++++++++ src/sensors/ProcessorAnalog.h | 13 +++++++++ src/sensors/TIADS1x15.cpp | 48 ++++++++++++++++++++++++++++++++- src/sensors/TIADS1x15.h | 20 ++++++++++++++ 5 files changed, 154 insertions(+), 1 deletion(-) diff --git a/src/sensors/AnalogVoltageBase.h b/src/sensors/AnalogVoltageBase.h index a56611d06..64b115254 100644 --- a/src/sensors/AnalogVoltageBase.h +++ b/src/sensors/AnalogVoltageBase.h @@ -26,6 +26,9 @@ // Include the known processors for default values #include "KnownProcessors.h" +// Include math library for log10 function +#include + // Define the print label[s] for the debugger #ifdef MS_ANALOGVOLTAGEBASE_DEBUG #define MS_DEBUGGING_STD "AnalogVoltageBase" @@ -184,7 +187,27 @@ class AnalogVoltageBase { virtual String getAnalogLocation(int8_t analogChannel, int8_t analogReferenceChannel) = 0; + /** + * @brief Calculate the analog resolution in volts based on the ADC + * characteristics + * + * This pure virtual function must be implemented by derived classes to + * provide their specific analog resolution calculation based on their ADC + * characteristics (bit resolution, gain settings, supply voltage, etc.). + * + * @return The analog resolution in volts per LSB + */ + virtual float calculateAnalogResolutionVolts(void) = 0; + protected: + /** + * @brief Convert voltage resolution to appropriate decimal places + * + * @param voltageResolution The voltage resolution in volts per LSB + * @return The number of decimal places needed to represent the resolution + */ + uint8_t voltageResolutionToDecimalPlaces(float voltageResolution); + /** * @brief Stored voltage multiplier value * @@ -201,4 +224,23 @@ class AnalogVoltageBase { float _supplyVoltage; }; +// Inline implementation of voltageResolutionToDecimalPlaces +inline uint8_t +AnalogVoltageBase::voltageResolutionToDecimalPlaces(float voltageResolution) { + if (voltageResolution <= 0.0f) { + return 4; // Default to 4 decimal places for invalid input + } + + // Calculate the number of decimal places needed to represent the resolution + // We want at least one significant digit beyond the resolution + float log10Resolution = log10f(voltageResolution); + int decimalPlaces = static_cast(-log10Resolution) + 1; + + // Clamp to reasonable bounds (0-6 decimal places) + if (decimalPlaces < 0) decimalPlaces = 0; + if (decimalPlaces > 6) decimalPlaces = 6; + + return static_cast(decimalPlaces); +} + #endif // SRC_SENSORS_ANALOGVOLTAGEBASE_H_ diff --git a/src/sensors/ProcessorAnalog.cpp b/src/sensors/ProcessorAnalog.cpp index c7500df84..25afbbae9 100644 --- a/src/sensors/ProcessorAnalog.cpp +++ b/src/sensors/ProcessorAnalog.cpp @@ -81,6 +81,38 @@ bool ProcessorAnalogBase::readVoltageDifferential( return false; } +float ProcessorAnalogBase::calculateAnalogResolutionVolts(void) { + // Use the configured processor ADC resolution + uint8_t resolutionBits = MS_PROCESSOR_ADC_RESOLUTION; + + // For processor ADCs, the full scale range is the supply voltage + // (single-ended measurements from 0V to supply voltage) + float fullScaleRangeVolts = _supplyVoltage; + + if (resolutionBits == 0 || resolutionBits > 32 || + fullScaleRangeVolts <= 0.0f) { + MS_DBG(F("Invalid ADC configuration - bits: "), resolutionBits, + F(", supply voltage: "), fullScaleRangeVolts, F("V")); + return -9999.0f; + } + + // Calculate the total number of ADC codes + uint32_t totalCodes = 1UL << resolutionBits; // 2^resolutionBits + + // Voltage resolution is the full scale range divided by total codes + float resolutionVolts = fullScaleRangeVolts / + static_cast(totalCodes); + + MS_DBG(F("Processor ADC resolution calculation:")); + MS_DBG(F(" ADC resolution: "), resolutionBits, F(" bits")); + MS_DBG(F(" Supply voltage: "), fullScaleRangeVolts, F("V")); + MS_DBG(F(" Total codes: "), totalCodes); + MS_DBG(F(" Voltage resolution: "), resolutionVolts, F("V/LSB")); + + return resolutionVolts; +} + + // ============================================================================ // ProcessorAnalog Functions // ============================================================================ diff --git a/src/sensors/ProcessorAnalog.h b/src/sensors/ProcessorAnalog.h index b857e87c2..8a1bea474 100644 --- a/src/sensors/ProcessorAnalog.h +++ b/src/sensors/ProcessorAnalog.h @@ -213,6 +213,19 @@ class ProcessorAnalogBase : public AnalogVoltageBase { String getAnalogLocation(int8_t analogChannel, int8_t analogReferenceChannel) override; + + /** + * @brief Calculate the analog resolution in volts for the processor ADC + * + * For processor ADCs, this calculates the voltage resolution based on the + * configured ADC resolution and supply voltage. The calculation uses: + * - ADC resolution in bits: MS_PROCESSOR_ADC_RESOLUTION + * - Full scale range: processor supply voltage (single-ended, 0V to Vcc) + * + * @return The analog resolution in volts per LSB + */ + float calculateAnalogResolutionVolts(void) override; + }; // Inline utility function implementation diff --git a/src/sensors/TIADS1x15.cpp b/src/sensors/TIADS1x15.cpp index 2787d8bef..f06b37e37 100644 --- a/src/sensors/TIADS1x15.cpp +++ b/src/sensors/TIADS1x15.cpp @@ -265,6 +265,51 @@ void TIADS1x15Base::setSupplyVoltage(float supplyVoltage) { } } +float TIADS1x15Base::calculateAnalogResolutionVolts(void) { + // Determine ADC resolution based on model +#ifndef MS_USE_ADS1015 + uint8_t resolutionBits = 16; // ADS1115 is 16-bit +#else + uint8_t resolutionBits = 12; // ADS1015 is 12-bit +#endif + + // Get the current PGA full-scale range from the gain setting + float pgaFullScaleRange = _ads.getFsRange(); + + // For single-ended measurements, the actual usable range is limited by: + // 1. PGA full-scale range (gain-dependent) + // 2. Supply voltage + 0.3V (per datasheet) + // 3. Absolute maximum 5.5V (per datasheet) + float effectiveFullScale = pgaFullScaleRange; + float supplyBasedMax = _supplyVoltage + 0.3f; + if (supplyBasedMax < effectiveFullScale) { + effectiveFullScale = supplyBasedMax; + } + if (effectiveFullScale > 5.5f) { effectiveFullScale = 5.5f; } + + // Calculate the total number of ADC codes + uint32_t totalCodes = 1UL << resolutionBits; // 2^resolutionBits + + // Voltage resolution is the effective full scale range divided by total + // codes + float resolutionVolts = effectiveFullScale / static_cast(totalCodes); + + MS_DBG(F("ADS resolution calculation:")); +#ifndef MS_USE_ADS1015 + MS_DBG(F(" ADC model: ADS1115 (16-bit)")); +#else + MS_DBG(F(" ADC model: ADS1015 (12-bit)")); +#endif + MS_DBG(F(" PGA full scale range: "), pgaFullScaleRange, F("V")); + MS_DBG(F(" Supply voltage: "), _supplyVoltage, F("V")); + MS_DBG(F(" Effective full scale: "), effectiveFullScale, F("V")); + MS_DBG(F(" Resolution bits: "), resolutionBits); + MS_DBG(F(" Total codes: "), totalCodes); + MS_DBG(F(" Voltage resolution: "), resolutionVolts, F("V/LSB")); + + return resolutionVolts; +} + // ============================================================================ // TIADS1x15 Functions // ============================================================================ @@ -338,7 +383,8 @@ bool TIADS1x15::addSingleMeasurementResult(void) { _dataPin, _analogReferenceChannel, resultValue); } else { if (_analogReferenceChannel >= 0) { - // Differential was requested but pair is invalid - fail the measurement + // Differential was requested but pair is invalid - fail the + // measurement MS_DBG(F(" Error: Invalid differential pair ("), _dataPin, F("-"), _analogReferenceChannel, F("). Measurement failed.")); success = false; diff --git a/src/sensors/TIADS1x15.h b/src/sensors/TIADS1x15.h index 39cba5c2f..a232920a3 100644 --- a/src/sensors/TIADS1x15.h +++ b/src/sensors/TIADS1x15.h @@ -374,6 +374,26 @@ class TIADS1x15Base : public AnalogVoltageBase { */ void setSupplyVoltage(float supplyVoltage) override; + /** + * @brief Calculate the analog resolution in volts for the ADS1x15 + * + * For ADS1x15, this calculates the voltage resolution based on the current + * gain setting, supply voltage, and ADC bit resolution. The resolution + * depends on: + * - ADC model: 12-bit (ADS1015) or 16-bit (ADS1115) + * - Gain setting: determines PGA full-scale range + * - Supply voltage: limits actual usable range for single-ended + * measurements + * + * The effective full scale range is the minimum of: + * - PGA full-scale range (gain-dependent) + * - Supply voltage + 0.3V (for single-ended measurements) + * - Absolute maximum 5.5V per datasheet + * + * @return The analog resolution in volts per LSB + */ + float calculateAnalogResolutionVolts(void) override; + protected: /** * @brief Internal reference to the I2C address of the TI-ADS1x15 From 08961257647cd199eda9a633d265b514380c40bc Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Thu, 26 Feb 2026 16:25:01 -0500 Subject: [PATCH 350/533] Move function to convert a float resolution to a number of decimal places to the variable class Signed-off-by: Sara Damiano --- src/VariableBase.h | 33 +++++++++++++++++++++++++++++++++ src/sensors/AnalogVoltageBase.h | 27 --------------------------- 2 files changed, 33 insertions(+), 27 deletions(-) diff --git a/src/VariableBase.h b/src/VariableBase.h index 025f989d0..787176280 100644 --- a/src/VariableBase.h +++ b/src/VariableBase.h @@ -20,6 +20,9 @@ // Include the debugging config #include "ModSensorDebugConfig.h" +// Include math library for log10f function +#include + // Define the print label[s] for the debugger #ifdef MS_VARIABLEBASE_DEBUG #define MS_DEBUGGING_STD "VariableBase" @@ -404,6 +407,36 @@ class Variable { */ bool isCalculated = false; + /** + * @brief Convert measurement resolution to appropriate decimal places + * + * This static utility function converts any measurement resolution value to + * the appropriate number of decimal places for variable resolution + * settings. Works with any float resolution value (voltage, temperature, + * pressure, etc.). + * + * @param resolution The measurement resolution (e.g., volts per LSB, + * degrees per count, etc.) + * @return The number of decimal places needed to represent the resolution + */ + static inline uint8_t floatResolutionToDecimalPlaces(float resolution) { + if (resolution <= 0.0f) { + return 4; // Default to 4 decimal places for invalid input + } + + // Calculate the number of decimal places needed to represent the + // resolution We want at least one significant digit beyond the + // resolution + float log10Resolution = log10f(resolution); + int decimalPlaces = static_cast(-log10Resolution) + 1; + + // Clamp to reasonable bounds (0-6 decimal places) + if (decimalPlaces < 0) decimalPlaces = 0; + if (decimalPlaces > 6) decimalPlaces = 6; + + return static_cast(decimalPlaces); + } + protected: /** * @brief The current data value diff --git a/src/sensors/AnalogVoltageBase.h b/src/sensors/AnalogVoltageBase.h index 64b115254..56039f7bc 100644 --- a/src/sensors/AnalogVoltageBase.h +++ b/src/sensors/AnalogVoltageBase.h @@ -200,14 +200,6 @@ class AnalogVoltageBase { virtual float calculateAnalogResolutionVolts(void) = 0; protected: - /** - * @brief Convert voltage resolution to appropriate decimal places - * - * @param voltageResolution The voltage resolution in volts per LSB - * @return The number of decimal places needed to represent the resolution - */ - uint8_t voltageResolutionToDecimalPlaces(float voltageResolution); - /** * @brief Stored voltage multiplier value * @@ -224,23 +216,4 @@ class AnalogVoltageBase { float _supplyVoltage; }; -// Inline implementation of voltageResolutionToDecimalPlaces -inline uint8_t -AnalogVoltageBase::voltageResolutionToDecimalPlaces(float voltageResolution) { - if (voltageResolution <= 0.0f) { - return 4; // Default to 4 decimal places for invalid input - } - - // Calculate the number of decimal places needed to represent the resolution - // We want at least one significant digit beyond the resolution - float log10Resolution = log10f(voltageResolution); - int decimalPlaces = static_cast(-log10Resolution) + 1; - - // Clamp to reasonable bounds (0-6 decimal places) - if (decimalPlaces < 0) decimalPlaces = 0; - if (decimalPlaces > 6) decimalPlaces = 6; - - return static_cast(decimalPlaces); -} - #endif // SRC_SENSORS_ANALOGVOLTAGEBASE_H_ From 212fe8134e9554645cacb5bdb601bd04a8b29b96 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Thu, 26 Feb 2026 16:35:59 -0500 Subject: [PATCH 351/533] Update ChangeLog.md Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --- ChangeLog.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ChangeLog.md b/ChangeLog.md index 4d29be1e5..73fa2dfef 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -97,7 +97,7 @@ If you are using code from a previous version of the library, make sure to updat - *Potentially breaking* The constructors for all of these analog-based classes have changed! Previously the I2C address of the ADS1x15 was an optional input parameter which came *before* the optional input parameter for the number of measurements to average. The input parameter for the I2C address has been *removed* and the input for the number of measurements to average has been moved up in the order! -For users who used the default values, this will have no affect. +For users who used the default values, this will have no effect. For users who provided both a custom I2C address and a custom number of measurements, this will cause a compiler error. For users who provided a custom I2C address *but not a custom number of measurements* this will cause a *silent failure* because the custom I2C address will be used as the measurement count and the default I2C address will be used. Users who need a custom I2C address for the ADS1x15 must construct a TIADS1x15Base object with the correct address and pass a pointer to that object to the constructor. From 180d23009a26d30998ed4b71fc459098418d9bb5 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Thu, 26 Feb 2026 16:36:31 -0500 Subject: [PATCH 352/533] Update ChangeLog.md Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --- ChangeLog.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ChangeLog.md b/ChangeLog.md index 73fa2dfef..112b0d215 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -196,7 +196,7 @@ This affects the following classes: #### Library Wide -- Added KnownProcessors.h and moved defines valued for supported built-in sensors on known processors to that file. +- Added KnownProcessors.h and moved define values for supported built-in sensors on known processors to that file. - This affects ProcessorStats and the Everlight ALS PT-19. - Added a new example specific to the [EnviroDIY Monitoring Station Kit](https://www.envirodiy.org/product/envirodiy-monitoring-station-kit/). From a0746254ebf210112a4812d1395ee16ecac12428 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Thu, 26 Feb 2026 16:37:10 -0500 Subject: [PATCH 353/533] Update ChangeLog.md Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --- ChangeLog.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ChangeLog.md b/ChangeLog.md index 112b0d215..09c2a9708 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -184,7 +184,7 @@ These values should generally be set in the specific sensor constructors and onl - Added the functions `Sensor::clearStatus()`,`Sensor::clearPowerStatus()`,`Sensor::clearWakeStatus()`,and `Sensor::clearMeasurementStatus()` which reset some or all of the sensor status bits and related timing variables. - Added an abstract AnalogVoltageBase class with two concrete classes for analog voltage measurements: ProcessorAnalogBase and TIADS1x15Base. All supported analog sensors can now accept a pointer to an object of any concrete subclass of the AnalogVoltageBase class to use for raw voltage measurements. -By default the existing analog sensors will create an AnalogVoltageBase class object internally for whichever type of ADC (processor or ADS1x15) the sensor was originally coded to use. +By default, existing analog sensors will create an internal concrete AnalogVoltageBase subclass instance for whichever ADC type (processor or ADS1x15) the sensor was originally coded to use. This affects the following classes: - AlphasenseCO2 - AnalogElecConductivity From e28b7bb16fcd649e735213aa5697a57344d608c9 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Thu, 26 Feb 2026 16:44:06 -0500 Subject: [PATCH 354/533] Implement a begin function for analog voltage classes and call it from setup Signed-off-by: Sara Damiano --- src/sensors/AlphasenseCO2.cpp | 19 +++++++++ src/sensors/AlphasenseCO2.h | 2 + src/sensors/AnalogElecConductivity.cpp | 19 +++++++++ src/sensors/AnalogElecConductivity.h | 2 + src/sensors/AnalogVoltageBase.h | 13 ++++++ src/sensors/ApogeeSQ212.cpp | 19 +++++++++ src/sensors/ApogeeSQ212.h | 2 + src/sensors/CampbellOBS3.cpp | 19 +++++++++ src/sensors/CampbellOBS3.h | 2 + src/sensors/EverlightALSPT19.cpp | 19 +++++++++ src/sensors/EverlightALSPT19.h | 5 ++- src/sensors/ProcessorAnalog.cpp | 6 +++ src/sensors/ProcessorAnalog.h | 10 +++++ src/sensors/TIADS1x15.cpp | 56 +++++++++++++++++++++----- src/sensors/TIADS1x15.h | 21 ++++++++++ src/sensors/TurnerCyclops.cpp | 19 +++++++++ src/sensors/TurnerCyclops.h | 2 + src/sensors/TurnerTurbidityPlus.cpp | 16 +++++++- 18 files changed, 240 insertions(+), 11 deletions(-) diff --git a/src/sensors/AlphasenseCO2.cpp b/src/sensors/AlphasenseCO2.cpp index d3320644f..079a62966 100644 --- a/src/sensors/AlphasenseCO2.cpp +++ b/src/sensors/AlphasenseCO2.cpp @@ -54,6 +54,25 @@ String AlphasenseCO2::getSensorLocation(void) { } +bool AlphasenseCO2::setup(void) { + bool sensorSetupSuccess = Sensor::setup(); + bool analogVoltageReaderSuccess = false; + + if (_analogVoltageReader != nullptr) { + analogVoltageReaderSuccess = _analogVoltageReader->begin(); + if (!analogVoltageReaderSuccess) { + MS_DBG(getSensorNameAndLocation(), + F("Analog voltage reader initialization failed")); + } + } else { + MS_DBG(getSensorNameAndLocation(), + F("No analog voltage reader to initialize")); + } + + return sensorSetupSuccess && analogVoltageReaderSuccess; +} + + bool AlphasenseCO2::addSingleMeasurementResult(void) { // Immediately quit if the measurement was not successfully started if (!getStatusBit(MEASUREMENT_SUCCESSFUL)) { diff --git a/src/sensors/AlphasenseCO2.h b/src/sensors/AlphasenseCO2.h index fd9cbfd0e..c82c8bbf9 100644 --- a/src/sensors/AlphasenseCO2.h +++ b/src/sensors/AlphasenseCO2.h @@ -314,6 +314,8 @@ class AlphasenseCO2 : public Sensor { String getSensorLocation(void) override; + bool setup(void) override; + bool addSingleMeasurementResult(void) override; private: diff --git a/src/sensors/AnalogElecConductivity.cpp b/src/sensors/AnalogElecConductivity.cpp index 5bb3ec267..684c39dcc 100644 --- a/src/sensors/AnalogElecConductivity.cpp +++ b/src/sensors/AnalogElecConductivity.cpp @@ -55,6 +55,25 @@ String AnalogElecConductivity::getSensorLocation(void) { } +bool AnalogElecConductivity::setup(void) { + bool sensorSetupSuccess = Sensor::setup(); + bool analogVoltageReaderSuccess = false; + + if (_analogVoltageReader != nullptr) { + analogVoltageReaderSuccess = _analogVoltageReader->begin(); + if (!analogVoltageReaderSuccess) { + MS_DBG(getSensorNameAndLocation(), + F("Analog voltage reader initialization failed")); + } + } else { + MS_DBG(getSensorNameAndLocation(), + F("No analog voltage reader to initialize")); + } + + return sensorSetupSuccess && analogVoltageReaderSuccess; +} + + bool AnalogElecConductivity::addSingleMeasurementResult(void) { // Immediately quit if the measurement was not successfully started if (!getStatusBit(MEASUREMENT_SUCCESSFUL)) { diff --git a/src/sensors/AnalogElecConductivity.h b/src/sensors/AnalogElecConductivity.h index def30e0d7..a26bb2236 100644 --- a/src/sensors/AnalogElecConductivity.h +++ b/src/sensors/AnalogElecConductivity.h @@ -352,6 +352,8 @@ class AnalogElecConductivity : public Sensor { */ String getSensorLocation(void) override; + bool setup(void) override; + bool addSingleMeasurementResult(void) override; /** diff --git a/src/sensors/AnalogVoltageBase.h b/src/sensors/AnalogVoltageBase.h index 56039f7bc..8eea34e73 100644 --- a/src/sensors/AnalogVoltageBase.h +++ b/src/sensors/AnalogVoltageBase.h @@ -74,6 +74,19 @@ class AnalogVoltageBase { */ virtual ~AnalogVoltageBase() = default; + /** + * @brief Initialize the analog voltage reading system + * + * This pure virtual function must be implemented by derived classes to + * perform any initialization that cannot be safely done in the constructor. + * This includes hardware setup that depends on other systems being + * initialized, Serial communication being available, or operations that + * might need to communicate with external devices. + * + * @return True if the initialization was successful, false otherwise + */ + virtual bool begin(void) = 0; + /** * @brief Set the voltage multiplier for voltage divider calculations * diff --git a/src/sensors/ApogeeSQ212.cpp b/src/sensors/ApogeeSQ212.cpp index b0a35a6f9..8e5cfe3d7 100644 --- a/src/sensors/ApogeeSQ212.cpp +++ b/src/sensors/ApogeeSQ212.cpp @@ -49,6 +49,25 @@ String ApogeeSQ212::getSensorLocation(void) { } +bool ApogeeSQ212::setup(void) { + bool sensorSetupSuccess = Sensor::setup(); + bool analogVoltageReaderSuccess = false; + + if (_analogVoltageReader != nullptr) { + analogVoltageReaderSuccess = _analogVoltageReader->begin(); + if (!analogVoltageReaderSuccess) { + MS_DBG(getSensorNameAndLocation(), + F("Analog voltage reader initialization failed")); + } + } else { + MS_DBG(getSensorNameAndLocation(), + F("No analog voltage reader to initialize")); + } + + return sensorSetupSuccess && analogVoltageReaderSuccess; +} + + bool ApogeeSQ212::addSingleMeasurementResult(void) { // Immediately quit if the measurement was not successfully started if (!getStatusBit(MEASUREMENT_SUCCESSFUL)) { diff --git a/src/sensors/ApogeeSQ212.h b/src/sensors/ApogeeSQ212.h index 636577018..c505889c0 100644 --- a/src/sensors/ApogeeSQ212.h +++ b/src/sensors/ApogeeSQ212.h @@ -293,6 +293,8 @@ class ApogeeSQ212 : public Sensor { String getSensorLocation(void) override; + bool setup(void) override; + bool addSingleMeasurementResult(void) override; private: diff --git a/src/sensors/CampbellOBS3.cpp b/src/sensors/CampbellOBS3.cpp index 2d97db2af..e14ed5bdc 100644 --- a/src/sensors/CampbellOBS3.cpp +++ b/src/sensors/CampbellOBS3.cpp @@ -50,6 +50,25 @@ String CampbellOBS3::getSensorLocation(void) { } +bool CampbellOBS3::setup(void) { + bool sensorSetupSuccess = Sensor::setup(); + bool analogVoltageReaderSuccess = false; + + if (_analogVoltageReader != nullptr) { + analogVoltageReaderSuccess = _analogVoltageReader->begin(); + if (!analogVoltageReaderSuccess) { + MS_DBG(getSensorNameAndLocation(), + F("Analog voltage reader initialization failed")); + } + } else { + MS_DBG(getSensorNameAndLocation(), + F("No analog voltage reader to initialize")); + } + + return sensorSetupSuccess && analogVoltageReaderSuccess; +} + + bool CampbellOBS3::addSingleMeasurementResult(void) { // Immediately quit if the measurement was not successfully started if (!getStatusBit(MEASUREMENT_SUCCESSFUL)) { diff --git a/src/sensors/CampbellOBS3.h b/src/sensors/CampbellOBS3.h index dc20e3359..2214ed059 100644 --- a/src/sensors/CampbellOBS3.h +++ b/src/sensors/CampbellOBS3.h @@ -290,6 +290,8 @@ class CampbellOBS3 : public Sensor { String getSensorLocation(void) override; + bool setup(void) override; + bool addSingleMeasurementResult(void) override; private: diff --git a/src/sensors/EverlightALSPT19.cpp b/src/sensors/EverlightALSPT19.cpp index 80ceeadd6..ebf8c6ab4 100644 --- a/src/sensors/EverlightALSPT19.cpp +++ b/src/sensors/EverlightALSPT19.cpp @@ -61,6 +61,25 @@ String EverlightALSPT19::getSensorLocation(void) { } +bool EverlightALSPT19::setup(void) { + bool sensorSetupSuccess = Sensor::setup(); + bool analogVoltageReaderSuccess = false; + + if (_analogVoltageReader != nullptr) { + analogVoltageReaderSuccess = _analogVoltageReader->begin(); + if (!analogVoltageReaderSuccess) { + MS_DBG(getSensorNameAndLocation(), + F("Analog voltage reader initialization failed")); + } + } else { + MS_DBG(getSensorNameAndLocation(), + F("No analog voltage reader to initialize")); + } + + return sensorSetupSuccess && analogVoltageReaderSuccess; +} + + bool EverlightALSPT19::addSingleMeasurementResult(void) { // Immediately quit if the measurement was not successfully started if (!getStatusBit(MEASUREMENT_SUCCESSFUL)) { diff --git a/src/sensors/EverlightALSPT19.h b/src/sensors/EverlightALSPT19.h index 03a339bf1..3f755056f 100644 --- a/src/sensors/EverlightALSPT19.h +++ b/src/sensors/EverlightALSPT19.h @@ -313,7 +313,10 @@ class EverlightALSPT19 : public Sensor { EverlightALSPT19& operator=(EverlightALSPT19&&) = delete; String getSensorLocation(void) override; - bool addSingleMeasurementResult(void) override; + + bool setup(void) override; + + bool addSingleMeasurementResult(void) override; private: /// @brief The PT-19 power supply voltage diff --git a/src/sensors/ProcessorAnalog.cpp b/src/sensors/ProcessorAnalog.cpp index 25afbbae9..58974704e 100644 --- a/src/sensors/ProcessorAnalog.cpp +++ b/src/sensors/ProcessorAnalog.cpp @@ -25,6 +25,12 @@ ProcessorAnalogBase::ProcessorAnalogBase(float voltageMultiplier, // ProcessorAnalogBase Functions // ============================================================================ +bool ProcessorAnalogBase::begin(void) { + // For processor analog systems, no special initialization is required + // beyond what is done in the constructor + return true; +} + bool ProcessorAnalogBase::readVoltageSingleEnded(int8_t analogChannel, float& resultValue) { // Compile-time validation of ADC configuration diff --git a/src/sensors/ProcessorAnalog.h b/src/sensors/ProcessorAnalog.h index 8a1bea474..2da371535 100644 --- a/src/sensors/ProcessorAnalog.h +++ b/src/sensors/ProcessorAnalog.h @@ -182,6 +182,16 @@ class ProcessorAnalogBase : public AnalogVoltageBase { */ virtual ~ProcessorAnalogBase() = default; + /** + * @brief Initialize the processor analog system + * + * For processor analog systems, no special initialization is required + * beyond what is done in the constructor, so this function does nothing. + * + * @return Always true indicating successful initialization + */ + bool begin(void) override; + /** * @brief Read a single-ended voltage measurement from the processor ADC * diff --git a/src/sensors/TIADS1x15.cpp b/src/sensors/TIADS1x15.cpp index f06b37e37..a6c2397ee 100644 --- a/src/sensors/TIADS1x15.cpp +++ b/src/sensors/TIADS1x15.cpp @@ -25,7 +25,9 @@ TIADS1x15Base::TIADS1x15Base(float voltageMultiplier, adsGain_t adsGain, uint8_t i2cAddress, float adsSupplyVoltage, uint16_t adsDataRate) : AnalogVoltageBase(voltageMultiplier, adsSupplyVoltage), - _i2cAddress(i2cAddress) { + _i2cAddress(i2cAddress), + _adsGain(adsGain), + _adsDataRate(adsDataRate) { // Clamp supply voltage to valid ADS1x15 range: 0.0V to 5.5V per datasheet // NOTE: This clamp is intentionally silent — Serial/MS_DBG is NOT safe to // call during construction (the Serial object may not be initialized yet on @@ -35,6 +37,17 @@ TIADS1x15Base::TIADS1x15Base(float voltageMultiplier, adsGain_t adsGain, } else if (_supplyVoltage > 5.5f) { _supplyVoltage = 5.5f; } + // ADS initialization is deferred to begin() function for safe I2C + // communication +} + + +// ============================================================================ +// TIADS1x15Base Functions +// ============================================================================ + +bool TIADS1x15Base::begin(void) { + // Initialize the per-instance ADS driver with stored configuration // ADS Library default settings: // - TI ADS1115 (16 bit) // - single-shot mode (powers down between conversions) @@ -45,17 +58,23 @@ TIADS1x15Base::TIADS1x15Base(float voltageMultiplier, adsGain_t adsGain, // - 1600 samples per second (625µs conversion time) // - 2/3 gain +/- 6.144V range (limited to VDD +0.3V max) - // Initialize the per-instance ADS driver - _ads.setGain(adsGain); - _ads.setDataRate(adsDataRate); + // Configure the ADS with stored settings + _ads.setGain(_adsGain); + _ads.setDataRate(_adsDataRate); - _ads.begin(_i2cAddress); -} + // Initialize I2C communication with the ADS + bool success = _ads.begin(_i2cAddress); + if (success) { + MS_DBG(F("ADS1x15 initialized successfully at address 0x"), + String(_i2cAddress, HEX)); + } else { + MS_DBG(F("ADS1x15 initialization failed at address 0x"), + String(_i2cAddress, HEX)); + } -// ============================================================================ -// TIADS1x15Base Functions -// ============================================================================ + return success; +} String TIADS1x15Base::getAnalogLocation(int8_t analogChannel, int8_t analogReferenceChannel) { @@ -358,6 +377,25 @@ String TIADS1x15::getSensorLocation(void) { } } + +bool TIADS1x15::setup(void) { + bool sensorSetupSuccess = Sensor::setup(); + bool analogVoltageReaderSuccess = false; + + if (_analogVoltageReader != nullptr) { + analogVoltageReaderSuccess = _analogVoltageReader->begin(); + if (!analogVoltageReaderSuccess) { + MS_DBG(getSensorNameAndLocation(), + F("Analog voltage reader initialization failed")); + } + } else { + MS_DBG(getSensorNameAndLocation(), + F("No analog voltage reader to initialize")); + } + + return sensorSetupSuccess && analogVoltageReaderSuccess; +} + bool TIADS1x15::addSingleMeasurementResult(void) { // Immediately quit if the measurement was not successfully started if (!getStatusBit(MEASUREMENT_SUCCESSFUL)) { diff --git a/src/sensors/TIADS1x15.h b/src/sensors/TIADS1x15.h index a232920a3..444d488c9 100644 --- a/src/sensors/TIADS1x15.h +++ b/src/sensors/TIADS1x15.h @@ -289,6 +289,17 @@ class TIADS1x15Base : public AnalogVoltageBase { */ virtual ~TIADS1x15Base() = default; + /** + * @brief Initialize the ADS1x15 analog voltage reading system + * + * This function performs hardware initialization that cannot be safely + * done in the constructor, including I2C communication with the ADS1x15 + * device to configure gain and data rate settings. + * + * @return True if the initialization was successful, false otherwise + */ + bool begin(void) override; + /** * @brief Read a single-ended voltage measurement from the ADS1x15 * @@ -399,6 +410,14 @@ class TIADS1x15Base : public AnalogVoltageBase { * @brief Internal reference to the I2C address of the TI-ADS1x15 */ uint8_t _i2cAddress; + /** + * @brief The internal gain setting for the ADS1x15 + */ + adsGain_t _adsGain; + /** + * @brief The data rate setting for the ADS1x15 + */ + uint16_t _adsDataRate; /** * @brief Per-instance ADS1x15 driver to maintain separate I2C state */ @@ -490,6 +509,8 @@ class TIADS1x15 : public Sensor { String getSensorLocation(void) override; + bool setup(void) override; + bool addSingleMeasurementResult(void) override; private: diff --git a/src/sensors/TurnerCyclops.cpp b/src/sensors/TurnerCyclops.cpp index 4cc1e9667..c700e3e33 100644 --- a/src/sensors/TurnerCyclops.cpp +++ b/src/sensors/TurnerCyclops.cpp @@ -51,6 +51,25 @@ String TurnerCyclops::getSensorLocation(void) { } +bool TurnerCyclops::setup(void) { + bool sensorSetupSuccess = Sensor::setup(); + bool analogVoltageReaderSuccess = false; + + if (_analogVoltageReader != nullptr) { + analogVoltageReaderSuccess = _analogVoltageReader->begin(); + if (!analogVoltageReaderSuccess) { + MS_DBG(getSensorNameAndLocation(), + F("Analog voltage reader initialization failed")); + } + } else { + MS_DBG(getSensorNameAndLocation(), + F("No analog voltage reader to initialize")); + } + + return sensorSetupSuccess && analogVoltageReaderSuccess; +} + + bool TurnerCyclops::addSingleMeasurementResult(void) { // Immediately quit if the measurement was not successfully started if (!getStatusBit(MEASUREMENT_SUCCESSFUL)) { diff --git a/src/sensors/TurnerCyclops.h b/src/sensors/TurnerCyclops.h index 6c6162f25..20545459d 100644 --- a/src/sensors/TurnerCyclops.h +++ b/src/sensors/TurnerCyclops.h @@ -379,6 +379,8 @@ class TurnerCyclops : public Sensor { String getSensorLocation(void) override; + bool setup(void) override; + bool addSingleMeasurementResult(void) override; private: diff --git a/src/sensors/TurnerTurbidityPlus.cpp b/src/sensors/TurnerTurbidityPlus.cpp index e6575f293..26a115240 100644 --- a/src/sensors/TurnerTurbidityPlus.cpp +++ b/src/sensors/TurnerTurbidityPlus.cpp @@ -72,7 +72,21 @@ void TurnerTurbidityPlus::runWiper() { bool TurnerTurbidityPlus::setup(void) { // Set up the wiper trigger pin, which is active-LOW. pinMode(_wiperTriggerPin, OUTPUT); - return Sensor::setup(); + bool sensorSetupSuccess = Sensor::setup(); + bool analogVoltageReaderSuccess = false; + + if (_analogVoltageReader != nullptr) { + analogVoltageReaderSuccess = _analogVoltageReader->begin(); + if (!analogVoltageReaderSuccess) { + MS_DBG(getSensorNameAndLocation(), + F("Analog voltage reader initialization failed")); + } + } else { + MS_DBG(getSensorNameAndLocation(), + F("No analog voltage reader to initialize")); + } + + return sensorSetupSuccess && analogVoltageReaderSuccess; } bool TurnerTurbidityPlus::wake(void) { From a9ddcc42e7d7c39343972a2b358ba24ffe486396 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Thu, 26 Feb 2026 16:59:40 -0500 Subject: [PATCH 355/533] Minor fixes Signed-off-by: Sara Damiano --- ChangeLog.md | 6 +++--- examples/menu_a_la_carte/menu_a_la_carte.ino | 6 +++--- src/sensors/AlphasenseCO2.cpp | 8 ++++---- src/sensors/AnalogVoltageBase.h | 8 +++++--- src/sensors/ProcessorAnalog.cpp | 2 +- src/sensors/TIADS1x15.cpp | 4 ++++ 6 files changed, 20 insertions(+), 14 deletions(-) diff --git a/ChangeLog.md b/ChangeLog.md index 09c2a9708..2b08a6d0a 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -83,7 +83,7 @@ The logging interval has been added as a required parameter for the constructor! - **AlphasenseCO2** and **TurnerTurbidityPlus** - **BREAKING** The constructors for both of these analog-based classes have changed! Previously the constructor required an enum object for the supported differential channels. -The new constructor requires of two different analog channel numbers as inputs for the differential voltage measurement. +The new constructor requires two different analog channel numbers as inputs for the differential voltage measurement. If you are using code from a previous version of the library, make sure to update your code to use the new constructor and provide the correct analog channel inputs for the differential voltage measurement. - Moved resistor settings and calibration values into the following preprocessor defines that can be modified to tweak the library if necessary: - `ALPHASENSE_CO2_SENSE_RESISTOR_OHM` (defaults to `250.0f`) @@ -144,7 +144,7 @@ Use `completeUpdate(false, false, false, false)` instead. The two functions have been consolidated into one function with four arguments, one each for power on, wake, sleep, and power off. To achieve the same functionality as the old `updateAllSensors()` function (ie, only updating values), set all the arguments to false. -#### Library Wide +#### Library-Wide - Bumped several dependencies - including crucial bug fixes to SensorModbusMaster. - Applied many suggestions from Code Rabbit AI. @@ -194,7 +194,7 @@ This affects the following classes: - TurnerCyclops - TurnerTurbidityPlus -#### Library Wide +#### Library-Wide - Added KnownProcessors.h and moved define values for supported built-in sensors on known processors to that file. - This affects ProcessorStats and the Everlight ALS PT-19. diff --git a/examples/menu_a_la_carte/menu_a_la_carte.ino b/examples/menu_a_la_carte/menu_a_la_carte.ino index 0c23e67a4..5579e1b21 100644 --- a/examples/menu_a_la_carte/menu_a_la_carte.ino +++ b/examples/menu_a_la_carte/menu_a_la_carte.ino @@ -1004,7 +1004,7 @@ Variable* ds3231Temp = const int8_t asCO2Power = sensorPowerPin; // Power pin const int8_t asCO2Channel1 = 2; // First differential channel const int8_t asCO2Channel2 = 3; // Second differential channel -const uint8_t asCO2Meas = 1; // Second differential channel +const uint8_t asCO2Meas = 1; // Number of readings to average // Create an Alphasense CO2 sensor object AlphasenseCO2 alphasenseCO2(asCO2Power, asCO2Channel1, asCO2Channel2, @@ -1137,7 +1137,7 @@ Variable* dhtHI = new AOSongDHT_HI(&dht, // NOTE: Use -1 for any pins that don't apply or aren't being used. const int8_t sq212Power = sensorPowerPin; // Power pin const int8_t sq212ADSChannel = 3; // The ADS channel for the SQ212 -const uint8_t sq212Readings = 1; // The ADS channel for the SQ212 +const uint8_t sq212Readings = 1; // The number of readings to average // Create an Apogee SQ212 sensor object with the default voltage reader ApogeeSQ212 sq212(sq212Power, sq212ADSChannel); @@ -2506,7 +2506,7 @@ float analogECMultiplier = 1.0f; // factor for a voltage divider float analogECSupply = 3.3f; // supply voltage of the Processor ADC ProcessorAnalogBase analogECADS(analogECMultiplier, analogECSupply); -// Create a Turner analogEC sensor object with the custom ADS instance +// Create an AnalogElecConductivity sensor object with the custom ADS instance AnalogElecConductivity analogEC_c(analogECPower, analogECData, ANALOGELECCONDUCTIVITY_RSERIES_OHMS, ANALOGELECCONDUCTIVITY_KONST, diff --git a/src/sensors/AlphasenseCO2.cpp b/src/sensors/AlphasenseCO2.cpp index 079a62966..215456984 100644 --- a/src/sensors/AlphasenseCO2.cpp +++ b/src/sensors/AlphasenseCO2.cpp @@ -55,9 +55,9 @@ String AlphasenseCO2::getSensorLocation(void) { bool AlphasenseCO2::setup(void) { - bool sensorSetupSuccess = Sensor::setup(); + bool sensorSetupSuccess = Sensor::setup(); bool analogVoltageReaderSuccess = false; - + if (_analogVoltageReader != nullptr) { analogVoltageReaderSuccess = _analogVoltageReader->begin(); if (!analogVoltageReaderSuccess) { @@ -68,7 +68,7 @@ bool AlphasenseCO2::setup(void) { MS_DBG(getSensorNameAndLocation(), F("No analog voltage reader to initialize")); } - + return sensorSetupSuccess && analogVoltageReaderSuccess; } @@ -104,7 +104,7 @@ bool AlphasenseCO2::addSingleMeasurementResult(void) { // Convert voltage to current (mA) - assuming a 250 Ohm resistor is in // series float co2Current = (adcVoltage / ALPHASENSE_CO2_SENSE_RESISTOR_OHM) * - 1000; + 1000.0f; MS_DBG(F(" co2Current:"), co2Current); // Convert current to ppm (using a formula recommended by the sensor diff --git a/src/sensors/AnalogVoltageBase.h b/src/sensors/AnalogVoltageBase.h index 8eea34e73..57d063013 100644 --- a/src/sensors/AnalogVoltageBase.h +++ b/src/sensors/AnalogVoltageBase.h @@ -44,11 +44,13 @@ * * This class provides a unified interface for analog voltage reading, * whether from external ADCs (like TI ADS1x15) or processor built-in ADCs. - * Classes that inherit from this base must implement three pure virtual + * Classes that inherit from this base must implement five pure virtual * methods: + * - begin() for hardware initialization, * - readVoltageSingleEnded() for single-ended voltage measurements, - * - readVoltageDifferential() for differential voltage measurements, and - * - getAnalogLocation() to provide sensor location identification. + * - readVoltageDifferential() for differential voltage measurements, + * - getAnalogLocation() to provide sensor location identification, and + * - calculateAnalogResolutionVolts() to compute voltage resolution. */ class AnalogVoltageBase { public: diff --git a/src/sensors/ProcessorAnalog.cpp b/src/sensors/ProcessorAnalog.cpp index 58974704e..16823e047 100644 --- a/src/sensors/ProcessorAnalog.cpp +++ b/src/sensors/ProcessorAnalog.cpp @@ -95,7 +95,7 @@ float ProcessorAnalogBase::calculateAnalogResolutionVolts(void) { // (single-ended measurements from 0V to supply voltage) float fullScaleRangeVolts = _supplyVoltage; - if (resolutionBits == 0 || resolutionBits > 32 || + if (resolutionBits == 0 || resolutionBits >= 32 || fullScaleRangeVolts <= 0.0f) { MS_DBG(F("Invalid ADC configuration - bits: "), resolutionBits, F(", supply voltage: "), fullScaleRangeVolts, F("V")); diff --git a/src/sensors/TIADS1x15.cpp b/src/sensors/TIADS1x15.cpp index a6c2397ee..71fd77cf4 100644 --- a/src/sensors/TIADS1x15.cpp +++ b/src/sensors/TIADS1x15.cpp @@ -252,6 +252,8 @@ bool TIADS1x15Base::isValidDifferentialPair(int8_t channel1, int8_t channel2) { void TIADS1x15Base::setADSGain(adsGain_t adsGain) { // Update the per-instance driver with new gain setting _ads.setGain(adsGain); + // Keep cached value in sync + _adsGain = adsGain; } adsGain_t TIADS1x15Base::getADSGain(void) { @@ -262,6 +264,8 @@ adsGain_t TIADS1x15Base::getADSGain(void) { void TIADS1x15Base::setADSDataRate(uint16_t adsDataRate) { // Update the per-instance driver with new data rate setting _ads.setDataRate(adsDataRate); + // Keep cached value in sync + _adsDataRate = adsDataRate; } uint16_t TIADS1x15Base::getADSDataRate(void) { From a132175cd92e9cd086b8b2f33ffaadfaeda5faab Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Thu, 26 Feb 2026 17:13:13 -0500 Subject: [PATCH 356/533] if the call to create new objects fails the stack is overflowing and a null check isn't going to save us. Get rid of the hated helper. Signed-off-by: Sara Damiano --- src/sensors/AlphasenseCO2.cpp | 12 +++++------ src/sensors/AnalogElecConductivity.cpp | 19 +++++++---------- src/sensors/ApogeeSQ212.cpp | 18 +++++++--------- src/sensors/CampbellOBS3.cpp | 18 +++++++--------- src/sensors/EverlightALSPT19.cpp | 20 ++++++++---------- src/sensors/ProcessorAnalog.cpp | 13 +++++------- src/sensors/ProcessorAnalog.h | 29 -------------------------- src/sensors/TIADS1x15.cpp | 16 +++++++------- src/sensors/TIADS1x15.h | 27 ------------------------ src/sensors/TurnerCyclops.cpp | 18 +++++++--------- src/sensors/TurnerTurbidityPlus.cpp | 18 +++++++--------- 11 files changed, 66 insertions(+), 142 deletions(-) diff --git a/src/sensors/AlphasenseCO2.cpp b/src/sensors/AlphasenseCO2.cpp index 215456984..1bd6e2ac2 100644 --- a/src/sensors/AlphasenseCO2.cpp +++ b/src/sensors/AlphasenseCO2.cpp @@ -27,13 +27,11 @@ AlphasenseCO2::AlphasenseCO2(int8_t powerPin, int8_t analogChannel, measurementsToAverage, ALPHASENSE_CO2_INC_CALC_VARIABLES), _analogReferenceChannel(analogReferenceChannel), - _analogVoltageReader(analogVoltageReader), - _ownsAnalogVoltageReader(analogVoltageReader == nullptr) { - // If no analog voltage reader was provided, create a default one - if (analogVoltageReader == nullptr) { - _analogVoltageReader = createTIADS1x15Base(_ownsAnalogVoltageReader); - } -} + // If no analog voltage reader was provided, create a default one + _analogVoltageReader(analogVoltageReader == nullptr + ? new TIADS1x15Base() + : analogVoltageReader), + _ownsAnalogVoltageReader(analogVoltageReader == nullptr) {} // Destructor AlphasenseCO2::~AlphasenseCO2() { diff --git a/src/sensors/AnalogElecConductivity.cpp b/src/sensors/AnalogElecConductivity.cpp index 684c39dcc..356947478 100644 --- a/src/sensors/AnalogElecConductivity.cpp +++ b/src/sensors/AnalogElecConductivity.cpp @@ -24,14 +24,11 @@ AnalogElecConductivity::AnalogElecConductivity( measurementsToAverage, ANALOGELECCONDUCTIVITY_INC_CALC_VARIABLES), _Rseries_ohms(Rseries_ohms), _sensorEC_Konst(sensorEC_Konst), - _analogVoltageReader(analogVoltageReader), - _ownsAnalogVoltageReader(analogVoltageReader == nullptr) { - // If no analog voltage reader was provided, create a default one - if (analogVoltageReader == nullptr) { - _analogVoltageReader = - createProcessorAnalogBase(_ownsAnalogVoltageReader); - } -} + // If no analog voltage reader was provided, create a default one + _analogVoltageReader(analogVoltageReader == nullptr + ? new ProcessorAnalogBase() + : analogVoltageReader), + _ownsAnalogVoltageReader(analogVoltageReader == nullptr) {} // Destructor AnalogElecConductivity::~AnalogElecConductivity() { @@ -56,9 +53,9 @@ String AnalogElecConductivity::getSensorLocation(void) { bool AnalogElecConductivity::setup(void) { - bool sensorSetupSuccess = Sensor::setup(); + bool sensorSetupSuccess = Sensor::setup(); bool analogVoltageReaderSuccess = false; - + if (_analogVoltageReader != nullptr) { analogVoltageReaderSuccess = _analogVoltageReader->begin(); if (!analogVoltageReaderSuccess) { @@ -69,7 +66,7 @@ bool AnalogElecConductivity::setup(void) { MS_DBG(getSensorNameAndLocation(), F("No analog voltage reader to initialize")); } - + return sensorSetupSuccess && analogVoltageReaderSuccess; } diff --git a/src/sensors/ApogeeSQ212.cpp b/src/sensors/ApogeeSQ212.cpp index 8e5cfe3d7..053f31e5f 100644 --- a/src/sensors/ApogeeSQ212.cpp +++ b/src/sensors/ApogeeSQ212.cpp @@ -23,13 +23,11 @@ ApogeeSQ212::ApogeeSQ212(int8_t powerPin, int8_t analogChannel, : Sensor("ApogeeSQ212", SQ212_NUM_VARIABLES, SQ212_WARM_UP_TIME_MS, SQ212_STABILIZATION_TIME_MS, SQ212_MEASUREMENT_TIME_MS, powerPin, analogChannel, measurementsToAverage, SQ212_INC_CALC_VARIABLES), - _analogVoltageReader(analogVoltageReader), - _ownsAnalogVoltageReader(analogVoltageReader == nullptr) { - // If no analog voltage reader was provided, create a default one - if (analogVoltageReader == nullptr) { - _analogVoltageReader = createTIADS1x15Base(_ownsAnalogVoltageReader); - } -} + // If no analog voltage reader was provided, create a default one + _analogVoltageReader(analogVoltageReader == nullptr + ? new TIADS1x15Base() + : analogVoltageReader), + _ownsAnalogVoltageReader(analogVoltageReader == nullptr) {} // Destructor ApogeeSQ212::~ApogeeSQ212() { @@ -50,9 +48,9 @@ String ApogeeSQ212::getSensorLocation(void) { bool ApogeeSQ212::setup(void) { - bool sensorSetupSuccess = Sensor::setup(); + bool sensorSetupSuccess = Sensor::setup(); bool analogVoltageReaderSuccess = false; - + if (_analogVoltageReader != nullptr) { analogVoltageReaderSuccess = _analogVoltageReader->begin(); if (!analogVoltageReaderSuccess) { @@ -63,7 +61,7 @@ bool ApogeeSQ212::setup(void) { MS_DBG(getSensorNameAndLocation(), F("No analog voltage reader to initialize")); } - + return sensorSetupSuccess && analogVoltageReaderSuccess; } diff --git a/src/sensors/CampbellOBS3.cpp b/src/sensors/CampbellOBS3.cpp index e14ed5bdc..32686ad24 100644 --- a/src/sensors/CampbellOBS3.cpp +++ b/src/sensors/CampbellOBS3.cpp @@ -24,13 +24,11 @@ CampbellOBS3::CampbellOBS3(int8_t powerPin, int8_t analogChannel, _x2_coeff_A(x2_coeff_A), _x1_coeff_B(x1_coeff_B), _x0_coeff_C(x0_coeff_C), - _analogVoltageReader(analogVoltageReader), - _ownsAnalogVoltageReader(analogVoltageReader == nullptr) { - // If no analog voltage reader was provided, create a default one - if (analogVoltageReader == nullptr) { - _analogVoltageReader = createTIADS1x15Base(_ownsAnalogVoltageReader); - } -} + // If no analog voltage reader was provided, create a default one + _analogVoltageReader(analogVoltageReader == nullptr + ? new TIADS1x15Base() + : analogVoltageReader), + _ownsAnalogVoltageReader(analogVoltageReader == nullptr) {} // Destructor CampbellOBS3::~CampbellOBS3() { @@ -51,9 +49,9 @@ String CampbellOBS3::getSensorLocation(void) { bool CampbellOBS3::setup(void) { - bool sensorSetupSuccess = Sensor::setup(); + bool sensorSetupSuccess = Sensor::setup(); bool analogVoltageReaderSuccess = false; - + if (_analogVoltageReader != nullptr) { analogVoltageReaderSuccess = _analogVoltageReader->begin(); if (!analogVoltageReaderSuccess) { @@ -64,7 +62,7 @@ bool CampbellOBS3::setup(void) { MS_DBG(getSensorNameAndLocation(), F("No analog voltage reader to initialize")); } - + return sensorSetupSuccess && analogVoltageReaderSuccess; } diff --git a/src/sensors/EverlightALSPT19.cpp b/src/sensors/EverlightALSPT19.cpp index ebf8c6ab4..8986bc7df 100644 --- a/src/sensors/EverlightALSPT19.cpp +++ b/src/sensors/EverlightALSPT19.cpp @@ -22,15 +22,13 @@ EverlightALSPT19::EverlightALSPT19(int8_t powerPin, int8_t dataPin, measurementsToAverage, ALSPT19_INC_CALC_VARIABLES), _alsSupplyVoltage((alsSupplyVoltage > 0.0f) ? alsSupplyVoltage : OPERATING_VOLTAGE), + // If no analog voltage reader was provided, create a default one _loadResistor(loadResistor), - _analogVoltageReader(analogVoltageReader), - _ownsAnalogVoltageReader(analogVoltageReader == nullptr) { - // If no analog voltage reader was provided, create a default one - if (analogVoltageReader == nullptr) { - _analogVoltageReader = - createProcessorAnalogBase(_ownsAnalogVoltageReader); - } -} + _analogVoltageReader(analogVoltageReader == nullptr + ? new ProcessorAnalogBase() + : analogVoltageReader), + _ownsAnalogVoltageReader(analogVoltageReader == nullptr) {} + #if (defined(BUILT_IN_ALS_POWER_PIN) && defined(BUILT_IN_ALS_DATA_PIN) && \ defined(BUILT_IN_ALS_SUPPLY_VOLTAGE) && \ defined(BUILT_IN_ALS_LOADING_RESISTANCE)) || \ @@ -62,9 +60,9 @@ String EverlightALSPT19::getSensorLocation(void) { bool EverlightALSPT19::setup(void) { - bool sensorSetupSuccess = Sensor::setup(); + bool sensorSetupSuccess = Sensor::setup(); bool analogVoltageReaderSuccess = false; - + if (_analogVoltageReader != nullptr) { analogVoltageReaderSuccess = _analogVoltageReader->begin(); if (!analogVoltageReaderSuccess) { @@ -75,7 +73,7 @@ bool EverlightALSPT19::setup(void) { MS_DBG(getSensorNameAndLocation(), F("No analog voltage reader to initialize")); } - + return sensorSetupSuccess && analogVoltageReaderSuccess; } diff --git a/src/sensors/ProcessorAnalog.cpp b/src/sensors/ProcessorAnalog.cpp index 16823e047..0f4e15748 100644 --- a/src/sensors/ProcessorAnalog.cpp +++ b/src/sensors/ProcessorAnalog.cpp @@ -133,14 +133,11 @@ ProcessorAnalog::ProcessorAnalog(int8_t powerPin, int8_t dataPin, PROCESSOR_ANALOG_STABILIZATION_TIME_MS, PROCESSOR_ANALOG_MEASUREMENT_TIME_MS, powerPin, dataPin, measurementsToAverage, PROCESSOR_ANALOG_INC_CALC_VARIABLES), - _analogVoltageReader(analogVoltageReader), - _ownsAnalogVoltageReader(analogVoltageReader == nullptr) { - // If no analog base provided, create one with default settings - if (analogVoltageReader == nullptr) { - _analogVoltageReader = - createProcessorAnalogBase(_ownsAnalogVoltageReader); - } -} + // If no analog base provided, create one with default settings + _analogVoltageReader(analogVoltageReader == nullptr + ? new ProcessorAnalogBase() + : analogVoltageReader), + _ownsAnalogVoltageReader(analogVoltageReader == nullptr) {} // Destructor ProcessorAnalog::~ProcessorAnalog() { diff --git a/src/sensors/ProcessorAnalog.h b/src/sensors/ProcessorAnalog.h index 2da371535..514336a89 100644 --- a/src/sensors/ProcessorAnalog.h +++ b/src/sensors/ProcessorAnalog.h @@ -238,35 +238,6 @@ class ProcessorAnalogBase : public AnalogVoltageBase { }; -// Inline utility function implementation -/** - * @brief Create a ProcessorAnalogBase analog voltage reader with ownership - * tracking - * - * This utility function safely creates a new ProcessorAnalogBase object with - * default settings and verifies it was created successfully. It handles the - * pattern of creating default analog voltage readers when none is provided to - * sensor constructors. - * - * @param[out] ownsAnalogVoltageReader Reference to bool that tracks ownership. - * Set to true if the reader was created successfully, false if creation - * failed. - * @return Pointer to created ProcessorAnalogBase object, or nullptr if creation - * failed - * - * @note This function is designed for use in sensor constructors that need a - * default analog voltage reader. The ownership flag should be used to determine - * whether the returned pointer needs to be deleted in the sensor's destructor. - */ -inline ProcessorAnalogBase* -createProcessorAnalogBase(bool& ownsAnalogVoltageReader) { - ProcessorAnalogBase* reader = new ProcessorAnalogBase(); - // verify that the voltage reader was created successfully - // this could fail silently on no-exceptions Arduino targets - ownsAnalogVoltageReader = (reader != nullptr); - return reader; -} - /* clang-format off */ /** * @brief The Sensor sub-class for the diff --git a/src/sensors/TIADS1x15.cpp b/src/sensors/TIADS1x15.cpp index 71fd77cf4..6f4bbdbbb 100644 --- a/src/sensors/TIADS1x15.cpp +++ b/src/sensors/TIADS1x15.cpp @@ -348,13 +348,11 @@ TIADS1x15::TIADS1x15(int8_t powerPin, int8_t adsChannel, powerPin, adsChannel, measurementsToAverage, TIADS1X15_INC_CALC_VARIABLES), _analogReferenceChannel(analogReferenceChannel), - _analogVoltageReader(analogVoltageReader), + // If no analog voltage reader was provided, create a default one + _analogVoltageReader(analogVoltageReader == nullptr + ? new TIADS1x15Base() + : analogVoltageReader), _ownsAnalogVoltageReader(analogVoltageReader == nullptr) { - // If no analog voltage reader was provided, create a default one - if (analogVoltageReader == nullptr) { - _analogVoltageReader = createTIADS1x15Base(_ownsAnalogVoltageReader); - } - // NOTE: We DO NOT validate the channel numbers and pairings in this // constructor! We CANNOT print a warning here about invalid channel // because the Serial object may not be initialized yet, and we don't want @@ -383,9 +381,9 @@ String TIADS1x15::getSensorLocation(void) { bool TIADS1x15::setup(void) { - bool sensorSetupSuccess = Sensor::setup(); + bool sensorSetupSuccess = Sensor::setup(); bool analogVoltageReaderSuccess = false; - + if (_analogVoltageReader != nullptr) { analogVoltageReaderSuccess = _analogVoltageReader->begin(); if (!analogVoltageReaderSuccess) { @@ -396,7 +394,7 @@ bool TIADS1x15::setup(void) { MS_DBG(getSensorNameAndLocation(), F("No analog voltage reader to initialize")); } - + return sensorSetupSuccess && analogVoltageReaderSuccess; } diff --git a/src/sensors/TIADS1x15.h b/src/sensors/TIADS1x15.h index 444d488c9..0e057ad99 100644 --- a/src/sensors/TIADS1x15.h +++ b/src/sensors/TIADS1x15.h @@ -428,33 +428,6 @@ class TIADS1x15Base : public AnalogVoltageBase { #endif }; -// Inline utility function implementation -/** - * @brief Create a TIADS1x15Base analog voltage reader with ownership tracking - * - * This utility function safely creates a new TIADS1x15Base object with default - * settings and verifies it was created successfully. It handles the pattern of - * creating default analog voltage readers when none is provided to sensor - * constructors. - * - * @param[out] ownsAnalogVoltageReader Reference to bool that tracks ownership. - * Set to true if the reader was created successfully, false if creation - * failed. - * @return Pointer to created TIADS1x15Base object, or nullptr if creation - * failed - * - * @note This function is designed for use in sensor constructors that need a - * default analog voltage reader. The ownership flag should be used to determine - * whether the returned pointer needs to be deleted in the sensor's destructor. - */ -inline TIADS1x15Base* createTIADS1x15Base(bool& ownsAnalogVoltageReader) { - TIADS1x15Base* reader = new TIADS1x15Base(); - // verify that the voltage reader was created successfully - // this could fail silently on no-exceptions Arduino targets - ownsAnalogVoltageReader = (reader != nullptr); - return reader; -} - /* clang-format off */ /** * @brief The Sensor sub-class for the diff --git a/src/sensors/TurnerCyclops.cpp b/src/sensors/TurnerCyclops.cpp index c700e3e33..7f83b89ce 100644 --- a/src/sensors/TurnerCyclops.cpp +++ b/src/sensors/TurnerCyclops.cpp @@ -25,13 +25,11 @@ TurnerCyclops::TurnerCyclops(int8_t powerPin, int8_t analogChannel, _conc_std(conc_std), _volt_std(volt_std), _volt_blank(volt_blank), - _analogVoltageReader(analogVoltageReader), - _ownsAnalogVoltageReader(analogVoltageReader == nullptr) { - // If no analog voltage reader was provided, create a default one - if (analogVoltageReader == nullptr) { - _analogVoltageReader = createTIADS1x15Base(_ownsAnalogVoltageReader); - } -} + // If no analog voltage reader was provided, create a default one + _analogVoltageReader(analogVoltageReader == nullptr + ? new TIADS1x15Base() + : analogVoltageReader), + _ownsAnalogVoltageReader(analogVoltageReader == nullptr) {} // Destructor TurnerCyclops::~TurnerCyclops() { @@ -52,9 +50,9 @@ String TurnerCyclops::getSensorLocation(void) { bool TurnerCyclops::setup(void) { - bool sensorSetupSuccess = Sensor::setup(); + bool sensorSetupSuccess = Sensor::setup(); bool analogVoltageReaderSuccess = false; - + if (_analogVoltageReader != nullptr) { analogVoltageReaderSuccess = _analogVoltageReader->begin(); if (!analogVoltageReaderSuccess) { @@ -65,7 +63,7 @@ bool TurnerCyclops::setup(void) { MS_DBG(getSensorNameAndLocation(), F("No analog voltage reader to initialize")); } - + return sensorSetupSuccess && analogVoltageReaderSuccess; } diff --git a/src/sensors/TurnerTurbidityPlus.cpp b/src/sensors/TurnerTurbidityPlus.cpp index 26a115240..0cb9c42ae 100644 --- a/src/sensors/TurnerTurbidityPlus.cpp +++ b/src/sensors/TurnerTurbidityPlus.cpp @@ -28,13 +28,11 @@ TurnerTurbidityPlus::TurnerTurbidityPlus( _volt_std(volt_std), _volt_blank(volt_blank), _analogReferenceChannel(analogReferenceChannel), - _analogVoltageReader(analogVoltageReader), - _ownsAnalogVoltageReader(analogVoltageReader == nullptr) { - // If no analog voltage reader was provided, create a default one - if (analogVoltageReader == nullptr) { - _analogVoltageReader = createTIADS1x15Base(_ownsAnalogVoltageReader); - } -} + // If no analog voltage reader was provided, create a default one + _analogVoltageReader(analogVoltageReader == nullptr + ? new TIADS1x15Base() + : analogVoltageReader), + _ownsAnalogVoltageReader(analogVoltageReader == nullptr) {} // Destructor TurnerTurbidityPlus::~TurnerTurbidityPlus() { @@ -72,9 +70,9 @@ void TurnerTurbidityPlus::runWiper() { bool TurnerTurbidityPlus::setup(void) { // Set up the wiper trigger pin, which is active-LOW. pinMode(_wiperTriggerPin, OUTPUT); - bool sensorSetupSuccess = Sensor::setup(); + bool sensorSetupSuccess = Sensor::setup(); bool analogVoltageReaderSuccess = false; - + if (_analogVoltageReader != nullptr) { analogVoltageReaderSuccess = _analogVoltageReader->begin(); if (!analogVoltageReaderSuccess) { @@ -85,7 +83,7 @@ bool TurnerTurbidityPlus::setup(void) { MS_DBG(getSensorNameAndLocation(), F("No analog voltage reader to initialize")); } - + return sensorSetupSuccess && analogVoltageReaderSuccess; } From ea9b009666460f373f2c9e28e4bf4b57d58e71c2 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Thu, 26 Feb 2026 17:13:36 -0500 Subject: [PATCH 357/533] Properly use ALPHASENSE_CO2_VOLTAGE_MULTIPLIER Signed-off-by: Sara Damiano --- src/sensors/AlphasenseCO2.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/sensors/AlphasenseCO2.cpp b/src/sensors/AlphasenseCO2.cpp index 1bd6e2ac2..23ad0277c 100644 --- a/src/sensors/AlphasenseCO2.cpp +++ b/src/sensors/AlphasenseCO2.cpp @@ -28,9 +28,10 @@ AlphasenseCO2::AlphasenseCO2(int8_t powerPin, int8_t analogChannel, _analogReferenceChannel(analogReferenceChannel), // If no analog voltage reader was provided, create a default one - _analogVoltageReader(analogVoltageReader == nullptr - ? new TIADS1x15Base() - : analogVoltageReader), + _analogVoltageReader( + analogVoltageReader == nullptr + ? new TIADS1x15Base(ALPHASENSE_CO2_VOLTAGE_MULTIPLIER) + : analogVoltageReader), _ownsAnalogVoltageReader(analogVoltageReader == nullptr) {} // Destructor From 14a9b038cd8514126ff530e81f06e7198a791ccf Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Thu, 26 Feb 2026 17:39:23 -0500 Subject: [PATCH 358/533] Fix ctor order Signed-off-by: Sara Damiano --- ChangeLog.md | 10 +++--- examples/menu_a_la_carte/menu_a_la_carte.ino | 38 ++++++++++---------- src/sensors/ProcessorAnalog.h | 7 ++-- 3 files changed, 27 insertions(+), 28 deletions(-) diff --git a/ChangeLog.md b/ChangeLog.md index 2b08a6d0a..4193acc17 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -227,7 +227,7 @@ This affects the following classes: ### Changed -- **BREAKING** Converted the watch-dog classes in to static classes with all static function and a **deleted constructor**. +- **BREAKING** Converted the watch-dog classes into static classes with all static function and a **deleted constructor**. - Any code that attempted to interact with the watchdog (ie, with a "complex loop") must now call the extendedWatchDog class directly, ie: `extendedWatchDog::resetWatchDog();` rather than `dataLogger.watchDogTimer.resetWatchDog();` - **BREAKING** Renamed `markedLocalEpochTime` to `markedLocalUnixTime` to clarify the start of the epoch that we're marking down. - **BREAKING** Renamed `markedUTCEpochTime` to `markedUTCUnixTime` to clarify the start of the epoch that we're marking down. @@ -249,7 +249,7 @@ I realized this was a problem for analog values I tried to read that reported co - `Logger::setRTClock(UTCEpochSeconds)`; use `loggerClock::setRTClock(ts, utcOffset, epoch)` in new code. - `Logger::isRTCSane()`; use `loggerClock::isRTCSane()` in new code. - `Logger::wakeISR()`; use `loggerClock::rtcISR()` in new code. -- Support timestamps as time_t objects instead of uint32_t where every sensible. +- Support timestamps as time_t objects instead of uint32_t wherever sensible. - The size of a uint32_t is always 32 bits, but the size of the time_t object varies by processor - for some it is 32 bits, for other 64. - Changed the watchdog from a fixed 15 minute reset timer to 2x the logging interval (or at least 5 minutes). - Modified all examples which define a sercom serial port for SAMD21 processors to require the defines for the supported processors. @@ -275,7 +275,7 @@ This should only make a difference for my compilation tests, real users should p ### Added -- **CONFIGURATION** Added a two configuration files (ModSensorConfig.h and ModSensorDebugConfig.h) that all files read from to check for configuration-related defines. +- **CONFIGURATION** Added two configuration files (ModSensorConfig.h and ModSensorDebugConfig.h) that all files read from to check for configuration-related defines. This allows Arduino IDE users who are unable to use build flags to more easily configure the library or enable debugging. It also allows PlatformIO users to avoid the time-consuming re-compile of all their libraries required when changing build flags. - **ALL** library configuration build flags previously in any other header file for the library have been moved into the ModSensorConfig.h file, including ADC, SDI-12, and variable array options. @@ -290,7 +290,7 @@ If no epoch start is given, it is assumed to be UNIX (January 1, 1970). - The supported epochs are given in the enum epochStart. - Storing _buttonPinMode internally. - Added a single define (`MS_OUTPUT`) to use for all outputs from ModularSensors. -- Added support for sending printouts and debugging to two different serial ports. This is useful for devices (like SAMD) that use a built in USB serial port which is turned off when the device sleeps. If `MS_2ND_OUTPUT` is defined, output will go to *both* `MS_2ND_OUTPUT` and to `MS_OUTPUT`. +- Added support for sending printouts and debugging to two different serial ports. This is useful for devices (like SAMD) that use a built in USB serial port which is turned off when the device sleeps. If `MS_2ND_OUTPUT` is defined, output will go to *both* `MS_2ND_OUTPUT` and to `MS_OUTPUT`. - Added example code for flashing boards with a neo-pixel in the menu example. - **NEW SENSOR** Added support for [Geolux HydroCam](https://www.geolux-radars.com/hydrocam) - **NEW SENSOR** Added support for [ANB Sensors pH Sensors](https://www.anbsensors.com/) @@ -1043,7 +1043,7 @@ Support for all Atlas Scientific I2C sensors, compiler-safe begin functions ## [0.19.6] - 2019-02-27 -Modem Improvements & ADS1X15 Generalization +Modem Improvements & ADS1x15 Generalization [![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.2579301.svg)](https://doi.org/10.5281/zenodo.2579301) diff --git a/examples/menu_a_la_carte/menu_a_la_carte.ino b/examples/menu_a_la_carte/menu_a_la_carte.ino index 5579e1b21..d55c0605e 100644 --- a/examples/menu_a_la_carte/menu_a_la_carte.ino +++ b/examples/menu_a_la_carte/menu_a_la_carte.ino @@ -1021,8 +1021,8 @@ float AsCO2Multiplier = 1.0f; // factor for a voltage divider adsGain_t AsCO2AdsGain = GAIN_ONE; // gain of the ADS1115 float AsCO2adsSupply = 3.3f; // supply voltage of the ADS1115 const uint8_t AsCO2i2c_addr = 0x48; // The I2C address of the ADS1115 ADC -TIADS1x15Base AsCO2ADS(AsCO2Multiplier, AsCO2AdsGain, AsCO2adsSupply, - AsCO2i2c_addr); +TIADS1x15Base AsCO2ADS(AsCO2Multiplier, AsCO2AdsGain, AsCO2i2c_addr, + AsCO2adsSupply); // Create an Alphasense CO2 sensor object with the custom TIADS1x15Base AlphasenseCO2 alphasenseCO2_c(asCO2Power, asCO2Channel1, asCO2Channel2, @@ -1047,10 +1047,10 @@ AlphasenseCO2 alphasenseCO2_c(asCO2Power, asCO2Channel1, asCO2Channel2, // NOTE: Use -1 for any pins that don't apply or aren't being used. byte anbModbusAddress = 0x55; // The modbus address of ANB pH Sensor (0x55 is the default) -const int8_t anbPower = sensorPowerPin; // ANB pH Sensor power pin +const int8_t anbPower = sensorPowerPin; // ANB pH Sensor power pin const int8_t anbAdapterPower = sensorPowerPin; // RS485 adapter power pin const int8_t anb485EnablePin = -1; // Adapter RE/DE pin -const uint8_t anbNReadings = 1; +const uint8_t anbNReadings = 1; // Number of readings // Create an ANB pH sensor object ANBpH anbPH(anbModbusAddress, modbusSerial, anbPower, loggingInterval, @@ -1153,8 +1153,8 @@ float sq212Multiplier = 1.0f; // factor for a voltage divider adsGain_t sq212AdsGain = GAIN_ONE; // gain of the ADS1115 float sq212adsSupply = 3.3f; // supply voltage of the ADS1115 const uint8_t sq212i2c_addr = 0x48; // The I2C address of the ADS1115 ADC -TIADS1x15Base sq212ADS(sq212Multiplier, sq212AdsGain, sq212adsSupply, - sq212i2c_addr); +TIADS1x15Base sq212ADS(sq212Multiplier, sq212AdsGain, sq212i2c_addr, + sq212adsSupply); // Create an Apogee SQ212 sensor object with the custom TIADS1x15Base ApogeeSQ212 sq212_c(sq212Power, sq212ADSChannel, sq212Readings, &sq212ADS); @@ -1463,8 +1463,8 @@ Variable* clarivueError = new CampbellClariVUE10_ErrorCode( #include // NOTE: Use -1 for any pins that don't apply or aren't being used. -const int8_t OBS3Power = sensorPowerPin; // Power pin -const uint8_t OBS3NReadings = 10; +const int8_t OBS3Power = sensorPowerPin; // Power pin +const uint8_t OBS3NReadings = 10; const int8_t OBSLowADSChannel = 0; // ADS channel for *low* range output @@ -1506,8 +1506,8 @@ float OBS3Multiplier = 1.0f; // factor for a voltage divider adsGain_t OBS3AdsGain = GAIN_ONE; // gain of the ADS1115 float OBS3AdsSupplyVoltage = 3.3f; // supply voltage of the ADS1115 const uint8_t OBS3AdsI2C_addr = 0x48; // The I2C address of the ADS1115 ADC -TIADS1x15Base OBSADS(OBS3Multiplier, OBS3AdsGain, OBS3AdsSupplyVoltage, - OBS3AdsI2C_addr); +TIADS1x15Base OBSADS(OBS3Multiplier, OBS3AdsGain, OBS3AdsI2C_addr, + OBS3AdsSupplyVoltage); // Create a Campbell OBS3+ *low* range sensor object with the custom // TIADS1x15Base @@ -1679,8 +1679,8 @@ float evVoltageMultiplier = 1.0f; // factor for a voltage divider adsGain_t evAdsGain = GAIN_ONE; // gain of the ADS1115 float evAdsSupplyVoltage = 3.3f; // supply voltage of the ADS1115 const uint8_t evAdsI2C_addr = 0x48; // The I2C address of the ADS1115 ADC -TIADS1x15Base evADS(evVoltageMultiplier, evAdsGain, evAdsSupplyVoltage, - evAdsI2C_addr); +TIADS1x15Base evADS(evVoltageMultiplier, evAdsGain, evAdsI2C_addr, + evAdsSupplyVoltage); // Create a single ended External Voltage sensor object with the custom // TIADS1x15Base @@ -2314,9 +2314,9 @@ Variable* inaPower = new TIINA219_Power(&ina219, #include // NOTE: Use -1 for any pins that don't apply or aren't being used. -const int8_t cyclopsPower = sensorPowerPin; // Power pin -const uint8_t cyclopsNReadings = 10; -const int8_t cyclopsADSChannel = 0; // ADS channel +const int8_t cyclopsPower = sensorPowerPin; // Power pin +const uint8_t cyclopsNReadings = 10; +const int8_t cyclopsADSChannel = 0; // ADS channel // Cyclops calibration information const float cyclopsStdConc = 1.000; // Concentration of the standard used @@ -2368,8 +2368,8 @@ float cyclopsMultiplier = 1.0f; // factor for a voltage divider adsGain_t cyclopsAdsGain = GAIN_ONE; // gain of the ADS1115 float cyclopsAdsSupplyVoltage = 3.3f; // supply voltage of the ADS1115 const uint8_t cyclopsAdsI2C_addr = 0x48; // The I2C address of the ADS1115 ADC -TIADS1x15Base cyclopsADS(cyclopsMultiplier, cyclopsAdsGain, - cyclopsAdsSupplyVoltage, cyclopsAdsI2C_addr); +TIADS1x15Base cyclopsADS(cyclopsMultiplier, cyclopsAdsGain, cyclopsAdsI2C_addr, + cyclopsAdsSupplyVoltage); // Create a Turner Cyclops sensor object with the custom ADS instance TurnerCyclops cyclops_c(cyclopsPower, cyclopsADSChannel, cyclopsStdConc, @@ -2428,8 +2428,8 @@ float ttPlusMultiplier = 1.0f; // factor for a voltage divider adsGain_t ttPlusAdsGain = GAIN_ONE; // gain of the ADS1115 float ttPlusAdsSupply = 3.3f; // supply voltage of the ADS1115 const uint8_t ttPlusI2C_addr = 0x48; // The I2C address of the ADS1115 ADC -TIADS1x15Base ttPlusADS(ttPlusMultiplier, ttPlusAdsGain, ttPlusAdsSupply, - ttPlusI2C_addr); +TIADS1x15Base ttPlusADS(ttPlusMultiplier, ttPlusAdsGain, ttPlusI2C_addr, + ttPlusAdsSupply); // Create a Turner Turbidity Plus sensor object with the custom TIADS1x15Base TurnerTurbidityPlus turbidityPlus_c(ttPlusPower, ttPlusWiper, ttPlusChannel1, diff --git a/src/sensors/ProcessorAnalog.h b/src/sensors/ProcessorAnalog.h index 514336a89..845d92daa 100644 --- a/src/sensors/ProcessorAnalog.h +++ b/src/sensors/ProcessorAnalog.h @@ -159,9 +159,9 @@ /** * @brief Processor analog base class that inherits from AnalogVoltageBase * - * This class provides processor-specific analog functionality on top of - * the generic AnalogVoltageBase class. It handles processor ADC configuration - * and maintains the data pin information for analog readings. + * This class provides processor-specific analog functionality on top of the + * generic AnalogVoltageBase class. It handles processor ADC configuration and + * processor-based analog voltage reads for requested channels. */ class ProcessorAnalogBase : public AnalogVoltageBase { public: @@ -235,7 +235,6 @@ class ProcessorAnalogBase : public AnalogVoltageBase { * @return The analog resolution in volts per LSB */ float calculateAnalogResolutionVolts(void) override; - }; /* clang-format off */ From 618e7e5e25170eb751d55a76a6c8591d96344e6f Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Thu, 26 Feb 2026 18:20:31 -0500 Subject: [PATCH 359/533] First cut via AI. Does not work. Signed-off-by: Sara Damiano --- README.md | 6 +- continuous_integration/dependencies.json | 16 +- docs/For-Developers/Developer-Setup.md | 3 +- examples/menu_a_la_carte/menu_a_la_carte.ino | 24 ++ library.json | 12 +- library.properties | 2 +- src/ModSensorDebugConfig.h | 1 + src/sensors/TEConnectivityMS5837.cpp | 109 ++++++ src/sensors/TEConnectivityMS5837.h | 345 +++++++++++++++++++ 9 files changed, 512 insertions(+), 6 deletions(-) create mode 100644 src/sensors/TEConnectivityMS5837.cpp create mode 100644 src/sensors/TEConnectivityMS5837.h diff --git a/README.md b/README.md index 81f0371f2..45466d0a3 100644 --- a/README.md +++ b/README.md @@ -45,6 +45,7 @@ For some generalized information about attaching sensors to an Arduino style boa - [Processor Metrics: battery voltage, free RAM, sample count](https://envirodiy.github.io/ModularSensors/group__sensor__processor.html) - [Maxim DS3231: real time clock](https://envirodiy.github.io/ModularSensors/group__sensor__ds3231.html) +- [Alphasense IRC-A1: CO2 and temperature, via TI ADS1115](https://envirodiy.github.io/ModularSensors/group__sensor__alphasense__co2.html) - [Analog Electrical Conductivity: conductivity](https://envirodiy.github.io/ModularSensors/group__sensor__analog__cond.html) - [ANB Sensors pH Sensor: pH](https://envirodiy.github.io/ModularSensors/group__sensor__anb__ph.html) - [AOSong AM2315: humidity & temperature](https://envirodiy.github.io/ModularSensors/group__sensor__am2315.html) @@ -77,16 +78,19 @@ For some generalized information about attaching sensors to an Arduino style boa - [MaxBotix MaxSonar: water level](https://envirodiy.github.io/ModularSensors/group__sensor__maxbotix.html) - [Maxim DS18: temperature](https://envirodiy.github.io/ModularSensors/group__sensor__ds18.html) - [Measurement Specialties MS5803: pressure and temperature](https://envirodiy.github.io/ModularSensors/group__sensor__ms5803.html) +- [TE Connectivity MS5837: pressure and temperature (deployed as Blue Robotics Bar02/Bar30)](https://envirodiy.github.io/ModularSensors/group__sensor__ms5837.html) - Meter Environmental Soil Moisture Probes: soil Ea and volumetric water content - [Meter ECH2O 5TM](https://envirodiy.github.io/ModularSensors/group__sensor__fivetm.html) - [Meter Teros 11](https://envirodiy.github.io/ModularSensors/group__sensor__teros11.html) - [Meter Environmental Hydros 21: conductivity, temperature & depth](https://envirodiy.github.io/ModularSensors/group__sensor__hydros21.html) - [Northern Widget Tally Event Counter: number of events](https://envirodiy.github.io/ModularSensors/group__sensor__tally.html) - [PaleoTerra Redox Sensor: redox potential](https://envirodiy.github.io/ModularSensors/group__sensor__pt__redox.html) +- [Processor Analog Voltage: external voltage using built-in ADC](https://envirodiy.github.io/ModularSensors/group__sensor__processor__analog.html) - [Sensirion SHT40: humidity & temperature](https://envirodiy.github.io/ModularSensors/group__sensor__sht4x.html) - [TI ADS1115: external voltage with support for divided current](https://envirodiy.github.io/ModularSensors/group__sensor__ads1x15.html) - [TI INA219: current, voltage, and power draw](https://envirodiy.github.io/ModularSensors/group__sensor__ina219.html) - [Turner Cyclops-7F: various parameters](https://envirodiy.github.io/ModularSensors/group__sensor__cyclops.html) +- [Turner Turbidity Plus: turbidity, via TI ADS1115](https://envirodiy.github.io/ModularSensors/group__sensor__turbidity__plus.html) - [Vega Puls 21: radar distance](https://envirodiy.github.io/ModularSensors/group__sensor__vega__puls21.html) - [Yosemitech: water quality sensors](https://envirodiy.github.io/ModularSensors/group__yosemitech__group.html) - [Y502-A or Y504-A: Optical DO and Temperature](https://envirodiy.github.io/ModularSensors/group__sensor__y504.html) @@ -152,7 +156,7 @@ Feel free to open issues about any bugs you find or any sensors you would like t If you would like to directly help with the coding development of the library, there are some [tips and instructions here](https://envirodiy.github.io/ModularSensors/page_developer_setup.html) on how to set up PlatformIO so you can fork the library and test programs while in the library repo. Please *take time to familiarize yourself with the [terminology, classes and data structures](https://envirodiy.github.io/ModularSensors/page_library_terminology.html) this library uses*. -This library is built to fully take advantage of Objecting Oriented Programing (OOP) approaches and is larger and more complicated than many Arduino libraries. +This library is built to fully take advantage of Objecting Oriented Programming (OOP) approaches and is larger and more complicated than many Arduino libraries. There is doxygen-created documentation on our [github pages](https://envirodiy.github.io/ModularSensors/index.html) and an *enormous* number of comments and debugging printouts in the code itself to help you get going. ## License diff --git a/continuous_integration/dependencies.json b/continuous_integration/dependencies.json index b3dd52478..7b4e5403d 100644 --- a/continuous_integration/dependencies.json +++ b/continuous_integration/dependencies.json @@ -1,5 +1,5 @@ { - "action_cache_version": 46, + "action_cache_version": 47, "dependencies": [ { "name": "EnviroDIY_DS3231", @@ -162,7 +162,7 @@ "owner": "adafruit", "library id": "19", "url": "https://github.com/adafruit/DHT-sensor-library", - "version": "~1.4.6", + "version": "~1.4.7", "note": "AOSong DHT Sensor Library by Adafruit", "authors": [ "Adafruit" @@ -277,6 +277,18 @@ "Sara Damiano" ] }, + { + "name": "BlueRobotics MS5837 Library", + "owner": "bluerobotics", + "url": "https://github.com/bluerobotics/BlueRobotics_MS5837_Library", + "version": "https://github.com/bluerobotics/BlueRobotics_MS5837_Library", + "version_note": "~0.1.2", + "note": "Library for TE Connectivity MS5837 pressure sensor, commonly deployed in Blue Robotics Bar02/Bar30 sensors", + "authors": [ + "Blue Robotics" + ], + "frameworks": "arduino" + }, { "name": "Tally_Library_I2C", "version": "https://github.com/EnviroDIY/Tally_Library.git#Dev_I2C", diff --git a/docs/For-Developers/Developer-Setup.md b/docs/For-Developers/Developer-Setup.md index fe2bdd2e3..cdd0425fe 100644 --- a/docs/For-Developers/Developer-Setup.md +++ b/docs/For-Developers/Developer-Setup.md @@ -133,7 +133,7 @@ lib_deps = adafruit/Adafruit AM2315@^2.2.3 adafruit/Adafruit BME280 Library@^2.3.0 MartinL1/BMP388_DEV@^1.0.11 - adafruit/DHT sensor library@^1.4.6 + adafruit/DHT sensor library@^1.4.7 adafruit/Adafruit INA219@^1.2.3 adafruit/Adafruit MPL115A2@^2.0.2 adafruit/Adafruit SHT4x Library@^1.0.5 @@ -150,6 +150,7 @@ lib_deps = envirodiy/GeoluxCamera@^0.1.3 robtillaart/fast_math@^0.2.4 envirodiy/ANBSensorsModbus@^0.4.2 + BlueRobotics MS5837 Library=https://github.com/bluerobotics/BlueRobotics_MS5837_Library StreamDebugger=https://github.com/EnviroDIY/StreamDebugger.git NeoSWSerial=https://github.com/SRGDamia1/NeoSWSerial.git AltSoftSerial=https://github.com/PaulStoffregen/AltSoftSerial.git diff --git a/examples/menu_a_la_carte/menu_a_la_carte.ino b/examples/menu_a_la_carte/menu_a_la_carte.ino index d55c0605e..822d8e5df 100644 --- a/examples/menu_a_la_carte/menu_a_la_carte.ino +++ b/examples/menu_a_la_carte/menu_a_la_carte.ino @@ -2077,6 +2077,30 @@ Variable* ms5803Temp = #endif +#if defined(BUILD_SENSOR_TE_CONNECTIVITY_MS5837) +// ========================================================================== +// TE Connectivity MS5837 Pressure Sensor (deployed in Blue Robotics Bar02/Bar30) +// ========================================================================== +/** Start [te_connectivity_ms5837] */ +#include + +// NOTE: Use -1 for any pins that don't apply or aren't being used. +const int8_t MS5837Power = sensorPowerPin; // Power pin +const uint8_t MS5837model = MS5837_30BA; // Model: MS5837_02BA for 2bar range or MS5837_30BA for 30bar range +const uint8_t MS5837ReadingsToAvg = 1; + +// Create a TE Connectivity MS5837 pressure and temperature sensor object +TEConnectivityMS5837 ms5837(MS5837Power, MS5837model, MS5837ReadingsToAvg); + +// Create pressure and temperature variable pointers for the MS5837 +Variable* ms5837Press = + new TEConnectivityMS5837_Pressure(&ms5837, "12345678-abcd-1234-ef00-1234567890ab"); +Variable* ms5837Temp = + new TEConnectivityMS5837_Temp(&ms5837, "12345678-abcd-1234-ef00-1234567890ab"); +/** End [te_connectivity_ms5837] */ +#endif + + #if defined(BUILD_SENSOR_DECAGON_5TM) // ========================================================================== // Meter ECH2O Soil Moisture Sensor diff --git a/library.json b/library.json index da5cc2ff7..f03db5cde 100644 --- a/library.json +++ b/library.json @@ -192,7 +192,7 @@ "owner": "adafruit", "library id": "19", "url": "https://github.com/adafruit/DHT-sensor-library", - "version": "~1.4.6", + "version": "~1.4.7", "note": "AOSong DHT Sensor Library by Adafruit", "authors": ["Adafruit"], "frameworks": "arduino" @@ -286,6 +286,16 @@ "note": "General interface to MS5803-series pressure transducers", "authors": ["Bobby Schulz", "Andrew Wickert", "Chad Sandell", "Sara Damiano"] }, + { + "name": "BlueRobotics MS5837 Library", + "owner": "bluerobotics", + "url": "https://github.com/bluerobotics/BlueRobotics_MS5837_Library", + "version": "https://github.com/bluerobotics/BlueRobotics_MS5837_Library", + "version_note": "~0.1.2", + "note": "Library for TE Connectivity MS5837 pressure sensor, commonly deployed in Blue Robotics Bar02/Bar30 sensors", + "authors": ["Blue Robotics"], + "frameworks": "arduino" + }, { "name": "Tally_Library_I2C", "version": "https://github.com/EnviroDIY/Tally_Library.git#Dev_I2C", diff --git a/library.properties b/library.properties index fd7658c57..a9d94004c 100644 --- a/library.properties +++ b/library.properties @@ -8,4 +8,4 @@ category=Sensors url=https://github.com/EnviroDIY/ModularSensors architectures=avr,samd includes=LoggerBase.h -depends=EnviroDIY_DS3231, RTCZero, EnableInterrupt, SdFat, TinyGSM, PubSubClient, Adafruit BusIO, Adafruit Unified Sensor, Adafruit ADS1X15, Adafruit AM2315, Adafruit BME280 Library, DHT sensor library, Adafruit INA219, Adafruit MPL115A2, Adafruit SHT4x Library, OneWire, DallasTemperature, SDI-12, SensorModbusMaster, KellerModbus, YosemitechModbus, SparkFun Qwiic RTC RV8803 Arduino Library, StreamDebugger +depends=EnviroDIY_DS3231, RTCZero, EnableInterrupt, SdFat, TinyGSM, PubSubClient, Adafruit BusIO, Adafruit Unified Sensor, Adafruit ADS1X15, Adafruit AM2315, Adafruit BME280 Library, DHT sensor library, Adafruit INA219, Adafruit MPL115A2, Adafruit SHT4x Library, OneWire, DallasTemperature, SDI-12, SensorModbusMaster, KellerModbus, YosemitechModbus, SparkFun Qwiic RTC RV8803 Arduino Library, StreamDebugger, BlueRobotics MS5837 Library diff --git a/src/ModSensorDebugConfig.h b/src/ModSensorDebugConfig.h index 5e8bb477b..aebb5a0a9 100644 --- a/src/ModSensorDebugConfig.h +++ b/src/ModSensorDebugConfig.h @@ -125,6 +125,7 @@ // #define MS_MAXIMDS18_DEBUG // #define MS_MAXIMDS3231_DEBUG // #define MS_MEASPECMS5803_DEBUG +// #define MS_TECONNECTIVITYMS5837_DEBUG // #define MS_PALEOTERRAREDOX_DEBUG // #define MS_PROCESSORSTATS_DEBUG // #define MS_RAINCOUNTERI2C_DEBUG diff --git a/src/sensors/TEConnectivityMS5837.cpp b/src/sensors/TEConnectivityMS5837.cpp new file mode 100644 index 000000000..1ab20df67 --- /dev/null +++ b/src/sensors/TEConnectivityMS5837.cpp @@ -0,0 +1,109 @@ +/** + * @file TEConnectivityMS5837.cpp + * @copyright Stroud Water Research Center + * Part of the EnviroDIY ModularSensors library for Arduino. + * This library is published under the BSD-3 license. + * @author Sara Geleskie Damiano + * + * @brief Implements the TEConnectivityMS5837 class. + */ + +#include "TEConnectivityMS5837.h" + + +// The constructor - because this is I2C, only need the power pin +TEConnectivityMS5837::TEConnectivityMS5837(int8_t powerPin, uint8_t model, + uint8_t measurementsToAverage) + : Sensor("TEConnectivityMS5837", MS5837_NUM_VARIABLES, + MS5837_WARM_UP_TIME_MS, MS5837_STABILIZATION_TIME_MS, + MS5837_MEASUREMENT_TIME_MS, powerPin, -1, measurementsToAverage, + MS5837_INC_CALC_VARIABLES), + _model(model) {} + +// Destructor +TEConnectivityMS5837::~TEConnectivityMS5837() {} + + +String TEConnectivityMS5837::getSensorLocation(void) { + String modelStr = F("I2C_0x76_"); + switch (_model) { + case MS5837_02BA: modelStr += F("02BA"); break; + case MS5837_30BA: modelStr += F("30BA"); break; + default: modelStr += F("Unknown"); break; + } + return modelStr; +} + + +bool TEConnectivityMS5837::setup(void) { + bool retVal = + Sensor::setup(); // this will set pin modes and the setup status bit + + // This sensor needs power for setup! + delay(10); + bool wasOn = checkPowerOn(); + if (!wasOn) { powerUp(); } + waitForWarmUp(); + + // Initialize the sensor + MS5837_internal.init(); + + // Set the sensor model + if (!MS5837_internal.setModel(_model)) { + MS_DBG(getSensorNameAndLocation(), F("Failed to set sensor model")); + retVal = false; + } + + // Turn the power back off if it had been turned on + if (!wasOn) { powerDown(); } + + return retVal; +} + + +bool TEConnectivityMS5837::addSingleMeasurementResult(void) { + // Immediately quit if the measurement was not successfully started + if (!getStatusBit(MEASUREMENT_SUCCESSFUL)) { + return bumpMeasurementAttemptCount(false); + } + + bool success = false; + float temp = -9999; + float press = -9999; + + MS_DBG(getSensorNameAndLocation(), F("is reporting:")); + + // Read values from the sensor + MS5837_internal.read(); + + // Get temperature in Celsius + temp = MS5837_internal.temperature(); + + // Get pressure in millibar + press = MS5837_internal.pressure(); + + MS_DBG(F(" Temperature:"), temp); + MS_DBG(F(" Pressure:"), press); + + // Validate the readings + float maxPressure = 0; + switch (_model) { + case MS5837_02BA: maxPressure = 2000.0; break; // 2 bar = 2000 mbar + case MS5837_30BA: maxPressure = 30000.0; break; // 30 bar = 30000 mbar + default: maxPressure = 30000.0; break; + } + + if (!isnan(temp) && !isnan(press) && temp >= -40.0 && temp <= 85.0 && + press > 0.0 && press <= maxPressure) { + // Temperature Range is -40°C to +85°C + // Pressure returns 0 when disconnected, which is highly unlikely to be + // a real value. + // Pressure range depends on the model + verifyAndAddMeasurementResult(MS5837_TEMP_VAR_NUM, temp); + verifyAndAddMeasurementResult(MS5837_PRESSURE_VAR_NUM, press); + success = true; + } + + // Return success value when finished + return bumpMeasurementAttemptCount(success); +} diff --git a/src/sensors/TEConnectivityMS5837.h b/src/sensors/TEConnectivityMS5837.h new file mode 100644 index 000000000..dae5d5afc --- /dev/null +++ b/src/sensors/TEConnectivityMS5837.h @@ -0,0 +1,345 @@ +/** + * @file TEConnectivityMS5837.h + * @copyright Stroud Water Research Center + * Part of the EnviroDIY ModularSensors library for Arduino. + * This library is published under the BSD-3 license. + * @author Sara Geleskie Damiano + * + * @brief Contains the TEConnectivityMS5837 sensor subclass and the variable + * subclasses TEConnectivityMS5837_Temp and TEConnectivityMS5837_Pressure. + * + * These are for the TE Connectivity MS5837 pressure sensor. This sensor is + * commonly deployed in Blue Robotics Bar02/Bar30 pressure sensors for + * underwater/high-pressure applications and is commonly used for depth + * measurement. Blue Robotics maintains the MS5837 Arduino library for + * communication with this sensor. + * + * This depends on the Blue Robotics MS5837 library at + * https://github.com/bluerobotics/BlueRobotics_MS5837_Library + */ +/* clang-format off */ +/** + * @defgroup sensor_ms5837 TE Connectivity MS5837 + * Classes for the TE Connectivity MS5837 digital pressure sensor. + * + * @ingroup the_sensors + * + * @tableofcontents + * @m_footernavigation + * + * @section sensor_ms5837_intro Introduction + * + * The TE Connectivity MS5837 is a miniature digital pressure sensor designed for + * underwater and high-pressure applications. It is commonly deployed in Blue Robotics + * Bar02/Bar30 pressure sensors and is frequently used for depth measurement. + * The MS5837 comes in several different pressure ranges, with 2 bar and 30 bar being + * the most common for underwater applications. The sensor communicates via I2C at + * address 0x76. These sensors should be attached to a 1.7-3.6V power source and the + * power supply to the sensor can be stopped between measurements. + * + * @warning The I2C address (0x76) is the same as some configurations of the + * Measurement Specialties MS5803, Bosch BME280, BMP388, and BMP390 sensors! + * If you are also using one of those sensors, make sure that the address for + * that sensor does not conflict with the address of this sensor. + * + * @note Neither secondary hardware nor software I2C is supported for the MS5837. + * Only the primary hardware I2C defined in the Arduino core can be used. + * + * The lower level communication between the mcu and the MS5837 is handled by the + * [Blue Robotics MS5837 library](https://github.com/bluerobotics/BlueRobotics_MS5837_Library). + * + * @section sensor_ms5837_datasheet Sensor Datasheet + * + * Documentation for the sensor can be found at: + * https://www.te.com/en/product-CAT-BLPS0017.html + * + * Blue Robotics deployable versions: + * https://bluerobotics.com/store/sensors-sonars-cameras/sensors/bar02-sensor-r1-rp/ + * https://bluerobotics.com/store/sensors-sonars-cameras/sensors/bar30-sensor-r1/ + * + * @section sensor_ms5837_ctor Sensor Constructor + * {{ @ref TEConnectivityMS5837::TEConnectivityMS5837 }} + * + * ___ + * @section sensor_ms5837_examples Example Code + * The TE Connectivity MS5837 is used in the @menulink{te_connectivity_ms5837} example. + * + * @menusnip{te_connectivity_ms5837} + */ +/* clang-format on */ + +// Header Guards +#ifndef SRC_SENSORS_TECONNECTIVITYMS5837_H_ +#define SRC_SENSORS_TECONNECTIVITYMS5837_H_ + +// Include the library config before anything else +#include "ModSensorConfig.h" + +// Include the debugging config +#include "ModSensorDebugConfig.h" + +// Define the print label[s] for the debugger +#ifdef MS_TECONNECTIVITYMS5837_DEBUG +#define MS_DEBUGGING_STD "TEConnectivityMS5837" +#endif + +// Include the debugger +#include "ModSensorDebugger.h" +// Undefine the debugger label[s] +#undef MS_DEBUGGING_STD + +// Include other in-library and external dependencies +#include "VariableBase.h" +#include "SensorBase.h" +#include + +/** @ingroup sensor_ms5837 */ +/**@{*/ + +/** + * @anchor sensor_ms5837_var_counts + * @name Sensor Variable Counts + * The number of variables that can be returned by the MS5837 + */ +/**@{*/ +/// @brief Sensor::_numReturnedValues; the MS5837 can report 2 values. +#define MS5837_NUM_VARIABLES 2 +/// @brief Sensor::_incCalcValues; we don't calculate any additional values. +#define MS5837_INC_CALC_VARIABLES 0 +/**@}*/ + +/** + * @anchor sensor_ms5837_timing + * @name Sensor Timing + * The sensor timing for a Blue Robotics MS5837 + */ +/**@{*/ +/// @brief Sensor::_warmUpTime_ms; the MS5837 warms up in 10ms. +#define MS5837_WARM_UP_TIME_MS 10 +/// @brief Sensor::_stabilizationTime_ms; the MS5837 is stable as soon as it +/// warms up (0ms stabilization). +#define MS5837_STABILIZATION_TIME_MS 0 +/** + * @brief Sensor::_measurementTime_ms; the MS5837 takes 20ms to complete a + * measurement. + * - Sensor takes about 0.5 / 1.1 / 2.1 / 4.1 / 8.22 ms to respond + * at oversampling ratios: 256 / 512 / 1024 / 2048 / 4096, respectively. + */ +#define MS5837_MEASUREMENT_TIME_MS 20 +/**@}*/ + +/** + * @anchor sensor_ms5837_temp + * @name Temperature + * The temperature variable from a TE Connectivity MS5837 + * - Range is -40°C to +85°C + * - Accuracy is ±2.0°C + * + * {{ @ref TEConnectivityMS5837_Temp::TEConnectivityMS5837_Temp }} + */ +/**@{*/ +/// @brief Decimals places in string representation; temperature should have 2 - +/// resolution is <0.01°C. +#define MS5837_TEMP_RESOLUTION 2 +/// @brief Sensor variable number; temperature is stored in sensorValues[0]. +#define MS5837_TEMP_VAR_NUM 0 +/// @brief Variable name in +/// [ODM2 controlled vocabulary](http://vocabulary.odm2.org/variablename/); +/// "temperature" +#define MS5837_TEMP_VAR_NAME "temperature" +/// @brief Variable unit name in +/// [ODM2 controlled vocabulary](http://vocabulary.odm2.org/units/); +/// "degreeCelsius" (°C) +#define MS5837_TEMP_UNIT_NAME "degreeCelsius" +/// @brief Default variable short code; "TEConnectivityMS5837Temp" +#define MS5837_TEMP_DEFAULT_CODE "TEConnectivityMS5837Temp" +/**@}*/ + +/** + * @anchor sensor_ms5837_pressure + * @name Pressure + * The pressure variable from a TE Connectivity MS5837 + * - Range depends on sensor model: + * - Bar02: 0 to 2 bar + * - Bar30: 0 to 30 bar + * - Accuracy: + * - Bar02: ±1.5mbar + * - Bar30: ±20mbar + * - Resolution is: (at oversampling ratios: 256 / 512 / 1024 / 2048 / + * 4096, respectively)) + * - Bar02: 0.13 / 0.084 / 0.054 / 0.036 / 0.024 mbar + * - Bar30: 1 / 0.6 / 0.4 / 0.3 / 0.2 mbar (where 1 mbar = 100 pascals) + * - @m_span{m-dim}@ref #MS5837_PRESSURE_RESOLUTION = 3@m_endspan + * + * {{ @ref TEConnectivityMS5837_Pressure::TEConnectivityMS5837_Pressure }} + */ +/**@{*/ +/// @brief Decimals places in string representation; pressure should have 3. +#define MS5837_PRESSURE_RESOLUTION 3 +/// @brief Sensor variable number; pressure is stored in sensorValues[1]. +#define MS5837_PRESSURE_VAR_NUM 1 +/// @brief Variable name in +/// [ODM2 controlled vocabulary](http://vocabulary.odm2.org/variablename/); +/// "barometricPressure" +#define MS5837_PRESSURE_VAR_NAME "barometricPressure" +/// @brief Variable unit name in +/// [ODM2 controlled vocabulary](http://vocabulary.odm2.org/units/); "millibar" +#define MS5837_PRESSURE_UNIT_NAME "millibar" +/// @brief Default variable short code; "TEConnectivityMS5837Pressure" +#define MS5837_PRESSURE_DEFAULT_CODE "TEConnectivityMS5837Pressure" +/**@}*/ + + +/* clang-format off */ +/** + * @brief The Sensor sub-class for the + * [TE Connectivity MS5837 sensor](@ref sensor_ms5837). + * + * @ingroup sensor_ms5837 + */ +/* clang-format on */ +class TEConnectivityMS5837 : public Sensor { + public: + /** + * @brief Construct a new TEConnectivityMS5837 object. + * + * @note Neither secondary hardware nor software I2C is supported for the + * MS5837. Only the primary hardware I2C defined in the Arduino core can be + * used. + * + * @param powerPin The pin on the mcu controlling power to the MS5837 + * Use -1 if it is continuously powered. + * - The MS5837 requires a 1.7 - 3.6V power source + * @param model The model of MS5837 sensor. Use MS5837::MS5837_02BA for + * 2 bar range sensors or MS5837::MS5837_30BA for 30 bar range sensors. + * Default is MS5837::MS5837_30BA. + * @param measurementsToAverage The number of measurements to take and + * average before giving a "final" result from the sensor; optional with a + * default value of 1. + */ + explicit TEConnectivityMS5837(int8_t powerPin, + uint8_t model = MS5837::MS5837_02BA, + uint8_t measurementsToAverage = 1); + /** + * @brief Destroy the TEConnectivityMS5837 object + */ + ~TEConnectivityMS5837(); + + /** + * @brief Do any one-time preparations needed before the sensor will be able + * to take readings. + * + * This sets the pin modes for #_powerPin and I2C, initializes the MS5837, + * and updates the #_sensorStatus. The MS5837 must be powered for setup. + * + * @return True if the setup was successful. + */ + bool setup(void) override; + + String getSensorLocation(void) override; + + bool addSingleMeasurementResult(void) override; + + private: + /** + * @brief Private internal reference to the MS5837 object. + */ + MS5837 MS5837_internal; + /** + * @brief The model of the MS5837. + */ + uint8_t _model; +}; + + +/* clang-format off */ +/** + * @brief The Variable sub-class used for the + * [temperature output](@ref sensor_ms5837_temp) from a + * [TE Connectivity MS5837 digital pressure sensor](@ref sensor_ms5837). + * + * @ingroup sensor_ms5837 + */ +/* clang-format on */ +class TEConnectivityMS5837_Temp : public Variable { + public: + /** + * @brief Construct a new TEConnectivityMS5837_Temp object. + * + * @param parentSense The parent TEConnectivityMS5837 providing the result + * values. + * @param uuid A universally unique identifier (UUID or GUID) for the + * variable; optional with the default value of an empty string. + * @param varCode A short code to help identify the variable in files; + * optional with a default value of "TEConnectivityMS5837Temp". + */ + explicit TEConnectivityMS5837_Temp( + TEConnectivityMS5837* parentSense, const char* uuid = "", + const char* varCode = MS5837_TEMP_DEFAULT_CODE) + : Variable(parentSense, (uint8_t)MS5837_TEMP_VAR_NUM, + (uint8_t)MS5837_TEMP_RESOLUTION, MS5837_TEMP_VAR_NAME, + MS5837_TEMP_UNIT_NAME, varCode, uuid) {} + /** + * @brief Construct a new TEConnectivityMS5837_Temp object. + * + * @note This must be tied with a parent TEConnectivityMS5837 before it can + * be used. + */ + TEConnectivityMS5837_Temp() + : Variable((uint8_t)MS5837_TEMP_VAR_NUM, + (uint8_t)MS5837_TEMP_RESOLUTION, MS5837_TEMP_VAR_NAME, + MS5837_TEMP_UNIT_NAME, MS5837_TEMP_DEFAULT_CODE) {} + /** + * @brief Destroy the TEConnectivityMS5837_Temp object - no action needed. + */ + ~TEConnectivityMS5837_Temp() {} +}; + + +/* clang-format off */ +/** + * @brief The Variable sub-class used for the + * [pressure output](@ref sensor_ms5837_pressure) from a + * [TE Connectivity MS5837 digital pressure sensor](@ref sensor_ms5837). + * + * @ingroup sensor_ms5837 + */ +/* clang-format on */ +class TEConnectivityMS5837_Pressure : public Variable { + public: + /** + * @brief Construct a new TEConnectivityMS5837_Pressure object. + * + * @param parentSense The parent TEConnectivityMS5837 providing the result + * values. + * @param uuid A universally unique identifier (UUID or GUID) for the + * variable; optional with the default value of an empty string. + * @param varCode A short code to help identify the variable in files; + * optional with a default value of "TEConnectivityMS5837Pressure". + */ + explicit TEConnectivityMS5837_Pressure( + TEConnectivityMS5837* parentSense, const char* uuid = "", + const char* varCode = MS5837_PRESSURE_DEFAULT_CODE) + : Variable(parentSense, (uint8_t)MS5837_PRESSURE_VAR_NUM, + (uint8_t)MS5837_PRESSURE_RESOLUTION, + MS5837_PRESSURE_VAR_NAME, MS5837_PRESSURE_UNIT_NAME, varCode, + uuid) {} + /** + * @brief Construct a new TEConnectivityMS5837_Pressure object. + * + * @note This must be tied with a parent TEConnectivityMS5837 before it can + * be used. + */ + TEConnectivityMS5837_Pressure() + : Variable((uint8_t)MS5837_PRESSURE_VAR_NUM, + (uint8_t)MS5837_PRESSURE_RESOLUTION, + MS5837_PRESSURE_VAR_NAME, MS5837_PRESSURE_UNIT_NAME, + MS5837_PRESSURE_DEFAULT_CODE) {} + /** + * @brief Destroy the TEConnectivityMS5837_Pressure object - no action + * needed. + */ + ~TEConnectivityMS5837_Pressure() {} +}; +/**@}*/ +#endif // SRC_SENSORS_TECONNECTIVITYMS5837_H_ From 4d031e37512bb2b420b9e8646154e48445dfab53 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Fri, 27 Feb 2026 11:47:53 -0500 Subject: [PATCH 360/533] Switch to Rob Tillaart's library which reduces footprint with 32-bit math and has error tracking Signed-off-by: Sara Damiano --- README.md | 4 +- continuous_integration/dependencies.json | 14 +- cspell.json | 1 + examples/menu_a_la_carte/menu_a_la_carte.ino | 28 ++- library.json | 14 +- library.properties | 2 +- src/ModSensorConfig.h | 23 +++ src/sensors/TEConnectivityMS5837.cpp | 105 +++++++--- src/sensors/TEConnectivityMS5837.h | 206 +++++++++++++++++-- 9 files changed, 337 insertions(+), 60 deletions(-) diff --git a/README.md b/README.md index 45466d0a3..2dafba915 100644 --- a/README.md +++ b/README.md @@ -77,7 +77,7 @@ For some generalized information about attaching sensors to an Arduino style boa - [Nanolevel](https://envirodiy.github.io/ModularSensors/group__sensor__nanolevel.html) - [MaxBotix MaxSonar: water level](https://envirodiy.github.io/ModularSensors/group__sensor__maxbotix.html) - [Maxim DS18: temperature](https://envirodiy.github.io/ModularSensors/group__sensor__ds18.html) -- [Measurement Specialties MS5803: pressure and temperature](https://envirodiy.github.io/ModularSensors/group__sensor__ms5803.html) +- [Measurement Specialties/TE Connectivity MS5803: pressure and temperature](https://envirodiy.github.io/ModularSensors/group__sensor__ms5803.html) - [TE Connectivity MS5837: pressure and temperature (deployed as Blue Robotics Bar02/Bar30)](https://envirodiy.github.io/ModularSensors/group__sensor__ms5837.html) - Meter Environmental Soil Moisture Probes: soil Ea and volumetric water content - [Meter ECH2O 5TM](https://envirodiy.github.io/ModularSensors/group__sensor__fivetm.html) @@ -156,7 +156,7 @@ Feel free to open issues about any bugs you find or any sensors you would like t If you would like to directly help with the coding development of the library, there are some [tips and instructions here](https://envirodiy.github.io/ModularSensors/page_developer_setup.html) on how to set up PlatformIO so you can fork the library and test programs while in the library repo. Please *take time to familiarize yourself with the [terminology, classes and data structures](https://envirodiy.github.io/ModularSensors/page_library_terminology.html) this library uses*. -This library is built to fully take advantage of Objecting Oriented Programming (OOP) approaches and is larger and more complicated than many Arduino libraries. +This library is built to fully take advantage of Object Oriented Programming (OOP) approaches and is larger and more complicated than many Arduino libraries. There is doxygen-created documentation on our [github pages](https://envirodiy.github.io/ModularSensors/index.html) and an *enormous* number of comments and debugging printouts in the code itself to help you get going. ## License diff --git a/continuous_integration/dependencies.json b/continuous_integration/dependencies.json index 7b4e5403d..cec68ebdf 100644 --- a/continuous_integration/dependencies.json +++ b/continuous_integration/dependencies.json @@ -278,14 +278,14 @@ ] }, { - "name": "BlueRobotics MS5837 Library", - "owner": "bluerobotics", - "url": "https://github.com/bluerobotics/BlueRobotics_MS5837_Library", - "version": "https://github.com/bluerobotics/BlueRobotics_MS5837_Library", - "version_note": "~0.1.2", - "note": "Library for TE Connectivity MS5837 pressure sensor, commonly deployed in Blue Robotics Bar02/Bar30 sensors", + "name": "MS5837", + "owner": "robtillaart", + "library id": "6205", + "url": "https://github.com/RobTillaart/MS5837", + "version": "~0.3.2", + "note": "Arduino library for the MS5837 temperature and pressure sensor and compatibles", "authors": [ - "Blue Robotics" + "Rob Tillaart" ], "frameworks": "arduino" }, diff --git a/cspell.json b/cspell.json index e72a8745d..caa57261c 100644 --- a/cspell.json +++ b/cspell.json @@ -256,6 +256,7 @@ "Testato", "ThingSpeak", "tiads1x15", + "Tillaart", "TINYGSM", "TINYUSB", "TurbHigh", diff --git a/examples/menu_a_la_carte/menu_a_la_carte.ino b/examples/menu_a_la_carte/menu_a_la_carte.ino index 822d8e5df..92abe8c06 100644 --- a/examples/menu_a_la_carte/menu_a_la_carte.ino +++ b/examples/menu_a_la_carte/menu_a_la_carte.ino @@ -2079,24 +2079,32 @@ Variable* ms5803Temp = #if defined(BUILD_SENSOR_TE_CONNECTIVITY_MS5837) // ========================================================================== -// TE Connectivity MS5837 Pressure Sensor (deployed in Blue Robotics Bar02/Bar30) +// TE Connectivity MS5837 Pressure Sensor (deployed in Blue Robotics +// Bar02/Bar30) // ========================================================================== /** Start [te_connectivity_ms5837] */ #include // NOTE: Use -1 for any pins that don't apply or aren't being used. const int8_t MS5837Power = sensorPowerPin; // Power pin -const uint8_t MS5837model = MS5837_30BA; // Model: MS5837_02BA for 2bar range or MS5837_30BA for 30bar range +const uint8_t MS5837model = + MS5837_TYPE_30; // Model: MS5837_TYPE_02 for 2bar range or + // MS5837_TYPE_30 for 30bar range const uint8_t MS5837ReadingsToAvg = 1; // Create a TE Connectivity MS5837 pressure and temperature sensor object TEConnectivityMS5837 ms5837(MS5837Power, MS5837model, MS5837ReadingsToAvg); -// Create pressure and temperature variable pointers for the MS5837 -Variable* ms5837Press = - new TEConnectivityMS5837_Pressure(&ms5837, "12345678-abcd-1234-ef00-1234567890ab"); -Variable* ms5837Temp = - new TEConnectivityMS5837_Temp(&ms5837, "12345678-abcd-1234-ef00-1234567890ab"); +// Create pressure, temperature, depth, and altitude variable pointers for the +// MS5837 +Variable* ms5837Press = new TEConnectivityMS5837_Pressure( + &ms5837, "12345678-abcd-1234-ef00-1234567890ab"); +Variable* ms5837Temp = new TEConnectivityMS5837_Temp( + &ms5837, "12345678-abcd-1234-ef00-1234567890ab"); +Variable* ms5837Depth = new TEConnectivityMS5837_Depth( + &ms5837, "12345678-abcd-1234-ef00-1234567890ac"); +Variable* ms5837Alt = new TEConnectivityMS5837_Altitude( + &ms5837, "12345678-abcd-1234-ef00-1234567890ad"); /** End [te_connectivity_ms5837] */ #endif @@ -3321,6 +3329,12 @@ Variable* variableList[] = { ms5803Temp, ms5803Press, #endif +#if defined(BUILD_SENSOR_TE_CONNECTIVITY_MS5837) + ms5837Temp, + ms5837Press, + ms5837Depth, + ms5837Alt, +#endif #if defined(BUILD_SENSOR_DECAGON_5TM) fivetmEa, fivetmVWC, diff --git a/library.json b/library.json index f03db5cde..a51ea34b7 100644 --- a/library.json +++ b/library.json @@ -287,13 +287,13 @@ "authors": ["Bobby Schulz", "Andrew Wickert", "Chad Sandell", "Sara Damiano"] }, { - "name": "BlueRobotics MS5837 Library", - "owner": "bluerobotics", - "url": "https://github.com/bluerobotics/BlueRobotics_MS5837_Library", - "version": "https://github.com/bluerobotics/BlueRobotics_MS5837_Library", - "version_note": "~0.1.2", - "note": "Library for TE Connectivity MS5837 pressure sensor, commonly deployed in Blue Robotics Bar02/Bar30 sensors", - "authors": ["Blue Robotics"], + "name": "MS5837", + "owner": "robtillaart", + "library id": "6205", + "url": "https://github.com/RobTillaart/MS5837", + "version": "~0.3.2", + "note": "Arduino library for the MS5837 temperature and pressure sensor and compatibles", + "authors": ["Rob Tillaart"], "frameworks": "arduino" }, { diff --git a/library.properties b/library.properties index a9d94004c..2df531b72 100644 --- a/library.properties +++ b/library.properties @@ -8,4 +8,4 @@ category=Sensors url=https://github.com/EnviroDIY/ModularSensors architectures=avr,samd includes=LoggerBase.h -depends=EnviroDIY_DS3231, RTCZero, EnableInterrupt, SdFat, TinyGSM, PubSubClient, Adafruit BusIO, Adafruit Unified Sensor, Adafruit ADS1X15, Adafruit AM2315, Adafruit BME280 Library, DHT sensor library, Adafruit INA219, Adafruit MPL115A2, Adafruit SHT4x Library, OneWire, DallasTemperature, SDI-12, SensorModbusMaster, KellerModbus, YosemitechModbus, SparkFun Qwiic RTC RV8803 Arduino Library, StreamDebugger, BlueRobotics MS5837 Library +depends=EnviroDIY_DS3231, RTCZero, EnableInterrupt, SdFat, TinyGSM, PubSubClient, Adafruit BusIO, Adafruit Unified Sensor, Adafruit ADS1X15, Adafruit AM2315, Adafruit BME280 Library, DHT sensor library, Adafruit INA219, Adafruit MPL115A2, Adafruit SHT4x Library, OneWire, DallasTemperature, SDI-12, SensorModbusMaster, KellerModbus, YosemitechModbus, SparkFun Qwiic RTC RV8803 Arduino Library, StreamDebugger, MS5837 diff --git a/src/ModSensorConfig.h b/src/ModSensorConfig.h index f87d9c7cf..129dc4493 100644 --- a/src/ModSensorConfig.h +++ b/src/ModSensorConfig.h @@ -197,6 +197,27 @@ */ #define MS_PROCESSOR_ANALOG_MAX_CHANNEL 100 #endif // MS_PROCESSOR_ANALOG_MAX_CHANNEL + +//============================================================== +// Environmental sensor configuration +//============================================================== +#if !defined(MS_SEA_LEVEL_PRESSURE_HPA) || defined(DOXYGEN) +/** + * @brief The atmospheric pressure at sea level in hPa for barometric sensors. + * + * This value is used by environmental sensors (BME280, BMP3xx, MS5837) for + * calculating altitude and depth measurements. The default value is standard + * atmospheric pressure at sea level (1013.25 hPa). Adjust this value based on + * local atmospheric conditions for more accurate calculations. + * + * @note In library versions prior to 0.37.0, this variable was named + * SEALEVELPRESSURE_HPA. and was defined in the header files for the BME280 and + * BMP3xx sensors. + */ +#define MS_SEA_LEVEL_PRESSURE_HPA 1013.25f +#endif +//============================================================== + #if !defined(MS_PROCESSOR_ADC_REFERENCE_MODE) || defined(DOXYGEN) #if defined(ARDUINO_ARCH_AVR) || defined(DOXYGEN) /** @@ -390,5 +411,7 @@ // #define MS_S3PRESIGNED_PREVENT_REUSE //============================================================== +// cSpell:words SEALEVELPRESSURE + #endif // SRC_MODSENSORCONFIG_H_ diff --git a/src/sensors/TEConnectivityMS5837.cpp b/src/sensors/TEConnectivityMS5837.cpp index 1ab20df67..c73a70f93 100644 --- a/src/sensors/TEConnectivityMS5837.cpp +++ b/src/sensors/TEConnectivityMS5837.cpp @@ -13,12 +13,16 @@ // The constructor - because this is I2C, only need the power pin TEConnectivityMS5837::TEConnectivityMS5837(int8_t powerPin, uint8_t model, - uint8_t measurementsToAverage) + uint8_t measurementsToAverage, + float fluidDensity, + float airPressure) : Sensor("TEConnectivityMS5837", MS5837_NUM_VARIABLES, MS5837_WARM_UP_TIME_MS, MS5837_STABILIZATION_TIME_MS, MS5837_MEASUREMENT_TIME_MS, powerPin, -1, measurementsToAverage, MS5837_INC_CALC_VARIABLES), - _model(model) {} + _model(model), + _fluidDensity(fluidDensity), + _airPressure(airPressure) {} // Destructor TEConnectivityMS5837::~TEConnectivityMS5837() {} @@ -27,8 +31,9 @@ TEConnectivityMS5837::~TEConnectivityMS5837() {} String TEConnectivityMS5837::getSensorLocation(void) { String modelStr = F("I2C_0x76_"); switch (_model) { - case MS5837_02BA: modelStr += F("02BA"); break; - case MS5837_30BA: modelStr += F("30BA"); break; + case MS5837_TYPE_02: modelStr += F("02BA"); break; + case MS5837_TYPE_30: modelStr += F("30BA"); break; + case MS5803_TYPE_01: modelStr += F("01BA"); break; default: modelStr += F("Unknown"); break; } return modelStr; @@ -36,7 +41,7 @@ String TEConnectivityMS5837::getSensorLocation(void) { bool TEConnectivityMS5837::setup(void) { - bool retVal = + bool success = Sensor::setup(); // this will set pin modes and the setup status bit // This sensor needs power for setup! @@ -45,19 +50,28 @@ bool TEConnectivityMS5837::setup(void) { if (!wasOn) { powerUp(); } waitForWarmUp(); - // Initialize the sensor - MS5837_internal.init(); + // Set the sensor model and initialize the sensor + success &= MS5837_internal.begin(_model); - // Set the sensor model - if (!MS5837_internal.setModel(_model)) { - MS_DBG(getSensorNameAndLocation(), F("Failed to set sensor model")); - retVal = false; + // Set the fluid density for depth calculations + MS5837_internal.setDensity(_fluidDensity); + + if (!success) { + MS_DBG(getSensorNameAndLocation(), F("Failed to initialize sensor")); + success = false; } // Turn the power back off if it had been turned on if (!wasOn) { powerDown(); } - return retVal; + if (!success) { + // Set the status error bit (bit 7) + setStatusBit(ERROR_OCCURRED); + // UN-set the set-up bit (bit 0) since setup failed! + clearStatusBit(SETUP_SUCCESSFUL); + } + + return success; } @@ -67,40 +81,83 @@ bool TEConnectivityMS5837::addSingleMeasurementResult(void) { return bumpMeasurementAttemptCount(false); } - bool success = false; - float temp = -9999; - float press = -9999; + // Validate configuration parameters + if (_fluidDensity <= 0.0 || _fluidDensity > 5.0) { + MS_DBG(F("Invalid fluid density:"), _fluidDensity, + F("g/cm³. Expected range: 0.0-5.0")); + return bumpMeasurementAttemptCount(false); + } + if (_airPressure < 500.0 || _airPressure > 1200.0) { + MS_DBG(F("Invalid air pressure:"), _airPressure, + F("mBar. Expected range: 500-1200")); + return bumpMeasurementAttemptCount(false); + } + + float temp = -9999; + float press = -9999; + float depth = -9999; + float alt = -9999; MS_DBG(getSensorNameAndLocation(), F("is reporting:")); - // Read values from the sensor - MS5837_internal.read(); + // Set fluid density for depth calculations + MS5837_internal.setDensity(_fluidDensity); + + // Read values from the sensor - returns 0 on success + bool success = MS5837_internal.read() == 0; + if (success) { + // Get temperature in Celsius + temp = MS5837_internal.getTemperature(); - // Get temperature in Celsius - temp = MS5837_internal.temperature(); + // Get pressure in millibar + press = MS5837_internal.getPressure(); - // Get pressure in millibar - press = MS5837_internal.pressure(); + // Calculate altitude in meters using configured air pressure + alt = MS5837_internal.getAltitude(_airPressure); + + // Calculate depth in meters + depth = MS5837_internal.getDepth(); + } else { + MS_DBG(F(" Read failed, error:"), MS5837_internal.getLastError()); + return bumpMeasurementAttemptCount(false); + } MS_DBG(F(" Temperature:"), temp); MS_DBG(F(" Pressure:"), press); + MS_DBG(F(" Depth:"), depth); + MS_DBG(F(" Altitude:"), alt); // Validate the readings float maxPressure = 0; switch (_model) { - case MS5837_02BA: maxPressure = 2000.0; break; // 2 bar = 2000 mbar - case MS5837_30BA: maxPressure = 30000.0; break; // 30 bar = 30000 mbar + case MS5803_TYPE_01: maxPressure = 1000.0; break; // 1 bar = 1000 mbar + case MS5837_TYPE_02: maxPressure = 2000.0; break; // 2 bar = 2000 mbar + case MS5837_TYPE_30: + maxPressure = 30000.0; + break; // 30 bar = 30000 mbar default: maxPressure = 30000.0; break; } if (!isnan(temp) && !isnan(press) && temp >= -40.0 && temp <= 85.0 && - press > 0.0 && press <= maxPressure) { + press > 0.0 && + press <= maxPressure * 1.05) { // allow 5% over max pressure // Temperature Range is -40°C to +85°C // Pressure returns 0 when disconnected, which is highly unlikely to be // a real value. // Pressure range depends on the model verifyAndAddMeasurementResult(MS5837_TEMP_VAR_NUM, temp); verifyAndAddMeasurementResult(MS5837_PRESSURE_VAR_NUM, press); + + // Store calculated values if they are valid + if (!isnan(depth) && depth >= -2000.0 && depth <= 2000.0) { + // Reasonable depth range from -2000m to +2000m + verifyAndAddMeasurementResult(MS5837_DEPTH_VAR_NUM, depth); + } + if (!isnan(alt) && alt >= -1000.0 && alt <= 10000.0) { + // Reasonable altitude range from -1000m to +10000m + verifyAndAddMeasurementResult(MS5837_ALTITUDE_VAR_NUM, alt); + } + success = true; } diff --git a/src/sensors/TEConnectivityMS5837.h b/src/sensors/TEConnectivityMS5837.h index dae5d5afc..8a056d77f 100644 --- a/src/sensors/TEConnectivityMS5837.h +++ b/src/sensors/TEConnectivityMS5837.h @@ -11,11 +11,11 @@ * These are for the TE Connectivity MS5837 pressure sensor. This sensor is * commonly deployed in Blue Robotics Bar02/Bar30 pressure sensors for * underwater/high-pressure applications and is commonly used for depth - * measurement. Blue Robotics maintains the MS5837 Arduino library for + * measurement. Rob Tillaart maintains the MS5837 Arduino library for * communication with this sensor. * - * This depends on the Blue Robotics MS5837 library at - * https://github.com/bluerobotics/BlueRobotics_MS5837_Library + * This depends on the Rob Tillaart MS5837 library at + * https://github.com/RobTillaart/MS5837 */ /* clang-format off */ /** @@ -46,7 +46,7 @@ * Only the primary hardware I2C defined in the Arduino core can be used. * * The lower level communication between the mcu and the MS5837 is handled by the - * [Blue Robotics MS5837 library](https://github.com/bluerobotics/BlueRobotics_MS5837_Library). + * [Rob Tillaart MS5837 library](https://github.com/RobTillaart/MS5837). * * @section sensor_ms5837_datasheet Sensor Datasheet * @@ -57,6 +57,20 @@ * https://bluerobotics.com/store/sensors-sonars-cameras/sensors/bar02-sensor-r1-rp/ * https://bluerobotics.com/store/sensors-sonars-cameras/sensors/bar30-sensor-r1/ * + * @section sensor_bme280_flags Build flags + * - ```-D MS5837_DEFAULT_FLUID_DENSITY=0.99802f``` + * - Changes the default fluid density used for depth calculations. The + * default value is for water at 20°C. For seawater, use approximately 1.025f. + * For other fluids, consult density tables and enter the density in grams per + * cm³. + * - ```-D MS_SEA_LEVEL_PRESSURE_HPA=1013.25f``` + * - Changes the default air pressure used for altitude and depth + * calculations. The default value is standard atmospheric pressure at sea level + * (1013.25 mBar). Adjust based on local atmospheric conditions or altitude for + * more accurate depth measurements. + * - The same sea level pressure flag is used for BMP3xx, BME280, and + * MS5837 sensors. + * * @section sensor_ms5837_ctor Sensor Constructor * {{ @ref TEConnectivityMS5837::TEConnectivityMS5837 }} * @@ -96,6 +110,17 @@ /** @ingroup sensor_ms5837 */ /**@{*/ +/** + * @anchor sensor_ms5837_config + * @name Sensor Configuration + * Build-time configuration for the MS5837 + */ +/**@{*/ +/// @brief Default fluid density for depth calculations (grams/cm³) +/// Water at 20°C = 0.99802 g/cm³ +#define MS5837_DEFAULT_FLUID_DENSITY 0.99802f +/**@}*/ + /** * @anchor sensor_ms5837_var_counts * @name Sensor Variable Counts @@ -104,8 +129,8 @@ /**@{*/ /// @brief Sensor::_numReturnedValues; the MS5837 can report 2 values. #define MS5837_NUM_VARIABLES 2 -/// @brief Sensor::_incCalcValues; we don't calculate any additional values. -#define MS5837_INC_CALC_VARIABLES 0 +/// @brief Sensor::_incCalcValues; we calculate depth and altitude values. +#define MS5837_INC_CALC_VARIABLES 2 /**@}*/ /** @@ -189,6 +214,57 @@ #define MS5837_PRESSURE_DEFAULT_CODE "TEConnectivityMS5837Pressure" /**@}*/ +/** + * @anchor sensor_ms5837_depth + * @name Depth + * The depth variable calculated from a TE Connectivity MS5837 + * - Calculated from pressure using the configured fluid density + * - Accuracy depends on pressure sensor accuracy and fluid density accuracy + * - Resolution is 1mm (0.001m) + * + * {{ @ref TEConnectivityMS5837_Depth::TEConnectivityMS5837_Depth }} + */ +/**@{*/ +/// @brief Decimals places in string representation; depth should have 3. +#define MS5837_DEPTH_RESOLUTION 3 +/// @brief Sensor variable number; depth is stored in sensorValues[2]. +#define MS5837_DEPTH_VAR_NUM 2 +/// @brief Variable name in +/// [ODM2 controlled vocabulary](http://vocabulary.odm2.org/variablename/); +/// "waterDepth" +#define MS5837_DEPTH_VAR_NAME "waterDepth" +/// @brief Variable unit name in +/// [ODM2 controlled vocabulary](http://vocabulary.odm2.org/units/); "meter" +#define MS5837_DEPTH_UNIT_NAME "meter" +/// @brief Default variable short code; "TEConnectivityMS5837Depth" +#define MS5837_DEPTH_DEFAULT_CODE "TEConnectivityMS5837Depth" +/**@}*/ + +/** + * @anchor sensor_ms5837_altitude + * @name Altitude + * The altitude variable calculated from a TE Connectivity MS5837 + * - Calculated from barometric pressure using standard atmosphere equations + * - Accuracy depends on pressure sensor accuracy and reference air pressure + * - Resolution is 0.01m + * + * {{ @ref TEConnectivityMS5837_Altitude::TEConnectivityMS5837_Altitude }} + */ +/**@{*/ +/// @brief Decimals places in string representation; altitude should have 2. +#define MS5837_ALTITUDE_RESOLUTION 2 +/// @brief Sensor variable number; altitude is stored in sensorValues[3]. +#define MS5837_ALTITUDE_VAR_NUM 3 +/// @brief Variable name in +/// [ODM2 controlled vocabulary](http://vocabulary.odm2.org/variablename/); +/// "altitude" +#define MS5837_ALTITUDE_VAR_NAME "altitude" +/// @brief Variable unit name in +/// [ODM2 controlled vocabulary](http://vocabulary.odm2.org/units/); "meter" +#define MS5837_ALTITUDE_UNIT_NAME "meter" +/// @brief Default variable short code; "TEConnectivityMS5837Altitude" +#define MS5837_ALTITUDE_DEFAULT_CODE "TEConnectivityMS5837Altitude" +/**@}*/ /* clang-format off */ /** @@ -210,16 +286,23 @@ class TEConnectivityMS5837 : public Sensor { * @param powerPin The pin on the mcu controlling power to the MS5837 * Use -1 if it is continuously powered. * - The MS5837 requires a 1.7 - 3.6V power source - * @param model The model of MS5837 sensor. Use MS5837::MS5837_02BA for - * 2 bar range sensors or MS5837::MS5837_30BA for 30 bar range sensors. - * Default is MS5837::MS5837_30BA. + * @param model The model of MS5837 sensor. Use MS5837_TYPE_02 for + * 2 bar range sensors or MS5837_TYPE_30 for 30 bar range sensors. + * Default is MS5837_TYPE_02. * @param measurementsToAverage The number of measurements to take and * average before giving a "final" result from the sensor; optional with a * default value of 1. + * @param fluidDensity The density of the fluid for depth calculations + * (grams/cm³); optional with default value from + * MS5837_DEFAULT_FLUID_DENSITY. + * @param airPressure The air pressure for altitude/depth calculations + * (mBar); optional with default value from MS_SEA_LEVEL_PRESSURE_HPA. */ - explicit TEConnectivityMS5837(int8_t powerPin, - uint8_t model = MS5837::MS5837_02BA, - uint8_t measurementsToAverage = 1); + explicit TEConnectivityMS5837( + int8_t powerPin, uint8_t model = MS5837_TYPE_02, + uint8_t measurementsToAverage = 1, + float fluidDensity = MS5837_DEFAULT_FLUID_DENSITY, + float airPressure = MS_SEA_LEVEL_PRESSURE_HPA); /** * @brief Destroy the TEConnectivityMS5837 object */ @@ -249,6 +332,14 @@ class TEConnectivityMS5837 : public Sensor { * @brief The model of the MS5837. */ uint8_t _model; + /** + * @brief The fluid density for depth calculations (grams/cm³). + */ + float _fluidDensity; + /** + * @brief The air pressure for altitude/depth calculations (mBar). + */ + float _airPressure; }; @@ -341,5 +432,96 @@ class TEConnectivityMS5837_Pressure : public Variable { */ ~TEConnectivityMS5837_Pressure() {} }; + + +/* clang-format off */ +/** + * @brief The Variable sub-class used for the + * [depth output](@ref sensor_ms5837_depth) calculated from a + * [TE Connectivity MS5837 digital pressure sensor](@ref sensor_ms5837). + * + * @ingroup sensor_ms5837 + */ +/* clang-format on */ +class TEConnectivityMS5837_Depth : public Variable { + public: + /** + * @brief Construct a new TEConnectivityMS5837_Depth object. + * + * @param parentSense The parent TEConnectivityMS5837 providing the result + * values. + * @param uuid A universally unique identifier (UUID or GUID) for the + * variable; optional with the default value of an empty string. + * @param varCode A short code to help identify the variable in files; + * optional with a default value of "TEConnectivityMS5837Depth". + */ + explicit TEConnectivityMS5837_Depth( + TEConnectivityMS5837* parentSense, const char* uuid = "", + const char* varCode = MS5837_DEPTH_DEFAULT_CODE) + : Variable(parentSense, (uint8_t)MS5837_DEPTH_VAR_NUM, + (uint8_t)MS5837_DEPTH_RESOLUTION, MS5837_DEPTH_VAR_NAME, + MS5837_DEPTH_UNIT_NAME, varCode, uuid) {} + /** + * @brief Construct a new TEConnectivityMS5837_Depth object. + * + * @note This must be tied with a parent TEConnectivityMS5837 before it can + * be used. + */ + TEConnectivityMS5837_Depth() + : Variable((uint8_t)MS5837_DEPTH_VAR_NUM, + (uint8_t)MS5837_DEPTH_RESOLUTION, MS5837_DEPTH_VAR_NAME, + MS5837_DEPTH_UNIT_NAME, MS5837_DEPTH_DEFAULT_CODE) {} + /** + * @brief Destroy the TEConnectivityMS5837_Depth object - no action needed. + */ + ~TEConnectivityMS5837_Depth() {} +}; + + +/* clang-format off */ +/** + * @brief The Variable sub-class used for the + * [altitude output](@ref sensor_ms5837_altitude) calculated from a + * [TE Connectivity MS5837 digital pressure sensor](@ref sensor_ms5837). + * + * @ingroup sensor_ms5837 + */ +/* clang-format on */ +class TEConnectivityMS5837_Altitude : public Variable { + public: + /** + * @brief Construct a new TEConnectivityMS5837_Altitude object. + * + * @param parentSense The parent TEConnectivityMS5837 providing the result + * values. + * @param uuid A universally unique identifier (UUID or GUID) for the + * variable; optional with the default value of an empty string. + * @param varCode A short code to help identify the variable in files; + * optional with a default value of "TEConnectivityMS5837Altitude". + */ + explicit TEConnectivityMS5837_Altitude( + TEConnectivityMS5837* parentSense, const char* uuid = "", + const char* varCode = MS5837_ALTITUDE_DEFAULT_CODE) + : Variable(parentSense, (uint8_t)MS5837_ALTITUDE_VAR_NUM, + (uint8_t)MS5837_ALTITUDE_RESOLUTION, + MS5837_ALTITUDE_VAR_NAME, MS5837_ALTITUDE_UNIT_NAME, varCode, + uuid) {} + /** + * @brief Construct a new TEConnectivityMS5837_Altitude object. + * + * @note This must be tied with a parent TEConnectivityMS5837 before it can + * be used. + */ + TEConnectivityMS5837_Altitude() + : Variable((uint8_t)MS5837_ALTITUDE_VAR_NUM, + (uint8_t)MS5837_ALTITUDE_RESOLUTION, + MS5837_ALTITUDE_VAR_NAME, MS5837_ALTITUDE_UNIT_NAME, + MS5837_ALTITUDE_DEFAULT_CODE) {} + /** + * @brief Destroy the TEConnectivityMS5837_Altitude object - no action + * needed. + */ + ~TEConnectivityMS5837_Altitude() {} +}; /**@}*/ #endif // SRC_SENSORS_TECONNECTIVITYMS5837_H_ From 95afec4a0de431ccc56f884e2fa5d857b9ca90b5 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Fri, 27 Feb 2026 11:50:18 -0500 Subject: [PATCH 361/533] Use single common define for air pressure; correct var name for altitude Signed-off-by: Sara Damiano --- src/sensors/BoschBME280.cpp | 4 ++-- src/sensors/BoschBME280.h | 24 ++++-------------------- src/sensors/BoschBMP3xx.cpp | 6 +++--- src/sensors/BoschBMP3xx.h | 24 +++++------------------- 4 files changed, 14 insertions(+), 44 deletions(-) diff --git a/src/sensors/BoschBME280.cpp b/src/sensors/BoschBME280.cpp index 1680b73da..366f37f87 100644 --- a/src/sensors/BoschBME280.cpp +++ b/src/sensors/BoschBME280.cpp @@ -135,7 +135,7 @@ bool BoschBME280::addSingleMeasurementResult(void) { if (isnan(humid)) humid = -9999; press = bme_internal.readPressure(); if (isnan(press)) press = -9999; - alt = bme_internal.readAltitude(SEALEVELPRESSURE_HPA); + alt = bme_internal.readAltitude(MS_SEA_LEVEL_PRESSURE_HPA); if (isnan(alt)) alt = -9999; MS_DBG(F(" Temperature:"), temp, F("°C")); @@ -161,4 +161,4 @@ bool BoschBME280::addSingleMeasurementResult(void) { return bumpMeasurementAttemptCount(success); } -// cSpell:ignore SEALEVELPRESSURE_HPA + diff --git a/src/sensors/BoschBME280.h b/src/sensors/BoschBME280.h index e3a45cfb1..1b7ead3cc 100644 --- a/src/sensors/BoschBME280.h +++ b/src/sensors/BoschBME280.h @@ -66,11 +66,10 @@ * [Datasheet](https://github.com/EnviroDIY/ModularSensors/wiki/Sensor-Datasheets/Bosch-BME280-Datasheet.pdf) * * @section sensor_bme280_flags Build flags - * - ```-D SEALEVELPRESSURE_HPA``` + * - ```-D MS_SEA_LEVEL_PRESSURE_HPA``` * - use to adjust the sea level pressure used to calculate altitude from measured barometric pressure * - if not defined, 1013.25 is used - * - The same sea level pressure flag is used for both the BMP3xx and the BME280. - * Whatever you select will be used for both sensors. + * - The same sea level pressure flag is used for BME280, BMP3xx, and MS5837 sensors. * * @section sensor_bme280_ctor Sensor Constructors * {{ @ref BoschBME280::BoschBME280(int8_t, uint8_t, uint8_t) }} @@ -125,19 +124,6 @@ #define BME280_INC_CALC_VARIABLES 1 /**@}*/ -/** - * @anchor sensor_bme280_config - * @name Configuration Defines - * Defines to set the calibration of the calculated base pressure used to - * calculate altitude by the BME280. - */ -/**@{*/ -#if !defined(SEALEVELPRESSURE_HPA) || defined(DOXYGEN) -/// The atmospheric pressure at sea level -#define SEALEVELPRESSURE_HPA (1013.25) -#endif -/**@}*/ - /** * @anchor sensor_bme280_timing * @name Sensor Timing @@ -260,8 +246,8 @@ #define BME280_ALTITUDE_VAR_NUM 3 /// @brief Variable name in /// [ODM2 controlled vocabulary](http://vocabulary.odm2.org/variablename/); -/// "heightAboveSeaFloor" -#define BME280_ALTITUDE_VAR_NAME "heightAboveSeaFloor" +/// "altitude" +#define BME280_ALTITUDE_VAR_NAME "altitude" /// @brief Variable unit name in /// [ODM2 controlled vocabulary](http://vocabulary.odm2.org/units/); "meter" #define BME280_ALTITUDE_UNIT_NAME "meter" @@ -523,5 +509,3 @@ class BoschBME280_Altitude : public Variable { }; /**@}*/ #endif // SRC_SENSORS_BOSCHBME280_H_ - -// cSpell:ignore SEALEVELPRESSURE_HPA diff --git a/src/sensors/BoschBMP3xx.cpp b/src/sensors/BoschBMP3xx.cpp index 2dd9d90c8..99cd4fa0d 100644 --- a/src/sensors/BoschBMP3xx.cpp +++ b/src/sensors/BoschBMP3xx.cpp @@ -177,8 +177,8 @@ bool BoschBMP3xx::setup(void) { bmp_internal.setIIRFilter(_filterCoeffEnum); MS_DBG(F("Setting sea level atmospheric pressure to"), - SEALEVELPRESSURE_HPA); - bmp_internal.setSeaLevelPressure(SEALEVELPRESSURE_HPA); + MS_SEA_LEVEL_PRESSURE_HPA); + bmp_internal.setSeaLevelPressure(MS_SEA_LEVEL_PRESSURE_HPA); // if we plan to operate in normal mode, set that up and begin sampling // at the specified intervals @@ -309,4 +309,4 @@ bool BoschBMP3xx::addSingleMeasurementResult(void) { return bumpMeasurementAttemptCount(success); } -// cSpell:ignore oversample SEALEVELPRESSURE +// cSpell:words oversample diff --git a/src/sensors/BoschBMP3xx.h b/src/sensors/BoschBMP3xx.h index b8c06fb17..c600e2d3f 100644 --- a/src/sensors/BoschBMP3xx.h +++ b/src/sensors/BoschBMP3xx.h @@ -111,11 +111,10 @@ * - [BMP388 Datasheet](https://github.com/EnviroDIY/ModularSensors/wiki/Sensor-Datasheets/Bosch-BMP388-Datasheet.pdf) * * @section sensor_bmp3xx_flags Build flags - * - ```-D SEALEVELPRESSURE_HPA``` + * - ```-D MS_SEA_LEVEL_PRESSURE_HPA``` * - use to adjust the sea level pressure used to calculate altitude from measured barometric pressure * - if not defined, 1013.25 is used - * - The same sea level pressure flag is used for both the BMP3xx and the BME280. - * Whatever you select will be used for both sensors. + * - The same sea level pressure flag is used for BMP3xx, BME280, and MS5837 sensors. * * @section sensor_bmp3xx_ctor Sensor Constructors * {{ @ref BoschBMP3xx::BoschBMP3xx(int8_t, Mode, Oversampling, Oversampling, IIRFilter, TimeStandby, uint8_t) }} @@ -169,19 +168,6 @@ #define BMP3XX_INC_CALC_VARIABLES 1 /**@}*/ -/** - * @anchor sensor_bme3xx_config - * @name Configuration Defines - * Defines to set the calibration of the calculated base pressure used to - * calculate altitude by the BME3xx. - */ -/**@{*/ -#if !defined(SEALEVELPRESSURE_HPA) || defined(DOXYGEN) -/// The atmospheric pressure at sea level -#define SEALEVELPRESSURE_HPA (1013.25) -#endif -/**@}*/ - /** * @anchor sensor_bmp3xx_timing * @name Sensor Timing @@ -320,8 +306,8 @@ #define BMP3XX_ALTITUDE_VAR_NUM 2 /// @brief Variable name in /// [ODM2 controlled vocabulary](http://vocabulary.odm2.org/variablename/); -/// "heightAboveSeaFloor" -#define BMP3XX_ALTITUDE_VAR_NAME "heightAboveSeaFloor" +/// "altitude" +#define BMP3XX_ALTITUDE_VAR_NAME "altitude" /// @brief Variable unit name in /// [ODM2 controlled vocabulary](http://vocabulary.odm2.org/units/); "meter" #define BMP3XX_ALTITUDE_UNIT_NAME "meter" @@ -697,4 +683,4 @@ class BoschBMP3xx_Altitude : public Variable { /**@}*/ #endif // SRC_SENSORS_BOSCHBMP3XX_H_ -// cSpell:ignore oversample SEALEVELPRESSURE osrs_p DDIO bmp3xxtimingTest +// cSpell:words oversample osrs_p DDIO bmp3xxtimingTest From b58a6cb6a0ab9067a83be927c771b0a9ae3350a0 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Fri, 27 Feb 2026 12:00:45 -0500 Subject: [PATCH 362/533] Add static assert checks of defined values Signed-off-by: Sara Damiano --- src/ModSensorConfig.h | 62 ++++++++++++++++++++++++++++++ src/sensors/TEConnectivityMS5837.h | 18 ++++++++- 2 files changed, 78 insertions(+), 2 deletions(-) diff --git a/src/ModSensorConfig.h b/src/ModSensorConfig.h index 129dc4493..4bb1f9793 100644 --- a/src/ModSensorConfig.h +++ b/src/ModSensorConfig.h @@ -58,6 +58,17 @@ */ #define MS_DEFAULT_ADS1X15_ADDRESS 0x48 #endif + +// Static assert to validate ADS1X15 I2C address is valid +static_assert( + MS_DEFAULT_ADS1X15_ADDRESS >= 0x08 && MS_DEFAULT_ADS1X15_ADDRESS <= 0x77, + "MS_DEFAULT_ADS1X15_ADDRESS must be a valid 7-bit I2C address (0x08-0x77)"); +static_assert(MS_DEFAULT_ADS1X15_ADDRESS == 0x48 || + MS_DEFAULT_ADS1X15_ADDRESS == 0x49 || + MS_DEFAULT_ADS1X15_ADDRESS == 0x4A || + MS_DEFAULT_ADS1X15_ADDRESS == 0x4B, + "MS_DEFAULT_ADS1X15_ADDRESS should be 0x48, 0x49, 0x4A, or 0x4B " + "for ADS1X15"); //============================================================== //============================================================== @@ -155,6 +166,11 @@ // GroPoint Profile GPLP-8 has 8 Moisture and 13 Temperature values #endif +// Static assert to the maximum number of variables is no more than the largest +// number of variables from any sensor. Anything more is a waste of memory. +static_assert(MAX_NUMBER_VARS > 0 && MAX_NUMBER_VARS <= 21, + "MAX_NUMBER_VARS must be between 1 and 21"); + //============================================================== // Analog voltage configuration //============================================================== @@ -179,6 +195,11 @@ #if !defined(MS_PROCESSOR_ADC_RESOLUTION) #error The processor ADC resolution must be defined! #endif // MS_PROCESSOR_ADC_RESOLUTION + +// Static assert to validate ADC resolution is reasonable +static_assert(MS_PROCESSOR_ADC_RESOLUTION >= 8 && + MS_PROCESSOR_ADC_RESOLUTION <= 16, + "MS_PROCESSOR_ADC_RESOLUTION must be between 8 and 16 bits"); #endif /// @brief The maximum possible value of the ADC - one less than the resolution @@ -198,6 +219,11 @@ #define MS_PROCESSOR_ANALOG_MAX_CHANNEL 100 #endif // MS_PROCESSOR_ANALOG_MAX_CHANNEL +// Static assert to validate analog channel maximum is reasonable +static_assert(MS_PROCESSOR_ANALOG_MAX_CHANNEL > 0 && + MS_PROCESSOR_ANALOG_MAX_CHANNEL <= 255, + "MS_PROCESSOR_ANALOG_MAX_CHANNEL must be between 1 and 255"); + //============================================================== // Environmental sensor configuration //============================================================== @@ -216,6 +242,12 @@ */ #define MS_SEA_LEVEL_PRESSURE_HPA 1013.25f #endif + +// Static assert to validate sea level pressure is reasonable +static_assert(MS_SEA_LEVEL_PRESSURE_HPA >= 800.0f && + MS_SEA_LEVEL_PRESSURE_HPA <= 1200.0f, + "MS_SEA_LEVEL_PRESSURE_HPA must be between 800 and 1200 hPa " + "(reasonable atmospheric pressure range)"); //============================================================== #if !defined(MS_PROCESSOR_ADC_REFERENCE_MODE) || defined(DOXYGEN) @@ -287,6 +319,9 @@ */ #define MAX_NUMBER_SENDERS 4 #endif +// Static asserts to validate AWS IoT publisher counts are reasonable +static_assert(MAX_NUMBER_SENDERS >= 0 && MAX_NUMBER_SENDERS <= 16, + "MAX_NUMBER_SENDERS must be between 0 and 16"); #ifndef MS_ALWAYS_FLUSH_PUBLISHERS /** @@ -315,6 +350,10 @@ #define MS_SEND_BUFFER_SIZE 1360 #endif +// Static assert to validate send buffer size is reasonable +static_assert(MS_SEND_BUFFER_SIZE >= 32 && MS_SEND_BUFFER_SIZE <= 2048, + "MS_SEND_BUFFER_SIZE must be between 32 and 2048 bytes"); + #ifndef TINY_GSM_RX_BUFFER /** * @brief The size of the buffer for incoming data. @@ -326,6 +365,11 @@ #define TINY_GSM_RX_BUFFER 64 #endif +// Static assert to validate GSM RX buffer size is reasonable +static_assert(TINY_GSM_RX_BUFFER >= 16 && TINY_GSM_RX_BUFFER <= 2048, + "TINY_GSM_RX_BUFFER must be between 16 and 2048 bytes"); + + #ifndef TINY_GSM_YIELD_MS /** * @brief The number of milliseconds to yield to the GSM module when using @@ -338,6 +382,10 @@ #define TINY_GSM_YIELD_MS 2 #endif +// Static assert to validate GSM yield time is reasonable +static_assert(TINY_GSM_YIELD_MS >= 0 && TINY_GSM_YIELD_MS <= 1000, + "TINY_GSM_YIELD_MS must be between 0 and 1000 milliseconds"); + #ifndef MS_MQTT_MAX_PACKET_SIZE /** * @brief Configure the size of the PubSubClient buffer for MQTT publishers. @@ -352,6 +400,11 @@ */ #define MS_MQTT_MAX_PACKET_SIZE 1536 #endif + +// Static assert to validate MQTT packet size is reasonable +static_assert(MS_MQTT_MAX_PACKET_SIZE >= 128 && MS_MQTT_MAX_PACKET_SIZE <= 4096, + "MS_MQTT_MAX_PACKET_SIZE must be between 128 and 4096 bytes"); + //============================================================== @@ -374,6 +427,15 @@ */ #define MS_AWS_IOT_PUBLISHER_PUB_COUNT 4 #endif + +// Static asserts to validate AWS IoT publisher counts are reasonable +static_assert( + MS_AWS_IOT_PUBLISHER_SUB_COUNT >= 0 && MS_AWS_IOT_PUBLISHER_SUB_COUNT <= 8, + "MS_AWS_IOT_PUBLISHER_SUB_COUNT must be between 0 and 8 (AWS limit)"); +static_assert(MS_AWS_IOT_PUBLISHER_PUB_COUNT >= 0 && + MS_AWS_IOT_PUBLISHER_PUB_COUNT <= 16, + "MS_AWS_IOT_PUBLISHER_PUB_COUNT must be between 0 and 16"); + #ifndef MS_AWS_IOT_MAX_CONNECTION_TIME /** * @brief The maximum time to wait for subscriptions after publishing data to diff --git a/src/sensors/TEConnectivityMS5837.h b/src/sensors/TEConnectivityMS5837.h index 8a056d77f..7dfb363ee 100644 --- a/src/sensors/TEConnectivityMS5837.h +++ b/src/sensors/TEConnectivityMS5837.h @@ -116,9 +116,23 @@ * Build-time configuration for the MS5837 */ /**@{*/ -/// @brief Default fluid density for depth calculations (grams/cm³) -/// Water at 20°C = 0.99802 g/cm³ +#if !defined(MS5837_DEFAULT_FLUID_DENSITY) || defined(DOXYGEN) +/** + * @brief Default fluid density for depth calculations (grams/cm³) + * + * Water at 20°C = 0.99802 g/cm³. For seawater, use approximately 1.025 g/cm³. + * For other fluids, consult density tables and enter the density in grams per + * cm³. This can be overridden at compile time with -D + * MS5837_DEFAULT_FLUID_DENSITY=value + */ #define MS5837_DEFAULT_FLUID_DENSITY 0.99802f +#endif + +// Static assert to validate fluid density is reasonable +static_assert(MS5837_DEFAULT_FLUID_DENSITY > 0.1f && + MS5837_DEFAULT_FLUID_DENSITY <= 5.0f, + "MS5837_DEFAULT_FLUID_DENSITY must be between 0.1 and 5.0 g/cm³ " + "(reasonable fluid density range)"); /**@}*/ /** From ece4c576176b51c146573ef0aa176e1175885241 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Fri, 27 Feb 2026 12:08:53 -0500 Subject: [PATCH 363/533] Fix assertion checks Signed-off-by: Sara Damiano --- src/ModSensorConfig.h | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/ModSensorConfig.h b/src/ModSensorConfig.h index 4bb1f9793..97e6471cf 100644 --- a/src/ModSensorConfig.h +++ b/src/ModSensorConfig.h @@ -60,9 +60,6 @@ #endif // Static assert to validate ADS1X15 I2C address is valid -static_assert( - MS_DEFAULT_ADS1X15_ADDRESS >= 0x08 && MS_DEFAULT_ADS1X15_ADDRESS <= 0x77, - "MS_DEFAULT_ADS1X15_ADDRESS must be a valid 7-bit I2C address (0x08-0x77)"); static_assert(MS_DEFAULT_ADS1X15_ADDRESS == 0x48 || MS_DEFAULT_ADS1X15_ADDRESS == 0x49 || MS_DEFAULT_ADS1X15_ADDRESS == 0x4A || @@ -195,12 +192,12 @@ static_assert(MAX_NUMBER_VARS > 0 && MAX_NUMBER_VARS <= 21, #if !defined(MS_PROCESSOR_ADC_RESOLUTION) #error The processor ADC resolution must be defined! #endif // MS_PROCESSOR_ADC_RESOLUTION +#endif // Static assert to validate ADC resolution is reasonable static_assert(MS_PROCESSOR_ADC_RESOLUTION >= 8 && MS_PROCESSOR_ADC_RESOLUTION <= 16, "MS_PROCESSOR_ADC_RESOLUTION must be between 8 and 16 bits"); -#endif /// @brief The maximum possible value of the ADC - one less than the resolution /// shifted up one bit. From 7e7860bffd2ca3cbe6c785cf81ccd5dd2708f53e Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Fri, 27 Feb 2026 12:09:39 -0500 Subject: [PATCH 364/533] Fix setting of density, typo Signed-off-by: Sara Damiano --- src/sensors/TEConnectivityMS5837.cpp | 21 ++++++++++++--------- src/sensors/TEConnectivityMS5837.h | 2 +- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/src/sensors/TEConnectivityMS5837.cpp b/src/sensors/TEConnectivityMS5837.cpp index c73a70f93..e20592843 100644 --- a/src/sensors/TEConnectivityMS5837.cpp +++ b/src/sensors/TEConnectivityMS5837.cpp @@ -53,18 +53,16 @@ bool TEConnectivityMS5837::setup(void) { // Set the sensor model and initialize the sensor success &= MS5837_internal.begin(_model); - // Set the fluid density for depth calculations - MS5837_internal.setDensity(_fluidDensity); - - if (!success) { - MS_DBG(getSensorNameAndLocation(), F("Failed to initialize sensor")); - success = false; + if (success) { + // Set the fluid density for depth calculations + MS5837_internal.setDensity(_fluidDensity); } // Turn the power back off if it had been turned on if (!wasOn) { powerDown(); } if (!success) { + MS_DBG(getSensorNameAndLocation(), F("Failed to initialize sensor")); // Set the status error bit (bit 7) setStatusBit(ERROR_OCCURRED); // UN-set the set-up bit (bit 0) since setup failed! @@ -100,9 +98,6 @@ bool TEConnectivityMS5837::addSingleMeasurementResult(void) { MS_DBG(getSensorNameAndLocation(), F("is reporting:")); - // Set fluid density for depth calculations - MS5837_internal.setDensity(_fluidDensity); - // Read values from the sensor - returns 0 on success bool success = MS5837_internal.read() == 0; if (success) { @@ -116,6 +111,10 @@ bool TEConnectivityMS5837::addSingleMeasurementResult(void) { alt = MS5837_internal.getAltitude(_airPressure); // Calculate depth in meters + // Note: fluidDensity is set in the MS5837_internal object at setup and + // used in the getDepth() function. The fluidDensity is only set in the + // constructor and cannot be changed, so there's no reason to re-pass + // the value to the internal object here. depth = MS5837_internal.getDepth(); } else { MS_DBG(F(" Read failed, error:"), MS5837_internal.getLastError()); @@ -152,10 +151,14 @@ bool TEConnectivityMS5837::addSingleMeasurementResult(void) { if (!isnan(depth) && depth >= -2000.0 && depth <= 2000.0) { // Reasonable depth range from -2000m to +2000m verifyAndAddMeasurementResult(MS5837_DEPTH_VAR_NUM, depth); + } else if (!isnan(depth)) { + MS_DBG(F(" Depth out of range:"), depth); } if (!isnan(alt) && alt >= -1000.0 && alt <= 10000.0) { // Reasonable altitude range from -1000m to +10000m verifyAndAddMeasurementResult(MS5837_ALTITUDE_VAR_NUM, alt); + } else if (!isnan(alt)) { + MS_DBG(F(" Altitude out of range:"), alt); } success = true; diff --git a/src/sensors/TEConnectivityMS5837.h b/src/sensors/TEConnectivityMS5837.h index 7dfb363ee..3ab6f2e83 100644 --- a/src/sensors/TEConnectivityMS5837.h +++ b/src/sensors/TEConnectivityMS5837.h @@ -57,7 +57,7 @@ * https://bluerobotics.com/store/sensors-sonars-cameras/sensors/bar02-sensor-r1-rp/ * https://bluerobotics.com/store/sensors-sonars-cameras/sensors/bar30-sensor-r1/ * - * @section sensor_bme280_flags Build flags + * @section sensor_ms5837_flags Build flags * - ```-D MS5837_DEFAULT_FLUID_DENSITY=0.99802f``` * - Changes the default fluid density used for depth calculations. The * default value is for water at 20°C. For seawater, use approximately 1.025f. From 313c8a5afff6a909247fcd61b0b745d33e83a5c1 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Fri, 27 Feb 2026 12:11:51 -0500 Subject: [PATCH 365/533] Update src/sensors/YosemitechParent.cpp Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --- src/sensors/YosemitechParent.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sensors/YosemitechParent.cpp b/src/sensors/YosemitechParent.cpp index 148914137..5491aa7bb 100644 --- a/src/sensors/YosemitechParent.cpp +++ b/src/sensors/YosemitechParent.cpp @@ -80,7 +80,7 @@ bool YosemitechParent::wake(void) { // Sensor::wake() checks if the power pin is on and sets the wake timestamp // and status bits. If it returns false, there's no reason to go on. if (!Sensor::wake()) return false; - // reset pin mode, incase the pins were tri-stated during sleep + // reset pin mode, in case the pins were tri-stated during sleep if (_RS485EnablePin >= 0) { pinMode(_RS485EnablePin, OUTPUT); } // Send the command to begin taking readings, trying up to 5 times From e1254e52c7be200f56c74cfef7dee09ba9122e5f Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Fri, 27 Feb 2026 12:12:46 -0500 Subject: [PATCH 366/533] Update setupGitFilters.bat Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --- setupGitFilters.bat | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/setupGitFilters.bat b/setupGitFilters.bat index 29a61b3e2..6ae3d9bf4 100644 --- a/setupGitFilters.bat +++ b/setupGitFilters.bat @@ -21,4 +21,5 @@ echo Filters configured: echo smudgePasswords - Manages credentials in .ino files echo disableDebug - Manages debug defines in ModSensorDebugConfig.h echo. -echo You may need to run "git checkout HEAD -- ." to apply filters to existing files. +echo To re-apply filters to existing files, first commit or stash local changes. +echo Then re-checkout only the affected files (for example, specific .ino files and ModSensorDebugConfig.h). From a6970e0e440c3200a85181ddcff9f3b093109950 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Fri, 27 Feb 2026 12:24:05 -0500 Subject: [PATCH 367/533] Change to bit shifting, add missing dtors, fix some typos and copy errors Signed-off-by: Sara Damiano --- src/ModSensorConfig.h | 3 +-- src/sensors/BoschBME280.cpp | 8 +++----- src/sensors/BoschBME280.h | 8 ++++++++ src/sensors/BoschBMP3xx.cpp | 14 +++++++------- src/sensors/BoschBMP3xx.h | 20 ++++++++++++-------- src/sensors/TEConnectivityMS5837.cpp | 4 ++-- 6 files changed, 33 insertions(+), 24 deletions(-) diff --git a/src/ModSensorConfig.h b/src/ModSensorConfig.h index 97e6471cf..3d8250226 100644 --- a/src/ModSensorConfig.h +++ b/src/ModSensorConfig.h @@ -316,10 +316,9 @@ static_assert(MS_SEA_LEVEL_PRESSURE_HPA >= 800.0f && */ #define MAX_NUMBER_SENDERS 4 #endif -// Static asserts to validate AWS IoT publisher counts are reasonable +// Static assert to validate MAX_NUMBER_SENDERS is reasonable static_assert(MAX_NUMBER_SENDERS >= 0 && MAX_NUMBER_SENDERS <= 16, "MAX_NUMBER_SENDERS must be between 0 and 16"); - #ifndef MS_ALWAYS_FLUSH_PUBLISHERS /** * @brief Set this to true to always force publishers to attempt to transmit diff --git a/src/sensors/BoschBME280.cpp b/src/sensors/BoschBME280.cpp index 366f37f87..51dbb8d53 100644 --- a/src/sensors/BoschBME280.cpp +++ b/src/sensors/BoschBME280.cpp @@ -16,7 +16,7 @@ BoschBME280::BoschBME280(TwoWire* theI2C, int8_t powerPin, uint8_t i2cAddressHex, uint8_t measurementsToAverage) : Sensor("BoschBME280", BME280_NUM_VARIABLES, BME280_WARM_UP_TIME_MS, BME280_STABILIZATION_TIME_MS, BME280_MEASUREMENT_TIME_MS, powerPin, - -1, measurementsToAverage), + -1, measurementsToAverage, BME280_INC_CALC_VARIABLES), _i2cAddressHex(i2cAddressHex), _i2c(theI2C) {} @@ -66,7 +66,7 @@ bool BoschBME280::setup(void) { } retVal &= success; - // Turn the power back off it it had been turned on + // Turn the power back off if it had been turned on if (!wasOn) { powerDown(); } return retVal; @@ -145,7 +145,7 @@ bool BoschBME280::addSingleMeasurementResult(void) { bool values_ok = temp != -9999 && humid != -9999 && press != -9999 && alt != -9999; - // Assume that if all three are 0, really a failed response + // Assume that if all four are 0, it's really a failed response // May also return a very negative temp when receiving a bad response if (!values_ok || (temp == 0 && press == 0 && humid == 0) || temp < -40) { MS_DBG(F("All values 0 or bad, assuming sensor non-response!")); @@ -160,5 +160,3 @@ bool BoschBME280::addSingleMeasurementResult(void) { // Return success value when finished return bumpMeasurementAttemptCount(success); } - - diff --git a/src/sensors/BoschBME280.h b/src/sensors/BoschBME280.h index 1b7ead3cc..2d2b4da8f 100644 --- a/src/sensors/BoschBME280.h +++ b/src/sensors/BoschBME280.h @@ -465,6 +465,10 @@ class BoschBME280_Pressure : public Variable { (uint8_t)BME280_PRESSURE_RESOLUTION, BME280_PRESSURE_VAR_NAME, BME280_PRESSURE_UNIT_NAME, BME280_PRESSURE_DEFAULT_CODE) {} + /** + * @brief Destroy the BoschBME280_Pressure object - no action needed. + */ + ~BoschBME280_Pressure() {} }; @@ -506,6 +510,10 @@ class BoschBME280_Altitude : public Variable { (uint8_t)BME280_ALTITUDE_RESOLUTION, BME280_ALTITUDE_VAR_NAME, BME280_ALTITUDE_UNIT_NAME, BME280_ALTITUDE_DEFAULT_CODE) {} + /** + * @brief Destroy the BoschBME280_Altitude object - no action needed. + */ + ~BoschBME280_Altitude() {} }; /**@}*/ #endif // SRC_SENSORS_BOSCHBME280_H_ diff --git a/src/sensors/BoschBMP3xx.cpp b/src/sensors/BoschBMP3xx.cpp index 99cd4fa0d..a6bcaa7ba 100644 --- a/src/sensors/BoschBMP3xx.cpp +++ b/src/sensors/BoschBMP3xx.cpp @@ -68,8 +68,8 @@ bool BoschBMP3xx::setup(void) { // The enum values for oversampling match with the values of osr_p and osr_t auto typ_measurementTime_us = static_cast( 234 + - 1 * (392 + (pow(2, static_cast(_pressureOversampleEnum))) * 2020) + - 1 * (163 + (pow(2, static_cast(_tempOversampleEnum))) * 2020)); + 1 * (392 + (1U << static_cast(_pressureOversampleEnum)) * 2020) + + 1 * (163 + (1U << static_cast(_tempOversampleEnum)) * 2020)); float max_measurementTime_us = static_cast(typ_measurementTime_us) * 1.18; // Set the sensor measurement time to the safety-factored max time @@ -111,7 +111,7 @@ bool BoschBMP3xx::setup(void) { // ADC NOTE: The ADC will return repeated values if the ADC's ODR (output // data rate) is set faster than the actual measurement time, given // oversampling. - float _timeStandby_ms = 5.0f * pow(2, static_cast(_standbyEnum)); + float _timeStandby_ms = 5.0f * (1U << static_cast(_standbyEnum)); // warn if an impossible sampling rate is selected if ((_timeStandby_ms < max_measurementTime_us / 1000) && _mode == NORMAL_MODE) { @@ -120,12 +120,12 @@ bool BoschBMP3xx::setup(void) { _measurementTime_ms, F("ms needed for temperature and pressure oversampling.")); // bump up the standby time to a possible value - while (5.0f * pow(2, static_cast(_standbyEnum)) < + while (5.0f * (1U << static_cast(_standbyEnum)) < max_measurementTime_us / 1000) { _standbyEnum = static_cast(static_cast(_standbyEnum) + 1); #if defined(MS_DEBUGGING_STD) - _timeStandby_ms = 5.0f * pow(2, static_cast(_standbyEnum)); + _timeStandby_ms = 5.0f * (1U << static_cast(_standbyEnum)); #endif MS_DBG(_standbyEnum, _timeStandby_ms, static_cast(max_measurementTime_us / 1000)); @@ -138,13 +138,13 @@ bool BoschBMP3xx::setup(void) { // the value of the enum is the power of the number of samples if (_filterCoeffEnum != IIR_FILTER_OFF && _mode == NORMAL_MODE) { MS_DBG(F("BMP388/390's IIR filter will only be fully initialized"), - pow(2, static_cast(_filterCoeffEnum)) * _timeStandby_ms, + (1U << static_cast(_filterCoeffEnum)) * _timeStandby_ms, F("ms after power on")); } if (_filterCoeffEnum != IIR_FILTER_OFF && _mode == FORCED_MODE) { MS_DBG( F("BMP388/390's IIR filter will only be fully initialized after"), - pow(2, static_cast(_filterCoeffEnum)), F("samples")); + (1U << static_cast(_filterCoeffEnum)), F("samples")); } if (_mode == FORCED_MODE) { diff --git a/src/sensors/BoschBMP3xx.h b/src/sensors/BoschBMP3xx.h index c600e2d3f..72447da9a 100644 --- a/src/sensors/BoschBMP3xx.h +++ b/src/sensors/BoschBMP3xx.h @@ -6,10 +6,9 @@ * @author Sara Geleskie Damiano * * @brief Contains the BoschBMP3xx sensor subclass and the variable subclasses - * BoschBMP3xx_Temp, BoschBMP3xx_Humidity, BoschBMP3xx_Pressure, and - * BoschBMP3xx_Altitude. + * BoschBMP3xx_Temp, BoschBMP3xx_Pressure, and BoschBMP3xx_Altitude. * - * These are used for the Bosch BMP3xx digital pressure and humidity sensor. + * These are used for the Bosch BMP3xx digital pressure and temperature sensor. * * This depends on the [MartinL1's BMP388 * library](https://github.com/MartinL1/BMP388_DEV). @@ -163,11 +162,8 @@ /**@{*/ /// @brief Sensor::_numReturnedValues; the BMP3xx can report 3 values. #define BMP3XX_NUM_VARIABLES 3 -/// @brief Sensor::_incCalcValues; altitude is calculated within the Adafruit -/// library. +/// @brief Sensor::_incCalcValues; altitude is calculated from pressure. #define BMP3XX_INC_CALC_VARIABLES 1 -/**@}*/ - /** * @anchor sensor_bmp3xx_timing * @name Sensor Timing @@ -241,7 +237,7 @@ */ /**@{*/ /// @brief Decimals places in string representation; temperature should have 5 - -/// resolution is 0.0.00015°C at the hightest oversampling. See table 7 in the +/// resolution is 0.00015°C at the hightest oversampling. See table 7 in the /// [sensor /// datasheet](https://github.com/EnviroDIY/ModularSensors/wiki/Sensor-Datasheets/Bosch-BMP390-Datasheet.pdf) /// for resolution at all bandwidths. @@ -638,6 +634,10 @@ class BoschBMP3xx_Pressure : public Variable { (uint8_t)BMP3XX_PRESSURE_RESOLUTION, BMP3XX_PRESSURE_VAR_NAME, BMP3XX_PRESSURE_UNIT_NAME, BMP3XX_PRESSURE_DEFAULT_CODE) {} + /** + * @brief Destroy the BoschBMP3xx_Pressure object - no action needed. + */ + ~BoschBMP3xx_Pressure() {} }; @@ -679,6 +679,10 @@ class BoschBMP3xx_Altitude : public Variable { (uint8_t)BMP3XX_ALTITUDE_RESOLUTION, BMP3XX_ALTITUDE_VAR_NAME, BMP3XX_ALTITUDE_UNIT_NAME, BMP3XX_ALTITUDE_DEFAULT_CODE) {} + /** + * @brief Destroy the BoschBMP3xx_Altitude object - no action needed. + */ + ~BoschBMP3xx_Altitude() {} }; /**@}*/ #endif // SRC_SENSORS_BOSCHBMP3XX_H_ diff --git a/src/sensors/TEConnectivityMS5837.cpp b/src/sensors/TEConnectivityMS5837.cpp index e20592843..4d6b1e354 100644 --- a/src/sensors/TEConnectivityMS5837.cpp +++ b/src/sensors/TEConnectivityMS5837.cpp @@ -113,8 +113,8 @@ bool TEConnectivityMS5837::addSingleMeasurementResult(void) { // Calculate depth in meters // Note: fluidDensity is set in the MS5837_internal object at setup and // used in the getDepth() function. The fluidDensity is only set in the - // constructor and cannot be changed, so there's no reason to re-pass - // the value to the internal object here. + // constructor and further setters and getters are not provided, so + // there's no reason to re-pass the value to the internal object here. depth = MS5837_internal.getDepth(); } else { MS_DBG(F(" Read failed, error:"), MS5837_internal.getLastError()); From 91ec2b07e0586640545bdb4055bedb28a80c4ddc Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Fri, 27 Feb 2026 12:37:22 -0500 Subject: [PATCH 368/533] Fix docs Signed-off-by: Sara Damiano --- examples/menu_a_la_carte/ReadMe.md | 19 +++++++++++++++++-- src/sensors/BoschBMP3xx.h | 4 +++- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/examples/menu_a_la_carte/ReadMe.md b/examples/menu_a_la_carte/ReadMe.md index cbe53588e..317439409 100644 --- a/examples/menu_a_la_carte/ReadMe.md +++ b/examples/menu_a_la_carte/ReadMe.md @@ -90,6 +90,7 @@ ___ - [Maxbotix HRXL Ultrasonic Range Finder](#maxbotix-hrxl-ultrasonic-range-finder) - [Maxim DS18 One Wire Temperature Sensor](#maxim-ds18-one-wire-temperature-sensor) - [Measurement Specialties MS5803-14BA Pressure Sensor](#measurement-specialties-ms5803-14ba-pressure-sensor) + - [TE Connectivity MS5837 Pressure Sensor](#te-connectivity-ms5837-pressure-sensor) - [Meter SDI-12 Sensors](#meter-sdi-12-sensors) - [Meter ECH2O Soil Moisture Sensor](#meter-ech2o-soil-moisture-sensor) - [Meter Hydros 21 Conductivity, Temperature, and Depth Sensor](#meter-hydros-21-conductivity-temperature-and-depth-sensor) @@ -731,7 +732,7 @@ ___ Here is the code for the Bosch BME280 environmental sensor. The only input needed is the Arduino pin controlling power on/off; the i2cAddressHex is optional as is the number of readings to average. -Keep in mind that the possible I2C addresses of the BME280 match those of the MS5803; when using those sensors together, make sure they are set to opposite addresses. +Keep in mind that the I2C address (0x76) of the BME280 matches those of some configurations of the MS5803, MS5837, BMP388, and BMP390 sensors; when using those sensors together, make sure they are set to different addresses. @see @ref sensor_bme280 @@ -741,6 +742,8 @@ ___ ### Bosch BMP388 and BMP398 Pressure Sensors +Keep in mind that the I2C address (0x76) of the BMP388/BMP390 sensors matches those of some configurations of the MS5803, MS5837, and BME280 sensors; when using those sensors together, make sure they are set to different addresses. + @see @ref sensor_bmp3xx @@ -948,7 +951,7 @@ ___ ### Measurement Specialties MS5803-14BA Pressure Sensor The only input needed is the Arduino pin controlling power on/off; the i2cAddressHex and maximum pressure are optional as is the number of readings to average. -Keep in mind that the possible I2C addresses of the MS5803 match those of the BME280. +Keep in mind that the I2C address (0x76) of the MS5803 matches those of some configurations of the MS5837, BME280, BMP388, and BMP390 sensors; when using those sensors together, make sure they are set to different addresses. @see @ref sensor_ms5803 @@ -956,6 +959,18 @@ Keep in mind that the possible I2C addresses of the MS5803 match those of the BM ___ +### TE Connectivity MS5837 Pressure Sensor + +The MS5837 is commonly used in Blue Robotics Bar02/Bar30 pressure sensors for underwater applications and depth measurement. +The only required input is the Arduino pin controlling power on/off; the sensor model, fluid density, air pressure, and number of readings to average are optional. +Keep in mind that the I2C address (0x76) of the MS5837 matches those of some configurations of the MS5803, BME280, BMP388, and BMP390 sensors. + +@see @ref sensor_ms5837 + + + +___ + ### Meter SDI-12 Sensors The next few sections are for Meter SDI-12 sensors. diff --git a/src/sensors/BoschBMP3xx.h b/src/sensors/BoschBMP3xx.h index 72447da9a..3a235a648 100644 --- a/src/sensors/BoschBMP3xx.h +++ b/src/sensors/BoschBMP3xx.h @@ -164,6 +164,8 @@ #define BMP3XX_NUM_VARIABLES 3 /// @brief Sensor::_incCalcValues; altitude is calculated from pressure. #define BMP3XX_INC_CALC_VARIABLES 1 +/**@}*/ + /** * @anchor sensor_bmp3xx_timing * @name Sensor Timing @@ -237,7 +239,7 @@ */ /**@{*/ /// @brief Decimals places in string representation; temperature should have 5 - -/// resolution is 0.00015°C at the hightest oversampling. See table 7 in the +/// resolution is 0.00015°C at the highest oversampling. See table 7 in the /// [sensor /// datasheet](https://github.com/EnviroDIY/ModularSensors/wiki/Sensor-Datasheets/Bosch-BMP390-Datasheet.pdf) /// for resolution at all bandwidths. From 51ae6986676b672231badde9301a98f14d6ff4f1 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Fri, 27 Feb 2026 18:17:01 -0500 Subject: [PATCH 369/533] Support second hardware I2C; fix name/location issue, fix validation, add attempt to correct model Signed-off-by: Sara Damiano --- docs/For-Developers/Developer-Setup.md | 2 +- examples/menu_a_la_carte/menu_a_la_carte.ino | 11 +- src/sensors/TEConnectivityMS5837.cpp | 263 +++++++++++++++---- src/sensors/TEConnectivityMS5837.h | 183 ++++++++++++- 4 files changed, 390 insertions(+), 69 deletions(-) diff --git a/docs/For-Developers/Developer-Setup.md b/docs/For-Developers/Developer-Setup.md index cdd0425fe..6286fa2fc 100644 --- a/docs/For-Developers/Developer-Setup.md +++ b/docs/For-Developers/Developer-Setup.md @@ -150,7 +150,7 @@ lib_deps = envirodiy/GeoluxCamera@^0.1.3 robtillaart/fast_math@^0.2.4 envirodiy/ANBSensorsModbus@^0.4.2 - BlueRobotics MS5837 Library=https://github.com/bluerobotics/BlueRobotics_MS5837_Library + robtillaart/MS5837@^0.3.2 StreamDebugger=https://github.com/EnviroDIY/StreamDebugger.git NeoSWSerial=https://github.com/SRGDamia1/NeoSWSerial.git AltSoftSerial=https://github.com/PaulStoffregen/AltSoftSerial.git diff --git a/examples/menu_a_la_carte/menu_a_la_carte.ino b/examples/menu_a_la_carte/menu_a_la_carte.ino index 92abe8c06..f7d3f1d86 100644 --- a/examples/menu_a_la_carte/menu_a_la_carte.ino +++ b/examples/menu_a_la_carte/menu_a_la_carte.ino @@ -2086,11 +2086,12 @@ Variable* ms5803Temp = #include // NOTE: Use -1 for any pins that don't apply or aren't being used. -const int8_t MS5837Power = sensorPowerPin; // Power pin -const uint8_t MS5837model = - MS5837_TYPE_30; // Model: MS5837_TYPE_02 for 2bar range or - // MS5837_TYPE_30 for 30bar range -const uint8_t MS5837ReadingsToAvg = 1; +const int8_t MS5837Power = sensorPowerPin; // Power pin +const MS5837Model MS5837model = MS5837Model::MS5837_02BA; +// - MS5837Model::MS5837_30BA for 30 bar range sensors (MS5837-30BA) +// - MS5837Model::MS5837_02BA for 2 bar range sensors (MS5837-02BA) +// - MS5837Model::MS5803_01BA for 1 bar range sensors (MS5803-01BA) +const uint8_t MS5837ReadingsToAvg = 1; // Create a TE Connectivity MS5837 pressure and temperature sensor object TEConnectivityMS5837 ms5837(MS5837Power, MS5837model, MS5837ReadingsToAvg); diff --git a/src/sensors/TEConnectivityMS5837.cpp b/src/sensors/TEConnectivityMS5837.cpp index 4d6b1e354..c24d2767e 100644 --- a/src/sensors/TEConnectivityMS5837.cpp +++ b/src/sensors/TEConnectivityMS5837.cpp @@ -10,26 +10,61 @@ #include "TEConnectivityMS5837.h" +// Include math library for log function +#include -// The constructor - because this is I2C, only need the power pin -TEConnectivityMS5837::TEConnectivityMS5837(int8_t powerPin, uint8_t model, - uint8_t measurementsToAverage, - float fluidDensity, - float airPressure) + +// The constructor +TEConnectivityMS5837::TEConnectivityMS5837(TwoWire* theI2C, int8_t powerPin, + uint8_t model, + uint8_t measurementsToAverage, + uint16_t overSamplingRatio, + float fluidDensity, + float airPressure) : Sensor("TEConnectivityMS5837", MS5837_NUM_VARIABLES, MS5837_WARM_UP_TIME_MS, MS5837_STABILIZATION_TIME_MS, MS5837_MEASUREMENT_TIME_MS, powerPin, -1, measurementsToAverage, MS5837_INC_CALC_VARIABLES), + MS5837_internal(theI2C), + _wire(theI2C), _model(model), _fluidDensity(fluidDensity), - _airPressure(airPressure) {} + _airPressure(airPressure), + _overSamplingRatio(overSamplingRatio) {} +TEConnectivityMS5837::TEConnectivityMS5837(int8_t powerPin, uint8_t model, + uint8_t measurementsToAverage, + uint16_t overSamplingRatio, + float fluidDensity, + float airPressure) + : TEConnectivityMS5837(&Wire, powerPin, model, measurementsToAverage, + overSamplingRatio, fluidDensity, airPressure) {}; + +// Enum-based constructors +TEConnectivityMS5837::TEConnectivityMS5837(int8_t powerPin, MS5837Model model, + uint8_t measurementsToAverage, + uint16_t overSamplingRatio, + float fluidDensity, + float airPressure) + : TEConnectivityMS5837(powerPin, static_cast(model), + measurementsToAverage, overSamplingRatio, + fluidDensity, airPressure) {} + +TEConnectivityMS5837::TEConnectivityMS5837(TwoWire* theI2C, int8_t powerPin, + MS5837Model model, + uint8_t measurementsToAverage, + uint16_t overSamplingRatio, + float fluidDensity, + float airPressure) + : TEConnectivityMS5837(theI2C, powerPin, static_cast(model), + measurementsToAverage, overSamplingRatio, + fluidDensity, airPressure) {} // Destructor TEConnectivityMS5837::~TEConnectivityMS5837() {} -String TEConnectivityMS5837::getSensorLocation(void) { - String modelStr = F("I2C_0x76_"); +String TEConnectivityMS5837::getSensorName(void) { + String modelStr = F("TEConnectivityMS5837_"); switch (_model) { case MS5837_TYPE_02: modelStr += F("02BA"); break; case MS5837_TYPE_30: modelStr += F("30BA"); break; @@ -40,6 +75,11 @@ String TEConnectivityMS5837::getSensorLocation(void) { } +String TEConnectivityMS5837::getSensorLocation(void) { + return F("I2C_0x76"); +} + + bool TEConnectivityMS5837::setup(void) { bool success = Sensor::setup(); // this will set pin modes and the setup status bit @@ -53,6 +93,15 @@ bool TEConnectivityMS5837::setup(void) { // Set the sensor model and initialize the sensor success &= MS5837_internal.begin(_model); + // Validate that the pressure range is reasonable for the sensor model and + // change the model if possible based on the pressure sensitivity read from + // the sensor. + if (changeModelIfPossible()) { + // If the model was changed, we need to re-initialize the sensor with + // the new model. + success &= MS5837_internal.reset(_model); + } + if (success) { // Set the fluid density for depth calculations MS5837_internal.setDensity(_fluidDensity); @@ -73,6 +122,32 @@ bool TEConnectivityMS5837::setup(void) { } +bool TEConnectivityMS5837::wake(void) { + // Run the parent wake function + if (!Sensor::wake()) return false; + + bool success = true; + // Re-initialize the sensor communication, if the sensor was powered down + if (_powerPin >= 0) { + success = MS5837_internal.begin(_model); + // There's no need to validate the model or change the fluid density or + // other parameters. Those are not affected by power cycling the sensor. + } + if (!success) { + MS_DBG(getSensorNameAndLocation(), + F("Wake failed - sensor re-initialization failed")); + // Set the status error bit (bit 7) + setStatusBit(ERROR_OCCURRED); + // Make sure that the wake time and wake success bit (bit 4) are + // unset + _millisSensorActivated = 0; + clearStatusBit(WAKE_SUCCESSFUL); + } + + return success; +} + + bool TEConnectivityMS5837::addSingleMeasurementResult(void) { // Immediately quit if the measurement was not successfully started if (!getStatusBit(MEASUREMENT_SUCCESSFUL)) { @@ -90,25 +165,90 @@ bool TEConnectivityMS5837::addSingleMeasurementResult(void) { F("mBar. Expected range: 500-1200")); return bumpMeasurementAttemptCount(false); } + if (_overSamplingRatio != 256 && _overSamplingRatio != 512 && + _overSamplingRatio != 1024 && _overSamplingRatio != 2048 && + _overSamplingRatio != 4096 && _overSamplingRatio != 8192) { + MS_DBG(F("Invalid oversampling ratio:"), _overSamplingRatio, + F(". Valid values: 256, 512, 1024, 2048, 4096, 8192")); + return bumpMeasurementAttemptCount(false); + } float temp = -9999; float press = -9999; float depth = -9999; float alt = -9999; - MS_DBG(getSensorNameAndLocation(), F("is reporting:")); // Read values from the sensor - returns 0 on success - bool success = MS5837_internal.read() == 0; + int OSR = log(_overSamplingRatio) / log(2); + MS_DBG(F(" Requesting OSR:"), OSR, F("for oversampling ratio:"), + _overSamplingRatio); + // Convert oversampling ratio to the value expected by the MS5837 library + // (8-13 for oversampling ratios 256-8192) + int read_return = MS5837_internal.read(OSR); + bool success = read_return == 0; if (success) { // Get temperature in Celsius temp = MS5837_internal.getTemperature(); // Get pressure in millibar press = MS5837_internal.getPressure(); + } else { + MS_DBG(F(" Read failed, error:"), MS5837_internal.getLastError(), + F("Return value from read():"), read_return); + return bumpMeasurementAttemptCount(false); + } + + // Validate the readings + float maxPressure = 0.0f; + switch (_model) { + case MS5803_TYPE_01: maxPressure = 1000.0f; break; // 1 bar = 1000 mbar + case MS5837_TYPE_02: maxPressure = 2000.0f; break; // 2 bar = 2000 mbar + case MS5837_TYPE_30: + maxPressure = 30000.0f; + break; // 30 bar = 30000 mbar + default: maxPressure = 30000.0; break; + } + + MS_DBG(getSensorNameAndLocation(), F("is reporting:")); + + // Pressure returns 0 when disconnected, which is highly unlikely to be + // a real value. + // Pressure range depends on the model; allow 5% over max pressure + if (!isnan(press) && press > 0.0f && press <= maxPressure * 1.05f) { + MS_DBG(F(" Pressure:"), press); + verifyAndAddMeasurementResult(MS5837_PRESSURE_VAR_NUM, press); + } else if (!isnan(press)) { + MS_DBG(F(" Pressure out of range:"), press); + success = false; + } else { + MS_DBG(F(" Pressure is NaN")); + success = false; + } + + // Temperature Range is -40°C to +85°C + if (!isnan(temp) && temp >= -40.0f && temp <= 85.0f) { + MS_DBG(F(" Temperature:"), temp); + verifyAndAddMeasurementResult(MS5837_TEMP_VAR_NUM, temp); + } else if (!isnan(temp)) { + MS_DBG(F(" Temperature out of range:"), temp); + success = false; + } else { + MS_DBG(F(" Temperature is NaN")); + success = false; + } + + if (success) { + // Calculate and store depth and altitude only if input temperature and + // depth are are valid + // If the temperature and pressure are valid - and we've already checked + // for reasonable air pressure and fluid density, then the altitude and + // depth will be valid. // Calculate altitude in meters using configured air pressure alt = MS5837_internal.getAltitude(_airPressure); + MS_DBG(F(" Altitude:"), alt); + verifyAndAddMeasurementResult(MS5837_ALTITUDE_VAR_NUM, alt); // Calculate depth in meters // Note: fluidDensity is set in the MS5837_internal object at setup and @@ -116,54 +256,75 @@ bool TEConnectivityMS5837::addSingleMeasurementResult(void) { // constructor and further setters and getters are not provided, so // there's no reason to re-pass the value to the internal object here. depth = MS5837_internal.getDepth(); + MS_DBG(F(" Depth:"), depth); + verifyAndAddMeasurementResult(MS5837_DEPTH_VAR_NUM, depth); } else { - MS_DBG(F(" Read failed, error:"), MS5837_internal.getLastError()); - return bumpMeasurementAttemptCount(false); + MS_DBG( + F(" Invalid readings, skipping depth and altitude calculations")); } - MS_DBG(F(" Temperature:"), temp); - MS_DBG(F(" Pressure:"), press); - MS_DBG(F(" Depth:"), depth); - MS_DBG(F(" Altitude:"), alt); + // Return success value when finished + return bumpMeasurementAttemptCount(success); +} + - // Validate the readings - float maxPressure = 0; - switch (_model) { - case MS5803_TYPE_01: maxPressure = 1000.0; break; // 1 bar = 1000 mbar - case MS5837_TYPE_02: maxPressure = 2000.0; break; // 2 bar = 2000 mbar - case MS5837_TYPE_30: - maxPressure = 30000.0; - break; // 30 bar = 30000 mbar - default: maxPressure = 30000.0; break; - } +bool TEConnectivityMS5837::changeModelIfPossible() { + MS_DBG(F("Attempting to read SENS_T1 from PROM of sensor at address"), + String(MS5837_internal.getAddress(), HEX)); - if (!isnan(temp) && !isnan(press) && temp >= -40.0 && temp <= 85.0 && - press > 0.0 && - press <= maxPressure * 1.05) { // allow 5% over max pressure - // Temperature Range is -40°C to +85°C - // Pressure returns 0 when disconnected, which is highly unlikely to be - // a real value. - // Pressure range depends on the model - verifyAndAddMeasurementResult(MS5837_TEMP_VAR_NUM, temp); - verifyAndAddMeasurementResult(MS5837_PRESSURE_VAR_NUM, press); + bool success = true; + uint8_t address = MS5837_internal.getAddress(); - // Store calculated values if they are valid - if (!isnan(depth) && depth >= -2000.0 && depth <= 2000.0) { - // Reasonable depth range from -2000m to +2000m - verifyAndAddMeasurementResult(MS5837_DEPTH_VAR_NUM, depth); - } else if (!isnan(depth)) { - MS_DBG(F(" Depth out of range:"), depth); - } - if (!isnan(alt) && alt >= -1000.0 && alt <= 10000.0) { - // Reasonable altitude range from -1000m to +10000m - verifyAndAddMeasurementResult(MS5837_ALTITUDE_VAR_NUM, alt); - } else if (!isnan(alt)) { - MS_DBG(F(" Altitude out of range:"), alt); - } + // Verify I2C connectivity with a lightweight probe + _wire->beginTransmission(address); + if (_wire->endTransmission() != 0) { + MS_DBG(F(" I2C communication failed at 0x"), String(address, HEX)); + return false; + } - success = true; + // MS5837_CMD_READ_PROM = 0xA0 + // Read SENS_T1 from PROM 1 [0xA0 + (1*2)] + _wire->beginTransmission(address); + _wire->write(0xA0 + (1 * 2)); + success &= _wire->endTransmission() == 0; + if (!success) { + MS_DBG(F("Failed to request SENS_T1 from PROM. Unable to validate " + "pressure range.")); + return false; } - // Return success value when finished - return bumpMeasurementAttemptCount(success); + uint8_t length = 2; + if (_wire->requestFrom(address, length) != length) { + MS_DBG(F("Failed to retrieve SENS_T1 from PROM. Unable to validate " + "pressure range.")); + return false; + } + uint16_t SENS_T1 = (_wire->read() << 8) | _wire->read(); + MS_DBG(F("SENS_T1 value:"), SENS_T1); + + // Values from + // https://github.com/ArduPilot/ardupilot/pull/29122#issuecomment-2877269114 + const uint16_t MS5837_02BA_MAX_SENSITIVITY = 49000; + const uint16_t MS5837_02BA_30BA_SEPARATION = 37000; + const uint16_t MS5837_30BA_MIN_SENSITIVITY = 26000; + // PROM Word 1 represents the sensor's pressure sensitivity calibration + // NOTE: The calibrated pressure sensitivity value (SENS_T1) is **not** the + // same as the as the pressure range from the datasheet! + // Set _model according to the experimental pressure sensitivity thresholds + if (SENS_T1 > MS5837_30BA_MIN_SENSITIVITY && + SENS_T1 < MS5837_02BA_30BA_SEPARATION && _model == 1) { + MS_DBG( + F("SENS_T1 value indicates 30BA model, but model is set to 02BA")); + MS_DBG(F("Changing model to 30BA")); + _model = 0; + return false; // Return false to indicate that the model was changed + } else if (SENS_T1 > MS5837_02BA_30BA_SEPARATION && + SENS_T1 < MS5837_02BA_MAX_SENSITIVITY && _model == 0) { + MS_DBG( + F("SENS_T1 value indicates 02BA model, but model is set to 30BA")); + MS_DBG(F("Setting model to 02BA")); + _model = 1; + return false; // Return false to indicate that the model was changed + } + return true; } diff --git a/src/sensors/TEConnectivityMS5837.h b/src/sensors/TEConnectivityMS5837.h index 3ab6f2e83..566b3e26f 100644 --- a/src/sensors/TEConnectivityMS5837.h +++ b/src/sensors/TEConnectivityMS5837.h @@ -133,6 +133,29 @@ static_assert(MS5837_DEFAULT_FLUID_DENSITY > 0.1f && MS5837_DEFAULT_FLUID_DENSITY <= 5.0f, "MS5837_DEFAULT_FLUID_DENSITY must be between 0.1 and 5.0 g/cm³ " "(reasonable fluid density range)"); + +#if !defined(MS5837_DEFAULT_OVERSAMPLING_RATIO) || defined(DOXYGEN) +/** + * @brief Default oversampling ratio for pressure and temperature measurements + * + * Higher oversampling ratios provide better resolution and noise reduction but + * increase measurement time. Valid values are: 256, 512, 1024, 2048, 4096, + * 8192. Default is 4096 for good balance of accuracy and speed. This can be + * overridden at compile time with -D MS5837_DEFAULT_OVERSAMPLING_RATIO=value + */ +#define MS5837_DEFAULT_OVERSAMPLING_RATIO 4096 +#endif + +// Static assert to validate oversampling ratio is one of the valid values +static_assert( + MS5837_DEFAULT_OVERSAMPLING_RATIO == 256 || + MS5837_DEFAULT_OVERSAMPLING_RATIO == 512 || + MS5837_DEFAULT_OVERSAMPLING_RATIO == 1024 || + MS5837_DEFAULT_OVERSAMPLING_RATIO == 2048 || + MS5837_DEFAULT_OVERSAMPLING_RATIO == 4096 || + MS5837_DEFAULT_OVERSAMPLING_RATIO == 8192, + "MS5837_DEFAULT_OVERSAMPLING_RATIO must be one of: 256, 512, 1024, " + "2048, 4096, 8192 (valid MS5837 oversampling ratios)"); /**@}*/ /** @@ -142,7 +165,7 @@ static_assert(MS5837_DEFAULT_FLUID_DENSITY > 0.1f && */ /**@{*/ /// @brief Sensor::_numReturnedValues; the MS5837 can report 2 values. -#define MS5837_NUM_VARIABLES 2 +#define MS5837_NUM_VARIABLES 4 /// @brief Sensor::_incCalcValues; we calculate depth and altitude values. #define MS5837_INC_CALC_VARIABLES 2 /**@}*/ @@ -280,6 +303,24 @@ static_assert(MS5837_DEFAULT_FLUID_DENSITY > 0.1f && #define MS5837_ALTITUDE_DEFAULT_CODE "TEConnectivityMS5837Altitude" /**@}*/ +/** + * @brief Supported MS5837/MS5803 sensor models + * + * These enum values correspond to the **math model** values used in the Rob + * Tillaart MS5837 library. They are **not** equivalent to the "type" values + * defined in that library, which are not used in the MS5837 class. The math + * model values are used to set the correct calibration coefficients and + * calculations for the different sensor models, which have different pressure + * ranges and sensitivities. + * + * @ingroup sensor_ms5837 + */ +enum class MS5837Model : uint8_t { + MS5837_30BA = 0, ///< MS5837-30BA: 30 bar range sensor + MS5837_02BA = 1, ///< MS5837-02BA: 2 bar range sensor + MS5803_01BA = 2 ///< MS5803-01BA: 1 bar range sensor +}; + /* clang-format off */ /** * @brief The Sensor sub-class for the @@ -291,32 +332,107 @@ static_assert(MS5837_DEFAULT_FLUID_DENSITY > 0.1f && class TEConnectivityMS5837 : public Sensor { public: /** - * @brief Construct a new TEConnectivityMS5837 object. + * @brief Construct a new TEConnectivityMS5837 object using the default + * Hardware Wire instance. * - * @note Neither secondary hardware nor software I2C is supported for the - * MS5837. Only the primary hardware I2C defined in the Arduino core can be - * used. + * @param powerPin The pin on the mcu controlling power to the MS5837 + * Use -1 if it is continuously powered. + * - The MS5837 requires a 1.7 - 3.6V power source + * @param model The model of MS5837 sensor. + * - 0 for 30 bar range sensors (MS5837-30BA) + * - 1 for 2 bar range sensors (MS5837-02BA) + * - 2 for 1 bar range sensors (MS5803-01BA) + * @param measurementsToAverage The number of measurements to take and + * average before giving a "final" result from the sensor; optional with a + * default value of 1. + * @param fluidDensity The density of the fluid for depth calculations + * (grams/cm³); optional with default value from + * MS5837_DEFAULT_FLUID_DENSITY. + * @param airPressure The air pressure for altitude/depth calculations + * (mBar); optional with default value from MS_SEA_LEVEL_PRESSURE_HPA. + * @param overSamplingRatio The oversampling ratio for pressure and + * temperature measurements; optional with default value from + * MS5837_DEFAULT_OVERSAMPLING_RATIO. Valid values: 256, 512, 1024, 2048, + * 4096, 8192. + * + * @warning This can be used for the MS5803-01BA sensor, but **only** for + * that exact model of MS5803. For any other MS5803 model, use the + * MeasSpecMS5803 class instead of this class. + */ + explicit TEConnectivityMS5837( + int8_t powerPin, uint8_t model, uint8_t measurementsToAverage = 1, + uint16_t overSamplingRatio = MS5837_DEFAULT_OVERSAMPLING_RATIO, + float fluidDensity = MS5837_DEFAULT_FLUID_DENSITY, + float airPressure = MS_SEA_LEVEL_PRESSURE_HPA); + /** + * @brief Construct a new TEConnectivityMS5837 object using a secondary + * *hardware* I2C instance. + * + * @copydetails TEConnectivityMS5837::TEConnectivityMS5837(int8_t, uint8_t, + * uint8_t, float, float) + * + * @param theI2C A TwoWire instance for I2C communication. Due to the + * limitations of the Arduino core, only a hardware I2C instance can be + * used. For an AVR board, there is only one I2C instance possible and this + * form of the constructor should not be used. For a SAMD board, this can + * be used if a secondary I2C port is created on one of the extra SERCOMs. + */ + TEConnectivityMS5837( + TwoWire* theI2C, int8_t powerPin, uint8_t model, + uint8_t measurementsToAverage = 1, + uint16_t overSamplingRatio = MS5837_DEFAULT_OVERSAMPLING_RATIO, + float fluidDensity = MS5837_DEFAULT_FLUID_DENSITY, + float airPressure = MS_SEA_LEVEL_PRESSURE_HPA); + + /** + * @brief Construct a new TEConnectivityMS5837 object using the default + * Hardware Wire instance with enum model type. * * @param powerPin The pin on the mcu controlling power to the MS5837 * Use -1 if it is continuously powered. * - The MS5837 requires a 1.7 - 3.6V power source - * @param model The model of MS5837 sensor. Use MS5837_TYPE_02 for - * 2 bar range sensors or MS5837_TYPE_30 for 30 bar range sensors. - * Default is MS5837_TYPE_02. + * @param model The model of MS5837 sensor using enum type. * @param measurementsToAverage The number of measurements to take and * average before giving a "final" result from the sensor; optional with a * default value of 1. + * @param overSamplingRatio The oversampling ratio for pressure and + * temperature measurements; optional with default value from + * MS5837_DEFAULT_OVERSAMPLING_RATIO. Valid values: 256, 512, 1024, 2048, + * 4096, 8192. * @param fluidDensity The density of the fluid for depth calculations * (grams/cm³); optional with default value from * MS5837_DEFAULT_FLUID_DENSITY. * @param airPressure The air pressure for altitude/depth calculations * (mBar); optional with default value from MS_SEA_LEVEL_PRESSURE_HPA. + * + * @warning This can be used for the MS5803-01BA sensor, but **only** for + * that exact model of MS5803. For any other MS5803 model, use the + * MeasSpecMS5803 class instead of this class. */ explicit TEConnectivityMS5837( - int8_t powerPin, uint8_t model = MS5837_TYPE_02, - uint8_t measurementsToAverage = 1, - float fluidDensity = MS5837_DEFAULT_FLUID_DENSITY, - float airPressure = MS_SEA_LEVEL_PRESSURE_HPA); + int8_t powerPin, MS5837Model model, uint8_t measurementsToAverage = 1, + uint16_t overSamplingRatio = MS5837_DEFAULT_OVERSAMPLING_RATIO, + float fluidDensity = MS5837_DEFAULT_FLUID_DENSITY, + float airPressure = MS_SEA_LEVEL_PRESSURE_HPA); + /** + * @brief Construct a new TEConnectivityMS5837 object using a secondary + * *hardware* I2C instance. + * + * @copydetails TEConnectivityMS5837::TEConnectivityMS5837(int8_t, + * MS5837Model, uint8_t, float, float) + * + * @param theI2C A TwoWire instance for I2C communication. Due to the + * limitations of the Arduino core, only a hardware I2C instance can be + * used. For an AVR board, there is only one I2C instance possible and this + * form of the constructor should not be used. For a SAMD board, this can + * be used if a secondary I2C port is created on one of the extra SERCOMs. + */ + TEConnectivityMS5837( + TwoWire* theI2C, int8_t powerPin, MS5837Model model, + uint8_t measurementsToAverage = 1, + uint16_t overSamplingRatio = MS5837_DEFAULT_OVERSAMPLING_RATIO, + float fluidDensity = MS5837_DEFAULT_FLUID_DENSITY, + float airPressure = MS_SEA_LEVEL_PRESSURE_HPA); /** * @brief Destroy the TEConnectivityMS5837 object */ @@ -333,6 +449,19 @@ class TEConnectivityMS5837 : public Sensor { */ bool setup(void) override; + /** + * @brief Wake the sensor and re-establish communication. + * + * This re-runs the MS5837_internal begin method to re-establish I2C + * communication, re-read the sensor calibration constants, and ensure that + * the sensor itself has loaded the calibration PROM into its internal + * register. This is required after every power cycle of the sensor. + * + * @return True if the wake was successful. + */ + bool wake(void) override; + + String getSensorName(void) override; String getSensorLocation(void) override; bool addSingleMeasurementResult(void) override; @@ -342,6 +471,10 @@ class TEConnectivityMS5837 : public Sensor { * @brief Private internal reference to the MS5837 object. */ MS5837 MS5837_internal; + /** + * @brief An internal reference to the hardware Wire instance. + */ + TwoWire* _wire; // Hardware Wire /** * @brief The model of the MS5837. */ @@ -354,6 +487,32 @@ class TEConnectivityMS5837 : public Sensor { * @brief The air pressure for altitude/depth calculations (mBar). */ float _airPressure; + /** + * @brief The oversampling ratio for pressure and temperature measurements. + */ + uint16_t _overSamplingRatio; + + /** + * @brief Attempts to validate the pressure range of the sensor by reading + * the SENS_T1 calibration value and change the model if the value indicates + * a different model than the one currently configured. + * + * @note This will only change the configuration if a valid SENS_T1 value is + * returned, one of the MS5837 models is currently configured, and the + * SENS_T1 value indicates the other MS5837 model based on experimentally + * derived sensitivity thresholds. If the SENS_T1 cannot be retrieved, the + * value is out of the expected range for both models, or a MS5803 is + * configured, no changes will be made. + * + * The thresholds used for determining whether to change the model + * configuration are taken from the Blue Robotics MS5837 library and are + * based on experimental results posted here: + * https://github.com/ArduPilot/ardupilot/pull/29122#issuecomment-2877269114 + * + * @return True if the model value was changed based on the returned SENS_T1 + * value, false otherwise. + */ + bool changeModelIfPossible(); }; From d4cdb7c31befb9c51398e014122988be90ffa7ac Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Fri, 27 Feb 2026 18:17:22 -0500 Subject: [PATCH 370/533] Prettier print out Signed-off-by: Sara Damiano --- src/VariableArray.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/VariableArray.cpp b/src/VariableArray.cpp index 6725293eb..b494142f8 100644 --- a/src/VariableArray.cpp +++ b/src/VariableArray.cpp @@ -642,11 +642,15 @@ bool VariableArray::completeUpdate(bool powerUp, bool wake, bool sleep, // Calculated Variable results will be included void VariableArray::printSensorData(Stream* stream) { for (uint8_t i = 0; i < _variableCount; i++) { + if (i > 0 && + arrayOfVars[i]->parentSensor != arrayOfVars[i - 1]->parentSensor) { + stream->println(); + } if (arrayOfVars[i]->isCalculated) { stream->print(arrayOfVars[i]->getVarName()); stream->print(F(" (")); stream->print(arrayOfVars[i]->getVarCode()); - stream->print(F(") ")); + stream->print(F(")")); stream->print(F(" is calculated to be ")); stream->print(arrayOfVars[i]->getValueString()); stream->print(F(" ")); @@ -667,7 +671,7 @@ void VariableArray::printSensorData(Stream* stream) { stream->print(arrayOfVars[i]->getVarName()); stream->print(F(" (")); stream->print(arrayOfVars[i]->getVarCode()); - stream->print(F(") ")); + stream->print(F(")")); stream->print(F(" is ")); stream->print(arrayOfVars[i]->getValueString()); stream->print(F(" ")); From a79194097fe1c90328515a7f6411a887f4462217 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Fri, 27 Feb 2026 18:22:13 -0500 Subject: [PATCH 371/533] Support secondary hardware I2C for ADS1x15 Signed-off-by: Sara Damiano --- src/sensors/TIADS1x15.cpp | 18 +++++++++++++----- src/sensors/TIADS1x15.h | 35 +++++++++++++++++++++++++++++++++-- 2 files changed, 46 insertions(+), 7 deletions(-) diff --git a/src/sensors/TIADS1x15.cpp b/src/sensors/TIADS1x15.cpp index 6f4bbdbbb..7aa83a6b5 100644 --- a/src/sensors/TIADS1x15.cpp +++ b/src/sensors/TIADS1x15.cpp @@ -20,11 +20,12 @@ // TIADS1x15Base Constructors // ============================================================================ -// Constructor -TIADS1x15Base::TIADS1x15Base(float voltageMultiplier, adsGain_t adsGain, - uint8_t i2cAddress, float adsSupplyVoltage, - uint16_t adsDataRate) +// Constructor with TwoWire instance +TIADS1x15Base::TIADS1x15Base(TwoWire* theI2C, float voltageMultiplier, + adsGain_t adsGain, uint8_t i2cAddress, + float adsSupplyVoltage, uint16_t adsDataRate) : AnalogVoltageBase(voltageMultiplier, adsSupplyVoltage), + _wire(theI2C), _i2cAddress(i2cAddress), _adsGain(adsGain), _adsDataRate(adsDataRate) { @@ -41,6 +42,13 @@ TIADS1x15Base::TIADS1x15Base(float voltageMultiplier, adsGain_t adsGain, // communication } +// Constructor using default Wire instance +TIADS1x15Base::TIADS1x15Base(float voltageMultiplier, adsGain_t adsGain, + uint8_t i2cAddress, float adsSupplyVoltage, + uint16_t adsDataRate) + : TIADS1x15Base(&Wire, voltageMultiplier, adsGain, i2cAddress, + adsSupplyVoltage, adsDataRate) {} + // ============================================================================ // TIADS1x15Base Functions @@ -63,7 +71,7 @@ bool TIADS1x15Base::begin(void) { _ads.setDataRate(_adsDataRate); // Initialize I2C communication with the ADS - bool success = _ads.begin(_i2cAddress); + bool success = _ads.begin(_i2cAddress, _wire); if (success) { MS_DBG(F("ADS1x15 initialized successfully at address 0x"), diff --git a/src/sensors/TIADS1x15.h b/src/sensors/TIADS1x15.h index 0e057ad99..c154e5d6b 100644 --- a/src/sensors/TIADS1x15.h +++ b/src/sensors/TIADS1x15.h @@ -48,8 +48,9 @@ * on the ADS1x15. The ADS1x15 requires an input voltage of 2.0-5.5V, but *this library * always assumes the ADS is powered with 3.3V*. * - * @note ModularSensors only supports connecting the ADS1x15 to primary hardware I2C instance. - * Connecting the ADS to a secondary hardware or software I2C instance is *not* supported! + * @note ModularSensors supports connecting the ADS1x15 to primary hardware I2C instance + * or to a secondary hardware I2C instance using the TwoWire parameter in the constructor. + * Software I2C is *not* supported! * * Communication with the ADS1x15 depends on the * [soligen2010 fork of the Adafruit ADS1015 library](https://github.com/soligen2010/Adafruit_ADS1X15). @@ -267,6 +268,32 @@ class TIADS1x15Base : public AnalogVoltageBase { /** * @brief Construct a new TIADS1x15Base object * + * @param theI2C A TwoWire instance for I2C communication. Due to the + * speed and sensitivity requirements of the ADS1x15, only hardware I2C is + * supported. For AVR boards, this will be Wire. For SAMD boards, this + * can be Wire, Wire1, Wire2, etc.. + * @param voltageMultiplier The voltage multiplier for any voltage dividers + * @param adsGain The internal gain setting of the ADS1x15 + * @param i2cAddress The I2C address of the ADS 1x15 + * @param adsSupplyVoltage The power supply voltage for the ADS1x15 in volts + * @param adsDataRate The data rate for the ADS1x15 (samples per second) + */ + explicit TIADS1x15Base(TwoWire* theI2C, + float voltageMultiplier = 1.0f, + adsGain_t adsGain = GAIN_ONE, + uint8_t i2cAddress = MS_DEFAULT_ADS1X15_ADDRESS, + float adsSupplyVoltage = OPERATING_VOLTAGE, +#ifndef MS_USE_ADS1015 + uint16_t adsDataRate = RATE_ADS1115_128SPS +#else + uint16_t adsDataRate = RATE_ADS1015_1600SPS +#endif + ); + + /** + * @brief Construct a new TIADS1x15Base object using the default hardware + * Wire instance. + * * @param voltageMultiplier The voltage multiplier for any voltage dividers * @param adsGain The internal gain setting of the ADS1x15 * @param i2cAddress The I2C address of the ADS 1x15 @@ -406,6 +433,10 @@ class TIADS1x15Base : public AnalogVoltageBase { float calculateAnalogResolutionVolts(void) override; protected: + /** + * @brief An internal reference to the hardware Wire instance. + */ + TwoWire* _wire; /** * @brief Internal reference to the I2C address of the TI-ADS1x15 */ From f5576b9244117809818636f00b0ccdac2ecf1883 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Fri, 27 Feb 2026 18:37:11 -0500 Subject: [PATCH 372/533] Rename validate fxn, remove math, use enums Signed-off-by: Sara Damiano --- src/sensors/TEConnectivityMS5837.cpp | 116 ++++++++++++++++----------- src/sensors/TEConnectivityMS5837.h | 17 ++-- 2 files changed, 80 insertions(+), 53 deletions(-) diff --git a/src/sensors/TEConnectivityMS5837.cpp b/src/sensors/TEConnectivityMS5837.cpp index c24d2767e..8edf47952 100644 --- a/src/sensors/TEConnectivityMS5837.cpp +++ b/src/sensors/TEConnectivityMS5837.cpp @@ -10,52 +10,50 @@ #include "TEConnectivityMS5837.h" -// Include math library for log function -#include - -// The constructor +// Primary implementation constructor using type-safe enum TEConnectivityMS5837::TEConnectivityMS5837(TwoWire* theI2C, int8_t powerPin, - uint8_t model, - uint8_t measurementsToAverage, - uint16_t overSamplingRatio, - float fluidDensity, - float airPressure) + MS5837Model model, + uint8_t measurementsToAverage, + uint16_t overSamplingRatio, + float fluidDensity, + float airPressure) : Sensor("TEConnectivityMS5837", MS5837_NUM_VARIABLES, MS5837_WARM_UP_TIME_MS, MS5837_STABILIZATION_TIME_MS, MS5837_MEASUREMENT_TIME_MS, powerPin, -1, measurementsToAverage, MS5837_INC_CALC_VARIABLES), MS5837_internal(theI2C), _wire(theI2C), - _model(model), + _model(static_cast(model)), _fluidDensity(fluidDensity), _airPressure(airPressure), _overSamplingRatio(overSamplingRatio) {} -TEConnectivityMS5837::TEConnectivityMS5837(int8_t powerPin, uint8_t model, + +// Delegating constructors +TEConnectivityMS5837::TEConnectivityMS5837(TwoWire* theI2C, int8_t powerPin, + uint8_t model, uint8_t measurementsToAverage, uint16_t overSamplingRatio, float fluidDensity, float airPressure) - : TEConnectivityMS5837(&Wire, powerPin, model, measurementsToAverage, - overSamplingRatio, fluidDensity, airPressure) {}; + : TEConnectivityMS5837(theI2C, powerPin, static_cast(model), + measurementsToAverage, overSamplingRatio, + fluidDensity, airPressure) {} -// Enum-based constructors TEConnectivityMS5837::TEConnectivityMS5837(int8_t powerPin, MS5837Model model, uint8_t measurementsToAverage, uint16_t overSamplingRatio, float fluidDensity, float airPressure) - : TEConnectivityMS5837(powerPin, static_cast(model), - measurementsToAverage, overSamplingRatio, - fluidDensity, airPressure) {} + : TEConnectivityMS5837(&Wire, powerPin, model, measurementsToAverage, + overSamplingRatio, fluidDensity, airPressure) {} -TEConnectivityMS5837::TEConnectivityMS5837(TwoWire* theI2C, int8_t powerPin, - MS5837Model model, - uint8_t measurementsToAverage, - uint16_t overSamplingRatio, - float fluidDensity, - float airPressure) - : TEConnectivityMS5837(theI2C, powerPin, static_cast(model), +TEConnectivityMS5837::TEConnectivityMS5837(int8_t powerPin, uint8_t model, + uint8_t measurementsToAverage, + uint16_t overSamplingRatio, + float fluidDensity, + float airPressure) + : TEConnectivityMS5837(&Wire, powerPin, static_cast(model), measurementsToAverage, overSamplingRatio, fluidDensity, airPressure) {} @@ -66,9 +64,15 @@ TEConnectivityMS5837::~TEConnectivityMS5837() {} String TEConnectivityMS5837::getSensorName(void) { String modelStr = F("TEConnectivityMS5837_"); switch (_model) { - case MS5837_TYPE_02: modelStr += F("02BA"); break; - case MS5837_TYPE_30: modelStr += F("30BA"); break; - case MS5803_TYPE_01: modelStr += F("01BA"); break; + case static_cast(MS5837Model::MS5837_02BA): + modelStr += F("02BA"); + break; + case static_cast(MS5837Model::MS5837_30BA): + modelStr += F("30BA"); + break; + case static_cast(MS5837Model::MS5803_01BA): + modelStr += F("01BA"); + break; default: modelStr += F("Unknown"); break; } return modelStr; @@ -96,7 +100,7 @@ bool TEConnectivityMS5837::setup(void) { // Validate that the pressure range is reasonable for the sensor model and // change the model if possible based on the pressure sensitivity read from // the sensor. - if (changeModelIfPossible()) { + if (validateAndCorrectModel()) { // If the model was changed, we need to re-initialize the sensor with // the new model. success &= MS5837_internal.reset(_model); @@ -180,7 +184,18 @@ bool TEConnectivityMS5837::addSingleMeasurementResult(void) { // Read values from the sensor - returns 0 on success - int OSR = log(_overSamplingRatio) / log(2); + int OSR; + switch (_overSamplingRatio) { + case 256: OSR = 8; break; + case 512: OSR = 9; break; + case 1024: OSR = 10; break; + case 2048: OSR = 11; break; + case 4096: OSR = 12; break; + case 8192: OSR = 13; break; + default: + OSR = 12; + break; // fallback, though validation above should prevent this + } MS_DBG(F(" Requesting OSR:"), OSR, F("for oversampling ratio:"), _overSamplingRatio); // Convert oversampling ratio to the value expected by the MS5837 library @@ -202,12 +217,16 @@ bool TEConnectivityMS5837::addSingleMeasurementResult(void) { // Validate the readings float maxPressure = 0.0f; switch (_model) { - case MS5803_TYPE_01: maxPressure = 1000.0f; break; // 1 bar = 1000 mbar - case MS5837_TYPE_02: maxPressure = 2000.0f; break; // 2 bar = 2000 mbar - case MS5837_TYPE_30: + case static_cast(MS5837Model::MS5803_01BA): + maxPressure = 1000.0f; + break; // 1 bar = 1000 mbar + case static_cast(MS5837Model::MS5837_02BA): + maxPressure = 2000.0f; + break; // 2 bar = 2000 mbar + case static_cast(MS5837Model::MS5837_30BA): maxPressure = 30000.0f; break; // 30 bar = 30000 mbar - default: maxPressure = 30000.0; break; + default: maxPressure = 30000.0f; break; } MS_DBG(getSensorNameAndLocation(), F("is reporting:")); @@ -268,36 +287,37 @@ bool TEConnectivityMS5837::addSingleMeasurementResult(void) { } -bool TEConnectivityMS5837::changeModelIfPossible() { +bool TEConnectivityMS5837::validateAndCorrectModel() { MS_DBG(F("Attempting to read SENS_T1 from PROM of sensor at address"), String(MS5837_internal.getAddress(), HEX)); - bool success = true; uint8_t address = MS5837_internal.getAddress(); // Verify I2C connectivity with a lightweight probe _wire->beginTransmission(address); if (_wire->endTransmission() != 0) { MS_DBG(F(" I2C communication failed at 0x"), String(address, HEX)); - return false; + return false; // can't change the model since we can't communicate with + // the sensor at all } // MS5837_CMD_READ_PROM = 0xA0 // Read SENS_T1 from PROM 1 [0xA0 + (1*2)] _wire->beginTransmission(address); _wire->write(0xA0 + (1 * 2)); - success &= _wire->endTransmission() == 0; - if (!success) { + if (_wire->endTransmission() != 0) { MS_DBG(F("Failed to request SENS_T1 from PROM. Unable to validate " "pressure range.")); - return false; + return false; // can't change the model since we can't request the + // calibration value } uint8_t length = 2; if (_wire->requestFrom(address, length) != length) { MS_DBG(F("Failed to retrieve SENS_T1 from PROM. Unable to validate " "pressure range.")); - return false; + return false; // can't change the model since we can't retrieve the + // calibration value } uint16_t SENS_T1 = (_wire->read() << 8) | _wire->read(); MS_DBG(F("SENS_T1 value:"), SENS_T1); @@ -312,19 +332,21 @@ bool TEConnectivityMS5837::changeModelIfPossible() { // same as the as the pressure range from the datasheet! // Set _model according to the experimental pressure sensitivity thresholds if (SENS_T1 > MS5837_30BA_MIN_SENSITIVITY && - SENS_T1 < MS5837_02BA_30BA_SEPARATION && _model == 1) { + SENS_T1 < MS5837_02BA_30BA_SEPARATION && + _model == static_cast(MS5837Model::MS5837_02BA)) { MS_DBG( F("SENS_T1 value indicates 30BA model, but model is set to 02BA")); MS_DBG(F("Changing model to 30BA")); - _model = 0; - return false; // Return false to indicate that the model was changed + _model = static_cast(MS5837Model::MS5837_30BA); + return true; // Return true to indicate that the model was changed } else if (SENS_T1 > MS5837_02BA_30BA_SEPARATION && - SENS_T1 < MS5837_02BA_MAX_SENSITIVITY && _model == 0) { + SENS_T1 < MS5837_02BA_MAX_SENSITIVITY && + _model == static_cast(MS5837Model::MS5837_30BA)) { MS_DBG( F("SENS_T1 value indicates 02BA model, but model is set to 30BA")); MS_DBG(F("Setting model to 02BA")); - _model = 1; - return false; // Return false to indicate that the model was changed + _model = static_cast(MS5837Model::MS5837_02BA); + return true; // Return true to indicate that the model was changed } - return true; + return false; // Model was not changed } diff --git a/src/sensors/TEConnectivityMS5837.h b/src/sensors/TEConnectivityMS5837.h index 566b3e26f..292508d39 100644 --- a/src/sensors/TEConnectivityMS5837.h +++ b/src/sensors/TEConnectivityMS5837.h @@ -369,7 +369,7 @@ class TEConnectivityMS5837 : public Sensor { * *hardware* I2C instance. * * @copydetails TEConnectivityMS5837::TEConnectivityMS5837(int8_t, uint8_t, - * uint8_t, float, float) + * uint8_t, uint16_t, float, float) * * @param theI2C A TwoWire instance for I2C communication. Due to the * limitations of the Arduino core, only a hardware I2C instance can be @@ -419,7 +419,7 @@ class TEConnectivityMS5837 : public Sensor { * *hardware* I2C instance. * * @copydetails TEConnectivityMS5837::TEConnectivityMS5837(int8_t, - * MS5837Model, uint8_t, float, float) + * MS5837Model, uint8_t, uint16_t, float, float) * * @param theI2C A TwoWire instance for I2C communication. Due to the * limitations of the Arduino core, only a hardware I2C instance can be @@ -493,9 +493,14 @@ class TEConnectivityMS5837 : public Sensor { uint16_t _overSamplingRatio; /** - * @brief Attempts to validate the pressure range of the sensor by reading - * the SENS_T1 calibration value and change the model if the value indicates - * a different model than the one currently configured. + * @brief Validates the configured sensor model against hardware and + * corrects it if a mismatch is detected. + * + * This method reads the SENS_T1 calibration value from the sensor's PROM + * and compares it against known sensitivity thresholds to determine if the + * configured model matches the actual hardware. If a mismatch is detected + * and the correct model can be determined, the model configuration is + * automatically updated. * * @note This will only change the configuration if a valid SENS_T1 value is * returned, one of the MS5837 models is currently configured, and the @@ -512,7 +517,7 @@ class TEConnectivityMS5837 : public Sensor { * @return True if the model value was changed based on the returned SENS_T1 * value, false otherwise. */ - bool changeModelIfPossible(); + bool validateAndCorrectModel(); }; From 6c9bd5c77cb0f882d897c8f811e056863bc14e9d Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Fri, 27 Feb 2026 18:48:14 -0500 Subject: [PATCH 373/533] Reorder ctor, fix wire calls Signed-off-by: Sara Damiano --- ChangeLog.md | 7 ++++ src/VariableArray.cpp | 3 +- src/sensors/TEConnectivityMS5837.cpp | 49 +++++++++++++--------------- src/sensors/TIADS1x15.cpp | 8 ++--- 4 files changed, 35 insertions(+), 32 deletions(-) diff --git a/ChangeLog.md b/ChangeLog.md index 4193acc17..bd7839888 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -159,6 +159,13 @@ This is *not* breaking because only AVR and SAMD processors were supported anywa #### New Sensors - **NEW SENSOR** Added a new sensor for simple analog voltage using the built-in processor ADC +- **NEW SENSOR** Added support for the TE Connectivity (Meas Specialties) MS5837 + - This is the sensor embedded in the Blue Robotics Bar02 and Bar30 sensors + +#### New Features for Specific Sensors + +- **TIADS1x15** + - Added support for a secondary hardware I2C instance. #### Features for All Sensors diff --git a/src/VariableArray.cpp b/src/VariableArray.cpp index b494142f8..a4a201dda 100644 --- a/src/VariableArray.cpp +++ b/src/VariableArray.cpp @@ -738,8 +738,9 @@ bool VariableArray::checkVariableUUIDs(void) { } } } - if (success) + if (success) { PRINTOUT(F("All variable UUIDs appear to be correctly formed.\n")); + } // Print out all UUIDs to check for (uint8_t i = 0; i < _variableCount; i++) { if (arrayOfVars[i]->getVarUUID() != nullptr && diff --git a/src/sensors/TEConnectivityMS5837.cpp b/src/sensors/TEConnectivityMS5837.cpp index 8edf47952..b4163b3ea 100644 --- a/src/sensors/TEConnectivityMS5837.cpp +++ b/src/sensors/TEConnectivityMS5837.cpp @@ -11,36 +11,36 @@ #include "TEConnectivityMS5837.h" -// Primary implementation constructor using type-safe enum +// Primary implementation constructor using uint8_t model TEConnectivityMS5837::TEConnectivityMS5837(TwoWire* theI2C, int8_t powerPin, - MS5837Model model, - uint8_t measurementsToAverage, - uint16_t overSamplingRatio, - float fluidDensity, - float airPressure) + uint8_t model, + uint8_t measurementsToAverage, + uint16_t overSamplingRatio, + float fluidDensity, + float airPressure) : Sensor("TEConnectivityMS5837", MS5837_NUM_VARIABLES, MS5837_WARM_UP_TIME_MS, MS5837_STABILIZATION_TIME_MS, MS5837_MEASUREMENT_TIME_MS, powerPin, -1, measurementsToAverage, MS5837_INC_CALC_VARIABLES), MS5837_internal(theI2C), _wire(theI2C), - _model(static_cast(model)), + _model(model), _fluidDensity(fluidDensity), _airPressure(airPressure), _overSamplingRatio(overSamplingRatio) {} // Delegating constructors TEConnectivityMS5837::TEConnectivityMS5837(TwoWire* theI2C, int8_t powerPin, - uint8_t model, - uint8_t measurementsToAverage, - uint16_t overSamplingRatio, - float fluidDensity, - float airPressure) - : TEConnectivityMS5837(theI2C, powerPin, static_cast(model), + MS5837Model model, + uint8_t measurementsToAverage, + uint16_t overSamplingRatio, + float fluidDensity, + float airPressure) + : TEConnectivityMS5837(theI2C, powerPin, static_cast(model), measurementsToAverage, overSamplingRatio, fluidDensity, airPressure) {} -TEConnectivityMS5837::TEConnectivityMS5837(int8_t powerPin, MS5837Model model, +TEConnectivityMS5837::TEConnectivityMS5837(int8_t powerPin, uint8_t model, uint8_t measurementsToAverage, uint16_t overSamplingRatio, float fluidDensity, @@ -48,12 +48,12 @@ TEConnectivityMS5837::TEConnectivityMS5837(int8_t powerPin, MS5837Model model, : TEConnectivityMS5837(&Wire, powerPin, model, measurementsToAverage, overSamplingRatio, fluidDensity, airPressure) {} -TEConnectivityMS5837::TEConnectivityMS5837(int8_t powerPin, uint8_t model, +TEConnectivityMS5837::TEConnectivityMS5837(int8_t powerPin, MS5837Model model, uint8_t measurementsToAverage, uint16_t overSamplingRatio, float fluidDensity, float airPressure) - : TEConnectivityMS5837(&Wire, powerPin, static_cast(model), + : TEConnectivityMS5837(&Wire, powerPin, static_cast(model), measurementsToAverage, overSamplingRatio, fluidDensity, airPressure) {} @@ -62,17 +62,12 @@ TEConnectivityMS5837::~TEConnectivityMS5837() {} String TEConnectivityMS5837::getSensorName(void) { - String modelStr = F("TEConnectivityMS5837_"); - switch (_model) { - case static_cast(MS5837Model::MS5837_02BA): - modelStr += F("02BA"); - break; - case static_cast(MS5837Model::MS5837_30BA): - modelStr += F("30BA"); - break; - case static_cast(MS5837Model::MS5803_01BA): - modelStr += F("01BA"); - break; + auto modelEnum = static_cast(_model); + String modelStr = F("TEConnectivityMS5837_"); + switch (modelEnum) { + case MS5837Model::MS5837_02BA: modelStr += F("02BA"); break; + case MS5837Model::MS5837_30BA: modelStr += F("30BA"); break; + case MS5837Model::MS5803_01BA: modelStr += F("01BA"); break; default: modelStr += F("Unknown"); break; } return modelStr; diff --git a/src/sensors/TIADS1x15.cpp b/src/sensors/TIADS1x15.cpp index 7aa83a6b5..e151085ae 100644 --- a/src/sensors/TIADS1x15.cpp +++ b/src/sensors/TIADS1x15.cpp @@ -115,8 +115,8 @@ bool TIADS1x15Base::readVoltageSingleEnded(int8_t analogChannel, // Use the per-instance ADS driver (gain configured in constructor) // Verify I2C connectivity with a lightweight probe - Wire.beginTransmission(_i2cAddress); - if (Wire.endTransmission() != 0) { + _wire->beginTransmission(_i2cAddress); + if (_wire->endTransmission() != 0) { MS_DBG(F(" I2C communication failed at 0x"), String(_i2cAddress, HEX)); return false; } @@ -182,8 +182,8 @@ bool TIADS1x15Base::readVoltageDifferential(int8_t analogChannel, // Use the per-instance ADS driver (configured in constructor) // Verify I2C connectivity with a lightweight probe - Wire.beginTransmission(_i2cAddress); - if (Wire.endTransmission() != 0) { + _wire->beginTransmission(_i2cAddress); + if (_wire->endTransmission() != 0) { MS_DBG(F(" I2C communication failed at 0x"), String(_i2cAddress, HEX)); return false; } From 8d2b9d2257d80f9931eade60c05a313c7e1ebbda Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Fri, 27 Feb 2026 19:14:17 -0500 Subject: [PATCH 374/533] Some fixes and formatting Signed-off-by: Sara Damiano --- ChangeLog.md | 2 +- docs/Further-Reading/Sleep-Configurations.md | 4 +-- examples/EnviroDIY_Monitoring_Kit/ReadMe.md | 6 ++--- .../DRWI_CitizenScience/DRWI_2G/ReadMe.md | 4 +-- .../DRWI_NoCellular/ReadMe.md | 4 +-- examples/baro_rho_correction/ReadMe.md | 4 +-- examples/logging_to_MMW/ReadMe.md | 4 +-- src/SensorBase.cpp | 27 ++++++++++++++++--- src/WatchDogs/WatchDogSAMD.cpp | 4 +-- src/modems/DigiXBeeCellularTransparent.cpp | 2 +- src/modems/DigiXBeeWifi.cpp | 4 +-- .../MonitorMyWatershedPublisher.cpp | 7 +++++ src/sensors/MeaSpecMS5803.cpp | 3 ++- src/sensors/TIADS1x15.cpp | 7 ++--- src/sensors/TIINA219.cpp | 5 +++- src/sensors/TurnerTurbidityPlus.h | 3 ++- 16 files changed, 61 insertions(+), 29 deletions(-) diff --git a/ChangeLog.md b/ChangeLog.md index 4193acc17..540376cbd 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -290,7 +290,7 @@ If no epoch start is given, it is assumed to be UNIX (January 1, 1970). - The supported epochs are given in the enum epochStart. - Storing _buttonPinMode internally. - Added a single define (`MS_OUTPUT`) to use for all outputs from ModularSensors. -- Added support for sending printouts and debugging to two different serial ports. This is useful for devices (like SAMD) that use a built in USB serial port which is turned off when the device sleeps. If `MS_2ND_OUTPUT` is defined, output will go to *both* `MS_2ND_OUTPUT` and to `MS_OUTPUT`. +- Added support for sending printouts and debugging to two different serial ports. This is useful for devices (like SAMD) that use a built-in USB serial port which is turned off when the device sleeps. If `MS_2ND_OUTPUT` is defined, output will go to *both* `MS_2ND_OUTPUT` and to `MS_OUTPUT`. - Added example code for flashing boards with a neo-pixel in the menu example. - **NEW SENSOR** Added support for [Geolux HydroCam](https://www.geolux-radars.com/hydrocam) - **NEW SENSOR** Added support for [ANB Sensors pH Sensors](https://www.anbsensors.com/) diff --git a/docs/Further-Reading/Sleep-Configurations.md b/docs/Further-Reading/Sleep-Configurations.md index 48c3d8fcc..3be758d1f 100644 --- a/docs/Further-Reading/Sleep-Configurations.md +++ b/docs/Further-Reading/Sleep-Configurations.md @@ -236,7 +236,7 @@ See [The SAMD clock file](@ref samd51_clock_other_libraries) for a list of which After completing the [steps for putting all boards to sleep](#steps-for-putting-all-boards-to-sleep), SAMD51 boards finish their bedtime routine with these steps: -- Detach any USB devices (ie, the built in USB drivers for communication with a PC) +- Detach any USB devices (ie, the built-in USB drivers for communication with a PC) - This is skipped if the TinyUSB library is called for some reason. - Force all pins except the RTC wake and button pins to go to minimum power draw levels (tri-state) - Configure GCLK7 to be disconnected from an oscillator source. @@ -285,7 +285,7 @@ The pin configurations for the SAMD21 are identical to those described above for After completing the [steps for putting all boards to sleep](#steps-for-putting-all-boards-to-sleep), SAMD21 boards finish their bedtime routine with these steps: -- Detach any USB devices (ie, the built in USB drivers for communication with a PC) +- Detach any USB devices (ie, the built-in USB drivers for communication with a PC) - This is skipped if the TinyUSB library is called for some reason. - Force all pins except the RTC wake and button pins to go to minimum power draw levels (tri-state) - Wait for all serial ports to finish transmitting diff --git a/examples/EnviroDIY_Monitoring_Kit/ReadMe.md b/examples/EnviroDIY_Monitoring_Kit/ReadMe.md index 086c866cc..14a56b092 100644 --- a/examples/EnviroDIY_Monitoring_Kit/ReadMe.md +++ b/examples/EnviroDIY_Monitoring_Kit/ReadMe.md @@ -40,7 +40,7 @@ _______ - [Set the logger ID](#set-the-logger-id) - [Set the logging interval](#set-the-logging-interval) - [Set the time zone](#set-the-time-zone) - - [Set the universally unique identifiers (UUID) for each variable](#set-the-universally-unique-identifiers-uuid-for-each-variable) + - [Set the universally unique identifiers (UUIDs) for each variable](#set-the-universally-unique-identifiers-uuids-for-each-variable) - [Upload!](#upload) @@ -87,7 +87,7 @@ In the configuration section, select no more than one of the "bee" types that yo #### Add Connection Info -Replace `YourAPN` or `YourWiFiSSID` and `YourWiFiPassword` with the appropriate APN or SSID and password for your network. +Replace `YourAPN` or both `YourWiFiSSID` and `YourWiFiPassword` with the appropriate APN or SSID and password for your network. Your APN is assigned by your SIM card provider. If you are using a Hologram SIM card (recommended with the kit) the APN is `hologram`. @@ -144,7 +144,7 @@ Please use standard time! const int8_t timeZone = -5; // Eastern Standard Time ``` -### Set the universally unique identifiers (UUID) for each variable +### Set the universally unique identifiers (UUIDs) for each variable - Go back to the web page for your site on [Monitor My Watershed](http://monitormywatershed.org/) - Find and click the white "View Token UUID List" button above the small map on your site page. diff --git a/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_2G/ReadMe.md b/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_2G/ReadMe.md index 294a67313..80f555223 100644 --- a/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_2G/ReadMe.md +++ b/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_2G/ReadMe.md @@ -23,7 +23,7 @@ _______ - [Prepare and set up PlatformIO](#prepare-and-set-up-platformio) - [Set the logger ID](#set-the-logger-id) - [Set the calibration coefficients for the Campbell OBS3+](#set-the-calibration-coefficients-for-the-campbell-obs3) - - [Set the universally unique identifiers (UUID) for each variable](#set-the-universally-unique-identifiers-uuid-for-each-variable) + - [Set the universally unique identifiers (UUIDs) for each variable](#set-the-universally-unique-identifiers-uuids-for-each-variable) - [Upload!](#upload) @@ -89,7 +89,7 @@ const float OBSHigh_C = 0.000E+00; // "C" value [*high* range] CampbellOBS3 osb3high(OBS3Power, OBSHighADSChannel, OBSHigh_A, OBSHigh_B, OBSHigh_C, ADSi2c_addr, OBS3numberReadings); ``` -### Set the universally unique identifiers (UUID) for each variable +### Set the universally unique identifiers (UUIDs) for each variable - Go back to the web page for your site on [Monitor My Watershed](https://monitormywatershed.org) - Find and click the white "View Token UUID List" button above the small map on your site page diff --git a/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_NoCellular/ReadMe.md b/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_NoCellular/ReadMe.md index 88c1d534d..39e790782 100644 --- a/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_NoCellular/ReadMe.md +++ b/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_NoCellular/ReadMe.md @@ -28,7 +28,7 @@ _______ - [Prepare and set up PlatformIO](#prepare-and-set-up-platformio) - [Set the logger ID](#set-the-logger-id) - [Set the calibration coefficients for the Campbell OBS3+](#set-the-calibration-coefficients-for-the-campbell-obs3) - - [Set the universally unique identifiers (UUID) for each variable](#set-the-universally-unique-identifiers-uuid-for-each-variable) + - [Set the universally unique identifiers (UUIDs) for each variable](#set-the-universally-unique-identifiers-uuids-for-each-variable) - [Upload!](#upload) @@ -94,7 +94,7 @@ const float OBSHigh_C = 0.000E+00; // "C" value [*high* range] CampbellOBS3 osb3high(OBS3Power, OBSHighADSChannel, OBSHigh_A, OBSHigh_B, OBSHigh_C, ADSi2c_addr, OBS3numberReadings); ``` -### Set the universally unique identifiers (UUID) for each variable +### Set the universally unique identifiers (UUIDs) for each variable - Go back to the web page for your site on [Monitor My Watershed](https://monitormywatershed.org) - Find and click the white "View Token UUID List" button above the small map on your site page diff --git a/examples/baro_rho_correction/ReadMe.md b/examples/baro_rho_correction/ReadMe.md index fad6bb7dd..4674d360e 100644 --- a/examples/baro_rho_correction/ReadMe.md +++ b/examples/baro_rho_correction/ReadMe.md @@ -19,7 +19,7 @@ _______ - [To Use this Example](#to-use-this-example) - [Prepare and set up PlatformIO](#prepare-and-set-up-platformio) - [Set the logger ID](#set-the-logger-id) - - [Set the universally unique identifiers (UUID) for each variable](#set-the-universally-unique-identifiers-uuid-for-each-variable) + - [Set the universally unique identifiers (UUIDs) for each variable](#set-the-universally-unique-identifiers-uuids-for-each-variable) - [Upload!](#upload) @@ -54,7 +54,7 @@ _______ const char *LoggerID = "YourLoggerID"; ``` -### Set the universally unique identifiers (UUID) for each variable +### Set the universally unique identifiers (UUIDs) for each variable - Go back to the web page for your site on [Monitor My Watershed](https://monitormywatershed.org) - For each variable, find the dummy UUID (`"12345678-abcd-1234-ef00-1234567890ab"`) and replace it with the real UUID for the variable. diff --git a/examples/logging_to_MMW/ReadMe.md b/examples/logging_to_MMW/ReadMe.md index 5ff0e7f57..95e4f7f73 100644 --- a/examples/logging_to_MMW/ReadMe.md +++ b/examples/logging_to_MMW/ReadMe.md @@ -21,7 +21,7 @@ _______ - [To Use this Example](#to-use-this-example) - [Prepare and set up PlatformIO](#prepare-and-set-up-platformio) - [Set the logger ID](#set-the-logger-id) - - [Set the universally unique identifiers (UUID) for each variable](#set-the-universally-unique-identifiers-uuid-for-each-variable) + - [Set the universally unique identifiers (UUIDs) for each variable](#set-the-universally-unique-identifiers-uuids-for-each-variable) - [Upload!](#upload) @@ -56,7 +56,7 @@ _______ const char *LoggerID = "YourLoggerID"; ``` -### Set the universally unique identifiers (UUID) for each variable +### Set the universally unique identifiers (UUIDs) for each variable - Go back to the web page for your site on [Monitor My Watershed](https://monitormywatershed.org) - For each variable, find the dummy UUID (`"12345678-abcd-1234-ef00-1234567890ab"`) and replace it with the real UUID for the variable. diff --git a/src/SensorBase.cpp b/src/SensorBase.cpp index af14ea69a..91398c73e 100644 --- a/src/SensorBase.cpp +++ b/src/SensorBase.cpp @@ -515,14 +515,33 @@ bool Sensor::update(void) { // Wait for the sensor to stabilize waitForStability(); - // loop through as many measurements as requested - for (uint8_t j = 0; j < _measurementsToAverage; j++) { + // loop through until we have the requested number of successful + // measurements + while (_measurementAttemptsCompleted < _measurementsToAverage) { // start a measurement - ret_val &= startSingleMeasurement(); + bool measurementStarted = startSingleMeasurement(); + if (!measurementStarted) { + ret_val = false; + // Use bumpMeasurementAttemptCount to track failed attempts + if (!bumpMeasurementAttemptCount(false)) { + // If we've exhausted retries for this measurement, break + break; + } + continue; // Try again if retries are available + } + // wait for the measurement to finish waitForMeasurementCompletion(); + // get the measurement result - ret_val &= addSingleMeasurementResult(); + bool measurementSuccessful = addSingleMeasurementResult(); + ret_val &= measurementSuccessful; + + // Use bumpMeasurementAttemptCount to handle retry logic + if (!bumpMeasurementAttemptCount(measurementSuccessful)) { + // If we've exhausted retries and still failed, break + if (!measurementSuccessful) { break; } + } } averageMeasurements(); diff --git a/src/WatchDogs/WatchDogSAMD.cpp b/src/WatchDogs/WatchDogSAMD.cpp index 96068e631..01a02778c 100644 --- a/src/WatchDogs/WatchDogSAMD.cpp +++ b/src/WatchDogs/WatchDogSAMD.cpp @@ -120,8 +120,8 @@ void extendedWatchDogSAMD::enableWatchDog() { // before the interrupt is generated, relative to the start of the watchdog // time-out period. This must be less than the size of the watchdog period // or the interrupt will not be generated. - // Use the maximum offset for the longest time before the interrupt in normal - // mode. + // Use the maximum offset for the longest time before the interrupt in + // normal mode. // This is irrelevant in windowed mode. // 0xA = 8192 clock cycles @ 1024hz = 8 seconds diff --git a/src/modems/DigiXBeeCellularTransparent.cpp b/src/modems/DigiXBeeCellularTransparent.cpp index 0ea54307c..1590d1ee4 100644 --- a/src/modems/DigiXBeeCellularTransparent.cpp +++ b/src/modems/DigiXBeeCellularTransparent.cpp @@ -218,7 +218,7 @@ uint32_t DigiXBeeCellularTransparent::getNISTTime(void) { /* This is the IP address of time-e-wwv.nist.gov */ /* XBee's address lookup falters on time.nist.gov */ - IPAddress ip(132, 163, 97, 6); + IPAddress ip(132, 163, 97, 6); TinyGsmXBee::GsmClientXBee gsmClient( gsmModem); /*create client, default mux*/ connectionMade = gsmClient.connect(ip, 37, 15); diff --git a/src/modems/DigiXBeeWifi.cpp b/src/modems/DigiXBeeWifi.cpp index 3988e6e99..949413be4 100644 --- a/src/modems/DigiXBeeWifi.cpp +++ b/src/modems/DigiXBeeWifi.cpp @@ -354,8 +354,8 @@ void DigiXBeeWifi::disconnectInternet(void) { // localhost IP For A XBee S6B bug, then force restart. TinyGsmXBee::GsmClientXBee gsmClient( gsmModem); // need to create again to force close - String oldRemoteIp = gsmClient.remoteIP(); - IPAddress newHostIp = IPAddress(127, 0, 0, 1); // localhost + String oldRemoteIp = gsmClient.remoteIP(); + IPAddress newHostIp = IPAddress(127, 0, 0, 1); // localhost gsmClient.connect(newHostIp, 80); MS_DBG(gsmModem.getBeeName(), oldRemoteIp, F("disconnectInternet set to"), gsmClient.remoteIP()); diff --git a/src/publishers/MonitorMyWatershedPublisher.cpp b/src/publishers/MonitorMyWatershedPublisher.cpp index aa7068b51..551116eeb 100644 --- a/src/publishers/MonitorMyWatershedPublisher.cpp +++ b/src/publishers/MonitorMyWatershedPublisher.cpp @@ -331,6 +331,13 @@ int16_t MonitorMyWatershedPublisher::flushDataBuffer(Client* outClient) { return 0; } + // Check for valid client before attempting connection + if (outClient == nullptr) { + PRINTOUT(F("No client available for publishing data to Monitor My " + "Watershed!")); + return 0; + } + // Open a TCP/IP connection to Monitor My Watershed MS_DBG(F("Connecting client")); MS_START_DEBUG_TIMER; diff --git a/src/sensors/MeaSpecMS5803.cpp b/src/sensors/MeaSpecMS5803.cpp index b66026b55..ef07d37a4 100644 --- a/src/sensors/MeaSpecMS5803.cpp +++ b/src/sensors/MeaSpecMS5803.cpp @@ -80,7 +80,8 @@ bool MeaSpecMS5803::addSingleMeasurementResult(void) { // Temperature Range is -40°C to +85°C // Pressure returns 0 when disconnected, which is highly unlikely to be // a real value. - // Pressure range depends on the model; validation uses _maxPressure * 1000.0 + // Pressure range depends on the model; validation uses _maxPressure * + // 1000.0 verifyAndAddMeasurementResult(MS5803_TEMP_VAR_NUM, temp); verifyAndAddMeasurementResult(MS5803_PRESSURE_VAR_NUM, press); success = true; diff --git a/src/sensors/TIADS1x15.cpp b/src/sensors/TIADS1x15.cpp index 6f4bbdbbb..491d34b19 100644 --- a/src/sensors/TIADS1x15.cpp +++ b/src/sensors/TIADS1x15.cpp @@ -311,10 +311,11 @@ float TIADS1x15Base::calculateAnalogResolutionVolts(void) { if (effectiveFullScale > 5.5f) { effectiveFullScale = 5.5f; } // Calculate the total number of ADC codes - uint32_t totalCodes = 1UL << resolutionBits; // 2^resolutionBits + // For single-ended measurements, only positive codes are used: 2^(N-1) + uint32_t totalCodes = 1UL << (resolutionBits - 1); - // Voltage resolution is the effective full scale range divided by total - // codes + // Voltage resolution is the effective full scale range divided by positive + // code count float resolutionVolts = effectiveFullScale / static_cast(totalCodes); MS_DBG(F("ADS resolution calculation:")); diff --git a/src/sensors/TIINA219.cpp b/src/sensors/TIINA219.cpp index 76d0f367e..2f167e912 100644 --- a/src/sensors/TIINA219.cpp +++ b/src/sensors/TIINA219.cpp @@ -17,6 +17,7 @@ TIINA219::TIINA219(TwoWire* theI2C, int8_t powerPin, uint8_t i2cAddressHex, : Sensor("TIINA219", INA219_NUM_VARIABLES, INA219_WARM_UP_TIME_MS, INA219_STABILIZATION_TIME_MS, INA219_MEASUREMENT_TIME_MS, powerPin, -1, measurementsToAverage), + ina219_phy(i2cAddressHex), _i2cAddressHex(i2cAddressHex), _i2c(theI2C) {} TIINA219::TIINA219(int8_t powerPin, uint8_t i2cAddressHex, @@ -24,6 +25,7 @@ TIINA219::TIINA219(int8_t powerPin, uint8_t i2cAddressHex, : Sensor("TIINA219", INA219_NUM_VARIABLES, INA219_WARM_UP_TIME_MS, INA219_STABILIZATION_TIME_MS, INA219_MEASUREMENT_TIME_MS, powerPin, -1, measurementsToAverage, INA219_INC_CALC_VARIABLES), + ina219_phy(i2cAddressHex), _i2cAddressHex(i2cAddressHex), _i2c(&Wire) {} // Destructor @@ -39,7 +41,8 @@ String TIINA219::getSensorLocation(void) { bool TIINA219::setup(void) { bool wasOn; - bool setupSuccess = Sensor::setup(); // this will set pin modes and the setup status bit + bool setupSuccess = + Sensor::setup(); // this will set pin modes and the setup status bit // This sensor needs power for setup! delay(10); diff --git a/src/sensors/TurnerTurbidityPlus.h b/src/sensors/TurnerTurbidityPlus.h index 0415977da..757f6bdff 100644 --- a/src/sensors/TurnerTurbidityPlus.h +++ b/src/sensors/TurnerTurbidityPlus.h @@ -108,7 +108,8 @@ class AnalogVoltageBase; #endif #if !defined(TURBIDITY_PLUS_CALIBRATION_EPSILON) || defined(DOXYGEN) /** - * @brief Epsilon value for calibration validation to detect invalid calibration curves + * @brief Epsilon value for calibration validation to detect invalid calibration + * curves */ #define TURBIDITY_PLUS_CALIBRATION_EPSILON 1e-4f #endif From 3e84f3e2bf35cee6cb69176ef177b4280034eeca Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Fri, 27 Feb 2026 19:19:20 -0500 Subject: [PATCH 375/533] Step down version until Adafruit creates a release Signed-off-by: Sara Damiano --- continuous_integration/dependencies.json | 4 ++-- docs/For-Developers/Developer-Setup.md | 2 +- library.json | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/continuous_integration/dependencies.json b/continuous_integration/dependencies.json index cec68ebdf..d193955a1 100644 --- a/continuous_integration/dependencies.json +++ b/continuous_integration/dependencies.json @@ -162,7 +162,7 @@ "owner": "adafruit", "library id": "19", "url": "https://github.com/adafruit/DHT-sensor-library", - "version": "~1.4.7", + "version": "~1.4.6", "note": "AOSong DHT Sensor Library by Adafruit", "authors": [ "Adafruit" @@ -387,4 +387,4 @@ "note": "Used for debugging modem streams and duplicating primary output stream" } ] -} \ No newline at end of file +} diff --git a/docs/For-Developers/Developer-Setup.md b/docs/For-Developers/Developer-Setup.md index 6286fa2fc..aefbe6f8a 100644 --- a/docs/For-Developers/Developer-Setup.md +++ b/docs/For-Developers/Developer-Setup.md @@ -133,7 +133,7 @@ lib_deps = adafruit/Adafruit AM2315@^2.2.3 adafruit/Adafruit BME280 Library@^2.3.0 MartinL1/BMP388_DEV@^1.0.11 - adafruit/DHT sensor library@^1.4.7 + adafruit/DHT sensor library@^1.4.6 adafruit/Adafruit INA219@^1.2.3 adafruit/Adafruit MPL115A2@^2.0.2 adafruit/Adafruit SHT4x Library@^1.0.5 diff --git a/library.json b/library.json index a51ea34b7..1ecff04dd 100644 --- a/library.json +++ b/library.json @@ -192,7 +192,7 @@ "owner": "adafruit", "library id": "19", "url": "https://github.com/adafruit/DHT-sensor-library", - "version": "~1.4.7", + "version": "~1.4.6", "note": "AOSong DHT Sensor Library by Adafruit", "authors": ["Adafruit"], "frameworks": "arduino" From 12bb263afda6c881c5ae04473a935255f851c7ba Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Fri, 27 Feb 2026 19:28:49 -0500 Subject: [PATCH 376/533] Null checks on wire Signed-off-by: Sara Damiano --- README.md | 2 +- src/ModSensorConfig.h | 1 + src/sensors/AOSongAM2315.cpp | 2 +- src/sensors/AtlasParent.cpp | 2 +- src/sensors/BoschBME280.cpp | 2 +- src/sensors/FreescaleMPL115A2.cpp | 2 +- src/sensors/PaleoTerraRedox.cpp | 2 +- src/sensors/RainCounterI2C.cpp | 2 +- src/sensors/SensirionSHT4x.cpp | 2 +- src/sensors/TEConnectivityMS5837.cpp | 4 ++-- src/sensors/TEConnectivityMS5837.h | 4 ++-- src/sensors/TIADS1x15.cpp | 2 +- src/sensors/TIINA219.cpp | 2 +- 13 files changed, 15 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 2dafba915..fb7682cbb 100644 --- a/README.md +++ b/README.md @@ -156,7 +156,7 @@ Feel free to open issues about any bugs you find or any sensors you would like t If you would like to directly help with the coding development of the library, there are some [tips and instructions here](https://envirodiy.github.io/ModularSensors/page_developer_setup.html) on how to set up PlatformIO so you can fork the library and test programs while in the library repo. Please *take time to familiarize yourself with the [terminology, classes and data structures](https://envirodiy.github.io/ModularSensors/page_library_terminology.html) this library uses*. -This library is built to fully take advantage of Object Oriented Programming (OOP) approaches and is larger and more complicated than many Arduino libraries. +This library is built to fully take advantage of Object-Oriented Programming (OOP) approaches and is larger and more complicated than many Arduino libraries. There is doxygen-created documentation on our [github pages](https://envirodiy.github.io/ModularSensors/index.html) and an *enormous* number of comments and debugging printouts in the code itself to help you get going. ## License diff --git a/src/ModSensorConfig.h b/src/ModSensorConfig.h index 3d8250226..ef2d1ce5c 100644 --- a/src/ModSensorConfig.h +++ b/src/ModSensorConfig.h @@ -317,6 +317,7 @@ static_assert(MS_SEA_LEVEL_PRESSURE_HPA >= 800.0f && #define MAX_NUMBER_SENDERS 4 #endif // Static assert to validate MAX_NUMBER_SENDERS is reasonable +// Upper limit of 16 is set to constrain memory usage and array sizing static_assert(MAX_NUMBER_SENDERS >= 0 && MAX_NUMBER_SENDERS <= 16, "MAX_NUMBER_SENDERS must be between 0 and 16"); #ifndef MS_ALWAYS_FLUSH_PUBLISHERS diff --git a/src/sensors/AOSongAM2315.cpp b/src/sensors/AOSongAM2315.cpp index ba77fc5e1..89f9e1f8f 100644 --- a/src/sensors/AOSongAM2315.cpp +++ b/src/sensors/AOSongAM2315.cpp @@ -18,7 +18,7 @@ AOSongAM2315::AOSongAM2315(TwoWire* theI2C, int8_t powerPin, : Sensor("AOSongAM2315", AM2315_NUM_VARIABLES, AM2315_WARM_UP_TIME_MS, AM2315_STABILIZATION_TIME_MS, AM2315_MEASUREMENT_TIME_MS, powerPin, -1, measurementsToAverage), - _i2c(theI2C) { + _i2c(theI2C != nullptr ? theI2C : &Wire) { am2315ptr = new Adafruit_AM2315(_i2c); } AOSongAM2315::AOSongAM2315(int8_t powerPin, uint8_t measurementsToAverage) diff --git a/src/sensors/AtlasParent.cpp b/src/sensors/AtlasParent.cpp index 418051608..942256009 100644 --- a/src/sensors/AtlasParent.cpp +++ b/src/sensors/AtlasParent.cpp @@ -24,7 +24,7 @@ AtlasParent::AtlasParent(TwoWire* theI2C, int8_t powerPin, stabilizationTime_ms, measurementTime_ms, powerPin, -1, measurementsToAverage, incCalcValues), _i2cAddressHex(i2cAddressHex), - _i2c(theI2C) {} + _i2c(theI2C != nullptr ? theI2C : &Wire) {} AtlasParent::AtlasParent(int8_t powerPin, uint8_t i2cAddressHex, uint8_t measurementsToAverage, const char* sensorName, const uint8_t totalReturnedValues, diff --git a/src/sensors/BoschBME280.cpp b/src/sensors/BoschBME280.cpp index 51dbb8d53..12410cd41 100644 --- a/src/sensors/BoschBME280.cpp +++ b/src/sensors/BoschBME280.cpp @@ -18,7 +18,7 @@ BoschBME280::BoschBME280(TwoWire* theI2C, int8_t powerPin, BME280_STABILIZATION_TIME_MS, BME280_MEASUREMENT_TIME_MS, powerPin, -1, measurementsToAverage, BME280_INC_CALC_VARIABLES), _i2cAddressHex(i2cAddressHex), - _i2c(theI2C) {} + _i2c(theI2C != nullptr ? theI2C : &Wire) {} BoschBME280::BoschBME280(int8_t powerPin, uint8_t i2cAddressHex, uint8_t measurementsToAverage) diff --git a/src/sensors/FreescaleMPL115A2.cpp b/src/sensors/FreescaleMPL115A2.cpp index a2aba9106..f81daefc7 100644 --- a/src/sensors/FreescaleMPL115A2.cpp +++ b/src/sensors/FreescaleMPL115A2.cpp @@ -19,7 +19,7 @@ FreescaleMPL115A2::FreescaleMPL115A2(TwoWire* theI2C, int8_t powerPin, : Sensor("FreescaleMPL115A2", MPL115A2_NUM_VARIABLES, MPL115A2_WARM_UP_TIME_MS, MPL115A2_STABILIZATION_TIME_MS, MPL115A2_MEASUREMENT_TIME_MS, powerPin, -1, measurementsToAverage), - _i2c(theI2C) {} + _i2c(theI2C != nullptr ? theI2C : &Wire) {} FreescaleMPL115A2::FreescaleMPL115A2(int8_t powerPin, uint8_t measurementsToAverage) : Sensor("FreescaleMPL115A2", MPL115A2_NUM_VARIABLES, diff --git a/src/sensors/PaleoTerraRedox.cpp b/src/sensors/PaleoTerraRedox.cpp index 1119b57e5..1e24c5ba2 100644 --- a/src/sensors/PaleoTerraRedox.cpp +++ b/src/sensors/PaleoTerraRedox.cpp @@ -45,7 +45,7 @@ PaleoTerraRedox::PaleoTerraRedox(TwoWire* theI2C, int8_t powerPin, PTR_STABILIZATION_TIME_MS, PTR_MEASUREMENT_TIME_MS, powerPin, -1, measurementsToAverage), _i2cAddressHex(i2cAddressHex), - _i2c(theI2C) {} + _i2c(theI2C != nullptr ? theI2C : &Wire) {} PaleoTerraRedox::PaleoTerraRedox(int8_t powerPin, uint8_t i2cAddressHex, uint8_t measurementsToAverage) : Sensor("PaleoTerraRedox", PTR_NUM_VARIABLES, PTR_WARM_UP_TIME_MS, diff --git a/src/sensors/RainCounterI2C.cpp b/src/sensors/RainCounterI2C.cpp index 88a2ed47a..92fe769e3 100644 --- a/src/sensors/RainCounterI2C.cpp +++ b/src/sensors/RainCounterI2C.cpp @@ -40,7 +40,7 @@ RainCounterI2C::RainCounterI2C(TwoWire* theI2C, uint8_t i2cAddressHex, 1), _rainPerTip(rainPerTip), _i2cAddressHex(i2cAddressHex), - _i2c(theI2C) {} + _i2c(theI2C != nullptr ? theI2C : &Wire) {} RainCounterI2C::RainCounterI2C(uint8_t i2cAddressHex, float rainPerTip) : Sensor("RainCounterI2C", BUCKET_NUM_VARIABLES, BUCKET_WARM_UP_TIME_MS, BUCKET_STABILIZATION_TIME_MS, BUCKET_MEASUREMENT_TIME_MS, -1, -1, diff --git a/src/sensors/SensirionSHT4x.cpp b/src/sensors/SensirionSHT4x.cpp index fe052d85e..b4eef9ab7 100644 --- a/src/sensors/SensirionSHT4x.cpp +++ b/src/sensors/SensirionSHT4x.cpp @@ -18,7 +18,7 @@ SensirionSHT4x::SensirionSHT4x(TwoWire* theI2C, int8_t powerPin, bool useHeater, SHT4X_STABILIZATION_TIME_MS, SHT4X_MEASUREMENT_TIME_MS, powerPin, -1, measurementsToAverage), _useHeater(useHeater), - _i2c(theI2C) {} + _i2c(theI2C != nullptr ? theI2C : &Wire) {} SensirionSHT4x::SensirionSHT4x(int8_t powerPin, bool useHeater, uint8_t measurementsToAverage) : Sensor("SensirionSHT4x", SHT4X_NUM_VARIABLES, SHT4X_WARM_UP_TIME_MS, diff --git a/src/sensors/TEConnectivityMS5837.cpp b/src/sensors/TEConnectivityMS5837.cpp index b4163b3ea..d9e887252 100644 --- a/src/sensors/TEConnectivityMS5837.cpp +++ b/src/sensors/TEConnectivityMS5837.cpp @@ -22,8 +22,8 @@ TEConnectivityMS5837::TEConnectivityMS5837(TwoWire* theI2C, int8_t powerPin, MS5837_WARM_UP_TIME_MS, MS5837_STABILIZATION_TIME_MS, MS5837_MEASUREMENT_TIME_MS, powerPin, -1, measurementsToAverage, MS5837_INC_CALC_VARIABLES), - MS5837_internal(theI2C), - _wire(theI2C), + MS5837_internal(theI2C != nullptr ? theI2C : &Wire), + _wire(theI2C != nullptr ? theI2C : &Wire), _model(model), _fluidDensity(fluidDensity), _airPressure(airPressure), diff --git a/src/sensors/TEConnectivityMS5837.h b/src/sensors/TEConnectivityMS5837.h index 292508d39..13af9ff05 100644 --- a/src/sensors/TEConnectivityMS5837.h +++ b/src/sensors/TEConnectivityMS5837.h @@ -42,8 +42,8 @@ * If you are also using one of those sensors, make sure that the address for * that sensor does not conflict with the address of this sensor. * - * @note Neither secondary hardware nor software I2C is supported for the MS5837. - * Only the primary hardware I2C defined in the Arduino core can be used. + * @note This sensor supports both primary and secondary hardware I2C instances + * through TwoWire* constructor parameters. Software I2C is not supported. * * The lower level communication between the mcu and the MS5837 is handled by the * [Rob Tillaart MS5837 library](https://github.com/RobTillaart/MS5837). diff --git a/src/sensors/TIADS1x15.cpp b/src/sensors/TIADS1x15.cpp index e151085ae..4f69dd711 100644 --- a/src/sensors/TIADS1x15.cpp +++ b/src/sensors/TIADS1x15.cpp @@ -25,7 +25,7 @@ TIADS1x15Base::TIADS1x15Base(TwoWire* theI2C, float voltageMultiplier, adsGain_t adsGain, uint8_t i2cAddress, float adsSupplyVoltage, uint16_t adsDataRate) : AnalogVoltageBase(voltageMultiplier, adsSupplyVoltage), - _wire(theI2C), + _wire(theI2C != nullptr ? theI2C : &Wire), _i2cAddress(i2cAddress), _adsGain(adsGain), _adsDataRate(adsDataRate) { diff --git a/src/sensors/TIINA219.cpp b/src/sensors/TIINA219.cpp index 76d0f367e..374248aab 100644 --- a/src/sensors/TIINA219.cpp +++ b/src/sensors/TIINA219.cpp @@ -18,7 +18,7 @@ TIINA219::TIINA219(TwoWire* theI2C, int8_t powerPin, uint8_t i2cAddressHex, INA219_STABILIZATION_TIME_MS, INA219_MEASUREMENT_TIME_MS, powerPin, -1, measurementsToAverage), _i2cAddressHex(i2cAddressHex), - _i2c(theI2C) {} + _i2c(theI2C != nullptr ? theI2C : &Wire) {} TIINA219::TIINA219(int8_t powerPin, uint8_t i2cAddressHex, uint8_t measurementsToAverage) : Sensor("TIINA219", INA219_NUM_VARIABLES, INA219_WARM_UP_TIME_MS, From 4e026c10c19118e79f86e5346511e8b37d5d080d Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Fri, 27 Feb 2026 19:46:56 -0500 Subject: [PATCH 377/533] AI suggested fixes Signed-off-by: Sara Damiano --- src/sensors/TEConnectivityMS5837.cpp | 7 ++++--- src/sensors/TEConnectivityMS5837.h | 5 +++-- src/sensors/TIADS1x15.cpp | 17 +++++++++++------ src/sensors/TIADS1x15.h | 7 +++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/src/sensors/TEConnectivityMS5837.cpp b/src/sensors/TEConnectivityMS5837.cpp index d9e887252..391544930 100644 --- a/src/sensors/TEConnectivityMS5837.cpp +++ b/src/sensors/TEConnectivityMS5837.cpp @@ -156,7 +156,7 @@ bool TEConnectivityMS5837::addSingleMeasurementResult(void) { // Validate configuration parameters if (_fluidDensity <= 0.0 || _fluidDensity > 5.0) { MS_DBG(F("Invalid fluid density:"), _fluidDensity, - F("g/cm³. Expected range: 0.0-5.0")); + F("g/cm³. Expected range: (0.0-5.0]")); return bumpMeasurementAttemptCount(false); } if (_airPressure < 500.0 || _airPressure > 1200.0) { @@ -188,8 +188,9 @@ bool TEConnectivityMS5837::addSingleMeasurementResult(void) { case 4096: OSR = 12; break; case 8192: OSR = 13; break; default: - OSR = 12; - break; // fallback, though validation above should prevent this + MS_DBG(F("Unexpected _overSamplingRatio value:"), + _overSamplingRatio, F(". Unable to map to OSR value.")); + return bumpMeasurementAttemptCount(false); } MS_DBG(F(" Requesting OSR:"), OSR, F("for oversampling ratio:"), _overSamplingRatio); diff --git a/src/sensors/TEConnectivityMS5837.h b/src/sensors/TEConnectivityMS5837.h index 13af9ff05..cd154c3f7 100644 --- a/src/sensors/TEConnectivityMS5837.h +++ b/src/sensors/TEConnectivityMS5837.h @@ -6,7 +6,8 @@ * @author Sara Geleskie Damiano * * @brief Contains the TEConnectivityMS5837 sensor subclass and the variable - * subclasses TEConnectivityMS5837_Temp and TEConnectivityMS5837_Pressure. + * subclasses TEConnectivityMS5837_Temp, TEConnectivityMS5837_Pressure, + * TEConnectivityMS5837_Depth, and TEConnectivityMS5837_Altitude. * * These are for the TE Connectivity MS5837 pressure sensor. This sensor is * commonly deployed in Blue Robotics Bar02/Bar30 pressure sensors for @@ -436,7 +437,7 @@ class TEConnectivityMS5837 : public Sensor { /** * @brief Destroy the TEConnectivityMS5837 object */ - ~TEConnectivityMS5837(); + ~TEConnectivityMS5837() = default; /** * @brief Do any one-time preparations needed before the sensor will be able diff --git a/src/sensors/TIADS1x15.cpp b/src/sensors/TIADS1x15.cpp index 4f69dd711..5a995e387 100644 --- a/src/sensors/TIADS1x15.cpp +++ b/src/sensors/TIADS1x15.cpp @@ -115,9 +115,7 @@ bool TIADS1x15Base::readVoltageSingleEnded(int8_t analogChannel, // Use the per-instance ADS driver (gain configured in constructor) // Verify I2C connectivity with a lightweight probe - _wire->beginTransmission(_i2cAddress); - if (_wire->endTransmission() != 0) { - MS_DBG(F(" I2C communication failed at 0x"), String(_i2cAddress, HEX)); + if (!probeI2C()) { return false; } @@ -182,9 +180,7 @@ bool TIADS1x15Base::readVoltageDifferential(int8_t analogChannel, // Use the per-instance ADS driver (configured in constructor) // Verify I2C connectivity with a lightweight probe - _wire->beginTransmission(_i2cAddress); - if (_wire->endTransmission() != 0) { - MS_DBG(F(" I2C communication failed at 0x"), String(_i2cAddress, HEX)); + if (!probeI2C()) { return false; } @@ -341,6 +337,15 @@ float TIADS1x15Base::calculateAnalogResolutionVolts(void) { return resolutionVolts; } +bool TIADS1x15Base::probeI2C(void) { + _wire->beginTransmission(_i2cAddress); + if (_wire->endTransmission() != 0) { + MS_DBG(F(" I2C communication failed at 0x"), String(_i2cAddress, HEX)); + return false; + } + return true; +} + // ============================================================================ // TIADS1x15 Functions // ============================================================================ diff --git a/src/sensors/TIADS1x15.h b/src/sensors/TIADS1x15.h index c154e5d6b..8594f5c02 100644 --- a/src/sensors/TIADS1x15.h +++ b/src/sensors/TIADS1x15.h @@ -457,6 +457,13 @@ class TIADS1x15Base : public AnalogVoltageBase { #else Adafruit_ADS1015 _ads; // 12-bit version #endif + + /** + * @brief Probe I2C connectivity to the ADS device + * + * @return true if device responds, false if communication failed + */ + bool probeI2C(void); }; /* clang-format off */ From 8df32e20b210ba8a83c44036a9fd7a5cf1ba1e9e Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Fri, 27 Feb 2026 22:14:18 -0500 Subject: [PATCH 378/533] Update examples/ReadMe.md Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --- examples/ReadMe.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/ReadMe.md b/examples/ReadMe.md index 2c5cabef1..7fc16d983 100644 --- a/examples/ReadMe.md +++ b/examples/ReadMe.md @@ -165,7 +165,7 @@ The exclusion of the modem and publisher simplifies the code from the other DRWI #### DRWI CitSci (2G) The 2G DRWI Citizen Science example uses the sensors and equipment found on older stations used in the DRWI Citizen Science project before 2020. -The 2G GPRSbee boards no longer function in the USA, so this code should not be used and is only provided to archival and reference purposes. +The 2G GPRSbee boards no longer function in the USA, so this code should not be used and is only provided for archival and reference purposes. It includes a Meter Hydros 21 (formerly know as a Decagon CTD), a Campbell OBS3+, and a Sodaq GPRSBee for communication. The results are saved to the SD card and posted to Monitor My Watershed. The only difference between this and the other cellular DRWI examples is the type of modem used. From 81c97b20510734c4834f581c751e7d8d00a192bb Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Fri, 27 Feb 2026 22:17:06 -0500 Subject: [PATCH 379/533] Update src/sensors/ProcessorAnalog.cpp Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --- src/sensors/ProcessorAnalog.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/sensors/ProcessorAnalog.cpp b/src/sensors/ProcessorAnalog.cpp index 0f4e15748..627137848 100644 --- a/src/sensors/ProcessorAnalog.cpp +++ b/src/sensors/ProcessorAnalog.cpp @@ -123,8 +123,8 @@ float ProcessorAnalogBase::calculateAnalogResolutionVolts(void) { // ProcessorAnalog Functions // ============================================================================ -// The constructor - need the power pin, the data pin, the voltage divider -// value, and the operating voltage +// The constructor - need the power pin, the data pin, and the number of +// measurements to average, with an optional external analog reader ProcessorAnalog::ProcessorAnalog(int8_t powerPin, int8_t dataPin, uint8_t measurementsToAverage, ProcessorAnalogBase* analogVoltageReader) From 5b56a33c85c58975ba4305c36e24a9a89fdc9289 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Fri, 27 Feb 2026 22:17:41 -0500 Subject: [PATCH 380/533] Update src/sensors/AnalogVoltageBase.h Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --- src/sensors/AnalogVoltageBase.h | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/sensors/AnalogVoltageBase.h b/src/sensors/AnalogVoltageBase.h index 57d063013..db8605889 100644 --- a/src/sensors/AnalogVoltageBase.h +++ b/src/sensors/AnalogVoltageBase.h @@ -26,9 +26,6 @@ // Include the known processors for default values #include "KnownProcessors.h" -// Include math library for log10 function -#include - // Define the print label[s] for the debugger #ifdef MS_ANALOGVOLTAGEBASE_DEBUG #define MS_DEBUGGING_STD "AnalogVoltageBase" From 1e92944445330f3bc4a7dcd3f4745bc63b5d0b49 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Fri, 27 Feb 2026 22:24:41 -0500 Subject: [PATCH 381/533] Update TEConnectivityMS5837.h --- src/sensors/TEConnectivityMS5837.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sensors/TEConnectivityMS5837.h b/src/sensors/TEConnectivityMS5837.h index cd154c3f7..8b5a3d037 100644 --- a/src/sensors/TEConnectivityMS5837.h +++ b/src/sensors/TEConnectivityMS5837.h @@ -165,7 +165,7 @@ static_assert( * The number of variables that can be returned by the MS5837 */ /**@{*/ -/// @brief Sensor::_numReturnedValues; the MS5837 can report 2 values. +/// @brief Sensor::_numReturnedValues; the MS5837 can report 4 values. #define MS5837_NUM_VARIABLES 4 /// @brief Sensor::_incCalcValues; we calculate depth and altitude values. #define MS5837_INC_CALC_VARIABLES 2 From 8abbe83a441a31a7f0dfb523f833c0b243797956 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Fri, 27 Feb 2026 22:26:30 -0500 Subject: [PATCH 382/533] Update TEConnectivityMS5837.h --- src/sensors/TEConnectivityMS5837.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sensors/TEConnectivityMS5837.h b/src/sensors/TEConnectivityMS5837.h index 8b5a3d037..ec13b9354 100644 --- a/src/sensors/TEConnectivityMS5837.h +++ b/src/sensors/TEConnectivityMS5837.h @@ -437,7 +437,7 @@ class TEConnectivityMS5837 : public Sensor { /** * @brief Destroy the TEConnectivityMS5837 object */ - ~TEConnectivityMS5837() = default; + ~TEConnectivityMS5837(); /** * @brief Do any one-time preparations needed before the sensor will be able From 8cec3b29c86494b0a032cc76a7ecdfdb7a86bc22 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Fri, 27 Feb 2026 22:31:14 -0500 Subject: [PATCH 383/533] Update VariableArray.h to fix typo --- src/VariableArray.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/VariableArray.h b/src/VariableArray.h index 62c369bed..a7c44b40c 100644 --- a/src/VariableArray.h +++ b/src/VariableArray.h @@ -304,7 +304,7 @@ class VariableArray { */ bool isLastVarFromSensor(int arrayIndex); /** - * @brief Check that all variable have valid UUIDs, if they are assigned + * @brief Check that all variables have valid UUIDs, if they are assigned * * @return True if all variables have valid UUIDs. * From c85a29a094fa4aecf03d22c929e66cecca9029ad Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Fri, 27 Feb 2026 22:51:35 -0500 Subject: [PATCH 384/533] Update src/sensors/ProcessorStats.cpp Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --- src/sensors/ProcessorStats.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/sensors/ProcessorStats.cpp b/src/sensors/ProcessorStats.cpp index d05c040f2..51a153672 100644 --- a/src/sensors/ProcessorStats.cpp +++ b/src/sensors/ProcessorStats.cpp @@ -50,10 +50,13 @@ ProcessorStats::ProcessorStats(const char* version, _batteryMultiplier = -1; } #elif defined(ARDUINO_SODAQ_AUTONOMO) - if (_version != nullptr && strcmp(_version, "v0.1") == 0) - _batteryPin = 48; - else - _batteryPin = 33; + if (_version != nullptr) { + if (strcmp(_version, "v0.1") == 0) { + _batteryPin = 48; + } else { + _batteryPin = 33; + } + } #endif } From 2aadc43c015827fb0e689160ee3bf318f47f705d Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Fri, 27 Feb 2026 22:54:27 -0500 Subject: [PATCH 385/533] Update GeoluxHydroCam.cpp --- src/sensors/GeoluxHydroCam.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/sensors/GeoluxHydroCam.cpp b/src/sensors/GeoluxHydroCam.cpp index b725c8cd3..93bd82145 100644 --- a/src/sensors/GeoluxHydroCam.cpp +++ b/src/sensors/GeoluxHydroCam.cpp @@ -198,8 +198,8 @@ bool GeoluxHydroCam::addSingleMeasurementResult(void) { int32_t image_size = _camera.getImageSize(); MS_DBG(F("Completed image is"), image_size, F("bytes.")); - if (image_size == 0) { - MS_DBG(F("Camera returned an image size of 0, which means the snapshot " + if (image_size <= 0) { + MS_DBG(F("Camera returned an image size <= 0, which means the snapshot " "failed!")); return bumpMeasurementAttemptCount(false); } From 001f05615525c79dda0383d100c83717f738ced4 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Mon, 2 Mar 2026 10:26:15 -0500 Subject: [PATCH 386/533] Align runtime check with static assert Signed-off-by: Sara Damiano --- src/sensors/TEConnectivityMS5837.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/sensors/TEConnectivityMS5837.cpp b/src/sensors/TEConnectivityMS5837.cpp index 391544930..e9a175ec7 100644 --- a/src/sensors/TEConnectivityMS5837.cpp +++ b/src/sensors/TEConnectivityMS5837.cpp @@ -154,9 +154,9 @@ bool TEConnectivityMS5837::addSingleMeasurementResult(void) { } // Validate configuration parameters - if (_fluidDensity <= 0.0 || _fluidDensity > 5.0) { + if (_fluidDensity <= 0.1 || _fluidDensity > 5.0) { MS_DBG(F("Invalid fluid density:"), _fluidDensity, - F("g/cm³. Expected range: (0.0-5.0]")); + F("g/cm³. Expected range: (0.1-5.0]")); return bumpMeasurementAttemptCount(false); } if (_airPressure < 500.0 || _airPressure > 1200.0) { From 1269d8241545262158de4c2a01f8266be43338dd Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Mon, 2 Mar 2026 10:31:08 -0500 Subject: [PATCH 387/533] Document 8192 OSR Signed-off-by: Sara Damiano --- src/sensors/TEConnectivityMS5837.h | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/sensors/TEConnectivityMS5837.h b/src/sensors/TEConnectivityMS5837.h index ec13b9354..dc0e211cc 100644 --- a/src/sensors/TEConnectivityMS5837.h +++ b/src/sensors/TEConnectivityMS5837.h @@ -141,8 +141,10 @@ static_assert(MS5837_DEFAULT_FLUID_DENSITY > 0.1f && * * Higher oversampling ratios provide better resolution and noise reduction but * increase measurement time. Valid values are: 256, 512, 1024, 2048, 4096, - * 8192. Default is 4096 for good balance of accuracy and speed. This can be - * overridden at compile time with -D MS5837_DEFAULT_OVERSAMPLING_RATIO=value + * 8192. This can be overridden at compile time with + * `-D MS5837_DEFAULT_OVERSAMPLING_RATIO=value` + * + * @note The 13-bit (8192) sampling mode is not available on the MS5803. */ #define MS5837_DEFAULT_OVERSAMPLING_RATIO 4096 #endif @@ -185,8 +187,10 @@ static_assert( /** * @brief Sensor::_measurementTime_ms; the MS5837 takes 20ms to complete a * measurement. - * - Sensor takes about 0.5 / 1.1 / 2.1 / 4.1 / 8.22 ms to respond - * at oversampling ratios: 256 / 512 / 1024 / 2048 / 4096, respectively. + * - Sensor takes about 0.5 / 1.1 / 2.1 / 4.1 / 8.22 / 16.44 ms to respond + * at oversampling ratios: 256 / 512 / 1024 / 2048 / 4096 / 8192, respectively. + * + * @note The 13-bit (8192) sampling mode is not available on the MS5803. */ #define MS5837_MEASUREMENT_TIME_MS 20 /**@}*/ From 2b429fda6814753ab0dbe7fc51703c6094c22255 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Mon, 2 Mar 2026 10:57:28 -0500 Subject: [PATCH 388/533] Clamp, move non-functional define to config and give warning Signed-off-by: Sara Damiano --- src/ModSensorConfig.h | 12 +++++++++++ src/SensorBase.h | 4 ---- src/sensors/ANBpH.cpp | 39 ++++++++++++++++++++++-------------- src/sensors/KellerParent.cpp | 4 +--- 4 files changed, 37 insertions(+), 22 deletions(-) diff --git a/src/ModSensorConfig.h b/src/ModSensorConfig.h index f87d9c7cf..949c712e3 100644 --- a/src/ModSensorConfig.h +++ b/src/ModSensorConfig.h @@ -155,6 +155,18 @@ // GroPoint Profile GPLP-8 has 8 Moisture and 13 Temperature values #endif +#if 0 +#ifndef MS_NUMBER_SUPPORTED_POWER_PINS +/** + * @brief The maximum number of power pins the library can support for a single + * sensor. + * + * @warning There is currently no support for this functionality and changing this value will not do anything. This is a placeholder for possible. future functionality to support multiple power pins per sensor. + */ +#define MS_NUMBER_SUPPORTED_POWER_PINS 2 +#endif +#endif + //============================================================== // Analog voltage configuration //============================================================== diff --git a/src/SensorBase.h b/src/SensorBase.h index 4f4c04d09..a4396cfb7 100644 --- a/src/SensorBase.h +++ b/src/SensorBase.h @@ -43,10 +43,6 @@ // Include other in-library and external dependencies #include -/// @brief The maximum number of power pins the library can support for a single -/// sensor. -#define NUMBER_SUPPORTED_POWER_PINS 2 - class Variable; // Forward declaration class VariableArray; // Forward declaration diff --git a/src/sensors/ANBpH.cpp b/src/sensors/ANBpH.cpp index 90be38267..a5010bab5 100644 --- a/src/sensors/ANBpH.cpp +++ b/src/sensors/ANBpH.cpp @@ -20,7 +20,27 @@ ANBpH::ANBpH(byte modbusAddress, Stream* stream, int8_t powerPin, _anb_sensor(modbusAddress, stream, enablePin), _modbusAddress(modbusAddress), _stream(stream), - _loggingIntervalMinutes(loggingIntervalMinutes), + _loggingIntervalMinutes([powerPin, loggingIntervalMinutes]() -> int16_t { + // NOTE: These clamps are intentionally silent — Serial/MS_DBG is NOT + // safe to call during construction (the Serial object may not be + // initialized yet on Arduino targets). + // Validate and normalize loggingIntervalMinutes based on powerPin + if (powerPin != -1) { // Cycled power + if (loggingIntervalMinutes == 0) { + return 10; // Force to minimum for cycled power + } + return (loggingIntervalMinutes < 10) ? 10 + : (loggingIntervalMinutes > 240) ? 240 + : loggingIntervalMinutes; + } else { // Always-powered (powerPin == -1) + if (loggingIntervalMinutes == 0) { + return 0; // Allow 0 for always-on mode + } + return (loggingIntervalMinutes < 10) ? 10 + : (loggingIntervalMinutes > 240) ? 240 + : loggingIntervalMinutes; + } + }()), _RS485EnablePin(enablePin) { #ifdef MS_ANB_SENSORS_PH_DEBUG_DEEP _anb_sensor.setDebugStream(&MS_SERIAL_OUTPUT); @@ -28,23 +48,12 @@ ANBpH::ANBpH(byte modbusAddress, Stream* stream, int8_t powerPin, setSecondaryPowerPin(powerPin2); setAllowedMeasurementRetries(5); } +// Delegating constructor ANBpH::ANBpH(byte modbusAddress, Stream& stream, int8_t powerPin, int16_t loggingIntervalMinutes, int8_t powerPin2, int8_t enablePin, uint8_t measurementsToAverage) - : Sensor("ANBpHSensor", ANB_PH_NUM_VARIABLES, ANB_PH_WARM_UP_TIME_MS, - ANB_PH_STABILIZATION_TIME_MS, ANB_PH_2ND_VALUE_LOW_SALT, powerPin, - -1, measurementsToAverage, ANB_PH_INC_CALC_VARIABLES), - _anb_sensor(modbusAddress, stream, enablePin), - _modbusAddress(modbusAddress), - _stream(&stream), - _loggingIntervalMinutes(loggingIntervalMinutes), - _RS485EnablePin(enablePin) { -#ifdef MS_ANB_SENSORS_PH_DEBUG_DEEP - _anb_sensor.setDebugStream(&MS_SERIAL_OUTPUT); -#endif - setSecondaryPowerPin(powerPin2); - setAllowedMeasurementRetries(5); -} + : ANBpH(modbusAddress, &stream, powerPin, loggingIntervalMinutes, powerPin2, + enablePin, measurementsToAverage) {} // Destructor ANBpH::~ANBpH() {} diff --git a/src/sensors/KellerParent.cpp b/src/sensors/KellerParent.cpp index 8beab639a..2421d6929 100644 --- a/src/sensors/KellerParent.cpp +++ b/src/sensors/KellerParent.cpp @@ -121,9 +121,7 @@ bool KellerParent::addSingleMeasurementResult(void) { MS_DBG(F(" Temp_C:"), waterTemperatureC); MS_DBG(F(" Height_m:"), waterDepthM); - success &= (!isnan(waterPressureBar) && waterPressureBar != -9999 && - !isnan(waterTemperatureC) && waterTemperatureC != -9999 && - !isnan(waterDepthM) && waterDepthM != -9999); + success &= (!isnan(waterDepthM) && waterDepthM != -9999); if (success) { // Put values into the array From e4db6eb2f4d3a26b7aca4dd536362bc51b12761c Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Mon, 2 Mar 2026 14:29:42 -0500 Subject: [PATCH 389/533] Convert second and further constructors into delegating constructors where possible Signed-off-by: Sara Damiano --- ChangeLog.md | 1 + src/VariableArray.cpp | 5 +- src/VariableBase.cpp | 70 ++++++++++--------- src/dataPublisherBase.cpp | 8 +-- src/publishers/AWS_IoT_Publisher.cpp | 57 +++++++-------- src/publishers/DreamHostPublisher.cpp | 22 +++--- .../MonitorMyWatershedPublisher.cpp | 67 ++++++++---------- src/publishers/S3PresignedPublisher.cpp | 17 +++-- src/publishers/ThingSpeakPublisher.cpp | 38 +++++----- src/publishers/UbidotsPublisher.cpp | 27 +++---- src/sensors/AOSongAM2315.cpp | 12 ++-- src/sensors/AtlasParent.cpp | 9 ++- src/sensors/AtlasScientificCO2.cpp | 8 +-- src/sensors/AtlasScientificDO.cpp | 9 ++- src/sensors/AtlasScientificEC.cpp | 8 +-- src/sensors/BoschBME280.cpp | 9 +-- src/sensors/FreescaleMPL115A2.cpp | 10 ++- src/sensors/GroPointParent.cpp | 14 ++-- src/sensors/KellerParent.cpp | 13 ++-- src/sensors/MaxBotixSonar.cpp | 13 ++-- src/sensors/SDI12Sensors.cpp | 22 +++--- src/sensors/YosemitechParent.cpp | 14 ++-- 22 files changed, 213 insertions(+), 240 deletions(-) diff --git a/ChangeLog.md b/ChangeLog.md index 540376cbd..c3a921619 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -153,6 +153,7 @@ To achieve the same functionality as the old `updateAllSensors()` function (ie, - Moved the define for the default address used for a TI ADS from multiple individual files to the ModSensorConfig and renamed to `MS_DEFAULT_ADS1X15_ADDRESS`. - Within ModSensorConfig removed the default `MS_PROCESSOR_ADC_RESOLUTION` for all processors and clarified that the 12-bit default only applies to SAMD processors. This is *not* breaking because only AVR and SAMD processors were supported anyway. +- Converted as many duplicated constructors as possible into delegating constructors. ### Added diff --git a/src/VariableArray.cpp b/src/VariableArray.cpp index 6725293eb..a093d92e6 100644 --- a/src/VariableArray.cpp +++ b/src/VariableArray.cpp @@ -18,11 +18,10 @@ VariableArray::VariableArray(uint8_t variableCount, Variable* variableList[]) _variableCount(variableCount) { _sensorCount = getSensorCount(); } +// Delegating constructor VariableArray::VariableArray(uint8_t variableCount, Variable* variableList[], const char* uuids[]) - : arrayOfVars(variableList), - _variableCount(variableCount) { - _sensorCount = getSensorCount(); + : VariableArray(variableCount, variableList) { matchUUIDs(uuids); } diff --git a/src/VariableBase.cpp b/src/VariableBase.cpp index 12fdbdc08..3e4a59bb5 100644 --- a/src/VariableBase.cpp +++ b/src/VariableBase.cpp @@ -15,55 +15,46 @@ // The class and functions for interfacing with a specific variable. // ============================================================================ +// Primary constructors with UUID parameter // The constructor for a measured variable - that is, one whose values are // updated by a sensor. Variable::Variable(Sensor* parentSense, uint8_t sensorVarNum, uint8_t decimalResolution, const char* varName, const char* varUnit, const char* varCode, const char* uuid) - : _sensorVarNum(sensorVarNum) { - setVarUUID(uuid); - setVarCode(varCode); - setVarUnit(varUnit); - setVarName(varName); - setResolution(decimalResolution); - - attachSensor(parentSense); -} -Variable::Variable(uint8_t sensorVarNum, uint8_t decimalResolution, - const char* varName, const char* varUnit, - const char* varCode) - : _sensorVarNum(sensorVarNum) { - setVarCode(varCode); - setVarUnit(varUnit); - setVarName(varName); + : _sensorVarNum(sensorVarNum), isCalculated(false) { + if (uuid) setVarUUID(uuid); + if (varCode) setVarCode(varCode); + if (varUnit) setVarUnit(varUnit); + if (varName) setVarName(varName); setResolution(decimalResolution); + if (parentSense) attachSensor(parentSense); } - // The constructor for a calculated variable - that is, one whose value is // calculated by the calcFxn which returns a float. Variable::Variable(float (*calcFxn)(), uint8_t decimalResolution, const char* varName, const char* varUnit, const char* varCode, const char* uuid) - : isCalculated(true) { - setVarUUID(uuid); - setVarCode(varCode); - setVarUnit(varUnit); - setVarName(varName); + : isCalculated(calcFxn != nullptr), + _calcFxn(nullptr) { + if (uuid) setVarUUID(uuid); + if (varCode) setVarCode(varCode); + if (varUnit) setVarUnit(varUnit); + if (varName) setVarName(varName); setResolution(decimalResolution); - - setCalculation(calcFxn); + if (calcFxn) setCalculation(calcFxn); } + +// Delegating constructors +Variable::Variable(uint8_t sensorVarNum, uint8_t decimalResolution, + const char* varName, const char* varUnit, + const char* varCode) + : Variable(nullptr, sensorVarNum, decimalResolution, varName, varUnit, + varCode, nullptr) {} Variable::Variable(float (*calcFxn)(), uint8_t decimalResolution, const char* varName, const char* varUnit, const char* varCode) - : isCalculated(true) { - setVarCode(varCode); - setVarUnit(varUnit); - setVarName(varName); - setResolution(decimalResolution); - - setCalculation(calcFxn); + : Variable(calcFxn, decimalResolution, varName, varUnit, varCode, nullptr) { } // constructor with no arguments @@ -159,7 +150,8 @@ String Variable::getParentSensorNameAndLocation(void) { // This ties a calculated variable to its calculation function void Variable::setCalculation(float (*calcFxn)()) { - if (isCalculated) { _calcFxn = calcFxn; } + _calcFxn = calcFxn; + isCalculated = (calcFxn != nullptr); } @@ -255,10 +247,20 @@ float Variable::getValue(bool updateValue) { // different values each time - ie, the data on the CSV and each // publisher will report a different value. That is **NOT** the desired // behavior. Thus, we stash the value. - if (updateValue) _currentValue = _calcFxn(); + if (updateValue && _calcFxn != nullptr) { + _currentValue = _calcFxn(); + } else if (updateValue && _calcFxn == nullptr) { + // If no calculation function is set, return error value + _currentValue = -9999; + } return _currentValue; } else { - if (updateValue) parentSensor->update(); + if (updateValue && parentSensor != nullptr) { + parentSensor->update(); + } else if (updateValue && parentSensor == nullptr) { + // If no parent sensor is set, return error value + _currentValue = -9999; + } return _currentValue; } } diff --git a/src/dataPublisherBase.cpp b/src/dataPublisherBase.cpp index b58d8cc3a..7fd140eee 100644 --- a/src/dataPublisherBase.cpp +++ b/src/dataPublisherBase.cpp @@ -32,13 +32,11 @@ dataPublisher::dataPublisher(Logger& baseLogger, int sendEveryX) _baseModem = _baseLogger->registerDataPublisher(this); // register self with logger } +// Delegating constructor dataPublisher::dataPublisher(Logger& baseLogger, Client* inClient, int sendEveryX) - : _baseLogger(&baseLogger), - _inClient(inClient), - _sendEveryX(sendEveryX) { - _baseModem = - _baseLogger->registerDataPublisher(this); // register self with logger + : dataPublisher(baseLogger, sendEveryX) { + _inClient = inClient; } // Destructor dataPublisher::~dataPublisher() {} diff --git a/src/publishers/AWS_IoT_Publisher.cpp b/src/publishers/AWS_IoT_Publisher.cpp index b1ba88acb..12bff3da9 100644 --- a/src/publishers/AWS_IoT_Publisher.cpp +++ b/src/publishers/AWS_IoT_Publisher.cpp @@ -25,51 +25,52 @@ const char* AWS_IoT_Publisher::timestampTag = "\"timestamp\":\""; // Constructors -AWS_IoT_Publisher::AWS_IoT_Publisher() : dataPublisher() { - init(); -} -AWS_IoT_Publisher::AWS_IoT_Publisher(Logger& baseLogger, int sendEveryX) - : dataPublisher(baseLogger, sendEveryX) { - init(); -} -AWS_IoT_Publisher::AWS_IoT_Publisher(Logger& baseLogger, Client* inClient, - int sendEveryX) - : dataPublisher(baseLogger, inClient, sendEveryX) { - init(); -} +// Primary constructor - handles full initialization with all parameters AWS_IoT_Publisher::AWS_IoT_Publisher( Logger& baseLogger, const char* awsIoTEndpoint, const char* caCertName, const char* clientCertName, const char* clientKeyName, const char* samplingFeatureUUID, int sendEveryX) : dataPublisher(baseLogger, sendEveryX) { - setEndpoint(awsIoTEndpoint); - setCACertName(caCertName); - setClientCertName(clientCertName); - setClientKeyName(clientKeyName); - _baseLogger->setSamplingFeatureUUID(samplingFeatureUUID); + if (awsIoTEndpoint) setEndpoint(awsIoTEndpoint); + if (caCertName) setCACertName(caCertName); + if (clientCertName) setClientCertName(clientCertName); + if (clientKeyName) setClientKeyName(clientKeyName); + if (samplingFeatureUUID && _baseLogger) { + _baseLogger->setSamplingFeatureUUID(samplingFeatureUUID); + } init(); } + +// Delegating constructors +AWS_IoT_Publisher::AWS_IoT_Publisher() : dataPublisher() { + init(); +} +AWS_IoT_Publisher::AWS_IoT_Publisher(Logger& baseLogger, int sendEveryX) + : AWS_IoT_Publisher(baseLogger, nullptr, nullptr, nullptr, nullptr, nullptr, + sendEveryX) {} +AWS_IoT_Publisher::AWS_IoT_Publisher(Logger& baseLogger, Client* inClient, + int sendEveryX) + : AWS_IoT_Publisher(baseLogger, nullptr, nullptr, nullptr, nullptr, nullptr, + sendEveryX) { + if (inClient) _inClient = inClient; +} AWS_IoT_Publisher::AWS_IoT_Publisher(Logger& baseLogger, const char* awsIoTEndpoint, const char* caCertName, const char* clientCertName, const char* clientKeyName, int sendEveryX) - : dataPublisher(baseLogger, sendEveryX) { - setEndpoint(awsIoTEndpoint); - setCACertName(caCertName); - setClientCertName(clientCertName); - setClientKeyName(clientKeyName); - init(); -} + : AWS_IoT_Publisher(baseLogger, awsIoTEndpoint, caCertName, clientCertName, + clientKeyName, nullptr, sendEveryX) {} AWS_IoT_Publisher::AWS_IoT_Publisher(Logger& baseLogger, Client* inClient, const char* awsIoTEndpoint, const char* samplingFeatureUUID, int sendEveryX) - : dataPublisher(baseLogger, inClient, sendEveryX) { - setEndpoint(awsIoTEndpoint); - _baseLogger->setSamplingFeatureUUID(samplingFeatureUUID); - init(); + : AWS_IoT_Publisher(baseLogger, awsIoTEndpoint, nullptr, nullptr, nullptr, + samplingFeatureUUID, sendEveryX) { + if (inClient) _inClient = inClient; } + + void AWS_IoT_Publisher::init() { // Initialize the sub topics as null pointers for (uint8_t i = 0; i < MS_AWS_IOT_PUBLISHER_SUB_COUNT; i++) { diff --git a/src/publishers/DreamHostPublisher.cpp b/src/publishers/DreamHostPublisher.cpp index 9fe526fca..0eea325a4 100644 --- a/src/publishers/DreamHostPublisher.cpp +++ b/src/publishers/DreamHostPublisher.cpp @@ -22,24 +22,28 @@ const char* DreamHostPublisher::loggerTag = "?LoggerID="; const char* DreamHostPublisher::timestampTagDH = "&Loggertime="; // Constructors -DreamHostPublisher::DreamHostPublisher() : dataPublisher() {} - -DreamHostPublisher::DreamHostPublisher(Logger& baseLogger, int sendEveryX) - : dataPublisher(baseLogger, sendEveryX) {} - +// Primary constructor with Client parameter DreamHostPublisher::DreamHostPublisher(Logger& baseLogger, Client* inClient, int sendEveryX) : dataPublisher(baseLogger, inClient, sendEveryX) {} +// Default constructor (base class initialization) +DreamHostPublisher::DreamHostPublisher() : dataPublisher() {} + +// Delegating constructors +DreamHostPublisher::DreamHostPublisher(Logger& baseLogger, int sendEveryX) + : DreamHostPublisher(baseLogger, static_cast(nullptr), + sendEveryX) {} DreamHostPublisher::DreamHostPublisher(Logger& baseLogger, const char* dhUrl, int sendEveryX) - : dataPublisher(baseLogger, sendEveryX) { - setDreamHostPortalRX(dhUrl); + : DreamHostPublisher(baseLogger, static_cast(nullptr), + sendEveryX) { + if (dhUrl) setDreamHostPortalRX(dhUrl); } DreamHostPublisher::DreamHostPublisher(Logger& baseLogger, Client* inClient, const char* dhUrl, int sendEveryX) - : dataPublisher(baseLogger, inClient, sendEveryX) { - setDreamHostPortalRX(dhUrl); + : DreamHostPublisher(baseLogger, inClient, sendEveryX) { + if (dhUrl) setDreamHostPortalRX(dhUrl); } // Destructor DreamHostPublisher::~DreamHostPublisher() {} diff --git a/src/publishers/MonitorMyWatershedPublisher.cpp b/src/publishers/MonitorMyWatershedPublisher.cpp index 551116eeb..c6d00019d 100644 --- a/src/publishers/MonitorMyWatershedPublisher.cpp +++ b/src/publishers/MonitorMyWatershedPublisher.cpp @@ -31,69 +31,58 @@ const char* MonitorMyWatershedPublisher::timestampTag = "\",\"timestamp\":"; // Constructors -MonitorMyWatershedPublisher::MonitorMyWatershedPublisher() : dataPublisher() { - setHost("monitormywatershed.org"); - setPath("/api/data-stream/"); - setPort(80); -} +// Primary constructor with client MonitorMyWatershedPublisher::MonitorMyWatershedPublisher(Logger& baseLogger, + Client* inClient, int sendEveryX) - : dataPublisher(baseLogger, sendEveryX) { + : dataPublisher(baseLogger, inClient, sendEveryX) { _logBuffer.setNumVariables(_baseLogger->getArrayVarCount()); setHost("monitormywatershed.org"); setPath("/api/data-stream/"); setPort(80); } -MonitorMyWatershedPublisher::MonitorMyWatershedPublisher(Logger& baseLogger, - Client* inClient, - int sendEveryX) - : dataPublisher(baseLogger, inClient, sendEveryX) { - _logBuffer.setNumVariables(_baseLogger->getArrayVarCount()); + +// Delegating constructors +MonitorMyWatershedPublisher::MonitorMyWatershedPublisher() : dataPublisher() { + // NOTE: _logBuffer is not initialized here because _baseLogger is null + // Must call begin(Logger&, ...) before use to properly initialize + // _logBuffer setHost("monitormywatershed.org"); setPath("/api/data-stream/"); setPort(80); } +MonitorMyWatershedPublisher::MonitorMyWatershedPublisher(Logger& baseLogger, + int sendEveryX) + : MonitorMyWatershedPublisher(baseLogger, static_cast(nullptr), + sendEveryX) {} + MonitorMyWatershedPublisher::MonitorMyWatershedPublisher( Logger& baseLogger, const char* registrationToken, const char* samplingFeatureUUID, int sendEveryX) - : dataPublisher(baseLogger, sendEveryX) { - setToken(registrationToken); - _baseLogger->setSamplingFeatureUUID(samplingFeatureUUID); - _logBuffer.setNumVariables(_baseLogger->getArrayVarCount()); - setHost("monitormywatershed.org"); - setPath("/api/data-stream/"); - setPort(80); + : MonitorMyWatershedPublisher(baseLogger, static_cast(nullptr), + sendEveryX) { + if (registrationToken) setToken(registrationToken); + if (samplingFeatureUUID) + _baseLogger->setSamplingFeatureUUID(samplingFeatureUUID); } +// Delegating constructor MonitorMyWatershedPublisher::MonitorMyWatershedPublisher( Logger& baseLogger, const char* registrationToken, int sendEveryX) - : dataPublisher(baseLogger, sendEveryX) { - setToken(registrationToken); - _logBuffer.setNumVariables(_baseLogger->getArrayVarCount()); - setHost("monitormywatershed.org"); - setPath("/api/data-stream/"); - setPort(80); -} + : MonitorMyWatershedPublisher(baseLogger, registrationToken, nullptr, + sendEveryX) {} +// Delegating constructor MonitorMyWatershedPublisher::MonitorMyWatershedPublisher( Logger& baseLogger, Client* inClient, const char* registrationToken, const char* samplingFeatureUUID, int sendEveryX) - : dataPublisher(baseLogger, inClient, sendEveryX) { - setToken(registrationToken); - _baseLogger->setSamplingFeatureUUID(samplingFeatureUUID); - _logBuffer.setNumVariables(_baseLogger->getArrayVarCount()); - setHost("monitormywatershed.org"); - setPath("/api/data-stream/"); - setPort(80); + : MonitorMyWatershedPublisher(baseLogger, registrationToken, samplingFeatureUUID, sendEveryX) { + if (inClient) _inClient = inClient; } +// Delegating constructor MonitorMyWatershedPublisher::MonitorMyWatershedPublisher( Logger& baseLogger, Client* inClient, const char* registrationToken, int sendEveryX) - : dataPublisher(baseLogger, inClient, sendEveryX) { - setToken(registrationToken); - _logBuffer.setNumVariables(_baseLogger->getArrayVarCount()); - setHost("monitormywatershed.org"); - setPath("/api/data-stream/"); - setPort(80); -} + : MonitorMyWatershedPublisher(baseLogger, inClient, registrationToken, + nullptr, sendEveryX) {} // Destructor MonitorMyWatershedPublisher::~MonitorMyWatershedPublisher() {} diff --git a/src/publishers/S3PresignedPublisher.cpp b/src/publishers/S3PresignedPublisher.cpp index 060c66fb4..f473f771b 100644 --- a/src/publishers/S3PresignedPublisher.cpp +++ b/src/publishers/S3PresignedPublisher.cpp @@ -18,24 +18,27 @@ const char* S3PresignedPublisher::contentLengthHeader = "\r\nContent-Length: "; const char* S3PresignedPublisher::contentTypeHeader = "\r\nContent-Type: "; // Constructors -S3PresignedPublisher::S3PresignedPublisher() : dataPublisher() {} +// Primary constructor with all parameters S3PresignedPublisher::S3PresignedPublisher(Logger& baseLogger, const char* caCertName, String (*getUrlFxn)(String), String (*getFileNameFxn)(void), int sendEveryX) : dataPublisher(baseLogger, sendEveryX) { - setCACertName(caCertName); - setURLUpdateFunction(getUrlFxn); - setFileUpdateFunction(getFileNameFxn); + if (caCertName) setCACertName(caCertName); + if (getUrlFxn) setURLUpdateFunction(getUrlFxn); + if (getFileNameFxn) setFileUpdateFunction(getFileNameFxn); } + +// Delegating constructors +S3PresignedPublisher::S3PresignedPublisher() : dataPublisher() {} S3PresignedPublisher::S3PresignedPublisher(Logger& baseLogger, Client* inClient, String (*getUrlFxn)(String), String (*getFileNameFxn)(void), int sendEveryX) - : dataPublisher(baseLogger, inClient, sendEveryX) { - setURLUpdateFunction(getUrlFxn); - setFileUpdateFunction(getFileNameFxn); + : S3PresignedPublisher(baseLogger, static_cast(nullptr), + getUrlFxn, getFileNameFxn, sendEveryX) { + if (inClient) _inClient = inClient; } // Destructor S3PresignedPublisher::~S3PresignedPublisher() {} diff --git a/src/publishers/ThingSpeakPublisher.cpp b/src/publishers/ThingSpeakPublisher.cpp index a3c51b7a3..aa47b4faf 100644 --- a/src/publishers/ThingSpeakPublisher.cpp +++ b/src/publishers/ThingSpeakPublisher.cpp @@ -26,36 +26,40 @@ const int ThingSpeakPublisher::mqttPort = 1883; // Constructors -ThingSpeakPublisher::ThingSpeakPublisher() : dataPublisher() {} -ThingSpeakPublisher::ThingSpeakPublisher(Logger& baseLogger, int sendEveryX) - : dataPublisher(baseLogger, sendEveryX) {} -ThingSpeakPublisher::ThingSpeakPublisher(Logger& baseLogger, Client* inClient, - int sendEveryX) - : dataPublisher(baseLogger, inClient, sendEveryX) {} +// Primary constructor with all MQTT parameters and client ThingSpeakPublisher::ThingSpeakPublisher(Logger& baseLogger, const char* thingSpeakClientName, const char* thingSpeakMQTTUser, const char* thingSpeakMQTTPassword, const char* thingSpeakChannelID, - int sendEveryX) + Client* inClient, int sendEveryX) : dataPublisher(baseLogger, sendEveryX) { - setMQTTClient(thingSpeakClientName); - setUserName(thingSpeakMQTTUser); - setPassword(thingSpeakMQTTPassword); - setChannelID(thingSpeakChannelID); + if (thingSpeakClientName) setMQTTClient(thingSpeakClientName); + if (thingSpeakMQTTUser) setUserName(thingSpeakMQTTUser); + if (thingSpeakMQTTPassword) setPassword(thingSpeakMQTTPassword); + if (thingSpeakChannelID) setChannelID(thingSpeakChannelID); + if (inClient) _inClient = inClient; } + +// Delegating constructors +ThingSpeakPublisher::ThingSpeakPublisher() : dataPublisher() {} +ThingSpeakPublisher::ThingSpeakPublisher(Logger& baseLogger, int sendEveryX) + : ThingSpeakPublisher(baseLogger, nullptr, nullptr, nullptr, nullptr, + nullptr, sendEveryX) {} +ThingSpeakPublisher::ThingSpeakPublisher(Logger& baseLogger, Client* inClient, + int sendEveryX) + : ThingSpeakPublisher(baseLogger, nullptr, nullptr, nullptr, nullptr, + inClient, sendEveryX) {} +// Delegating constructor ThingSpeakPublisher::ThingSpeakPublisher(Logger& baseLogger, Client* inClient, const char* thingSpeakClientName, const char* thingSpeakMQTTUser, const char* thingSpeakMQTTPassword, const char* thingSpeakChannelID, int sendEveryX) - : dataPublisher(baseLogger, inClient, sendEveryX) { - setMQTTClient(thingSpeakClientName); - setUserName(thingSpeakMQTTUser); - setPassword(thingSpeakMQTTPassword); - setChannelID(thingSpeakChannelID); -} + : ThingSpeakPublisher(baseLogger, thingSpeakClientName, thingSpeakMQTTUser, + thingSpeakMQTTPassword, thingSpeakChannelID, inClient, + sendEveryX) {} // Destructor ThingSpeakPublisher::~ThingSpeakPublisher() {} diff --git a/src/publishers/UbidotsPublisher.cpp b/src/publishers/UbidotsPublisher.cpp index 286995e7c..471f9ee25 100644 --- a/src/publishers/UbidotsPublisher.cpp +++ b/src/publishers/UbidotsPublisher.cpp @@ -32,27 +32,30 @@ const char* UbidotsPublisher::payload = "{"; // Constructors -UbidotsPublisher::UbidotsPublisher() : dataPublisher() {} -UbidotsPublisher::UbidotsPublisher(Logger& baseLogger, int sendEveryX) - : dataPublisher(baseLogger, sendEveryX) {} -UbidotsPublisher::UbidotsPublisher(Logger& baseLogger, Client* inClient, - int sendEveryX) - : dataPublisher(baseLogger, inClient, sendEveryX) {} +// Primary constructor with authentication parameters UbidotsPublisher::UbidotsPublisher(Logger& baseLogger, const char* authenticationToken, const char* deviceID, int sendEveryX) : dataPublisher(baseLogger, sendEveryX) { - setToken(authenticationToken); - _baseLogger->setSamplingFeatureUUID(deviceID); + if (authenticationToken) setToken(authenticationToken); + if (deviceID) _baseLogger->setSamplingFeatureUUID(deviceID); MS_DBG(F("dataPublisher object created")); } + +// Delegating constructors +UbidotsPublisher::UbidotsPublisher() : dataPublisher() {} +UbidotsPublisher::UbidotsPublisher(Logger& baseLogger, int sendEveryX) + : UbidotsPublisher(baseLogger, nullptr, nullptr, sendEveryX) {} +UbidotsPublisher::UbidotsPublisher(Logger& baseLogger, Client* inClient, + int sendEveryX) + : UbidotsPublisher(baseLogger, nullptr, nullptr, sendEveryX) { + if (inClient) _inClient = inClient; +} UbidotsPublisher::UbidotsPublisher(Logger& baseLogger, Client* inClient, const char* authenticationToken, const char* deviceID, int sendEveryX) - : dataPublisher(baseLogger, inClient, sendEveryX) { - setToken(authenticationToken); - _baseLogger->setSamplingFeatureUUID(deviceID); - MS_DBG(F("dataPublisher object created")); + : UbidotsPublisher(baseLogger, authenticationToken, deviceID, sendEveryX) { + if (inClient) _inClient = inClient; } // Destructor UbidotsPublisher::~UbidotsPublisher() {} diff --git a/src/sensors/AOSongAM2315.cpp b/src/sensors/AOSongAM2315.cpp index ba77fc5e1..c9e476e0c 100644 --- a/src/sensors/AOSongAM2315.cpp +++ b/src/sensors/AOSongAM2315.cpp @@ -21,14 +21,14 @@ AOSongAM2315::AOSongAM2315(TwoWire* theI2C, int8_t powerPin, _i2c(theI2C) { am2315ptr = new Adafruit_AM2315(_i2c); } +// Delegating constructor AOSongAM2315::AOSongAM2315(int8_t powerPin, uint8_t measurementsToAverage) - : Sensor("AOSongAM2315", AM2315_NUM_VARIABLES, AM2315_WARM_UP_TIME_MS, - AM2315_STABILIZATION_TIME_MS, AM2315_MEASUREMENT_TIME_MS, powerPin, - -1, measurementsToAverage, AM2315_INC_CALC_VARIABLES), - _i2c(&Wire) { - am2315ptr = new Adafruit_AM2315(_i2c); + : AOSongAM2315(&Wire, powerPin, measurementsToAverage) {} + +// Destructor +AOSongAM2315::~AOSongAM2315() { + delete am2315ptr; } -AOSongAM2315::~AOSongAM2315() {} String AOSongAM2315::getSensorLocation(void) { diff --git a/src/sensors/AtlasParent.cpp b/src/sensors/AtlasParent.cpp index 418051608..e54b7584e 100644 --- a/src/sensors/AtlasParent.cpp +++ b/src/sensors/AtlasParent.cpp @@ -25,16 +25,15 @@ AtlasParent::AtlasParent(TwoWire* theI2C, int8_t powerPin, measurementsToAverage, incCalcValues), _i2cAddressHex(i2cAddressHex), _i2c(theI2C) {} +// Delegating constructor AtlasParent::AtlasParent(int8_t powerPin, uint8_t i2cAddressHex, uint8_t measurementsToAverage, const char* sensorName, const uint8_t totalReturnedValues, uint32_t warmUpTime_ms, uint32_t stabilizationTime_ms, uint32_t measurementTime_ms, uint8_t incCalcValues) - : Sensor(sensorName, totalReturnedValues, warmUpTime_ms, - stabilizationTime_ms, measurementTime_ms, powerPin, -1, - measurementsToAverage, incCalcValues), - _i2cAddressHex(i2cAddressHex), - _i2c(&Wire) {} + : AtlasParent(&Wire, powerPin, i2cAddressHex, measurementsToAverage, + sensorName, totalReturnedValues, warmUpTime_ms, + stabilizationTime_ms, measurementTime_ms, incCalcValues) {} // Destructors AtlasParent::~AtlasParent() {} diff --git a/src/sensors/AtlasScientificCO2.cpp b/src/sensors/AtlasScientificCO2.cpp index 15c734717..31cfba78c 100644 --- a/src/sensors/AtlasScientificCO2.cpp +++ b/src/sensors/AtlasScientificCO2.cpp @@ -21,13 +21,11 @@ AtlasScientificCO2::AtlasScientificCO2(TwoWire* theI2C, int8_t powerPin, ATLAS_CO2_WARM_UP_TIME_MS, ATLAS_CO2_STABILIZATION_TIME_MS, ATLAS_CO2_MEASUREMENT_TIME_MS, ATLAS_CO2_INC_CALC_VARIABLES) { } +// Delegating constructor AtlasScientificCO2::AtlasScientificCO2(int8_t powerPin, uint8_t i2cAddressHex, uint8_t measurementsToAverage) - : AtlasParent(powerPin, i2cAddressHex, measurementsToAverage, - "AtlasScientificCO2", ATLAS_CO2_NUM_VARIABLES, - ATLAS_CO2_WARM_UP_TIME_MS, ATLAS_CO2_STABILIZATION_TIME_MS, - ATLAS_CO2_MEASUREMENT_TIME_MS, ATLAS_CO2_INC_CALC_VARIABLES) { -} + : AtlasScientificCO2(&Wire, powerPin, i2cAddressHex, + measurementsToAverage) {} // Destructor AtlasScientificCO2::~AtlasScientificCO2() {} diff --git a/src/sensors/AtlasScientificDO.cpp b/src/sensors/AtlasScientificDO.cpp index 1611bc95a..cfe9e3f68 100644 --- a/src/sensors/AtlasScientificDO.cpp +++ b/src/sensors/AtlasScientificDO.cpp @@ -6,7 +6,7 @@ * @author Initial development for Atlas Sensors was done by Adam Gold * Files were edited by Sara Damiano * - * @brief Implements the AtlasScientificCO2 class. + * @brief Implements the AtlasScientificDO class. */ // Included Dependencies @@ -20,12 +20,11 @@ AtlasScientificDO::AtlasScientificDO(TwoWire* theI2C, int8_t powerPin, "AtlasScientificDO", ATLAS_DO_NUM_VARIABLES, ATLAS_DO_WARM_UP_TIME_MS, ATLAS_DO_STABILIZATION_TIME_MS, ATLAS_DO_MEASUREMENT_TIME_MS, ATLAS_DO_INC_CALC_VARIABLES) {} +// Delegating constructor AtlasScientificDO::AtlasScientificDO(int8_t powerPin, uint8_t i2cAddressHex, uint8_t measurementsToAverage) - : AtlasParent(powerPin, i2cAddressHex, measurementsToAverage, - "AtlasScientificDO", ATLAS_DO_NUM_VARIABLES, - ATLAS_DO_WARM_UP_TIME_MS, ATLAS_DO_STABILIZATION_TIME_MS, - ATLAS_DO_MEASUREMENT_TIME_MS, ATLAS_DO_INC_CALC_VARIABLES) {} + : AtlasScientificDO(&Wire, powerPin, i2cAddressHex, measurementsToAverage) { +} // Destructor AtlasScientificDO::~AtlasScientificDO() {} diff --git a/src/sensors/AtlasScientificEC.cpp b/src/sensors/AtlasScientificEC.cpp index f3d2f6311..00b8c5423 100644 --- a/src/sensors/AtlasScientificEC.cpp +++ b/src/sensors/AtlasScientificEC.cpp @@ -21,13 +21,11 @@ AtlasScientificEC::AtlasScientificEC(TwoWire* theI2C, int8_t powerPin, ATLAS_COND_WARM_UP_TIME_MS, ATLAS_COND_STABILIZATION_TIME_MS, ATLAS_COND_MEASUREMENT_TIME_MS, ATLAS_COND_INC_CALC_VARIABLES) {} +// Delegating constructor AtlasScientificEC::AtlasScientificEC(int8_t powerPin, uint8_t i2cAddressHex, uint8_t measurementsToAverage) - : AtlasParent(powerPin, i2cAddressHex, measurementsToAverage, - "AtlasScientificEC", ATLAS_COND_NUM_VARIABLES, - ATLAS_COND_WARM_UP_TIME_MS, ATLAS_COND_STABILIZATION_TIME_MS, - ATLAS_COND_MEASUREMENT_TIME_MS, - ATLAS_COND_INC_CALC_VARIABLES) {} + : AtlasScientificEC(&Wire, powerPin, i2cAddressHex, measurementsToAverage) { +} // Destructor AtlasScientificEC::~AtlasScientificEC() {} diff --git a/src/sensors/BoschBME280.cpp b/src/sensors/BoschBME280.cpp index 1680b73da..c79fd354f 100644 --- a/src/sensors/BoschBME280.cpp +++ b/src/sensors/BoschBME280.cpp @@ -16,17 +16,14 @@ BoschBME280::BoschBME280(TwoWire* theI2C, int8_t powerPin, uint8_t i2cAddressHex, uint8_t measurementsToAverage) : Sensor("BoschBME280", BME280_NUM_VARIABLES, BME280_WARM_UP_TIME_MS, BME280_STABILIZATION_TIME_MS, BME280_MEASUREMENT_TIME_MS, powerPin, - -1, measurementsToAverage), + -1, measurementsToAverage, BME280_INC_CALC_VARIABLES), _i2cAddressHex(i2cAddressHex), _i2c(theI2C) {} +// Delegating constructor BoschBME280::BoschBME280(int8_t powerPin, uint8_t i2cAddressHex, uint8_t measurementsToAverage) - : Sensor("BoschBME280", BME280_NUM_VARIABLES, BME280_WARM_UP_TIME_MS, - BME280_STABILIZATION_TIME_MS, BME280_MEASUREMENT_TIME_MS, powerPin, - -1, measurementsToAverage, BME280_INC_CALC_VARIABLES), - _i2cAddressHex(i2cAddressHex), - _i2c(&Wire) {} + : BoschBME280(&Wire, powerPin, i2cAddressHex, measurementsToAverage) {} // Destructor BoschBME280::~BoschBME280() {} diff --git a/src/sensors/FreescaleMPL115A2.cpp b/src/sensors/FreescaleMPL115A2.cpp index a2aba9106..0a0cfc09e 100644 --- a/src/sensors/FreescaleMPL115A2.cpp +++ b/src/sensors/FreescaleMPL115A2.cpp @@ -18,15 +18,13 @@ FreescaleMPL115A2::FreescaleMPL115A2(TwoWire* theI2C, int8_t powerPin, uint8_t measurementsToAverage) : Sensor("FreescaleMPL115A2", MPL115A2_NUM_VARIABLES, MPL115A2_WARM_UP_TIME_MS, MPL115A2_STABILIZATION_TIME_MS, - MPL115A2_MEASUREMENT_TIME_MS, powerPin, -1, measurementsToAverage), + MPL115A2_MEASUREMENT_TIME_MS, powerPin, -1, measurementsToAverage, + MPL115A2_INC_CALC_VARIABLES), _i2c(theI2C) {} +// Delegating constructor FreescaleMPL115A2::FreescaleMPL115A2(int8_t powerPin, uint8_t measurementsToAverage) - : Sensor("FreescaleMPL115A2", MPL115A2_NUM_VARIABLES, - MPL115A2_WARM_UP_TIME_MS, MPL115A2_STABILIZATION_TIME_MS, - MPL115A2_MEASUREMENT_TIME_MS, powerPin, -1, measurementsToAverage, - MPL115A2_INC_CALC_VARIABLES), - _i2c(&Wire) {} + : FreescaleMPL115A2(&Wire, powerPin, measurementsToAverage) {} // Destructor FreescaleMPL115A2::~FreescaleMPL115A2() {} diff --git a/src/sensors/GroPointParent.cpp b/src/sensors/GroPointParent.cpp index bd6f270c1..f588c1291 100644 --- a/src/sensors/GroPointParent.cpp +++ b/src/sensors/GroPointParent.cpp @@ -29,6 +29,7 @@ GroPointParent::GroPointParent(byte modbusAddress, Stream* stream, _RS485EnablePin(enablePin) { setSecondaryPowerPin(powerPin2); } +// Delegating constructor GroPointParent::GroPointParent(byte modbusAddress, Stream& stream, int8_t powerPin, int8_t powerPin2, int8_t enablePin, uint8_t measurementsToAverage, @@ -37,15 +38,10 @@ GroPointParent::GroPointParent(byte modbusAddress, Stream& stream, uint32_t stabilizationTime_ms, uint32_t measurementTime_ms, uint8_t incCalcValues) - : Sensor(sensName, numVariables, warmUpTime_ms, stabilizationTime_ms, - measurementTime_ms, powerPin, -1, measurementsToAverage, - incCalcValues), - _model(model), - _modbusAddress(modbusAddress), - _stream(&stream), - _RS485EnablePin(enablePin) { - setSecondaryPowerPin(powerPin2); -} + : GroPointParent(modbusAddress, &stream, powerPin, powerPin2, enablePin, + measurementsToAverage, model, sensName, numVariables, + warmUpTime_ms, stabilizationTime_ms, measurementTime_ms, + incCalcValues) {} // Destructor GroPointParent::~GroPointParent() {} diff --git a/src/sensors/KellerParent.cpp b/src/sensors/KellerParent.cpp index 2421d6929..ca08bec19 100644 --- a/src/sensors/KellerParent.cpp +++ b/src/sensors/KellerParent.cpp @@ -29,6 +29,7 @@ KellerParent::KellerParent(byte modbusAddress, Stream* stream, int8_t powerPin, _RS485EnablePin(enablePin) { setSecondaryPowerPin(powerPin2); } +// Delegating constructor KellerParent::KellerParent(byte modbusAddress, Stream& stream, int8_t powerPin, int8_t powerPin2, int8_t enablePin, uint8_t measurementsToAverage, kellerModel model, @@ -36,15 +37,9 @@ KellerParent::KellerParent(byte modbusAddress, Stream& stream, int8_t powerPin, uint32_t warmUpTime_ms, uint32_t stabilizationTime_ms, uint32_t measurementTime_ms) - : Sensor(sensName, numVariables, warmUpTime_ms, stabilizationTime_ms, - measurementTime_ms, powerPin, -1, measurementsToAverage, - KELLER_INC_CALC_VARIABLES), - _model(model), - _modbusAddress(modbusAddress), - _stream(&stream), - _RS485EnablePin(enablePin) { - setSecondaryPowerPin(powerPin2); -} + : KellerParent(modbusAddress, &stream, powerPin, powerPin2, enablePin, + measurementsToAverage, model, sensName, numVariables, + warmUpTime_ms, stabilizationTime_ms, measurementTime_ms) {} // Destructor KellerParent::~KellerParent() {} diff --git a/src/sensors/MaxBotixSonar.cpp b/src/sensors/MaxBotixSonar.cpp index 894d13bb3..172ea1091 100644 --- a/src/sensors/MaxBotixSonar.cpp +++ b/src/sensors/MaxBotixSonar.cpp @@ -16,23 +16,18 @@ MaxBotixSonar::MaxBotixSonar(Stream* stream, int8_t powerPin, int8_t triggerPin, bool convertCm) : Sensor("MaxBotixMaxSonar", HRXL_NUM_VARIABLES, HRXL_WARM_UP_TIME_MS, HRXL_STABILIZATION_TIME_MS, HRXL_MEASUREMENT_TIME_MS, powerPin, -1, - measurementsToAverage), + measurementsToAverage, HRXL_INC_CALC_VARIABLES), _maxRange(maxRange), _triggerPin(triggerPin), _convertCm(convertCm), _stream(stream) {} - +// Delegating constructor MaxBotixSonar::MaxBotixSonar(Stream& stream, int8_t powerPin, int8_t triggerPin, int16_t maxRange, uint8_t measurementsToAverage, bool convertCm) - : Sensor("MaxBotixMaxSonar", HRXL_NUM_VARIABLES, HRXL_WARM_UP_TIME_MS, - HRXL_STABILIZATION_TIME_MS, HRXL_MEASUREMENT_TIME_MS, powerPin, -1, - measurementsToAverage, HRXL_INC_CALC_VARIABLES), - _maxRange(maxRange), - _triggerPin(triggerPin), - _convertCm(convertCm), - _stream(&stream) {} + : MaxBotixSonar(&stream, powerPin, triggerPin, maxRange, + measurementsToAverage, convertCm) {} // Destructor MaxBotixSonar::~MaxBotixSonar() {} diff --git a/src/sensors/SDI12Sensors.cpp b/src/sensors/SDI12Sensors.cpp index 6c313e5e0..9b9ea2f28 100644 --- a/src/sensors/SDI12Sensors.cpp +++ b/src/sensors/SDI12Sensors.cpp @@ -48,6 +48,7 @@ SDI12Sensors::SDI12Sensors(char SDI12address, int8_t powerPin, int8_t dataPin, _SDI12Internal(dataPin), _SDI12address(SDI12address), _extraWakeTime(extraWakeTime) {} +// Delegating constructor SDI12Sensors::SDI12Sensors(char* SDI12address, int8_t powerPin, int8_t dataPin, uint8_t measurementsToAverage, const char* sensorName, @@ -56,12 +57,11 @@ SDI12Sensors::SDI12Sensors(char* SDI12address, int8_t powerPin, int8_t dataPin, uint32_t stabilizationTime_ms, uint32_t measurementTime_ms, int8_t extraWakeTime, uint8_t incCalcValues) - : Sensor(sensorName, totalReturnedValues, warmUpTime_ms, - stabilizationTime_ms, measurementTime_ms, powerPin, dataPin, - measurementsToAverage, incCalcValues), - _SDI12Internal(dataPin), - _SDI12address(*SDI12address), - _extraWakeTime(extraWakeTime) {} + : SDI12Sensors(*SDI12address, powerPin, dataPin, measurementsToAverage, + sensorName, totalReturnedValues, warmUpTime_ms, + stabilizationTime_ms, measurementTime_ms, extraWakeTime, + incCalcValues) {} +// Delegating constructor SDI12Sensors::SDI12Sensors(int SDI12address, int8_t powerPin, int8_t dataPin, uint8_t measurementsToAverage, const char* sensorName, @@ -70,12 +70,10 @@ SDI12Sensors::SDI12Sensors(int SDI12address, int8_t powerPin, int8_t dataPin, uint32_t stabilizationTime_ms, uint32_t measurementTime_ms, int8_t extraWakeTime, uint8_t incCalcValues) - : Sensor(sensorName, totalReturnedValues, warmUpTime_ms, - stabilizationTime_ms, measurementTime_ms, powerPin, dataPin, - measurementsToAverage, incCalcValues), - _SDI12Internal(dataPin), - _SDI12address(static_cast(SDI12address + '0')), - _extraWakeTime(extraWakeTime) {} + : SDI12Sensors(static_cast(SDI12address + '0'), powerPin, dataPin, + measurementsToAverage, sensorName, totalReturnedValues, + warmUpTime_ms, stabilizationTime_ms, measurementTime_ms, + extraWakeTime, incCalcValues) {} // Destructor SDI12Sensors::~SDI12Sensors() {} diff --git a/src/sensors/YosemitechParent.cpp b/src/sensors/YosemitechParent.cpp index 5491aa7bb..eeafa583e 100644 --- a/src/sensors/YosemitechParent.cpp +++ b/src/sensors/YosemitechParent.cpp @@ -27,21 +27,17 @@ YosemitechParent::YosemitechParent( _RS485EnablePin(enablePin) { setSecondaryPowerPin(powerPin2); } +// Delegating constructor YosemitechParent::YosemitechParent( byte modbusAddress, Stream& stream, int8_t powerPin, int8_t powerPin2, int8_t enablePin, uint8_t measurementsToAverage, yosemitechModel model, const char* sensName, uint8_t numVariables, uint32_t warmUpTime_ms, uint32_t stabilizationTime_ms, uint32_t measurementTime_ms, uint8_t incCalcValues) - : Sensor(sensName, numVariables, warmUpTime_ms, stabilizationTime_ms, - measurementTime_ms, powerPin, -1, measurementsToAverage, - incCalcValues), - _model(model), - _modbusAddress(modbusAddress), - _stream(&stream), - _RS485EnablePin(enablePin) { - setSecondaryPowerPin(powerPin2); -} + : YosemitechParent(modbusAddress, &stream, powerPin, powerPin2, enablePin, + measurementsToAverage, model, sensName, numVariables, + warmUpTime_ms, stabilizationTime_ms, measurementTime_ms, + incCalcValues) {} // Destructor YosemitechParent::~YosemitechParent() {} From 8f59d26da6656a6ea04a1a61263e6398b162b53a Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Mon, 2 Mar 2026 16:07:45 -0500 Subject: [PATCH 390/533] loggerClock::setRTClock now returns TRUE when the clock was not set because it was already correct and only false if a valid time wasn't received or the attempt failed. Signed-off-by: Sara Damiano --- src/ClockSupport.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/ClockSupport.cpp b/src/ClockSupport.cpp index b03d9d0e8..04f9b6316 100644 --- a/src/ClockSupport.cpp +++ b/src/ClockSupport.cpp @@ -382,7 +382,9 @@ bool loggerClock::setRTClock(epochTime in_time, int8_t utcOffset) { // If the RTC is already within 5 seconds of the input time, just quit if (abs(new_rtc_value - prev_rtc_value) < 5) { PRINTOUT(F("Clock already within 5 seconds of time.")); - return false; + // return true because the clock is correctly set, even if we didn't + // actually set it + return true; } MS_DEEP_DBG(F("Setting raw RTC value to:"), new_rtc_value); From e5e6aa7036e31ed424801d310fb96adfce962e9d Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Mon, 2 Mar 2026 16:08:23 -0500 Subject: [PATCH 391/533] Support using onboard NTP for modems where it's implemented Signed-off-by: Sara Damiano --- src/modems/LoggerModemMacros.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/modems/LoggerModemMacros.h b/src/modems/LoggerModemMacros.h index 28b818999..4cb3b63c0 100644 --- a/src/modems/LoggerModemMacros.h +++ b/src/modems/LoggerModemMacros.h @@ -611,6 +611,23 @@ * subclass. * */ +#if defined(TINY_GSM_MODEM_ESP8266) || defined(TINY_GSM_MODEM_ESP32) || \ + defined(TINY_GSM_MODEM_SIM7070) || defined(TINY_GSM_MODEM_SIM7080) || \ + defined(TINY_GSM_MODEM_SIM7090) +#define MS_MODEM_GET_NIST_TIME(specificModem, TinyGSMType) \ + uint32_t specificModem::getNISTTime(void) { \ + /** Check for and bail if not connected to the internet. */ \ + if (!isInternetAvailable()) { \ + MS_DBG(F("No internet connection, cannot get network time.")); \ + return 0; \ + } \ + \ + MS_DBG("Asking modem to sync with NTP"); \ + gsmModem.NTPServerSync("pool.ntp.org", 0); /*UTC!*/ \ + gsmModem.waitForTimeSync(); \ + return gsmModem.getNetworkEpoch(TinyGSM_EpochStart::UNIX); \ + } +#else #define MS_MODEM_GET_NIST_TIME(specificModem, TinyGSMType) \ uint32_t specificModem::getNISTTime(void) { \ /** Check for and bail if not connected to the internet. */ \ @@ -661,6 +678,7 @@ } \ return 0; \ } +#endif /** * @def MS_MODEM_CALC_SIGNAL_QUALITY From 40c03886bbfe9517f35b8c28999a2d48e552bb8b Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Mon, 2 Mar 2026 16:36:02 -0500 Subject: [PATCH 392/533] minor debug change Signed-off-by: Sara Damiano --- src/sensors/TEConnectivityMS5837.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/sensors/TEConnectivityMS5837.cpp b/src/sensors/TEConnectivityMS5837.cpp index e9a175ec7..a26f50069 100644 --- a/src/sensors/TEConnectivityMS5837.cpp +++ b/src/sensors/TEConnectivityMS5837.cpp @@ -192,8 +192,8 @@ bool TEConnectivityMS5837::addSingleMeasurementResult(void) { _overSamplingRatio, F(". Unable to map to OSR value.")); return bumpMeasurementAttemptCount(false); } - MS_DBG(F(" Requesting OSR:"), OSR, F("for oversampling ratio:"), - _overSamplingRatio); + MS_DBG(F(" Requesting"), OSR, F("bit OSR (oversampling ratio:"), + _overSamplingRatio, F(")")); // Convert oversampling ratio to the value expected by the MS5837 library // (8-13 for oversampling ratios 256-8192) int read_return = MS5837_internal.read(OSR); From aae713af460146f3bcbbea30ef91dd32150b40f3 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Mon, 2 Mar 2026 16:49:03 -0500 Subject: [PATCH 393/533] Fix compiler errors Signed-off-by: Sara Damiano --- src/VariableBase.cpp | 3 ++- src/publishers/ThingSpeakPublisher.cpp | 25 ++++++++++++++----------- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/src/VariableBase.cpp b/src/VariableBase.cpp index 3e4a59bb5..8e598035f 100644 --- a/src/VariableBase.cpp +++ b/src/VariableBase.cpp @@ -21,7 +21,8 @@ Variable::Variable(Sensor* parentSense, uint8_t sensorVarNum, uint8_t decimalResolution, const char* varName, const char* varUnit, const char* varCode, const char* uuid) - : _sensorVarNum(sensorVarNum), isCalculated(false) { + : isCalculated(false), + _sensorVarNum(sensorVarNum) { if (uuid) setVarUUID(uuid); if (varCode) setVarCode(varCode); if (varUnit) setVarUnit(varUnit); diff --git a/src/publishers/ThingSpeakPublisher.cpp b/src/publishers/ThingSpeakPublisher.cpp index aa47b4faf..fcf542ceb 100644 --- a/src/publishers/ThingSpeakPublisher.cpp +++ b/src/publishers/ThingSpeakPublisher.cpp @@ -27,12 +27,12 @@ const int ThingSpeakPublisher::mqttPort = 1883; // Constructors // Primary constructor with all MQTT parameters and client -ThingSpeakPublisher::ThingSpeakPublisher(Logger& baseLogger, +ThingSpeakPublisher::ThingSpeakPublisher(Logger& baseLogger, Client* inClient, const char* thingSpeakClientName, const char* thingSpeakMQTTUser, const char* thingSpeakMQTTPassword, const char* thingSpeakChannelID, - Client* inClient, int sendEveryX) + int sendEveryX) : dataPublisher(baseLogger, sendEveryX) { if (thingSpeakClientName) setMQTTClient(thingSpeakClientName); if (thingSpeakMQTTUser) setUserName(thingSpeakMQTTUser); @@ -44,22 +44,25 @@ ThingSpeakPublisher::ThingSpeakPublisher(Logger& baseLogger, // Delegating constructors ThingSpeakPublisher::ThingSpeakPublisher() : dataPublisher() {} ThingSpeakPublisher::ThingSpeakPublisher(Logger& baseLogger, int sendEveryX) - : ThingSpeakPublisher(baseLogger, nullptr, nullptr, nullptr, nullptr, - nullptr, sendEveryX) {} + : ThingSpeakPublisher( + baseLogger, nullptr, static_cast(nullptr), + static_cast(nullptr), static_cast(nullptr), + static_cast(nullptr), sendEveryX) {} ThingSpeakPublisher::ThingSpeakPublisher(Logger& baseLogger, Client* inClient, int sendEveryX) - : ThingSpeakPublisher(baseLogger, nullptr, nullptr, nullptr, nullptr, - inClient, sendEveryX) {} -// Delegating constructor -ThingSpeakPublisher::ThingSpeakPublisher(Logger& baseLogger, Client* inClient, + : ThingSpeakPublisher( + baseLogger, inClient, static_cast(nullptr), + static_cast(nullptr), static_cast(nullptr), + static_cast(nullptr), sendEveryX) {} +ThingSpeakPublisher::ThingSpeakPublisher(Logger& baseLogger, const char* thingSpeakClientName, const char* thingSpeakMQTTUser, const char* thingSpeakMQTTPassword, const char* thingSpeakChannelID, int sendEveryX) - : ThingSpeakPublisher(baseLogger, thingSpeakClientName, thingSpeakMQTTUser, - thingSpeakMQTTPassword, thingSpeakChannelID, inClient, - sendEveryX) {} + : ThingSpeakPublisher(baseLogger, nullptr, thingSpeakClientName, + thingSpeakMQTTUser, thingSpeakMQTTPassword, + thingSpeakChannelID, sendEveryX) {} // Destructor ThingSpeakPublisher::~ThingSpeakPublisher() {} From 3b129e34d0617411709cd9e0551f23877f94478d Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Mon, 2 Mar 2026 16:59:31 -0500 Subject: [PATCH 394/533] Woops! 7080 doesn't give epoch! Signed-off-by: Sara Damiano --- src/modems/LoggerModemMacros.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/modems/LoggerModemMacros.h b/src/modems/LoggerModemMacros.h index 4cb3b63c0..90d606ef1 100644 --- a/src/modems/LoggerModemMacros.h +++ b/src/modems/LoggerModemMacros.h @@ -611,9 +611,7 @@ * subclass. * */ -#if defined(TINY_GSM_MODEM_ESP8266) || defined(TINY_GSM_MODEM_ESP32) || \ - defined(TINY_GSM_MODEM_SIM7070) || defined(TINY_GSM_MODEM_SIM7080) || \ - defined(TINY_GSM_MODEM_SIM7090) +#if defined(TINY_GSM_MODEM_ESP8266) || defined(TINY_GSM_MODEM_ESP32) #define MS_MODEM_GET_NIST_TIME(specificModem, TinyGSMType) \ uint32_t specificModem::getNISTTime(void) { \ /** Check for and bail if not connected to the internet. */ \ From 9894d8f7363cc3304998b681a87b7dd9bf9ee443 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Mon, 2 Mar 2026 17:22:07 -0500 Subject: [PATCH 395/533] Update examples/menu_a_la_carte/ReadMe.md Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --- examples/menu_a_la_carte/ReadMe.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/menu_a_la_carte/ReadMe.md b/examples/menu_a_la_carte/ReadMe.md index cbe53588e..0aeffefa3 100644 --- a/examples/menu_a_la_carte/ReadMe.md +++ b/examples/menu_a_la_carte/ReadMe.md @@ -1291,7 +1291,7 @@ Here we set up all three possible data publishers and link all of them to the sa #### Monitor My Watershed -To publish data to the Monitor My Watershed first you must register yourself as a user at . +To publish data to Monitor My Watershed, you must first register as a user at . Then you must register your site. After registering your site, a sampling feature and registration token for that site should be visible on the site page. From 3c90e3a0c0ecb7059048331a725eb93367b4b7b3 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Mon, 2 Mar 2026 18:20:03 -0500 Subject: [PATCH 396/533] Gave a default of 5 retries Signed-off-by: Sara Damiano --- src/sensors/TEConnectivityMS5837.cpp | 4 +++- src/sensors/TEConnectivityMS5837.h | 23 +++++++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/src/sensors/TEConnectivityMS5837.cpp b/src/sensors/TEConnectivityMS5837.cpp index a26f50069..1fc61de96 100644 --- a/src/sensors/TEConnectivityMS5837.cpp +++ b/src/sensors/TEConnectivityMS5837.cpp @@ -27,7 +27,9 @@ TEConnectivityMS5837::TEConnectivityMS5837(TwoWire* theI2C, int8_t powerPin, _model(model), _fluidDensity(fluidDensity), _airPressure(airPressure), - _overSamplingRatio(overSamplingRatio) {} + _overSamplingRatio(overSamplingRatio) { + setAllowedMeasurementRetries(MS5837_DEFAULT_MEASUREMENT_RETRIES); +} // Delegating constructors TEConnectivityMS5837::TEConnectivityMS5837(TwoWire* theI2C, int8_t powerPin, diff --git a/src/sensors/TEConnectivityMS5837.h b/src/sensors/TEConnectivityMS5837.h index dc0e211cc..a471a1a92 100644 --- a/src/sensors/TEConnectivityMS5837.h +++ b/src/sensors/TEConnectivityMS5837.h @@ -59,6 +59,10 @@ * https://bluerobotics.com/store/sensors-sonars-cameras/sensors/bar30-sensor-r1/ * * @section sensor_ms5837_flags Build flags + * - ```-D MS5837_DEFAULT_MEASUREMENT_RETRIES=5``` + * - Changes the default number of measurement retries when a measurement + * fails. The default value is 5. Higher values provide better reliability but + * may increase total measurement time on sensor failures. * - ```-D MS5837_DEFAULT_FLUID_DENSITY=0.99802f``` * - Changes the default fluid density used for depth calculations. The * default value is for water at 20°C. For seawater, use approximately 1.025f. @@ -117,6 +121,25 @@ * Build-time configuration for the MS5837 */ /**@{*/ +#if !defined(MS5837_DEFAULT_MEASUREMENT_RETRIES) || defined(DOXYGEN) +/** + * @brief Default number of measurement retries + * + * The default number of times to retry a measurement when it fails. Higher + * values provide better reliability but may increase total measurement time on + * sensor failures. This can be set at runtime for individual sensors and the + * default can be overridden at compile time with `-D + * MS5837_DEFAULT_MEASUREMENT_RETRIES=value` + */ +#define MS5837_DEFAULT_MEASUREMENT_RETRIES 5 +#endif + +// Static assert to validate measurement retries is reasonable +static_assert(MS5837_DEFAULT_MEASUREMENT_RETRIES >= 0 && + MS5837_DEFAULT_MEASUREMENT_RETRIES <= 20, + "MS5837_DEFAULT_MEASUREMENT_RETRIES must be between 0 and 20 " + "(reasonable measurement retry range)"); + #if !defined(MS5837_DEFAULT_FLUID_DENSITY) || defined(DOXYGEN) /** * @brief Default fluid density for depth calculations (grams/cm³) From 825b3ac534b11534f77d1319dcdc0f28e0949b8b Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Mon, 2 Mar 2026 17:27:53 -0500 Subject: [PATCH 397/533] Fix link Signed-off-by: Sara Damiano --- examples/ReadMe.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/ReadMe.md b/examples/ReadMe.md index 7fc16d983..fbc132e82 100644 --- a/examples/ReadMe.md +++ b/examples/ReadMe.md @@ -125,7 +125,7 @@ ___ The EnviroDIY Sensor Station Kit is designed to be used with the [EnviroDIY Monitoring Station Kit](https://www.envirodiy.org/product/envirodiy-monitoring-station-kit/). - [Instructions for the EnviroDIY sensor station kit example](https://envirodiy.github.io/ModularSensors/example_envirodiy_monitoring_kit.html) -- [The EnviroDIY sensor station kit example on GitHub](https://github.com/EnviroDIY/ModularSensors/tree/master/examples/example_envirodiy_monitoring_kit) +- [The EnviroDIY sensor station kit example on GitHub](https://github.com/EnviroDIY/ModularSensors/tree/master/examples/EnviroDIY_Monitoring_Kit) ___ From 8467987c99d2ae2983ad08a0100325a8811598e6 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Mon, 2 Mar 2026 17:30:39 -0500 Subject: [PATCH 398/533] Fix _remainingShortIntervals size Signed-off-by: Sara Damiano --- src/LoggerBase.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/LoggerBase.h b/src/LoggerBase.h index 7bd643d16..3e05f0612 100644 --- a/src/LoggerBase.h +++ b/src/LoggerBase.h @@ -477,7 +477,7 @@ class Logger { * @brief The initial number of samples to log at an interval of 1 minute * for fast field verification */ - int8_t _remainingShortIntervals = 5; + int16_t _remainingShortIntervals = 5; /** * @brief Digital pin number on the mcu controlling the SD card slave * select. From 83af33afae4dd58654caea555306979de26e9ccc Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Mon, 2 Mar 2026 17:32:09 -0500 Subject: [PATCH 399/533] Add nullptr checks Signed-off-by: Sara Damiano --- src/publishers/ThingSpeakPublisher.cpp | 18 ++++++++++++++++++ src/publishers/UbidotsPublisher.cpp | 6 ++++++ 2 files changed, 24 insertions(+) diff --git a/src/publishers/ThingSpeakPublisher.cpp b/src/publishers/ThingSpeakPublisher.cpp index fcf542ceb..77685bb9f 100644 --- a/src/publishers/ThingSpeakPublisher.cpp +++ b/src/publishers/ThingSpeakPublisher.cpp @@ -129,6 +129,24 @@ void ThingSpeakPublisher::begin(Logger& baseLogger, // This sends the data to ThingSpeak int16_t ThingSpeakPublisher::publishData(Client* outClient, bool) { + // Validate required MQTT parameters before proceeding + if (_thingSpeakChannelID == nullptr || strlen(_thingSpeakChannelID) == 0) { + MS_DBG(F("ERROR: ThingSpeak Channel ID is required but not set!")); + return -1; + } + if (_thingSpeakClientName == nullptr) { + MS_DBG(F("ERROR: ThingSpeak Client Name is required but not set!")); + return -1; + } + if (_thingSpeakMQTTUser == nullptr) { + MS_DBG(F("ERROR: ThingSpeak MQTT User is required but not set!")); + return -1; + } + if (_thingSpeakMQTTPassword == nullptr) { + MS_DBG(F("ERROR: ThingSpeak MQTT Password is required but not set!")); + return -1; + } + bool retVal = false; // Make sure we don't have too many fields diff --git a/src/publishers/UbidotsPublisher.cpp b/src/publishers/UbidotsPublisher.cpp index 471f9ee25..463891328 100644 --- a/src/publishers/UbidotsPublisher.cpp +++ b/src/publishers/UbidotsPublisher.cpp @@ -123,6 +123,12 @@ int16_t UbidotsPublisher::publishData(Client* outClient, bool) { "to Ubidots!")); return 0; } + if (_authenticationToken == nullptr || + strlen(_authenticationToken) == 0) { + PRINTOUT(F("An authentication token must be set before publishing data " + "to Ubidots!")); + return 0; + } MS_DBG(F("Outgoing JSON size:"), calculateJsonSize()); From eb6602cc30d24f00c3a10041f2198142b19859b5 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Mon, 2 Mar 2026 17:55:10 -0500 Subject: [PATCH 400/533] Measurement retries as define for some with known Signed-off-by: Sara Damiano --- src/sensors/ANBpH.cpp | 2 +- src/sensors/ANBpH.h | 27 +++++++++++++++++++++++++++ src/sensors/AOSongDHT.cpp | 4 +++- src/sensors/AOSongDHT.h | 27 +++++++++++++++++++++++++++ 4 files changed, 58 insertions(+), 2 deletions(-) diff --git a/src/sensors/ANBpH.cpp b/src/sensors/ANBpH.cpp index a5010bab5..df0824a2e 100644 --- a/src/sensors/ANBpH.cpp +++ b/src/sensors/ANBpH.cpp @@ -46,7 +46,7 @@ ANBpH::ANBpH(byte modbusAddress, Stream* stream, int8_t powerPin, _anb_sensor.setDebugStream(&MS_SERIAL_OUTPUT); #endif setSecondaryPowerPin(powerPin2); - setAllowedMeasurementRetries(5); + setAllowedMeasurementRetries(ANB_PH_DEFAULT_MEASUREMENT_RETRIES); } // Delegating constructor ANBpH::ANBpH(byte modbusAddress, Stream& stream, int8_t powerPin, diff --git a/src/sensors/ANBpH.h b/src/sensors/ANBpH.h index e62de3289..3514c08a4 100644 --- a/src/sensors/ANBpH.h +++ b/src/sensors/ANBpH.h @@ -58,6 +58,11 @@ * the time the logger woke or other sensors took measurements by the time it * takes the pH sensor to warm up and take a reading. * + * @section sensor_anb_ph_config_flags Build flags + * - `-D ANB_PH_DEFAULT_MEASUREMENT_RETRIES=##` + * - used to set the default number of measurement retries for ANB pH sensors + * when communication errors occur + * * @section sensor_anb_ph_ctor Sensor Constructor * {{ @ref ANBpH::ANBpH }} * @@ -101,6 +106,28 @@ /** @ingroup sensor_anb_ph */ /**@{*/ +/** + * @anchor sensor_anb_ph_config + * @name Configuration Defines + * Define for the ANB pH measurement retry behavior. + */ +/**@{*/ +#if !defined(ANB_PH_DEFAULT_MEASUREMENT_RETRIES) || defined(DOXYGEN) +/** + * @brief The default number of measurement retries for ANB pH sensors when + * communication errors occur. + * + * ANB pH sensors use Modbus communication which can be susceptible to + * communication errors, especially in harsh environmental conditions. This + * define sets the default number of retries when a measurement fails. + * + * @note The default value of 5 retries provides good reliability while + * preventing excessive delays in case of persistent communication issues. + */ +#define ANB_PH_DEFAULT_MEASUREMENT_RETRIES 5 +#endif +/**@}*/ + /** * @brief The minimum spacing between requesting responses from the sensor. * diff --git a/src/sensors/AOSongDHT.cpp b/src/sensors/AOSongDHT.cpp index 504b2bf31..a788d9aba 100644 --- a/src/sensors/AOSongDHT.cpp +++ b/src/sensors/AOSongDHT.cpp @@ -19,7 +19,7 @@ AOSongDHT::AOSongDHT(int8_t powerPin, int8_t dataPin, const uint8_t type, dataPin, measurementsToAverage, DHT_INC_CALC_VARIABLES), dht_internal(dataPin, type), _dhtType(type) { - setAllowedMeasurementRetries(5); + setAllowedMeasurementRetries(DHT_DEFAULT_MEASUREMENT_RETRIES); } // Destructor - does nothing. @@ -72,6 +72,8 @@ bool AOSongDHT::addSingleMeasurementResult(void) { verifyAndAddMeasurementResult(DHT_HUMIDITY_VAR_NUM, humid_val); verifyAndAddMeasurementResult(DHT_HI_VAR_NUM, hi_val); success = true; + } else { + MS_DBG(F(" DHT read failed (NaN temperature/humidity).")); } // Return success value when finished diff --git a/src/sensors/AOSongDHT.h b/src/sensors/AOSongDHT.h index 577b95ab6..8dcde62bb 100644 --- a/src/sensors/AOSongDHT.h +++ b/src/sensors/AOSongDHT.h @@ -45,6 +45,11 @@ * @section sensor_dht_datasheet Sensor Datasheet * [Datasheet](https://github.com/EnviroDIY/ModularSensors/wiki/Sensor-Datasheets/AOSong-DHT22-Datasheet.pdf) * + * @section sensor_dht_config_flags Build flags + * - `-D DHT_DEFAULT_MEASUREMENT_RETRIES=##` + * - used to set the default number of measurement retries for DHT sensors + * when communication errors occur + * * @section sensor_dht_ctor Sensor Constructor * {{ @ref AOSongDHT::AOSongDHT }} * @@ -102,6 +107,28 @@ static const uint8_t AM2301{21}; /**< AM2301 */ /** @ingroup sensor_dht */ /**@{*/ +/** + * @anchor sensor_dht_config + * @name Configuration Defines + * Define for the DHT measurement retry behavior. + */ +/**@{*/ +#if !defined(DHT_DEFAULT_MEASUREMENT_RETRIES) || defined(DOXYGEN) +/** + * @brief The default number of measurement retries for DHT sensors when + * communication errors occur. + * + * DHT sensors use a single-wire protocol that can be susceptible to timing + * issues and communication errors. This define sets the default number of + * retries when a measurement fails. + * + * @note The default value of 5 retries provides good reliability while + * preventing excessive delays in case of persistent communication issues. + */ +#define DHT_DEFAULT_MEASUREMENT_RETRIES 5 +#endif +/**@}*/ + /** * @anchor sensor_dht_var_counts * @name Sensor Variable Counts From b6ffdd7ad71c43fc79a7d3874fd3ac0536620b8f Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Mon, 2 Mar 2026 17:55:40 -0500 Subject: [PATCH 401/533] Mark failure when wake fails Signed-off-by: Sara Damiano --- src/VariableArray.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/VariableArray.cpp b/src/VariableArray.cpp index a093d92e6..03c8b6017 100644 --- a/src/VariableArray.cpp +++ b/src/VariableArray.cpp @@ -404,6 +404,7 @@ bool VariableArray::completeUpdate(bool powerUp, bool wake, bool sleep, F("failed to wake up! No measurements will be taken! " "<<---"), i); + success = false; // Set the number of measurements already complete equal to // whatever total number requested to ensure the sensor is // skipped in further loops. NOTE: These are protected members From 7a9d656b00905430a3172a92550ca4064f76d35a Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Mon, 2 Mar 2026 17:56:05 -0500 Subject: [PATCH 402/533] Add define for failure value Signed-off-by: Sara Damiano --- src/ModSensorConfig.h | 121 +++++++++++++++++++++--------------------- 1 file changed, 60 insertions(+), 61 deletions(-) diff --git a/src/ModSensorConfig.h b/src/ModSensorConfig.h index 949c712e3..ab7686ccd 100644 --- a/src/ModSensorConfig.h +++ b/src/ModSensorConfig.h @@ -38,28 +38,62 @@ // #define MS_USE_RTC_ZERO //============================================================== + //============================================================== -// Select ADS1015 instead of the ADS1115, if desired -// This is for sensors that use the external ADC for analog voltage -// measurements. -// #define MS_USE_ADS1015 +// Time-stamp configurations +//============================================================== +#ifndef MS_LOGGER_EPOCH +/** + * @brief The epoch start to use for the logger + */ +#define MS_LOGGER_EPOCH epochStart::unix_epoch +#endif -#if !defined(MS_DEFAULT_ADS1X15_ADDRESS) || defined(DOXYGEN) +#ifndef EARLIEST_SANE_UNIX_TIMESTAMP /** - * @brief The default I²C address of the ADS1115 or ADS1015 external ADC. + * @brief The earliest unix timestamp that can be considered sane. * - * Valid addresses depend on the ADDR pin connection: - * - `0x48` – ADDR to GND (default) - * - `0x49` – ADDR to VDD - * - `0x4A` – ADDR to SDA - * - `0x4B` – ADDR to SCL + * January 1, 2025 + */ +#define EARLIEST_SANE_UNIX_TIMESTAMP 1735689600 +#endif + +#ifndef LATEST_SANE_UNIX_TIMESTAMP +/** + * @brief The latest unix timestamp that can be considered sane. * - * Override with a build flag: `-DMS_DEFAULT_ADS1X15_ADDRESS=0x49` + * January 1, 2035 */ -#define MS_DEFAULT_ADS1X15_ADDRESS 0x48 +#define LATEST_SANE_UNIX_TIMESTAMP 2051222400 #endif //============================================================== + +//============================================================== +// Variable configurations +//============================================================== +#ifndef MS_INVALID_VALUE +/** + * @brief The value used to represent an invalid or missing measurement. + * + * Every sensor will use this value to indicate that a measurement is invalid + * or missing. + */ +#define MS_INVALID_VALUE -9999.0 + +// GroPoint Profile GPLP-8 has 8 Moisture and 13 Temperature values +#endif +#ifndef MAX_NUMBER_VARS +/** + * @brief The largest number of variables from a single sensor. + * + * Every sensor will create a buffer of this length for holding variable values. + * Decrease this value to save a memory. + */ +#define MAX_NUMBER_VARS 21 +// GroPoint Profile GPLP-8 has 8 Moisture and 13 Temperature values +#endif + //============================================================== // Disable concurrent polling of SDI-12 sensors, if needed // Concurrent measurement support was introduced in version 1.2 (April 12, 1996) @@ -110,63 +144,28 @@ #endif //============================================================== - -//============================================================== -// Time-stamp configurations //============================================================== -#ifndef MS_LOGGER_EPOCH -/** - * @brief The epoch start to use for the logger - */ -#define MS_LOGGER_EPOCH epochStart::unix_epoch -#endif +// Select ADS1015 instead of the ADS1115, if desired +// This is for sensors that use the external ADC for analog voltage +// measurements. +// #define MS_USE_ADS1015 -#ifndef EARLIEST_SANE_UNIX_TIMESTAMP +#if !defined(MS_DEFAULT_ADS1X15_ADDRESS) || defined(DOXYGEN) /** - * @brief The earliest unix timestamp that can be considered sane. + * @brief The default I²C address of the ADS1115 or ADS1015 external ADC. * - * January 1, 2025 - */ -#define EARLIEST_SANE_UNIX_TIMESTAMP 1735689600 -#endif - -#ifndef LATEST_SANE_UNIX_TIMESTAMP -/** - * @brief The latest unix timestamp that can be considered sane. + * Valid addresses depend on the ADDR pin connection: + * - `0x48` – ADDR to GND (default) + * - `0x49` – ADDR to VDD + * - `0x4A` – ADDR to SDA + * - `0x4B` – ADDR to SCL * - * January 1, 2035 + * Override with a build flag: `-DMS_DEFAULT_ADS1X15_ADDRESS=0x49` */ -#define LATEST_SANE_UNIX_TIMESTAMP 2051222400 +#define MS_DEFAULT_ADS1X15_ADDRESS 0x48 #endif //============================================================== - -//============================================================== -// Variable configurations -//============================================================== -#ifndef MAX_NUMBER_VARS -/** - * @brief The largest number of variables from a single sensor. - * - * Every sensor will create a buffer of this length for holding variable values. - * Decrease this value to save a memory. - */ -#define MAX_NUMBER_VARS 21 -// GroPoint Profile GPLP-8 has 8 Moisture and 13 Temperature values -#endif - -#if 0 -#ifndef MS_NUMBER_SUPPORTED_POWER_PINS -/** - * @brief The maximum number of power pins the library can support for a single - * sensor. - * - * @warning There is currently no support for this functionality and changing this value will not do anything. This is a placeholder for possible. future functionality to support multiple power pins per sensor. - */ -#define MS_NUMBER_SUPPORTED_POWER_PINS 2 -#endif -#endif - //============================================================== // Analog voltage configuration //============================================================== From 4bfd28b9a8b04f04fac6d71568621a88c24fd394 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Mon, 2 Mar 2026 17:56:53 -0500 Subject: [PATCH 403/533] Add failure message Signed-off-by: Sara Damiano --- src/sensors/ProcessorAnalog.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/sensors/ProcessorAnalog.cpp b/src/sensors/ProcessorAnalog.cpp index 627137848..ca54eb65a 100644 --- a/src/sensors/ProcessorAnalog.cpp +++ b/src/sensors/ProcessorAnalog.cpp @@ -177,6 +177,8 @@ bool ProcessorAnalog::addSingleMeasurementResult(void) { if (success) { verifyAndAddMeasurementResult(PROCESSOR_ANALOG_VAR_NUM, resultValue); + } else { + MS_DBG(F(" Failed to get valid voltage from analog reader")); } // Return success value when finished From 7e84d5f8cbd4b970ea193423b33b1cbed82f43fb Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Mon, 2 Mar 2026 17:59:34 -0500 Subject: [PATCH 404/533] Clamp in setup, not ctor Signed-off-by: Sara Damiano --- src/sensors/ANBpH.cpp | 79 ++++++++++++++++++++++--------------------- 1 file changed, 41 insertions(+), 38 deletions(-) diff --git a/src/sensors/ANBpH.cpp b/src/sensors/ANBpH.cpp index df0824a2e..977c066d3 100644 --- a/src/sensors/ANBpH.cpp +++ b/src/sensors/ANBpH.cpp @@ -20,27 +20,7 @@ ANBpH::ANBpH(byte modbusAddress, Stream* stream, int8_t powerPin, _anb_sensor(modbusAddress, stream, enablePin), _modbusAddress(modbusAddress), _stream(stream), - _loggingIntervalMinutes([powerPin, loggingIntervalMinutes]() -> int16_t { - // NOTE: These clamps are intentionally silent — Serial/MS_DBG is NOT - // safe to call during construction (the Serial object may not be - // initialized yet on Arduino targets). - // Validate and normalize loggingIntervalMinutes based on powerPin - if (powerPin != -1) { // Cycled power - if (loggingIntervalMinutes == 0) { - return 10; // Force to minimum for cycled power - } - return (loggingIntervalMinutes < 10) ? 10 - : (loggingIntervalMinutes > 240) ? 240 - : loggingIntervalMinutes; - } else { // Always-powered (powerPin == -1) - if (loggingIntervalMinutes == 0) { - return 0; // Allow 0 for always-on mode - } - return (loggingIntervalMinutes < 10) ? 10 - : (loggingIntervalMinutes > 240) ? 240 - : loggingIntervalMinutes; - } - }()), + _loggingIntervalMinutes(loggingIntervalMinutes), _RS485EnablePin(enablePin) { #ifdef MS_ANB_SENSORS_PH_DEBUG_DEEP _anb_sensor.setDebugStream(&MS_SERIAL_OUTPUT); @@ -160,23 +140,46 @@ bool ANBpH::setup(void) { bool intervalSet = false; uint16_t programmedInterval = _loggingIntervalMinutes; - if (_loggingIntervalMinutes == 0 && _powerPin >= 0) { - programmedInterval = 10; - MS_DBG(F("Requested interval of 0 minutes is invalid when power is " - "cycled; using"), - programmedInterval, F("minutes.")); - } - if (_loggingIntervalMinutes < 10 && _loggingIntervalMinutes != 0) { - programmedInterval = 10; - MS_DBG(F("Requested interval of"), _loggingIntervalMinutes, - F("minutes is too short; using"), programmedInterval, - F("minutes.")); - } - if (_loggingIntervalMinutes > 240 && _loggingIntervalMinutes != 0) { - programmedInterval = 240; - MS_DBG(F("Requested interval of"), _loggingIntervalMinutes, - F("minutes is too long; using"), programmedInterval, - F("minutes.")); + + // Validate and normalize loggingIntervalMinutes based on powerPin + int16_t originalInterval = _loggingIntervalMinutes; // Store original for debug messages + if (_powerPin >= 0) { // Cycled power + if (_loggingIntervalMinutes == 0) { + programmedInterval = 10; + _loggingIntervalMinutes = 10; // Update the stored value + MS_DBG(F("Requested interval of"), originalInterval, + F("minutes is invalid when power is cycled; using"), + programmedInterval, F("minutes.")); + } else if (_loggingIntervalMinutes < 10) { + programmedInterval = 10; + _loggingIntervalMinutes = 10; // Update the stored value + MS_DBG(F("Requested interval of"), originalInterval, + F("minutes is too short; using"), programmedInterval, + F("minutes.")); + } else if (_loggingIntervalMinutes > 240) { + programmedInterval = 240; + _loggingIntervalMinutes = 240; // Update the stored value + MS_DBG(F("Requested interval of"), originalInterval, + F("minutes is too long; using"), programmedInterval, + F("minutes.")); + } + } else { // Always-powered (powerPin == -1) + if (_loggingIntervalMinutes == 0) { + programmedInterval = 0; // Allow 0 for always-on mode + // No need to change _loggingIntervalMinutes + } else if (_loggingIntervalMinutes < 10) { + programmedInterval = 10; + _loggingIntervalMinutes = 10; // Update the stored value + MS_DBG(F("Requested interval of"), originalInterval, + F("minutes is too short; using"), programmedInterval, + F("minutes.")); + } else if (_loggingIntervalMinutes > 240) { + programmedInterval = 240; + _loggingIntervalMinutes = 240; // Update the stored value + MS_DBG(F("Requested interval of"), originalInterval, + F("minutes is too long; using"), programmedInterval, + F("minutes.")); + } } if (_powerPin >= 0) { // Set sampling interval to the expected sampling interval if the sensor From 4c2ba65787787e92f6ca9d5f36f89ffabd9edcdb Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Mon, 2 Mar 2026 17:59:59 -0500 Subject: [PATCH 405/533] Support modems that can get times internally as parts Signed-off-by: Sara Damiano --- src/modems/LoggerModemMacros.h | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/src/modems/LoggerModemMacros.h b/src/modems/LoggerModemMacros.h index 90d606ef1..6958100fb 100644 --- a/src/modems/LoggerModemMacros.h +++ b/src/modems/LoggerModemMacros.h @@ -625,6 +625,35 @@ gsmModem.waitForTimeSync(); \ return gsmModem.getNetworkEpoch(TinyGSM_EpochStart::UNIX); \ } +#elif defined(TINY_GSM_MODEM_HAS_NTP) && defined(TINY_GSM_MODEM_HAS_TIME) +#include "ClockSupport.h" +#define MS_MODEM_GET_NIST_TIME(specificModem, TinyGSMType) \ + uint32_t specificModem::getNISTTime(void) { \ + /** Check for and bail if not connected to the internet. */ \ + if (!isInternetAvailable()) { \ + MS_DBG(F("No internet connection, cannot get network time.")); \ + return 0; \ + } \ + \ + MS_DBG("Asking modem to sync with NTP"); \ + gsmModem.NTPServerSync("pool.ntp.org", 0); /*UTC!*/ \ + gsmModem.waitForTimeSync(); \ + \ + /* Create ints to hold time parts */ \ + int seconds = 0; \ + int minutes = 0; \ + int hours = 0; \ + int day = 0; \ + int month = 0; \ + int year = 0; \ + /* Fetch the time as parts */ \ + bool success = gsmModem.getNetworkTime(year, &month, &day, &hours, \ + &minutes, &seconds, 0); \ + if (!success) { return 0; } \ + tm timeParts = {seconds, minutes, hours, day, month, year - 1900}; \ + time_t timeTimeT = mktime(&timeParts); \ + return epochTime(timeTimeT, epochStart::unix_epoch); \ + } #else #define MS_MODEM_GET_NIST_TIME(specificModem, TinyGSMType) \ uint32_t specificModem::getNISTTime(void) { \ From 318ae79a97a8dfe748e816e7f9d65aca72edcc6c Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Mon, 2 Mar 2026 18:08:29 -0500 Subject: [PATCH 406/533] Reorder defines to put config on top Signed-off-by: Sara Damiano --- src/sensors/AlphasenseCO2.h | 26 +++++++++++----------- src/sensors/AnalogElecConductivity.h | 32 ++++++++++++++-------------- src/sensors/ApogeeSQ212.h | 26 +++++++++++----------- src/sensors/AtlasScientificCO2.h | 20 ++++++++--------- src/sensors/AtlasScientificDO.h | 20 ++++++++--------- src/sensors/AtlasScientificEC.h | 24 ++++++++++----------- src/sensors/AtlasScientificORP.h | 20 ++++++++--------- src/sensors/AtlasScientificRTD.h | 22 +++++++++---------- src/sensors/AtlasScientificpH.h | 20 ++++++++--------- src/sensors/EverlightALSPT19.h | 28 ++++++++++++------------ src/sensors/TIINA219.h | 20 ++++++++--------- src/sensors/TallyCounterI2C.h | 20 ++++++++--------- src/sensors/TurnerTurbidityPlus.h | 30 +++++++++++++------------- 13 files changed, 154 insertions(+), 154 deletions(-) diff --git a/src/sensors/AlphasenseCO2.h b/src/sensors/AlphasenseCO2.h index c82c8bbf9..cac614172 100644 --- a/src/sensors/AlphasenseCO2.h +++ b/src/sensors/AlphasenseCO2.h @@ -101,19 +101,6 @@ class AnalogVoltageBase; /** @ingroup sensor_alphasense_co2 */ /**@{*/ -/** - * @anchor sensor_alphasense_co2_var_counts - * @name Sensor Variable Counts - * The number of variables that can be returned by the Alphasense CO2 sensor - */ -/**@{*/ -/// @brief Sensor::_numReturnedValues; the Alphasense CO2 sensor can report 2 -/// values, raw voltage and calculated CO2. -#define ALPHASENSE_CO2_NUM_VARIABLES 2 -/// @brief Sensor::_incCalcValues; CO2 is calculated from the raw voltage. -#define ALPHASENSE_CO2_INC_CALC_VARIABLES 1 -/**@}*/ - /** * @anchor sensor_alphasense_co2_config * @name Configuration Defines @@ -146,6 +133,19 @@ class AnalogVoltageBase; #endif /**@}*/ +/** + * @anchor sensor_alphasense_co2_var_counts + * @name Sensor Variable Counts + * The number of variables that can be returned by the Alphasense CO2 sensor + */ +/**@{*/ +/// @brief Sensor::_numReturnedValues; the Alphasense CO2 sensor can report 2 +/// values, raw voltage and calculated CO2. +#define ALPHASENSE_CO2_NUM_VARIABLES 2 +/// @brief Sensor::_incCalcValues; CO2 is calculated from the raw voltage. +#define ALPHASENSE_CO2_INC_CALC_VARIABLES 1 +/**@}*/ + /** * @anchor sensor_alphasense_co2_timing * @name Sensor Timing diff --git a/src/sensors/AnalogElecConductivity.h b/src/sensors/AnalogElecConductivity.h index a26bb2236..8f9b0636c 100644 --- a/src/sensors/AnalogElecConductivity.h +++ b/src/sensors/AnalogElecConductivity.h @@ -171,22 +171,6 @@ /** @ingroup sensor_analog_cond */ /**@{*/ -/** - * @anchor sensor_analog_cond_parts_var_counts - * @name Sensor Variable Counts - * The number of variables that can be returned by the analog conductivity - * sensor - */ -/**@{*/ -/// @brief Sensor::_numReturnedValues; we only get one value from the analog -/// conductivity sensor. -#define ANALOGELECCONDUCTIVITY_NUM_VARIABLES 1 -/// @brief Sensor::_incCalcValues; we don't calculate any additional values -/// though we recommend users include a temperature sensor and calculate -/// specific conductance in their own program. -#define ANALOGELECCONDUCTIVITY_INC_CALC_VARIABLES 0 -/**@}*/ - /** * @anchor sensor_analog_cond_parts_config * @name Configuration Defines @@ -236,6 +220,22 @@ static_assert( "ANALOGELECCONDUCTIVITY_ADC_MAX_RATIO must be in the range (0.0, 1.0)"); /**@}*/ +/** + * @anchor sensor_analog_cond_parts_var_counts + * @name Sensor Variable Counts + * The number of variables that can be returned by the analog conductivity + * sensor + */ +/**@{*/ +/// @brief Sensor::_numReturnedValues; we only get one value from the analog +/// conductivity sensor. +#define ANALOGELECCONDUCTIVITY_NUM_VARIABLES 1 +/// @brief Sensor::_incCalcValues; we don't calculate any additional values +/// though we recommend users include a temperature sensor and calculate +/// specific conductance in their own program. +#define ANALOGELECCONDUCTIVITY_INC_CALC_VARIABLES 0 +/**@}*/ + /** * @anchor sensor_analog_cond_parts_timing * @name Sensor Timing diff --git a/src/sensors/ApogeeSQ212.h b/src/sensors/ApogeeSQ212.h index c505889c0..3e2c3c1bb 100644 --- a/src/sensors/ApogeeSQ212.h +++ b/src/sensors/ApogeeSQ212.h @@ -98,19 +98,6 @@ class AnalogVoltageBase; /** @ingroup sensor_sq212 */ /**@{*/ -/** - * @anchor sensor_sq212_var_counts - * @name Sensor Variable Counts - * The number of variables that can be returned by the Apogee SQ-212 - */ -/**@{*/ -/// @brief Sensor::_numReturnedValues; the SQ212 can report 2 values, raw -/// voltage and calculated PAR. -#define SQ212_NUM_VARIABLES 2 -/// @brief Sensor::_incCalcValues; PAR is calculated from the raw voltage. -#define SQ212_INC_CALC_VARIABLES 1 -/**@}*/ - /** * @anchor sensor_sq212_config * @name Configuration Defines @@ -127,6 +114,19 @@ class AnalogVoltageBase; #endif /**@}*/ +/** + * @anchor sensor_sq212_var_counts + * @name Sensor Variable Counts + * The number of variables that can be returned by the Apogee SQ-212 + */ +/**@{*/ +/// @brief Sensor::_numReturnedValues; the SQ212 can report 2 values, raw +/// voltage and calculated PAR. +#define SQ212_NUM_VARIABLES 2 +/// @brief Sensor::_incCalcValues; PAR is calculated from the raw voltage. +#define SQ212_INC_CALC_VARIABLES 1 +/**@}*/ + /** * @anchor sensor_sq212_timing * @name Sensor Timing diff --git a/src/sensors/AtlasScientificCO2.h b/src/sensors/AtlasScientificCO2.h index c16743a82..61bc70a9f 100644 --- a/src/sensors/AtlasScientificCO2.h +++ b/src/sensors/AtlasScientificCO2.h @@ -73,6 +73,16 @@ /** @ingroup sensor_atlas_co2 */ /**@{*/ +/** + * @anchor sensor_atlas_co2_config + * @name Configuration Defines + * Defines to configure and set the address of the Atlas CO2 sensor + */ +/**@{*/ +/// @brief The default I2C address of the Atlas CO2 sensor is 0x69 (105) +#define ATLAS_CO2_I2C_ADDR 0x69 +/**@}*/ + /** * @anchor sensor_atlas_co2_var_counts * @name Sensor Variable Counts @@ -85,16 +95,6 @@ #define ATLAS_CO2_INC_CALC_VARIABLES 0 /**@}*/ -/** - * @anchor sensor_atlas_co2_config - * @name Configuration Defines - * Defines to configure and set the address of the Atlas CO2 sensor - */ -/**@{*/ -/// @brief The default I2C address of the Atlas CO2 sensor is 0x69 (105) -#define ATLAS_CO2_I2C_ADDR 0x69 -/**@}*/ - /** * @anchor sensor_atlas_co2_timing * @name Sensor Timing diff --git a/src/sensors/AtlasScientificDO.h b/src/sensors/AtlasScientificDO.h index 7d00e8078..ce7d2fe16 100644 --- a/src/sensors/AtlasScientificDO.h +++ b/src/sensors/AtlasScientificDO.h @@ -72,6 +72,16 @@ /** @ingroup sensor_atlas_do */ /**@{*/ +/** + * @anchor sensor_atlas_do_config + * @name Configuration Defines + * Defines to configure and set the address of the Atlas DO sensor + */ +/**@{*/ +/// @brief The default I2C address of the Atlas DO sensor is 0x61 (97) +#define ATLAS_DO_I2C_ADDR 0x61 +/**@}*/ + /** * @anchor sensor_atlas_do_var_counts * @name Sensor Variable Counts @@ -85,16 +95,6 @@ #define ATLAS_DO_INC_CALC_VARIABLES 0 /**@}*/ -/** - * @anchor sensor_atlas_do_config - * @name Configuration Defines - * Defines to configure and set the address of the Atlas DO sensor - */ -/**@{*/ -/// @brief The default I2C address of the Atlas DO sensor is 0x61 (97) -#define ATLAS_DO_I2C_ADDR 0x61 -/**@}*/ - /** * @anchor sensor_atlas_do_timing * @name Sensor Timing diff --git a/src/sensors/AtlasScientificEC.h b/src/sensors/AtlasScientificEC.h index 1eb810cb1..70ef9f746 100644 --- a/src/sensors/AtlasScientificEC.h +++ b/src/sensors/AtlasScientificEC.h @@ -80,6 +80,18 @@ /** @ingroup sensor_atlas_cond */ /**@{*/ +/** + * @anchor sensor_atlas_cond_config + * @name Configuration Defines + * Defines to configure and set the address of the Atlas conductivity + * sensor + */ +/**@{*/ +/// @brief The default I2C address of the Atlas conductivity sensor is 0x64 +/// (100) +#define ATLAS_COND_I2C_ADDR 0x64 +/**@}*/ + /** * @anchor sensor_atlas_cond_var_counts * @name Sensor Variable Counts @@ -95,18 +107,6 @@ #define ATLAS_COND_INC_CALC_VARIABLES 0 /**@}*/ -/** - * @anchor sensor_atlas_cond_config - * @name Configuration Defines - * Defines to configure and set the address of the Atlas conductivity - * sensor - */ -/**@{*/ -/// @brief The default I2C address of the Atlas conductivity sensor is 0x64 -/// (100) -#define ATLAS_COND_I2C_ADDR 0x64 -/**@}*/ - /** * @anchor sensor_atlas_cond_timing * @name Sensor Timing diff --git a/src/sensors/AtlasScientificORP.h b/src/sensors/AtlasScientificORP.h index 6e1cbd703..29bf1604b 100644 --- a/src/sensors/AtlasScientificORP.h +++ b/src/sensors/AtlasScientificORP.h @@ -49,6 +49,16 @@ /** @ingroup sensor_atlas_orp */ /**@{*/ +/** + * @anchor sensor_atlas_orp_config + * @name Configuration Defines + * Defines to configure and set the address of the Atlas ORP sensor + */ +/**@{*/ +/// @brief The default I2C address of the Atlas ORP sensor is 0x62 (98) +#define ATLAS_ORP_I2C_ADDR 0x62 +/**@}*/ + /** * @anchor sensor_atlas_orp_var_counts * @name Sensor Variable Counts @@ -62,16 +72,6 @@ #define ATLAS_ORP_INC_CALC_VARIABLES 0 /**@}*/ -/** - * @anchor sensor_atlas_orp_config - * @name Configuration Defines - * Defines to configure and set the address of the Atlas ORP sensor - */ -/**@{*/ -/// @brief The default I2C address of the Atlas ORP sensor is 0x62 (98) -#define ATLAS_ORP_I2C_ADDR 0x62 -/**@}*/ - /** * @anchor sensor_atlas_orp_timing * @name Sensor Timing diff --git a/src/sensors/AtlasScientificRTD.h b/src/sensors/AtlasScientificRTD.h index e3023c5ab..9170f03d6 100644 --- a/src/sensors/AtlasScientificRTD.h +++ b/src/sensors/AtlasScientificRTD.h @@ -54,6 +54,17 @@ /** @ingroup sensor_atlas_rtd */ /**@{*/ +/** + * @anchor sensor_atlas_rtd_config + * @name Configuration Defines + * Defines to configure and set the address of the Atlas RTD (temperature) + * sensor + */ +/**@{*/ +/// @brief The default I2C address of the Atlas RTD sensor is 0x66 (102) +#define ATLAS_RTD_I2C_ADDR 0x66 +/**@}*/ + /** * @anchor sensor_atlas_rtd_var_counts * @name Sensor Variable Counts @@ -68,17 +79,6 @@ #define ATLAS_RTD_INC_CALC_VARIABLES 0 /**@}*/ -/** - * @anchor sensor_atlas_rtd_config - * @name Configuration Defines - * Defines to configure and set the address of the Atlas RTD (temperature) - * sensor - */ -/**@{*/ -/// @brief The default I2C address of the Atlas RTD sensor is 0x66 (102) -#define ATLAS_RTD_I2C_ADDR 0x66 -/**@}*/ - /** * @anchor sensor_atlas_rtd_timing * @name Sensor Timing diff --git a/src/sensors/AtlasScientificpH.h b/src/sensors/AtlasScientificpH.h index de978e48d..7ce159d07 100644 --- a/src/sensors/AtlasScientificpH.h +++ b/src/sensors/AtlasScientificpH.h @@ -51,6 +51,16 @@ /** @ingroup sensor_atlas_ph */ /**@{*/ +/** + * @anchor sensor_atlas_ph_config + * @name Configuration Defines + * Defines to configure and set the address of the Atlas pH sensor + */ +/**@{*/ +/// @brief The default I2C address of the Atlas pH sensor is 0x63 (99) +#define ATLAS_PH_I2C_ADDR 0x63 +/**@}*/ + /** * @anchor sensor_atlas_ph_var_counts * @name Sensor Variable Counts @@ -64,16 +74,6 @@ #define ATLAS_PH_INC_CALC_VARIABLES 0 /**@}*/ -/** - * @anchor sensor_atlas_ph_config - * @name Configuration Defines - * Defines to configure and set the address of the Atlas pH sensor - */ -/**@{*/ -/// @brief The default I2C address of the Atlas pH sensor is 0x63 (99) -#define ATLAS_PH_I2C_ADDR 0x63 -/**@}*/ - /** * @anchor sensor_atlas_ph_timing * @name Sensor Timing diff --git a/src/sensors/EverlightALSPT19.h b/src/sensors/EverlightALSPT19.h index 3f755056f..ce07ea32d 100644 --- a/src/sensors/EverlightALSPT19.h +++ b/src/sensors/EverlightALSPT19.h @@ -79,20 +79,6 @@ /** @ingroup sensor_alspt19 */ /**@{*/ -/** - * @anchor sensor_alspt19_var_counts - * @name Sensor Variable Counts - * The number of variables that can be returned by an ALS-PT19 - */ -/**@{*/ -/// @brief Sensor::_numReturnedValues; the ALS-PT19 can report 1 "raw" value -/// (voltage) and we calculate current and illuminance from it. -#define ALSPT19_NUM_VARIABLES 3 -/// @brief Sensor::_incCalcValues; we calculate photocurrent from the supply -/// voltage and loading resistance and illuminance from the photocurrent. -#define ALSPT19_INC_CALC_VARIABLES 2 -/**@}*/ - /** * @anchor sensor_alspt19_config * @name Configuration Defines @@ -119,6 +105,20 @@ #endif /**@}*/ +/** + * @anchor sensor_alspt19_var_counts + * @name Sensor Variable Counts + * The number of variables that can be returned by an ALS-PT19 + */ +/**@{*/ +/// @brief Sensor::_numReturnedValues; the ALS-PT19 can report 1 "raw" value +/// (voltage) and we calculate current and illuminance from it. +#define ALSPT19_NUM_VARIABLES 3 +/// @brief Sensor::_incCalcValues; we calculate photocurrent from the supply +/// voltage and loading resistance and illuminance from the photocurrent. +#define ALSPT19_INC_CALC_VARIABLES 2 +/**@}*/ + /** * @anchor sensor_alspt19_timing * @name Sensor Timing diff --git a/src/sensors/TIINA219.h b/src/sensors/TIINA219.h index ad2ae8a0e..706019a3e 100644 --- a/src/sensors/TIINA219.h +++ b/src/sensors/TIINA219.h @@ -86,6 +86,16 @@ /** @ingroup sensor_ina219 */ /**@{*/ +/** + * @anchor sensor_ina219_config + * @name Configuration Defines + * Defines to set the address of the INA219. + */ +/**@{*/ +/// @brief The default address of the INA219 +#define INA219_ADDRESS_BASE 0x40 +/**@}*/ + /** * @anchor sensor_ina219_var_counts * @name Sensor Variable Counts @@ -98,16 +108,6 @@ #define INA219_INC_CALC_VARIABLES 0 /**@}*/ -/** - * @anchor sensor_ina219_config - * @name Configuration Defines - * Defines to set the address of the INA219. - */ -/**@{*/ -/// @brief The default address of the INA219 -#define INA219_ADDRESS_BASE 0x40 -/**@}*/ - /** * @anchor sensor_ina219_timing * @name Sensor Timing diff --git a/src/sensors/TallyCounterI2C.h b/src/sensors/TallyCounterI2C.h index 8fd4bfcc2..10c76c9bf 100644 --- a/src/sensors/TallyCounterI2C.h +++ b/src/sensors/TallyCounterI2C.h @@ -96,6 +96,16 @@ /** @ingroup sensor_tally */ /**@{*/ +/** + * @anchor sensor_tally_config + * @name Configuration Defines + * Defines to set the address of the Tally event counter. + */ +/**@{*/ +/// @brief The default address of the Tally +#define TALLY_ADDRESS_BASE 0x33 +/**@}*/ + /** * @anchor sensor_tally_var_counts * @name Sensor Variable Counts @@ -108,16 +118,6 @@ #define TALLY_INC_CALC_VARIABLES 0 /**@}*/ -/** - * @anchor sensor_tally_config - * @name Configuration Defines - * Defines to set the address of the Tally event counter. - */ -/**@{*/ -/// @brief The default address of the Tally -#define TALLY_ADDRESS_BASE 0x33 -/**@}*/ - /** * @anchor sensor_tally_timing * @name Sensor Timing diff --git a/src/sensors/TurnerTurbidityPlus.h b/src/sensors/TurnerTurbidityPlus.h index 757f6bdff..02782d4d0 100644 --- a/src/sensors/TurnerTurbidityPlus.h +++ b/src/sensors/TurnerTurbidityPlus.h @@ -73,21 +73,6 @@ class AnalogVoltageBase; /** @ingroup sensor_turbidity_plus */ /**@{*/ -/** - * @anchor sensor_turbidity_plus_var_counts - * @name Sensor Variable Counts - * The number of variables that can be returned by Turbidity Plus - */ -/**@{*/ -/** - * @brief Sensor::_numReturnedValues; the Turbidity Plus can report 2 values. - */ -#define TURBIDITY_PLUS_NUM_VARIABLES 2 -/// @brief Sensor::_incCalcValues; turbidity is calculated from raw voltage -/// using the input calibration equation. -#define TURBIDITY_PLUS_INC_CALC_VARIABLES 1 -/**@}*/ - /** * @anchor sensor_turbidity_plus_config * @name Configuration Defines @@ -115,6 +100,21 @@ class AnalogVoltageBase; #endif /**@}*/ +/** + * @anchor sensor_turbidity_plus_var_counts + * @name Sensor Variable Counts + * The number of variables that can be returned by Turbidity Plus + */ +/**@{*/ +/** + * @brief Sensor::_numReturnedValues; the Turbidity Plus can report 2 values. + */ +#define TURBIDITY_PLUS_NUM_VARIABLES 2 +/// @brief Sensor::_incCalcValues; turbidity is calculated from raw voltage +/// using the input calibration equation. +#define TURBIDITY_PLUS_INC_CALC_VARIABLES 1 +/**@}*/ + /** * @anchor sensor_turbidity_plus_timing * @name Sensor Timing From 2066e94f8bb423fa1da668d681545ac992a267b4 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Tue, 3 Mar 2026 12:24:13 -0500 Subject: [PATCH 407/533] Decimal[s] places? Signed-off-by: Sara Damiano --- src/LoggerModem.h | 16 ++++++++-------- src/sensors/ANBpH.h | 16 ++++++++-------- src/sensors/AOSongAM2315.h | 4 ++-- src/sensors/AOSongDHT.h | 6 +++--- src/sensors/AlphasenseCO2.h | 8 ++++---- src/sensors/AnalogElecConductivity.h | 2 +- src/sensors/ApogeeSQ212.h | 8 ++++---- src/sensors/AtlasScientificCO2.h | 4 ++-- src/sensors/AtlasScientificDO.h | 4 ++-- src/sensors/AtlasScientificEC.h | 8 ++++---- src/sensors/AtlasScientificORP.h | 2 +- src/sensors/AtlasScientificRTD.h | 2 +- src/sensors/AtlasScientificpH.h | 2 +- src/sensors/BoschBME280.h | 8 ++++---- src/sensors/BoschBMP3xx.h | 6 +++--- src/sensors/CampbellClariVUE10.h | 6 +++--- src/sensors/CampbellOBS3.h | 8 ++++---- src/sensors/CampbellRainVUE10.h | 8 ++++---- src/sensors/Decagon5TM.h | 6 +++--- src/sensors/DecagonCTD.h | 6 +++--- src/sensors/DecagonES2.h | 4 ++-- src/sensors/EverlightALSPT19.h | 6 +++--- src/sensors/FreescaleMPL115A2.h | 4 ++-- src/sensors/GeoluxHydroCam.h | 4 ++-- src/sensors/GroPointGPLP8.h | 4 ++-- src/sensors/InSituRDO.h | 8 ++++---- src/sensors/InSituTrollSdi12a.h | 6 +++--- src/sensors/KellerAcculevel.h | 6 +++--- src/sensors/KellerNanolevel.h | 6 +++--- src/sensors/MaxBotixSonar.h | 2 +- src/sensors/MaximDS18.h | 2 +- src/sensors/MaximDS3231.h | 2 +- src/sensors/MeaSpecMS5803.h | 4 ++-- src/sensors/MeterHydros21.h | 6 +++--- src/sensors/MeterTeros11.h | 8 ++++---- src/sensors/PaleoTerraRedox.h | 2 +- src/sensors/ProcessorAnalog.h | 4 ++-- src/sensors/ProcessorStats.h | 8 ++++---- src/sensors/RainCounterI2C.h | 4 ++-- src/sensors/SensirionSHT4x.h | 4 ++-- src/sensors/TIADS1x15.h | 4 ++-- src/sensors/TIINA219.h | 6 +++--- src/sensors/TallyCounterI2C.h | 2 +- src/sensors/TurnerCyclops.h | 8 ++++---- src/sensors/TurnerTurbidityPlus.h | 8 ++++---- src/sensors/VegaPuls21.h | 10 +++++----- src/sensors/YosemitechY4000.h | 16 ++++++++-------- src/sensors/YosemitechY504.h | 6 +++--- src/sensors/YosemitechY510.h | 4 ++-- src/sensors/YosemitechY511.h | 4 ++-- src/sensors/YosemitechY513.h | 4 ++-- src/sensors/YosemitechY514.h | 4 ++-- src/sensors/YosemitechY520.h | 4 ++-- src/sensors/YosemitechY532.h | 6 +++--- src/sensors/YosemitechY533.h | 4 ++-- src/sensors/YosemitechY551.h | 6 +++--- src/sensors/YosemitechY560.h | 6 +++--- src/sensors/YosemitechY700.h | 4 ++-- src/sensors/ZebraTechDOpto.h | 6 +++--- 59 files changed, 168 insertions(+), 168 deletions(-) diff --git a/src/LoggerModem.h b/src/LoggerModem.h index da28f36a1..dff1d3001 100644 --- a/src/LoggerModem.h +++ b/src/LoggerModem.h @@ -72,7 +72,7 @@ */ /**@{*/ /** - * @brief Decimals places in string representation; RSSI should have 0. + * @brief Decimal places in string representation; RSSI should have 0. * * RSSI is a rough calculation, so it has 0 decimal place resolution */ @@ -100,7 +100,7 @@ */ /**@{*/ /** - * @brief Decimals places in string representation; percent signal should have + * @brief Decimal places in string representation; percent signal should have * 0. * * Percent signal is a rough calculation, so it has 0 decimal place resolution @@ -134,7 +134,7 @@ */ /**@{*/ /** - * @brief Decimals places in string representation; battery state should have 0. + * @brief Decimal places in string representation; battery state should have 0. * * Battery state is a code value; it has 0 decimal place resolution */ @@ -166,7 +166,7 @@ * {{ @ref Modem_BatteryPercent::Modem_BatteryPercent }} */ /**@{*/ -/// @brief Decimals places in string representation; battery charge percent +/// @brief Decimal places in string representation; battery charge percent /// should have 0. #define MODEM_BATTERY_PERCENT_RESOLUTION 0 /// @brief The bit mask for loggerModem::_pollModemMetaData to enable modem @@ -196,7 +196,7 @@ */ /**@{*/ /** - * @brief Decimals places in string representation; battery voltage should have + * @brief Decimal places in string representation; battery voltage should have * 0. * * No supported module has higher than 1mV resolution in battery reading. @@ -228,7 +228,7 @@ */ /**@{*/ /** - * @brief Decimals places in string representation; temperature should + * @brief Decimal places in string representation; temperature should * have 1. * * Most modules that can measure temperature measure to 0.1°C @@ -260,7 +260,7 @@ * {{ @ref Modem_ActivationDuration::Modem_ActivationDuration }} */ /**@{*/ -/// @brief Decimals places in string representation; total active time should +/// @brief Decimal places in string representation; total active time should /// have 3. #define MODEM_ACTIVATION_RESOLUTION 3 /// @brief The bit mask for loggerModem::_pollModemMetaData to enable modem @@ -287,7 +287,7 @@ * {{ @ref Modem_PoweredDuration::Modem_PoweredDuration }} */ /**@{*/ -/// @brief Decimals places in string representation; total powered time should +/// @brief Decimal places in string representation; total powered time should /// have 3. #define MODEM_POWERED_RESOLUTION 3 /// @brief The bit mask for loggerModem::_pollModemMetaData to enable modem diff --git a/src/sensors/ANBpH.h b/src/sensors/ANBpH.h index 3514c08a4..1089eb777 100644 --- a/src/sensors/ANBpH.h +++ b/src/sensors/ANBpH.h @@ -221,7 +221,7 @@ * {{ @ref ANBpH_pH::ANBpH_pH }} */ /**@{*/ -/// @brief Decimals places in string representation; soil moisture should have 1 +/// @brief Decimal places in string representation; soil moisture should have 1 /// - resolution is 0.01. #define ANB_PH_PH_RESOLUTION 2 /// @brief Sensor variable number; pH is stored in sensorValues[0]. @@ -245,7 +245,7 @@ * {{ @ref ANBpH_Temp::ANBpH_Temp }} */ /**@{*/ -/// @brief Decimals places in string representation; temperature should have 1 - +/// @brief Decimal places in string representation; temperature should have 1 - /// resolution is 0.01°C. #define ANB_PH_TEMP_RESOLUTION 2 /// @brief Sensor variable number; temperature is stored in sensorValues[1]. @@ -278,7 +278,7 @@ * {{ @ref ANBpH_Salinity::ANBpH_Salinity }} */ /**@{*/ -/// @brief Decimals places in string representation; salinity should have 2. +/// @brief Decimal places in string representation; salinity should have 2. #define ANB_PH_SALINITY_RESOLUTION 2 /// @brief Sensor variable number; salinity is stored in sensorValues[2]. #define ANB_PH_SALINITY_VAR_NUM 2 @@ -312,7 +312,7 @@ * {{ @ref ANBpH_SpCond::ANBpH_SpCond }} */ /**@{*/ -/// @brief Decimals places in string representation; specific conductance +/// @brief Decimal places in string representation; specific conductance /// should have 2. #define ANB_PH_SPCOND_RESOLUTION 2 /// @brief Sensor variable number; specific conductance is stored in @@ -349,7 +349,7 @@ * {{ @ref ANBpH_EC::ANBpH_EC }} */ /**@{*/ -/// @brief Decimals places in string representation; raw electrical conductivity +/// @brief Decimal places in string representation; raw electrical conductivity /// should have 2. #define ANB_PH_EC_RESOLUTION 3 /// @brief Sensor variable number; conductivity is stored in sensorValues[4]. @@ -393,7 +393,7 @@ */ /**@{*/ // clang-format on -/// @brief Decimals places in string representation; the health code has 0. +/// @brief Decimal places in string representation; the health code has 0. #define ANB_PH_HEALTH_CODE_RESOLUTION 0 /// @brief Sensor variable number; health code is stored in sensorValues[5] #define ANB_PH_HEALTH_CODE_VAR_NUM 5 @@ -429,7 +429,7 @@ */ /**@{*/ // clang-format on -/// @brief Decimals places in string representation; the diagnostic code has 0. +/// @brief Decimal places in string representation; the diagnostic code has 0. #define ANB_PH_DIAGNOSTIC_CODE_RESOLUTION 0 /// @brief Sensor variable number; diagnostic code is stored in sensorValues[6] #define ANB_PH_DIAGNOSTIC_CODE_VAR_NUM 6 @@ -466,7 +466,7 @@ */ /**@{*/ // clang-format on -/// @brief Decimals places in string representation; the error code has 0. +/// @brief Decimal places in string representation; the error code has 0. #define ANB_PH_STATUS_CODE_RESOLUTION 0 /// @brief Sensor variable number; error code is stored in sensorValues[7] #define ANB_PH_STATUS_CODE_VAR_NUM 7 diff --git a/src/sensors/AOSongAM2315.h b/src/sensors/AOSongAM2315.h index 2edaf734e..6f9ef4ffd 100644 --- a/src/sensors/AOSongAM2315.h +++ b/src/sensors/AOSongAM2315.h @@ -118,7 +118,7 @@ * {{ @ref AOSongAM2315_Humidity::AOSongAM2315_Humidity }} */ /**@{*/ -/// @brief Decimals places in string representation; humidity should have 1 (0.1 +/// @brief Decimal places in string representation; humidity should have 1 (0.1 /// % RH for the 16 bit sensor). #define AM2315_HUMIDITY_RESOLUTION 1 /// @brief Sensor variable number; humidity is stored in sensorValues[0]. @@ -145,7 +145,7 @@ * {{ @ref AOSongAM2315_Temp::AOSongAM2315_Temp }} */ /**@{*/ -/// @brief Decimals places in string representation; temperature should have 1. +/// @brief Decimal places in string representation; temperature should have 1. /// (0.1°C for the 16 bit sensor) #define AM2315_TEMP_RESOLUTION 1 /// @brief Sensor variable number; temperature is stored in sensorValues[1]. diff --git a/src/sensors/AOSongDHT.h b/src/sensors/AOSongDHT.h index 8dcde62bb..8e90ce000 100644 --- a/src/sensors/AOSongDHT.h +++ b/src/sensors/AOSongDHT.h @@ -167,7 +167,7 @@ static const uint8_t AM2301{21}; /**< AM2301 */ * {{ @ref AOSongDHT_Humidity::AOSongDHT_Humidity }} */ /**@{*/ -/// @brief Decimals places in string representation; humidity should have 1 (0.1 +/// @brief Decimal places in string representation; humidity should have 1 (0.1 /// % RH for DHT22 and 1 % RH for DHT11) #define DHT_HUMIDITY_RESOLUTION 1 /// @brief Sensor variable number; humidity is stored in sensorValues[0]. @@ -194,7 +194,7 @@ static const uint8_t AM2301{21}; /**< AM2301 */ * {{ @ref AOSongDHT_Temp::AOSongDHT_Temp }} */ /**@{*/ -/// @brief Decimals places in string representation; temperature should have 1 - +/// @brief Decimal places in string representation; temperature should have 1 - /// resolution is 0.1°C. #define DHT_TEMP_RESOLUTION 1 /// @brief Sensor variable number; temperature is stored in sensorValues[1]. @@ -221,7 +221,7 @@ static const uint8_t AM2301{21}; /**< AM2301 */ * {{ @ref AOSongDHT_HI::AOSongDHT_HI }} */ /**@{*/ -/// @brief Decimals places in string representation; heat index should have 1 - +/// @brief Decimal places in string representation; heat index should have 1 - /// resolution is 0.1°C #define DHT_HI_RESOLUTION 1 /// @brief Sensor variable number; HI is stored in sensorValues[2]. diff --git a/src/sensors/AlphasenseCO2.h b/src/sensors/AlphasenseCO2.h index cac614172..941f92392 100644 --- a/src/sensors/AlphasenseCO2.h +++ b/src/sensors/AlphasenseCO2.h @@ -201,11 +201,11 @@ class AnalogVoltageBase; /// @brief Default variable short code; "AlphasenseCO2ppm" #define ALPHASENSE_CO2_DEFAULT_CODE "AlphasenseCO2ppm" #ifdef MS_USE_ADS1015 -/// @brief Decimals places in string representation; CO2 should have 0 when +/// @brief Decimal places in string representation; CO2 should have 0 when /// using an ADS1015. #define ALPHASENSE_CO2_RESOLUTION 0 #else -/// @brief Decimals places in string representation; CO2 should have 4 when +/// @brief Decimal places in string representation; CO2 should have 4 when /// using an ADS1115. #define ALPHASENSE_CO2_RESOLUTION 4 #endif @@ -240,11 +240,11 @@ class AnalogVoltageBase; /// @brief Default variable short code; "AlphasenseCO2Voltage" #define ALPHASENSE_CO2_VOLTAGE_DEFAULT_CODE "AlphasenseCO2Voltage" #ifdef MS_USE_ADS1015 -/// @brief Decimals places in string representation; voltage should have 1 when +/// @brief Decimal places in string representation; voltage should have 1 when /// used with an ADS1015. #define ALPHASENSE_CO2_VOLTAGE_RESOLUTION 1 #else -/// @brief Decimals places in string representation; voltage should have 4 when +/// @brief Decimal places in string representation; voltage should have 4 when /// used with an ADS1115. #define ALPHASENSE_CO2_VOLTAGE_RESOLUTION 4 #endif diff --git a/src/sensors/AnalogElecConductivity.h b/src/sensors/AnalogElecConductivity.h index 8f9b0636c..9c4704499 100644 --- a/src/sensors/AnalogElecConductivity.h +++ b/src/sensors/AnalogElecConductivity.h @@ -268,7 +268,7 @@ static_assert( */ /**@{*/ /** - * @brief Decimals places in string representation; EC should have 1 + * @brief Decimal places in string representation; EC should have 1 * * Range of 0-3V3 with 10bit ADC - resolution of 0.003 = 3 µS/cm. */ diff --git a/src/sensors/ApogeeSQ212.h b/src/sensors/ApogeeSQ212.h index 3e2c3c1bb..c8ffc217b 100644 --- a/src/sensors/ApogeeSQ212.h +++ b/src/sensors/ApogeeSQ212.h @@ -171,11 +171,11 @@ class AnalogVoltageBase; */ /**@{*/ #ifdef MS_USE_ADS1015 -/// @brief Decimals places in string representation; PAR should have 0 when +/// @brief Decimal places in string representation; PAR should have 0 when /// using an ADS1015. #define SQ212_PAR_RESOLUTION 0 #else -/// @brief Decimals places in string representation; PAR should have 4 when +/// @brief Decimal places in string representation; PAR should have 4 when /// using an ADS1115. #define SQ212_PAR_RESOLUTION 4 #endif @@ -222,11 +222,11 @@ class AnalogVoltageBase; /// @brief Default variable short code; "SQ212Voltage" #define SQ212_VOLTAGE_DEFAULT_CODE "SQ212Voltage" #ifdef MS_USE_ADS1015 -/// @brief Decimals places in string representation; voltage should have 1 when +/// @brief Decimal places in string representation; voltage should have 1 when /// used with an ADS1015. #define SQ212_VOLTAGE_RESOLUTION 1 #else -/// @brief Decimals places in string representation; voltage should have 4 when +/// @brief Decimal places in string representation; voltage should have 4 when /// used with an ADS1115. #define SQ212_VOLTAGE_RESOLUTION 4 #endif diff --git a/src/sensors/AtlasScientificCO2.h b/src/sensors/AtlasScientificCO2.h index 61bc70a9f..37ebb02d3 100644 --- a/src/sensors/AtlasScientificCO2.h +++ b/src/sensors/AtlasScientificCO2.h @@ -122,7 +122,7 @@ * {{ @ref AtlasScientificCO2_CO2::AtlasScientificCO2_CO2 }} */ /**@{*/ -/// @brief Decimals places in string representation; CO2 should have 1 - +/// @brief Decimal places in string representation; CO2 should have 1 - /// resolution is 1 ppm. #define ATLAS_CO2_RESOLUTION 1 /// @brief Sensor variable number; CO2 is stored in sensorValues[0]. @@ -149,7 +149,7 @@ * {{ @ref AtlasScientificCO2_Temp::AtlasScientificCO2_Temp }} */ /**@{*/ -/// @brief Decimals places in string representation; CO2TEMP should have 0 - +/// @brief Decimal places in string representation; CO2TEMP should have 0 - /// resolution is 1°C. #define ATLAS_CO2TEMP_RESOLUTION 0 /// @brief Sensor variable number; CO2TEMP is stored in sensorValues[1]. diff --git a/src/sensors/AtlasScientificDO.h b/src/sensors/AtlasScientificDO.h index ce7d2fe16..08157e234 100644 --- a/src/sensors/AtlasScientificDO.h +++ b/src/sensors/AtlasScientificDO.h @@ -131,7 +131,7 @@ * {{ @ref AtlasScientificDO_DOmgL::AtlasScientificDO_DOmgL }} */ /**@{*/ -/// @brief Decimals places in string representation; dissolved oxygen +/// @brief Decimal places in string representation; dissolved oxygen /// concentration should have 2 - resolution is 0.01 mg/L. #define ATLAS_DOMGL_RESOLUTION 2 /// @brief Sensor variable number; dissolved oxygen concentration is stored in @@ -159,7 +159,7 @@ * {{ @ref AtlasScientificDO_DOpct::AtlasScientificDO_DOpct }} */ /**@{*/ -/// @brief Decimals places in string representation; dissolved oxygen percent +/// @brief Decimal places in string representation; dissolved oxygen percent /// should have 1 - resolution is 0.1 % saturation. #define ATLAS_DOPCT_RESOLUTION 1 /// @brief Sensor variable number; dissolved oxygen percent is stored in diff --git a/src/sensors/AtlasScientificEC.h b/src/sensors/AtlasScientificEC.h index 70ef9f746..435a5082b 100644 --- a/src/sensors/AtlasScientificEC.h +++ b/src/sensors/AtlasScientificEC.h @@ -142,7 +142,7 @@ * {{ @ref AtlasScientificEC_Cond::AtlasScientificEC_Cond }} */ /**@{*/ -/// @brief Decimals places in string representation; conductivity should have 3. +/// @brief Decimal places in string representation; conductivity should have 3. #define ATLAS_COND_RESOLUTION 3 /// @brief Sensor variable number; conductivity is stored in sensorValues[0]. #define ATLAS_COND_VAR_NUM 0 @@ -168,7 +168,7 @@ * {{ @ref AtlasScientificEC_TDS::AtlasScientificEC_TDS }} */ /**@{*/ -/// @brief Decimals places in string representation; TDS should have 3. +/// @brief Decimal places in string representation; TDS should have 3. #define ATLAS_TDS_RESOLUTION 3 /// @brief Sensor variable number; TDS is stored in sensorValues[1]. #define ATLAS_TDS_VAR_NUM 1 @@ -194,7 +194,7 @@ * {{ @ref AtlasScientificEC_Salinity::AtlasScientificEC_Salinity }} */ /**@{*/ -/// @brief Decimals places in string representation; salinity should have 3. +/// @brief Decimal places in string representation; salinity should have 3. #define ATLAS_SALINITY_RESOLUTION 3 /// @brief Sensor variable number; salinity is stored in sensorValues[2]. #define ATLAS_SALINITY_VAR_NUM 2 @@ -222,7 +222,7 @@ */ /* clang-format on */ /**@{*/ -/// @brief Decimals places in string representation; specific gravity should +/// @brief Decimal places in string representation; specific gravity should /// have 3. #define ATLAS_SG_RESOLUTION 3 /// @brief Sensor variable number; specific gravity is stored in diff --git a/src/sensors/AtlasScientificORP.h b/src/sensors/AtlasScientificORP.h index 29bf1604b..f84a0f4c4 100644 --- a/src/sensors/AtlasScientificORP.h +++ b/src/sensors/AtlasScientificORP.h @@ -109,7 +109,7 @@ * {{ @ref AtlasScientificORP_Potential::AtlasScientificORP_Potential }} */ /**@{*/ -/// @brief Decimals places in string representation; ORP should have 1 - +/// @brief Decimal places in string representation; ORP should have 1 - /// resolution is 0.1 mV. #define ATLAS_ORP_RESOLUTION 1 /// @brief Sensor variable number; ORP is stored in sensorValues[0]. diff --git a/src/sensors/AtlasScientificRTD.h b/src/sensors/AtlasScientificRTD.h index 9170f03d6..8ffad41b1 100644 --- a/src/sensors/AtlasScientificRTD.h +++ b/src/sensors/AtlasScientificRTD.h @@ -117,7 +117,7 @@ * {{ @ref AtlasScientificRTD_Temp::AtlasScientificRTD_Temp }} */ /**@{*/ -/// @brief Decimals places in string representation; temperature should have 3 - +/// @brief Decimal places in string representation; temperature should have 3 - /// resolution is 0.001°C. #define ATLAS_RTD_RESOLUTION 3 /// @brief Sensor variable number; RTD is stored in sensorValues[0]. diff --git a/src/sensors/AtlasScientificpH.h b/src/sensors/AtlasScientificpH.h index 7ce159d07..84fd9ee02 100644 --- a/src/sensors/AtlasScientificpH.h +++ b/src/sensors/AtlasScientificpH.h @@ -113,7 +113,7 @@ * {{ @ref AtlasScientificpH_pH::AtlasScientificpH_pH }} */ /**@{*/ -/// @brief Decimals places in string representation; pH should have 3 - +/// @brief Decimal places in string representation; pH should have 3 - /// resolution is 0.001. #define ATLAS_PH_RESOLUTION 3 /// @brief Sensor variable number; pH is stored in sensorValues[0]. diff --git a/src/sensors/BoschBME280.h b/src/sensors/BoschBME280.h index e3a45cfb1..25bc9e998 100644 --- a/src/sensors/BoschBME280.h +++ b/src/sensors/BoschBME280.h @@ -175,7 +175,7 @@ * {{ @ref BoschBME280_Temp::BoschBME280_Temp }} */ /**@{*/ -/// @brief Decimals places in string representation; temperature should have 2 - +/// @brief Decimal places in string representation; temperature should have 2 - /// resolution is 0.01°C. #define BME280_TEMP_RESOLUTION 2 /// @brief Sensor variable number; temperature is stored in sensorValues[0]. @@ -200,7 +200,7 @@ * {{ @ref BoschBME280_Humidity::BoschBME280_Humidity }} */ /**@{*/ -/// @brief Decimals places in string representation; humidity should have 3- +/// @brief Decimal places in string representation; humidity should have 3- /// resolution is 0.008 % RH (16 bit). #define BME280_HUMIDITY_RESOLUTION 3 /// @brief Sensor variable number; humidity is stored in sensorValues[1]. @@ -228,7 +228,7 @@ * {{ @ref BoschBME280_Pressure::BoschBME280_Pressure }} */ /**@{*/ -/// @brief Decimals places in string representation; barometric pressure should +/// @brief Decimal places in string representation; barometric pressure should /// have 2. #define BME280_PRESSURE_RESOLUTION 2 /// @brief Sensor variable number; pressure is stored in sensorValues[2]. @@ -253,7 +253,7 @@ * {{ @ref BoschBME280_Altitude::BoschBME280_Altitude }} */ /**@{*/ -/// @brief Decimals places in string representation; altitude should have 0 - +/// @brief Decimal places in string representation; altitude should have 0 - /// resolution is 1m. #define BME280_ALTITUDE_RESOLUTION 0 /// @brief Sensor variable number; altitude is stored in sensorValues[3]. diff --git a/src/sensors/BoschBMP3xx.h b/src/sensors/BoschBMP3xx.h index b8c06fb17..10cd3f0bc 100644 --- a/src/sensors/BoschBMP3xx.h +++ b/src/sensors/BoschBMP3xx.h @@ -254,7 +254,7 @@ * {{ @ref BoschBMP3xx_Temp::BoschBMP3xx_Temp }} */ /**@{*/ -/// @brief Decimals places in string representation; temperature should have 5 - +/// @brief Decimal places in string representation; temperature should have 5 - /// resolution is 0.0.00015°C at the hightest oversampling. See table 7 in the /// [sensor /// datasheet](https://github.com/EnviroDIY/ModularSensors/wiki/Sensor-Datasheets/Bosch-BMP390-Datasheet.pdf) @@ -285,7 +285,7 @@ * {{ @ref BoschBMP3xx_Pressure::BoschBMP3xx_Pressure }} */ /**@{*/ -/// @brief Decimals places in string representation; barometric pressure should +/// @brief Decimal places in string representation; barometric pressure should /// have 3. Resolution of output data in highest resolution mode at lowest /// bandwidth is 0.016 Pa. See table 6 in the [sensor /// datasheet](https://github.com/EnviroDIY/ModularSensors/wiki/Sensor-Datasheets/Bosch-BMP390-Datasheet.pdf) @@ -313,7 +313,7 @@ * {{ @ref BoschBMP3xx_Altitude::BoschBMP3xx_Altitude }} */ /**@{*/ -/// @brief Decimals places in string representation; altitude should have 0 - +/// @brief Decimal places in string representation; altitude should have 0 - /// resolution is 1m. #define BMP3XX_ALTITUDE_RESOLUTION 0 /// @brief Sensor variable number; altitude is stored in sensorValues[2]. diff --git a/src/sensors/CampbellClariVUE10.h b/src/sensors/CampbellClariVUE10.h index 5f38ceb57..c97c127e3 100644 --- a/src/sensors/CampbellClariVUE10.h +++ b/src/sensors/CampbellClariVUE10.h @@ -119,7 +119,7 @@ * {{ @ref CampbellClariVUE10_Turbidity::CampbellClariVUE10_Turbidity }} */ /**@{*/ -/// @brief Decimals places in string representation; turbidity should have 1 +/// @brief Decimal places in string representation; turbidity should have 1 /// (resolution is 0.2 FNU). #define CLARIVUE10_TURBIDITY_RESOLUTION 1 /// @brief Sensor variable number; turbidity is stored in sensorValues[0] @@ -146,7 +146,7 @@ * {{ @ref CampbellClariVUE10_Temp::CampbellClariVUE10_Temp }} */ /**@{*/ -/// @brief Decimals places in string representation; temperature should have 2 - +/// @brief Decimal places in string representation; temperature should have 2 - /// resolution is 0.01°C. #define CLARIVUE10_TEMP_RESOLUTION 2 /// @brief Sensor variable number; temperature is stored in sensorValues[5]. @@ -172,7 +172,7 @@ * {{ @ref CampbellClariVUE10_ErrorCode::CampbellClariVUE10_ErrorCode }} */ /**@{*/ -/// @brief Decimals places in string representation; the error code has 0. +/// @brief Decimal places in string representation; the error code has 0. #define CLARIVUE10_ERRORCODE_RESOLUTION 0 /// @brief Sensor variable number; error code is stored in sensorValues[2] #define CLARIVUE10_ERRORCODE_VAR_NUM 6 diff --git a/src/sensors/CampbellOBS3.h b/src/sensors/CampbellOBS3.h index 2214ed059..9da48559b 100644 --- a/src/sensors/CampbellOBS3.h +++ b/src/sensors/CampbellOBS3.h @@ -158,10 +158,10 @@ class AnalogVoltageBase; /// Variable number; turbidity is stored in sensorValues[0]. #define OBS3_TURB_VAR_NUM 0 #ifdef MS_USE_ADS1015 -/// @brief Decimals places in string representation; turbidity should have 1. +/// @brief Decimal places in string representation; turbidity should have 1. #define OBS3_RESOLUTION 1 #else -/// @brief Decimals places in string representation; turbidity should have 5. +/// @brief Decimal places in string representation; turbidity should have 5. #define OBS3_RESOLUTION 5 #endif /// @brief Variable name in @@ -204,12 +204,12 @@ class AnalogVoltageBase; #define OBS3_VOLTAGE_DEFAULT_CODE "OBS3Voltage" #ifdef MS_USE_ADS1015 -/// @brief Decimals places in string representation; voltage should have 1. +/// @brief Decimal places in string representation; voltage should have 1. /// - Resolution: /// - 16-bit ADC (ADS1115): 0.125 mV #define OBS3_VOLTAGE_RESOLUTION 1 #else -/// @brief Decimals places in string representation; voltage should have 4. +/// @brief Decimal places in string representation; voltage should have 4. /// - Resolution: /// - 12-bit ADC (ADS1015, using build flag ```MS_USE_ADS1015```): 2 mV #define OBS3_VOLTAGE_RESOLUTION 4 diff --git a/src/sensors/CampbellRainVUE10.h b/src/sensors/CampbellRainVUE10.h index f6e0b34af..0cc1b22f2 100644 --- a/src/sensors/CampbellRainVUE10.h +++ b/src/sensors/CampbellRainVUE10.h @@ -122,7 +122,7 @@ * {{ @ref CampbellRainVUE10_Precipitation::CampbellRainVUE10_Precipitation }} */ /**@{*/ -/// @brief Decimals places in string representation; depth should have 2 +/// @brief Decimal places in string representation; depth should have 2 /// (resolution is 0.01 inches). #define RAINVUE10_PRECIPITATION_RESOLUTION 2 /// @brief Sensor variable number; precipitation is stored in sensorValues[0] @@ -148,7 +148,7 @@ * {{ @ref CampbellRainVUE10_Tips::CampbellRainVUE10_Tips }} */ /**@{*/ -/// @brief Decimals places in string representation; the number of tips should +/// @brief Decimal places in string representation; the number of tips should /// have 0 - resolution is 1 tip. #define RAINVUE10_TIPS_RESOLUTION 0 /// @brief Sensor variable number; tips is stored in sensorValues[1]. @@ -183,7 +183,7 @@ * {{ @ref CampbellRainVUE10_RainRateAve::CampbellRainVUE10_RainRateAve }} */ /**@{*/ -/// @brief Decimals places in string representation; the rainfall intensity +/// @brief Decimal places in string representation; the rainfall intensity /// has 2. #define RAINVUE10_RAINRATEAVE_RESOLUTION 2 /// @brief Sensor variable number; average intensity is stored in @@ -210,7 +210,7 @@ * {{ @ref CampbellRainVUE10_RainRateMax::CampbellRainVUE10_RainRateMax }} */ /**@{*/ -/// @brief Decimals places in string representation; the rainfall intensity +/// @brief Decimal places in string representation; the rainfall intensity /// has 2. #define RAINVUE10_RAINRATEMAX_RESOLUTION 2 /// @brief Sensor variable number; average intensity is stored in diff --git a/src/sensors/Decagon5TM.h b/src/sensors/Decagon5TM.h index fe037a4b3..409a3d654 100644 --- a/src/sensors/Decagon5TM.h +++ b/src/sensors/Decagon5TM.h @@ -133,7 +133,7 @@ */ /**@{*/ /** - * @brief Decimals places in string representation; EA should have 5 + * @brief Decimal places in string representation; EA should have 5 * * 4 are reported, adding extra digit to resolution to allow the proper number * of significant figures for averaging - resolution is 0.0008 m3/m3 (0.08% VWC) @@ -165,7 +165,7 @@ */ /**@{*/ /** - * @brief Decimals places in string representation; temperature should have 2 + * @brief Decimal places in string representation; temperature should have 2 * * 1 is reported, adding extra digit to resolution to allow the proper number * of significant figures for averaging - resolution is 0.1°C. @@ -197,7 +197,7 @@ */ /**@{*/ /** - * @brief Decimals places in string representation; VWC should have 3 + * @brief Decimal places in string representation; VWC should have 3 * * 2 are reported, adding extra digit to resolution to allow the proper number * of significant figures for averaging - resolution is 0.0008 m3/m3 (0.08% VWC) diff --git a/src/sensors/DecagonCTD.h b/src/sensors/DecagonCTD.h index 105cdc05f..f37d6cf6e 100644 --- a/src/sensors/DecagonCTD.h +++ b/src/sensors/DecagonCTD.h @@ -110,7 +110,7 @@ */ /**@{*/ /** - * @brief Decimals places in string representation; conductivity should have 1. + * @brief Decimal places in string representation; conductivity should have 1. * * 0 are reported, adding extra digit to resolution to allow the proper number * of significant figures for averaging - resolution is 0.001 mS/cm = 1 µS/cm @@ -141,7 +141,7 @@ */ /**@{*/ /** - * @brief Decimals places in string representation; temperature should have 2. + * @brief Decimal places in string representation; temperature should have 2. * * 1 is reported, adding extra digit to resolution to allow the proper number * of significant figures for averaging - resolution is 0.1°C @@ -172,7 +172,7 @@ */ /**@{*/ /** - * @brief Decimals places in string representation; depth should have 1. + * @brief Decimal places in string representation; depth should have 1. * * 0 are reported, adding extra digit to resolution to allow the proper number * of significant figures for averaging - resolution is 2 mm diff --git a/src/sensors/DecagonES2.h b/src/sensors/DecagonES2.h index 96bbd9ec8..e16f7093b 100644 --- a/src/sensors/DecagonES2.h +++ b/src/sensors/DecagonES2.h @@ -105,7 +105,7 @@ */ /**@{*/ /** - * @brief Decimals places in string representation; conductivity should have 1. + * @brief Decimal places in string representation; conductivity should have 1. * * 0 are reported, adding extra digit to resolution to allow the proper number * of significant figures for averaging - resolution is 0.001 mS/cm = 1 µS/cm @@ -136,7 +136,7 @@ */ /**@{*/ /** - * @brief Decimals places in string representation; temperature should have 2. + * @brief Decimal places in string representation; temperature should have 2. * * 1 is reported, adding extra digit to resolution to allow the proper number * of significant figures for averaging - resolution is 0.1°C diff --git a/src/sensors/EverlightALSPT19.h b/src/sensors/EverlightALSPT19.h index ce07ea32d..217a3a361 100644 --- a/src/sensors/EverlightALSPT19.h +++ b/src/sensors/EverlightALSPT19.h @@ -147,7 +147,7 @@ */ /**@{*/ /** - * @brief Decimals places in string representation; voltage should have 0 + * @brief Decimal places in string representation; voltage should have 0 * * The true resolution depends on the ADC, the supply voltage, and the loading * resistor, but for simplicity we will use 3, which is an appropriate value for @@ -178,7 +178,7 @@ */ /**@{*/ /** - * @brief Decimals places in string representation; voltage should have 0 + * @brief Decimal places in string representation; voltage should have 0 * * The true resolution depends on the ADC, the supply voltage, and the loading * resistor, but for simplicity we will use 0 as this is not a high precision @@ -209,7 +209,7 @@ */ /**@{*/ /** - * @brief Decimals places in string representation; illuminance should have 0 + * @brief Decimal places in string representation; illuminance should have 0 * * The true resolution depends on the ADC, the supply voltage, the loading * resistor, and the light source, but for simplicity we will use 0 as this is diff --git a/src/sensors/FreescaleMPL115A2.h b/src/sensors/FreescaleMPL115A2.h index 4d6af6516..dd5a45f8c 100644 --- a/src/sensors/FreescaleMPL115A2.h +++ b/src/sensors/FreescaleMPL115A2.h @@ -125,7 +125,7 @@ * {{ @ref FreescaleMPL115A2_Temp::FreescaleMPL115A2_Temp }} */ /**@{*/ -/// @brief Decimals places in string representation; temperature should have 2 - +/// @brief Decimal places in string representation; temperature should have 2 - /// resolution is 0.01°C. #define MPL115A2_TEMP_RESOLUTION 2 /// @brief Sensor variable number; temperature is stored in sensorValues[0]. @@ -152,7 +152,7 @@ * {{ @ref FreescaleMPL115A2_Pressure::FreescaleMPL115A2_Pressure }} */ /**@{*/ -/// @brief Decimals places in string representation; pressure should have 2 - +/// @brief Decimal places in string representation; pressure should have 2 - /// resolution is 1.5 hPa. #define MPL115A2_PRESSURE_RESOLUTION 2 /// @brief Sensor variable number; pressure is stored in sensorValues[1]. diff --git a/src/sensors/GeoluxHydroCam.h b/src/sensors/GeoluxHydroCam.h index 899f6b1fe..a42865e1f 100644 --- a/src/sensors/GeoluxHydroCam.h +++ b/src/sensors/GeoluxHydroCam.h @@ -172,7 +172,7 @@ * {{ @ref GeoluxHydroCam_ImageSize::GeoluxHydroCam_ImageSize }} */ /**@{*/ -/// @brief Decimals places in string representation; image size should have 0 - +/// @brief Decimal places in string representation; image size should have 0 - /// resolution is 1 byte. #define HYDROCAM_SIZE_RESOLUTION 0 /// @brief Sensor variable number; image size is stored in sensorValues[0]. @@ -198,7 +198,7 @@ * {{ @ref GeoluxHydroCam_ByteError::GeoluxHydroCam_ByteError }} */ /**@{*/ -/// @brief Decimals places in string representation; byte error should have +/// @brief Decimal places in string representation; byte error should have /// 0 - resolution is 1 byte. #define HYDROCAM_ERROR_RESOLUTION 0 /// @brief Sensor variable number; byte error is stored in sensorValues[1]. diff --git a/src/sensors/GroPointGPLP8.h b/src/sensors/GroPointGPLP8.h index 7a0ea8d07..254b3040d 100644 --- a/src/sensors/GroPointGPLP8.h +++ b/src/sensors/GroPointGPLP8.h @@ -101,7 +101,7 @@ * {{ @ref GroPointGPLP8_Moist::GroPointGPLP8_Moist }} */ /**@{*/ -/// @brief Decimals places in string representation; soil moisture should have 1 +/// @brief Decimal places in string representation; soil moisture should have 1 /// - resolution is 0.1 %. #define GPLP8_MOIST_RESOLUTION 1 /// @brief Variable name in @@ -124,7 +124,7 @@ * {{ @ref GroPointGPLP8_Temp::GroPointGPLP8_Temp }} */ /**@{*/ -/// @brief Decimals places in string representation; temperature should have 1 - +/// @brief Decimal places in string representation; temperature should have 1 - /// resolution is 0.1°C. #define GPLP8_TEMP_RESOLUTION 1 /// @brief Variable name in diff --git a/src/sensors/InSituRDO.h b/src/sensors/InSituRDO.h index b3f5eaf6d..5cb8cd704 100644 --- a/src/sensors/InSituRDO.h +++ b/src/sensors/InSituRDO.h @@ -225,7 +225,7 @@ */ /**@{*/ /** - * @brief Decimals places in string representation; dissolved oxygen + * @brief Decimal places in string representation; dissolved oxygen * concentration should have 2 - resolution is 0.01 mg/L. * * Contrary to the spec sheet, the actual resolution returned by the sensor in @@ -264,7 +264,7 @@ */ /**@{*/ /** - * @brief Decimals places in string representation; dissolved oxygen percent + * @brief Decimal places in string representation; dissolved oxygen percent * saturation should have 1. * * The actual resolution returned by the sensor in SDI-12 mode is 0.00001 %. @@ -299,7 +299,7 @@ /**@{*/ /// @brief /** - * @brief Decimals places in string representation; temperature should have 2 - + * @brief Decimal places in string representation; temperature should have 2 - * resolution is 0.01°C. * * The spec sheet lists 2 decimal resolution, but the returned value has 5. @@ -332,7 +332,7 @@ * {{ @ref InSituRDO_Pressure::InSituRDO_Pressure }} */ /**@{*/ -/// @brief Decimals places in string representation; pressure should have 3 +/// @brief Decimal places in string representation; pressure should have 3 #define INSITU_RDO_PRESSURE_RESOLUTION 2 /// @brief Variable number; temperature is stored in sensorValues[3]. #define INSITU_RDO_PRESSURE_VAR_NUM 3 diff --git a/src/sensors/InSituTrollSdi12a.h b/src/sensors/InSituTrollSdi12a.h index fc2ace370..801a26b90 100644 --- a/src/sensors/InSituTrollSdi12a.h +++ b/src/sensors/InSituTrollSdi12a.h @@ -124,7 +124,7 @@ */ /**@{*/ /** - * @brief Decimals places in string representation; conductivity should have 1. + * @brief Decimal places in string representation; conductivity should have 1. * * 0 are reported, adding extra digit to resolution to allow the proper number * of significant figures for averaging - resolution is 0.001 mS/cm = 1 µS/cm @@ -155,7 +155,7 @@ */ /**@{*/ /** - * @brief Decimals places in string representation; temperature should have 2. + * @brief Decimal places in string representation; temperature should have 2. * * 1 is reported, adding extra digit to resolution to allow the proper number * of significant figures for averaging - resolution is 0.1°C @@ -186,7 +186,7 @@ */ /**@{*/ /** - * @brief Decimals places in string representation; depth should have 1. + * @brief Decimal places in string representation; depth should have 1. * * 0 are reported, adding extra digit to resolution to allow the proper number * of significant figures for averaging - resolution is 2 mm diff --git a/src/sensors/KellerAcculevel.h b/src/sensors/KellerAcculevel.h index fabf79f6e..a2303c753 100644 --- a/src/sensors/KellerAcculevel.h +++ b/src/sensors/KellerAcculevel.h @@ -83,7 +83,7 @@ * {{ @ref KellerAcculevel_Pressure::KellerAcculevel_Pressure }} */ /**@{*/ -/// @brief Decimals places in string representation; pressure should have 5 - +/// @brief Decimal places in string representation; pressure should have 5 - /// resolution is 0.002%. #define ACCULEVEL_PRESSURE_RESOLUTION 5 /// @brief Default variable short code; "kellerAccuPress" @@ -100,7 +100,7 @@ * {{ @ref KellerAcculevel_Temp::KellerAcculevel_Temp }} */ /**@{*/ -/// @brief Decimals places in string representation; temperature should have 2 - +/// @brief Decimal places in string representation; temperature should have 2 - /// resolution is 0.01°C. #define ACCULEVEL_TEMP_RESOLUTION 2 /// @brief Default variable short code; "kellerAccuTemp" @@ -117,7 +117,7 @@ * {{ @ref KellerAcculevel_Height::KellerAcculevel_Height }} */ /**@{*/ -/// @brief Decimals places in string representation; height should have 4 - +/// @brief Decimal places in string representation; height should have 4 - /// resolution is 0.002%. #define ACCULEVEL_HEIGHT_RESOLUTION 4 /// @brief Default variable short code; "kellerAccuHeight" diff --git a/src/sensors/KellerNanolevel.h b/src/sensors/KellerNanolevel.h index 94f3b81c7..99da9a657 100644 --- a/src/sensors/KellerNanolevel.h +++ b/src/sensors/KellerNanolevel.h @@ -75,7 +75,7 @@ * {{ @ref KellerNanolevel_Pressure::KellerNanolevel_Pressure }} */ /**@{*/ -/// @brief Decimals places in string representation; pressure should have 5 - +/// @brief Decimal places in string representation; pressure should have 5 - /// resolution is 0.002%. #define NANOLEVEL_PRESSURE_RESOLUTION 5 /// @brief Default variable short code; "kellerNanoPress" @@ -92,7 +92,7 @@ * {{ @ref KellerNanolevel_Temp::KellerNanolevel_Temp }} */ /**@{*/ -/// @brief Decimals places in string representation; temperature should have 2 - +/// @brief Decimal places in string representation; temperature should have 2 - /// resolution is 0.01°C. #define NANOLEVEL_TEMP_RESOLUTION 2 /// @brief Default variable short code; "kellerNanoTemp" @@ -109,7 +109,7 @@ * {{ @ref KellerNanolevel_Height::KellerNanolevel_Height }} */ /**@{*/ -/// @brief Decimals places in string representation; height should have 4 - +/// @brief Decimal places in string representation; height should have 4 - /// resolution is 0.002%. #define NANOLEVEL_HEIGHT_RESOLUTION 4 /// @brief Default variable short code; "kellerNanoHeight" diff --git a/src/sensors/MaxBotixSonar.h b/src/sensors/MaxBotixSonar.h index 447f2f560..a50acc531 100644 --- a/src/sensors/MaxBotixSonar.h +++ b/src/sensors/MaxBotixSonar.h @@ -163,7 +163,7 @@ * {{ @ref MaxBotixSonar_Range::MaxBotixSonar_Range }} */ /**@{*/ -/// @brief Decimals places in string representation; range should have 0 - +/// @brief Decimal places in string representation; range should have 0 - /// resolution is 1mm (except for models which have range 10mm). #define HRXL_RESOLUTION 0 /// @brief Sensor variable number; range is stored in sensorValues[0]. diff --git a/src/sensors/MaximDS18.h b/src/sensors/MaximDS18.h index b6146e3fc..ea16c1a21 100644 --- a/src/sensors/MaximDS18.h +++ b/src/sensors/MaximDS18.h @@ -153,7 +153,7 @@ * {{ @ref MaximDS18_Temp::MaximDS18_Temp }} */ /**@{*/ -/// @brief Decimals places in string representation; temperature should have 4. +/// @brief Decimal places in string representation; temperature should have 4. #define DS18_TEMP_RESOLUTION 4 /// @brief Sensor variable number; temperature is stored in sensorValues[0]. #define DS18_TEMP_VAR_NUM 0 diff --git a/src/sensors/MaximDS3231.h b/src/sensors/MaximDS3231.h index 33b6411cb..26026a442 100644 --- a/src/sensors/MaximDS3231.h +++ b/src/sensors/MaximDS3231.h @@ -127,7 +127,7 @@ * {{ @ref MaximDS3231_Temp::MaximDS3231_Temp }} */ /**@{*/ -/// @brief Decimals places in string representation; temperature should have 2 - +/// @brief Decimal places in string representation; temperature should have 2 - /// resolution is -0.25°C (10 bit). #define DS3231_TEMP_RESOLUTION 2 /// @brief Sensor variable number; temperature is stored in sensorValues[0]. diff --git a/src/sensors/MeaSpecMS5803.h b/src/sensors/MeaSpecMS5803.h index d98f7074d..4ddd672d9 100644 --- a/src/sensors/MeaSpecMS5803.h +++ b/src/sensors/MeaSpecMS5803.h @@ -144,7 +144,7 @@ * {{ @ref MeaSpecMS5803_Temp::MeaSpecMS5803_Temp }} */ /**@{*/ -/// @brief Decimals places in string representation; temperature should have 2 - +/// @brief Decimal places in string representation; temperature should have 2 - /// resolution is <0.01°C. #define MS5803_TEMP_RESOLUTION 2 /// @brief Sensor variable number; temperature is stored in sensorValues[0]. @@ -183,7 +183,7 @@ * {{ @ref MeaSpecMS5803_Pressure::MeaSpecMS5803_Pressure }} */ /**@{*/ -/// @brief Decimals places in string representation; pressure should have 3. +/// @brief Decimal places in string representation; pressure should have 3. #define MS5803_PRESSURE_RESOLUTION 3 /// @brief Sensor variable number; pressure is stored in sensorValues[1]. #define MS5803_PRESSURE_VAR_NUM 1 diff --git a/src/sensors/MeterHydros21.h b/src/sensors/MeterHydros21.h index 449b525d5..f335233be 100644 --- a/src/sensors/MeterHydros21.h +++ b/src/sensors/MeterHydros21.h @@ -128,7 +128,7 @@ */ /**@{*/ /** - * @brief Decimals places in string representation; conductivity should have 1. + * @brief Decimal places in string representation; conductivity should have 1. * * 0 are reported, adding extra digit to resolution to allow the proper number * of significant figures for averaging - resolution is 0.001 mS/cm = 1 µS/cm @@ -159,7 +159,7 @@ */ /**@{*/ /** - * @brief Decimals places in string representation; temperature should have 2. + * @brief Decimal places in string representation; temperature should have 2. * * 1 is reported, adding extra digit to resolution to allow the proper number * of significant figures for averaging - resolution is 0.1°C @@ -190,7 +190,7 @@ */ /**@{*/ /** - * @brief Decimals places in string representation; depth should have 1. + * @brief Decimal places in string representation; depth should have 1. * * 0 are reported, adding extra digit to resolution to allow the proper number * of significant figures for averaging - resolution is 2 mm diff --git a/src/sensors/MeterTeros11.h b/src/sensors/MeterTeros11.h index bfdad388e..18f737e96 100644 --- a/src/sensors/MeterTeros11.h +++ b/src/sensors/MeterTeros11.h @@ -143,7 +143,7 @@ */ /**@{*/ /** - * @brief Decimals places in string representation; EA should have 1. + * @brief Decimal places in string representation; EA should have 1. */ #define TEROS11_COUNT_RESOLUTION 1 /// @brief Sensor variable number; EA is stored in sensorValues[0]. @@ -173,7 +173,7 @@ */ /**@{*/ /** - * @brief Decimals places in string representation; temperature should have 2. + * @brief Decimal places in string representation; temperature should have 2. * * 1 is reported, adding extra digit to resolution to allow the proper number * of significant figures for averaging - resolution is 0.1°C @@ -206,7 +206,7 @@ */ /**@{*/ /** - * @brief Decimals places in string representation; EA should have 5. + * @brief Decimal places in string representation; EA should have 5. * * 4 are reported, adding extra digit to resolution to allow the proper number * of significant figures for averaging - resolution is 0.00001 @@ -243,7 +243,7 @@ */ /**@{*/ /** - * @brief Decimals places in string representation; VWC should have 3. + * @brief Decimal places in string representation; VWC should have 3. * * 2 are reported, adding extra digit to resolution to allow the proper number * of significant figures for averaging - Resolution is 0.001 m3/m3 (0.1% VWC) diff --git a/src/sensors/PaleoTerraRedox.h b/src/sensors/PaleoTerraRedox.h index 1af1aab59..4f86b204c 100644 --- a/src/sensors/PaleoTerraRedox.h +++ b/src/sensors/PaleoTerraRedox.h @@ -143,7 +143,7 @@ * {{ @ref PaleoTerraRedox_Voltage::PaleoTerraRedox_Voltage }} */ /**@{*/ -/** @brief Decimals places in string representation; voltage should have 2. +/** @brief Decimal places in string representation; voltage should have 2. * * Resolution is 1mV and 1 extra digit is added to increase the number of * significant figures to allow for averaging of multiple measurements. diff --git a/src/sensors/ProcessorAnalog.h b/src/sensors/ProcessorAnalog.h index 845d92daa..23ac7c1a9 100644 --- a/src/sensors/ProcessorAnalog.h +++ b/src/sensors/ProcessorAnalog.h @@ -143,11 +143,11 @@ #define PROCESSOR_ANALOG_DEFAULT_CODE "analogVoltage" #if MS_PROCESSOR_ADC_RESOLUTION == 12 -/// @brief Decimals places in string representation; a 3.3V processor at 12-bit +/// @brief Decimal places in string representation; a 3.3V processor at 12-bit /// resolution should have 4 [3.3V / 4096 ~= 0.0008] . #define PROCESSOR_ANALOG_RESOLUTION 4 #elif MS_PROCESSOR_ADC_RESOLUTION == 10 -/// @brief Decimals places in string representation; a 3.3V processor at 10-bit +/// @brief Decimal places in string representation; a 3.3V processor at 10-bit /// resolution should have 3 [3.3V / 1024 ~= 0.0032] . #define PROCESSOR_ANALOG_RESOLUTION 3 #else diff --git a/src/sensors/ProcessorStats.h b/src/sensors/ProcessorStats.h index a57e542e2..38c9aeb1f 100644 --- a/src/sensors/ProcessorStats.h +++ b/src/sensors/ProcessorStats.h @@ -125,7 +125,7 @@ */ /**@{*/ /** - * @brief Decimals places in string representation; battery voltage should + * @brief Decimal places in string representation; battery voltage should * have 3. * * The resolution is of the EnviroDIY Mayfly is 0.005V, we will use that @@ -160,7 +160,7 @@ * {{ @ref ProcessorStats_FreeRam::ProcessorStats_FreeRam }} */ /**@{*/ -/// @brief Decimals places in string representation; ram should have 0 - +/// @brief Decimal places in string representation; ram should have 0 - /// resolution is 1 bit. #define PROCESSOR_RAM_RESOLUTION 0 /// @brief Free RAM is stored in sensorValues[1] @@ -190,7 +190,7 @@ * {{ @ref ProcessorStats_SampleNumber::ProcessorStats_SampleNumber }} */ /**@{*/ -/// @brief Decimals places in string representation; sample number should have +/// @brief Decimal places in string representation; sample number should have /// 0 - resolution is 1. #define PROCESSOR_SAMPNUM_RESOLUTION 0 /// @brief Sample number is stored in sensorValues[2] @@ -220,7 +220,7 @@ * {{ @ref ProcessorStats_ResetCode::ProcessorStats_ResetCode }} */ /**@{*/ -/// @brief Decimals places in string representation; ram should have 0 - +/// @brief Decimal places in string representation; ram should have 0 - /// it's just a code #define PROCESSOR_RESET_RESOLUTION 0 /// @brief Free RAM is stored in sensorValues[1] diff --git a/src/sensors/RainCounterI2C.h b/src/sensors/RainCounterI2C.h index ebd468e20..9e274cbc3 100644 --- a/src/sensors/RainCounterI2C.h +++ b/src/sensors/RainCounterI2C.h @@ -143,7 +143,7 @@ */ /**@{*/ /** - * @brief Decimals places in string representation; rain depth should have 2. + * @brief Decimal places in string representation; rain depth should have 2. * * Resolution is typically either 0.01" or 0.2mm of rainfall, depending on * if bucket is calibrated to English or metric units. @@ -172,7 +172,7 @@ * {{ @ref RainCounterI2C_Tips::RainCounterI2C_Tips }} */ /**@{*/ -/// @brief Decimals places in string representation; the number of tips should +/// @brief Decimal places in string representation; the number of tips should /// have 0 - resolution is 1 tip. #define BUCKET_TIPS_RESOLUTION 0 /// @brief Sensor variable number; the number of tips is stored in diff --git a/src/sensors/SensirionSHT4x.h b/src/sensors/SensirionSHT4x.h index 2df8188fe..19c8aca54 100644 --- a/src/sensors/SensirionSHT4x.h +++ b/src/sensors/SensirionSHT4x.h @@ -130,7 +130,7 @@ */ /**@{*/ /** - * @brief Decimals places in string representation; humidity should have 2 (0.01 + * @brief Decimal places in string representation; humidity should have 2 (0.01 * % RH). * * @note This resolution is some-what silly in light of the ± 1.8 % RH accuracy. @@ -161,7 +161,7 @@ */ /**@{*/ /** - * @brief Decimals places in string representation; humidity should have 2 (0.01 + * @brief Decimal places in string representation; humidity should have 2 (0.01 * °C). * * @note This resolution is some-what silly in light of the ± 0.2°C accuracy. diff --git a/src/sensors/TIADS1x15.h b/src/sensors/TIADS1x15.h index 0e057ad99..fc01dc37f 100644 --- a/src/sensors/TIADS1x15.h +++ b/src/sensors/TIADS1x15.h @@ -246,10 +246,10 @@ #define TIADS1X15_DEFAULT_CODE "extVoltage" #ifdef MS_USE_ADS1015 -/// @brief Decimals places in string representation; voltage should have 1. +/// @brief Decimal places in string representation; voltage should have 1. #define TIADS1X15_RESOLUTION 1 #else -/// @brief Decimals places in string representation; voltage should have 4. +/// @brief Decimal places in string representation; voltage should have 4. #define TIADS1X15_RESOLUTION 4 #endif /**@}*/ diff --git a/src/sensors/TIINA219.h b/src/sensors/TIINA219.h index 706019a3e..5dc117dfe 100644 --- a/src/sensors/TIINA219.h +++ b/src/sensors/TIINA219.h @@ -146,7 +146,7 @@ */ /**@{*/ /** - * @brief Decimals places in string representation; current should have 1. + * @brief Decimal places in string representation; current should have 1. * - resolution is 12-bit * - 0.8mA using +/-3.2 Amp range * - 0.1mA using +/-0.4 Amp range @@ -175,7 +175,7 @@ * {{ @ref TIINA219_Voltage::TIINA219_Voltage }} */ /**@{*/ -/// @brief Decimals places in string representation; bus voltage should have 3 - +/// @brief Decimal places in string representation; bus voltage should have 3 - /// resolution is 0.004V. #define INA219_BUS_VOLTAGE_RESOLUTION 3 /// @brief Sensor variable number; bus voltage is stored in sensorValues[1]. @@ -199,7 +199,7 @@ * {{ @ref TIINA219_Power::TIINA219_Power }} */ /**@{*/ -/// @brief Decimals places in string representation; power draw should have 2 - +/// @brief Decimal places in string representation; power draw should have 2 - /// resolution is 0.01mW. #define INA219_POWER_MW_RESOLUTION 2 /// @brief Sensor variable number; power draw is stored in sensorValues[2]. diff --git a/src/sensors/TallyCounterI2C.h b/src/sensors/TallyCounterI2C.h index 10c76c9bf..7e9783fa5 100644 --- a/src/sensors/TallyCounterI2C.h +++ b/src/sensors/TallyCounterI2C.h @@ -147,7 +147,7 @@ * {{ @ref TallyCounterI2C_Events::TallyCounterI2C_Events }} */ /**@{*/ -/// @brief Decimals places in string representation; events are an integer +/// @brief Decimal places in string representation; events are an integer /// should be 0 - resolution is 1 event. #define TALLY_EVENTS_RESOLUTION 0 /// @brief Sensor variable number; events is stored in sensorValues[0]. diff --git a/src/sensors/TurnerCyclops.h b/src/sensors/TurnerCyclops.h index 20545459d..a66ca689f 100644 --- a/src/sensors/TurnerCyclops.h +++ b/src/sensors/TurnerCyclops.h @@ -255,10 +255,10 @@ class AnalogVoltageBase; /// Variable number; the primary variable is stored in sensorValues[0]. #define CYCLOPS_VAR_NUM 0 #ifdef MS_USE_ADS1015 -/// @brief Decimals places in string representation; 1. +/// @brief Decimal places in string representation; 1. #define CYCLOPS_RESOLUTION 1 #else -/// @brief Decimals places in string representation; 5. +/// @brief Decimal places in string representation; 5. #define CYCLOPS_RESOLUTION 5 #endif /**@}*/ @@ -292,12 +292,12 @@ class AnalogVoltageBase; #define CYCLOPS_VOLTAGE_DEFAULT_CODE "CyclopsVoltage" #ifdef MS_USE_ADS1015 -/// @brief Decimals places in string representation; voltage should have 1. +/// @brief Decimal places in string representation; voltage should have 1. /// - Resolution: /// - 16-bit ADC (ADS1115): 0.125 mV #define CYCLOPS_VOLTAGE_RESOLUTION 1 #else -/// @brief Decimals places in string representation; voltage should have 4. +/// @brief Decimal places in string representation; voltage should have 4. /// - Resolution: /// - 12-bit ADC (ADS1015, using build flag ```MS_USE_ADS1015```): 2 mV #define CYCLOPS_VOLTAGE_RESOLUTION 4 diff --git a/src/sensors/TurnerTurbidityPlus.h b/src/sensors/TurnerTurbidityPlus.h index 02782d4d0..90a3184b4 100644 --- a/src/sensors/TurnerTurbidityPlus.h +++ b/src/sensors/TurnerTurbidityPlus.h @@ -155,10 +155,10 @@ class AnalogVoltageBase; /// @brief Default variable short code; "TurnerTurbidity" #define TURBIDITY_PLUS_DEFAULT_CODE "TurnerTurbidity" #ifdef MS_USE_ADS1015 -/// @brief Decimals places in string representation; 1. +/// @brief Decimal places in string representation; 1. #define TURBIDITY_PLUS_RESOLUTION 1 #else -/// @brief Decimals places in string representation; 5. +/// @brief Decimal places in string representation; 5. #define TURBIDITY_PLUS_RESOLUTION 5 #endif /**@}*/ @@ -190,12 +190,12 @@ class AnalogVoltageBase; /// @brief Default variable short code; "TurbidityPlusVoltage" #define TURBIDITY_PLUS_VOLTAGE_DEFAULT_CODE "TurbidityPlusVoltage" #ifdef MS_USE_ADS1015 -/// @brief Decimals places in string representation; voltage should have 1. +/// @brief Decimal places in string representation; voltage should have 1. /// - Resolution: /// - 12-bit ADC (ADS1015): 2 mV #define TURBIDITY_PLUS_VOLTAGE_RESOLUTION 1 #else -/// @brief Decimals places in string representation; voltage should have 4. +/// @brief Decimal places in string representation; voltage should have 4. /// - Resolution: /// - 16-bit ADC (ADS1115): 0.125 mV #define TURBIDITY_PLUS_VOLTAGE_RESOLUTION 4 diff --git a/src/sensors/VegaPuls21.h b/src/sensors/VegaPuls21.h index faf7c3de6..a428a5a02 100644 --- a/src/sensors/VegaPuls21.h +++ b/src/sensors/VegaPuls21.h @@ -113,7 +113,7 @@ * {{ @ref VegaPuls21_Stage::VegaPuls21_Stage }} */ /**@{*/ -/// @brief Decimals places in string representation; stage in meters should have +/// @brief Decimal places in string representation; stage in meters should have /// 3 - resolution is 1mm. #define VEGAPULS21_STAGE_RESOLUTION 3 /// @brief Sensor variable number; stage is stored in sensorValues[0]. @@ -139,7 +139,7 @@ * {{ @ref VegaPuls21_Distance::VegaPuls21_Distance }} */ /**@{*/ -/// @brief Decimals places in string representation; distance in meters should +/// @brief Decimal places in string representation; distance in meters should /// have 3 - resolution is 1mm. #define VEGAPULS21_DISTANCE_RESOLUTION 3 /// @brief Sensor variable number; stage is stored in sensorValues[1]. @@ -164,7 +164,7 @@ * {{ @ref VegaPuls21_Temp::VegaPuls21_Temp }} */ /**@{*/ -/// @brief Decimals places in string representation; temperature should have 1 - +/// @brief Decimal places in string representation; temperature should have 1 - /// resolution is 0.1°C. #define VEGAPULS21_TEMP_RESOLUTION 1 /// @brief Sensor variable number; temperature is stored in sensorValues[2]. @@ -189,7 +189,7 @@ * {{ @ref VegaPuls21_Reliability::VegaPuls21_Reliability }} */ /**@{*/ -/// @brief Decimals places in string representation; reliability should have 1 +/// @brief Decimal places in string representation; reliability should have 1 /// (resolution is 0.1 dB). #define VEGAPULS21_RELIABILITY_RESOLUTION 1 /// @brief Sensor variable number; reliability is stored in sensorValues[3] @@ -215,7 +215,7 @@ * {{ @ref VegaPuls21_ErrorCode::VegaPuls21_ErrorCode }} */ /**@{*/ -/// @brief Decimals places in string representation; the error code has 0. +/// @brief Decimal places in string representation; the error code has 0. #define VEGAPULS21_ERRORCODE_RESOLUTION 0 /// @brief Sensor variable number; error code is stored in sensorValues[4] #define VEGAPULS21_ERRORCODE_VAR_NUM 4 diff --git a/src/sensors/YosemitechY4000.h b/src/sensors/YosemitechY4000.h index 61656bfe8..05c5fb090 100644 --- a/src/sensors/YosemitechY4000.h +++ b/src/sensors/YosemitechY4000.h @@ -109,7 +109,7 @@ * {{ @ref YosemitechY4000_DOmgL::YosemitechY4000_DOmgL }} */ /**@{*/ -/// @brief Decimals places in string representation; dissolved oxygen +/// @brief Decimal places in string representation; dissolved oxygen /// concentration should have 2 - resolution is 0.01 mg/L. #define Y4000_DOMGL_RESOLUTION 2 /// @brief Sensor variable number; dissolved oxygen concentration is stored in @@ -137,7 +137,7 @@ * {{ @ref YosemitechY4000_Turbidity::YosemitechY4000_Turbidity }} */ /**@{*/ -/// @brief Decimals places in string representation; turbidity should have 2 - +/// @brief Decimal places in string representation; turbidity should have 2 - /// resolution is 0.01 NTU. #define Y4000_TURB_RESOLUTION 2 /// @brief Sensor variable number; turbidity is stored in sensorValues[1]. @@ -164,7 +164,7 @@ * {{ @ref YosemitechY4000_Cond::YosemitechY4000_Cond }} */ /**@{*/ -/// @brief Decimals places in string representation; conductivity should have 1 +/// @brief Decimal places in string representation; conductivity should have 1 /// - resolution is 0.1 µS/cm. #define Y4000_COND_RESOLUTION 1 /// @brief Sensor variable number; conductivity is stored in sensorValues[2]. @@ -191,7 +191,7 @@ * {{ @ref YosemitechY4000_pH::YosemitechY4000_pH }} */ /**@{*/ -/// @brief Decimals places in string representation; ph should have 2 - +/// @brief Decimal places in string representation; ph should have 2 - /// resolution is 0.01 pH units. #define Y4000_PH_RESOLUTION 2 /// @brief Sensor variable number; pH is stored in sensorValues[3]. @@ -217,7 +217,7 @@ * {{ @ref YosemitechY4000_Temp::YosemitechY4000_Temp }} */ /**@{*/ -/// @brief Decimals places in string representation; temperature should have 1 - +/// @brief Decimal places in string representation; temperature should have 1 - /// resolution is 0.1°C. #define Y4000_TEMP_RESOLUTION 1 /// @brief Sensor variable number; temperature is stored in sensorValues[4]. @@ -244,7 +244,7 @@ * {{ @ref YosemitechY4000_ORP::YosemitechY4000_ORP }} */ /**@{*/ -/// @brief Decimals places in string representation; orp should have 0 - +/// @brief Decimal places in string representation; orp should have 0 - /// resolution is 1 mV. #define Y4000_ORP_RESOLUTION 0 /// @brief Sensor variable number; ORP is stored in sensorValues[5]. @@ -272,7 +272,7 @@ * {{ @ref YosemitechY4000_Chlorophyll::YosemitechY4000_Chlorophyll }} */ /**@{*/ -/// @brief Decimals places in string representation; chlorophyll concentration +/// @brief Decimal places in string representation; chlorophyll concentration /// should have 1 - resolution is 0.1 µg/L / 0.1 RFU. #define Y4000_CHLORO_RESOLUTION 1 /// @brief Sensor variable number; chlorophyll concentration is stored in @@ -300,7 +300,7 @@ * {{ @ref YosemitechY4000_BGA::YosemitechY4000_BGA }} */ /**@{*/ -/// @brief Decimals places in string representation; bga should have 2 - +/// @brief Decimal places in string representation; bga should have 2 - /// resolution is 0.01 µg/L / 0.01 RFU. #define Y4000_BGA_RESOLUTION 2 /// @brief Sensor variable number; BGA is stored in sensorValues[7]. diff --git a/src/sensors/YosemitechY504.h b/src/sensors/YosemitechY504.h index bf3eedfad..dc7897432 100644 --- a/src/sensors/YosemitechY504.h +++ b/src/sensors/YosemitechY504.h @@ -100,7 +100,7 @@ * {{ @ref YosemitechY504_DOpct::YosemitechY504_DOpct }} */ /**@{*/ -/// @brief Decimals places in string representation; dissolved oxygen percent +/// @brief Decimal places in string representation; dissolved oxygen percent /// should have 1 - resolution is 0.1%. #define Y504_DOPCT_RESOLUTION 1 /// @brief Sensor variable number; dissolved oxygen percent is stored in @@ -128,7 +128,7 @@ * {{ @ref YosemitechY504_Temp::YosemitechY504_Temp }} */ /**@{*/ -/// @brief Decimals places in string representation; temperature should have 1 - +/// @brief Decimal places in string representation; temperature should have 1 - /// resolution is 0.1°C. #define Y504_TEMP_RESOLUTION 1 /// @brief Sensor variable number; temperature is stored in sensorValues[1]. @@ -155,7 +155,7 @@ * {{ @ref YosemitechY504_DOmgL::YosemitechY504_DOmgL }} */ /**@{*/ -/// @brief Decimals places in string representation; dissolved oxygen +/// @brief Decimal places in string representation; dissolved oxygen /// concentration should have 2 - resolution is 0.01 mg/L. #define Y504_DOMGL_RESOLUTION 2 /// @brief Sensor variable number; dissolved oxygen concentration is stored in diff --git a/src/sensors/YosemitechY510.h b/src/sensors/YosemitechY510.h index fb83c67c6..40b94bc38 100644 --- a/src/sensors/YosemitechY510.h +++ b/src/sensors/YosemitechY510.h @@ -95,7 +95,7 @@ * {{ @ref YosemitechY510_Turbidity::YosemitechY510_Turbidity }} */ /**@{*/ -/// @brief Decimals places in string representation; turbidity should have 2 - +/// @brief Decimal places in string representation; turbidity should have 2 - /// resolution is 0.01 NTU. #define Y510_TURB_RESOLUTION 2 /// @brief Sensor variable number; turbidity is stored in sensorValues[0]. @@ -122,7 +122,7 @@ * {{ @ref YosemitechY510_Temp::YosemitechY510_Temp }} */ /**@{*/ -/// @brief Decimals places in string representation; temperature should have 1 - +/// @brief Decimal places in string representation; temperature should have 1 - /// resolution is 0.1°C. #define Y510_TEMP_RESOLUTION 1 /// @brief Sensor variable number; temperature is stored in sensorValues[1]. diff --git a/src/sensors/YosemitechY511.h b/src/sensors/YosemitechY511.h index 01bff973e..10465d998 100644 --- a/src/sensors/YosemitechY511.h +++ b/src/sensors/YosemitechY511.h @@ -109,7 +109,7 @@ * {{ @ref YosemitechY511_Turbidity::YosemitechY511_Turbidity }} */ /**@{*/ -/// @brief Decimals places in string representation; turbidity should have 2 - +/// @brief Decimal places in string representation; turbidity should have 2 - /// resolution is 0.01 NTU. #define Y511_TURB_RESOLUTION 2 /// @brief Sensor variable number; turbidity is stored in sensorValues[0]. @@ -136,7 +136,7 @@ * {{ @ref YosemitechY511_Temp::YosemitechY511_Temp }} */ /**@{*/ -/// @brief Decimals places in string representation; temperature should have 1 - +/// @brief Decimal places in string representation; temperature should have 1 - /// resolution is 0.1°C. #define Y511_TEMP_RESOLUTION 1 /// @brief Sensor variable number; temperature is stored in sensorValues[1]. diff --git a/src/sensors/YosemitechY513.h b/src/sensors/YosemitechY513.h index 3c3d7906c..bf163e380 100644 --- a/src/sensors/YosemitechY513.h +++ b/src/sensors/YosemitechY513.h @@ -95,7 +95,7 @@ * {{ @ref YosemitechY513_BGA::YosemitechY513_BGA }} */ /**@{*/ -/// @brief Decimals places in string representation; blue green algae +/// @brief Decimal places in string representation; blue green algae /// concentration should have 1 - resolution is 0.1 µg/L / 0.1 RFU. #define Y513_BGA_RESOLUTION 1 /// @brief Sensor variable number; blue green algae concentration is stored in @@ -123,7 +123,7 @@ * {{ @ref YosemitechY513_Temp::YosemitechY513_Temp }} */ /**@{*/ -/// @brief Decimals places in string representation; temperature should have 1 - +/// @brief Decimal places in string representation; temperature should have 1 - /// resolution is 0.1°C. #define Y513_TEMP_RESOLUTION 1 /// @brief Sensor variable number; temperature is stored in sensorValues[1]. diff --git a/src/sensors/YosemitechY514.h b/src/sensors/YosemitechY514.h index 7467faafb..89144939f 100644 --- a/src/sensors/YosemitechY514.h +++ b/src/sensors/YosemitechY514.h @@ -97,7 +97,7 @@ * {{ @ref YosemitechY514_Chlorophyll::YosemitechY514_Chlorophyll }} */ /**@{*/ -/// @brief Decimals places in string representation; chlorophyll concentration +/// @brief Decimal places in string representation; chlorophyll concentration /// should have 1 - resolution is 0.1 µg/L / 0.1 RFU. #define Y514_CHLORO_RESOLUTION 1 /// @brief Sensor variable number; chlorophyll concentration is stored in @@ -125,7 +125,7 @@ * {{ @ref YosemitechY514_Temp::YosemitechY514_Temp }} */ /**@{*/ -/// @brief Decimals places in string representation; temperature should have 1 - +/// @brief Decimal places in string representation; temperature should have 1 - /// resolution is 0.1°C. #define Y514_TEMP_RESOLUTION 1 /// @brief Sensor variable number; temperature is stored in sensorValues[1]. diff --git a/src/sensors/YosemitechY520.h b/src/sensors/YosemitechY520.h index 02ab4616d..a4e3f60d6 100644 --- a/src/sensors/YosemitechY520.h +++ b/src/sensors/YosemitechY520.h @@ -96,7 +96,7 @@ * {{ @ref YosemitechY520_Cond::YosemitechY520_Cond }} */ /**@{*/ -/// @brief Decimals places in string representation; conductivity should have 1 +/// @brief Decimal places in string representation; conductivity should have 1 /// - resolution is 0.1 µS/cm. #define Y520_COND_RESOLUTION 1 /// @brief Sensor variable number; conductivity is stored in sensorValues[0]. @@ -123,7 +123,7 @@ * {{ @ref YosemitechY520_Temp::YosemitechY520_Temp }} */ /**@{*/ -/// @brief Decimals places in string representation; temperature should have 1 - +/// @brief Decimal places in string representation; temperature should have 1 - /// resolution is 0.1°C. #define Y520_TEMP_RESOLUTION 1 /// @brief Sensor variable number; temperature is stored in sensorValues[1]. diff --git a/src/sensors/YosemitechY532.h b/src/sensors/YosemitechY532.h index 970532d83..290dfa3fd 100644 --- a/src/sensors/YosemitechY532.h +++ b/src/sensors/YosemitechY532.h @@ -96,7 +96,7 @@ * {{ @ref YosemitechY532_pH::YosemitechY532_pH }} */ /**@{*/ -/// @brief Decimals places in string representation; pH should have 2 - +/// @brief Decimal places in string representation; pH should have 2 - /// resolution is 0.01 pH units. #define Y532_PH_RESOLUTION 2 /// @brief Sensor variable number; pH is stored in sensorValues[0]. @@ -122,7 +122,7 @@ * {{ @ref YosemitechY532_Temp::YosemitechY532_Temp }} */ /**@{*/ -/// @brief Decimals places in string representation; temperature should have 1 - +/// @brief Decimal places in string representation; temperature should have 1 - /// resolution is 0.1°C. #define Y532_TEMP_RESOLUTION 1 /// @brief Sensor variable number; temperature is stored in sensorValues[1]. @@ -149,7 +149,7 @@ * {{ @ref YosemitechY532_Voltage::YosemitechY532_Voltage }} */ /**@{*/ -/// @brief Decimals places in string representation; voltage should have 0 - +/// @brief Decimal places in string representation; voltage should have 0 - /// resolution is 1mV. #define Y532_VOLTAGE_RESOLUTION 0 /// @brief Sensor variable number; voltage is stored in sensorValues[2]. diff --git a/src/sensors/YosemitechY533.h b/src/sensors/YosemitechY533.h index e39eaf86c..93393a386 100644 --- a/src/sensors/YosemitechY533.h +++ b/src/sensors/YosemitechY533.h @@ -96,7 +96,7 @@ * {{ @ref YosemitechY533_ORP::YosemitechY533_ORP }} */ /**@{*/ -/// @brief Decimals places in string representation; ph should have 2 - +/// @brief Decimal places in string representation; ph should have 2 - /// resolution is 1 mV units. #define Y533_ORP_RESOLUTION 0 /// @brief Sensor variable number; ORP is stored in sensorValues[0]. @@ -125,7 +125,7 @@ * {{ @ref YosemitechY533_Temp::YosemitechY533_Temp }} */ /**@{*/ -/// @brief Decimals places in string representation; temperature should have 1 - +/// @brief Decimal places in string representation; temperature should have 1 - /// resolution is 0.1°C. #define Y533_TEMP_RESOLUTION 1 /// @brief Sensor variable number; temperature is stored in sensorValues[1]. diff --git a/src/sensors/YosemitechY551.h b/src/sensors/YosemitechY551.h index 72c50199f..69144e177 100644 --- a/src/sensors/YosemitechY551.h +++ b/src/sensors/YosemitechY551.h @@ -99,7 +99,7 @@ * {{ @ref YosemitechY551_COD::YosemitechY551_COD }} */ /**@{*/ -/// @brief Decimals places in string representation; cod should have 2 - +/// @brief Decimal places in string representation; cod should have 2 - /// resolution is 0.01 mg/L COD. #define Y551_COD_RESOLUTION 2 /// @brief Sensor variable number; COD is stored in sensorValues[0]. @@ -126,7 +126,7 @@ * {{ @ref YosemitechY551_Temp::YosemitechY551_Temp }} */ /**@{*/ -/// @brief Decimals places in string representation; temperature should have 2 - +/// @brief Decimal places in string representation; temperature should have 2 - /// resolution is 0.01°C. #define Y551_TEMP_RESOLUTION 2 /// @brief Sensor variable number; temperature is stored in sensorValues[1]. @@ -153,7 +153,7 @@ * {{ @ref YosemitechY551_Turbidity::YosemitechY551_Turbidity }} */ /**@{*/ -/// @brief Decimals places in string representation; turbidity should have 2 - +/// @brief Decimal places in string representation; turbidity should have 2 - /// resolution is 0.01 NTU. #define Y551_TURB_RESOLUTION 2 /// @brief Sensor variable number; turbidity is stored in sensorValues[2]. diff --git a/src/sensors/YosemitechY560.h b/src/sensors/YosemitechY560.h index c5d228755..7e6ec2b99 100644 --- a/src/sensors/YosemitechY560.h +++ b/src/sensors/YosemitechY560.h @@ -97,7 +97,7 @@ * {{ @ref YosemitechY560_NH4_N::YosemitechY560_NH4_N }} */ /**@{*/ -/// @brief Decimals places in string representation; NH4_N should have 1 - +/// @brief Decimal places in string representation; NH4_N should have 1 - /// resolution is 0.1 mg/L. #define Y560_NH4_N_RESOLUTION 1 /// @brief Sensor variable number; NH4_N is stored in sensorValues[0]. @@ -124,7 +124,7 @@ * {{ @ref YosemitechY560_Temp::YosemitechY560_Temp }} */ /**@{*/ -/// @brief Decimals places in string representation; temperature should have 1 - +/// @brief Decimal places in string representation; temperature should have 1 - /// resolution is 0.1°C. #define Y560_TEMP_RESOLUTION 1 /// @brief Sensor variable number; temperature is stored in sensorValues[1]. @@ -151,7 +151,7 @@ * {{ @ref YosemitechY560_pH::YosemitechY560_pH }} */ /**@{*/ -/// @brief Decimals places in string representation; pH should have 2 - +/// @brief Decimal places in string representation; pH should have 2 - /// resolution is 0.01 pH units. #define Y560_PH_RESOLUTION 2 /// @brief Sensor variable number; pH is stored in sensorValues[2]. diff --git a/src/sensors/YosemitechY700.h b/src/sensors/YosemitechY700.h index f1a8cbd02..ec283512f 100644 --- a/src/sensors/YosemitechY700.h +++ b/src/sensors/YosemitechY700.h @@ -95,7 +95,7 @@ * {{ @ref YosemitechY700_Pressure::YosemitechY700_Pressure }} */ /**@{*/ -/// @brief Decimals places in string representation; Pressure should have 1 +/// @brief Decimal places in string representation; Pressure should have 1 /// - resolution is 0.01 mm. #define Y700_PRES_RESOLUTION 2 /// @brief Sensor variable number; pressure is stored in sensorValues[0]. @@ -122,7 +122,7 @@ * {{ @ref YosemitechY700_Temp::YosemitechY700_Temp }} */ /**@{*/ -/// @brief Decimals places in string representation; temperature should have 1 - +/// @brief Decimal places in string representation; temperature should have 1 - /// resolution is 0.1°C. #define Y700_TEMP_RESOLUTION 1 /// @brief Sensor variable number; temperature is stored in sensorValues[1]. diff --git a/src/sensors/ZebraTechDOpto.h b/src/sensors/ZebraTechDOpto.h index 6ac86e297..9a26e6d7e 100644 --- a/src/sensors/ZebraTechDOpto.h +++ b/src/sensors/ZebraTechDOpto.h @@ -113,7 +113,7 @@ * {{ @ref ZebraTechDOpto_Temp::ZebraTechDOpto_Temp }} */ /**@{*/ -/// @brief Decimals places in string representation; temperature should have 2 - +/// @brief Decimal places in string representation; temperature should have 2 - /// resolution is 0.01°C. #define DOPTO_TEMP_RESOLUTION 2 /// @brief Sensor variable number; temperature is stored in sensorValues[0]. @@ -140,7 +140,7 @@ * {{ @ref ZebraTechDOpto_DOpct::ZebraTechDOpto_DOpct }} */ /**@{*/ -/// @brief Decimals places in string representation; dissolved oxygen percent +/// @brief Decimal places in string representation; dissolved oxygen percent /// should have 2. #define DOPTO_DOPCT_RESOLUTION 2 /// @brief Sensor variable number; dissolved oxygen percent is stored in @@ -168,7 +168,7 @@ * {{ @ref ZebraTechDOpto_DOmgL::ZebraTechDOpto_DOmgL }} */ /**@{*/ -/// @brief Decimals places in string representation; dissolved oxygen +/// @brief Decimal places in string representation; dissolved oxygen /// concentration should have 3 - resolution is 0.01 % / 0.001 PPM. #define DOPTO_DOMGL_RESOLUTION 3 /// @brief Sensor variable number; dissolved oxygen concentration is stored in From ed9ded65320cb0a6b5a3a95ccca7c669c08fe3b9 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Tue, 3 Mar 2026 12:27:11 -0500 Subject: [PATCH 408/533] Decimal place[s] here Signed-off-by: Sara Damiano --- src/sensors/TEConnectivityMS5837.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/sensors/TEConnectivityMS5837.h b/src/sensors/TEConnectivityMS5837.h index a471a1a92..30662e695 100644 --- a/src/sensors/TEConnectivityMS5837.h +++ b/src/sensors/TEConnectivityMS5837.h @@ -228,7 +228,7 @@ static_assert( * {{ @ref TEConnectivityMS5837_Temp::TEConnectivityMS5837_Temp }} */ /**@{*/ -/// @brief Decimals places in string representation; temperature should have 2 - +/// @brief Decimal places in string representation; temperature should have 2 - /// resolution is <0.01°C. #define MS5837_TEMP_RESOLUTION 2 /// @brief Sensor variable number; temperature is stored in sensorValues[0]. @@ -264,7 +264,7 @@ static_assert( * {{ @ref TEConnectivityMS5837_Pressure::TEConnectivityMS5837_Pressure }} */ /**@{*/ -/// @brief Decimals places in string representation; pressure should have 3. +/// @brief Decimal places in string representation; pressure should have 3. #define MS5837_PRESSURE_RESOLUTION 3 /// @brief Sensor variable number; pressure is stored in sensorValues[1]. #define MS5837_PRESSURE_VAR_NUM 1 @@ -290,7 +290,7 @@ static_assert( * {{ @ref TEConnectivityMS5837_Depth::TEConnectivityMS5837_Depth }} */ /**@{*/ -/// @brief Decimals places in string representation; depth should have 3. +/// @brief Decimal places in string representation; depth should have 3. #define MS5837_DEPTH_RESOLUTION 3 /// @brief Sensor variable number; depth is stored in sensorValues[2]. #define MS5837_DEPTH_VAR_NUM 2 @@ -316,7 +316,7 @@ static_assert( * {{ @ref TEConnectivityMS5837_Altitude::TEConnectivityMS5837_Altitude }} */ /**@{*/ -/// @brief Decimals places in string representation; altitude should have 2. +/// @brief Decimal places in string representation; altitude should have 2. #define MS5837_ALTITUDE_RESOLUTION 2 /// @brief Sensor variable number; altitude is stored in sensorValues[3]. #define MS5837_ALTITUDE_VAR_NUM 3 From 7edac173aee6571eebfbdb329aec30a185dd436b Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Tue, 3 Mar 2026 13:51:50 -0500 Subject: [PATCH 409/533] Change default oversampling for BMP3xx Signed-off-by: Sara Damiano --- ChangeLog.md | 2 + src/sensors/BoschBMP3xx.cpp | 78 ++++++++++++++++++++----------------- src/sensors/BoschBMP3xx.h | 16 +++++++- 3 files changed, 58 insertions(+), 38 deletions(-) diff --git a/ChangeLog.md b/ChangeLog.md index 57b90d5da..e27331563 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -109,6 +109,8 @@ This affects the following defines: - `ANALOGELECCONDUCTIVITY_ADC_MAX_RATIO` (formerly a hardcoded value of `0.999f`) - **EverlightALSPT19** - Moved the calibration constant between current and lux to the `ALSPT19_UA_PER_1000LUX` preprocessor define. +- **Bosch BMP3xx** + - Changed the default oversampling for both pressure and temperature to 1x (no oversampling) which is what is recommended by the datasheet for ultra-low-power mode operation - including weather and environmental monitoring. #### All Sensors diff --git a/src/sensors/BoschBMP3xx.cpp b/src/sensors/BoschBMP3xx.cpp index a6bcaa7ba..a12fb52b3 100644 --- a/src/sensors/BoschBMP3xx.cpp +++ b/src/sensors/BoschBMP3xx.cpp @@ -105,7 +105,6 @@ bool BoschBMP3xx::setup(void) { "recommended")); } - // convert the standby time enum value into the time between readouts from // the BMP's // ADC NOTE: The ADC will return repeated values if the ADC's ODR (output @@ -163,33 +162,39 @@ bool BoschBMP3xx::setup(void) { "trim parameters")); success = bmp_internal.begin(_i2cAddressHex); - // Set up oversampling and filter initialization - // Using the filter selection recommended for "Weather monitoring - // (lowest power)" in table 10 of the sensor datasheet - - // Oversampling setting - MS_DBG(F("Sending BMP3xx oversampling settings")); - bmp_internal.setTempOversampling(_tempOversampleEnum); - bmp_internal.setPresOversampling(_pressureOversampleEnum); - - // Coefficient of the filter (in samples) - MS_DBG(F("Sending BMP3xx IIR Filter settings")); - bmp_internal.setIIRFilter(_filterCoeffEnum); - - MS_DBG(F("Setting sea level atmospheric pressure to"), - MS_SEA_LEVEL_PRESSURE_HPA); - bmp_internal.setSeaLevelPressure(MS_SEA_LEVEL_PRESSURE_HPA); - - // if we plan to operate in normal mode, set that up and begin sampling - // at the specified intervals - // if we're going to operate in forced mode, this isn't needed - if (_mode == NORMAL_MODE) { - // Standby time between samples in normal sampling mode - doesn't - // apply in forced mode - MS_DBG(F( - "Sending BMP3xx stand-by time and starting normal conversion")); - bmp_internal.setTimeStandby(_standbyEnum); - bmp_internal.startNormalConversion(); + if (success) { + // The sea level pressure is used for calculating altitude. This is + // stored as a parameter of the bmp_internal object and only needs + // to be sent once at setup, not repeated at wake, even if we're not + // continuously powered. + MS_DBG(F("Setting sea level atmospheric pressure to"), + MS_SEA_LEVEL_PRESSURE_HPA); + bmp_internal.setSeaLevelPressure(MS_SEA_LEVEL_PRESSURE_HPA); + + // Oversampling settings - these settings are sent to the BMP3xx and + // need to be repeated at wake if we're not continuously powered + MS_DBG(F("Sending BMP3xx oversampling settings")); + bmp_internal.setTempOversampling(_tempOversampleEnum); + bmp_internal.setPresOversampling(_pressureOversampleEnum); + + // if we plan to operate in normal mode, set that up, configure + // standby time and filtering, and begin sampling at the specified + // intervals if we're going to operate in forced mode, this isn't + // needed + if (_mode == NORMAL_MODE) { + // Coefficient of the filter (in samples) + MS_DBG(F("Sending BMP3xx IIR Filter settings")); + bmp_internal.setIIRFilter(_filterCoeffEnum); + // Standby time between samples in normal sampling mode - + // doesn't apply in forced mode + MS_DBG(F("Sending BMP3xx stand-by time and starting normal " + "conversion")); + bmp_internal.setTimeStandby(_standbyEnum); + bmp_internal.startNormalConversion(); + } + } else { + MS_DBG(F("Failed to connect to BMP3xx, attempt"), ntries + 1, + F("of 5")); } ntries++; } @@ -213,9 +218,13 @@ bool BoschBMP3xx::wake(void) { // and status bits. If it returns false, there's no reason to go on. if (!Sensor::wake()) return false; - // if the power has gone off, we need to re-read the coefficients, - // we don't need to do anything if always powered. - // NOTE: only forced sampling is supported with switched power + // If the power has gone off, we need to re-read the coefficients and + // reconfigure the oversampling settings, since the sensor will have lost + // its memory of those things. If the power has not gone off, then the + // sensor will still have those things set and we don't need to do anything. + // NOTE: Only forced sampling with the IIR filter disabled is supported + // with switched power. There's no reason to resend the IIR filter and + // standby settings because those only apply to continuous power. if (_powerPin >= 0) { // Run begin fxn because it returns true or false // for success in contact // Make 5 attempts @@ -227,11 +236,8 @@ bool BoschBMP3xx::wake(void) { "trim parameters")); success = bmp_internal.begin(_i2cAddressHex); - // Set up oversampling and filter initialization - // Using the filter selection recommended for "Weather monitoring - // (lowest power)" in table 10 of the sensor datasheet - - // Oversampling setting + // Oversampling settings - these settings are sent to the BMP3xx and + // need to be repeated at wake if we're not continuously powered MS_DBG(F("Sending BMP3xx oversampling settings")); bmp_internal.setTempOversampling(_tempOversampleEnum); bmp_internal.setPresOversampling(_pressureOversampleEnum); diff --git a/src/sensors/BoschBMP3xx.h b/src/sensors/BoschBMP3xx.h index 787b85ba5..3fd9ea7ee 100644 --- a/src/sensors/BoschBMP3xx.h +++ b/src/sensors/BoschBMP3xx.h @@ -353,11 +353,23 @@ class BoschBMP3xx : public Sensor { * - `OVERSAMPLING_X8` * - `OVERSAMPLING_X16`, * - `OVERSAMPLING_X32` + *
Optional with a default of `OVERSAMPLING_SKIP` (no oversampling). + * This is what is recommended in the datasheet for the lowest power use + * case including environmental and weather monitoring, but you may want to + * use oversampling for better resolution. + * See @ref sensor_bmp3xx_pressure_osr for recommended pressure oversampling + * settings. * * @param tempOversample Temperature oversampling setting *
Possible values are the same as those for pressureOversample. Using * temperature oversampling above X2 is not recommended as it does not * further improve pressure data quality. + *
Optional with a default of `OVERSAMPLING_SKIP` (no oversampling). + * This is what is recommended in the datasheet for the lowest power use + * case including environmental and weather monitoring, but you may want to + * use oversampling for better resolution. + * See @ref sensor_bmp3xx_temp_osr for recommended temperature oversampling + * settings. * * @param filterCoeff Coefficient of the infinite impulse response (IIR) * filter (in samples). @@ -415,8 +427,8 @@ class BoschBMP3xx : public Sensor { * @ref sensor_bmp3xx_filts_uses for recommended settings */ explicit BoschBMP3xx(int8_t powerPin, Mode mode = FORCED_MODE, - Oversampling pressureOversample = OVERSAMPLING_X16, - Oversampling tempOversample = OVERSAMPLING_X2, + Oversampling pressureOversample = OVERSAMPLING_SKIP, + Oversampling tempOversample = OVERSAMPLING_SKIP, IIRFilter filterCoeff = IIR_FILTER_OFF, TimeStandby timeStandby = TIME_STANDBY_10MS, uint8_t i2cAddressHex = 0x76); From abc5d9eae2cab773cf533de9b8f46d20b7a34e84 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Tue, 3 Mar 2026 13:52:27 -0500 Subject: [PATCH 410/533] Fancier pretty print check Signed-off-by: Sara Damiano --- src/VariableArray.cpp | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/src/VariableArray.cpp b/src/VariableArray.cpp index cf16586a3..9c0aab416 100644 --- a/src/VariableArray.cpp +++ b/src/VariableArray.cpp @@ -642,9 +642,22 @@ bool VariableArray::completeUpdate(bool powerUp, bool wake, bool sleep, // Calculated Variable results will be included void VariableArray::printSensorData(Stream* stream) { for (uint8_t i = 0; i < _variableCount; i++) { - if (i > 0 && - arrayOfVars[i]->parentSensor != arrayOfVars[i - 1]->parentSensor) { - stream->println(); + if (i > 0) { + // Check if we need to add a line break between different sensors + // For calculated variables or when parentSensor pointers differ + bool differentSensors = false; + + // If either variable is calculated, treat as different sensors + if (arrayOfVars[i]->isCalculated || + arrayOfVars[i - 1]->isCalculated) { + differentSensors = true; + } else { + // Direct pointer comparison works safely even with nulls + differentSensors = (arrayOfVars[i]->parentSensor != + arrayOfVars[i - 1]->parentSensor); + } + + if (differentSensors) { stream->println(); } } if (arrayOfVars[i]->isCalculated) { stream->print(arrayOfVars[i]->getVarName()); From 0a8ab8b4944f8cffd81f47e931ad02e65ff606c3 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Tue, 3 Mar 2026 14:03:48 -0500 Subject: [PATCH 411/533] Don't double validate OSR,, nitpicks Signed-off-by: Sara Damiano --- ChangeLog.md | 4 +-- README.md | 2 +- src/sensors/BoschBME280.cpp | 8 +++--- src/sensors/TEConnectivityMS5837.cpp | 37 ++++++++++++---------------- src/sensors/TEConnectivityMS5837.h | 11 ++++++--- 5 files changed, 31 insertions(+), 31 deletions(-) diff --git a/ChangeLog.md b/ChangeLog.md index e27331563..c2915017b 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -110,7 +110,7 @@ This affects the following defines: - **EverlightALSPT19** - Moved the calibration constant between current and lux to the `ALSPT19_UA_PER_1000LUX` preprocessor define. - **Bosch BMP3xx** - - Changed the default oversampling for both pressure and temperature to 1x (no oversampling) which is what is recommended by the datasheet for ultra-low-power mode operation - including weather and environmental monitoring. + - Changed the default oversampling for both pressure and temperature to 1x (no oversampling) as recommended by the datasheet for weather and environmental monitoring. #### All Sensors @@ -163,7 +163,7 @@ This is *not* breaking because only AVR and SAMD processors were supported anywa - **NEW SENSOR** Added a new sensor for simple analog voltage using the built-in processor ADC - **NEW SENSOR** Added support for the TE Connectivity (Meas Specialties) MS5837 - - This is the sensor embedded in the Blue Robotics Bar02 and Bar30 sensors + - This is the sensor embedded in the Blue Robotics Bar02 and Bar30 sensors. #### New Features for Specific Sensors diff --git a/README.md b/README.md index fb7682cbb..687ebb318 100644 --- a/README.md +++ b/README.md @@ -78,7 +78,7 @@ For some generalized information about attaching sensors to an Arduino style boa - [MaxBotix MaxSonar: water level](https://envirodiy.github.io/ModularSensors/group__sensor__maxbotix.html) - [Maxim DS18: temperature](https://envirodiy.github.io/ModularSensors/group__sensor__ds18.html) - [Measurement Specialties/TE Connectivity MS5803: pressure and temperature](https://envirodiy.github.io/ModularSensors/group__sensor__ms5803.html) -- [TE Connectivity MS5837: pressure and temperature (deployed as Blue Robotics Bar02/Bar30)](https://envirodiy.github.io/ModularSensors/group__sensor__ms5837.html) +- [Measurement Specialties/TE Connectivity MS5837: pressure and temperature (deployed as Blue Robotics Bar02/Bar30)](https://envirodiy.github.io/ModularSensors/group__sensor__ms5837.html) - Meter Environmental Soil Moisture Probes: soil Ea and volumetric water content - [Meter ECH2O 5TM](https://envirodiy.github.io/ModularSensors/group__sensor__fivetm.html) - [Meter Teros 11](https://envirodiy.github.io/ModularSensors/group__sensor__teros11.html) diff --git a/src/sensors/BoschBME280.cpp b/src/sensors/BoschBME280.cpp index 989bbf696..8463c548a 100644 --- a/src/sensors/BoschBME280.cpp +++ b/src/sensors/BoschBME280.cpp @@ -142,10 +142,12 @@ bool BoschBME280::addSingleMeasurementResult(void) { bool values_ok = temp != -9999 && humid != -9999 && press != -9999 && alt != -9999; - // Assume that if all four are 0, it's really a failed response - // May also return a very negative temp when receiving a bad response + // Assume that if temperature, pressure, and humidity are all 0, it's really + // a failed response. A temperature below -40°C (outside sensor range) also + // indicates a bad response. if (!values_ok || (temp == 0 && press == 0 && humid == 0) || temp < -40) { - MS_DBG(F("All values 0 or bad, assuming sensor non-response!")); + MS_DBG(F("Invalid reading (missing, all zeros, or out of range), " + "assuming sensor non-response!")); } else { verifyAndAddMeasurementResult(BME280_TEMP_VAR_NUM, temp); verifyAndAddMeasurementResult(BME280_HUMIDITY_VAR_NUM, humid); diff --git a/src/sensors/TEConnectivityMS5837.cpp b/src/sensors/TEConnectivityMS5837.cpp index 1fc61de96..31feb069c 100644 --- a/src/sensors/TEConnectivityMS5837.cpp +++ b/src/sensors/TEConnectivityMS5837.cpp @@ -97,7 +97,7 @@ bool TEConnectivityMS5837::setup(void) { // Validate that the pressure range is reasonable for the sensor model and // change the model if possible based on the pressure sensitivity read from // the sensor. - if (validateAndCorrectModel()) { + if (success && validateAndCorrectModel()) { // If the model was changed, we need to re-initialize the sensor with // the new model. success &= MS5837_internal.reset(_model); @@ -166,22 +166,10 @@ bool TEConnectivityMS5837::addSingleMeasurementResult(void) { F("mBar. Expected range: 500-1200")); return bumpMeasurementAttemptCount(false); } - if (_overSamplingRatio != 256 && _overSamplingRatio != 512 && - _overSamplingRatio != 1024 && _overSamplingRatio != 2048 && - _overSamplingRatio != 4096 && _overSamplingRatio != 8192) { - MS_DBG(F("Invalid oversampling ratio:"), _overSamplingRatio, - F(". Valid values: 256, 512, 1024, 2048, 4096, 8192")); - return bumpMeasurementAttemptCount(false); - } - - float temp = -9999; - float press = -9999; - float depth = -9999; - float alt = -9999; - // Read values from the sensor - returns 0 on success - int OSR; + // Map oversampling ratio to OSR value and validate + int OSR = -1; switch (_overSamplingRatio) { case 256: OSR = 8; break; case 512: OSR = 9; break; @@ -190,14 +178,19 @@ bool TEConnectivityMS5837::addSingleMeasurementResult(void) { case 4096: OSR = 12; break; case 8192: OSR = 13; break; default: - MS_DBG(F("Unexpected _overSamplingRatio value:"), - _overSamplingRatio, F(". Unable to map to OSR value.")); + MS_DBG(F("Invalid oversampling ratio:"), _overSamplingRatio, + F(". Valid values: 256, 512, 1024, 2048, 4096, 8192")); return bumpMeasurementAttemptCount(false); } MS_DBG(F(" Requesting"), OSR, F("bit OSR (oversampling ratio:"), _overSamplingRatio, F(")")); - // Convert oversampling ratio to the value expected by the MS5837 library - // (8-13 for oversampling ratios 256-8192) + + float temp = -9999; + float press = -9999; + float depth = -9999; + float alt = -9999; + + // Read values from the sensor - returns 0 on success int read_return = MS5837_internal.read(OSR); bool success = read_return == 0; if (success) { @@ -257,7 +250,7 @@ bool TEConnectivityMS5837::addSingleMeasurementResult(void) { if (success) { // Calculate and store depth and altitude only if input temperature and - // depth are are valid + // pressure are valid // If the temperature and pressure are valid - and we've already checked // for reasonable air pressure and fluid density, then the altitude and // depth will be valid. @@ -317,7 +310,9 @@ bool TEConnectivityMS5837::validateAndCorrectModel() { return false; // can't change the model since we can't retrieve the // calibration value } - uint16_t SENS_T1 = (_wire->read() << 8) | _wire->read(); + uint8_t highByte = _wire->read(); + uint8_t lowByte = _wire->read(); + uint16_t SENS_T1 = (highByte << 8) | lowByte; MS_DBG(F("SENS_T1 value:"), SENS_T1); // Values from diff --git a/src/sensors/TEConnectivityMS5837.h b/src/sensors/TEConnectivityMS5837.h index 30662e695..d22363532 100644 --- a/src/sensors/TEConnectivityMS5837.h +++ b/src/sensors/TEConnectivityMS5837.h @@ -373,15 +373,15 @@ class TEConnectivityMS5837 : public Sensor { * @param measurementsToAverage The number of measurements to take and * average before giving a "final" result from the sensor; optional with a * default value of 1. + * @param overSamplingRatio The oversampling ratio for pressure and + * temperature measurements; optional with default value from + * MS5837_DEFAULT_OVERSAMPLING_RATIO. Valid values: 256, 512, 1024, 2048, + * 4096, 8192. * @param fluidDensity The density of the fluid for depth calculations * (grams/cm³); optional with default value from * MS5837_DEFAULT_FLUID_DENSITY. * @param airPressure The air pressure for altitude/depth calculations * (mBar); optional with default value from MS_SEA_LEVEL_PRESSURE_HPA. - * @param overSamplingRatio The oversampling ratio for pressure and - * temperature measurements; optional with default value from - * MS5837_DEFAULT_OVERSAMPLING_RATIO. Valid values: 256, 512, 1024, 2048, - * 4096, 8192. * * @warning This can be used for the MS5803-01BA sensor, but **only** for * that exact model of MS5803. For any other MS5803 model, use the @@ -505,6 +505,9 @@ class TEConnectivityMS5837 : public Sensor { TwoWire* _wire; // Hardware Wire /** * @brief The model of the MS5837. + * + * @note This is stored as a uint8_t for easier comparison with the math + * model values used in the Rob Tillaart MS5837 library. */ uint8_t _model; /** From 00d183aaa7e1c9d8fb01914032615581ab75da0e Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Tue, 3 Mar 2026 18:26:20 -0500 Subject: [PATCH 412/533] Fix NIST time from parts Signed-off-by: Sara Damiano --- src/modems/LoggerModemMacros.h | 57 ++++++++++++++++++---------------- 1 file changed, 31 insertions(+), 26 deletions(-) diff --git a/src/modems/LoggerModemMacros.h b/src/modems/LoggerModemMacros.h index 6958100fb..e7f94690d 100644 --- a/src/modems/LoggerModemMacros.h +++ b/src/modems/LoggerModemMacros.h @@ -627,32 +627,37 @@ } #elif defined(TINY_GSM_MODEM_HAS_NTP) && defined(TINY_GSM_MODEM_HAS_TIME) #include "ClockSupport.h" -#define MS_MODEM_GET_NIST_TIME(specificModem, TinyGSMType) \ - uint32_t specificModem::getNISTTime(void) { \ - /** Check for and bail if not connected to the internet. */ \ - if (!isInternetAvailable()) { \ - MS_DBG(F("No internet connection, cannot get network time.")); \ - return 0; \ - } \ - \ - MS_DBG("Asking modem to sync with NTP"); \ - gsmModem.NTPServerSync("pool.ntp.org", 0); /*UTC!*/ \ - gsmModem.waitForTimeSync(); \ - \ - /* Create ints to hold time parts */ \ - int seconds = 0; \ - int minutes = 0; \ - int hours = 0; \ - int day = 0; \ - int month = 0; \ - int year = 0; \ - /* Fetch the time as parts */ \ - bool success = gsmModem.getNetworkTime(year, &month, &day, &hours, \ - &minutes, &seconds, 0); \ - if (!success) { return 0; } \ - tm timeParts = {seconds, minutes, hours, day, month, year - 1900}; \ - time_t timeTimeT = mktime(&timeParts); \ - return epochTime(timeTimeT, epochStart::unix_epoch); \ +#define MS_MODEM_GET_NIST_TIME(specificModem, TinyGSMType) \ + uint32_t specificModem::getNISTTime(void) { \ + /** Check for and bail if not connected to the internet. */ \ + if (!isInternetAvailable()) { \ + MS_DBG(F("No internet connection, cannot get network time.")); \ + return 0; \ + } \ + \ + MS_DBG("Asking modem to sync with NTP"); \ + gsmModem.NTPServerSync("pool.ntp.org", 0); /*UTC!*/ \ + gsmModem.waitForTimeSync(); \ + \ + /* Create ints to hold time parts */ \ + int seconds = 0; \ + int minutes = 0; \ + int hours = 0; \ + int day = 0; \ + int month = 0; \ + int year = 0; \ + /* Fetch the time as parts */ \ + bool success = gsmModem.getNetworkTime(year, &month, &day, &hours, \ + &minutes, &seconds, 0); \ + if (!success) { return 0; } \ + tm timeParts = { \ + static_cast(seconds), static_cast(minutes), \ + static_cast(hours), static_cast(day), \ + static_cast(month - 1), /* tm_mon is 0-11 */ \ + static_cast(year - 1900) /* tm_year is since 1900 */ \ + }; \ + time_t timeTimeT = mktime(&timeParts); \ + return static_cast(timeTimeT); \ } #else #define MS_MODEM_GET_NIST_TIME(specificModem, TinyGSMType) \ From d686efab04bf723fb825ab14437570d9b9a8bc24 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Tue, 3 Mar 2026 18:26:49 -0500 Subject: [PATCH 413/533] Fix compiler warning Signed-off-by: Sara Damiano --- src/sensors/ANBpH.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/sensors/ANBpH.cpp b/src/sensors/ANBpH.cpp index 977c066d3..48acfe08b 100644 --- a/src/sensors/ANBpH.cpp +++ b/src/sensors/ANBpH.cpp @@ -142,7 +142,9 @@ bool ANBpH::setup(void) { uint16_t programmedInterval = _loggingIntervalMinutes; // Validate and normalize loggingIntervalMinutes based on powerPin +#if defined(MS_ANB_SENSORS_PH_DEBUG) || defined(MS_ANB_SENSORS_PH_DEBUG_DEEP) int16_t originalInterval = _loggingIntervalMinutes; // Store original for debug messages +#endif if (_powerPin >= 0) { // Cycled power if (_loggingIntervalMinutes == 0) { programmedInterval = 10; From 986c1d3f5fd8317967bdbfcfd842b3b9e71f02b4 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Wed, 4 Mar 2026 09:38:48 -0500 Subject: [PATCH 414/533] Convert all -9999s to a defined MS_INVALID_VALUE Signed-off-by: Sara Damiano --- ChangeLog.md | 3 +- examples/AWS_IoT_Core/AWS_IoT_Core.ino | 6 +-- .../EnviroDIY_Monitoring_Kit.ino | 2 +- .../DRWI_CitizenScience/DRWI_2G/DRWI_2G.ino | 2 +- .../DRWI_DigiLTE/DRWI_DigiLTE.ino | 2 +- .../DRWI_Mayfly1/DRWI_Mayfly1.ino | 4 +- .../DRWI_Mayfly1_WiFi/DRWI_Mayfly1_WiFi.ino | 2 +- .../DRWI_NoCellular/DRWI_NoCellular.ino | 2 +- .../DRWI_SIM7080LTE/DRWI_SIM7080LTE.ino | 4 +- .../baro_rho_correction.ino | 15 ++++--- examples/double_logger/double_logger.ino | 4 +- examples/logging_to_MMW/logging_to_MMW.ino | 2 +- .../logging_to_ThingSpeak.ino | 6 +-- examples/menu_a_la_carte/menu_a_la_carte.ino | 21 +++++----- src/LoggerModem.cpp | 41 ++++++++++--------- src/SensorBase.cpp | 9 ++-- src/SensorBase.h | 25 +++++------ src/VariableBase.cpp | 4 +- src/VariableBase.h | 4 +- src/modems/DigiXBeeCellularTransparent.cpp | 19 ++++----- src/modems/DigiXBeeWifi.cpp | 31 +++++++------- src/modems/LoggerModemMacros.h | 12 ++++-- .../MonitorMyWatershedPublisher.cpp | 3 +- src/publishers/ThingSpeakPublisher.cpp | 2 +- src/publishers/UbidotsPublisher.cpp | 3 +- src/sensors/ANBpH.cpp | 23 ++++++----- src/sensors/ANBpH.h | 4 +- src/sensors/AOSongAM2315.cpp | 8 ++-- src/sensors/AOSongDHT.cpp | 6 +-- src/sensors/AlphasenseCO2.cpp | 2 +- src/sensors/AnalogElecConductivity.cpp | 4 +- src/sensors/AnalogVoltageBase.h | 2 +- src/sensors/ApogeeSQ212.cpp | 2 +- src/sensors/AtlasParent.cpp | 2 +- src/sensors/BoschBME280.cpp | 20 ++++----- src/sensors/BoschBMP3xx.cpp | 6 +-- src/sensors/CampbellOBS3.cpp | 2 +- src/sensors/Decagon5TM.cpp | 10 ++--- src/sensors/EverlightALSPT19.cpp | 2 +- src/sensors/FreescaleMPL115A2.cpp | 4 +- src/sensors/GeoluxHydroCam.cpp | 4 +- src/sensors/GroPointParent.cpp | 13 +++--- src/sensors/KellerParent.cpp | 21 +++++----- src/sensors/MaxBotixSonar.cpp | 4 +- src/sensors/MaximDS18.cpp | 2 +- src/sensors/MeaSpecMS5803.cpp | 4 +- src/sensors/MeterTeros11.cpp | 16 ++++---- src/sensors/PaleoTerraRedox.cpp | 6 +-- src/sensors/ProcessorAnalog.cpp | 8 ++-- src/sensors/ProcessorAnalog.h | 2 +- src/sensors/ProcessorStats.cpp | 4 +- src/sensors/RainCounterI2C.cpp | 16 +++++--- src/sensors/SDI12Sensors.cpp | 15 +++---- src/sensors/SensirionSHT4x.cpp | 4 +- src/sensors/TEConnectivityMS5837.cpp | 8 ++-- src/sensors/TIADS1x15.cpp | 26 +++++------- src/sensors/TIADS1x15.h | 7 ++-- src/sensors/TIINA219.cpp | 6 +-- src/sensors/TallyCounterI2C.cpp | 4 +- src/sensors/TurnerCyclops.cpp | 2 +- src/sensors/TurnerTurbidityPlus.cpp | 2 +- src/sensors/YosemitechParent.cpp | 22 +++++----- 62 files changed, 270 insertions(+), 251 deletions(-) diff --git a/ChangeLog.md b/ChangeLog.md index c2915017b..2a1194ca3 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -120,7 +120,7 @@ This affects the following defines: These resets were an awkward attempt to deal with bad values before feeding any bad values to the `verifyAndAddMeasurementResult()` function which was previously always called even if the sensor returned junk. This was probably a hold-over from incorrect implementation and calling of the clearValues function deep in the library history. - Also made the return from the `addSingleMeasurementResult()` function consistently false for a bad sensor response and true for a good one - where it's possible to tell the difference. -- The Sensor::clearValues() function now resets the attempt and retry counts in addition to setting all values in the value array to -9999. +- The Sensor::clearValues() function now resets the attempt and retry counts in addition to setting all values in the value array to MS_INVALID_VALUE. #### Individual Publishers @@ -206,6 +206,7 @@ This affects the following classes: #### Library-Wide +- Added a configuration define for MS_INVALID_VALUE and replaced all occurrences of the standard -9999 with this define. - Added KnownProcessors.h and moved define values for supported built-in sensors on known processors to that file. - This affects ProcessorStats and the Everlight ALS PT-19. - Added a new example specific to the [EnviroDIY Monitoring Station Kit](https://www.envirodiy.org/product/envirodiy-monitoring-station-kit/). diff --git a/examples/AWS_IoT_Core/AWS_IoT_Core.ino b/examples/AWS_IoT_Core/AWS_IoT_Core.ino index 511bc2800..de09d6f12 100644 --- a/examples/AWS_IoT_Core/AWS_IoT_Core.ino +++ b/examples/AWS_IoT_Core/AWS_IoT_Core.ino @@ -99,8 +99,8 @@ const int8_t modemLEDPin = redLED; // MCU pin connected an LED to show modem status // Network connection information -const char* wifiId = "YourWiFiSSID"; // The WiFi access point -const char* wifiPwd = "YourWiFiPassword"; // The WiFi password +const char* wifiId = "YourWiFiSSID"; // The WiFi access point +const char* wifiPwd = "YourWiFiPassword"; // The WiFi password // Create the loggerModem object EspressifESP32 modemESP(&modemSerial, modemVccPin, modemResetPin, wifiId, @@ -264,7 +264,7 @@ void greenRedFlash(uint8_t numFlash = 4, uint8_t rate = 75) { // Reads the battery voltage // NOTE: This will actually return the battery level from the previous update! float getBatteryVoltage() { - if (mcuBoard.sensorValues[0] == -9999) mcuBoard.update(); + if (mcuBoard.sensorValues[0] == MS_INVALID_VALUE) mcuBoard.update(); return mcuBoard.sensorValues[0]; } /** End [working_functions] */ diff --git a/examples/EnviroDIY_Monitoring_Kit/EnviroDIY_Monitoring_Kit.ino b/examples/EnviroDIY_Monitoring_Kit/EnviroDIY_Monitoring_Kit.ino index b9913e126..051fed5ec 100644 --- a/examples/EnviroDIY_Monitoring_Kit/EnviroDIY_Monitoring_Kit.ino +++ b/examples/EnviroDIY_Monitoring_Kit/EnviroDIY_Monitoring_Kit.ino @@ -361,7 +361,7 @@ void greenRedFlash(uint8_t numFlash = 4, uint8_t rate = 75) { // Uses the processor sensor object to read the battery voltage // NOTE: This will actually return the battery level from the previous update! float getBatteryVoltage() { - if (mcuBoard.sensorValues[PROCESSOR_BATTERY_VAR_NUM] == -9999 || + if (mcuBoard.sensorValues[PROCESSOR_BATTERY_VAR_NUM] == MS_INVALID_VALUE || mcuBoard.sensorValues[PROCESSOR_BATTERY_VAR_NUM] == 0) { mcuBoard.update(); } diff --git a/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_2G/DRWI_2G.ino b/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_2G/DRWI_2G.ino index dcf7e3c6b..63225a5bd 100644 --- a/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_2G/DRWI_2G.ino +++ b/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_2G/DRWI_2G.ino @@ -240,7 +240,7 @@ void greenRedFlash(uint8_t numFlash = 4, uint8_t rate = 75) { // Reads the battery voltage // NOTE: This will actually return the battery level from the previous update! float getBatteryVoltage() { - if (mcuBoard.sensorValues[0] == -9999) mcuBoard.update(); + if (mcuBoard.sensorValues[0] == MS_INVALID_VALUE) mcuBoard.update(); return mcuBoard.sensorValues[0]; } /** End [working_functions] */ diff --git a/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_DigiLTE/DRWI_DigiLTE.ino b/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_DigiLTE/DRWI_DigiLTE.ino index 5b2ee90d3..451414e02 100644 --- a/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_DigiLTE/DRWI_DigiLTE.ino +++ b/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_DigiLTE/DRWI_DigiLTE.ino @@ -260,7 +260,7 @@ void greenRedFlash(uint8_t numFlash = 4, uint8_t rate = 75) { // Reads the battery voltage // NOTE: This will actually return the battery level from the previous update! float getBatteryVoltage() { - if (mcuBoard.sensorValues[0] == -9999) mcuBoard.update(); + if (mcuBoard.sensorValues[0] == MS_INVALID_VALUE) mcuBoard.update(); return mcuBoard.sensorValues[0]; } diff --git a/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_Mayfly1/DRWI_Mayfly1.ino b/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_Mayfly1/DRWI_Mayfly1.ino index 7046785b3..e276b6c0e 100644 --- a/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_Mayfly1/DRWI_Mayfly1.ino +++ b/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_Mayfly1/DRWI_Mayfly1.ino @@ -85,7 +85,7 @@ const int8_t modemLEDPin = redLED; // MCU pin connected an LED to show modem // Network connection information const char* apn = "YourAPN"; // APN connection name, typically Hologram unless you have a - // different provider's SIM card. Change as needed + // different provider's SIM card. Change as needed // Create the modem object SIMComSIM7080 modem7080(&modemSerial, modemVccPin, modemStatusPin, @@ -267,7 +267,7 @@ void greenRedFlash(uint8_t numFlash = 4, uint8_t rate = 75) { // Reads the battery voltage // NOTE: This will actually return the battery level from the previous update! float getBatteryVoltage() { - if (mcuBoard.sensorValues[0] == -9999) mcuBoard.update(); + if (mcuBoard.sensorValues[0] == MS_INVALID_VALUE) mcuBoard.update(); return mcuBoard.sensorValues[0]; } diff --git a/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_Mayfly1_WiFi/DRWI_Mayfly1_WiFi.ino b/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_Mayfly1_WiFi/DRWI_Mayfly1_WiFi.ino index 0d6121a45..5947eddcb 100644 --- a/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_Mayfly1_WiFi/DRWI_Mayfly1_WiFi.ino +++ b/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_Mayfly1_WiFi/DRWI_Mayfly1_WiFi.ino @@ -242,7 +242,7 @@ void greenRedFlash(uint8_t numFlash = 4, uint8_t rate = 75) { // Reads the battery voltage // NOTE: This will actually return the battery level from the previous update! float getBatteryVoltage() { - if (mcuBoard.sensorValues[0] == -9999) mcuBoard.update(); + if (mcuBoard.sensorValues[0] == MS_INVALID_VALUE) mcuBoard.update(); return mcuBoard.sensorValues[0]; } diff --git a/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_NoCellular/DRWI_NoCellular.ino b/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_NoCellular/DRWI_NoCellular.ino index 66fc3fe75..0dd6d87e0 100644 --- a/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_NoCellular/DRWI_NoCellular.ino +++ b/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_NoCellular/DRWI_NoCellular.ino @@ -199,7 +199,7 @@ void greenRedFlash(uint8_t numFlash = 4, uint8_t rate = 75) { // Reads the battery voltage // NOTE: This will actually return the battery level from the previous update! float getBatteryVoltage() { - if (mcuBoard.sensorValues[0] == -9999) mcuBoard.update(); + if (mcuBoard.sensorValues[0] == MS_INVALID_VALUE) mcuBoard.update(); return mcuBoard.sensorValues[0]; } /** End [working_functions] */ diff --git a/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_SIM7080LTE/DRWI_SIM7080LTE.ino b/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_SIM7080LTE/DRWI_SIM7080LTE.ino index 4f4b3ac4b..6980561e0 100644 --- a/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_SIM7080LTE/DRWI_SIM7080LTE.ino +++ b/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_SIM7080LTE/DRWI_SIM7080LTE.ino @@ -86,7 +86,7 @@ const int8_t modemLEDPin = redLED; // MCU pin connected an LED to show modem // Network connection information const char* apn = "YourAPN"; // APN connection name, typically Hologram unless you have a - // different provider's SIM card. Change as needed + // different provider's SIM card. Change as needed // Create the modem object SIMComSIM7080 modem7080(&modemSerial, modemVccPin, modemStatusPin, @@ -267,7 +267,7 @@ void greenRedFlash(uint8_t numFlash = 4, uint8_t rate = 75) { // Reads the battery voltage // NOTE: This will actually return the battery level from the previous update! float getBatteryVoltage() { - if (mcuBoard.sensorValues[0] == -9999) mcuBoard.update(); + if (mcuBoard.sensorValues[0] == MS_INVALID_VALUE) mcuBoard.update(); return mcuBoard.sensorValues[0]; } diff --git a/examples/baro_rho_correction/baro_rho_correction.ino b/examples/baro_rho_correction/baro_rho_correction.ino index 82edd8db3..4b1b51c05 100644 --- a/examples/baro_rho_correction/baro_rho_correction.ino +++ b/examples/baro_rho_correction/baro_rho_correction.ino @@ -211,8 +211,9 @@ float calculateWaterPressure(void) { float baroPressureFromBME280 = bme280Press->getValue(); float waterPressure = totalPressureFromMS5803 - (baroPressureFromBME280) * 0.01; - if (totalPressureFromMS5803 == -9999 || baroPressureFromBME280 == -9999) { - waterPressure = -9999; + if (totalPressureFromMS5803 == MS_INVALID_VALUE || + baroPressureFromBME280 == MS_INVALID_VALUE) { + waterPressure = MS_INVALID_VALUE; } // Serial.print(F("Water pressure is ")); // for debugging // Serial.println(waterPressure); // for debugging @@ -240,7 +241,8 @@ Variable* calcWaterPress = new Variable( // This calculation gives a final result in mm of water float calculateWaterDepthRaw(void) { float waterDepth = calculateWaterPressure() * 10.1972; - if (calculateWaterPressure() == -9999) waterDepth = -9999; + if (calculateWaterPressure() == MS_INVALID_VALUE) + waterDepth = MS_INVALID_VALUE; // Serial.print(F("'Raw' water depth is ")); // for debugging // Serial.println(waterDepth); // for debugging return waterDepth; @@ -282,8 +284,9 @@ float calculateWaterDepthTempCorrected(void) { // from P = rho * g * h float rhoDepth = 1000 * waterPressurePa / (waterDensity * gravitationalConstant); - if (calculateWaterPressure() == -9999 || waterTemperatureC == -9999) { - rhoDepth = -9999; + if (calculateWaterPressure() == MS_INVALID_VALUE || + waterTemperatureC == MS_INVALID_VALUE) { + rhoDepth = MS_INVALID_VALUE; } // Serial.print(F("Temperature corrected water depth is ")); // for // debugging Serial.println(rhoDepth); // for debugging @@ -374,7 +377,7 @@ void greenRedFlash(uint8_t numFlash = 4, uint8_t rate = 75) { // Uses the processor sensor to read the battery voltage // NOTE: This will actually return the battery level from the previous update! float getBatteryVoltage() { - if (mcuBoard.sensorValues[0] == -9999) mcuBoard.update(); + if (mcuBoard.sensorValues[0] == MS_INVALID_VALUE) mcuBoard.update(); return mcuBoard.sensorValues[0]; } /** End [working_functions] */ diff --git a/examples/double_logger/double_logger.ino b/examples/double_logger/double_logger.ino index 1219147bc..93af6f5d2 100644 --- a/examples/double_logger/double_logger.ino +++ b/examples/double_logger/double_logger.ino @@ -77,8 +77,8 @@ const int8_t modemLEDPin = redLED; // MCU pin connected an LED to show modem // status (-1 if unconnected) // Network connection information -const char* wifiId = "YourWiFiSSID"; // The WiFi access point -const char* wifiPwd = "YourWiFiPassword"; // The WiFi password +const char* wifiId = "YourWiFiSSID"; // The WiFi access point +const char* wifiPwd = "YourWiFiPassword"; // The WiFi password DigiXBeeWifi modemXBWF(&modemSerial, modemVccPin, modemStatusPin, useCTSforStatus, modemResetPin, modemSleepRqPin, wifiId, diff --git a/examples/logging_to_MMW/logging_to_MMW.ino b/examples/logging_to_MMW/logging_to_MMW.ino index bb07a6147..40408f6d5 100644 --- a/examples/logging_to_MMW/logging_to_MMW.ino +++ b/examples/logging_to_MMW/logging_to_MMW.ino @@ -227,7 +227,7 @@ void greenRedFlash(uint8_t numFlash = 4, uint8_t rate = 75) { // Reads the battery voltage // NOTE: This will actually return the battery level from the previous update! float getBatteryVoltage() { - if (mcuBoard.sensorValues[0] == -9999) mcuBoard.update(); + if (mcuBoard.sensorValues[0] == MS_INVALID_VALUE) mcuBoard.update(); return mcuBoard.sensorValues[0]; } /** End [working_functions] */ diff --git a/examples/logging_to_ThingSpeak/logging_to_ThingSpeak.ino b/examples/logging_to_ThingSpeak/logging_to_ThingSpeak.ino index 9df2e7281..fa93f9e35 100644 --- a/examples/logging_to_ThingSpeak/logging_to_ThingSpeak.ino +++ b/examples/logging_to_ThingSpeak/logging_to_ThingSpeak.ino @@ -76,8 +76,8 @@ const int8_t modemLEDPin = redLED; // MCU pin connected an LED to show modem status // Network connection information -const char* wifiId = "YourWiFiSSID"; // The WiFi access point -const char* wifiPwd = "YourWiFiPassword"; // The WiFi password +const char* wifiId = "YourWiFiSSID"; // The WiFi access point +const char* wifiPwd = "YourWiFiPassword"; // The WiFi password // Create the loggerModem object EspressifESP8266 modemESP(&modemSerial, modemVccPin, modemResetPin, wifiId, @@ -236,7 +236,7 @@ void greenRedFlash(uint8_t numFlash = 4, uint8_t rate = 75) { // Reads the battery voltage // NOTE: This will actually return the battery level from the previous update! float getBatteryVoltage() { - if (mcuBoard.sensorValues[0] == -9999) mcuBoard.update(); + if (mcuBoard.sensorValues[0] == MS_INVALID_VALUE) mcuBoard.update(); return mcuBoard.sensorValues[0]; } /** End [working_functions] */ diff --git a/examples/menu_a_la_carte/menu_a_la_carte.ino b/examples/menu_a_la_carte/menu_a_la_carte.ino index f7d3f1d86..e89a5af1e 100644 --- a/examples/menu_a_la_carte/menu_a_la_carte.ino +++ b/examples/menu_a_la_carte/menu_a_la_carte.ino @@ -1327,7 +1327,7 @@ Variable* atlasGrav = new AtlasScientificEC_SpecificGravity( // **DO NOT** use your logger board temperature (ie, from the DS3231) to // calculate specific conductance! float calculateAtlasSpCond() { - float spCond = -9999; // Always safest to start with a bad value + float spCond = MS_INVALID_VALUE; // Always safest to start with a bad value float waterTemp = atlasTemp->getValue(); float rawCond = atlasCond->getValue(); // ^^ Linearized temperature correction coefficient per degrees Celsius. @@ -1336,7 +1336,7 @@ float calculateAtlasSpCond() { // environmental monitoring and geophysical data inversion. Environ Monit // Assess. 2004 Aug-Sep;96(1-3):119-28. // doi: 10.1023/b:emas.0000031719.83065.68. PMID: 15327152. - if (waterTemp != -9999 && rawCond != -9999) { + if (waterTemp != MS_INVALID_VALUE && rawCond != MS_INVALID_VALUE) { // make sure both inputs are good float temperatureCoef = 0.019; spCond = rawCond / (1 + temperatureCoef * (waterTemp - 25.0)); @@ -2086,12 +2086,12 @@ Variable* ms5803Temp = #include // NOTE: Use -1 for any pins that don't apply or aren't being used. -const int8_t MS5837Power = sensorPowerPin; // Power pin -const MS5837Model MS5837model = MS5837Model::MS5837_02BA; +const int8_t MS5837Power = sensorPowerPin; // Power pin +const MS5837Model MS5837model = MS5837Model::MS5837_02BA; // - MS5837Model::MS5837_30BA for 30 bar range sensors (MS5837-30BA) // - MS5837Model::MS5837_02BA for 2 bar range sensors (MS5837-02BA) // - MS5837Model::MS5803_01BA for 1 bar range sensors (MS5803-01BA) -const uint8_t MS5837ReadingsToAvg = 1; +const uint8_t MS5837ReadingsToAvg = 1; // Create a TE Connectivity MS5837 pressure and temperature sensor object TEConnectivityMS5837 ms5837(MS5837Power, MS5837model, MS5837ReadingsToAvg); @@ -2499,7 +2499,7 @@ Variable* analogEc_cond = new AnalogElecConductivity_EC( // temperature sensor if desired. **DO NOT** use your logger board temperature // (ie, from the DS3231) to calculate specific conductance! float calculateAnalogSpCond() { - float spCond = -9999; // Always safest to start with a bad value + float spCond = MS_INVALID_VALUE; // Always safest to start with a bad value float waterTemp = ds18Temp->getValue(); float rawCond = analogEc_cond->getValue(); float temperatureCoef = 0.019; @@ -2509,7 +2509,7 @@ float calculateAnalogSpCond() { // environmental monitoring and geophysical data inversion. Environ Monit // Assess. 2004 Aug-Sep;96(1-3):119-28. // doi: 10.1023/b:emas.0000031719.83065.68. PMID: 15327152. - if (waterTemp != -9999 && rawCond != -9999) { + if (waterTemp != MS_INVALID_VALUE && rawCond != MS_INVALID_VALUE) { // make sure both inputs are good spCond = rawCond / (1 + temperatureCoef * (waterTemp - 25.0)); } @@ -3064,11 +3064,12 @@ Variable* dOptoTemp = // variable->getValue() float calculateVariableValue() { - float calculatedResult = -9999; // Always safest to start with a bad value + float calculatedResult = + MS_INVALID_VALUE; // Always safest to start with a bad value // float inputVar1 = variable1->getValue(); // float inputVar2 = variable2->getValue(); // make sure both inputs are good - // if (inputVar1 != -9999 && inputVar2 != -9999) { + // if (inputVar1 != MS_INVALID_VALUE && inputVar2 != MS_INVALID_VALUE) { // calculatedResult = inputVar1 + inputVar2; // } return calculatedResult; @@ -3745,7 +3746,7 @@ void greenRedFlash(uint8_t numFlash = 4, uint8_t rate = 75) { // Uses the processor sensor object to read the battery voltage // NOTE: This will actually return the battery level from the previous update! float getBatteryVoltage() { - if (mcuBoard.sensorValues[PROCESSOR_BATTERY_VAR_NUM] == -9999 || + if (mcuBoard.sensorValues[PROCESSOR_BATTERY_VAR_NUM] == MS_INVALID_VALUE || mcuBoard.sensorValues[PROCESSOR_BATTERY_VAR_NUM] == 0) { mcuBoard.update(); } diff --git a/src/LoggerModem.cpp b/src/LoggerModem.cpp index 225f33b16..782e91935 100644 --- a/src/LoggerModem.cpp +++ b/src/LoggerModem.cpp @@ -12,12 +12,12 @@ #include "ClockSupport.h" // Initialize the static members -int16_t loggerModem::_priorRSSI = -9999; -int16_t loggerModem::_priorSignalPercent = -9999; -float loggerModem::_priorModemTemp = -9999; -float loggerModem::_priorBatteryState = -9999; -float loggerModem::_priorBatteryPercent = -9999; -float loggerModem::_priorBatteryVoltage = -9999; +int16_t loggerModem::_priorRSSI = MS_INVALID_VALUE; +int16_t loggerModem::_priorSignalPercent = MS_INVALID_VALUE; +float loggerModem::_priorModemTemp = MS_INVALID_VALUE; +float loggerModem::_priorBatteryState = MS_INVALID_VALUE; +float loggerModem::_priorBatteryPercent = MS_INVALID_VALUE; +float loggerModem::_priorBatteryVoltage = MS_INVALID_VALUE; // Constructor loggerModem::loggerModem(int8_t powerPin, int8_t statusPin, bool statusLevel, @@ -330,16 +330,16 @@ bool loggerModem::updateModemMetadata(void) { bool success = true; // Unset whatever we had previously - loggerModem::_priorRSSI = -9999; - loggerModem::_priorSignalPercent = -9999; - loggerModem::_priorBatteryState = -9999; - loggerModem::_priorBatteryPercent = -9999; - loggerModem::_priorBatteryPercent = -9999; - loggerModem::_priorModemTemp = -9999; + loggerModem::_priorRSSI = MS_INVALID_VALUE; + loggerModem::_priorSignalPercent = MS_INVALID_VALUE; + loggerModem::_priorBatteryState = MS_INVALID_VALUE; + loggerModem::_priorBatteryPercent = MS_INVALID_VALUE; + loggerModem::_priorBatteryVoltage = MS_INVALID_VALUE; + loggerModem::_priorModemTemp = MS_INVALID_VALUE; // Initialize variable - int16_t rssi = -9999; - int16_t percent = -9999; + int16_t rssi = MS_INVALID_VALUE; + int16_t percent = MS_INVALID_VALUE; int8_t state = 99; int8_t bpercent = -99; int16_t volt = 9999; @@ -356,9 +356,9 @@ bool loggerModem::updateModemMetadata(void) { success &= getModemSignalQuality(rssi, percent); loggerModem::_priorRSSI = rssi; loggerModem::_priorSignalPercent = percent; - if (rssi != 0 && rssi != -9999) break; + if (rssi != 0 && rssi != MS_INVALID_VALUE) break; delay(250); - } while ((rssi == 0 || rssi == -9999) && + } while ((rssi == 0 || rssi == MS_INVALID_VALUE) && millis() - startMillis < 15000L && success); MS_DBG(F("CURRENT RSSI:"), rssi); MS_DBG(F("CURRENT Percent signal strength:"), percent); @@ -379,17 +379,20 @@ bool loggerModem::updateModemMetadata(void) { if (state != 99) loggerModem::_priorBatteryState = static_cast(state); else - loggerModem::_priorBatteryState = static_cast(-9999); + loggerModem::_priorBatteryState = + static_cast(MS_INVALID_VALUE); if (bpercent != -99) loggerModem::_priorBatteryPercent = static_cast(bpercent); else - loggerModem::_priorBatteryPercent = static_cast(-9999); + loggerModem::_priorBatteryPercent = + static_cast(MS_INVALID_VALUE); if (volt != 9999) loggerModem::_priorBatteryVoltage = static_cast(volt); else - loggerModem::_priorBatteryVoltage = static_cast(-9999); + loggerModem::_priorBatteryVoltage = + static_cast(MS_INVALID_VALUE); } else { MS_DBG(F("Polling for all modem battery parameters is disabled")); } diff --git a/src/SensorBase.cpp b/src/SensorBase.cpp index 91398c73e..84ee5964b 100644 --- a/src/SensorBase.cpp +++ b/src/SensorBase.cpp @@ -33,7 +33,7 @@ Sensor::Sensor(const char* sensorName, const uint8_t totalReturnedValues, // Clear arrays for (uint8_t i = 0; i < MAX_NUMBER_VARS; i++) { variables[i] = nullptr; - sensorValues[i] = -9999; + sensorValues[i] = MS_INVALID_VALUE; numberGoodMeasurementsMade[i] = 0; } } @@ -367,7 +367,7 @@ void Sensor::notifyVariables(void) { void Sensor::clearValues(void) { MS_DBG(F("Clearing value array for"), getSensorNameAndLocation()); for (uint8_t i = 0; i < _numReturnedValues; i++) { - sensorValues[i] = -9999; + sensorValues[i] = MS_INVALID_VALUE; numberGoodMeasurementsMade[i] = 0; } // Reset measurement attempt counters @@ -413,9 +413,10 @@ void Sensor::clearStatus(void) { // averaged void Sensor::verifyAndAddMeasurementResult(uint8_t resultNumber, float resultValue) { - bool prevResultGood = (sensorValues[resultNumber] != -9999 && + bool prevResultGood = (sensorValues[resultNumber] != MS_INVALID_VALUE && !isnan(sensorValues[resultNumber])); - bool newResultGood = (resultValue != -9999 && !isnan(resultValue)); + bool newResultGood = (resultValue != MS_INVALID_VALUE && + !isnan(resultValue)); // If the new result is good and there was were only bad results, set the // result value as the new result and add 1 to the good result total if (!prevResultGood && newResultGood) { diff --git a/src/SensorBase.h b/src/SensorBase.h index a4396cfb7..e5433309f 100644 --- a/src/SensorBase.h +++ b/src/SensorBase.h @@ -514,16 +514,17 @@ class Sensor { * * @note The values in this array will not be usable until after the sensor * completes all requested measurements! Prior to that, the values in this - * array will be the sum of all good values measured so far (or -9999 if no - * good values have been measured yet). + * array will be the sum of all good values measured so far (or + * #MS_INVALID_VALUE if no good values have been measured yet). */ float sensorValues[MAX_NUMBER_VARS]; /** * @brief Clear the values array and reset retry counts. * - * This clears the values array by setting all values to -9999, sets all - * values in numberGoodMeasurementsMade to 0, and resets the attempt + * This clears the values array by setting all values to #MS_INVALID_VALUE, + * sets all values in numberGoodMeasurementsMade to 0, and resets the + * attempt * (#_measurementAttemptsCompleted) and retry (#_retryAttemptsMade) counts. */ void clearValues(); @@ -566,16 +567,16 @@ class Sensor { */ void clearMeasurementStatus(); /** - * @brief Verify that a measurement is OK (ie, not -9999) before adding it - * to the result array + * @brief Verify that a measurement is OK (ie, not #MS_INVALID_VALUE) before + * adding it to the result array * * @param resultNumber The position of the result within the result array. * @param resultValue The value of the result. */ void verifyAndAddMeasurementResult(uint8_t resultNumber, float resultValue); /** - * @brief Verify that a measurement is OK (ie, not -9999) before adding it - * to the result array + * @brief Verify that a measurement is OK (ie, not #MS_INVALID_VALUE) before + * adding it to the result array * * @param resultNumber The position of the result within the result array. * @param resultValue The value of the result. @@ -727,10 +728,10 @@ class Sensor { * @brief The number of measurements from the sensor to average. * * This will become the number of readings actually taken by a sensor prior - * to data averaging. Any "bad" (-9999) values returned by the sensor will - * not be included in the final averaging. This means that the actual - * number of "good" values that are averaged may be less than what was - * requested. + * to data averaging. Any "bad" (#MS_INVALID_VALUE) values returned by the + * sensor will not be included in the final averaging. This means that the + * actual number of "good" values that are averaged may be less than what + * was requested. */ uint8_t _measurementsToAverage; /** diff --git a/src/VariableBase.cpp b/src/VariableBase.cpp index 8e598035f..4f8af5560 100644 --- a/src/VariableBase.cpp +++ b/src/VariableBase.cpp @@ -252,7 +252,7 @@ float Variable::getValue(bool updateValue) { _currentValue = _calcFxn(); } else if (updateValue && _calcFxn == nullptr) { // If no calculation function is set, return error value - _currentValue = -9999; + _currentValue = MS_INVALID_VALUE; } return _currentValue; } else { @@ -260,7 +260,7 @@ float Variable::getValue(bool updateValue) { parentSensor->update(); } else if (updateValue && parentSensor == nullptr) { // If no parent sensor is set, return error value - _currentValue = -9999; + _currentValue = MS_INVALID_VALUE; } return _currentValue; } diff --git a/src/VariableBase.h b/src/VariableBase.h index 787176280..c8530a696 100644 --- a/src/VariableBase.h +++ b/src/VariableBase.h @@ -442,9 +442,9 @@ class Variable { * @brief The current data value * * When we create the variable, we also want to initialize it with a current - * value of -9999 (ie, a bad result). + * value of #MS_INVALID_VALUE (ie, a bad result). */ - float _currentValue = -9999; + float _currentValue = MS_INVALID_VALUE; private: diff --git a/src/modems/DigiXBeeCellularTransparent.cpp b/src/modems/DigiXBeeCellularTransparent.cpp index 1590d1ee4..1405185be 100644 --- a/src/modems/DigiXBeeCellularTransparent.cpp +++ b/src/modems/DigiXBeeCellularTransparent.cpp @@ -262,15 +262,14 @@ bool DigiXBeeCellularTransparent::updateModemMetadata(void) { bool success = true; // Unset whatever we had previously - loggerModem::_priorRSSI = -9999; - loggerModem::_priorSignalPercent = -9999; - loggerModem::_priorBatteryState = -9999; - loggerModem::_priorBatteryPercent = -9999; - loggerModem::_priorBatteryPercent = -9999; - loggerModem::_priorModemTemp = -9999; - + loggerModem::_priorRSSI = MS_INVALID_VALUE; + loggerModem::_priorSignalPercent = MS_INVALID_VALUE; + loggerModem::_priorBatteryState = MS_INVALID_VALUE; + loggerModem::_priorBatteryPercent = MS_INVALID_VALUE; + loggerModem::_priorBatteryVoltage = MS_INVALID_VALUE; + loggerModem::_priorModemTemp = MS_INVALID_VALUE; // Initialize variable - int16_t signalQual = -9999; + int16_t signalQual = MS_INVALID_VALUE; MS_DBG(F("Modem polling settings:"), String(_pollModemMetaData, BIN)); @@ -299,9 +298,9 @@ bool DigiXBeeCellularTransparent::updateModemMetadata(void) { MS_DBG(F("Getting signal quality:")); signalQual = gsmModem.getSignalQuality(); MS_DBG(F("Raw signal quality:"), signalQual); - if (signalQual != 0 && signalQual != -9999) break; + if (signalQual != 0 && signalQual != MS_INVALID_VALUE) break; delay(250); - } while ((signalQual == 0 || signalQual == -9999) && + } while ((signalQual == 0 || signalQual == MS_INVALID_VALUE) && millis() - startMillis < 15000L && success); // Convert signal quality to RSSI diff --git a/src/modems/DigiXBeeWifi.cpp b/src/modems/DigiXBeeWifi.cpp index 949413be4..a74adc7af 100644 --- a/src/modems/DigiXBeeWifi.cpp +++ b/src/modems/DigiXBeeWifi.cpp @@ -442,12 +442,12 @@ bool DigiXBeeWifi::updateModemMetadata(void) { bool success = true; // Unset whatever we had previously - loggerModem::_priorRSSI = -9999; - loggerModem::_priorSignalPercent = -9999; - loggerModem::_priorBatteryState = -9999; - loggerModem::_priorBatteryPercent = -9999; - loggerModem::_priorBatteryPercent = -9999; - loggerModem::_priorModemTemp = -9999; + loggerModem::_priorRSSI = MS_INVALID_VALUE; + loggerModem::_priorSignalPercent = MS_INVALID_VALUE; + loggerModem::_priorBatteryState = MS_INVALID_VALUE; + loggerModem::_priorBatteryPercent = MS_INVALID_VALUE; + loggerModem::_priorBatteryVoltage = MS_INVALID_VALUE; + loggerModem::_priorModemTemp = MS_INVALID_VALUE; MS_DBG(F("Modem polling settings:"), String(_pollModemMetaData, BIN)); @@ -474,14 +474,14 @@ bool DigiXBeeWifi::updateModemMetadata(void) { // Try up to 5 times to get a signal quality int8_t num_trys_remaining = 5; - int16_t rssi = -9999; + int16_t rssi = MS_INVALID_VALUE; do { rssi = gsmModem.getSignalQuality(); MS_DBG(F("Raw signal quality ("), num_trys_remaining, F("):"), rssi); - if (rssi != 0 && rssi != -9999) break; + if (rssi != 0 && rssi != MS_INVALID_VALUE) break; num_trys_remaining--; - } while ((rssi == 0 || rssi == -9999) && num_trys_remaining); + } while ((rssi == 0 || rssi == MS_INVALID_VALUE) && num_trys_remaining); // Convert signal quality to a percent @@ -492,7 +492,7 @@ bool DigiXBeeWifi::updateModemMetadata(void) { loggerModem::_priorRSSI = rssi; MS_DBG(F("CURRENT RSSI:"), rssi); - success &= ((rssi != -9999) && (rssi != 0)); + success &= ((rssi != MS_INVALID_VALUE) && (rssi != 0)); } else { MS_DBG(F("Polling for both RSSI and signal strength is disabled")); } @@ -508,7 +508,8 @@ bool DigiXBeeWifi::updateModemMetadata(void) { loggerModem::_priorBatteryVoltage = static_cast(volt_mV / 1000); } else { - loggerModem::_priorBatteryVoltage = static_cast(-9999); + loggerModem::_priorBatteryVoltage = + static_cast(MS_INVALID_VALUE); } success &= ((volt_mV != 9999) && (volt_mV != 0)); @@ -519,17 +520,17 @@ bool DigiXBeeWifi::updateModemMetadata(void) { if ((_pollModemMetaData & MODEM_TEMPERATURE_ENABLE_BITMASK) == MODEM_TEMPERATURE_ENABLE_BITMASK) { MS_DBG(F("Getting chip temperature:")); - float chip_temp = -9999; + float chip_temp = MS_INVALID_VALUE; chip_temp = getModemChipTemperature(); MS_DBG(F("CURRENT Modem temperature(C):"), loggerModem::_priorModemTemp); - if (chip_temp != -9999.f) { + if (chip_temp != MS_INVALID_VALUE) { loggerModem::_priorModemTemp = chip_temp; } else { - loggerModem::_priorModemTemp = static_cast(-9999); + loggerModem::_priorModemTemp = static_cast(MS_INVALID_VALUE); } - success &= ((chip_temp != -9999.f) && (chip_temp != 0)); + success &= ((chip_temp != MS_INVALID_VALUE) && (chip_temp != 0)); } else { MS_DBG(F("Polling for modem chip temperature is disabled")); } diff --git a/src/modems/LoggerModemMacros.h b/src/modems/LoggerModemMacros.h index e7f94690d..78dd29eca 100644 --- a/src/modems/LoggerModemMacros.h +++ b/src/modems/LoggerModemMacros.h @@ -783,8 +783,12 @@ * chargeState, int8_t& percent, int16_t& milliVolts) for modems where such * data is available. * - * This populates the entered references with -9999s for modems where such data - * is not available. + * This populates the entered references with invalid values for modems where + * such data is not available. + * + * @warning This function does **not** use #MS_INVALID_VALUE for the invalid + * values! This is because of the size of the int variables and the standards + * within TinyGSM. * * @param specificModem The modem subclass * @@ -820,7 +824,7 @@ * This is a passthrough to the specific modem's getTemperature() for modems * where such data is available * - * This returns -9999 for modems that don't return such data. + * This returns #MS_INVALID_VALUE for modems that don't return such data. * * @param specificModem The modem subclass * @@ -841,7 +845,7 @@ #define MS_MODEM_GET_MODEM_TEMPERATURE_DATA(specificModem) \ float specificModem::getModemChipTemperature(void) { \ MS_DBG(F("This modem doesn't return temperature!")); \ - return static_cast(-9999); \ + return static_cast(MS_INVALID_VALUE); \ } #endif diff --git a/src/publishers/MonitorMyWatershedPublisher.cpp b/src/publishers/MonitorMyWatershedPublisher.cpp index c6d00019d..c020cf495 100644 --- a/src/publishers/MonitorMyWatershedPublisher.cpp +++ b/src/publishers/MonitorMyWatershedPublisher.cpp @@ -74,7 +74,8 @@ MonitorMyWatershedPublisher::MonitorMyWatershedPublisher( MonitorMyWatershedPublisher::MonitorMyWatershedPublisher( Logger& baseLogger, Client* inClient, const char* registrationToken, const char* samplingFeatureUUID, int sendEveryX) - : MonitorMyWatershedPublisher(baseLogger, registrationToken, samplingFeatureUUID, sendEveryX) { + : MonitorMyWatershedPublisher(baseLogger, registrationToken, + samplingFeatureUUID, sendEveryX) { if (inClient) _inClient = inClient; } // Delegating constructor diff --git a/src/publishers/ThingSpeakPublisher.cpp b/src/publishers/ThingSpeakPublisher.cpp index 77685bb9f..4323fd829 100644 --- a/src/publishers/ThingSpeakPublisher.cpp +++ b/src/publishers/ThingSpeakPublisher.cpp @@ -146,7 +146,7 @@ int16_t ThingSpeakPublisher::publishData(Client* outClient, bool) { MS_DBG(F("ERROR: ThingSpeak MQTT Password is required but not set!")); return -1; } - + bool retVal = false; // Make sure we don't have too many fields diff --git a/src/publishers/UbidotsPublisher.cpp b/src/publishers/UbidotsPublisher.cpp index 463891328..0e5706428 100644 --- a/src/publishers/UbidotsPublisher.cpp +++ b/src/publishers/UbidotsPublisher.cpp @@ -123,8 +123,7 @@ int16_t UbidotsPublisher::publishData(Client* outClient, bool) { "to Ubidots!")); return 0; } - if (_authenticationToken == nullptr || - strlen(_authenticationToken) == 0) { + if (_authenticationToken == nullptr || strlen(_authenticationToken) == 0) { PRINTOUT(F("An authentication token must be set before publishing data " "to Ubidots!")); return 0; diff --git a/src/sensors/ANBpH.cpp b/src/sensors/ANBpH.cpp index 48acfe08b..ab9345fab 100644 --- a/src/sensors/ANBpH.cpp +++ b/src/sensors/ANBpH.cpp @@ -143,23 +143,24 @@ bool ANBpH::setup(void) { // Validate and normalize loggingIntervalMinutes based on powerPin #if defined(MS_ANB_SENSORS_PH_DEBUG) || defined(MS_ANB_SENSORS_PH_DEBUG_DEEP) - int16_t originalInterval = _loggingIntervalMinutes; // Store original for debug messages + int16_t originalInterval = + _loggingIntervalMinutes; // Store original for debug messages #endif if (_powerPin >= 0) { // Cycled power if (_loggingIntervalMinutes == 0) { - programmedInterval = 10; + programmedInterval = 10; _loggingIntervalMinutes = 10; // Update the stored value MS_DBG(F("Requested interval of"), originalInterval, F("minutes is invalid when power is cycled; using"), programmedInterval, F("minutes.")); } else if (_loggingIntervalMinutes < 10) { - programmedInterval = 10; + programmedInterval = 10; _loggingIntervalMinutes = 10; // Update the stored value MS_DBG(F("Requested interval of"), originalInterval, F("minutes is too short; using"), programmedInterval, F("minutes.")); } else if (_loggingIntervalMinutes > 240) { - programmedInterval = 240; + programmedInterval = 240; _loggingIntervalMinutes = 240; // Update the stored value MS_DBG(F("Requested interval of"), originalInterval, F("minutes is too long; using"), programmedInterval, @@ -170,13 +171,13 @@ bool ANBpH::setup(void) { programmedInterval = 0; // Allow 0 for always-on mode // No need to change _loggingIntervalMinutes } else if (_loggingIntervalMinutes < 10) { - programmedInterval = 10; + programmedInterval = 10; _loggingIntervalMinutes = 10; // Update the stored value MS_DBG(F("Requested interval of"), originalInterval, F("minutes is too short; using"), programmedInterval, F("minutes.")); } else if (_loggingIntervalMinutes > 240) { - programmedInterval = 240; + programmedInterval = 240; _loggingIntervalMinutes = 240; // Update the stored value MS_DBG(F("Requested interval of"), originalInterval, F("minutes is too long; using"), programmedInterval, @@ -338,11 +339,11 @@ bool ANBpH::addSingleMeasurementResult(void) { } bool success = false; - float pH = -9999; - float temp = -9999; - float sal = -9999; - float spcond = -9999; - float raw_cond = -9999; + float pH = MS_INVALID_VALUE; + float temp = MS_INVALID_VALUE; + float sal = MS_INVALID_VALUE; + float spcond = MS_INVALID_VALUE; + float raw_cond = MS_INVALID_VALUE; ANBHealthCode health = ANBHealthCode::UNKNOWN; ANBStatusCode status = ANBStatusCode::UNKNOWN; ANBDiagnosticCode diagnostic = ANBDiagnosticCode::UNKNOWN; diff --git a/src/sensors/ANBpH.h b/src/sensors/ANBpH.h index 1089eb777..ca9b9755d 100644 --- a/src/sensors/ANBpH.h +++ b/src/sensors/ANBpH.h @@ -60,8 +60,8 @@ * * @section sensor_anb_ph_config_flags Build flags * - `-D ANB_PH_DEFAULT_MEASUREMENT_RETRIES=##` - * - used to set the default number of measurement retries for ANB pH sensors - * when communication errors occur + * - used to set the default number of measurement retries for ANB pH + * sensors when communication errors occur * * @section sensor_anb_ph_ctor Sensor Constructor * {{ @ref ANBpH::ANBpH }} diff --git a/src/sensors/AOSongAM2315.cpp b/src/sensors/AOSongAM2315.cpp index f70a75bcd..77a93425c 100644 --- a/src/sensors/AOSongAM2315.cpp +++ b/src/sensors/AOSongAM2315.cpp @@ -57,16 +57,16 @@ bool AOSongAM2315::addSingleMeasurementResult(void) { } bool success = false; - float temp_val = -9999; - float humid_val = -9999; + float temp_val = MS_INVALID_VALUE; + float humid_val = MS_INVALID_VALUE; MS_DBG(getSensorNameAndLocation(), F("is reporting:")); success = am2315ptr->readTemperatureAndHumidity(&temp_val, &humid_val); - success &= !isnan(temp_val) && temp_val != -9999 && !isnan(humid_val) && - humid_val != -9999; + success &= !isnan(temp_val) && temp_val != MS_INVALID_VALUE && + !isnan(humid_val) && humid_val != MS_INVALID_VALUE; MS_DBG(F(" Temp:"), temp_val, F("°C")); MS_DBG(F(" Humidity:"), humid_val, '%'); diff --git a/src/sensors/AOSongDHT.cpp b/src/sensors/AOSongDHT.cpp index a788d9aba..326bedcea 100644 --- a/src/sensors/AOSongDHT.cpp +++ b/src/sensors/AOSongDHT.cpp @@ -50,9 +50,9 @@ bool AOSongDHT::addSingleMeasurementResult(void) { } bool success = false; - float humid_val = -9999; - float temp_val = -9999; - float hi_val = -9999; + float humid_val = MS_INVALID_VALUE; + float temp_val = MS_INVALID_VALUE; + float hi_val = MS_INVALID_VALUE; // Reading temperature or humidity takes about 250 milliseconds! MS_DBG(getSensorNameAndLocation(), F("is reporting:")); diff --git a/src/sensors/AlphasenseCO2.cpp b/src/sensors/AlphasenseCO2.cpp index 23ad0277c..991f2c4a6 100644 --- a/src/sensors/AlphasenseCO2.cpp +++ b/src/sensors/AlphasenseCO2.cpp @@ -91,7 +91,7 @@ bool AlphasenseCO2::addSingleMeasurementResult(void) { return bumpMeasurementAttemptCount(false); } - float adcVoltage = -9999; + float adcVoltage = MS_INVALID_VALUE; MS_DBG(getSensorNameAndLocation(), F("is reporting:")); diff --git a/src/sensors/AnalogElecConductivity.cpp b/src/sensors/AnalogElecConductivity.cpp index 356947478..cb058d7df 100644 --- a/src/sensors/AnalogElecConductivity.cpp +++ b/src/sensors/AnalogElecConductivity.cpp @@ -91,7 +91,7 @@ bool AnalogElecConductivity::addSingleMeasurementResult(void) { return bumpMeasurementAttemptCount(false); } - float adcVoltage = -9999.0f; + float adcVoltage = MS_INVALID_VALUE; MS_DBG(getSensorNameAndLocation(), F("is reporting:")); @@ -125,7 +125,7 @@ bool AnalogElecConductivity::addSingleMeasurementResult(void) { MS_DBG(F(" Resistance:"), Rwater_ohms, F("ohms")); // Convert to EC - float EC_uScm = -9999.0f; // units are uS per cm + float EC_uScm = MS_INVALID_VALUE; // units are uS per cm if (Rwater_ohms > 0.0f) { EC_uScm = 1000000.0f / (Rwater_ohms * _sensorEC_Konst); MS_DBG(F("Water EC (uS/cm)"), EC_uScm); diff --git a/src/sensors/AnalogVoltageBase.h b/src/sensors/AnalogVoltageBase.h index db8605889..5b97e330b 100644 --- a/src/sensors/AnalogVoltageBase.h +++ b/src/sensors/AnalogVoltageBase.h @@ -164,7 +164,7 @@ class AnalogVoltageBase { * provide their specific method of reading differential voltages. * * If the sensor does not support differential measurements, this function - * should set the resultValue to -9999.0 and return false. + * should set the resultValue to #MS_INVALID_VALUE and return false. * * @param analogChannel The primary analog channel for differential * measurement. Negative or invalid channel numbers or pairings between the diff --git a/src/sensors/ApogeeSQ212.cpp b/src/sensors/ApogeeSQ212.cpp index 053f31e5f..d9e0f2719 100644 --- a/src/sensors/ApogeeSQ212.cpp +++ b/src/sensors/ApogeeSQ212.cpp @@ -79,7 +79,7 @@ bool ApogeeSQ212::addSingleMeasurementResult(void) { return bumpMeasurementAttemptCount(false); } - float adcVoltage = -9999.0f; + float adcVoltage = MS_INVALID_VALUE; MS_DBG(getSensorNameAndLocation(), F("is reporting:")); diff --git a/src/sensors/AtlasParent.cpp b/src/sensors/AtlasParent.cpp index 6ffd8cb34..769b59833 100644 --- a/src/sensors/AtlasParent.cpp +++ b/src/sensors/AtlasParent.cpp @@ -179,7 +179,7 @@ bool AtlasParent::addSingleMeasurementResult(void) { } float result = _i2c->parseFloat(); if (isnan(result) || result < -1020) { - result = -9999; + result = MS_INVALID_VALUE; success = false; MS_DBG(F(" Invalid response for result #"), i); // Don't break - subsequent values may be ok diff --git a/src/sensors/BoschBME280.cpp b/src/sensors/BoschBME280.cpp index 8463c548a..5ce81c1d8 100644 --- a/src/sensors/BoschBME280.cpp +++ b/src/sensors/BoschBME280.cpp @@ -118,30 +118,30 @@ bool BoschBME280::addSingleMeasurementResult(void) { } bool success = false; - float temp = -9999; - float humid = -9999; - float press = -9999; - float alt = -9999; + float temp = MS_INVALID_VALUE; + float humid = MS_INVALID_VALUE; + float press = MS_INVALID_VALUE; + float alt = MS_INVALID_VALUE; MS_DBG(getSensorNameAndLocation(), F("is reporting:")); // Read values temp = bme_internal.readTemperature(); - if (isnan(temp)) temp = -9999; + if (isnan(temp)) temp = MS_INVALID_VALUE; humid = bme_internal.readHumidity(); - if (isnan(humid)) humid = -9999; + if (isnan(humid)) humid = MS_INVALID_VALUE; press = bme_internal.readPressure(); - if (isnan(press)) press = -9999; + if (isnan(press)) press = MS_INVALID_VALUE; alt = bme_internal.readAltitude(MS_SEA_LEVEL_PRESSURE_HPA); - if (isnan(alt)) alt = -9999; + if (isnan(alt)) alt = MS_INVALID_VALUE; MS_DBG(F(" Temperature:"), temp, F("°C")); MS_DBG(F(" Humidity:"), humid, F("%RH")); MS_DBG(F(" Barometric Pressure:"), press, F("Pa")); MS_DBG(F(" Calculated Altitude:"), alt, F("m ASL")); - bool values_ok = temp != -9999 && humid != -9999 && press != -9999 && - alt != -9999; + bool values_ok = temp != MS_INVALID_VALUE && humid != MS_INVALID_VALUE && + press != MS_INVALID_VALUE && alt != MS_INVALID_VALUE; // Assume that if temperature, pressure, and humidity are all 0, it's really // a failed response. A temperature below -40°C (outside sensor range) also // indicates a bad response. diff --git a/src/sensors/BoschBMP3xx.cpp b/src/sensors/BoschBMP3xx.cpp index a12fb52b3..4daf459d8 100644 --- a/src/sensors/BoschBMP3xx.cpp +++ b/src/sensors/BoschBMP3xx.cpp @@ -291,9 +291,9 @@ bool BoschBMP3xx::addSingleMeasurementResult(void) { } bool success = false; - float temp = -9999; - float press = -9999; - float alt = -9999; + float temp = MS_INVALID_VALUE; + float press = MS_INVALID_VALUE; + float alt = MS_INVALID_VALUE; // Read values diff --git a/src/sensors/CampbellOBS3.cpp b/src/sensors/CampbellOBS3.cpp index 32686ad24..b61013f67 100644 --- a/src/sensors/CampbellOBS3.cpp +++ b/src/sensors/CampbellOBS3.cpp @@ -84,7 +84,7 @@ bool CampbellOBS3::addSingleMeasurementResult(void) { MS_DBG(F(" Input calibration Curve:"), _x2_coeff_A, F("x^2 +"), _x1_coeff_B, F("x +"), _x0_coeff_C); - float adcVoltage = -9999.0f; + float adcVoltage = MS_INVALID_VALUE; MS_DBG(getSensorNameAndLocation(), F("is reporting:")); diff --git a/src/sensors/Decagon5TM.cpp b/src/sensors/Decagon5TM.cpp index 150e27962..2ff5246e8 100644 --- a/src/sensors/Decagon5TM.cpp +++ b/src/sensors/Decagon5TM.cpp @@ -19,17 +19,17 @@ bool Decagon5TM::getResults(bool verify_crc) { float temp = sensorValues[TM_TEMP_VAR_NUM]; // Set up the float variables for calculated variable - float VWC = -9999; + float VWC = MS_INVALID_VALUE; // Calculate the VWC from EA using the Topp equation // range check if (ea < 0 || ea > 350) { MS_DBG(F("WARNING: Ea results out of range (0-350)! Cannot calculate " "VWC")); - ea = -9999; + ea = MS_INVALID_VALUE; } // calculate - if (ea != -9999) { + if (ea != MS_INVALID_VALUE) { VWC = (4.3e-6 * (ea * ea * ea)) - (5.5e-4 * (ea * ea)) + (2.92e-2 * ea) - 5.3e-2; VWC *= 100; // Convert to actual percent @@ -48,7 +48,7 @@ bool Decagon5TM::getResults(bool verify_crc) { // range check on temp; range is - 40°C to + 50°C if (temp < -50 || temp > 60) { - temp = -9999; + temp = MS_INVALID_VALUE; MS_DBG(F("WARNING: temperature results out of range (-50-60)!")); } @@ -57,5 +57,5 @@ bool Decagon5TM::getResults(bool verify_crc) { verifyAndAddMeasurementResult(TM_EA_VAR_NUM, ea); verifyAndAddMeasurementResult(TM_VWC_VAR_NUM, VWC); - return success && temp != -9999; + return success && temp != MS_INVALID_VALUE; } diff --git a/src/sensors/EverlightALSPT19.cpp b/src/sensors/EverlightALSPT19.cpp index 8986bc7df..4fd3fe23e 100644 --- a/src/sensors/EverlightALSPT19.cpp +++ b/src/sensors/EverlightALSPT19.cpp @@ -102,7 +102,7 @@ bool EverlightALSPT19::addSingleMeasurementResult(void) { return bumpMeasurementAttemptCount(false); } - float adcVoltage = -9999.0f; + float adcVoltage = MS_INVALID_VALUE; MS_DBG(getSensorNameAndLocation(), F("is reporting:")); diff --git a/src/sensors/FreescaleMPL115A2.cpp b/src/sensors/FreescaleMPL115A2.cpp index 5351f11d2..1350a2076 100644 --- a/src/sensors/FreescaleMPL115A2.cpp +++ b/src/sensors/FreescaleMPL115A2.cpp @@ -64,8 +64,8 @@ bool FreescaleMPL115A2::addSingleMeasurementResult(void) { } bool success = false; - float temp = -9999; - float press = -9999; + float temp = MS_INVALID_VALUE; + float press = MS_INVALID_VALUE; MS_DBG(getSensorNameAndLocation(), F("is reporting:")); diff --git a/src/sensors/GeoluxHydroCam.cpp b/src/sensors/GeoluxHydroCam.cpp index 93bd82145..f71411959 100644 --- a/src/sensors/GeoluxHydroCam.cpp +++ b/src/sensors/GeoluxHydroCam.cpp @@ -193,8 +193,8 @@ bool GeoluxHydroCam::addSingleMeasurementResult(void) { } bool success = false; - int32_t bytes_transferred = -9999; - int32_t byte_error = -9999; + int32_t bytes_transferred = MS_INVALID_VALUE; + int32_t byte_error = MS_INVALID_VALUE; int32_t image_size = _camera.getImageSize(); MS_DBG(F("Completed image is"), image_size, F("bytes.")); diff --git a/src/sensors/GroPointParent.cpp b/src/sensors/GroPointParent.cpp index f588c1291..056302470 100644 --- a/src/sensors/GroPointParent.cpp +++ b/src/sensors/GroPointParent.cpp @@ -167,12 +167,15 @@ bool GroPointParent::addSingleMeasurementResult(void) { bool success = false; bool successT = false; // Initialize moisture variables for each probe segment - float M1 = -9999, M2 = -9999, M3 = -9999, M4 = -9999, M5 = -9999, - M6 = -9999, M7 = -9999, M8 = -9999; + float M1 = MS_INVALID_VALUE, M2 = MS_INVALID_VALUE, M3 = MS_INVALID_VALUE, + M4 = MS_INVALID_VALUE, M5 = MS_INVALID_VALUE, M6 = MS_INVALID_VALUE, + M7 = MS_INVALID_VALUE, M8 = MS_INVALID_VALUE; // Initialize temperature variables for each probe sensor - float T1 = -9999, T2 = -9999, T3 = -9999, T4 = -9999, T5 = -9999, - T6 = -9999, T7 = -9999, T8 = -9999, T9 = -9999, T10 = -9999, - T11 = -9999, T12 = -9999, T13 = -9999; + float T1 = MS_INVALID_VALUE, T2 = MS_INVALID_VALUE, T3 = MS_INVALID_VALUE, + T4 = MS_INVALID_VALUE, T5 = MS_INVALID_VALUE, T6 = MS_INVALID_VALUE, + T7 = MS_INVALID_VALUE, T8 = MS_INVALID_VALUE, T9 = MS_INVALID_VALUE, + T10 = MS_INVALID_VALUE, T11 = MS_INVALID_VALUE, + T12 = MS_INVALID_VALUE, T13 = MS_INVALID_VALUE; switch (_model) { case GPLP8: { diff --git a/src/sensors/KellerParent.cpp b/src/sensors/KellerParent.cpp index ca08bec19..3028b7499 100644 --- a/src/sensors/KellerParent.cpp +++ b/src/sensors/KellerParent.cpp @@ -88,21 +88,22 @@ bool KellerParent::addSingleMeasurementResult(void) { } bool success = false; - float waterPressureBar = -9999; - float waterTemperatureC = -9999; - float waterDepthM = -9999; - float waterPressure_mBar = -9999; + float waterPressureBar = MS_INVALID_VALUE; + float waterTemperatureC = MS_INVALID_VALUE; + float waterDepthM = MS_INVALID_VALUE; + float waterPressure_mBar = MS_INVALID_VALUE; MS_DBG(getSensorNameAndLocation(), F("is reporting:")); // Get Values // the getValues function in the KellerModbus library will *always* return - // true, but will set the value variables to -9999 if it fails to get a - // value. So we check for success by checking that the value variables are - // not -9999 or NaN. + // true, but will set the value variables to MS_INVALID_VALUE if it fails to + // get a value. So we check for success by checking that the value + // variables are not MS_INVALID_VALUE or NaN. _ksensor.getValues(waterPressureBar, waterTemperatureC); - success = (!isnan(waterPressureBar) && waterPressureBar != -9999 && - !isnan(waterTemperatureC) && waterTemperatureC != -9999); + success = + (!isnan(waterPressureBar) && waterPressureBar != MS_INVALID_VALUE && + !isnan(waterTemperatureC) && waterTemperatureC != MS_INVALID_VALUE); if (success) { // calculate depth from pressure and temperature @@ -116,7 +117,7 @@ bool KellerParent::addSingleMeasurementResult(void) { MS_DBG(F(" Temp_C:"), waterTemperatureC); MS_DBG(F(" Height_m:"), waterDepthM); - success &= (!isnan(waterDepthM) && waterDepthM != -9999); + success &= (!isnan(waterDepthM) && waterDepthM != MS_INVALID_VALUE); if (success) { // Put values into the array diff --git a/src/sensors/MaxBotixSonar.cpp b/src/sensors/MaxBotixSonar.cpp index 172ea1091..da435d02b 100644 --- a/src/sensors/MaxBotixSonar.cpp +++ b/src/sensors/MaxBotixSonar.cpp @@ -125,7 +125,7 @@ bool MaxBotixSonar::addSingleMeasurementResult(void) { // Initialize values bool success = false; - int16_t result = -9999; + int16_t result = MS_INVALID_VALUE; // Clear anything out of the stream buffer auto junkChars = static_cast(_stream->available()); @@ -177,7 +177,7 @@ bool MaxBotixSonar::addSingleMeasurementResult(void) { if (result <= 0 || result >= _maxRange) { MS_DBG(F(" Bad or Suspicious Result, Retry Attempt #"), rangeAttempts); - result = -9999; + result = MS_INVALID_VALUE; } else { MS_DBG(F(" Good result found")); // convert result from cm to mm if convertCm is set to true diff --git a/src/sensors/MaximDS18.cpp b/src/sensors/MaximDS18.cpp index 9a38e4bfd..1571bbb61 100644 --- a/src/sensors/MaximDS18.cpp +++ b/src/sensors/MaximDS18.cpp @@ -187,7 +187,7 @@ bool MaximDS18::addSingleMeasurementResult(void) { } bool success = false; - float result = -9999; + float result = MS_INVALID_VALUE; MS_DBG(getSensorNameAndLocation(), F("is reporting:")); result = _internalDallasTemp.getTempC(_OneWireAddress); diff --git a/src/sensors/MeaSpecMS5803.cpp b/src/sensors/MeaSpecMS5803.cpp index ef07d37a4..cd843709c 100644 --- a/src/sensors/MeaSpecMS5803.cpp +++ b/src/sensors/MeaSpecMS5803.cpp @@ -61,8 +61,8 @@ bool MeaSpecMS5803::addSingleMeasurementResult(void) { } bool success = false; - float temp = -9999; - float press = -9999; + float temp = MS_INVALID_VALUE; + float press = MS_INVALID_VALUE; MS_DBG(getSensorNameAndLocation(), F("is reporting:")); // Read values diff --git a/src/sensors/MeterTeros11.cpp b/src/sensors/MeterTeros11.cpp index 4da65d1d4..d8c234864 100644 --- a/src/sensors/MeterTeros11.cpp +++ b/src/sensors/MeterTeros11.cpp @@ -22,8 +22,8 @@ bool MeterTeros11::getResults(bool verify_crc) { float raw = sensorValues[TEROS11_COUNT_VAR_NUM]; // Set up the float variables for calculated variable - float ea = -9999; - float VWC = -9999; + float ea = MS_INVALID_VALUE; + float VWC = MS_INVALID_VALUE; // Calculate the dielectric EA from the raw count value. // Equation 8 from the Teros 11 user manual: @@ -32,9 +32,9 @@ bool MeterTeros11::getResults(bool verify_crc) { MS_DBG( F("WARNING: raw results out of range (0-5000)! Cannot calculate " "Ea or VWC")); - raw = -9999; + raw = MS_INVALID_VALUE; } - if (raw != -9999) { + if (raw != MS_INVALID_VALUE) { ea = ((2.887e-9 * (raw * raw * raw)) - (2.08e-5 * (raw * raw)) + (5.276e-2 * raw) - 43.39) * ((2.887e-9 * (raw * raw * raw)) - (2.08e-5 * (raw * raw)) + @@ -47,10 +47,10 @@ bool MeterTeros11::getResults(bool verify_crc) { if (ea < 0 || ea > 350) { MS_DBG(F("WARNING: Ea results out of range (0-350)! Cannot calculate " "VWC")); - ea = -9999; + ea = MS_INVALID_VALUE; } // calculate - if (ea != -9999) { + if (ea != MS_INVALID_VALUE) { VWC = (4.3e-6 * (ea * ea * ea)) - (5.5e-4 * (ea * ea)) + (2.92e-2 * ea) - 5.3e-2; VWC *= 100; // Convert to actual percent @@ -69,7 +69,7 @@ bool MeterTeros11::getResults(bool verify_crc) { // range check on temp; range is - 40°C to + 50°C if (temp < -50 || temp > 60) { - temp = -9999; + temp = MS_INVALID_VALUE; MS_DBG(F("WARNING: temperature results out of range (-50-60)!")); } @@ -79,5 +79,5 @@ bool MeterTeros11::getResults(bool verify_crc) { verifyAndAddMeasurementResult(TEROS11_EA_VAR_NUM, ea); verifyAndAddMeasurementResult(TEROS11_VWC_VAR_NUM, VWC); - return success && temp != -9999; + return success && temp != MS_INVALID_VALUE; } diff --git a/src/sensors/PaleoTerraRedox.cpp b/src/sensors/PaleoTerraRedox.cpp index 1e24c5ba2..a1e3ed325 100644 --- a/src/sensors/PaleoTerraRedox.cpp +++ b/src/sensors/PaleoTerraRedox.cpp @@ -103,9 +103,9 @@ bool PaleoTerraRedox::addSingleMeasurementResult(void) { } bool success = false; - byte config = 0; // Returned config - int32_t adcValue = 0; // Raw ADC value from the sensor - float res = -9999.0; // Calculated voltage in uV + byte config = 0; // Returned config + int32_t adcValue = 0; // Raw ADC value from the sensor + float res = MS_INVALID_VALUE; // Calculated voltage in uV byte i2c_status; diff --git a/src/sensors/ProcessorAnalog.cpp b/src/sensors/ProcessorAnalog.cpp index ca54eb65a..4665e5dc6 100644 --- a/src/sensors/ProcessorAnalog.cpp +++ b/src/sensors/ProcessorAnalog.cpp @@ -43,7 +43,7 @@ bool ProcessorAnalogBase::readVoltageSingleEnded(int8_t analogChannel, _supplyVoltage <= 0 || _voltageMultiplier <= 0) { MS_DBG(F("Invalid configuration: either the analog channel, the supply " "voltage, or the voltage multiplier is not set correctly!")); - resultValue = -9999.0f; + resultValue = MS_INVALID_VALUE; return false; } @@ -83,7 +83,7 @@ bool ProcessorAnalogBase::readVoltageDifferential( float& resultValue) { // ProcessorAnalog does not support differential measurements MS_DBG(F("ProcessorAnalog does not support differential measurements")); - resultValue = -9999.0f; + resultValue = MS_INVALID_VALUE; return false; } @@ -99,7 +99,7 @@ float ProcessorAnalogBase::calculateAnalogResolutionVolts(void) { fullScaleRangeVolts <= 0.0f) { MS_DBG(F("Invalid ADC configuration - bits: "), resolutionBits, F(", supply voltage: "), fullScaleRangeVolts, F("V")); - return -9999.0f; + return MS_INVALID_VALUE; } // Calculate the total number of ADC codes @@ -171,7 +171,7 @@ bool ProcessorAnalog::addSingleMeasurementResult(void) { MS_DBG(getSensorNameAndLocation(), F("is reporting:")); - float resultValue = -9999.0f; + float resultValue = MS_INVALID_VALUE; bool success = _analogVoltageReader->readVoltageSingleEnded(_dataPin, resultValue); diff --git a/src/sensors/ProcessorAnalog.h b/src/sensors/ProcessorAnalog.h index 23ac7c1a9..6f57ac81e 100644 --- a/src/sensors/ProcessorAnalog.h +++ b/src/sensors/ProcessorAnalog.h @@ -214,7 +214,7 @@ class ProcessorAnalogBase : public AnalogVoltageBase { * @param analogReferenceChannel The secondary (reference) analog channel * (ignored) * @param resultValue Reference to store the resulting voltage measurement. - * This will be set to -9999.0 to indicate an invalid reading. + * This will be set to #MS_INVALID_VALUE to indicate an invalid reading. * @return Always false (differential not supported) */ bool readVoltageDifferential(int8_t analogChannel, diff --git a/src/sensors/ProcessorStats.cpp b/src/sensors/ProcessorStats.cpp index 51a153672..eafd6ac88 100644 --- a/src/sensors/ProcessorStats.cpp +++ b/src/sensors/ProcessorStats.cpp @@ -84,7 +84,7 @@ String ProcessorStats::getSensorLocation(void) { } float ProcessorStats::getBatteryVoltage(void) { - float sensorValue_battery = -9999; + float sensorValue_battery = MS_INVALID_VALUE; if (_batteryPin >= 0 && _batteryMultiplier > 0) { // Get the battery voltage MS_DBG(F("Getting battery voltage from pin"), _batteryPin); @@ -233,7 +233,7 @@ bool ProcessorStats::addSingleMeasurementResult(void) { #if !defined(__SAMD51__) float sensorValue_freeRam = FreeRam(); #else - float sensorValue_freeRam = -9999; + float sensorValue_freeRam = MS_INVALID_VALUE; #endif verifyAndAddMeasurementResult(PROCESSOR_RAM_VAR_NUM, diff --git a/src/sensors/RainCounterI2C.cpp b/src/sensors/RainCounterI2C.cpp index 92fe769e3..42be1818f 100644 --- a/src/sensors/RainCounterI2C.cpp +++ b/src/sensors/RainCounterI2C.cpp @@ -96,9 +96,10 @@ bool RainCounterI2C::addSingleMeasurementResult(void) { return bumpMeasurementAttemptCount(false); } - bool success = false; // assume the worst - float rain = -9999; // Number of mm of rain - int32_t tips = -9999; // Number of tip events, increased for anemometer + bool success = false; // assume the worst + float rain = MS_INVALID_VALUE; // Number of mm of rain + int32_t tips = + MS_INVALID_VALUE; // Number of tip events, increased for anemometer // Get data from external tip counter // if the 'requestFrom' returns 0, it means no bytes were received @@ -147,14 +148,17 @@ bool RainCounterI2C::addSingleMeasurementResult(void) { _rainPerTip; // Multiply by tip coefficient (0.2 by default) if (tips < 0) - tips = -9999; // If negative value results, return failure + tips = + MS_INVALID_VALUE; // If negative value results, return failure if (rain < 0) - rain = -9999; // If negative value results, return failure + rain = + MS_INVALID_VALUE; // If negative value results, return failure MS_DBG(F(" Rain:"), rain); MS_DBG(F(" Tips:"), tips); - if (rain != -9999 && tips != -9999) { // if both are valid + if (rain != MS_INVALID_VALUE && + tips != MS_INVALID_VALUE) { // if both are valid verifyAndAddMeasurementResult(BUCKET_RAIN_VAR_NUM, rain); verifyAndAddMeasurementResult(BUCKET_TIPS_VAR_NUM, tips); success = true; diff --git a/src/sensors/SDI12Sensors.cpp b/src/sensors/SDI12Sensors.cpp index 9b9ea2f28..0a65f1d44 100644 --- a/src/sensors/SDI12Sensors.cpp +++ b/src/sensors/SDI12Sensors.cpp @@ -97,8 +97,8 @@ bool SDI12Sensors::setup(void) { // by the SDI-12 protocol for a sensor response. // May want to bump it up even further here. _SDI12Internal.setTimeout(150); - // Force the timeout value to be -9999 (This should be library default.) - _SDI12Internal.setTimeoutValue(-9999); + // Force the timeout value to be MS_INVALID_VALUE + _SDI12Internal.setTimeoutValue(MS_INVALID_VALUE); #if defined(__AVR__) || defined(ARDUINO_ARCH_AVR) // Allow the SDI-12 library access to interrupts @@ -613,10 +613,10 @@ bool SDI12Sensors::getResults(bool verify_crc) { F("Parsed value:"), String(result, len_post_dec)); #endif // The SDI-12 library should return our set timeout value of - // -9999 on timeout - if (result == -9999 || isnan(result)) { + // MS_INVALID_VALUE on timeout + if (result == MS_INVALID_VALUE || isnan(result)) { MS_DBG(F("Result is not valid!")); - result = -9999; + result = MS_INVALID_VALUE; } // Put the read value into the temporary buffer. After each // result is read, tick up the number of results received so @@ -624,7 +624,7 @@ bool SDI12Sensors::getResults(bool verify_crc) { // buffer. cmd_rx[cmd_results] = result; // add how many results we have - if (result != -9999) { + if (result != MS_INVALID_VALUE) { gotResults = true; cmd_results++; } @@ -790,7 +790,8 @@ bool SDI12Sensors::addSingleMeasurementResult(void) { MS_DBG(getSensorNameAndLocation(), F("is not currently measuring!")); for (uint8_t i = 0; i < _numReturnedValues; i++) { - verifyAndAddMeasurementResult(i, static_cast(-9999)); + verifyAndAddMeasurementResult( + i, static_cast(MS_INVALID_VALUE)); } } } diff --git a/src/sensors/SensirionSHT4x.cpp b/src/sensors/SensirionSHT4x.cpp index b4eef9ab7..49977fb95 100644 --- a/src/sensors/SensirionSHT4x.cpp +++ b/src/sensors/SensirionSHT4x.cpp @@ -94,8 +94,8 @@ bool SensirionSHT4x::addSingleMeasurementResult(void) { } bool success = false; - float temp_val = -9999; - float humid_val = -9999; + float temp_val = MS_INVALID_VALUE; + float humid_val = MS_INVALID_VALUE; MS_DBG(getSensorNameAndLocation(), F("is reporting:")); diff --git a/src/sensors/TEConnectivityMS5837.cpp b/src/sensors/TEConnectivityMS5837.cpp index 31feb069c..4e696eb33 100644 --- a/src/sensors/TEConnectivityMS5837.cpp +++ b/src/sensors/TEConnectivityMS5837.cpp @@ -185,10 +185,10 @@ bool TEConnectivityMS5837::addSingleMeasurementResult(void) { MS_DBG(F(" Requesting"), OSR, F("bit OSR (oversampling ratio:"), _overSamplingRatio, F(")")); - float temp = -9999; - float press = -9999; - float depth = -9999; - float alt = -9999; + float temp = MS_INVALID_VALUE; + float press = MS_INVALID_VALUE; + float depth = MS_INVALID_VALUE; + float alt = MS_INVALID_VALUE; // Read values from the sensor - returns 0 on success int read_return = MS5837_internal.read(OSR); diff --git a/src/sensors/TIADS1x15.cpp b/src/sensors/TIADS1x15.cpp index 217633961..37a88b8e8 100644 --- a/src/sensors/TIADS1x15.cpp +++ b/src/sensors/TIADS1x15.cpp @@ -108,16 +108,14 @@ String TIADS1x15Base::getAnalogLocation(int8_t analogChannel, bool TIADS1x15Base::readVoltageSingleEnded(int8_t analogChannel, float& resultValue) { bool success = false; - int16_t adcCounts = -9999; - float adcVoltage = -9999.0f; - float scaledResult = -9999.0f; + int16_t adcCounts = MS_INVALID_VALUE; + float adcVoltage = MS_INVALID_VALUE; + float scaledResult = MS_INVALID_VALUE; // Use the per-instance ADS driver (gain configured in constructor) // Verify I2C connectivity with a lightweight probe - if (!probeI2C()) { - return false; - } + if (!probeI2C()) { return false; } // Read Analog to Digital Converter (ADC) // Validate ADS1x15 channel range for single-ended measurements @@ -164,7 +162,7 @@ bool TIADS1x15Base::readVoltageSingleEnded(int8_t analogChannel, success = true; } else { MS_DBG(F(" ADC voltage "), adcVoltage, F("V out of valid range")); - resultValue = -9999.0f; + resultValue = MS_INVALID_VALUE; } return success; @@ -174,15 +172,13 @@ bool TIADS1x15Base::readVoltageDifferential(int8_t analogChannel, int8_t analogReferenceChannel, float& resultValue) { bool success = false; - int16_t adcCounts = -9999; - float adcVoltage = -9999.0f; - float scaledResult = -9999.0f; + int16_t adcCounts = MS_INVALID_VALUE; + float adcVoltage = MS_INVALID_VALUE; + float scaledResult = MS_INVALID_VALUE; // Use the per-instance ADS driver (configured in constructor) // Verify I2C connectivity with a lightweight probe - if (!probeI2C()) { - return false; - } + if (!probeI2C()) { return false; } // Validate differential channel combination if (!isValidDifferentialPair(analogChannel, analogReferenceChannel)) { @@ -234,7 +230,7 @@ bool TIADS1x15Base::readVoltageDifferential(int8_t analogChannel, success = true; } else { MS_DBG(F(" Differential voltage out of valid range")); - resultValue = -9999.0f; + resultValue = MS_INVALID_VALUE; } return success; @@ -425,7 +421,7 @@ bool TIADS1x15::addSingleMeasurementResult(void) { return bumpMeasurementAttemptCount(false); } - float resultValue = -9999.0f; + float resultValue = MS_INVALID_VALUE; bool success = false; MS_DBG(getSensorNameAndLocation(), F("is reporting:")); diff --git a/src/sensors/TIADS1x15.h b/src/sensors/TIADS1x15.h index 0deb5c55a..6f2d80abc 100644 --- a/src/sensors/TIADS1x15.h +++ b/src/sensors/TIADS1x15.h @@ -278,9 +278,8 @@ class TIADS1x15Base : public AnalogVoltageBase { * @param adsSupplyVoltage The power supply voltage for the ADS1x15 in volts * @param adsDataRate The data rate for the ADS1x15 (samples per second) */ - explicit TIADS1x15Base(TwoWire* theI2C, - float voltageMultiplier = 1.0f, - adsGain_t adsGain = GAIN_ONE, + explicit TIADS1x15Base(TwoWire* theI2C, float voltageMultiplier = 1.0f, + adsGain_t adsGain = GAIN_ONE, uint8_t i2cAddress = MS_DEFAULT_ADS1X15_ADDRESS, float adsSupplyVoltage = OPERATING_VOLTAGE, #ifndef MS_USE_ADS1015 @@ -460,7 +459,7 @@ class TIADS1x15Base : public AnalogVoltageBase { /** * @brief Probe I2C connectivity to the ADS device - * + * * @return true if device responds, false if communication failed */ bool probeI2C(void); diff --git a/src/sensors/TIINA219.cpp b/src/sensors/TIINA219.cpp index afeec55d6..79b59f285 100644 --- a/src/sensors/TIINA219.cpp +++ b/src/sensors/TIINA219.cpp @@ -95,9 +95,9 @@ bool TIINA219::addSingleMeasurementResult(void) { } bool success = false; - float current_mA = -9999; - float busV_V = -9999; - float power_mW = -9999; + float current_mA = MS_INVALID_VALUE; + float busV_V = MS_INVALID_VALUE; + float power_mW = MS_INVALID_VALUE; MS_DBG(getSensorNameAndLocation(), F("is reporting:")); diff --git a/src/sensors/TallyCounterI2C.cpp b/src/sensors/TallyCounterI2C.cpp index 523b84e46..532115258 100644 --- a/src/sensors/TallyCounterI2C.cpp +++ b/src/sensors/TallyCounterI2C.cpp @@ -74,7 +74,7 @@ bool TallyCounterI2C::addSingleMeasurementResult(void) { } bool success = false; - int16_t events = -9999; // Number of events + int16_t events = MS_INVALID_VALUE; // Number of events // Read values // Read data from counter before clear @@ -86,7 +86,7 @@ bool TallyCounterI2C::addSingleMeasurementResult(void) { if (events < 0) { MS_DBG(getSensorNameAndLocation(), F("returned negative value, assuming sensor non-response!")); - events = -9999; + events = MS_INVALID_VALUE; } else { MS_DBG(getSensorNameAndLocation(), F("is reporting:")); verifyAndAddMeasurementResult(TALLY_EVENTS_VAR_NUM, events); diff --git a/src/sensors/TurnerCyclops.cpp b/src/sensors/TurnerCyclops.cpp index 7f83b89ce..5a3e0d3f0 100644 --- a/src/sensors/TurnerCyclops.cpp +++ b/src/sensors/TurnerCyclops.cpp @@ -89,7 +89,7 @@ bool TurnerCyclops::addSingleMeasurementResult(void) { return bumpMeasurementAttemptCount(false); } - float adcVoltage = -9999.0f; + float adcVoltage = MS_INVALID_VALUE; MS_DBG(getSensorNameAndLocation(), F("is reporting:")); diff --git a/src/sensors/TurnerTurbidityPlus.cpp b/src/sensors/TurnerTurbidityPlus.cpp index 0cb9c42ae..708927451 100644 --- a/src/sensors/TurnerTurbidityPlus.cpp +++ b/src/sensors/TurnerTurbidityPlus.cpp @@ -130,7 +130,7 @@ bool TurnerTurbidityPlus::addSingleMeasurementResult(void) { return bumpMeasurementAttemptCount(false); } - float adcVoltage = -9999.0f; + float adcVoltage = MS_INVALID_VALUE; MS_DBG(getSensorNameAndLocation(), F("is reporting:")); diff --git a/src/sensors/YosemitechParent.cpp b/src/sensors/YosemitechParent.cpp index eeafa583e..0803a103d 100644 --- a/src/sensors/YosemitechParent.cpp +++ b/src/sensors/YosemitechParent.cpp @@ -177,14 +177,14 @@ bool YosemitechParent::addSingleMeasurementResult(void) { switch (_model) { case Y4000: { // Initialize float variables - float DOmgL = -9999; - float Turbidity = -9999; - float Cond = -9999; - float pH = -9999; - float Temp = -9999; - float ORP = -9999; - float Chlorophyll = -9999; - float BGA = -9999; + float DOmgL = MS_INVALID_VALUE; + float Turbidity = MS_INVALID_VALUE; + float Cond = MS_INVALID_VALUE; + float pH = MS_INVALID_VALUE; + float Temp = MS_INVALID_VALUE; + float ORP = MS_INVALID_VALUE; + float Chlorophyll = MS_INVALID_VALUE; + float BGA = MS_INVALID_VALUE; // Get Values MS_DBG(F("Get Values from"), getSensorNameAndLocation()); @@ -215,9 +215,9 @@ bool YosemitechParent::addSingleMeasurementResult(void) { } default: { // Initialize float variables - float parmValue = -9999; - float tempValue = -9999; - float thirdValue = -9999; + float parmValue = MS_INVALID_VALUE; + float tempValue = MS_INVALID_VALUE; + float thirdValue = MS_INVALID_VALUE; // Get Values MS_DBG(F("Get Values from"), getSensorNameAndLocation()); From e290ccf6f78729dfeb2b866489b5c0cd39aec19c Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Wed, 4 Mar 2026 09:54:54 -0500 Subject: [PATCH 415/533] Use -9999, not -9999.0 as sentinel value Signed-off-by: Sara Damiano --- src/ModSensorConfig.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ModSensorConfig.h b/src/ModSensorConfig.h index 7c24ce80c..522d9c929 100644 --- a/src/ModSensorConfig.h +++ b/src/ModSensorConfig.h @@ -79,7 +79,7 @@ * Every sensor will use this value to indicate that a measurement is invalid * or missing. */ -#define MS_INVALID_VALUE -9999.0 +#define MS_INVALID_VALUE -9999 // GroPoint Profile GPLP-8 has 8 Moisture and 13 Temperature values #endif From a03732ecc74bd84561ec03dd7981dbf22f62268d Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Wed, 4 Mar 2026 09:55:08 -0500 Subject: [PATCH 416/533] Reduce some duplication Signed-off-by: Sara Damiano --- src/SensorBase.h | 4 ++-- src/VariableBase.cpp | 3 +++ src/modems/DigiXBeeWifi.cpp | 6 +---- src/modems/LoggerModemMacros.h | 2 +- .../MonitorMyWatershedPublisher.cpp | 22 +++++++++---------- src/publishers/UbidotsPublisher.cpp | 2 +- src/sensors/PaleoTerraRedox.cpp | 1 - 7 files changed, 19 insertions(+), 21 deletions(-) diff --git a/src/SensorBase.h b/src/SensorBase.h index e5433309f..c67b5c6be 100644 --- a/src/SensorBase.h +++ b/src/SensorBase.h @@ -524,8 +524,8 @@ class Sensor { * * This clears the values array by setting all values to #MS_INVALID_VALUE, * sets all values in numberGoodMeasurementsMade to 0, and resets the - * attempt - * (#_measurementAttemptsCompleted) and retry (#_retryAttemptsMade) counts. + * attempt (#_measurementAttemptsCompleted) and retry (#_retryAttemptsMade) + * counts. */ void clearValues(); /** diff --git a/src/VariableBase.cpp b/src/VariableBase.cpp index 4f8af5560..39bbf3e6f 100644 --- a/src/VariableBase.cpp +++ b/src/VariableBase.cpp @@ -253,6 +253,8 @@ float Variable::getValue(bool updateValue) { } else if (updateValue && _calcFxn == nullptr) { // If no calculation function is set, return error value _currentValue = MS_INVALID_VALUE; + MS_DBG( + F("ERROR! Calculated variable has no calculation function!")); } return _currentValue; } else { @@ -261,6 +263,7 @@ float Variable::getValue(bool updateValue) { } else if (updateValue && parentSensor == nullptr) { // If no parent sensor is set, return error value _currentValue = MS_INVALID_VALUE; + MS_DBG(F("ERROR! Variable has no parent sensor!")); } return _currentValue; } diff --git a/src/modems/DigiXBeeWifi.cpp b/src/modems/DigiXBeeWifi.cpp index a74adc7af..52f7d1ce3 100644 --- a/src/modems/DigiXBeeWifi.cpp +++ b/src/modems/DigiXBeeWifi.cpp @@ -524,11 +524,7 @@ bool DigiXBeeWifi::updateModemMetadata(void) { chip_temp = getModemChipTemperature(); MS_DBG(F("CURRENT Modem temperature(C):"), loggerModem::_priorModemTemp); - if (chip_temp != MS_INVALID_VALUE) { - loggerModem::_priorModemTemp = chip_temp; - } else { - loggerModem::_priorModemTemp = static_cast(MS_INVALID_VALUE); - } + loggerModem::_priorModemTemp = chip_temp; success &= ((chip_temp != MS_INVALID_VALUE) && (chip_temp != 0)); } else { diff --git a/src/modems/LoggerModemMacros.h b/src/modems/LoggerModemMacros.h index 78dd29eca..4cdc80d02 100644 --- a/src/modems/LoggerModemMacros.h +++ b/src/modems/LoggerModemMacros.h @@ -786,7 +786,7 @@ * This populates the entered references with invalid values for modems where * such data is not available. * - * @warning This function does **not** use #MS_INVALID_VALUE for the invalid + * @warning This function does **not** use #MS_INVALID_VALUE for the invalid * values! This is because of the size of the int variables and the standards * within TinyGSM. * diff --git a/src/publishers/MonitorMyWatershedPublisher.cpp b/src/publishers/MonitorMyWatershedPublisher.cpp index c020cf495..cdd05621b 100644 --- a/src/publishers/MonitorMyWatershedPublisher.cpp +++ b/src/publishers/MonitorMyWatershedPublisher.cpp @@ -74,9 +74,10 @@ MonitorMyWatershedPublisher::MonitorMyWatershedPublisher( MonitorMyWatershedPublisher::MonitorMyWatershedPublisher( Logger& baseLogger, Client* inClient, const char* registrationToken, const char* samplingFeatureUUID, int sendEveryX) - : MonitorMyWatershedPublisher(baseLogger, registrationToken, - samplingFeatureUUID, sendEveryX) { - if (inClient) _inClient = inClient; + : MonitorMyWatershedPublisher(baseLogger, inClient, sendEveryX) { + if (registrationToken) setToken(registrationToken); + if (samplingFeatureUUID) + _baseLogger->setSamplingFeatureUUID(samplingFeatureUUID); } // Delegating constructor MonitorMyWatershedPublisher::MonitorMyWatershedPublisher( @@ -183,22 +184,21 @@ void MonitorMyWatershedPublisher::begin(Logger& baseLogger, Client* inClient, const char* samplingFeatureUUID) { setToken(registrationToken); dataPublisher::begin(baseLogger, inClient); - _baseLogger->setSamplingFeatureUUID(samplingFeatureUUID); + if (samplingFeatureUUID != nullptr) { + _baseLogger->setSamplingFeatureUUID(samplingFeatureUUID); + } _logBuffer.setNumVariables(_baseLogger->getArrayVarCount()); } void MonitorMyWatershedPublisher::begin(Logger& baseLogger, const char* registrationToken, const char* samplingFeatureUUID) { - setToken(registrationToken); - dataPublisher::begin(baseLogger); - _baseLogger->setSamplingFeatureUUID(samplingFeatureUUID); - _logBuffer.setNumVariables(_baseLogger->getArrayVarCount()); + begin(baseLogger, static_cast(nullptr), registrationToken, + samplingFeatureUUID); } void MonitorMyWatershedPublisher::begin(Logger& baseLogger, const char* registrationToken) { - setToken(registrationToken); - dataPublisher::begin(baseLogger); - _logBuffer.setNumVariables(_baseLogger->getArrayVarCount()); + begin(baseLogger, static_cast(nullptr), registrationToken, + nullptr); } bool MonitorMyWatershedPublisher::connectionNeeded(void) { diff --git a/src/publishers/UbidotsPublisher.cpp b/src/publishers/UbidotsPublisher.cpp index 0e5706428..ef7f579bc 100644 --- a/src/publishers/UbidotsPublisher.cpp +++ b/src/publishers/UbidotsPublisher.cpp @@ -123,7 +123,7 @@ int16_t UbidotsPublisher::publishData(Client* outClient, bool) { "to Ubidots!")); return 0; } - if (_authenticationToken == nullptr || strlen(_authenticationToken) == 0) { + if (_authenticationToken == nullptr || _authenticationToken[0] == '\0') { PRINTOUT(F("An authentication token must be set before publishing data " "to Ubidots!")); return 0; diff --git a/src/sensors/PaleoTerraRedox.cpp b/src/sensors/PaleoTerraRedox.cpp index a1e3ed325..ad5b9f06a 100644 --- a/src/sensors/PaleoTerraRedox.cpp +++ b/src/sensors/PaleoTerraRedox.cpp @@ -142,7 +142,6 @@ bool PaleoTerraRedox::addSingleMeasurementResult(void) { byte res3 = _i2c->read(); // byte 3: [ D7 ~ D0 ] config = _i2c->read(); // byte 4: [config byte] - res = 0; // Assemble the 18-bit raw sample from the three bytes // Only use the lower 2 bits of res1 (D17 D16), ignore sign-extension bits // Cast to uint32_t to ensure sufficient bit width for left shift operations From ef08e1ee7379047f2bbb46bb3c3482e00c04f3bf Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Wed, 4 Mar 2026 10:21:27 -0500 Subject: [PATCH 417/533] Declared trivial destructors as default Signed-off-by: Sara Damiano --- src/LogBuffer.cpp | 2 -- src/LogBuffer.h | 2 +- src/LoggerBase.cpp | 2 -- src/LoggerBase.h | 2 +- src/LoggerModem.cpp | 3 -- src/LoggerModem.h | 14 +++++----- src/SensorBase.cpp | 2 -- src/SensorBase.h | 2 +- src/VariableBase.cpp | 3 -- src/VariableBase.h | 2 +- src/dataPublisherBase.cpp | 2 -- src/dataPublisherBase.h | 2 +- src/modems/DigiXBee.cpp | 3 -- src/modems/DigiXBee.h | 2 +- src/modems/DigiXBeeCellularTransparent.cpp | 3 -- src/modems/DigiXBeeCellularTransparent.h | 2 +- src/modems/DigiXBeeLTEBypass.cpp | 3 -- src/modems/DigiXBeeLTEBypass.h | 2 +- src/modems/DigiXBeeWifi.cpp | 3 -- src/modems/DigiXBeeWifi.h | 2 +- src/modems/Espressif.cpp | 3 -- src/modems/Espressif.h | 2 +- src/modems/EspressifESP32.cpp | 3 -- src/modems/EspressifESP32.h | 2 +- src/modems/EspressifESP8266.cpp | 3 -- src/modems/EspressifESP8266.h | 2 +- src/publishers/AWS_IoT_Publisher.cpp | 4 +-- src/publishers/AWS_IoT_Publisher.h | 2 +- src/publishers/DreamHostPublisher.cpp | 3 -- src/publishers/DreamHostPublisher.h | 2 +- .../MonitorMyWatershedPublisher.cpp | 3 -- src/publishers/MonitorMyWatershedPublisher.h | 2 +- src/publishers/S3PresignedPublisher.cpp | 2 -- src/publishers/S3PresignedPublisher.h | 2 +- src/publishers/ThingSpeakPublisher.cpp | 2 -- src/publishers/ThingSpeakPublisher.h | 2 +- src/publishers/UbidotsPublisher.cpp | 2 -- src/publishers/UbidotsPublisher.h | 2 +- src/sensors/ANBpH.cpp | 2 -- src/sensors/ANBpH.h | 18 ++++++------ src/sensors/AOSongAM2315.h | 4 +-- src/sensors/AOSongDHT.h | 6 ++-- src/sensors/AlphasenseCO2.h | 4 +-- src/sensors/AnalogElecConductivity.h | 2 +- src/sensors/ApogeeSQ212.h | 4 +-- src/sensors/AtlasScientificCO2.h | 4 +-- src/sensors/AtlasScientificDO.h | 4 +-- src/sensors/AtlasScientificEC.h | 8 +++--- src/sensors/AtlasScientificORP.h | 4 +-- src/sensors/AtlasScientificRTD.h | 4 +-- src/sensors/AtlasScientificpH.h | 4 +-- src/sensors/BoschBME280.h | 8 +++--- src/sensors/BoschBMP3xx.h | 6 ++-- src/sensors/CampbellClariVUE10.h | 8 +++--- src/sensors/CampbellOBS3.h | 4 +-- src/sensors/CampbellRainVUE10.h | 10 +++---- src/sensors/Decagon5TM.h | 8 +++--- src/sensors/DecagonCTD.h | 8 +++--- src/sensors/DecagonES2.h | 6 ++-- src/sensors/EverlightALSPT19.h | 6 ++-- src/sensors/FreescaleMPL115A2.h | 4 +-- src/sensors/GeoluxHydroCam.h | 4 +-- src/sensors/GroPointGPLP8.h | 6 ++-- src/sensors/InSituRDO.h | 10 +++---- src/sensors/InSituTrollSdi12a.h | 8 +++--- src/sensors/KellerAcculevel.h | 8 +++--- src/sensors/KellerNanolevel.h | 8 +++--- src/sensors/MaxBotixSonar.h | 2 +- src/sensors/MaximDS18.h | 2 +- src/sensors/MaximDS3231.h | 2 +- src/sensors/MeaSpecMS5803.h | 4 +-- src/sensors/MeterHydros21.h | 8 +++--- src/sensors/MeterTeros11.h | 10 +++---- src/sensors/PaleoTerraRedox.h | 2 +- src/sensors/ProcessorAnalog.h | 2 +- src/sensors/ProcessorStats.h | 8 +++--- src/sensors/RainCounterI2C.h | 4 +-- src/sensors/SensirionSHT4x.h | 4 +-- src/sensors/TEConnectivityMS5837.h | 8 +++--- src/sensors/TIADS1x15.h | 2 +- src/sensors/TIINA219.h | 6 ++-- src/sensors/TallyCounterI2C.h | 2 +- src/sensors/TurnerCyclops.h | 28 +++++++++---------- src/sensors/TurnerTurbidityPlus.h | 4 +-- src/sensors/VegaPuls21.h | 12 ++++---- src/sensors/YosemitechY4000.h | 18 ++++++------ src/sensors/YosemitechY504.h | 8 +++--- src/sensors/YosemitechY510.h | 6 ++-- src/sensors/YosemitechY511.h | 6 ++-- src/sensors/YosemitechY513.h | 6 ++-- src/sensors/YosemitechY514.h | 6 ++-- src/sensors/YosemitechY520.h | 6 ++-- src/sensors/YosemitechY532.h | 8 +++--- src/sensors/YosemitechY533.h | 6 ++-- src/sensors/YosemitechY551.h | 8 +++--- src/sensors/YosemitechY560.h | 8 +++--- src/sensors/YosemitechY700.h | 6 ++-- src/sensors/ZebraTechDOpto.h | 8 +++--- 98 files changed, 220 insertions(+), 271 deletions(-) diff --git a/src/LogBuffer.cpp b/src/LogBuffer.cpp index ca4eab926..731d3a642 100644 --- a/src/LogBuffer.cpp +++ b/src/LogBuffer.cpp @@ -14,8 +14,6 @@ // Constructor LogBuffer::LogBuffer() {} -// Destructor -LogBuffer::~LogBuffer() {} void LogBuffer::setNumVariables(uint8_t numVariables_) { // each record is one uint32_t to hold the timestamp, plus N floats to hold diff --git a/src/LogBuffer.h b/src/LogBuffer.h index 49e7035f7..daab29832 100644 --- a/src/LogBuffer.h +++ b/src/LogBuffer.h @@ -54,7 +54,7 @@ class LogBuffer { /** * @brief Destroys the buffer. */ - virtual ~LogBuffer(); + virtual ~LogBuffer() = default; /** * @brief Sets the number of variables the buffer will store in each record. diff --git a/src/LoggerBase.cpp b/src/LoggerBase.cpp index 22c2f7559..e09ea8746 100644 --- a/src/LoggerBase.cpp +++ b/src/LoggerBase.cpp @@ -178,8 +178,6 @@ Logger::Logger() { // Set a datetime callback for automatic time-stamping of files by SdFat SdFile::dateTimeCallback(fileDateTimeCallback); } -// Destructor -Logger::~Logger() {} // ===================================================================== // diff --git a/src/LoggerBase.h b/src/LoggerBase.h index 3e05f0612..8ec1e6933 100644 --- a/src/LoggerBase.h +++ b/src/LoggerBase.h @@ -178,7 +178,7 @@ class Logger { /** * @brief Destroy the Logger object - takes no action. */ - virtual ~Logger(); + virtual ~Logger() = default; // ===================================================================== // /** diff --git a/src/LoggerModem.cpp b/src/LoggerModem.cpp index 782e91935..8f9f9ec96 100644 --- a/src/LoggerModem.cpp +++ b/src/LoggerModem.cpp @@ -43,9 +43,6 @@ loggerModem::loggerModem(int8_t powerPin, int8_t statusPin, bool statusLevel, _max_at_response_time_ms(max_at_response_time_ms), _modemName("unspecified modem") {} -// Destructor -loggerModem::~loggerModem() {} - void loggerModem::setModemLED(int8_t modemLEDPin) { _modemLEDPin = modemLEDPin; diff --git a/src/LoggerModem.h b/src/LoggerModem.h index dff1d3001..28a115bb9 100644 --- a/src/LoggerModem.h +++ b/src/LoggerModem.h @@ -357,7 +357,7 @@ class loggerModem { /** * @brief Destroy the logger Modem object - no action taken. */ - virtual ~loggerModem(); + virtual ~loggerModem() = default; /** * @brief Set an LED to turn on (pin will be `HIGH`) when the modem is on. @@ -1257,7 +1257,7 @@ class Modem_RSSI : public Variable { /** * @brief Destroy the Modem_RSSI object - no action needed. */ - ~Modem_RSSI() {} + ~Modem_RSSI() = default; }; @@ -1292,7 +1292,7 @@ class Modem_SignalPercent : public Variable { /** * @brief Destroy the Modem_SignalPercent object - no action needed. */ - ~Modem_SignalPercent() {} + ~Modem_SignalPercent() = default; }; @@ -1330,7 +1330,7 @@ class Modem_BatteryState : public Variable { /** * @brief Destroy the Modem_BatteryState object - no action needed. */ - ~Modem_BatteryState() {} + ~Modem_BatteryState() = default; }; @@ -1369,7 +1369,7 @@ class Modem_BatteryPercent : public Variable { /** * @brief Destroy the Modem_BatteryPercent object - no action needed. */ - ~Modem_BatteryPercent() {} + ~Modem_BatteryPercent() = default; }; @@ -1408,7 +1408,7 @@ class Modem_BatteryVoltage : public Variable { /** * @brief Destroy the Modem_BatteryVoltage object - no action needed. */ - ~Modem_BatteryVoltage() {} + ~Modem_BatteryVoltage() = default; }; @@ -1445,7 +1445,7 @@ class Modem_Temp : public Variable { /** * @brief Destroy the Modem_Temp object - no action needed. */ - ~Modem_Temp() {} + ~Modem_Temp() = default; }; #endif // SRC_LOGGERMODEM_H_ diff --git a/src/SensorBase.cpp b/src/SensorBase.cpp index 84ee5964b..9932f78a6 100644 --- a/src/SensorBase.cpp +++ b/src/SensorBase.cpp @@ -37,8 +37,6 @@ Sensor::Sensor(const char* sensorName, const uint8_t totalReturnedValues, numberGoodMeasurementsMade[i] = 0; } } -// Destructor -Sensor::~Sensor() {} // This gets the place the sensor is installed ON THE MAYFLY (ie, pin number) diff --git a/src/SensorBase.h b/src/SensorBase.h index c67b5c6be..d613c0dd4 100644 --- a/src/SensorBase.h +++ b/src/SensorBase.h @@ -118,7 +118,7 @@ class Sensor { /** * @brief Destroy the Sensor object - no action taken. */ - virtual ~Sensor(); + virtual ~Sensor() = default; // These functions are dependent on the constructor and return the // constructor values. diff --git a/src/VariableBase.cpp b/src/VariableBase.cpp index 39bbf3e6f..e22ed93c8 100644 --- a/src/VariableBase.cpp +++ b/src/VariableBase.cpp @@ -57,11 +57,8 @@ Variable::Variable(float (*calcFxn)(), uint8_t decimalResolution, const char* varCode) : Variable(calcFxn, decimalResolution, varName, varUnit, varCode, nullptr) { } - // constructor with no arguments Variable::Variable() : isCalculated(true) {} -// Destructor -Variable::~Variable() {} // This does all of the setup that can't happen in the constructors diff --git a/src/VariableBase.h b/src/VariableBase.h index c8530a696..80acaaef3 100644 --- a/src/VariableBase.h +++ b/src/VariableBase.h @@ -155,7 +155,7 @@ class Variable { /** * @brief Destroy the Variable object - no action taken. */ - ~Variable(); + ~Variable() = default; /** * @brief Begin for the Variable object diff --git a/src/dataPublisherBase.cpp b/src/dataPublisherBase.cpp index 7fd140eee..4518e7947 100644 --- a/src/dataPublisherBase.cpp +++ b/src/dataPublisherBase.cpp @@ -38,8 +38,6 @@ dataPublisher::dataPublisher(Logger& baseLogger, Client* inClient, : dataPublisher(baseLogger, sendEveryX) { _inClient = inClient; } -// Destructor -dataPublisher::~dataPublisher() {} // Sets the client diff --git a/src/dataPublisherBase.h b/src/dataPublisherBase.h index c37d60653..a8864f1dd 100644 --- a/src/dataPublisherBase.h +++ b/src/dataPublisherBase.h @@ -100,7 +100,7 @@ class dataPublisher { /** * @brief Destroy the data publisher object - no action is taken. */ - virtual ~dataPublisher(); + virtual ~dataPublisher() = default; /** * @brief Set the Client object. diff --git a/src/modems/DigiXBee.cpp b/src/modems/DigiXBee.cpp index 371a3fdc7..725cae890 100644 --- a/src/modems/DigiXBee.cpp +++ b/src/modems/DigiXBee.cpp @@ -21,9 +21,6 @@ DigiXBee::DigiXBee(int8_t powerPin, int8_t statusPin, bool useCTSStatus, XBEE_DISCONNECT_TIME_MS, XBEE_WAKE_DELAY_MS, XBEE_AT_RESPONSE_TIME_MS) {} -// Destructor -DigiXBee::~DigiXBee() {} - // Create the wake and sleep methods for the modem // These can be functions of any type and must return a boolean diff --git a/src/modems/DigiXBee.h b/src/modems/DigiXBee.h index a1a4f466b..d2bddbb17 100644 --- a/src/modems/DigiXBee.h +++ b/src/modems/DigiXBee.h @@ -221,7 +221,7 @@ class DigiXBee : public loggerModem { /** * @brief Destroy the Digi XBee object - no action taken */ - virtual ~DigiXBee(); + virtual ~DigiXBee() = default; protected: bool modemSleepFxn(void) override; diff --git a/src/modems/DigiXBeeCellularTransparent.cpp b/src/modems/DigiXBeeCellularTransparent.cpp index 1405185be..2899702be 100644 --- a/src/modems/DigiXBeeCellularTransparent.cpp +++ b/src/modems/DigiXBeeCellularTransparent.cpp @@ -31,9 +31,6 @@ DigiXBeeCellularTransparent::DigiXBeeCellularTransparent( _pwd(pwd) { } -// Destructor -DigiXBeeCellularTransparent::~DigiXBeeCellularTransparent() {} - MS_IS_MODEM_AWAKE(DigiXBeeCellularTransparent); MS_MODEM_WAKE(DigiXBeeCellularTransparent); diff --git a/src/modems/DigiXBeeCellularTransparent.h b/src/modems/DigiXBeeCellularTransparent.h index 0f7604cf2..30d296ef5 100644 --- a/src/modems/DigiXBeeCellularTransparent.h +++ b/src/modems/DigiXBeeCellularTransparent.h @@ -159,7 +159,7 @@ class DigiXBeeCellularTransparent : public DigiXBee { * @brief Destroy the Digi XBee Cellular Transparent object - no action * needed */ - ~DigiXBeeCellularTransparent(); + ~DigiXBeeCellularTransparent() = default; bool modemWake(void) override; diff --git a/src/modems/DigiXBeeLTEBypass.cpp b/src/modems/DigiXBeeLTEBypass.cpp index e8477b61d..f2512b373 100644 --- a/src/modems/DigiXBeeLTEBypass.cpp +++ b/src/modems/DigiXBeeLTEBypass.cpp @@ -28,9 +28,6 @@ DigiXBeeLTEBypass::DigiXBeeLTEBypass(Stream* modemStream, int8_t powerPin, _apn(apn) { } -// Destructor -DigiXBeeLTEBypass::~DigiXBeeLTEBypass() {} - MS_IS_MODEM_AWAKE(DigiXBeeLTEBypass); MS_MODEM_WAKE(DigiXBeeLTEBypass); diff --git a/src/modems/DigiXBeeLTEBypass.h b/src/modems/DigiXBeeLTEBypass.h index 8ac75e1dc..0329f0246 100644 --- a/src/modems/DigiXBeeLTEBypass.h +++ b/src/modems/DigiXBeeLTEBypass.h @@ -140,7 +140,7 @@ class DigiXBeeLTEBypass : public DigiXBee { /** * @brief Destroy the Digi XBee LTE Bypass object - no action needed */ - ~DigiXBeeLTEBypass(); + ~DigiXBeeLTEBypass() = default; bool modemWake(void) override; diff --git a/src/modems/DigiXBeeWifi.cpp b/src/modems/DigiXBeeWifi.cpp index 52f7d1ce3..6a488298f 100644 --- a/src/modems/DigiXBeeWifi.cpp +++ b/src/modems/DigiXBeeWifi.cpp @@ -32,9 +32,6 @@ DigiXBeeWifi::DigiXBeeWifi(Stream* modemStream, int8_t powerPin, _maintainAssociation(maintainAssociation) { } -// Destructor -DigiXBeeWifi::~DigiXBeeWifi() {} - MS_IS_MODEM_AWAKE(DigiXBeeWifi); MS_MODEM_WAKE(DigiXBeeWifi); diff --git a/src/modems/DigiXBeeWifi.h b/src/modems/DigiXBeeWifi.h index e4eb8fb16..9ab6d02ea 100644 --- a/src/modems/DigiXBeeWifi.h +++ b/src/modems/DigiXBeeWifi.h @@ -135,7 +135,7 @@ class DigiXBeeWifi : public DigiXBee { /** * @brief Destroy the Digi XBee Wifi object - no action taken */ - ~DigiXBeeWifi(); + ~DigiXBeeWifi() = default; bool modemWake(void) override; diff --git a/src/modems/Espressif.cpp b/src/modems/Espressif.cpp index 6633a2569..b04e8e871 100644 --- a/src/modems/Espressif.cpp +++ b/src/modems/Espressif.cpp @@ -23,9 +23,6 @@ Espressif::Espressif(Stream* modemStream, int8_t powerPin, int8_t modemResetPin, _ssid(ssid), _pwd(pwd) {} -// Destructor -Espressif::~Espressif() {} - // A helper function to wait for the esp to boot and immediately change some // settings We'll use this in the wake function bool Espressif::ESPwaitForBoot(void) { diff --git a/src/modems/Espressif.h b/src/modems/Espressif.h index 92f24c2b6..a17331fec 100644 --- a/src/modems/Espressif.h +++ b/src/modems/Espressif.h @@ -200,7 +200,7 @@ class Espressif : public loggerModem { /** * @brief Destroy the Espressif object - no action taken */ - virtual ~Espressif(); + virtual ~Espressif() = default; /** * @brief A pointer to the Arduino serial Stream used for communication diff --git a/src/modems/EspressifESP32.cpp b/src/modems/EspressifESP32.cpp index c26e78e79..c3cc6c69d 100644 --- a/src/modems/EspressifESP32.cpp +++ b/src/modems/EspressifESP32.cpp @@ -26,9 +26,6 @@ EspressifESP32::EspressifESP32(Stream* modemStream, int8_t powerPin, { } -// Destructor -EspressifESP32::~EspressifESP32() {} - MS_IS_MODEM_AWAKE(EspressifESP32); MS_MODEM_WAKE(EspressifESP32); diff --git a/src/modems/EspressifESP32.h b/src/modems/EspressifESP32.h index 63b1f1352..bba60130a 100644 --- a/src/modems/EspressifESP32.h +++ b/src/modems/EspressifESP32.h @@ -123,7 +123,7 @@ class EspressifESP32 : public Espressif { /** * @brief Destroy the Espressif ESP32 object - no action taken */ - ~EspressifESP32(); + ~EspressifESP32() = default; bool modemWake(void) override; diff --git a/src/modems/EspressifESP8266.cpp b/src/modems/EspressifESP8266.cpp index 742554d0b..b44c99b96 100644 --- a/src/modems/EspressifESP8266.cpp +++ b/src/modems/EspressifESP8266.cpp @@ -26,9 +26,6 @@ EspressifESP8266::EspressifESP8266(Stream* modemStream, int8_t powerPin, { } -// Destructor -EspressifESP8266::~EspressifESP8266() {} - MS_IS_MODEM_AWAKE(EspressifESP8266); MS_MODEM_WAKE(EspressifESP8266); diff --git a/src/modems/EspressifESP8266.h b/src/modems/EspressifESP8266.h index ed53fca65..3022783eb 100644 --- a/src/modems/EspressifESP8266.h +++ b/src/modems/EspressifESP8266.h @@ -122,7 +122,7 @@ class EspressifESP8266 : public Espressif { /** * @brief Destroy the Espressif ESP8266 object - no action taken */ - ~EspressifESP8266(); + ~EspressifESP8266() = default; bool modemWake(void) override; diff --git a/src/publishers/AWS_IoT_Publisher.cpp b/src/publishers/AWS_IoT_Publisher.cpp index 12bff3da9..f5c1be339 100644 --- a/src/publishers/AWS_IoT_Publisher.cpp +++ b/src/publishers/AWS_IoT_Publisher.cpp @@ -41,6 +41,7 @@ AWS_IoT_Publisher::AWS_IoT_Publisher( init(); } + // Delegating constructors AWS_IoT_Publisher::AWS_IoT_Publisher() : dataPublisher() { init(); @@ -85,9 +86,6 @@ void AWS_IoT_Publisher::init() { contentGetrFxns[i] = nullptr; } } -// Destructor -AWS_IoT_Publisher::~AWS_IoT_Publisher() {} - void AWS_IoT_Publisher::setEndpoint(const char* awsIoTEndpoint) { _awsIoTEndpoint = awsIoTEndpoint; diff --git a/src/publishers/AWS_IoT_Publisher.h b/src/publishers/AWS_IoT_Publisher.h index 17a4a17c8..c302c46b7 100644 --- a/src/publishers/AWS_IoT_Publisher.h +++ b/src/publishers/AWS_IoT_Publisher.h @@ -173,7 +173,7 @@ class AWS_IoT_Publisher : public dataPublisher { /** * @brief Destroy the AWS IoT Core Publisher object */ - virtual ~AWS_IoT_Publisher(); + virtual ~AWS_IoT_Publisher() = default; // Returns the data destination String getEndpoint(void) override { diff --git a/src/publishers/DreamHostPublisher.cpp b/src/publishers/DreamHostPublisher.cpp index 0eea325a4..3c7be6321 100644 --- a/src/publishers/DreamHostPublisher.cpp +++ b/src/publishers/DreamHostPublisher.cpp @@ -29,7 +29,6 @@ DreamHostPublisher::DreamHostPublisher(Logger& baseLogger, Client* inClient, // Default constructor (base class initialization) DreamHostPublisher::DreamHostPublisher() : dataPublisher() {} - // Delegating constructors DreamHostPublisher::DreamHostPublisher(Logger& baseLogger, int sendEveryX) : DreamHostPublisher(baseLogger, static_cast(nullptr), @@ -45,8 +44,6 @@ DreamHostPublisher::DreamHostPublisher(Logger& baseLogger, Client* inClient, : DreamHostPublisher(baseLogger, inClient, sendEveryX) { if (dhUrl) setDreamHostPortalRX(dhUrl); } -// Destructor -DreamHostPublisher::~DreamHostPublisher() {} // Functions for private SWRC server diff --git a/src/publishers/DreamHostPublisher.h b/src/publishers/DreamHostPublisher.h index d1d0e313e..31d9d58b9 100644 --- a/src/publishers/DreamHostPublisher.h +++ b/src/publishers/DreamHostPublisher.h @@ -101,7 +101,7 @@ class DreamHostPublisher : public dataPublisher { /** * @brief Destroy the DreamHost Publisher object */ - virtual ~DreamHostPublisher(); + virtual ~DreamHostPublisher() = default; // Returns the data destination String getEndpoint(void) override { diff --git a/src/publishers/MonitorMyWatershedPublisher.cpp b/src/publishers/MonitorMyWatershedPublisher.cpp index cdd05621b..25a1a8fc4 100644 --- a/src/publishers/MonitorMyWatershedPublisher.cpp +++ b/src/publishers/MonitorMyWatershedPublisher.cpp @@ -85,9 +85,6 @@ MonitorMyWatershedPublisher::MonitorMyWatershedPublisher( int sendEveryX) : MonitorMyWatershedPublisher(baseLogger, inClient, registrationToken, nullptr, sendEveryX) {} -// Destructor -MonitorMyWatershedPublisher::~MonitorMyWatershedPublisher() {} - // Returns the data destination String MonitorMyWatershedPublisher::getHost(void) { diff --git a/src/publishers/MonitorMyWatershedPublisher.h b/src/publishers/MonitorMyWatershedPublisher.h index a8d6e6042..cc9d5c6c7 100644 --- a/src/publishers/MonitorMyWatershedPublisher.h +++ b/src/publishers/MonitorMyWatershedPublisher.h @@ -141,7 +141,7 @@ class MonitorMyWatershedPublisher : public dataPublisher { /** * @brief Destroy the Monitor My Watershed Publisher object */ - virtual ~MonitorMyWatershedPublisher(); + virtual ~MonitorMyWatershedPublisher() = default; // Returns the data destination String getEndpoint(void) override { diff --git a/src/publishers/S3PresignedPublisher.cpp b/src/publishers/S3PresignedPublisher.cpp index f473f771b..64f728c90 100644 --- a/src/publishers/S3PresignedPublisher.cpp +++ b/src/publishers/S3PresignedPublisher.cpp @@ -40,8 +40,6 @@ S3PresignedPublisher::S3PresignedPublisher(Logger& baseLogger, Client* inClient, getUrlFxn, getFileNameFxn, sendEveryX) { if (inClient) _inClient = inClient; } -// Destructor -S3PresignedPublisher::~S3PresignedPublisher() {} void S3PresignedPublisher::setPort(int port) { diff --git a/src/publishers/S3PresignedPublisher.h b/src/publishers/S3PresignedPublisher.h index 633a3aae5..55ecfd84a 100644 --- a/src/publishers/S3PresignedPublisher.h +++ b/src/publishers/S3PresignedPublisher.h @@ -176,7 +176,7 @@ class S3PresignedPublisher : public dataPublisher { /** * @brief Destroy the S3 Publisher object */ - virtual ~S3PresignedPublisher(); + virtual ~S3PresignedPublisher() = default; /** * @brief Set the S3 host name diff --git a/src/publishers/ThingSpeakPublisher.cpp b/src/publishers/ThingSpeakPublisher.cpp index 4323fd829..e6b782ca1 100644 --- a/src/publishers/ThingSpeakPublisher.cpp +++ b/src/publishers/ThingSpeakPublisher.cpp @@ -63,8 +63,6 @@ ThingSpeakPublisher::ThingSpeakPublisher(Logger& baseLogger, : ThingSpeakPublisher(baseLogger, nullptr, thingSpeakClientName, thingSpeakMQTTUser, thingSpeakMQTTPassword, thingSpeakChannelID, sendEveryX) {} -// Destructor -ThingSpeakPublisher::~ThingSpeakPublisher() {} void ThingSpeakPublisher::setMQTTClient(const char* thingSpeakClientName) { diff --git a/src/publishers/ThingSpeakPublisher.h b/src/publishers/ThingSpeakPublisher.h index c9a05ad11..e1068a95a 100644 --- a/src/publishers/ThingSpeakPublisher.h +++ b/src/publishers/ThingSpeakPublisher.h @@ -127,7 +127,7 @@ class ThingSpeakPublisher : public dataPublisher { /** * @brief Destroy the ThingSpeak Publisher object */ - virtual ~ThingSpeakPublisher(); + virtual ~ThingSpeakPublisher() = default; // Returns the data destination String getEndpoint(void) override { diff --git a/src/publishers/UbidotsPublisher.cpp b/src/publishers/UbidotsPublisher.cpp index ef7f579bc..6fb66569e 100644 --- a/src/publishers/UbidotsPublisher.cpp +++ b/src/publishers/UbidotsPublisher.cpp @@ -57,8 +57,6 @@ UbidotsPublisher::UbidotsPublisher(Logger& baseLogger, Client* inClient, : UbidotsPublisher(baseLogger, authenticationToken, deviceID, sendEveryX) { if (inClient) _inClient = inClient; } -// Destructor -UbidotsPublisher::~UbidotsPublisher() {} void UbidotsPublisher::setToken(const char* authenticationToken) { diff --git a/src/publishers/UbidotsPublisher.h b/src/publishers/UbidotsPublisher.h index 64fe9194e..94d4463f1 100644 --- a/src/publishers/UbidotsPublisher.h +++ b/src/publishers/UbidotsPublisher.h @@ -110,7 +110,7 @@ class UbidotsPublisher : public dataPublisher { /** * @brief Destroy the Ubidots Publisher object */ - virtual ~UbidotsPublisher(); + virtual ~UbidotsPublisher() = default; // Returns the data destination /** diff --git a/src/sensors/ANBpH.cpp b/src/sensors/ANBpH.cpp index ab9345fab..3ced87863 100644 --- a/src/sensors/ANBpH.cpp +++ b/src/sensors/ANBpH.cpp @@ -34,8 +34,6 @@ ANBpH::ANBpH(byte modbusAddress, Stream& stream, int8_t powerPin, uint8_t measurementsToAverage) : ANBpH(modbusAddress, &stream, powerPin, loggingIntervalMinutes, powerPin2, enablePin, measurementsToAverage) {} -// Destructor -ANBpH::~ANBpH() {} // The sensor installation location on the Mayfly diff --git a/src/sensors/ANBpH.h b/src/sensors/ANBpH.h index ca9b9755d..042671b77 100644 --- a/src/sensors/ANBpH.h +++ b/src/sensors/ANBpH.h @@ -538,7 +538,7 @@ class ANBpH : public Sensor { /** * @brief Destroy the ANB pH object - no action taken */ - virtual ~ANBpH(); + virtual ~ANBpH() = default; String getSensorLocation(void) override; @@ -746,7 +746,7 @@ class ANBpH_pH : public Variable { /** * @brief Destroy the ANBpH_pH object - no action needed. */ - ~ANBpH_pH() {} + ~ANBpH_pH() = default; }; /* clang-format off */ @@ -785,7 +785,7 @@ class ANBpH_Temp : public Variable { /** * @brief Destroy the ANBpH_Temp object - no action needed. */ - ~ANBpH_Temp() {} + ~ANBpH_Temp() = default; }; /* clang-format off */ @@ -827,7 +827,7 @@ class ANBpH_Salinity : public Variable { * @brief Destroy the ANBpH_Salinity() object - no action * needed. */ - ~ANBpH_Salinity() {} + ~ANBpH_Salinity() = default; }; @@ -866,7 +866,7 @@ class ANBpH_SpCond : public Variable { /** * @brief Destroy the ANBpH_SpCond object - no action needed. */ - ~ANBpH_SpCond() {} + ~ANBpH_SpCond() = default; }; /* clang-format off */ @@ -905,7 +905,7 @@ class ANBpH_EC : public Variable { /** * @brief Destroy the ANBpH_EC object - no action needed. */ - ~ANBpH_EC() {} + ~ANBpH_EC() = default; }; @@ -950,7 +950,7 @@ class ANBpH_HealthCode : public Variable { * @brief Destroy the ANBpH_HealthCode object - no action * needed. */ - ~ANBpH_HealthCode() {} + ~ANBpH_HealthCode() = default; }; @@ -996,7 +996,7 @@ class ANBpH_DiagnosticCode : public Variable { * @brief Destroy the ANBpH_DiagnosticCode object - no action * needed. */ - ~ANBpH_DiagnosticCode() {} + ~ANBpH_DiagnosticCode() = default; }; @@ -1041,7 +1041,7 @@ class ANBpH_StatusCode : public Variable { * @brief Destroy the ANBpH_StatusCode object - no action * needed. */ - ~ANBpH_StatusCode() {} + ~ANBpH_StatusCode() = default; }; /**@}*/ #endif // SRC_SENSORS_ANB_SENSORS_PH_H_ diff --git a/src/sensors/AOSongAM2315.h b/src/sensors/AOSongAM2315.h index 6f9ef4ffd..ae3b8a3f1 100644 --- a/src/sensors/AOSongAM2315.h +++ b/src/sensors/AOSongAM2315.h @@ -290,7 +290,7 @@ class AOSongAM2315_Humidity : public Variable { /** * @brief Destroy the AOSongAM2315_Humidity object - no action needed. */ - ~AOSongAM2315_Humidity() {} + ~AOSongAM2315_Humidity() = default; }; @@ -330,7 +330,7 @@ class AOSongAM2315_Temp : public Variable { /** * @brief Destroy the AOSongAM2315_Temp object - no action needed. */ - ~AOSongAM2315_Temp() {} + ~AOSongAM2315_Temp() = default; }; /**@}*/ #endif // SRC_SENSORS_AOSONGAM2315_H_ diff --git a/src/sensors/AOSongDHT.h b/src/sensors/AOSongDHT.h index 8e90ce000..cf949b946 100644 --- a/src/sensors/AOSongDHT.h +++ b/src/sensors/AOSongDHT.h @@ -319,7 +319,7 @@ class AOSongDHT_Humidity : public Variable { /** * @brief Destroy the AOSongDHT_Humidity object - no action needed. */ - ~AOSongDHT_Humidity() {} + ~AOSongDHT_Humidity() = default; }; @@ -360,7 +360,7 @@ class AOSongDHT_Temp : public Variable { /** * @brief Destroy the AOSongDHT_Temp object - no action needed. */ - ~AOSongDHT_Temp() {} + ~AOSongDHT_Temp() = default; }; @@ -400,7 +400,7 @@ class AOSongDHT_HI : public Variable { /** * @brief Destroy the AOSongDHT_HI object - no action needed. */ - ~AOSongDHT_HI() {} + ~AOSongDHT_HI() = default; }; /**@}*/ #endif // SRC_SENSORS_AOSONGDHT_H_ diff --git a/src/sensors/AlphasenseCO2.h b/src/sensors/AlphasenseCO2.h index 941f92392..8133dab31 100644 --- a/src/sensors/AlphasenseCO2.h +++ b/src/sensors/AlphasenseCO2.h @@ -374,7 +374,7 @@ class AlphasenseCO2_CO2 : public Variable { /** * @brief Destroy the AlphasenseCO2_CO2 object - no action needed. */ - ~AlphasenseCO2_CO2() {} + ~AlphasenseCO2_CO2() = default; }; @@ -419,7 +419,7 @@ class AlphasenseCO2_Voltage : public Variable { /** * @brief Destroy the AlphasenseCO2_Voltage object - no action needed. */ - ~AlphasenseCO2_Voltage() {} + ~AlphasenseCO2_Voltage() = default; }; /**@}*/ #endif // SRC_SENSORS_ALPHASENSECO2_H_ diff --git a/src/sensors/AnalogElecConductivity.h b/src/sensors/AnalogElecConductivity.h index 9c4704499..e65cf0bbb 100644 --- a/src/sensors/AnalogElecConductivity.h +++ b/src/sensors/AnalogElecConductivity.h @@ -425,7 +425,7 @@ class AnalogElecConductivity_EC : public Variable { /** * @brief Destroy the AnalogElecConductivity_EC object - no action needed. */ - ~AnalogElecConductivity_EC() {} + ~AnalogElecConductivity_EC() = default; }; /**@}*/ #endif // SRC_SENSORS_ANALOGELECCONDUCTIVITY_H_ diff --git a/src/sensors/ApogeeSQ212.h b/src/sensors/ApogeeSQ212.h index c8ffc217b..59f379eb6 100644 --- a/src/sensors/ApogeeSQ212.h +++ b/src/sensors/ApogeeSQ212.h @@ -344,7 +344,7 @@ class ApogeeSQ212_PAR : public Variable { /** * @brief Destroy the ApogeeSQ212_PAR object - no action needed. */ - ~ApogeeSQ212_PAR() {} + ~ApogeeSQ212_PAR() = default; }; @@ -387,7 +387,7 @@ class ApogeeSQ212_Voltage : public Variable { /** * @brief Destroy the ApogeeSQ212_Voltage object - no action needed. */ - ~ApogeeSQ212_Voltage() {} + ~ApogeeSQ212_Voltage() = default; }; /**@}*/ #endif // SRC_SENSORS_APOGEESQ212_H_ diff --git a/src/sensors/AtlasScientificCO2.h b/src/sensors/AtlasScientificCO2.h index 37ebb02d3..6e939231c 100644 --- a/src/sensors/AtlasScientificCO2.h +++ b/src/sensors/AtlasScientificCO2.h @@ -286,7 +286,7 @@ class AtlasScientificCO2_CO2 : public Variable { /** * @brief Destroy the AtlasScientificCO2_CO2 object - no action needed. */ - ~AtlasScientificCO2_CO2() {} + ~AtlasScientificCO2_CO2() = default; }; /* clang-format off */ @@ -329,7 +329,7 @@ class AtlasScientificCO2_Temp : public Variable { /** * @brief Destroy the AtlasScientificCO2_Temp object - no action needed. */ - ~AtlasScientificCO2_Temp() {} + ~AtlasScientificCO2_Temp() = default; }; /**@}*/ #endif // SRC_SENSORS_ATLASSCIENTIFICCO2_H_ diff --git a/src/sensors/AtlasScientificDO.h b/src/sensors/AtlasScientificDO.h index 08157e234..a3ad58e70 100644 --- a/src/sensors/AtlasScientificDO.h +++ b/src/sensors/AtlasScientificDO.h @@ -294,7 +294,7 @@ class AtlasScientificDO_DOmgL : public Variable { /** * @brief Destroy the AtlasScientificDO_DOmgL object - no action needed. */ - ~AtlasScientificDO_DOmgL() {} + ~AtlasScientificDO_DOmgL() = default; }; /* clang-format off */ @@ -337,7 +337,7 @@ class AtlasScientificDO_DOpct : public Variable { /** * @brief Destroy the AtlasScientificDO_DOpct object - no action needed. */ - ~AtlasScientificDO_DOpct() {} + ~AtlasScientificDO_DOpct() = default; }; /**@}*/ #endif // SRC_SENSORS_ATLASSCIENTIFICDO_H_ diff --git a/src/sensors/AtlasScientificEC.h b/src/sensors/AtlasScientificEC.h index 435a5082b..b52b0c74e 100644 --- a/src/sensors/AtlasScientificEC.h +++ b/src/sensors/AtlasScientificEC.h @@ -357,7 +357,7 @@ class AtlasScientificEC_Cond : public Variable { /** * @brief Destroy the AtlasScientificEC_Cond object - no action needed. */ - ~AtlasScientificEC_Cond() {} + ~AtlasScientificEC_Cond() = default; }; /* clang-format off */ @@ -400,7 +400,7 @@ class AtlasScientificEC_TDS : public Variable { /** * @brief Destroy the AtlasScientificEC_TDS object - no action needed. */ - ~AtlasScientificEC_TDS() {} + ~AtlasScientificEC_TDS() = default; }; /* clang-format off */ @@ -444,7 +444,7 @@ class AtlasScientificEC_Salinity : public Variable { * @brief Destroy the AtlasScientificEC_Salinity() object - no action * needed. */ - ~AtlasScientificEC_Salinity() {} + ~AtlasScientificEC_Salinity() = default; }; /* clang-format off */ @@ -488,7 +488,7 @@ class AtlasScientificEC_SpecificGravity : public Variable { * @brief Destroy the AtlasScientificEC_SpecificGravity() object - no action * needed. */ - ~AtlasScientificEC_SpecificGravity() {} + ~AtlasScientificEC_SpecificGravity() = default; }; /**@}*/ #endif // SRC_SENSORS_ATLASSCIENTIFICEC_H_ diff --git a/src/sensors/AtlasScientificORP.h b/src/sensors/AtlasScientificORP.h index f84a0f4c4..955b4aaec 100644 --- a/src/sensors/AtlasScientificORP.h +++ b/src/sensors/AtlasScientificORP.h @@ -197,7 +197,7 @@ class AtlasScientificORP : public AtlasParent { /** * @brief Destroy the Atlas Scientific ORP object */ - ~AtlasScientificORP() {} + ~AtlasScientificORP() = default; }; @@ -242,7 +242,7 @@ class AtlasScientificORP_Potential : public Variable { * @brief Destroy the AtlasScientificORP_Potential() object - no action * needed. */ - ~AtlasScientificORP_Potential() {} + ~AtlasScientificORP_Potential() = default; }; /**@}*/ #endif // SRC_SENSORS_ATLASSCIENTIFICORP_H_ diff --git a/src/sensors/AtlasScientificRTD.h b/src/sensors/AtlasScientificRTD.h index 8ffad41b1..17ed5f70a 100644 --- a/src/sensors/AtlasScientificRTD.h +++ b/src/sensors/AtlasScientificRTD.h @@ -205,7 +205,7 @@ class AtlasScientificRTD : public AtlasParent { /** * @brief Destroy the Atlas Scientific RTD object */ - ~AtlasScientificRTD() {} + ~AtlasScientificRTD() = default; }; /* clang-format off */ @@ -248,7 +248,7 @@ class AtlasScientificRTD_Temp : public Variable { /** * @brief Destroy the AtlasScientificRTD_Temp object - no action needed. */ - ~AtlasScientificRTD_Temp() {} + ~AtlasScientificRTD_Temp() = default; }; /**@}*/ #endif // SRC_SENSORS_ATLASSCIENTIFICRTD_H_ diff --git a/src/sensors/AtlasScientificpH.h b/src/sensors/AtlasScientificpH.h index 84fd9ee02..e80b4c66f 100644 --- a/src/sensors/AtlasScientificpH.h +++ b/src/sensors/AtlasScientificpH.h @@ -203,7 +203,7 @@ class AtlasScientificpH : public AtlasParent { /** * @brief Destroy the Atlas Scientific pH object */ - ~AtlasScientificpH() {} + ~AtlasScientificpH() = default; }; @@ -249,7 +249,7 @@ class AtlasScientificpH_pH : public Variable { /** * @brief Destroy the AtlasScientificpH_pH object - no action needed. */ - ~AtlasScientificpH_pH() {} + ~AtlasScientificpH_pH() = default; }; /**@}*/ #endif // SRC_SENSORS_ATLASSCIENTIFICPH_H_ diff --git a/src/sensors/BoschBME280.h b/src/sensors/BoschBME280.h index 9c1db2f2e..a355b1ee3 100644 --- a/src/sensors/BoschBME280.h +++ b/src/sensors/BoschBME280.h @@ -378,7 +378,7 @@ class BoschBME280_Temp : public Variable { /** * @brief Destroy the BoschBME280_Temp object - no action needed. */ - ~BoschBME280_Temp() {} + ~BoschBME280_Temp() = default; }; @@ -423,7 +423,7 @@ class BoschBME280_Humidity : public Variable { /** * @brief Destroy the BoschBME280_Humidity object - no action needed. */ - ~BoschBME280_Humidity() {} + ~BoschBME280_Humidity() = default; }; @@ -468,7 +468,7 @@ class BoschBME280_Pressure : public Variable { /** * @brief Destroy the BoschBME280_Pressure object - no action needed. */ - ~BoschBME280_Pressure() {} + ~BoschBME280_Pressure() = default; }; @@ -513,7 +513,7 @@ class BoschBME280_Altitude : public Variable { /** * @brief Destroy the BoschBME280_Altitude object - no action needed. */ - ~BoschBME280_Altitude() {} + ~BoschBME280_Altitude() = default; }; /**@}*/ #endif // SRC_SENSORS_BOSCHBME280_H_ diff --git a/src/sensors/BoschBMP3xx.h b/src/sensors/BoschBMP3xx.h index 3fd9ea7ee..59ef61ce7 100644 --- a/src/sensors/BoschBMP3xx.h +++ b/src/sensors/BoschBMP3xx.h @@ -606,7 +606,7 @@ class BoschBMP3xx_Temp : public Variable { /** * @brief Destroy the BoschBMP3xx_Temp object - no action needed. */ - ~BoschBMP3xx_Temp() {} + ~BoschBMP3xx_Temp() = default; }; @@ -651,7 +651,7 @@ class BoschBMP3xx_Pressure : public Variable { /** * @brief Destroy the BoschBMP3xx_Pressure object - no action needed. */ - ~BoschBMP3xx_Pressure() {} + ~BoschBMP3xx_Pressure() = default; }; @@ -696,7 +696,7 @@ class BoschBMP3xx_Altitude : public Variable { /** * @brief Destroy the BoschBMP3xx_Altitude object - no action needed. */ - ~BoschBMP3xx_Altitude() {} + ~BoschBMP3xx_Altitude() = default; }; /**@}*/ #endif // SRC_SENSORS_BOSCHBMP3XX_H_ diff --git a/src/sensors/CampbellClariVUE10.h b/src/sensors/CampbellClariVUE10.h index c97c127e3..c950a20be 100644 --- a/src/sensors/CampbellClariVUE10.h +++ b/src/sensors/CampbellClariVUE10.h @@ -255,7 +255,7 @@ class CampbellClariVUE10 : public SDI12Sensors { /** * @brief Destroy the Campbell ClariVUE10 object */ - ~CampbellClariVUE10() {} + ~CampbellClariVUE10() = default; }; @@ -303,7 +303,7 @@ class CampbellClariVUE10_Turbidity : public Variable { * @brief Destroy the CampbellClariVUE10_Turbidity object - no action * needed. */ - ~CampbellClariVUE10_Turbidity() {} + ~CampbellClariVUE10_Turbidity() = default; }; @@ -349,7 +349,7 @@ class CampbellClariVUE10_Temp : public Variable { /** * @brief Destroy the CampbellClariVUE10_Temp object - no action needed. */ - ~CampbellClariVUE10_Temp() {} + ~CampbellClariVUE10_Temp() = default; }; @@ -397,7 +397,7 @@ class CampbellClariVUE10_ErrorCode : public Variable { * @brief Destroy the CampbellClariVUE10_ErrorCode object - no action * needed. */ - ~CampbellClariVUE10_ErrorCode() {} + ~CampbellClariVUE10_ErrorCode() = default; }; /**@}*/ #endif // SRC_SENSORS_CAMPBELLCLARIVUE10_H_ diff --git a/src/sensors/CampbellOBS3.h b/src/sensors/CampbellOBS3.h index 9da48559b..918f7fb33 100644 --- a/src/sensors/CampbellOBS3.h +++ b/src/sensors/CampbellOBS3.h @@ -351,7 +351,7 @@ class CampbellOBS3_Turbidity : public Variable { /** * @brief Destroy the Campbell OBS3 Turbidity object */ - ~CampbellOBS3_Turbidity() {} + ~CampbellOBS3_Turbidity() = default; }; @@ -396,7 +396,7 @@ class CampbellOBS3_Voltage : public Variable { /** * @brief Destroy the CampbellOBS3_Voltage object - no action needed. */ - ~CampbellOBS3_Voltage() {} + ~CampbellOBS3_Voltage() = default; }; /**@}*/ #endif // SRC_SENSORS_CAMPBELLOBS3_H_ diff --git a/src/sensors/CampbellRainVUE10.h b/src/sensors/CampbellRainVUE10.h index 0cc1b22f2..ef93e78d7 100644 --- a/src/sensors/CampbellRainVUE10.h +++ b/src/sensors/CampbellRainVUE10.h @@ -294,7 +294,7 @@ class CampbellRainVUE10 : public SDI12Sensors { /** * @brief Destroy the Campbell RainVUE10 object */ - ~CampbellRainVUE10() {} + ~CampbellRainVUE10() = default; }; @@ -342,7 +342,7 @@ class CampbellRainVUE10_Precipitation : public Variable { * @brief Destroy the CampbellRainVUE10_Precipitation object - no action * needed. */ - ~CampbellRainVUE10_Precipitation() {} + ~CampbellRainVUE10_Precipitation() = default; }; @@ -386,7 +386,7 @@ class CampbellRainVUE10_Tips : public Variable { /** * @brief Destroy the CampbellRainVUE10_Tips object - no action needed. */ - ~CampbellRainVUE10_Tips() {} + ~CampbellRainVUE10_Tips() = default; }; @@ -434,7 +434,7 @@ class CampbellRainVUE10_RainRateAve : public Variable { * @brief Destroy the CampbellRainVUE10_RainRateAve object - no action * needed. */ - ~CampbellRainVUE10_RainRateAve() {} + ~CampbellRainVUE10_RainRateAve() = default; }; /* clang-format off */ @@ -483,7 +483,7 @@ class CampbellRainVUE10_RainRateMax : public Variable { * @brief Destroy the CampbellRainVUE10_RainRateMax object - no action * needed. */ - ~CampbellRainVUE10_RainRateMax() {} + ~CampbellRainVUE10_RainRateMax() = default; }; /**@}*/ #endif // SRC_SENSORS_CAMPBELLRAINVUE10_H_ diff --git a/src/sensors/Decagon5TM.h b/src/sensors/Decagon5TM.h index 409a3d654..3eb23a1c0 100644 --- a/src/sensors/Decagon5TM.h +++ b/src/sensors/Decagon5TM.h @@ -283,7 +283,7 @@ class Decagon5TM : public SDI12Sensors { /** * @brief Destroy the Decagon 5TM object */ - ~Decagon5TM() {} + ~Decagon5TM() = default; /** * @copydoc SDI12Sensors::getResults(bool verify_crc) @@ -329,7 +329,7 @@ class Decagon5TM_Ea : public Variable { /** * @brief Destroy the Decagon5TM_Ea object - no action needed. */ - ~Decagon5TM_Ea() {} + ~Decagon5TM_Ea() = default; }; @@ -369,7 +369,7 @@ class Decagon5TM_Temp : public Variable { /** * @brief Destroy the Decagon5TM_Temp object - no action needed. */ - ~Decagon5TM_Temp() {} + ~Decagon5TM_Temp() = default; }; @@ -409,7 +409,7 @@ class Decagon5TM_VWC : public Variable { /** * @brief Destroy the Decagon5TM_VWC object - no action needed. */ - ~Decagon5TM_VWC() {} + ~Decagon5TM_VWC() = default; }; /**@}*/ #endif // SRC_SENSORS_DECAGON5TM_H_ diff --git a/src/sensors/DecagonCTD.h b/src/sensors/DecagonCTD.h index f37d6cf6e..9f50f68f6 100644 --- a/src/sensors/DecagonCTD.h +++ b/src/sensors/DecagonCTD.h @@ -256,7 +256,7 @@ class DecagonCTD : public SDI12Sensors { /** * @brief Destroy the Decagon CTD object */ - ~DecagonCTD() {} + ~DecagonCTD() = default; }; @@ -297,7 +297,7 @@ class DecagonCTD_Cond : public Variable { /** * @brief Destroy the DecagonCTD_Cond object - no action needed. */ - ~DecagonCTD_Cond() {} + ~DecagonCTD_Cond() = default; }; @@ -338,7 +338,7 @@ class DecagonCTD_Temp : public Variable { /** * @brief Destroy the DecagonCTD_Temp object - no action needed. */ - ~DecagonCTD_Temp() {} + ~DecagonCTD_Temp() = default; }; @@ -379,7 +379,7 @@ class DecagonCTD_Depth : public Variable { /** * @brief Destroy the DecagonCTD_Depth object - no action needed. */ - ~DecagonCTD_Depth() {} + ~DecagonCTD_Depth() = default; }; /**@}*/ #endif // SRC_SENSORS_decagon_ctd_H_ diff --git a/src/sensors/DecagonES2.h b/src/sensors/DecagonES2.h index e16f7093b..edf1b8ff6 100644 --- a/src/sensors/DecagonES2.h +++ b/src/sensors/DecagonES2.h @@ -218,7 +218,7 @@ class DecagonES2 : public SDI12Sensors { /** * @brief Destroy the Decagon ES2 object */ - ~DecagonES2() {} + ~DecagonES2() = default; }; @@ -259,7 +259,7 @@ class DecagonES2_Cond : public Variable { /** * @brief Destroy the DecagonES2_Cond object - no action needed. */ - ~DecagonES2_Cond() {} + ~DecagonES2_Cond() = default; }; /* clang-format off */ @@ -299,7 +299,7 @@ class DecagonES2_Temp : public Variable { /** * @brief Destroy the DecagonES2_Temp object - no action needed. */ - ~DecagonES2_Temp() {} + ~DecagonES2_Temp() = default; }; /**@}*/ #endif // SRC_SENSORS_DECAGONES2_H_ diff --git a/src/sensors/EverlightALSPT19.h b/src/sensors/EverlightALSPT19.h index 217a3a361..4f1f25db3 100644 --- a/src/sensors/EverlightALSPT19.h +++ b/src/sensors/EverlightALSPT19.h @@ -371,7 +371,7 @@ class EverlightALSPT19_Voltage : public Variable { /** * @brief Destroy the EverlightALSPT19_Voltage object - no action needed. */ - ~EverlightALSPT19_Voltage() {} + ~EverlightALSPT19_Voltage() = default; }; @@ -415,7 +415,7 @@ class EverlightALSPT19_Current : public Variable { /** * @brief Destroy the EverlightALSPT19_Current object - no action needed. */ - ~EverlightALSPT19_Current() {} + ~EverlightALSPT19_Current() = default; }; @@ -460,7 +460,7 @@ class EverlightALSPT19_Illuminance : public Variable { * @brief Destroy the EverlightALSPT19_Illuminance object - no action * needed. */ - ~EverlightALSPT19_Illuminance() {} + ~EverlightALSPT19_Illuminance() = default; }; /**@}*/ #endif // SRC_SENSORS_EVERLIGHTALSPT19_H_ diff --git a/src/sensors/FreescaleMPL115A2.h b/src/sensors/FreescaleMPL115A2.h index dd5a45f8c..21543c654 100644 --- a/src/sensors/FreescaleMPL115A2.h +++ b/src/sensors/FreescaleMPL115A2.h @@ -299,7 +299,7 @@ class FreescaleMPL115A2_Temp : public Variable { /** * @brief Destroy the FreescaleMPL115A2_Temp object - no action needed. */ - ~FreescaleMPL115A2_Temp() {} + ~FreescaleMPL115A2_Temp() = default; }; /** @@ -353,7 +353,7 @@ class FreescaleMPL115A2_Pressure : public Variable { /** * @brief Destroy the FreescaleMPL115A2_Pressure object - no action needed. */ - ~FreescaleMPL115A2_Pressure() {} + ~FreescaleMPL115A2_Pressure() = default; }; /** diff --git a/src/sensors/GeoluxHydroCam.h b/src/sensors/GeoluxHydroCam.h index a42865e1f..c5d09e4a0 100644 --- a/src/sensors/GeoluxHydroCam.h +++ b/src/sensors/GeoluxHydroCam.h @@ -459,7 +459,7 @@ class GeoluxHydroCam_ImageSize : public Variable { /** * @brief Destroy the GeoluxHydroCam_ImageSize object - no action needed. */ - ~GeoluxHydroCam_ImageSize() {} + ~GeoluxHydroCam_ImageSize() = default; }; @@ -504,7 +504,7 @@ class GeoluxHydroCam_ByteError : public Variable { * @brief Destroy the GeoluxHydroCam_ByteError object - no action * needed. */ - ~GeoluxHydroCam_ByteError() {} + ~GeoluxHydroCam_ByteError() = default; }; /**@}*/ #endif // SRC_SENSORS_GEOLUXHYDROCAM_H_ diff --git a/src/sensors/GroPointGPLP8.h b/src/sensors/GroPointGPLP8.h index 254b3040d..e4ebdafa1 100644 --- a/src/sensors/GroPointGPLP8.h +++ b/src/sensors/GroPointGPLP8.h @@ -193,7 +193,7 @@ class GroPointGPLP8 : public GroPointParent { /** * @brief Destroy the GroPoint GPLP8 object */ - ~GroPointGPLP8() {} + ~GroPointGPLP8() = default; }; @@ -247,7 +247,7 @@ class GroPointGPLP8_Moist : public Variable { /** * @brief Destroy the GroPointGPLP8_Moist object - no action needed. */ - ~GroPointGPLP8_Moist() {} + ~GroPointGPLP8_Moist() = default; }; /* clang-format off */ @@ -299,7 +299,7 @@ class GroPointGPLP8_Temp : public Variable { /** * @brief Destroy the GroPointGPLP8_Temp object - no action needed. */ - ~GroPointGPLP8_Temp() {} + ~GroPointGPLP8_Temp() = default; }; /**@}*/ diff --git a/src/sensors/InSituRDO.h b/src/sensors/InSituRDO.h index 5cb8cd704..9590a79cc 100644 --- a/src/sensors/InSituRDO.h +++ b/src/sensors/InSituRDO.h @@ -413,7 +413,7 @@ class InSituRDO : public SDI12Sensors { /** * @brief Destroy the In-Situ RDO object */ - ~InSituRDO() {} + ~InSituRDO() = default; }; @@ -459,7 +459,7 @@ class InSituRDO_DOmgL : public Variable { /** * @brief Destroy the InSituRDO_DOmgL object - no action needed. */ - ~InSituRDO_DOmgL() {} + ~InSituRDO_DOmgL() = default; }; @@ -505,7 +505,7 @@ class InSituRDO_DOpct : public Variable { /** * @brief Destroy the InSituRDO_DOpct object - no action needed. */ - ~InSituRDO_DOpct() {} + ~InSituRDO_DOpct() = default; }; @@ -550,7 +550,7 @@ class InSituRDO_Temp : public Variable { /** * @brief Destroy the InSituRDO_Temp object - no action needed. */ - ~InSituRDO_Temp() {} + ~InSituRDO_Temp() = default; }; @@ -596,7 +596,7 @@ class InSituRDO_Pressure : public Variable { /** * @brief Destroy the InSituRDO_Pressure object - no action needed. */ - ~InSituRDO_Pressure() {} + ~InSituRDO_Pressure() = default; }; /**@}*/ #endif // SRC_SENSORS_INSITURDO_H_ diff --git a/src/sensors/InSituTrollSdi12a.h b/src/sensors/InSituTrollSdi12a.h index 801a26b90..1b6ed8d47 100644 --- a/src/sensors/InSituTrollSdi12a.h +++ b/src/sensors/InSituTrollSdi12a.h @@ -270,7 +270,7 @@ class InSituTrollSdi12a : public SDI12Sensors { /** * @brief Destroy the ITROLL object */ - ~InSituTrollSdi12a() {} + ~InSituTrollSdi12a() = default; }; @@ -315,7 +315,7 @@ class InSituTrollSdi12a_Pressure : public Variable { /** * @brief Destroy the InSituTrollSdi12a_Pressure object - no action needed. */ - ~InSituTrollSdi12a_Pressure() {} + ~InSituTrollSdi12a_Pressure() = default; }; @@ -358,7 +358,7 @@ class InSituTrollSdi12a_Temp : public Variable { /** * @brief Destroy the InSituTrollSdi12a_Temp object - no action needed. */ - ~InSituTrollSdi12a_Temp() {} + ~InSituTrollSdi12a_Temp() = default; }; @@ -400,7 +400,7 @@ class InSituTrollSdi12a_Depth : public Variable { /** * @brief Destroy the InSituTrollSdi12a_Depth object - no action needed. */ - ~InSituTrollSdi12a_Depth() {} + ~InSituTrollSdi12a_Depth() = default; }; /**@}*/ diff --git a/src/sensors/KellerAcculevel.h b/src/sensors/KellerAcculevel.h index a2303c753..adb2c1e23 100644 --- a/src/sensors/KellerAcculevel.h +++ b/src/sensors/KellerAcculevel.h @@ -179,7 +179,7 @@ class KellerAcculevel : public KellerParent { /** * @brief Destroy the Keller Acculevel object */ - ~KellerAcculevel() {} + ~KellerAcculevel() = default; }; @@ -225,7 +225,7 @@ class KellerAcculevel_Pressure : public Variable { /** * @brief Destroy the KellerAcculevel_Pressure object - no action needed. */ - ~KellerAcculevel_Pressure() {} + ~KellerAcculevel_Pressure() = default; }; @@ -269,7 +269,7 @@ class KellerAcculevel_Temp : public Variable { /** * @brief Destroy the KellerAcculevel_Temp object - no action needed. */ - ~KellerAcculevel_Temp() {} + ~KellerAcculevel_Temp() = default; }; @@ -313,7 +313,7 @@ class KellerAcculevel_Height : public Variable { /** * @brief Destroy the KellerAcculevel_Height object - no action needed. */ - ~KellerAcculevel_Height() {} + ~KellerAcculevel_Height() = default; }; /**@}*/ #endif // SRC_SENSORS_KELLERACCULEVEL_H_ diff --git a/src/sensors/KellerNanolevel.h b/src/sensors/KellerNanolevel.h index 99da9a657..990fb7aa1 100644 --- a/src/sensors/KellerNanolevel.h +++ b/src/sensors/KellerNanolevel.h @@ -171,7 +171,7 @@ class KellerNanolevel : public KellerParent { /** * @brief Destroy the Keller Nanolevel object */ - ~KellerNanolevel() {} + ~KellerNanolevel() = default; }; @@ -217,7 +217,7 @@ class KellerNanolevel_Pressure : public Variable { /** * @brief Destroy the KellerNanolevel_Pressure object - no action needed. */ - ~KellerNanolevel_Pressure() {} + ~KellerNanolevel_Pressure() = default; }; @@ -261,7 +261,7 @@ class KellerNanolevel_Temp : public Variable { /** * @brief Destroy the KellerNanolevel_Temp object - no action needed. */ - ~KellerNanolevel_Temp() {} + ~KellerNanolevel_Temp() = default; }; @@ -305,7 +305,7 @@ class KellerNanolevel_Height : public Variable { /** * @brief Destroy the KellerNanolevel_Height object - no action needed. */ - ~KellerNanolevel_Height() {} + ~KellerNanolevel_Height() = default; }; /**@}*/ #endif // SRC_SENSORS_KELLERNANOLEVEL_H_ diff --git a/src/sensors/MaxBotixSonar.h b/src/sensors/MaxBotixSonar.h index a50acc531..a18a4eb92 100644 --- a/src/sensors/MaxBotixSonar.h +++ b/src/sensors/MaxBotixSonar.h @@ -311,7 +311,7 @@ class MaxBotixSonar_Range : public Variable { /** * @brief Destroy the MaxBotixSonar_Range object - no action needed. */ - ~MaxBotixSonar_Range() {} + ~MaxBotixSonar_Range() = default; }; /**@}*/ #endif // SRC_SENSORS_MAXBOTIXSONAR_H_ diff --git a/src/sensors/MaximDS18.h b/src/sensors/MaximDS18.h index ea16c1a21..0f3c31e38 100644 --- a/src/sensors/MaximDS18.h +++ b/src/sensors/MaximDS18.h @@ -324,7 +324,7 @@ class MaximDS18_Temp : public Variable { /** * @brief Destroy the MaximDS18_Temp object - no action needed. */ - ~MaximDS18_Temp() {} + ~MaximDS18_Temp() = default; }; /**@}*/ #endif // SRC_SENSORS_MAXIMDS18_H_ diff --git a/src/sensors/MaximDS3231.h b/src/sensors/MaximDS3231.h index 26026a442..ce2be6531 100644 --- a/src/sensors/MaximDS3231.h +++ b/src/sensors/MaximDS3231.h @@ -236,7 +236,7 @@ class MaximDS3231_Temp : public Variable { /** * @brief Destroy the MaximDS3231_Temp object - no action needed. */ - ~MaximDS3231_Temp() {} + ~MaximDS3231_Temp() = default; }; /**@}*/ #endif // SRC_SENSORS_MAXIMDS3231_H_ diff --git a/src/sensors/MeaSpecMS5803.h b/src/sensors/MeaSpecMS5803.h index 4ddd672d9..c44dcc79b 100644 --- a/src/sensors/MeaSpecMS5803.h +++ b/src/sensors/MeaSpecMS5803.h @@ -311,7 +311,7 @@ class MeaSpecMS5803_Temp : public Variable { /** * @brief Destroy the MeaSpecMS5803_Temp object - no action needed. */ - ~MeaSpecMS5803_Temp() {} + ~MeaSpecMS5803_Temp() = default; }; @@ -358,7 +358,7 @@ class MeaSpecMS5803_Pressure : public Variable { /** * @brief Destroy the MeaSpecMS5803_Pressure object - no action needed. */ - ~MeaSpecMS5803_Pressure() {} + ~MeaSpecMS5803_Pressure() = default; }; /**@}*/ #endif // SRC_SENSORS_MEASPECMS5803_H_ diff --git a/src/sensors/MeterHydros21.h b/src/sensors/MeterHydros21.h index f335233be..e0b2c3085 100644 --- a/src/sensors/MeterHydros21.h +++ b/src/sensors/MeterHydros21.h @@ -277,7 +277,7 @@ class MeterHydros21 : public SDI12Sensors { /** * @brief Destroy the Meter Hydros 21 object */ - ~MeterHydros21() {} + ~MeterHydros21() = default; }; @@ -320,7 +320,7 @@ class MeterHydros21_Cond : public Variable { /** * @brief Destroy the MeterHydros21_Cond object - no action needed. */ - ~MeterHydros21_Cond() {} + ~MeterHydros21_Cond() = default; }; @@ -363,7 +363,7 @@ class MeterHydros21_Temp : public Variable { /** * @brief Destroy the MeterHydros21_Temp object - no action needed. */ - ~MeterHydros21_Temp() {} + ~MeterHydros21_Temp() = default; }; @@ -406,7 +406,7 @@ class MeterHydros21_Depth : public Variable { /** * @brief Destroy the MeterHydros21_Depth object - no action needed. */ - ~MeterHydros21_Depth() {} + ~MeterHydros21_Depth() = default; }; /**@}*/ #endif // SRC_SENSORS_METERHYDROS21_H_ diff --git a/src/sensors/MeterTeros11.h b/src/sensors/MeterTeros11.h index 18f737e96..a8f075ba5 100644 --- a/src/sensors/MeterTeros11.h +++ b/src/sensors/MeterTeros11.h @@ -330,7 +330,7 @@ class MeterTeros11 : public SDI12Sensors { /** * @brief Destroy the Meter Teros 11 object */ - ~MeterTeros11() {} + ~MeterTeros11() = default; /** * @copydoc SDI12Sensors::getResults(bool verify_crc) @@ -379,7 +379,7 @@ class MeterTeros11_Count : public Variable { /** * @brief Destroy the MeterTeros11_Count object - no action needed. */ - ~MeterTeros11_Count() {} + ~MeterTeros11_Count() = default; }; @@ -421,7 +421,7 @@ class MeterTeros11_Temp : public Variable { /** * @brief Destroy the MeterTeros11_Temp object - no action needed. */ - ~MeterTeros11_Temp() {} + ~MeterTeros11_Temp() = default; }; @@ -464,7 +464,7 @@ class MeterTeros11_Ea : public Variable { /** * @brief Destroy the MeterTeros11_Ea object - no action needed. */ - ~MeterTeros11_Ea() {} + ~MeterTeros11_Ea() = default; }; @@ -506,7 +506,7 @@ class MeterTeros11_VWC : public Variable { /** * @brief Destroy the MeterTeros11_VWC object - no action needed. */ - ~MeterTeros11_VWC() {} + ~MeterTeros11_VWC() = default; }; /**@}*/ #endif // SRC_SENSORS_METERTEROS11_H_ diff --git a/src/sensors/PaleoTerraRedox.h b/src/sensors/PaleoTerraRedox.h index 4f86b204c..e2a53719a 100644 --- a/src/sensors/PaleoTerraRedox.h +++ b/src/sensors/PaleoTerraRedox.h @@ -337,7 +337,7 @@ class PaleoTerraRedox_Voltage : public Variable { /** * @brief Destroy the PaleoTerraRedox_Voltage object - no action needed. */ - ~PaleoTerraRedox_Voltage() {} + ~PaleoTerraRedox_Voltage() = default; }; /** diff --git a/src/sensors/ProcessorAnalog.h b/src/sensors/ProcessorAnalog.h index 6f57ac81e..d374a4583 100644 --- a/src/sensors/ProcessorAnalog.h +++ b/src/sensors/ProcessorAnalog.h @@ -343,7 +343,7 @@ class ProcessorAnalog_Voltage : public Variable { /** * @brief Destroy the ProcessorAnalog_Voltage object - no action needed. */ - ~ProcessorAnalog_Voltage() {} + ~ProcessorAnalog_Voltage() = default; }; /**@}*/ diff --git a/src/sensors/ProcessorStats.h b/src/sensors/ProcessorStats.h index 38c9aeb1f..a2a91531f 100644 --- a/src/sensors/ProcessorStats.h +++ b/src/sensors/ProcessorStats.h @@ -407,7 +407,7 @@ class ProcessorStats_Battery : public Variable { /** * @brief Destroy the ProcessorStats_Battery object - no action needed. */ - ~ProcessorStats_Battery() {} + ~ProcessorStats_Battery() = default; }; @@ -458,7 +458,7 @@ class ProcessorStats_FreeRam : public Variable { /** * @brief Destroy the ProcessorStats_FreeRam object - no action needed. */ - ~ProcessorStats_FreeRam() {} + ~ProcessorStats_FreeRam() = default; }; @@ -508,7 +508,7 @@ class ProcessorStats_SampleNumber : public Variable { * @brief Destroy the ProcessorStats_SampleNumber() object - no action * needed. */ - ~ProcessorStats_SampleNumber() {} + ~ProcessorStats_SampleNumber() = default; }; @@ -558,7 +558,7 @@ class ProcessorStats_ResetCode : public Variable { /** * @brief Destroy the ProcessorStats_ResetCode object - no action needed. */ - ~ProcessorStats_ResetCode() {} + ~ProcessorStats_ResetCode() = default; }; /**@}*/ #endif // SRC_SENSORS_PROCESSORSTATS_H_ diff --git a/src/sensors/RainCounterI2C.h b/src/sensors/RainCounterI2C.h index 9e274cbc3..1358e54ab 100644 --- a/src/sensors/RainCounterI2C.h +++ b/src/sensors/RainCounterI2C.h @@ -357,7 +357,7 @@ class RainCounterI2C_Tips : public Variable { /** * @brief Destroy the RainCounterI2C_Tips object - no action needed. */ - ~RainCounterI2C_Tips() {} + ~RainCounterI2C_Tips() = default; }; /** @@ -399,7 +399,7 @@ class RainCounterI2C_Depth : public Variable { /** * @brief Destroy the RainCounterI2C_Depth object - no action needed. */ - ~RainCounterI2C_Depth() {} + ~RainCounterI2C_Depth() = default; }; /**@}*/ #endif // SRC_SENSORS_RAINCOUNTERI2C_H_ diff --git a/src/sensors/SensirionSHT4x.h b/src/sensors/SensirionSHT4x.h index 19c8aca54..32dc1f260 100644 --- a/src/sensors/SensirionSHT4x.h +++ b/src/sensors/SensirionSHT4x.h @@ -338,7 +338,7 @@ class SensirionSHT4x_Humidity : public Variable { /** * @brief Destroy the SensirionSHT4x_Humidity object - no action needed. */ - ~SensirionSHT4x_Humidity() {} + ~SensirionSHT4x_Humidity() = default; }; @@ -380,7 +380,7 @@ class SensirionSHT4x_Temp : public Variable { /** * @brief Destroy the SensirionSHT4x_Temp object - no action needed. */ - ~SensirionSHT4x_Temp() {} + ~SensirionSHT4x_Temp() = default; }; /**@}*/ #endif // SRC_SENSORS_SENSIRIONSHT4X_H_ diff --git a/src/sensors/TEConnectivityMS5837.h b/src/sensors/TEConnectivityMS5837.h index d22363532..d21169b64 100644 --- a/src/sensors/TEConnectivityMS5837.h +++ b/src/sensors/TEConnectivityMS5837.h @@ -592,7 +592,7 @@ class TEConnectivityMS5837_Temp : public Variable { /** * @brief Destroy the TEConnectivityMS5837_Temp object - no action needed. */ - ~TEConnectivityMS5837_Temp() {} + ~TEConnectivityMS5837_Temp() = default; }; @@ -639,7 +639,7 @@ class TEConnectivityMS5837_Pressure : public Variable { * @brief Destroy the TEConnectivityMS5837_Pressure object - no action * needed. */ - ~TEConnectivityMS5837_Pressure() {} + ~TEConnectivityMS5837_Pressure() = default; }; @@ -683,7 +683,7 @@ class TEConnectivityMS5837_Depth : public Variable { /** * @brief Destroy the TEConnectivityMS5837_Depth object - no action needed. */ - ~TEConnectivityMS5837_Depth() {} + ~TEConnectivityMS5837_Depth() = default; }; @@ -730,7 +730,7 @@ class TEConnectivityMS5837_Altitude : public Variable { * @brief Destroy the TEConnectivityMS5837_Altitude object - no action * needed. */ - ~TEConnectivityMS5837_Altitude() {} + ~TEConnectivityMS5837_Altitude() = default; }; /**@}*/ #endif // SRC_SENSORS_TECONNECTIVITYMS5837_H_ diff --git a/src/sensors/TIADS1x15.h b/src/sensors/TIADS1x15.h index 6f2d80abc..a080c06c4 100644 --- a/src/sensors/TIADS1x15.h +++ b/src/sensors/TIADS1x15.h @@ -595,7 +595,7 @@ class TIADS1x15_Voltage : public Variable { /** * @brief Destroy the TIADS1x15_Voltage object - no action needed. */ - ~TIADS1x15_Voltage() {} + ~TIADS1x15_Voltage() = default; }; /** diff --git a/src/sensors/TIINA219.h b/src/sensors/TIINA219.h index 5dc117dfe..6981a30b1 100644 --- a/src/sensors/TIINA219.h +++ b/src/sensors/TIINA219.h @@ -351,7 +351,7 @@ class TIINA219_Current : public Variable { /** * @brief Destroy the TIINA219_Current object - no action needed. */ - ~TIINA219_Current() {} + ~TIINA219_Current() = default; }; @@ -394,7 +394,7 @@ class TIINA219_Voltage : public Variable { /** * @brief Destroy the TIINA219_Voltage object - no action needed. */ - ~TIINA219_Voltage() {} + ~TIINA219_Voltage() = default; }; /** @@ -445,7 +445,7 @@ class TIINA219_Power : public Variable { /** * @brief Destroy the TIINA219_Power object - no action needed. */ - ~TIINA219_Power() {} + ~TIINA219_Power() = default; }; /**@}*/ #endif // SRC_SENSORS_TIINA219_H_ diff --git a/src/sensors/TallyCounterI2C.h b/src/sensors/TallyCounterI2C.h index 7e9783fa5..6f9fd1ddb 100644 --- a/src/sensors/TallyCounterI2C.h +++ b/src/sensors/TallyCounterI2C.h @@ -274,7 +274,7 @@ class TallyCounterI2C_Events : public Variable { /** * @brief Destroy the BoschBME280_Temp object - no action needed. */ - ~TallyCounterI2C_Events() {} + ~TallyCounterI2C_Events() = default; }; /**@}*/ #endif // SRC_SENSORS_TallyCounterI2C_H_ diff --git a/src/sensors/TurnerCyclops.h b/src/sensors/TurnerCyclops.h index a66ca689f..44862fab3 100644 --- a/src/sensors/TurnerCyclops.h +++ b/src/sensors/TurnerCyclops.h @@ -456,7 +456,7 @@ class TurnerCyclops_Voltage : public Variable { /** * @brief Destroy the Turner Cyclops Voltage object - no action needed. */ - ~TurnerCyclops_Voltage() {} + ~TurnerCyclops_Voltage() = default; }; @@ -514,7 +514,7 @@ class TurnerCyclops_Chlorophyll : public Variable { * @brief Destroy the Turner Cyclops Chlorophyll variable object - no action * needed. */ - ~TurnerCyclops_Chlorophyll() {} + ~TurnerCyclops_Chlorophyll() = default; }; @@ -571,7 +571,7 @@ class TurnerCyclops_Rhodamine : public Variable { * @brief Destroy the Turner Cyclops Rhodamine variable object - no action * needed. */ - ~TurnerCyclops_Rhodamine() {} + ~TurnerCyclops_Rhodamine() = default; }; @@ -627,7 +627,7 @@ class TurnerCyclops_Fluorescein : public Variable { * @brief Destroy the Turner Cyclops Fluorescein variable object - no action * needed. */ - ~TurnerCyclops_Fluorescein() {} + ~TurnerCyclops_Fluorescein() = default; }; @@ -686,7 +686,7 @@ class TurnerCyclops_Phycocyanin : public Variable { * @brief Destroy the Turner Cyclops Phycocyanin variable object - no action * needed. */ - ~TurnerCyclops_Phycocyanin() {} + ~TurnerCyclops_Phycocyanin() = default; }; @@ -743,7 +743,7 @@ class TurnerCyclops_Phycoerythrin : public Variable { * @brief Destroy the Turner Cyclops Phycoerythrin variable object - no * action needed. */ - ~TurnerCyclops_Phycoerythrin() {} + ~TurnerCyclops_Phycoerythrin() = default; }; @@ -805,7 +805,7 @@ class TurnerCyclops_CDOM : public Variable { * @brief Destroy the Turner Cyclops CDOM variable object - no action * needed. */ - ~TurnerCyclops_CDOM() {} + ~TurnerCyclops_CDOM() = default; }; @@ -864,7 +864,7 @@ class TurnerCyclops_CrudeOil : public Variable { * @brief Destroy the Turner Cyclops CrudeOil variable object - no action * needed. */ - ~TurnerCyclops_CrudeOil() {} + ~TurnerCyclops_CrudeOil() = default; }; @@ -923,7 +923,7 @@ class TurnerCyclops_Brighteners : public Variable { /** * @brief Destroy the Turner Cyclops Brighteners object - no action needed. */ - ~TurnerCyclops_Brighteners() {} + ~TurnerCyclops_Brighteners() = default; }; @@ -980,7 +980,7 @@ class TurnerCyclops_Turbidity : public Variable { * @brief Destroy the Turner Cyclops Turbidity variable object - no action * needed. */ - ~TurnerCyclops_Turbidity() {} + ~TurnerCyclops_Turbidity() = default; }; @@ -1037,7 +1037,7 @@ class TurnerCyclops_PTSA : public Variable { * @brief Destroy the Turner Cyclops PTSA variable object - no action * needed. */ - ~TurnerCyclops_PTSA() {} + ~TurnerCyclops_PTSA() = default; }; @@ -1094,7 +1094,7 @@ class TurnerCyclops_BTEX : public Variable { * @brief Destroy the Turner Cyclops BTEX variable object - no action * needed. */ - ~TurnerCyclops_BTEX() {} + ~TurnerCyclops_BTEX() = default; }; @@ -1150,7 +1150,7 @@ class TurnerCyclops_Tryptophan : public Variable { * @brief Destroy the Turner Cyclops Tryptophan variable object - no action * needed. */ - ~TurnerCyclops_Tryptophan() {} + ~TurnerCyclops_Tryptophan() = default; }; @@ -1208,7 +1208,7 @@ class TurnerCyclops_RedChlorophyll : public Variable { * @brief Destroy the Turner Cyclops Red Chlorophyll variable object - no * action needed. */ - ~TurnerCyclops_RedChlorophyll() {} + ~TurnerCyclops_RedChlorophyll() = default; }; /**@}*/ #endif // SRC_SENSORS_TURNERCYCLOPS_H_ diff --git a/src/sensors/TurnerTurbidityPlus.h b/src/sensors/TurnerTurbidityPlus.h index 90a3184b4..dad8d7c3b 100644 --- a/src/sensors/TurnerTurbidityPlus.h +++ b/src/sensors/TurnerTurbidityPlus.h @@ -397,7 +397,7 @@ class TurnerTurbidityPlus_Voltage : public Variable { /** * @brief Destroy the TurnerTurbidityPlus_Voltage object - no action needed. */ - ~TurnerTurbidityPlus_Voltage() {} + ~TurnerTurbidityPlus_Voltage() = default; }; @@ -444,7 +444,7 @@ class TurnerTurbidityPlus_Turbidity : public Variable { * @brief Destroy the TurnerTurbidityPlus_Turbidity object - no action * needed. */ - ~TurnerTurbidityPlus_Turbidity() {} + ~TurnerTurbidityPlus_Turbidity() = default; }; /**@}*/ diff --git a/src/sensors/VegaPuls21.h b/src/sensors/VegaPuls21.h index a428a5a02..e75919485 100644 --- a/src/sensors/VegaPuls21.h +++ b/src/sensors/VegaPuls21.h @@ -298,7 +298,7 @@ class VegaPuls21 : public SDI12Sensors { /** * @brief Destroy the VEGAPULS C 21 object */ - ~VegaPuls21() {} + ~VegaPuls21() = default; }; @@ -344,7 +344,7 @@ class VegaPuls21_Stage : public Variable { /** * @brief Destroy the VegaPuls21_Stage object - no action needed. */ - ~VegaPuls21_Stage() {} + ~VegaPuls21_Stage() = default; }; @@ -390,7 +390,7 @@ class VegaPuls21_Distance : public Variable { /** * @brief Destroy the VegaPuls21_Distance object - no action needed. */ - ~VegaPuls21_Distance() {} + ~VegaPuls21_Distance() = default; }; @@ -435,7 +435,7 @@ class VegaPuls21_Temp : public Variable { /** * @brief Destroy the VegaPuls21_Temp object - no action needed. */ - ~VegaPuls21_Temp() {} + ~VegaPuls21_Temp() = default; }; @@ -483,7 +483,7 @@ class VegaPuls21_Reliability : public Variable { * @brief Destroy the VegaPuls21_Reliability object - no action * needed. */ - ~VegaPuls21_Reliability() {} + ~VegaPuls21_Reliability() = default; }; @@ -531,7 +531,7 @@ class VegaPuls21_ErrorCode : public Variable { * @brief Destroy the VegaPuls21_ErrorCode object - no action * needed. */ - ~VegaPuls21_ErrorCode() {} + ~VegaPuls21_ErrorCode() = default; }; /**@}*/ #endif // SRC_SENSORS_VEGAPULS21_H_ diff --git a/src/sensors/YosemitechY4000.h b/src/sensors/YosemitechY4000.h index 05c5fb090..18a5a3f30 100644 --- a/src/sensors/YosemitechY4000.h +++ b/src/sensors/YosemitechY4000.h @@ -373,7 +373,7 @@ class YosemitechY4000 : public YosemitechParent { /** * @brief Destroy the Yosemitech Y4000 object */ - ~YosemitechY4000() {} + ~YosemitechY4000() = default; }; @@ -417,7 +417,7 @@ class YosemitechY4000_DOmgL : public Variable { /** * @brief Destroy the YosemitechY4000_DOmgL object - no action needed. */ - ~YosemitechY4000_DOmgL() {} + ~YosemitechY4000_DOmgL() = default; }; /* clang-format off */ @@ -460,7 +460,7 @@ class YosemitechY4000_Turbidity : public Variable { /** * @brief Destroy the YosemitechY4000_Turbidity object - no action needed. */ - ~YosemitechY4000_Turbidity() {} + ~YosemitechY4000_Turbidity() = default; }; /* clang-format off */ @@ -503,7 +503,7 @@ class YosemitechY4000_Cond : public Variable { /** * @brief Destroy the YosemitechY4000_Cond object - no action needed. */ - ~YosemitechY4000_Cond() {} + ~YosemitechY4000_Cond() = default; }; /* clang-format off */ @@ -546,7 +546,7 @@ class YosemitechY4000_pH : public Variable { /** * @brief Destroy the YosemitechY4000_pH object - no action needed. */ - ~YosemitechY4000_pH() {} + ~YosemitechY4000_pH() = default; }; /* clang-format off */ @@ -589,7 +589,7 @@ class YosemitechY4000_Temp : public Variable { /** * @brief Destroy the YosemitechY4000_Temp object - no action needed. */ - ~YosemitechY4000_Temp() {} + ~YosemitechY4000_Temp() = default; }; /* clang-format off */ @@ -632,7 +632,7 @@ class YosemitechY4000_ORP : public Variable { /** * @brief Destroy the YosemitechY4000_ORP object - no action needed. */ - ~YosemitechY4000_ORP() {} + ~YosemitechY4000_ORP() = default; }; /* clang-format off */ @@ -676,7 +676,7 @@ class YosemitechY4000_Chlorophyll : public Variable { * @brief Destroy the YosemitechY4000_Chlorophyll() object - no action * needed. */ - ~YosemitechY4000_Chlorophyll() {} + ~YosemitechY4000_Chlorophyll() = default; }; /* clang-format off */ @@ -719,7 +719,7 @@ class YosemitechY4000_BGA : public Variable { /** * @brief Destroy the YosemitechY4000_BGA object - no action needed. */ - ~YosemitechY4000_BGA() {} + ~YosemitechY4000_BGA() = default; }; /**@}*/ #endif // SRC_SENSORS_YOSEMITECHY4000_H_ diff --git a/src/sensors/YosemitechY504.h b/src/sensors/YosemitechY504.h index dc7897432..8703942c2 100644 --- a/src/sensors/YosemitechY504.h +++ b/src/sensors/YosemitechY504.h @@ -227,7 +227,7 @@ class YosemitechY504 : public YosemitechParent { /** * @brief Destroy the Yosemitech Y504 object */ - ~YosemitechY504() {} + ~YosemitechY504() = default; }; @@ -271,7 +271,7 @@ class YosemitechY504_DOpct : public Variable { /** * @brief Destroy the YosemitechY504_DOpct object - no action needed. */ - ~YosemitechY504_DOpct() {} + ~YosemitechY504_DOpct() = default; }; @@ -315,7 +315,7 @@ class YosemitechY504_Temp : public Variable { /** * @brief Destroy the YosemitechY504_Temp object - no action needed. */ - ~YosemitechY504_Temp() {} + ~YosemitechY504_Temp() = default; }; @@ -359,7 +359,7 @@ class YosemitechY504_DOmgL : public Variable { /** * @brief Destroy the YosemitechY504_DOmgL object - no action needed. */ - ~YosemitechY504_DOmgL() {} + ~YosemitechY504_DOmgL() = default; }; /**@}*/ #endif // SRC_SENSORS_YOSEMITECHY504_H_ diff --git a/src/sensors/YosemitechY510.h b/src/sensors/YosemitechY510.h index 40b94bc38..1532e1b44 100644 --- a/src/sensors/YosemitechY510.h +++ b/src/sensors/YosemitechY510.h @@ -193,7 +193,7 @@ class YosemitechY510 : public YosemitechParent { /** * @brief Destroy the Yosemitech Y510 object */ - ~YosemitechY510() {} + ~YosemitechY510() = default; }; @@ -237,7 +237,7 @@ class YosemitechY510_Turbidity : public Variable { /** * @brief Destroy the YosemitechY510_Turbidity object - no action needed. */ - ~YosemitechY510_Turbidity() {} + ~YosemitechY510_Turbidity() = default; }; @@ -281,7 +281,7 @@ class YosemitechY510_Temp : public Variable { /** * @brief Destroy the YosemitechY510_Temp object - no action needed. */ - ~YosemitechY510_Temp() {} + ~YosemitechY510_Temp() = default; }; /**@}*/ #endif // SRC_SENSORS_YOSEMITECHY510_H_ diff --git a/src/sensors/YosemitechY511.h b/src/sensors/YosemitechY511.h index 10465d998..75e902bce 100644 --- a/src/sensors/YosemitechY511.h +++ b/src/sensors/YosemitechY511.h @@ -207,7 +207,7 @@ class YosemitechY511 : public YosemitechParent { /** * @brief Destroy the Yosemitech Y511 object */ - ~YosemitechY511() {} + ~YosemitechY511() = default; }; @@ -251,7 +251,7 @@ class YosemitechY511_Turbidity : public Variable { /** * @brief Destroy the YosemitechY511_Turbidity object - no action needed. */ - ~YosemitechY511_Turbidity() {} + ~YosemitechY511_Turbidity() = default; }; @@ -295,7 +295,7 @@ class YosemitechY511_Temp : public Variable { /** * @brief Destroy the YosemitechY511_Temp object - no action needed. */ - ~YosemitechY511_Temp() {} + ~YosemitechY511_Temp() = default; }; /**@}*/ #endif // SRC_SENSORS_YOSEMITECHY511_H_ diff --git a/src/sensors/YosemitechY513.h b/src/sensors/YosemitechY513.h index bf163e380..dd37f44f5 100644 --- a/src/sensors/YosemitechY513.h +++ b/src/sensors/YosemitechY513.h @@ -194,7 +194,7 @@ class YosemitechY513 : public YosemitechParent { /** * @brief Destroy the Yosemitech Y513 object */ - ~YosemitechY513() {} + ~YosemitechY513() = default; }; @@ -239,7 +239,7 @@ class YosemitechY513_BGA : public Variable { * @brief Destroy the YosemitechY513_BGA() object - no action * needed. */ - ~YosemitechY513_BGA() {} + ~YosemitechY513_BGA() = default; }; @@ -283,7 +283,7 @@ class YosemitechY513_Temp : public Variable { /** * @brief Destroy the YosemitechY513_Temp object - no action needed. */ - ~YosemitechY513_Temp() {} + ~YosemitechY513_Temp() = default; }; /**@}*/ #endif // SRC_SENSORS_YOSEMITECHY513_H_ diff --git a/src/sensors/YosemitechY514.h b/src/sensors/YosemitechY514.h index 89144939f..e1d73f99c 100644 --- a/src/sensors/YosemitechY514.h +++ b/src/sensors/YosemitechY514.h @@ -196,7 +196,7 @@ class YosemitechY514 : public YosemitechParent { /** * @brief Destroy the Yosemitech Y514 object */ - ~YosemitechY514() {} + ~YosemitechY514() = default; }; @@ -241,7 +241,7 @@ class YosemitechY514_Chlorophyll : public Variable { * @brief Destroy the YosemitechY514_Chlorophyll() object - no action * needed. */ - ~YosemitechY514_Chlorophyll() {} + ~YosemitechY514_Chlorophyll() = default; }; @@ -285,7 +285,7 @@ class YosemitechY514_Temp : public Variable { /** * @brief Destroy the YosemitechY514_Temp object - no action needed. */ - ~YosemitechY514_Temp() {} + ~YosemitechY514_Temp() = default; }; /**@}*/ #endif // SRC_SENSORS_YOSEMITECHY514_H_ diff --git a/src/sensors/YosemitechY520.h b/src/sensors/YosemitechY520.h index a4e3f60d6..074c715c7 100644 --- a/src/sensors/YosemitechY520.h +++ b/src/sensors/YosemitechY520.h @@ -194,7 +194,7 @@ class YosemitechY520 : public YosemitechParent { /** * @brief Destroy the Yosemitech Y520 object */ - ~YosemitechY520() {} + ~YosemitechY520() = default; }; @@ -238,7 +238,7 @@ class YosemitechY520_Cond : public Variable { /** * @brief Destroy the YosemitechY520_Cond object - no action needed. */ - ~YosemitechY520_Cond() {} + ~YosemitechY520_Cond() = default; }; @@ -282,7 +282,7 @@ class YosemitechY520_Temp : public Variable { /** * @brief Destroy the YosemitechY520_Temp object - no action needed. */ - ~YosemitechY520_Temp() {} + ~YosemitechY520_Temp() = default; }; /**@}*/ #endif // SRC_SENSORS_YOSEMITECHY520_H_ diff --git a/src/sensors/YosemitechY532.h b/src/sensors/YosemitechY532.h index 290dfa3fd..0c7a766e3 100644 --- a/src/sensors/YosemitechY532.h +++ b/src/sensors/YosemitechY532.h @@ -220,7 +220,7 @@ class YosemitechY532 : public YosemitechParent { /** * @brief Destroy the Yosemitech Y532 object */ - ~YosemitechY532() {} + ~YosemitechY532() = default; }; @@ -263,7 +263,7 @@ class YosemitechY532_pH : public Variable { /** * @brief Destroy the YosemitechY532_pH object - no action needed. */ - ~YosemitechY532_pH() {} + ~YosemitechY532_pH() = default; }; @@ -307,7 +307,7 @@ class YosemitechY532_Temp : public Variable { /** * @brief Destroy the YosemitechY532_Temp object - no action needed. */ - ~YosemitechY532_Temp() {} + ~YosemitechY532_Temp() = default; }; @@ -351,7 +351,7 @@ class YosemitechY532_Voltage : public Variable { /** * @brief Destroy the YosemitechY532_Voltage object - no action needed. */ - ~YosemitechY532_Voltage() {} + ~YosemitechY532_Voltage() = default; }; /**@}*/ #endif // SRC_SENSORS_YOSEMITECHY532_H_ diff --git a/src/sensors/YosemitechY533.h b/src/sensors/YosemitechY533.h index 93393a386..bab4cd67f 100644 --- a/src/sensors/YosemitechY533.h +++ b/src/sensors/YosemitechY533.h @@ -196,7 +196,7 @@ class YosemitechY533 : public YosemitechParent { /** * @brief Destroy the Yosemitech Y533 object */ - ~YosemitechY533() {} + ~YosemitechY533() = default; }; @@ -240,7 +240,7 @@ class YosemitechY533_ORP : public Variable { /** * @brief Destroy the YosemitechY533_ORP object - no action needed. */ - ~YosemitechY533_ORP() {} + ~YosemitechY533_ORP() = default; }; @@ -284,7 +284,7 @@ class YosemitechY533_Temp : public Variable { /** * @brief Destroy the YosemitechY533_Temp object - no action needed. */ - ~YosemitechY533_Temp() {} + ~YosemitechY533_Temp() = default; }; /**@}*/ diff --git a/src/sensors/YosemitechY551.h b/src/sensors/YosemitechY551.h index 69144e177..20016e050 100644 --- a/src/sensors/YosemitechY551.h +++ b/src/sensors/YosemitechY551.h @@ -224,7 +224,7 @@ class YosemitechY551 : public YosemitechParent { /** * @brief Destroy the Yosemitech Y551 object */ - ~YosemitechY551() {} + ~YosemitechY551() = default; }; @@ -268,7 +268,7 @@ class YosemitechY551_COD : public Variable { /** * @brief Destroy the YosemitechY551_COD object - no action needed. */ - ~YosemitechY551_COD() {} + ~YosemitechY551_COD() = default; }; @@ -312,7 +312,7 @@ class YosemitechY551_Temp : public Variable { /** * @brief Destroy the YosemitechY551_Temp object - no action needed. */ - ~YosemitechY551_Temp() {} + ~YosemitechY551_Temp() = default; }; @@ -356,7 +356,7 @@ class YosemitechY551_Turbidity : public Variable { /** * @brief Destroy the YosemitechY551_Turbidity object - no action needed. */ - ~YosemitechY551_Turbidity() {} + ~YosemitechY551_Turbidity() = default; }; /**@}*/ #endif // SRC_SENSORS_YOSEMITECHY551_H_ diff --git a/src/sensors/YosemitechY560.h b/src/sensors/YosemitechY560.h index 7e6ec2b99..8087a858d 100644 --- a/src/sensors/YosemitechY560.h +++ b/src/sensors/YosemitechY560.h @@ -221,7 +221,7 @@ class YosemitechY560 : public YosemitechParent { /** * @brief Destroy the Yosemitech Y560 object */ - ~YosemitechY560() {} + ~YosemitechY560() = default; }; @@ -265,7 +265,7 @@ class YosemitechY560_NH4_N : public Variable { /** * @brief Destroy the YosemitechY560_NH4_N object - no action needed. */ - ~YosemitechY560_NH4_N() {} + ~YosemitechY560_NH4_N() = default; }; @@ -309,7 +309,7 @@ class YosemitechY560_Temp : public Variable { /** * @brief Destroy the YosemitechY560_Temp object - no action needed. */ - ~YosemitechY560_Temp() {} + ~YosemitechY560_Temp() = default; }; @@ -352,7 +352,7 @@ class YosemitechY560_pH : public Variable { /** * @brief Destroy the YosemitechY560_pH object - no action needed. */ - ~YosemitechY560_pH() {} + ~YosemitechY560_pH() = default; }; /**@}*/ #endif // SRC_SENSORS_YOSEMITECHY560_H_ diff --git a/src/sensors/YosemitechY700.h b/src/sensors/YosemitechY700.h index ec283512f..c522abd1c 100644 --- a/src/sensors/YosemitechY700.h +++ b/src/sensors/YosemitechY700.h @@ -193,7 +193,7 @@ class YosemitechY700 : public YosemitechParent { /** * @brief Destroy the Yosemitech Y700 object */ - ~YosemitechY700() {} + ~YosemitechY700() = default; }; @@ -237,7 +237,7 @@ class YosemitechY700_Pressure : public Variable { /** * @brief Destroy the YosemitechY700_Pressure object - no action needed. */ - ~YosemitechY700_Pressure() {} + ~YosemitechY700_Pressure() = default; }; @@ -281,7 +281,7 @@ class YosemitechY700_Temp : public Variable { /** * @brief Destroy the YosemitechY700_Temp object - no action needed. */ - ~YosemitechY700_Temp() {} + ~YosemitechY700_Temp() = default; }; /**@}*/ #endif // SRC_SENSORS_YOSEMITECHY700_H_ diff --git a/src/sensors/ZebraTechDOpto.h b/src/sensors/ZebraTechDOpto.h index 9a26e6d7e..82bf1f8e4 100644 --- a/src/sensors/ZebraTechDOpto.h +++ b/src/sensors/ZebraTechDOpto.h @@ -249,7 +249,7 @@ class ZebraTechDOpto : public SDI12Sensors { /** * @brief Destroy the Zebra-Tech DOpto object */ - ~ZebraTechDOpto() {} + ~ZebraTechDOpto() = default; }; @@ -293,7 +293,7 @@ class ZebraTechDOpto_Temp : public Variable { /** * @brief Destroy the ZebraTechDOpto_Temp object - no action needed. */ - ~ZebraTechDOpto_Temp() {} + ~ZebraTechDOpto_Temp() = default; }; @@ -337,7 +337,7 @@ class ZebraTechDOpto_DOpct : public Variable { /** * @brief Destroy the ZebraTechDOpto_DOpct object - no action needed. */ - ~ZebraTechDOpto_DOpct() {} + ~ZebraTechDOpto_DOpct() = default; }; @@ -381,7 +381,7 @@ class ZebraTechDOpto_DOmgL : public Variable { /** * @brief Destroy the ZebraTechDOpto_DOmgL object - no action needed. */ - ~ZebraTechDOpto_DOmgL() {} + ~ZebraTechDOpto_DOmgL() = default; }; /**@}*/ #endif // SRC_SENSORS_ZEBRATECHDOPTO_H_ From 26cdcad640d93b5a7cdb761d18ce2aeecc75eb2c Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Wed, 4 Mar 2026 10:22:26 -0500 Subject: [PATCH 418/533] Fix compiler warnings on getNISTTime Signed-off-by: Sara Damiano --- src/modems/LoggerModemMacros.h | 64 ++++++++++++++++++---------------- 1 file changed, 33 insertions(+), 31 deletions(-) diff --git a/src/modems/LoggerModemMacros.h b/src/modems/LoggerModemMacros.h index 4cdc80d02..df89b6456 100644 --- a/src/modems/LoggerModemMacros.h +++ b/src/modems/LoggerModemMacros.h @@ -627,37 +627,39 @@ } #elif defined(TINY_GSM_MODEM_HAS_NTP) && defined(TINY_GSM_MODEM_HAS_TIME) #include "ClockSupport.h" -#define MS_MODEM_GET_NIST_TIME(specificModem, TinyGSMType) \ - uint32_t specificModem::getNISTTime(void) { \ - /** Check for and bail if not connected to the internet. */ \ - if (!isInternetAvailable()) { \ - MS_DBG(F("No internet connection, cannot get network time.")); \ - return 0; \ - } \ - \ - MS_DBG("Asking modem to sync with NTP"); \ - gsmModem.NTPServerSync("pool.ntp.org", 0); /*UTC!*/ \ - gsmModem.waitForTimeSync(); \ - \ - /* Create ints to hold time parts */ \ - int seconds = 0; \ - int minutes = 0; \ - int hours = 0; \ - int day = 0; \ - int month = 0; \ - int year = 0; \ - /* Fetch the time as parts */ \ - bool success = gsmModem.getNetworkTime(year, &month, &day, &hours, \ - &minutes, &seconds, 0); \ - if (!success) { return 0; } \ - tm timeParts = { \ - static_cast(seconds), static_cast(minutes), \ - static_cast(hours), static_cast(day), \ - static_cast(month - 1), /* tm_mon is 0-11 */ \ - static_cast(year - 1900) /* tm_year is since 1900 */ \ - }; \ - time_t timeTimeT = mktime(&timeParts); \ - return static_cast(timeTimeT); \ +#define MS_MODEM_GET_NIST_TIME(specificModem, TinyGSMType) \ + uint32_t specificModem::getNISTTime(void) { \ + /** Check for and bail if not connected to the internet. */ \ + if (!isInternetAvailable()) { \ + MS_DBG(F("No internet connection, cannot get network time.")); \ + return 0; \ + } \ + \ + MS_DBG("Asking modem to sync with NTP"); \ + gsmModem.NTPServerSync("pool.ntp.org", 0); /*UTC!*/ \ + gsmModem.waitForTimeSync(); \ + \ + /* Create ints to hold time parts */ \ + int seconds = 0; \ + int minutes = 0; \ + int hours = 0; \ + int day = 0; \ + int month = 0; \ + int year = 0; \ + /* Fetch the time as parts */ \ + bool success = gsmModem.getNetworkTime(&year, &month, &day, &hours, \ + &minutes, &seconds, 0); \ + if (!success) { return 0; } \ + tm timeParts = {}; \ + timeParts.tm_sec = seconds; \ + timeParts.tm_min = minutes; \ + timeParts.tm_hour = hours; \ + timeParts.tm_mday = day; \ + timeParts.tm_mon = month - 1; /* tm_mon is 0-11 */ \ + timeParts.tm_year = year - 1900; /* tm_year is since 1900 */ \ + timeParts.tm_wday = 0; /* day of week, will be calculated */ \ + time_t timeTimeT = mktime(&timeParts); \ + return static_cast(timeTimeT); \ } #else #define MS_MODEM_GET_NIST_TIME(specificModem, TinyGSMType) \ From 1880b6ed00e1192f0e7ecd98a1e77ee4bd98a5d4 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Wed, 4 Mar 2026 12:46:17 -0500 Subject: [PATCH 419/533] default a bunch more destructors Signed-off-by: Sara Damiano --- src/VariableArray.cpp | 2 -- src/VariableArray.h | 2 +- src/modems/DigiXBee3GBypass.cpp | 3 --- src/modems/DigiXBee3GBypass.h | 2 +- src/modems/QuectelBG96.cpp | 3 --- src/modems/QuectelBG96.h | 2 +- src/modems/SIMComSIM7000.cpp | 3 --- src/modems/SIMComSIM7000.h | 2 +- src/modems/SIMComSIM7080.cpp | 2 -- src/modems/SIMComSIM7080.h | 2 +- src/modems/SIMComSIM800.cpp | 3 --- src/modems/SIMComSIM800.h | 2 +- src/modems/SequansMonarch.cpp | 2 -- src/modems/SequansMonarch.h | 2 +- src/modems/Sodaq2GBeeR6.cpp | 2 -- src/modems/Sodaq2GBeeR6.h | 2 +- src/modems/SodaqUBeeR410M.cpp | 3 --- src/modems/SodaqUBeeR410M.h | 4 +--- src/modems/SodaqUBeeU201.cpp | 3 --- src/modems/SodaqUBeeU201.h | 2 +- src/sensors/AOSongDHT.cpp | 3 --- src/sensors/AOSongDHT.h | 2 +- src/sensors/AtlasParent.cpp | 2 -- src/sensors/AtlasParent.h | 5 ++--- src/sensors/AtlasScientificCO2.cpp | 3 --- src/sensors/AtlasScientificCO2.h | 5 ++--- src/sensors/AtlasScientificDO.cpp | 3 --- src/sensors/AtlasScientificDO.h | 2 +- src/sensors/AtlasScientificEC.cpp | 3 --- src/sensors/AtlasScientificEC.h | 2 +- src/sensors/BoschBME280.cpp | 3 --- src/sensors/BoschBME280.h | 2 +- src/sensors/BoschBMP3xx.cpp | 2 -- src/sensors/BoschBMP3xx.h | 2 +- src/sensors/FreescaleMPL115A2.cpp | 2 -- src/sensors/FreescaleMPL115A2.h | 2 +- src/sensors/GeoluxHydroCam.cpp | 2 -- src/sensors/GeoluxHydroCam.h | 2 +- src/sensors/GroPointParent.cpp | 2 -- src/sensors/GroPointParent.h | 2 +- src/sensors/KellerParent.cpp | 2 -- src/sensors/KellerParent.h | 2 +- src/sensors/MaxBotixSonar.cpp | 3 --- src/sensors/MaxBotixSonar.h | 2 +- src/sensors/MaximDS18.cpp | 2 -- src/sensors/MaximDS18.h | 2 +- src/sensors/MaximDS3231.cpp | 3 +-- src/sensors/MaximDS3231.h | 2 +- src/sensors/MeaSpecMS5803.cpp | 2 -- src/sensors/MeaSpecMS5803.h | 2 +- src/sensors/ProcessorStats.cpp | 3 --- src/sensors/ProcessorStats.h | 2 +- src/sensors/SDI12Sensors.cpp | 2 -- src/sensors/SDI12Sensors.h | 2 +- src/sensors/SensirionSHT4x.cpp | 2 -- src/sensors/SensirionSHT4x.h | 2 +- src/sensors/TEConnectivityMS5837.cpp | 3 --- src/sensors/TEConnectivityMS5837.h | 2 +- src/sensors/TIINA219.cpp | 2 -- src/sensors/TIINA219.h | 2 +- src/sensors/TallyCounterI2C.cpp | 2 -- src/sensors/TallyCounterI2C.h | 2 +- src/sensors/YosemitechParent.cpp | 2 -- src/sensors/YosemitechParent.h | 2 +- 64 files changed, 35 insertions(+), 116 deletions(-) diff --git a/src/VariableArray.cpp b/src/VariableArray.cpp index 9c0aab416..789bdadcf 100644 --- a/src/VariableArray.cpp +++ b/src/VariableArray.cpp @@ -25,8 +25,6 @@ VariableArray::VariableArray(uint8_t variableCount, Variable* variableList[], matchUUIDs(uuids); } -// Destructor -VariableArray::~VariableArray() {} void VariableArray::begin(uint8_t variableCount, Variable* variableList[], const char* uuids[]) { diff --git a/src/VariableArray.h b/src/VariableArray.h index a7c44b40c..6116b48de 100644 --- a/src/VariableArray.h +++ b/src/VariableArray.h @@ -103,7 +103,7 @@ class VariableArray { /** * @brief Destroy the Variable Array object - no action taken. */ - ~VariableArray(); + ~VariableArray() = default; // "Begins" the VariableArray - attaches the number and array of variables // Not doing this in the constructor because we expect the VariableArray to diff --git a/src/modems/DigiXBee3GBypass.cpp b/src/modems/DigiXBee3GBypass.cpp index 31304f103..cfd0df3f5 100644 --- a/src/modems/DigiXBee3GBypass.cpp +++ b/src/modems/DigiXBee3GBypass.cpp @@ -28,9 +28,6 @@ DigiXBee3GBypass::DigiXBee3GBypass(Stream* modemStream, int8_t powerPin, _apn(apn) { } -// Destructor -DigiXBee3GBypass::~DigiXBee3GBypass() {} - MS_IS_MODEM_AWAKE(DigiXBee3GBypass); MS_MODEM_WAKE(DigiXBee3GBypass); diff --git a/src/modems/DigiXBee3GBypass.h b/src/modems/DigiXBee3GBypass.h index bb980e8f8..4f27b9db4 100644 --- a/src/modems/DigiXBee3GBypass.h +++ b/src/modems/DigiXBee3GBypass.h @@ -125,7 +125,7 @@ class DigiXBee3GBypass : public DigiXBee { /** * @brief Destroy the Digi XBee 3G Bypass object - no action needed */ - ~DigiXBee3GBypass(); + ~DigiXBee3GBypass() = default; bool modemWake(void) override; diff --git a/src/modems/QuectelBG96.cpp b/src/modems/QuectelBG96.cpp index 215271117..8ce90b1af 100644 --- a/src/modems/QuectelBG96.cpp +++ b/src/modems/QuectelBG96.cpp @@ -30,9 +30,6 @@ QuectelBG96::QuectelBG96(Stream* modemStream, int8_t powerPin, int8_t statusPin, _apn(apn) { } -// Destructor -QuectelBG96::~QuectelBG96() {} - MS_MODEM_EXTRA_SETUP(QuectelBG96); MS_IS_MODEM_AWAKE(QuectelBG96); MS_MODEM_WAKE(QuectelBG96); diff --git a/src/modems/QuectelBG96.h b/src/modems/QuectelBG96.h index 79e812704..bf362e63d 100644 --- a/src/modems/QuectelBG96.h +++ b/src/modems/QuectelBG96.h @@ -200,7 +200,7 @@ class QuectelBG96 : public loggerModem { /** * @brief Destroy the Quectel BG96 object - no action taken */ - ~QuectelBG96(); + ~QuectelBG96() = default; bool modemWake(void) override; diff --git a/src/modems/SIMComSIM7000.cpp b/src/modems/SIMComSIM7000.cpp index 09dca62f8..69e88c6ba 100644 --- a/src/modems/SIMComSIM7000.cpp +++ b/src/modems/SIMComSIM7000.cpp @@ -30,9 +30,6 @@ SIMComSIM7000::SIMComSIM7000(Stream* modemStream, int8_t powerPin, _apn(apn) { } -// Destructor -SIMComSIM7000::~SIMComSIM7000() {} - MS_MODEM_EXTRA_SETUP(SIMComSIM7000); MS_IS_MODEM_AWAKE(SIMComSIM7000); MS_MODEM_WAKE(SIMComSIM7000); diff --git a/src/modems/SIMComSIM7000.h b/src/modems/SIMComSIM7000.h index 26a2177e4..fb1105d13 100644 --- a/src/modems/SIMComSIM7000.h +++ b/src/modems/SIMComSIM7000.h @@ -188,7 +188,7 @@ class SIMComSIM7000 : public loggerModem { /** * @brief Destroy the SIMComSIM7000 object - no action needed */ - ~SIMComSIM7000(); + ~SIMComSIM7000() = default; bool modemWake(void) override; diff --git a/src/modems/SIMComSIM7080.cpp b/src/modems/SIMComSIM7080.cpp index 48bc7396c..9e7b3e8b3 100644 --- a/src/modems/SIMComSIM7080.cpp +++ b/src/modems/SIMComSIM7080.cpp @@ -30,8 +30,6 @@ SIMComSIM7080::SIMComSIM7080(Stream* modemStream, int8_t powerPin, _apn(apn) { } -// Destructor -SIMComSIM7080::~SIMComSIM7080() {} bool SIMComSIM7080::extraModemSetup(void) { bool success = gsmModem.init(); diff --git a/src/modems/SIMComSIM7080.h b/src/modems/SIMComSIM7080.h index cacf8f4aa..ca98ff0e1 100644 --- a/src/modems/SIMComSIM7080.h +++ b/src/modems/SIMComSIM7080.h @@ -183,7 +183,7 @@ class SIMComSIM7080 : public loggerModem { /** * @brief Destroy the SIMComSIM7080 object - no action needed */ - ~SIMComSIM7080(); + ~SIMComSIM7080() = default; bool modemWake(void) override; diff --git a/src/modems/SIMComSIM800.cpp b/src/modems/SIMComSIM800.cpp index a8ce4aa7c..5c4598e22 100644 --- a/src/modems/SIMComSIM800.cpp +++ b/src/modems/SIMComSIM800.cpp @@ -30,9 +30,6 @@ SIMComSIM800::SIMComSIM800(Stream* modemStream, int8_t powerPin, _apn(apn) { } -// Destructor -SIMComSIM800::~SIMComSIM800() {} - MS_MODEM_EXTRA_SETUP(SIMComSIM800); MS_IS_MODEM_AWAKE(SIMComSIM800); MS_MODEM_WAKE(SIMComSIM800); diff --git a/src/modems/SIMComSIM800.h b/src/modems/SIMComSIM800.h index a9b38d248..416a7dc95 100644 --- a/src/modems/SIMComSIM800.h +++ b/src/modems/SIMComSIM800.h @@ -190,7 +190,7 @@ class SIMComSIM800 : public loggerModem { /** * @brief Destroy the SIMComSIM800 object - no action taken */ - ~SIMComSIM800(); + ~SIMComSIM800() = default; bool modemWake(void) override; diff --git a/src/modems/SequansMonarch.cpp b/src/modems/SequansMonarch.cpp index 4b6a54b98..460ed971f 100644 --- a/src/modems/SequansMonarch.cpp +++ b/src/modems/SequansMonarch.cpp @@ -30,8 +30,6 @@ SequansMonarch::SequansMonarch(Stream* modemStream, int8_t powerPin, _apn(apn) { } -// Destructor -SequansMonarch::~SequansMonarch() {} MS_IS_MODEM_AWAKE(SequansMonarch); MS_MODEM_WAKE(SequansMonarch); diff --git a/src/modems/SequansMonarch.h b/src/modems/SequansMonarch.h index 867f3192e..a617cda9c 100644 --- a/src/modems/SequansMonarch.h +++ b/src/modems/SequansMonarch.h @@ -221,7 +221,7 @@ class SequansMonarch : public loggerModem { /** * @brief Destroy the Sequans Monarch object - no action taken */ - ~SequansMonarch(); + ~SequansMonarch() = default; bool modemWake(void) override; diff --git a/src/modems/Sodaq2GBeeR6.cpp b/src/modems/Sodaq2GBeeR6.cpp index 614901582..3215eb6a7 100644 --- a/src/modems/Sodaq2GBeeR6.cpp +++ b/src/modems/Sodaq2GBeeR6.cpp @@ -27,8 +27,6 @@ Sodaq2GBeeR6::Sodaq2GBeeR6(Stream* modemStream, int8_t vRefPin, setVRefPin(vRefPin); } -// Destructor -Sodaq2GBeeR6::~Sodaq2GBeeR6() {} // Create the wake and sleep methods for the modem // These can be functions of any type and must return a boolean diff --git a/src/modems/Sodaq2GBeeR6.h b/src/modems/Sodaq2GBeeR6.h index e7116ce63..6862bac44 100644 --- a/src/modems/Sodaq2GBeeR6.h +++ b/src/modems/Sodaq2GBeeR6.h @@ -162,7 +162,7 @@ class Sodaq2GBeeR6 : public SIMComSIM800 { /** * @brief Destroy the Sodaq 2GBee R6 object - no action taken */ - ~Sodaq2GBeeR6(); + ~Sodaq2GBeeR6() = default; /** * @brief Sets the pin to use to control voltage reference on the GPRSBee. diff --git a/src/modems/SodaqUBeeR410M.cpp b/src/modems/SodaqUBeeR410M.cpp index df645eb9d..08cedef35 100644 --- a/src/modems/SodaqUBeeR410M.cpp +++ b/src/modems/SodaqUBeeR410M.cpp @@ -51,9 +51,6 @@ SodaqUBeeR410M::SodaqUBeeR410M(Stream* modemStream, int8_t powerPin, } #endif -// Destructor -SodaqUBeeR410M::~SodaqUBeeR410M() {} - MS_IS_MODEM_AWAKE(SodaqUBeeR410M); MS_MODEM_WAKE(SodaqUBeeR410M); diff --git a/src/modems/SodaqUBeeR410M.h b/src/modems/SodaqUBeeR410M.h index b8873c4fb..e5b112385 100644 --- a/src/modems/SodaqUBeeR410M.h +++ b/src/modems/SodaqUBeeR410M.h @@ -223,8 +223,6 @@ */ class SodaqUBeeR410M : public loggerModem { public: - // Constructor/Destructor - #if F_CPU == 8000000L /** * @brief Construct a new Sodaq UBee R410M object @@ -299,7 +297,7 @@ class SodaqUBeeR410M : public loggerModem { /** * @brief Destroy the Sodaq UBee R410M object - no action needed */ - ~SodaqUBeeR410M(); + ~SodaqUBeeR410M() = default; bool modemWake(void) override; diff --git a/src/modems/SodaqUBeeU201.cpp b/src/modems/SodaqUBeeU201.cpp index 3941b614a..d9ab54225 100644 --- a/src/modems/SodaqUBeeU201.cpp +++ b/src/modems/SodaqUBeeU201.cpp @@ -30,9 +30,6 @@ SodaqUBeeU201::SodaqUBeeU201(Stream* modemStream, int8_t powerPin, _apn(apn) { } -// Destructor -SodaqUBeeU201::~SodaqUBeeU201() {} - MS_IS_MODEM_AWAKE(SodaqUBeeU201); MS_MODEM_WAKE(SodaqUBeeU201); diff --git a/src/modems/SodaqUBeeU201.h b/src/modems/SodaqUBeeU201.h index 475a0bef8..e61c9c33b 100644 --- a/src/modems/SodaqUBeeU201.h +++ b/src/modems/SodaqUBeeU201.h @@ -196,7 +196,7 @@ class SodaqUBeeU201 : public loggerModem { /** * @brief Destroy the Sodaq UBee U201 object - no action taken */ - ~SodaqUBeeU201(); + ~SodaqUBeeU201() = default; bool modemWake(void) override; diff --git a/src/sensors/AOSongDHT.cpp b/src/sensors/AOSongDHT.cpp index 326bedcea..d968322f6 100644 --- a/src/sensors/AOSongDHT.cpp +++ b/src/sensors/AOSongDHT.cpp @@ -22,9 +22,6 @@ AOSongDHT::AOSongDHT(int8_t powerPin, int8_t dataPin, const uint8_t type, setAllowedMeasurementRetries(DHT_DEFAULT_MEASUREMENT_RETRIES); } -// Destructor - does nothing. -AOSongDHT::~AOSongDHT() {} - bool AOSongDHT::setup(void) { dht_internal.begin(); // Start up the sensor (only sets pin modes, sensor diff --git a/src/sensors/AOSongDHT.h b/src/sensors/AOSongDHT.h index cf949b946..69aebd458 100644 --- a/src/sensors/AOSongDHT.h +++ b/src/sensors/AOSongDHT.h @@ -269,7 +269,7 @@ class AOSongDHT : public Sensor { /** * @brief Destroy the AOSongDHT object - no action needed. */ - ~AOSongDHT(); + ~AOSongDHT() = default; bool setup(void) override; diff --git a/src/sensors/AtlasParent.cpp b/src/sensors/AtlasParent.cpp index 769b59833..2de12b424 100644 --- a/src/sensors/AtlasParent.cpp +++ b/src/sensors/AtlasParent.cpp @@ -34,8 +34,6 @@ AtlasParent::AtlasParent(int8_t powerPin, uint8_t i2cAddressHex, : AtlasParent(&Wire, powerPin, i2cAddressHex, measurementsToAverage, sensorName, totalReturnedValues, warmUpTime_ms, stabilizationTime_ms, measurementTime_ms, incCalcValues) {} -// Destructors -AtlasParent::~AtlasParent() {} String AtlasParent::getSensorLocation(void) { diff --git a/src/sensors/AtlasParent.h b/src/sensors/AtlasParent.h index 294ec7fa6..1d43012c5 100644 --- a/src/sensors/AtlasParent.h +++ b/src/sensors/AtlasParent.h @@ -171,10 +171,9 @@ class AtlasParent : public Sensor { uint32_t measurementTime_ms = 0, uint8_t incCalcValues = 0); /** - * @brief Destroy the Atlas Parent object. Also destroy the software I2C - * instance if one was created. + * @brief Destroy the Atlas Parent object. */ - virtual ~AtlasParent(); + virtual ~AtlasParent() = default; /** * @brief Return the I2C address of the EZO circuit. diff --git a/src/sensors/AtlasScientificCO2.cpp b/src/sensors/AtlasScientificCO2.cpp index 31cfba78c..f873330e2 100644 --- a/src/sensors/AtlasScientificCO2.cpp +++ b/src/sensors/AtlasScientificCO2.cpp @@ -27,9 +27,6 @@ AtlasScientificCO2::AtlasScientificCO2(int8_t powerPin, uint8_t i2cAddressHex, : AtlasScientificCO2(&Wire, powerPin, i2cAddressHex, measurementsToAverage) {} -// Destructor -AtlasScientificCO2::~AtlasScientificCO2() {} - // Setup bool AtlasScientificCO2::setup() { diff --git a/src/sensors/AtlasScientificCO2.h b/src/sensors/AtlasScientificCO2.h index 6e939231c..cd5f769bc 100644 --- a/src/sensors/AtlasScientificCO2.h +++ b/src/sensors/AtlasScientificCO2.h @@ -228,10 +228,9 @@ class AtlasScientificCO2 : public AtlasParent { uint8_t measurementsToAverage = 1); /** - * @brief Destroy the Atlas Scientific CO2 object. Also destroy the - * software I2C instance if one was created. + * @brief Destroy the Atlas Scientific CO2 object. */ - ~AtlasScientificCO2(); + ~AtlasScientificCO2() = default; /** * @brief Do any one-time preparations needed before the sensor will be able diff --git a/src/sensors/AtlasScientificDO.cpp b/src/sensors/AtlasScientificDO.cpp index cfe9e3f68..c25f0dbb3 100644 --- a/src/sensors/AtlasScientificDO.cpp +++ b/src/sensors/AtlasScientificDO.cpp @@ -26,9 +26,6 @@ AtlasScientificDO::AtlasScientificDO(int8_t powerPin, uint8_t i2cAddressHex, : AtlasScientificDO(&Wire, powerPin, i2cAddressHex, measurementsToAverage) { } -// Destructor -AtlasScientificDO::~AtlasScientificDO() {} - // Setup bool AtlasScientificDO::setup() { diff --git a/src/sensors/AtlasScientificDO.h b/src/sensors/AtlasScientificDO.h index a3ad58e70..a21f34a66 100644 --- a/src/sensors/AtlasScientificDO.h +++ b/src/sensors/AtlasScientificDO.h @@ -239,7 +239,7 @@ class AtlasScientificDO : public AtlasParent { /** * @brief Destroy the Atlas Scientific DO object */ - ~AtlasScientificDO(); + ~AtlasScientificDO() = default; /** * @brief Do any one-time preparations needed before the sensor will be able diff --git a/src/sensors/AtlasScientificEC.cpp b/src/sensors/AtlasScientificEC.cpp index 00b8c5423..35c8eceee 100644 --- a/src/sensors/AtlasScientificEC.cpp +++ b/src/sensors/AtlasScientificEC.cpp @@ -27,9 +27,6 @@ AtlasScientificEC::AtlasScientificEC(int8_t powerPin, uint8_t i2cAddressHex, : AtlasScientificEC(&Wire, powerPin, i2cAddressHex, measurementsToAverage) { } -// Destructor -AtlasScientificEC::~AtlasScientificEC() {} - // Setup bool AtlasScientificEC::setup() { diff --git a/src/sensors/AtlasScientificEC.h b/src/sensors/AtlasScientificEC.h index b52b0c74e..f7d8d9850 100644 --- a/src/sensors/AtlasScientificEC.h +++ b/src/sensors/AtlasScientificEC.h @@ -302,7 +302,7 @@ class AtlasScientificEC : public AtlasParent { /** * @brief Destroy the Atlas Scientific EC object */ - ~AtlasScientificEC(); + ~AtlasScientificEC() = default; /** * @brief Do any one-time preparations needed before the sensor will be able diff --git a/src/sensors/BoschBME280.cpp b/src/sensors/BoschBME280.cpp index 5ce81c1d8..c8d7159e4 100644 --- a/src/sensors/BoschBME280.cpp +++ b/src/sensors/BoschBME280.cpp @@ -25,9 +25,6 @@ BoschBME280::BoschBME280(int8_t powerPin, uint8_t i2cAddressHex, uint8_t measurementsToAverage) : BoschBME280(&Wire, powerPin, i2cAddressHex, measurementsToAverage) {} -// Destructor -BoschBME280::~BoschBME280() {} - String BoschBME280::getSensorLocation(void) { String address = F("I2C_0x"); diff --git a/src/sensors/BoschBME280.h b/src/sensors/BoschBME280.h index a355b1ee3..5f358dbf2 100644 --- a/src/sensors/BoschBME280.h +++ b/src/sensors/BoschBME280.h @@ -304,7 +304,7 @@ class BoschBME280 : public Sensor { /** * @brief Destroy the Bosch BME280 object */ - ~BoschBME280(); + ~BoschBME280() = default; bool wake(void) override; /** diff --git a/src/sensors/BoschBMP3xx.cpp b/src/sensors/BoschBMP3xx.cpp index 4daf459d8..b923f8e80 100644 --- a/src/sensors/BoschBMP3xx.cpp +++ b/src/sensors/BoschBMP3xx.cpp @@ -25,8 +25,6 @@ BoschBMP3xx::BoschBMP3xx(int8_t powerPin, Mode mode, _filterCoeffEnum(filterCoeff), _standbyEnum(timeStandby), _i2cAddressHex(i2cAddressHex) {} -// Destructor -BoschBMP3xx::~BoschBMP3xx() {} String BoschBMP3xx::getSensorLocation(void) { diff --git a/src/sensors/BoschBMP3xx.h b/src/sensors/BoschBMP3xx.h index 59ef61ce7..60a7c26bb 100644 --- a/src/sensors/BoschBMP3xx.h +++ b/src/sensors/BoschBMP3xx.h @@ -435,7 +435,7 @@ class BoschBMP3xx : public Sensor { /** * @brief Destroy the Bosch BMP3xx object */ - ~BoschBMP3xx(); + ~BoschBMP3xx() = default; bool wake(void) override; /** diff --git a/src/sensors/FreescaleMPL115A2.cpp b/src/sensors/FreescaleMPL115A2.cpp index 1350a2076..f98d87cf0 100644 --- a/src/sensors/FreescaleMPL115A2.cpp +++ b/src/sensors/FreescaleMPL115A2.cpp @@ -25,8 +25,6 @@ FreescaleMPL115A2::FreescaleMPL115A2(TwoWire* theI2C, int8_t powerPin, FreescaleMPL115A2::FreescaleMPL115A2(int8_t powerPin, uint8_t measurementsToAverage) : FreescaleMPL115A2(&Wire, powerPin, measurementsToAverage) {} -// Destructor -FreescaleMPL115A2::~FreescaleMPL115A2() {} String FreescaleMPL115A2::getSensorLocation(void) { diff --git a/src/sensors/FreescaleMPL115A2.h b/src/sensors/FreescaleMPL115A2.h index 21543c654..36f5074f2 100644 --- a/src/sensors/FreescaleMPL115A2.h +++ b/src/sensors/FreescaleMPL115A2.h @@ -220,7 +220,7 @@ class FreescaleMPL115A2 : public Sensor { /** * @brief Destroy the FreescaleMPL115A2 object */ - ~FreescaleMPL115A2(); + ~FreescaleMPL115A2() = default; /** * @brief Do any one-time preparations needed before the sensor will be able diff --git a/src/sensors/GeoluxHydroCam.cpp b/src/sensors/GeoluxHydroCam.cpp index f71411959..b413d73ee 100644 --- a/src/sensors/GeoluxHydroCam.cpp +++ b/src/sensors/GeoluxHydroCam.cpp @@ -44,8 +44,6 @@ GeoluxHydroCam::GeoluxHydroCam(Stream& stream, int8_t powerPin, setSecondaryPowerPin(powerPin2); } -// Destructor -GeoluxHydroCam::~GeoluxHydroCam() {} String GeoluxHydroCam::getLastSavedImageName() { return _filename; diff --git a/src/sensors/GeoluxHydroCam.h b/src/sensors/GeoluxHydroCam.h index c5d09e4a0..b3dc804fa 100644 --- a/src/sensors/GeoluxHydroCam.h +++ b/src/sensors/GeoluxHydroCam.h @@ -283,7 +283,7 @@ class GeoluxHydroCam : public Sensor { /** * @brief Destroy the Geolux HydroCam object */ - ~GeoluxHydroCam(); + ~GeoluxHydroCam() = default; /** * @brief Extra unique function to retrieve the name of the last saved image diff --git a/src/sensors/GroPointParent.cpp b/src/sensors/GroPointParent.cpp index 056302470..e3ebdd753 100644 --- a/src/sensors/GroPointParent.cpp +++ b/src/sensors/GroPointParent.cpp @@ -42,8 +42,6 @@ GroPointParent::GroPointParent(byte modbusAddress, Stream& stream, measurementsToAverage, model, sensName, numVariables, warmUpTime_ms, stabilizationTime_ms, measurementTime_ms, incCalcValues) {} -// Destructor -GroPointParent::~GroPointParent() {} // The sensor installation location on the Mayfly diff --git a/src/sensors/GroPointParent.h b/src/sensors/GroPointParent.h index 26351cb54..8dc846fd3 100644 --- a/src/sensors/GroPointParent.h +++ b/src/sensors/GroPointParent.h @@ -154,7 +154,7 @@ class GroPointParent : public Sensor { /** * @brief Destroy the GroPoint Parent object - no action taken */ - virtual ~GroPointParent(); + virtual ~GroPointParent() = default; String getSensorLocation(void) override; diff --git a/src/sensors/KellerParent.cpp b/src/sensors/KellerParent.cpp index 3028b7499..1cf540b79 100644 --- a/src/sensors/KellerParent.cpp +++ b/src/sensors/KellerParent.cpp @@ -40,8 +40,6 @@ KellerParent::KellerParent(byte modbusAddress, Stream& stream, int8_t powerPin, : KellerParent(modbusAddress, &stream, powerPin, powerPin2, enablePin, measurementsToAverage, model, sensName, numVariables, warmUpTime_ms, stabilizationTime_ms, measurementTime_ms) {} -// Destructor -KellerParent::~KellerParent() {} // The sensor installation location on the Mayfly diff --git a/src/sensors/KellerParent.h b/src/sensors/KellerParent.h index 6b1f4ca5a..77ec51740 100644 --- a/src/sensors/KellerParent.h +++ b/src/sensors/KellerParent.h @@ -231,7 +231,7 @@ class KellerParent : public Sensor { /** * @brief Destroy the Keller Parent object - no action taken */ - virtual ~KellerParent(); + virtual ~KellerParent() = default; String getSensorLocation(void) override; diff --git a/src/sensors/MaxBotixSonar.cpp b/src/sensors/MaxBotixSonar.cpp index da435d02b..7bef7a628 100644 --- a/src/sensors/MaxBotixSonar.cpp +++ b/src/sensors/MaxBotixSonar.cpp @@ -29,9 +29,6 @@ MaxBotixSonar::MaxBotixSonar(Stream& stream, int8_t powerPin, int8_t triggerPin, : MaxBotixSonar(&stream, powerPin, triggerPin, maxRange, measurementsToAverage, convertCm) {} -// Destructor -MaxBotixSonar::~MaxBotixSonar() {} - // unfortunately, we really cannot know where the stream is attached. String MaxBotixSonar::getSensorLocation(void) { diff --git a/src/sensors/MaxBotixSonar.h b/src/sensors/MaxBotixSonar.h index a18a4eb92..9c3577c34 100644 --- a/src/sensors/MaxBotixSonar.h +++ b/src/sensors/MaxBotixSonar.h @@ -222,7 +222,7 @@ class MaxBotixSonar : public Sensor { /** * @brief Destroy the MaxBotix Sonar object */ - ~MaxBotixSonar(); + ~MaxBotixSonar() = default; String getSensorLocation(void) override; diff --git a/src/sensors/MaximDS18.cpp b/src/sensors/MaximDS18.cpp index 1571bbb61..411d48feb 100644 --- a/src/sensors/MaximDS18.cpp +++ b/src/sensors/MaximDS18.cpp @@ -34,8 +34,6 @@ MaximDS18::MaximDS18(int8_t powerPin, int8_t dataPin, _addressKnown(false), _internalOneWire(dataPin), _internalDallasTemp(&_internalOneWire) {} -// Destructor -MaximDS18::~MaximDS18() {} // Turns the address into a printable string diff --git a/src/sensors/MaximDS18.h b/src/sensors/MaximDS18.h index 0f3c31e38..ef5abaf79 100644 --- a/src/sensors/MaximDS18.h +++ b/src/sensors/MaximDS18.h @@ -225,7 +225,7 @@ class MaximDS18 : public Sensor { /** * @brief Destroy the Maxim DS18 object */ - ~MaximDS18(); + ~MaximDS18() = default; /** * @brief Do any one-time preparations needed before the sensor will be able diff --git a/src/sensors/MaximDS3231.cpp b/src/sensors/MaximDS3231.cpp index 353e571c8..bba9a608b 100644 --- a/src/sensors/MaximDS3231.cpp +++ b/src/sensors/MaximDS3231.cpp @@ -16,8 +16,7 @@ MaximDS3231::MaximDS3231(uint8_t measurementsToAverage) : Sensor("MaximDS3231", DS3231_NUM_VARIABLES, DS3231_WARM_UP_TIME_MS, DS3231_STABILIZATION_TIME_MS, DS3231_MEASUREMENT_TIME_MS, -1, -1, measurementsToAverage, DS3231_INC_CALC_VARIABLES) {} -// Destructor -MaximDS3231::~MaximDS3231() {} + String MaximDS3231::getSensorLocation(void) { return F("I2C_0x68"); diff --git a/src/sensors/MaximDS3231.h b/src/sensors/MaximDS3231.h index ce2be6531..a2f19b7f5 100644 --- a/src/sensors/MaximDS3231.h +++ b/src/sensors/MaximDS3231.h @@ -166,7 +166,7 @@ class MaximDS3231 : public Sensor { /** * @brief Destroy the Maxim DS3231 object */ - ~MaximDS3231(); + ~MaximDS3231() = default; String getSensorLocation(void) override; diff --git a/src/sensors/MeaSpecMS5803.cpp b/src/sensors/MeaSpecMS5803.cpp index cd843709c..de878f9fe 100644 --- a/src/sensors/MeaSpecMS5803.cpp +++ b/src/sensors/MeaSpecMS5803.cpp @@ -21,8 +21,6 @@ MeaSpecMS5803::MeaSpecMS5803(int8_t powerPin, uint8_t i2cAddressHex, -1, measurementsToAverage, MS5803_INC_CALC_VARIABLES), _i2cAddressHex(i2cAddressHex), _maxPressure(maxPressure) {} -// Destructor -MeaSpecMS5803::~MeaSpecMS5803() {} String MeaSpecMS5803::getSensorLocation(void) { diff --git a/src/sensors/MeaSpecMS5803.h b/src/sensors/MeaSpecMS5803.h index c44dcc79b..67b29f9c6 100644 --- a/src/sensors/MeaSpecMS5803.h +++ b/src/sensors/MeaSpecMS5803.h @@ -235,7 +235,7 @@ class MeaSpecMS5803 : public Sensor { /** * @brief Destroy the MeaSpecMS5803 object */ - ~MeaSpecMS5803(); + ~MeaSpecMS5803() = default; /** * @brief Do any one-time preparations needed before the sensor will be able diff --git a/src/sensors/ProcessorStats.cpp b/src/sensors/ProcessorStats.cpp index eafd6ac88..3e6459c1c 100644 --- a/src/sensors/ProcessorStats.cpp +++ b/src/sensors/ProcessorStats.cpp @@ -75,9 +75,6 @@ ProcessorStats::ProcessorStats(const char* boardName, const char* version, _batteryMultiplier(batteryMultiplier), _operatingVoltage(operatingVoltage) {} -// Destructor -ProcessorStats::~ProcessorStats() {} - String ProcessorStats::getSensorLocation(void) { return String(_boardName) + " " + String(_version); diff --git a/src/sensors/ProcessorStats.h b/src/sensors/ProcessorStats.h index a2a91531f..791ad5df8 100644 --- a/src/sensors/ProcessorStats.h +++ b/src/sensors/ProcessorStats.h @@ -317,7 +317,7 @@ class ProcessorStats : public Sensor { /** * @brief Destroy the Processor Stats object */ - ~ProcessorStats(); + ~ProcessorStats() = default; /** * @copydoc Sensor::getSensorLocation() diff --git a/src/sensors/SDI12Sensors.cpp b/src/sensors/SDI12Sensors.cpp index 0a65f1d44..6fcbb5728 100644 --- a/src/sensors/SDI12Sensors.cpp +++ b/src/sensors/SDI12Sensors.cpp @@ -74,8 +74,6 @@ SDI12Sensors::SDI12Sensors(int SDI12address, int8_t powerPin, int8_t dataPin, measurementsToAverage, sensorName, totalReturnedValues, warmUpTime_ms, stabilizationTime_ms, measurementTime_ms, extraWakeTime, incCalcValues) {} -// Destructor -SDI12Sensors::~SDI12Sensors() {} bool SDI12Sensors::setup(void) { diff --git a/src/sensors/SDI12Sensors.h b/src/sensors/SDI12Sensors.h index 4545ab207..ce90817d8 100644 --- a/src/sensors/SDI12Sensors.h +++ b/src/sensors/SDI12Sensors.h @@ -165,7 +165,7 @@ class SDI12Sensors : public Sensor { /** * @brief Destroy the SDI12Sensors object - no action taken */ - virtual ~SDI12Sensors(); + virtual ~SDI12Sensors() = default; /** * @brief Get the stored sensor vendor name returned by a previously called diff --git a/src/sensors/SensirionSHT4x.cpp b/src/sensors/SensirionSHT4x.cpp index 49977fb95..d00cd0443 100644 --- a/src/sensors/SensirionSHT4x.cpp +++ b/src/sensors/SensirionSHT4x.cpp @@ -26,8 +26,6 @@ SensirionSHT4x::SensirionSHT4x(int8_t powerPin, bool useHeater, -1, measurementsToAverage, SHT4X_INC_CALC_VARIABLES), _useHeater(useHeater), _i2c(&Wire) {} -// Destructor -SensirionSHT4x::~SensirionSHT4x() {} String SensirionSHT4x::getSensorLocation(void) { diff --git a/src/sensors/SensirionSHT4x.h b/src/sensors/SensirionSHT4x.h index 32dc1f260..9af29f9fb 100644 --- a/src/sensors/SensirionSHT4x.h +++ b/src/sensors/SensirionSHT4x.h @@ -253,7 +253,7 @@ class SensirionSHT4x : public Sensor { /** * @brief Destroy the SensirionSHT4x object - no action needed. */ - ~SensirionSHT4x(); + ~SensirionSHT4x() = default; /** * @brief Report the I2C address of the SHT4x - which is always 0x44. diff --git a/src/sensors/TEConnectivityMS5837.cpp b/src/sensors/TEConnectivityMS5837.cpp index 4e696eb33..2e08aaa60 100644 --- a/src/sensors/TEConnectivityMS5837.cpp +++ b/src/sensors/TEConnectivityMS5837.cpp @@ -59,9 +59,6 @@ TEConnectivityMS5837::TEConnectivityMS5837(int8_t powerPin, MS5837Model model, measurementsToAverage, overSamplingRatio, fluidDensity, airPressure) {} -// Destructor -TEConnectivityMS5837::~TEConnectivityMS5837() {} - String TEConnectivityMS5837::getSensorName(void) { auto modelEnum = static_cast(_model); diff --git a/src/sensors/TEConnectivityMS5837.h b/src/sensors/TEConnectivityMS5837.h index d21169b64..b7f0a69f8 100644 --- a/src/sensors/TEConnectivityMS5837.h +++ b/src/sensors/TEConnectivityMS5837.h @@ -464,7 +464,7 @@ class TEConnectivityMS5837 : public Sensor { /** * @brief Destroy the TEConnectivityMS5837 object */ - ~TEConnectivityMS5837(); + ~TEConnectivityMS5837() = default; /** * @brief Do any one-time preparations needed before the sensor will be able diff --git a/src/sensors/TIINA219.cpp b/src/sensors/TIINA219.cpp index 79b59f285..fcc70af20 100644 --- a/src/sensors/TIINA219.cpp +++ b/src/sensors/TIINA219.cpp @@ -28,8 +28,6 @@ TIINA219::TIINA219(int8_t powerPin, uint8_t i2cAddressHex, ina219_phy(i2cAddressHex), _i2cAddressHex(i2cAddressHex), _i2c(&Wire) {} -// Destructor -TIINA219::~TIINA219() {} String TIINA219::getSensorLocation(void) { diff --git a/src/sensors/TIINA219.h b/src/sensors/TIINA219.h index 6981a30b1..2478e9113 100644 --- a/src/sensors/TIINA219.h +++ b/src/sensors/TIINA219.h @@ -267,7 +267,7 @@ class TIINA219 : public Sensor { /** * @brief Destroy the TI INA219 object */ - ~TIINA219(); + ~TIINA219() = default; /** * @brief Wake the sensor up and read the calibration coefficient from it. diff --git a/src/sensors/TallyCounterI2C.cpp b/src/sensors/TallyCounterI2C.cpp index 532115258..63471e091 100644 --- a/src/sensors/TallyCounterI2C.cpp +++ b/src/sensors/TallyCounterI2C.cpp @@ -18,8 +18,6 @@ TallyCounterI2C::TallyCounterI2C(int8_t powerPin, uint8_t i2cAddressHex) TALLY_STABILIZATION_TIME_MS, TALLY_MEASUREMENT_TIME_MS, powerPin, -1, 1, TALLY_INC_CALC_VARIABLES), _i2cAddressHex(i2cAddressHex) {} -// Destructor -TallyCounterI2C::~TallyCounterI2C() {} String TallyCounterI2C::getSensorLocation(void) { diff --git a/src/sensors/TallyCounterI2C.h b/src/sensors/TallyCounterI2C.h index 6f9fd1ddb..6638da5e8 100644 --- a/src/sensors/TallyCounterI2C.h +++ b/src/sensors/TallyCounterI2C.h @@ -203,7 +203,7 @@ class TallyCounterI2C : public Sensor { /** * @brief Destroy the Tally Counter object */ - ~TallyCounterI2C(); + ~TallyCounterI2C() = default; /** * @brief Do any one-time preparations needed before the sensor will be able diff --git a/src/sensors/YosemitechParent.cpp b/src/sensors/YosemitechParent.cpp index 0803a103d..7107ac18f 100644 --- a/src/sensors/YosemitechParent.cpp +++ b/src/sensors/YosemitechParent.cpp @@ -38,8 +38,6 @@ YosemitechParent::YosemitechParent( measurementsToAverage, model, sensName, numVariables, warmUpTime_ms, stabilizationTime_ms, measurementTime_ms, incCalcValues) {} -// Destructor -YosemitechParent::~YosemitechParent() {} // The sensor installation location on the Mayfly diff --git a/src/sensors/YosemitechParent.h b/src/sensors/YosemitechParent.h index 505b7c9b6..b5508eb05 100644 --- a/src/sensors/YosemitechParent.h +++ b/src/sensors/YosemitechParent.h @@ -207,7 +207,7 @@ class YosemitechParent : public Sensor { /** * @brief Destroy the Yosemitech Parent object - no action taken */ - virtual ~YosemitechParent(); + virtual ~YosemitechParent() = default; String getSensorLocation(void) override; From 11b181d6b3217b3dc66d1e665730d8064900a95c Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Wed, 4 Mar 2026 13:22:38 -0500 Subject: [PATCH 420/533] Fix retries in the update function Signed-off-by: Sara Damiano --- src/SensorBase.cpp | 41 ++++++++++++++++++++--------------------- 1 file changed, 20 insertions(+), 21 deletions(-) diff --git a/src/SensorBase.cpp b/src/SensorBase.cpp index 9932f78a6..51ac025ca 100644 --- a/src/SensorBase.cpp +++ b/src/SensorBase.cpp @@ -516,30 +516,27 @@ bool Sensor::update(void) { // loop through until we have the requested number of successful // measurements + // NOTE: The number of measurement attempts completed is bumped by + // bumpMeasurementAttemptCount() only after success or the last retry + // attempt, so it's safe to check this value to determine if we have the + // requested number of successful measurements. while (_measurementAttemptsCompleted < _measurementsToAverage) { // start a measurement - bool measurementStarted = startSingleMeasurement(); - if (!measurementStarted) { - ret_val = false; - // Use bumpMeasurementAttemptCount to track failed attempts - if (!bumpMeasurementAttemptCount(false)) { - // If we've exhausted retries for this measurement, break - break; - } - continue; // Try again if retries are available - } - - // wait for the measurement to finish - waitForMeasurementCompletion(); - - // get the measurement result - bool measurementSuccessful = addSingleMeasurementResult(); - ret_val &= measurementSuccessful; + ret_val &= startSingleMeasurement(); + if (!getStatusBit(MEASUREMENT_SUCCESSFUL)) { + // If the measurement didn't start, bump the measurement attempt + // count to trigger retry logic, but skip waiting for measurement + // completion and adding a result since we didn't actually start a + // measurement + bumpMeasurementAttemptCount(false); + } else { + // wait for the measurement to finish + waitForMeasurementCompletion(); - // Use bumpMeasurementAttemptCount to handle retry logic - if (!bumpMeasurementAttemptCount(measurementSuccessful)) { - // If we've exhausted retries and still failed, break - if (!measurementSuccessful) { break; } + // get the measurement result - this should call + // bumpMeasurementAttemptCount() and update the measurement attempt + // and retry counts as needed + ret_val &= addSingleMeasurementResult(); } } @@ -756,5 +753,7 @@ bool Sensor::bumpMeasurementAttemptCount(bool wasSuccessful) { // Reset the number of retries made for the next measurement attempt _retryAttemptsMade = 0; } + // Return the input parameter so it's easy to use this in a return statement + // to pass forward a value return wasSuccessful; } From 17ca511a3ff03935ee87155ee51f4180d6acdef8 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Wed, 4 Mar 2026 13:23:18 -0500 Subject: [PATCH 421/533] Save partially correct values Signed-off-by: Sara Damiano --- src/sensors/KellerParent.cpp | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/src/sensors/KellerParent.cpp b/src/sensors/KellerParent.cpp index 1cf540b79..0730c4a7e 100644 --- a/src/sensors/KellerParent.cpp +++ b/src/sensors/KellerParent.cpp @@ -93,35 +93,37 @@ bool KellerParent::addSingleMeasurementResult(void) { MS_DBG(getSensorNameAndLocation(), F("is reporting:")); - // Get Values - // the getValues function in the KellerModbus library will *always* return - // true, but will set the value variables to MS_INVALID_VALUE if it fails to - // get a value. So we check for success by checking that the value - // variables are not MS_INVALID_VALUE or NaN. - _ksensor.getValues(waterPressureBar, waterTemperatureC); - success = + // NOTE: As of KellerModbus library version 0.2.7, the getValues function + // will *always* return true. We set the success with it here for + // future-readiness. + success = _ksensor.getValues(waterPressureBar, waterTemperatureC); + // Since we can't depend on the return value, we check for success by + // checking that the value variables are not MS_INVALID_VALUE or NaN. + success &= (!isnan(waterPressureBar) && waterPressureBar != MS_INVALID_VALUE && !isnan(waterTemperatureC) && waterTemperatureC != MS_INVALID_VALUE); if (success) { + // display values for debugging + MS_DBG(F(" Pressure_mbar:"), waterPressure_mBar); + MS_DBG(F(" Temp_C:"), waterTemperatureC); + // Put pressure and temperature into the array + verifyAndAddMeasurementResult(KELLER_PRESSURE_VAR_NUM, + waterPressure_mBar); + verifyAndAddMeasurementResult(KELLER_TEMP_VAR_NUM, waterTemperatureC); + // calculate depth from pressure and temperature waterDepthM = _ksensor.calcWaterDepthM(waterPressureBar, waterTemperatureC); // For waterPressureBar, convert bar to millibar waterPressure_mBar = 1000 * waterPressureBar; + // display value for debugging + MS_DBG(F(" Height_m:"), waterDepthM); } - MS_DBG(F(" Pressure_mbar:"), waterPressure_mBar); - MS_DBG(F(" Temp_C:"), waterTemperatureC); - MS_DBG(F(" Height_m:"), waterDepthM); - success &= (!isnan(waterDepthM) && waterDepthM != MS_INVALID_VALUE); if (success) { - // Put values into the array - verifyAndAddMeasurementResult(KELLER_PRESSURE_VAR_NUM, - waterPressure_mBar); - verifyAndAddMeasurementResult(KELLER_TEMP_VAR_NUM, waterTemperatureC); verifyAndAddMeasurementResult(KELLER_HEIGHT_VAR_NUM, waterDepthM); } From 7103f5343135c66c41ce2f51a14a1cbf82b7d5bb Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Wed, 4 Mar 2026 14:00:31 -0500 Subject: [PATCH 422/533] Made destructors override where applicable Signed-off-by: Sara Damiano --- src/LoggerModem.h | 12 ++++---- src/VariableBase.h | 2 +- src/modems/DigiXBee.h | 2 +- src/modems/DigiXBee3GBypass.h | 2 +- src/modems/DigiXBeeCellularTransparent.h | 2 +- src/modems/DigiXBeeLTEBypass.h | 2 +- src/modems/DigiXBeeWifi.h | 2 +- src/modems/Espressif.h | 2 +- src/modems/EspressifESP32.h | 2 +- src/modems/EspressifESP8266.h | 2 +- src/modems/QuectelBG96.h | 2 +- src/modems/SIMComSIM7000.h | 2 +- src/modems/SIMComSIM7080.h | 2 +- src/modems/SIMComSIM800.h | 2 +- src/modems/SequansMonarch.h | 2 +- src/modems/Sodaq2GBeeR6.h | 2 +- src/modems/SodaqUBeeR410M.h | 2 +- src/modems/SodaqUBeeU201.h | 2 +- src/publishers/AWS_IoT_Publisher.h | 2 +- src/publishers/DreamHostPublisher.h | 2 +- src/publishers/MonitorMyWatershedPublisher.h | 2 +- src/publishers/S3PresignedPublisher.h | 2 +- src/publishers/ThingSpeakPublisher.h | 2 +- src/publishers/UbidotsPublisher.h | 2 +- src/sensors/ANBpH.h | 18 ++++++------ src/sensors/AOSongAM2315.h | 6 ++-- src/sensors/AOSongDHT.h | 8 +++--- src/sensors/AlphasenseCO2.h | 6 ++-- src/sensors/AnalogElecConductivity.h | 4 +-- src/sensors/ApogeeSQ212.h | 6 ++-- src/sensors/AtlasParent.h | 2 +- src/sensors/AtlasScientificCO2.h | 6 ++-- src/sensors/AtlasScientificDO.cpp | 3 +- src/sensors/AtlasScientificDO.h | 6 ++-- src/sensors/AtlasScientificEC.h | 10 +++---- src/sensors/AtlasScientificORP.h | 4 +-- src/sensors/AtlasScientificRTD.h | 4 +-- src/sensors/AtlasScientificpH.h | 4 +-- src/sensors/BoschBME280.h | 6 ++-- src/sensors/BoschBMP3xx.h | 6 ++-- src/sensors/CampbellClariVUE10.h | 8 +++--- src/sensors/CampbellOBS3.h | 6 ++-- src/sensors/CampbellRainVUE10.h | 10 +++---- src/sensors/Decagon5TM.h | 8 +++--- src/sensors/DecagonCTD.h | 8 +++--- src/sensors/DecagonES2.h | 6 ++-- src/sensors/EverlightALSPT19.h | 8 +++--- src/sensors/FreescaleMPL115A2.h | 6 ++-- src/sensors/GeoluxHydroCam.h | 6 ++-- src/sensors/GroPointGPLP8.h | 6 ++-- src/sensors/GroPointParent.h | 2 +- src/sensors/InSituRDO.h | 10 +++---- src/sensors/InSituTrollSdi12a.h | 8 +++--- src/sensors/KellerAcculevel.h | 8 +++--- src/sensors/KellerNanolevel.h | 8 +++--- src/sensors/KellerParent.h | 2 +- src/sensors/MaxBotixSonar.h | 4 +-- src/sensors/MaximDS18.h | 4 +-- src/sensors/MaximDS3231.h | 4 +-- src/sensors/MeaSpecMS5803.h | 6 ++-- src/sensors/MeterHydros21.h | 8 +++--- src/sensors/MeterTeros11.h | 10 +++---- src/sensors/PaleoTerraRedox.h | 4 +-- src/sensors/ProcessorAnalog.h | 6 ++-- src/sensors/ProcessorStats.h | 10 +++---- src/sensors/RainCounterI2C.h | 6 ++-- src/sensors/SDI12Sensors.h | 2 +- src/sensors/SensirionSHT4x.h | 6 ++-- src/sensors/TEConnectivityMS5837.h | 10 +++---- src/sensors/TIADS1x15.h | 4 +-- src/sensors/TIINA219.h | 8 +++--- src/sensors/TallyCounterI2C.h | 6 ++-- src/sensors/TurnerCyclops.h | 30 ++++++++++---------- src/sensors/TurnerTurbidityPlus.h | 6 ++-- src/sensors/VegaPuls21.h | 12 ++++---- src/sensors/YosemitechParent.h | 2 +- src/sensors/YosemitechY4000.h | 18 ++++++------ src/sensors/YosemitechY504.h | 8 +++--- src/sensors/YosemitechY510.h | 6 ++-- src/sensors/YosemitechY511.h | 6 ++-- src/sensors/YosemitechY513.h | 6 ++-- src/sensors/YosemitechY514.h | 6 ++-- src/sensors/YosemitechY520.h | 6 ++-- src/sensors/YosemitechY532.h | 8 +++--- src/sensors/YosemitechY533.h | 6 ++-- src/sensors/YosemitechY551.h | 8 +++--- src/sensors/YosemitechY560.h | 8 +++--- src/sensors/YosemitechY700.h | 6 ++-- src/sensors/ZebraTechDOpto.h | 8 +++--- 89 files changed, 257 insertions(+), 258 deletions(-) diff --git a/src/LoggerModem.h b/src/LoggerModem.h index 28a115bb9..5f7fea1fb 100644 --- a/src/LoggerModem.h +++ b/src/LoggerModem.h @@ -1257,7 +1257,7 @@ class Modem_RSSI : public Variable { /** * @brief Destroy the Modem_RSSI object - no action needed. */ - ~Modem_RSSI() = default; + ~Modem_RSSI() override = default; }; @@ -1292,7 +1292,7 @@ class Modem_SignalPercent : public Variable { /** * @brief Destroy the Modem_SignalPercent object - no action needed. */ - ~Modem_SignalPercent() = default; + ~Modem_SignalPercent() override = default; }; @@ -1330,7 +1330,7 @@ class Modem_BatteryState : public Variable { /** * @brief Destroy the Modem_BatteryState object - no action needed. */ - ~Modem_BatteryState() = default; + ~Modem_BatteryState() override = default; }; @@ -1369,7 +1369,7 @@ class Modem_BatteryPercent : public Variable { /** * @brief Destroy the Modem_BatteryPercent object - no action needed. */ - ~Modem_BatteryPercent() = default; + ~Modem_BatteryPercent() override = default; }; @@ -1408,7 +1408,7 @@ class Modem_BatteryVoltage : public Variable { /** * @brief Destroy the Modem_BatteryVoltage object - no action needed. */ - ~Modem_BatteryVoltage() = default; + ~Modem_BatteryVoltage() override = default; }; @@ -1445,7 +1445,7 @@ class Modem_Temp : public Variable { /** * @brief Destroy the Modem_Temp object - no action needed. */ - ~Modem_Temp() = default; + ~Modem_Temp() override = default; }; #endif // SRC_LOGGERMODEM_H_ diff --git a/src/VariableBase.h b/src/VariableBase.h index 80acaaef3..8c35d66f3 100644 --- a/src/VariableBase.h +++ b/src/VariableBase.h @@ -155,7 +155,7 @@ class Variable { /** * @brief Destroy the Variable object - no action taken. */ - ~Variable() = default; + virtual ~Variable() = default; /** * @brief Begin for the Variable object diff --git a/src/modems/DigiXBee.h b/src/modems/DigiXBee.h index d2bddbb17..b3efb794f 100644 --- a/src/modems/DigiXBee.h +++ b/src/modems/DigiXBee.h @@ -221,7 +221,7 @@ class DigiXBee : public loggerModem { /** * @brief Destroy the Digi XBee object - no action taken */ - virtual ~DigiXBee() = default; + virtual ~DigiXBee() override = default; protected: bool modemSleepFxn(void) override; diff --git a/src/modems/DigiXBee3GBypass.h b/src/modems/DigiXBee3GBypass.h index 4f27b9db4..4ebc2a8b6 100644 --- a/src/modems/DigiXBee3GBypass.h +++ b/src/modems/DigiXBee3GBypass.h @@ -125,7 +125,7 @@ class DigiXBee3GBypass : public DigiXBee { /** * @brief Destroy the Digi XBee 3G Bypass object - no action needed */ - ~DigiXBee3GBypass() = default; + ~DigiXBee3GBypass() override = default; bool modemWake(void) override; diff --git a/src/modems/DigiXBeeCellularTransparent.h b/src/modems/DigiXBeeCellularTransparent.h index 30d296ef5..782839944 100644 --- a/src/modems/DigiXBeeCellularTransparent.h +++ b/src/modems/DigiXBeeCellularTransparent.h @@ -159,7 +159,7 @@ class DigiXBeeCellularTransparent : public DigiXBee { * @brief Destroy the Digi XBee Cellular Transparent object - no action * needed */ - ~DigiXBeeCellularTransparent() = default; + ~DigiXBeeCellularTransparent() override = default; bool modemWake(void) override; diff --git a/src/modems/DigiXBeeLTEBypass.h b/src/modems/DigiXBeeLTEBypass.h index 0329f0246..d9b5c095b 100644 --- a/src/modems/DigiXBeeLTEBypass.h +++ b/src/modems/DigiXBeeLTEBypass.h @@ -140,7 +140,7 @@ class DigiXBeeLTEBypass : public DigiXBee { /** * @brief Destroy the Digi XBee LTE Bypass object - no action needed */ - ~DigiXBeeLTEBypass() = default; + ~DigiXBeeLTEBypass() override = default; bool modemWake(void) override; diff --git a/src/modems/DigiXBeeWifi.h b/src/modems/DigiXBeeWifi.h index 9ab6d02ea..300470eb6 100644 --- a/src/modems/DigiXBeeWifi.h +++ b/src/modems/DigiXBeeWifi.h @@ -135,7 +135,7 @@ class DigiXBeeWifi : public DigiXBee { /** * @brief Destroy the Digi XBee Wifi object - no action taken */ - ~DigiXBeeWifi() = default; + ~DigiXBeeWifi() override = default; bool modemWake(void) override; diff --git a/src/modems/Espressif.h b/src/modems/Espressif.h index a17331fec..8e366850c 100644 --- a/src/modems/Espressif.h +++ b/src/modems/Espressif.h @@ -200,7 +200,7 @@ class Espressif : public loggerModem { /** * @brief Destroy the Espressif object - no action taken */ - virtual ~Espressif() = default; + virtual ~Espressif() override = default; /** * @brief A pointer to the Arduino serial Stream used for communication diff --git a/src/modems/EspressifESP32.h b/src/modems/EspressifESP32.h index bba60130a..cda24da93 100644 --- a/src/modems/EspressifESP32.h +++ b/src/modems/EspressifESP32.h @@ -123,7 +123,7 @@ class EspressifESP32 : public Espressif { /** * @brief Destroy the Espressif ESP32 object - no action taken */ - ~EspressifESP32() = default; + ~EspressifESP32() override = default; bool modemWake(void) override; diff --git a/src/modems/EspressifESP8266.h b/src/modems/EspressifESP8266.h index 3022783eb..4ed6249cb 100644 --- a/src/modems/EspressifESP8266.h +++ b/src/modems/EspressifESP8266.h @@ -122,7 +122,7 @@ class EspressifESP8266 : public Espressif { /** * @brief Destroy the Espressif ESP8266 object - no action taken */ - ~EspressifESP8266() = default; + ~EspressifESP8266() override = default; bool modemWake(void) override; diff --git a/src/modems/QuectelBG96.h b/src/modems/QuectelBG96.h index bf362e63d..6a9421632 100644 --- a/src/modems/QuectelBG96.h +++ b/src/modems/QuectelBG96.h @@ -200,7 +200,7 @@ class QuectelBG96 : public loggerModem { /** * @brief Destroy the Quectel BG96 object - no action taken */ - ~QuectelBG96() = default; + ~QuectelBG96() override = default; bool modemWake(void) override; diff --git a/src/modems/SIMComSIM7000.h b/src/modems/SIMComSIM7000.h index fb1105d13..0d38ef5ac 100644 --- a/src/modems/SIMComSIM7000.h +++ b/src/modems/SIMComSIM7000.h @@ -188,7 +188,7 @@ class SIMComSIM7000 : public loggerModem { /** * @brief Destroy the SIMComSIM7000 object - no action needed */ - ~SIMComSIM7000() = default; + ~SIMComSIM7000() override = default; bool modemWake(void) override; diff --git a/src/modems/SIMComSIM7080.h b/src/modems/SIMComSIM7080.h index ca98ff0e1..7836bbb1b 100644 --- a/src/modems/SIMComSIM7080.h +++ b/src/modems/SIMComSIM7080.h @@ -183,7 +183,7 @@ class SIMComSIM7080 : public loggerModem { /** * @brief Destroy the SIMComSIM7080 object - no action needed */ - ~SIMComSIM7080() = default; + ~SIMComSIM7080() override = default; bool modemWake(void) override; diff --git a/src/modems/SIMComSIM800.h b/src/modems/SIMComSIM800.h index 416a7dc95..7f5cf14ce 100644 --- a/src/modems/SIMComSIM800.h +++ b/src/modems/SIMComSIM800.h @@ -190,7 +190,7 @@ class SIMComSIM800 : public loggerModem { /** * @brief Destroy the SIMComSIM800 object - no action taken */ - ~SIMComSIM800() = default; + ~SIMComSIM800() override = default; bool modemWake(void) override; diff --git a/src/modems/SequansMonarch.h b/src/modems/SequansMonarch.h index a617cda9c..5cb688970 100644 --- a/src/modems/SequansMonarch.h +++ b/src/modems/SequansMonarch.h @@ -221,7 +221,7 @@ class SequansMonarch : public loggerModem { /** * @brief Destroy the Sequans Monarch object - no action taken */ - ~SequansMonarch() = default; + ~SequansMonarch() override = default; bool modemWake(void) override; diff --git a/src/modems/Sodaq2GBeeR6.h b/src/modems/Sodaq2GBeeR6.h index 6862bac44..c977639c8 100644 --- a/src/modems/Sodaq2GBeeR6.h +++ b/src/modems/Sodaq2GBeeR6.h @@ -162,7 +162,7 @@ class Sodaq2GBeeR6 : public SIMComSIM800 { /** * @brief Destroy the Sodaq 2GBee R6 object - no action taken */ - ~Sodaq2GBeeR6() = default; + ~Sodaq2GBeeR6() override = default; /** * @brief Sets the pin to use to control voltage reference on the GPRSBee. diff --git a/src/modems/SodaqUBeeR410M.h b/src/modems/SodaqUBeeR410M.h index e5b112385..8d97a879e 100644 --- a/src/modems/SodaqUBeeR410M.h +++ b/src/modems/SodaqUBeeR410M.h @@ -297,7 +297,7 @@ class SodaqUBeeR410M : public loggerModem { /** * @brief Destroy the Sodaq UBee R410M object - no action needed */ - ~SodaqUBeeR410M() = default; + ~SodaqUBeeR410M() override = default; bool modemWake(void) override; diff --git a/src/modems/SodaqUBeeU201.h b/src/modems/SodaqUBeeU201.h index e61c9c33b..2c505381a 100644 --- a/src/modems/SodaqUBeeU201.h +++ b/src/modems/SodaqUBeeU201.h @@ -196,7 +196,7 @@ class SodaqUBeeU201 : public loggerModem { /** * @brief Destroy the Sodaq UBee U201 object - no action taken */ - ~SodaqUBeeU201() = default; + ~SodaqUBeeU201() override = default; bool modemWake(void) override; diff --git a/src/publishers/AWS_IoT_Publisher.h b/src/publishers/AWS_IoT_Publisher.h index c302c46b7..134b9d8dd 100644 --- a/src/publishers/AWS_IoT_Publisher.h +++ b/src/publishers/AWS_IoT_Publisher.h @@ -173,7 +173,7 @@ class AWS_IoT_Publisher : public dataPublisher { /** * @brief Destroy the AWS IoT Core Publisher object */ - virtual ~AWS_IoT_Publisher() = default; + virtual ~AWS_IoT_Publisher() override = default; // Returns the data destination String getEndpoint(void) override { diff --git a/src/publishers/DreamHostPublisher.h b/src/publishers/DreamHostPublisher.h index 31d9d58b9..deda69cdc 100644 --- a/src/publishers/DreamHostPublisher.h +++ b/src/publishers/DreamHostPublisher.h @@ -101,7 +101,7 @@ class DreamHostPublisher : public dataPublisher { /** * @brief Destroy the DreamHost Publisher object */ - virtual ~DreamHostPublisher() = default; + virtual ~DreamHostPublisher() override = default; // Returns the data destination String getEndpoint(void) override { diff --git a/src/publishers/MonitorMyWatershedPublisher.h b/src/publishers/MonitorMyWatershedPublisher.h index cc9d5c6c7..d412caeb6 100644 --- a/src/publishers/MonitorMyWatershedPublisher.h +++ b/src/publishers/MonitorMyWatershedPublisher.h @@ -141,7 +141,7 @@ class MonitorMyWatershedPublisher : public dataPublisher { /** * @brief Destroy the Monitor My Watershed Publisher object */ - virtual ~MonitorMyWatershedPublisher() = default; + virtual ~MonitorMyWatershedPublisher() override = default; // Returns the data destination String getEndpoint(void) override { diff --git a/src/publishers/S3PresignedPublisher.h b/src/publishers/S3PresignedPublisher.h index 55ecfd84a..d9683151b 100644 --- a/src/publishers/S3PresignedPublisher.h +++ b/src/publishers/S3PresignedPublisher.h @@ -176,7 +176,7 @@ class S3PresignedPublisher : public dataPublisher { /** * @brief Destroy the S3 Publisher object */ - virtual ~S3PresignedPublisher() = default; + virtual ~S3PresignedPublisher() override = default; /** * @brief Set the S3 host name diff --git a/src/publishers/ThingSpeakPublisher.h b/src/publishers/ThingSpeakPublisher.h index e1068a95a..6daac7f32 100644 --- a/src/publishers/ThingSpeakPublisher.h +++ b/src/publishers/ThingSpeakPublisher.h @@ -127,7 +127,7 @@ class ThingSpeakPublisher : public dataPublisher { /** * @brief Destroy the ThingSpeak Publisher object */ - virtual ~ThingSpeakPublisher() = default; + virtual ~ThingSpeakPublisher() override = default; // Returns the data destination String getEndpoint(void) override { diff --git a/src/publishers/UbidotsPublisher.h b/src/publishers/UbidotsPublisher.h index 94d4463f1..e492e0f6a 100644 --- a/src/publishers/UbidotsPublisher.h +++ b/src/publishers/UbidotsPublisher.h @@ -110,7 +110,7 @@ class UbidotsPublisher : public dataPublisher { /** * @brief Destroy the Ubidots Publisher object */ - virtual ~UbidotsPublisher() = default; + virtual ~UbidotsPublisher() override = default; // Returns the data destination /** diff --git a/src/sensors/ANBpH.h b/src/sensors/ANBpH.h index 042671b77..d16f5d978 100644 --- a/src/sensors/ANBpH.h +++ b/src/sensors/ANBpH.h @@ -538,7 +538,7 @@ class ANBpH : public Sensor { /** * @brief Destroy the ANB pH object - no action taken */ - virtual ~ANBpH() = default; + virtual ~ANBpH() override = default; String getSensorLocation(void) override; @@ -746,7 +746,7 @@ class ANBpH_pH : public Variable { /** * @brief Destroy the ANBpH_pH object - no action needed. */ - ~ANBpH_pH() = default; + ~ANBpH_pH() override = default; }; /* clang-format off */ @@ -785,7 +785,7 @@ class ANBpH_Temp : public Variable { /** * @brief Destroy the ANBpH_Temp object - no action needed. */ - ~ANBpH_Temp() = default; + ~ANBpH_Temp() override = default; }; /* clang-format off */ @@ -827,7 +827,7 @@ class ANBpH_Salinity : public Variable { * @brief Destroy the ANBpH_Salinity() object - no action * needed. */ - ~ANBpH_Salinity() = default; + ~ANBpH_Salinity() override = default; }; @@ -866,7 +866,7 @@ class ANBpH_SpCond : public Variable { /** * @brief Destroy the ANBpH_SpCond object - no action needed. */ - ~ANBpH_SpCond() = default; + ~ANBpH_SpCond() override = default; }; /* clang-format off */ @@ -905,7 +905,7 @@ class ANBpH_EC : public Variable { /** * @brief Destroy the ANBpH_EC object - no action needed. */ - ~ANBpH_EC() = default; + ~ANBpH_EC() override = default; }; @@ -950,7 +950,7 @@ class ANBpH_HealthCode : public Variable { * @brief Destroy the ANBpH_HealthCode object - no action * needed. */ - ~ANBpH_HealthCode() = default; + ~ANBpH_HealthCode() override = default; }; @@ -996,7 +996,7 @@ class ANBpH_DiagnosticCode : public Variable { * @brief Destroy the ANBpH_DiagnosticCode object - no action * needed. */ - ~ANBpH_DiagnosticCode() = default; + ~ANBpH_DiagnosticCode() override = default; }; @@ -1041,7 +1041,7 @@ class ANBpH_StatusCode : public Variable { * @brief Destroy the ANBpH_StatusCode object - no action * needed. */ - ~ANBpH_StatusCode() = default; + ~ANBpH_StatusCode() override = default; }; /**@}*/ #endif // SRC_SENSORS_ANB_SENSORS_PH_H_ diff --git a/src/sensors/AOSongAM2315.h b/src/sensors/AOSongAM2315.h index ae3b8a3f1..a32bd4197 100644 --- a/src/sensors/AOSongAM2315.h +++ b/src/sensors/AOSongAM2315.h @@ -213,9 +213,9 @@ class AOSongAM2315 : public Sensor { */ explicit AOSongAM2315(int8_t powerPin, uint8_t measurementsToAverage = 1); /** - * @brief Destroy the AOSongAM2315 object - no action needed. + * @brief Destroy the AOSongAM2315 object */ - ~AOSongAM2315(); + ~AOSongAM2315() override; /** * @brief Report the I2C address of the AM2315 - which is always 0xB8. @@ -330,7 +330,7 @@ class AOSongAM2315_Temp : public Variable { /** * @brief Destroy the AOSongAM2315_Temp object - no action needed. */ - ~AOSongAM2315_Temp() = default; + ~AOSongAM2315_Temp() override = default; }; /**@}*/ #endif // SRC_SENSORS_AOSONGAM2315_H_ diff --git a/src/sensors/AOSongDHT.h b/src/sensors/AOSongDHT.h index 69aebd458..2147ba795 100644 --- a/src/sensors/AOSongDHT.h +++ b/src/sensors/AOSongDHT.h @@ -269,7 +269,7 @@ class AOSongDHT : public Sensor { /** * @brief Destroy the AOSongDHT object - no action needed. */ - ~AOSongDHT() = default; + ~AOSongDHT() override = default; bool setup(void) override; @@ -319,7 +319,7 @@ class AOSongDHT_Humidity : public Variable { /** * @brief Destroy the AOSongDHT_Humidity object - no action needed. */ - ~AOSongDHT_Humidity() = default; + ~AOSongDHT_Humidity() override = default; }; @@ -360,7 +360,7 @@ class AOSongDHT_Temp : public Variable { /** * @brief Destroy the AOSongDHT_Temp object - no action needed. */ - ~AOSongDHT_Temp() = default; + ~AOSongDHT_Temp() override = default; }; @@ -400,7 +400,7 @@ class AOSongDHT_HI : public Variable { /** * @brief Destroy the AOSongDHT_HI object - no action needed. */ - ~AOSongDHT_HI() = default; + ~AOSongDHT_HI() override = default; }; /**@}*/ #endif // SRC_SENSORS_AOSONGDHT_H_ diff --git a/src/sensors/AlphasenseCO2.h b/src/sensors/AlphasenseCO2.h index 8133dab31..1e5725230 100644 --- a/src/sensors/AlphasenseCO2.h +++ b/src/sensors/AlphasenseCO2.h @@ -301,7 +301,7 @@ class AlphasenseCO2 : public Sensor { /** * @brief Destroy the AlphasenseCO2 object */ - ~AlphasenseCO2(); + ~AlphasenseCO2() override; // Delete copy constructor and copy assignment operator to prevent shallow // copies @@ -374,7 +374,7 @@ class AlphasenseCO2_CO2 : public Variable { /** * @brief Destroy the AlphasenseCO2_CO2 object - no action needed. */ - ~AlphasenseCO2_CO2() = default; + ~AlphasenseCO2_CO2() override = default; }; @@ -419,7 +419,7 @@ class AlphasenseCO2_Voltage : public Variable { /** * @brief Destroy the AlphasenseCO2_Voltage object - no action needed. */ - ~AlphasenseCO2_Voltage() = default; + ~AlphasenseCO2_Voltage() override = default; }; /**@}*/ #endif // SRC_SENSORS_ALPHASENSECO2_H_ diff --git a/src/sensors/AnalogElecConductivity.h b/src/sensors/AnalogElecConductivity.h index e65cf0bbb..225a7667e 100644 --- a/src/sensors/AnalogElecConductivity.h +++ b/src/sensors/AnalogElecConductivity.h @@ -334,7 +334,7 @@ class AnalogElecConductivity : public Sensor { * * Deletes the internal analog voltage reader if this object owns it. */ - ~AnalogElecConductivity(); + ~AnalogElecConductivity() override; // Delete copy constructor and copy assignment operator to prevent shallow // copies @@ -425,7 +425,7 @@ class AnalogElecConductivity_EC : public Variable { /** * @brief Destroy the AnalogElecConductivity_EC object - no action needed. */ - ~AnalogElecConductivity_EC() = default; + ~AnalogElecConductivity_EC() override = default; }; /**@}*/ #endif // SRC_SENSORS_ANALOGELECCONDUCTIVITY_H_ diff --git a/src/sensors/ApogeeSQ212.h b/src/sensors/ApogeeSQ212.h index 59f379eb6..1563bb225 100644 --- a/src/sensors/ApogeeSQ212.h +++ b/src/sensors/ApogeeSQ212.h @@ -280,7 +280,7 @@ class ApogeeSQ212 : public Sensor { /** * @brief Destroy the ApogeeSQ212 object */ - ~ApogeeSQ212(); + ~ApogeeSQ212() override; // Delete copy constructor and copy assignment operator to prevent shallow // copies @@ -344,7 +344,7 @@ class ApogeeSQ212_PAR : public Variable { /** * @brief Destroy the ApogeeSQ212_PAR object - no action needed. */ - ~ApogeeSQ212_PAR() = default; + ~ApogeeSQ212_PAR() override = default; }; @@ -387,7 +387,7 @@ class ApogeeSQ212_Voltage : public Variable { /** * @brief Destroy the ApogeeSQ212_Voltage object - no action needed. */ - ~ApogeeSQ212_Voltage() = default; + ~ApogeeSQ212_Voltage() override = default; }; /**@}*/ #endif // SRC_SENSORS_APOGEESQ212_H_ diff --git a/src/sensors/AtlasParent.h b/src/sensors/AtlasParent.h index 1d43012c5..f50f3e73f 100644 --- a/src/sensors/AtlasParent.h +++ b/src/sensors/AtlasParent.h @@ -173,7 +173,7 @@ class AtlasParent : public Sensor { /** * @brief Destroy the Atlas Parent object. */ - virtual ~AtlasParent() = default; + virtual ~AtlasParent() override = default; /** * @brief Return the I2C address of the EZO circuit. diff --git a/src/sensors/AtlasScientificCO2.h b/src/sensors/AtlasScientificCO2.h index cd5f769bc..f97c1dc2c 100644 --- a/src/sensors/AtlasScientificCO2.h +++ b/src/sensors/AtlasScientificCO2.h @@ -230,7 +230,7 @@ class AtlasScientificCO2 : public AtlasParent { /** * @brief Destroy the Atlas Scientific CO2 object. */ - ~AtlasScientificCO2() = default; + ~AtlasScientificCO2() override = default; /** * @brief Do any one-time preparations needed before the sensor will be able @@ -285,7 +285,7 @@ class AtlasScientificCO2_CO2 : public Variable { /** * @brief Destroy the AtlasScientificCO2_CO2 object - no action needed. */ - ~AtlasScientificCO2_CO2() = default; + ~AtlasScientificCO2_CO2() override = default; }; /* clang-format off */ @@ -328,7 +328,7 @@ class AtlasScientificCO2_Temp : public Variable { /** * @brief Destroy the AtlasScientificCO2_Temp object - no action needed. */ - ~AtlasScientificCO2_Temp() = default; + ~AtlasScientificCO2_Temp() override = default; }; /**@}*/ #endif // SRC_SENSORS_ATLASSCIENTIFICCO2_H_ diff --git a/src/sensors/AtlasScientificDO.cpp b/src/sensors/AtlasScientificDO.cpp index c25f0dbb3..218d54c2b 100644 --- a/src/sensors/AtlasScientificDO.cpp +++ b/src/sensors/AtlasScientificDO.cpp @@ -23,8 +23,7 @@ AtlasScientificDO::AtlasScientificDO(TwoWire* theI2C, int8_t powerPin, // Delegating constructor AtlasScientificDO::AtlasScientificDO(int8_t powerPin, uint8_t i2cAddressHex, uint8_t measurementsToAverage) - : AtlasScientificDO(&Wire, powerPin, i2cAddressHex, measurementsToAverage) { -} + : AtlasScientificDO(&Wire, powerPin, i2cAddressHex, measurementsToAverage) {} // Setup diff --git a/src/sensors/AtlasScientificDO.h b/src/sensors/AtlasScientificDO.h index a21f34a66..62d47efef 100644 --- a/src/sensors/AtlasScientificDO.h +++ b/src/sensors/AtlasScientificDO.h @@ -239,7 +239,7 @@ class AtlasScientificDO : public AtlasParent { /** * @brief Destroy the Atlas Scientific DO object */ - ~AtlasScientificDO() = default; + ~AtlasScientificDO() override = default; /** * @brief Do any one-time preparations needed before the sensor will be able @@ -294,7 +294,7 @@ class AtlasScientificDO_DOmgL : public Variable { /** * @brief Destroy the AtlasScientificDO_DOmgL object - no action needed. */ - ~AtlasScientificDO_DOmgL() = default; + ~AtlasScientificDO_DOmgL() override = default; }; /* clang-format off */ @@ -337,7 +337,7 @@ class AtlasScientificDO_DOpct : public Variable { /** * @brief Destroy the AtlasScientificDO_DOpct object - no action needed. */ - ~AtlasScientificDO_DOpct() = default; + ~AtlasScientificDO_DOpct() override = default; }; /**@}*/ #endif // SRC_SENSORS_ATLASSCIENTIFICDO_H_ diff --git a/src/sensors/AtlasScientificEC.h b/src/sensors/AtlasScientificEC.h index f7d8d9850..4985b72f9 100644 --- a/src/sensors/AtlasScientificEC.h +++ b/src/sensors/AtlasScientificEC.h @@ -302,7 +302,7 @@ class AtlasScientificEC : public AtlasParent { /** * @brief Destroy the Atlas Scientific EC object */ - ~AtlasScientificEC() = default; + ~AtlasScientificEC() override = default; /** * @brief Do any one-time preparations needed before the sensor will be able @@ -357,7 +357,7 @@ class AtlasScientificEC_Cond : public Variable { /** * @brief Destroy the AtlasScientificEC_Cond object - no action needed. */ - ~AtlasScientificEC_Cond() = default; + ~AtlasScientificEC_Cond() override = default; }; /* clang-format off */ @@ -400,7 +400,7 @@ class AtlasScientificEC_TDS : public Variable { /** * @brief Destroy the AtlasScientificEC_TDS object - no action needed. */ - ~AtlasScientificEC_TDS() = default; + ~AtlasScientificEC_TDS() override = default; }; /* clang-format off */ @@ -444,7 +444,7 @@ class AtlasScientificEC_Salinity : public Variable { * @brief Destroy the AtlasScientificEC_Salinity() object - no action * needed. */ - ~AtlasScientificEC_Salinity() = default; + ~AtlasScientificEC_Salinity() override = default; }; /* clang-format off */ @@ -488,7 +488,7 @@ class AtlasScientificEC_SpecificGravity : public Variable { * @brief Destroy the AtlasScientificEC_SpecificGravity() object - no action * needed. */ - ~AtlasScientificEC_SpecificGravity() = default; + ~AtlasScientificEC_SpecificGravity() override = default; }; /**@}*/ #endif // SRC_SENSORS_ATLASSCIENTIFICEC_H_ diff --git a/src/sensors/AtlasScientificORP.h b/src/sensors/AtlasScientificORP.h index 955b4aaec..a1df68c50 100644 --- a/src/sensors/AtlasScientificORP.h +++ b/src/sensors/AtlasScientificORP.h @@ -197,7 +197,7 @@ class AtlasScientificORP : public AtlasParent { /** * @brief Destroy the Atlas Scientific ORP object */ - ~AtlasScientificORP() = default; + ~AtlasScientificORP() override = default; }; @@ -242,7 +242,7 @@ class AtlasScientificORP_Potential : public Variable { * @brief Destroy the AtlasScientificORP_Potential() object - no action * needed. */ - ~AtlasScientificORP_Potential() = default; + ~AtlasScientificORP_Potential() override = default; }; /**@}*/ #endif // SRC_SENSORS_ATLASSCIENTIFICORP_H_ diff --git a/src/sensors/AtlasScientificRTD.h b/src/sensors/AtlasScientificRTD.h index 17ed5f70a..f5bdd769b 100644 --- a/src/sensors/AtlasScientificRTD.h +++ b/src/sensors/AtlasScientificRTD.h @@ -205,7 +205,7 @@ class AtlasScientificRTD : public AtlasParent { /** * @brief Destroy the Atlas Scientific RTD object */ - ~AtlasScientificRTD() = default; + ~AtlasScientificRTD() override = default; }; /* clang-format off */ @@ -248,7 +248,7 @@ class AtlasScientificRTD_Temp : public Variable { /** * @brief Destroy the AtlasScientificRTD_Temp object - no action needed. */ - ~AtlasScientificRTD_Temp() = default; + ~AtlasScientificRTD_Temp() override = default; }; /**@}*/ #endif // SRC_SENSORS_ATLASSCIENTIFICRTD_H_ diff --git a/src/sensors/AtlasScientificpH.h b/src/sensors/AtlasScientificpH.h index e80b4c66f..56c28b302 100644 --- a/src/sensors/AtlasScientificpH.h +++ b/src/sensors/AtlasScientificpH.h @@ -203,7 +203,7 @@ class AtlasScientificpH : public AtlasParent { /** * @brief Destroy the Atlas Scientific pH object */ - ~AtlasScientificpH() = default; + ~AtlasScientificpH() override = default; }; @@ -249,7 +249,7 @@ class AtlasScientificpH_pH : public Variable { /** * @brief Destroy the AtlasScientificpH_pH object - no action needed. */ - ~AtlasScientificpH_pH() = default; + ~AtlasScientificpH_pH() override = default; }; /**@}*/ #endif // SRC_SENSORS_ATLASSCIENTIFICPH_H_ diff --git a/src/sensors/BoschBME280.h b/src/sensors/BoschBME280.h index 5f358dbf2..10e6a2f91 100644 --- a/src/sensors/BoschBME280.h +++ b/src/sensors/BoschBME280.h @@ -378,7 +378,7 @@ class BoschBME280_Temp : public Variable { /** * @brief Destroy the BoschBME280_Temp object - no action needed. */ - ~BoschBME280_Temp() = default; + ~BoschBME280_Temp() override = default; }; @@ -423,7 +423,7 @@ class BoschBME280_Humidity : public Variable { /** * @brief Destroy the BoschBME280_Humidity object - no action needed. */ - ~BoschBME280_Humidity() = default; + ~BoschBME280_Humidity() override = default; }; @@ -513,7 +513,7 @@ class BoschBME280_Altitude : public Variable { /** * @brief Destroy the BoschBME280_Altitude object - no action needed. */ - ~BoschBME280_Altitude() = default; + ~BoschBME280_Altitude() override = default; }; /**@}*/ #endif // SRC_SENSORS_BOSCHBME280_H_ diff --git a/src/sensors/BoschBMP3xx.h b/src/sensors/BoschBMP3xx.h index 60a7c26bb..c6b629947 100644 --- a/src/sensors/BoschBMP3xx.h +++ b/src/sensors/BoschBMP3xx.h @@ -435,7 +435,7 @@ class BoschBMP3xx : public Sensor { /** * @brief Destroy the Bosch BMP3xx object */ - ~BoschBMP3xx() = default; + ~BoschBMP3xx() override = default; bool wake(void) override; /** @@ -651,7 +651,7 @@ class BoschBMP3xx_Pressure : public Variable { /** * @brief Destroy the BoschBMP3xx_Pressure object - no action needed. */ - ~BoschBMP3xx_Pressure() = default; + ~BoschBMP3xx_Pressure() override = default; }; @@ -696,7 +696,7 @@ class BoschBMP3xx_Altitude : public Variable { /** * @brief Destroy the BoschBMP3xx_Altitude object - no action needed. */ - ~BoschBMP3xx_Altitude() = default; + ~BoschBMP3xx_Altitude() override = default; }; /**@}*/ #endif // SRC_SENSORS_BOSCHBMP3XX_H_ diff --git a/src/sensors/CampbellClariVUE10.h b/src/sensors/CampbellClariVUE10.h index c950a20be..855d7874a 100644 --- a/src/sensors/CampbellClariVUE10.h +++ b/src/sensors/CampbellClariVUE10.h @@ -255,7 +255,7 @@ class CampbellClariVUE10 : public SDI12Sensors { /** * @brief Destroy the Campbell ClariVUE10 object */ - ~CampbellClariVUE10() = default; + ~CampbellClariVUE10() override = default; }; @@ -303,7 +303,7 @@ class CampbellClariVUE10_Turbidity : public Variable { * @brief Destroy the CampbellClariVUE10_Turbidity object - no action * needed. */ - ~CampbellClariVUE10_Turbidity() = default; + ~CampbellClariVUE10_Turbidity() override = default; }; @@ -349,7 +349,7 @@ class CampbellClariVUE10_Temp : public Variable { /** * @brief Destroy the CampbellClariVUE10_Temp object - no action needed. */ - ~CampbellClariVUE10_Temp() = default; + ~CampbellClariVUE10_Temp() override = default; }; @@ -397,7 +397,7 @@ class CampbellClariVUE10_ErrorCode : public Variable { * @brief Destroy the CampbellClariVUE10_ErrorCode object - no action * needed. */ - ~CampbellClariVUE10_ErrorCode() = default; + ~CampbellClariVUE10_ErrorCode() override = default; }; /**@}*/ #endif // SRC_SENSORS_CAMPBELLCLARIVUE10_H_ diff --git a/src/sensors/CampbellOBS3.h b/src/sensors/CampbellOBS3.h index 918f7fb33..170c5f88b 100644 --- a/src/sensors/CampbellOBS3.h +++ b/src/sensors/CampbellOBS3.h @@ -277,7 +277,7 @@ class CampbellOBS3 : public Sensor { /** * @brief Destroy the Campbell OBS3 object */ - ~CampbellOBS3(); + ~CampbellOBS3() override; // Delete copy constructor and copy assignment operator to prevent shallow // copies @@ -351,7 +351,7 @@ class CampbellOBS3_Turbidity : public Variable { /** * @brief Destroy the Campbell OBS3 Turbidity object */ - ~CampbellOBS3_Turbidity() = default; + ~CampbellOBS3_Turbidity() override = default; }; @@ -396,7 +396,7 @@ class CampbellOBS3_Voltage : public Variable { /** * @brief Destroy the CampbellOBS3_Voltage object - no action needed. */ - ~CampbellOBS3_Voltage() = default; + ~CampbellOBS3_Voltage() override = default; }; /**@}*/ #endif // SRC_SENSORS_CAMPBELLOBS3_H_ diff --git a/src/sensors/CampbellRainVUE10.h b/src/sensors/CampbellRainVUE10.h index ef93e78d7..5f356317c 100644 --- a/src/sensors/CampbellRainVUE10.h +++ b/src/sensors/CampbellRainVUE10.h @@ -294,7 +294,7 @@ class CampbellRainVUE10 : public SDI12Sensors { /** * @brief Destroy the Campbell RainVUE10 object */ - ~CampbellRainVUE10() = default; + ~CampbellRainVUE10() override = default; }; @@ -342,7 +342,7 @@ class CampbellRainVUE10_Precipitation : public Variable { * @brief Destroy the CampbellRainVUE10_Precipitation object - no action * needed. */ - ~CampbellRainVUE10_Precipitation() = default; + ~CampbellRainVUE10_Precipitation() override = default; }; @@ -386,7 +386,7 @@ class CampbellRainVUE10_Tips : public Variable { /** * @brief Destroy the CampbellRainVUE10_Tips object - no action needed. */ - ~CampbellRainVUE10_Tips() = default; + ~CampbellRainVUE10_Tips() override = default; }; @@ -434,7 +434,7 @@ class CampbellRainVUE10_RainRateAve : public Variable { * @brief Destroy the CampbellRainVUE10_RainRateAve object - no action * needed. */ - ~CampbellRainVUE10_RainRateAve() = default; + ~CampbellRainVUE10_RainRateAve() override = default; }; /* clang-format off */ @@ -483,7 +483,7 @@ class CampbellRainVUE10_RainRateMax : public Variable { * @brief Destroy the CampbellRainVUE10_RainRateMax object - no action * needed. */ - ~CampbellRainVUE10_RainRateMax() = default; + ~CampbellRainVUE10_RainRateMax() override = default; }; /**@}*/ #endif // SRC_SENSORS_CAMPBELLRAINVUE10_H_ diff --git a/src/sensors/Decagon5TM.h b/src/sensors/Decagon5TM.h index 3eb23a1c0..a8cca5857 100644 --- a/src/sensors/Decagon5TM.h +++ b/src/sensors/Decagon5TM.h @@ -283,7 +283,7 @@ class Decagon5TM : public SDI12Sensors { /** * @brief Destroy the Decagon 5TM object */ - ~Decagon5TM() = default; + ~Decagon5TM() override = default; /** * @copydoc SDI12Sensors::getResults(bool verify_crc) @@ -329,7 +329,7 @@ class Decagon5TM_Ea : public Variable { /** * @brief Destroy the Decagon5TM_Ea object - no action needed. */ - ~Decagon5TM_Ea() = default; + ~Decagon5TM_Ea() override = default; }; @@ -369,7 +369,7 @@ class Decagon5TM_Temp : public Variable { /** * @brief Destroy the Decagon5TM_Temp object - no action needed. */ - ~Decagon5TM_Temp() = default; + ~Decagon5TM_Temp() override = default; }; @@ -409,7 +409,7 @@ class Decagon5TM_VWC : public Variable { /** * @brief Destroy the Decagon5TM_VWC object - no action needed. */ - ~Decagon5TM_VWC() = default; + ~Decagon5TM_VWC() override = default; }; /**@}*/ #endif // SRC_SENSORS_DECAGON5TM_H_ diff --git a/src/sensors/DecagonCTD.h b/src/sensors/DecagonCTD.h index 9f50f68f6..69a4c378c 100644 --- a/src/sensors/DecagonCTD.h +++ b/src/sensors/DecagonCTD.h @@ -256,7 +256,7 @@ class DecagonCTD : public SDI12Sensors { /** * @brief Destroy the Decagon CTD object */ - ~DecagonCTD() = default; + ~DecagonCTD() override = default; }; @@ -297,7 +297,7 @@ class DecagonCTD_Cond : public Variable { /** * @brief Destroy the DecagonCTD_Cond object - no action needed. */ - ~DecagonCTD_Cond() = default; + ~DecagonCTD_Cond() override = default; }; @@ -338,7 +338,7 @@ class DecagonCTD_Temp : public Variable { /** * @brief Destroy the DecagonCTD_Temp object - no action needed. */ - ~DecagonCTD_Temp() = default; + ~DecagonCTD_Temp() override = default; }; @@ -379,7 +379,7 @@ class DecagonCTD_Depth : public Variable { /** * @brief Destroy the DecagonCTD_Depth object - no action needed. */ - ~DecagonCTD_Depth() = default; + ~DecagonCTD_Depth() override = default; }; /**@}*/ #endif // SRC_SENSORS_decagon_ctd_H_ diff --git a/src/sensors/DecagonES2.h b/src/sensors/DecagonES2.h index edf1b8ff6..4587f81f5 100644 --- a/src/sensors/DecagonES2.h +++ b/src/sensors/DecagonES2.h @@ -218,7 +218,7 @@ class DecagonES2 : public SDI12Sensors { /** * @brief Destroy the Decagon ES2 object */ - ~DecagonES2() = default; + ~DecagonES2() override = default; }; @@ -259,7 +259,7 @@ class DecagonES2_Cond : public Variable { /** * @brief Destroy the DecagonES2_Cond object - no action needed. */ - ~DecagonES2_Cond() = default; + ~DecagonES2_Cond() override = default; }; /* clang-format off */ @@ -299,7 +299,7 @@ class DecagonES2_Temp : public Variable { /** * @brief Destroy the DecagonES2_Temp object - no action needed. */ - ~DecagonES2_Temp() = default; + ~DecagonES2_Temp() override = default; }; /**@}*/ #endif // SRC_SENSORS_DECAGONES2_H_ diff --git a/src/sensors/EverlightALSPT19.h b/src/sensors/EverlightALSPT19.h index 4f1f25db3..61c714e8b 100644 --- a/src/sensors/EverlightALSPT19.h +++ b/src/sensors/EverlightALSPT19.h @@ -301,7 +301,7 @@ class EverlightALSPT19 : public Sensor { * Conditionally deletes the _analogVoltageReader member if the ownership * flag _ownsAnalogVoltageReader is true, otherwise leaves it unmodified. */ - ~EverlightALSPT19(); + ~EverlightALSPT19() override; // Delete copy constructor and copy assignment operator to prevent shallow // copies @@ -371,7 +371,7 @@ class EverlightALSPT19_Voltage : public Variable { /** * @brief Destroy the EverlightALSPT19_Voltage object - no action needed. */ - ~EverlightALSPT19_Voltage() = default; + ~EverlightALSPT19_Voltage() override = default; }; @@ -415,7 +415,7 @@ class EverlightALSPT19_Current : public Variable { /** * @brief Destroy the EverlightALSPT19_Current object - no action needed. */ - ~EverlightALSPT19_Current() = default; + ~EverlightALSPT19_Current() override = default; }; @@ -460,7 +460,7 @@ class EverlightALSPT19_Illuminance : public Variable { * @brief Destroy the EverlightALSPT19_Illuminance object - no action * needed. */ - ~EverlightALSPT19_Illuminance() = default; + ~EverlightALSPT19_Illuminance() override = default; }; /**@}*/ #endif // SRC_SENSORS_EVERLIGHTALSPT19_H_ diff --git a/src/sensors/FreescaleMPL115A2.h b/src/sensors/FreescaleMPL115A2.h index 36f5074f2..0934a1720 100644 --- a/src/sensors/FreescaleMPL115A2.h +++ b/src/sensors/FreescaleMPL115A2.h @@ -220,7 +220,7 @@ class FreescaleMPL115A2 : public Sensor { /** * @brief Destroy the FreescaleMPL115A2 object */ - ~FreescaleMPL115A2() = default; + ~FreescaleMPL115A2() override = default; /** * @brief Do any one-time preparations needed before the sensor will be able @@ -299,7 +299,7 @@ class FreescaleMPL115A2_Temp : public Variable { /** * @brief Destroy the FreescaleMPL115A2_Temp object - no action needed. */ - ~FreescaleMPL115A2_Temp() = default; + ~FreescaleMPL115A2_Temp() override = default; }; /** @@ -353,7 +353,7 @@ class FreescaleMPL115A2_Pressure : public Variable { /** * @brief Destroy the FreescaleMPL115A2_Pressure object - no action needed. */ - ~FreescaleMPL115A2_Pressure() = default; + ~FreescaleMPL115A2_Pressure() override = default; }; /** diff --git a/src/sensors/GeoluxHydroCam.h b/src/sensors/GeoluxHydroCam.h index b3dc804fa..37a973dd9 100644 --- a/src/sensors/GeoluxHydroCam.h +++ b/src/sensors/GeoluxHydroCam.h @@ -283,7 +283,7 @@ class GeoluxHydroCam : public Sensor { /** * @brief Destroy the Geolux HydroCam object */ - ~GeoluxHydroCam() = default; + ~GeoluxHydroCam() override = default; /** * @brief Extra unique function to retrieve the name of the last saved image @@ -459,7 +459,7 @@ class GeoluxHydroCam_ImageSize : public Variable { /** * @brief Destroy the GeoluxHydroCam_ImageSize object - no action needed. */ - ~GeoluxHydroCam_ImageSize() = default; + ~GeoluxHydroCam_ImageSize() override = default; }; @@ -504,7 +504,7 @@ class GeoluxHydroCam_ByteError : public Variable { * @brief Destroy the GeoluxHydroCam_ByteError object - no action * needed. */ - ~GeoluxHydroCam_ByteError() = default; + ~GeoluxHydroCam_ByteError() override = default; }; /**@}*/ #endif // SRC_SENSORS_GEOLUXHYDROCAM_H_ diff --git a/src/sensors/GroPointGPLP8.h b/src/sensors/GroPointGPLP8.h index e4ebdafa1..a8596cc1c 100644 --- a/src/sensors/GroPointGPLP8.h +++ b/src/sensors/GroPointGPLP8.h @@ -193,7 +193,7 @@ class GroPointGPLP8 : public GroPointParent { /** * @brief Destroy the GroPoint GPLP8 object */ - ~GroPointGPLP8() = default; + ~GroPointGPLP8() override = default; }; @@ -247,7 +247,7 @@ class GroPointGPLP8_Moist : public Variable { /** * @brief Destroy the GroPointGPLP8_Moist object - no action needed. */ - ~GroPointGPLP8_Moist() = default; + ~GroPointGPLP8_Moist() override = default; }; /* clang-format off */ @@ -299,7 +299,7 @@ class GroPointGPLP8_Temp : public Variable { /** * @brief Destroy the GroPointGPLP8_Temp object - no action needed. */ - ~GroPointGPLP8_Temp() = default; + ~GroPointGPLP8_Temp() override = default; }; /**@}*/ diff --git a/src/sensors/GroPointParent.h b/src/sensors/GroPointParent.h index 8dc846fd3..ecb85ff04 100644 --- a/src/sensors/GroPointParent.h +++ b/src/sensors/GroPointParent.h @@ -154,7 +154,7 @@ class GroPointParent : public Sensor { /** * @brief Destroy the GroPoint Parent object - no action taken */ - virtual ~GroPointParent() = default; + virtual ~GroPointParent() override = default; String getSensorLocation(void) override; diff --git a/src/sensors/InSituRDO.h b/src/sensors/InSituRDO.h index 9590a79cc..20e6f24ea 100644 --- a/src/sensors/InSituRDO.h +++ b/src/sensors/InSituRDO.h @@ -413,7 +413,7 @@ class InSituRDO : public SDI12Sensors { /** * @brief Destroy the In-Situ RDO object */ - ~InSituRDO() = default; + ~InSituRDO() override = default; }; @@ -459,7 +459,7 @@ class InSituRDO_DOmgL : public Variable { /** * @brief Destroy the InSituRDO_DOmgL object - no action needed. */ - ~InSituRDO_DOmgL() = default; + ~InSituRDO_DOmgL() override = default; }; @@ -505,7 +505,7 @@ class InSituRDO_DOpct : public Variable { /** * @brief Destroy the InSituRDO_DOpct object - no action needed. */ - ~InSituRDO_DOpct() = default; + ~InSituRDO_DOpct() override = default; }; @@ -550,7 +550,7 @@ class InSituRDO_Temp : public Variable { /** * @brief Destroy the InSituRDO_Temp object - no action needed. */ - ~InSituRDO_Temp() = default; + ~InSituRDO_Temp() override = default; }; @@ -596,7 +596,7 @@ class InSituRDO_Pressure : public Variable { /** * @brief Destroy the InSituRDO_Pressure object - no action needed. */ - ~InSituRDO_Pressure() = default; + ~InSituRDO_Pressure() override = default; }; /**@}*/ #endif // SRC_SENSORS_INSITURDO_H_ diff --git a/src/sensors/InSituTrollSdi12a.h b/src/sensors/InSituTrollSdi12a.h index 1b6ed8d47..785c5b4b1 100644 --- a/src/sensors/InSituTrollSdi12a.h +++ b/src/sensors/InSituTrollSdi12a.h @@ -270,7 +270,7 @@ class InSituTrollSdi12a : public SDI12Sensors { /** * @brief Destroy the ITROLL object */ - ~InSituTrollSdi12a() = default; + ~InSituTrollSdi12a() override = default; }; @@ -315,7 +315,7 @@ class InSituTrollSdi12a_Pressure : public Variable { /** * @brief Destroy the InSituTrollSdi12a_Pressure object - no action needed. */ - ~InSituTrollSdi12a_Pressure() = default; + ~InSituTrollSdi12a_Pressure() override = default; }; @@ -358,7 +358,7 @@ class InSituTrollSdi12a_Temp : public Variable { /** * @brief Destroy the InSituTrollSdi12a_Temp object - no action needed. */ - ~InSituTrollSdi12a_Temp() = default; + ~InSituTrollSdi12a_Temp() override = default; }; @@ -400,7 +400,7 @@ class InSituTrollSdi12a_Depth : public Variable { /** * @brief Destroy the InSituTrollSdi12a_Depth object - no action needed. */ - ~InSituTrollSdi12a_Depth() = default; + ~InSituTrollSdi12a_Depth() override = default; }; /**@}*/ diff --git a/src/sensors/KellerAcculevel.h b/src/sensors/KellerAcculevel.h index adb2c1e23..8088041e6 100644 --- a/src/sensors/KellerAcculevel.h +++ b/src/sensors/KellerAcculevel.h @@ -179,7 +179,7 @@ class KellerAcculevel : public KellerParent { /** * @brief Destroy the Keller Acculevel object */ - ~KellerAcculevel() = default; + ~KellerAcculevel() override = default; }; @@ -225,7 +225,7 @@ class KellerAcculevel_Pressure : public Variable { /** * @brief Destroy the KellerAcculevel_Pressure object - no action needed. */ - ~KellerAcculevel_Pressure() = default; + ~KellerAcculevel_Pressure() override = default; }; @@ -269,7 +269,7 @@ class KellerAcculevel_Temp : public Variable { /** * @brief Destroy the KellerAcculevel_Temp object - no action needed. */ - ~KellerAcculevel_Temp() = default; + ~KellerAcculevel_Temp() override = default; }; @@ -313,7 +313,7 @@ class KellerAcculevel_Height : public Variable { /** * @brief Destroy the KellerAcculevel_Height object - no action needed. */ - ~KellerAcculevel_Height() = default; + ~KellerAcculevel_Height() override = default; }; /**@}*/ #endif // SRC_SENSORS_KELLERACCULEVEL_H_ diff --git a/src/sensors/KellerNanolevel.h b/src/sensors/KellerNanolevel.h index 990fb7aa1..8a210f004 100644 --- a/src/sensors/KellerNanolevel.h +++ b/src/sensors/KellerNanolevel.h @@ -171,7 +171,7 @@ class KellerNanolevel : public KellerParent { /** * @brief Destroy the Keller Nanolevel object */ - ~KellerNanolevel() = default; + ~KellerNanolevel() override = default; }; @@ -217,7 +217,7 @@ class KellerNanolevel_Pressure : public Variable { /** * @brief Destroy the KellerNanolevel_Pressure object - no action needed. */ - ~KellerNanolevel_Pressure() = default; + ~KellerNanolevel_Pressure() override = default; }; @@ -261,7 +261,7 @@ class KellerNanolevel_Temp : public Variable { /** * @brief Destroy the KellerNanolevel_Temp object - no action needed. */ - ~KellerNanolevel_Temp() = default; + ~KellerNanolevel_Temp() override = default; }; @@ -305,7 +305,7 @@ class KellerNanolevel_Height : public Variable { /** * @brief Destroy the KellerNanolevel_Height object - no action needed. */ - ~KellerNanolevel_Height() = default; + ~KellerNanolevel_Height() override = default; }; /**@}*/ #endif // SRC_SENSORS_KELLERNANOLEVEL_H_ diff --git a/src/sensors/KellerParent.h b/src/sensors/KellerParent.h index 77ec51740..fa8333c5f 100644 --- a/src/sensors/KellerParent.h +++ b/src/sensors/KellerParent.h @@ -231,7 +231,7 @@ class KellerParent : public Sensor { /** * @brief Destroy the Keller Parent object - no action taken */ - virtual ~KellerParent() = default; + virtual ~KellerParent() override = default; String getSensorLocation(void) override; diff --git a/src/sensors/MaxBotixSonar.h b/src/sensors/MaxBotixSonar.h index 9c3577c34..944e922ea 100644 --- a/src/sensors/MaxBotixSonar.h +++ b/src/sensors/MaxBotixSonar.h @@ -222,7 +222,7 @@ class MaxBotixSonar : public Sensor { /** * @brief Destroy the MaxBotix Sonar object */ - ~MaxBotixSonar() = default; + ~MaxBotixSonar() override = default; String getSensorLocation(void) override; @@ -311,7 +311,7 @@ class MaxBotixSonar_Range : public Variable { /** * @brief Destroy the MaxBotixSonar_Range object - no action needed. */ - ~MaxBotixSonar_Range() = default; + ~MaxBotixSonar_Range() override = default; }; /**@}*/ #endif // SRC_SENSORS_MAXBOTIXSONAR_H_ diff --git a/src/sensors/MaximDS18.h b/src/sensors/MaximDS18.h index ef5abaf79..e200a0e58 100644 --- a/src/sensors/MaximDS18.h +++ b/src/sensors/MaximDS18.h @@ -225,7 +225,7 @@ class MaximDS18 : public Sensor { /** * @brief Destroy the Maxim DS18 object */ - ~MaximDS18() = default; + ~MaximDS18() override = default; /** * @brief Do any one-time preparations needed before the sensor will be able @@ -324,7 +324,7 @@ class MaximDS18_Temp : public Variable { /** * @brief Destroy the MaximDS18_Temp object - no action needed. */ - ~MaximDS18_Temp() = default; + ~MaximDS18_Temp() override = default; }; /**@}*/ #endif // SRC_SENSORS_MAXIMDS18_H_ diff --git a/src/sensors/MaximDS3231.h b/src/sensors/MaximDS3231.h index a2f19b7f5..ee8270af1 100644 --- a/src/sensors/MaximDS3231.h +++ b/src/sensors/MaximDS3231.h @@ -166,7 +166,7 @@ class MaximDS3231 : public Sensor { /** * @brief Destroy the Maxim DS3231 object */ - ~MaximDS3231() = default; + ~MaximDS3231() override = default; String getSensorLocation(void) override; @@ -236,7 +236,7 @@ class MaximDS3231_Temp : public Variable { /** * @brief Destroy the MaximDS3231_Temp object - no action needed. */ - ~MaximDS3231_Temp() = default; + ~MaximDS3231_Temp() override = default; }; /**@}*/ #endif // SRC_SENSORS_MAXIMDS3231_H_ diff --git a/src/sensors/MeaSpecMS5803.h b/src/sensors/MeaSpecMS5803.h index 67b29f9c6..10d4a6a55 100644 --- a/src/sensors/MeaSpecMS5803.h +++ b/src/sensors/MeaSpecMS5803.h @@ -235,7 +235,7 @@ class MeaSpecMS5803 : public Sensor { /** * @brief Destroy the MeaSpecMS5803 object */ - ~MeaSpecMS5803() = default; + ~MeaSpecMS5803() override = default; /** * @brief Do any one-time preparations needed before the sensor will be able @@ -311,7 +311,7 @@ class MeaSpecMS5803_Temp : public Variable { /** * @brief Destroy the MeaSpecMS5803_Temp object - no action needed. */ - ~MeaSpecMS5803_Temp() = default; + ~MeaSpecMS5803_Temp() override = default; }; @@ -358,7 +358,7 @@ class MeaSpecMS5803_Pressure : public Variable { /** * @brief Destroy the MeaSpecMS5803_Pressure object - no action needed. */ - ~MeaSpecMS5803_Pressure() = default; + ~MeaSpecMS5803_Pressure() override = default; }; /**@}*/ #endif // SRC_SENSORS_MEASPECMS5803_H_ diff --git a/src/sensors/MeterHydros21.h b/src/sensors/MeterHydros21.h index e0b2c3085..cee5f2c70 100644 --- a/src/sensors/MeterHydros21.h +++ b/src/sensors/MeterHydros21.h @@ -277,7 +277,7 @@ class MeterHydros21 : public SDI12Sensors { /** * @brief Destroy the Meter Hydros 21 object */ - ~MeterHydros21() = default; + ~MeterHydros21() override = default; }; @@ -320,7 +320,7 @@ class MeterHydros21_Cond : public Variable { /** * @brief Destroy the MeterHydros21_Cond object - no action needed. */ - ~MeterHydros21_Cond() = default; + ~MeterHydros21_Cond() override = default; }; @@ -363,7 +363,7 @@ class MeterHydros21_Temp : public Variable { /** * @brief Destroy the MeterHydros21_Temp object - no action needed. */ - ~MeterHydros21_Temp() = default; + ~MeterHydros21_Temp() override = default; }; @@ -406,7 +406,7 @@ class MeterHydros21_Depth : public Variable { /** * @brief Destroy the MeterHydros21_Depth object - no action needed. */ - ~MeterHydros21_Depth() = default; + ~MeterHydros21_Depth() override = default; }; /**@}*/ #endif // SRC_SENSORS_METERHYDROS21_H_ diff --git a/src/sensors/MeterTeros11.h b/src/sensors/MeterTeros11.h index a8f075ba5..32dedd01f 100644 --- a/src/sensors/MeterTeros11.h +++ b/src/sensors/MeterTeros11.h @@ -330,7 +330,7 @@ class MeterTeros11 : public SDI12Sensors { /** * @brief Destroy the Meter Teros 11 object */ - ~MeterTeros11() = default; + ~MeterTeros11() override = default; /** * @copydoc SDI12Sensors::getResults(bool verify_crc) @@ -379,7 +379,7 @@ class MeterTeros11_Count : public Variable { /** * @brief Destroy the MeterTeros11_Count object - no action needed. */ - ~MeterTeros11_Count() = default; + ~MeterTeros11_Count() override = default; }; @@ -421,7 +421,7 @@ class MeterTeros11_Temp : public Variable { /** * @brief Destroy the MeterTeros11_Temp object - no action needed. */ - ~MeterTeros11_Temp() = default; + ~MeterTeros11_Temp() override = default; }; @@ -464,7 +464,7 @@ class MeterTeros11_Ea : public Variable { /** * @brief Destroy the MeterTeros11_Ea object - no action needed. */ - ~MeterTeros11_Ea() = default; + ~MeterTeros11_Ea() override = default; }; @@ -506,7 +506,7 @@ class MeterTeros11_VWC : public Variable { /** * @brief Destroy the MeterTeros11_VWC object - no action needed. */ - ~MeterTeros11_VWC() = default; + ~MeterTeros11_VWC() override = default; }; /**@}*/ #endif // SRC_SENSORS_METERTEROS11_H_ diff --git a/src/sensors/PaleoTerraRedox.h b/src/sensors/PaleoTerraRedox.h index e2a53719a..ebb7ac7c5 100644 --- a/src/sensors/PaleoTerraRedox.h +++ b/src/sensors/PaleoTerraRedox.h @@ -257,7 +257,7 @@ class PaleoTerraRedox : public Sensor { * @brief Destroy the PaleoTerra Redox object. Also destroy the software * I2C instance if one was created. */ - ~PaleoTerraRedox(); + ~PaleoTerraRedox() override; /** * @brief Do any one-time preparations needed before the sensor will be able @@ -337,7 +337,7 @@ class PaleoTerraRedox_Voltage : public Variable { /** * @brief Destroy the PaleoTerraRedox_Voltage object - no action needed. */ - ~PaleoTerraRedox_Voltage() = default; + ~PaleoTerraRedox_Voltage() override = default; }; /** diff --git a/src/sensors/ProcessorAnalog.h b/src/sensors/ProcessorAnalog.h index d374a4583..bef583965 100644 --- a/src/sensors/ProcessorAnalog.h +++ b/src/sensors/ProcessorAnalog.h @@ -180,7 +180,7 @@ class ProcessorAnalogBase : public AnalogVoltageBase { /** * @brief Destroy the ProcessorAnalogBase object */ - virtual ~ProcessorAnalogBase() = default; + virtual ~ProcessorAnalogBase() override = default; /** * @brief Initialize the processor analog system @@ -270,7 +270,7 @@ class ProcessorAnalog : public Sensor { /** * @brief Destroy the Processor Analog object */ - ~ProcessorAnalog(); + ~ProcessorAnalog() override; // Delete copy constructor and copy assignment operator to prevent shallow // copies @@ -343,7 +343,7 @@ class ProcessorAnalog_Voltage : public Variable { /** * @brief Destroy the ProcessorAnalog_Voltage object - no action needed. */ - ~ProcessorAnalog_Voltage() = default; + ~ProcessorAnalog_Voltage() override = default; }; /**@}*/ diff --git a/src/sensors/ProcessorStats.h b/src/sensors/ProcessorStats.h index 791ad5df8..94d8c5e2a 100644 --- a/src/sensors/ProcessorStats.h +++ b/src/sensors/ProcessorStats.h @@ -317,7 +317,7 @@ class ProcessorStats : public Sensor { /** * @brief Destroy the Processor Stats object */ - ~ProcessorStats() = default; + ~ProcessorStats() override = default; /** * @copydoc Sensor::getSensorLocation() @@ -407,7 +407,7 @@ class ProcessorStats_Battery : public Variable { /** * @brief Destroy the ProcessorStats_Battery object - no action needed. */ - ~ProcessorStats_Battery() = default; + ~ProcessorStats_Battery() override = default; }; @@ -458,7 +458,7 @@ class ProcessorStats_FreeRam : public Variable { /** * @brief Destroy the ProcessorStats_FreeRam object - no action needed. */ - ~ProcessorStats_FreeRam() = default; + ~ProcessorStats_FreeRam() override = default; }; @@ -508,7 +508,7 @@ class ProcessorStats_SampleNumber : public Variable { * @brief Destroy the ProcessorStats_SampleNumber() object - no action * needed. */ - ~ProcessorStats_SampleNumber() = default; + ~ProcessorStats_SampleNumber() override = default; }; @@ -558,7 +558,7 @@ class ProcessorStats_ResetCode : public Variable { /** * @brief Destroy the ProcessorStats_ResetCode object - no action needed. */ - ~ProcessorStats_ResetCode() = default; + ~ProcessorStats_ResetCode() override = default; }; /**@}*/ #endif // SRC_SENSORS_PROCESSORSTATS_H_ diff --git a/src/sensors/RainCounterI2C.h b/src/sensors/RainCounterI2C.h index 1358e54ab..25ae51bf6 100644 --- a/src/sensors/RainCounterI2C.h +++ b/src/sensors/RainCounterI2C.h @@ -271,7 +271,7 @@ class RainCounterI2C : public Sensor { * @brief Destroy the Rain Counter I2C object. Also destroy the software * I2C instance if one was created. */ - ~RainCounterI2C(); + ~RainCounterI2C() override; /** * @brief Do any one-time preparations needed before the sensor will be able @@ -357,7 +357,7 @@ class RainCounterI2C_Tips : public Variable { /** * @brief Destroy the RainCounterI2C_Tips object - no action needed. */ - ~RainCounterI2C_Tips() = default; + ~RainCounterI2C_Tips() override = default; }; /** @@ -399,7 +399,7 @@ class RainCounterI2C_Depth : public Variable { /** * @brief Destroy the RainCounterI2C_Depth object - no action needed. */ - ~RainCounterI2C_Depth() = default; + ~RainCounterI2C_Depth() override = default; }; /**@}*/ #endif // SRC_SENSORS_RAINCOUNTERI2C_H_ diff --git a/src/sensors/SDI12Sensors.h b/src/sensors/SDI12Sensors.h index ce90817d8..8a69c9229 100644 --- a/src/sensors/SDI12Sensors.h +++ b/src/sensors/SDI12Sensors.h @@ -165,7 +165,7 @@ class SDI12Sensors : public Sensor { /** * @brief Destroy the SDI12Sensors object - no action taken */ - virtual ~SDI12Sensors() = default; + virtual ~SDI12Sensors() override = default; /** * @brief Get the stored sensor vendor name returned by a previously called diff --git a/src/sensors/SensirionSHT4x.h b/src/sensors/SensirionSHT4x.h index 9af29f9fb..9fd79973f 100644 --- a/src/sensors/SensirionSHT4x.h +++ b/src/sensors/SensirionSHT4x.h @@ -253,7 +253,7 @@ class SensirionSHT4x : public Sensor { /** * @brief Destroy the SensirionSHT4x object - no action needed. */ - ~SensirionSHT4x() = default; + ~SensirionSHT4x() override = default; /** * @brief Report the I2C address of the SHT4x - which is always 0x44. @@ -338,7 +338,7 @@ class SensirionSHT4x_Humidity : public Variable { /** * @brief Destroy the SensirionSHT4x_Humidity object - no action needed. */ - ~SensirionSHT4x_Humidity() = default; + ~SensirionSHT4x_Humidity() override = default; }; @@ -380,7 +380,7 @@ class SensirionSHT4x_Temp : public Variable { /** * @brief Destroy the SensirionSHT4x_Temp object - no action needed. */ - ~SensirionSHT4x_Temp() = default; + ~SensirionSHT4x_Temp() override = default; }; /**@}*/ #endif // SRC_SENSORS_SENSIRIONSHT4X_H_ diff --git a/src/sensors/TEConnectivityMS5837.h b/src/sensors/TEConnectivityMS5837.h index b7f0a69f8..8c975ee49 100644 --- a/src/sensors/TEConnectivityMS5837.h +++ b/src/sensors/TEConnectivityMS5837.h @@ -464,7 +464,7 @@ class TEConnectivityMS5837 : public Sensor { /** * @brief Destroy the TEConnectivityMS5837 object */ - ~TEConnectivityMS5837() = default; + ~TEConnectivityMS5837() override = default; /** * @brief Do any one-time preparations needed before the sensor will be able @@ -592,7 +592,7 @@ class TEConnectivityMS5837_Temp : public Variable { /** * @brief Destroy the TEConnectivityMS5837_Temp object - no action needed. */ - ~TEConnectivityMS5837_Temp() = default; + ~TEConnectivityMS5837_Temp() override = default; }; @@ -639,7 +639,7 @@ class TEConnectivityMS5837_Pressure : public Variable { * @brief Destroy the TEConnectivityMS5837_Pressure object - no action * needed. */ - ~TEConnectivityMS5837_Pressure() = default; + ~TEConnectivityMS5837_Pressure() override = default; }; @@ -683,7 +683,7 @@ class TEConnectivityMS5837_Depth : public Variable { /** * @brief Destroy the TEConnectivityMS5837_Depth object - no action needed. */ - ~TEConnectivityMS5837_Depth() = default; + ~TEConnectivityMS5837_Depth() override = default; }; @@ -730,7 +730,7 @@ class TEConnectivityMS5837_Altitude : public Variable { * @brief Destroy the TEConnectivityMS5837_Altitude object - no action * needed. */ - ~TEConnectivityMS5837_Altitude() = default; + ~TEConnectivityMS5837_Altitude() override = default; }; /**@}*/ #endif // SRC_SENSORS_TECONNECTIVITYMS5837_H_ diff --git a/src/sensors/TIADS1x15.h b/src/sensors/TIADS1x15.h index a080c06c4..04883b9db 100644 --- a/src/sensors/TIADS1x15.h +++ b/src/sensors/TIADS1x15.h @@ -313,7 +313,7 @@ class TIADS1x15Base : public AnalogVoltageBase { /** * @brief Destroy the TIADS1x15Base object */ - virtual ~TIADS1x15Base() = default; + virtual ~TIADS1x15Base() override = default; /** * @brief Initialize the ADS1x15 analog voltage reading system @@ -595,7 +595,7 @@ class TIADS1x15_Voltage : public Variable { /** * @brief Destroy the TIADS1x15_Voltage object - no action needed. */ - ~TIADS1x15_Voltage() = default; + ~TIADS1x15_Voltage() override = default; }; /** diff --git a/src/sensors/TIINA219.h b/src/sensors/TIINA219.h index 2478e9113..89c2edc73 100644 --- a/src/sensors/TIINA219.h +++ b/src/sensors/TIINA219.h @@ -267,7 +267,7 @@ class TIINA219 : public Sensor { /** * @brief Destroy the TI INA219 object */ - ~TIINA219() = default; + ~TIINA219() override = default; /** * @brief Wake the sensor up and read the calibration coefficient from it. @@ -351,7 +351,7 @@ class TIINA219_Current : public Variable { /** * @brief Destroy the TIINA219_Current object - no action needed. */ - ~TIINA219_Current() = default; + ~TIINA219_Current() override = default; }; @@ -394,7 +394,7 @@ class TIINA219_Voltage : public Variable { /** * @brief Destroy the TIINA219_Voltage object - no action needed. */ - ~TIINA219_Voltage() = default; + ~TIINA219_Voltage() override = default; }; /** @@ -445,7 +445,7 @@ class TIINA219_Power : public Variable { /** * @brief Destroy the TIINA219_Power object - no action needed. */ - ~TIINA219_Power() = default; + ~TIINA219_Power() override = default; }; /**@}*/ #endif // SRC_SENSORS_TIINA219_H_ diff --git a/src/sensors/TallyCounterI2C.h b/src/sensors/TallyCounterI2C.h index 6638da5e8..bb8507b56 100644 --- a/src/sensors/TallyCounterI2C.h +++ b/src/sensors/TallyCounterI2C.h @@ -203,7 +203,7 @@ class TallyCounterI2C : public Sensor { /** * @brief Destroy the Tally Counter object */ - ~TallyCounterI2C() = default; + ~TallyCounterI2C() override = default; /** * @brief Do any one-time preparations needed before the sensor will be able @@ -272,9 +272,9 @@ class TallyCounterI2C_Events : public Variable { (uint8_t)TALLY_EVENTS_RESOLUTION, TALLY_EVENTS_VAR_NAME, TALLY_EVENTS_UNIT_NAME, TALLY_EVENTS_DEFAULT_CODE) {} /** - * @brief Destroy the BoschBME280_Temp object - no action needed. + * @brief Destroy the TallyCounterI2C_Events object - no action needed. */ - ~TallyCounterI2C_Events() = default; + ~TallyCounterI2C_Events() override = default; }; /**@}*/ #endif // SRC_SENSORS_TallyCounterI2C_H_ diff --git a/src/sensors/TurnerCyclops.h b/src/sensors/TurnerCyclops.h index 44862fab3..1224b409c 100644 --- a/src/sensors/TurnerCyclops.h +++ b/src/sensors/TurnerCyclops.h @@ -366,7 +366,7 @@ class TurnerCyclops : public Sensor { /** * @brief Destroy the Turner Cyclops object */ - ~TurnerCyclops(); + ~TurnerCyclops() override; // Delete copy constructor and copy assignment operator to prevent shallow // copies @@ -456,7 +456,7 @@ class TurnerCyclops_Voltage : public Variable { /** * @brief Destroy the Turner Cyclops Voltage object - no action needed. */ - ~TurnerCyclops_Voltage() = default; + ~TurnerCyclops_Voltage() override = default; }; @@ -514,7 +514,7 @@ class TurnerCyclops_Chlorophyll : public Variable { * @brief Destroy the Turner Cyclops Chlorophyll variable object - no action * needed. */ - ~TurnerCyclops_Chlorophyll() = default; + ~TurnerCyclops_Chlorophyll() override = default; }; @@ -571,7 +571,7 @@ class TurnerCyclops_Rhodamine : public Variable { * @brief Destroy the Turner Cyclops Rhodamine variable object - no action * needed. */ - ~TurnerCyclops_Rhodamine() = default; + ~TurnerCyclops_Rhodamine() override = default; }; @@ -627,7 +627,7 @@ class TurnerCyclops_Fluorescein : public Variable { * @brief Destroy the Turner Cyclops Fluorescein variable object - no action * needed. */ - ~TurnerCyclops_Fluorescein() = default; + ~TurnerCyclops_Fluorescein() override = default; }; @@ -686,7 +686,7 @@ class TurnerCyclops_Phycocyanin : public Variable { * @brief Destroy the Turner Cyclops Phycocyanin variable object - no action * needed. */ - ~TurnerCyclops_Phycocyanin() = default; + ~TurnerCyclops_Phycocyanin() override = default; }; @@ -743,7 +743,7 @@ class TurnerCyclops_Phycoerythrin : public Variable { * @brief Destroy the Turner Cyclops Phycoerythrin variable object - no * action needed. */ - ~TurnerCyclops_Phycoerythrin() = default; + ~TurnerCyclops_Phycoerythrin() override = default; }; @@ -805,7 +805,7 @@ class TurnerCyclops_CDOM : public Variable { * @brief Destroy the Turner Cyclops CDOM variable object - no action * needed. */ - ~TurnerCyclops_CDOM() = default; + ~TurnerCyclops_CDOM() override = default; }; @@ -864,7 +864,7 @@ class TurnerCyclops_CrudeOil : public Variable { * @brief Destroy the Turner Cyclops CrudeOil variable object - no action * needed. */ - ~TurnerCyclops_CrudeOil() = default; + ~TurnerCyclops_CrudeOil() override = default; }; @@ -923,7 +923,7 @@ class TurnerCyclops_Brighteners : public Variable { /** * @brief Destroy the Turner Cyclops Brighteners object - no action needed. */ - ~TurnerCyclops_Brighteners() = default; + ~TurnerCyclops_Brighteners() override = default; }; @@ -980,7 +980,7 @@ class TurnerCyclops_Turbidity : public Variable { * @brief Destroy the Turner Cyclops Turbidity variable object - no action * needed. */ - ~TurnerCyclops_Turbidity() = default; + ~TurnerCyclops_Turbidity() override = default; }; @@ -1037,7 +1037,7 @@ class TurnerCyclops_PTSA : public Variable { * @brief Destroy the Turner Cyclops PTSA variable object - no action * needed. */ - ~TurnerCyclops_PTSA() = default; + ~TurnerCyclops_PTSA() override = default; }; @@ -1094,7 +1094,7 @@ class TurnerCyclops_BTEX : public Variable { * @brief Destroy the Turner Cyclops BTEX variable object - no action * needed. */ - ~TurnerCyclops_BTEX() = default; + ~TurnerCyclops_BTEX() override = default; }; @@ -1150,7 +1150,7 @@ class TurnerCyclops_Tryptophan : public Variable { * @brief Destroy the Turner Cyclops Tryptophan variable object - no action * needed. */ - ~TurnerCyclops_Tryptophan() = default; + ~TurnerCyclops_Tryptophan() override = default; }; @@ -1208,7 +1208,7 @@ class TurnerCyclops_RedChlorophyll : public Variable { * @brief Destroy the Turner Cyclops Red Chlorophyll variable object - no * action needed. */ - ~TurnerCyclops_RedChlorophyll() = default; + ~TurnerCyclops_RedChlorophyll() override = default; }; /**@}*/ #endif // SRC_SENSORS_TURNERCYCLOPS_H_ diff --git a/src/sensors/TurnerTurbidityPlus.h b/src/sensors/TurnerTurbidityPlus.h index dad8d7c3b..9d4d6e298 100644 --- a/src/sensors/TurnerTurbidityPlus.h +++ b/src/sensors/TurnerTurbidityPlus.h @@ -278,7 +278,7 @@ class TurnerTurbidityPlus : public Sensor { /** * @brief Destroy the Turner Turbidity Plus object */ - ~TurnerTurbidityPlus(); + ~TurnerTurbidityPlus() override; // Delete copy constructor and copy assignment operator to prevent shallow // copies @@ -397,7 +397,7 @@ class TurnerTurbidityPlus_Voltage : public Variable { /** * @brief Destroy the TurnerTurbidityPlus_Voltage object - no action needed. */ - ~TurnerTurbidityPlus_Voltage() = default; + ~TurnerTurbidityPlus_Voltage() override = default; }; @@ -444,7 +444,7 @@ class TurnerTurbidityPlus_Turbidity : public Variable { * @brief Destroy the TurnerTurbidityPlus_Turbidity object - no action * needed. */ - ~TurnerTurbidityPlus_Turbidity() = default; + ~TurnerTurbidityPlus_Turbidity() override = default; }; /**@}*/ diff --git a/src/sensors/VegaPuls21.h b/src/sensors/VegaPuls21.h index e75919485..abd3703a0 100644 --- a/src/sensors/VegaPuls21.h +++ b/src/sensors/VegaPuls21.h @@ -298,7 +298,7 @@ class VegaPuls21 : public SDI12Sensors { /** * @brief Destroy the VEGAPULS C 21 object */ - ~VegaPuls21() = default; + ~VegaPuls21() override = default; }; @@ -344,7 +344,7 @@ class VegaPuls21_Stage : public Variable { /** * @brief Destroy the VegaPuls21_Stage object - no action needed. */ - ~VegaPuls21_Stage() = default; + ~VegaPuls21_Stage() override = default; }; @@ -390,7 +390,7 @@ class VegaPuls21_Distance : public Variable { /** * @brief Destroy the VegaPuls21_Distance object - no action needed. */ - ~VegaPuls21_Distance() = default; + ~VegaPuls21_Distance() override = default; }; @@ -435,7 +435,7 @@ class VegaPuls21_Temp : public Variable { /** * @brief Destroy the VegaPuls21_Temp object - no action needed. */ - ~VegaPuls21_Temp() = default; + ~VegaPuls21_Temp() override = default; }; @@ -483,7 +483,7 @@ class VegaPuls21_Reliability : public Variable { * @brief Destroy the VegaPuls21_Reliability object - no action * needed. */ - ~VegaPuls21_Reliability() = default; + ~VegaPuls21_Reliability() override = default; }; @@ -531,7 +531,7 @@ class VegaPuls21_ErrorCode : public Variable { * @brief Destroy the VegaPuls21_ErrorCode object - no action * needed. */ - ~VegaPuls21_ErrorCode() = default; + ~VegaPuls21_ErrorCode() override = default; }; /**@}*/ #endif // SRC_SENSORS_VEGAPULS21_H_ diff --git a/src/sensors/YosemitechParent.h b/src/sensors/YosemitechParent.h index b5508eb05..5701b37c2 100644 --- a/src/sensors/YosemitechParent.h +++ b/src/sensors/YosemitechParent.h @@ -207,7 +207,7 @@ class YosemitechParent : public Sensor { /** * @brief Destroy the Yosemitech Parent object - no action taken */ - virtual ~YosemitechParent() = default; + virtual ~YosemitechParent() override = default; String getSensorLocation(void) override; diff --git a/src/sensors/YosemitechY4000.h b/src/sensors/YosemitechY4000.h index 18a5a3f30..8712fac94 100644 --- a/src/sensors/YosemitechY4000.h +++ b/src/sensors/YosemitechY4000.h @@ -373,7 +373,7 @@ class YosemitechY4000 : public YosemitechParent { /** * @brief Destroy the Yosemitech Y4000 object */ - ~YosemitechY4000() = default; + ~YosemitechY4000() override = default; }; @@ -417,7 +417,7 @@ class YosemitechY4000_DOmgL : public Variable { /** * @brief Destroy the YosemitechY4000_DOmgL object - no action needed. */ - ~YosemitechY4000_DOmgL() = default; + ~YosemitechY4000_DOmgL() override = default; }; /* clang-format off */ @@ -460,7 +460,7 @@ class YosemitechY4000_Turbidity : public Variable { /** * @brief Destroy the YosemitechY4000_Turbidity object - no action needed. */ - ~YosemitechY4000_Turbidity() = default; + ~YosemitechY4000_Turbidity() override = default; }; /* clang-format off */ @@ -503,7 +503,7 @@ class YosemitechY4000_Cond : public Variable { /** * @brief Destroy the YosemitechY4000_Cond object - no action needed. */ - ~YosemitechY4000_Cond() = default; + ~YosemitechY4000_Cond() override = default; }; /* clang-format off */ @@ -546,7 +546,7 @@ class YosemitechY4000_pH : public Variable { /** * @brief Destroy the YosemitechY4000_pH object - no action needed. */ - ~YosemitechY4000_pH() = default; + ~YosemitechY4000_pH() override = default; }; /* clang-format off */ @@ -589,7 +589,7 @@ class YosemitechY4000_Temp : public Variable { /** * @brief Destroy the YosemitechY4000_Temp object - no action needed. */ - ~YosemitechY4000_Temp() = default; + ~YosemitechY4000_Temp() override = default; }; /* clang-format off */ @@ -632,7 +632,7 @@ class YosemitechY4000_ORP : public Variable { /** * @brief Destroy the YosemitechY4000_ORP object - no action needed. */ - ~YosemitechY4000_ORP() = default; + ~YosemitechY4000_ORP() override = default; }; /* clang-format off */ @@ -676,7 +676,7 @@ class YosemitechY4000_Chlorophyll : public Variable { * @brief Destroy the YosemitechY4000_Chlorophyll() object - no action * needed. */ - ~YosemitechY4000_Chlorophyll() = default; + ~YosemitechY4000_Chlorophyll() override = default; }; /* clang-format off */ @@ -719,7 +719,7 @@ class YosemitechY4000_BGA : public Variable { /** * @brief Destroy the YosemitechY4000_BGA object - no action needed. */ - ~YosemitechY4000_BGA() = default; + ~YosemitechY4000_BGA() override = default; }; /**@}*/ #endif // SRC_SENSORS_YOSEMITECHY4000_H_ diff --git a/src/sensors/YosemitechY504.h b/src/sensors/YosemitechY504.h index 8703942c2..47cc9c58f 100644 --- a/src/sensors/YosemitechY504.h +++ b/src/sensors/YosemitechY504.h @@ -227,7 +227,7 @@ class YosemitechY504 : public YosemitechParent { /** * @brief Destroy the Yosemitech Y504 object */ - ~YosemitechY504() = default; + ~YosemitechY504() override = default; }; @@ -271,7 +271,7 @@ class YosemitechY504_DOpct : public Variable { /** * @brief Destroy the YosemitechY504_DOpct object - no action needed. */ - ~YosemitechY504_DOpct() = default; + ~YosemitechY504_DOpct() override = default; }; @@ -315,7 +315,7 @@ class YosemitechY504_Temp : public Variable { /** * @brief Destroy the YosemitechY504_Temp object - no action needed. */ - ~YosemitechY504_Temp() = default; + ~YosemitechY504_Temp() override = default; }; @@ -359,7 +359,7 @@ class YosemitechY504_DOmgL : public Variable { /** * @brief Destroy the YosemitechY504_DOmgL object - no action needed. */ - ~YosemitechY504_DOmgL() = default; + ~YosemitechY504_DOmgL() override = default; }; /**@}*/ #endif // SRC_SENSORS_YOSEMITECHY504_H_ diff --git a/src/sensors/YosemitechY510.h b/src/sensors/YosemitechY510.h index 1532e1b44..a614acfca 100644 --- a/src/sensors/YosemitechY510.h +++ b/src/sensors/YosemitechY510.h @@ -193,7 +193,7 @@ class YosemitechY510 : public YosemitechParent { /** * @brief Destroy the Yosemitech Y510 object */ - ~YosemitechY510() = default; + ~YosemitechY510() override = default; }; @@ -237,7 +237,7 @@ class YosemitechY510_Turbidity : public Variable { /** * @brief Destroy the YosemitechY510_Turbidity object - no action needed. */ - ~YosemitechY510_Turbidity() = default; + ~YosemitechY510_Turbidity() override = default; }; @@ -281,7 +281,7 @@ class YosemitechY510_Temp : public Variable { /** * @brief Destroy the YosemitechY510_Temp object - no action needed. */ - ~YosemitechY510_Temp() = default; + ~YosemitechY510_Temp() override = default; }; /**@}*/ #endif // SRC_SENSORS_YOSEMITECHY510_H_ diff --git a/src/sensors/YosemitechY511.h b/src/sensors/YosemitechY511.h index 75e902bce..d65d7c008 100644 --- a/src/sensors/YosemitechY511.h +++ b/src/sensors/YosemitechY511.h @@ -207,7 +207,7 @@ class YosemitechY511 : public YosemitechParent { /** * @brief Destroy the Yosemitech Y511 object */ - ~YosemitechY511() = default; + ~YosemitechY511() override = default; }; @@ -251,7 +251,7 @@ class YosemitechY511_Turbidity : public Variable { /** * @brief Destroy the YosemitechY511_Turbidity object - no action needed. */ - ~YosemitechY511_Turbidity() = default; + ~YosemitechY511_Turbidity() override = default; }; @@ -295,7 +295,7 @@ class YosemitechY511_Temp : public Variable { /** * @brief Destroy the YosemitechY511_Temp object - no action needed. */ - ~YosemitechY511_Temp() = default; + ~YosemitechY511_Temp() override = default; }; /**@}*/ #endif // SRC_SENSORS_YOSEMITECHY511_H_ diff --git a/src/sensors/YosemitechY513.h b/src/sensors/YosemitechY513.h index dd37f44f5..c8011efc6 100644 --- a/src/sensors/YosemitechY513.h +++ b/src/sensors/YosemitechY513.h @@ -194,7 +194,7 @@ class YosemitechY513 : public YosemitechParent { /** * @brief Destroy the Yosemitech Y513 object */ - ~YosemitechY513() = default; + ~YosemitechY513() override = default; }; @@ -239,7 +239,7 @@ class YosemitechY513_BGA : public Variable { * @brief Destroy the YosemitechY513_BGA() object - no action * needed. */ - ~YosemitechY513_BGA() = default; + ~YosemitechY513_BGA() override = default; }; @@ -283,7 +283,7 @@ class YosemitechY513_Temp : public Variable { /** * @brief Destroy the YosemitechY513_Temp object - no action needed. */ - ~YosemitechY513_Temp() = default; + ~YosemitechY513_Temp() override = default; }; /**@}*/ #endif // SRC_SENSORS_YOSEMITECHY513_H_ diff --git a/src/sensors/YosemitechY514.h b/src/sensors/YosemitechY514.h index e1d73f99c..049075202 100644 --- a/src/sensors/YosemitechY514.h +++ b/src/sensors/YosemitechY514.h @@ -196,7 +196,7 @@ class YosemitechY514 : public YosemitechParent { /** * @brief Destroy the Yosemitech Y514 object */ - ~YosemitechY514() = default; + ~YosemitechY514() override = default; }; @@ -241,7 +241,7 @@ class YosemitechY514_Chlorophyll : public Variable { * @brief Destroy the YosemitechY514_Chlorophyll() object - no action * needed. */ - ~YosemitechY514_Chlorophyll() = default; + ~YosemitechY514_Chlorophyll() override = default; }; @@ -285,7 +285,7 @@ class YosemitechY514_Temp : public Variable { /** * @brief Destroy the YosemitechY514_Temp object - no action needed. */ - ~YosemitechY514_Temp() = default; + ~YosemitechY514_Temp() override = default; }; /**@}*/ #endif // SRC_SENSORS_YOSEMITECHY514_H_ diff --git a/src/sensors/YosemitechY520.h b/src/sensors/YosemitechY520.h index 074c715c7..4753718da 100644 --- a/src/sensors/YosemitechY520.h +++ b/src/sensors/YosemitechY520.h @@ -194,7 +194,7 @@ class YosemitechY520 : public YosemitechParent { /** * @brief Destroy the Yosemitech Y520 object */ - ~YosemitechY520() = default; + ~YosemitechY520() override = default; }; @@ -238,7 +238,7 @@ class YosemitechY520_Cond : public Variable { /** * @brief Destroy the YosemitechY520_Cond object - no action needed. */ - ~YosemitechY520_Cond() = default; + ~YosemitechY520_Cond() override = default; }; @@ -282,7 +282,7 @@ class YosemitechY520_Temp : public Variable { /** * @brief Destroy the YosemitechY520_Temp object - no action needed. */ - ~YosemitechY520_Temp() = default; + ~YosemitechY520_Temp() override = default; }; /**@}*/ #endif // SRC_SENSORS_YOSEMITECHY520_H_ diff --git a/src/sensors/YosemitechY532.h b/src/sensors/YosemitechY532.h index 0c7a766e3..c62b4dd81 100644 --- a/src/sensors/YosemitechY532.h +++ b/src/sensors/YosemitechY532.h @@ -220,7 +220,7 @@ class YosemitechY532 : public YosemitechParent { /** * @brief Destroy the Yosemitech Y532 object */ - ~YosemitechY532() = default; + ~YosemitechY532() override = default; }; @@ -263,7 +263,7 @@ class YosemitechY532_pH : public Variable { /** * @brief Destroy the YosemitechY532_pH object - no action needed. */ - ~YosemitechY532_pH() = default; + ~YosemitechY532_pH() override = default; }; @@ -307,7 +307,7 @@ class YosemitechY532_Temp : public Variable { /** * @brief Destroy the YosemitechY532_Temp object - no action needed. */ - ~YosemitechY532_Temp() = default; + ~YosemitechY532_Temp() override = default; }; @@ -351,7 +351,7 @@ class YosemitechY532_Voltage : public Variable { /** * @brief Destroy the YosemitechY532_Voltage object - no action needed. */ - ~YosemitechY532_Voltage() = default; + ~YosemitechY532_Voltage() override = default; }; /**@}*/ #endif // SRC_SENSORS_YOSEMITECHY532_H_ diff --git a/src/sensors/YosemitechY533.h b/src/sensors/YosemitechY533.h index bab4cd67f..e2901c457 100644 --- a/src/sensors/YosemitechY533.h +++ b/src/sensors/YosemitechY533.h @@ -196,7 +196,7 @@ class YosemitechY533 : public YosemitechParent { /** * @brief Destroy the Yosemitech Y533 object */ - ~YosemitechY533() = default; + ~YosemitechY533() override = default; }; @@ -240,7 +240,7 @@ class YosemitechY533_ORP : public Variable { /** * @brief Destroy the YosemitechY533_ORP object - no action needed. */ - ~YosemitechY533_ORP() = default; + ~YosemitechY533_ORP() override = default; }; @@ -284,7 +284,7 @@ class YosemitechY533_Temp : public Variable { /** * @brief Destroy the YosemitechY533_Temp object - no action needed. */ - ~YosemitechY533_Temp() = default; + ~YosemitechY533_Temp() override = default; }; /**@}*/ diff --git a/src/sensors/YosemitechY551.h b/src/sensors/YosemitechY551.h index 20016e050..88053f5c3 100644 --- a/src/sensors/YosemitechY551.h +++ b/src/sensors/YosemitechY551.h @@ -224,7 +224,7 @@ class YosemitechY551 : public YosemitechParent { /** * @brief Destroy the Yosemitech Y551 object */ - ~YosemitechY551() = default; + ~YosemitechY551() override = default; }; @@ -268,7 +268,7 @@ class YosemitechY551_COD : public Variable { /** * @brief Destroy the YosemitechY551_COD object - no action needed. */ - ~YosemitechY551_COD() = default; + ~YosemitechY551_COD() override = default; }; @@ -312,7 +312,7 @@ class YosemitechY551_Temp : public Variable { /** * @brief Destroy the YosemitechY551_Temp object - no action needed. */ - ~YosemitechY551_Temp() = default; + ~YosemitechY551_Temp() override = default; }; @@ -356,7 +356,7 @@ class YosemitechY551_Turbidity : public Variable { /** * @brief Destroy the YosemitechY551_Turbidity object - no action needed. */ - ~YosemitechY551_Turbidity() = default; + ~YosemitechY551_Turbidity() override = default; }; /**@}*/ #endif // SRC_SENSORS_YOSEMITECHY551_H_ diff --git a/src/sensors/YosemitechY560.h b/src/sensors/YosemitechY560.h index 8087a858d..012fa5140 100644 --- a/src/sensors/YosemitechY560.h +++ b/src/sensors/YosemitechY560.h @@ -221,7 +221,7 @@ class YosemitechY560 : public YosemitechParent { /** * @brief Destroy the Yosemitech Y560 object */ - ~YosemitechY560() = default; + ~YosemitechY560() override = default; }; @@ -265,7 +265,7 @@ class YosemitechY560_NH4_N : public Variable { /** * @brief Destroy the YosemitechY560_NH4_N object - no action needed. */ - ~YosemitechY560_NH4_N() = default; + ~YosemitechY560_NH4_N() override = default; }; @@ -309,7 +309,7 @@ class YosemitechY560_Temp : public Variable { /** * @brief Destroy the YosemitechY560_Temp object - no action needed. */ - ~YosemitechY560_Temp() = default; + ~YosemitechY560_Temp() override = default; }; @@ -352,7 +352,7 @@ class YosemitechY560_pH : public Variable { /** * @brief Destroy the YosemitechY560_pH object - no action needed. */ - ~YosemitechY560_pH() = default; + ~YosemitechY560_pH() override = default; }; /**@}*/ #endif // SRC_SENSORS_YOSEMITECHY560_H_ diff --git a/src/sensors/YosemitechY700.h b/src/sensors/YosemitechY700.h index c522abd1c..fc6187cae 100644 --- a/src/sensors/YosemitechY700.h +++ b/src/sensors/YosemitechY700.h @@ -193,7 +193,7 @@ class YosemitechY700 : public YosemitechParent { /** * @brief Destroy the Yosemitech Y700 object */ - ~YosemitechY700() = default; + ~YosemitechY700() override = default; }; @@ -237,7 +237,7 @@ class YosemitechY700_Pressure : public Variable { /** * @brief Destroy the YosemitechY700_Pressure object - no action needed. */ - ~YosemitechY700_Pressure() = default; + ~YosemitechY700_Pressure() override = default; }; @@ -281,7 +281,7 @@ class YosemitechY700_Temp : public Variable { /** * @brief Destroy the YosemitechY700_Temp object - no action needed. */ - ~YosemitechY700_Temp() = default; + ~YosemitechY700_Temp() override = default; }; /**@}*/ #endif // SRC_SENSORS_YOSEMITECHY700_H_ diff --git a/src/sensors/ZebraTechDOpto.h b/src/sensors/ZebraTechDOpto.h index 82bf1f8e4..328e836d5 100644 --- a/src/sensors/ZebraTechDOpto.h +++ b/src/sensors/ZebraTechDOpto.h @@ -249,7 +249,7 @@ class ZebraTechDOpto : public SDI12Sensors { /** * @brief Destroy the Zebra-Tech DOpto object */ - ~ZebraTechDOpto() = default; + ~ZebraTechDOpto() override = default; }; @@ -293,7 +293,7 @@ class ZebraTechDOpto_Temp : public Variable { /** * @brief Destroy the ZebraTechDOpto_Temp object - no action needed. */ - ~ZebraTechDOpto_Temp() = default; + ~ZebraTechDOpto_Temp() override = default; }; @@ -337,7 +337,7 @@ class ZebraTechDOpto_DOpct : public Variable { /** * @brief Destroy the ZebraTechDOpto_DOpct object - no action needed. */ - ~ZebraTechDOpto_DOpct() = default; + ~ZebraTechDOpto_DOpct() override = default; }; @@ -381,7 +381,7 @@ class ZebraTechDOpto_DOmgL : public Variable { /** * @brief Destroy the ZebraTechDOpto_DOmgL object - no action needed. */ - ~ZebraTechDOpto_DOmgL() = default; + ~ZebraTechDOpto_DOmgL() override = default; }; /**@}*/ #endif // SRC_SENSORS_ZEBRATECHDOPTO_H_ From 8b156d9f56a52a2d5bfc3d62210bb4f0f660b6e6 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Wed, 4 Mar 2026 14:07:06 -0500 Subject: [PATCH 423/533] Add ifndef checks Signed-off-by: Sara Damiano --- src/sensors/AtlasScientificCO2.h | 2 ++ src/sensors/AtlasScientificDO.h | 2 ++ src/sensors/AtlasScientificEC.h | 2 ++ src/sensors/AtlasScientificORP.h | 2 ++ src/sensors/AtlasScientificRTD.h | 2 ++ src/sensors/AtlasScientificpH.h | 2 ++ 6 files changed, 12 insertions(+) diff --git a/src/sensors/AtlasScientificCO2.h b/src/sensors/AtlasScientificCO2.h index f97c1dc2c..b6c019a2a 100644 --- a/src/sensors/AtlasScientificCO2.h +++ b/src/sensors/AtlasScientificCO2.h @@ -79,8 +79,10 @@ * Defines to configure and set the address of the Atlas CO2 sensor */ /**@{*/ +#ifndef ATLAS_CO2_I2C_ADDR /// @brief The default I2C address of the Atlas CO2 sensor is 0x69 (105) #define ATLAS_CO2_I2C_ADDR 0x69 +#endif /**@}*/ /** diff --git a/src/sensors/AtlasScientificDO.h b/src/sensors/AtlasScientificDO.h index 62d47efef..b95a3a2fe 100644 --- a/src/sensors/AtlasScientificDO.h +++ b/src/sensors/AtlasScientificDO.h @@ -78,8 +78,10 @@ * Defines to configure and set the address of the Atlas DO sensor */ /**@{*/ +#ifndef ATLAS_DO_I2C_ADDR /// @brief The default I2C address of the Atlas DO sensor is 0x61 (97) #define ATLAS_DO_I2C_ADDR 0x61 +#endif /**@}*/ /** diff --git a/src/sensors/AtlasScientificEC.h b/src/sensors/AtlasScientificEC.h index 4985b72f9..88268620f 100644 --- a/src/sensors/AtlasScientificEC.h +++ b/src/sensors/AtlasScientificEC.h @@ -87,9 +87,11 @@ * sensor */ /**@{*/ +#ifndef ATLAS_COND_I2C_ADDR /// @brief The default I2C address of the Atlas conductivity sensor is 0x64 /// (100) #define ATLAS_COND_I2C_ADDR 0x64 +#endif /**@}*/ /** diff --git a/src/sensors/AtlasScientificORP.h b/src/sensors/AtlasScientificORP.h index a1df68c50..dde101f76 100644 --- a/src/sensors/AtlasScientificORP.h +++ b/src/sensors/AtlasScientificORP.h @@ -55,8 +55,10 @@ * Defines to configure and set the address of the Atlas ORP sensor */ /**@{*/ +#ifndef ATLAS_ORP_I2C_ADDR /// @brief The default I2C address of the Atlas ORP sensor is 0x62 (98) #define ATLAS_ORP_I2C_ADDR 0x62 +#endif /**@}*/ /** diff --git a/src/sensors/AtlasScientificRTD.h b/src/sensors/AtlasScientificRTD.h index f5bdd769b..5587e9eb5 100644 --- a/src/sensors/AtlasScientificRTD.h +++ b/src/sensors/AtlasScientificRTD.h @@ -61,8 +61,10 @@ * sensor */ /**@{*/ +#ifndef ATLAS_RTD_I2C_ADDR /// @brief The default I2C address of the Atlas RTD sensor is 0x66 (102) #define ATLAS_RTD_I2C_ADDR 0x66 +#endif /**@}*/ /** diff --git a/src/sensors/AtlasScientificpH.h b/src/sensors/AtlasScientificpH.h index 56c28b302..9069ed736 100644 --- a/src/sensors/AtlasScientificpH.h +++ b/src/sensors/AtlasScientificpH.h @@ -57,8 +57,10 @@ * Defines to configure and set the address of the Atlas pH sensor */ /**@{*/ +#ifndef ATLAS_PH_I2C_ADDR /// @brief The default I2C address of the Atlas pH sensor is 0x63 (99) #define ATLAS_PH_I2C_ADDR 0x63 +#endif /**@}*/ /** From 784055bcdbea2985f440f90ead8bffcd3d91fadb Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Wed, 4 Mar 2026 14:19:41 -0500 Subject: [PATCH 424/533] Fix some comments, unmarked overrides Signed-off-by: Sara Damiano --- src/sensors/AOSongAM2315.h | 11 ++++++++++- src/sensors/BoschBME280.h | 6 ++++-- src/sensors/BoschBMP3xx.h | 4 +++- src/sensors/Decagon5TM.cpp | 3 ++- src/sensors/GeoluxHydroCam.cpp | 6 ++++-- src/sensors/GroPointParent.h | 3 --- src/sensors/InSituRDO.h | 2 +- src/sensors/KnownProcessors.h | 6 +++--- src/sensors/MeterTeros11.cpp | 3 ++- src/sensors/YosemitechY533.h | 2 +- 10 files changed, 30 insertions(+), 16 deletions(-) diff --git a/src/sensors/AOSongAM2315.h b/src/sensors/AOSongAM2315.h index a32bd4197..5af4c40dc 100644 --- a/src/sensors/AOSongAM2315.h +++ b/src/sensors/AOSongAM2315.h @@ -217,6 +217,15 @@ class AOSongAM2315 : public Sensor { */ ~AOSongAM2315() override; + // Delete copy constructor and copy assignment operator to prevent shallow + // copies + AOSongAM2315(const AOSongAM2315&) = delete; + AOSongAM2315& operator=(const AOSongAM2315&) = delete; + + // Delete move constructor and move assignment operator + AOSongAM2315(AOSongAM2315&&) = delete; + AOSongAM2315& operator=(AOSongAM2315&&) = delete; + /** * @brief Report the I2C address of the AM2315 - which is always 0xB8. * @@ -290,7 +299,7 @@ class AOSongAM2315_Humidity : public Variable { /** * @brief Destroy the AOSongAM2315_Humidity object - no action needed. */ - ~AOSongAM2315_Humidity() = default; + ~AOSongAM2315_Humidity() override = default; }; diff --git a/src/sensors/BoschBME280.h b/src/sensors/BoschBME280.h index 10e6a2f91..5f9e09202 100644 --- a/src/sensors/BoschBME280.h +++ b/src/sensors/BoschBME280.h @@ -247,6 +247,8 @@ /// @brief Variable name in /// [ODM2 controlled vocabulary](http://vocabulary.odm2.org/variablename/); /// "altitude" +/// @remark In library versions 0.37.0 and earlier, this variable was +/// incorrectly named "heightAboveSeaFloor" #define BME280_ALTITUDE_VAR_NAME "altitude" /// @brief Variable unit name in /// [ODM2 controlled vocabulary](http://vocabulary.odm2.org/units/); "meter" @@ -304,7 +306,7 @@ class BoschBME280 : public Sensor { /** * @brief Destroy the Bosch BME280 object */ - ~BoschBME280() = default; + ~BoschBME280() override = default; bool wake(void) override; /** @@ -468,7 +470,7 @@ class BoschBME280_Pressure : public Variable { /** * @brief Destroy the BoschBME280_Pressure object - no action needed. */ - ~BoschBME280_Pressure() = default; + ~BoschBME280_Pressure() override = default; }; diff --git a/src/sensors/BoschBMP3xx.h b/src/sensors/BoschBMP3xx.h index c6b629947..dabadb2ab 100644 --- a/src/sensors/BoschBMP3xx.h +++ b/src/sensors/BoschBMP3xx.h @@ -305,6 +305,8 @@ /// @brief Variable name in /// [ODM2 controlled vocabulary](http://vocabulary.odm2.org/variablename/); /// "altitude" +/// @remark In library versions 0.37.0 and earlier, this variable was +/// incorrectly named "heightAboveSeaFloor" #define BMP3XX_ALTITUDE_VAR_NAME "altitude" /// @brief Variable unit name in /// [ODM2 controlled vocabulary](http://vocabulary.odm2.org/units/); "meter" @@ -606,7 +608,7 @@ class BoschBMP3xx_Temp : public Variable { /** * @brief Destroy the BoschBMP3xx_Temp object - no action needed. */ - ~BoschBMP3xx_Temp() = default; + ~BoschBMP3xx_Temp() override = default; }; diff --git a/src/sensors/Decagon5TM.cpp b/src/sensors/Decagon5TM.cpp index 2ff5246e8..31cf6edd0 100644 --- a/src/sensors/Decagon5TM.cpp +++ b/src/sensors/Decagon5TM.cpp @@ -46,7 +46,8 @@ bool Decagon5TM::getResults(bool verify_crc) { // VWC = 3.879e-4*raw-0.6956; // equation for mineral soils - // range check on temp; range is - 40°C to + 50°C + // range check on temp; range is - 40°C to + 50°C (with 10°C margin beyond + // spec) if (temp < -50 || temp > 60) { temp = MS_INVALID_VALUE; MS_DBG(F("WARNING: temperature results out of range (-50-60)!")); diff --git a/src/sensors/GeoluxHydroCam.cpp b/src/sensors/GeoluxHydroCam.cpp index b413d73ee..5096f5161 100644 --- a/src/sensors/GeoluxHydroCam.cpp +++ b/src/sensors/GeoluxHydroCam.cpp @@ -214,7 +214,8 @@ bool GeoluxHydroCam::addSingleMeasurementResult(void) { return bumpMeasurementAttemptCount(false); } - // Create and then open the file in write mode + // Open the file in write mode - creating a new file if it doesn't exist or + // appending to the end an existing one if (imgFile.open(filename.c_str(), O_CREAT | O_WRITE | O_AT_END)) { MS_DBG(F("Created new file:"), filename); } else { @@ -232,7 +233,8 @@ bool GeoluxHydroCam::addSingleMeasurementResult(void) { // transfer the image from the camera to a file on the SD card MS_START_DEBUG_TIMER; bytes_transferred = _camera.transferImage(imgFile, image_size); - byte_error = labs(bytes_transferred - image_size); + byte_error = (bytes_transferred >= 0) ? labs(bytes_transferred - image_size) + : MS_INVALID_VALUE; // Close the image file after transfer imgFile.close(); diff --git a/src/sensors/GroPointParent.h b/src/sensors/GroPointParent.h index ecb85ff04..d5ec5ee7c 100644 --- a/src/sensors/GroPointParent.h +++ b/src/sensors/GroPointParent.h @@ -44,9 +44,6 @@ * AltSoftSerial and HardwareSerial work fine. * Up to two power pins are provided so that the RS485 adapter, the sensor and/or an external power relay can be controlled separately. * If the power to everything is controlled by the same pin, use -1 for the second power pin or omit the argument. - * If they are controlled by different pins _and no other sensors are dependent on power from either pin_ then the order of the pins doesn't matter. - * If the RS485 adapter, sensor, or relay are controlled by different pins _and any other sensors are controlled by the same pins_ you should put the shared pin first and the un-shared pin second. - * Both pins _cannot_ be shared pins. * * By default, this library cuts power to the sensors between readings, causing them to lose track of their brushing interval. * The library manually activates the brushes as part of the "wake" command. diff --git a/src/sensors/InSituRDO.h b/src/sensors/InSituRDO.h index 20e6f24ea..7e699c36e 100644 --- a/src/sensors/InSituRDO.h +++ b/src/sensors/InSituRDO.h @@ -332,7 +332,7 @@ * {{ @ref InSituRDO_Pressure::InSituRDO_Pressure }} */ /**@{*/ -/// @brief Decimal places in string representation; pressure should have 3 +/// @brief Decimal places in string representation; pressure should have 2 #define INSITU_RDO_PRESSURE_RESOLUTION 2 /// @brief Variable number; temperature is stored in sensorValues[3]. #define INSITU_RDO_PRESSURE_VAR_NUM 3 diff --git a/src/sensors/KnownProcessors.h b/src/sensors/KnownProcessors.h index aad16550b..ca74d62fe 100644 --- a/src/sensors/KnownProcessors.h +++ b/src/sensors/KnownProcessors.h @@ -266,7 +266,7 @@ #define OPERATING_VOLTAGE 3.3 #pragma message \ "Warning: OPERATING_VOLTAGE is not defined for this processor.\n" \ - "If you have specified the operating voltage in your code, you can ignore this message\n." \ + "If you have specified the operating voltage in your code, you can ignore this message.\n" \ "The operating voltage can be added by editing KnownProcessors.h." #endif #ifndef BATTERY_PIN @@ -274,7 +274,7 @@ #pragma message \ "Warning: BATTERY_PIN is not defined for this processor.\n" \ "If your processor does not have a built-in pin for measuring the battery voltage," \ - "or you have specified a different pin in your code, you can ignore this message\n." \ + "or you have specified a different pin in your code, you can ignore this message.\n" \ "The battery pin can be added by editing KnownProcessors.h." #endif @@ -283,7 +283,7 @@ #pragma message \ "Warning: BATTERY_MULTIPLIER is not defined for this processor.\n" \ "If your processor does not have a built-in pin for measuring the battery voltage," \ - "or you have specified the multiplier in your code, you can ignore this message\n." \ + "or you have specified the multiplier in your code, you can ignore this message.\n" \ "The battery multiplier can be added by editing KnownProcessors.h." #endif diff --git a/src/sensors/MeterTeros11.cpp b/src/sensors/MeterTeros11.cpp index d8c234864..41b304ec0 100644 --- a/src/sensors/MeterTeros11.cpp +++ b/src/sensors/MeterTeros11.cpp @@ -67,7 +67,8 @@ bool MeterTeros11::getResults(bool verify_crc) { // VWC = 3.879e-4*raw-0.6956; // equation for mineral soils - // range check on temp; range is - 40°C to + 50°C + // range check on temp; sensor range is -40°C to +50°C; add an extra 10°C + // buffer on either side if (temp < -50 || temp > 60) { temp = MS_INVALID_VALUE; MS_DBG(F("WARNING: temperature results out of range (-50-60)!")); diff --git a/src/sensors/YosemitechY533.h b/src/sensors/YosemitechY533.h index e2901c457..de35736ed 100644 --- a/src/sensors/YosemitechY533.h +++ b/src/sensors/YosemitechY533.h @@ -96,7 +96,7 @@ * {{ @ref YosemitechY533_ORP::YosemitechY533_ORP }} */ /**@{*/ -/// @brief Decimal places in string representation; ph should have 2 - +/// @brief Decimal places in string representation; ORP should have 0 - /// resolution is 1 mV units. #define Y533_ORP_RESOLUTION 0 /// @brief Sensor variable number; ORP is stored in sensorValues[0]. From a99860bc7ad68d43e3a47d5073968fbc4f4b4280 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Wed, 4 Mar 2026 14:21:03 -0500 Subject: [PATCH 425/533] Replace the many, many (void) functions with c++ style () Signed-off-by: Sara Damiano --- src/ClockSupport.cpp | 8 +-- src/ClockSupport.h | 6 +- src/LogBuffer.cpp | 8 +-- src/LogBuffer.h | 8 +-- src/LoggerBase.cpp | 34 +++++------ src/LoggerBase.h | 32 +++++----- src/LoggerModem.cpp | 24 ++++---- src/LoggerModem.h | 48 +++++++-------- src/SensorBase.cpp | 60 +++++++++---------- src/SensorBase.h | 52 ++++++++-------- src/VariableArray.cpp | 18 +++--- src/VariableArray.h | 20 +++---- src/VariableBase.cpp | 18 +++--- src/VariableBase.h | 22 +++---- src/WatchDogs/WatchDogSAMD.cpp | 2 +- src/WatchDogs/WatchDogSAMD.h | 2 +- src/dataPublisherBase.cpp | 2 +- src/dataPublisherBase.h | 4 +- src/modems/DigiXBee.cpp | 4 +- src/modems/DigiXBee.h | 4 +- src/modems/DigiXBee3GBypass.cpp | 4 +- src/modems/DigiXBee3GBypass.h | 16 ++--- src/modems/DigiXBeeCellularTransparent.cpp | 10 ++-- src/modems/DigiXBeeCellularTransparent.h | 20 +++---- src/modems/DigiXBeeLTEBypass.cpp | 4 +- src/modems/DigiXBeeLTEBypass.h | 16 ++--- src/modems/DigiXBeeWifi.cpp | 8 +-- src/modems/DigiXBeeWifi.h | 16 ++--- src/modems/Espressif.cpp | 4 +- src/modems/Espressif.h | 4 +- src/modems/EspressifESP32.cpp | 4 +- src/modems/EspressifESP32.h | 16 ++--- src/modems/EspressifESP8266.cpp | 4 +- src/modems/EspressifESP8266.h | 16 ++--- src/modems/LoggerModemMacros.h | 24 ++++---- src/modems/QuectelBG96.cpp | 6 +- src/modems/QuectelBG96.h | 20 +++---- src/modems/SIMComSIM7000.cpp | 4 +- src/modems/SIMComSIM7000.h | 18 +++--- src/modems/SIMComSIM7080.cpp | 6 +- src/modems/SIMComSIM7080.h | 18 +++--- src/modems/SIMComSIM800.cpp | 4 +- src/modems/SIMComSIM800.h | 18 +++--- src/modems/SequansMonarch.cpp | 6 +- src/modems/SequansMonarch.h | 18 +++--- src/modems/Sodaq2GBeeR6.cpp | 6 +- src/modems/Sodaq2GBeeR6.h | 6 +- src/modems/SodaqUBeeR410M.cpp | 8 +-- src/modems/SodaqUBeeR410M.h | 20 +++---- src/modems/SodaqUBeeU201.cpp | 6 +- src/modems/SodaqUBeeU201.h | 18 +++--- src/publishers/AWS_IoT_Publisher.cpp | 2 +- src/publishers/AWS_IoT_Publisher.h | 6 +- src/publishers/DreamHostPublisher.cpp | 2 +- src/publishers/DreamHostPublisher.h | 2 +- .../MonitorMyWatershedPublisher.cpp | 8 +-- src/publishers/MonitorMyWatershedPublisher.h | 10 ++-- src/publishers/S3PresignedPublisher.cpp | 7 +-- src/publishers/S3PresignedPublisher.h | 18 +++--- src/publishers/ThingSpeakPublisher.h | 2 +- src/publishers/UbidotsPublisher.h | 2 +- src/sensors/ANBpH.cpp | 14 ++--- src/sensors/ANBpH.h | 16 ++--- src/sensors/AOSongAM2315.cpp | 6 +- src/sensors/AOSongAM2315.h | 6 +- src/sensors/AOSongDHT.cpp | 6 +- src/sensors/AOSongDHT.h | 6 +- src/sensors/AlphasenseCO2.cpp | 6 +- src/sensors/AlphasenseCO2.h | 6 +- src/sensors/AnalogElecConductivity.cpp | 6 +- src/sensors/AnalogElecConductivity.h | 6 +- src/sensors/AnalogVoltageBase.h | 8 +-- src/sensors/ApogeeSQ212.cpp | 6 +- src/sensors/ApogeeSQ212.h | 6 +- src/sensors/AtlasParent.cpp | 10 ++-- src/sensors/AtlasParent.h | 12 ++-- src/sensors/AtlasScientificCO2.h | 2 +- src/sensors/AtlasScientificDO.h | 2 +- src/sensors/AtlasScientificEC.h | 2 +- src/sensors/BoschBME280.cpp | 8 +-- src/sensors/BoschBME280.h | 10 ++-- src/sensors/BoschBMP3xx.cpp | 10 ++-- src/sensors/BoschBMP3xx.h | 10 ++-- src/sensors/CampbellOBS3.cpp | 6 +- src/sensors/CampbellOBS3.h | 6 +- src/sensors/EverlightALSPT19.cpp | 6 +- src/sensors/EverlightALSPT19.h | 6 +- src/sensors/FreescaleMPL115A2.cpp | 6 +- src/sensors/FreescaleMPL115A2.h | 6 +- src/sensors/GeoluxHydroCam.cpp | 12 ++-- src/sensors/GeoluxHydroCam.h | 12 ++-- src/sensors/GroPointParent.cpp | 10 ++-- src/sensors/GroPointParent.h | 10 ++-- src/sensors/KellerParent.cpp | 8 +-- src/sensors/KellerParent.h | 8 +-- src/sensors/MaxBotixSonar.cpp | 10 ++-- src/sensors/MaxBotixSonar.h | 10 ++-- src/sensors/MaximDS18.cpp | 8 +-- src/sensors/MaximDS18.h | 8 +-- src/sensors/MaximDS3231.cpp | 8 +-- src/sensors/MaximDS3231.h | 8 +-- src/sensors/MeaSpecMS5803.cpp | 6 +- src/sensors/MeaSpecMS5803.h | 6 +- src/sensors/PaleoTerraRedox.cpp | 6 +- src/sensors/PaleoTerraRedox.h | 6 +- src/sensors/ProcessorAnalog.cpp | 6 +- src/sensors/ProcessorAnalog.h | 8 +-- src/sensors/ProcessorStats.cpp | 10 ++-- src/sensors/ProcessorStats.h | 12 ++-- src/sensors/RainCounterI2C.cpp | 6 +- src/sensors/RainCounterI2C.h | 6 +- src/sensors/SDI12Sensors.cpp | 26 ++++---- src/sensors/SDI12Sensors.h | 24 ++++---- src/sensors/SensirionSHT4x.cpp | 8 +-- src/sensors/SensirionSHT4x.h | 8 +-- src/sensors/TEConnectivityMS5837.cpp | 10 ++-- src/sensors/TEConnectivityMS5837.h | 10 ++-- src/sensors/TIADS1x15.cpp | 16 ++--- src/sensors/TIADS1x15.h | 16 ++--- src/sensors/TIINA219.cpp | 8 +-- src/sensors/TIINA219.h | 8 +-- src/sensors/TallyCounterI2C.cpp | 6 +- src/sensors/TallyCounterI2C.h | 8 +-- src/sensors/TurnerCyclops.cpp | 6 +- src/sensors/TurnerCyclops.h | 6 +- src/sensors/TurnerTurbidityPlus.cpp | 12 ++-- src/sensors/TurnerTurbidityPlus.h | 14 ++--- src/sensors/YosemitechParent.cpp | 10 ++-- src/sensors/YosemitechParent.h | 10 ++-- 129 files changed, 686 insertions(+), 687 deletions(-) diff --git a/src/ClockSupport.cpp b/src/ClockSupport.cpp index 04f9b6316..0ea290d39 100644 --- a/src/ClockSupport.cpp +++ b/src/ClockSupport.cpp @@ -227,7 +227,7 @@ void loggerClock::setRTCOffset(int8_t offsetHours) { } #endif } -int8_t loggerClock::getRTCOffset(void) { +int8_t loggerClock::getRTCOffset() { return loggerClock::_rtcUTCOffset; } @@ -397,7 +397,7 @@ bool loggerClock::setRTClock(epochTime in_time, int8_t utcOffset) { } // This checks that the logger time is within a "sane" range -bool loggerClock::isRTCSane(void) { +bool loggerClock::isRTCSane() { time_t curRTC = getRawRTCNow(); bool is_sane = isEpochTimeSane(curRTC, loggerClock::_rtcUTCOffset, loggerClock::_rtcEpoch); @@ -531,7 +531,7 @@ void loggerClock::disableRTCInterrupts() { #endif } -void loggerClock::resetClockInterruptStatus(void) { +void loggerClock::resetClockInterruptStatus() { MS_DBG(F("Clearing all interrupt flags on the"), MS_CLOCK_NAME); #if defined(MS_USE_RV8803) // NOTE: We're not going to bother to call getInterruptFlag(x) to see which @@ -554,7 +554,7 @@ void loggerClock::resetClockInterruptStatus(void) { #endif } -void loggerClock::rtcISR(void) { +void loggerClock::rtcISR() { #if defined(MS_CLOCKSUPPORT_DEBUG) || defined(MS_LOGGERBASE_DEBUG_DEEP) // This is bad practice - calling a Serial.print from an ISR // But.. it's so helpful for debugging! diff --git a/src/ClockSupport.h b/src/ClockSupport.h index f84e9936b..7ca2e1956 100644 --- a/src/ClockSupport.h +++ b/src/ClockSupport.h @@ -374,7 +374,7 @@ class loggerClock { * * @return The offset of the real-time clock (RTC) from UTC in hours */ - static int8_t getRTCOffset(void); + static int8_t getRTCOffset(); /** * @brief Get the current Universal Coordinated Time (UTC) epoch time from @@ -511,7 +511,7 @@ class loggerClock { * @return True if the current time on the RTC passes sanity range * checking */ - static bool isRTCSane(void); + static bool isRTCSane(); /** * @brief Check that a given epoch time (seconds since 1970) is within a * "sane" range. @@ -587,7 +587,7 @@ class loggerClock { * For some clocks, we need to reset the clock's interrupt flag so the next * interrupt will fire. */ - static void rtcISR(void); + static void rtcISR(); /** * @brief Start up the real-time clock. diff --git a/src/LogBuffer.cpp b/src/LogBuffer.cpp index 731d3a642..366f392c0 100644 --- a/src/LogBuffer.cpp +++ b/src/LogBuffer.cpp @@ -25,7 +25,7 @@ void LogBuffer::setNumVariables(uint8_t numVariables_) { clear(); } -void LogBuffer::clear(void) { +void LogBuffer::clear() { // clear out the buffer numRecords = 0; dataBufferTail = 0; @@ -33,15 +33,15 @@ void LogBuffer::clear(void) { _bufferOverflow = false; } -uint8_t LogBuffer::getNumVariables(void) { +uint8_t LogBuffer::getNumVariables() { return numVariables; } -int LogBuffer::getNumRecords(void) { +int LogBuffer::getNumRecords() { return numRecords; } -uint8_t LogBuffer::getPercentFull(void) { +uint8_t LogBuffer::getPercentFull() { uint32_t bytesFull = (uint32_t)numRecords * (uint32_t)recordSize; uint32_t bytesTotal = MS_LOG_DATA_BUFFER_SIZE; diff --git a/src/LogBuffer.h b/src/LogBuffer.h index daab29832..c965c6046 100644 --- a/src/LogBuffer.h +++ b/src/LogBuffer.h @@ -69,26 +69,26 @@ class LogBuffer { * * @return The variable count. */ - uint8_t getNumVariables(void); + uint8_t getNumVariables(); /** * @brief Clears all records from the log. */ - void clear(void); + void clear(); /** * @brief Gets the number of records currently in the log. * * @return The number of records. */ - int getNumRecords(void); + int getNumRecords(); /** * @brief Computes the percentage full of the buffer. * * @return The current percent full. */ - uint8_t getPercentFull(void); + uint8_t getPercentFull(); /** * @brief Adds a new record with the given timestamp. diff --git a/src/LoggerBase.cpp b/src/LoggerBase.cpp index e09ea8746..bdd0b7ed7 100644 --- a/src/LoggerBase.cpp +++ b/src/LoggerBase.cpp @@ -516,7 +516,7 @@ loggerModem* Logger::registerDataPublisher(dataPublisher* publisher) { return _logModem; } -bool Logger::checkRemotesConnectionNeeded(void) { +bool Logger::checkRemotesConnectionNeeded() { MS_DBG(F("Asking publishers if they need a connection.")); bool needed = false; @@ -541,7 +541,7 @@ void Logger::publishDataToRemotes(bool forceFlush) { } } } -void Logger::sendDataToRemotes(void) { +void Logger::sendDataToRemotes() { publishDataToRemotes(); } void Logger::publishMetadataToRemotes() { @@ -577,7 +577,7 @@ void Logger::setLoggerTimeZone(int8_t timeZone) { } #endif } -int8_t Logger::getLoggerTimeZone(void) { +int8_t Logger::getLoggerTimeZone() { return Logger::_loggerUTCOffset; } // Sets the static timezone that the RTC is programmed in @@ -587,7 +587,7 @@ int8_t Logger::getLoggerTimeZone(void) { void Logger::setRTCTimeZone(int8_t timeZone) { loggerClock::setRTCOffset(timeZone); } -int8_t Logger::getRTCTimeZone(void) { +int8_t Logger::getRTCTimeZone() { return loggerClock::getRTCOffset(); } @@ -613,7 +613,7 @@ void Logger::setTZOffset(int8_t offset) { F("hours behind the logging timezone")); } } -int8_t Logger::getTZOffset(void) { +int8_t Logger::getTZOffset() { return Logger::_loggerRTCOffset; } time_t Logger::getNowLocalEpoch() { @@ -645,7 +645,7 @@ void Logger::formatDateTime(char* buffer, const char* fmt, Logger::_loggerEpoch); } // This checks that the logger time is within a "sane" range -bool Logger::isRTCSane(void) { +bool Logger::isRTCSane() { return loggerClock::isRTCSane(); } @@ -657,7 +657,7 @@ bool Logger::isRTCSane(void) { // It is not currently possible to output the instantaneous time an individual // sensor was updated, just a single marked time. By custom, this should be // called before updating the sensors, not after. -void Logger::markTime(void) { +void Logger::markTime() { MS_DEEP_DBG(F("Marking time...")); Logger::markedUTCUnixTime = getNowUTCEpoch(); Logger::markedLocalUnixTime = markedUTCUnixTime + @@ -667,7 +667,7 @@ void Logger::markTime(void) { // This checks to see if the CURRENT time is an even interval of the logging // rate -bool Logger::checkInterval(void) { +bool Logger::checkInterval() { bool retval; uint32_t checkTime = static_cast(getNowLocalEpoch()); int16_t interval = _loggingIntervalMinutes; @@ -723,7 +723,7 @@ bool Logger::checkInterval(void) { // This checks to see if the MARKED time is an even interval of the logging rate -bool Logger::checkMarkedInterval(void) { +bool Logger::checkMarkedInterval() { int16_t interval = _loggingIntervalMinutes; // If we're within the range of our initial short intervals, we're logging, // then set the interval to 1. @@ -762,14 +762,14 @@ bool Logger::checkMarkedInterval(void) { // In this case, we're doing nothing, we just want the processor to wake // This must be a static function (which means it can only call other static // functions.) -void Logger::wakeISR(void) { +void Logger::wakeISR() { MS_DEEP_DBG(F("\nInterrupt on wake pin!")); } // Puts the system to sleep to conserve battery life. // This DOES NOT sleep or wake the sensors!! -void Logger::systemSleep(void) { +void Logger::systemSleep() { MS_DBG(F("\n\nEntering system sleep function. ZZzzz...")); #if !defined(MS_USE_RTC_ZERO) @@ -915,7 +915,7 @@ void Logger::systemSleep(void) { // https://github.com/adafruit/circuitpython/blob/65cfcb83f279869c7b38eb5891ddac557dba155b/ports/atmel-samd/common-hal/alarm/__init__.c#L146 if (__get_FPSCR() & ~(0x9f)) { __set_FPSCR(__get_FPSCR() & ~(0x9f)); - (void)__get_FPSCR(); + () __get_FPSCR(); } // Set the sleep config @@ -1239,7 +1239,7 @@ String Logger::generateFileName(bool include_time, const char* extension, // This generates a file name from the logger id and the current date // This will be used if the setFileName function is not called before the // begin() function is called. -void Logger::generateAutoFileName(void) { +void Logger::generateAutoFileName() { // Generate the file name from logger ID and date auto fileName = generateFileName(false, ".csv"); setFileName(fileName); @@ -1320,7 +1320,7 @@ void Logger::printSensorDataCSV(Stream* stream) { } // Protected helper function - This checks if the SD card is available and ready -bool Logger::initializeSDCard(void) { +bool Logger::initializeSDCard() { // If we don't know the slave select of the sd card, we can't use it if (_SDCardSSPin < 0) { PRINTOUT(F("Slave/Chip select pin for SD card has not been set.")); @@ -1463,7 +1463,7 @@ bool Logger::openFile(String& filename, bool createFile, // These functions create a file on the SD card with the given filename and // set the proper timestamps to the file. // The filename may either be the one set by -// setFileName(String)/setFileName(void) or can be specified in the function. If +// setFileName(String)/setFileName() or can be specified in the function. If // specified, it will also write a header to the file based on the sensors in // the group. This can be used to force a logger to create a file with a // secondary file name. @@ -1488,7 +1488,7 @@ bool Logger::createLogFile(bool writeDefaultHeader) { // These functions write a file on the SD card with the given filename and // set the proper timestamps to the file. // The filename may either be the one set by -// setFileName(String)/setFileName(void) or can be specified in the function. If +// setFileName(String)/setFileName() or can be specified in the function. If // the file does not already exist, the file will be created. This can be used // to force a logger to write to a file with a secondary file name. bool Logger::logToSD(String& filename, String& rec) { @@ -1521,7 +1521,7 @@ bool Logger::logToSD(String& rec) { } // NOTE: This is structured differently than the version with a string input // record. This is to avoid the creation/passing of very long strings. -bool Logger::logToSD(void) { +bool Logger::logToSD() { // Get a new file name if the name is blank if (_fileName == "") generateAutoFileName(); diff --git a/src/LoggerBase.h b/src/LoggerBase.h index 8ec1e6933..2e1f81f6d 100644 --- a/src/LoggerBase.h +++ b/src/LoggerBase.h @@ -747,7 +747,7 @@ class Logger { * * @return True if any remotes need a connection. */ - bool checkRemotesConnectionNeeded(void); + bool checkRemotesConnectionNeeded(); /** * @brief Publish data to all registered data publishers. * @@ -760,7 +760,7 @@ class Logger { * * @m_deprecated_since{0,22,5} */ - void sendDataToRemotes(void); + void sendDataToRemotes(); /** * @brief Publish **metadata** to all registered data publishers. * @@ -812,7 +812,7 @@ class Logger { * @return The timezone data is be saved to the SD card in. This * is not be the same as the timezone of the real time clock. */ - static int8_t getLoggerTimeZone(void); + static int8_t getLoggerTimeZone(); /** * @brief A passthrough to loggerClock::setRTCOffset(int8_t offsetHours); @@ -837,7 +837,7 @@ class Logger { * * @return The offset of the real-time clock (RTC) from UTC in hours */ - static int8_t getRTCTimeZone(void); + static int8_t getRTCTimeZone(); /** * @brief Set the offset between the built-in clock and the time zone * where the data is being recorded. @@ -857,7 +857,7 @@ class Logger { * @return The offset between the built-in clock and the time * zone where the data is being recorded. */ - static int8_t getTZOffset(void); + static int8_t getTZOffset(); /** * @brief Get the current epoch time from the RTC and correct it to the @@ -964,7 +964,7 @@ class Logger { * @return True if the current time on the RTC passes sanity range * checking */ - static bool isRTCSane(void); + static bool isRTCSane(); /** * @brief Set static variables for the date/time @@ -976,7 +976,7 @@ class Logger { * an individual sensor was updated, just a single marked time. By custom, * this should be called before updating the sensors, not after. */ - static void markTime(void); + static void markTime(); /** * @brief Check if the CURRENT time is an even interval of the logging rate @@ -984,7 +984,7 @@ class Logger { * @return True if the current time on the RTC is an even interval * of the logging rate. */ - bool checkInterval(void); + bool checkInterval(); /** * @brief Check if the MARKED time is an even interval of the logging rate - @@ -998,7 +998,7 @@ class Logger { * @return True if the marked time is an even interval of the * logging rate. */ - bool checkMarkedInterval(void); + bool checkMarkedInterval(); protected: /** @@ -1113,7 +1113,7 @@ class Logger { * * Use loggerClock::rtcISR() in new code! */ - static void wakeISR(void); + static void wakeISR(); /** * @brief Put the mcu to sleep to conserve battery life and handle @@ -1126,7 +1126,7 @@ class Logger { * I2C device during sleep (ie, thorough an interrupt) will cause the board * to hang indefinitely. */ - void systemSleep(void); + void systemSleep(); #if defined(ARDUINO_ARCH_SAMD) public: @@ -1227,7 +1227,7 @@ class Logger { * * @return The name of the file data is currently being saved to. */ - String getFileName(void) { + String getFileName() { return _fileName; } @@ -1259,7 +1259,7 @@ class Logger { * * @return True if the SD card is ready */ - bool initializeSDCard(void); + bool initializeSDCard(); /** * @brief Create a file on the SD card and set the created, modified, and @@ -1330,7 +1330,7 @@ class Logger { * @return True if the file was successfully accessed or created * _and_ data appended to it. */ - bool logToSD(void); + bool logToSD(); /** * @brief Generate a file name with the current date and time appended to @@ -1368,7 +1368,7 @@ class Logger { * * @note This cannot be called until *after* the RTC is started */ - void generateAutoFileName(void); + void generateAutoFileName(); /** * @brief This function is used to automatically mark files as @@ -1422,7 +1422,7 @@ class Logger { * @brief The interrupt service routine called when an interrupt is detected * on the pin assigned for "testing" mode. */ - static void testingISR(void); + static void testingISR(); /** * @brief Execute bench testing mode if enabled. diff --git a/src/LoggerModem.cpp b/src/LoggerModem.cpp index 8f9f9ec96..474391f7f 100644 --- a/src/LoggerModem.cpp +++ b/src/LoggerModem.cpp @@ -51,22 +51,22 @@ void loggerModem::setModemLED(int8_t modemLEDPin) { digitalWrite(_modemLEDPin, LOW); } } -void loggerModem::modemLEDOn(void) { +void loggerModem::modemLEDOn() { if (_modemLEDPin >= 0) { pinMode(_modemLEDPin, OUTPUT); digitalWrite(_modemLEDPin, HIGH); } } -void loggerModem::modemLEDOff(void) { +void loggerModem::modemLEDOff() { if (_modemLEDPin >= 0) { digitalWrite(_modemLEDPin, LOW); } } -String loggerModem::getModemName(void) { +String loggerModem::getModemName() { return _modemName; } // @todo Implement this for all modems -String loggerModem::getModemDevId(void) { +String loggerModem::getModemDevId() { return _modemName + F(" Sn ") + _modemSerialNumber + F(" HwVer ") + _modemHwVersion + F(" FwVer ") + _modemFwVersion; } @@ -75,7 +75,7 @@ void loggerModem::setModemTimeZone(int8_t timeZone) { _modemUTCOffset = timeZone; } -void loggerModem::modemPowerUp(void) { +void loggerModem::modemPowerUp() { if (_powerPin >= 0) { if (_modemSleepRqPin >= 0) { // For most modules, the sleep pin should be held high during power @@ -99,7 +99,7 @@ void loggerModem::modemPowerUp(void) { } } -void loggerModem::modemPowerDown(void) { +void loggerModem::modemPowerDown() { if (_powerPin >= 0) { MS_DBG(F("Turning off power to"), getModemName(), F("with pin"), _powerPin); @@ -112,7 +112,7 @@ void loggerModem::modemPowerDown(void) { } } -bool loggerModem::modemSetup(void) { +bool loggerModem::modemSetup() { // NOTE: Set flag FIRST to stop infinite loop between modemSetup() and // modemWake() bool success = true; @@ -177,7 +177,7 @@ bool loggerModem::modemSetup(void) { } // Nicely put the modem to sleep and power down -bool loggerModem::modemSleep(void) { +bool loggerModem::modemSleep() { bool success = true; MS_DBG(F("Putting"), getModemName(), F("to sleep.")); @@ -203,7 +203,7 @@ bool loggerModem::modemSleep(void) { } // Nicely put the modem to sleep and power down -bool loggerModem::modemSleepPowerDown(void) { +bool loggerModem::modemSleepPowerDown() { bool success = true; uint32_t start = millis(); MS_DBG(F("Turning"), getModemName(), F("off.")); @@ -256,7 +256,7 @@ bool loggerModem::modemSleepPowerDown(void) { } // Perform a hard/panic reset for when the modem is completely unresponsive -bool loggerModem::modemHardReset(void) { +bool loggerModem::modemHardReset() { if (_modemResetPin >= 0) { MS_DBG(F("Doing a hard reset on the modem by setting pin"), _modemResetPin, _resetLevel ? F("HIGH") : F("LOW"), F("for"), @@ -281,7 +281,7 @@ void loggerModem::setModemResetLevel(bool level) { } -void loggerModem::setModemPinModes(void) { +void loggerModem::setModemPinModes() { // Set-up pin modes if (_statusPin >= 0) { MS_DEEP_DBG(F("Initializing pin"), _statusPin, @@ -323,7 +323,7 @@ void loggerModem::setMetadataPolling(uint8_t pollingBitmask) { } -bool loggerModem::updateModemMetadata(void) { +bool loggerModem::updateModemMetadata() { bool success = true; // Unset whatever we had previously diff --git a/src/LoggerModem.h b/src/LoggerModem.h index 5f7fea1fb..7400a663e 100644 --- a/src/LoggerModem.h +++ b/src/LoggerModem.h @@ -371,7 +371,7 @@ class loggerModem { * * @return The modem name */ - String getModemName(void); + String getModemName(); /** * @brief Get a detailed printable description of the modem. @@ -383,7 +383,7 @@ class loggerModem { * * @todo Implement this for modems other than the XBee WiFi */ - String getModemDevId(void); + String getModemDevId(); /** * @brief Set the timezone that the modem will attempt to sync itself to. * @@ -408,7 +408,7 @@ class loggerModem { * * @return True if setup was successful */ - virtual bool modemSetup(void); + virtual bool modemSetup(); /** * @brief Retained for backwards compatibility; use modemSetup() in new * code. @@ -417,7 +417,7 @@ class loggerModem { * * @return True if setup was successful */ - bool setup(void) { + bool setup() { return modemSetup(); } @@ -440,7 +440,7 @@ class loggerModem { * * @return True if the modem is responsive and ready for action. */ - virtual bool modemWake(void) = 0; + virtual bool modemWake() = 0; /** * @brief Retained for backwards compatibility; use modemWake() in new code. * @@ -449,14 +449,14 @@ class loggerModem { * @return True if wake was successful, modem should be ready to * communicate */ - bool wake(void) { + bool wake() { return modemWake(); } /** * @brief Power the modem by setting the modem power pin high. */ - virtual void modemPowerUp(void); + virtual void modemPowerUp(); /** * @brief Cut power to the modem by setting the modem power pin low. * @@ -464,14 +464,14 @@ class loggerModem { * allows for graceful shut down. You should use modemSleepPowerDown() * whenever possible. */ - virtual void modemPowerDown(void); + virtual void modemPowerDown(); /** * @brief Request that the modem enter its lowest possible power state. * * @return True if the modem has successfully entered low power * state */ - virtual bool modemSleep(void); + virtual bool modemSleep(); /** * @brief Request that the modem enter its lowest possible power state and * then set the power pin low after the modem has indicated it has @@ -483,7 +483,7 @@ class loggerModem { * @return True if the modem has successfully entered low power * state _and_ then powered off */ - virtual bool modemSleepPowerDown(void); + virtual bool modemSleepPowerDown(); /**@}*/ /** @@ -497,7 +497,7 @@ class loggerModem { * reset failed to fix the communication issue or because a reset is not * possible with the current pin/modem configuration. */ - virtual bool modemHardReset(void); + virtual bool modemHardReset(); /** @@ -567,7 +567,7 @@ class loggerModem { * @brief Detach from EPS or GPRS data connection and then deregister from * the cellular network. */ - virtual void disconnectInternet(void) = 0; + virtual void disconnectInternet() = 0; /** * @brief Create a new client object using the default socket number @@ -650,7 +650,7 @@ class loggerModem { * * @return The number of seconds since Jan 1, 1970 IN UTC */ - virtual uint32_t getNISTTime(void) = 0; + virtual uint32_t getNISTTime() = 0; /**@}*/ @@ -702,7 +702,7 @@ class loggerModem { * * @return The temperature in degrees Celsius */ - virtual float getModemChipTemperature(void) = 0; + virtual float getModemChipTemperature() = 0; /** @@ -756,7 +756,7 @@ class loggerModem { * was successful and the values of the internal static variables should * be valid. */ - virtual bool updateModemMetadata(void); + virtual bool updateModemMetadata(); /**@}*/ /** @@ -867,16 +867,16 @@ class loggerModem { /** * @brief Turn on the modem LED/alert pin - sets it `HIGH` */ - void modemLEDOn(void); + void modemLEDOn(); /** * @brief Turn off the modem LED/alert pin - sets it `LOW` */ - void modemLEDOff(void); + void modemLEDOff(); /** * @brief Set the processor pin modes (input vs output, with and without * pull-up) for all pins connected between the modem module and the mcu. */ - virtual void setModemPinModes(void); + virtual void setModemPinModes(); /**@}*/ /** @@ -890,7 +890,7 @@ class loggerModem { * @return True if there is an active data connection to the * internet. */ - virtual bool isInternetAvailable(void) = 0; + virtual bool isInternetAvailable() = 0; /** * @brief Perform the parts of the modem sleep process that are unique to a * specific module, as opposed to the parts of setup that are common to all @@ -899,7 +899,7 @@ class loggerModem { * @return True if the unique part of the sleep function ran * successfully. */ - virtual bool modemSleepFxn(void) = 0; + virtual bool modemSleepFxn() = 0; /** * @brief Perform the parts of the modem wake up process that are unique to * a specific module, as opposed to the parts of setup that are common to @@ -908,7 +908,7 @@ class loggerModem { * @return True if the unique part of the wake function ran * successfully - does _NOT_ indicate that the modem is now responsive. */ - virtual bool modemWakeFxn(void) = 0; + virtual bool modemWakeFxn() = 0; /** * @brief Perform the parts of the modem set up process that are unique to a * specific module, as opposed to the parts of setup that are common to all @@ -919,7 +919,7 @@ class loggerModem { * * @return True if the extra setup succeeded. */ - virtual bool extraModemSetup(void) = 0; + virtual bool extraModemSetup() = 0; /** * @brief Check if the modem was awake using all possible means. * @@ -941,7 +941,7 @@ class loggerModem { * * @return True if the modem is already awake. */ - virtual bool isModemAwake(void) = 0; + virtual bool isModemAwake() = 0; /**@}*/ /** @@ -1225,7 +1225,7 @@ class loggerModem { uint8_t _pollModemMetaData = 0; }; -// typedef float (loggerModem::_*loggerGetValueFxn)(void); +// typedef float (loggerModem::_*loggerGetValueFxn)(); // Classes for the modem variables diff --git a/src/SensorBase.cpp b/src/SensorBase.cpp index 51ac025ca..4ac7d5f9b 100644 --- a/src/SensorBase.cpp +++ b/src/SensorBase.cpp @@ -40,7 +40,7 @@ Sensor::Sensor(const char* sensorName, const uint8_t totalReturnedValues, // This gets the place the sensor is installed ON THE MAYFLY (ie, pin number) -String Sensor::getSensorLocation(void) { +String Sensor::getSensorLocation() { String senseLoc = F("Pin"); senseLoc += String(_dataPin); return senseLoc; @@ -48,19 +48,19 @@ String Sensor::getSensorLocation(void) { // This returns the name of the sensor. -String Sensor::getSensorName(void) { +String Sensor::getSensorName() { return _sensorName; } // This concatenates and returns the name and location. -String Sensor::getSensorNameAndLocation(void) { +String Sensor::getSensorNameAndLocation() { return getSensorName() + " at " + getSensorLocation(); } // This returns the number of the power pin -int8_t Sensor::getPowerPin(void) { +int8_t Sensor::getPowerPin() { return _powerPin; } // This sets the power pin @@ -68,7 +68,7 @@ void Sensor::setPowerPin(int8_t pin) { _powerPin = pin; } // This returns the number of the secondary power pin -int8_t Sensor::getSecondaryPowerPin(void) { +int8_t Sensor::getSecondaryPowerPin() { return _powerPin2; } // This sets the secondary power pin @@ -82,19 +82,19 @@ void Sensor::setSecondaryPowerPin(int8_t pin) { void Sensor::setNumberMeasurementsToAverage(uint8_t nReadings) { _measurementsToAverage = nReadings; } -uint8_t Sensor::getNumberMeasurementsToAverage(void) { +uint8_t Sensor::getNumberMeasurementsToAverage() { return _measurementsToAverage; } -uint8_t Sensor::getNumberCompleteMeasurementsAttempts(void) { +uint8_t Sensor::getNumberCompleteMeasurementsAttempts() { return _measurementAttemptsCompleted; } -uint8_t Sensor::getNumberRetryAttemptsMade(void) { +uint8_t Sensor::getNumberRetryAttemptsMade() { return _retryAttemptsMade; } void Sensor::setAllowedMeasurementRetries(uint8_t allowedMeasurementRetries) { _allowedMeasurementRetries = allowedMeasurementRetries; } -uint8_t Sensor::getAllowedMeasurementRetries(void) { +uint8_t Sensor::getAllowedMeasurementRetries() { return _allowedMeasurementRetries; } @@ -102,19 +102,19 @@ uint8_t Sensor::getAllowedMeasurementRetries(void) { void Sensor::setWarmUpTime(uint32_t warmUpTime_ms) { _warmUpTime_ms = warmUpTime_ms; } -uint32_t Sensor::getWarmUpTime(void) { +uint32_t Sensor::getWarmUpTime() { return _warmUpTime_ms; } void Sensor::setStabilizationTime(uint32_t stabilizationTime_ms) { _stabilizationTime_ms = stabilizationTime_ms; } -uint32_t Sensor::getStabilizationTime(void) { +uint32_t Sensor::getStabilizationTime() { return _stabilizationTime_ms; } void Sensor::setMeasurementTime(uint32_t measurementTime_ms) { _measurementTime_ms = measurementTime_ms; } -uint32_t Sensor::getMeasurementTime(void) { +uint32_t Sensor::getMeasurementTime() { return _measurementTime_ms; } @@ -127,7 +127,7 @@ uint32_t Sensor::getMeasurementTime(void) { // bit 5 - 0=Measurement start attempted, 1=No measurements have been requested // bit 6 - 0=Measurement start failed, 1=Measurement attempt succeeded // Bit 7 - 0=No known errors, 1=Some sort of error has occurred -uint8_t Sensor::getStatus(void) { +uint8_t Sensor::getStatus() { return _sensorStatus; } @@ -143,7 +143,7 @@ void Sensor::clearStatusBit(sensor_status_bits bitToClear) { // This turns on sensor power -void Sensor::powerUp(void) { +void Sensor::powerUp() { if (_powerPin >= 0 || _powerPin2 >= 0) { // Reset power pin mode every power up because pins are set to tri-state // on sleep on SAMD boards @@ -173,7 +173,7 @@ void Sensor::powerUp(void) { // This turns off sensor power -void Sensor::powerDown(void) { +void Sensor::powerDown() { if (_powerPin >= 0 || _powerPin2 >= 0) { // Reset power pin mode every power up because pins are set to tri-state // on sleep on SAMD boards @@ -211,7 +211,7 @@ void Sensor::powerDown(void) { // The function to set up connection to a sensor. // By default, sets pin modes and returns true -bool Sensor::setup(void) { +bool Sensor::setup() { MS_DBG(F("Setting up"), getSensorName(), F("attached at"), getSensorLocation(), F("which can return up to"), _numReturnedValues, F("variable[s]"), _incCalcValues, @@ -239,7 +239,7 @@ bool Sensor::setup(void) { // The function to wake up a sensor -bool Sensor::wake(void) { +bool Sensor::wake() { MS_DBG(F("Waking"), getSensorNameAndLocation(), F("by doing nothing!")); // Set the status bit for sensor activation attempt (bit 3) // Setting this bit even if the activation failed, to show the attempt was @@ -276,7 +276,7 @@ bool Sensor::wake(void) { // The function to put a sensor to sleep // Does NOT power down the sensor! -bool Sensor::sleep(void) { +bool Sensor::sleep() { // If nothing needs to be done to make the sensor go to sleep, we'll leave // the bits and time stamps set because running the sleep function doesn't // do anything. If the sensor has a power pin and it is powered down, then @@ -287,7 +287,7 @@ bool Sensor::sleep(void) { // This is a place holder for starting a single measurement, for those sensors // that need no instructions to start a measurement. -bool Sensor::startSingleMeasurement(void) { +bool Sensor::startSingleMeasurement() { bool success = true; // check if the sensor was successfully set up, run set up if not @@ -340,7 +340,7 @@ void Sensor::registerVariable(int sensorVarNum, Variable* var) { variables[sensorVarNum] = var; } -void Sensor::notifyVariables(void) { +void Sensor::notifyVariables() { MS_DBG(F("Notifying variables registered to"), getSensorNameAndLocation(), F("of value update.")); @@ -362,7 +362,7 @@ void Sensor::notifyVariables(void) { // This function empties the value array and resets the measurement counts. -void Sensor::clearValues(void) { +void Sensor::clearValues() { MS_DBG(F("Clearing value array for"), getSensorNameAndLocation()); for (uint8_t i = 0; i < _numReturnedValues; i++) { sensorValues[i] = MS_INVALID_VALUE; @@ -373,7 +373,7 @@ void Sensor::clearValues(void) { _retryAttemptsMade = 0; } // This clears power-related status bits and resets power timing. -void Sensor::clearPowerStatus(void) { +void Sensor::clearPowerStatus() { // Reset power timing value _millisPowerOn = 0; // Unset power status bits @@ -381,7 +381,7 @@ void Sensor::clearPowerStatus(void) { } // This clears wake-related status bits and resets wake timing. -void Sensor::clearWakeStatus(void) { +void Sensor::clearWakeStatus() { // Reset wake timing value _millisSensorActivated = 0; // Unset wake status bits @@ -389,7 +389,7 @@ void Sensor::clearWakeStatus(void) { } // This clears measurement-related status bits and resets measurement timing. -void Sensor::clearMeasurementStatus(void) { +void Sensor::clearMeasurementStatus() { // Reset measurement timing values _millisMeasurementRequested = 0; _millisMeasurementCompleted = 0; @@ -399,7 +399,7 @@ void Sensor::clearMeasurementStatus(void) { // This clears all status bits except the setup and error bit and sets the // timing values to 0. -void Sensor::clearStatus(void) { +void Sensor::clearStatus() { // Use the individual clear functions for better maintainability clearPowerStatus(); clearWakeStatus(); @@ -458,7 +458,7 @@ void Sensor::verifyAndAddMeasurementResult(uint8_t resultNumber, } -void Sensor::averageMeasurements(void) { +void Sensor::averageMeasurements() { MS_DBG(F("Averaging results from"), getSensorNameAndLocation(), F("over"), _measurementsToAverage, F("reading[s]")); for (uint8_t i = 0; i < _numReturnedValues; i++) { @@ -471,7 +471,7 @@ void Sensor::averageMeasurements(void) { // This updates a sensor value by checking it's power, waking it, taking as many // readings as requested, then putting the sensor to sleep and powering down. -bool Sensor::update(void) { +bool Sensor::update() { bool ret_val = true; // Check if the sensor power is on, turn it on if not @@ -642,7 +642,7 @@ bool Sensor::isWarmedUp(bool debug) { // is - to be ready to communicate and to be asked to take readings // NOTE: This is "blocking" - that is, nothing else can happen during this // wait. -void Sensor::waitForWarmUp(void) { +void Sensor::waitForWarmUp() { while (!isWarmedUp()) { // wait } @@ -690,7 +690,7 @@ bool Sensor::isStable(bool debug) { // taking readings // NOTE: This is "blocking" - that is, nothing else can happen during this // wait. -void Sensor::waitForStability(void) { +void Sensor::waitForStability() { while (!isStable()) { // wait } @@ -729,7 +729,7 @@ bool Sensor::isMeasurementComplete(bool debug) { // This delays until enough time has passed for the sensor to give a new value // NOTE: This is "blocking" - that is, nothing else can happen during this // wait. -void Sensor::waitForMeasurementCompletion(void) { +void Sensor::waitForMeasurementCompletion() { while (!isMeasurementComplete()) { // wait } diff --git a/src/SensorBase.h b/src/SensorBase.h index d613c0dd4..1b5ce9928 100644 --- a/src/SensorBase.h +++ b/src/SensorBase.h @@ -130,26 +130,26 @@ class Sensor { * * @return Text describing how the sensor is attached to the mcu. */ - virtual String getSensorLocation(void); + virtual String getSensorLocation(); /** * @brief Get the name of the sensor. * * @return The sensor name as given in the constructor. */ - virtual String getSensorName(void); + virtual String getSensorName(); /** * @brief Concatenate and returns the name and location of the sensor. * * @return A concatenation of the sensor name and its "location" * - how it is connected to the mcu. */ - String getSensorNameAndLocation(void); + String getSensorNameAndLocation(); /** * @brief Get the pin number controlling sensor power. * * @return The pin on the mcu controlling power to the sensor. */ - virtual int8_t getPowerPin(void); + virtual int8_t getPowerPin(); /** * @brief Set the pin number controlling sensor power. * @param pin The pin on the mcu controlling power to the sensor. @@ -164,7 +164,7 @@ class Sensor { * to an adapter or converter needed to talk to the sensor - ie, an RS232 * adapter, an RS485 adapter, or an IO multiplexer. */ - virtual int8_t getSecondaryPowerPin(void); + virtual int8_t getSecondaryPowerPin(); /** * @brief Set the pin number controlling secondary sensor power. * @@ -193,14 +193,14 @@ class Sensor { * * @copydetails _measurementsToAverage */ - uint8_t getNumberMeasurementsToAverage(void); + uint8_t getNumberMeasurementsToAverage(); /** * @brief Get the number of measurement attempts that have been made and * completed (whether successful or not). * * @return The number of complete measurement attempts. */ - uint8_t getNumberCompleteMeasurementsAttempts(void); + uint8_t getNumberCompleteMeasurementsAttempts(); /** * @brief Get the number of retry attempts that have been made for a * measurement @@ -212,13 +212,13 @@ class Sensor { * sensor. For some it may be that if any values were returned, for others * that a specific value is in range, etc. */ - uint8_t getNumberRetryAttemptsMade(void); + uint8_t getNumberRetryAttemptsMade(); /** * @brief Get the number of allowed retries if a measurement fails. * * @return The number of allowed retries. */ - uint8_t getAllowedMeasurementRetries(void); + uint8_t getAllowedMeasurementRetries(); /** * @brief Set the number of retries if a measurement fails. * @@ -240,7 +240,7 @@ class Sensor { * @brief Get the warm-up time for the sensor. * @return The warm-up time in milliseconds. */ - uint32_t getWarmUpTime(void); + uint32_t getWarmUpTime(); /** * @brief Set the stabilization time for the sensor. * @param stabilizationTime_ms The stabilization time in milliseconds. @@ -253,7 +253,7 @@ class Sensor { * @brief Get the stabilization time for the sensor. * @return The stabilization time in milliseconds. */ - uint32_t getStabilizationTime(void); + uint32_t getStabilizationTime(); /** * @brief Set the measurement time for the sensor. * @param measurementTime_ms The measurement time in milliseconds. @@ -266,7 +266,7 @@ class Sensor { * @brief Get the measurement time for the sensor. * @return The measurement time in milliseconds. */ - uint32_t getMeasurementTime(void); + uint32_t getMeasurementTime(); /// @brief The significance of the various status bits typedef enum { @@ -329,7 +329,7 @@ class Sensor { * * @return The status as a uint8_t. */ - uint8_t getStatus(void); + uint8_t getStatus(); /** * @brief Get the value of a specific status bit. @@ -394,7 +394,7 @@ class Sensor { * * @return True if the setup was successful. */ - virtual bool setup(void); + virtual bool setup(); /** * @brief Update the sensor's values. @@ -416,7 +416,7 @@ class Sensor { * @return True if all steps of the sensor update completed * successfully. */ - virtual bool update(void); + virtual bool update(); /** * @brief Turn on the sensor power, if applicable. @@ -426,7 +426,7 @@ class Sensor { * * @todo Universally support power pins that are active LOW. */ - virtual void powerUp(void); + virtual void powerUp(); /** * @brief Turn off the sensor power, if applicable. * @@ -436,7 +436,7 @@ class Sensor { * * @todo Universally support power pins that are inactive HIGH. */ - virtual void powerDown(void); + virtual void powerDown(); /** * @brief Wake the sensor up, if necessary. Do whatever it takes to get a @@ -456,7 +456,7 @@ class Sensor { * * @return True if the wake function completed successfully. */ - virtual bool wake(void); + virtual bool wake(); /** * @brief Puts the sensor to sleep, if necessary. * @@ -466,7 +466,7 @@ class Sensor { * * @return True if the sleep function completed successfully. */ - virtual bool sleep(void); + virtual bool sleep(); /** * @brief Tell the sensor to start a single measurement, if needed. @@ -487,7 +487,7 @@ class Sensor { * @return True if the start measurement function completed * successfully. */ - virtual bool startSingleMeasurement(void); + virtual bool startSingleMeasurement(); /** * @brief Get the results from a single measurement. @@ -503,7 +503,7 @@ class Sensor { * * @return True if the function completed successfully. */ - virtual bool addSingleMeasurementResult(void) = 0; + virtual bool addSingleMeasurementResult() = 0; /** * @brief The array of result values for each sensor. @@ -596,7 +596,7 @@ class Sensor { * @brief Average the results of all measurements by dividing the sum of * all measurements by the number of measurements taken. */ - void averageMeasurements(void); + void averageMeasurements(); /** * @brief Register a variable object to a sensor. @@ -611,7 +611,7 @@ class Sensor { /** * @brief Notify attached variables of new values. */ - void notifyVariables(void); + void notifyVariables(); /** @@ -637,7 +637,7 @@ class Sensor { * @brief Hold all further program execution until this sensor is ready to * receive commands. */ - void waitForWarmUp(void); + void waitForWarmUp(); /** * @brief Check whether or not enough time has passed between the sensor @@ -656,7 +656,7 @@ class Sensor { * @brief Hold all further program execution until this sensor is reporting * stable values. */ - void waitForStability(void); + void waitForStability(); /** * @brief Check whether or not enough time has passed between when the @@ -676,7 +676,7 @@ class Sensor { * @brief Hold all further program execution until this sensor is has * finished the current measurement. */ - void waitForMeasurementCompletion(void); + void waitForMeasurementCompletion(); protected: diff --git a/src/VariableArray.cpp b/src/VariableArray.cpp index 789bdadcf..db4c2cfec 100644 --- a/src/VariableArray.cpp +++ b/src/VariableArray.cpp @@ -48,7 +48,7 @@ void VariableArray::begin() { } // This counts and returns the number of calculated variables -uint8_t VariableArray::getCalculatedVariableCount(void) { +uint8_t VariableArray::getCalculatedVariableCount() { uint8_t numCalc = 0; // Check for unique sensors for (uint8_t i = 0; i < _variableCount; i++) { @@ -60,7 +60,7 @@ uint8_t VariableArray::getCalculatedVariableCount(void) { // This counts and returns the number of sensors -uint8_t VariableArray::getSensorCount(void) { +uint8_t VariableArray::getSensorCount() { uint8_t numSensors = 0; // Check for unique sensors for (uint8_t i = 0; i < _variableCount; i++) { @@ -81,7 +81,7 @@ void VariableArray::matchUUIDs(const char* uuids[]) { // NOTE: Calculated variables will always be skipped in this process because // a calculated variable will never be marked as the last variable from a // sensor. -bool VariableArray::setupSensors(void) { +bool VariableArray::setupSensors() { bool success = true; // #ifdef MS_VARIABLEARRAY_DEBUG_DEEP @@ -149,7 +149,7 @@ bool VariableArray::setupSensors(void) { // NOTE: Calculated variables will always be skipped in this process because // a calculated variable will never be marked as the last variable from a // sensor. -void VariableArray::sensorsPowerUp(void) { +void VariableArray::sensorsPowerUp() { MS_DBG(F("Powering up sensors...")); for (uint8_t i = 0; i < _variableCount; i++) { if (isLastVarFromSensor(i)) { // Skip non-unique sensors @@ -167,7 +167,7 @@ void VariableArray::sensorsPowerUp(void) { // NOTE: Calculated variables will always be skipped in this process because // a calculated variable will never be marked as the last variable from a // sensor. -bool VariableArray::sensorsWake(void) { +bool VariableArray::sensorsWake() { MS_DBG(F("Waking sensors...")); bool success = true; uint8_t nSensorsAwake = 0; @@ -234,7 +234,7 @@ bool VariableArray::sensorsWake(void) { // NOTE: Calculated variables will always be skipped in this process because // a calculated variable will never be marked as the last variable from a // sensor. -bool VariableArray::sensorsSleep(void) { +bool VariableArray::sensorsSleep() { MS_DBG(F("Putting sensors to sleep...")); bool success = true; for (uint8_t i = 0; i < _variableCount; i++) { @@ -261,7 +261,7 @@ bool VariableArray::sensorsSleep(void) { // NOTE: Calculated variables will always be skipped in this process because // a calculated variable will never be marked as the last variable from a // sensor. -void VariableArray::sensorsPowerDown(void) { +void VariableArray::sensorsPowerDown() { MS_DBG(F("Powering down sensors...")); for (uint8_t i = 0; i < _variableCount; i++) { if (isLastVarFromSensor(i)) { // Skip non-unique sensors @@ -278,7 +278,7 @@ void VariableArray::sensorsPowerDown(void) { // Please note that this does NOT run the update functions, it instead uses // the startSingleMeasurement and addSingleMeasurementResult functions to // take advantage of the ability of sensors to be measuring concurrently. -bool VariableArray::updateAllSensors(void) { +bool VariableArray::updateAllSensors() { return completeUpdate(false, false, false, false); } @@ -721,7 +721,7 @@ bool VariableArray::getSensorStatusBit(int arrayIndex, // Check that all variable have valid UUIDs, if they are assigned -bool VariableArray::checkVariableUUIDs(void) { +bool VariableArray::checkVariableUUIDs() { bool success = true; for (uint8_t i = 0; i < _variableCount; i++) { if (!arrayOfVars[i]->checkUUIDFormat()) { diff --git a/src/VariableArray.h b/src/VariableArray.h index 6116b48de..b0f4f77c4 100644 --- a/src/VariableArray.h +++ b/src/VariableArray.h @@ -155,7 +155,7 @@ class VariableArray { * * @return The number of variables */ - uint8_t getVariableCount(void) { + uint8_t getVariableCount() { return _variableCount; } @@ -165,7 +165,7 @@ class VariableArray { * @return The number of calculated (ie, not measured by a * sensor) variables */ - uint8_t getCalculatedVariableCount(void); + uint8_t getCalculatedVariableCount(); // This counts and returns the number of sensors /** @@ -177,7 +177,7 @@ class VariableArray { * * @return The number of sensors */ - uint8_t getSensorCount(void); + uint8_t getSensorCount(); /** * @brief Match UUIDs from the given variables in the variable array. @@ -202,14 +202,14 @@ class VariableArray { * @return True indicates all sensors have been set up * successfully. */ - bool setupSensors(void); + bool setupSensors(); /** * @brief Power up each sensor. * * Runs the powerUp sensor function for each unique sensor. */ - void sensorsPowerUp(void); + void sensorsPowerUp(); /** * @brief Wake up each sensor. @@ -219,7 +219,7 @@ class VariableArray { * * @return True if all wake functions were run successfully. */ - bool sensorsWake(void); + bool sensorsWake(); /** * @brief Put all sensors to sleep @@ -228,13 +228,13 @@ class VariableArray { * * @return True if all sleep functions were run successfully. */ - bool sensorsSleep(void); + bool sensorsSleep(); /** * @brief Cut power to all sensors. * Runs the powerDown sensor function for each unique sensor. */ - void sensorsPowerDown(void); + void sensorsPowerDown(); /** * @brief Update the values for all connected sensors. @@ -246,7 +246,7 @@ class VariableArray { * * @return True if all steps of the update succeeded. */ - bool updateAllSensors(void); + bool updateAllSensors(); // This function powers, wakes, updates values, sleeps and powers down. @@ -311,7 +311,7 @@ class VariableArray { * @warning This does not check that the UUIDs are the true UUIDs for the * variables, just that the text is a validly formed UUID. */ - bool checkVariableUUIDs(void); + bool checkVariableUUIDs(); /** * @brief Get a specific status bit from the sensor tied to a variable in diff --git a/src/VariableBase.cpp b/src/VariableBase.cpp index e22ed93c8..cd3e1f76c 100644 --- a/src/VariableBase.cpp +++ b/src/VariableBase.cpp @@ -120,7 +120,7 @@ void Variable::onSensorUpdate(Sensor* parentSense) { // This is a helper - it returns the name of the parent sensor, if applicable // This is needed for dealing with variables in arrays -String Variable::getParentSensorName(void) { +String Variable::getParentSensorName() { if (isCalculated) { return "Calculated"; } else if (parentSensor == nullptr) { @@ -134,7 +134,7 @@ String Variable::getParentSensorName(void) { // This is a helper - it returns the name and location of the parent sensor, if // applicable This is needed for dealing with variables in arrays -String Variable::getParentSensorNameAndLocation(void) { +String Variable::getParentSensorNameAndLocation() { if (isCalculated) { return "Calculated"; } else if (parentSensor == nullptr) { @@ -154,7 +154,7 @@ void Variable::setCalculation(float (*calcFxn)()) { // This gets/sets the variable's resolution for value strings -uint8_t Variable::getResolution(void) { +uint8_t Variable::getResolution() { return _decimalResolution; } void Variable::setResolution(uint8_t decimalResolution) { @@ -163,7 +163,7 @@ void Variable::setResolution(uint8_t decimalResolution) { // This gets/sets the variable's name using // http://vocabulary.odm2.org/variablename/ -String Variable::getVarName(void) { +String Variable::getVarName() { return _varName; } void Variable::setVarName(const char* varName) { @@ -171,7 +171,7 @@ void Variable::setVarName(const char* varName) { } // This gets/sets the variable's unit using http://vocabulary.odm2.org/units/ -String Variable::getVarUnit(void) { +String Variable::getVarUnit() { return _varUnit; } void Variable::setVarUnit(const char* varUnit) { @@ -179,7 +179,7 @@ void Variable::setVarUnit(const char* varUnit) { } // This returns a customized code for the variable -String Variable::getVarCode(void) { +String Variable::getVarCode() { return _varCode; } // This sets the variable code to a new custom value @@ -188,12 +188,12 @@ void Variable::setVarCode(const char* varCode) { } // This returns the variable UUID as a String, if one has been assigned -String Variable::getVarUUIDString(void) { +String Variable::getVarUUIDString() { return String(_uuid); } // This returns the variable UUID as a pointer to a const char array, if one has // been assigned -const char* Variable::getVarUUID(void) { +const char* Variable::getVarUUID() { return _uuid; } // This sets the UUID @@ -201,7 +201,7 @@ void Variable::setVarUUID(const char* uuid) { _uuid = uuid; } // This checks that the UUID is properly formatted -bool Variable::checkUUIDFormat(void) { +bool Variable::checkUUIDFormat() { // If no UUID, move on if (_uuid == nullptr || strlen(_uuid) == 0) { return true; } diff --git a/src/VariableBase.h b/src/VariableBase.h index 8c35d66f3..dbb2a0fe9 100644 --- a/src/VariableBase.h +++ b/src/VariableBase.h @@ -237,7 +237,7 @@ class Variable { const char* varCode); // This sets up the variable (generally attaching it to its parent) - // bool setup(void); + // bool setup(); /** * @brief Notify the parent sensor that it has an observing variable. @@ -265,7 +265,7 @@ class Variable { * * @return The parent sensor name */ - String getParentSensorName(void); + String getParentSensorName(); /** * @brief Get the parent sensor name and location, if applicable. * @@ -273,7 +273,7 @@ class Variable { * * @return The parent sensor's concatenated name and location. */ - String getParentSensorNameAndLocation(void); + String getParentSensorNameAndLocation(); /** * @brief Set the calculation function for a calculated variable @@ -288,7 +288,7 @@ class Variable { * * @return the variable resolution */ - uint8_t getResolution(void); + uint8_t getResolution(); /** * @brief Set the variable's resolution * @@ -300,7 +300,7 @@ class Variable { * * @return The variable name */ - String getVarName(void); + String getVarName(); /** * @brief Set the variable name. * @@ -316,7 +316,7 @@ class Variable { * * @return The variable unit */ - String getVarUnit(void); + String getVarUnit(); /** * @brief Set the variable unit. * @@ -332,7 +332,7 @@ class Variable { * * @return The customized code for the variable */ - String getVarCode(void); + String getVarCode(); /** * @brief Set a customized code for the variable * @@ -346,14 +346,14 @@ class Variable { * * @return The variable's UUID as a String */ - String getVarUUIDString(void); + String getVarUUIDString(); // This gets/sets the variable UUID, if one has been assigned /** * @brief Get the variable's UUID as a C-style string * * @return The variable's UUID as a const char* (or nullptr if not assigned) */ - const char* getVarUUID(void); + const char* getVarUUID(); /** * @brief Set a customized code for the variable * @@ -368,7 +368,7 @@ class Variable { * @note This only checks the _format_ of the UUID. It does not in any way * indicate that the value of the UUID is correct. */ - bool checkUUIDFormat(void); + bool checkUUIDFormat(); /** * @brief Get current value of the variable as a float @@ -452,7 +452,7 @@ class Variable { * @brief Private reference to function used to calculate the variables * value. */ - float (*_calcFxn)(void) = nullptr; + float (*_calcFxn)() = nullptr; /** diff --git a/src/WatchDogs/WatchDogSAMD.cpp b/src/WatchDogs/WatchDogSAMD.cpp index 01a02778c..4be9f2f71 100644 --- a/src/WatchDogs/WatchDogSAMD.cpp +++ b/src/WatchDogs/WatchDogSAMD.cpp @@ -394,7 +394,7 @@ void extendedWatchDogSAMD::waitForGCLKBitSync() { // ISR for watchdog early warning -void WDT_Handler(void) { +void WDT_Handler() { extendedWatchDogSAMD::clearWDTInterrupt(); MS_DEEP_DBG(F("\nWatchdog early warning interrupt!")); #if defined(MS_WATCHDOGSAMD_DEBUG_DEEP) diff --git a/src/WatchDogs/WatchDogSAMD.h b/src/WatchDogs/WatchDogSAMD.h index d43e030a0..23afc0651 100644 --- a/src/WatchDogs/WatchDogSAMD.h +++ b/src/WatchDogs/WatchDogSAMD.h @@ -71,7 +71,7 @@ /** * @brief ISR handler for watchdog timer early warning (WDT EW) interrupt */ -void WDT_Handler(void); +void WDT_Handler(); /** * @brief The extendedWatchDogSAMD class uses the early warning interrupt to of diff --git a/src/dataPublisherBase.cpp b/src/dataPublisherBase.cpp index 4518e7947..dec5f3515 100644 --- a/src/dataPublisherBase.cpp +++ b/src/dataPublisherBase.cpp @@ -176,7 +176,7 @@ void dataPublisher::txBufferFlush(bool debug_flush) { } } -bool dataPublisher::connectionNeeded(void) { +bool dataPublisher::connectionNeeded() { // connection is always needed unless publisher has special logic return true; } diff --git a/src/dataPublisherBase.h b/src/dataPublisherBase.h index a8864f1dd..bd2b3c53e 100644 --- a/src/dataPublisherBase.h +++ b/src/dataPublisherBase.h @@ -176,7 +176,7 @@ class dataPublisher { * * @return The URL or HOST to receive published data */ - virtual String getEndpoint(void) = 0; + virtual String getEndpoint() = 0; /** @@ -185,7 +185,7 @@ class dataPublisher { * * @return True if an internet connection is needed for the next publish. */ - virtual bool connectionNeeded(void); + virtual bool connectionNeeded(); /** * @brief Opens a socket to the correct receiver and sends out the formatted diff --git a/src/modems/DigiXBee.cpp b/src/modems/DigiXBee.cpp index 725cae890..0a64fb3db 100644 --- a/src/modems/DigiXBee.cpp +++ b/src/modems/DigiXBee.cpp @@ -27,7 +27,7 @@ DigiXBee::DigiXBee(int8_t powerPin, int8_t statusPin, bool useCTSStatus, // After enabling pin sleep, the sleep request pin is held `LOW` to keep the // XBee on. Enable pin sleep in the setup function or using XCTU prior to // connecting the XBee -bool DigiXBee::modemWakeFxn(void) { +bool DigiXBee::modemWakeFxn() { if (_modemSleepRqPin >= 0) { // Don't go to sleep if there's not a wake pin! MS_DBG(F("Setting pin"), _modemSleepRqPin, @@ -40,7 +40,7 @@ bool DigiXBee::modemWakeFxn(void) { } -bool DigiXBee::modemSleepFxn(void) { +bool DigiXBee::modemSleepFxn() { if (_modemSleepRqPin >= 0) { MS_DBG(F("Setting pin"), _modemSleepRqPin, !_wakeLevel ? F("HIGH") : F("LOW"), F("to put"), _modemName, diff --git a/src/modems/DigiXBee.h b/src/modems/DigiXBee.h index b3efb794f..fa14e1f0f 100644 --- a/src/modems/DigiXBee.h +++ b/src/modems/DigiXBee.h @@ -224,8 +224,8 @@ class DigiXBee : public loggerModem { virtual ~DigiXBee() override = default; protected: - bool modemSleepFxn(void) override; - bool modemWakeFxn(void) override; + bool modemSleepFxn() override; + bool modemWakeFxn() override; }; /**@}*/ #endif // SRC_MODEMS_DIGIXBEE_H_ diff --git a/src/modems/DigiXBee3GBypass.cpp b/src/modems/DigiXBee3GBypass.cpp index cfd0df3f5..f40a3eb06 100644 --- a/src/modems/DigiXBee3GBypass.cpp +++ b/src/modems/DigiXBee3GBypass.cpp @@ -48,7 +48,7 @@ MS_MODEM_GET_MODEM_BATTERY_DATA(DigiXBee3GBypass); // mode MS_MODEM_GET_MODEM_TEMPERATURE_DATA(DigiXBee3GBypass); -bool DigiXBee3GBypass::extraModemSetup(void) { +bool DigiXBee3GBypass::extraModemSetup() { bool success = false; MS_DBG(F("Putting XBee into command mode...")); for (uint8_t i = 0; i < 5; i++) { @@ -145,7 +145,7 @@ bool DigiXBee3GBypass::extraModemSetup(void) { return success; } -bool DigiXBee3GBypass::modemHardReset(void) { +bool DigiXBee3GBypass::modemHardReset() { bool success = false; // If the u-blox cellular component isn't responding but the Digi processor // is, use the Digi API to reset the cellular component diff --git a/src/modems/DigiXBee3GBypass.h b/src/modems/DigiXBee3GBypass.h index 4ebc2a8b6..0852bc583 100644 --- a/src/modems/DigiXBee3GBypass.h +++ b/src/modems/DigiXBee3GBypass.h @@ -127,10 +127,10 @@ class DigiXBee3GBypass : public DigiXBee { */ ~DigiXBee3GBypass() override = default; - bool modemWake(void) override; + bool modemWake() override; bool connectInternet(uint32_t maxConnectionTime = 50000L) override; - void disconnectInternet(void) override; + void disconnectInternet() override; virtual Client* createClient() override; virtual void deleteClient(Client* client); @@ -147,14 +147,14 @@ class DigiXBee3GBypass : public DigiXBee { createSecureClient(const char* pskTableName, SSLVersion sslVersion = SSLVersion::TLS1_2) override; - uint32_t getNISTTime(void) override; + uint32_t getNISTTime() override; bool getModemSignalQuality(int16_t& rssi, int16_t& percent) override; bool getModemBatteryStats(int8_t& chargeState, int8_t& percent, int16_t& milliVolts) override; - float getModemChipTemperature(void) override; + float getModemChipTemperature() override; - bool modemHardReset(void) override; + bool modemHardReset() override; #ifdef MS_DIGIXBEE3GBYPASS_DEBUG_DEEP StreamDebugger _modemATDebugger; @@ -166,7 +166,7 @@ class DigiXBee3GBypass : public DigiXBee { TinyGsmUBLOX gsmModem; protected: - bool isInternetAvailable(void) override; + bool isInternetAvailable() override; /** * @copybrief loggerModem::extraModemSetup() * @@ -176,8 +176,8 @@ class DigiXBee3GBypass : public DigiXBee { * * @return True if the extra setup succeeded. */ - bool extraModemSetup(void) override; - bool isModemAwake(void) override; + bool extraModemSetup() override; + bool isModemAwake() override; private: const char* _apn; ///< Internal reference to the cellular APN diff --git a/src/modems/DigiXBeeCellularTransparent.cpp b/src/modems/DigiXBeeCellularTransparent.cpp index 2899702be..7c3c270c9 100644 --- a/src/modems/DigiXBeeCellularTransparent.cpp +++ b/src/modems/DigiXBeeCellularTransparent.cpp @@ -48,7 +48,7 @@ MS_MODEM_GET_MODEM_BATTERY_DATA(DigiXBeeCellularTransparent); MS_MODEM_GET_MODEM_TEMPERATURE_DATA(DigiXBeeCellularTransparent); // We turn off airplane mode in the wake. -bool DigiXBeeCellularTransparent::modemWakeFxn(void) { +bool DigiXBeeCellularTransparent::modemWakeFxn() { if (_modemSleepRqPin >= 0) { // Don't go to sleep if there's not a wake pin! MS_DBG(F("Setting pin"), _modemSleepRqPin, @@ -71,7 +71,7 @@ bool DigiXBeeCellularTransparent::modemWakeFxn(void) { // We turn on airplane mode in before sleep -bool DigiXBeeCellularTransparent::modemSleepFxn(void) { +bool DigiXBeeCellularTransparent::modemSleepFxn() { if (_modemSleepRqPin >= 0) { MS_DBG(F("Turning on airplane mode...")); if (gsmModem.commandMode()) { @@ -95,7 +95,7 @@ bool DigiXBeeCellularTransparent::modemSleepFxn(void) { } -bool DigiXBeeCellularTransparent::extraModemSetup(void) { +bool DigiXBeeCellularTransparent::extraModemSetup() { bool success = true; /** First run the TinyGSM init() function for the XBee. */ MS_DBG(F("Initializing the XBee...")); @@ -192,7 +192,7 @@ bool DigiXBeeCellularTransparent::extraModemSetup(void) { return success; } -uint32_t DigiXBeeCellularTransparent::getNISTTime(void) { +uint32_t DigiXBeeCellularTransparent::getNISTTime() { /* bail if not connected to the internet */ if (!isInternetAvailable()) { MS_DBG(F("No internet connection, cannot connect to NIST.")); @@ -255,7 +255,7 @@ uint32_t DigiXBeeCellularTransparent::getNISTTime(void) { } -bool DigiXBeeCellularTransparent::updateModemMetadata(void) { +bool DigiXBeeCellularTransparent::updateModemMetadata() { bool success = true; // Unset whatever we had previously diff --git a/src/modems/DigiXBeeCellularTransparent.h b/src/modems/DigiXBeeCellularTransparent.h index 782839944..d549b576d 100644 --- a/src/modems/DigiXBeeCellularTransparent.h +++ b/src/modems/DigiXBeeCellularTransparent.h @@ -161,10 +161,10 @@ class DigiXBeeCellularTransparent : public DigiXBee { */ ~DigiXBeeCellularTransparent() override = default; - bool modemWake(void) override; + bool modemWake() override; bool connectInternet(uint32_t maxConnectionTime = 50000L) override; - void disconnectInternet(void) override; + void disconnectInternet() override; virtual Client* createClient() override; virtual void deleteClient(Client* client); @@ -181,14 +181,14 @@ class DigiXBeeCellularTransparent : public DigiXBee { createSecureClient(const char* pskTableName, SSLVersion sslVersion = SSLVersion::TLS1_2) override; - uint32_t getNISTTime(void) override; + uint32_t getNISTTime() override; bool getModemSignalQuality(int16_t& rssi, int16_t& percent) override; bool getModemBatteryStats(int8_t& chargeState, int8_t& percent, int16_t& milliVolts) override; - float getModemChipTemperature(void) override; + float getModemChipTemperature() override; - bool updateModemMetadata(void) override; + bool updateModemMetadata() override; #ifdef MS_DIGIXBEECELLULARTRANSPARENT_DEBUG_DEEP StreamDebugger _modemATDebugger; @@ -200,9 +200,9 @@ class DigiXBeeCellularTransparent : public DigiXBee { TinyGsmXBee gsmModem; protected: - bool isInternetAvailable(void) override; - bool modemWakeFxn(void) override; - bool modemSleepFxn(void) override; + bool isInternetAvailable() override; + bool modemWakeFxn() override; + bool modemSleepFxn() override; /** * @copybrief loggerModem::extraModemSetup() * @@ -212,8 +212,8 @@ class DigiXBeeCellularTransparent : public DigiXBee { * * @return True if the extra setup succeeded. */ - bool extraModemSetup(void) override; - bool isModemAwake(void) override; + bool extraModemSetup() override; + bool isModemAwake() override; private: const char* _apn; ///< Internal reference to the cellular APN diff --git a/src/modems/DigiXBeeLTEBypass.cpp b/src/modems/DigiXBeeLTEBypass.cpp index f2512b373..20644ddef 100644 --- a/src/modems/DigiXBeeLTEBypass.cpp +++ b/src/modems/DigiXBeeLTEBypass.cpp @@ -46,7 +46,7 @@ MS_MODEM_GET_MODEM_SIGNAL_QUALITY(DigiXBeeLTEBypass); MS_MODEM_GET_MODEM_BATTERY_DATA(DigiXBeeLTEBypass); MS_MODEM_GET_MODEM_TEMPERATURE_DATA(DigiXBeeLTEBypass); -bool DigiXBeeLTEBypass::extraModemSetup(void) { +bool DigiXBeeLTEBypass::extraModemSetup() { bool success = false; MS_DBG(F("Putting XBee into command mode...")); for (uint8_t i = 0; i < 5; i++) { @@ -147,7 +147,7 @@ bool DigiXBeeLTEBypass::extraModemSetup(void) { return success; } -bool DigiXBeeLTEBypass::modemHardReset(void) { +bool DigiXBeeLTEBypass::modemHardReset() { bool success = false; // If the u-blox cellular component isn't responding but the Digi processor // is, use the Digi API to reset the cellular component diff --git a/src/modems/DigiXBeeLTEBypass.h b/src/modems/DigiXBeeLTEBypass.h index d9b5c095b..eb4346925 100644 --- a/src/modems/DigiXBeeLTEBypass.h +++ b/src/modems/DigiXBeeLTEBypass.h @@ -142,10 +142,10 @@ class DigiXBeeLTEBypass : public DigiXBee { */ ~DigiXBeeLTEBypass() override = default; - bool modemWake(void) override; + bool modemWake() override; bool connectInternet(uint32_t maxConnectionTime = 50000L) override; - void disconnectInternet(void) override; + void disconnectInternet() override; virtual Client* createClient() override; virtual void deleteClient(Client* client); @@ -162,14 +162,14 @@ class DigiXBeeLTEBypass : public DigiXBee { createSecureClient(const char* pskTableName, SSLVersion sslVersion = SSLVersion::TLS1_2) override; - uint32_t getNISTTime(void) override; + uint32_t getNISTTime() override; bool getModemSignalQuality(int16_t& rssi, int16_t& percent) override; bool getModemBatteryStats(int8_t& chargeState, int8_t& percent, int16_t& milliVolts) override; - float getModemChipTemperature(void) override; + float getModemChipTemperature() override; - bool modemHardReset(void) override; + bool modemHardReset() override; #ifdef MS_DIGIXBEELTEBYPASS_DEBUG_DEEP StreamDebugger _modemATDebugger; @@ -181,7 +181,7 @@ class DigiXBeeLTEBypass : public DigiXBee { TinyGsmSaraR4 gsmModem; protected: - bool isInternetAvailable(void) override; + bool isInternetAvailable() override; /** * @copybrief loggerModem::extraModemSetup() * @@ -191,8 +191,8 @@ class DigiXBeeLTEBypass : public DigiXBee { * * @return True if the extra setup succeeded. */ - bool extraModemSetup(void) override; - bool isModemAwake(void) override; + bool extraModemSetup() override; + bool isModemAwake() override; private: const char* _apn; ///< Internal reference to the cellular APN diff --git a/src/modems/DigiXBeeWifi.cpp b/src/modems/DigiXBeeWifi.cpp index 6a488298f..58fa5e9a2 100644 --- a/src/modems/DigiXBeeWifi.cpp +++ b/src/modems/DigiXBeeWifi.cpp @@ -93,7 +93,7 @@ MS_MODEM_GET_MODEM_SIGNAL_QUALITY(DigiXBeeWifi); MS_MODEM_GET_MODEM_BATTERY_DATA(DigiXBeeWifi); MS_MODEM_GET_MODEM_TEMPERATURE_DATA(DigiXBeeWifi); -bool DigiXBeeWifi::extraModemSetup(void) { +bool DigiXBeeWifi::extraModemSetup() { bool success = true; /** First run the TinyGSM init() function for the XBee. */ MS_DBG(F("Initializing the XBee...")); @@ -346,7 +346,7 @@ bool DigiXBeeWifi::extraModemSetup(void) { } -void DigiXBeeWifi::disconnectInternet(void) { +void DigiXBeeWifi::disconnectInternet() { // Ensure Wifi XBee IP socket torn down by forcing connection to // localhost IP For A XBee S6B bug, then force restart. TinyGsmXBee::GsmClientXBee gsmClient( @@ -362,7 +362,7 @@ void DigiXBeeWifi::disconnectInternet(void) { // Get the time from NIST via TIME protocol (rfc868) -uint32_t DigiXBeeWifi::getNISTTime(void) { +uint32_t DigiXBeeWifi::getNISTTime() { // bail if not connected to the internet if (!isInternetAvailable()) { MS_DBG(F("No internet connection, cannot connect to NIST.")); @@ -435,7 +435,7 @@ uint32_t DigiXBeeWifi::getNISTTime(void) { } -bool DigiXBeeWifi::updateModemMetadata(void) { +bool DigiXBeeWifi::updateModemMetadata() { bool success = true; // Unset whatever we had previously diff --git a/src/modems/DigiXBeeWifi.h b/src/modems/DigiXBeeWifi.h index 300470eb6..965ca4f34 100644 --- a/src/modems/DigiXBeeWifi.h +++ b/src/modems/DigiXBeeWifi.h @@ -137,10 +137,10 @@ class DigiXBeeWifi : public DigiXBee { */ ~DigiXBeeWifi() override = default; - bool modemWake(void) override; + bool modemWake() override; bool connectInternet(uint32_t maxConnectionTime = 50000L) override; - void disconnectInternet(void) override; + void disconnectInternet() override; virtual Client* createClient() override; virtual void deleteClient(Client* client); @@ -157,14 +157,14 @@ class DigiXBeeWifi : public DigiXBee { createSecureClient(const char* pskTableName, SSLVersion sslVersion = SSLVersion::TLS1_2) override; - uint32_t getNISTTime(void) override; + uint32_t getNISTTime() override; bool getModemSignalQuality(int16_t& rssi, int16_t& percent) override; bool getModemBatteryStats(int8_t& chargeState, int8_t& percent, int16_t& milliVolts) override; - float getModemChipTemperature(void) override; + float getModemChipTemperature() override; - bool updateModemMetadata(void) override; + bool updateModemMetadata() override; #ifdef MS_DIGIXBEEWIFI_DEBUG_DEEP StreamDebugger _modemATDebugger; @@ -176,7 +176,7 @@ class DigiXBeeWifi : public DigiXBee { TinyGsmXBee gsmModem; protected: - bool isInternetAvailable(void) override; + bool isInternetAvailable() override; /** * @copybrief loggerModem::extraModemSetup() * @@ -186,8 +186,8 @@ class DigiXBeeWifi : public DigiXBee { * * @return True if the extra setup succeeded. */ - bool extraModemSetup(void) override; - bool isModemAwake(void) override; + bool extraModemSetup() override; + bool isModemAwake() override; private: diff --git a/src/modems/Espressif.cpp b/src/modems/Espressif.cpp index b04e8e871..94c079541 100644 --- a/src/modems/Espressif.cpp +++ b/src/modems/Espressif.cpp @@ -25,7 +25,7 @@ Espressif::Espressif(Stream* modemStream, int8_t powerPin, int8_t modemResetPin, // A helper function to wait for the esp to boot and immediately change some // settings We'll use this in the wake function -bool Espressif::ESPwaitForBoot(void) { +bool Espressif::ESPwaitForBoot() { // Wait for boot - finished when characters start coming // NOTE: After every "hard" reset (either power off or via RST-B), the ESP // sends out a boot log from the ROM on UART1 at 74880 baud. We're not @@ -51,7 +51,7 @@ bool Espressif::ESPwaitForBoot(void) { // Create the wake and sleep methods for the modem // These can be functions of any type and must return a boolean -bool Espressif::modemWakeFxn(void) { +bool Espressif::modemWakeFxn() { bool success = true; if (_powerPin >= 0) { // Turns on when power is applied MS_DEEP_DBG( diff --git a/src/modems/Espressif.h b/src/modems/Espressif.h index 8e366850c..05c83bfe6 100644 --- a/src/modems/Espressif.h +++ b/src/modems/Espressif.h @@ -211,7 +211,7 @@ class Espressif : public loggerModem { Stream* _modemStream; protected: - bool modemWakeFxn(void) override; + bool modemWakeFxn() override; protected: /** @@ -222,7 +222,7 @@ class Espressif : public loggerModem { * @return True if text (assumed to be the start message) was received; * false if text was received after boot. */ - bool ESPwaitForBoot(void); + bool ESPwaitForBoot(); const char* _ssid; ///< Internal reference to the WiFi SSID const char* _pwd; ///< Internal reference to the WiFi password }; diff --git a/src/modems/EspressifESP32.cpp b/src/modems/EspressifESP32.cpp index c3cc6c69d..54a807977 100644 --- a/src/modems/EspressifESP32.cpp +++ b/src/modems/EspressifESP32.cpp @@ -44,7 +44,7 @@ MS_MODEM_GET_MODEM_SIGNAL_QUALITY(EspressifESP32); MS_MODEM_GET_MODEM_BATTERY_DATA(EspressifESP32); MS_MODEM_GET_MODEM_TEMPERATURE_DATA(EspressifESP32); -bool EspressifESP32::modemSleepFxn(void) { +bool EspressifESP32::modemSleepFxn() { // Use this if you have an MCU pin connected to the ESP's reset pin to wake // from deep sleep. We'll also put it in deep sleep before yanking power. if (_modemResetPin >= 0 || _powerPin >= 0) { @@ -64,7 +64,7 @@ bool EspressifESP32::modemSleepFxn(void) { } // Set up the light-sleep status pin, if applicable -bool EspressifESP32::extraModemSetup(void) { +bool EspressifESP32::extraModemSetup() { if (_modemSleepRqPin >= 0) { digitalWrite(_modemSleepRqPin, !_wakeLevel); } gsmModem.init(); _modemName = gsmModem.getModemName(); diff --git a/src/modems/EspressifESP32.h b/src/modems/EspressifESP32.h index cda24da93..9b44e656a 100644 --- a/src/modems/EspressifESP32.h +++ b/src/modems/EspressifESP32.h @@ -125,10 +125,10 @@ class EspressifESP32 : public Espressif { */ ~EspressifESP32() override = default; - bool modemWake(void) override; + bool modemWake() override; bool connectInternet(uint32_t maxConnectionTime = 50000L) override; - void disconnectInternet(void) override; + void disconnectInternet() override; virtual Client* createClient() override; virtual void deleteClient(Client* client); @@ -145,12 +145,12 @@ class EspressifESP32 : public Espressif { createSecureClient(const char* pskTableName, SSLVersion sslVersion = SSLVersion::TLS1_2) override; - uint32_t getNISTTime(void) override; + uint32_t getNISTTime() override; bool getModemSignalQuality(int16_t& rssi, int16_t& percent) override; bool getModemBatteryStats(int8_t& chargeState, int8_t& percent, int16_t& milliVolts) override; - float getModemChipTemperature(void) override; + float getModemChipTemperature() override; #ifdef MS_ESPRESSIFESP32_DEBUG_DEEP StreamDebugger _modemATDebugger; @@ -162,10 +162,10 @@ class EspressifESP32 : public Espressif { TinyGsmESP32 gsmModem; protected: - bool isInternetAvailable(void) override; - bool modemSleepFxn(void) override; - bool extraModemSetup(void) override; - bool isModemAwake(void) override; + bool isInternetAvailable() override; + bool modemSleepFxn() override; + bool extraModemSetup() override; + bool isModemAwake() override; }; /**@}*/ #endif // SRC_MODEMS_ESPRESSIFESP32_H_ diff --git a/src/modems/EspressifESP8266.cpp b/src/modems/EspressifESP8266.cpp index b44c99b96..f4bd1c749 100644 --- a/src/modems/EspressifESP8266.cpp +++ b/src/modems/EspressifESP8266.cpp @@ -44,7 +44,7 @@ MS_MODEM_GET_MODEM_SIGNAL_QUALITY(EspressifESP8266); MS_MODEM_GET_MODEM_BATTERY_DATA(EspressifESP8266); MS_MODEM_GET_MODEM_TEMPERATURE_DATA(EspressifESP8266); -bool EspressifESP8266::modemSleepFxn(void) { +bool EspressifESP8266::modemSleepFxn() { // Use this if you have an MCU pin connected to the ESP's reset pin to wake // from deep sleep. We'll also put it in deep sleep before yanking power. if (_modemResetPin >= 0 || _powerPin >= 0) { @@ -64,7 +64,7 @@ bool EspressifESP8266::modemSleepFxn(void) { } // Set up the light-sleep status pin, if applicable -bool EspressifESP8266::extraModemSetup(void) { +bool EspressifESP8266::extraModemSetup() { if (_modemSleepRqPin >= 0) { digitalWrite(_modemSleepRqPin, !_wakeLevel); } gsmModem.init(); _modemName = gsmModem.getModemName(); diff --git a/src/modems/EspressifESP8266.h b/src/modems/EspressifESP8266.h index 4ed6249cb..9b1c3e025 100644 --- a/src/modems/EspressifESP8266.h +++ b/src/modems/EspressifESP8266.h @@ -124,10 +124,10 @@ class EspressifESP8266 : public Espressif { */ ~EspressifESP8266() override = default; - bool modemWake(void) override; + bool modemWake() override; bool connectInternet(uint32_t maxConnectionTime = 50000L) override; - void disconnectInternet(void) override; + void disconnectInternet() override; virtual Client* createClient() override; virtual void deleteClient(Client* client); @@ -144,12 +144,12 @@ class EspressifESP8266 : public Espressif { createSecureClient(const char* pskTableName, SSLVersion sslVersion = SSLVersion::TLS1_2) override; - uint32_t getNISTTime(void) override; + uint32_t getNISTTime() override; bool getModemSignalQuality(int16_t& rssi, int16_t& percent) override; bool getModemBatteryStats(int8_t& chargeState, int8_t& percent, int16_t& milliVolts) override; - float getModemChipTemperature(void) override; + float getModemChipTemperature() override; #ifdef MS_ESPRESSIFESP8266_DEBUG_DEEP StreamDebugger _modemATDebugger; @@ -161,10 +161,10 @@ class EspressifESP8266 : public Espressif { TinyGsmESP8266 gsmModem; protected: - bool isInternetAvailable(void) override; - bool modemSleepFxn(void) override; - bool extraModemSetup(void) override; - bool isModemAwake(void) override; + bool isInternetAvailable() override; + bool modemSleepFxn() override; + bool extraModemSetup() override; + bool isModemAwake() override; }; /**@}*/ #endif // SRC_MODEMS_ESPRESSIFESP8266_H_ diff --git a/src/modems/LoggerModemMacros.h b/src/modems/LoggerModemMacros.h index df89b6456..900c33ab0 100644 --- a/src/modems/LoggerModemMacros.h +++ b/src/modems/LoggerModemMacros.h @@ -42,7 +42,7 @@ * subclass. */ #define MS_MODEM_EXTRA_SETUP(specificModem) \ - bool specificModem::extraModemSetup(void) { \ + bool specificModem::extraModemSetup() { \ bool success = gsmModem.init(); \ _modemName = gsmModem.getModemName(); \ MS_MODEM_NTP_SYNC \ @@ -59,7 +59,7 @@ * subclass. */ #define MS_IS_MODEM_AWAKE(specificModem) \ - bool specificModem::isModemAwake(void) { \ + bool specificModem::isModemAwake() { \ if (_wakePulse_ms == 0 && _modemSleepRqPin >= 0) { \ /** If the wake up is one where a pin is held (0 wake time) and \ * that pin is defined, then we're going to check the level of the \ @@ -117,7 +117,7 @@ * subclass. */ #define MS_MODEM_WAKE(specificModem) \ - bool specificModem::modemWake(void) { \ + bool specificModem::modemWake() { \ /** Set-up pin modes. \ Because the modem calls wake BEFORE the first setup, we must set \ the pin modes in the wake function. */ \ @@ -253,7 +253,7 @@ #if defined(TINY_GSM_MODEM_HAS_GPRS) #define MS_MODEM_IS_INTERNET_AVAILABLE(specificModem) \ - bool specificModem::isInternetAvailable(void) { \ + bool specificModem::isInternetAvailable() { \ return gsmModem.isGprsConnected(); \ } @@ -327,7 +327,7 @@ } #define MS_MODEM_DISCONNECT_INTERNET(specificModem) \ - void specificModem::disconnectInternet(void) { \ + void specificModem::disconnectInternet() { \ MS_START_DEBUG_TIMER; \ gsmModem.gprsDisconnect(); \ MS_DBG(F("Disconnected from cellular network after"), \ @@ -338,7 +338,7 @@ //^^ from #if defined(TINY_GSM_MODEM_HAS_GPRS) (ie, this is wifi) #define MS_MODEM_IS_INTERNET_AVAILABLE(specificModem) \ - bool specificModem::isInternetAvailable(void) { \ + bool specificModem::isInternetAvailable() { \ return gsmModem.isNetworkConnected(); \ } @@ -421,7 +421,7 @@ } #define MS_MODEM_DISCONNECT_INTERNET(specificModem) \ - void specificModem::disconnectInternet(void) { \ + void specificModem::disconnectInternet() { \ MS_START_DEBUG_TIMER; \ gsmModem.networkDisconnect(); \ MS_DBG(F("Disconnected from WiFi network after"), \ @@ -613,7 +613,7 @@ */ #if defined(TINY_GSM_MODEM_ESP8266) || defined(TINY_GSM_MODEM_ESP32) #define MS_MODEM_GET_NIST_TIME(specificModem, TinyGSMType) \ - uint32_t specificModem::getNISTTime(void) { \ + uint32_t specificModem::getNISTTime() { \ /** Check for and bail if not connected to the internet. */ \ if (!isInternetAvailable()) { \ MS_DBG(F("No internet connection, cannot get network time.")); \ @@ -628,7 +628,7 @@ #elif defined(TINY_GSM_MODEM_HAS_NTP) && defined(TINY_GSM_MODEM_HAS_TIME) #include "ClockSupport.h" #define MS_MODEM_GET_NIST_TIME(specificModem, TinyGSMType) \ - uint32_t specificModem::getNISTTime(void) { \ + uint32_t specificModem::getNISTTime() { \ /** Check for and bail if not connected to the internet. */ \ if (!isInternetAvailable()) { \ MS_DBG(F("No internet connection, cannot get network time.")); \ @@ -663,7 +663,7 @@ } #else #define MS_MODEM_GET_NIST_TIME(specificModem, TinyGSMType) \ - uint32_t specificModem::getNISTTime(void) { \ + uint32_t specificModem::getNISTTime() { \ /** Check for and bail if not connected to the internet. */ \ if (!isInternetAvailable()) { \ MS_DBG(F("No internet connection, cannot connect to NIST.")); \ @@ -836,7 +836,7 @@ */ #ifdef TINY_GSM_MODEM_HAS_TEMPERATURE #define MS_MODEM_GET_MODEM_TEMPERATURE_DATA(specificModem) \ - float specificModem::getModemChipTemperature(void) { \ + float specificModem::getModemChipTemperature() { \ MS_DBG(F("Getting temperature:")); \ float temp = gsmModem.getTemperature(); \ MS_DBG(F("Temperature:"), temp); \ @@ -845,7 +845,7 @@ } #else #define MS_MODEM_GET_MODEM_TEMPERATURE_DATA(specificModem) \ - float specificModem::getModemChipTemperature(void) { \ + float specificModem::getModemChipTemperature() { \ MS_DBG(F("This modem doesn't return temperature!")); \ return static_cast(MS_INVALID_VALUE); \ } diff --git a/src/modems/QuectelBG96.cpp b/src/modems/QuectelBG96.cpp index 8ce90b1af..3d60ff178 100644 --- a/src/modems/QuectelBG96.cpp +++ b/src/modems/QuectelBG96.cpp @@ -51,7 +51,7 @@ MS_MODEM_GET_MODEM_TEMPERATURE_DATA(QuectelBG96); // Create the wake and sleep methods for the modem // These can be functions of any type and must return a boolean -bool QuectelBG96::modemWakeFxn(void) { +bool QuectelBG96::modemWakeFxn() { // Must power on and then pulse on if (_modemSleepRqPin >= 0) { MS_DBG(F("Sending a"), _wakePulse_ms, F("ms"), @@ -66,7 +66,7 @@ bool QuectelBG96::modemWakeFxn(void) { } -bool QuectelBG96::modemSleepFxn(void) { +bool QuectelBG96::modemSleepFxn() { if (_modemSleepRqPin >= 0) { // BG96 must have access to `PWRKEY` pin to sleep // Easiest to just go to sleep with the AT command rather than using @@ -79,7 +79,7 @@ bool QuectelBG96::modemSleepFxn(void) { return true; // DON'T go to sleep if we can't wake up! } -bool QuectelBG96::modemHardReset(void) { +bool QuectelBG96::modemHardReset() { digitalWrite(_modemSleepRqPin, !_wakeLevel); // set the wake pin high bool success = loggerModem::modemHardReset(); if (success) { return gsmModem.waitResponse(10000L, GF("RDY")) == 1; } diff --git a/src/modems/QuectelBG96.h b/src/modems/QuectelBG96.h index 6a9421632..eddea4d3d 100644 --- a/src/modems/QuectelBG96.h +++ b/src/modems/QuectelBG96.h @@ -202,10 +202,10 @@ class QuectelBG96 : public loggerModem { */ ~QuectelBG96() override = default; - bool modemWake(void) override; + bool modemWake() override; bool connectInternet(uint32_t maxConnectionTime = 50000L) override; - void disconnectInternet(void) override; + void disconnectInternet() override; virtual Client* createClient() override; virtual void deleteClient(Client* client); @@ -222,14 +222,14 @@ class QuectelBG96 : public loggerModem { createSecureClient(const char* pskTableName, SSLVersion sslVersion = SSLVersion::TLS1_2) override; - uint32_t getNISTTime(void) override; + uint32_t getNISTTime() override; bool getModemSignalQuality(int16_t& rssi, int16_t& percent) override; bool getModemBatteryStats(int8_t& chargeState, int8_t& percent, int16_t& milliVolts) override; - float getModemChipTemperature(void) override; + float getModemChipTemperature() override; - bool modemHardReset(void) override; + bool modemHardReset() override; #ifdef MS_QUECTELBG96_DEBUG_DEEP StreamDebugger _modemATDebugger; @@ -241,11 +241,11 @@ class QuectelBG96 : public loggerModem { TinyGsmBG96 gsmModem; protected: - bool isInternetAvailable(void) override; - bool modemSleepFxn(void) override; - bool modemWakeFxn(void) override; - bool extraModemSetup(void) override; - bool isModemAwake(void) override; + bool isInternetAvailable() override; + bool modemSleepFxn() override; + bool modemWakeFxn() override; + bool extraModemSetup() override; + bool isModemAwake() override; private: const char* _apn; ///< Internal reference to the cellular APN diff --git a/src/modems/SIMComSIM7000.cpp b/src/modems/SIMComSIM7000.cpp index 69e88c6ba..a4e043301 100644 --- a/src/modems/SIMComSIM7000.cpp +++ b/src/modems/SIMComSIM7000.cpp @@ -51,7 +51,7 @@ MS_MODEM_GET_MODEM_TEMPERATURE_DATA(SIMComSIM7000); // Create the wake and sleep methods for the modem // These can be functions of any type and must return a boolean -bool SIMComSIM7000::modemWakeFxn(void) { +bool SIMComSIM7000::modemWakeFxn() { // Must power on and then pulse on if (_modemSleepRqPin >= 0) { MS_DBG(F("Sending a"), _wakePulse_ms, F("ms"), @@ -65,7 +65,7 @@ bool SIMComSIM7000::modemWakeFxn(void) { } -bool SIMComSIM7000::modemSleepFxn(void) { +bool SIMComSIM7000::modemSleepFxn() { if (_modemSleepRqPin >= 0) { // Must have access to `PWRKEY` pin to sleep // Easiest to just go to sleep with the AT command rather than using diff --git a/src/modems/SIMComSIM7000.h b/src/modems/SIMComSIM7000.h index 0d38ef5ac..13d904774 100644 --- a/src/modems/SIMComSIM7000.h +++ b/src/modems/SIMComSIM7000.h @@ -190,10 +190,10 @@ class SIMComSIM7000 : public loggerModem { */ ~SIMComSIM7000() override = default; - bool modemWake(void) override; + bool modemWake() override; bool connectInternet(uint32_t maxConnectionTime = 50000L) override; - void disconnectInternet(void) override; + void disconnectInternet() override; virtual Client* createClient() override; virtual void deleteClient(Client* client); @@ -210,12 +210,12 @@ class SIMComSIM7000 : public loggerModem { createSecureClient(const char* pskTableName, SSLVersion sslVersion = SSLVersion::TLS1_2) override; - uint32_t getNISTTime(void) override; + uint32_t getNISTTime() override; bool getModemSignalQuality(int16_t& rssi, int16_t& percent) override; bool getModemBatteryStats(int8_t& chargeState, int8_t& percent, int16_t& milliVolts) override; - float getModemChipTemperature(void) override; + float getModemChipTemperature() override; #ifdef MS_SIMCOMSIM7000_DEBUG_DEEP StreamDebugger _modemATDebugger; @@ -227,11 +227,11 @@ class SIMComSIM7000 : public loggerModem { TinyGsmSim7000SSL gsmModem; protected: - bool isInternetAvailable(void) override; - bool modemSleepFxn(void) override; - bool modemWakeFxn(void) override; - bool extraModemSetup(void) override; - bool isModemAwake(void) override; + bool isInternetAvailable() override; + bool modemSleepFxn() override; + bool modemWakeFxn() override; + bool extraModemSetup() override; + bool isModemAwake() override; private: const char* _apn; ///< Internal reference to the cellular APN diff --git a/src/modems/SIMComSIM7080.cpp b/src/modems/SIMComSIM7080.cpp index 9e7b3e8b3..1d073880d 100644 --- a/src/modems/SIMComSIM7080.cpp +++ b/src/modems/SIMComSIM7080.cpp @@ -31,7 +31,7 @@ SIMComSIM7080::SIMComSIM7080(Stream* modemStream, int8_t powerPin, } -bool SIMComSIM7080::extraModemSetup(void) { +bool SIMComSIM7080::extraModemSetup() { bool success = gsmModem.init(); _modemName = gsmModem.getModemName(); @@ -82,7 +82,7 @@ MS_MODEM_GET_MODEM_TEMPERATURE_DATA(SIMComSIM7080); // Create the wake and sleep methods for the modem // These can be functions of any type and must return a boolean -bool SIMComSIM7080::modemWakeFxn(void) { +bool SIMComSIM7080::modemWakeFxn() { // Must power on and then pulse on if (_modemSleepRqPin >= 0) { MS_DBG(F("Sending a"), _wakePulse_ms, F("ms"), @@ -108,7 +108,7 @@ bool SIMComSIM7080::modemWakeFxn(void) { } -bool SIMComSIM7080::modemSleepFxn(void) { +bool SIMComSIM7080::modemSleepFxn() { if (_modemSleepRqPin >= 0) { // Must have access to `PWRKEY` pin to sleep // Easiest to just go to sleep with the AT command rather than using diff --git a/src/modems/SIMComSIM7080.h b/src/modems/SIMComSIM7080.h index 7836bbb1b..1a03fc9ac 100644 --- a/src/modems/SIMComSIM7080.h +++ b/src/modems/SIMComSIM7080.h @@ -185,10 +185,10 @@ class SIMComSIM7080 : public loggerModem { */ ~SIMComSIM7080() override = default; - bool modemWake(void) override; + bool modemWake() override; bool connectInternet(uint32_t maxConnectionTime = 50000L) override; - void disconnectInternet(void) override; + void disconnectInternet() override; virtual Client* createClient() override; virtual void deleteClient(Client* client); @@ -205,12 +205,12 @@ class SIMComSIM7080 : public loggerModem { createSecureClient(const char* pskTableName, SSLVersion sslVersion = SSLVersion::TLS1_2) override; - uint32_t getNISTTime(void) override; + uint32_t getNISTTime() override; bool getModemSignalQuality(int16_t& rssi, int16_t& percent) override; bool getModemBatteryStats(int8_t& chargeState, int8_t& percent, int16_t& milliVolts) override; - float getModemChipTemperature(void) override; + float getModemChipTemperature() override; #ifdef MS_SIMCOMSIM7080_DEBUG_DEEP StreamDebugger _modemATDebugger; @@ -222,11 +222,11 @@ class SIMComSIM7080 : public loggerModem { TinyGsmSim7080 gsmModem; protected: - bool isInternetAvailable(void) override; - bool modemSleepFxn(void) override; - bool modemWakeFxn(void) override; - bool extraModemSetup(void) override; - bool isModemAwake(void) override; + bool isInternetAvailable() override; + bool modemSleepFxn() override; + bool modemWakeFxn() override; + bool extraModemSetup() override; + bool isModemAwake() override; private: const char* _apn; ///< Internal reference to the cellular APN diff --git a/src/modems/SIMComSIM800.cpp b/src/modems/SIMComSIM800.cpp index 5c4598e22..bc2300722 100644 --- a/src/modems/SIMComSIM800.cpp +++ b/src/modems/SIMComSIM800.cpp @@ -51,7 +51,7 @@ MS_MODEM_GET_MODEM_TEMPERATURE_DATA(SIMComSIM800); // Create the wake and sleep methods for the modem // These can be functions of any type and must return a boolean -bool SIMComSIM800::modemWakeFxn(void) { +bool SIMComSIM800::modemWakeFxn() { // Must power on and then pulse on if (_modemSleepRqPin >= 0) { MS_DBG(F("Sending a"), _wakePulse_ms, F("ms"), @@ -65,7 +65,7 @@ bool SIMComSIM800::modemWakeFxn(void) { } -bool SIMComSIM800::modemSleepFxn(void) { +bool SIMComSIM800::modemSleepFxn() { if (_modemSleepRqPin >= 0) { // Must have access to `PWRKEY` pin to sleep // Easiest to just go to sleep with the AT command rather than using diff --git a/src/modems/SIMComSIM800.h b/src/modems/SIMComSIM800.h index 7f5cf14ce..21fc57367 100644 --- a/src/modems/SIMComSIM800.h +++ b/src/modems/SIMComSIM800.h @@ -192,10 +192,10 @@ class SIMComSIM800 : public loggerModem { */ ~SIMComSIM800() override = default; - bool modemWake(void) override; + bool modemWake() override; bool connectInternet(uint32_t maxConnectionTime = 50000L) override; - void disconnectInternet(void) override; + void disconnectInternet() override; virtual Client* createClient() override; virtual void deleteClient(Client* client); @@ -212,12 +212,12 @@ class SIMComSIM800 : public loggerModem { createSecureClient(const char* pskTableName, SSLVersion sslVersion = SSLVersion::TLS1_2) override; - uint32_t getNISTTime(void) override; + uint32_t getNISTTime() override; bool getModemSignalQuality(int16_t& rssi, int16_t& percent) override; bool getModemBatteryStats(int8_t& chargeState, int8_t& percent, int16_t& milliVolts) override; - float getModemChipTemperature(void) override; + float getModemChipTemperature() override; #ifdef MS_SIMCOMSIM800_DEBUG_DEEP StreamDebugger _modemATDebugger; @@ -229,11 +229,11 @@ class SIMComSIM800 : public loggerModem { TinyGsmSim800 gsmModem; protected: - bool isInternetAvailable(void) override; - bool modemSleepFxn(void) override; - bool modemWakeFxn(void) override; - bool extraModemSetup(void) override; - bool isModemAwake(void) override; + bool isInternetAvailable() override; + bool modemSleepFxn() override; + bool modemWakeFxn() override; + bool extraModemSetup() override; + bool isModemAwake() override; private: const char* _apn; ///< Internal reference to the cellular APN diff --git a/src/modems/SequansMonarch.cpp b/src/modems/SequansMonarch.cpp index 460ed971f..f5af2514d 100644 --- a/src/modems/SequansMonarch.cpp +++ b/src/modems/SequansMonarch.cpp @@ -51,7 +51,7 @@ MS_MODEM_GET_MODEM_TEMPERATURE_DATA(SequansMonarch); // Create the wake and sleep methods for the modem // These can be functions of any type and must return a boolean -bool SequansMonarch::modemWakeFxn(void) { +bool SequansMonarch::modemWakeFxn() { // Module turns on when power is applied // No pulsing required in this case if (_powerPin >= 0) { @@ -88,7 +88,7 @@ bool SequansMonarch::modemWakeFxn(void) { } -bool SequansMonarch::modemSleepFxn(void) { +bool SequansMonarch::modemSleepFxn() { if (_powerPin >= 0 || _modemResetPin >= 0) { // Module will go on with power on // Easiest to just go to sleep with the AT command rather than using @@ -117,7 +117,7 @@ bool SequansMonarch::modemSleepFxn(void) { } -bool SequansMonarch::extraModemSetup(void) { +bool SequansMonarch::extraModemSetup() { bool success = gsmModem.init(); _modemName = gsmModem.getModemName(); // Turn on the LED diff --git a/src/modems/SequansMonarch.h b/src/modems/SequansMonarch.h index 5cb688970..f560a87ff 100644 --- a/src/modems/SequansMonarch.h +++ b/src/modems/SequansMonarch.h @@ -223,10 +223,10 @@ class SequansMonarch : public loggerModem { */ ~SequansMonarch() override = default; - bool modemWake(void) override; + bool modemWake() override; bool connectInternet(uint32_t maxConnectionTime = 50000L) override; - void disconnectInternet(void) override; + void disconnectInternet() override; virtual Client* createClient() override; virtual void deleteClient(Client* client); @@ -243,12 +243,12 @@ class SequansMonarch : public loggerModem { createSecureClient(const char* pskTableName, SSLVersion sslVersion = SSLVersion::TLS1_2) override; - uint32_t getNISTTime(void) override; + uint32_t getNISTTime() override; bool getModemSignalQuality(int16_t& rssi, int16_t& percent) override; bool getModemBatteryStats(int8_t& chargeState, int8_t& percent, int16_t& milliVolts) override; - float getModemChipTemperature(void) override; + float getModemChipTemperature() override; #ifdef MS_SEQUANSMONARCH_DEBUG_DEEP StreamDebugger _modemATDebugger; @@ -260,11 +260,11 @@ class SequansMonarch : public loggerModem { TinyGsmSequansMonarch gsmModem; protected: - bool isInternetAvailable(void) override; - bool modemSleepFxn(void) override; - bool modemWakeFxn(void) override; - bool extraModemSetup(void) override; - bool isModemAwake(void) override; + bool isInternetAvailable() override; + bool modemSleepFxn() override; + bool modemWakeFxn() override; + bool extraModemSetup() override; + bool isModemAwake() override; private: const char* _apn; ///< Internal reference to the cellular APN diff --git a/src/modems/Sodaq2GBeeR6.cpp b/src/modems/Sodaq2GBeeR6.cpp index 3215eb6a7..efb320abd 100644 --- a/src/modems/Sodaq2GBeeR6.cpp +++ b/src/modems/Sodaq2GBeeR6.cpp @@ -30,7 +30,7 @@ Sodaq2GBeeR6::Sodaq2GBeeR6(Stream* modemStream, int8_t vRefPin, // Create the wake and sleep methods for the modem // These can be functions of any type and must return a boolean -bool Sodaq2GBeeR6::modemWakeFxn(void) { +bool Sodaq2GBeeR6::modemWakeFxn() { if (_vRefPin >= 0) { MS_DBG(F("Enabling voltage reference for GPRSBeeR6 on pin"), _vRefPin); pinMode(_vRefPin, OUTPUT); @@ -40,7 +40,7 @@ bool Sodaq2GBeeR6::modemWakeFxn(void) { } -bool Sodaq2GBeeR6::modemSleepFxn(void) { +bool Sodaq2GBeeR6::modemSleepFxn() { // Ask the SIM800 to shut down nicely MS_DBG(F("Asking SIM800 on GPRSBeeR6 to power down")); bool success = gsmModem.poweroff(); @@ -52,7 +52,7 @@ bool Sodaq2GBeeR6::modemSleepFxn(void) { return success; } -bool Sodaq2GBeeR6::extraModemSetup(void) { +bool Sodaq2GBeeR6::extraModemSetup() { bool success = gsmModem.init(); _modemName = gsmModem.getModemName(); if (_vRefPin >= 0) { pinMode(_vRefPin, OUTPUT); } diff --git a/src/modems/Sodaq2GBeeR6.h b/src/modems/Sodaq2GBeeR6.h index c977639c8..9a1f1c043 100644 --- a/src/modems/Sodaq2GBeeR6.h +++ b/src/modems/Sodaq2GBeeR6.h @@ -173,9 +173,9 @@ class Sodaq2GBeeR6 : public SIMComSIM800 { void setVRefPin(int8_t vRefPin); protected: - bool modemSleepFxn(void) override; - bool modemWakeFxn(void) override; - bool extraModemSetup(void) override; + bool modemSleepFxn() override; + bool modemWakeFxn() override; + bool extraModemSetup() override; private: /** diff --git a/src/modems/SodaqUBeeR410M.cpp b/src/modems/SodaqUBeeR410M.cpp index 08cedef35..3d9280cef 100644 --- a/src/modems/SodaqUBeeR410M.cpp +++ b/src/modems/SodaqUBeeR410M.cpp @@ -71,7 +71,7 @@ MS_MODEM_GET_MODEM_TEMPERATURE_DATA(SodaqUBeeR410M); // Create the wake and sleep methods for the modem // These can be functions of any type and must return a boolean -bool SodaqUBeeR410M::modemWakeFxn(void) { +bool SodaqUBeeR410M::modemWakeFxn() { // SARA R4/N4 series must power on and then pulse on if (_modemSleepRqPin >= 0) { MS_DBG(F("Sending a"), _wakePulse_ms, F("ms"), @@ -133,7 +133,7 @@ bool SodaqUBeeR410M::modemWakeFxn(void) { } -bool SodaqUBeeR410M::modemSleepFxn(void) { +bool SodaqUBeeR410M::modemSleepFxn() { if (_modemSleepRqPin >= 0) { // R410 must have access to `PWR_ON` pin to sleep // Easiest to just go to sleep with the AT command rather than using @@ -149,7 +149,7 @@ bool SodaqUBeeR410M::modemSleepFxn(void) { } -bool SodaqUBeeR410M::modemHardReset(void) { +bool SodaqUBeeR410M::modemHardReset() { if (_modemResetPin >= 0) { MS_DBG(F("Doing a hard reset on the modem by setting pin"), _modemResetPin, _resetLevel ? F("HIGH") : F("LOW"), F("for"), @@ -177,7 +177,7 @@ bool SodaqUBeeR410M::modemHardReset(void) { } } -bool SodaqUBeeR410M::extraModemSetup(void) { +bool SodaqUBeeR410M::extraModemSetup() { bool success = gsmModem.init(); _modemName = gsmModem.getModemName(); // Turn on network indicator light diff --git a/src/modems/SodaqUBeeR410M.h b/src/modems/SodaqUBeeR410M.h index 8d97a879e..5e89fd4e7 100644 --- a/src/modems/SodaqUBeeR410M.h +++ b/src/modems/SodaqUBeeR410M.h @@ -299,10 +299,10 @@ class SodaqUBeeR410M : public loggerModem { */ ~SodaqUBeeR410M() override = default; - bool modemWake(void) override; + bool modemWake() override; bool connectInternet(uint32_t maxConnectionTime = 50000L) override; - void disconnectInternet(void) override; + void disconnectInternet() override; virtual Client* createClient() override; virtual void deleteClient(Client* client); @@ -319,14 +319,14 @@ class SodaqUBeeR410M : public loggerModem { createSecureClient(const char* pskTableName, SSLVersion sslVersion = SSLVersion::TLS1_2) override; - uint32_t getNISTTime(void) override; + uint32_t getNISTTime() override; bool getModemSignalQuality(int16_t& rssi, int16_t& percent) override; bool getModemBatteryStats(int8_t& chargeState, int8_t& percent, int16_t& milliVolts) override; - float getModemChipTemperature(void) override; + float getModemChipTemperature() override; - bool modemHardReset(void) override; + bool modemHardReset() override; #ifdef MS_SODAQUBEER410M_DEBUG_DEEP StreamDebugger _modemATDebugger; @@ -346,11 +346,11 @@ class SodaqUBeeR410M : public loggerModem { #endif protected: - bool isInternetAvailable(void) override; - bool modemSleepFxn(void) override; - bool modemWakeFxn(void) override; - bool extraModemSetup(void) override; - bool isModemAwake(void) override; + bool isInternetAvailable() override; + bool modemSleepFxn() override; + bool modemWakeFxn() override; + bool extraModemSetup() override; + bool isModemAwake() override; private: const char* _apn; ///< Internal reference to the cellular APN diff --git a/src/modems/SodaqUBeeU201.cpp b/src/modems/SodaqUBeeU201.cpp index d9ab54225..bb5701946 100644 --- a/src/modems/SodaqUBeeU201.cpp +++ b/src/modems/SodaqUBeeU201.cpp @@ -50,7 +50,7 @@ MS_MODEM_GET_MODEM_TEMPERATURE_DATA(SodaqUBeeU201); // Create the wake and sleep methods for the modem // These can be functions of any type and must return a boolean -bool SodaqUBeeU201::modemWakeFxn(void) { +bool SodaqUBeeU201::modemWakeFxn() { // SARA/LISA U2/G2 and SARA G3 series turn on when power is applied // No pulsing required in this case if (_powerPin >= 0) { return true; } @@ -69,7 +69,7 @@ bool SodaqUBeeU201::modemWakeFxn(void) { } -bool SodaqUBeeU201::modemSleepFxn(void) { +bool SodaqUBeeU201::modemSleepFxn() { if (_powerPin >= 0 || _modemSleepRqPin >= 0) { // will go on with power on // Easiest to just go to sleep with the AT command rather than using @@ -84,7 +84,7 @@ bool SodaqUBeeU201::modemSleepFxn(void) { } } -bool SodaqUBeeU201::extraModemSetup(void) { +bool SodaqUBeeU201::extraModemSetup() { bool success = gsmModem.init(); _modemName = gsmModem.getModemName(); // Turn on network indicator light diff --git a/src/modems/SodaqUBeeU201.h b/src/modems/SodaqUBeeU201.h index 2c505381a..fe0c51150 100644 --- a/src/modems/SodaqUBeeU201.h +++ b/src/modems/SodaqUBeeU201.h @@ -198,10 +198,10 @@ class SodaqUBeeU201 : public loggerModem { */ ~SodaqUBeeU201() override = default; - bool modemWake(void) override; + bool modemWake() override; bool connectInternet(uint32_t maxConnectionTime = 50000L) override; - void disconnectInternet(void) override; + void disconnectInternet() override; virtual Client* createClient() override; virtual void deleteClient(Client* client); @@ -218,12 +218,12 @@ class SodaqUBeeU201 : public loggerModem { createSecureClient(const char* pskTableName, SSLVersion sslVersion = SSLVersion::TLS1_2) override; - uint32_t getNISTTime(void) override; + uint32_t getNISTTime() override; bool getModemSignalQuality(int16_t& rssi, int16_t& percent) override; bool getModemBatteryStats(int8_t& chargeState, int8_t& percent, int16_t& milliVolts) override; - float getModemChipTemperature(void) override; + float getModemChipTemperature() override; #ifdef MS_SODAQUBEEU201_DEBUG_DEEP StreamDebugger _modemATDebugger; @@ -235,11 +235,11 @@ class SodaqUBeeU201 : public loggerModem { TinyGsmUBLOX gsmModem; protected: - bool isInternetAvailable(void) override; - bool modemSleepFxn(void) override; - bool modemWakeFxn(void) override; - bool extraModemSetup(void) override; - bool isModemAwake(void) override; + bool isInternetAvailable() override; + bool modemSleepFxn() override; + bool modemWakeFxn() override; + bool extraModemSetup() override; + bool isModemAwake() override; private: const char* _apn; ///< Internal reference to the cellular APN diff --git a/src/publishers/AWS_IoT_Publisher.cpp b/src/publishers/AWS_IoT_Publisher.cpp index f5c1be339..361e28f8f 100644 --- a/src/publishers/AWS_IoT_Publisher.cpp +++ b/src/publishers/AWS_IoT_Publisher.cpp @@ -143,7 +143,7 @@ void AWS_IoT_Publisher::removeSubTopic(const char* topic) { } void AWS_IoT_Publisher::addPublishRequest(const char* topic, - String (*contentGetrFxn)(void)) { + String (*contentGetrFxn)()) { for (uint8_t i = 0; i < MS_AWS_IOT_PUBLISHER_PUB_COUNT; i++) { if (pub_topics[i] == nullptr) { pub_topics[i] = topic; diff --git a/src/publishers/AWS_IoT_Publisher.h b/src/publishers/AWS_IoT_Publisher.h index 134b9d8dd..064f6f23d 100644 --- a/src/publishers/AWS_IoT_Publisher.h +++ b/src/publishers/AWS_IoT_Publisher.h @@ -176,7 +176,7 @@ class AWS_IoT_Publisher : public dataPublisher { virtual ~AWS_IoT_Publisher() override = default; // Returns the data destination - String getEndpoint(void) override { + String getEndpoint() override { return String(_awsIoTEndpoint); } @@ -343,7 +343,7 @@ class AWS_IoT_Publisher : public dataPublisher { * @param contentGetrFxn A function to call to get the content to publish. * The function should return a pointer to a char array. */ - void addPublishRequest(const char* topic, String (*contentGetrFxn)(void)); + void addPublishRequest(const char* topic, String (*contentGetrFxn)()); /** * @brief Removes a topic from the publish list. * @@ -489,7 +489,7 @@ class AWS_IoT_Publisher : public dataPublisher { /** * @brief An array of functions to call to get publish content */ - String (*contentGetrFxns[MS_AWS_IOT_PUBLISHER_PUB_COUNT])(void); + String (*contentGetrFxns[MS_AWS_IOT_PUBLISHER_PUB_COUNT])(); /// constructor helper void init(); }; diff --git a/src/publishers/DreamHostPublisher.cpp b/src/publishers/DreamHostPublisher.cpp index 3c7be6321..36c93f2ac 100644 --- a/src/publishers/DreamHostPublisher.cpp +++ b/src/publishers/DreamHostPublisher.cpp @@ -65,7 +65,7 @@ void DreamHostPublisher::begin(Logger& baseLogger, const char* dhUrl) { // Post the data to dream host. -// int16_t DreamHostPublisher::postDataDreamHost(void) +// int16_t DreamHostPublisher::postDataDreamHost() int16_t DreamHostPublisher::publishData(Client* outClient, bool) { // Create a buffer for the portions of the request and response char tempBuffer[37] = ""; diff --git a/src/publishers/DreamHostPublisher.h b/src/publishers/DreamHostPublisher.h index deda69cdc..07e5dc17b 100644 --- a/src/publishers/DreamHostPublisher.h +++ b/src/publishers/DreamHostPublisher.h @@ -104,7 +104,7 @@ class DreamHostPublisher : public dataPublisher { virtual ~DreamHostPublisher() override = default; // Returns the data destination - String getEndpoint(void) override { + String getEndpoint() override { return String(dreamhostHost); } diff --git a/src/publishers/MonitorMyWatershedPublisher.cpp b/src/publishers/MonitorMyWatershedPublisher.cpp index 25a1a8fc4..a9c080a48 100644 --- a/src/publishers/MonitorMyWatershedPublisher.cpp +++ b/src/publishers/MonitorMyWatershedPublisher.cpp @@ -87,7 +87,7 @@ MonitorMyWatershedPublisher::MonitorMyWatershedPublisher( nullptr, sendEveryX) {} // Returns the data destination -String MonitorMyWatershedPublisher::getHost(void) { +String MonitorMyWatershedPublisher::getHost() { return String(monitorMWHost); } @@ -97,7 +97,7 @@ void MonitorMyWatershedPublisher::setHost(const char* host) { } // Returns the data destination -String MonitorMyWatershedPublisher::getPath(void) { +String MonitorMyWatershedPublisher::getPath() { return String(monitorMWPath); } @@ -107,7 +107,7 @@ void MonitorMyWatershedPublisher::setPath(const char* endpoint) { } // Returns the data destination -int MonitorMyWatershedPublisher::getPort(void) { +int MonitorMyWatershedPublisher::getPort() { return monitorMWPort; } @@ -198,7 +198,7 @@ void MonitorMyWatershedPublisher::begin(Logger& baseLogger, nullptr); } -bool MonitorMyWatershedPublisher::connectionNeeded(void) { +bool MonitorMyWatershedPublisher::connectionNeeded() { // compute the send interval, reducing it as the buffer gets more full so we // have less of a chance of losing data int interval = _sendEveryX; diff --git a/src/publishers/MonitorMyWatershedPublisher.h b/src/publishers/MonitorMyWatershedPublisher.h index d412caeb6..8f61f9c17 100644 --- a/src/publishers/MonitorMyWatershedPublisher.h +++ b/src/publishers/MonitorMyWatershedPublisher.h @@ -144,7 +144,7 @@ class MonitorMyWatershedPublisher : public dataPublisher { virtual ~MonitorMyWatershedPublisher() override = default; // Returns the data destination - String getEndpoint(void) override { + String getEndpoint() override { return String(monitorMWHost) + String(monitorMWPath); } @@ -153,7 +153,7 @@ class MonitorMyWatershedPublisher : public dataPublisher { * * @return The Monitor My Watershed web host */ - String getHost(void); + String getHost(); /** * @brief Set the Monitor My Watershed web host @@ -172,7 +172,7 @@ class MonitorMyWatershedPublisher : public dataPublisher { * * @return The Monitor My Watershed API path */ - String getPath(void); + String getPath(); /** * @brief Set the Monitor My Watershed API path * @@ -190,7 +190,7 @@ class MonitorMyWatershedPublisher : public dataPublisher { * * @return The Monitor My Watershed API port */ - int getPort(void); + int getPort(); /** * @brief Set the Monitor My Watershed API port * @@ -246,7 +246,7 @@ class MonitorMyWatershedPublisher : public dataPublisher { * * @return True if an internet connection is needed for the next publish. */ - bool connectionNeeded(void) override; + bool connectionNeeded() override; /** * @brief Utilize an attached modem to open a TCP connection to Monitor My diff --git a/src/publishers/S3PresignedPublisher.cpp b/src/publishers/S3PresignedPublisher.cpp index 64f728c90..88e41ed12 100644 --- a/src/publishers/S3PresignedPublisher.cpp +++ b/src/publishers/S3PresignedPublisher.cpp @@ -22,7 +22,7 @@ const char* S3PresignedPublisher::contentTypeHeader = "\r\nContent-Type: "; S3PresignedPublisher::S3PresignedPublisher(Logger& baseLogger, const char* caCertName, String (*getUrlFxn)(String), - String (*getFileNameFxn)(void), + String (*getFileNameFxn)(), int sendEveryX) : dataPublisher(baseLogger, sendEveryX) { if (caCertName) setCACertName(caCertName); @@ -34,7 +34,7 @@ S3PresignedPublisher::S3PresignedPublisher(Logger& baseLogger, S3PresignedPublisher::S3PresignedPublisher() : dataPublisher() {} S3PresignedPublisher::S3PresignedPublisher(Logger& baseLogger, Client* inClient, String (*getUrlFxn)(String), - String (*getFileNameFxn)(void), + String (*getFileNameFxn)(), int sendEveryX) : S3PresignedPublisher(baseLogger, static_cast(nullptr), getUrlFxn, getFileNameFxn, sendEveryX) { @@ -52,8 +52,7 @@ void S3PresignedPublisher::setHost(const char* host) { void S3PresignedPublisher::setURLUpdateFunction(String (*getUrlFxn)(String)) { _getUrlFxn = getUrlFxn; } -void S3PresignedPublisher::setFileUpdateFunction( - String (*getFileNameFxn)(void)) { +void S3PresignedPublisher::setFileUpdateFunction(String (*getFileNameFxn)()) { _getFileNameFxn = getFileNameFxn; } diff --git a/src/publishers/S3PresignedPublisher.h b/src/publishers/S3PresignedPublisher.h index d9683151b..92032b24f 100644 --- a/src/publishers/S3PresignedPublisher.h +++ b/src/publishers/S3PresignedPublisher.h @@ -154,9 +154,9 @@ class S3PresignedPublisher : public dataPublisher { * it is stored on you modem module, not the actual certificate content. */ S3PresignedPublisher(Logger& baseLogger, const char* caCertName, - String (*getUrlFxn)(String) = nullptr, - String (*getFileNameFxn)(void) = nullptr, - int sendEveryX = 1); + String (*getUrlFxn)(String) = nullptr, + String (*getFileNameFxn)() = nullptr, + int sendEveryX = 1); /** * @brief Construct a new S3 Publisher object * @@ -170,9 +170,9 @@ class S3PresignedPublisher : public dataPublisher { * attempted data transmissions. NOTE: not implemented by this publisher! */ S3PresignedPublisher(Logger& baseLogger, Client* inClient, - String (*getUrlFxn)(String) = nullptr, - String (*getFileNameFxn)(void) = nullptr, - int sendEveryX = 1); + String (*getUrlFxn)(String) = nullptr, + String (*getFileNameFxn)() = nullptr, + int sendEveryX = 1); /** * @brief Destroy the S3 Publisher object */ @@ -204,7 +204,7 @@ class S3PresignedPublisher : public dataPublisher { void setPort(int port); // Returns the data destination - String getEndpoint(void) override { + String getEndpoint() override { return String(s3_parent_host); } @@ -252,7 +252,7 @@ class S3PresignedPublisher : public dataPublisher { * * @param getFileNameFxn A function to call to get a new filename */ - void setFileUpdateFunction(String (*getFileNameFxn)(void)); + void setFileUpdateFunction(String (*getFileNameFxn)()); /** * @brief Set the name of your certificate authority certificate file. @@ -353,7 +353,7 @@ class S3PresignedPublisher : public dataPublisher { /** * @brief Private reference to function used fetch a new file name. */ - String (*_getFileNameFxn)(void); + String (*_getFileNameFxn)(); /** * @brief The name of your certificate authority certificate file */ diff --git a/src/publishers/ThingSpeakPublisher.h b/src/publishers/ThingSpeakPublisher.h index 6daac7f32..64e9a2eb9 100644 --- a/src/publishers/ThingSpeakPublisher.h +++ b/src/publishers/ThingSpeakPublisher.h @@ -130,7 +130,7 @@ class ThingSpeakPublisher : public dataPublisher { virtual ~ThingSpeakPublisher() override = default; // Returns the data destination - String getEndpoint(void) override { + String getEndpoint() override { return String(mqttServer); } diff --git a/src/publishers/UbidotsPublisher.h b/src/publishers/UbidotsPublisher.h index e492e0f6a..6e8bafafa 100644 --- a/src/publishers/UbidotsPublisher.h +++ b/src/publishers/UbidotsPublisher.h @@ -119,7 +119,7 @@ class UbidotsPublisher : public dataPublisher { * * @return The URL or HOST to receive published data */ - String getEndpoint(void) override { + String getEndpoint() override { return String(ubidotsHost); } diff --git a/src/sensors/ANBpH.cpp b/src/sensors/ANBpH.cpp index 3ced87863..8b3342343 100644 --- a/src/sensors/ANBpH.cpp +++ b/src/sensors/ANBpH.cpp @@ -37,7 +37,7 @@ ANBpH::ANBpH(byte modbusAddress, Stream& stream, int8_t powerPin, // The sensor installation location on the Mayfly -String ANBpH::getSensorLocation(void) { +String ANBpH::getSensorLocation() { String sensorLocation = F("modbus_0x"); if (_modbusAddress < 16) sensorLocation += "0"; sensorLocation += String(_modbusAddress, HEX); @@ -45,7 +45,7 @@ String ANBpH::getSensorLocation(void) { } -bool ANBpH::setup(void) { +bool ANBpH::setup() { bool retVal = Sensor::setup(); // this will set pin modes and the setup // status bit if (_RS485EnablePin >= 0) { pinMode(_RS485EnablePin, OUTPUT); } @@ -227,7 +227,7 @@ bool ANBpH::setup(void) { } -bool ANBpH::wake(void) { +bool ANBpH::wake() { // Sensor::wake() checks if the power pin is on and sets the wake timestamp // and status bits. If it returns false, there's no reason to go on. if (!Sensor::wake()) return false; @@ -287,7 +287,7 @@ bool ANBpH::wake(void) { // The function to put the sensor to sleep // Different from the standard in that it stops measurements and empties and // flushes the stream. -bool ANBpH::sleep(void) { +bool ANBpH::sleep() { // empty then flush the buffer while (_stream->available()) { _stream->read(); } _stream->flush(); @@ -330,7 +330,7 @@ bool ANBpH::sleep(void) { return success; } -bool ANBpH::addSingleMeasurementResult(void) { +bool ANBpH::addSingleMeasurementResult() { // Immediately quit if the measurement was not successfully started if (!getStatusBit(MEASUREMENT_SUCCESSFUL)) { return bumpMeasurementAttemptCount(false); @@ -484,7 +484,7 @@ bool ANBpH::isWarmedUp(bool debug) { } } -uint32_t ANBpH::getStartMeasurementWindow(void) { +uint32_t ANBpH::getStartMeasurementWindow() { if (_powerPin >= 0 && _retryAttemptsMade == 0) { if (_salinityMode == ANBSalinityMode::HIGH_SALINITY) { return ANB_PH_1ST_VALUE_HIGH_SALT; @@ -500,7 +500,7 @@ uint32_t ANBpH::getStartMeasurementWindow(void) { // the maximum wait time for the second measurement as our maximum wait. // If a pin was provided for power, we assume it's on-demand powered and use // the maximum wait time for the first measurement as our maximum wait. -uint32_t ANBpH::getEndMeasurementWindow(void) { +uint32_t ANBpH::getEndMeasurementWindow() { if (_powerPin >= 0 && _retryAttemptsMade == 0) { if (_salinityMode == ANBSalinityMode::HIGH_SALINITY) { return ANB_PH_1ST_VALUE_HIGH_SALT_MAX; diff --git a/src/sensors/ANBpH.h b/src/sensors/ANBpH.h index d16f5d978..55966ea86 100644 --- a/src/sensors/ANBpH.h +++ b/src/sensors/ANBpH.h @@ -540,7 +540,7 @@ class ANBpH : public Sensor { */ virtual ~ANBpH() override = default; - String getSensorLocation(void) override; + String getSensorLocation() override; /** * @brief Do any one-time preparations needed before the sensor will be able @@ -553,7 +553,7 @@ class ANBpH : public Sensor { * * @return True if the setup was successful. */ - bool setup(void) override; + bool setup() override; /** * @brief Confirms that the sensor is giving a valid status code in response * to modbus commands, re-sets the RTC, and starts measurements. @@ -566,10 +566,10 @@ class ANBpH : public Sensor { * * @return True if the sensor started scanning. */ - bool wake(void) override; - bool sleep(void) override; + bool wake() override; + bool sleep() override; - bool addSingleMeasurementResult(void) override; + bool addSingleMeasurementResult() override; /** * @copydoc Sensor::isWarmedUp(bool debug) @@ -688,14 +688,14 @@ class ANBpH : public Sensor { * @return The start of the estimated time window for a measurement to * complete. */ - uint32_t getStartMeasurementWindow(void); + uint32_t getStartMeasurementWindow(); /** * @brief Get the end of the estimated time window for a measurement to * complete based on the sensor's current configuration. * @return The end of the estimated time window for a measurement to * complete. */ - uint32_t getEndMeasurementWindow(void); + uint32_t getEndMeasurementWindow(); /** * @brief Set the sensor's real time clock (RTC) to the current time. * @@ -707,7 +707,7 @@ class ANBpH : public Sensor { * * @return True if the RTC was successfully set, false if not. */ - bool setSensorRTC(void); + bool setSensorRTC(); }; diff --git a/src/sensors/AOSongAM2315.cpp b/src/sensors/AOSongAM2315.cpp index 77a93425c..c1d378399 100644 --- a/src/sensors/AOSongAM2315.cpp +++ b/src/sensors/AOSongAM2315.cpp @@ -31,12 +31,12 @@ AOSongAM2315::~AOSongAM2315() { } -String AOSongAM2315::getSensorLocation(void) { +String AOSongAM2315::getSensorLocation() { return F("I2C_0xB8"); } -bool AOSongAM2315::setup(void) { +bool AOSongAM2315::setup() { _i2c->begin(); // Start the wire library (sensor power not required) // Eliminate any potential extra waits in the wire library // These waits would be caused by a readBytes or parseX being called @@ -50,7 +50,7 @@ bool AOSongAM2315::setup(void) { } -bool AOSongAM2315::addSingleMeasurementResult(void) { +bool AOSongAM2315::addSingleMeasurementResult() { // Immediately quit if the measurement was not successfully started if (!getStatusBit(MEASUREMENT_SUCCESSFUL)) { return bumpMeasurementAttemptCount(false); diff --git a/src/sensors/AOSongAM2315.h b/src/sensors/AOSongAM2315.h index 5af4c40dc..3e9d1767f 100644 --- a/src/sensors/AOSongAM2315.h +++ b/src/sensors/AOSongAM2315.h @@ -231,7 +231,7 @@ class AOSongAM2315 : public Sensor { * * @return Text describing how the sensor is attached to the mcu. */ - String getSensorLocation(void) override; + String getSensorLocation() override; /** * @brief Do any one-time preparations needed before the sensor will be able @@ -244,9 +244,9 @@ class AOSongAM2315 : public Sensor { * @return True if the setup was successful. For the AOSong AM2315 * the result will always be true. */ - bool setup(void) override; + bool setup() override; - bool addSingleMeasurementResult(void) override; + bool addSingleMeasurementResult() override; private: /** diff --git a/src/sensors/AOSongDHT.cpp b/src/sensors/AOSongDHT.cpp index d968322f6..ccda78537 100644 --- a/src/sensors/AOSongDHT.cpp +++ b/src/sensors/AOSongDHT.cpp @@ -23,14 +23,14 @@ AOSongDHT::AOSongDHT(int8_t powerPin, int8_t dataPin, const uint8_t type, } -bool AOSongDHT::setup(void) { +bool AOSongDHT::setup() { dht_internal.begin(); // Start up the sensor (only sets pin modes, sensor // power not required) return Sensor::setup(); // this will set pin modes and the setup status bit } -String AOSongDHT::getSensorName(void) { +String AOSongDHT::getSensorName() { switch (_dhtType) { case 11: return "AOSongDHT11"; case 12: return "AOSongDHT12"; @@ -40,7 +40,7 @@ String AOSongDHT::getSensorName(void) { } -bool AOSongDHT::addSingleMeasurementResult(void) { +bool AOSongDHT::addSingleMeasurementResult() { // Immediately quit if the measurement was not successfully started if (!getStatusBit(MEASUREMENT_SUCCESSFUL)) { return bumpMeasurementAttemptCount(false); diff --git a/src/sensors/AOSongDHT.h b/src/sensors/AOSongDHT.h index 2147ba795..8f434f016 100644 --- a/src/sensors/AOSongDHT.h +++ b/src/sensors/AOSongDHT.h @@ -271,11 +271,11 @@ class AOSongDHT : public Sensor { */ ~AOSongDHT() override = default; - bool setup(void) override; + bool setup() override; - String getSensorName(void) override; + String getSensorName() override; - bool addSingleMeasurementResult(void) override; + bool addSingleMeasurementResult() override; private: DHT dht_internal; ///< Internal reference to the Adafruit DHT object diff --git a/src/sensors/AlphasenseCO2.cpp b/src/sensors/AlphasenseCO2.cpp index 991f2c4a6..5ad38ba8a 100644 --- a/src/sensors/AlphasenseCO2.cpp +++ b/src/sensors/AlphasenseCO2.cpp @@ -43,7 +43,7 @@ AlphasenseCO2::~AlphasenseCO2() { } -String AlphasenseCO2::getSensorLocation(void) { +String AlphasenseCO2::getSensorLocation() { if (_analogVoltageReader != nullptr) { return _analogVoltageReader->getAnalogLocation(_dataPin, _analogReferenceChannel); @@ -53,7 +53,7 @@ String AlphasenseCO2::getSensorLocation(void) { } -bool AlphasenseCO2::setup(void) { +bool AlphasenseCO2::setup() { bool sensorSetupSuccess = Sensor::setup(); bool analogVoltageReaderSuccess = false; @@ -72,7 +72,7 @@ bool AlphasenseCO2::setup(void) { } -bool AlphasenseCO2::addSingleMeasurementResult(void) { +bool AlphasenseCO2::addSingleMeasurementResult() { // Immediately quit if the measurement was not successfully started if (!getStatusBit(MEASUREMENT_SUCCESSFUL)) { return bumpMeasurementAttemptCount(false); diff --git a/src/sensors/AlphasenseCO2.h b/src/sensors/AlphasenseCO2.h index 1e5725230..df8caae55 100644 --- a/src/sensors/AlphasenseCO2.h +++ b/src/sensors/AlphasenseCO2.h @@ -312,11 +312,11 @@ class AlphasenseCO2 : public Sensor { AlphasenseCO2(AlphasenseCO2&&) = delete; AlphasenseCO2& operator=(AlphasenseCO2&&) = delete; - String getSensorLocation(void) override; + String getSensorLocation() override; - bool setup(void) override; + bool setup() override; - bool addSingleMeasurementResult(void) override; + bool addSingleMeasurementResult() override; private: diff --git a/src/sensors/AnalogElecConductivity.cpp b/src/sensors/AnalogElecConductivity.cpp index cb058d7df..08ae85d1a 100644 --- a/src/sensors/AnalogElecConductivity.cpp +++ b/src/sensors/AnalogElecConductivity.cpp @@ -39,7 +39,7 @@ AnalogElecConductivity::~AnalogElecConductivity() { } -String AnalogElecConductivity::getSensorLocation(void) { +String AnalogElecConductivity::getSensorLocation() { String sensorLocation; if (_analogVoltageReader != nullptr) { sensorLocation = _analogVoltageReader->getAnalogLocation(_dataPin, -1); @@ -52,7 +52,7 @@ String AnalogElecConductivity::getSensorLocation(void) { } -bool AnalogElecConductivity::setup(void) { +bool AnalogElecConductivity::setup() { bool sensorSetupSuccess = Sensor::setup(); bool analogVoltageReaderSuccess = false; @@ -71,7 +71,7 @@ bool AnalogElecConductivity::setup(void) { } -bool AnalogElecConductivity::addSingleMeasurementResult(void) { +bool AnalogElecConductivity::addSingleMeasurementResult() { // Immediately quit if the measurement was not successfully started if (!getStatusBit(MEASUREMENT_SUCCESSFUL)) { return bumpMeasurementAttemptCount(false); diff --git a/src/sensors/AnalogElecConductivity.h b/src/sensors/AnalogElecConductivity.h index 225a7667e..d973c5015 100644 --- a/src/sensors/AnalogElecConductivity.h +++ b/src/sensors/AnalogElecConductivity.h @@ -350,11 +350,11 @@ class AnalogElecConductivity : public Sensor { * * @return Text describing how the sensor is attached to the mcu. */ - String getSensorLocation(void) override; + String getSensorLocation() override; - bool setup(void) override; + bool setup() override; - bool addSingleMeasurementResult(void) override; + bool addSingleMeasurementResult() override; /** * @brief Set EC constants for internal calculations. diff --git a/src/sensors/AnalogVoltageBase.h b/src/sensors/AnalogVoltageBase.h index 5b97e330b..d992f81d1 100644 --- a/src/sensors/AnalogVoltageBase.h +++ b/src/sensors/AnalogVoltageBase.h @@ -84,7 +84,7 @@ class AnalogVoltageBase { * * @return True if the initialization was successful, false otherwise */ - virtual bool begin(void) = 0; + virtual bool begin() = 0; /** * @brief Set the voltage multiplier for voltage divider calculations @@ -111,7 +111,7 @@ class AnalogVoltageBase { * * @return The current voltage multiplier */ - float getVoltageMultiplier(void) const { + float getVoltageMultiplier() const { return _voltageMultiplier; } @@ -138,7 +138,7 @@ class AnalogVoltageBase { * * @return The current supply voltage in volts */ - float getSupplyVoltage(void) const { + float getSupplyVoltage() const { return _supplyVoltage; } @@ -209,7 +209,7 @@ class AnalogVoltageBase { * * @return The analog resolution in volts per LSB */ - virtual float calculateAnalogResolutionVolts(void) = 0; + virtual float calculateAnalogResolutionVolts() = 0; protected: /** diff --git a/src/sensors/ApogeeSQ212.cpp b/src/sensors/ApogeeSQ212.cpp index d9e0f2719..79c4922e1 100644 --- a/src/sensors/ApogeeSQ212.cpp +++ b/src/sensors/ApogeeSQ212.cpp @@ -38,7 +38,7 @@ ApogeeSQ212::~ApogeeSQ212() { } -String ApogeeSQ212::getSensorLocation(void) { +String ApogeeSQ212::getSensorLocation() { if (_analogVoltageReader != nullptr) { return _analogVoltageReader->getAnalogLocation(_dataPin, -1); } else { @@ -47,7 +47,7 @@ String ApogeeSQ212::getSensorLocation(void) { } -bool ApogeeSQ212::setup(void) { +bool ApogeeSQ212::setup() { bool sensorSetupSuccess = Sensor::setup(); bool analogVoltageReaderSuccess = false; @@ -66,7 +66,7 @@ bool ApogeeSQ212::setup(void) { } -bool ApogeeSQ212::addSingleMeasurementResult(void) { +bool ApogeeSQ212::addSingleMeasurementResult() { // Immediately quit if the measurement was not successfully started if (!getStatusBit(MEASUREMENT_SUCCESSFUL)) { return bumpMeasurementAttemptCount(false); diff --git a/src/sensors/ApogeeSQ212.h b/src/sensors/ApogeeSQ212.h index 1563bb225..77f8434c2 100644 --- a/src/sensors/ApogeeSQ212.h +++ b/src/sensors/ApogeeSQ212.h @@ -291,11 +291,11 @@ class ApogeeSQ212 : public Sensor { ApogeeSQ212(ApogeeSQ212&&) = delete; ApogeeSQ212& operator=(ApogeeSQ212&&) = delete; - String getSensorLocation(void) override; + String getSensorLocation() override; - bool setup(void) override; + bool setup() override; - bool addSingleMeasurementResult(void) override; + bool addSingleMeasurementResult() override; private: /// @brief Pointer to analog voltage reader diff --git a/src/sensors/AtlasParent.cpp b/src/sensors/AtlasParent.cpp index 2de12b424..511c3f4a2 100644 --- a/src/sensors/AtlasParent.cpp +++ b/src/sensors/AtlasParent.cpp @@ -36,14 +36,14 @@ AtlasParent::AtlasParent(int8_t powerPin, uint8_t i2cAddressHex, stabilizationTime_ms, measurementTime_ms, incCalcValues) {} -String AtlasParent::getSensorLocation(void) { +String AtlasParent::getSensorLocation() { String address = F("I2C_0x"); address += String(_i2cAddressHex, HEX); return address; } -bool AtlasParent::setup(void) { +bool AtlasParent::setup() { _i2c->begin(); // Start the wire library (sensor power not required) // Eliminate any potential extra waits in the wire library // These waits would be caused by a readBytes or parseX being called @@ -59,7 +59,7 @@ bool AtlasParent::setup(void) { // The function to put the sensor to sleep // The Atlas sensors must be told to sleep -bool AtlasParent::sleep(void) { +bool AtlasParent::sleep() { if (!checkPowerOn()) { return true; } if (_millisSensorActivated == 0) { MS_DBG(getSensorNameAndLocation(), F("was not measuring!")); @@ -97,7 +97,7 @@ bool AtlasParent::sleep(void) { // To start a measurement we write the command "R" to the sensor // NOTE: documentation says to use a capital "R" but the examples provided // by Atlas use a lower case "r". -bool AtlasParent::startSingleMeasurement(void) { +bool AtlasParent::startSingleMeasurement() { // Sensor::startSingleMeasurement() checks that if it's awake/active and // sets the timestamp and status bits. If it returns false, there's no // reason to go on. @@ -132,7 +132,7 @@ bool AtlasParent::startSingleMeasurement(void) { } -bool AtlasParent::addSingleMeasurementResult(void) { +bool AtlasParent::addSingleMeasurementResult() { // Immediately quit if the measurement was not successfully started if (!getStatusBit(MEASUREMENT_SUCCESSFUL)) { return bumpMeasurementAttemptCount(false); diff --git a/src/sensors/AtlasParent.h b/src/sensors/AtlasParent.h index f50f3e73f..994996640 100644 --- a/src/sensors/AtlasParent.h +++ b/src/sensors/AtlasParent.h @@ -180,7 +180,7 @@ class AtlasParent : public Sensor { * * @return Text describing how the sensor is attached to the mcu. */ - String getSensorLocation(void) override; + String getSensorLocation() override; /** * @brief Do any one-time preparations needed before the sensor will be able @@ -192,12 +192,12 @@ class AtlasParent : public Sensor { * * @return True if the setup was successful. */ - bool setup(void) override; + bool setup() override; // NOTE: The sensor should wake as soon as any command is sent. // I assume that means we can use the command to take a reading to both // wake it and ask for a reading. - // bool wake(void) override; + // bool wake() override; /** * @brief Puts the sensor to sleep, if necessary. @@ -207,7 +207,7 @@ class AtlasParent : public Sensor { * * @return True if the sleep function completed successfully. */ - bool sleep(void) override; + bool sleep() override; /** * @brief Tell the sensor to start a single measurement, if needed. @@ -220,8 +220,8 @@ class AtlasParent : public Sensor { * @return True if the start measurement function completed * successfully. */ - bool startSingleMeasurement(void) override; - bool addSingleMeasurementResult(void) override; + bool startSingleMeasurement() override; + bool addSingleMeasurementResult() override; protected: /** diff --git a/src/sensors/AtlasScientificCO2.h b/src/sensors/AtlasScientificCO2.h index b6c019a2a..38bdc59d7 100644 --- a/src/sensors/AtlasScientificCO2.h +++ b/src/sensors/AtlasScientificCO2.h @@ -244,7 +244,7 @@ class AtlasScientificCO2 : public AtlasParent { * * @return True if the setup was successful. */ - bool setup(void) override; + bool setup() override; }; /* clang-format off */ diff --git a/src/sensors/AtlasScientificDO.h b/src/sensors/AtlasScientificDO.h index b95a3a2fe..56cd58630 100644 --- a/src/sensors/AtlasScientificDO.h +++ b/src/sensors/AtlasScientificDO.h @@ -253,7 +253,7 @@ class AtlasScientificDO : public AtlasParent { * * @return True if the setup was successful. */ - bool setup(void) override; + bool setup() override; }; /* clang-format off */ diff --git a/src/sensors/AtlasScientificEC.h b/src/sensors/AtlasScientificEC.h index 88268620f..44d1de34a 100644 --- a/src/sensors/AtlasScientificEC.h +++ b/src/sensors/AtlasScientificEC.h @@ -316,7 +316,7 @@ class AtlasScientificEC : public AtlasParent { * * @return True if the setup was successful. */ - bool setup(void) override; + bool setup() override; }; /* clang-format off */ diff --git a/src/sensors/BoschBME280.cpp b/src/sensors/BoschBME280.cpp index c8d7159e4..c36638c4d 100644 --- a/src/sensors/BoschBME280.cpp +++ b/src/sensors/BoschBME280.cpp @@ -26,14 +26,14 @@ BoschBME280::BoschBME280(int8_t powerPin, uint8_t i2cAddressHex, : BoschBME280(&Wire, powerPin, i2cAddressHex, measurementsToAverage) {} -String BoschBME280::getSensorLocation(void) { +String BoschBME280::getSensorLocation() { String address = F("I2C_0x"); address += String(_i2cAddressHex, HEX); return address; } -bool BoschBME280::setup(void) { +bool BoschBME280::setup() { bool retVal = Sensor::setup(); // this will set pin modes and the setup status bit @@ -67,7 +67,7 @@ bool BoschBME280::setup(void) { } -bool BoschBME280::wake(void) { +bool BoschBME280::wake() { // Sensor::wake() checks if the power pin is on and sets the wake timestamp // and status bits. If it returns false, there's no reason to go on. if (!Sensor::wake()) return false; @@ -108,7 +108,7 @@ bool BoschBME280::wake(void) { } -bool BoschBME280::addSingleMeasurementResult(void) { +bool BoschBME280::addSingleMeasurementResult() { // Immediately quit if the measurement was not successfully started if (!getStatusBit(MEASUREMENT_SUCCESSFUL)) { return bumpMeasurementAttemptCount(false); diff --git a/src/sensors/BoschBME280.h b/src/sensors/BoschBME280.h index 5f9e09202..38492ad8d 100644 --- a/src/sensors/BoschBME280.h +++ b/src/sensors/BoschBME280.h @@ -308,7 +308,7 @@ class BoschBME280 : public Sensor { */ ~BoschBME280() override = default; - bool wake(void) override; + bool wake() override; /** * @brief Do any one-time preparations needed before the sensor will be able * to take readings. @@ -319,12 +319,12 @@ class BoschBME280 : public Sensor { * * @return True if the setup was successful. */ - bool setup(void) override; + bool setup() override; - String getSensorLocation(void) override; + String getSensorLocation() override; - // bool startSingleMeasurement(void) override; // for forced mode - bool addSingleMeasurementResult(void) override; + // bool startSingleMeasurement() override; // for forced mode + bool addSingleMeasurementResult() override; private: /** diff --git a/src/sensors/BoschBMP3xx.cpp b/src/sensors/BoschBMP3xx.cpp index b923f8e80..00fcdd45a 100644 --- a/src/sensors/BoschBMP3xx.cpp +++ b/src/sensors/BoschBMP3xx.cpp @@ -27,14 +27,14 @@ BoschBMP3xx::BoschBMP3xx(int8_t powerPin, Mode mode, _i2cAddressHex(i2cAddressHex) {} -String BoschBMP3xx::getSensorLocation(void) { +String BoschBMP3xx::getSensorLocation() { String address = F("I2C_0x"); address += String(_i2cAddressHex, HEX); return address; } -bool BoschBMP3xx::setup(void) { +bool BoschBMP3xx::setup() { bool retVal = Sensor::setup(); // this will set pin modes and the setup status bit @@ -211,7 +211,7 @@ bool BoschBMP3xx::setup(void) { } -bool BoschBMP3xx::wake(void) { +bool BoschBMP3xx::wake() { // Sensor::wake() checks if the power pin is on and sets the wake timestamp // and status bits. If it returns false, there's no reason to go on. if (!Sensor::wake()) return false; @@ -257,7 +257,7 @@ bool BoschBMP3xx::wake(void) { } -bool BoschBMP3xx::startSingleMeasurement(void) { +bool BoschBMP3xx::startSingleMeasurement() { // Sensor::startSingleMeasurement() checks that if it's awake/active and // sets the timestamp and status bits. If it returns false, there's no // reason to go on. @@ -282,7 +282,7 @@ bool BoschBMP3xx::startSingleMeasurement(void) { } -bool BoschBMP3xx::addSingleMeasurementResult(void) { +bool BoschBMP3xx::addSingleMeasurementResult() { // Immediately quit if the measurement was not successfully started if (!getStatusBit(MEASUREMENT_SUCCESSFUL)) { return bumpMeasurementAttemptCount(false); diff --git a/src/sensors/BoschBMP3xx.h b/src/sensors/BoschBMP3xx.h index dabadb2ab..d4aecaa08 100644 --- a/src/sensors/BoschBMP3xx.h +++ b/src/sensors/BoschBMP3xx.h @@ -439,7 +439,7 @@ class BoschBMP3xx : public Sensor { */ ~BoschBMP3xx() override = default; - bool wake(void) override; + bool wake() override; /** * @brief Do any one-time preparations needed before the sensor will be able * to take readings. @@ -450,12 +450,12 @@ class BoschBMP3xx : public Sensor { * * @return True if the setup was successful. */ - bool setup(void) override; + bool setup() override; - String getSensorLocation(void) override; + String getSensorLocation() override; - bool startSingleMeasurement(void) override; - bool addSingleMeasurementResult(void) override; + bool startSingleMeasurement() override; + bool addSingleMeasurementResult() override; private: /** diff --git a/src/sensors/CampbellOBS3.cpp b/src/sensors/CampbellOBS3.cpp index b61013f67..5829ae3dd 100644 --- a/src/sensors/CampbellOBS3.cpp +++ b/src/sensors/CampbellOBS3.cpp @@ -39,7 +39,7 @@ CampbellOBS3::~CampbellOBS3() { } -String CampbellOBS3::getSensorLocation(void) { +String CampbellOBS3::getSensorLocation() { if (_analogVoltageReader != nullptr) { return _analogVoltageReader->getAnalogLocation(_dataPin, -1); } else { @@ -48,7 +48,7 @@ String CampbellOBS3::getSensorLocation(void) { } -bool CampbellOBS3::setup(void) { +bool CampbellOBS3::setup() { bool sensorSetupSuccess = Sensor::setup(); bool analogVoltageReaderSuccess = false; @@ -67,7 +67,7 @@ bool CampbellOBS3::setup(void) { } -bool CampbellOBS3::addSingleMeasurementResult(void) { +bool CampbellOBS3::addSingleMeasurementResult() { // Immediately quit if the measurement was not successfully started if (!getStatusBit(MEASUREMENT_SUCCESSFUL)) { return bumpMeasurementAttemptCount(false); diff --git a/src/sensors/CampbellOBS3.h b/src/sensors/CampbellOBS3.h index 170c5f88b..30317b0c2 100644 --- a/src/sensors/CampbellOBS3.h +++ b/src/sensors/CampbellOBS3.h @@ -288,11 +288,11 @@ class CampbellOBS3 : public Sensor { CampbellOBS3(CampbellOBS3&&) = delete; CampbellOBS3& operator=(CampbellOBS3&&) = delete; - String getSensorLocation(void) override; + String getSensorLocation() override; - bool setup(void) override; + bool setup() override; - bool addSingleMeasurementResult(void) override; + bool addSingleMeasurementResult() override; private: /// @brief The x^2 (A) calibration coefficient diff --git a/src/sensors/EverlightALSPT19.cpp b/src/sensors/EverlightALSPT19.cpp index 4fd3fe23e..432ce7eb4 100644 --- a/src/sensors/EverlightALSPT19.cpp +++ b/src/sensors/EverlightALSPT19.cpp @@ -50,7 +50,7 @@ EverlightALSPT19::~EverlightALSPT19() { } -String EverlightALSPT19::getSensorLocation(void) { +String EverlightALSPT19::getSensorLocation() { if (_analogVoltageReader != nullptr) { return _analogVoltageReader->getAnalogLocation(_dataPin, -1); } else { @@ -59,7 +59,7 @@ String EverlightALSPT19::getSensorLocation(void) { } -bool EverlightALSPT19::setup(void) { +bool EverlightALSPT19::setup() { bool sensorSetupSuccess = Sensor::setup(); bool analogVoltageReaderSuccess = false; @@ -78,7 +78,7 @@ bool EverlightALSPT19::setup(void) { } -bool EverlightALSPT19::addSingleMeasurementResult(void) { +bool EverlightALSPT19::addSingleMeasurementResult() { // Immediately quit if the measurement was not successfully started if (!getStatusBit(MEASUREMENT_SUCCESSFUL)) { return bumpMeasurementAttemptCount(false); diff --git a/src/sensors/EverlightALSPT19.h b/src/sensors/EverlightALSPT19.h index 61c714e8b..3e5a5ffc4 100644 --- a/src/sensors/EverlightALSPT19.h +++ b/src/sensors/EverlightALSPT19.h @@ -312,11 +312,11 @@ class EverlightALSPT19 : public Sensor { EverlightALSPT19(EverlightALSPT19&&) = delete; EverlightALSPT19& operator=(EverlightALSPT19&&) = delete; - String getSensorLocation(void) override; + String getSensorLocation() override; - bool setup(void) override; + bool setup() override; - bool addSingleMeasurementResult(void) override; + bool addSingleMeasurementResult() override; private: /// @brief The PT-19 power supply voltage diff --git a/src/sensors/FreescaleMPL115A2.cpp b/src/sensors/FreescaleMPL115A2.cpp index f98d87cf0..d340120af 100644 --- a/src/sensors/FreescaleMPL115A2.cpp +++ b/src/sensors/FreescaleMPL115A2.cpp @@ -27,12 +27,12 @@ FreescaleMPL115A2::FreescaleMPL115A2(int8_t powerPin, : FreescaleMPL115A2(&Wire, powerPin, measurementsToAverage) {} -String FreescaleMPL115A2::getSensorLocation(void) { +String FreescaleMPL115A2::getSensorLocation() { return F("I2C_0x60"); } -bool FreescaleMPL115A2::setup(void) { +bool FreescaleMPL115A2::setup() { bool retVal = Sensor::setup(); // this will set pin modes and the setup status bit @@ -55,7 +55,7 @@ bool FreescaleMPL115A2::setup(void) { } -bool FreescaleMPL115A2::addSingleMeasurementResult(void) { +bool FreescaleMPL115A2::addSingleMeasurementResult() { // Immediately quit if the measurement was not successfully started if (!getStatusBit(MEASUREMENT_SUCCESSFUL)) { return bumpMeasurementAttemptCount(false); diff --git a/src/sensors/FreescaleMPL115A2.h b/src/sensors/FreescaleMPL115A2.h index 0934a1720..2601ac228 100644 --- a/src/sensors/FreescaleMPL115A2.h +++ b/src/sensors/FreescaleMPL115A2.h @@ -233,11 +233,11 @@ class FreescaleMPL115A2 : public Sensor { * * @return True if the setup was successful. */ - bool setup(void) override; + bool setup() override; - String getSensorLocation(void) override; + String getSensorLocation() override; - bool addSingleMeasurementResult(void) override; + bool addSingleMeasurementResult() override; private: /** diff --git a/src/sensors/GeoluxHydroCam.cpp b/src/sensors/GeoluxHydroCam.cpp index 5096f5161..46d505476 100644 --- a/src/sensors/GeoluxHydroCam.cpp +++ b/src/sensors/GeoluxHydroCam.cpp @@ -50,12 +50,12 @@ String GeoluxHydroCam::getLastSavedImageName() { } -String GeoluxHydroCam::getSensorLocation(void) { +String GeoluxHydroCam::getSensorLocation() { return F("cameraSerial"); } -bool GeoluxHydroCam::setup(void) { +bool GeoluxHydroCam::setup() { MS_DEEP_DBG(F("Setting up Geolux HydroCam sensor...")); bool success = Sensor::setup(); // this will set pin modes and the setup status bit @@ -112,7 +112,7 @@ bool GeoluxHydroCam::setup(void) { } -bool GeoluxHydroCam::wake(void) { +bool GeoluxHydroCam::wake() { // Sensor::wake() checks if the power pin is on and sets the wake timestamp // and status bits. If it returns false, there's no reason to go on. if (!Sensor::wake()) return false; @@ -135,14 +135,14 @@ bool GeoluxHydroCam::wake(void) { // The function to put the sensor to sleep // Different from the standard in that empties and flushes the stream. -bool GeoluxHydroCam::sleep(void) { +bool GeoluxHydroCam::sleep() { // empty then flush the buffer while (_stream->available()) { _stream->read(); } _stream->flush(); return Sensor::sleep(); }; -bool GeoluxHydroCam::startSingleMeasurement(void) { +bool GeoluxHydroCam::startSingleMeasurement() { // Sensor::startSingleMeasurement() checks that if it's awake/active and // sets the timestamp and status bits. If it returns false, there's no // reason to go on. @@ -184,7 +184,7 @@ bool GeoluxHydroCam::startSingleMeasurement(void) { } -bool GeoluxHydroCam::addSingleMeasurementResult(void) { +bool GeoluxHydroCam::addSingleMeasurementResult() { // Immediately quit if the measurement was not successfully started if (!getStatusBit(MEASUREMENT_SUCCESSFUL)) { return bumpMeasurementAttemptCount(false); diff --git a/src/sensors/GeoluxHydroCam.h b/src/sensors/GeoluxHydroCam.h index 37a973dd9..7b3c2e0f9 100644 --- a/src/sensors/GeoluxHydroCam.h +++ b/src/sensors/GeoluxHydroCam.h @@ -292,7 +292,7 @@ class GeoluxHydroCam : public Sensor { */ String getLastSavedImageName(); - String getSensorLocation(void) override; + String getSensorLocation() override; /** * @brief Do any one-time preparations needed before the sensor will be able @@ -306,7 +306,7 @@ class GeoluxHydroCam : public Sensor { * * @return True if the setup was successful. */ - bool setup(void) override; + bool setup() override; /** * @brief Wake the sensor up, if necessary. Do whatever it takes to get a * sensor in the proper state to begin a measurement. @@ -320,11 +320,11 @@ class GeoluxHydroCam : public Sensor { * * @return True if the wake function completed successfully. */ - bool wake(void) override; - bool sleep(void) override; + bool wake() override; + bool sleep() override; - bool startSingleMeasurement(void) override; - bool addSingleMeasurementResult(void) override; + bool startSingleMeasurement() override; + bool addSingleMeasurementResult() override; /** * @copydoc Sensor::isWarmedUp(bool debug) diff --git a/src/sensors/GroPointParent.cpp b/src/sensors/GroPointParent.cpp index e3ebdd753..5e68a1f5c 100644 --- a/src/sensors/GroPointParent.cpp +++ b/src/sensors/GroPointParent.cpp @@ -45,7 +45,7 @@ GroPointParent::GroPointParent(byte modbusAddress, Stream& stream, // The sensor installation location on the Mayfly -String GroPointParent::getSensorLocation(void) { +String GroPointParent::getSensorLocation() { String sensorLocation = F("modbus_0x"); if (_modbusAddress < 16) sensorLocation += "0"; sensorLocation += String(_modbusAddress, HEX); @@ -53,7 +53,7 @@ String GroPointParent::getSensorLocation(void) { } -bool GroPointParent::setup(void) { +bool GroPointParent::setup() { bool retVal = Sensor::setup(); // this will set pin modes and the setup status bit if (_RS485EnablePin >= 0) { pinMode(_RS485EnablePin, OUTPUT); } @@ -73,7 +73,7 @@ bool GroPointParent::setup(void) { // The function to wake up a sensor // Different from the standard in that it waits for warm up and starts // measurements -bool GroPointParent::wake(void) { +bool GroPointParent::wake() { // Sensor::wake() checks if the power pin is on and sets the wake timestamp // and status bits. If it returns false, there's no reason to go on. if (!Sensor::wake()) return false; @@ -112,7 +112,7 @@ bool GroPointParent::wake(void) { // The function to put the sensor to sleep // Different from the standard in that it stops measurements and empties and // flushes the stream. -bool GroPointParent::sleep(void) { +bool GroPointParent::sleep() { // empty then flush the buffer while (_stream->available()) { _stream->read(); } _stream->flush(); @@ -156,7 +156,7 @@ bool GroPointParent::sleep(void) { } -bool GroPointParent::addSingleMeasurementResult(void) { +bool GroPointParent::addSingleMeasurementResult() { // Immediately quit if the measurement was not successfully started if (!getStatusBit(MEASUREMENT_SUCCESSFUL)) { return bumpMeasurementAttemptCount(false); diff --git a/src/sensors/GroPointParent.h b/src/sensors/GroPointParent.h index d5ec5ee7c..490f92bf4 100644 --- a/src/sensors/GroPointParent.h +++ b/src/sensors/GroPointParent.h @@ -153,7 +153,7 @@ class GroPointParent : public Sensor { */ virtual ~GroPointParent() override = default; - String getSensorLocation(void) override; + String getSensorLocation() override; /** * @brief Do any one-time preparations needed before the sensor will be able @@ -166,9 +166,9 @@ class GroPointParent : public Sensor { * * @return True if the setup was successful. */ - bool setup(void) override; + bool setup() override; - bool wake(void) override; + bool wake() override; /** * @brief Puts the sensor to sleep, if necessary. * @@ -177,9 +177,9 @@ class GroPointParent : public Sensor { * * @return True if the sleep function completed successfully. */ - bool sleep(void) override; + bool sleep() override; - bool addSingleMeasurementResult(void) override; + bool addSingleMeasurementResult() override; private: /** diff --git a/src/sensors/KellerParent.cpp b/src/sensors/KellerParent.cpp index 0730c4a7e..ab9d7062b 100644 --- a/src/sensors/KellerParent.cpp +++ b/src/sensors/KellerParent.cpp @@ -43,7 +43,7 @@ KellerParent::KellerParent(byte modbusAddress, Stream& stream, int8_t powerPin, // The sensor installation location on the Mayfly -String KellerParent::getSensorLocation(void) { +String KellerParent::getSensorLocation() { String sensorLocation = F("modbus_0x"); if (_modbusAddress < 16) sensorLocation += "0"; sensorLocation += String(_modbusAddress, HEX); @@ -51,7 +51,7 @@ String KellerParent::getSensorLocation(void) { } -bool KellerParent::setup(void) { +bool KellerParent::setup() { bool retVal = Sensor::setup(); // this will set pin modes and the setup status bit if (_RS485EnablePin >= 0) { pinMode(_RS485EnablePin, OUTPUT); } @@ -71,7 +71,7 @@ bool KellerParent::setup(void) { // The function to put the sensor to sleep // Different from the standard in that empties and flushes the stream. -bool KellerParent::sleep(void) { +bool KellerParent::sleep() { // empty then flush the buffer while (_stream->available()) { _stream->read(); } _stream->flush(); @@ -79,7 +79,7 @@ bool KellerParent::sleep(void) { }; -bool KellerParent::addSingleMeasurementResult(void) { +bool KellerParent::addSingleMeasurementResult() { // Immediately quit if the measurement was not successfully started if (!getStatusBit(MEASUREMENT_SUCCESSFUL)) { return bumpMeasurementAttemptCount(false); diff --git a/src/sensors/KellerParent.h b/src/sensors/KellerParent.h index fa8333c5f..dd44e2860 100644 --- a/src/sensors/KellerParent.h +++ b/src/sensors/KellerParent.h @@ -233,7 +233,7 @@ class KellerParent : public Sensor { */ virtual ~KellerParent() override = default; - String getSensorLocation(void) override; + String getSensorLocation() override; /** * @brief Do any one-time preparations needed before the sensor will be able @@ -246,12 +246,12 @@ class KellerParent : public Sensor { * * @return True if the setup was successful. */ - bool setup(void) override; + bool setup() override; // override to empty and flush the stream - bool sleep(void) override; + bool sleep() override; - bool addSingleMeasurementResult(void) override; + bool addSingleMeasurementResult() override; private: /** diff --git a/src/sensors/MaxBotixSonar.cpp b/src/sensors/MaxBotixSonar.cpp index 7bef7a628..6e62d364c 100644 --- a/src/sensors/MaxBotixSonar.cpp +++ b/src/sensors/MaxBotixSonar.cpp @@ -31,14 +31,14 @@ MaxBotixSonar::MaxBotixSonar(Stream& stream, int8_t powerPin, int8_t triggerPin, // unfortunately, we really cannot know where the stream is attached. -String MaxBotixSonar::getSensorLocation(void) { +String MaxBotixSonar::getSensorLocation() { // attach the trigger pin to the stream number String loc = "sonarStream_trigger" + String(_triggerPin); return loc; } -bool MaxBotixSonar::setup(void) { +bool MaxBotixSonar::setup() { // Set up the trigger, if applicable if (_triggerPin >= 0) { pinMode(_triggerPin, OUTPUT); @@ -54,7 +54,7 @@ bool MaxBotixSonar::setup(void) { // Parsing and tossing the header lines in the wake-up -bool MaxBotixSonar::wake(void) { +bool MaxBotixSonar::wake() { // Sensor::wake() checks if the power pin is on and sets the wake timestamp // and status bits. If it returns false, there's no reason to go on. if (!Sensor::wake()) return false; @@ -106,7 +106,7 @@ bool MaxBotixSonar::wake(void) { // The function to put the sensor to sleep // Different from the standard in that empties and flushes the stream. -bool MaxBotixSonar::sleep(void) { +bool MaxBotixSonar::sleep() { // empty then flush the buffer while (_stream->available()) { _stream->read(); } _stream->flush(); @@ -114,7 +114,7 @@ bool MaxBotixSonar::sleep(void) { }; -bool MaxBotixSonar::addSingleMeasurementResult(void) { +bool MaxBotixSonar::addSingleMeasurementResult() { // Immediately quit if the measurement was not successfully started if (!getStatusBit(MEASUREMENT_SUCCESSFUL)) { return bumpMeasurementAttemptCount(false); diff --git a/src/sensors/MaxBotixSonar.h b/src/sensors/MaxBotixSonar.h index 944e922ea..539f5f712 100644 --- a/src/sensors/MaxBotixSonar.h +++ b/src/sensors/MaxBotixSonar.h @@ -224,7 +224,7 @@ class MaxBotixSonar : public Sensor { */ ~MaxBotixSonar() override = default; - String getSensorLocation(void) override; + String getSensorLocation() override; /** * @brief Do any one-time preparations needed before the sensor will be able @@ -236,7 +236,7 @@ class MaxBotixSonar : public Sensor { * * @return True if the setup was successful. */ - bool setup(void) override; + bool setup() override; /** * @brief Wake the sensor up, if necessary. Do whatever it takes to get a * sensor in the proper state to begin a measurement. @@ -251,11 +251,11 @@ class MaxBotixSonar : public Sensor { * * @return True if the wake function completed successfully. */ - bool wake(void) override; + bool wake() override; // override to empty and flush the stream - bool sleep(void) override; + bool sleep() override; - bool addSingleMeasurementResult(void) override; + bool addSingleMeasurementResult() override; private: int16_t _maxRange; ///< The maximum range of the Maxbotix sonar diff --git a/src/sensors/MaximDS18.cpp b/src/sensors/MaximDS18.cpp index 411d48feb..be8c2a6b5 100644 --- a/src/sensors/MaximDS18.cpp +++ b/src/sensors/MaximDS18.cpp @@ -54,14 +54,14 @@ String MaximDS18::makeAddressString(DeviceAddress owAddr) { // This gets the place the sensor is installed ON THE MAYFLY (ie, pin number) -String MaximDS18::getSensorLocation(void) { +String MaximDS18::getSensorLocation() { return makeAddressString(_OneWireAddress); } // The function to set up connection to a sensor. // By default, sets pin modes and returns ready -bool MaximDS18::setup(void) { +bool MaximDS18::setup() { uint8_t ntries = 0; bool retVal = @@ -149,7 +149,7 @@ bool MaximDS18::setup(void) { // Sending the device a request to start temp conversion. // Because we put ourselves in ASYNC mode in setup, we don't have to wait for // finish -bool MaximDS18::startSingleMeasurement(void) { +bool MaximDS18::startSingleMeasurement() { // Sensor::startSingleMeasurement() checks that if it's awake/active and // sets the timestamp and status bits. If it returns false, there's no // reason to go on. @@ -178,7 +178,7 @@ bool MaximDS18::startSingleMeasurement(void) { } -bool MaximDS18::addSingleMeasurementResult(void) { +bool MaximDS18::addSingleMeasurementResult() { // Immediately quit if the measurement was not successfully started if (!getStatusBit(MEASUREMENT_SUCCESSFUL)) { return bumpMeasurementAttemptCount(false); diff --git a/src/sensors/MaximDS18.h b/src/sensors/MaximDS18.h index e200a0e58..4c028344a 100644 --- a/src/sensors/MaximDS18.h +++ b/src/sensors/MaximDS18.h @@ -238,9 +238,9 @@ class MaximDS18 : public Sensor { * * @return True if the setup was successful. */ - bool setup(void) override; + bool setup() override; - String getSensorLocation(void) override; + String getSensorLocation() override; /** * @brief Tell the sensor to start a single measurement, if needed. @@ -253,8 +253,8 @@ class MaximDS18 : public Sensor { * @return True if the start measurement function completed * successfully. successfully. */ - bool startSingleMeasurement(void) override; - bool addSingleMeasurementResult(void) override; + bool startSingleMeasurement() override; + bool addSingleMeasurementResult() override; private: /** diff --git a/src/sensors/MaximDS3231.cpp b/src/sensors/MaximDS3231.cpp index bba9a608b..0aad4f4a1 100644 --- a/src/sensors/MaximDS3231.cpp +++ b/src/sensors/MaximDS3231.cpp @@ -18,12 +18,12 @@ MaximDS3231::MaximDS3231(uint8_t measurementsToAverage) measurementsToAverage, DS3231_INC_CALC_VARIABLES) {} -String MaximDS3231::getSensorLocation(void) { +String MaximDS3231::getSensorLocation() { return F("I2C_0x68"); } -bool MaximDS3231::setup(void) { +bool MaximDS3231::setup() { rtc.begin(); // NOTE: This also turns off interrupts on the RTC! return Sensor::setup(); // this will set pin modes and the setup status bit // The clock should be continuously powered, so we never need to worry about @@ -32,7 +32,7 @@ bool MaximDS3231::setup(void) { // Sending the device a request to start temp conversion. -bool MaximDS3231::startSingleMeasurement(void) { +bool MaximDS3231::startSingleMeasurement() { // Sensor::startSingleMeasurement() checks that if it's awake/active and // sets the timestamp and status bits. If it returns false, there's no // reason to go on. @@ -53,7 +53,7 @@ bool MaximDS3231::startSingleMeasurement(void) { } -bool MaximDS3231::addSingleMeasurementResult(void) { +bool MaximDS3231::addSingleMeasurementResult() { // NOTE: If this fails we have much bigger problems than just a lost // temperature value. That is, if I2C communication with the clock fails, // the system is too broken to even ask for this temperature. diff --git a/src/sensors/MaximDS3231.h b/src/sensors/MaximDS3231.h index ee8270af1..5c993beb3 100644 --- a/src/sensors/MaximDS3231.h +++ b/src/sensors/MaximDS3231.h @@ -168,7 +168,7 @@ class MaximDS3231 : public Sensor { */ ~MaximDS3231() override = default; - String getSensorLocation(void) override; + String getSensorLocation() override; /** * @brief Do any one-time preparations needed before the sensor will be able @@ -181,7 +181,7 @@ class MaximDS3231 : public Sensor { * * @return True if the setup was successful. */ - bool setup(void) override; + bool setup() override; /** * @brief Tell the sensor to start a single measurement, if needed. @@ -194,8 +194,8 @@ class MaximDS3231 : public Sensor { * @return True if the start measurement function completed * successfully. successfully. */ - bool startSingleMeasurement(void) override; - bool addSingleMeasurementResult(void) override; + bool startSingleMeasurement() override; + bool addSingleMeasurementResult() override; }; diff --git a/src/sensors/MeaSpecMS5803.cpp b/src/sensors/MeaSpecMS5803.cpp index de878f9fe..2b3866845 100644 --- a/src/sensors/MeaSpecMS5803.cpp +++ b/src/sensors/MeaSpecMS5803.cpp @@ -23,14 +23,14 @@ MeaSpecMS5803::MeaSpecMS5803(int8_t powerPin, uint8_t i2cAddressHex, _maxPressure(maxPressure) {} -String MeaSpecMS5803::getSensorLocation(void) { +String MeaSpecMS5803::getSensorLocation() { String address = F("I2C_0x"); address += String(_i2cAddressHex, HEX); return address; } -bool MeaSpecMS5803::setup(void) { +bool MeaSpecMS5803::setup() { bool retVal = Sensor::setup(); // this will set pin modes and the setup status bit @@ -52,7 +52,7 @@ bool MeaSpecMS5803::setup(void) { } -bool MeaSpecMS5803::addSingleMeasurementResult(void) { +bool MeaSpecMS5803::addSingleMeasurementResult() { // Immediately quit if the measurement was not successfully started if (!getStatusBit(MEASUREMENT_SUCCESSFUL)) { return bumpMeasurementAttemptCount(false); diff --git a/src/sensors/MeaSpecMS5803.h b/src/sensors/MeaSpecMS5803.h index 10d4a6a55..30b159255 100644 --- a/src/sensors/MeaSpecMS5803.h +++ b/src/sensors/MeaSpecMS5803.h @@ -249,11 +249,11 @@ class MeaSpecMS5803 : public Sensor { * * @return True if the setup was successful. */ - bool setup(void) override; + bool setup() override; - String getSensorLocation(void) override; + String getSensorLocation() override; - bool addSingleMeasurementResult(void) override; + bool addSingleMeasurementResult() override; private: /** diff --git a/src/sensors/PaleoTerraRedox.cpp b/src/sensors/PaleoTerraRedox.cpp index ad5b9f06a..4d9a1ced2 100644 --- a/src/sensors/PaleoTerraRedox.cpp +++ b/src/sensors/PaleoTerraRedox.cpp @@ -68,7 +68,7 @@ PaleoTerraRedox::~PaleoTerraRedox() {} #endif -String PaleoTerraRedox::getSensorLocation(void) { +String PaleoTerraRedox::getSensorLocation() { #if defined(MS_PALEOTERRA_SOFTWAREWIRE) String address = F("SoftwareWire"); if (_dataPin >= 0) address += _dataPin; @@ -81,7 +81,7 @@ String PaleoTerraRedox::getSensorLocation(void) { } -bool PaleoTerraRedox::setup(void) { +bool PaleoTerraRedox::setup() { _i2c->begin(); // Start the wire library (sensor power not required) // Eliminate any potential extra waits in the wire library // These waits would be caused by a readBytes or parseX being called @@ -96,7 +96,7 @@ bool PaleoTerraRedox::setup(void) { } -bool PaleoTerraRedox::addSingleMeasurementResult(void) { +bool PaleoTerraRedox::addSingleMeasurementResult() { // Immediately quit if the measurement was not successfully started if (!getStatusBit(MEASUREMENT_SUCCESSFUL)) { return bumpMeasurementAttemptCount(false); diff --git a/src/sensors/PaleoTerraRedox.h b/src/sensors/PaleoTerraRedox.h index ebb7ac7c5..07315302d 100644 --- a/src/sensors/PaleoTerraRedox.h +++ b/src/sensors/PaleoTerraRedox.h @@ -268,11 +268,11 @@ class PaleoTerraRedox : public Sensor { * * @return True if the setup was successful. */ - bool setup(void) override; + bool setup() override; - String getSensorLocation(void) override; + String getSensorLocation() override; - bool addSingleMeasurementResult(void) override; + bool addSingleMeasurementResult() override; private: /** diff --git a/src/sensors/ProcessorAnalog.cpp b/src/sensors/ProcessorAnalog.cpp index 4665e5dc6..8978ac0b2 100644 --- a/src/sensors/ProcessorAnalog.cpp +++ b/src/sensors/ProcessorAnalog.cpp @@ -25,7 +25,7 @@ ProcessorAnalogBase::ProcessorAnalogBase(float voltageMultiplier, // ProcessorAnalogBase Functions // ============================================================================ -bool ProcessorAnalogBase::begin(void) { +bool ProcessorAnalogBase::begin() { // For processor analog systems, no special initialization is required // beyond what is done in the constructor return true; @@ -87,7 +87,7 @@ bool ProcessorAnalogBase::readVoltageDifferential( return false; } -float ProcessorAnalogBase::calculateAnalogResolutionVolts(void) { +float ProcessorAnalogBase::calculateAnalogResolutionVolts() { // Use the configured processor ADC resolution uint8_t resolutionBits = MS_PROCESSOR_ADC_RESOLUTION; @@ -156,7 +156,7 @@ String ProcessorAnalog::getSensorLocation() { } } -bool ProcessorAnalog::addSingleMeasurementResult(void) { +bool ProcessorAnalog::addSingleMeasurementResult() { // Immediately quit if the measurement was not successfully started if (!getStatusBit(MEASUREMENT_SUCCESSFUL)) { return bumpMeasurementAttemptCount(false); diff --git a/src/sensors/ProcessorAnalog.h b/src/sensors/ProcessorAnalog.h index bef583965..b669ac456 100644 --- a/src/sensors/ProcessorAnalog.h +++ b/src/sensors/ProcessorAnalog.h @@ -190,7 +190,7 @@ class ProcessorAnalogBase : public AnalogVoltageBase { * * @return Always true indicating successful initialization */ - bool begin(void) override; + bool begin() override; /** * @brief Read a single-ended voltage measurement from the processor ADC @@ -234,7 +234,7 @@ class ProcessorAnalogBase : public AnalogVoltageBase { * * @return The analog resolution in volts per LSB */ - float calculateAnalogResolutionVolts(void) override; + float calculateAnalogResolutionVolts() override; }; /* clang-format off */ @@ -281,9 +281,9 @@ class ProcessorAnalog : public Sensor { ProcessorAnalog(ProcessorAnalog&&) = delete; ProcessorAnalog& operator=(ProcessorAnalog&&) = delete; - String getSensorLocation(void) override; + String getSensorLocation() override; - bool addSingleMeasurementResult(void) override; + bool addSingleMeasurementResult() override; private: /** diff --git a/src/sensors/ProcessorStats.cpp b/src/sensors/ProcessorStats.cpp index 3e6459c1c..f06fa78c3 100644 --- a/src/sensors/ProcessorStats.cpp +++ b/src/sensors/ProcessorStats.cpp @@ -76,11 +76,11 @@ ProcessorStats::ProcessorStats(const char* boardName, const char* version, _operatingVoltage(operatingVoltage) {} -String ProcessorStats::getSensorLocation(void) { +String ProcessorStats::getSensorLocation() { return String(_boardName) + " " + String(_version); } -float ProcessorStats::getBatteryVoltage(void) { +float ProcessorStats::getBatteryVoltage() { float sensorValue_battery = MS_INVALID_VALUE; if (_batteryPin >= 0 && _batteryMultiplier > 0) { // Get the battery voltage @@ -165,7 +165,7 @@ int16_t FreeRam() { return &stack_dummy - sbrk(0); } -uint8_t ProcessorStats::getLastResetCode(void) { +uint8_t ProcessorStats::getLastResetCode() { return PM->RCAUSE.reg; } String ProcessorStats::getLastResetCause() { @@ -196,7 +196,7 @@ int16_t FreeRam() { return sensorValue_freeRam; } -uint8_t ProcessorStats::getLastResetCode(void) { +uint8_t ProcessorStats::getLastResetCode() { return MCUSR; } String ProcessorStats::getLastResetCause() { @@ -213,7 +213,7 @@ String ProcessorStats::getLastResetCause() { #endif -bool ProcessorStats::addSingleMeasurementResult(void) { +bool ProcessorStats::addSingleMeasurementResult() { // NOTE: We don't need to check if a measurement was started successfully // because there is no way for it to fail! diff --git a/src/sensors/ProcessorStats.h b/src/sensors/ProcessorStats.h index 94d8c5e2a..36262c573 100644 --- a/src/sensors/ProcessorStats.h +++ b/src/sensors/ProcessorStats.h @@ -324,9 +324,9 @@ class ProcessorStats : public Sensor { * * This returns the processor name as read from the compiler variable. */ - String getSensorLocation(void) override; + String getSensorLocation() override; - bool addSingleMeasurementResult(void) override; + bool addSingleMeasurementResult() override; /** * @brief A helper to get battery voltage as measured by a direct connection @@ -334,7 +334,7 @@ class ProcessorStats : public Sensor { * * @return The battery voltage in volts */ - float getBatteryVoltage(void); + float getBatteryVoltage(); /** * @brief Get the processor code for the last reset cause @@ -342,16 +342,16 @@ class ProcessorStats : public Sensor { * @return The processor code for the last reset cause */ #if !defined(__SAMD51__) - uint8_t getLastResetCode(void); + uint8_t getLastResetCode(); #else - uint16_t getLastResetCode(void); + uint16_t getLastResetCode(); #endif /** * @brief Get the cause of the last reset as a string description. * * @return A string describing the last reset cause */ - String getLastResetCause(void); + String getLastResetCause(); private: const char* _version; ///< Internal reference to the board version diff --git a/src/sensors/RainCounterI2C.cpp b/src/sensors/RainCounterI2C.cpp index 42be1818f..d8bb93357 100644 --- a/src/sensors/RainCounterI2C.cpp +++ b/src/sensors/RainCounterI2C.cpp @@ -63,7 +63,7 @@ RainCounterI2C::~RainCounterI2C() {} #endif -String RainCounterI2C::getSensorLocation(void) { +String RainCounterI2C::getSensorLocation() { #if defined(MS_RAIN_SOFTWAREWIRE) String address = F("SoftwareWire"); if (_dataPin >= 0) address += _dataPin; @@ -76,7 +76,7 @@ String RainCounterI2C::getSensorLocation(void) { } -bool RainCounterI2C::setup(void) { +bool RainCounterI2C::setup() { _i2c->begin(); // Start the wire library (sensor power not required) // Eliminate any potential extra waits in the wire library // These waits would be caused by a readBytes or parseX being called @@ -90,7 +90,7 @@ bool RainCounterI2C::setup(void) { } -bool RainCounterI2C::addSingleMeasurementResult(void) { +bool RainCounterI2C::addSingleMeasurementResult() { // Immediately quit if the measurement was not successfully started if (!getStatusBit(MEASUREMENT_SUCCESSFUL)) { return bumpMeasurementAttemptCount(false); diff --git a/src/sensors/RainCounterI2C.h b/src/sensors/RainCounterI2C.h index 25ae51bf6..927be3aea 100644 --- a/src/sensors/RainCounterI2C.h +++ b/src/sensors/RainCounterI2C.h @@ -282,11 +282,11 @@ class RainCounterI2C : public Sensor { * * @return True if the setup was successful. */ - bool setup(void) override; + bool setup() override; - String getSensorLocation(void) override; + String getSensorLocation() override; - bool addSingleMeasurementResult(void) override; + bool addSingleMeasurementResult() override; private: /** diff --git a/src/sensors/SDI12Sensors.cpp b/src/sensors/SDI12Sensors.cpp index 6fcbb5728..4d02d8e27 100644 --- a/src/sensors/SDI12Sensors.cpp +++ b/src/sensors/SDI12Sensors.cpp @@ -76,7 +76,7 @@ SDI12Sensors::SDI12Sensors(int SDI12address, int8_t powerPin, int8_t dataPin, extraWakeTime, incCalcValues) {} -bool SDI12Sensors::setup(void) { +bool SDI12Sensors::setup() { bool retVal = Sensor::setup(); // this will set pin modes and the setup status bit @@ -122,7 +122,7 @@ bool SDI12Sensors::setup(void) { } -void SDI12Sensors::activate(void) { +void SDI12Sensors::activate() { // Begin the SDI-12 interface _SDI12Internal.begin(); @@ -130,7 +130,7 @@ void SDI12Sensors::activate(void) { _SDI12Internal.clearBuffer(); } -void SDI12Sensors::deactivate(void) { +void SDI12Sensors::deactivate() { // Empty the SDI-12 buffer _SDI12Internal.clearBuffer(); @@ -140,7 +140,7 @@ void SDI12Sensors::deactivate(void) { } -bool SDI12Sensors::requestSensorAcknowledgement(void) { +bool SDI12Sensors::requestSensorAcknowledgement() { // Empty the buffer _SDI12Internal.clearBuffer(); @@ -186,7 +186,7 @@ bool SDI12Sensors::requestSensorAcknowledgement(void) { // A helper function to run the "sensor info" SDI12 command -bool SDI12Sensors::getSensorInfo(void) { +bool SDI12Sensors::getSensorInfo() { activate(); // Check that the sensor is there and responding @@ -257,28 +257,28 @@ bool SDI12Sensors::getSensorInfo(void) { // The sensor vendor -String SDI12Sensors::getSensorVendor(void) { +String SDI12Sensors::getSensorVendor() { return _sensorVendor; } // The sensor model -String SDI12Sensors::getSensorModel(void) { +String SDI12Sensors::getSensorModel() { return _sensorModel; } // The sensor version -String SDI12Sensors::getSensorVersion(void) { +String SDI12Sensors::getSensorVersion() { return _sensorVersion; } // The sensor serial number -String SDI12Sensors::getSensorSerialNumber(void) { +String SDI12Sensors::getSensorSerialNumber() { return _sensorSerialNumber; } // The sensor installation location on the Mayfly -String SDI12Sensors::getSensorLocation(void) { +String SDI12Sensors::getSensorLocation() { String sensorLocation = F("SDI12-"); sensorLocation += String(_SDI12address) + F("_Pin") + String(_dataPin); return sensorLocation; @@ -371,7 +371,7 @@ int8_t SDI12Sensors::startSDI12Measurement(bool isConcurrent) { #ifndef MS_SDI12_NON_CONCURRENT // Sending the command to get a concurrent measurement -bool SDI12Sensors::startSingleMeasurement(void) { +bool SDI12Sensors::startSingleMeasurement() { // Sensor::startSingleMeasurement() checks that if it's awake/active and // sets the timestamp and status bits. If it returns false, there's no // reason to go on. @@ -707,7 +707,7 @@ bool SDI12Sensors::getResults(bool verify_crc) { // This function is using concurrent measurements, so the MEASUREMENT_SUCCESSFUL // bit was set in the specialized startSingleMeasurement function based on // whether the response to the SDI-12 start measurement command. -bool SDI12Sensors::addSingleMeasurementResult(void) { +bool SDI12Sensors::addSingleMeasurementResult() { // Immediately quit if the measurement was not successfully started if (!getStatusBit(MEASUREMENT_SUCCESSFUL)) { return bumpMeasurementAttemptCount(false); @@ -724,7 +724,7 @@ bool SDI12Sensors::addSingleMeasurementResult(void) { // MEASUREMENT_SUCCESSFUL bit is set in the generic sensor // startSingleMeasurement function from sensor base, which only verifies that // the sensor is awake and capable of starting measurements. -bool SDI12Sensors::addSingleMeasurementResult(void) { +bool SDI12Sensors::addSingleMeasurementResult() { // Immediately quit if the measurement was not successfully started if (!getStatusBit(MEASUREMENT_SUCCESSFUL)) { return bumpMeasurementAttemptCount(false); diff --git a/src/sensors/SDI12Sensors.h b/src/sensors/SDI12Sensors.h index 8a69c9229..3e3863d78 100644 --- a/src/sensors/SDI12Sensors.h +++ b/src/sensors/SDI12Sensors.h @@ -174,7 +174,7 @@ class SDI12Sensors : public Sensor { * @return String The name of the sensor vendor as reported by the sensor * itself. */ - String getSensorVendor(void); + String getSensorVendor(); /** * @brief Get the stored sensor model name returned by a previously called * SDI-12 get sensor information (aI!) command. @@ -182,7 +182,7 @@ class SDI12Sensors : public Sensor { * @return String The name of the sensor model as reported by the sensor * itself. */ - String getSensorModel(void); + String getSensorModel(); /** * @brief Get the stored sensor version returned by a previously called * SDI-12 get sensor information (aI!) command. @@ -190,7 +190,7 @@ class SDI12Sensors : public Sensor { * @return String The version of the sensor as reported by the sensor * itself. */ - String getSensorVersion(void); + String getSensorVersion(); /** * @brief Get the stored sensor serial number returned by a previously * called SDI-12 get sensor information (aI!) command. @@ -198,27 +198,27 @@ class SDI12Sensors : public Sensor { * @return String The serial number of the sensor as reported by the sensor * itself. */ - String getSensorSerialNumber(void); + String getSensorSerialNumber(); /** * @copydoc Sensor::getSensorLocation() * * For SDI-12 sensors this returns a concatenation of the data pin number * and the SDI-12 address. */ - String getSensorLocation(void) override; + String getSensorLocation() override; /** * @brief Calls the begin for the SDI-12 object to set all of the * pre-scalers and timers. */ - void activate(void); + void activate(); /** * @brief Empties the SDI-12 object buffer and then ends it. The end * function unsets all timer pre-scalers and **--crucially--** disables the * interrupts on the SDI-12 data pin. */ - void deactivate(void); + void deactivate(); /** * @brief Do any one-time preparations needed before the sensor will be able @@ -233,7 +233,7 @@ class SDI12Sensors : public Sensor { * * @return True if the setup was successful. */ - bool setup(void) override; + bool setup() override; // Only need this for concurrent measurements. // NOTE: By default, concurrent measurements are used! @@ -249,9 +249,9 @@ class SDI12Sensors : public Sensor { * @return True if the start measurement function completed * successfully. */ - bool startSingleMeasurement(void) override; + bool startSingleMeasurement() override; #endif - bool addSingleMeasurementResult(void) override; + bool addSingleMeasurementResult() override; protected: /** @@ -261,7 +261,7 @@ class SDI12Sensors : public Sensor { * @return True if the correct SDI-12 sensor replied to the * command. */ - bool requestSensorAcknowledgement(void); + bool requestSensorAcknowledgement(); /** * @brief Send the SDI-12 'info' command [address][I][!] to a sensor and * parse the result into the vendor, model, version, and serial number. @@ -269,7 +269,7 @@ class SDI12Sensors : public Sensor { * @return True if all expected information fields returned by the * sensor. */ - bool getSensorInfo(void); + bool getSensorInfo(); /** * @brief Tell the sensor to start a single measurement, if needed. * diff --git a/src/sensors/SensirionSHT4x.cpp b/src/sensors/SensirionSHT4x.cpp index d00cd0443..9d87ddcbd 100644 --- a/src/sensors/SensirionSHT4x.cpp +++ b/src/sensors/SensirionSHT4x.cpp @@ -28,12 +28,12 @@ SensirionSHT4x::SensirionSHT4x(int8_t powerPin, bool useHeater, _i2c(&Wire) {} -String SensirionSHT4x::getSensorLocation(void) { +String SensirionSHT4x::getSensorLocation() { return F("I2C_0x44"); } -bool SensirionSHT4x::setup(void) { +bool SensirionSHT4x::setup() { _i2c->begin(); // Start the wire library (sensor power not required) // Eliminate any potential extra waits in the wire library // These waits would be caused by a readBytes or parseX being called @@ -85,7 +85,7 @@ bool SensirionSHT4x::setup(void) { } -bool SensirionSHT4x::addSingleMeasurementResult(void) { +bool SensirionSHT4x::addSingleMeasurementResult() { // Immediately quit if the measurement was not successfully started if (!getStatusBit(MEASUREMENT_SUCCESSFUL)) { return bumpMeasurementAttemptCount(false); @@ -130,7 +130,7 @@ bool SensirionSHT4x::addSingleMeasurementResult(void) { // The function to run the internal heater before going to sleep -bool SensirionSHT4x::sleep(void) { +bool SensirionSHT4x::sleep() { if (_useHeater) { return Sensor::sleep(); } if (!checkPowerOn()) { return true; } diff --git a/src/sensors/SensirionSHT4x.h b/src/sensors/SensirionSHT4x.h index 9fd79973f..5c8043f21 100644 --- a/src/sensors/SensirionSHT4x.h +++ b/src/sensors/SensirionSHT4x.h @@ -260,7 +260,7 @@ class SensirionSHT4x : public Sensor { * * @return Text describing how the sensor is attached to the mcu. */ - String getSensorLocation(void) override; + String getSensorLocation() override; /** * @brief Do any one-time preparations needed before the sensor will be able @@ -272,9 +272,9 @@ class SensirionSHT4x : public Sensor { * * @return True if the setup was successful. */ - bool setup(void) override; + bool setup() override; - bool addSingleMeasurementResult(void) override; + bool addSingleMeasurementResult() override; /** * @copydoc Sensor::sleep() @@ -282,7 +282,7 @@ class SensirionSHT4x : public Sensor { * If opted for, we run the SHT4x's internal heater for 1s before going to * sleep. */ - bool sleep(void) override; + bool sleep() override; private: /** diff --git a/src/sensors/TEConnectivityMS5837.cpp b/src/sensors/TEConnectivityMS5837.cpp index 2e08aaa60..02e61ce25 100644 --- a/src/sensors/TEConnectivityMS5837.cpp +++ b/src/sensors/TEConnectivityMS5837.cpp @@ -60,7 +60,7 @@ TEConnectivityMS5837::TEConnectivityMS5837(int8_t powerPin, MS5837Model model, fluidDensity, airPressure) {} -String TEConnectivityMS5837::getSensorName(void) { +String TEConnectivityMS5837::getSensorName() { auto modelEnum = static_cast(_model); String modelStr = F("TEConnectivityMS5837_"); switch (modelEnum) { @@ -73,12 +73,12 @@ String TEConnectivityMS5837::getSensorName(void) { } -String TEConnectivityMS5837::getSensorLocation(void) { +String TEConnectivityMS5837::getSensorLocation() { return F("I2C_0x76"); } -bool TEConnectivityMS5837::setup(void) { +bool TEConnectivityMS5837::setup() { bool success = Sensor::setup(); // this will set pin modes and the setup status bit @@ -120,7 +120,7 @@ bool TEConnectivityMS5837::setup(void) { } -bool TEConnectivityMS5837::wake(void) { +bool TEConnectivityMS5837::wake() { // Run the parent wake function if (!Sensor::wake()) return false; @@ -146,7 +146,7 @@ bool TEConnectivityMS5837::wake(void) { } -bool TEConnectivityMS5837::addSingleMeasurementResult(void) { +bool TEConnectivityMS5837::addSingleMeasurementResult() { // Immediately quit if the measurement was not successfully started if (!getStatusBit(MEASUREMENT_SUCCESSFUL)) { return bumpMeasurementAttemptCount(false); diff --git a/src/sensors/TEConnectivityMS5837.h b/src/sensors/TEConnectivityMS5837.h index 8c975ee49..651fa2579 100644 --- a/src/sensors/TEConnectivityMS5837.h +++ b/src/sensors/TEConnectivityMS5837.h @@ -475,7 +475,7 @@ class TEConnectivityMS5837 : public Sensor { * * @return True if the setup was successful. */ - bool setup(void) override; + bool setup() override; /** * @brief Wake the sensor and re-establish communication. @@ -487,12 +487,12 @@ class TEConnectivityMS5837 : public Sensor { * * @return True if the wake was successful. */ - bool wake(void) override; + bool wake() override; - String getSensorName(void) override; - String getSensorLocation(void) override; + String getSensorName() override; + String getSensorLocation() override; - bool addSingleMeasurementResult(void) override; + bool addSingleMeasurementResult() override; private: /** diff --git a/src/sensors/TIADS1x15.cpp b/src/sensors/TIADS1x15.cpp index 37a88b8e8..c9c8aa8c7 100644 --- a/src/sensors/TIADS1x15.cpp +++ b/src/sensors/TIADS1x15.cpp @@ -54,7 +54,7 @@ TIADS1x15Base::TIADS1x15Base(float voltageMultiplier, adsGain_t adsGain, // TIADS1x15Base Functions // ============================================================================ -bool TIADS1x15Base::begin(void) { +bool TIADS1x15Base::begin() { // Initialize the per-instance ADS driver with stored configuration // ADS Library default settings: // - TI ADS1115 (16 bit) @@ -256,7 +256,7 @@ void TIADS1x15Base::setADSGain(adsGain_t adsGain) { _adsGain = adsGain; } -adsGain_t TIADS1x15Base::getADSGain(void) { +adsGain_t TIADS1x15Base::getADSGain() { return _ads.getGain(); } @@ -268,7 +268,7 @@ void TIADS1x15Base::setADSDataRate(uint16_t adsDataRate) { _adsDataRate = adsDataRate; } -uint16_t TIADS1x15Base::getADSDataRate(void) { +uint16_t TIADS1x15Base::getADSDataRate() { return _ads.getDataRate(); } @@ -288,7 +288,7 @@ void TIADS1x15Base::setSupplyVoltage(float supplyVoltage) { } } -float TIADS1x15Base::calculateAnalogResolutionVolts(void) { +float TIADS1x15Base::calculateAnalogResolutionVolts() { // Determine ADC resolution based on model #ifndef MS_USE_ADS1015 uint8_t resolutionBits = 16; // ADS1115 is 16-bit @@ -334,7 +334,7 @@ float TIADS1x15Base::calculateAnalogResolutionVolts(void) { return resolutionVolts; } -bool TIADS1x15Base::probeI2C(void) { +bool TIADS1x15Base::probeI2C() { _wire->beginTransmission(_i2cAddress); if (_wire->endTransmission() != 0) { MS_DBG(F(" I2C communication failed at 0x"), String(_i2cAddress, HEX)); @@ -380,7 +380,7 @@ TIADS1x15::~TIADS1x15() { } } -String TIADS1x15::getSensorLocation(void) { +String TIADS1x15::getSensorLocation() { if (_analogVoltageReader != nullptr) { return _analogVoltageReader->getAnalogLocation(_dataPin, _analogReferenceChannel); @@ -390,7 +390,7 @@ String TIADS1x15::getSensorLocation(void) { } -bool TIADS1x15::setup(void) { +bool TIADS1x15::setup() { bool sensorSetupSuccess = Sensor::setup(); bool analogVoltageReaderSuccess = false; @@ -408,7 +408,7 @@ bool TIADS1x15::setup(void) { return sensorSetupSuccess && analogVoltageReaderSuccess; } -bool TIADS1x15::addSingleMeasurementResult(void) { +bool TIADS1x15::addSingleMeasurementResult() { // Immediately quit if the measurement was not successfully started if (!getStatusBit(MEASUREMENT_SUCCESSFUL)) { return bumpMeasurementAttemptCount(false); diff --git a/src/sensors/TIADS1x15.h b/src/sensors/TIADS1x15.h index 04883b9db..44b8a73d3 100644 --- a/src/sensors/TIADS1x15.h +++ b/src/sensors/TIADS1x15.h @@ -324,7 +324,7 @@ class TIADS1x15Base : public AnalogVoltageBase { * * @return True if the initialization was successful, false otherwise */ - bool begin(void) override; + bool begin() override; /** * @brief Read a single-ended voltage measurement from the ADS1x15 @@ -372,7 +372,7 @@ class TIADS1x15Base : public AnalogVoltageBase { * * @return The internal gain setting */ - adsGain_t getADSGain(void); + adsGain_t getADSGain(); /** * @brief Set the data rate for the ADS1x15 @@ -386,7 +386,7 @@ class TIADS1x15Base : public AnalogVoltageBase { * * @return The data rate setting (samples per second) */ - uint16_t getADSDataRate(void); + uint16_t getADSDataRate(); /** * @brief Check if the two channels form a valid differential pair @@ -429,7 +429,7 @@ class TIADS1x15Base : public AnalogVoltageBase { * * @return The analog resolution in volts per LSB */ - float calculateAnalogResolutionVolts(void) override; + float calculateAnalogResolutionVolts() override; protected: /** @@ -462,7 +462,7 @@ class TIADS1x15Base : public AnalogVoltageBase { * * @return true if device responds, false if communication failed */ - bool probeI2C(void); + bool probeI2C(); }; /* clang-format off */ @@ -517,11 +517,11 @@ class TIADS1x15 : public Sensor { TIADS1x15(TIADS1x15&&) = delete; TIADS1x15& operator=(TIADS1x15&&) = delete; - String getSensorLocation(void) override; + String getSensorLocation() override; - bool setup(void) override; + bool setup() override; - bool addSingleMeasurementResult(void) override; + bool addSingleMeasurementResult() override; private: /** diff --git a/src/sensors/TIINA219.cpp b/src/sensors/TIINA219.cpp index fcc70af20..323e840f9 100644 --- a/src/sensors/TIINA219.cpp +++ b/src/sensors/TIINA219.cpp @@ -30,14 +30,14 @@ TIINA219::TIINA219(int8_t powerPin, uint8_t i2cAddressHex, _i2c(&Wire) {} -String TIINA219::getSensorLocation(void) { +String TIINA219::getSensorLocation() { String address = F("I2C_0x"); address += String(_i2cAddressHex, HEX); return address; } -bool TIINA219::setup(void) { +bool TIINA219::setup() { bool wasOn; bool setupSuccess = Sensor::setup(); // this will set pin modes and the setup status bit @@ -65,7 +65,7 @@ bool TIINA219::setup(void) { } -bool TIINA219::wake(void) { +bool TIINA219::wake() { // Sensor::wake() checks if the power pin is on and sets the wake timestamp // and status bits. If it returns false, there's no reason to go on. if (!Sensor::wake()) return false; @@ -86,7 +86,7 @@ bool TIINA219::wake(void) { } -bool TIINA219::addSingleMeasurementResult(void) { +bool TIINA219::addSingleMeasurementResult() { // Immediately quit if the measurement was not successfully started if (!getStatusBit(MEASUREMENT_SUCCESSFUL)) { return bumpMeasurementAttemptCount(false); diff --git a/src/sensors/TIINA219.h b/src/sensors/TIINA219.h index 89c2edc73..48bfaa2de 100644 --- a/src/sensors/TIINA219.h +++ b/src/sensors/TIINA219.h @@ -279,7 +279,7 @@ class TIINA219 : public Sensor { * * @return True if the wake function completed successfully. */ - bool wake(void) override; + bool wake() override; /** * @brief Do any one-time preparations needed before the sensor will be able * to take readings. @@ -290,11 +290,11 @@ class TIINA219 : public Sensor { * * @return True if the setup was successful. */ - bool setup(void) override; + bool setup() override; - String getSensorLocation(void) override; + String getSensorLocation() override; - bool addSingleMeasurementResult(void) override; + bool addSingleMeasurementResult() override; private: /** diff --git a/src/sensors/TallyCounterI2C.cpp b/src/sensors/TallyCounterI2C.cpp index 63471e091..6c41c128c 100644 --- a/src/sensors/TallyCounterI2C.cpp +++ b/src/sensors/TallyCounterI2C.cpp @@ -20,14 +20,14 @@ TallyCounterI2C::TallyCounterI2C(int8_t powerPin, uint8_t i2cAddressHex) _i2cAddressHex(i2cAddressHex) {} -String TallyCounterI2C::getSensorLocation(void) { +String TallyCounterI2C::getSensorLocation() { String address = F("I2C_0x"); address += String(_i2cAddressHex, HEX); return address; } -bool TallyCounterI2C::setup(void) { +bool TallyCounterI2C::setup() { bool retVal = Sensor::setup(); // this will set pin modes and the setup status bit @@ -65,7 +65,7 @@ bool TallyCounterI2C::setup(void) { } -bool TallyCounterI2C::addSingleMeasurementResult(void) { +bool TallyCounterI2C::addSingleMeasurementResult() { // Immediately quit if the measurement was not successfully started if (!getStatusBit(MEASUREMENT_SUCCESSFUL)) { return bumpMeasurementAttemptCount(false); diff --git a/src/sensors/TallyCounterI2C.h b/src/sensors/TallyCounterI2C.h index bb8507b56..b1b3d0a04 100644 --- a/src/sensors/TallyCounterI2C.h +++ b/src/sensors/TallyCounterI2C.h @@ -215,12 +215,12 @@ class TallyCounterI2C : public Sensor { * * @return True if the setup was successful. */ - bool setup(void) override; + bool setup() override; - String getSensorLocation(void) override; + String getSensorLocation() override; - // bool startSingleMeasurement(void) override; // for forced mode - bool addSingleMeasurementResult(void) override; + // bool startSingleMeasurement() override; // for forced mode + bool addSingleMeasurementResult() override; private: /** diff --git a/src/sensors/TurnerCyclops.cpp b/src/sensors/TurnerCyclops.cpp index 5a3e0d3f0..6ef12dd48 100644 --- a/src/sensors/TurnerCyclops.cpp +++ b/src/sensors/TurnerCyclops.cpp @@ -40,7 +40,7 @@ TurnerCyclops::~TurnerCyclops() { } -String TurnerCyclops::getSensorLocation(void) { +String TurnerCyclops::getSensorLocation() { if (_analogVoltageReader != nullptr) { return _analogVoltageReader->getAnalogLocation(_dataPin, -1); } else { @@ -49,7 +49,7 @@ String TurnerCyclops::getSensorLocation(void) { } -bool TurnerCyclops::setup(void) { +bool TurnerCyclops::setup() { bool sensorSetupSuccess = Sensor::setup(); bool analogVoltageReaderSuccess = false; @@ -68,7 +68,7 @@ bool TurnerCyclops::setup(void) { } -bool TurnerCyclops::addSingleMeasurementResult(void) { +bool TurnerCyclops::addSingleMeasurementResult() { // Immediately quit if the measurement was not successfully started if (!getStatusBit(MEASUREMENT_SUCCESSFUL)) { return bumpMeasurementAttemptCount(false); diff --git a/src/sensors/TurnerCyclops.h b/src/sensors/TurnerCyclops.h index 1224b409c..4dcf91684 100644 --- a/src/sensors/TurnerCyclops.h +++ b/src/sensors/TurnerCyclops.h @@ -377,11 +377,11 @@ class TurnerCyclops : public Sensor { TurnerCyclops(TurnerCyclops&&) = delete; TurnerCyclops& operator=(TurnerCyclops&&) = delete; - String getSensorLocation(void) override; + String getSensorLocation() override; - bool setup(void) override; + bool setup() override; - bool addSingleMeasurementResult(void) override; + bool addSingleMeasurementResult() override; private: /** diff --git a/src/sensors/TurnerTurbidityPlus.cpp b/src/sensors/TurnerTurbidityPlus.cpp index 708927451..017c0effa 100644 --- a/src/sensors/TurnerTurbidityPlus.cpp +++ b/src/sensors/TurnerTurbidityPlus.cpp @@ -43,7 +43,7 @@ TurnerTurbidityPlus::~TurnerTurbidityPlus() { } -String TurnerTurbidityPlus::getSensorLocation(void) { +String TurnerTurbidityPlus::getSensorLocation() { if (_analogVoltageReader != nullptr) { return _analogVoltageReader->getAnalogLocation(_dataPin, _analogReferenceChannel); @@ -67,7 +67,7 @@ void TurnerTurbidityPlus::runWiper() { MS_DBG(F("TurbidityPlus wiper cycle should be finished")); } -bool TurnerTurbidityPlus::setup(void) { +bool TurnerTurbidityPlus::setup() { // Set up the wiper trigger pin, which is active-LOW. pinMode(_wiperTriggerPin, OUTPUT); bool sensorSetupSuccess = Sensor::setup(); @@ -87,7 +87,7 @@ bool TurnerTurbidityPlus::setup(void) { return sensorSetupSuccess && analogVoltageReaderSuccess; } -bool TurnerTurbidityPlus::wake(void) { +bool TurnerTurbidityPlus::wake() { // Set the wiper trigger pin mode. // Reset this on every wake because pins are set to tri-state on sleep pinMode(_wiperTriggerPin, OUTPUT); @@ -97,19 +97,19 @@ bool TurnerTurbidityPlus::wake(void) { return Sensor::wake(); } -void TurnerTurbidityPlus::powerDown(void) { +void TurnerTurbidityPlus::powerDown() { // Set the wiper trigger pin LOW to avoid power drain. digitalWrite(_wiperTriggerPin, LOW); Sensor::powerDown(); } -void TurnerTurbidityPlus::powerUp(void) { +void TurnerTurbidityPlus::powerUp() { // Set the wiper trigger pin HIGH to prepare for wiping. digitalWrite(_wiperTriggerPin, HIGH); Sensor::powerUp(); } -bool TurnerTurbidityPlus::addSingleMeasurementResult(void) { +bool TurnerTurbidityPlus::addSingleMeasurementResult() { // Immediately quit if the measurement was not successfully started if (!getStatusBit(MEASUREMENT_SUCCESSFUL)) { return bumpMeasurementAttemptCount(false); diff --git a/src/sensors/TurnerTurbidityPlus.h b/src/sensors/TurnerTurbidityPlus.h index 9d4d6e298..ba1bb634f 100644 --- a/src/sensors/TurnerTurbidityPlus.h +++ b/src/sensors/TurnerTurbidityPlus.h @@ -289,12 +289,12 @@ class TurnerTurbidityPlus : public Sensor { TurnerTurbidityPlus(TurnerTurbidityPlus&&) = delete; TurnerTurbidityPlus& operator=(TurnerTurbidityPlus&&) = delete; - String getSensorLocation(void) override; + String getSensorLocation() override; /** * @brief Run one wiper cycle */ - void runWiper(void); + void runWiper(); /** * @brief Do any one-time preparations needed before the sensor will be able @@ -304,15 +304,15 @@ class TurnerTurbidityPlus : public Sensor { * * @return **bool** True if the setup was successful. */ - bool setup(void) override; + bool setup() override; - bool wake(void) override; + bool wake() override; - void powerUp(void) override; + void powerUp() override; - void powerDown(void) override; + void powerDown() override; - bool addSingleMeasurementResult(void) override; + bool addSingleMeasurementResult() override; private: /** diff --git a/src/sensors/YosemitechParent.cpp b/src/sensors/YosemitechParent.cpp index 7107ac18f..895ac2d0b 100644 --- a/src/sensors/YosemitechParent.cpp +++ b/src/sensors/YosemitechParent.cpp @@ -41,7 +41,7 @@ YosemitechParent::YosemitechParent( // The sensor installation location on the Mayfly -String YosemitechParent::getSensorLocation(void) { +String YosemitechParent::getSensorLocation() { String sensorLocation = F("modbus_0x"); if (_modbusAddress < 16) sensorLocation += "0"; sensorLocation += String(_modbusAddress, HEX); @@ -49,7 +49,7 @@ String YosemitechParent::getSensorLocation(void) { } -bool YosemitechParent::setup(void) { +bool YosemitechParent::setup() { bool retVal = Sensor::setup(); // this will set pin modes and the setup status bit if (_RS485EnablePin >= 0) { pinMode(_RS485EnablePin, OUTPUT); } @@ -70,7 +70,7 @@ bool YosemitechParent::setup(void) { // The function to wake up a sensor // Different from the standard in that it waits for warm up and starts // measurements -bool YosemitechParent::wake(void) { +bool YosemitechParent::wake() { // Sensor::wake() checks if the power pin is on and sets the wake timestamp // and status bits. If it returns false, there's no reason to go on. if (!Sensor::wake()) return false; @@ -120,7 +120,7 @@ bool YosemitechParent::wake(void) { // The function to put the sensor to sleep // Different from the standard in that it empties and flushes the stream and // stops measurements -bool YosemitechParent::sleep(void) { +bool YosemitechParent::sleep() { // empty then flush the buffer while (_stream->available()) { _stream->read(); } _stream->flush(); @@ -164,7 +164,7 @@ bool YosemitechParent::sleep(void) { } -bool YosemitechParent::addSingleMeasurementResult(void) { +bool YosemitechParent::addSingleMeasurementResult() { // Immediately quit if the measurement was not successfully started if (!getStatusBit(MEASUREMENT_SUCCESSFUL)) { return bumpMeasurementAttemptCount(false); diff --git a/src/sensors/YosemitechParent.h b/src/sensors/YosemitechParent.h index 5701b37c2..f1f3f74b7 100644 --- a/src/sensors/YosemitechParent.h +++ b/src/sensors/YosemitechParent.h @@ -209,7 +209,7 @@ class YosemitechParent : public Sensor { */ virtual ~YosemitechParent() override = default; - String getSensorLocation(void) override; + String getSensorLocation() override; /** * @brief Do any one-time preparations needed before the sensor will be able @@ -222,7 +222,7 @@ class YosemitechParent : public Sensor { * * @return True if the setup was successful. */ - bool setup(void) override; + bool setup() override; /** * @brief Wakes the sensor, starts measurements, and activates brushes. * @@ -234,7 +234,7 @@ class YosemitechParent : public Sensor { * * @return True if the wake function completed successfully. */ - bool wake(void) override; + bool wake() override; /** * @brief Puts the sensor to sleep, if necessary. * @@ -243,9 +243,9 @@ class YosemitechParent : public Sensor { * * @return True if the sleep function completed successfully. */ - bool sleep(void) override; + bool sleep() override; - bool addSingleMeasurementResult(void) override; + bool addSingleMeasurementResult() override; private: /** From bf646b2df31301dafe14b61688ce321f70822be3 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Wed, 4 Mar 2026 14:30:29 -0500 Subject: [PATCH 426/533] added static_assert Signed-off-by: Sara Damiano --- src/sensors/AlphasenseCO2.cpp | 6 ------ src/sensors/AlphasenseCO2.h | 3 +++ 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/src/sensors/AlphasenseCO2.cpp b/src/sensors/AlphasenseCO2.cpp index 5ad38ba8a..ca1428553 100644 --- a/src/sensors/AlphasenseCO2.cpp +++ b/src/sensors/AlphasenseCO2.cpp @@ -84,12 +84,6 @@ bool AlphasenseCO2::addSingleMeasurementResult() { F("No analog voltage reader available")); return bumpMeasurementAttemptCount(false); } - // validate the resistor value - if (ALPHASENSE_CO2_SENSE_RESISTOR_OHM <= 0) { - MS_DBG(F(" Error: Invalid sense resistor value"), - ALPHASENSE_CO2_SENSE_RESISTOR_OHM); - return bumpMeasurementAttemptCount(false); - } float adcVoltage = MS_INVALID_VALUE; diff --git a/src/sensors/AlphasenseCO2.h b/src/sensors/AlphasenseCO2.h index df8caae55..903f52d56 100644 --- a/src/sensors/AlphasenseCO2.h +++ b/src/sensors/AlphasenseCO2.h @@ -113,6 +113,9 @@ class AnalogVoltageBase; */ #define ALPHASENSE_CO2_SENSE_RESISTOR_OHM 250.0f #endif +// Compile-time validation of configuration constants +static_assert(ALPHASENSE_CO2_SENSE_RESISTOR_OHM > 0, + "Sense resistor value must be positive"); #if !defined(ALPHASENSE_CO2_MFG_SCALE) || defined(DOXYGEN) /** * @brief Manufacturer scale factor for CO2 conversion (ppm/mA) From 05d7728c33627bb832617611b74316e952f49915 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Wed, 4 Mar 2026 14:47:34 -0500 Subject: [PATCH 427/533] Change to c++ style static casts Signed-off-by: Sara Damiano --- src/LoggerModem.h | 13 +-- src/sensors/ANBpH.h | 81 ++++++++-------- src/sensors/AOSongAM2315.h | 22 +++-- src/sensors/AOSongDHT.h | 33 ++++--- src/sensors/AlphasenseCO2.h | 25 ++--- src/sensors/AnalogElecConductivity.h | 9 +- src/sensors/ApogeeSQ212.h | 23 +++-- src/sensors/AtlasScientificCO2.h | 23 +++-- src/sensors/AtlasScientificDO.cpp | 3 +- src/sensors/AtlasScientificDO.h | 28 +++--- src/sensors/AtlasScientificEC.h | 42 +++++---- src/sensors/AtlasScientificORP.h | 9 +- src/sensors/AtlasScientificRTD.h | 9 +- src/sensors/AtlasScientificpH.h | 10 +- src/sensors/BoschBME280.h | 38 ++++---- src/sensors/BoschBMP3xx.h | 30 +++--- src/sensors/CampbellClariVUE10.h | 26 +++--- src/sensors/CampbellOBS3.h | 24 ++--- src/sensors/CampbellRainVUE10.h | 41 +++++---- src/sensors/Decagon5TM.h | 29 +++--- src/sensors/DecagonCTD.h | 29 +++--- src/sensors/DecagonES2.h | 20 ++-- src/sensors/EverlightALSPT19.h | 25 ++--- src/sensors/FreescaleMPL115A2.h | 22 +++-- src/sensors/GeoluxHydroCam.h | 28 +++--- src/sensors/GroPointGPLP8.h | 10 +- src/sensors/InSituRDO.h | 33 +++---- src/sensors/InSituTrollSdi12a.h | 36 ++++---- src/sensors/KellerAcculevel.h | 36 ++++---- src/sensors/KellerNanolevel.h | 36 ++++---- src/sensors/MaxBotixSonar.h | 10 +- src/sensors/MaximDS18.h | 9 +- src/sensors/MaximDS3231.h | 14 +-- src/sensors/MeaSpecMS5803.h | 22 +++-- src/sensors/MeterHydros21.h | 42 +++++---- src/sensors/MeterTeros11.h | 51 +++++----- src/sensors/PaleoTerraRedox.h | 14 +-- src/sensors/ProcessorAnalog.h | 8 +- src/sensors/ProcessorStats.h | 38 ++++---- src/sensors/RainCounterI2C.h | 28 +++--- src/sensors/SensirionSHT4x.h | 23 +++-- src/sensors/TEConnectivityMS5837.h | 44 +++++---- src/sensors/TIADS1x15.h | 9 +- src/sensors/TIINA219.h | 25 ++--- src/sensors/TallyCounterI2C.h | 14 +-- src/sensors/TurnerCyclops.h | 133 +++++++++++++++------------ src/sensors/TurnerTurbidityPlus.h | 23 +++-- src/sensors/VegaPuls21.h | 43 +++++---- src/sensors/YosemitechY4000.h | 83 +++++++++-------- src/sensors/YosemitechY504.h | 27 +++--- src/sensors/YosemitechY510.h | 18 ++-- src/sensors/YosemitechY511.h | 18 ++-- src/sensors/YosemitechY513.h | 19 ++-- src/sensors/YosemitechY514.h | 23 +++-- src/sensors/YosemitechY520.h | 18 ++-- src/sensors/YosemitechY532.h | 32 ++++--- src/sensors/YosemitechY533.h | 19 ++-- src/sensors/YosemitechY551.h | 28 +++--- src/sensors/YosemitechY560.h | 22 +++-- src/sensors/YosemitechY700.h | 18 ++-- src/sensors/ZebraTechDOpto.h | 37 ++++---- 61 files changed, 939 insertions(+), 766 deletions(-) diff --git a/src/LoggerModem.h b/src/LoggerModem.h index 7400a663e..c49191d06 100644 --- a/src/LoggerModem.h +++ b/src/LoggerModem.h @@ -1249,7 +1249,8 @@ class Modem_RSSI : public Variable { */ explicit Modem_RSSI(loggerModem* parentModem, const char* uuid = "", const char* varCode = MODEM_RSSI_DEFAULT_CODE) - : Variable(&parentModem->getModemRSSI, (uint8_t)MODEM_RSSI_RESOLUTION, + : Variable(&parentModem->getModemRSSI, + static_cast(MODEM_RSSI_RESOLUTION), &*MODEM_RSSI_VAR_NAME, &*MODEM_RSSI_UNIT_NAME, varCode, uuid) { parentModem->enableMetadataPolling(MODEM_RSSI_ENABLE_BITMASK); @@ -1284,7 +1285,7 @@ class Modem_SignalPercent : public Variable { loggerModem* parentModem, const char* uuid = "", const char* varCode = MODEM_PERCENT_SIGNAL_DEFAULT_CODE) : Variable(&parentModem->getModemSignalPercent, - (uint8_t)MODEM_PERCENT_SIGNAL_RESOLUTION, + static_cast(MODEM_PERCENT_SIGNAL_RESOLUTION), &*MODEM_PERCENT_SIGNAL_VAR_NAME, &*MODEM_PERCENT_SIGNAL_UNIT_NAME, varCode, uuid) { parentModem->enableMetadataPolling(MODEM_PERCENT_SIGNAL_ENABLE_BITMASK); @@ -1322,7 +1323,7 @@ class Modem_BatteryState : public Variable { loggerModem* parentModem, const char* uuid = "", const char* varCode = MODEM_BATTERY_STATE_DEFAULT_CODE) : Variable(&parentModem->getModemBatteryChargeState, - (uint8_t)MODEM_BATTERY_STATE_RESOLUTION, + static_cast(MODEM_BATTERY_STATE_RESOLUTION), &*MODEM_BATTERY_STATE_VAR_NAME, &*MODEM_BATTERY_STATE_UNIT_NAME, varCode, uuid) { parentModem->enableMetadataPolling(MODEM_BATTERY_STATE_ENABLE_BITMASK); @@ -1360,7 +1361,7 @@ class Modem_BatteryPercent : public Variable { loggerModem* parentModem, const char* uuid = "", const char* varCode = MODEM_BATTERY_PERCENT_DEFAULT_CODE) : Variable(&parentModem->getModemBatteryChargePercent, - (uint8_t)MODEM_BATTERY_PERCENT_RESOLUTION, + static_cast(MODEM_BATTERY_PERCENT_RESOLUTION), &*MODEM_BATTERY_PERCENT_VAR_NAME, &*MODEM_BATTERY_PERCENT_UNIT_NAME, varCode, uuid) { parentModem->enableMetadataPolling( @@ -1399,7 +1400,7 @@ class Modem_BatteryVoltage : public Variable { loggerModem* parentModem, const char* uuid = "", const char* varCode = MODEM_BATTERY_VOLTAGE_DEFAULT_CODE) : Variable(&parentModem->getModemBatteryVoltage, - (uint8_t)MODEM_BATTERY_VOLTAGE_RESOLUTION, + static_cast(MODEM_BATTERY_VOLTAGE_RESOLUTION), &*MODEM_BATTERY_VOLTAGE_VAR_NAME, &*MODEM_BATTERY_VOLTAGE_UNIT_NAME, varCode, uuid) { parentModem->enableMetadataPolling( @@ -1437,7 +1438,7 @@ class Modem_Temp : public Variable { explicit Modem_Temp(loggerModem* parentModem, const char* uuid = "", const char* varCode = MODEM_TEMPERATURE_DEFAULT_CODE) : Variable(&parentModem->getModemTemperature, - (uint8_t)MODEM_TEMPERATURE_RESOLUTION, + static_cast(MODEM_TEMPERATURE_RESOLUTION), &*MODEM_TEMPERATURE_VAR_NAME, &*MODEM_TEMPERATURE_UNIT_NAME, varCode, uuid) { parentModem->enableMetadataPolling(MODEM_TEMPERATURE_ENABLE_BITMASK); diff --git a/src/sensors/ANBpH.h b/src/sensors/ANBpH.h index 55966ea86..6cf6dabbf 100644 --- a/src/sensors/ANBpH.h +++ b/src/sensors/ANBpH.h @@ -730,9 +730,9 @@ class ANBpH_pH : public Variable { */ explicit ANBpH_pH(ANBpH* parentSense, const char* uuid = "", const char* varCode = ANB_PH_PH_DEFAULT_CODE) - : Variable(parentSense, (uint8_t)ANB_PH_PH_VAR_NUM, - (uint8_t)ANB_PH_PH_RESOLUTION, ANB_PH_PH_VAR_NAME, - ANB_PH_PH_UNIT_NAME, varCode, uuid) {} + : Variable(parentSense, static_cast(ANB_PH_PH_VAR_NUM), + static_cast(ANB_PH_PH_RESOLUTION), + ANB_PH_PH_VAR_NAME, ANB_PH_PH_UNIT_NAME, varCode, uuid) {} /** * @brief Construct a new ANBpH_pH object. * @@ -740,7 +740,8 @@ class ANBpH_pH : public Variable { * used. */ ANBpH_pH() - : Variable((uint8_t)ANB_PH_PH_VAR_NUM, (uint8_t)ANB_PH_PH_RESOLUTION, + : Variable(static_cast(ANB_PH_PH_VAR_NUM), + static_cast(ANB_PH_PH_RESOLUTION), ANB_PH_PH_VAR_NAME, ANB_PH_PH_UNIT_NAME, ANB_PH_PH_DEFAULT_CODE) {} /** @@ -769,9 +770,10 @@ class ANBpH_Temp : public Variable { */ explicit ANBpH_Temp(ANBpH* parentSense, const char* uuid = "", const char* varCode = ANB_PH_TEMP_DEFAULT_CODE) - : Variable(parentSense, (uint8_t)ANB_PH_TEMP_VAR_NUM, - (uint8_t)ANB_PH_TEMP_RESOLUTION, ANB_PH_TEMP_VAR_NAME, - ANB_PH_TEMP_UNIT_NAME, varCode, uuid) {} + : Variable(parentSense, static_cast(ANB_PH_TEMP_VAR_NUM), + static_cast(ANB_PH_TEMP_RESOLUTION), + ANB_PH_TEMP_VAR_NAME, ANB_PH_TEMP_UNIT_NAME, varCode, uuid) { + } /** * @brief Construct a new ANBpH_Temp object. * @@ -779,9 +781,10 @@ class ANBpH_Temp : public Variable { * used. */ ANBpH_Temp() - : Variable((uint8_t)ANB_PH_TEMP_VAR_NUM, - (uint8_t)ANB_PH_TEMP_RESOLUTION, ANB_PH_TEMP_VAR_NAME, - ANB_PH_TEMP_UNIT_NAME, ANB_PH_TEMP_DEFAULT_CODE) {} + : Variable(static_cast(ANB_PH_TEMP_VAR_NUM), + static_cast(ANB_PH_TEMP_RESOLUTION), + ANB_PH_TEMP_VAR_NAME, ANB_PH_TEMP_UNIT_NAME, + ANB_PH_TEMP_DEFAULT_CODE) {} /** * @brief Destroy the ANBpH_Temp object - no action needed. */ @@ -808,8 +811,8 @@ class ANBpH_Salinity : public Variable { */ explicit ANBpH_Salinity(ANBpH* parentSense, const char* uuid = "", const char* varCode = ANB_PH_SALINITY_DEFAULT_CODE) - : Variable(parentSense, (uint8_t)ANB_PH_SALINITY_VAR_NUM, - (uint8_t)ANB_PH_SALINITY_RESOLUTION, + : Variable(parentSense, static_cast(ANB_PH_SALINITY_VAR_NUM), + static_cast(ANB_PH_SALINITY_RESOLUTION), ANB_PH_SALINITY_VAR_NAME, ANB_PH_SALINITY_UNIT_NAME, varCode, uuid) {} /** @@ -819,8 +822,8 @@ class ANBpH_Salinity : public Variable { * used. */ ANBpH_Salinity() - : Variable((uint8_t)ANB_PH_SALINITY_VAR_NUM, - (uint8_t)ANB_PH_SALINITY_RESOLUTION, + : Variable(static_cast(ANB_PH_SALINITY_VAR_NUM), + static_cast(ANB_PH_SALINITY_RESOLUTION), ANB_PH_SALINITY_VAR_NAME, ANB_PH_SALINITY_UNIT_NAME, ANB_PH_SALINITY_DEFAULT_CODE) {} /** @@ -851,18 +854,20 @@ class ANBpH_SpCond : public Variable { */ explicit ANBpH_SpCond(ANBpH* parentSense, const char* uuid = "", const char* varCode = ANB_PH_SPCOND_DEFAULT_CODE) - : Variable(parentSense, (uint8_t)ANB_PH_SPCOND_VAR_NUM, - (uint8_t)ANB_PH_SPCOND_RESOLUTION, ANB_PH_SPCOND_VAR_NAME, - ANB_PH_SPCOND_UNIT_NAME, varCode, uuid) {} + : Variable(parentSense, static_cast(ANB_PH_SPCOND_VAR_NUM), + static_cast(ANB_PH_SPCOND_RESOLUTION), + ANB_PH_SPCOND_VAR_NAME, ANB_PH_SPCOND_UNIT_NAME, varCode, + uuid) {} /** * @brief Construct a new ANBpH_SpCond object. * * @note This must be tied with a parent ANBpH object before it can be used. */ ANBpH_SpCond() - : Variable((uint8_t)ANB_PH_SPCOND_VAR_NUM, - (uint8_t)ANB_PH_SPCOND_RESOLUTION, ANB_PH_SPCOND_VAR_NAME, - ANB_PH_SPCOND_UNIT_NAME, ANB_PH_SPCOND_DEFAULT_CODE) {} + : Variable(static_cast(ANB_PH_SPCOND_VAR_NUM), + static_cast(ANB_PH_SPCOND_RESOLUTION), + ANB_PH_SPCOND_VAR_NAME, ANB_PH_SPCOND_UNIT_NAME, + ANB_PH_SPCOND_DEFAULT_CODE) {} /** * @brief Destroy the ANBpH_SpCond object - no action needed. */ @@ -889,9 +894,9 @@ class ANBpH_EC : public Variable { */ explicit ANBpH_EC(ANBpH* parentSense, const char* uuid = "", const char* varCode = ANB_PH_EC_DEFAULT_CODE) - : Variable(parentSense, (uint8_t)ANB_PH_EC_VAR_NUM, - (uint8_t)ANB_PH_EC_RESOLUTION, ANB_PH_EC_VAR_NAME, - ANB_PH_EC_UNIT_NAME, varCode, uuid) {} + : Variable(parentSense, static_cast(ANB_PH_EC_VAR_NUM), + static_cast(ANB_PH_EC_RESOLUTION), + ANB_PH_EC_VAR_NAME, ANB_PH_EC_UNIT_NAME, varCode, uuid) {} /** * @brief Construct a new ANBpH_EC object. * @@ -899,7 +904,8 @@ class ANBpH_EC : public Variable { * used. */ ANBpH_EC() - : Variable((uint8_t)ANB_PH_EC_VAR_NUM, (uint8_t)ANB_PH_EC_RESOLUTION, + : Variable(static_cast(ANB_PH_EC_VAR_NUM), + static_cast(ANB_PH_EC_RESOLUTION), ANB_PH_EC_VAR_NAME, ANB_PH_EC_UNIT_NAME, ANB_PH_EC_DEFAULT_CODE) {} /** @@ -931,8 +937,9 @@ class ANBpH_HealthCode : public Variable { explicit ANBpH_HealthCode( ANBpH* parentSense, const char* uuid = "", const char* varCode = ANB_PH_HEALTH_CODE_DEFAULT_CODE) - : Variable(parentSense, (uint8_t)ANB_PH_HEALTH_CODE_VAR_NUM, - (uint8_t)ANB_PH_HEALTH_CODE_RESOLUTION, + : Variable(parentSense, + static_cast(ANB_PH_HEALTH_CODE_VAR_NUM), + static_cast(ANB_PH_HEALTH_CODE_RESOLUTION), ANB_PH_HEALTH_CODE_VAR_NAME, ANB_PH_HEALTH_CODE_UNIT_NAME, varCode, uuid) {} /** @@ -942,8 +949,8 @@ class ANBpH_HealthCode : public Variable { * used. */ ANBpH_HealthCode() - : Variable((uint8_t)ANB_PH_HEALTH_CODE_VAR_NUM, - (uint8_t)ANB_PH_HEALTH_CODE_RESOLUTION, + : Variable(static_cast(ANB_PH_HEALTH_CODE_VAR_NUM), + static_cast(ANB_PH_HEALTH_CODE_RESOLUTION), ANB_PH_HEALTH_CODE_VAR_NAME, ANB_PH_HEALTH_CODE_UNIT_NAME, ANB_PH_HEALTH_CODE_DEFAULT_CODE) {} /** @@ -976,8 +983,9 @@ class ANBpH_DiagnosticCode : public Variable { explicit ANBpH_DiagnosticCode( ANBpH* parentSense, const char* uuid = "", const char* varCode = ANB_PH_DIAGNOSTIC_CODE_DEFAULT_CODE) - : Variable(parentSense, (uint8_t)ANB_PH_DIAGNOSTIC_CODE_VAR_NUM, - (uint8_t)ANB_PH_DIAGNOSTIC_CODE_RESOLUTION, + : Variable(parentSense, + static_cast(ANB_PH_DIAGNOSTIC_CODE_VAR_NUM), + static_cast(ANB_PH_DIAGNOSTIC_CODE_RESOLUTION), ANB_PH_DIAGNOSTIC_CODE_VAR_NAME, ANB_PH_DIAGNOSTIC_CODE_UNIT_NAME, varCode, uuid) {} /** @@ -987,8 +995,8 @@ class ANBpH_DiagnosticCode : public Variable { * used. */ ANBpH_DiagnosticCode() - : Variable((uint8_t)ANB_PH_DIAGNOSTIC_CODE_VAR_NUM, - (uint8_t)ANB_PH_DIAGNOSTIC_CODE_RESOLUTION, + : Variable(static_cast(ANB_PH_DIAGNOSTIC_CODE_VAR_NUM), + static_cast(ANB_PH_DIAGNOSTIC_CODE_RESOLUTION), ANB_PH_DIAGNOSTIC_CODE_VAR_NAME, ANB_PH_DIAGNOSTIC_CODE_UNIT_NAME, ANB_PH_DIAGNOSTIC_CODE_DEFAULT_CODE) {} @@ -1022,8 +1030,9 @@ class ANBpH_StatusCode : public Variable { explicit ANBpH_StatusCode( ANBpH* parentSense, const char* uuid = "", const char* varCode = ANB_PH_STATUS_CODE_DEFAULT_CODE) - : Variable(parentSense, (uint8_t)ANB_PH_STATUS_CODE_VAR_NUM, - (uint8_t)ANB_PH_STATUS_CODE_RESOLUTION, + : Variable(parentSense, + static_cast(ANB_PH_STATUS_CODE_VAR_NUM), + static_cast(ANB_PH_STATUS_CODE_RESOLUTION), ANB_PH_STATUS_CODE_VAR_NAME, ANB_PH_STATUS_CODE_UNIT_NAME, varCode, uuid) {} /** @@ -1033,8 +1042,8 @@ class ANBpH_StatusCode : public Variable { * used. */ ANBpH_StatusCode() - : Variable((uint8_t)ANB_PH_STATUS_CODE_VAR_NUM, - (uint8_t)ANB_PH_STATUS_CODE_RESOLUTION, + : Variable(static_cast(ANB_PH_STATUS_CODE_VAR_NUM), + static_cast(ANB_PH_STATUS_CODE_RESOLUTION), ANB_PH_STATUS_CODE_VAR_NAME, ANB_PH_STATUS_CODE_UNIT_NAME, ANB_PH_STATUS_CODE_DEFAULT_CODE) {} /** diff --git a/src/sensors/AOSongAM2315.h b/src/sensors/AOSongAM2315.h index 3e9d1767f..d11cd35d3 100644 --- a/src/sensors/AOSongAM2315.h +++ b/src/sensors/AOSongAM2315.h @@ -282,8 +282,8 @@ class AOSongAM2315_Humidity : public Variable { explicit AOSongAM2315_Humidity( AOSongAM2315* parentSense, const char* uuid = "", const char* varCode = AM2315_HUMIDITY_DEFAULT_CODE) - : Variable(parentSense, (uint8_t)AM2315_HUMIDITY_VAR_NUM, - (uint8_t)AM2315_HUMIDITY_RESOLUTION, + : Variable(parentSense, static_cast(AM2315_HUMIDITY_VAR_NUM), + static_cast(AM2315_HUMIDITY_RESOLUTION), AM2315_HUMIDITY_VAR_NAME, AM2315_HUMIDITY_UNIT_NAME, varCode, uuid) {} /** @@ -292,8 +292,8 @@ class AOSongAM2315_Humidity : public Variable { * @note This must be tied with a parent AOSongAM2315 before it can be used. */ AOSongAM2315_Humidity() - : Variable((uint8_t)AM2315_HUMIDITY_VAR_NUM, - (uint8_t)AM2315_HUMIDITY_RESOLUTION, + : Variable(static_cast(AM2315_HUMIDITY_VAR_NUM), + static_cast(AM2315_HUMIDITY_RESOLUTION), AM2315_HUMIDITY_VAR_NAME, AM2315_HUMIDITY_UNIT_NAME, AM2315_HUMIDITY_DEFAULT_CODE) {} /** @@ -324,18 +324,20 @@ class AOSongAM2315_Temp : public Variable { */ explicit AOSongAM2315_Temp(AOSongAM2315* parentSense, const char* uuid = "", const char* varCode = AM2315_TEMP_DEFAULT_CODE) - : Variable(parentSense, (uint8_t)AM2315_TEMP_VAR_NUM, - (uint8_t)AM2315_TEMP_RESOLUTION, AM2315_TEMP_VAR_NAME, - AM2315_TEMP_UNIT_NAME, varCode, uuid) {} + : Variable(parentSense, static_cast(AM2315_TEMP_VAR_NUM), + static_cast(AM2315_TEMP_RESOLUTION), + AM2315_TEMP_VAR_NAME, AM2315_TEMP_UNIT_NAME, varCode, uuid) { + } /** * @brief Construct a new AOSongAM2315_Temp object. * * @note This must be tied with a parent AOSongAM2315 before it can be used. */ AOSongAM2315_Temp() - : Variable((uint8_t)AM2315_TEMP_VAR_NUM, - (uint8_t)AM2315_TEMP_RESOLUTION, AM2315_TEMP_VAR_NAME, - AM2315_TEMP_UNIT_NAME, AM2315_TEMP_DEFAULT_CODE) {} + : Variable(static_cast(AM2315_TEMP_VAR_NUM), + static_cast(AM2315_TEMP_RESOLUTION), + AM2315_TEMP_VAR_NAME, AM2315_TEMP_UNIT_NAME, + AM2315_TEMP_DEFAULT_CODE) {} /** * @brief Destroy the AOSongAM2315_Temp object - no action needed. */ diff --git a/src/sensors/AOSongDHT.h b/src/sensors/AOSongDHT.h index 8f434f016..e31f7a4dc 100644 --- a/src/sensors/AOSongDHT.h +++ b/src/sensors/AOSongDHT.h @@ -304,18 +304,20 @@ class AOSongDHT_Humidity : public Variable { */ explicit AOSongDHT_Humidity(AOSongDHT* parentSense, const char* uuid = "", const char* varCode = DHT_HUMIDITY_DEFAULT_CODE) - : Variable(parentSense, (uint8_t)DHT_HUMIDITY_VAR_NUM, - (uint8_t)DHT_HUMIDITY_RESOLUTION, DHT_HUMIDITY_VAR_NAME, - DHT_HUMIDITY_UNIT_NAME, varCode, uuid) {} + : Variable(parentSense, static_cast(DHT_HUMIDITY_VAR_NUM), + static_cast(DHT_HUMIDITY_RESOLUTION), + DHT_HUMIDITY_VAR_NAME, DHT_HUMIDITY_UNIT_NAME, varCode, + uuid) {} /** * @brief Construct a new AOSongDHT_Humidity object. * * @note This must be tied with a parent AOSongDHT before it can be used. */ AOSongDHT_Humidity() - : Variable((uint8_t)DHT_HUMIDITY_VAR_NUM, - (uint8_t)DHT_HUMIDITY_RESOLUTION, DHT_HUMIDITY_VAR_NAME, - DHT_HUMIDITY_UNIT_NAME, DHT_HUMIDITY_DEFAULT_CODE) {} + : Variable(static_cast(DHT_HUMIDITY_VAR_NUM), + static_cast(DHT_HUMIDITY_RESOLUTION), + DHT_HUMIDITY_VAR_NAME, DHT_HUMIDITY_UNIT_NAME, + DHT_HUMIDITY_DEFAULT_CODE) {} /** * @brief Destroy the AOSongDHT_Humidity object - no action needed. */ @@ -345,8 +347,8 @@ class AOSongDHT_Temp : public Variable { */ explicit AOSongDHT_Temp(AOSongDHT* parentSense, const char* uuid = "", const char* varCode = DHT_TEMP_DEFAULT_CODE) - : Variable(parentSense, (uint8_t)DHT_TEMP_VAR_NUM, - (uint8_t)DHT_TEMP_RESOLUTION, DHT_TEMP_VAR_NAME, + : Variable(parentSense, static_cast(DHT_TEMP_VAR_NUM), + static_cast(DHT_TEMP_RESOLUTION), DHT_TEMP_VAR_NAME, DHT_TEMP_UNIT_NAME, varCode, uuid) {} /** * @brief Construct a new AOSongDHT_Temp object. @@ -354,9 +356,9 @@ class AOSongDHT_Temp : public Variable { * @note This must be tied with a parent AOSongDHT before it can be used. */ AOSongDHT_Temp() - : Variable((uint8_t)DHT_TEMP_VAR_NUM, (uint8_t)DHT_TEMP_RESOLUTION, - DHT_TEMP_VAR_NAME, DHT_TEMP_UNIT_NAME, - DHT_TEMP_DEFAULT_CODE) {} + : Variable(static_cast(DHT_TEMP_VAR_NUM), + static_cast(DHT_TEMP_RESOLUTION), DHT_TEMP_VAR_NAME, + DHT_TEMP_UNIT_NAME, DHT_TEMP_DEFAULT_CODE) {} /** * @brief Destroy the AOSongDHT_Temp object - no action needed. */ @@ -386,8 +388,8 @@ class AOSongDHT_HI : public Variable { */ explicit AOSongDHT_HI(AOSongDHT* parentSense, const char* uuid = "", const char* varCode = DHT_HI_DEFAULT_CODE) - : Variable(parentSense, (uint8_t)DHT_HI_VAR_NUM, - (uint8_t)DHT_HI_RESOLUTION, DHT_HI_VAR_NAME, + : Variable(parentSense, static_cast(DHT_HI_VAR_NUM), + static_cast(DHT_HI_RESOLUTION), DHT_HI_VAR_NAME, DHT_HI_UNIT_NAME, varCode, uuid) {} /** * @brief Construct a new AOSongDHT_HI object. @@ -395,8 +397,9 @@ class AOSongDHT_HI : public Variable { * @note This must be tied with a parent AOSongDHT before it can be used. */ AOSongDHT_HI() - : Variable((uint8_t)DHT_HI_VAR_NUM, (uint8_t)DHT_HI_RESOLUTION, - DHT_HI_VAR_NAME, DHT_HI_UNIT_NAME, DHT_HI_DEFAULT_CODE) {} + : Variable(static_cast(DHT_HI_VAR_NUM), + static_cast(DHT_HI_RESOLUTION), DHT_HI_VAR_NAME, + DHT_HI_UNIT_NAME, DHT_HI_DEFAULT_CODE) {} /** * @brief Destroy the AOSongDHT_HI object - no action needed. */ diff --git a/src/sensors/AlphasenseCO2.h b/src/sensors/AlphasenseCO2.h index 903f52d56..46125b169 100644 --- a/src/sensors/AlphasenseCO2.h +++ b/src/sensors/AlphasenseCO2.h @@ -114,7 +114,7 @@ class AnalogVoltageBase; #define ALPHASENSE_CO2_SENSE_RESISTOR_OHM 250.0f #endif // Compile-time validation of configuration constants -static_assert(ALPHASENSE_CO2_SENSE_RESISTOR_OHM > 0, +static_assert(ALPHASENSE_CO2_SENSE_RESISTOR_OHM > 0, "Sense resistor value must be positive"); #if !defined(ALPHASENSE_CO2_MFG_SCALE) || defined(DOXYGEN) /** @@ -361,9 +361,10 @@ class AlphasenseCO2_CO2 : public Variable { explicit AlphasenseCO2_CO2( AlphasenseCO2* parentSense, const char* uuid = "", const char* varCode = ALPHASENSE_CO2_DEFAULT_CODE) - : Variable(parentSense, (uint8_t)ALPHASENSE_CO2_VAR_NUM, - (uint8_t)ALPHASENSE_CO2_RESOLUTION, ALPHASENSE_CO2_VAR_NAME, - ALPHASENSE_CO2_UNIT_NAME, varCode, uuid) {} + : Variable(parentSense, static_cast(ALPHASENSE_CO2_VAR_NUM), + static_cast(ALPHASENSE_CO2_RESOLUTION), + ALPHASENSE_CO2_VAR_NAME, ALPHASENSE_CO2_UNIT_NAME, varCode, + uuid) {} /** * @brief Construct a new AlphasenseCO2_CO2 object. * @@ -371,9 +372,10 @@ class AlphasenseCO2_CO2 : public Variable { * used. */ AlphasenseCO2_CO2() - : Variable((uint8_t)ALPHASENSE_CO2_VAR_NUM, - (uint8_t)ALPHASENSE_CO2_RESOLUTION, ALPHASENSE_CO2_VAR_NAME, - ALPHASENSE_CO2_UNIT_NAME, ALPHASENSE_CO2_DEFAULT_CODE) {} + : Variable(static_cast(ALPHASENSE_CO2_VAR_NUM), + static_cast(ALPHASENSE_CO2_RESOLUTION), + ALPHASENSE_CO2_VAR_NAME, ALPHASENSE_CO2_UNIT_NAME, + ALPHASENSE_CO2_DEFAULT_CODE) {} /** * @brief Destroy the AlphasenseCO2_CO2 object - no action needed. */ @@ -403,8 +405,9 @@ class AlphasenseCO2_Voltage : public Variable { explicit AlphasenseCO2_Voltage( AlphasenseCO2* parentSense, const char* uuid = "", const char* varCode = ALPHASENSE_CO2_VOLTAGE_DEFAULT_CODE) - : Variable(parentSense, (uint8_t)ALPHASENSE_CO2_VOLTAGE_VAR_NUM, - (uint8_t)ALPHASENSE_CO2_VOLTAGE_RESOLUTION, + : Variable(parentSense, + static_cast(ALPHASENSE_CO2_VOLTAGE_VAR_NUM), + static_cast(ALPHASENSE_CO2_VOLTAGE_RESOLUTION), ALPHASENSE_CO2_VOLTAGE_VAR_NAME, ALPHASENSE_CO2_VOLTAGE_UNIT_NAME, varCode, uuid) {} /** @@ -414,8 +417,8 @@ class AlphasenseCO2_Voltage : public Variable { * used. */ AlphasenseCO2_Voltage() - : Variable((uint8_t)ALPHASENSE_CO2_VOLTAGE_VAR_NUM, - (uint8_t)ALPHASENSE_CO2_VOLTAGE_RESOLUTION, + : Variable(static_cast(ALPHASENSE_CO2_VOLTAGE_VAR_NUM), + static_cast(ALPHASENSE_CO2_VOLTAGE_RESOLUTION), ALPHASENSE_CO2_VOLTAGE_VAR_NAME, ALPHASENSE_CO2_VOLTAGE_UNIT_NAME, ALPHASENSE_CO2_VOLTAGE_DEFAULT_CODE) {} diff --git a/src/sensors/AnalogElecConductivity.h b/src/sensors/AnalogElecConductivity.h index d973c5015..1bc04de13 100644 --- a/src/sensors/AnalogElecConductivity.h +++ b/src/sensors/AnalogElecConductivity.h @@ -405,8 +405,9 @@ class AnalogElecConductivity_EC : public Variable { AnalogElecConductivity_EC( AnalogElecConductivity* parentSense, const char* uuid = "", const char* varCode = ANALOGELECCONDUCTIVITY_EC_DEFAULT_CODE) - : Variable(parentSense, (uint8_t)ANALOGELECCONDUCTIVITY_EC_VAR_NUM, - (uint8_t)ANALOGELECCONDUCTIVITY_EC_RESOLUTION, + : Variable(parentSense, + static_cast(ANALOGELECCONDUCTIVITY_EC_VAR_NUM), + static_cast(ANALOGELECCONDUCTIVITY_EC_RESOLUTION), ANALOGELECCONDUCTIVITY_EC_VAR_NAME, ANALOGELECCONDUCTIVITY_EC_UNIT_NAME, varCode, uuid) {} @@ -417,8 +418,8 @@ class AnalogElecConductivity_EC : public Variable { * can be used. */ AnalogElecConductivity_EC() - : Variable((uint8_t)ANALOGELECCONDUCTIVITY_EC_VAR_NUM, - (uint8_t)ANALOGELECCONDUCTIVITY_EC_RESOLUTION, + : Variable(static_cast(ANALOGELECCONDUCTIVITY_EC_VAR_NUM), + static_cast(ANALOGELECCONDUCTIVITY_EC_RESOLUTION), ANALOGELECCONDUCTIVITY_EC_VAR_NAME, ANALOGELECCONDUCTIVITY_EC_UNIT_NAME, ANALOGELECCONDUCTIVITY_EC_DEFAULT_CODE) {} diff --git a/src/sensors/ApogeeSQ212.h b/src/sensors/ApogeeSQ212.h index 77f8434c2..ffe71868e 100644 --- a/src/sensors/ApogeeSQ212.h +++ b/src/sensors/ApogeeSQ212.h @@ -329,16 +329,17 @@ class ApogeeSQ212_PAR : public Variable { */ explicit ApogeeSQ212_PAR(ApogeeSQ212* parentSense, const char* uuid = "", const char* varCode = SQ212_PAR_DEFAULT_CODE) - : Variable(parentSense, (uint8_t)SQ212_PAR_VAR_NUM, - (uint8_t)SQ212_PAR_RESOLUTION, SQ212_PAR_VAR_NAME, - SQ212_PAR_UNIT_NAME, varCode, uuid) {} + : Variable(parentSense, static_cast(SQ212_PAR_VAR_NUM), + static_cast(SQ212_PAR_RESOLUTION), + SQ212_PAR_VAR_NAME, SQ212_PAR_UNIT_NAME, varCode, uuid) {} /** * @brief Construct a new ApogeeSQ212_PAR object. * * @note This must be tied with a parent ApogeeSQ212 before it can be used. */ ApogeeSQ212_PAR() - : Variable((uint8_t)SQ212_PAR_VAR_NUM, (uint8_t)SQ212_PAR_RESOLUTION, + : Variable(static_cast(SQ212_PAR_VAR_NUM), + static_cast(SQ212_PAR_RESOLUTION), SQ212_PAR_VAR_NAME, SQ212_PAR_UNIT_NAME, SQ212_PAR_DEFAULT_CODE) {} /** @@ -372,18 +373,20 @@ class ApogeeSQ212_Voltage : public Variable { explicit ApogeeSQ212_Voltage( ApogeeSQ212* parentSense, const char* uuid = "", const char* varCode = SQ212_VOLTAGE_DEFAULT_CODE) - : Variable(parentSense, (uint8_t)SQ212_VOLTAGE_VAR_NUM, - (uint8_t)SQ212_VOLTAGE_RESOLUTION, SQ212_VOLTAGE_VAR_NAME, - SQ212_VOLTAGE_UNIT_NAME, varCode, uuid) {} + : Variable(parentSense, static_cast(SQ212_VOLTAGE_VAR_NUM), + static_cast(SQ212_VOLTAGE_RESOLUTION), + SQ212_VOLTAGE_VAR_NAME, SQ212_VOLTAGE_UNIT_NAME, varCode, + uuid) {} /** * @brief Construct a new ApogeeSQ212_Voltage object. * * @note This must be tied with a parent ApogeeSQ212 before it can be used. */ ApogeeSQ212_Voltage() - : Variable((uint8_t)SQ212_VOLTAGE_VAR_NUM, - (uint8_t)SQ212_VOLTAGE_RESOLUTION, SQ212_VOLTAGE_VAR_NAME, - SQ212_VOLTAGE_UNIT_NAME, SQ212_VOLTAGE_DEFAULT_CODE) {} + : Variable(static_cast(SQ212_VOLTAGE_VAR_NUM), + static_cast(SQ212_VOLTAGE_RESOLUTION), + SQ212_VOLTAGE_VAR_NAME, SQ212_VOLTAGE_UNIT_NAME, + SQ212_VOLTAGE_DEFAULT_CODE) {} /** * @brief Destroy the ApogeeSQ212_Voltage object - no action needed. */ diff --git a/src/sensors/AtlasScientificCO2.h b/src/sensors/AtlasScientificCO2.h index 38bdc59d7..6cc1be80e 100644 --- a/src/sensors/AtlasScientificCO2.h +++ b/src/sensors/AtlasScientificCO2.h @@ -271,9 +271,9 @@ class AtlasScientificCO2_CO2 : public Variable { explicit AtlasScientificCO2_CO2( AtlasScientificCO2* parentSense, const char* uuid = "", const char* varCode = ATLAS_CO2_DEFAULT_CODE) - : Variable(parentSense, (uint8_t)ATLAS_CO2_VAR_NUM, - (uint8_t)ATLAS_CO2_RESOLUTION, ATLAS_CO2_VAR_NAME, - ATLAS_CO2_UNIT_NAME, varCode, uuid) {} + : Variable(parentSense, static_cast(ATLAS_CO2_VAR_NUM), + static_cast(ATLAS_CO2_RESOLUTION), + ATLAS_CO2_VAR_NAME, ATLAS_CO2_UNIT_NAME, varCode, uuid) {} /** * @brief Construct a new AtlasScientificCO2_CO2 object. * @@ -281,7 +281,8 @@ class AtlasScientificCO2_CO2 : public Variable { * used. */ AtlasScientificCO2_CO2() - : Variable((uint8_t)ATLAS_CO2_VAR_NUM, (uint8_t)ATLAS_CO2_RESOLUTION, + : Variable(static_cast(ATLAS_CO2_VAR_NUM), + static_cast(ATLAS_CO2_RESOLUTION), ATLAS_CO2_VAR_NAME, ATLAS_CO2_UNIT_NAME, ATLAS_CO2_DEFAULT_CODE) {} /** @@ -314,9 +315,10 @@ class AtlasScientificCO2_Temp : public Variable { explicit AtlasScientificCO2_Temp( AtlasScientificCO2* parentSense, const char* uuid = "", const char* varCode = ATLAS_CO2TEMP_DEFAULT_CODE) - : Variable(parentSense, (uint8_t)ATLAS_CO2TEMP_VAR_NUM, - (uint8_t)ATLAS_CO2TEMP_RESOLUTION, ATLAS_CO2TEMP_VAR_NAME, - ATLAS_CO2TEMP_UNIT_NAME, varCode, uuid) {} + : Variable(parentSense, static_cast(ATLAS_CO2TEMP_VAR_NUM), + static_cast(ATLAS_CO2TEMP_RESOLUTION), + ATLAS_CO2TEMP_VAR_NAME, ATLAS_CO2TEMP_UNIT_NAME, varCode, + uuid) {} /** * @brief Construct a new AtlasScientificCO2_Temp object. * @@ -324,9 +326,10 @@ class AtlasScientificCO2_Temp : public Variable { * used. */ AtlasScientificCO2_Temp() - : Variable((uint8_t)ATLAS_CO2TEMP_VAR_NUM, - (uint8_t)ATLAS_CO2TEMP_RESOLUTION, ATLAS_CO2TEMP_VAR_NAME, - ATLAS_CO2TEMP_UNIT_NAME, ATLAS_CO2TEMP_DEFAULT_CODE) {} + : Variable(static_cast(ATLAS_CO2TEMP_VAR_NUM), + static_cast(ATLAS_CO2TEMP_RESOLUTION), + ATLAS_CO2TEMP_VAR_NAME, ATLAS_CO2TEMP_UNIT_NAME, + ATLAS_CO2TEMP_DEFAULT_CODE) {} /** * @brief Destroy the AtlasScientificCO2_Temp object - no action needed. */ diff --git a/src/sensors/AtlasScientificDO.cpp b/src/sensors/AtlasScientificDO.cpp index 218d54c2b..c25f0dbb3 100644 --- a/src/sensors/AtlasScientificDO.cpp +++ b/src/sensors/AtlasScientificDO.cpp @@ -23,7 +23,8 @@ AtlasScientificDO::AtlasScientificDO(TwoWire* theI2C, int8_t powerPin, // Delegating constructor AtlasScientificDO::AtlasScientificDO(int8_t powerPin, uint8_t i2cAddressHex, uint8_t measurementsToAverage) - : AtlasScientificDO(&Wire, powerPin, i2cAddressHex, measurementsToAverage) {} + : AtlasScientificDO(&Wire, powerPin, i2cAddressHex, measurementsToAverage) { +} // Setup diff --git a/src/sensors/AtlasScientificDO.h b/src/sensors/AtlasScientificDO.h index 56cd58630..2d04120c2 100644 --- a/src/sensors/AtlasScientificDO.h +++ b/src/sensors/AtlasScientificDO.h @@ -280,9 +280,10 @@ class AtlasScientificDO_DOmgL : public Variable { explicit AtlasScientificDO_DOmgL( AtlasScientificDO* parentSense, const char* uuid = "", const char* varCode = ATLAS_DOMGL_DEFAULT_CODE) - : Variable(parentSense, (uint8_t)ATLAS_DOMGL_VAR_NUM, - (uint8_t)ATLAS_DOMGL_RESOLUTION, ATLAS_DOMGL_VAR_NAME, - ATLAS_DOMGL_UNIT_NAME, varCode, uuid) {} + : Variable(parentSense, static_cast(ATLAS_DOMGL_VAR_NUM), + static_cast(ATLAS_DOMGL_RESOLUTION), + ATLAS_DOMGL_VAR_NAME, ATLAS_DOMGL_UNIT_NAME, varCode, uuid) { + } /** * @brief Construct a new AtlasScientificDO_DOmgL object. * @@ -290,9 +291,10 @@ class AtlasScientificDO_DOmgL : public Variable { * used. */ AtlasScientificDO_DOmgL() - : Variable((uint8_t)ATLAS_DOMGL_VAR_NUM, - (uint8_t)ATLAS_DOMGL_RESOLUTION, ATLAS_DOMGL_VAR_NAME, - ATLAS_DOMGL_UNIT_NAME, ATLAS_DOMGL_DEFAULT_CODE) {} + : Variable(static_cast(ATLAS_DOMGL_VAR_NUM), + static_cast(ATLAS_DOMGL_RESOLUTION), + ATLAS_DOMGL_VAR_NAME, ATLAS_DOMGL_UNIT_NAME, + ATLAS_DOMGL_DEFAULT_CODE) {} /** * @brief Destroy the AtlasScientificDO_DOmgL object - no action needed. */ @@ -323,9 +325,10 @@ class AtlasScientificDO_DOpct : public Variable { explicit AtlasScientificDO_DOpct( AtlasScientificDO* parentSense, const char* uuid = "", const char* varCode = ATLAS_DOPCT_DEFAULT_CODE) - : Variable(parentSense, (uint8_t)ATLAS_DOPCT_VAR_NUM, - (uint8_t)ATLAS_DOPCT_RESOLUTION, ATLAS_DOPCT_VAR_NAME, - ATLAS_DOPCT_UNIT_NAME, varCode, uuid) {} + : Variable(parentSense, static_cast(ATLAS_DOPCT_VAR_NUM), + static_cast(ATLAS_DOPCT_RESOLUTION), + ATLAS_DOPCT_VAR_NAME, ATLAS_DOPCT_UNIT_NAME, varCode, uuid) { + } /** * @brief Construct a new AtlasScientificDO_DOpct object. * @@ -333,9 +336,10 @@ class AtlasScientificDO_DOpct : public Variable { * used. */ AtlasScientificDO_DOpct() - : Variable((uint8_t)ATLAS_DOPCT_VAR_NUM, - (uint8_t)ATLAS_DOPCT_RESOLUTION, ATLAS_DOPCT_VAR_NAME, - ATLAS_DOPCT_UNIT_NAME, ATLAS_DOPCT_DEFAULT_CODE) {} + : Variable(static_cast(ATLAS_DOPCT_VAR_NUM), + static_cast(ATLAS_DOPCT_RESOLUTION), + ATLAS_DOPCT_VAR_NAME, ATLAS_DOPCT_UNIT_NAME, + ATLAS_DOPCT_DEFAULT_CODE) {} /** * @brief Destroy the AtlasScientificDO_DOpct object - no action needed. */ diff --git a/src/sensors/AtlasScientificEC.h b/src/sensors/AtlasScientificEC.h index 44d1de34a..645e92701 100644 --- a/src/sensors/AtlasScientificEC.h +++ b/src/sensors/AtlasScientificEC.h @@ -343,9 +343,9 @@ class AtlasScientificEC_Cond : public Variable { explicit AtlasScientificEC_Cond( AtlasScientificEC* parentSense, const char* uuid = "", const char* varCode = ATLAS_COND_DEFAULT_CODE) - : Variable(parentSense, (uint8_t)ATLAS_COND_VAR_NUM, - (uint8_t)ATLAS_COND_RESOLUTION, ATLAS_COND_VAR_NAME, - ATLAS_COND_UNIT_NAME, varCode, uuid) {} + : Variable(parentSense, static_cast(ATLAS_COND_VAR_NUM), + static_cast(ATLAS_COND_RESOLUTION), + ATLAS_COND_VAR_NAME, ATLAS_COND_UNIT_NAME, varCode, uuid) {} /** * @brief Construct a new AtlasScientificEC_Cond object. * @@ -353,7 +353,8 @@ class AtlasScientificEC_Cond : public Variable { * used. */ AtlasScientificEC_Cond() - : Variable((uint8_t)ATLAS_COND_VAR_NUM, (uint8_t)ATLAS_COND_RESOLUTION, + : Variable(static_cast(ATLAS_COND_VAR_NUM), + static_cast(ATLAS_COND_RESOLUTION), ATLAS_COND_VAR_NAME, ATLAS_COND_UNIT_NAME, ATLAS_COND_DEFAULT_CODE) {} /** @@ -386,9 +387,9 @@ class AtlasScientificEC_TDS : public Variable { explicit AtlasScientificEC_TDS(AtlasScientificEC* parentSense, const char* uuid = "", const char* varCode = ATLAS_TDS_DEFAULT_CODE) - : Variable(parentSense, (uint8_t)ATLAS_TDS_VAR_NUM, - (uint8_t)ATLAS_TDS_RESOLUTION, ATLAS_TDS_VAR_NAME, - ATLAS_TDS_UNIT_NAME, varCode, uuid) {} + : Variable(parentSense, static_cast(ATLAS_TDS_VAR_NUM), + static_cast(ATLAS_TDS_RESOLUTION), + ATLAS_TDS_VAR_NAME, ATLAS_TDS_UNIT_NAME, varCode, uuid) {} /** * @brief Construct a new AtlasScientificEC_TDS object. * @@ -396,7 +397,8 @@ class AtlasScientificEC_TDS : public Variable { * used. */ AtlasScientificEC_TDS() - : Variable((uint8_t)ATLAS_TDS_VAR_NUM, (uint8_t)ATLAS_TDS_RESOLUTION, + : Variable(static_cast(ATLAS_TDS_VAR_NUM), + static_cast(ATLAS_TDS_RESOLUTION), ATLAS_TDS_VAR_NAME, ATLAS_TDS_UNIT_NAME, ATLAS_TDS_DEFAULT_CODE) {} /** @@ -429,9 +431,10 @@ class AtlasScientificEC_Salinity : public Variable { explicit AtlasScientificEC_Salinity( AtlasScientificEC* parentSense, const char* uuid = "", const char* varCode = ATLAS_SALINITY_DEFAULT_CODE) - : Variable(parentSense, (uint8_t)ATLAS_SALINITY_VAR_NUM, - (uint8_t)ATLAS_SALINITY_RESOLUTION, ATLAS_SALINITY_VAR_NAME, - ATLAS_SALINITY_UNIT_NAME, varCode, uuid) {} + : Variable(parentSense, static_cast(ATLAS_SALINITY_VAR_NUM), + static_cast(ATLAS_SALINITY_RESOLUTION), + ATLAS_SALINITY_VAR_NAME, ATLAS_SALINITY_UNIT_NAME, varCode, + uuid) {} /** * @brief Construct a new AtlasScientificEC_Salinity object. * @@ -439,9 +442,10 @@ class AtlasScientificEC_Salinity : public Variable { * used. */ AtlasScientificEC_Salinity() - : Variable((uint8_t)ATLAS_SALINITY_VAR_NUM, - (uint8_t)ATLAS_SALINITY_RESOLUTION, ATLAS_SALINITY_VAR_NAME, - ATLAS_SALINITY_UNIT_NAME, ATLAS_SALINITY_DEFAULT_CODE) {} + : Variable(static_cast(ATLAS_SALINITY_VAR_NUM), + static_cast(ATLAS_SALINITY_RESOLUTION), + ATLAS_SALINITY_VAR_NAME, ATLAS_SALINITY_UNIT_NAME, + ATLAS_SALINITY_DEFAULT_CODE) {} /** * @brief Destroy the AtlasScientificEC_Salinity() object - no action * needed. @@ -473,8 +477,8 @@ class AtlasScientificEC_SpecificGravity : public Variable { explicit AtlasScientificEC_SpecificGravity( AtlasScientificEC* parentSense, const char* uuid = "", const char* varCode = ATLAS_SG_DEFAULT_CODE) - : Variable(parentSense, (uint8_t)ATLAS_SG_VAR_NUM, - (uint8_t)ATLAS_SG_RESOLUTION, ATLAS_SG_VAR_NAME, + : Variable(parentSense, static_cast(ATLAS_SG_VAR_NUM), + static_cast(ATLAS_SG_RESOLUTION), ATLAS_SG_VAR_NAME, ATLAS_SG_UNIT_NAME, varCode, uuid) {} /** * @brief Construct a new AtlasScientificEC_SpecificGravity object. @@ -483,9 +487,9 @@ class AtlasScientificEC_SpecificGravity : public Variable { * used. */ AtlasScientificEC_SpecificGravity() - : Variable((uint8_t)ATLAS_SG_VAR_NUM, (uint8_t)ATLAS_SG_RESOLUTION, - ATLAS_SG_VAR_NAME, ATLAS_SG_UNIT_NAME, - ATLAS_SG_DEFAULT_CODE) {} + : Variable(static_cast(ATLAS_SG_VAR_NUM), + static_cast(ATLAS_SG_RESOLUTION), ATLAS_SG_VAR_NAME, + ATLAS_SG_UNIT_NAME, ATLAS_SG_DEFAULT_CODE) {} /** * @brief Destroy the AtlasScientificEC_SpecificGravity() object - no action * needed. diff --git a/src/sensors/AtlasScientificORP.h b/src/sensors/AtlasScientificORP.h index dde101f76..cd925b0da 100644 --- a/src/sensors/AtlasScientificORP.h +++ b/src/sensors/AtlasScientificORP.h @@ -227,9 +227,9 @@ class AtlasScientificORP_Potential : public Variable { explicit AtlasScientificORP_Potential( AtlasScientificORP* parentSense, const char* uuid = "", const char* varCode = ATLAS_ORP_DEFAULT_CODE) - : Variable(parentSense, (uint8_t)ATLAS_ORP_VAR_NUM, - (uint8_t)ATLAS_ORP_RESOLUTION, ATLAS_ORP_VAR_NAME, - ATLAS_ORP_UNIT_NAME, varCode, uuid) {} + : Variable(parentSense, static_cast(ATLAS_ORP_VAR_NUM), + static_cast(ATLAS_ORP_RESOLUTION), + ATLAS_ORP_VAR_NAME, ATLAS_ORP_UNIT_NAME, varCode, uuid) {} /** * @brief Construct a new AtlasScientificORP_Potential object. * @@ -237,7 +237,8 @@ class AtlasScientificORP_Potential : public Variable { * used. */ AtlasScientificORP_Potential() - : Variable((uint8_t)ATLAS_ORP_VAR_NUM, (uint8_t)ATLAS_ORP_RESOLUTION, + : Variable(static_cast(ATLAS_ORP_VAR_NUM), + static_cast(ATLAS_ORP_RESOLUTION), ATLAS_ORP_VAR_NAME, ATLAS_ORP_UNIT_NAME, ATLAS_ORP_DEFAULT_CODE) {} /** diff --git a/src/sensors/AtlasScientificRTD.h b/src/sensors/AtlasScientificRTD.h index 5587e9eb5..0e1d074f4 100644 --- a/src/sensors/AtlasScientificRTD.h +++ b/src/sensors/AtlasScientificRTD.h @@ -234,9 +234,9 @@ class AtlasScientificRTD_Temp : public Variable { explicit AtlasScientificRTD_Temp( AtlasScientificRTD* parentSense, const char* uuid = "", const char* varCode = ATLAS_RTD_DEFAULT_CODE) - : Variable(parentSense, (uint8_t)ATLAS_RTD_VAR_NUM, - (uint8_t)ATLAS_RTD_RESOLUTION, ATLAS_RTD_VAR_NAME, - ATLAS_RTD_UNIT_NAME, varCode, uuid) {} + : Variable(parentSense, static_cast(ATLAS_RTD_VAR_NUM), + static_cast(ATLAS_RTD_RESOLUTION), + ATLAS_RTD_VAR_NAME, ATLAS_RTD_UNIT_NAME, varCode, uuid) {} /** * @brief Construct a new AtlasScientificRTD_Temp object. * @@ -244,7 +244,8 @@ class AtlasScientificRTD_Temp : public Variable { * used. */ AtlasScientificRTD_Temp() - : Variable((uint8_t)ATLAS_RTD_VAR_NUM, (uint8_t)ATLAS_RTD_RESOLUTION, + : Variable(static_cast(ATLAS_RTD_VAR_NUM), + static_cast(ATLAS_RTD_RESOLUTION), ATLAS_RTD_VAR_NAME, ATLAS_RTD_UNIT_NAME, ATLAS_RTD_DEFAULT_CODE) {} /** diff --git a/src/sensors/AtlasScientificpH.h b/src/sensors/AtlasScientificpH.h index 9069ed736..3e6daa7fd 100644 --- a/src/sensors/AtlasScientificpH.h +++ b/src/sensors/AtlasScientificpH.h @@ -235,8 +235,8 @@ class AtlasScientificpH_pH : public Variable { explicit AtlasScientificpH_pH(AtlasScientificpH* parentSense, const char* uuid = "", const char* varCode = ATLAS_PH_DEFAULT_CODE) - : Variable(parentSense, (uint8_t)ATLAS_PH_VAR_NUM, - (uint8_t)ATLAS_PH_RESOLUTION, ATLAS_PH_VAR_NAME, + : Variable(parentSense, static_cast(ATLAS_PH_VAR_NUM), + static_cast(ATLAS_PH_RESOLUTION), ATLAS_PH_VAR_NAME, ATLAS_PH_UNIT_NAME, varCode, uuid) {} /** * @brief Construct a new AtlasScientificpH_pH object. @@ -245,9 +245,9 @@ class AtlasScientificpH_pH : public Variable { * used. */ AtlasScientificpH_pH() - : Variable((uint8_t)ATLAS_PH_VAR_NUM, (uint8_t)ATLAS_PH_RESOLUTION, - ATLAS_PH_VAR_NAME, ATLAS_PH_UNIT_NAME, - ATLAS_PH_DEFAULT_CODE) {} + : Variable(static_cast(ATLAS_PH_VAR_NUM), + static_cast(ATLAS_PH_RESOLUTION), ATLAS_PH_VAR_NAME, + ATLAS_PH_UNIT_NAME, ATLAS_PH_DEFAULT_CODE) {} /** * @brief Destroy the AtlasScientificpH_pH object - no action needed. */ diff --git a/src/sensors/BoschBME280.h b/src/sensors/BoschBME280.h index 38492ad8d..66b0c918d 100644 --- a/src/sensors/BoschBME280.h +++ b/src/sensors/BoschBME280.h @@ -365,18 +365,20 @@ class BoschBME280_Temp : public Variable { */ explicit BoschBME280_Temp(BoschBME280* parentSense, const char* uuid = "", const char* varCode = BME280_TEMP_DEFAULT_CODE) - : Variable(parentSense, (uint8_t)BME280_TEMP_VAR_NUM, - (uint8_t)BME280_TEMP_RESOLUTION, BME280_TEMP_VAR_NAME, - BME280_TEMP_UNIT_NAME, varCode, uuid) {} + : Variable(parentSense, static_cast(BME280_TEMP_VAR_NUM), + static_cast(BME280_TEMP_RESOLUTION), + BME280_TEMP_VAR_NAME, BME280_TEMP_UNIT_NAME, varCode, uuid) { + } /** * @brief Construct a new BoschBME280_Temp object. * * @note This must be tied with a parent BoschBME280 before it can be used. */ BoschBME280_Temp() - : Variable((uint8_t)BME280_TEMP_VAR_NUM, - (uint8_t)BME280_TEMP_RESOLUTION, BME280_TEMP_VAR_NAME, - BME280_TEMP_UNIT_NAME, BME280_TEMP_DEFAULT_CODE) {} + : Variable(static_cast(BME280_TEMP_VAR_NUM), + static_cast(BME280_TEMP_RESOLUTION), + BME280_TEMP_VAR_NAME, BME280_TEMP_UNIT_NAME, + BME280_TEMP_DEFAULT_CODE) {} /** * @brief Destroy the BoschBME280_Temp object - no action needed. */ @@ -408,8 +410,8 @@ class BoschBME280_Humidity : public Variable { explicit BoschBME280_Humidity( BoschBME280* parentSense, const char* uuid = "", const char* varCode = BME280_HUMIDITY_DEFAULT_CODE) - : Variable(parentSense, (uint8_t)BME280_HUMIDITY_VAR_NUM, - (uint8_t)BME280_HUMIDITY_RESOLUTION, + : Variable(parentSense, static_cast(BME280_HUMIDITY_VAR_NUM), + static_cast(BME280_HUMIDITY_RESOLUTION), BME280_HUMIDITY_VAR_NAME, BME280_HUMIDITY_UNIT_NAME, varCode, uuid) {} /** @@ -418,8 +420,8 @@ class BoschBME280_Humidity : public Variable { * @note This must be tied with a parent BoschBME280 before it can be used. */ BoschBME280_Humidity() - : Variable((uint8_t)BME280_HUMIDITY_VAR_NUM, - (uint8_t)BME280_HUMIDITY_RESOLUTION, + : Variable(static_cast(BME280_HUMIDITY_VAR_NUM), + static_cast(BME280_HUMIDITY_RESOLUTION), BME280_HUMIDITY_VAR_NAME, BME280_HUMIDITY_UNIT_NAME, BME280_HUMIDITY_DEFAULT_CODE) {} /** @@ -453,8 +455,8 @@ class BoschBME280_Pressure : public Variable { explicit BoschBME280_Pressure( BoschBME280* parentSense, const char* uuid = "", const char* varCode = BME280_PRESSURE_DEFAULT_CODE) - : Variable(parentSense, (uint8_t)BME280_PRESSURE_VAR_NUM, - (uint8_t)BME280_PRESSURE_RESOLUTION, + : Variable(parentSense, static_cast(BME280_PRESSURE_VAR_NUM), + static_cast(BME280_PRESSURE_RESOLUTION), BME280_PRESSURE_VAR_NAME, BME280_PRESSURE_UNIT_NAME, varCode, uuid) {} /** @@ -463,8 +465,8 @@ class BoschBME280_Pressure : public Variable { * @note This must be tied with a parent BoschBME280 before it can be used. */ BoschBME280_Pressure() - : Variable((uint8_t)BME280_PRESSURE_VAR_NUM, - (uint8_t)BME280_PRESSURE_RESOLUTION, + : Variable(static_cast(BME280_PRESSURE_VAR_NUM), + static_cast(BME280_PRESSURE_RESOLUTION), BME280_PRESSURE_VAR_NAME, BME280_PRESSURE_UNIT_NAME, BME280_PRESSURE_DEFAULT_CODE) {} /** @@ -498,8 +500,8 @@ class BoschBME280_Altitude : public Variable { explicit BoschBME280_Altitude( BoschBME280* parentSense, const char* uuid = "", const char* varCode = BME280_ALTITUDE_DEFAULT_CODE) - : Variable(parentSense, (uint8_t)BME280_ALTITUDE_VAR_NUM, - (uint8_t)BME280_ALTITUDE_RESOLUTION, + : Variable(parentSense, static_cast(BME280_ALTITUDE_VAR_NUM), + static_cast(BME280_ALTITUDE_RESOLUTION), BME280_ALTITUDE_VAR_NAME, BME280_ALTITUDE_UNIT_NAME, varCode, uuid) {} /** @@ -508,8 +510,8 @@ class BoschBME280_Altitude : public Variable { * @note This must be tied with a parent BoschBME280 before it can be used. */ BoschBME280_Altitude() - : Variable((uint8_t)BME280_ALTITUDE_VAR_NUM, - (uint8_t)BME280_ALTITUDE_RESOLUTION, + : Variable(static_cast(BME280_ALTITUDE_VAR_NUM), + static_cast(BME280_ALTITUDE_RESOLUTION), BME280_ALTITUDE_VAR_NAME, BME280_ALTITUDE_UNIT_NAME, BME280_ALTITUDE_DEFAULT_CODE) {} /** diff --git a/src/sensors/BoschBMP3xx.h b/src/sensors/BoschBMP3xx.h index d4aecaa08..7ba425c04 100644 --- a/src/sensors/BoschBMP3xx.h +++ b/src/sensors/BoschBMP3xx.h @@ -593,18 +593,20 @@ class BoschBMP3xx_Temp : public Variable { */ explicit BoschBMP3xx_Temp(BoschBMP3xx* parentSense, const char* uuid = "", const char* varCode = BMP3XX_TEMP_DEFAULT_CODE) - : Variable(parentSense, (uint8_t)BMP3XX_TEMP_VAR_NUM, - (uint8_t)BMP3XX_TEMP_RESOLUTION, BMP3XX_TEMP_VAR_NAME, - BMP3XX_TEMP_UNIT_NAME, varCode, uuid) {} + : Variable(parentSense, static_cast(BMP3XX_TEMP_VAR_NUM), + static_cast(BMP3XX_TEMP_RESOLUTION), + BMP3XX_TEMP_VAR_NAME, BMP3XX_TEMP_UNIT_NAME, varCode, uuid) { + } /** * @brief Construct a new BoschBMP3xx_Temp object. * * @note This must be tied with a parent BoschBMP3xx before it can be used. */ BoschBMP3xx_Temp() - : Variable((uint8_t)BMP3XX_TEMP_VAR_NUM, - (uint8_t)BMP3XX_TEMP_RESOLUTION, BMP3XX_TEMP_VAR_NAME, - BMP3XX_TEMP_UNIT_NAME, BMP3XX_TEMP_DEFAULT_CODE) {} + : Variable(static_cast(BMP3XX_TEMP_VAR_NUM), + static_cast(BMP3XX_TEMP_RESOLUTION), + BMP3XX_TEMP_VAR_NAME, BMP3XX_TEMP_UNIT_NAME, + BMP3XX_TEMP_DEFAULT_CODE) {} /** * @brief Destroy the BoschBMP3xx_Temp object - no action needed. */ @@ -636,8 +638,8 @@ class BoschBMP3xx_Pressure : public Variable { explicit BoschBMP3xx_Pressure( BoschBMP3xx* parentSense, const char* uuid = "", const char* varCode = BMP3XX_PRESSURE_DEFAULT_CODE) - : Variable(parentSense, (uint8_t)BMP3XX_PRESSURE_VAR_NUM, - (uint8_t)BMP3XX_PRESSURE_RESOLUTION, + : Variable(parentSense, static_cast(BMP3XX_PRESSURE_VAR_NUM), + static_cast(BMP3XX_PRESSURE_RESOLUTION), BMP3XX_PRESSURE_VAR_NAME, BMP3XX_PRESSURE_UNIT_NAME, varCode, uuid) {} /** @@ -646,8 +648,8 @@ class BoschBMP3xx_Pressure : public Variable { * @note This must be tied with a parent BoschBMP3xx before it can be used. */ BoschBMP3xx_Pressure() - : Variable((uint8_t)BMP3XX_PRESSURE_VAR_NUM, - (uint8_t)BMP3XX_PRESSURE_RESOLUTION, + : Variable(static_cast(BMP3XX_PRESSURE_VAR_NUM), + static_cast(BMP3XX_PRESSURE_RESOLUTION), BMP3XX_PRESSURE_VAR_NAME, BMP3XX_PRESSURE_UNIT_NAME, BMP3XX_PRESSURE_DEFAULT_CODE) {} /** @@ -681,8 +683,8 @@ class BoschBMP3xx_Altitude : public Variable { explicit BoschBMP3xx_Altitude( BoschBMP3xx* parentSense, const char* uuid = "", const char* varCode = BMP3XX_ALTITUDE_DEFAULT_CODE) - : Variable(parentSense, (uint8_t)BMP3XX_ALTITUDE_VAR_NUM, - (uint8_t)BMP3XX_ALTITUDE_RESOLUTION, + : Variable(parentSense, static_cast(BMP3XX_ALTITUDE_VAR_NUM), + static_cast(BMP3XX_ALTITUDE_RESOLUTION), BMP3XX_ALTITUDE_VAR_NAME, BMP3XX_ALTITUDE_UNIT_NAME, varCode, uuid) {} /** @@ -691,8 +693,8 @@ class BoschBMP3xx_Altitude : public Variable { * @note This must be tied with a parent BoschBMP3xx before it can be used. */ BoschBMP3xx_Altitude() - : Variable((uint8_t)BMP3XX_ALTITUDE_VAR_NUM, - (uint8_t)BMP3XX_ALTITUDE_RESOLUTION, + : Variable(static_cast(BMP3XX_ALTITUDE_VAR_NUM), + static_cast(BMP3XX_ALTITUDE_RESOLUTION), BMP3XX_ALTITUDE_VAR_NAME, BMP3XX_ALTITUDE_UNIT_NAME, BMP3XX_ALTITUDE_DEFAULT_CODE) {} /** diff --git a/src/sensors/CampbellClariVUE10.h b/src/sensors/CampbellClariVUE10.h index 855d7874a..2c585b327 100644 --- a/src/sensors/CampbellClariVUE10.h +++ b/src/sensors/CampbellClariVUE10.h @@ -283,8 +283,9 @@ class CampbellClariVUE10_Turbidity : public Variable { explicit CampbellClariVUE10_Turbidity( CampbellClariVUE10* parentSense, const char* uuid = "", const char* varCode = CLARIVUE10_TURBIDITY_DEFAULT_CODE) - : Variable(parentSense, (uint8_t)CLARIVUE10_TURBIDITY_VAR_NUM, - (uint8_t)CLARIVUE10_TURBIDITY_RESOLUTION, + : Variable(parentSense, + static_cast(CLARIVUE10_TURBIDITY_VAR_NUM), + static_cast(CLARIVUE10_TURBIDITY_RESOLUTION), CLARIVUE10_TURBIDITY_VAR_NAME, CLARIVUE10_TURBIDITY_UNIT_NAME, varCode, uuid) {} /** @@ -294,8 +295,8 @@ class CampbellClariVUE10_Turbidity : public Variable { * used. */ CampbellClariVUE10_Turbidity() - : Variable((uint8_t)CLARIVUE10_TURBIDITY_VAR_NUM, - (uint8_t)CLARIVUE10_TURBIDITY_RESOLUTION, + : Variable(static_cast(CLARIVUE10_TURBIDITY_VAR_NUM), + static_cast(CLARIVUE10_TURBIDITY_RESOLUTION), CLARIVUE10_TURBIDITY_VAR_NAME, CLARIVUE10_TURBIDITY_UNIT_NAME, CLARIVUE10_TURBIDITY_DEFAULT_CODE) {} @@ -331,8 +332,8 @@ class CampbellClariVUE10_Temp : public Variable { explicit CampbellClariVUE10_Temp( CampbellClariVUE10* parentSense, const char* uuid = "", const char* varCode = CLARIVUE10_TEMP_DEFAULT_CODE) - : Variable(parentSense, (uint8_t)CLARIVUE10_TEMP_VAR_NUM, - (uint8_t)CLARIVUE10_TEMP_RESOLUTION, + : Variable(parentSense, static_cast(CLARIVUE10_TEMP_VAR_NUM), + static_cast(CLARIVUE10_TEMP_RESOLUTION), CLARIVUE10_TEMP_VAR_NAME, CLARIVUE10_TEMP_UNIT_NAME, varCode, uuid) {} /** @@ -342,8 +343,8 @@ class CampbellClariVUE10_Temp : public Variable { * used. */ CampbellClariVUE10_Temp() - : Variable((uint8_t)CLARIVUE10_TEMP_VAR_NUM, - (uint8_t)CLARIVUE10_TEMP_RESOLUTION, + : Variable(static_cast(CLARIVUE10_TEMP_VAR_NUM), + static_cast(CLARIVUE10_TEMP_RESOLUTION), CLARIVUE10_TEMP_VAR_NAME, CLARIVUE10_TEMP_UNIT_NAME, CLARIVUE10_TEMP_DEFAULT_CODE) {} /** @@ -377,8 +378,9 @@ class CampbellClariVUE10_ErrorCode : public Variable { explicit CampbellClariVUE10_ErrorCode( CampbellClariVUE10* parentSense, const char* uuid = "", const char* varCode = CLARIVUE10_ERRORCODE_DEFAULT_CODE) - : Variable(parentSense, (uint8_t)CLARIVUE10_ERRORCODE_VAR_NUM, - (uint8_t)CLARIVUE10_ERRORCODE_RESOLUTION, + : Variable(parentSense, + static_cast(CLARIVUE10_ERRORCODE_VAR_NUM), + static_cast(CLARIVUE10_ERRORCODE_RESOLUTION), CLARIVUE10_ERRORCODE_VAR_NAME, CLARIVUE10_ERRORCODE_UNIT_NAME, varCode, uuid) {} /** @@ -388,8 +390,8 @@ class CampbellClariVUE10_ErrorCode : public Variable { * used. */ CampbellClariVUE10_ErrorCode() - : Variable((uint8_t)CLARIVUE10_ERRORCODE_VAR_NUM, - (uint8_t)CLARIVUE10_ERRORCODE_RESOLUTION, + : Variable(static_cast(CLARIVUE10_ERRORCODE_VAR_NUM), + static_cast(CLARIVUE10_ERRORCODE_RESOLUTION), CLARIVUE10_ERRORCODE_VAR_NAME, CLARIVUE10_ERRORCODE_UNIT_NAME, CLARIVUE10_ERRORCODE_DEFAULT_CODE) {} diff --git a/src/sensors/CampbellOBS3.h b/src/sensors/CampbellOBS3.h index 30317b0c2..e4638fac2 100644 --- a/src/sensors/CampbellOBS3.h +++ b/src/sensors/CampbellOBS3.h @@ -336,8 +336,8 @@ class CampbellOBS3_Turbidity : public Variable { explicit CampbellOBS3_Turbidity( CampbellOBS3* parentSense, const char* uuid = "", const char* varCode = OBS3_TURB_DEFAULT_CODE) - : Variable(parentSense, (uint8_t)OBS3_TURB_VAR_NUM, - (uint8_t)OBS3_RESOLUTION, OBS3_TURB_VAR_NAME, + : Variable(parentSense, static_cast(OBS3_TURB_VAR_NUM), + static_cast(OBS3_RESOLUTION), OBS3_TURB_VAR_NAME, OBS3_TURB_UNIT_NAME, varCode, uuid) {} /** * @brief Construct a new CampbellOBS3_Turbidity object. @@ -345,9 +345,9 @@ class CampbellOBS3_Turbidity : public Variable { * @note This must be tied with a parent CampbellOBS3 before it can be used. */ CampbellOBS3_Turbidity() - : Variable((uint8_t)OBS3_TURB_VAR_NUM, (uint8_t)OBS3_RESOLUTION, - OBS3_TURB_VAR_NAME, OBS3_TURB_UNIT_NAME, - OBS3_TURB_DEFAULT_CODE) {} + : Variable(static_cast(OBS3_TURB_VAR_NUM), + static_cast(OBS3_RESOLUTION), OBS3_TURB_VAR_NAME, + OBS3_TURB_UNIT_NAME, OBS3_TURB_DEFAULT_CODE) {} /** * @brief Destroy the Campbell OBS3 Turbidity object */ @@ -381,18 +381,20 @@ class CampbellOBS3_Voltage : public Variable { explicit CampbellOBS3_Voltage( CampbellOBS3* parentSense, const char* uuid = "", const char* varCode = OBS3_VOLTAGE_DEFAULT_CODE) - : Variable(parentSense, (uint8_t)OBS3_VOLTAGE_VAR_NUM, - (uint8_t)OBS3_VOLTAGE_RESOLUTION, OBS3_VOLTAGE_VAR_NAME, - OBS3_VOLTAGE_UNIT_NAME, varCode, uuid) {} + : Variable(parentSense, static_cast(OBS3_VOLTAGE_VAR_NUM), + static_cast(OBS3_VOLTAGE_RESOLUTION), + OBS3_VOLTAGE_VAR_NAME, OBS3_VOLTAGE_UNIT_NAME, varCode, + uuid) {} /** * @brief Construct a new CampbellOBS3_Voltage object. * * @note This must be tied with a parent CampbellOBS3 before it can be used. */ CampbellOBS3_Voltage() - : Variable((uint8_t)OBS3_VOLTAGE_VAR_NUM, - (uint8_t)OBS3_VOLTAGE_RESOLUTION, OBS3_VOLTAGE_VAR_NAME, - OBS3_VOLTAGE_UNIT_NAME, OBS3_VOLTAGE_DEFAULT_CODE) {} + : Variable(static_cast(OBS3_VOLTAGE_VAR_NUM), + static_cast(OBS3_VOLTAGE_RESOLUTION), + OBS3_VOLTAGE_VAR_NAME, OBS3_VOLTAGE_UNIT_NAME, + OBS3_VOLTAGE_DEFAULT_CODE) {} /** * @brief Destroy the CampbellOBS3_Voltage object - no action needed. */ diff --git a/src/sensors/CampbellRainVUE10.h b/src/sensors/CampbellRainVUE10.h index 5f356317c..9ad672c8e 100644 --- a/src/sensors/CampbellRainVUE10.h +++ b/src/sensors/CampbellRainVUE10.h @@ -322,8 +322,9 @@ class CampbellRainVUE10_Precipitation : public Variable { explicit CampbellRainVUE10_Precipitation( CampbellRainVUE10* parentSense, const char* uuid = "", const char* varCode = RAINVUE10_PRECIPITATION_DEFAULT_CODE) - : Variable(parentSense, (uint8_t)RAINVUE10_PRECIPITATION_VAR_NUM, - (uint8_t)RAINVUE10_PRECIPITATION_RESOLUTION, + : Variable(parentSense, + static_cast(RAINVUE10_PRECIPITATION_VAR_NUM), + static_cast(RAINVUE10_PRECIPITATION_RESOLUTION), RAINVUE10_PRECIPITATION_VAR_NAME, RAINVUE10_PRECIPITATION_UNIT_NAME, varCode, uuid) {} /** @@ -333,8 +334,8 @@ class CampbellRainVUE10_Precipitation : public Variable { * used. */ CampbellRainVUE10_Precipitation() - : Variable((uint8_t)RAINVUE10_PRECIPITATION_VAR_NUM, - (uint8_t)RAINVUE10_PRECIPITATION_RESOLUTION, + : Variable(static_cast(RAINVUE10_PRECIPITATION_VAR_NUM), + static_cast(RAINVUE10_PRECIPITATION_RESOLUTION), RAINVUE10_PRECIPITATION_VAR_NAME, RAINVUE10_PRECIPITATION_UNIT_NAME, RAINVUE10_PRECIPITATION_DEFAULT_CODE) {} @@ -370,9 +371,10 @@ class CampbellRainVUE10_Tips : public Variable { explicit CampbellRainVUE10_Tips( CampbellRainVUE10* parentSense, const char* uuid = "", const char* varCode = RAINVUE10_TIPS_DEFAULT_CODE) - : Variable(parentSense, (uint8_t)RAINVUE10_TIPS_VAR_NUM, - (uint8_t)RAINVUE10_TIPS_RESOLUTION, RAINVUE10_TIPS_VAR_NAME, - RAINVUE10_TIPS_UNIT_NAME, varCode, uuid) {} + : Variable(parentSense, static_cast(RAINVUE10_TIPS_VAR_NUM), + static_cast(RAINVUE10_TIPS_RESOLUTION), + RAINVUE10_TIPS_VAR_NAME, RAINVUE10_TIPS_UNIT_NAME, varCode, + uuid) {} /** * @brief Construct a new CampbellRainVUE10_Tips object. * @@ -380,9 +382,10 @@ class CampbellRainVUE10_Tips : public Variable { * used. */ CampbellRainVUE10_Tips() - : Variable((uint8_t)RAINVUE10_TIPS_VAR_NUM, - (uint8_t)RAINVUE10_TIPS_RESOLUTION, RAINVUE10_TIPS_VAR_NAME, - RAINVUE10_TIPS_UNIT_NAME, RAINVUE10_TIPS_DEFAULT_CODE) {} + : Variable(static_cast(RAINVUE10_TIPS_VAR_NUM), + static_cast(RAINVUE10_TIPS_RESOLUTION), + RAINVUE10_TIPS_VAR_NAME, RAINVUE10_TIPS_UNIT_NAME, + RAINVUE10_TIPS_DEFAULT_CODE) {} /** * @brief Destroy the CampbellRainVUE10_Tips object - no action needed. */ @@ -414,8 +417,9 @@ class CampbellRainVUE10_RainRateAve : public Variable { explicit CampbellRainVUE10_RainRateAve( CampbellRainVUE10* parentSense, const char* uuid = "", const char* varCode = RAINVUE10_RAINRATEAVE_DEFAULT_CODE) - : Variable(parentSense, (uint8_t)RAINVUE10_RAINRATEAVE_VAR_NUM, - (uint8_t)RAINVUE10_RAINRATEAVE_RESOLUTION, + : Variable(parentSense, + static_cast(RAINVUE10_RAINRATEAVE_VAR_NUM), + static_cast(RAINVUE10_RAINRATEAVE_RESOLUTION), RAINVUE10_RAINRATEAVE_VAR_NAME, RAINVUE10_RAINRATEAVE_UNIT_NAME, varCode, uuid) {} /** @@ -425,8 +429,8 @@ class CampbellRainVUE10_RainRateAve : public Variable { * used. */ CampbellRainVUE10_RainRateAve() - : Variable((uint8_t)RAINVUE10_RAINRATEAVE_VAR_NUM, - (uint8_t)RAINVUE10_RAINRATEAVE_RESOLUTION, + : Variable(static_cast(RAINVUE10_RAINRATEAVE_VAR_NUM), + static_cast(RAINVUE10_RAINRATEAVE_RESOLUTION), RAINVUE10_RAINRATEAVE_VAR_NAME, RAINVUE10_RAINRATEAVE_UNIT_NAME, RAINVUE10_RAINRATEAVE_DEFAULT_CODE) {} @@ -463,8 +467,9 @@ class CampbellRainVUE10_RainRateMax : public Variable { explicit CampbellRainVUE10_RainRateMax( CampbellRainVUE10* parentSense, const char* uuid = "", const char* varCode = RAINVUE10_RAINRATEMAX_DEFAULT_CODE) - : Variable(parentSense, (uint8_t)RAINVUE10_RAINRATEMAX_VAR_NUM, - (uint8_t)RAINVUE10_RAINRATEMAX_RESOLUTION, + : Variable(parentSense, + static_cast(RAINVUE10_RAINRATEMAX_VAR_NUM), + static_cast(RAINVUE10_RAINRATEMAX_RESOLUTION), RAINVUE10_RAINRATEMAX_VAR_NAME, RAINVUE10_RAINRATEMAX_UNIT_NAME, varCode, uuid) {} /** @@ -474,8 +479,8 @@ class CampbellRainVUE10_RainRateMax : public Variable { * used. */ CampbellRainVUE10_RainRateMax() - : Variable((uint8_t)RAINVUE10_RAINRATEMAX_VAR_NUM, - (uint8_t)RAINVUE10_RAINRATEMAX_RESOLUTION, + : Variable(static_cast(RAINVUE10_RAINRATEMAX_VAR_NUM), + static_cast(RAINVUE10_RAINRATEMAX_RESOLUTION), RAINVUE10_RAINRATEMAX_VAR_NAME, RAINVUE10_RAINRATEMAX_UNIT_NAME, RAINVUE10_RAINRATEMAX_DEFAULT_CODE) {} diff --git a/src/sensors/Decagon5TM.h b/src/sensors/Decagon5TM.h index a8cca5857..67ddc7443 100644 --- a/src/sensors/Decagon5TM.h +++ b/src/sensors/Decagon5TM.h @@ -315,17 +315,18 @@ class Decagon5TM_Ea : public Variable { */ explicit Decagon5TM_Ea(Decagon5TM* parentSense, const char* uuid = "", const char* varCode = TM_EA_DEFAULT_CODE) - : Variable(parentSense, (uint8_t)TM_EA_VAR_NUM, - (uint8_t)TM_EA_RESOLUTION, TM_EA_VAR_NAME, TM_EA_UNIT_NAME, - varCode, uuid) {} + : Variable(parentSense, static_cast(TM_EA_VAR_NUM), + static_cast(TM_EA_RESOLUTION), TM_EA_VAR_NAME, + TM_EA_UNIT_NAME, varCode, uuid) {} /** * @brief Construct a new Decagon5TM_Ea object. * * @note This must be tied with a parent Decagon5TM before it can be used. */ Decagon5TM_Ea() - : Variable((uint8_t)TM_EA_VAR_NUM, (uint8_t)TM_EA_RESOLUTION, - TM_EA_VAR_NAME, TM_EA_UNIT_NAME, TM_EA_DEFAULT_CODE) {} + : Variable(static_cast(TM_EA_VAR_NUM), + static_cast(TM_EA_RESOLUTION), TM_EA_VAR_NAME, + TM_EA_UNIT_NAME, TM_EA_DEFAULT_CODE) {} /** * @brief Destroy the Decagon5TM_Ea object - no action needed. */ @@ -355,8 +356,8 @@ class Decagon5TM_Temp : public Variable { */ explicit Decagon5TM_Temp(Decagon5TM* parentSense, const char* uuid = "", const char* varCode = TM_TEMP_DEFAULT_CODE) - : Variable(parentSense, (uint8_t)TM_TEMP_VAR_NUM, - (uint8_t)TM_TEMP_RESOLUTION, TM_TEMP_VAR_NAME, + : Variable(parentSense, static_cast(TM_TEMP_VAR_NUM), + static_cast(TM_TEMP_RESOLUTION), TM_TEMP_VAR_NAME, TM_TEMP_UNIT_NAME, varCode, uuid) {} /** * @brief Construct a new Decagon5TM_Temp object. @@ -364,8 +365,9 @@ class Decagon5TM_Temp : public Variable { * @note This must be tied with a parent Decagon5TM before it can be used. */ Decagon5TM_Temp() - : Variable((uint8_t)TM_TEMP_VAR_NUM, (uint8_t)TM_TEMP_RESOLUTION, - TM_TEMP_VAR_NAME, TM_TEMP_UNIT_NAME, TM_TEMP_DEFAULT_CODE) {} + : Variable(static_cast(TM_TEMP_VAR_NUM), + static_cast(TM_TEMP_RESOLUTION), TM_TEMP_VAR_NAME, + TM_TEMP_UNIT_NAME, TM_TEMP_DEFAULT_CODE) {} /** * @brief Destroy the Decagon5TM_Temp object - no action needed. */ @@ -395,8 +397,8 @@ class Decagon5TM_VWC : public Variable { */ explicit Decagon5TM_VWC(Decagon5TM* parentSense, const char* uuid = "", const char* varCode = TM_VWC_DEFAULT_CODE) - : Variable(parentSense, (uint8_t)TM_VWC_VAR_NUM, - (uint8_t)TM_VWC_RESOLUTION, TM_VWC_VAR_NAME, + : Variable(parentSense, static_cast(TM_VWC_VAR_NUM), + static_cast(TM_VWC_RESOLUTION), TM_VWC_VAR_NAME, TM_VWC_UNIT_NAME, varCode, uuid) {} /** * @brief Construct a new Decagon5TM_VWC object. @@ -404,8 +406,9 @@ class Decagon5TM_VWC : public Variable { * @note This must be tied with a parent Decagon5TM before it can be used. */ Decagon5TM_VWC() - : Variable((uint8_t)TM_VWC_VAR_NUM, (uint8_t)TM_VWC_RESOLUTION, - TM_VWC_VAR_NAME, TM_VWC_UNIT_NAME, TM_VWC_DEFAULT_CODE) {} + : Variable(static_cast(TM_VWC_VAR_NUM), + static_cast(TM_VWC_RESOLUTION), TM_VWC_VAR_NAME, + TM_VWC_UNIT_NAME, TM_VWC_DEFAULT_CODE) {} /** * @brief Destroy the Decagon5TM_VWC object - no action needed. */ diff --git a/src/sensors/DecagonCTD.h b/src/sensors/DecagonCTD.h index 69a4c378c..ac62e860c 100644 --- a/src/sensors/DecagonCTD.h +++ b/src/sensors/DecagonCTD.h @@ -282,8 +282,8 @@ class DecagonCTD_Cond : public Variable { */ explicit DecagonCTD_Cond(DecagonCTD* parentSense, const char* uuid = "", const char* varCode = CTD_COND_DEFAULT_CODE) - : Variable(parentSense, (uint8_t)CTD_COND_VAR_NUM, - (uint8_t)CTD_COND_RESOLUTION, CTD_COND_VAR_NAME, + : Variable(parentSense, static_cast(CTD_COND_VAR_NUM), + static_cast(CTD_COND_RESOLUTION), CTD_COND_VAR_NAME, CTD_COND_UNIT_NAME, varCode, uuid) {} /** * @brief Construct a new DecagonCTD_Cond object. @@ -291,9 +291,9 @@ class DecagonCTD_Cond : public Variable { * @note This must be tied with a parent DecagonCTD before it can be used. */ DecagonCTD_Cond() - : Variable((uint8_t)CTD_COND_VAR_NUM, (uint8_t)CTD_COND_RESOLUTION, - CTD_COND_VAR_NAME, CTD_COND_UNIT_NAME, - CTD_COND_DEFAULT_CODE) {} + : Variable(static_cast(CTD_COND_VAR_NUM), + static_cast(CTD_COND_RESOLUTION), CTD_COND_VAR_NAME, + CTD_COND_UNIT_NAME, CTD_COND_DEFAULT_CODE) {} /** * @brief Destroy the DecagonCTD_Cond object - no action needed. */ @@ -323,8 +323,8 @@ class DecagonCTD_Temp : public Variable { */ explicit DecagonCTD_Temp(DecagonCTD* parentSense, const char* uuid = "", const char* varCode = CTD_TEMP_DEFAULT_CODE) - : Variable(parentSense, (uint8_t)CTD_TEMP_VAR_NUM, - (uint8_t)CTD_TEMP_RESOLUTION, CTD_TEMP_VAR_NAME, + : Variable(parentSense, static_cast(CTD_TEMP_VAR_NUM), + static_cast(CTD_TEMP_RESOLUTION), CTD_TEMP_VAR_NAME, CTD_TEMP_UNIT_NAME, varCode, uuid) {} /** * @brief Construct a new DecagonCTD_Temp object. @@ -332,9 +332,9 @@ class DecagonCTD_Temp : public Variable { * @note This must be tied with a parent DecagonCTD before it can be used. */ DecagonCTD_Temp() - : Variable((uint8_t)CTD_TEMP_VAR_NUM, (uint8_t)CTD_TEMP_RESOLUTION, - CTD_TEMP_VAR_NAME, CTD_TEMP_UNIT_NAME, - CTD_TEMP_DEFAULT_CODE) {} + : Variable(static_cast(CTD_TEMP_VAR_NUM), + static_cast(CTD_TEMP_RESOLUTION), CTD_TEMP_VAR_NAME, + CTD_TEMP_UNIT_NAME, CTD_TEMP_DEFAULT_CODE) {} /** * @brief Destroy the DecagonCTD_Temp object - no action needed. */ @@ -364,16 +364,17 @@ class DecagonCTD_Depth : public Variable { */ explicit DecagonCTD_Depth(DecagonCTD* parentSense, const char* uuid = "", const char* varCode = CTD_DEPTH_DEFAULT_CODE) - : Variable(parentSense, (uint8_t)CTD_DEPTH_VAR_NUM, - (uint8_t)CTD_DEPTH_RESOLUTION, CTD_DEPTH_VAR_NAME, - CTD_DEPTH_UNIT_NAME, varCode, uuid) {} + : Variable(parentSense, static_cast(CTD_DEPTH_VAR_NUM), + static_cast(CTD_DEPTH_RESOLUTION), + CTD_DEPTH_VAR_NAME, CTD_DEPTH_UNIT_NAME, varCode, uuid) {} /** * @brief Construct a new DecagonCTD_Depth object. * * @note This must be tied with a parent DecagonCTD before it can be used. */ DecagonCTD_Depth() - : Variable((uint8_t)CTD_DEPTH_VAR_NUM, (uint8_t)CTD_DEPTH_RESOLUTION, + : Variable(static_cast(CTD_DEPTH_VAR_NUM), + static_cast(CTD_DEPTH_RESOLUTION), CTD_DEPTH_VAR_NAME, CTD_DEPTH_UNIT_NAME, CTD_DEPTH_DEFAULT_CODE) {} /** diff --git a/src/sensors/DecagonES2.h b/src/sensors/DecagonES2.h index 4587f81f5..6a9f4367d 100644 --- a/src/sensors/DecagonES2.h +++ b/src/sensors/DecagonES2.h @@ -244,8 +244,8 @@ class DecagonES2_Cond : public Variable { */ explicit DecagonES2_Cond(DecagonES2* parentSense, const char* uuid = "", const char* varCode = ES2_COND_DEFAULT_CODE) - : Variable(parentSense, (uint8_t)ES2_COND_VAR_NUM, - (uint8_t)ES2_COND_RESOLUTION, ES2_COND_VAR_NAME, + : Variable(parentSense, static_cast(ES2_COND_VAR_NUM), + static_cast(ES2_COND_RESOLUTION), ES2_COND_VAR_NAME, ES2_COND_UNIT_NAME, varCode, uuid) {} /** * @brief Construct a new DecagonES2_Cond object. @@ -253,9 +253,9 @@ class DecagonES2_Cond : public Variable { * @note This must be tied with a parent DecagonES2 before it can be used. */ DecagonES2_Cond() - : Variable((uint8_t)ES2_COND_VAR_NUM, (uint8_t)ES2_COND_RESOLUTION, - ES2_COND_VAR_NAME, ES2_COND_UNIT_NAME, - ES2_COND_DEFAULT_CODE) {} + : Variable(static_cast(ES2_COND_VAR_NUM), + static_cast(ES2_COND_RESOLUTION), ES2_COND_VAR_NAME, + ES2_COND_UNIT_NAME, ES2_COND_DEFAULT_CODE) {} /** * @brief Destroy the DecagonES2_Cond object - no action needed. */ @@ -284,8 +284,8 @@ class DecagonES2_Temp : public Variable { */ explicit DecagonES2_Temp(DecagonES2* parentSense, const char* uuid = "", const char* varCode = ES2_TEMP_DEFAULT_CODE) - : Variable(parentSense, (uint8_t)ES2_TEMP_VAR_NUM, - (uint8_t)ES2_TEMP_RESOLUTION, ES2_TEMP_VAR_NAME, + : Variable(parentSense, static_cast(ES2_TEMP_VAR_NUM), + static_cast(ES2_TEMP_RESOLUTION), ES2_TEMP_VAR_NAME, ES2_TEMP_UNIT_NAME, varCode, uuid) {} /** * @brief Construct a new DecagonES2_Temp object. @@ -293,9 +293,9 @@ class DecagonES2_Temp : public Variable { * @note This must be tied with a parent DecagonES2 before it can be used. */ DecagonES2_Temp() - : Variable((uint8_t)ES2_TEMP_VAR_NUM, (uint8_t)ES2_TEMP_RESOLUTION, - ES2_TEMP_VAR_NAME, ES2_TEMP_UNIT_NAME, - ES2_TEMP_DEFAULT_CODE) {} + : Variable(static_cast(ES2_TEMP_VAR_NUM), + static_cast(ES2_TEMP_RESOLUTION), ES2_TEMP_VAR_NAME, + ES2_TEMP_UNIT_NAME, ES2_TEMP_DEFAULT_CODE) {} /** * @brief Destroy the DecagonES2_Temp object - no action needed. */ diff --git a/src/sensors/EverlightALSPT19.h b/src/sensors/EverlightALSPT19.h index 3e5a5ffc4..9f0579e7d 100644 --- a/src/sensors/EverlightALSPT19.h +++ b/src/sensors/EverlightALSPT19.h @@ -353,8 +353,8 @@ class EverlightALSPT19_Voltage : public Variable { explicit EverlightALSPT19_Voltage( EverlightALSPT19* parentSense, const char* uuid = "", const char* varCode = ALSPT19_VOLTAGE_DEFAULT_CODE) - : Variable(parentSense, (uint8_t)ALSPT19_VOLTAGE_VAR_NUM, - (uint8_t)ALSPT19_VOLTAGE_RESOLUTION, + : Variable(parentSense, static_cast(ALSPT19_VOLTAGE_VAR_NUM), + static_cast(ALSPT19_VOLTAGE_RESOLUTION), ALSPT19_VOLTAGE_VAR_NAME, ALSPT19_VOLTAGE_UNIT_NAME, varCode, uuid) {} /** @@ -364,8 +364,8 @@ class EverlightALSPT19_Voltage : public Variable { * used. */ EverlightALSPT19_Voltage() - : Variable((uint8_t)ALSPT19_VOLTAGE_VAR_NUM, - (uint8_t)ALSPT19_VOLTAGE_RESOLUTION, + : Variable(static_cast(ALSPT19_VOLTAGE_VAR_NUM), + static_cast(ALSPT19_VOLTAGE_RESOLUTION), ALSPT19_VOLTAGE_VAR_NAME, ALSPT19_VOLTAGE_UNIT_NAME, ALSPT19_VOLTAGE_DEFAULT_CODE) {} /** @@ -397,8 +397,8 @@ class EverlightALSPT19_Current : public Variable { explicit EverlightALSPT19_Current( EverlightALSPT19* parentSense, const char* uuid = "", const char* varCode = ALSPT19_CURRENT_DEFAULT_CODE) - : Variable(parentSense, (uint8_t)ALSPT19_CURRENT_VAR_NUM, - (uint8_t)ALSPT19_CURRENT_RESOLUTION, + : Variable(parentSense, static_cast(ALSPT19_CURRENT_VAR_NUM), + static_cast(ALSPT19_CURRENT_RESOLUTION), ALSPT19_CURRENT_VAR_NAME, ALSPT19_CURRENT_UNIT_NAME, varCode, uuid) {} /** @@ -408,8 +408,8 @@ class EverlightALSPT19_Current : public Variable { * used. */ EverlightALSPT19_Current() - : Variable((uint8_t)ALSPT19_CURRENT_VAR_NUM, - (uint8_t)ALSPT19_CURRENT_RESOLUTION, + : Variable(static_cast(ALSPT19_CURRENT_VAR_NUM), + static_cast(ALSPT19_CURRENT_RESOLUTION), ALSPT19_CURRENT_VAR_NAME, ALSPT19_CURRENT_UNIT_NAME, ALSPT19_CURRENT_DEFAULT_CODE) {} /** @@ -441,8 +441,9 @@ class EverlightALSPT19_Illuminance : public Variable { explicit EverlightALSPT19_Illuminance( EverlightALSPT19* parentSense, const char* uuid = "", const char* varCode = ALSPT19_ILLUMINANCE_DEFAULT_CODE) - : Variable(parentSense, (uint8_t)ALSPT19_ILLUMINANCE_VAR_NUM, - (uint8_t)ALSPT19_ILLUMINANCE_RESOLUTION, + : Variable(parentSense, + static_cast(ALSPT19_ILLUMINANCE_VAR_NUM), + static_cast(ALSPT19_ILLUMINANCE_RESOLUTION), ALSPT19_ILLUMINANCE_VAR_NAME, ALSPT19_ILLUMINANCE_UNIT_NAME, varCode, uuid) {} /** @@ -452,8 +453,8 @@ class EverlightALSPT19_Illuminance : public Variable { * used. */ EverlightALSPT19_Illuminance() - : Variable((uint8_t)ALSPT19_ILLUMINANCE_VAR_NUM, - (uint8_t)ALSPT19_ILLUMINANCE_RESOLUTION, + : Variable(static_cast(ALSPT19_ILLUMINANCE_VAR_NUM), + static_cast(ALSPT19_ILLUMINANCE_RESOLUTION), ALSPT19_ILLUMINANCE_VAR_NAME, ALSPT19_ILLUMINANCE_UNIT_NAME, ALSPT19_ILLUMINANCE_DEFAULT_CODE) {} /** diff --git a/src/sensors/FreescaleMPL115A2.h b/src/sensors/FreescaleMPL115A2.h index 2601ac228..39c20da40 100644 --- a/src/sensors/FreescaleMPL115A2.h +++ b/src/sensors/FreescaleMPL115A2.h @@ -283,9 +283,10 @@ class FreescaleMPL115A2_Temp : public Variable { explicit FreescaleMPL115A2_Temp( FreescaleMPL115A2* parentSense, const char* uuid = "", const char* varCode = MPL115A2_TEMP_DEFAULT_CODE) - : Variable(parentSense, (uint8_t)MPL115A2_TEMP_VAR_NUM, - (uint8_t)MPL115A2_TEMP_RESOLUTION, MPL115A2_TEMP_VAR_NAME, - MPL115A2_TEMP_UNIT_NAME, varCode, uuid) {} + : Variable(parentSense, static_cast(MPL115A2_TEMP_VAR_NUM), + static_cast(MPL115A2_TEMP_RESOLUTION), + MPL115A2_TEMP_VAR_NAME, MPL115A2_TEMP_UNIT_NAME, varCode, + uuid) {} /** * @brief Construct a new FreescaleMPL115A2_Temp object. * @@ -293,9 +294,10 @@ class FreescaleMPL115A2_Temp : public Variable { * used. */ FreescaleMPL115A2_Temp() - : Variable((uint8_t)MPL115A2_TEMP_VAR_NUM, - (uint8_t)MPL115A2_TEMP_RESOLUTION, MPL115A2_TEMP_VAR_NAME, - MPL115A2_TEMP_UNIT_NAME, MPL115A2_TEMP_DEFAULT_CODE) {} + : Variable(static_cast(MPL115A2_TEMP_VAR_NUM), + static_cast(MPL115A2_TEMP_RESOLUTION), + MPL115A2_TEMP_VAR_NAME, MPL115A2_TEMP_UNIT_NAME, + MPL115A2_TEMP_DEFAULT_CODE) {} /** * @brief Destroy the FreescaleMPL115A2_Temp object - no action needed. */ @@ -335,8 +337,8 @@ class FreescaleMPL115A2_Pressure : public Variable { explicit FreescaleMPL115A2_Pressure( FreescaleMPL115A2* parentSense, const char* uuid = "", const char* varCode = MPL115A2_PRESSURE_DEFAULT_CODE) - : Variable(parentSense, (uint8_t)MPL115A2_PRESSURE_VAR_NUM, - (uint8_t)MPL115A2_PRESSURE_RESOLUTION, + : Variable(parentSense, static_cast(MPL115A2_PRESSURE_VAR_NUM), + static_cast(MPL115A2_PRESSURE_RESOLUTION), MPL115A2_PRESSURE_VAR_NAME, MPL115A2_PRESSURE_UNIT_NAME, varCode, uuid) {} /** @@ -346,8 +348,8 @@ class FreescaleMPL115A2_Pressure : public Variable { * used. */ FreescaleMPL115A2_Pressure() - : Variable((uint8_t)MPL115A2_PRESSURE_VAR_NUM, - (uint8_t)MPL115A2_PRESSURE_RESOLUTION, + : Variable(static_cast(MPL115A2_PRESSURE_VAR_NUM), + static_cast(MPL115A2_PRESSURE_RESOLUTION), MPL115A2_PRESSURE_VAR_NAME, MPL115A2_PRESSURE_UNIT_NAME, MPL115A2_PRESSURE_DEFAULT_CODE) {} /** diff --git a/src/sensors/GeoluxHydroCam.h b/src/sensors/GeoluxHydroCam.h index 7b3c2e0f9..8a4331cad 100644 --- a/src/sensors/GeoluxHydroCam.h +++ b/src/sensors/GeoluxHydroCam.h @@ -443,9 +443,10 @@ class GeoluxHydroCam_ImageSize : public Variable { explicit GeoluxHydroCam_ImageSize( GeoluxHydroCam* parentSense, const char* uuid = "", const char* varCode = HYDROCAM_SIZE_DEFAULT_CODE) - : Variable(parentSense, (uint8_t)HYDROCAM_SIZE_VAR_NUM, - (uint8_t)HYDROCAM_SIZE_RESOLUTION, HYDROCAM_SIZE_VAR_NAME, - HYDROCAM_SIZE_UNIT_NAME, varCode, uuid) {} + : Variable(parentSense, static_cast(HYDROCAM_SIZE_VAR_NUM), + static_cast(HYDROCAM_SIZE_RESOLUTION), + HYDROCAM_SIZE_VAR_NAME, HYDROCAM_SIZE_UNIT_NAME, varCode, + uuid) {} /** * @brief Construct a new GeoluxHydroCam_ImageSize object. * @@ -453,9 +454,10 @@ class GeoluxHydroCam_ImageSize : public Variable { * used. */ GeoluxHydroCam_ImageSize() - : Variable((uint8_t)HYDROCAM_SIZE_VAR_NUM, - (uint8_t)HYDROCAM_SIZE_RESOLUTION, HYDROCAM_SIZE_VAR_NAME, - HYDROCAM_SIZE_UNIT_NAME, HYDROCAM_SIZE_DEFAULT_CODE) {} + : Variable(static_cast(HYDROCAM_SIZE_VAR_NUM), + static_cast(HYDROCAM_SIZE_RESOLUTION), + HYDROCAM_SIZE_VAR_NAME, HYDROCAM_SIZE_UNIT_NAME, + HYDROCAM_SIZE_DEFAULT_CODE) {} /** * @brief Destroy the GeoluxHydroCam_ImageSize object - no action needed. */ @@ -487,9 +489,10 @@ class GeoluxHydroCam_ByteError : public Variable { explicit GeoluxHydroCam_ByteError( GeoluxHydroCam* parentSense, const char* uuid = "", const char* varCode = HYDROCAM_ERROR_DEFAULT_CODE) - : Variable(parentSense, (uint8_t)HYDROCAM_ERROR_VAR_NUM, - (uint8_t)HYDROCAM_ERROR_RESOLUTION, HYDROCAM_ERROR_VAR_NAME, - HYDROCAM_ERROR_UNIT_NAME, varCode, uuid) {} + : Variable(parentSense, static_cast(HYDROCAM_ERROR_VAR_NUM), + static_cast(HYDROCAM_ERROR_RESOLUTION), + HYDROCAM_ERROR_VAR_NAME, HYDROCAM_ERROR_UNIT_NAME, varCode, + uuid) {} /** * @brief Construct a new GeoluxHydroCam_ByteError object. * @@ -497,9 +500,10 @@ class GeoluxHydroCam_ByteError : public Variable { * used. */ GeoluxHydroCam_ByteError() - : Variable((uint8_t)HYDROCAM_ERROR_VAR_NUM, - (uint8_t)HYDROCAM_ERROR_RESOLUTION, HYDROCAM_ERROR_VAR_NAME, - HYDROCAM_ERROR_UNIT_NAME, HYDROCAM_ERROR_DEFAULT_CODE) {} + : Variable(static_cast(HYDROCAM_ERROR_VAR_NUM), + static_cast(HYDROCAM_ERROR_RESOLUTION), + HYDROCAM_ERROR_VAR_NAME, HYDROCAM_ERROR_UNIT_NAME, + HYDROCAM_ERROR_DEFAULT_CODE) {} /** * @brief Destroy the GeoluxHydroCam_ByteError object - no action * needed. diff --git a/src/sensors/GroPointGPLP8.h b/src/sensors/GroPointGPLP8.h index a8596cc1c..9206921e7 100644 --- a/src/sensors/GroPointGPLP8.h +++ b/src/sensors/GroPointGPLP8.h @@ -226,7 +226,8 @@ class GroPointGPLP8_Moist : public Variable { const uint8_t sensorVarNum, const char* uuid = "", const char* varCode = GPLP8_MOIST_DEFAULT_CODE) - : Variable(parentSense, sensorVarNum, (uint8_t)GPLP8_MOIST_RESOLUTION, + : Variable(parentSense, sensorVarNum, + static_cast(GPLP8_MOIST_RESOLUTION), GPLP8_MOIST_VAR_NAME, GPLP8_MOIST_UNIT_NAME, varCode, uuid) { } /** @@ -241,7 +242,7 @@ class GroPointGPLP8_Moist : public Variable { * used. */ GroPointGPLP8_Moist(const uint8_t sensorVarNum) - : Variable(sensorVarNum, (uint8_t)GPLP8_MOIST_RESOLUTION, + : Variable(sensorVarNum, static_cast(GPLP8_MOIST_RESOLUTION), GPLP8_MOIST_VAR_NAME, GPLP8_MOIST_UNIT_NAME, GPLP8_MOIST_DEFAULT_CODE) {} /** @@ -279,7 +280,8 @@ class GroPointGPLP8_Temp : public Variable { const uint8_t sensorVarNum, const char* uuid = "", const char* varCode = GPLP8_TEMP_DEFAULT_CODE) - : Variable(parentSense, sensorVarNum, (uint8_t)GPLP8_TEMP_RESOLUTION, + : Variable(parentSense, sensorVarNum, + static_cast(GPLP8_TEMP_RESOLUTION), GPLP8_TEMP_VAR_NAME, GPLP8_TEMP_UNIT_NAME, varCode, uuid) {} /** * @brief Construct a new GroPointGPLP8_Temp object. @@ -293,7 +295,7 @@ class GroPointGPLP8_Temp : public Variable { * used. */ GroPointGPLP8_Temp(const uint8_t sensorVarNum) - : Variable(sensorVarNum, (uint8_t)GPLP8_TEMP_RESOLUTION, + : Variable(sensorVarNum, static_cast(GPLP8_TEMP_RESOLUTION), GPLP8_TEMP_VAR_NAME, GPLP8_TEMP_UNIT_NAME, GPLP8_TEMP_DEFAULT_CODE) {} /** diff --git a/src/sensors/InSituRDO.h b/src/sensors/InSituRDO.h index 7e699c36e..bf5728fa2 100644 --- a/src/sensors/InSituRDO.h +++ b/src/sensors/InSituRDO.h @@ -441,8 +441,8 @@ class InSituRDO_DOmgL : public Variable { explicit InSituRDO_DOmgL( InSituRDO* parentSense, const char* uuid = "", const char* varCode = INSITU_RDO_DOMGL_DEFAULT_CODE) - : Variable(parentSense, (uint8_t)INSITU_RDO_DOMGL_VAR_NUM, - (uint8_t)INSITU_RDO_DOMGL_RESOLUTION, + : Variable(parentSense, static_cast(INSITU_RDO_DOMGL_VAR_NUM), + static_cast(INSITU_RDO_DOMGL_RESOLUTION), INSITU_RDO_DOMGL_VAR_NAME, INSITU_RDO_DOMGL_UNIT_NAME, varCode, uuid) {} /** @@ -452,8 +452,8 @@ class InSituRDO_DOmgL : public Variable { * used. */ InSituRDO_DOmgL() - : Variable((uint8_t)INSITU_RDO_DOMGL_VAR_NUM, - (uint8_t)INSITU_RDO_DOMGL_RESOLUTION, + : Variable(static_cast(INSITU_RDO_DOMGL_VAR_NUM), + static_cast(INSITU_RDO_DOMGL_RESOLUTION), INSITU_RDO_DOMGL_VAR_NAME, INSITU_RDO_DOMGL_UNIT_NAME, INSITU_RDO_DOMGL_DEFAULT_CODE) {} /** @@ -487,8 +487,8 @@ class InSituRDO_DOpct : public Variable { explicit InSituRDO_DOpct( InSituRDO* parentSense, const char* uuid = "", const char* varCode = INSITU_RDO_DOPCT_DEFAULT_CODE) - : Variable(parentSense, (uint8_t)INSITU_RDO_DOPCT_VAR_NUM, - (uint8_t)INSITU_RDO_DOPCT_RESOLUTION, + : Variable(parentSense, static_cast(INSITU_RDO_DOPCT_VAR_NUM), + static_cast(INSITU_RDO_DOPCT_RESOLUTION), INSITU_RDO_DOPCT_VAR_NAME, INSITU_RDO_DOPCT_UNIT_NAME, varCode, uuid) {} /** @@ -498,8 +498,8 @@ class InSituRDO_DOpct : public Variable { * used. */ InSituRDO_DOpct() - : Variable((uint8_t)INSITU_RDO_DOPCT_VAR_NUM, - (uint8_t)INSITU_RDO_DOPCT_RESOLUTION, + : Variable(static_cast(INSITU_RDO_DOPCT_VAR_NUM), + static_cast(INSITU_RDO_DOPCT_RESOLUTION), INSITU_RDO_DOPCT_VAR_NAME, INSITU_RDO_DOPCT_UNIT_NAME, INSITU_RDO_DOPCT_DEFAULT_CODE) {} /** @@ -532,8 +532,8 @@ class InSituRDO_Temp : public Variable { */ explicit InSituRDO_Temp(InSituRDO* parentSense, const char* uuid = "", const char* varCode = INSITU_RDO_TEMP_DEFAULT_CODE) - : Variable(parentSense, (uint8_t)INSITU_RDO_TEMP_VAR_NUM, - (uint8_t)INSITU_RDO_TEMP_RESOLUTION, + : Variable(parentSense, static_cast(INSITU_RDO_TEMP_VAR_NUM), + static_cast(INSITU_RDO_TEMP_RESOLUTION), INSITU_RDO_TEMP_VAR_NAME, INSITU_RDO_TEMP_UNIT_NAME, varCode, uuid) {} /** @@ -543,8 +543,8 @@ class InSituRDO_Temp : public Variable { * used. */ InSituRDO_Temp() - : Variable((uint8_t)INSITU_RDO_TEMP_VAR_NUM, - (uint8_t)INSITU_RDO_TEMP_RESOLUTION, + : Variable(static_cast(INSITU_RDO_TEMP_VAR_NUM), + static_cast(INSITU_RDO_TEMP_RESOLUTION), INSITU_RDO_TEMP_VAR_NAME, INSITU_RDO_TEMP_UNIT_NAME, INSITU_RDO_TEMP_DEFAULT_CODE) {} /** @@ -578,8 +578,9 @@ class InSituRDO_Pressure : public Variable { explicit InSituRDO_Pressure( InSituRDO* parentSense, const char* uuid = "", const char* varCode = INSITU_RDO_PRESSURE_DEFAULT_CODE) - : Variable(parentSense, (uint8_t)INSITU_RDO_PRESSURE_VAR_NUM, - (uint8_t)INSITU_RDO_PRESSURE_RESOLUTION, + : Variable(parentSense, + static_cast(INSITU_RDO_PRESSURE_VAR_NUM), + static_cast(INSITU_RDO_PRESSURE_RESOLUTION), INSITU_RDO_PRESSURE_VAR_NAME, INSITU_RDO_PRESSURE_UNIT_NAME, varCode, uuid) {} /** @@ -589,8 +590,8 @@ class InSituRDO_Pressure : public Variable { * used. */ InSituRDO_Pressure() - : Variable((uint8_t)INSITU_RDO_PRESSURE_VAR_NUM, - (uint8_t)INSITU_RDO_PRESSURE_RESOLUTION, + : Variable(static_cast(INSITU_RDO_PRESSURE_VAR_NUM), + static_cast(INSITU_RDO_PRESSURE_RESOLUTION), INSITU_RDO_PRESSURE_VAR_NAME, INSITU_RDO_PRESSURE_UNIT_NAME, INSITU_RDO_PRESSURE_DEFAULT_CODE) {} /** diff --git a/src/sensors/InSituTrollSdi12a.h b/src/sensors/InSituTrollSdi12a.h index 785c5b4b1..dc61fcdd4 100644 --- a/src/sensors/InSituTrollSdi12a.h +++ b/src/sensors/InSituTrollSdi12a.h @@ -297,8 +297,8 @@ class InSituTrollSdi12a_Pressure : public Variable { InSituTrollSdi12a_Pressure( Sensor* parentSense, const char* uuid = "", const char* varCode = ITROLLA_PRESSURE_DEFAULT_CODE) - : Variable(parentSense, (uint8_t)ITROLLA_PRESSURE_VAR_NUM, - (uint8_t)ITROLLA_PRESSURE_RESOLUTION, + : Variable(parentSense, static_cast(ITROLLA_PRESSURE_VAR_NUM), + static_cast(ITROLLA_PRESSURE_RESOLUTION), ITROLLA_PRESSURE_VAR_NAME, ITROLLA_PRESSURE_UNIT_NAME, varCode, uuid) {} /** @@ -308,8 +308,8 @@ class InSituTrollSdi12a_Pressure : public Variable { * used. */ InSituTrollSdi12a_Pressure() - : Variable((uint8_t)ITROLLA_PRESSURE_VAR_NUM, - (uint8_t)ITROLLA_PRESSURE_RESOLUTION, + : Variable(static_cast(ITROLLA_PRESSURE_VAR_NUM), + static_cast(ITROLLA_PRESSURE_RESOLUTION), ITROLLA_PRESSURE_VAR_NAME, ITROLLA_PRESSURE_UNIT_NAME, ITROLLA_PRESSURE_DEFAULT_CODE) {} /** @@ -341,9 +341,10 @@ class InSituTrollSdi12a_Temp : public Variable { */ InSituTrollSdi12a_Temp(Sensor* parentSense, const char* uuid = "", const char* varCode = ITROLLA_TEMP_DEFAULT_CODE) - : Variable(parentSense, (uint8_t)ITROLLA_TEMP_VAR_NUM, - (uint8_t)ITROLLA_TEMP_RESOLUTION, ITROLLA_TEMP_TEMP_VAR_NAME, - ITROLLA_TEMP_TEMP_UNIT_NAME, varCode, uuid) {} + : Variable(parentSense, static_cast(ITROLLA_TEMP_VAR_NUM), + static_cast(ITROLLA_TEMP_RESOLUTION), + ITROLLA_TEMP_TEMP_VAR_NAME, ITROLLA_TEMP_TEMP_UNIT_NAME, + varCode, uuid) {} /** * @brief Construct a new InSituTrollSdi12a_Temp object. @@ -352,9 +353,10 @@ class InSituTrollSdi12a_Temp : public Variable { * used. */ InSituTrollSdi12a_Temp() - : Variable((uint8_t)ITROLLA_TEMP_VAR_NUM, - (uint8_t)ITROLLA_TEMP_RESOLUTION, ITROLLA_TEMP_TEMP_VAR_NAME, - ITROLLA_TEMP_TEMP_UNIT_NAME, ITROLLA_TEMP_DEFAULT_CODE) {} + : Variable(static_cast(ITROLLA_TEMP_VAR_NUM), + static_cast(ITROLLA_TEMP_RESOLUTION), + ITROLLA_TEMP_TEMP_VAR_NAME, ITROLLA_TEMP_TEMP_UNIT_NAME, + ITROLLA_TEMP_DEFAULT_CODE) {} /** * @brief Destroy the InSituTrollSdi12a_Temp object - no action needed. */ @@ -384,9 +386,10 @@ class InSituTrollSdi12a_Depth : public Variable { */ InSituTrollSdi12a_Depth(Sensor* parentSense, const char* uuid = "", const char* varCode = ITROLLA_DEPTH_DEFAULT_CODE) - : Variable(parentSense, (uint8_t)ITROLLA_DEPTH_VAR_NUM, - (uint8_t)ITROLLA_DEPTH_RESOLUTION, ITROLLA_DEPTH_VAR_NAME, - ITROLLA_DEPTH_UNIT_NAME, varCode, uuid) {} + : Variable(parentSense, static_cast(ITROLLA_DEPTH_VAR_NUM), + static_cast(ITROLLA_DEPTH_RESOLUTION), + ITROLLA_DEPTH_VAR_NAME, ITROLLA_DEPTH_UNIT_NAME, varCode, + uuid) {} /** * @brief Construct a new InSituTrollSdi12a_Depth object. * @@ -394,9 +397,10 @@ class InSituTrollSdi12a_Depth : public Variable { * used. */ InSituTrollSdi12a_Depth() - : Variable((uint8_t)ITROLLA_DEPTH_VAR_NUM, - (uint8_t)ITROLLA_DEPTH_RESOLUTION, ITROLLA_DEPTH_VAR_NAME, - ITROLLA_DEPTH_UNIT_NAME, ITROLLA_DEPTH_DEFAULT_CODE) {} + : Variable(static_cast(ITROLLA_DEPTH_VAR_NUM), + static_cast(ITROLLA_DEPTH_RESOLUTION), + ITROLLA_DEPTH_VAR_NAME, ITROLLA_DEPTH_UNIT_NAME, + ITROLLA_DEPTH_DEFAULT_CODE) {} /** * @brief Destroy the InSituTrollSdi12a_Depth object - no action needed. */ diff --git a/src/sensors/KellerAcculevel.h b/src/sensors/KellerAcculevel.h index 8088041e6..7033028a5 100644 --- a/src/sensors/KellerAcculevel.h +++ b/src/sensors/KellerAcculevel.h @@ -207,8 +207,8 @@ class KellerAcculevel_Pressure : public Variable { explicit KellerAcculevel_Pressure( KellerAcculevel* parentSense, const char* uuid = "", const char* varCode = ACCULEVEL_PRESSURE_DEFAULT_CODE) - : Variable(parentSense, (uint8_t)KELLER_PRESSURE_VAR_NUM, - (uint8_t)ACCULEVEL_PRESSURE_RESOLUTION, + : Variable(parentSense, static_cast(KELLER_PRESSURE_VAR_NUM), + static_cast(ACCULEVEL_PRESSURE_RESOLUTION), KELLER_PRESSURE_VAR_NAME, KELLER_PRESSURE_UNIT_NAME, varCode, uuid) {} /** @@ -218,8 +218,8 @@ class KellerAcculevel_Pressure : public Variable { * used. */ KellerAcculevel_Pressure() - : Variable((uint8_t)KELLER_PRESSURE_VAR_NUM, - (uint8_t)ACCULEVEL_PRESSURE_RESOLUTION, + : Variable(static_cast(KELLER_PRESSURE_VAR_NUM), + static_cast(ACCULEVEL_PRESSURE_RESOLUTION), KELLER_PRESSURE_VAR_NAME, KELLER_PRESSURE_UNIT_NAME, ACCULEVEL_PRESSURE_DEFAULT_CODE) {} /** @@ -253,9 +253,10 @@ class KellerAcculevel_Temp : public Variable { explicit KellerAcculevel_Temp( KellerAcculevel* parentSense, const char* uuid = "", const char* varCode = ACCULEVEL_TEMP_DEFAULT_CODE) - : Variable(parentSense, (uint8_t)KELLER_TEMP_VAR_NUM, - (uint8_t)ACCULEVEL_TEMP_RESOLUTION, KELLER_TEMP_VAR_NAME, - KELLER_TEMP_UNIT_NAME, varCode, uuid) {} + : Variable(parentSense, static_cast(KELLER_TEMP_VAR_NUM), + static_cast(ACCULEVEL_TEMP_RESOLUTION), + KELLER_TEMP_VAR_NAME, KELLER_TEMP_UNIT_NAME, varCode, uuid) { + } /** * @brief Construct a new KellerAcculevel_Temp object. * @@ -263,9 +264,10 @@ class KellerAcculevel_Temp : public Variable { * used. */ KellerAcculevel_Temp() - : Variable((uint8_t)KELLER_TEMP_VAR_NUM, - (uint8_t)ACCULEVEL_TEMP_RESOLUTION, KELLER_TEMP_VAR_NAME, - KELLER_TEMP_UNIT_NAME, ACCULEVEL_TEMP_DEFAULT_CODE) {} + : Variable(static_cast(KELLER_TEMP_VAR_NUM), + static_cast(ACCULEVEL_TEMP_RESOLUTION), + KELLER_TEMP_VAR_NAME, KELLER_TEMP_UNIT_NAME, + ACCULEVEL_TEMP_DEFAULT_CODE) {} /** * @brief Destroy the KellerAcculevel_Temp object - no action needed. */ @@ -297,9 +299,10 @@ class KellerAcculevel_Height : public Variable { explicit KellerAcculevel_Height( KellerAcculevel* parentSense, const char* uuid = "", const char* varCode = ACCULEVEL_HEIGHT_DEFAULT_CODE) - : Variable(parentSense, (uint8_t)KELLER_HEIGHT_VAR_NUM, - (uint8_t)ACCULEVEL_HEIGHT_RESOLUTION, KELLER_HEIGHT_VAR_NAME, - KELLER_HEIGHT_UNIT_NAME, varCode, uuid) {} + : Variable(parentSense, static_cast(KELLER_HEIGHT_VAR_NUM), + static_cast(ACCULEVEL_HEIGHT_RESOLUTION), + KELLER_HEIGHT_VAR_NAME, KELLER_HEIGHT_UNIT_NAME, varCode, + uuid) {} /** * @brief Construct a new KellerAcculevel_Height object. * @@ -307,9 +310,10 @@ class KellerAcculevel_Height : public Variable { * used. */ KellerAcculevel_Height() - : Variable((uint8_t)KELLER_HEIGHT_VAR_NUM, - (uint8_t)ACCULEVEL_HEIGHT_RESOLUTION, KELLER_HEIGHT_VAR_NAME, - KELLER_HEIGHT_UNIT_NAME, ACCULEVEL_HEIGHT_DEFAULT_CODE) {} + : Variable(static_cast(KELLER_HEIGHT_VAR_NUM), + static_cast(ACCULEVEL_HEIGHT_RESOLUTION), + KELLER_HEIGHT_VAR_NAME, KELLER_HEIGHT_UNIT_NAME, + ACCULEVEL_HEIGHT_DEFAULT_CODE) {} /** * @brief Destroy the KellerAcculevel_Height object - no action needed. */ diff --git a/src/sensors/KellerNanolevel.h b/src/sensors/KellerNanolevel.h index 8a210f004..34a53d19d 100644 --- a/src/sensors/KellerNanolevel.h +++ b/src/sensors/KellerNanolevel.h @@ -199,8 +199,8 @@ class KellerNanolevel_Pressure : public Variable { explicit KellerNanolevel_Pressure( KellerNanolevel* parentSense, const char* uuid = "", const char* varCode = NANOLEVEL_PRESSURE_DEFAULT_CODE) - : Variable(parentSense, (uint8_t)KELLER_PRESSURE_VAR_NUM, - (uint8_t)NANOLEVEL_PRESSURE_RESOLUTION, + : Variable(parentSense, static_cast(KELLER_PRESSURE_VAR_NUM), + static_cast(NANOLEVEL_PRESSURE_RESOLUTION), KELLER_PRESSURE_VAR_NAME, KELLER_PRESSURE_UNIT_NAME, varCode, uuid) {} /** @@ -210,8 +210,8 @@ class KellerNanolevel_Pressure : public Variable { * used. */ KellerNanolevel_Pressure() - : Variable((uint8_t)KELLER_PRESSURE_VAR_NUM, - (uint8_t)NANOLEVEL_PRESSURE_RESOLUTION, + : Variable(static_cast(KELLER_PRESSURE_VAR_NUM), + static_cast(NANOLEVEL_PRESSURE_RESOLUTION), KELLER_PRESSURE_VAR_NAME, KELLER_PRESSURE_UNIT_NAME, NANOLEVEL_PRESSURE_DEFAULT_CODE) {} /** @@ -245,9 +245,10 @@ class KellerNanolevel_Temp : public Variable { explicit KellerNanolevel_Temp( KellerNanolevel* parentSense, const char* uuid = "", const char* varCode = NANOLEVEL_TEMP_DEFAULT_CODE) - : Variable(parentSense, (uint8_t)KELLER_TEMP_VAR_NUM, - (uint8_t)NANOLEVEL_TEMP_RESOLUTION, KELLER_TEMP_VAR_NAME, - KELLER_TEMP_UNIT_NAME, varCode, uuid) {} + : Variable(parentSense, static_cast(KELLER_TEMP_VAR_NUM), + static_cast(NANOLEVEL_TEMP_RESOLUTION), + KELLER_TEMP_VAR_NAME, KELLER_TEMP_UNIT_NAME, varCode, uuid) { + } /** * @brief Construct a new KellerNanolevel_Temp object. * @@ -255,9 +256,10 @@ class KellerNanolevel_Temp : public Variable { * used. */ KellerNanolevel_Temp() - : Variable((uint8_t)KELLER_TEMP_VAR_NUM, - (uint8_t)NANOLEVEL_TEMP_RESOLUTION, KELLER_TEMP_VAR_NAME, - KELLER_TEMP_UNIT_NAME, NANOLEVEL_TEMP_DEFAULT_CODE) {} + : Variable(static_cast(KELLER_TEMP_VAR_NUM), + static_cast(NANOLEVEL_TEMP_RESOLUTION), + KELLER_TEMP_VAR_NAME, KELLER_TEMP_UNIT_NAME, + NANOLEVEL_TEMP_DEFAULT_CODE) {} /** * @brief Destroy the KellerNanolevel_Temp object - no action needed. */ @@ -289,9 +291,10 @@ class KellerNanolevel_Height : public Variable { explicit KellerNanolevel_Height( KellerNanolevel* parentSense, const char* uuid = "", const char* varCode = NANOLEVEL_HEIGHT_DEFAULT_CODE) - : Variable(parentSense, (uint8_t)KELLER_HEIGHT_VAR_NUM, - (uint8_t)NANOLEVEL_HEIGHT_RESOLUTION, KELLER_HEIGHT_VAR_NAME, - KELLER_HEIGHT_UNIT_NAME, varCode, uuid) {} + : Variable(parentSense, static_cast(KELLER_HEIGHT_VAR_NUM), + static_cast(NANOLEVEL_HEIGHT_RESOLUTION), + KELLER_HEIGHT_VAR_NAME, KELLER_HEIGHT_UNIT_NAME, varCode, + uuid) {} /** * @brief Construct a new KellerNanolevel_Height object. * @@ -299,9 +302,10 @@ class KellerNanolevel_Height : public Variable { * used. */ KellerNanolevel_Height() - : Variable((uint8_t)KELLER_HEIGHT_VAR_NUM, - (uint8_t)NANOLEVEL_HEIGHT_RESOLUTION, KELLER_HEIGHT_VAR_NAME, - KELLER_HEIGHT_UNIT_NAME, NANOLEVEL_HEIGHT_DEFAULT_CODE) {} + : Variable(static_cast(KELLER_HEIGHT_VAR_NUM), + static_cast(NANOLEVEL_HEIGHT_RESOLUTION), + KELLER_HEIGHT_VAR_NAME, KELLER_HEIGHT_UNIT_NAME, + NANOLEVEL_HEIGHT_DEFAULT_CODE) {} /** * @brief Destroy the KellerNanolevel_Height object - no action needed. */ diff --git a/src/sensors/MaxBotixSonar.h b/src/sensors/MaxBotixSonar.h index 539f5f712..f158c00d2 100644 --- a/src/sensors/MaxBotixSonar.h +++ b/src/sensors/MaxBotixSonar.h @@ -297,8 +297,9 @@ class MaxBotixSonar_Range : public Variable { explicit MaxBotixSonar_Range(MaxBotixSonar* parentSense, const char* uuid = "", const char* varCode = HRXL_DEFAULT_CODE) - : Variable(parentSense, (uint8_t)HRXL_VAR_NUM, (uint8_t)HRXL_RESOLUTION, - HRXL_VAR_NAME, HRXL_UNIT_NAME, varCode, uuid) {} + : Variable(parentSense, static_cast(HRXL_VAR_NUM), + static_cast(HRXL_RESOLUTION), HRXL_VAR_NAME, + HRXL_UNIT_NAME, varCode, uuid) {} /** * @brief Construct a new MaxBotixSonar_Range object. * @@ -306,8 +307,9 @@ class MaxBotixSonar_Range : public Variable { * used. */ MaxBotixSonar_Range() - : Variable((uint8_t)HRXL_VAR_NUM, (uint8_t)HRXL_RESOLUTION, - HRXL_VAR_NAME, HRXL_UNIT_NAME, HRXL_DEFAULT_CODE) {} + : Variable(static_cast(HRXL_VAR_NUM), + static_cast(HRXL_RESOLUTION), HRXL_VAR_NAME, + HRXL_UNIT_NAME, HRXL_DEFAULT_CODE) {} /** * @brief Destroy the MaxBotixSonar_Range object - no action needed. */ diff --git a/src/sensors/MaximDS18.h b/src/sensors/MaximDS18.h index 4c028344a..89f258aea 100644 --- a/src/sensors/MaximDS18.h +++ b/src/sensors/MaximDS18.h @@ -309,16 +309,17 @@ class MaximDS18_Temp : public Variable { */ explicit MaximDS18_Temp(MaximDS18* parentSense, const char* uuid = "", const char* varCode = DS18_TEMP_DEFAULT_CODE) - : Variable(parentSense, (uint8_t)DS18_TEMP_VAR_NUM, - (uint8_t)DS18_TEMP_RESOLUTION, DS18_TEMP_VAR_NAME, - DS18_TEMP_UNIT_NAME, varCode, uuid) {} + : Variable(parentSense, static_cast(DS18_TEMP_VAR_NUM), + static_cast(DS18_TEMP_RESOLUTION), + DS18_TEMP_VAR_NAME, DS18_TEMP_UNIT_NAME, varCode, uuid) {} /** * @brief Construct a new MaximDS18_Temp object. * * @note This must be tied with a parent MaximDS18 before it can be used. */ MaximDS18_Temp() - : Variable((uint8_t)DS18_TEMP_VAR_NUM, (uint8_t)DS18_TEMP_RESOLUTION, + : Variable(static_cast(DS18_TEMP_VAR_NUM), + static_cast(DS18_TEMP_RESOLUTION), DS18_TEMP_VAR_NAME, DS18_TEMP_UNIT_NAME, DS18_TEMP_DEFAULT_CODE) {} /** diff --git a/src/sensors/MaximDS3231.h b/src/sensors/MaximDS3231.h index 5c993beb3..564499ce3 100644 --- a/src/sensors/MaximDS3231.h +++ b/src/sensors/MaximDS3231.h @@ -221,18 +221,20 @@ class MaximDS3231_Temp : public Variable { */ explicit MaximDS3231_Temp(MaximDS3231* parentSense, const char* uuid = "", const char* varCode = DS3231_TEMP_DEFAULT_CODE) - : Variable(parentSense, (uint8_t)DS3231_TEMP_VAR_NUM, - (uint8_t)DS3231_TEMP_RESOLUTION, DS3231_TEMP_VAR_NAME, - DS3231_TEMP_UNIT_NAME, varCode, uuid) {} + : Variable(parentSense, static_cast(DS3231_TEMP_VAR_NUM), + static_cast(DS3231_TEMP_RESOLUTION), + DS3231_TEMP_VAR_NAME, DS3231_TEMP_UNIT_NAME, varCode, uuid) { + } /** * @brief Construct a new MaximDS3231_Temp object. * * @note This must be tied with a parent MaximDS3231 before it can be used. */ MaximDS3231_Temp() - : Variable((uint8_t)DS3231_TEMP_VAR_NUM, - (uint8_t)DS3231_TEMP_RESOLUTION, DS3231_TEMP_VAR_NAME, - DS3231_TEMP_UNIT_NAME, DS3231_TEMP_DEFAULT_CODE) {} + : Variable(static_cast(DS3231_TEMP_VAR_NUM), + static_cast(DS3231_TEMP_RESOLUTION), + DS3231_TEMP_VAR_NAME, DS3231_TEMP_UNIT_NAME, + DS3231_TEMP_DEFAULT_CODE) {} /** * @brief Destroy the MaximDS3231_Temp object - no action needed. */ diff --git a/src/sensors/MeaSpecMS5803.h b/src/sensors/MeaSpecMS5803.h index 30b159255..983e3932e 100644 --- a/src/sensors/MeaSpecMS5803.h +++ b/src/sensors/MeaSpecMS5803.h @@ -295,9 +295,10 @@ class MeaSpecMS5803_Temp : public Variable { explicit MeaSpecMS5803_Temp(MeaSpecMS5803* parentSense, const char* uuid = "", const char* varCode = MS5803_TEMP_DEFAULT_CODE) - : Variable(parentSense, (uint8_t)MS5803_TEMP_VAR_NUM, - (uint8_t)MS5803_TEMP_RESOLUTION, MS5803_TEMP_VAR_NAME, - MS5803_TEMP_UNIT_NAME, varCode, uuid) {} + : Variable(parentSense, static_cast(MS5803_TEMP_VAR_NUM), + static_cast(MS5803_TEMP_RESOLUTION), + MS5803_TEMP_VAR_NAME, MS5803_TEMP_UNIT_NAME, varCode, uuid) { + } /** * @brief Construct a new MeaSpecMS5803_Temp object. * @@ -305,9 +306,10 @@ class MeaSpecMS5803_Temp : public Variable { * used. */ MeaSpecMS5803_Temp() - : Variable((uint8_t)MS5803_TEMP_VAR_NUM, - (uint8_t)MS5803_TEMP_RESOLUTION, MS5803_TEMP_VAR_NAME, - MS5803_TEMP_UNIT_NAME, MS5803_TEMP_DEFAULT_CODE) {} + : Variable(static_cast(MS5803_TEMP_VAR_NUM), + static_cast(MS5803_TEMP_RESOLUTION), + MS5803_TEMP_VAR_NAME, MS5803_TEMP_UNIT_NAME, + MS5803_TEMP_DEFAULT_CODE) {} /** * @brief Destroy the MeaSpecMS5803_Temp object - no action needed. */ @@ -340,8 +342,8 @@ class MeaSpecMS5803_Pressure : public Variable { explicit MeaSpecMS5803_Pressure( MeaSpecMS5803* parentSense, const char* uuid = "", const char* varCode = MS5803_PRESSURE_DEFAULT_CODE) - : Variable(parentSense, (uint8_t)MS5803_PRESSURE_VAR_NUM, - (uint8_t)MS5803_PRESSURE_RESOLUTION, + : Variable(parentSense, static_cast(MS5803_PRESSURE_VAR_NUM), + static_cast(MS5803_PRESSURE_RESOLUTION), MS5803_PRESSURE_VAR_NAME, MS5803_PRESSURE_UNIT_NAME, varCode, uuid) {} /** @@ -351,8 +353,8 @@ class MeaSpecMS5803_Pressure : public Variable { * used. */ MeaSpecMS5803_Pressure() - : Variable((uint8_t)MS5803_PRESSURE_VAR_NUM, - (uint8_t)MS5803_PRESSURE_RESOLUTION, + : Variable(static_cast(MS5803_PRESSURE_VAR_NUM), + static_cast(MS5803_PRESSURE_RESOLUTION), MS5803_PRESSURE_VAR_NAME, MS5803_PRESSURE_UNIT_NAME, MS5803_PRESSURE_DEFAULT_CODE) {} /** diff --git a/src/sensors/MeterHydros21.h b/src/sensors/MeterHydros21.h index cee5f2c70..582b63d28 100644 --- a/src/sensors/MeterHydros21.h +++ b/src/sensors/MeterHydros21.h @@ -304,9 +304,10 @@ class MeterHydros21_Cond : public Variable { explicit MeterHydros21_Cond( MeterHydros21* parentSense, const char* uuid = "", const char* varCode = HYDROS21_COND_DEFAULT_CODE) - : Variable(parentSense, (uint8_t)HYDROS21_COND_VAR_NUM, - (uint8_t)HYDROS21_COND_RESOLUTION, HYDROS21_COND_VAR_NAME, - HYDROS21_COND_UNIT_NAME, varCode, uuid) {} + : Variable(parentSense, static_cast(HYDROS21_COND_VAR_NUM), + static_cast(HYDROS21_COND_RESOLUTION), + HYDROS21_COND_VAR_NAME, HYDROS21_COND_UNIT_NAME, varCode, + uuid) {} /** * @brief Construct a new MeterHydros21_Cond object. * @@ -314,9 +315,10 @@ class MeterHydros21_Cond : public Variable { * used. */ MeterHydros21_Cond() - : Variable((uint8_t)HYDROS21_COND_VAR_NUM, - (uint8_t)HYDROS21_COND_RESOLUTION, HYDROS21_COND_VAR_NAME, - HYDROS21_COND_UNIT_NAME, HYDROS21_COND_DEFAULT_CODE) {} + : Variable(static_cast(HYDROS21_COND_VAR_NUM), + static_cast(HYDROS21_COND_RESOLUTION), + HYDROS21_COND_VAR_NAME, HYDROS21_COND_UNIT_NAME, + HYDROS21_COND_DEFAULT_CODE) {} /** * @brief Destroy the MeterHydros21_Cond object - no action needed. */ @@ -347,9 +349,10 @@ class MeterHydros21_Temp : public Variable { explicit MeterHydros21_Temp( MeterHydros21* parentSense, const char* uuid = "", const char* varCode = HYDROS21_TEMP_DEFAULT_CODE) - : Variable(parentSense, (uint8_t)HYDROS21_TEMP_VAR_NUM, - (uint8_t)HYDROS21_TEMP_RESOLUTION, HYDROS21_TEMP_VAR_NAME, - HYDROS21_TEMP_UNIT_NAME, varCode, uuid) {} + : Variable(parentSense, static_cast(HYDROS21_TEMP_VAR_NUM), + static_cast(HYDROS21_TEMP_RESOLUTION), + HYDROS21_TEMP_VAR_NAME, HYDROS21_TEMP_UNIT_NAME, varCode, + uuid) {} /** * @brief Construct a new MeterHydros21_Temp object. * @@ -357,9 +360,10 @@ class MeterHydros21_Temp : public Variable { * used. */ MeterHydros21_Temp() - : Variable((uint8_t)HYDROS21_TEMP_VAR_NUM, - (uint8_t)HYDROS21_TEMP_RESOLUTION, HYDROS21_TEMP_VAR_NAME, - HYDROS21_TEMP_UNIT_NAME, HYDROS21_TEMP_DEFAULT_CODE) {} + : Variable(static_cast(HYDROS21_TEMP_VAR_NUM), + static_cast(HYDROS21_TEMP_RESOLUTION), + HYDROS21_TEMP_VAR_NAME, HYDROS21_TEMP_UNIT_NAME, + HYDROS21_TEMP_DEFAULT_CODE) {} /** * @brief Destroy the MeterHydros21_Temp object - no action needed. */ @@ -390,9 +394,10 @@ class MeterHydros21_Depth : public Variable { explicit MeterHydros21_Depth( MeterHydros21* parentSense, const char* uuid = "", const char* varCode = HYDROS21_DEPTH_DEFAULT_CODE) - : Variable(parentSense, (uint8_t)HYDROS21_DEPTH_VAR_NUM, - (uint8_t)HYDROS21_DEPTH_RESOLUTION, HYDROS21_DEPTH_VAR_NAME, - HYDROS21_DEPTH_UNIT_NAME, varCode, uuid) {} + : Variable(parentSense, static_cast(HYDROS21_DEPTH_VAR_NUM), + static_cast(HYDROS21_DEPTH_RESOLUTION), + HYDROS21_DEPTH_VAR_NAME, HYDROS21_DEPTH_UNIT_NAME, varCode, + uuid) {} /** * @brief Construct a new MeterHydros21_Depth object. * @@ -400,9 +405,10 @@ class MeterHydros21_Depth : public Variable { * used. */ MeterHydros21_Depth() - : Variable((uint8_t)HYDROS21_DEPTH_VAR_NUM, - (uint8_t)HYDROS21_DEPTH_RESOLUTION, HYDROS21_DEPTH_VAR_NAME, - HYDROS21_DEPTH_UNIT_NAME, HYDROS21_DEPTH_DEFAULT_CODE) {} + : Variable(static_cast(HYDROS21_DEPTH_VAR_NUM), + static_cast(HYDROS21_DEPTH_RESOLUTION), + HYDROS21_DEPTH_VAR_NAME, HYDROS21_DEPTH_UNIT_NAME, + HYDROS21_DEPTH_DEFAULT_CODE) {} /** * @brief Destroy the MeterHydros21_Depth object - no action needed. */ diff --git a/src/sensors/MeterTeros11.h b/src/sensors/MeterTeros11.h index 32dedd01f..b93e74e04 100644 --- a/src/sensors/MeterTeros11.h +++ b/src/sensors/MeterTeros11.h @@ -364,18 +364,20 @@ class MeterTeros11_Count : public Variable { explicit MeterTeros11_Count( MeterTeros11* parentSense, const char* uuid = "", const char* varCode = TEROS11_COUNT_DEFAULT_CODE) - : Variable(parentSense, (uint8_t)TEROS11_COUNT_VAR_NUM, - (uint8_t)TEROS11_COUNT_RESOLUTION, TEROS11_COUNT_VAR_NAME, - TEROS11_COUNT_UNIT_NAME, varCode, uuid) {} + : Variable(parentSense, static_cast(TEROS11_COUNT_VAR_NUM), + static_cast(TEROS11_COUNT_RESOLUTION), + TEROS11_COUNT_VAR_NAME, TEROS11_COUNT_UNIT_NAME, varCode, + uuid) {} /** * @brief Construct a new MeterTeros11_Count object. * * @note This must be tied with a parent MeterTeros11 before it can be used. */ MeterTeros11_Count() - : Variable((uint8_t)TEROS11_COUNT_VAR_NUM, - (uint8_t)TEROS11_COUNT_RESOLUTION, TEROS11_COUNT_VAR_NAME, - TEROS11_COUNT_UNIT_NAME, TEROS11_COUNT_DEFAULT_CODE) {} + : Variable(static_cast(TEROS11_COUNT_VAR_NUM), + static_cast(TEROS11_COUNT_RESOLUTION), + TEROS11_COUNT_VAR_NAME, TEROS11_COUNT_UNIT_NAME, + TEROS11_COUNT_DEFAULT_CODE) {} /** * @brief Destroy the MeterTeros11_Count object - no action needed. */ @@ -406,18 +408,20 @@ class MeterTeros11_Temp : public Variable { */ explicit MeterTeros11_Temp(MeterTeros11* parentSense, const char* uuid = "", const char* varCode = TEROS11_TEMP_DEFAULT_CODE) - : Variable(parentSense, (uint8_t)TEROS11_TEMP_VAR_NUM, - (uint8_t)TEROS11_TEMP_RESOLUTION, TEROS11_TEMP_VAR_NAME, - TEROS11_TEMP_UNIT_NAME, varCode, uuid) {} + : Variable(parentSense, static_cast(TEROS11_TEMP_VAR_NUM), + static_cast(TEROS11_TEMP_RESOLUTION), + TEROS11_TEMP_VAR_NAME, TEROS11_TEMP_UNIT_NAME, varCode, + uuid) {} /** * @brief Construct a new MeterTeros11_Temp object. * * @note This must be tied with a parent MeterTeros11 before it can be used. */ MeterTeros11_Temp() - : Variable((uint8_t)TEROS11_TEMP_VAR_NUM, - (uint8_t)TEROS11_TEMP_RESOLUTION, TEROS11_TEMP_VAR_NAME, - TEROS11_TEMP_UNIT_NAME, TEROS11_TEMP_DEFAULT_CODE) {} + : Variable(static_cast(TEROS11_TEMP_VAR_NUM), + static_cast(TEROS11_TEMP_RESOLUTION), + TEROS11_TEMP_VAR_NAME, TEROS11_TEMP_UNIT_NAME, + TEROS11_TEMP_DEFAULT_CODE) {} /** * @brief Destroy the MeterTeros11_Temp object - no action needed. */ @@ -449,16 +453,17 @@ class MeterTeros11_Ea : public Variable { */ explicit MeterTeros11_Ea(MeterTeros11* parentSense, const char* uuid = "", const char* varCode = TEROS11_EA_DEFAULT_CODE) - : Variable(parentSense, (uint8_t)TEROS11_EA_VAR_NUM, - (uint8_t)TEROS11_EA_RESOLUTION, TEROS11_EA_VAR_NAME, - TEROS11_EA_UNIT_NAME, varCode, uuid) {} + : Variable(parentSense, static_cast(TEROS11_EA_VAR_NUM), + static_cast(TEROS11_EA_RESOLUTION), + TEROS11_EA_VAR_NAME, TEROS11_EA_UNIT_NAME, varCode, uuid) {} /** * @brief Construct a new MeterTeros11_Ea object. * * @note This must be tied with a parent MeterTeros11 before it can be used. */ MeterTeros11_Ea() - : Variable((uint8_t)TEROS11_EA_VAR_NUM, (uint8_t)TEROS11_EA_RESOLUTION, + : Variable(static_cast(TEROS11_EA_VAR_NUM), + static_cast(TEROS11_EA_RESOLUTION), TEROS11_EA_VAR_NAME, TEROS11_EA_UNIT_NAME, TEROS11_EA_DEFAULT_CODE) {} /** @@ -491,18 +496,20 @@ class MeterTeros11_VWC : public Variable { */ explicit MeterTeros11_VWC(MeterTeros11* parentSense, const char* uuid = "", const char* varCode = TEROS11_VWC_DEFAULT_CODE) - : Variable(parentSense, (uint8_t)TEROS11_VWC_VAR_NUM, - (uint8_t)TEROS11_VWC_RESOLUTION, TEROS11_VWC_VAR_NAME, - TEROS11_VWC_UNIT_NAME, varCode, uuid) {} + : Variable(parentSense, static_cast(TEROS11_VWC_VAR_NUM), + static_cast(TEROS11_VWC_RESOLUTION), + TEROS11_VWC_VAR_NAME, TEROS11_VWC_UNIT_NAME, varCode, uuid) { + } /** * @brief Construct a new MeterTeros11_VWC object. * * @note This must be tied with a parent MeterTeros11 before it can be used. */ MeterTeros11_VWC() - : Variable((uint8_t)TEROS11_VWC_VAR_NUM, - (uint8_t)TEROS11_VWC_RESOLUTION, TEROS11_VWC_VAR_NAME, - TEROS11_VWC_UNIT_NAME, TEROS11_VWC_DEFAULT_CODE) {} + : Variable(static_cast(TEROS11_VWC_VAR_NUM), + static_cast(TEROS11_VWC_RESOLUTION), + TEROS11_VWC_VAR_NAME, TEROS11_VWC_UNIT_NAME, + TEROS11_VWC_DEFAULT_CODE) {} /** * @brief Destroy the MeterTeros11_VWC object - no action needed. */ diff --git a/src/sensors/PaleoTerraRedox.h b/src/sensors/PaleoTerraRedox.h index 07315302d..a43e6e92a 100644 --- a/src/sensors/PaleoTerraRedox.h +++ b/src/sensors/PaleoTerraRedox.h @@ -321,9 +321,10 @@ class PaleoTerraRedox_Voltage : public Variable { explicit PaleoTerraRedox_Voltage( Sensor* parentSense, const char* uuid = "", const char* varCode = PTR_VOLTAGE_DEFAULT_CODE) - : Variable(parentSense, (uint8_t)PTR_VOLTAGE_VAR_NUM, - (uint8_t)PTR_VOLTAGE_RESOLUTION, PTR_VOLTAGE_VAR_NAME, - PTR_VOLTAGE_UNIT_NAME, varCode, uuid) {} + : Variable(parentSense, static_cast(PTR_VOLTAGE_VAR_NUM), + static_cast(PTR_VOLTAGE_RESOLUTION), + PTR_VOLTAGE_VAR_NAME, PTR_VOLTAGE_UNIT_NAME, varCode, uuid) { + } /** * @brief Construct a new PaleoTerraRedox_Voltage object. * @@ -331,9 +332,10 @@ class PaleoTerraRedox_Voltage : public Variable { * used. */ PaleoTerraRedox_Voltage() - : Variable((uint8_t)PTR_VOLTAGE_VAR_NUM, - (uint8_t)PTR_VOLTAGE_RESOLUTION, PTR_VOLTAGE_VAR_NAME, - PTR_VOLTAGE_UNIT_NAME, PTR_VOLTAGE_DEFAULT_CODE) {} + : Variable(static_cast(PTR_VOLTAGE_VAR_NUM), + static_cast(PTR_VOLTAGE_RESOLUTION), + PTR_VOLTAGE_VAR_NAME, PTR_VOLTAGE_UNIT_NAME, + PTR_VOLTAGE_DEFAULT_CODE) {} /** * @brief Destroy the PaleoTerraRedox_Voltage object - no action needed. */ diff --git a/src/sensors/ProcessorAnalog.h b/src/sensors/ProcessorAnalog.h index b669ac456..ec68589d7 100644 --- a/src/sensors/ProcessorAnalog.h +++ b/src/sensors/ProcessorAnalog.h @@ -325,8 +325,8 @@ class ProcessorAnalog_Voltage : public Variable { explicit ProcessorAnalog_Voltage( ProcessorAnalog* parentSense, const char* uuid = "", const char* varCode = PROCESSOR_ANALOG_DEFAULT_CODE) - : Variable(parentSense, (uint8_t)PROCESSOR_ANALOG_VAR_NUM, - (uint8_t)PROCESSOR_ANALOG_RESOLUTION, + : Variable(parentSense, static_cast(PROCESSOR_ANALOG_VAR_NUM), + static_cast(PROCESSOR_ANALOG_RESOLUTION), PROCESSOR_ANALOG_VAR_NAME, PROCESSOR_ANALOG_UNIT_NAME, varCode, uuid) {} /** @@ -336,8 +336,8 @@ class ProcessorAnalog_Voltage : public Variable { * used. */ ProcessorAnalog_Voltage() - : Variable((uint8_t)PROCESSOR_ANALOG_VAR_NUM, - (uint8_t)PROCESSOR_ANALOG_RESOLUTION, + : Variable(static_cast(PROCESSOR_ANALOG_VAR_NUM), + static_cast(PROCESSOR_ANALOG_RESOLUTION), PROCESSOR_ANALOG_VAR_NAME, PROCESSOR_ANALOG_UNIT_NAME, PROCESSOR_ANALOG_DEFAULT_CODE) {} /** diff --git a/src/sensors/ProcessorStats.h b/src/sensors/ProcessorStats.h index 36262c573..c15249036 100644 --- a/src/sensors/ProcessorStats.h +++ b/src/sensors/ProcessorStats.h @@ -389,8 +389,8 @@ class ProcessorStats_Battery : public Variable { explicit ProcessorStats_Battery( ProcessorStats* parentSense, const char* uuid = "", const char* varCode = PROCESSOR_BATTERY_DEFAULT_CODE) - : Variable(parentSense, (uint8_t)PROCESSOR_BATTERY_VAR_NUM, - (uint8_t)PROCESSOR_BATTERY_RESOLUTION, + : Variable(parentSense, static_cast(PROCESSOR_BATTERY_VAR_NUM), + static_cast(PROCESSOR_BATTERY_RESOLUTION), PROCESSOR_BATTERY_VAR_NAME, PROCESSOR_BATTERY_UNIT_NAME, varCode, uuid) {} /** @@ -400,8 +400,8 @@ class ProcessorStats_Battery : public Variable { * used. */ ProcessorStats_Battery() - : Variable((uint8_t)PROCESSOR_BATTERY_VAR_NUM, - (uint8_t)PROCESSOR_BATTERY_RESOLUTION, + : Variable(static_cast(PROCESSOR_BATTERY_VAR_NUM), + static_cast(PROCESSOR_BATTERY_RESOLUTION), PROCESSOR_BATTERY_VAR_NAME, PROCESSOR_BATTERY_UNIT_NAME, PROCESSOR_BATTERY_DEFAULT_CODE) {} /** @@ -442,9 +442,10 @@ class ProcessorStats_FreeRam : public Variable { explicit ProcessorStats_FreeRam( ProcessorStats* parentSense, const char* uuid = "", const char* varCode = PROCESSOR_RAM_DEFAULT_CODE) - : Variable(parentSense, (uint8_t)PROCESSOR_RAM_VAR_NUM, - (uint8_t)PROCESSOR_RAM_RESOLUTION, PROCESSOR_RAM_VAR_NAME, - PROCESSOR_RAM_UNIT_NAME, varCode, uuid) {} + : Variable(parentSense, static_cast(PROCESSOR_RAM_VAR_NUM), + static_cast(PROCESSOR_RAM_RESOLUTION), + PROCESSOR_RAM_VAR_NAME, PROCESSOR_RAM_UNIT_NAME, varCode, + uuid) {} /** * @brief Construct a new ProcessorStats_FreeRam object. * @@ -452,9 +453,10 @@ class ProcessorStats_FreeRam : public Variable { * used. */ ProcessorStats_FreeRam() - : Variable((uint8_t)PROCESSOR_RAM_VAR_NUM, - (uint8_t)PROCESSOR_RAM_RESOLUTION, PROCESSOR_RAM_VAR_NAME, - PROCESSOR_RAM_UNIT_NAME, PROCESSOR_RAM_DEFAULT_CODE) {} + : Variable(static_cast(PROCESSOR_RAM_VAR_NUM), + static_cast(PROCESSOR_RAM_RESOLUTION), + PROCESSOR_RAM_VAR_NAME, PROCESSOR_RAM_UNIT_NAME, + PROCESSOR_RAM_DEFAULT_CODE) {} /** * @brief Destroy the ProcessorStats_FreeRam object - no action needed. */ @@ -489,8 +491,8 @@ class ProcessorStats_SampleNumber : public Variable { explicit ProcessorStats_SampleNumber( ProcessorStats* parentSense, const char* uuid = "", const char* varCode = PROCESSOR_SAMPNUM_DEFAULT_CODE) - : Variable(parentSense, (uint8_t)PROCESSOR_SAMPNUM_VAR_NUM, - (uint8_t)PROCESSOR_SAMPNUM_RESOLUTION, + : Variable(parentSense, static_cast(PROCESSOR_SAMPNUM_VAR_NUM), + static_cast(PROCESSOR_SAMPNUM_RESOLUTION), PROCESSOR_SAMPNUM_VAR_NAME, PROCESSOR_SAMPNUM_UNIT_NAME, varCode, uuid) {} /** @@ -500,8 +502,8 @@ class ProcessorStats_SampleNumber : public Variable { * used. */ ProcessorStats_SampleNumber() - : Variable((uint8_t)PROCESSOR_SAMPNUM_VAR_NUM, - (uint8_t)PROCESSOR_SAMPNUM_RESOLUTION, + : Variable(static_cast(PROCESSOR_SAMPNUM_VAR_NUM), + static_cast(PROCESSOR_SAMPNUM_RESOLUTION), PROCESSOR_SAMPNUM_VAR_NAME, PROCESSOR_SAMPNUM_UNIT_NAME, PROCESSOR_SAMPNUM_DEFAULT_CODE) {} /** @@ -540,8 +542,8 @@ class ProcessorStats_ResetCode : public Variable { explicit ProcessorStats_ResetCode( ProcessorStats* parentSense, const char* uuid = "", const char* varCode = PROCESSOR_RESET_DEFAULT_CODE) - : Variable(parentSense, (uint8_t)PROCESSOR_RESET_VAR_NUM, - (uint8_t)PROCESSOR_RESET_RESOLUTION, + : Variable(parentSense, static_cast(PROCESSOR_RESET_VAR_NUM), + static_cast(PROCESSOR_RESET_RESOLUTION), PROCESSOR_RESET_VAR_NAME, PROCESSOR_RESET_UNIT_NAME, varCode, uuid) {} /** @@ -551,8 +553,8 @@ class ProcessorStats_ResetCode : public Variable { * used. */ ProcessorStats_ResetCode() - : Variable((uint8_t)PROCESSOR_RESET_VAR_NUM, - (uint8_t)PROCESSOR_RESET_RESOLUTION, + : Variable(static_cast(PROCESSOR_RESET_VAR_NUM), + static_cast(PROCESSOR_RESET_RESOLUTION), PROCESSOR_RESET_VAR_NAME, PROCESSOR_RESET_UNIT_NAME, PROCESSOR_RESET_DEFAULT_CODE) {} /** diff --git a/src/sensors/RainCounterI2C.h b/src/sensors/RainCounterI2C.h index 927be3aea..c0ae1d47f 100644 --- a/src/sensors/RainCounterI2C.h +++ b/src/sensors/RainCounterI2C.h @@ -341,9 +341,10 @@ class RainCounterI2C_Tips : public Variable { explicit RainCounterI2C_Tips(RainCounterI2C* parentSense, const char* uuid = "", const char* varCode = BUCKET_TIPS_DEFAULT_CODE) - : Variable(parentSense, (uint8_t)BUCKET_TIPS_VAR_NUM, - (uint8_t)BUCKET_TIPS_RESOLUTION, BUCKET_TIPS_VAR_NAME, - BUCKET_TIPS_UNIT_NAME, varCode, uuid) {} + : Variable(parentSense, static_cast(BUCKET_TIPS_VAR_NUM), + static_cast(BUCKET_TIPS_RESOLUTION), + BUCKET_TIPS_VAR_NAME, BUCKET_TIPS_UNIT_NAME, varCode, uuid) { + } /** * @brief Construct a new RainCounterI2C_Tips object. * @@ -351,9 +352,10 @@ class RainCounterI2C_Tips : public Variable { * used. */ RainCounterI2C_Tips() - : Variable((uint8_t)BUCKET_TIPS_VAR_NUM, - (uint8_t)BUCKET_TIPS_RESOLUTION, BUCKET_TIPS_VAR_NAME, - BUCKET_TIPS_UNIT_NAME, BUCKET_TIPS_DEFAULT_CODE) {} + : Variable(static_cast(BUCKET_TIPS_VAR_NUM), + static_cast(BUCKET_TIPS_RESOLUTION), + BUCKET_TIPS_VAR_NAME, BUCKET_TIPS_UNIT_NAME, + BUCKET_TIPS_DEFAULT_CODE) {} /** * @brief Destroy the RainCounterI2C_Tips object - no action needed. */ @@ -383,9 +385,10 @@ class RainCounterI2C_Depth : public Variable { explicit RainCounterI2C_Depth( RainCounterI2C* parentSense, const char* uuid = "", const char* varCode = BUCKET_RAIN_DEFAULT_CODE) - : Variable(parentSense, (uint8_t)BUCKET_RAIN_VAR_NUM, - (uint8_t)BUCKET_RAIN_RESOLUTION, BUCKET_RAIN_VAR_NAME, - BUCKET_RAIN_UNIT_NAME, varCode, uuid) {} + : Variable(parentSense, static_cast(BUCKET_RAIN_VAR_NUM), + static_cast(BUCKET_RAIN_RESOLUTION), + BUCKET_RAIN_VAR_NAME, BUCKET_RAIN_UNIT_NAME, varCode, uuid) { + } /** * @brief Construct a new RainCounterI2C_Depth object. * @@ -393,9 +396,10 @@ class RainCounterI2C_Depth : public Variable { * used. */ RainCounterI2C_Depth() - : Variable((uint8_t)BUCKET_RAIN_VAR_NUM, - (uint8_t)BUCKET_RAIN_RESOLUTION, BUCKET_RAIN_VAR_NAME, - BUCKET_RAIN_UNIT_NAME, BUCKET_RAIN_DEFAULT_CODE) {} + : Variable(static_cast(BUCKET_RAIN_VAR_NUM), + static_cast(BUCKET_RAIN_RESOLUTION), + BUCKET_RAIN_VAR_NAME, BUCKET_RAIN_UNIT_NAME, + BUCKET_RAIN_DEFAULT_CODE) {} /** * @brief Destroy the RainCounterI2C_Depth object - no action needed. */ diff --git a/src/sensors/SensirionSHT4x.h b/src/sensors/SensirionSHT4x.h index 5c8043f21..ee0498514 100644 --- a/src/sensors/SensirionSHT4x.h +++ b/src/sensors/SensirionSHT4x.h @@ -322,9 +322,10 @@ class SensirionSHT4x_Humidity : public Variable { explicit SensirionSHT4x_Humidity( SensirionSHT4x* parentSense, const char* uuid = "", const char* varCode = SHT4X_HUMIDITY_DEFAULT_CODE) - : Variable(parentSense, (uint8_t)SHT4X_HUMIDITY_VAR_NUM, - (uint8_t)SHT4X_HUMIDITY_RESOLUTION, SHT4X_HUMIDITY_VAR_NAME, - SHT4X_HUMIDITY_UNIT_NAME, varCode, uuid) {} + : Variable(parentSense, static_cast(SHT4X_HUMIDITY_VAR_NUM), + static_cast(SHT4X_HUMIDITY_RESOLUTION), + SHT4X_HUMIDITY_VAR_NAME, SHT4X_HUMIDITY_UNIT_NAME, varCode, + uuid) {} /** * @brief Construct a new SensirionSHT4x_Humidity object. * @@ -332,9 +333,10 @@ class SensirionSHT4x_Humidity : public Variable { * used. */ SensirionSHT4x_Humidity() - : Variable((uint8_t)SHT4X_HUMIDITY_VAR_NUM, - (uint8_t)SHT4X_HUMIDITY_RESOLUTION, SHT4X_HUMIDITY_VAR_NAME, - SHT4X_HUMIDITY_UNIT_NAME, SHT4X_HUMIDITY_DEFAULT_CODE) {} + : Variable(static_cast(SHT4X_HUMIDITY_VAR_NUM), + static_cast(SHT4X_HUMIDITY_RESOLUTION), + SHT4X_HUMIDITY_VAR_NAME, SHT4X_HUMIDITY_UNIT_NAME, + SHT4X_HUMIDITY_DEFAULT_CODE) {} /** * @brief Destroy the SensirionSHT4x_Humidity object - no action needed. */ @@ -364,9 +366,9 @@ class SensirionSHT4x_Temp : public Variable { explicit SensirionSHT4x_Temp(SensirionSHT4x* parentSense, const char* uuid = "", const char* varCode = SHT4X_TEMP_DEFAULT_CODE) - : Variable(parentSense, (uint8_t)SHT4X_TEMP_VAR_NUM, - (uint8_t)SHT4X_TEMP_RESOLUTION, SHT4X_TEMP_VAR_NAME, - SHT4X_TEMP_UNIT_NAME, varCode, uuid) {} + : Variable(parentSense, static_cast(SHT4X_TEMP_VAR_NUM), + static_cast(SHT4X_TEMP_RESOLUTION), + SHT4X_TEMP_VAR_NAME, SHT4X_TEMP_UNIT_NAME, varCode, uuid) {} /** * @brief Construct a new SensirionSHT4x_Temp object. * @@ -374,7 +376,8 @@ class SensirionSHT4x_Temp : public Variable { * used. */ SensirionSHT4x_Temp() - : Variable((uint8_t)SHT4X_TEMP_VAR_NUM, (uint8_t)SHT4X_TEMP_RESOLUTION, + : Variable(static_cast(SHT4X_TEMP_VAR_NUM), + static_cast(SHT4X_TEMP_RESOLUTION), SHT4X_TEMP_VAR_NAME, SHT4X_TEMP_UNIT_NAME, SHT4X_TEMP_DEFAULT_CODE) {} /** diff --git a/src/sensors/TEConnectivityMS5837.h b/src/sensors/TEConnectivityMS5837.h index 651fa2579..60659c585 100644 --- a/src/sensors/TEConnectivityMS5837.h +++ b/src/sensors/TEConnectivityMS5837.h @@ -576,9 +576,10 @@ class TEConnectivityMS5837_Temp : public Variable { explicit TEConnectivityMS5837_Temp( TEConnectivityMS5837* parentSense, const char* uuid = "", const char* varCode = MS5837_TEMP_DEFAULT_CODE) - : Variable(parentSense, (uint8_t)MS5837_TEMP_VAR_NUM, - (uint8_t)MS5837_TEMP_RESOLUTION, MS5837_TEMP_VAR_NAME, - MS5837_TEMP_UNIT_NAME, varCode, uuid) {} + : Variable(parentSense, static_cast(MS5837_TEMP_VAR_NUM), + static_cast(MS5837_TEMP_RESOLUTION), + MS5837_TEMP_VAR_NAME, MS5837_TEMP_UNIT_NAME, varCode, uuid) { + } /** * @brief Construct a new TEConnectivityMS5837_Temp object. * @@ -586,9 +587,10 @@ class TEConnectivityMS5837_Temp : public Variable { * be used. */ TEConnectivityMS5837_Temp() - : Variable((uint8_t)MS5837_TEMP_VAR_NUM, - (uint8_t)MS5837_TEMP_RESOLUTION, MS5837_TEMP_VAR_NAME, - MS5837_TEMP_UNIT_NAME, MS5837_TEMP_DEFAULT_CODE) {} + : Variable(static_cast(MS5837_TEMP_VAR_NUM), + static_cast(MS5837_TEMP_RESOLUTION), + MS5837_TEMP_VAR_NAME, MS5837_TEMP_UNIT_NAME, + MS5837_TEMP_DEFAULT_CODE) {} /** * @brief Destroy the TEConnectivityMS5837_Temp object - no action needed. */ @@ -620,8 +622,8 @@ class TEConnectivityMS5837_Pressure : public Variable { explicit TEConnectivityMS5837_Pressure( TEConnectivityMS5837* parentSense, const char* uuid = "", const char* varCode = MS5837_PRESSURE_DEFAULT_CODE) - : Variable(parentSense, (uint8_t)MS5837_PRESSURE_VAR_NUM, - (uint8_t)MS5837_PRESSURE_RESOLUTION, + : Variable(parentSense, static_cast(MS5837_PRESSURE_VAR_NUM), + static_cast(MS5837_PRESSURE_RESOLUTION), MS5837_PRESSURE_VAR_NAME, MS5837_PRESSURE_UNIT_NAME, varCode, uuid) {} /** @@ -631,8 +633,8 @@ class TEConnectivityMS5837_Pressure : public Variable { * be used. */ TEConnectivityMS5837_Pressure() - : Variable((uint8_t)MS5837_PRESSURE_VAR_NUM, - (uint8_t)MS5837_PRESSURE_RESOLUTION, + : Variable(static_cast(MS5837_PRESSURE_VAR_NUM), + static_cast(MS5837_PRESSURE_RESOLUTION), MS5837_PRESSURE_VAR_NAME, MS5837_PRESSURE_UNIT_NAME, MS5837_PRESSURE_DEFAULT_CODE) {} /** @@ -667,9 +669,10 @@ class TEConnectivityMS5837_Depth : public Variable { explicit TEConnectivityMS5837_Depth( TEConnectivityMS5837* parentSense, const char* uuid = "", const char* varCode = MS5837_DEPTH_DEFAULT_CODE) - : Variable(parentSense, (uint8_t)MS5837_DEPTH_VAR_NUM, - (uint8_t)MS5837_DEPTH_RESOLUTION, MS5837_DEPTH_VAR_NAME, - MS5837_DEPTH_UNIT_NAME, varCode, uuid) {} + : Variable(parentSense, static_cast(MS5837_DEPTH_VAR_NUM), + static_cast(MS5837_DEPTH_RESOLUTION), + MS5837_DEPTH_VAR_NAME, MS5837_DEPTH_UNIT_NAME, varCode, + uuid) {} /** * @brief Construct a new TEConnectivityMS5837_Depth object. * @@ -677,9 +680,10 @@ class TEConnectivityMS5837_Depth : public Variable { * be used. */ TEConnectivityMS5837_Depth() - : Variable((uint8_t)MS5837_DEPTH_VAR_NUM, - (uint8_t)MS5837_DEPTH_RESOLUTION, MS5837_DEPTH_VAR_NAME, - MS5837_DEPTH_UNIT_NAME, MS5837_DEPTH_DEFAULT_CODE) {} + : Variable(static_cast(MS5837_DEPTH_VAR_NUM), + static_cast(MS5837_DEPTH_RESOLUTION), + MS5837_DEPTH_VAR_NAME, MS5837_DEPTH_UNIT_NAME, + MS5837_DEPTH_DEFAULT_CODE) {} /** * @brief Destroy the TEConnectivityMS5837_Depth object - no action needed. */ @@ -711,8 +715,8 @@ class TEConnectivityMS5837_Altitude : public Variable { explicit TEConnectivityMS5837_Altitude( TEConnectivityMS5837* parentSense, const char* uuid = "", const char* varCode = MS5837_ALTITUDE_DEFAULT_CODE) - : Variable(parentSense, (uint8_t)MS5837_ALTITUDE_VAR_NUM, - (uint8_t)MS5837_ALTITUDE_RESOLUTION, + : Variable(parentSense, static_cast(MS5837_ALTITUDE_VAR_NUM), + static_cast(MS5837_ALTITUDE_RESOLUTION), MS5837_ALTITUDE_VAR_NAME, MS5837_ALTITUDE_UNIT_NAME, varCode, uuid) {} /** @@ -722,8 +726,8 @@ class TEConnectivityMS5837_Altitude : public Variable { * be used. */ TEConnectivityMS5837_Altitude() - : Variable((uint8_t)MS5837_ALTITUDE_VAR_NUM, - (uint8_t)MS5837_ALTITUDE_RESOLUTION, + : Variable(static_cast(MS5837_ALTITUDE_VAR_NUM), + static_cast(MS5837_ALTITUDE_RESOLUTION), MS5837_ALTITUDE_VAR_NAME, MS5837_ALTITUDE_UNIT_NAME, MS5837_ALTITUDE_DEFAULT_CODE) {} /** diff --git a/src/sensors/TIADS1x15.h b/src/sensors/TIADS1x15.h index 44b8a73d3..9454357d8 100644 --- a/src/sensors/TIADS1x15.h +++ b/src/sensors/TIADS1x15.h @@ -579,9 +579,9 @@ class TIADS1x15_Voltage : public Variable { */ explicit TIADS1x15_Voltage(TIADS1x15* parentSense, const char* uuid = "", const char* varCode = TIADS1X15_DEFAULT_CODE) - : Variable(parentSense, (uint8_t)TIADS1X15_VAR_NUM, - (uint8_t)TIADS1X15_RESOLUTION, TIADS1X15_VAR_NAME, - TIADS1X15_UNIT_NAME, varCode, uuid) {} + : Variable(parentSense, static_cast(TIADS1X15_VAR_NUM), + static_cast(TIADS1X15_RESOLUTION), + TIADS1X15_VAR_NAME, TIADS1X15_UNIT_NAME, varCode, uuid) {} /** * @brief Construct a new TIADS1x15_Voltage object. * @@ -589,7 +589,8 @@ class TIADS1x15_Voltage : public Variable { * used. */ TIADS1x15_Voltage() - : Variable((uint8_t)TIADS1X15_VAR_NUM, (uint8_t)TIADS1X15_RESOLUTION, + : Variable(static_cast(TIADS1X15_VAR_NUM), + static_cast(TIADS1X15_RESOLUTION), TIADS1X15_VAR_NAME, TIADS1X15_UNIT_NAME, TIADS1X15_DEFAULT_CODE) {} /** diff --git a/src/sensors/TIINA219.h b/src/sensors/TIINA219.h index 48bfaa2de..9d9d6e41a 100644 --- a/src/sensors/TIINA219.h +++ b/src/sensors/TIINA219.h @@ -334,8 +334,8 @@ class TIINA219_Current : public Variable { explicit TIINA219_Current( TIINA219* parentSense, const char* uuid = "", const char* varCode = INA219_CURRENT_MA_DEFAULT_CODE) - : Variable(parentSense, (uint8_t)INA219_CURRENT_MA_VAR_NUM, - (uint8_t)INA219_CURRENT_MA_RESOLUTION, + : Variable(parentSense, static_cast(INA219_CURRENT_MA_VAR_NUM), + static_cast(INA219_CURRENT_MA_RESOLUTION), INA219_CURRENT_MA_VAR_NAME, INA219_CURRENT_MA_UNIT_NAME, varCode, uuid) {} /** @@ -344,8 +344,8 @@ class TIINA219_Current : public Variable { * @note This must be tied with a parent TIINA219 before it can be used. */ TIINA219_Current() - : Variable((uint8_t)INA219_CURRENT_MA_VAR_NUM, - (uint8_t)INA219_CURRENT_MA_RESOLUTION, + : Variable(static_cast(INA219_CURRENT_MA_VAR_NUM), + static_cast(INA219_CURRENT_MA_RESOLUTION), INA219_CURRENT_MA_VAR_NAME, INA219_CURRENT_MA_UNIT_NAME, INA219_CURRENT_MA_DEFAULT_CODE) {} /** @@ -377,8 +377,9 @@ class TIINA219_Voltage : public Variable { explicit TIINA219_Voltage( TIINA219* parentSense, const char* uuid = "", const char* varCode = INA219_BUS_VOLTAGE_DEFAULT_CODE) - : Variable(parentSense, (uint8_t)INA219_BUS_VOLTAGE_VAR_NUM, - (uint8_t)INA219_BUS_VOLTAGE_RESOLUTION, + : Variable(parentSense, + static_cast(INA219_BUS_VOLTAGE_VAR_NUM), + static_cast(INA219_BUS_VOLTAGE_RESOLUTION), INA219_BUS_VOLTAGE_VAR_NAME, INA219_BUS_VOLTAGE_UNIT_NAME, varCode, uuid) {} /** @@ -387,8 +388,8 @@ class TIINA219_Voltage : public Variable { * @note This must be tied with a parent TIINA219 before it can be used. */ TIINA219_Voltage() - : Variable((uint8_t)INA219_BUS_VOLTAGE_VAR_NUM, - (uint8_t)INA219_BUS_VOLTAGE_RESOLUTION, + : Variable(static_cast(INA219_BUS_VOLTAGE_VAR_NUM), + static_cast(INA219_BUS_VOLTAGE_RESOLUTION), INA219_BUS_VOLTAGE_VAR_NAME, INA219_BUS_VOLTAGE_UNIT_NAME, INA219_BUS_VOLTAGE_DEFAULT_CODE) {} /** @@ -428,8 +429,8 @@ class TIINA219_Power : public Variable { */ explicit TIINA219_Power(TIINA219* parentSense, const char* uuid = "", const char* varCode = INA219_POWER_MW_DEFAULT_CODE) - : Variable(parentSense, (uint8_t)INA219_POWER_MW_VAR_NUM, - (uint8_t)INA219_POWER_MW_RESOLUTION, + : Variable(parentSense, static_cast(INA219_POWER_MW_VAR_NUM), + static_cast(INA219_POWER_MW_RESOLUTION), INA219_POWER_MW_VAR_NAME, INA219_POWER_MW_UNIT_NAME, varCode, uuid) {} /** @@ -438,8 +439,8 @@ class TIINA219_Power : public Variable { * @note This must be tied with a parent TIINA219 before it can be used. */ TIINA219_Power() - : Variable((uint8_t)INA219_POWER_MW_VAR_NUM, - (uint8_t)INA219_POWER_MW_RESOLUTION, + : Variable(static_cast(INA219_POWER_MW_VAR_NUM), + static_cast(INA219_POWER_MW_RESOLUTION), INA219_POWER_MW_VAR_NAME, INA219_POWER_MW_UNIT_NAME, INA219_POWER_MW_DEFAULT_CODE) {} /** diff --git a/src/sensors/TallyCounterI2C.h b/src/sensors/TallyCounterI2C.h index b1b3d0a04..cd383241b 100644 --- a/src/sensors/TallyCounterI2C.h +++ b/src/sensors/TallyCounterI2C.h @@ -258,9 +258,10 @@ class TallyCounterI2C_Events : public Variable { explicit TallyCounterI2C_Events( TallyCounterI2C* parentSense, const char* uuid = "", const char* varCode = TALLY_EVENTS_DEFAULT_CODE) - : Variable(parentSense, (uint8_t)TALLY_EVENTS_VAR_NUM, - (uint8_t)TALLY_EVENTS_RESOLUTION, TALLY_EVENTS_VAR_NAME, - TALLY_EVENTS_UNIT_NAME, varCode, uuid) {} + : Variable(parentSense, static_cast(TALLY_EVENTS_VAR_NUM), + static_cast(TALLY_EVENTS_RESOLUTION), + TALLY_EVENTS_VAR_NAME, TALLY_EVENTS_UNIT_NAME, varCode, + uuid) {} /** * @brief Construct a new TallyCounterI2C_Events object. * @@ -268,9 +269,10 @@ class TallyCounterI2C_Events : public Variable { * used. */ TallyCounterI2C_Events() - : Variable((uint8_t)TALLY_EVENTS_VAR_NUM, - (uint8_t)TALLY_EVENTS_RESOLUTION, TALLY_EVENTS_VAR_NAME, - TALLY_EVENTS_UNIT_NAME, TALLY_EVENTS_DEFAULT_CODE) {} + : Variable(static_cast(TALLY_EVENTS_VAR_NUM), + static_cast(TALLY_EVENTS_RESOLUTION), + TALLY_EVENTS_VAR_NAME, TALLY_EVENTS_UNIT_NAME, + TALLY_EVENTS_DEFAULT_CODE) {} /** * @brief Destroy the TallyCounterI2C_Events object - no action needed. */ diff --git a/src/sensors/TurnerCyclops.h b/src/sensors/TurnerCyclops.h index 4dcf91684..89d7db843 100644 --- a/src/sensors/TurnerCyclops.h +++ b/src/sensors/TurnerCyclops.h @@ -438,8 +438,8 @@ class TurnerCyclops_Voltage : public Variable { explicit TurnerCyclops_Voltage( TurnerCyclops* parentSense, const char* uuid = "", const char* varCode = CYCLOPS_VOLTAGE_DEFAULT_CODE) - : Variable(parentSense, (uint8_t)CYCLOPS_VOLTAGE_VAR_NUM, - (uint8_t)CYCLOPS_VOLTAGE_RESOLUTION, + : Variable(parentSense, static_cast(CYCLOPS_VOLTAGE_VAR_NUM), + static_cast(CYCLOPS_VOLTAGE_RESOLUTION), CYCLOPS_VOLTAGE_VAR_NAME, CYCLOPS_VOLTAGE_UNIT_NAME, varCode, uuid) {} /** @@ -449,8 +449,8 @@ class TurnerCyclops_Voltage : public Variable { * used. */ TurnerCyclops_Voltage() - : Variable((uint8_t)CYCLOPS_VOLTAGE_VAR_NUM, - (uint8_t)CYCLOPS_VOLTAGE_RESOLUTION, + : Variable(static_cast(CYCLOPS_VOLTAGE_VAR_NUM), + static_cast(CYCLOPS_VOLTAGE_RESOLUTION), CYCLOPS_VOLTAGE_VAR_NAME, CYCLOPS_VOLTAGE_UNIT_NAME, CYCLOPS_VOLTAGE_DEFAULT_CODE) {} /** @@ -497,9 +497,10 @@ class TurnerCyclops_Chlorophyll : public Variable { explicit TurnerCyclops_Chlorophyll( TurnerCyclops* parentSense, const char* uuid = "", const char* varCode = "CyclopsChlorophyll") - : Variable(parentSense, (uint8_t)CYCLOPS_VAR_NUM, - (uint8_t)CYCLOPS_RESOLUTION, "chlorophyllFluorescence", - "microgramPerLiter", varCode, uuid) {} + : Variable(parentSense, static_cast(CYCLOPS_VAR_NUM), + static_cast(CYCLOPS_RESOLUTION), + "chlorophyllFluorescence", "microgramPerLiter", varCode, + uuid) {} /** * @brief Construct a new TurnerCyclops_Chlorophyll object. * @@ -507,7 +508,8 @@ class TurnerCyclops_Chlorophyll : public Variable { * used. */ TurnerCyclops_Chlorophyll() - : Variable((uint8_t)CYCLOPS_VAR_NUM, (uint8_t)CYCLOPS_RESOLUTION, + : Variable(static_cast(CYCLOPS_VAR_NUM), + static_cast(CYCLOPS_RESOLUTION), "chlorophyllFluorescence", "microgramPerLiter", "CyclopsChlorophyll") {} /** @@ -554,9 +556,9 @@ class TurnerCyclops_Rhodamine : public Variable { explicit TurnerCyclops_Rhodamine(TurnerCyclops* parentSense, const char* uuid = "", const char* varCode = "CyclopsRhodamine") - : Variable(parentSense, (uint8_t)CYCLOPS_VAR_NUM, - (uint8_t)CYCLOPS_RESOLUTION, "RhodamineFluorescence", - "partPerBillion", varCode, uuid) {} + : Variable(parentSense, static_cast(CYCLOPS_VAR_NUM), + static_cast(CYCLOPS_RESOLUTION), + "RhodamineFluorescence", "partPerBillion", varCode, uuid) {} /** * @brief Construct a new TurnerCyclops_Rhodamine object. * @@ -564,7 +566,8 @@ class TurnerCyclops_Rhodamine : public Variable { * used. */ TurnerCyclops_Rhodamine() - : Variable((uint8_t)CYCLOPS_VAR_NUM, (uint8_t)CYCLOPS_RESOLUTION, + : Variable(static_cast(CYCLOPS_VAR_NUM), + static_cast(CYCLOPS_RESOLUTION), "RhodamineFluorescence", "partPerBillion", "CyclopsRhodamine") {} /** @@ -611,9 +614,9 @@ class TurnerCyclops_Fluorescein : public Variable { explicit TurnerCyclops_Fluorescein( TurnerCyclops* parentSense, const char* uuid = "", const char* varCode = "CyclopsFluorescein") - : Variable(parentSense, (uint8_t)CYCLOPS_VAR_NUM, - (uint8_t)CYCLOPS_RESOLUTION, "fluorescein", "partPerBillion", - varCode, uuid) {} + : Variable(parentSense, static_cast(CYCLOPS_VAR_NUM), + static_cast(CYCLOPS_RESOLUTION), "fluorescein", + "partPerBillion", varCode, uuid) {} /** * @brief Construct a new TurnerCyclops_Fluorescein object. * @@ -621,8 +624,9 @@ class TurnerCyclops_Fluorescein : public Variable { * used. */ TurnerCyclops_Fluorescein() - : Variable((uint8_t)CYCLOPS_VAR_NUM, (uint8_t)CYCLOPS_RESOLUTION, - "fluorescein", "partPerBillion", "CyclopsFluorescein") {} + : Variable(static_cast(CYCLOPS_VAR_NUM), + static_cast(CYCLOPS_RESOLUTION), "fluorescein", + "partPerBillion", "CyclopsFluorescein") {} /** * @brief Destroy the Turner Cyclops Fluorescein variable object - no action * needed. @@ -668,8 +672,8 @@ class TurnerCyclops_Phycocyanin : public Variable { explicit TurnerCyclops_Phycocyanin( TurnerCyclops* parentSense, const char* uuid = "", const char* varCode = "CyclopsPhycocyanin") - : Variable(parentSense, (uint8_t)CYCLOPS_VAR_NUM, - (uint8_t)CYCLOPS_RESOLUTION, + : Variable(parentSense, static_cast(CYCLOPS_VAR_NUM), + static_cast(CYCLOPS_RESOLUTION), "blue_GreenAlgae_Cyanobacteria_Phycocyanin", "partPerBillion", varCode, uuid) {} /** @@ -679,7 +683,8 @@ class TurnerCyclops_Phycocyanin : public Variable { * used. */ TurnerCyclops_Phycocyanin() - : Variable((uint8_t)CYCLOPS_VAR_NUM, (uint8_t)CYCLOPS_RESOLUTION, + : Variable(static_cast(CYCLOPS_VAR_NUM), + static_cast(CYCLOPS_RESOLUTION), "blue_GreenAlgae_Cyanobacteria_Phycocyanin", "partPerBillion", "CyclopsPhycocyanin") {} /** @@ -727,8 +732,8 @@ class TurnerCyclops_Phycoerythrin : public Variable { explicit TurnerCyclops_Phycoerythrin( TurnerCyclops* parentSense, const char* uuid = "", const char* varCode = "CyclopsPhycoerythrin") - : Variable(parentSense, (uint8_t)CYCLOPS_VAR_NUM, - (uint8_t)CYCLOPS_RESOLUTION, "phycoerythrin", + : Variable(parentSense, static_cast(CYCLOPS_VAR_NUM), + static_cast(CYCLOPS_RESOLUTION), "phycoerythrin", "partPerBillion", varCode, uuid) {} /** * @brief Construct a new TurnerCyclops_Phycoerythrin object. @@ -737,8 +742,9 @@ class TurnerCyclops_Phycoerythrin : public Variable { * used. */ TurnerCyclops_Phycoerythrin() - : Variable((uint8_t)CYCLOPS_VAR_NUM, (uint8_t)CYCLOPS_RESOLUTION, - "phycoerythrin", "partPerBillion", "CyclopsPhycoerythrin") {} + : Variable(static_cast(CYCLOPS_VAR_NUM), + static_cast(CYCLOPS_RESOLUTION), "phycoerythrin", + "partPerBillion", "CyclopsPhycoerythrin") {} /** * @brief Destroy the Turner Cyclops Phycoerythrin variable object - no * action needed. @@ -787,8 +793,8 @@ class TurnerCyclops_CDOM : public Variable { explicit TurnerCyclops_CDOM(TurnerCyclops* parentSense, const char* uuid = "", const char* varCode = "CyclopsCDOM") - : Variable(parentSense, (uint8_t)CYCLOPS_VAR_NUM, - (uint8_t)CYCLOPS_RESOLUTION, + : Variable(parentSense, static_cast(CYCLOPS_VAR_NUM), + static_cast(CYCLOPS_RESOLUTION), "fluorescenceDissolvedOrganicMatter", "partPerBillion", varCode, uuid) {} /** @@ -798,7 +804,8 @@ class TurnerCyclops_CDOM : public Variable { * used. */ TurnerCyclops_CDOM() - : Variable((uint8_t)CYCLOPS_VAR_NUM, (uint8_t)CYCLOPS_RESOLUTION, + : Variable(static_cast(CYCLOPS_VAR_NUM), + static_cast(CYCLOPS_RESOLUTION), "fluorescenceDissolvedOrganicMatter", "partPerBillion", "CyclopsCDOM") {} /** @@ -847,9 +854,10 @@ class TurnerCyclops_CrudeOil : public Variable { explicit TurnerCyclops_CrudeOil(TurnerCyclops* parentSense, const char* uuid = "", const char* varCode = "CyclopsCrudeOil") - : Variable(parentSense, (uint8_t)CYCLOPS_VAR_NUM, - (uint8_t)CYCLOPS_RESOLUTION, "petroleumHydrocarbonTotal", - "partPerBillion", varCode, uuid) {} + : Variable(parentSense, static_cast(CYCLOPS_VAR_NUM), + static_cast(CYCLOPS_RESOLUTION), + "petroleumHydrocarbonTotal", "partPerBillion", varCode, + uuid) {} /** * @brief Construct a new TurnerCyclops_CrudeOil object. * @@ -857,7 +865,8 @@ class TurnerCyclops_CrudeOil : public Variable { * used. */ TurnerCyclops_CrudeOil() - : Variable((uint8_t)CYCLOPS_VAR_NUM, (uint8_t)CYCLOPS_RESOLUTION, + : Variable(static_cast(CYCLOPS_VAR_NUM), + static_cast(CYCLOPS_RESOLUTION), "petroleumHydrocarbonTotal", "partPerBillion", "CyclopsCrudeOil") {} /** @@ -907,9 +916,9 @@ class TurnerCyclops_Brighteners : public Variable { explicit TurnerCyclops_Brighteners( TurnerCyclops* parentSense, const char* uuid = "", const char* varCode = "CyclopsOpticalBrighteners") - : Variable(parentSense, (uint8_t)CYCLOPS_VAR_NUM, - (uint8_t)CYCLOPS_RESOLUTION, "opticalBrighteners", - "partPerBillion", varCode, uuid) {} + : Variable(parentSense, static_cast(CYCLOPS_VAR_NUM), + static_cast(CYCLOPS_RESOLUTION), + "opticalBrighteners", "partPerBillion", varCode, uuid) {} /** * @brief Construct a new TurnerCyclops_Brighteners object. * @@ -917,7 +926,8 @@ class TurnerCyclops_Brighteners : public Variable { * used. */ TurnerCyclops_Brighteners() - : Variable((uint8_t)CYCLOPS_VAR_NUM, (uint8_t)CYCLOPS_RESOLUTION, + : Variable(static_cast(CYCLOPS_VAR_NUM), + static_cast(CYCLOPS_RESOLUTION), "opticalBrighteners", "partPerBillion", "CyclopsOpticalBrighteners") {} /** @@ -963,8 +973,8 @@ class TurnerCyclops_Turbidity : public Variable { explicit TurnerCyclops_Turbidity(TurnerCyclops* parentSense, const char* uuid = "", const char* varCode = "CyclopsTurbidity") - : Variable(parentSense, (uint8_t)CYCLOPS_VAR_NUM, - (uint8_t)CYCLOPS_RESOLUTION, "Turbidity", + : Variable(parentSense, static_cast(CYCLOPS_VAR_NUM), + static_cast(CYCLOPS_RESOLUTION), "Turbidity", "nephelometricTurbidityUnit", varCode, uuid) {} /** * @brief Construct a new TurnerCyclops_Turbidity object. @@ -973,9 +983,9 @@ class TurnerCyclops_Turbidity : public Variable { * used. */ TurnerCyclops_Turbidity() - : Variable((uint8_t)CYCLOPS_VAR_NUM, (uint8_t)CYCLOPS_RESOLUTION, - "Turbidity", "nephelometricTurbidityUnit", - "CyclopsTurbidity") {} + : Variable(static_cast(CYCLOPS_VAR_NUM), + static_cast(CYCLOPS_RESOLUTION), "Turbidity", + "nephelometricTurbidityUnit", "CyclopsTurbidity") {} /** * @brief Destroy the Turner Cyclops Turbidity variable object - no action * needed. @@ -1021,9 +1031,9 @@ class TurnerCyclops_PTSA : public Variable { explicit TurnerCyclops_PTSA(TurnerCyclops* parentSense, const char* uuid = "", const char* varCode = "CyclopsPTSA") - : Variable(parentSense, (uint8_t)CYCLOPS_VAR_NUM, - (uint8_t)CYCLOPS_RESOLUTION, "ptsa", "partPerBillion", - varCode, uuid) {} + : Variable(parentSense, static_cast(CYCLOPS_VAR_NUM), + static_cast(CYCLOPS_RESOLUTION), "ptsa", + "partPerBillion", varCode, uuid) {} /** * @brief Construct a new TurnerCyclops_PTSA object. * @@ -1031,8 +1041,9 @@ class TurnerCyclops_PTSA : public Variable { * used. */ TurnerCyclops_PTSA() - : Variable((uint8_t)CYCLOPS_VAR_NUM, (uint8_t)CYCLOPS_RESOLUTION, - "ptsa", "partPerBillion", "CyclopsPTSA") {} + : Variable(static_cast(CYCLOPS_VAR_NUM), + static_cast(CYCLOPS_RESOLUTION), "ptsa", + "partPerBillion", "CyclopsPTSA") {} /** * @brief Destroy the Turner Cyclops PTSA variable object - no action * needed. @@ -1078,9 +1089,9 @@ class TurnerCyclops_BTEX : public Variable { explicit TurnerCyclops_BTEX(TurnerCyclops* parentSense, const char* uuid = "", const char* varCode = "CyclopsBTEX") - : Variable(parentSense, (uint8_t)CYCLOPS_VAR_NUM, - (uint8_t)CYCLOPS_RESOLUTION, "btex", "partPerMillion", - varCode, uuid) {} + : Variable(parentSense, static_cast(CYCLOPS_VAR_NUM), + static_cast(CYCLOPS_RESOLUTION), "btex", + "partPerMillion", varCode, uuid) {} /** * @brief Construct a new TurnerCyclops_BTEX object. * @@ -1088,8 +1099,9 @@ class TurnerCyclops_BTEX : public Variable { * used. */ TurnerCyclops_BTEX() - : Variable((uint8_t)CYCLOPS_VAR_NUM, (uint8_t)CYCLOPS_RESOLUTION, - "btex", "partPerMillion", "CyclopsBTEX") {} + : Variable(static_cast(CYCLOPS_VAR_NUM), + static_cast(CYCLOPS_RESOLUTION), "btex", + "partPerMillion", "CyclopsBTEX") {} /** * @brief Destroy the Turner Cyclops BTEX variable object - no action * needed. @@ -1134,9 +1146,9 @@ class TurnerCyclops_Tryptophan : public Variable { explicit TurnerCyclops_Tryptophan(TurnerCyclops* parentSense, const char* uuid = "", const char* varCode = "CyclopsTryptophan") - : Variable(parentSense, (uint8_t)CYCLOPS_VAR_NUM, - (uint8_t)CYCLOPS_RESOLUTION, "tryptophan", "partPerBillion", - varCode, uuid) {} + : Variable(parentSense, static_cast(CYCLOPS_VAR_NUM), + static_cast(CYCLOPS_RESOLUTION), "tryptophan", + "partPerBillion", varCode, uuid) {} /** * @brief Construct a new TurnerCyclops_Tryptophan object. * @@ -1144,8 +1156,9 @@ class TurnerCyclops_Tryptophan : public Variable { * used. */ TurnerCyclops_Tryptophan() - : Variable((uint8_t)CYCLOPS_VAR_NUM, (uint8_t)CYCLOPS_RESOLUTION, - "tryptophan", "partPerBillion", "CyclopsTryptophan") {} + : Variable(static_cast(CYCLOPS_VAR_NUM), + static_cast(CYCLOPS_RESOLUTION), "tryptophan", + "partPerBillion", "CyclopsTryptophan") {} /** * @brief Destroy the Turner Cyclops Tryptophan variable object - no action * needed. @@ -1191,9 +1204,10 @@ class TurnerCyclops_RedChlorophyll : public Variable { explicit TurnerCyclops_RedChlorophyll( TurnerCyclops* parentSense, const char* uuid = "", const char* varCode = "CyclopsRedChlorophyll") - : Variable(parentSense, (uint8_t)CYCLOPS_VAR_NUM, - (uint8_t)CYCLOPS_RESOLUTION, "chlorophyllFluorescence", - "microgramPerLiter", varCode, uuid) {} + : Variable(parentSense, static_cast(CYCLOPS_VAR_NUM), + static_cast(CYCLOPS_RESOLUTION), + "chlorophyllFluorescence", "microgramPerLiter", varCode, + uuid) {} /** * @brief Construct a new TurnerCyclops_RedChlorophyll object. * @@ -1201,7 +1215,8 @@ class TurnerCyclops_RedChlorophyll : public Variable { * used. */ TurnerCyclops_RedChlorophyll() - : Variable((uint8_t)CYCLOPS_VAR_NUM, (uint8_t)CYCLOPS_RESOLUTION, + : Variable(static_cast(CYCLOPS_VAR_NUM), + static_cast(CYCLOPS_RESOLUTION), "chlorophyllFluorescence", "microgramPerLiter", "CyclopsRedChlorophyll") {} /** diff --git a/src/sensors/TurnerTurbidityPlus.h b/src/sensors/TurnerTurbidityPlus.h index ba1bb634f..09595200a 100644 --- a/src/sensors/TurnerTurbidityPlus.h +++ b/src/sensors/TurnerTurbidityPlus.h @@ -378,8 +378,9 @@ class TurnerTurbidityPlus_Voltage : public Variable { explicit TurnerTurbidityPlus_Voltage( TurnerTurbidityPlus* parentSense, const char* uuid = "", const char* varCode = TURBIDITY_PLUS_VOLTAGE_DEFAULT_CODE) - : Variable(parentSense, (uint8_t)TURBIDITY_PLUS_VOLTAGE_VAR_NUM, - (uint8_t)TURBIDITY_PLUS_VOLTAGE_RESOLUTION, + : Variable(parentSense, + static_cast(TURBIDITY_PLUS_VOLTAGE_VAR_NUM), + static_cast(TURBIDITY_PLUS_VOLTAGE_RESOLUTION), TURBIDITY_PLUS_VOLTAGE_VAR_NAME, TURBIDITY_PLUS_VOLTAGE_UNIT_NAME, varCode, uuid) {} /** @@ -389,8 +390,8 @@ class TurnerTurbidityPlus_Voltage : public Variable { * be used. */ TurnerTurbidityPlus_Voltage() - : Variable((uint8_t)TURBIDITY_PLUS_VOLTAGE_VAR_NUM, - (uint8_t)TURBIDITY_PLUS_VOLTAGE_RESOLUTION, + : Variable(static_cast(TURBIDITY_PLUS_VOLTAGE_VAR_NUM), + static_cast(TURBIDITY_PLUS_VOLTAGE_RESOLUTION), TURBIDITY_PLUS_VOLTAGE_VAR_NAME, TURBIDITY_PLUS_VOLTAGE_UNIT_NAME, TURBIDITY_PLUS_VOLTAGE_DEFAULT_CODE) {} @@ -427,9 +428,10 @@ class TurnerTurbidityPlus_Turbidity : public Variable { explicit TurnerTurbidityPlus_Turbidity( TurnerTurbidityPlus* parentSense, const char* uuid = "", const char* varCode = TURBIDITY_PLUS_DEFAULT_CODE) - : Variable(parentSense, (uint8_t)TURBIDITY_PLUS_VAR_NUM, - (uint8_t)TURBIDITY_PLUS_RESOLUTION, TURBIDITY_PLUS_VAR_NAME, - TURBIDITY_PLUS_UNIT_NAME, varCode, uuid) {} + : Variable(parentSense, static_cast(TURBIDITY_PLUS_VAR_NUM), + static_cast(TURBIDITY_PLUS_RESOLUTION), + TURBIDITY_PLUS_VAR_NAME, TURBIDITY_PLUS_UNIT_NAME, varCode, + uuid) {} /** * @brief Construct a new TurnerTurbidityPlus_Turbidity object. * @@ -437,9 +439,10 @@ class TurnerTurbidityPlus_Turbidity : public Variable { * be used. */ TurnerTurbidityPlus_Turbidity() - : Variable((uint8_t)TURBIDITY_PLUS_VAR_NUM, - (uint8_t)TURBIDITY_PLUS_RESOLUTION, TURBIDITY_PLUS_VAR_NAME, - TURBIDITY_PLUS_UNIT_NAME, TURBIDITY_PLUS_DEFAULT_CODE) {} + : Variable(static_cast(TURBIDITY_PLUS_VAR_NUM), + static_cast(TURBIDITY_PLUS_RESOLUTION), + TURBIDITY_PLUS_VAR_NAME, TURBIDITY_PLUS_UNIT_NAME, + TURBIDITY_PLUS_DEFAULT_CODE) {} /** * @brief Destroy the TurnerTurbidityPlus_Turbidity object - no action * needed. diff --git a/src/sensors/VegaPuls21.h b/src/sensors/VegaPuls21.h index abd3703a0..8037c6845 100644 --- a/src/sensors/VegaPuls21.h +++ b/src/sensors/VegaPuls21.h @@ -326,8 +326,8 @@ class VegaPuls21_Stage : public Variable { explicit VegaPuls21_Stage( VegaPuls21* parentSense, const char* uuid = "", const char* varCode = VEGAPULS21_STAGE_DEFAULT_CODE) - : Variable(parentSense, (uint8_t)VEGAPULS21_STAGE_VAR_NUM, - (uint8_t)VEGAPULS21_STAGE_RESOLUTION, + : Variable(parentSense, static_cast(VEGAPULS21_STAGE_VAR_NUM), + static_cast(VEGAPULS21_STAGE_RESOLUTION), VEGAPULS21_STAGE_VAR_NAME, VEGAPULS21_STAGE_UNIT_NAME, varCode, uuid) {} /** @@ -337,8 +337,8 @@ class VegaPuls21_Stage : public Variable { * used. */ VegaPuls21_Stage() - : Variable((uint8_t)VEGAPULS21_STAGE_VAR_NUM, - (uint8_t)VEGAPULS21_STAGE_RESOLUTION, + : Variable(static_cast(VEGAPULS21_STAGE_VAR_NUM), + static_cast(VEGAPULS21_STAGE_RESOLUTION), VEGAPULS21_STAGE_VAR_NAME, VEGAPULS21_STAGE_UNIT_NAME, VEGAPULS21_STAGE_DEFAULT_CODE) {} /** @@ -372,8 +372,9 @@ class VegaPuls21_Distance : public Variable { explicit VegaPuls21_Distance( VegaPuls21* parentSense, const char* uuid = "", const char* varCode = VEGAPULS21_DISTANCE_DEFAULT_CODE) - : Variable(parentSense, (uint8_t)VEGAPULS21_DISTANCE_VAR_NUM, - (uint8_t)VEGAPULS21_DISTANCE_RESOLUTION, + : Variable(parentSense, + static_cast(VEGAPULS21_DISTANCE_VAR_NUM), + static_cast(VEGAPULS21_DISTANCE_RESOLUTION), VEGAPULS21_DISTANCE_VAR_NAME, VEGAPULS21_DISTANCE_UNIT_NAME, varCode, uuid) {} /** @@ -383,8 +384,8 @@ class VegaPuls21_Distance : public Variable { * used. */ VegaPuls21_Distance() - : Variable((uint8_t)VEGAPULS21_DISTANCE_VAR_NUM, - (uint8_t)VEGAPULS21_DISTANCE_RESOLUTION, + : Variable(static_cast(VEGAPULS21_DISTANCE_VAR_NUM), + static_cast(VEGAPULS21_DISTANCE_RESOLUTION), VEGAPULS21_DISTANCE_VAR_NAME, VEGAPULS21_DISTANCE_UNIT_NAME, VEGAPULS21_DISTANCE_DEFAULT_CODE) {} /** @@ -417,8 +418,8 @@ class VegaPuls21_Temp : public Variable { */ explicit VegaPuls21_Temp(VegaPuls21* parentSense, const char* uuid = "", const char* varCode = VEGAPULS21_TEMP_DEFAULT_CODE) - : Variable(parentSense, (uint8_t)VEGAPULS21_TEMP_VAR_NUM, - (uint8_t)VEGAPULS21_TEMP_RESOLUTION, + : Variable(parentSense, static_cast(VEGAPULS21_TEMP_VAR_NUM), + static_cast(VEGAPULS21_TEMP_RESOLUTION), VEGAPULS21_TEMP_VAR_NAME, VEGAPULS21_TEMP_UNIT_NAME, varCode, uuid) {} /** @@ -428,8 +429,8 @@ class VegaPuls21_Temp : public Variable { * used. */ VegaPuls21_Temp() - : Variable((uint8_t)VEGAPULS21_TEMP_VAR_NUM, - (uint8_t)VEGAPULS21_TEMP_RESOLUTION, + : Variable(static_cast(VEGAPULS21_TEMP_VAR_NUM), + static_cast(VEGAPULS21_TEMP_RESOLUTION), VEGAPULS21_TEMP_VAR_NAME, VEGAPULS21_TEMP_UNIT_NAME, VEGAPULS21_TEMP_DEFAULT_CODE) {} /** @@ -463,8 +464,9 @@ class VegaPuls21_Reliability : public Variable { explicit VegaPuls21_Reliability( VegaPuls21* parentSense, const char* uuid = "", const char* varCode = VEGAPULS21_RELIABILITY_DEFAULT_CODE) - : Variable(parentSense, (uint8_t)VEGAPULS21_RELIABILITY_VAR_NUM, - (uint8_t)VEGAPULS21_RELIABILITY_RESOLUTION, + : Variable(parentSense, + static_cast(VEGAPULS21_RELIABILITY_VAR_NUM), + static_cast(VEGAPULS21_RELIABILITY_RESOLUTION), VEGAPULS21_RELIABILITY_VAR_NAME, VEGAPULS21_RELIABILITY_UNIT_NAME, varCode, uuid) {} /** @@ -474,8 +476,8 @@ class VegaPuls21_Reliability : public Variable { * used. */ VegaPuls21_Reliability() - : Variable((uint8_t)VEGAPULS21_RELIABILITY_VAR_NUM, - (uint8_t)VEGAPULS21_RELIABILITY_RESOLUTION, + : Variable(static_cast(VEGAPULS21_RELIABILITY_VAR_NUM), + static_cast(VEGAPULS21_RELIABILITY_RESOLUTION), VEGAPULS21_RELIABILITY_VAR_NAME, VEGAPULS21_RELIABILITY_UNIT_NAME, VEGAPULS21_RELIABILITY_DEFAULT_CODE) {} @@ -511,8 +513,9 @@ class VegaPuls21_ErrorCode : public Variable { explicit VegaPuls21_ErrorCode( VegaPuls21* parentSense, const char* uuid = "", const char* varCode = VEGAPULS21_ERRORCODE_DEFAULT_CODE) - : Variable(parentSense, (uint8_t)VEGAPULS21_ERRORCODE_VAR_NUM, - (uint8_t)VEGAPULS21_ERRORCODE_RESOLUTION, + : Variable(parentSense, + static_cast(VEGAPULS21_ERRORCODE_VAR_NUM), + static_cast(VEGAPULS21_ERRORCODE_RESOLUTION), VEGAPULS21_ERRORCODE_VAR_NAME, VEGAPULS21_ERRORCODE_UNIT_NAME, varCode, uuid) {} /** @@ -522,8 +525,8 @@ class VegaPuls21_ErrorCode : public Variable { * used. */ VegaPuls21_ErrorCode() - : Variable((uint8_t)VEGAPULS21_ERRORCODE_VAR_NUM, - (uint8_t)VEGAPULS21_ERRORCODE_RESOLUTION, + : Variable(static_cast(VEGAPULS21_ERRORCODE_VAR_NUM), + static_cast(VEGAPULS21_ERRORCODE_RESOLUTION), VEGAPULS21_ERRORCODE_VAR_NAME, VEGAPULS21_ERRORCODE_UNIT_NAME, VEGAPULS21_ERRORCODE_DEFAULT_CODE) {} diff --git a/src/sensors/YosemitechY4000.h b/src/sensors/YosemitechY4000.h index 8712fac94..e9a6314cb 100644 --- a/src/sensors/YosemitechY4000.h +++ b/src/sensors/YosemitechY4000.h @@ -401,9 +401,10 @@ class YosemitechY4000_DOmgL : public Variable { explicit YosemitechY4000_DOmgL( YosemitechY4000* parentSense, const char* uuid = "", const char* varCode = Y4000_DOMGL_DEFAULT_CODE) - : Variable(parentSense, (uint8_t)Y4000_DOMGL_VAR_NUM, - (uint8_t)Y4000_DOMGL_RESOLUTION, Y4000_DOMGL_VAR_NAME, - Y4000_DOMGL_UNIT_NAME, varCode, uuid) {} + : Variable(parentSense, static_cast(Y4000_DOMGL_VAR_NUM), + static_cast(Y4000_DOMGL_RESOLUTION), + Y4000_DOMGL_VAR_NAME, Y4000_DOMGL_UNIT_NAME, varCode, uuid) { + } /** * @brief Construct a new YosemitechY4000_DOmgL object. * @@ -411,9 +412,10 @@ class YosemitechY4000_DOmgL : public Variable { * used. */ YosemitechY4000_DOmgL() - : Variable((uint8_t)Y4000_DOMGL_VAR_NUM, - (uint8_t)Y4000_DOMGL_RESOLUTION, Y4000_DOMGL_VAR_NAME, - Y4000_DOMGL_UNIT_NAME, Y4000_DOMGL_DEFAULT_CODE) {} + : Variable(static_cast(Y4000_DOMGL_VAR_NUM), + static_cast(Y4000_DOMGL_RESOLUTION), + Y4000_DOMGL_VAR_NAME, Y4000_DOMGL_UNIT_NAME, + Y4000_DOMGL_DEFAULT_CODE) {} /** * @brief Destroy the YosemitechY4000_DOmgL object - no action needed. */ @@ -444,9 +446,9 @@ class YosemitechY4000_Turbidity : public Variable { explicit YosemitechY4000_Turbidity( YosemitechY4000* parentSense, const char* uuid = "", const char* varCode = Y4000_TURB_DEFAULT_CODE) - : Variable(parentSense, (uint8_t)Y4000_TURB_VAR_NUM, - (uint8_t)Y4000_TURB_RESOLUTION, Y4000_TURB_VAR_NAME, - Y4000_TURB_UNIT_NAME, varCode, uuid) {} + : Variable(parentSense, static_cast(Y4000_TURB_VAR_NUM), + static_cast(Y4000_TURB_RESOLUTION), + Y4000_TURB_VAR_NAME, Y4000_TURB_UNIT_NAME, varCode, uuid) {} /** * @brief Construct a new YosemitechY4000_Turbidity object. * @@ -454,7 +456,8 @@ class YosemitechY4000_Turbidity : public Variable { * used. */ YosemitechY4000_Turbidity() - : Variable((uint8_t)Y4000_TURB_VAR_NUM, (uint8_t)Y4000_TURB_RESOLUTION, + : Variable(static_cast(Y4000_TURB_VAR_NUM), + static_cast(Y4000_TURB_RESOLUTION), Y4000_TURB_VAR_NAME, Y4000_TURB_UNIT_NAME, Y4000_TURB_DEFAULT_CODE) {} /** @@ -487,9 +490,9 @@ class YosemitechY4000_Cond : public Variable { explicit YosemitechY4000_Cond(YosemitechY4000* parentSense, const char* uuid = "", const char* varCode = Y4000_COND_DEFAULT_CODE) - : Variable(parentSense, (uint8_t)Y4000_COND_VAR_NUM, - (uint8_t)Y4000_COND_RESOLUTION, Y4000_COND_VAR_NAME, - Y4000_COND_UNIT_NAME, varCode, uuid) {} + : Variable(parentSense, static_cast(Y4000_COND_VAR_NUM), + static_cast(Y4000_COND_RESOLUTION), + Y4000_COND_VAR_NAME, Y4000_COND_UNIT_NAME, varCode, uuid) {} /** * @brief Construct a new YosemitechY4000_Cond object. * @@ -497,7 +500,8 @@ class YosemitechY4000_Cond : public Variable { * used. */ YosemitechY4000_Cond() - : Variable((uint8_t)Y4000_COND_VAR_NUM, (uint8_t)Y4000_COND_RESOLUTION, + : Variable(static_cast(Y4000_COND_VAR_NUM), + static_cast(Y4000_COND_RESOLUTION), Y4000_COND_VAR_NAME, Y4000_COND_UNIT_NAME, Y4000_COND_DEFAULT_CODE) {} /** @@ -530,8 +534,8 @@ class YosemitechY4000_pH : public Variable { explicit YosemitechY4000_pH(YosemitechY4000* parentSense, const char* uuid = "", const char* varCode = Y4000_PH_DEFAULT_CODE) - : Variable(parentSense, (uint8_t)Y4000_PH_VAR_NUM, - (uint8_t)Y4000_PH_RESOLUTION, Y4000_PH_VAR_NAME, + : Variable(parentSense, static_cast(Y4000_PH_VAR_NUM), + static_cast(Y4000_PH_RESOLUTION), Y4000_PH_VAR_NAME, Y4000_PH_UNIT_NAME, varCode, uuid) {} /** * @brief Construct a new YosemitechY4000_pH object. @@ -540,9 +544,9 @@ class YosemitechY4000_pH : public Variable { * used. */ YosemitechY4000_pH() - : Variable((uint8_t)Y4000_PH_VAR_NUM, (uint8_t)Y4000_PH_RESOLUTION, - Y4000_PH_VAR_NAME, Y4000_PH_UNIT_NAME, - Y4000_PH_DEFAULT_CODE) {} + : Variable(static_cast(Y4000_PH_VAR_NUM), + static_cast(Y4000_PH_RESOLUTION), Y4000_PH_VAR_NAME, + Y4000_PH_UNIT_NAME, Y4000_PH_DEFAULT_CODE) {} /** * @brief Destroy the YosemitechY4000_pH object - no action needed. */ @@ -573,9 +577,9 @@ class YosemitechY4000_Temp : public Variable { explicit YosemitechY4000_Temp(YosemitechY4000* parentSense, const char* uuid = "", const char* varCode = Y4000_TEMP_DEFAULT_CODE) - : Variable(parentSense, (uint8_t)Y4000_TEMP_VAR_NUM, - (uint8_t)Y4000_TEMP_RESOLUTION, Y4000_TEMP_VAR_NAME, - Y4000_TEMP_UNIT_NAME, varCode, uuid) {} + : Variable(parentSense, static_cast(Y4000_TEMP_VAR_NUM), + static_cast(Y4000_TEMP_RESOLUTION), + Y4000_TEMP_VAR_NAME, Y4000_TEMP_UNIT_NAME, varCode, uuid) {} /** * @brief Construct a new YosemitechY4000_Temp object. * @@ -583,7 +587,8 @@ class YosemitechY4000_Temp : public Variable { * used. */ YosemitechY4000_Temp() - : Variable((uint8_t)Y4000_TEMP_VAR_NUM, (uint8_t)Y4000_TEMP_RESOLUTION, + : Variable(static_cast(Y4000_TEMP_VAR_NUM), + static_cast(Y4000_TEMP_RESOLUTION), Y4000_TEMP_VAR_NAME, Y4000_TEMP_UNIT_NAME, Y4000_TEMP_DEFAULT_CODE) {} /** @@ -616,9 +621,9 @@ class YosemitechY4000_ORP : public Variable { explicit YosemitechY4000_ORP(YosemitechY4000* parentSense, const char* uuid = "", const char* varCode = Y4000_ORP_DEFAULT_CODE) - : Variable(parentSense, (uint8_t)Y4000_ORP_VAR_NUM, - (uint8_t)Y4000_ORP_RESOLUTION, Y4000_ORP_VAR_NAME, - Y4000_ORP_UNIT_NAME, varCode, uuid) {} + : Variable(parentSense, static_cast(Y4000_ORP_VAR_NUM), + static_cast(Y4000_ORP_RESOLUTION), + Y4000_ORP_VAR_NAME, Y4000_ORP_UNIT_NAME, varCode, uuid) {} /** * @brief Construct a new YosemitechY4000_ORP object. * @@ -626,7 +631,8 @@ class YosemitechY4000_ORP : public Variable { * used. */ YosemitechY4000_ORP() - : Variable((uint8_t)Y4000_ORP_VAR_NUM, (uint8_t)Y4000_ORP_RESOLUTION, + : Variable(static_cast(Y4000_ORP_VAR_NUM), + static_cast(Y4000_ORP_RESOLUTION), Y4000_ORP_VAR_NAME, Y4000_ORP_UNIT_NAME, Y4000_ORP_DEFAULT_CODE) {} /** @@ -659,9 +665,10 @@ class YosemitechY4000_Chlorophyll : public Variable { explicit YosemitechY4000_Chlorophyll( YosemitechY4000* parentSense, const char* uuid = "", const char* varCode = Y4000_CHLORO_DEFAULT_CODE) - : Variable(parentSense, (uint8_t)Y4000_CHLORO_VAR_NUM, - (uint8_t)Y4000_CHLORO_RESOLUTION, Y4000_CHLORO_VAR_NAME, - Y4000_CHLORO_UNIT_NAME, varCode, uuid) {} + : Variable(parentSense, static_cast(Y4000_CHLORO_VAR_NUM), + static_cast(Y4000_CHLORO_RESOLUTION), + Y4000_CHLORO_VAR_NAME, Y4000_CHLORO_UNIT_NAME, varCode, + uuid) {} /** * @brief Construct a new YosemitechY4000_Chlorophyll object. * @@ -669,9 +676,10 @@ class YosemitechY4000_Chlorophyll : public Variable { * used. */ YosemitechY4000_Chlorophyll() - : Variable((uint8_t)Y4000_CHLORO_VAR_NUM, - (uint8_t)Y4000_CHLORO_RESOLUTION, Y4000_CHLORO_VAR_NAME, - Y4000_CHLORO_UNIT_NAME, Y4000_CHLORO_DEFAULT_CODE) {} + : Variable(static_cast(Y4000_CHLORO_VAR_NUM), + static_cast(Y4000_CHLORO_RESOLUTION), + Y4000_CHLORO_VAR_NAME, Y4000_CHLORO_UNIT_NAME, + Y4000_CHLORO_DEFAULT_CODE) {} /** * @brief Destroy the YosemitechY4000_Chlorophyll() object - no action * needed. @@ -703,9 +711,9 @@ class YosemitechY4000_BGA : public Variable { explicit YosemitechY4000_BGA(YosemitechY4000* parentSense, const char* uuid = "", const char* varCode = Y4000_BGA_DEFAULT_CODE) - : Variable(parentSense, (uint8_t)Y4000_BGA_VAR_NUM, - (uint8_t)Y4000_BGA_RESOLUTION, Y4000_BGA_VAR_NAME, - Y4000_BGA_UNIT_NAME, varCode, uuid) {} + : Variable(parentSense, static_cast(Y4000_BGA_VAR_NUM), + static_cast(Y4000_BGA_RESOLUTION), + Y4000_BGA_VAR_NAME, Y4000_BGA_UNIT_NAME, varCode, uuid) {} /** * @brief Construct a new YosemitechY4000_BGA object. * @@ -713,7 +721,8 @@ class YosemitechY4000_BGA : public Variable { * used. */ YosemitechY4000_BGA() - : Variable((uint8_t)Y4000_BGA_VAR_NUM, (uint8_t)Y4000_BGA_RESOLUTION, + : Variable(static_cast(Y4000_BGA_VAR_NUM), + static_cast(Y4000_BGA_RESOLUTION), Y4000_BGA_VAR_NAME, Y4000_BGA_UNIT_NAME, Y4000_BGA_DEFAULT_CODE) {} /** diff --git a/src/sensors/YosemitechY504.h b/src/sensors/YosemitechY504.h index 47cc9c58f..939ad61a8 100644 --- a/src/sensors/YosemitechY504.h +++ b/src/sensors/YosemitechY504.h @@ -255,9 +255,9 @@ class YosemitechY504_DOpct : public Variable { explicit YosemitechY504_DOpct(YosemitechY504* parentSense, const char* uuid = "", const char* varCode = Y504_DOPCT_DEFAULT_CODE) - : Variable(parentSense, (uint8_t)Y504_DOPCT_VAR_NUM, - (uint8_t)Y504_DOPCT_RESOLUTION, Y504_DOPCT_VAR_NAME, - Y504_DOPCT_UNIT_NAME, varCode, uuid) {} + : Variable(parentSense, static_cast(Y504_DOPCT_VAR_NUM), + static_cast(Y504_DOPCT_RESOLUTION), + Y504_DOPCT_VAR_NAME, Y504_DOPCT_UNIT_NAME, varCode, uuid) {} /** * @brief Construct a new YosemitechY504_DOpct object. * @@ -265,7 +265,8 @@ class YosemitechY504_DOpct : public Variable { * used. */ YosemitechY504_DOpct() - : Variable((uint8_t)Y504_DOPCT_VAR_NUM, (uint8_t)Y504_DOPCT_RESOLUTION, + : Variable(static_cast(Y504_DOPCT_VAR_NUM), + static_cast(Y504_DOPCT_RESOLUTION), Y504_DOPCT_VAR_NAME, Y504_DOPCT_UNIT_NAME, Y504_DOPCT_DEFAULT_CODE) {} /** @@ -299,9 +300,9 @@ class YosemitechY504_Temp : public Variable { explicit YosemitechY504_Temp(YosemitechY504* parentSense, const char* uuid = "", const char* varCode = Y504_TEMP_DEFAULT_CODE) - : Variable(parentSense, (uint8_t)Y504_TEMP_VAR_NUM, - (uint8_t)Y504_TEMP_RESOLUTION, Y504_TEMP_VAR_NAME, - Y504_TEMP_UNIT_NAME, varCode, uuid) {} + : Variable(parentSense, static_cast(Y504_TEMP_VAR_NUM), + static_cast(Y504_TEMP_RESOLUTION), + Y504_TEMP_VAR_NAME, Y504_TEMP_UNIT_NAME, varCode, uuid) {} /** * @brief Construct a new YosemitechY504_Temp object. * @@ -309,7 +310,8 @@ class YosemitechY504_Temp : public Variable { * used. */ YosemitechY504_Temp() - : Variable((uint8_t)Y504_TEMP_VAR_NUM, (uint8_t)Y504_TEMP_RESOLUTION, + : Variable(static_cast(Y504_TEMP_VAR_NUM), + static_cast(Y504_TEMP_RESOLUTION), Y504_TEMP_VAR_NAME, Y504_TEMP_UNIT_NAME, Y504_TEMP_DEFAULT_CODE) {} /** @@ -343,9 +345,9 @@ class YosemitechY504_DOmgL : public Variable { explicit YosemitechY504_DOmgL(YosemitechY504* parentSense, const char* uuid = "", const char* varCode = Y504_DOMGL_DEFAULT_CODE) - : Variable(parentSense, (uint8_t)Y504_DOMGL_VAR_NUM, - (uint8_t)Y504_DOMGL_RESOLUTION, Y504_DOMGL_VAR_NAME, - Y504_DOMGL_UNIT_NAME, varCode, uuid) {} + : Variable(parentSense, static_cast(Y504_DOMGL_VAR_NUM), + static_cast(Y504_DOMGL_RESOLUTION), + Y504_DOMGL_VAR_NAME, Y504_DOMGL_UNIT_NAME, varCode, uuid) {} /** * @brief Construct a new YosemitechY504_DOmgL object. * @@ -353,7 +355,8 @@ class YosemitechY504_DOmgL : public Variable { * used. */ YosemitechY504_DOmgL() - : Variable((uint8_t)Y504_DOMGL_VAR_NUM, (uint8_t)Y504_DOMGL_RESOLUTION, + : Variable(static_cast(Y504_DOMGL_VAR_NUM), + static_cast(Y504_DOMGL_RESOLUTION), Y504_DOMGL_VAR_NAME, Y504_DOMGL_UNIT_NAME, Y504_DOMGL_DEFAULT_CODE) {} /** diff --git a/src/sensors/YosemitechY510.h b/src/sensors/YosemitechY510.h index a614acfca..da319c60f 100644 --- a/src/sensors/YosemitechY510.h +++ b/src/sensors/YosemitechY510.h @@ -221,9 +221,9 @@ class YosemitechY510_Turbidity : public Variable { explicit YosemitechY510_Turbidity( YosemitechY510* parentSense, const char* uuid = "", const char* varCode = Y510_TURB_DEFAULT_CODE) - : Variable(parentSense, (uint8_t)Y510_TURB_VAR_NUM, - (uint8_t)Y510_TURB_RESOLUTION, Y510_TURB_VAR_NAME, - Y510_TURB_UNIT_NAME, varCode, uuid) {} + : Variable(parentSense, static_cast(Y510_TURB_VAR_NUM), + static_cast(Y510_TURB_RESOLUTION), + Y510_TURB_VAR_NAME, Y510_TURB_UNIT_NAME, varCode, uuid) {} /** * @brief Construct a new YosemitechY510_Turbidity object. * @@ -231,7 +231,8 @@ class YosemitechY510_Turbidity : public Variable { * used. */ YosemitechY510_Turbidity() - : Variable((uint8_t)Y510_TURB_VAR_NUM, (uint8_t)Y510_TURB_RESOLUTION, + : Variable(static_cast(Y510_TURB_VAR_NUM), + static_cast(Y510_TURB_RESOLUTION), Y510_TURB_VAR_NAME, Y510_TURB_UNIT_NAME, Y510_TURB_DEFAULT_CODE) {} /** @@ -265,9 +266,9 @@ class YosemitechY510_Temp : public Variable { explicit YosemitechY510_Temp(YosemitechY510* parentSense, const char* uuid = "", const char* varCode = Y510_TEMP_DEFAULT_CODE) - : Variable(parentSense, (uint8_t)Y510_TEMP_VAR_NUM, - (uint8_t)Y510_TEMP_RESOLUTION, Y510_TEMP_VAR_NAME, - Y510_TEMP_UNIT_NAME, varCode, uuid) {} + : Variable(parentSense, static_cast(Y510_TEMP_VAR_NUM), + static_cast(Y510_TEMP_RESOLUTION), + Y510_TEMP_VAR_NAME, Y510_TEMP_UNIT_NAME, varCode, uuid) {} /** * @brief Construct a new YosemitechY510_Temp object. * @@ -275,7 +276,8 @@ class YosemitechY510_Temp : public Variable { * used. */ YosemitechY510_Temp() - : Variable((uint8_t)Y510_TEMP_VAR_NUM, (uint8_t)Y510_TEMP_RESOLUTION, + : Variable(static_cast(Y510_TEMP_VAR_NUM), + static_cast(Y510_TEMP_RESOLUTION), Y510_TEMP_VAR_NAME, Y510_TEMP_UNIT_NAME, Y510_TEMP_DEFAULT_CODE) {} /** diff --git a/src/sensors/YosemitechY511.h b/src/sensors/YosemitechY511.h index d65d7c008..32dce7011 100644 --- a/src/sensors/YosemitechY511.h +++ b/src/sensors/YosemitechY511.h @@ -235,9 +235,9 @@ class YosemitechY511_Turbidity : public Variable { explicit YosemitechY511_Turbidity( YosemitechY511* parentSense, const char* uuid = "", const char* varCode = Y511_TURB_DEFAULT_CODE) - : Variable(parentSense, (uint8_t)Y511_TURB_VAR_NUM, - (uint8_t)Y511_TURB_RESOLUTION, Y511_TURB_VAR_NAME, - Y511_TURB_UNIT_NAME, varCode, uuid) {} + : Variable(parentSense, static_cast(Y511_TURB_VAR_NUM), + static_cast(Y511_TURB_RESOLUTION), + Y511_TURB_VAR_NAME, Y511_TURB_UNIT_NAME, varCode, uuid) {} /** * @brief Construct a new YosemitechY511_Turbidity object. * @@ -245,7 +245,8 @@ class YosemitechY511_Turbidity : public Variable { * used. */ YosemitechY511_Turbidity() - : Variable((uint8_t)Y511_TURB_VAR_NUM, (uint8_t)Y511_TURB_RESOLUTION, + : Variable(static_cast(Y511_TURB_VAR_NUM), + static_cast(Y511_TURB_RESOLUTION), Y511_TURB_VAR_NAME, Y511_TURB_UNIT_NAME, Y511_TURB_DEFAULT_CODE) {} /** @@ -279,9 +280,9 @@ class YosemitechY511_Temp : public Variable { explicit YosemitechY511_Temp(YosemitechY511* parentSense, const char* uuid = "", const char* varCode = Y511_TEMP_DEFAULT_CODE) - : Variable(parentSense, (uint8_t)Y511_TEMP_VAR_NUM, - (uint8_t)Y511_TEMP_RESOLUTION, Y511_TEMP_VAR_NAME, - Y511_TEMP_UNIT_NAME, varCode, uuid) {} + : Variable(parentSense, static_cast(Y511_TEMP_VAR_NUM), + static_cast(Y511_TEMP_RESOLUTION), + Y511_TEMP_VAR_NAME, Y511_TEMP_UNIT_NAME, varCode, uuid) {} /** * @brief Construct a new YosemitechY511_Temp object. * @@ -289,7 +290,8 @@ class YosemitechY511_Temp : public Variable { * used. */ YosemitechY511_Temp() - : Variable((uint8_t)Y511_TEMP_VAR_NUM, (uint8_t)Y511_TEMP_RESOLUTION, + : Variable(static_cast(Y511_TEMP_VAR_NUM), + static_cast(Y511_TEMP_RESOLUTION), Y511_TEMP_VAR_NAME, Y511_TEMP_UNIT_NAME, Y511_TEMP_DEFAULT_CODE) {} /** diff --git a/src/sensors/YosemitechY513.h b/src/sensors/YosemitechY513.h index c8011efc6..16f627d4c 100644 --- a/src/sensors/YosemitechY513.h +++ b/src/sensors/YosemitechY513.h @@ -222,8 +222,8 @@ class YosemitechY513_BGA : public Variable { explicit YosemitechY513_BGA(YosemitechY513* parentSense, const char* uuid = "", const char* varCode = Y513_BGA_DEFAULT_CODE) - : Variable(parentSense, (uint8_t)Y513_BGA_VAR_NUM, - (uint8_t)Y513_BGA_RESOLUTION, Y513_BGA_VAR_NAME, + : Variable(parentSense, static_cast(Y513_BGA_VAR_NUM), + static_cast(Y513_BGA_RESOLUTION), Y513_BGA_VAR_NAME, Y513_BGA_UNIT_NAME, varCode, uuid) {} /** * @brief Construct a new YosemitechY513_BGA object. @@ -232,9 +232,9 @@ class YosemitechY513_BGA : public Variable { * used. */ YosemitechY513_BGA() - : Variable((uint8_t)Y513_BGA_VAR_NUM, (uint8_t)Y513_BGA_RESOLUTION, - Y513_BGA_VAR_NAME, Y513_BGA_UNIT_NAME, - Y513_BGA_DEFAULT_CODE) {} + : Variable(static_cast(Y513_BGA_VAR_NUM), + static_cast(Y513_BGA_RESOLUTION), Y513_BGA_VAR_NAME, + Y513_BGA_UNIT_NAME, Y513_BGA_DEFAULT_CODE) {} /** * @brief Destroy the YosemitechY513_BGA() object - no action * needed. @@ -267,9 +267,9 @@ class YosemitechY513_Temp : public Variable { explicit YosemitechY513_Temp(YosemitechY513* parentSense, const char* uuid = "", const char* varCode = Y513_TEMP_DEFAULT_CODE) - : Variable(parentSense, (uint8_t)Y513_TEMP_VAR_NUM, - (uint8_t)Y513_TEMP_RESOLUTION, Y513_TEMP_VAR_NAME, - Y513_TEMP_UNIT_NAME, varCode, uuid) {} + : Variable(parentSense, static_cast(Y513_TEMP_VAR_NUM), + static_cast(Y513_TEMP_RESOLUTION), + Y513_TEMP_VAR_NAME, Y513_TEMP_UNIT_NAME, varCode, uuid) {} /** * @brief Construct a new YosemitechY513_Temp object. * @@ -277,7 +277,8 @@ class YosemitechY513_Temp : public Variable { * used. */ YosemitechY513_Temp() - : Variable((uint8_t)Y513_TEMP_VAR_NUM, (uint8_t)Y513_TEMP_RESOLUTION, + : Variable(static_cast(Y513_TEMP_VAR_NUM), + static_cast(Y513_TEMP_RESOLUTION), Y513_TEMP_VAR_NAME, Y513_TEMP_UNIT_NAME, Y513_TEMP_DEFAULT_CODE) {} /** diff --git a/src/sensors/YosemitechY514.h b/src/sensors/YosemitechY514.h index 049075202..2a4cf50cf 100644 --- a/src/sensors/YosemitechY514.h +++ b/src/sensors/YosemitechY514.h @@ -224,9 +224,10 @@ class YosemitechY514_Chlorophyll : public Variable { explicit YosemitechY514_Chlorophyll( YosemitechY514* parentSense, const char* uuid = "", const char* varCode = Y514_CHLORO_DEFAULT_CODE) - : Variable(parentSense, (uint8_t)Y514_CHLORO_VAR_NUM, - (uint8_t)Y514_CHLORO_RESOLUTION, Y514_CHLORO_VAR_NAME, - Y514_CHLORO_UNIT_NAME, varCode, uuid) {} + : Variable(parentSense, static_cast(Y514_CHLORO_VAR_NUM), + static_cast(Y514_CHLORO_RESOLUTION), + Y514_CHLORO_VAR_NAME, Y514_CHLORO_UNIT_NAME, varCode, uuid) { + } /** * @brief Construct a new YosemitechY514_Chlorophyll object. * @@ -234,9 +235,10 @@ class YosemitechY514_Chlorophyll : public Variable { * used. */ YosemitechY514_Chlorophyll() - : Variable((uint8_t)Y514_CHLORO_VAR_NUM, - (uint8_t)Y514_CHLORO_RESOLUTION, Y514_CHLORO_VAR_NAME, - Y514_CHLORO_UNIT_NAME, Y514_CHLORO_DEFAULT_CODE) {} + : Variable(static_cast(Y514_CHLORO_VAR_NUM), + static_cast(Y514_CHLORO_RESOLUTION), + Y514_CHLORO_VAR_NAME, Y514_CHLORO_UNIT_NAME, + Y514_CHLORO_DEFAULT_CODE) {} /** * @brief Destroy the YosemitechY514_Chlorophyll() object - no action * needed. @@ -269,9 +271,9 @@ class YosemitechY514_Temp : public Variable { explicit YosemitechY514_Temp(YosemitechY514* parentSense, const char* uuid = "", const char* varCode = Y514_TEMP_DEFAULT_CODE) - : Variable(parentSense, (uint8_t)Y514_TEMP_VAR_NUM, - (uint8_t)Y514_TEMP_RESOLUTION, Y514_TEMP_VAR_NAME, - Y514_TEMP_UNIT_NAME, varCode, uuid) {} + : Variable(parentSense, static_cast(Y514_TEMP_VAR_NUM), + static_cast(Y514_TEMP_RESOLUTION), + Y514_TEMP_VAR_NAME, Y514_TEMP_UNIT_NAME, varCode, uuid) {} /** * @brief Construct a new YosemitechY514_Temp object. * @@ -279,7 +281,8 @@ class YosemitechY514_Temp : public Variable { * used. */ YosemitechY514_Temp() - : Variable((uint8_t)Y514_TEMP_VAR_NUM, (uint8_t)Y514_TEMP_RESOLUTION, + : Variable(static_cast(Y514_TEMP_VAR_NUM), + static_cast(Y514_TEMP_RESOLUTION), Y514_TEMP_VAR_NAME, Y514_TEMP_UNIT_NAME, Y514_TEMP_DEFAULT_CODE) {} /** diff --git a/src/sensors/YosemitechY520.h b/src/sensors/YosemitechY520.h index 4753718da..75641d489 100644 --- a/src/sensors/YosemitechY520.h +++ b/src/sensors/YosemitechY520.h @@ -222,9 +222,9 @@ class YosemitechY520_Cond : public Variable { explicit YosemitechY520_Cond(YosemitechY520* parentSense, const char* uuid = "", const char* varCode = Y520_COND_DEFAULT_CODE) - : Variable(parentSense, (uint8_t)Y520_COND_VAR_NUM, - (uint8_t)Y520_COND_RESOLUTION, Y520_COND_VAR_NAME, - Y520_COND_UNIT_NAME, varCode, uuid) {} + : Variable(parentSense, static_cast(Y520_COND_VAR_NUM), + static_cast(Y520_COND_RESOLUTION), + Y520_COND_VAR_NAME, Y520_COND_UNIT_NAME, varCode, uuid) {} /** * @brief Construct a new YosemitechY520_Cond object. * @@ -232,7 +232,8 @@ class YosemitechY520_Cond : public Variable { * used. */ YosemitechY520_Cond() - : Variable((uint8_t)Y520_COND_VAR_NUM, (uint8_t)Y520_COND_RESOLUTION, + : Variable(static_cast(Y520_COND_VAR_NUM), + static_cast(Y520_COND_RESOLUTION), Y520_COND_VAR_NAME, Y520_COND_UNIT_NAME, Y520_COND_DEFAULT_CODE) {} /** @@ -266,9 +267,9 @@ class YosemitechY520_Temp : public Variable { explicit YosemitechY520_Temp(YosemitechY520* parentSense, const char* uuid = "", const char* varCode = Y520_TEMP_DEFAULT_CODE) - : Variable(parentSense, (uint8_t)Y520_TEMP_VAR_NUM, - (uint8_t)Y520_TEMP_RESOLUTION, Y520_TEMP_VAR_NAME, - Y520_TEMP_UNIT_NAME, varCode, uuid) {} + : Variable(parentSense, static_cast(Y520_TEMP_VAR_NUM), + static_cast(Y520_TEMP_RESOLUTION), + Y520_TEMP_VAR_NAME, Y520_TEMP_UNIT_NAME, varCode, uuid) {} /** * @brief Construct a new YosemitechY520_Temp object. * @@ -276,7 +277,8 @@ class YosemitechY520_Temp : public Variable { * used. */ YosemitechY520_Temp() - : Variable((uint8_t)Y520_TEMP_VAR_NUM, (uint8_t)Y520_TEMP_RESOLUTION, + : Variable(static_cast(Y520_TEMP_VAR_NUM), + static_cast(Y520_TEMP_RESOLUTION), Y520_TEMP_VAR_NAME, Y520_TEMP_UNIT_NAME, Y520_TEMP_DEFAULT_CODE) {} /** diff --git a/src/sensors/YosemitechY532.h b/src/sensors/YosemitechY532.h index c62b4dd81..8da572d11 100644 --- a/src/sensors/YosemitechY532.h +++ b/src/sensors/YosemitechY532.h @@ -248,8 +248,8 @@ class YosemitechY532_pH : public Variable { explicit YosemitechY532_pH(YosemitechY532* parentSense, const char* uuid = "", const char* varCode = Y532_PH_DEFAULT_CODE) - : Variable(parentSense, (uint8_t)Y532_PH_VAR_NUM, - (uint8_t)Y532_PH_RESOLUTION, Y532_PH_VAR_NAME, + : Variable(parentSense, static_cast(Y532_PH_VAR_NUM), + static_cast(Y532_PH_RESOLUTION), Y532_PH_VAR_NAME, Y532_PH_UNIT_NAME, varCode, uuid) {} /** * @brief Construct a new YosemitechY532_pH object. @@ -258,8 +258,9 @@ class YosemitechY532_pH : public Variable { * used. */ YosemitechY532_pH() - : Variable((uint8_t)Y532_PH_VAR_NUM, (uint8_t)Y532_PH_RESOLUTION, - Y532_PH_VAR_NAME, Y532_PH_UNIT_NAME, Y532_PH_DEFAULT_CODE) {} + : Variable(static_cast(Y532_PH_VAR_NUM), + static_cast(Y532_PH_RESOLUTION), Y532_PH_VAR_NAME, + Y532_PH_UNIT_NAME, Y532_PH_DEFAULT_CODE) {} /** * @brief Destroy the YosemitechY532_pH object - no action needed. */ @@ -291,9 +292,9 @@ class YosemitechY532_Temp : public Variable { explicit YosemitechY532_Temp(YosemitechY532* parentSense, const char* uuid = "", const char* varCode = Y532_TEMP_DEFAULT_CODE) - : Variable(parentSense, (uint8_t)Y532_TEMP_VAR_NUM, - (uint8_t)Y532_TEMP_RESOLUTION, Y532_TEMP_VAR_NAME, - Y532_TEMP_UNIT_NAME, varCode, uuid) {} + : Variable(parentSense, static_cast(Y532_TEMP_VAR_NUM), + static_cast(Y532_TEMP_RESOLUTION), + Y532_TEMP_VAR_NAME, Y532_TEMP_UNIT_NAME, varCode, uuid) {} /** * @brief Construct a new YosemitechY532_Temp object. * @@ -301,7 +302,8 @@ class YosemitechY532_Temp : public Variable { * used. */ YosemitechY532_Temp() - : Variable((uint8_t)Y532_TEMP_VAR_NUM, (uint8_t)Y532_TEMP_RESOLUTION, + : Variable(static_cast(Y532_TEMP_VAR_NUM), + static_cast(Y532_TEMP_RESOLUTION), Y532_TEMP_VAR_NAME, Y532_TEMP_UNIT_NAME, Y532_TEMP_DEFAULT_CODE) {} /** @@ -335,9 +337,10 @@ class YosemitechY532_Voltage : public Variable { explicit YosemitechY532_Voltage( YosemitechY532* parentSense, const char* uuid = "", const char* varCode = Y532_VOLTAGE_DEFAULT_CODE) - : Variable(parentSense, (uint8_t)Y532_VOLTAGE_VAR_NUM, - (uint8_t)Y532_VOLTAGE_RESOLUTION, Y532_VOLTAGE_VAR_NAME, - Y532_VOLTAGE_UNIT_NAME, varCode, uuid) {} + : Variable(parentSense, static_cast(Y532_VOLTAGE_VAR_NUM), + static_cast(Y532_VOLTAGE_RESOLUTION), + Y532_VOLTAGE_VAR_NAME, Y532_VOLTAGE_UNIT_NAME, varCode, + uuid) {} /** * @brief Construct a new YosemitechY532_Voltage object. * @@ -345,9 +348,10 @@ class YosemitechY532_Voltage : public Variable { * used. */ YosemitechY532_Voltage() - : Variable((uint8_t)Y532_VOLTAGE_VAR_NUM, - (uint8_t)Y532_VOLTAGE_RESOLUTION, Y532_VOLTAGE_VAR_NAME, - Y532_VOLTAGE_UNIT_NAME, Y532_VOLTAGE_DEFAULT_CODE) {} + : Variable(static_cast(Y532_VOLTAGE_VAR_NUM), + static_cast(Y532_VOLTAGE_RESOLUTION), + Y532_VOLTAGE_VAR_NAME, Y532_VOLTAGE_UNIT_NAME, + Y532_VOLTAGE_DEFAULT_CODE) {} /** * @brief Destroy the YosemitechY532_Voltage object - no action needed. */ diff --git a/src/sensors/YosemitechY533.h b/src/sensors/YosemitechY533.h index de35736ed..d875c4946 100644 --- a/src/sensors/YosemitechY533.h +++ b/src/sensors/YosemitechY533.h @@ -224,8 +224,8 @@ class YosemitechY533_ORP : public Variable { explicit YosemitechY533_ORP(YosemitechY533* parentSense, const char* uuid = "", const char* varCode = Y533_ORP_DEFAULT_CODE) - : Variable(parentSense, (uint8_t)Y533_ORP_VAR_NUM, - (uint8_t)Y533_ORP_RESOLUTION, Y533_ORP_VAR_NAME, + : Variable(parentSense, static_cast(Y533_ORP_VAR_NUM), + static_cast(Y533_ORP_RESOLUTION), Y533_ORP_VAR_NAME, Y533_ORP_UNIT_NAME, varCode, uuid) {} /** * @brief Construct a new YosemitechY533_ORP object. @@ -234,9 +234,9 @@ class YosemitechY533_ORP : public Variable { * used. */ YosemitechY533_ORP() - : Variable((uint8_t)Y533_ORP_VAR_NUM, (uint8_t)Y533_ORP_RESOLUTION, - Y533_ORP_VAR_NAME, Y533_ORP_UNIT_NAME, - Y533_ORP_DEFAULT_CODE) {} + : Variable(static_cast(Y533_ORP_VAR_NUM), + static_cast(Y533_ORP_RESOLUTION), Y533_ORP_VAR_NAME, + Y533_ORP_UNIT_NAME, Y533_ORP_DEFAULT_CODE) {} /** * @brief Destroy the YosemitechY533_ORP object - no action needed. */ @@ -268,9 +268,9 @@ class YosemitechY533_Temp : public Variable { explicit YosemitechY533_Temp(YosemitechY533* parentSense, const char* uuid = "", const char* varCode = Y533_TEMP_DEFAULT_CODE) - : Variable(parentSense, (uint8_t)Y533_TEMP_VAR_NUM, - (uint8_t)Y533_TEMP_RESOLUTION, Y533_TEMP_VAR_NAME, - Y533_TEMP_UNIT_NAME, varCode, uuid) {} + : Variable(parentSense, static_cast(Y533_TEMP_VAR_NUM), + static_cast(Y533_TEMP_RESOLUTION), + Y533_TEMP_VAR_NAME, Y533_TEMP_UNIT_NAME, varCode, uuid) {} /** * @brief Construct a new YosemitechY533_Temp object. * @@ -278,7 +278,8 @@ class YosemitechY533_Temp : public Variable { * used. */ YosemitechY533_Temp() - : Variable((uint8_t)Y533_TEMP_VAR_NUM, (uint8_t)Y533_TEMP_RESOLUTION, + : Variable(static_cast(Y533_TEMP_VAR_NUM), + static_cast(Y533_TEMP_RESOLUTION), Y533_TEMP_VAR_NAME, Y533_TEMP_UNIT_NAME, Y533_TEMP_DEFAULT_CODE) {} /** diff --git a/src/sensors/YosemitechY551.h b/src/sensors/YosemitechY551.h index 88053f5c3..392a74cbb 100644 --- a/src/sensors/YosemitechY551.h +++ b/src/sensors/YosemitechY551.h @@ -252,8 +252,8 @@ class YosemitechY551_COD : public Variable { explicit YosemitechY551_COD(YosemitechY551* parentSense, const char* uuid = "", const char* varCode = Y551_COD_DEFAULT_CODE) - : Variable(parentSense, (uint8_t)Y551_COD_VAR_NUM, - (uint8_t)Y551_COD_RESOLUTION, Y551_COD_VAR_NAME, + : Variable(parentSense, static_cast(Y551_COD_VAR_NUM), + static_cast(Y551_COD_RESOLUTION), Y551_COD_VAR_NAME, Y551_COD_UNIT_NAME, varCode, uuid) {} /** * @brief Construct a new YosemitechY551_COD object. @@ -262,9 +262,9 @@ class YosemitechY551_COD : public Variable { * used. */ YosemitechY551_COD() - : Variable((uint8_t)Y551_COD_VAR_NUM, (uint8_t)Y551_COD_RESOLUTION, - Y551_COD_VAR_NAME, Y551_COD_UNIT_NAME, - Y551_COD_DEFAULT_CODE) {} + : Variable(static_cast(Y551_COD_VAR_NUM), + static_cast(Y551_COD_RESOLUTION), Y551_COD_VAR_NAME, + Y551_COD_UNIT_NAME, Y551_COD_DEFAULT_CODE) {} /** * @brief Destroy the YosemitechY551_COD object - no action needed. */ @@ -296,9 +296,9 @@ class YosemitechY551_Temp : public Variable { explicit YosemitechY551_Temp(YosemitechY551* parentSense, const char* uuid = "", const char* varCode = Y551_TEMP_DEFAULT_CODE) - : Variable(parentSense, (uint8_t)Y551_TEMP_VAR_NUM, - (uint8_t)Y551_TEMP_RESOLUTION, Y551_TEMP_VAR_NAME, - Y551_TEMP_UNIT_NAME, varCode, uuid) {} + : Variable(parentSense, static_cast(Y551_TEMP_VAR_NUM), + static_cast(Y551_TEMP_RESOLUTION), + Y551_TEMP_VAR_NAME, Y551_TEMP_UNIT_NAME, varCode, uuid) {} /** * @brief Construct a new YosemitechY551_Temp object. * @@ -306,7 +306,8 @@ class YosemitechY551_Temp : public Variable { * used. */ YosemitechY551_Temp() - : Variable((uint8_t)Y551_TEMP_VAR_NUM, (uint8_t)Y551_TEMP_RESOLUTION, + : Variable(static_cast(Y551_TEMP_VAR_NUM), + static_cast(Y551_TEMP_RESOLUTION), Y551_TEMP_VAR_NAME, Y551_TEMP_UNIT_NAME, Y551_TEMP_DEFAULT_CODE) {} /** @@ -340,9 +341,9 @@ class YosemitechY551_Turbidity : public Variable { explicit YosemitechY551_Turbidity( YosemitechY551* parentSense, const char* uuid = "", const char* varCode = Y551_TURB_DEFAULT_CODE) - : Variable(parentSense, (uint8_t)Y551_TURB_VAR_NUM, - (uint8_t)Y551_TURB_RESOLUTION, Y551_TURB_VAR_NAME, - Y551_TURB_UNIT_NAME, varCode, uuid) {} + : Variable(parentSense, static_cast(Y551_TURB_VAR_NUM), + static_cast(Y551_TURB_RESOLUTION), + Y551_TURB_VAR_NAME, Y551_TURB_UNIT_NAME, varCode, uuid) {} /** * @brief Construct a new YosemitechY551_Turbidity object. * @@ -350,7 +351,8 @@ class YosemitechY551_Turbidity : public Variable { * used. */ YosemitechY551_Turbidity() - : Variable((uint8_t)Y551_TURB_VAR_NUM, (uint8_t)Y551_TURB_RESOLUTION, + : Variable(static_cast(Y551_TURB_VAR_NUM), + static_cast(Y551_TURB_RESOLUTION), Y551_TURB_VAR_NAME, Y551_TURB_UNIT_NAME, Y551_TURB_DEFAULT_CODE) {} /** diff --git a/src/sensors/YosemitechY560.h b/src/sensors/YosemitechY560.h index 012fa5140..4273d42c0 100644 --- a/src/sensors/YosemitechY560.h +++ b/src/sensors/YosemitechY560.h @@ -249,7 +249,7 @@ class YosemitechY560_NH4_N : public Variable { explicit YosemitechY560_NH4_N(YosemitechY560* parentSense, const char* uuid = "", const char* varCode = Y560_NH4_N_DEFAULT_CODE) - : Variable(parentSense, (uint8_t)Y560_NH4_N_VAR_NUM, + : Variable(parentSense, static_cast(Y560_NH4_N_VAR_NUM), (const uint8_t)Y560_NH4_N_RESOLUTION, Y560_NH4_N_VAR_NAME, Y560_NH4_N_UNIT_NAME, varCode, uuid) {} /** @@ -259,7 +259,7 @@ class YosemitechY560_NH4_N : public Variable { * used. */ YosemitechY560_NH4_N() - : Variable((uint8_t)Y560_NH4_N_VAR_NUM, + : Variable(static_cast(Y560_NH4_N_VAR_NUM), (const uint8_t)Y560_NH4_N_RESOLUTION, Y560_NH4_N_VAR_NAME, Y560_NH4_N_UNIT_NAME, Y560_NH4_N_DEFAULT_CODE) {} /** @@ -293,9 +293,9 @@ class YosemitechY560_Temp : public Variable { explicit YosemitechY560_Temp(YosemitechY560* parentSense, const char* uuid = "", const char* varCode = Y560_TEMP_DEFAULT_CODE) - : Variable(parentSense, (uint8_t)Y560_TEMP_VAR_NUM, - (uint8_t)Y560_TEMP_RESOLUTION, Y560_TEMP_VAR_NAME, - Y560_TEMP_UNIT_NAME, varCode, uuid) {} + : Variable(parentSense, static_cast(Y560_TEMP_VAR_NUM), + static_cast(Y560_TEMP_RESOLUTION), + Y560_TEMP_VAR_NAME, Y560_TEMP_UNIT_NAME, varCode, uuid) {} /** * @brief Construct a new YosemitechY560_Temp object. * @@ -303,7 +303,8 @@ class YosemitechY560_Temp : public Variable { * used. */ YosemitechY560_Temp() - : Variable((uint8_t)Y560_TEMP_VAR_NUM, (uint8_t)Y560_TEMP_RESOLUTION, + : Variable(static_cast(Y560_TEMP_VAR_NUM), + static_cast(Y560_TEMP_RESOLUTION), Y560_TEMP_VAR_NAME, Y560_TEMP_UNIT_NAME, Y560_TEMP_DEFAULT_CODE) {} /** @@ -337,8 +338,8 @@ class YosemitechY560_pH : public Variable { explicit YosemitechY560_pH(YosemitechY560* parentSense, const char* uuid = "", const char* varCode = Y560_PH_DEFAULT_CODE) - : Variable(parentSense, (uint8_t)Y560_PH_VAR_NUM, - (uint8_t)Y560_PH_RESOLUTION, Y560_PH_VAR_NAME, + : Variable(parentSense, static_cast(Y560_PH_VAR_NUM), + static_cast(Y560_PH_RESOLUTION), Y560_PH_VAR_NAME, Y560_PH_UNIT_NAME, varCode, uuid) {} /** * @brief Construct a new YosemitechY560_pH object. @@ -347,8 +348,9 @@ class YosemitechY560_pH : public Variable { * used. */ YosemitechY560_pH() - : Variable((uint8_t)Y560_PH_VAR_NUM, (uint8_t)Y560_PH_RESOLUTION, - Y560_PH_VAR_NAME, Y560_PH_UNIT_NAME, Y560_PH_DEFAULT_CODE) {} + : Variable(static_cast(Y560_PH_VAR_NUM), + static_cast(Y560_PH_RESOLUTION), Y560_PH_VAR_NAME, + Y560_PH_UNIT_NAME, Y560_PH_DEFAULT_CODE) {} /** * @brief Destroy the YosemitechY560_pH object - no action needed. */ diff --git a/src/sensors/YosemitechY700.h b/src/sensors/YosemitechY700.h index fc6187cae..824255c18 100644 --- a/src/sensors/YosemitechY700.h +++ b/src/sensors/YosemitechY700.h @@ -221,9 +221,9 @@ class YosemitechY700_Pressure : public Variable { explicit YosemitechY700_Pressure( YosemitechY700* parentSense, const char* uuid = "", const char* varCode = Y700_PRES_DEFAULT_CODE) - : Variable(parentSense, (uint8_t)Y700_PRES_VAR_NUM, - (uint8_t)Y700_PRES_RESOLUTION, Y700_PRES_VAR_NAME, - Y700_PRES_UNIT_NAME, varCode, uuid) {} + : Variable(parentSense, static_cast(Y700_PRES_VAR_NUM), + static_cast(Y700_PRES_RESOLUTION), + Y700_PRES_VAR_NAME, Y700_PRES_UNIT_NAME, varCode, uuid) {} /** * @brief Construct a new YosemitechY700_Pressure object. * @@ -231,7 +231,8 @@ class YosemitechY700_Pressure : public Variable { * used. */ YosemitechY700_Pressure() - : Variable((uint8_t)Y700_PRES_VAR_NUM, (uint8_t)Y700_PRES_RESOLUTION, + : Variable(static_cast(Y700_PRES_VAR_NUM), + static_cast(Y700_PRES_RESOLUTION), Y700_PRES_VAR_NAME, Y700_PRES_UNIT_NAME, Y700_PRES_DEFAULT_CODE) {} /** @@ -265,9 +266,9 @@ class YosemitechY700_Temp : public Variable { explicit YosemitechY700_Temp(YosemitechY700* parentSense, const char* uuid = "", const char* varCode = Y700_TEMP_DEFAULT_CODE) - : Variable(parentSense, (uint8_t)Y700_TEMP_VAR_NUM, - (uint8_t)Y700_TEMP_RESOLUTION, Y700_TEMP_VAR_NAME, - Y700_TEMP_UNIT_NAME, varCode, uuid) {} + : Variable(parentSense, static_cast(Y700_TEMP_VAR_NUM), + static_cast(Y700_TEMP_RESOLUTION), + Y700_TEMP_VAR_NAME, Y700_TEMP_UNIT_NAME, varCode, uuid) {} /** * @brief Construct a new YosemitechY700_Temp object. * @@ -275,7 +276,8 @@ class YosemitechY700_Temp : public Variable { * used. */ YosemitechY700_Temp() - : Variable((uint8_t)Y700_TEMP_VAR_NUM, (uint8_t)Y700_TEMP_RESOLUTION, + : Variable(static_cast(Y700_TEMP_VAR_NUM), + static_cast(Y700_TEMP_RESOLUTION), Y700_TEMP_VAR_NAME, Y700_TEMP_UNIT_NAME, Y700_TEMP_DEFAULT_CODE) {} /** diff --git a/src/sensors/ZebraTechDOpto.h b/src/sensors/ZebraTechDOpto.h index 328e836d5..c7a3ff524 100644 --- a/src/sensors/ZebraTechDOpto.h +++ b/src/sensors/ZebraTechDOpto.h @@ -277,9 +277,9 @@ class ZebraTechDOpto_Temp : public Variable { explicit ZebraTechDOpto_Temp(ZebraTechDOpto* parentSense, const char* uuid = "", const char* varCode = DOPTO_TEMP_DEFAULT_CODE) - : Variable(parentSense, (uint8_t)DOPTO_TEMP_VAR_NUM, - (uint8_t)DOPTO_TEMP_RESOLUTION, DOPTO_TEMP_VAR_NAME, - DOPTO_TEMP_UNIT_NAME, varCode, uuid) {} + : Variable(parentSense, static_cast(DOPTO_TEMP_VAR_NUM), + static_cast(DOPTO_TEMP_RESOLUTION), + DOPTO_TEMP_VAR_NAME, DOPTO_TEMP_UNIT_NAME, varCode, uuid) {} /** * @brief Construct a new ZebraTechDOpto_Temp object. * @@ -287,7 +287,8 @@ class ZebraTechDOpto_Temp : public Variable { * used. */ ZebraTechDOpto_Temp() - : Variable((uint8_t)DOPTO_TEMP_VAR_NUM, (uint8_t)DOPTO_TEMP_RESOLUTION, + : Variable(static_cast(DOPTO_TEMP_VAR_NUM), + static_cast(DOPTO_TEMP_RESOLUTION), DOPTO_TEMP_VAR_NAME, DOPTO_TEMP_UNIT_NAME, DOPTO_TEMP_DEFAULT_CODE) {} /** @@ -321,9 +322,10 @@ class ZebraTechDOpto_DOpct : public Variable { explicit ZebraTechDOpto_DOpct( ZebraTechDOpto* parentSense, const char* uuid = "", const char* varCode = DOPTO_DOPCT_DEFAULT_CODE) - : Variable(parentSense, (uint8_t)DOPTO_DOPCT_VAR_NUM, - (uint8_t)DOPTO_DOPCT_RESOLUTION, DOPTO_DOPCT_VAR_NAME, - DOPTO_DOPCT_UNIT_NAME, varCode, uuid) {} + : Variable(parentSense, static_cast(DOPTO_DOPCT_VAR_NUM), + static_cast(DOPTO_DOPCT_RESOLUTION), + DOPTO_DOPCT_VAR_NAME, DOPTO_DOPCT_UNIT_NAME, varCode, uuid) { + } /** * @brief Construct a new ZebraTechDOpto_DOpct object. * @@ -331,9 +333,10 @@ class ZebraTechDOpto_DOpct : public Variable { * used. */ ZebraTechDOpto_DOpct() - : Variable((uint8_t)DOPTO_DOPCT_VAR_NUM, - (uint8_t)DOPTO_DOPCT_RESOLUTION, DOPTO_DOPCT_VAR_NAME, - DOPTO_DOPCT_UNIT_NAME, DOPTO_DOPCT_DEFAULT_CODE) {} + : Variable(static_cast(DOPTO_DOPCT_VAR_NUM), + static_cast(DOPTO_DOPCT_RESOLUTION), + DOPTO_DOPCT_VAR_NAME, DOPTO_DOPCT_UNIT_NAME, + DOPTO_DOPCT_DEFAULT_CODE) {} /** * @brief Destroy the ZebraTechDOpto_DOpct object - no action needed. */ @@ -365,9 +368,10 @@ class ZebraTechDOpto_DOmgL : public Variable { explicit ZebraTechDOpto_DOmgL( ZebraTechDOpto* parentSense, const char* uuid = "", const char* varCode = DOPTO_DOMGL_DEFAULT_CODE) - : Variable(parentSense, (uint8_t)DOPTO_DOMGL_VAR_NUM, - (uint8_t)DOPTO_DOMGL_RESOLUTION, DOPTO_DOMGL_VAR_NAME, - DOPTO_DOMGL_UNIT_NAME, varCode, uuid) {} + : Variable(parentSense, static_cast(DOPTO_DOMGL_VAR_NUM), + static_cast(DOPTO_DOMGL_RESOLUTION), + DOPTO_DOMGL_VAR_NAME, DOPTO_DOMGL_UNIT_NAME, varCode, uuid) { + } /** * @brief Construct a new ZebraTechDOpto_DOmgL object. * @@ -375,9 +379,10 @@ class ZebraTechDOpto_DOmgL : public Variable { * used. */ ZebraTechDOpto_DOmgL() - : Variable((uint8_t)DOPTO_DOMGL_VAR_NUM, - (uint8_t)DOPTO_DOMGL_RESOLUTION, DOPTO_DOMGL_VAR_NAME, - DOPTO_DOMGL_UNIT_NAME, DOPTO_DOMGL_DEFAULT_CODE) {} + : Variable(static_cast(DOPTO_DOMGL_VAR_NUM), + static_cast(DOPTO_DOMGL_RESOLUTION), + DOPTO_DOMGL_VAR_NAME, DOPTO_DOMGL_UNIT_NAME, + DOPTO_DOMGL_DEFAULT_CODE) {} /** * @brief Destroy the ZebraTechDOpto_DOmgL object - no action needed. */ From c7f9f0c454c0e2e68d6c60295e600c486122dc1c Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Wed, 4 Mar 2026 14:47:51 -0500 Subject: [PATCH 428/533] Fix void call botched in find/replace Signed-off-by: Sara Damiano --- src/LoggerBase.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/LoggerBase.cpp b/src/LoggerBase.cpp index bdd0b7ed7..7fb339d7b 100644 --- a/src/LoggerBase.cpp +++ b/src/LoggerBase.cpp @@ -915,7 +915,7 @@ void Logger::systemSleep() { // https://github.com/adafruit/circuitpython/blob/65cfcb83f279869c7b38eb5891ddac557dba155b/ports/atmel-samd/common-hal/alarm/__init__.c#L146 if (__get_FPSCR() & ~(0x9f)) { __set_FPSCR(__get_FPSCR() & ~(0x9f)); - () __get_FPSCR(); + (void)__get_FPSCR(); } // Set the sleep config From 805c0d4df0d471ee83822076b675b1c20fc3cbde Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Wed, 4 Mar 2026 15:09:29 -0500 Subject: [PATCH 429/533] Switch to static_assert check Signed-off-by: Sara Damiano --- src/sensors/EverlightALSPT19.cpp | 6 ------ src/sensors/EverlightALSPT19.h | 1 + 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/src/sensors/EverlightALSPT19.cpp b/src/sensors/EverlightALSPT19.cpp index 432ce7eb4..5be87eaf3 100644 --- a/src/sensors/EverlightALSPT19.cpp +++ b/src/sensors/EverlightALSPT19.cpp @@ -95,12 +95,6 @@ bool EverlightALSPT19::addSingleMeasurementResult() { MS_DBG(getSensorNameAndLocation(), F("Invalid load resistor value")); return bumpMeasurementAttemptCount(false); } - // Check if we have a valid calibration constant - if (ALSPT19_UA_PER_1000LUX <= 0) { - MS_DBG(getSensorNameAndLocation(), - F("Invalid current-to-lux calibration factor")); - return bumpMeasurementAttemptCount(false); - } float adcVoltage = MS_INVALID_VALUE; diff --git a/src/sensors/EverlightALSPT19.h b/src/sensors/EverlightALSPT19.h index 9f0579e7d..cf18809d7 100644 --- a/src/sensors/EverlightALSPT19.h +++ b/src/sensors/EverlightALSPT19.h @@ -102,6 +102,7 @@ * Lux, which doesn't appear to align with the datasheet. */ #define ALSPT19_UA_PER_1000LUX 200.0f +static_assert(ALSPT19_UA_PER_1000LUX > 0, "Current-to-lux calibration factor must be positive"); #endif /**@}*/ From cf7cf9dd641d1da3e4d9623b4f0da1e10ba2771c Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Wed, 4 Mar 2026 15:09:52 -0500 Subject: [PATCH 430/533] small changes Signed-off-by: Sara Damiano --- src/ModSensorConfig.h | 115 +++++++++++++++++----------------- src/VariableBase.cpp | 12 ++-- src/WatchDogs/WatchDogAVR.cpp | 2 +- 3 files changed, 65 insertions(+), 64 deletions(-) diff --git a/src/ModSensorConfig.h b/src/ModSensorConfig.h index 522d9c929..0dbb8e8a8 100644 --- a/src/ModSensorConfig.h +++ b/src/ModSensorConfig.h @@ -80,8 +80,6 @@ * or missing. */ #define MS_INVALID_VALUE -9999 - -// GroPoint Profile GPLP-8 has 8 Moisture and 13 Temperature values #endif #ifndef MAX_NUMBER_VARS /** @@ -97,29 +95,6 @@ // number of variables from any sensor. Anything more is a waste of memory. static_assert(MAX_NUMBER_VARS > 0 && MAX_NUMBER_VARS <= 21, "MAX_NUMBER_VARS must be between 1 and 21"); - -//============================================================== -// Disable concurrent polling of SDI-12 sensors, if needed -// Concurrent measurement support was introduced in version 1.2 (April 12, 1996) -// of the specification and all sensors that claim to use version 1.2 or higher -// must support it. -// That being said.. some new sensors are fussy and will incorrectly abort -// concurrent measurements due to noise or other sensors on the bus. -// NOTE: By default, concurrent measurements are used for all SDI-12 sensors! -// NOTE: This single setting applies to all SDI-12 sensors; it cannot be set on -// a per-sensor basis. -// #define MS_SDI12_NON_CONCURRENT - -// Disable CRC checking for SDI-12 sensors, if needed -// This may be necessary if using older or fussy sensors -// CRC support in SDI-12 was implemented with version 1.3 (April 7, 2000) and -// all sensors that claim to use version 1.3 or higher must support it. -// NOTE: By default, CRCs are used for all SDI-12 sensors! -// NOTE: This single setting applies to all SDI-12 sensors; it cannot be set on -// a per-sensor basis. -// #define MS_SDI12_NO_CRC_CHECK -//============================================================== - //============================================================== #ifndef MS_LOGGERBASE_BUTTON_BENCH_TEST /** @@ -150,39 +125,7 @@ static_assert(MAX_NUMBER_VARS > 0 && MAX_NUMBER_VARS <= 21, //============================================================== -// External ADC configuration and defaults -//============================================================== -// Select ADS1015 instead of the ADS1115, if desired -// This is for sensors that use the external ADC for analog voltage -// measurements. -// #define MS_USE_ADS1015 - -#if !defined(MS_DEFAULT_ADS1X15_ADDRESS) || defined(DOXYGEN) -/** - * @brief The default I²C address of the ADS1115 or ADS1015 external ADC. - * - * Valid addresses depend on the ADDR pin connection: - * - `0x48` – ADDR to GND (default) - * - `0x49` – ADDR to VDD - * - `0x4A` – ADDR to SDA - * - `0x4B` – ADDR to SCL - * - * Override with a build flag: `-DMS_DEFAULT_ADS1X15_ADDRESS=0x49` - */ -#define MS_DEFAULT_ADS1X15_ADDRESS 0x48 -#endif -// Static assert to validate ADS1X15 I2C address is valid -static_assert(MS_DEFAULT_ADS1X15_ADDRESS == 0x48 || - MS_DEFAULT_ADS1X15_ADDRESS == 0x49 || - MS_DEFAULT_ADS1X15_ADDRESS == 0x4A || - MS_DEFAULT_ADS1X15_ADDRESS == 0x4B, - "MS_DEFAULT_ADS1X15_ADDRESS should be 0x48, 0x49, 0x4A, or 0x4B " - "for ADS1X15"); -//============================================================== - - -//============================================================== -// Analog voltage configuration +// Processor ADC configuration //============================================================== #ifndef MS_PROCESSOR_ADC_RESOLUTION /** @@ -292,6 +235,62 @@ static_assert(MS_PROCESSOR_ANALOG_MAX_CHANNEL > 0 && //============================================================== +//============================================================== +// External ADC configuration and defaults +//============================================================== +// Select ADS1015 instead of the ADS1115, if desired +// This is for sensors that use the external ADC for analog voltage +// measurements. +// #define MS_USE_ADS1015 + +#if !defined(MS_DEFAULT_ADS1X15_ADDRESS) || defined(DOXYGEN) +/** + * @brief The default I²C address of the ADS1115 or ADS1015 external ADC. + * + * Valid addresses depend on the ADDR pin connection: + * - `0x48` – ADDR to GND (default) + * - `0x49` – ADDR to VDD + * - `0x4A` – ADDR to SDA + * - `0x4B` – ADDR to SCL + * + * Override with a build flag: `-DMS_DEFAULT_ADS1X15_ADDRESS=0x49` + */ +#define MS_DEFAULT_ADS1X15_ADDRESS 0x48 +#endif +// Static assert to validate ADS1X15 I2C address is valid +static_assert(MS_DEFAULT_ADS1X15_ADDRESS == 0x48 || + MS_DEFAULT_ADS1X15_ADDRESS == 0x49 || + MS_DEFAULT_ADS1X15_ADDRESS == 0x4A || + MS_DEFAULT_ADS1X15_ADDRESS == 0x4B, + "MS_DEFAULT_ADS1X15_ADDRESS should be 0x48, 0x49, 0x4A, or 0x4B " + "for ADS1X15"); +//============================================================== + +//============================================================== +// SDI-12 Configuration +//============================================================== +// Disable concurrent polling of SDI-12 sensors, if needed +// Concurrent measurement support was introduced in version 1.2 (April 12, 1996) +// of the specification and all sensors that claim to use version 1.2 or higher +// must support it. +// That being said.. some new sensors are fussy and will incorrectly abort +// concurrent measurements due to noise or other sensors on the bus. +// NOTE: By default, concurrent measurements are used for all SDI-12 sensors! +// NOTE: This single setting applies to all SDI-12 sensors; it cannot be set on +// a per-sensor basis. +// #define MS_SDI12_NON_CONCURRENT + +// Disable CRC checking for SDI-12 sensors, if needed +// This may be necessary if using older or fussy sensors +// CRC support in SDI-12 was implemented with version 1.3 (April 7, 2000) and +// all sensors that claim to use version 1.3 or higher must support it. +// NOTE: By default, CRCs are used for all SDI-12 sensors! +// NOTE: This single setting applies to all SDI-12 sensors; it cannot be set on +// a per-sensor basis. +// #define MS_SDI12_NO_CRC_CHECK +//============================================================== + + //============================================================== // Environmental sensor configuration //============================================================== diff --git a/src/VariableBase.cpp b/src/VariableBase.cpp index cd3e1f76c..56f3b8f59 100644 --- a/src/VariableBase.cpp +++ b/src/VariableBase.cpp @@ -22,6 +22,8 @@ Variable::Variable(Sensor* parentSense, uint8_t sensorVarNum, uint8_t decimalResolution, const char* varName, const char* varUnit, const char* varCode, const char* uuid) : isCalculated(false), + parentSensor(nullptr), + _currentValue(MS_INVALID_VALUE), _sensorVarNum(sensorVarNum) { if (uuid) setVarUUID(uuid); if (varCode) setVarCode(varCode); @@ -36,8 +38,7 @@ Variable::Variable(Sensor* parentSense, uint8_t sensorVarNum, Variable::Variable(float (*calcFxn)(), uint8_t decimalResolution, const char* varName, const char* varUnit, const char* varCode, const char* uuid) - : isCalculated(calcFxn != nullptr), - _calcFxn(nullptr) { + : _calcFxn(nullptr) { if (uuid) setVarUUID(uuid); if (varCode) setVarCode(varCode); if (varUnit) setVarUnit(varUnit); @@ -250,8 +251,8 @@ float Variable::getValue(bool updateValue) { } else if (updateValue && _calcFxn == nullptr) { // If no calculation function is set, return error value _currentValue = MS_INVALID_VALUE; - MS_DBG( - F("ERROR! Calculated variable has no calculation function!")); + MS_DBG(F("ERROR! Calculated variable"), getVarCode(), + F("has no calculation function!")); } return _currentValue; } else { @@ -260,7 +261,8 @@ float Variable::getValue(bool updateValue) { } else if (updateValue && parentSensor == nullptr) { // If no parent sensor is set, return error value _currentValue = MS_INVALID_VALUE; - MS_DBG(F("ERROR! Variable has no parent sensor!")); + MS_DBG(F("ERROR! Variable"), getVarCode(), + F("has no parent sensor!")); } return _currentValue; } diff --git a/src/WatchDogs/WatchDogAVR.cpp b/src/WatchDogs/WatchDogAVR.cpp index 6ebf9cabb..8b20cc481 100644 --- a/src/WatchDogs/WatchDogAVR.cpp +++ b/src/WatchDogs/WatchDogAVR.cpp @@ -103,7 +103,7 @@ ISR(WDT_vect) { MS_DEEP_DBG(F("\nWatchdog interrupt!")); extendedWatchDogAVR::_barksUntilReset--; // Increment down the counter, // makes multi cycle WDT possible - if (extendedWatchDogAVR::_barksUntilReset <= 0) { + if (extendedWatchDogAVR::_barksUntilReset == 0) { MS_DEEP_DBG(F("The dog has barked enough; resetting the board.")); MCUSR = 0; // reset flags From 86a3e6fd078f855c4164c1164877ed54f19cf035 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Wed, 4 Mar 2026 15:24:57 -0500 Subject: [PATCH 431/533] Reserve strings in all implementations of getSensorLocation Signed-off-by: Sara Damiano --- src/SensorBase.cpp | 4 +++- src/sensors/ANBpH.cpp | 4 +++- src/sensors/AtlasParent.cpp | 4 +++- src/sensors/BoschBME280.cpp | 4 +++- src/sensors/BoschBMP3xx.cpp | 4 +++- src/sensors/GroPointParent.cpp | 4 +++- src/sensors/KellerParent.cpp | 4 +++- src/sensors/MaxBotixSonar.cpp | 4 +++- src/sensors/MaximDS18.cpp | 4 +++- src/sensors/MeaSpecMS5803.cpp | 4 +++- src/sensors/PaleoTerraRedox.cpp | 8 ++++++-- src/sensors/ProcessorStats.cpp | 5 ++++- src/sensors/RainCounterI2C.cpp | 8 ++++++-- src/sensors/SDI12Sensors.cpp | 4 +++- src/sensors/TIINA219.cpp | 4 +++- src/sensors/TallyCounterI2C.cpp | 4 +++- src/sensors/YosemitechParent.cpp | 4 +++- 17 files changed, 58 insertions(+), 19 deletions(-) diff --git a/src/SensorBase.cpp b/src/SensorBase.cpp index 4ac7d5f9b..9338e301d 100644 --- a/src/SensorBase.cpp +++ b/src/SensorBase.cpp @@ -41,7 +41,9 @@ Sensor::Sensor(const char* sensorName, const uint8_t totalReturnedValues, // This gets the place the sensor is installed ON THE MAYFLY (ie, pin number) String Sensor::getSensorLocation() { - String senseLoc = F("Pin"); + String senseLoc; + senseLoc.reserve(10); // Reserve for "Pin" + pin number + senseLoc = F("Pin"); senseLoc += String(_dataPin); return senseLoc; } diff --git a/src/sensors/ANBpH.cpp b/src/sensors/ANBpH.cpp index 8b3342343..5e2d8a3ca 100644 --- a/src/sensors/ANBpH.cpp +++ b/src/sensors/ANBpH.cpp @@ -38,7 +38,9 @@ ANBpH::ANBpH(byte modbusAddress, Stream& stream, int8_t powerPin, // The sensor installation location on the Mayfly String ANBpH::getSensorLocation() { - String sensorLocation = F("modbus_0x"); + String sensorLocation; + sensorLocation.reserve(12); // Reserve for "modbus_0x" + 2 hex chars + sensorLocation = F("modbus_0x"); if (_modbusAddress < 16) sensorLocation += "0"; sensorLocation += String(_modbusAddress, HEX); return sensorLocation; diff --git a/src/sensors/AtlasParent.cpp b/src/sensors/AtlasParent.cpp index 511c3f4a2..2d49d85f2 100644 --- a/src/sensors/AtlasParent.cpp +++ b/src/sensors/AtlasParent.cpp @@ -37,7 +37,9 @@ AtlasParent::AtlasParent(int8_t powerPin, uint8_t i2cAddressHex, String AtlasParent::getSensorLocation() { - String address = F("I2C_0x"); + String address; + address.reserve(10); // Reserve for "I2C_0x" + 2 hex chars + address = F("I2C_0x"); address += String(_i2cAddressHex, HEX); return address; } diff --git a/src/sensors/BoschBME280.cpp b/src/sensors/BoschBME280.cpp index c36638c4d..e9252bcae 100644 --- a/src/sensors/BoschBME280.cpp +++ b/src/sensors/BoschBME280.cpp @@ -27,7 +27,9 @@ BoschBME280::BoschBME280(int8_t powerPin, uint8_t i2cAddressHex, String BoschBME280::getSensorLocation() { - String address = F("I2C_0x"); + String address; + address.reserve(10); // Reserve for "I2C_0x" + 2 hex chars + address = F("I2C_0x"); address += String(_i2cAddressHex, HEX); return address; } diff --git a/src/sensors/BoschBMP3xx.cpp b/src/sensors/BoschBMP3xx.cpp index 00fcdd45a..e35f02923 100644 --- a/src/sensors/BoschBMP3xx.cpp +++ b/src/sensors/BoschBMP3xx.cpp @@ -28,7 +28,9 @@ BoschBMP3xx::BoschBMP3xx(int8_t powerPin, Mode mode, String BoschBMP3xx::getSensorLocation() { - String address = F("I2C_0x"); + String address; + address.reserve(10); // Reserve for "I2C_0x" + 2 hex chars + address = F("I2C_0x"); address += String(_i2cAddressHex, HEX); return address; } diff --git a/src/sensors/GroPointParent.cpp b/src/sensors/GroPointParent.cpp index 5e68a1f5c..074375ec8 100644 --- a/src/sensors/GroPointParent.cpp +++ b/src/sensors/GroPointParent.cpp @@ -46,7 +46,9 @@ GroPointParent::GroPointParent(byte modbusAddress, Stream& stream, // The sensor installation location on the Mayfly String GroPointParent::getSensorLocation() { - String sensorLocation = F("modbus_0x"); + String sensorLocation; + sensorLocation.reserve(12); // Reserve for "modbus_0x" + 2 hex chars + sensorLocation = F("modbus_0x"); if (_modbusAddress < 16) sensorLocation += "0"; sensorLocation += String(_modbusAddress, HEX); return sensorLocation; diff --git a/src/sensors/KellerParent.cpp b/src/sensors/KellerParent.cpp index ab9d7062b..841c8cd3a 100644 --- a/src/sensors/KellerParent.cpp +++ b/src/sensors/KellerParent.cpp @@ -44,7 +44,9 @@ KellerParent::KellerParent(byte modbusAddress, Stream& stream, int8_t powerPin, // The sensor installation location on the Mayfly String KellerParent::getSensorLocation() { - String sensorLocation = F("modbus_0x"); + String sensorLocation; + sensorLocation.reserve(12); // Reserve for "modbus_0x" + 2 hex chars + sensorLocation = F("modbus_0x"); if (_modbusAddress < 16) sensorLocation += "0"; sensorLocation += String(_modbusAddress, HEX); return sensorLocation; diff --git a/src/sensors/MaxBotixSonar.cpp b/src/sensors/MaxBotixSonar.cpp index 6e62d364c..10700dec0 100644 --- a/src/sensors/MaxBotixSonar.cpp +++ b/src/sensors/MaxBotixSonar.cpp @@ -33,7 +33,9 @@ MaxBotixSonar::MaxBotixSonar(Stream& stream, int8_t powerPin, int8_t triggerPin, // unfortunately, we really cannot know where the stream is attached. String MaxBotixSonar::getSensorLocation() { // attach the trigger pin to the stream number - String loc = "sonarStream_trigger" + String(_triggerPin); + String loc; + loc.reserve(25); // Reserve for "sonarStream_trigger" + pin number + loc = "sonarStream_trigger" + String(_triggerPin); return loc; } diff --git a/src/sensors/MaximDS18.cpp b/src/sensors/MaximDS18.cpp index be8c2a6b5..3a9f5e62b 100644 --- a/src/sensors/MaximDS18.cpp +++ b/src/sensors/MaximDS18.cpp @@ -38,7 +38,9 @@ MaximDS18::MaximDS18(int8_t powerPin, int8_t dataPin, // Turns the address into a printable string String MaximDS18::makeAddressString(DeviceAddress owAddr) { - String addrStr = F("Pin"); + String addrStr; + addrStr.reserve(50); // Reserve for "Pin" + pin# + "{0x##,0x##...}" (8 addresses) + addrStr = F("Pin"); addrStr += (_dataPin); addrStr += '{'; for (uint8_t i = 0; i < 8; i++) { diff --git a/src/sensors/MeaSpecMS5803.cpp b/src/sensors/MeaSpecMS5803.cpp index 2b3866845..ed394e45d 100644 --- a/src/sensors/MeaSpecMS5803.cpp +++ b/src/sensors/MeaSpecMS5803.cpp @@ -24,7 +24,9 @@ MeaSpecMS5803::MeaSpecMS5803(int8_t powerPin, uint8_t i2cAddressHex, String MeaSpecMS5803::getSensorLocation() { - String address = F("I2C_0x"); + String address; + address.reserve(10); // Reserve for "I2C_0x" + 2 hex chars + address = F("I2C_0x"); address += String(_i2cAddressHex, HEX); return address; } diff --git a/src/sensors/PaleoTerraRedox.cpp b/src/sensors/PaleoTerraRedox.cpp index 4d9a1ced2..d769148f0 100644 --- a/src/sensors/PaleoTerraRedox.cpp +++ b/src/sensors/PaleoTerraRedox.cpp @@ -70,11 +70,15 @@ PaleoTerraRedox::~PaleoTerraRedox() {} String PaleoTerraRedox::getSensorLocation() { #if defined(MS_PALEOTERRA_SOFTWAREWIRE) - String address = F("SoftwareWire"); + String address; + address.reserve(25); // Reserve for "SoftwareWire" + pin# + "_0x" + hex chars + address = F("SoftwareWire"); if (_dataPin >= 0) address += _dataPin; address += F("_0x"); #else - String address = F("I2C_0x"); + String address; + address.reserve(10); // Reserve for "I2C_0x" + 2 hex chars + address = F("I2C_0x"); #endif address += String(_i2cAddressHex, HEX); return address; diff --git a/src/sensors/ProcessorStats.cpp b/src/sensors/ProcessorStats.cpp index f06fa78c3..b5932f53d 100644 --- a/src/sensors/ProcessorStats.cpp +++ b/src/sensors/ProcessorStats.cpp @@ -77,7 +77,10 @@ ProcessorStats::ProcessorStats(const char* boardName, const char* version, String ProcessorStats::getSensorLocation() { - return String(_boardName) + " " + String(_version); + String result; + result.reserve(50); // Reserve for board name + " " + version + result = String(_boardName) + " " + String(_version); + return result; } float ProcessorStats::getBatteryVoltage() { diff --git a/src/sensors/RainCounterI2C.cpp b/src/sensors/RainCounterI2C.cpp index d8bb93357..6fdace841 100644 --- a/src/sensors/RainCounterI2C.cpp +++ b/src/sensors/RainCounterI2C.cpp @@ -65,11 +65,15 @@ RainCounterI2C::~RainCounterI2C() {} String RainCounterI2C::getSensorLocation() { #if defined(MS_RAIN_SOFTWAREWIRE) - String address = F("SoftwareWire"); + String address; + address.reserve(25); // Reserve for "SoftwareWire" + pin# + "_0x" + hex chars + address = F("SoftwareWire"); if (_dataPin >= 0) address += _dataPin; address += F("_0x"); #else - String address = F("I2C_0x"); + String address; + address.reserve(10); // Reserve for "I2C_0x" + 2 hex chars + address = F("I2C_0x"); #endif address += String(_i2cAddressHex, HEX); return address; diff --git a/src/sensors/SDI12Sensors.cpp b/src/sensors/SDI12Sensors.cpp index 4d02d8e27..085d5398d 100644 --- a/src/sensors/SDI12Sensors.cpp +++ b/src/sensors/SDI12Sensors.cpp @@ -279,7 +279,9 @@ String SDI12Sensors::getSensorSerialNumber() { // The sensor installation location on the Mayfly String SDI12Sensors::getSensorLocation() { - String sensorLocation = F("SDI12-"); + String sensorLocation; + sensorLocation.reserve(20); // Reserve for "SDI12-" + address + "_Pin" + pin + sensorLocation = F("SDI12-"); sensorLocation += String(_SDI12address) + F("_Pin") + String(_dataPin); return sensorLocation; } diff --git a/src/sensors/TIINA219.cpp b/src/sensors/TIINA219.cpp index 323e840f9..a86de2386 100644 --- a/src/sensors/TIINA219.cpp +++ b/src/sensors/TIINA219.cpp @@ -31,7 +31,9 @@ TIINA219::TIINA219(int8_t powerPin, uint8_t i2cAddressHex, String TIINA219::getSensorLocation() { - String address = F("I2C_0x"); + String address; + address.reserve(10); // Reserve for "I2C_0x" + 2 hex chars + address = F("I2C_0x"); address += String(_i2cAddressHex, HEX); return address; } diff --git a/src/sensors/TallyCounterI2C.cpp b/src/sensors/TallyCounterI2C.cpp index 6c41c128c..f0e2a6164 100644 --- a/src/sensors/TallyCounterI2C.cpp +++ b/src/sensors/TallyCounterI2C.cpp @@ -21,7 +21,9 @@ TallyCounterI2C::TallyCounterI2C(int8_t powerPin, uint8_t i2cAddressHex) String TallyCounterI2C::getSensorLocation() { - String address = F("I2C_0x"); + String address; + address.reserve(10); // Reserve for "I2C_0x" + 2 hex chars + address = F("I2C_0x"); address += String(_i2cAddressHex, HEX); return address; } diff --git a/src/sensors/YosemitechParent.cpp b/src/sensors/YosemitechParent.cpp index 895ac2d0b..84cfade56 100644 --- a/src/sensors/YosemitechParent.cpp +++ b/src/sensors/YosemitechParent.cpp @@ -42,7 +42,9 @@ YosemitechParent::YosemitechParent( // The sensor installation location on the Mayfly String YosemitechParent::getSensorLocation() { - String sensorLocation = F("modbus_0x"); + String sensorLocation; + sensorLocation.reserve(12); // Reserve for "modbus_0x" + 2 hex chars + sensorLocation = F("modbus_0x"); if (_modbusAddress < 16) sensorLocation += "0"; sensorLocation += String(_modbusAddress, HEX); return sensorLocation; From 71f99b906e2187d268fece4f7733485734aa814b Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Wed, 4 Mar 2026 15:36:05 -0500 Subject: [PATCH 432/533] Minor fixes Signed-off-by: Sara Damiano --- src/VariableBase.cpp | 5 ++++- src/VariableBase.h | 2 +- src/sensors/ANBpH.h | 6 +++--- src/sensors/EverlightALSPT19.h | 3 ++- src/sensors/KellerParent.cpp | 4 ++-- 5 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/VariableBase.cpp b/src/VariableBase.cpp index 56f3b8f59..5af3c2dad 100644 --- a/src/VariableBase.cpp +++ b/src/VariableBase.cpp @@ -38,7 +38,10 @@ Variable::Variable(Sensor* parentSense, uint8_t sensorVarNum, Variable::Variable(float (*calcFxn)(), uint8_t decimalResolution, const char* varName, const char* varUnit, const char* varCode, const char* uuid) - : _calcFxn(nullptr) { + : isCalculated(false), + parentSensor(nullptr), + _currentValue(MS_INVALID_VALUE), + _calcFxn(nullptr) { if (uuid) setVarUUID(uuid); if (varCode) setVarCode(varCode); if (varUnit) setVarUnit(varUnit); diff --git a/src/VariableBase.h b/src/VariableBase.h index dbb2a0fe9..85cc56a3e 100644 --- a/src/VariableBase.h +++ b/src/VariableBase.h @@ -420,7 +420,7 @@ class Variable { * @return The number of decimal places needed to represent the resolution */ static inline uint8_t floatResolutionToDecimalPlaces(float resolution) { - if (resolution <= 0.0f) { + if (resolution <= 0.0f || isnan(resolution)) { return 4; // Default to 4 decimal places for invalid input } diff --git a/src/sensors/ANBpH.h b/src/sensors/ANBpH.h index 6cf6dabbf..14dd35d5f 100644 --- a/src/sensors/ANBpH.h +++ b/src/sensors/ANBpH.h @@ -221,8 +221,8 @@ * {{ @ref ANBpH_pH::ANBpH_pH }} */ /**@{*/ -/// @brief Decimal places in string representation; soil moisture should have 1 -/// - resolution is 0.01. +/// @brief Decimal places in string representation; pH should have 2 - +/// resolution is 0.01. #define ANB_PH_PH_RESOLUTION 2 /// @brief Sensor variable number; pH is stored in sensorValues[0]. #define ANB_PH_PH_VAR_NUM 0 @@ -245,7 +245,7 @@ * {{ @ref ANBpH_Temp::ANBpH_Temp }} */ /**@{*/ -/// @brief Decimal places in string representation; temperature should have 1 - +/// @brief Decimal places in string representation; temperature should have 2 - /// resolution is 0.01°C. #define ANB_PH_TEMP_RESOLUTION 2 /// @brief Sensor variable number; temperature is stored in sensorValues[1]. diff --git a/src/sensors/EverlightALSPT19.h b/src/sensors/EverlightALSPT19.h index cf18809d7..96ef07359 100644 --- a/src/sensors/EverlightALSPT19.h +++ b/src/sensors/EverlightALSPT19.h @@ -102,8 +102,9 @@ * Lux, which doesn't appear to align with the datasheet. */ #define ALSPT19_UA_PER_1000LUX 200.0f -static_assert(ALSPT19_UA_PER_1000LUX > 0, "Current-to-lux calibration factor must be positive"); #endif +static_assert(ALSPT19_UA_PER_1000LUX > 0, + "Current-to-lux calibration factor must be positive"); /**@}*/ /** diff --git a/src/sensors/KellerParent.cpp b/src/sensors/KellerParent.cpp index 841c8cd3a..677d2b65b 100644 --- a/src/sensors/KellerParent.cpp +++ b/src/sensors/KellerParent.cpp @@ -106,6 +106,8 @@ bool KellerParent::addSingleMeasurementResult() { !isnan(waterTemperatureC) && waterTemperatureC != MS_INVALID_VALUE); if (success) { + // For waterPressureBar, convert bar to millibar + waterPressure_mBar = 1000 * waterPressureBar; // display values for debugging MS_DBG(F(" Pressure_mbar:"), waterPressure_mBar); MS_DBG(F(" Temp_C:"), waterTemperatureC); @@ -117,8 +119,6 @@ bool KellerParent::addSingleMeasurementResult() { // calculate depth from pressure and temperature waterDepthM = _ksensor.calcWaterDepthM(waterPressureBar, waterTemperatureC); - // For waterPressureBar, convert bar to millibar - waterPressure_mBar = 1000 * waterPressureBar; // display value for debugging MS_DBG(F(" Height_m:"), waterDepthM); } From 7cbf90e05851a71380116d08f64e058b7ecafae9 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Wed, 4 Mar 2026 15:43:08 -0500 Subject: [PATCH 433/533] clang format Signed-off-by: Sara Damiano --- src/SensorBase.cpp | 2 +- src/sensors/ANBpH.cpp | 2 +- src/sensors/AtlasParent.cpp | 2 +- src/sensors/BoschBME280.cpp | 2 +- src/sensors/BoschBMP3xx.cpp | 2 +- src/sensors/GroPointParent.cpp | 2 +- src/sensors/KellerParent.cpp | 2 +- src/sensors/MaxBotixSonar.cpp | 2 +- src/sensors/MaximDS18.cpp | 3 ++- src/sensors/MeaSpecMS5803.cpp | 2 +- src/sensors/PaleoTerraRedox.cpp | 5 +++-- src/sensors/ProcessorStats.cpp | 2 +- src/sensors/RainCounterI2C.cpp | 5 +++-- src/sensors/SDI12Sensors.cpp | 3 ++- src/sensors/TIINA219.cpp | 2 +- src/sensors/TallyCounterI2C.cpp | 2 +- src/sensors/YosemitechParent.cpp | 2 +- 17 files changed, 23 insertions(+), 19 deletions(-) diff --git a/src/SensorBase.cpp b/src/SensorBase.cpp index 9338e301d..2a7bcd699 100644 --- a/src/SensorBase.cpp +++ b/src/SensorBase.cpp @@ -42,7 +42,7 @@ Sensor::Sensor(const char* sensorName, const uint8_t totalReturnedValues, // This gets the place the sensor is installed ON THE MAYFLY (ie, pin number) String Sensor::getSensorLocation() { String senseLoc; - senseLoc.reserve(10); // Reserve for "Pin" + pin number + senseLoc.reserve(10); // Reserve for "Pin" + pin number senseLoc = F("Pin"); senseLoc += String(_dataPin); return senseLoc; diff --git a/src/sensors/ANBpH.cpp b/src/sensors/ANBpH.cpp index 5e2d8a3ca..0861b7edc 100644 --- a/src/sensors/ANBpH.cpp +++ b/src/sensors/ANBpH.cpp @@ -39,7 +39,7 @@ ANBpH::ANBpH(byte modbusAddress, Stream& stream, int8_t powerPin, // The sensor installation location on the Mayfly String ANBpH::getSensorLocation() { String sensorLocation; - sensorLocation.reserve(12); // Reserve for "modbus_0x" + 2 hex chars + sensorLocation.reserve(12); // Reserve for "modbus_0x" + 2 hex chars sensorLocation = F("modbus_0x"); if (_modbusAddress < 16) sensorLocation += "0"; sensorLocation += String(_modbusAddress, HEX); diff --git a/src/sensors/AtlasParent.cpp b/src/sensors/AtlasParent.cpp index 2d49d85f2..52a767018 100644 --- a/src/sensors/AtlasParent.cpp +++ b/src/sensors/AtlasParent.cpp @@ -38,7 +38,7 @@ AtlasParent::AtlasParent(int8_t powerPin, uint8_t i2cAddressHex, String AtlasParent::getSensorLocation() { String address; - address.reserve(10); // Reserve for "I2C_0x" + 2 hex chars + address.reserve(10); // Reserve for "I2C_0x" + 2 hex chars address = F("I2C_0x"); address += String(_i2cAddressHex, HEX); return address; diff --git a/src/sensors/BoschBME280.cpp b/src/sensors/BoschBME280.cpp index e9252bcae..aa4d0b3d3 100644 --- a/src/sensors/BoschBME280.cpp +++ b/src/sensors/BoschBME280.cpp @@ -28,7 +28,7 @@ BoschBME280::BoschBME280(int8_t powerPin, uint8_t i2cAddressHex, String BoschBME280::getSensorLocation() { String address; - address.reserve(10); // Reserve for "I2C_0x" + 2 hex chars + address.reserve(10); // Reserve for "I2C_0x" + 2 hex chars address = F("I2C_0x"); address += String(_i2cAddressHex, HEX); return address; diff --git a/src/sensors/BoschBMP3xx.cpp b/src/sensors/BoschBMP3xx.cpp index e35f02923..d680087b5 100644 --- a/src/sensors/BoschBMP3xx.cpp +++ b/src/sensors/BoschBMP3xx.cpp @@ -29,7 +29,7 @@ BoschBMP3xx::BoschBMP3xx(int8_t powerPin, Mode mode, String BoschBMP3xx::getSensorLocation() { String address; - address.reserve(10); // Reserve for "I2C_0x" + 2 hex chars + address.reserve(10); // Reserve for "I2C_0x" + 2 hex chars address = F("I2C_0x"); address += String(_i2cAddressHex, HEX); return address; diff --git a/src/sensors/GroPointParent.cpp b/src/sensors/GroPointParent.cpp index 074375ec8..7aabf8e39 100644 --- a/src/sensors/GroPointParent.cpp +++ b/src/sensors/GroPointParent.cpp @@ -47,7 +47,7 @@ GroPointParent::GroPointParent(byte modbusAddress, Stream& stream, // The sensor installation location on the Mayfly String GroPointParent::getSensorLocation() { String sensorLocation; - sensorLocation.reserve(12); // Reserve for "modbus_0x" + 2 hex chars + sensorLocation.reserve(12); // Reserve for "modbus_0x" + 2 hex chars sensorLocation = F("modbus_0x"); if (_modbusAddress < 16) sensorLocation += "0"; sensorLocation += String(_modbusAddress, HEX); diff --git a/src/sensors/KellerParent.cpp b/src/sensors/KellerParent.cpp index 677d2b65b..2e4567a78 100644 --- a/src/sensors/KellerParent.cpp +++ b/src/sensors/KellerParent.cpp @@ -45,7 +45,7 @@ KellerParent::KellerParent(byte modbusAddress, Stream& stream, int8_t powerPin, // The sensor installation location on the Mayfly String KellerParent::getSensorLocation() { String sensorLocation; - sensorLocation.reserve(12); // Reserve for "modbus_0x" + 2 hex chars + sensorLocation.reserve(12); // Reserve for "modbus_0x" + 2 hex chars sensorLocation = F("modbus_0x"); if (_modbusAddress < 16) sensorLocation += "0"; sensorLocation += String(_modbusAddress, HEX); diff --git a/src/sensors/MaxBotixSonar.cpp b/src/sensors/MaxBotixSonar.cpp index 10700dec0..f6f3510ca 100644 --- a/src/sensors/MaxBotixSonar.cpp +++ b/src/sensors/MaxBotixSonar.cpp @@ -34,7 +34,7 @@ MaxBotixSonar::MaxBotixSonar(Stream& stream, int8_t powerPin, int8_t triggerPin, String MaxBotixSonar::getSensorLocation() { // attach the trigger pin to the stream number String loc; - loc.reserve(25); // Reserve for "sonarStream_trigger" + pin number + loc.reserve(25); // Reserve for "sonarStream_trigger" + pin number loc = "sonarStream_trigger" + String(_triggerPin); return loc; } diff --git a/src/sensors/MaximDS18.cpp b/src/sensors/MaximDS18.cpp index 3a9f5e62b..7f91b1736 100644 --- a/src/sensors/MaximDS18.cpp +++ b/src/sensors/MaximDS18.cpp @@ -39,7 +39,8 @@ MaximDS18::MaximDS18(int8_t powerPin, int8_t dataPin, // Turns the address into a printable string String MaximDS18::makeAddressString(DeviceAddress owAddr) { String addrStr; - addrStr.reserve(50); // Reserve for "Pin" + pin# + "{0x##,0x##...}" (8 addresses) + addrStr.reserve( + 50); // Reserve for "Pin" + pin# + "{0x##,0x##...}" (8 addresses) addrStr = F("Pin"); addrStr += (_dataPin); addrStr += '{'; diff --git a/src/sensors/MeaSpecMS5803.cpp b/src/sensors/MeaSpecMS5803.cpp index ed394e45d..e19638704 100644 --- a/src/sensors/MeaSpecMS5803.cpp +++ b/src/sensors/MeaSpecMS5803.cpp @@ -25,7 +25,7 @@ MeaSpecMS5803::MeaSpecMS5803(int8_t powerPin, uint8_t i2cAddressHex, String MeaSpecMS5803::getSensorLocation() { String address; - address.reserve(10); // Reserve for "I2C_0x" + 2 hex chars + address.reserve(10); // Reserve for "I2C_0x" + 2 hex chars address = F("I2C_0x"); address += String(_i2cAddressHex, HEX); return address; diff --git a/src/sensors/PaleoTerraRedox.cpp b/src/sensors/PaleoTerraRedox.cpp index d769148f0..aa08aae00 100644 --- a/src/sensors/PaleoTerraRedox.cpp +++ b/src/sensors/PaleoTerraRedox.cpp @@ -71,13 +71,14 @@ PaleoTerraRedox::~PaleoTerraRedox() {} String PaleoTerraRedox::getSensorLocation() { #if defined(MS_PALEOTERRA_SOFTWAREWIRE) String address; - address.reserve(25); // Reserve for "SoftwareWire" + pin# + "_0x" + hex chars + address.reserve( + 25); // Reserve for "SoftwareWire" + pin# + "_0x" + hex chars address = F("SoftwareWire"); if (_dataPin >= 0) address += _dataPin; address += F("_0x"); #else String address; - address.reserve(10); // Reserve for "I2C_0x" + 2 hex chars + address.reserve(10); // Reserve for "I2C_0x" + 2 hex chars address = F("I2C_0x"); #endif address += String(_i2cAddressHex, HEX); diff --git a/src/sensors/ProcessorStats.cpp b/src/sensors/ProcessorStats.cpp index b5932f53d..ebcdf9ffd 100644 --- a/src/sensors/ProcessorStats.cpp +++ b/src/sensors/ProcessorStats.cpp @@ -78,7 +78,7 @@ ProcessorStats::ProcessorStats(const char* boardName, const char* version, String ProcessorStats::getSensorLocation() { String result; - result.reserve(50); // Reserve for board name + " " + version + result.reserve(50); // Reserve for board name + " " + version result = String(_boardName) + " " + String(_version); return result; } diff --git a/src/sensors/RainCounterI2C.cpp b/src/sensors/RainCounterI2C.cpp index 6fdace841..7db5bc624 100644 --- a/src/sensors/RainCounterI2C.cpp +++ b/src/sensors/RainCounterI2C.cpp @@ -66,13 +66,14 @@ RainCounterI2C::~RainCounterI2C() {} String RainCounterI2C::getSensorLocation() { #if defined(MS_RAIN_SOFTWAREWIRE) String address; - address.reserve(25); // Reserve for "SoftwareWire" + pin# + "_0x" + hex chars + address.reserve( + 25); // Reserve for "SoftwareWire" + pin# + "_0x" + hex chars address = F("SoftwareWire"); if (_dataPin >= 0) address += _dataPin; address += F("_0x"); #else String address; - address.reserve(10); // Reserve for "I2C_0x" + 2 hex chars + address.reserve(10); // Reserve for "I2C_0x" + 2 hex chars address = F("I2C_0x"); #endif address += String(_i2cAddressHex, HEX); diff --git a/src/sensors/SDI12Sensors.cpp b/src/sensors/SDI12Sensors.cpp index 085d5398d..3d51d9146 100644 --- a/src/sensors/SDI12Sensors.cpp +++ b/src/sensors/SDI12Sensors.cpp @@ -280,7 +280,8 @@ String SDI12Sensors::getSensorSerialNumber() { // The sensor installation location on the Mayfly String SDI12Sensors::getSensorLocation() { String sensorLocation; - sensorLocation.reserve(20); // Reserve for "SDI12-" + address + "_Pin" + pin + sensorLocation.reserve( + 20); // Reserve for "SDI12-" + address + "_Pin" + pin sensorLocation = F("SDI12-"); sensorLocation += String(_SDI12address) + F("_Pin") + String(_dataPin); return sensorLocation; diff --git a/src/sensors/TIINA219.cpp b/src/sensors/TIINA219.cpp index a86de2386..fc078c059 100644 --- a/src/sensors/TIINA219.cpp +++ b/src/sensors/TIINA219.cpp @@ -32,7 +32,7 @@ TIINA219::TIINA219(int8_t powerPin, uint8_t i2cAddressHex, String TIINA219::getSensorLocation() { String address; - address.reserve(10); // Reserve for "I2C_0x" + 2 hex chars + address.reserve(10); // Reserve for "I2C_0x" + 2 hex chars address = F("I2C_0x"); address += String(_i2cAddressHex, HEX); return address; diff --git a/src/sensors/TallyCounterI2C.cpp b/src/sensors/TallyCounterI2C.cpp index f0e2a6164..721bd32d5 100644 --- a/src/sensors/TallyCounterI2C.cpp +++ b/src/sensors/TallyCounterI2C.cpp @@ -22,7 +22,7 @@ TallyCounterI2C::TallyCounterI2C(int8_t powerPin, uint8_t i2cAddressHex) String TallyCounterI2C::getSensorLocation() { String address; - address.reserve(10); // Reserve for "I2C_0x" + 2 hex chars + address.reserve(10); // Reserve for "I2C_0x" + 2 hex chars address = F("I2C_0x"); address += String(_i2cAddressHex, HEX); return address; diff --git a/src/sensors/YosemitechParent.cpp b/src/sensors/YosemitechParent.cpp index 84cfade56..f61e073a8 100644 --- a/src/sensors/YosemitechParent.cpp +++ b/src/sensors/YosemitechParent.cpp @@ -43,7 +43,7 @@ YosemitechParent::YosemitechParent( // The sensor installation location on the Mayfly String YosemitechParent::getSensorLocation() { String sensorLocation; - sensorLocation.reserve(12); // Reserve for "modbus_0x" + 2 hex chars + sensorLocation.reserve(12); // Reserve for "modbus_0x" + 2 hex chars sensorLocation = F("modbus_0x"); if (_modbusAddress < 16) sensorLocation += "0"; sensorLocation += String(_modbusAddress, HEX); From 78c720b6318d43c2ea1ed39b4183614e6a936266 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Wed, 4 Mar 2026 16:24:26 -0500 Subject: [PATCH 434/533] Null checks, debugs Signed-off-by: Sara Damiano --- src/SensorBase.cpp | 2 +- src/modems/DigiXBeeWifi.cpp | 2 +- src/publishers/DreamHostPublisher.cpp | 7 +++++++ src/publishers/MonitorMyWatershedPublisher.h | 3 ++- src/publishers/ThingSpeakPublisher.cpp | 8 +++++--- 5 files changed, 16 insertions(+), 6 deletions(-) diff --git a/src/SensorBase.cpp b/src/SensorBase.cpp index 2a7bcd699..185bd8ac1 100644 --- a/src/SensorBase.cpp +++ b/src/SensorBase.cpp @@ -602,7 +602,7 @@ bool Sensor::checkPowerOn(bool debug) { MEASUREMENT_SUCCESSFUL); return false; } else { - if (debug) { MS_DBG(" was on."); } + if (debug) { MS_DBG(F("was on.")); } // Mark the power-on time, just in case it had not been marked if (_millisPowerOn == 0) _millisPowerOn = millis(); // Set the status bit for sensor power attempt (bit 1) and success diff --git a/src/modems/DigiXBeeWifi.cpp b/src/modems/DigiXBeeWifi.cpp index 58fa5e9a2..5a9165794 100644 --- a/src/modems/DigiXBeeWifi.cpp +++ b/src/modems/DigiXBeeWifi.cpp @@ -519,9 +519,9 @@ bool DigiXBeeWifi::updateModemMetadata() { MS_DBG(F("Getting chip temperature:")); float chip_temp = MS_INVALID_VALUE; chip_temp = getModemChipTemperature(); + loggerModem::_priorModemTemp = chip_temp; MS_DBG(F("CURRENT Modem temperature(C):"), loggerModem::_priorModemTemp); - loggerModem::_priorModemTemp = chip_temp; success &= ((chip_temp != MS_INVALID_VALUE) && (chip_temp != 0)); } else { diff --git a/src/publishers/DreamHostPublisher.cpp b/src/publishers/DreamHostPublisher.cpp index 36c93f2ac..71586a302 100644 --- a/src/publishers/DreamHostPublisher.cpp +++ b/src/publishers/DreamHostPublisher.cpp @@ -67,6 +67,13 @@ void DreamHostPublisher::begin(Logger& baseLogger, const char* dhUrl) { // Post the data to dream host. // int16_t DreamHostPublisher::postDataDreamHost() int16_t DreamHostPublisher::publishData(Client* outClient, bool) { + // Validate required DreamHost URL is set before proceeding + if (_DreamHostPortalRX == nullptr) { + MS_DBG(F("ERROR: DreamHost Portal RX URL not set. Call begin() or " + "setDreamHostPortalRX() first.")); + return -1; + } + // Create a buffer for the portions of the request and response char tempBuffer[37] = ""; uint16_t did_respond = 0; diff --git a/src/publishers/MonitorMyWatershedPublisher.h b/src/publishers/MonitorMyWatershedPublisher.h index 8f61f9c17..f2a58dbdb 100644 --- a/src/publishers/MonitorMyWatershedPublisher.h +++ b/src/publishers/MonitorMyWatershedPublisher.h @@ -145,7 +145,8 @@ class MonitorMyWatershedPublisher : public dataPublisher { // Returns the data destination String getEndpoint() override { - return String(monitorMWHost) + String(monitorMWPath); + return String(monitorMWHost ? monitorMWHost : "") + + String(monitorMWPath ? monitorMWPath : ""); } /** diff --git a/src/publishers/ThingSpeakPublisher.cpp b/src/publishers/ThingSpeakPublisher.cpp index e6b782ca1..83c128089 100644 --- a/src/publishers/ThingSpeakPublisher.cpp +++ b/src/publishers/ThingSpeakPublisher.cpp @@ -132,15 +132,17 @@ int16_t ThingSpeakPublisher::publishData(Client* outClient, bool) { MS_DBG(F("ERROR: ThingSpeak Channel ID is required but not set!")); return -1; } - if (_thingSpeakClientName == nullptr) { + if (_thingSpeakClientName == nullptr || + strlen(_thingSpeakClientName) == 0) { MS_DBG(F("ERROR: ThingSpeak Client Name is required but not set!")); return -1; } - if (_thingSpeakMQTTUser == nullptr) { + if (_thingSpeakMQTTUser == nullptr || strlen(_thingSpeakMQTTUser) == 0) { MS_DBG(F("ERROR: ThingSpeak MQTT User is required but not set!")); return -1; } - if (_thingSpeakMQTTPassword == nullptr) { + if (_thingSpeakMQTTPassword == nullptr || + strlen(_thingSpeakMQTTPassword) == 0) { MS_DBG(F("ERROR: ThingSpeak MQTT Password is required but not set!")); return -1; } From 19a0ce071a9c5fb05283db4304d938f76c2d3ade Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Wed, 4 Mar 2026 16:52:19 -0500 Subject: [PATCH 435/533] Initializers Signed-off-by: Sara Damiano --- src/VariableBase.cpp | 3 ++- src/dataPublisherBase.cpp | 19 ++++++++----------- src/publishers/DreamHostPublisher.cpp | 1 - src/publishers/S3PresignedPublisher.h | 2 +- 4 files changed, 11 insertions(+), 14 deletions(-) diff --git a/src/VariableBase.cpp b/src/VariableBase.cpp index 5af3c2dad..8d497c4c5 100644 --- a/src/VariableBase.cpp +++ b/src/VariableBase.cpp @@ -24,7 +24,8 @@ Variable::Variable(Sensor* parentSense, uint8_t sensorVarNum, : isCalculated(false), parentSensor(nullptr), _currentValue(MS_INVALID_VALUE), - _sensorVarNum(sensorVarNum) { + _sensorVarNum(sensorVarNum), + _calcFxn(nullptr) { if (uuid) setVarUUID(uuid); if (varCode) setVarCode(varCode); if (varUnit) setVarUnit(varUnit); diff --git a/src/dataPublisherBase.cpp b/src/dataPublisherBase.cpp index dec5f3515..237540f13 100644 --- a/src/dataPublisherBase.cpp +++ b/src/dataPublisherBase.cpp @@ -22,22 +22,19 @@ const char* dataPublisher::putHeader = "PUT "; const char* dataPublisher::HTTPtag = " HTTP/1.1"; const char* dataPublisher::hostHeader = "\r\nHost: "; -// Constructors -dataPublisher::dataPublisher() {} - -dataPublisher::dataPublisher(Logger& baseLogger, int sendEveryX) +// Primary constructor +dataPublisher::dataPublisher(Logger& baseLogger, Client* inClient, + int sendEveryX) : _baseLogger(&baseLogger), - _inClient(nullptr), + _inClient(inClient), _sendEveryX(sendEveryX) { _baseModem = _baseLogger->registerDataPublisher(this); // register self with logger } -// Delegating constructor -dataPublisher::dataPublisher(Logger& baseLogger, Client* inClient, - int sendEveryX) - : dataPublisher(baseLogger, sendEveryX) { - _inClient = inClient; -} +// Constructors +dataPublisher::dataPublisher(Logger& baseLogger, int sendEveryX) + : dataPublisher(baseLogger, nullptr, sendEveryX) {} +dataPublisher::dataPublisher() {} // Sets the client diff --git a/src/publishers/DreamHostPublisher.cpp b/src/publishers/DreamHostPublisher.cpp index 71586a302..0ccacded7 100644 --- a/src/publishers/DreamHostPublisher.cpp +++ b/src/publishers/DreamHostPublisher.cpp @@ -65,7 +65,6 @@ void DreamHostPublisher::begin(Logger& baseLogger, const char* dhUrl) { // Post the data to dream host. -// int16_t DreamHostPublisher::postDataDreamHost() int16_t DreamHostPublisher::publishData(Client* outClient, bool) { // Validate required DreamHost URL is set before proceeding if (_DreamHostPortalRX == nullptr) { diff --git a/src/publishers/S3PresignedPublisher.h b/src/publishers/S3PresignedPublisher.h index 92032b24f..9d14814fa 100644 --- a/src/publishers/S3PresignedPublisher.h +++ b/src/publishers/S3PresignedPublisher.h @@ -353,7 +353,7 @@ class S3PresignedPublisher : public dataPublisher { /** * @brief Private reference to function used fetch a new file name. */ - String (*_getFileNameFxn)(); + String (*_getFileNameFxn)() = nullptr; /** * @brief The name of your certificate authority certificate file */ From be59a4daa1456feca3f5447b561d1e76f6a88e1e Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Wed, 4 Mar 2026 16:53:17 -0500 Subject: [PATCH 436/533] Add yields Signed-off-by: Sara Damiano --- src/SensorBase.cpp | 6 +++--- src/modems/LoggerModemMacros.h | 12 ++++++++---- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/SensorBase.cpp b/src/SensorBase.cpp index 185bd8ac1..3d843d2db 100644 --- a/src/SensorBase.cpp +++ b/src/SensorBase.cpp @@ -646,7 +646,7 @@ bool Sensor::isWarmedUp(bool debug) { // wait. void Sensor::waitForWarmUp() { while (!isWarmedUp()) { - // wait + yield(); // Allow other tasks to run } } @@ -694,7 +694,7 @@ bool Sensor::isStable(bool debug) { // wait. void Sensor::waitForStability() { while (!isStable()) { - // wait + yield(); // Allow other tasks to run } } @@ -733,7 +733,7 @@ bool Sensor::isMeasurementComplete(bool debug) { // wait. void Sensor::waitForMeasurementCompletion() { while (!isMeasurementComplete()) { - // wait + yield(); // Allow other tasks to run } } diff --git a/src/modems/LoggerModemMacros.h b/src/modems/LoggerModemMacros.h index 900c33ab0..f18b4b41b 100644 --- a/src/modems/LoggerModemMacros.h +++ b/src/modems/LoggerModemMacros.h @@ -15,6 +15,10 @@ #ifndef SRC_MODEMS_LOGGERMODEMMACROS_H_ #define SRC_MODEMS_LOGGERMODEMMACROS_H_ +#if defined(TINY_GSM_MODEM_HAS_NTP) && defined(TINY_GSM_MODEM_HAS_TIME) +#include "ClockSupport.h" +#endif + /** * @def MS_MODEM_NTP_SYNC @@ -626,7 +630,6 @@ return gsmModem.getNetworkEpoch(TinyGSM_EpochStart::UNIX); \ } #elif defined(TINY_GSM_MODEM_HAS_NTP) && defined(TINY_GSM_MODEM_HAS_TIME) -#include "ClockSupport.h" #define MS_MODEM_GET_NIST_TIME(specificModem, TinyGSMType) \ uint32_t specificModem::getNISTTime() { \ /** Check for and bail if not connected to the internet. */ \ @@ -672,8 +675,7 @@ \ /** Try up to 12 times to get a timestamp from NIST. */ \ for (uint8_t i = 0; i < NIST_SERVER_RETRYS; i++) { \ - while (millis() < _lastNISTrequest + 4000) { /* wait */ \ - } \ + while (millis() < _lastNISTrequest + 4000) { yield(); } \ \ /** Make TCP connection. */ \ TinyGsm##TinyGSMType::GsmClient##TinyGSMType gsmClient( \ @@ -687,7 +689,9 @@ uint32_t start = millis(); \ while (gsmClient && \ gsmClient.available() < NIST_RESPONSE_BYTES && \ - millis() - start < 5000L) {} \ + millis() - start < 5000L) { \ + yield(); \ + } \ \ if (gsmClient.available() >= NIST_RESPONSE_BYTES) { \ MS_DBG(F("NIST responded after"), millis() - start, \ From f719e6e35d2ed59f55d7a386c0fe442592d49a4c Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Wed, 4 Mar 2026 17:20:30 -0500 Subject: [PATCH 437/533] Fix virtual/override redundancies Signed-off-by: Sara Damiano --- src/modems/DigiXBee.cpp | 6 ++-- src/modems/DigiXBee.h | 2 +- src/modems/DigiXBee3GBypass.h | 19 +++++++------ src/modems/DigiXBeeCellularTransparent.h | 29 ++++++++++---------- src/modems/DigiXBeeLTEBypass.cpp | 4 +-- src/modems/DigiXBeeLTEBypass.h | 19 +++++++------ src/modems/DigiXBeeWifi.cpp | 4 +-- src/modems/DigiXBeeWifi.h | 19 +++++++------ src/modems/Espressif.h | 2 +- src/modems/EspressifESP32.cpp | 8 +++--- src/modems/EspressifESP32.h | 21 +++++++------- src/modems/EspressifESP8266.cpp | 6 ++-- src/modems/EspressifESP8266.h | 21 +++++++------- src/modems/QuectelBG96.h | 19 +++++++------ src/modems/SIMComSIM7000.h | 21 +++++++------- src/modems/SIMComSIM7080.h | 4 +-- src/modems/SIMComSIM800.h | 21 +++++++------- src/modems/SequansMonarch.h | 21 +++++++------- src/modems/SodaqUBeeR410M.h | 21 +++++++------- src/publishers/AWS_IoT_Publisher.h | 2 +- src/publishers/DreamHostPublisher.h | 2 +- src/publishers/MonitorMyWatershedPublisher.h | 2 +- src/publishers/S3PresignedPublisher.h | 2 +- src/publishers/ThingSpeakPublisher.h | 2 +- src/publishers/UbidotsPublisher.h | 2 +- src/sensors/ANBpH.h | 2 +- src/sensors/AtlasParent.h | 2 +- src/sensors/GroPointParent.h | 2 +- src/sensors/KellerParent.h | 2 +- src/sensors/ProcessorAnalog.h | 2 +- src/sensors/SDI12Sensors.h | 2 +- src/sensors/TIADS1x15.h | 2 +- src/sensors/YosemitechParent.h | 2 +- 33 files changed, 151 insertions(+), 144 deletions(-) diff --git a/src/modems/DigiXBee.cpp b/src/modems/DigiXBee.cpp index 0a64fb3db..f7bf420b1 100644 --- a/src/modems/DigiXBee.cpp +++ b/src/modems/DigiXBee.cpp @@ -34,9 +34,8 @@ bool DigiXBee::modemWakeFxn() { _wakeLevel ? F("HIGH") : F("LOW"), F("to wake"), _modemName); digitalWrite(_modemSleepRqPin, _wakeLevel); return true; - } else { - return true; } + return true; } @@ -47,7 +46,6 @@ bool DigiXBee::modemSleepFxn() { F("to sleep")); digitalWrite(_modemSleepRqPin, !_wakeLevel); return true; - } else { - return true; } + return true; } diff --git a/src/modems/DigiXBee.h b/src/modems/DigiXBee.h index fa14e1f0f..717d7ef31 100644 --- a/src/modems/DigiXBee.h +++ b/src/modems/DigiXBee.h @@ -221,7 +221,7 @@ class DigiXBee : public loggerModem { /** * @brief Destroy the Digi XBee object - no action taken */ - virtual ~DigiXBee() override = default; + ~DigiXBee() override = default; protected: bool modemSleepFxn() override; diff --git a/src/modems/DigiXBee3GBypass.h b/src/modems/DigiXBee3GBypass.h index 0852bc583..2a87232fc 100644 --- a/src/modems/DigiXBee3GBypass.h +++ b/src/modems/DigiXBee3GBypass.h @@ -132,15 +132,16 @@ class DigiXBee3GBypass : public DigiXBee { bool connectInternet(uint32_t maxConnectionTime = 50000L) override; void disconnectInternet() override; - virtual Client* createClient() override; - virtual void deleteClient(Client* client); - virtual Client* createSecureClient() override; - virtual void deleteSecureClient(Client* client); - virtual Client* createSecureClient( - SSLAuthMode sslAuthMode, SSLVersion sslVersion = SSLVersion::TLS1_2, - const char* CAcertName = nullptr, const char* clientCertName = nullptr, - const char* clientKeyName = nullptr) override; - virtual Client* + Client* createClient() override; + void deleteClient(Client* client) override; + Client* createSecureClient() override; + void deleteSecureClient(Client* client) override; + Client* createSecureClient(SSLAuthMode sslAuthMode, + SSLVersion sslVersion = SSLVersion::TLS1_2, + const char* CAcertName = nullptr, + const char* clientCertName = nullptr, + const char* clientKeyName = nullptr) override; + Client* createSecureClient(const char* pskIdent, const char* psKey, SSLVersion sslVersion = SSLVersion::TLS1_2) override; virtual Client* diff --git a/src/modems/DigiXBeeCellularTransparent.h b/src/modems/DigiXBeeCellularTransparent.h index d549b576d..030673d6e 100644 --- a/src/modems/DigiXBeeCellularTransparent.h +++ b/src/modems/DigiXBeeCellularTransparent.h @@ -144,17 +144,17 @@ class DigiXBeeCellularTransparent : public DigiXBee { * reference. * @param apn The Access Point Name (APN) for the SIM card. * @param user The user name, if required, associated with the APN; - * optional, defaulting to NULL + * optional, defaulting to nullptr * @param pwd The password, if required, associated with the APN; optional, - * defaulting to NULL + * defaulting to nullptr * * @see DigiXBee::DigiXBee */ DigiXBeeCellularTransparent(Stream* modemStream, int8_t powerPin, int8_t statusPin, bool useCTSStatus, int8_t modemResetPin, int8_t modemSleepRqPin, - const char* apn, const char* user = NULL, - const char* pwd = NULL); + const char* apn, const char* user = nullptr, + const char* pwd = nullptr); /** * @brief Destroy the Digi XBee Cellular Transparent object - no action * needed @@ -166,18 +166,19 @@ class DigiXBeeCellularTransparent : public DigiXBee { bool connectInternet(uint32_t maxConnectionTime = 50000L) override; void disconnectInternet() override; - virtual Client* createClient() override; - virtual void deleteClient(Client* client); - virtual Client* createSecureClient() override; - virtual void deleteSecureClient(Client* client); - virtual Client* createSecureClient( - SSLAuthMode sslAuthMode, SSLVersion sslVersion = SSLVersion::TLS1_2, - const char* CAcertName = nullptr, const char* clientCertName = nullptr, - const char* clientKeyName = nullptr) override; - virtual Client* + Client* createClient() override; + void deleteClient(Client* client) override; + Client* createSecureClient() override; + void deleteSecureClient(Client* client) override; + Client* createSecureClient(SSLAuthMode sslAuthMode, + SSLVersion sslVersion = SSLVersion::TLS1_2, + const char* CAcertName = nullptr, + const char* clientCertName = nullptr, + const char* clientKeyName = nullptr) override; + Client* createSecureClient(const char* pskIdent, const char* psKey, SSLVersion sslVersion = SSLVersion::TLS1_2) override; - virtual Client* + Client* createSecureClient(const char* pskTableName, SSLVersion sslVersion = SSLVersion::TLS1_2) override; diff --git a/src/modems/DigiXBeeLTEBypass.cpp b/src/modems/DigiXBeeLTEBypass.cpp index 20644ddef..af239631a 100644 --- a/src/modems/DigiXBeeLTEBypass.cpp +++ b/src/modems/DigiXBeeLTEBypass.cpp @@ -135,8 +135,6 @@ bool DigiXBeeLTEBypass::extraModemSetup() { MS_DBG(F("Attempting to reconnect to the u-blox SARA R410M module...")); success &= gsmModem.init(); _modemName = gsmModem.getModemName(); - } else { - success = false; } if (success) { @@ -161,7 +159,7 @@ bool DigiXBeeLTEBypass::modemHardReset() { } if (success) { MS_DBG(F("... and forcing a reset of the cellular component.")); - // Force a reset of the undelying cellular component + // Force a reset of the underlying cellular component gsmModem.sendAT(GF("!R")); success &= gsmModem.waitResponse(30000L, GF("OK\r")) == 1; // Exit command mode diff --git a/src/modems/DigiXBeeLTEBypass.h b/src/modems/DigiXBeeLTEBypass.h index eb4346925..558cf4a3a 100644 --- a/src/modems/DigiXBeeLTEBypass.h +++ b/src/modems/DigiXBeeLTEBypass.h @@ -147,15 +147,16 @@ class DigiXBeeLTEBypass : public DigiXBee { bool connectInternet(uint32_t maxConnectionTime = 50000L) override; void disconnectInternet() override; - virtual Client* createClient() override; - virtual void deleteClient(Client* client); - virtual Client* createSecureClient() override; - virtual void deleteSecureClient(Client* client); - virtual Client* createSecureClient( - SSLAuthMode sslAuthMode, SSLVersion sslVersion = SSLVersion::TLS1_2, - const char* CAcertName = nullptr, const char* clientCertName = nullptr, - const char* clientKeyName = nullptr) override; - virtual Client* + Client* createClient() override; + void deleteClient(Client* client) override; + Client* createSecureClient() override; + void deleteSecureClient(Client* client) override; + Client* createSecureClient(SSLAuthMode sslAuthMode, + SSLVersion sslVersion = SSLVersion::TLS1_2, + const char* CAcertName = nullptr, + const char* clientCertName = nullptr, + const char* clientKeyName = nullptr) override; + Client* createSecureClient(const char* pskIdent, const char* psKey, SSLVersion sslVersion = SSLVersion::TLS1_2) override; virtual Client* diff --git a/src/modems/DigiXBeeWifi.cpp b/src/modems/DigiXBeeWifi.cpp index 5a9165794..ae8a5d1b3 100644 --- a/src/modems/DigiXBeeWifi.cpp +++ b/src/modems/DigiXBeeWifi.cpp @@ -517,8 +517,8 @@ bool DigiXBeeWifi::updateModemMetadata() { if ((_pollModemMetaData & MODEM_TEMPERATURE_ENABLE_BITMASK) == MODEM_TEMPERATURE_ENABLE_BITMASK) { MS_DBG(F("Getting chip temperature:")); - float chip_temp = MS_INVALID_VALUE; - chip_temp = getModemChipTemperature(); + float chip_temp = MS_INVALID_VALUE; + chip_temp = getModemChipTemperature(); loggerModem::_priorModemTemp = chip_temp; MS_DBG(F("CURRENT Modem temperature(C):"), loggerModem::_priorModemTemp); diff --git a/src/modems/DigiXBeeWifi.h b/src/modems/DigiXBeeWifi.h index 965ca4f34..25c2575d7 100644 --- a/src/modems/DigiXBeeWifi.h +++ b/src/modems/DigiXBeeWifi.h @@ -142,15 +142,16 @@ class DigiXBeeWifi : public DigiXBee { bool connectInternet(uint32_t maxConnectionTime = 50000L) override; void disconnectInternet() override; - virtual Client* createClient() override; - virtual void deleteClient(Client* client); - virtual Client* createSecureClient() override; - virtual void deleteSecureClient(Client* client); - virtual Client* createSecureClient( - SSLAuthMode sslAuthMode, SSLVersion sslVersion = SSLVersion::TLS1_2, - const char* CAcertName = nullptr, const char* clientCertName = nullptr, - const char* clientKeyName = nullptr) override; - virtual Client* + Client* createClient() override; + void deleteClient(Client* client) override; + Client* createSecureClient() override; + void deleteSecureClient(Client* client) override; + Client* createSecureClient(SSLAuthMode sslAuthMode, + SSLVersion sslVersion = SSLVersion::TLS1_2, + const char* CAcertName = nullptr, + const char* clientCertName = nullptr, + const char* clientKeyName = nullptr) override; + Client* createSecureClient(const char* pskIdent, const char* psKey, SSLVersion sslVersion = SSLVersion::TLS1_2) override; virtual Client* diff --git a/src/modems/Espressif.h b/src/modems/Espressif.h index 05c83bfe6..1d23731fb 100644 --- a/src/modems/Espressif.h +++ b/src/modems/Espressif.h @@ -200,7 +200,7 @@ class Espressif : public loggerModem { /** * @brief Destroy the Espressif object - no action taken */ - virtual ~Espressif() override = default; + ~Espressif() override = default; /** * @brief A pointer to the Arduino serial Stream used for communication diff --git a/src/modems/EspressifESP32.cpp b/src/modems/EspressifESP32.cpp index 54a807977..9cfe03b8c 100644 --- a/src/modems/EspressifESP32.cpp +++ b/src/modems/EspressifESP32.cpp @@ -66,8 +66,8 @@ bool EspressifESP32::modemSleepFxn() { // Set up the light-sleep status pin, if applicable bool EspressifESP32::extraModemSetup() { if (_modemSleepRqPin >= 0) { digitalWrite(_modemSleepRqPin, !_wakeLevel); } - gsmModem.init(); - _modemName = gsmModem.getModemName(); + bool success = gsmModem.init(); + _modemName = gsmModem.getModemName(); // AT+CWCOUNTRY=,,, // : // 0: will change the county code to be the same as the AP that the @@ -81,8 +81,8 @@ bool EspressifESP32::extraModemSetup() { gsmModem.sendAT( GF("+CWCOUNTRY=0,\"US\",1,13")); // Set country code to default to US, // but allow to change if the AP is - gsmModem.waitResponse(); - return true; + success &= gsmModem.waitResponse() == 1; + return success; } // cSpell:ignore CWCOUNTRY diff --git a/src/modems/EspressifESP32.h b/src/modems/EspressifESP32.h index 9b44e656a..39b3f78be 100644 --- a/src/modems/EspressifESP32.h +++ b/src/modems/EspressifESP32.h @@ -130,18 +130,19 @@ class EspressifESP32 : public Espressif { bool connectInternet(uint32_t maxConnectionTime = 50000L) override; void disconnectInternet() override; - virtual Client* createClient() override; - virtual void deleteClient(Client* client); - virtual Client* createSecureClient() override; - virtual void deleteSecureClient(Client* client); - virtual Client* createSecureClient( - SSLAuthMode sslAuthMode, SSLVersion sslVersion = SSLVersion::TLS1_2, - const char* CAcertName = nullptr, const char* clientCertName = nullptr, - const char* clientKeyName = nullptr) override; - virtual Client* + Client* createClient() override; + void deleteClient(Client* client) override; + Client* createSecureClient() override; + void deleteSecureClient(Client* client) override; + Client* createSecureClient(SSLAuthMode sslAuthMode, + SSLVersion sslVersion = SSLVersion::TLS1_2, + const char* CAcertName = nullptr, + const char* clientCertName = nullptr, + const char* clientKeyName = nullptr) override; + Client* createSecureClient(const char* pskIdent, const char* psKey, SSLVersion sslVersion = SSLVersion::TLS1_2) override; - virtual Client* + Client* createSecureClient(const char* pskTableName, SSLVersion sslVersion = SSLVersion::TLS1_2) override; diff --git a/src/modems/EspressifESP8266.cpp b/src/modems/EspressifESP8266.cpp index f4bd1c749..61ff4cd3e 100644 --- a/src/modems/EspressifESP8266.cpp +++ b/src/modems/EspressifESP8266.cpp @@ -66,7 +66,7 @@ bool EspressifESP8266::modemSleepFxn() { // Set up the light-sleep status pin, if applicable bool EspressifESP8266::extraModemSetup() { if (_modemSleepRqPin >= 0) { digitalWrite(_modemSleepRqPin, !_wakeLevel); } - gsmModem.init(); - _modemName = gsmModem.getModemName(); - return true; + bool success = gsmModem.init(); + _modemName = gsmModem.getModemName(); + return success; } diff --git a/src/modems/EspressifESP8266.h b/src/modems/EspressifESP8266.h index 9b1c3e025..a59890371 100644 --- a/src/modems/EspressifESP8266.h +++ b/src/modems/EspressifESP8266.h @@ -129,18 +129,19 @@ class EspressifESP8266 : public Espressif { bool connectInternet(uint32_t maxConnectionTime = 50000L) override; void disconnectInternet() override; - virtual Client* createClient() override; - virtual void deleteClient(Client* client); - virtual Client* createSecureClient() override; - virtual void deleteSecureClient(Client* client); - virtual Client* createSecureClient( - SSLAuthMode sslAuthMode, SSLVersion sslVersion = SSLVersion::TLS1_2, - const char* CAcertName = nullptr, const char* clientCertName = nullptr, - const char* clientKeyName = nullptr) override; - virtual Client* + Client* createClient() override; + void deleteClient(Client* client) override; + Client* createSecureClient() override; + void deleteSecureClient(Client* client) override; + Client* createSecureClient(SSLAuthMode sslAuthMode, + SSLVersion sslVersion = SSLVersion::TLS1_2, + const char* CAcertName = nullptr, + const char* clientCertName = nullptr, + const char* clientKeyName = nullptr) override; + Client* createSecureClient(const char* pskIdent, const char* psKey, SSLVersion sslVersion = SSLVersion::TLS1_2) override; - virtual Client* + Client* createSecureClient(const char* pskTableName, SSLVersion sslVersion = SSLVersion::TLS1_2) override; diff --git a/src/modems/QuectelBG96.h b/src/modems/QuectelBG96.h index eddea4d3d..9b2eadecd 100644 --- a/src/modems/QuectelBG96.h +++ b/src/modems/QuectelBG96.h @@ -207,15 +207,16 @@ class QuectelBG96 : public loggerModem { bool connectInternet(uint32_t maxConnectionTime = 50000L) override; void disconnectInternet() override; - virtual Client* createClient() override; - virtual void deleteClient(Client* client); - virtual Client* createSecureClient() override; - virtual void deleteSecureClient(Client* client); - virtual Client* createSecureClient( - SSLAuthMode sslAuthMode, SSLVersion sslVersion = SSLVersion::TLS1_2, - const char* CAcertName = nullptr, const char* clientCertName = nullptr, - const char* clientKeyName = nullptr) override; - virtual Client* + Client* createClient() override; + void deleteClient(Client* client) override; + Client* createSecureClient() override; + void deleteSecureClient(Client* client) override; + Client* createSecureClient(SSLAuthMode sslAuthMode, + SSLVersion sslVersion = SSLVersion::TLS1_2, + const char* CAcertName = nullptr, + const char* clientCertName = nullptr, + const char* clientKeyName = nullptr) override; + Client* createSecureClient(const char* pskIdent, const char* psKey, SSLVersion sslVersion = SSLVersion::TLS1_2) override; virtual Client* diff --git a/src/modems/SIMComSIM7000.h b/src/modems/SIMComSIM7000.h index 13d904774..24176cedc 100644 --- a/src/modems/SIMComSIM7000.h +++ b/src/modems/SIMComSIM7000.h @@ -195,18 +195,19 @@ class SIMComSIM7000 : public loggerModem { bool connectInternet(uint32_t maxConnectionTime = 50000L) override; void disconnectInternet() override; - virtual Client* createClient() override; - virtual void deleteClient(Client* client); - virtual Client* createSecureClient() override; - virtual void deleteSecureClient(Client* client); - virtual Client* createSecureClient( - SSLAuthMode sslAuthMode, SSLVersion sslVersion = SSLVersion::TLS1_2, - const char* CAcertName = nullptr, const char* clientCertName = nullptr, - const char* clientKeyName = nullptr) override; - virtual Client* + Client* createClient() override; + void deleteClient(Client* client) override; + Client* createSecureClient() override; + void deleteSecureClient(Client* client) override; + Client* createSecureClient(SSLAuthMode sslAuthMode, + SSLVersion sslVersion = SSLVersion::TLS1_2, + const char* CAcertName = nullptr, + const char* clientCertName = nullptr, + const char* clientKeyName = nullptr) override; + Client* createSecureClient(const char* pskIdent, const char* psKey, SSLVersion sslVersion = SSLVersion::TLS1_2) override; - virtual Client* + Client* createSecureClient(const char* pskTableName, SSLVersion sslVersion = SSLVersion::TLS1_2) override; diff --git a/src/modems/SIMComSIM7080.h b/src/modems/SIMComSIM7080.h index 1a03fc9ac..6851ef090 100644 --- a/src/modems/SIMComSIM7080.h +++ b/src/modems/SIMComSIM7080.h @@ -191,9 +191,9 @@ class SIMComSIM7080 : public loggerModem { void disconnectInternet() override; virtual Client* createClient() override; - virtual void deleteClient(Client* client); + virtual void deleteClient(Client* client) override; virtual Client* createSecureClient() override; - virtual void deleteSecureClient(Client* client); + virtual void deleteSecureClient(Client* client) override; virtual Client* createSecureClient( SSLAuthMode sslAuthMode, SSLVersion sslVersion = SSLVersion::TLS1_2, const char* CAcertName = nullptr, const char* clientCertName = nullptr, diff --git a/src/modems/SIMComSIM800.h b/src/modems/SIMComSIM800.h index 21fc57367..587929bcb 100644 --- a/src/modems/SIMComSIM800.h +++ b/src/modems/SIMComSIM800.h @@ -197,18 +197,19 @@ class SIMComSIM800 : public loggerModem { bool connectInternet(uint32_t maxConnectionTime = 50000L) override; void disconnectInternet() override; - virtual Client* createClient() override; - virtual void deleteClient(Client* client); - virtual Client* createSecureClient() override; - virtual void deleteSecureClient(Client* client); - virtual Client* createSecureClient( - SSLAuthMode sslAuthMode, SSLVersion sslVersion = SSLVersion::TLS1_2, - const char* CAcertName = nullptr, const char* clientCertName = nullptr, - const char* clientKeyName = nullptr) override; - virtual Client* + Client* createClient() override; + void deleteClient(Client* client) override; + Client* createSecureClient() override; + void deleteSecureClient(Client* client) override; + Client* createSecureClient(SSLAuthMode sslAuthMode, + SSLVersion sslVersion = SSLVersion::TLS1_2, + const char* CAcertName = nullptr, + const char* clientCertName = nullptr, + const char* clientKeyName = nullptr) override; + Client* createSecureClient(const char* pskIdent, const char* psKey, SSLVersion sslVersion = SSLVersion::TLS1_2) override; - virtual Client* + Client* createSecureClient(const char* pskTableName, SSLVersion sslVersion = SSLVersion::TLS1_2) override; diff --git a/src/modems/SequansMonarch.h b/src/modems/SequansMonarch.h index f560a87ff..172081661 100644 --- a/src/modems/SequansMonarch.h +++ b/src/modems/SequansMonarch.h @@ -228,18 +228,19 @@ class SequansMonarch : public loggerModem { bool connectInternet(uint32_t maxConnectionTime = 50000L) override; void disconnectInternet() override; - virtual Client* createClient() override; - virtual void deleteClient(Client* client); - virtual Client* createSecureClient() override; - virtual void deleteSecureClient(Client* client); - virtual Client* createSecureClient( - SSLAuthMode sslAuthMode, SSLVersion sslVersion = SSLVersion::TLS1_2, - const char* CAcertName = nullptr, const char* clientCertName = nullptr, - const char* clientKeyName = nullptr) override; - virtual Client* + Client* createClient() override; + void deleteClient(Client* client) override; + Client* createSecureClient() override; + void deleteSecureClient(Client* client) override; + Client* createSecureClient(SSLAuthMode sslAuthMode, + SSLVersion sslVersion = SSLVersion::TLS1_2, + const char* CAcertName = nullptr, + const char* clientCertName = nullptr, + const char* clientKeyName = nullptr) override; + Client* createSecureClient(const char* pskIdent, const char* psKey, SSLVersion sslVersion = SSLVersion::TLS1_2) override; - virtual Client* + Client* createSecureClient(const char* pskTableName, SSLVersion sslVersion = SSLVersion::TLS1_2) override; diff --git a/src/modems/SodaqUBeeR410M.h b/src/modems/SodaqUBeeR410M.h index 5e89fd4e7..48a7cfbf3 100644 --- a/src/modems/SodaqUBeeR410M.h +++ b/src/modems/SodaqUBeeR410M.h @@ -304,18 +304,19 @@ class SodaqUBeeR410M : public loggerModem { bool connectInternet(uint32_t maxConnectionTime = 50000L) override; void disconnectInternet() override; - virtual Client* createClient() override; - virtual void deleteClient(Client* client); - virtual Client* createSecureClient() override; - virtual void deleteSecureClient(Client* client); - virtual Client* createSecureClient( - SSLAuthMode sslAuthMode, SSLVersion sslVersion = SSLVersion::TLS1_2, - const char* CAcertName = nullptr, const char* clientCertName = nullptr, - const char* clientKeyName = nullptr) override; - virtual Client* + Client* createClient() override; + void deleteClient(Client* client) override; + Client* createSecureClient() override; + void deleteSecureClient(Client* client) override; + Client* createSecureClient(SSLAuthMode sslAuthMode, + SSLVersion sslVersion = SSLVersion::TLS1_2, + const char* CAcertName = nullptr, + const char* clientCertName = nullptr, + const char* clientKeyName = nullptr) override; + Client* createSecureClient(const char* pskIdent, const char* psKey, SSLVersion sslVersion = SSLVersion::TLS1_2) override; - virtual Client* + Client* createSecureClient(const char* pskTableName, SSLVersion sslVersion = SSLVersion::TLS1_2) override; diff --git a/src/publishers/AWS_IoT_Publisher.h b/src/publishers/AWS_IoT_Publisher.h index 064f6f23d..f022f3393 100644 --- a/src/publishers/AWS_IoT_Publisher.h +++ b/src/publishers/AWS_IoT_Publisher.h @@ -173,7 +173,7 @@ class AWS_IoT_Publisher : public dataPublisher { /** * @brief Destroy the AWS IoT Core Publisher object */ - virtual ~AWS_IoT_Publisher() override = default; + ~AWS_IoT_Publisher() override = default; // Returns the data destination String getEndpoint() override { diff --git a/src/publishers/DreamHostPublisher.h b/src/publishers/DreamHostPublisher.h index 07e5dc17b..f289ee521 100644 --- a/src/publishers/DreamHostPublisher.h +++ b/src/publishers/DreamHostPublisher.h @@ -101,7 +101,7 @@ class DreamHostPublisher : public dataPublisher { /** * @brief Destroy the DreamHost Publisher object */ - virtual ~DreamHostPublisher() override = default; + ~DreamHostPublisher() override = default; // Returns the data destination String getEndpoint() override { diff --git a/src/publishers/MonitorMyWatershedPublisher.h b/src/publishers/MonitorMyWatershedPublisher.h index f2a58dbdb..69714b711 100644 --- a/src/publishers/MonitorMyWatershedPublisher.h +++ b/src/publishers/MonitorMyWatershedPublisher.h @@ -141,7 +141,7 @@ class MonitorMyWatershedPublisher : public dataPublisher { /** * @brief Destroy the Monitor My Watershed Publisher object */ - virtual ~MonitorMyWatershedPublisher() override = default; + ~MonitorMyWatershedPublisher() override = default; // Returns the data destination String getEndpoint() override { diff --git a/src/publishers/S3PresignedPublisher.h b/src/publishers/S3PresignedPublisher.h index 9d14814fa..e14c412f9 100644 --- a/src/publishers/S3PresignedPublisher.h +++ b/src/publishers/S3PresignedPublisher.h @@ -176,7 +176,7 @@ class S3PresignedPublisher : public dataPublisher { /** * @brief Destroy the S3 Publisher object */ - virtual ~S3PresignedPublisher() override = default; + ~S3PresignedPublisher() override = default; /** * @brief Set the S3 host name diff --git a/src/publishers/ThingSpeakPublisher.h b/src/publishers/ThingSpeakPublisher.h index 64e9a2eb9..66e431dd9 100644 --- a/src/publishers/ThingSpeakPublisher.h +++ b/src/publishers/ThingSpeakPublisher.h @@ -127,7 +127,7 @@ class ThingSpeakPublisher : public dataPublisher { /** * @brief Destroy the ThingSpeak Publisher object */ - virtual ~ThingSpeakPublisher() override = default; + ~ThingSpeakPublisher() override = default; // Returns the data destination String getEndpoint() override { diff --git a/src/publishers/UbidotsPublisher.h b/src/publishers/UbidotsPublisher.h index 6e8bafafa..2cee53aec 100644 --- a/src/publishers/UbidotsPublisher.h +++ b/src/publishers/UbidotsPublisher.h @@ -110,7 +110,7 @@ class UbidotsPublisher : public dataPublisher { /** * @brief Destroy the Ubidots Publisher object */ - virtual ~UbidotsPublisher() override = default; + ~UbidotsPublisher() override = default; // Returns the data destination /** diff --git a/src/sensors/ANBpH.h b/src/sensors/ANBpH.h index 14dd35d5f..c2b9c556f 100644 --- a/src/sensors/ANBpH.h +++ b/src/sensors/ANBpH.h @@ -538,7 +538,7 @@ class ANBpH : public Sensor { /** * @brief Destroy the ANB pH object - no action taken */ - virtual ~ANBpH() override = default; + ~ANBpH() override = default; String getSensorLocation() override; diff --git a/src/sensors/AtlasParent.h b/src/sensors/AtlasParent.h index 994996640..a5951a891 100644 --- a/src/sensors/AtlasParent.h +++ b/src/sensors/AtlasParent.h @@ -173,7 +173,7 @@ class AtlasParent : public Sensor { /** * @brief Destroy the Atlas Parent object. */ - virtual ~AtlasParent() override = default; + ~AtlasParent() override = default; /** * @brief Return the I2C address of the EZO circuit. diff --git a/src/sensors/GroPointParent.h b/src/sensors/GroPointParent.h index 490f92bf4..154e113b4 100644 --- a/src/sensors/GroPointParent.h +++ b/src/sensors/GroPointParent.h @@ -151,7 +151,7 @@ class GroPointParent : public Sensor { /** * @brief Destroy the GroPoint Parent object - no action taken */ - virtual ~GroPointParent() override = default; + ~GroPointParent() override = default; String getSensorLocation() override; diff --git a/src/sensors/KellerParent.h b/src/sensors/KellerParent.h index dd44e2860..8a383b716 100644 --- a/src/sensors/KellerParent.h +++ b/src/sensors/KellerParent.h @@ -231,7 +231,7 @@ class KellerParent : public Sensor { /** * @brief Destroy the Keller Parent object - no action taken */ - virtual ~KellerParent() override = default; + ~KellerParent() override = default; String getSensorLocation() override; diff --git a/src/sensors/ProcessorAnalog.h b/src/sensors/ProcessorAnalog.h index ec68589d7..e12525227 100644 --- a/src/sensors/ProcessorAnalog.h +++ b/src/sensors/ProcessorAnalog.h @@ -180,7 +180,7 @@ class ProcessorAnalogBase : public AnalogVoltageBase { /** * @brief Destroy the ProcessorAnalogBase object */ - virtual ~ProcessorAnalogBase() override = default; + ~ProcessorAnalogBase() override = default; /** * @brief Initialize the processor analog system diff --git a/src/sensors/SDI12Sensors.h b/src/sensors/SDI12Sensors.h index 3e3863d78..9a48ef1f2 100644 --- a/src/sensors/SDI12Sensors.h +++ b/src/sensors/SDI12Sensors.h @@ -165,7 +165,7 @@ class SDI12Sensors : public Sensor { /** * @brief Destroy the SDI12Sensors object - no action taken */ - virtual ~SDI12Sensors() override = default; + ~SDI12Sensors() override = default; /** * @brief Get the stored sensor vendor name returned by a previously called diff --git a/src/sensors/TIADS1x15.h b/src/sensors/TIADS1x15.h index 9454357d8..974d191cd 100644 --- a/src/sensors/TIADS1x15.h +++ b/src/sensors/TIADS1x15.h @@ -313,7 +313,7 @@ class TIADS1x15Base : public AnalogVoltageBase { /** * @brief Destroy the TIADS1x15Base object */ - virtual ~TIADS1x15Base() override = default; + ~TIADS1x15Base() override = default; /** * @brief Initialize the ADS1x15 analog voltage reading system diff --git a/src/sensors/YosemitechParent.h b/src/sensors/YosemitechParent.h index f1f3f74b7..33795607c 100644 --- a/src/sensors/YosemitechParent.h +++ b/src/sensors/YosemitechParent.h @@ -207,7 +207,7 @@ class YosemitechParent : public Sensor { /** * @brief Destroy the Yosemitech Parent object - no action taken */ - virtual ~YosemitechParent() override = default; + ~YosemitechParent() override = default; String getSensorLocation() override; From 73a70e5c1ed74d8f7281294336c765ac331444c2 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Wed, 4 Mar 2026 17:21:03 -0500 Subject: [PATCH 438/533] Unique status codes Signed-off-by: Sara Damiano --- src/publishers/ThingSpeakPublisher.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/publishers/ThingSpeakPublisher.cpp b/src/publishers/ThingSpeakPublisher.cpp index 83c128089..fb0110267 100644 --- a/src/publishers/ThingSpeakPublisher.cpp +++ b/src/publishers/ThingSpeakPublisher.cpp @@ -147,7 +147,7 @@ int16_t ThingSpeakPublisher::publishData(Client* outClient, bool) { return -1; } - bool retVal = false; + int16_t status = 0; // Make sure we don't have too many fields // A channel can have a max of 8 fields @@ -211,7 +211,8 @@ int16_t ThingSpeakPublisher::publishData(Client* outClient, bool) { MS_DBG(F("Publishing to ThingSpeak")); PRINTOUT(F("\nTopic ["), strlen(topicBuffer), F("]:"), topicBuffer); PRINTOUT(F("Message ["), strlen(txBuffer), F("]:"), txBuffer); - retVal = _mqttClient.publish(topicBuffer, txBuffer, false); + bool publishSuccess = _mqttClient.publish(topicBuffer, txBuffer, false); + status = publishSuccess ? 1 : 0; PRINTOUT(F("ThingSpeak topic published! Current state:"), parseMQTTState(_mqttClient.state())); @@ -219,7 +220,7 @@ int16_t ThingSpeakPublisher::publishData(Client* outClient, bool) { PRINTOUT(F("MQTT connection failed with state:"), parseMQTTState(_mqttClient.state())); delay(1000); - retVal = false; + status = 0; } // Disconnect from MQTT @@ -227,7 +228,7 @@ int16_t ThingSpeakPublisher::publishData(Client* outClient, bool) { MS_RESET_DEBUG_TIMER _mqttClient.disconnect(); MS_DBG(F("Disconnected after"), MS_PRINT_DEBUG_TIMER, F("ms")); - return retVal; + return status; } // This updates your channel field names on ThingSpeak From 55a61bad6e3727af482b3e87f3c45d13b1c4fec6 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Wed, 4 Mar 2026 17:23:18 -0500 Subject: [PATCH 439/533] Fix some comments Signed-off-by: Sara Damiano --- src/VariableBase.h | 2 -- src/publishers/MonitorMyWatershedPublisher.cpp | 16 ++++++++-------- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/src/VariableBase.h b/src/VariableBase.h index 85cc56a3e..e92810418 100644 --- a/src/VariableBase.h +++ b/src/VariableBase.h @@ -236,8 +236,6 @@ class Variable { const char* varName, const char* varUnit, const char* varCode); - // This sets up the variable (generally attaching it to its parent) - // bool setup(); /** * @brief Notify the parent sensor that it has an observing variable. diff --git a/src/publishers/MonitorMyWatershedPublisher.cpp b/src/publishers/MonitorMyWatershedPublisher.cpp index a9c080a48..ac5677de5 100644 --- a/src/publishers/MonitorMyWatershedPublisher.cpp +++ b/src/publishers/MonitorMyWatershedPublisher.cpp @@ -91,7 +91,7 @@ String MonitorMyWatershedPublisher::getHost() { return String(monitorMWHost); } -// Returns the data destination +// Sets the data destination host void MonitorMyWatershedPublisher::setHost(const char* host) { monitorMWHost = host; } @@ -101,7 +101,7 @@ String MonitorMyWatershedPublisher::getPath() { return String(monitorMWPath); } -// Returns the data destination +// Sets the data destination path/endpoint void MonitorMyWatershedPublisher::setPath(const char* endpoint) { monitorMWPath = endpoint; } @@ -111,7 +111,7 @@ int MonitorMyWatershedPublisher::getPort() { return monitorMWPort; } -// Returns the data destination +// Sets the data destination port void MonitorMyWatershedPublisher::setPort(int port) { monitorMWPort = port; } @@ -304,25 +304,25 @@ int16_t MonitorMyWatershedPublisher::flushDataBuffer(Client* outClient) { // Early return if no records to send if (_logBuffer.getNumRecords() == 0) { MS_DBG(F("No records to send, returning without action")); - return 0; + return -1; } if (_baseLogger->getSamplingFeatureUUID() == nullptr || strlen(_baseLogger->getSamplingFeatureUUID()) == 0) { PRINTOUT(F("A sampling feature UUID must be set before publishing data " "to Monitor My Watershed!.")); - return 0; + return -2; } if (_registrationToken == nullptr || strlen(_registrationToken) == 0) { PRINTOUT(F("A registration token must be set before publishing data " "to Monitor My Watershed!.")); - return 0; + return -3; } // Check for valid client before attempting connection if (outClient == nullptr) { PRINTOUT(F("No client available for publishing data to Monitor My " "Watershed!")); - return 0; + return -4; } // Open a TCP/IP connection to Monitor My Watershed @@ -412,7 +412,7 @@ int16_t MonitorMyWatershedPublisher::flushDataBuffer(Client* outClient) { char responseCode_char[4]; memcpy(responseCode_char, tempBuffer + 9, 3); // Null terminate the string - memset(responseCode_char + 3, '\0', 1); + responseCode_char[3] = '\0'; responseCode = atoi(responseCode_char); PRINTOUT(F("\n-- Response Code --")); PRINTOUT(responseCode); From 246c0a4ab22f28e3df67a7492e7702b8d36f5d5a Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Wed, 4 Mar 2026 17:27:43 -0500 Subject: [PATCH 440/533] Reorder ctors Signed-off-by: Sara Damiano --- src/publishers/AWS_IoT_Publisher.cpp | 43 ++++++++++---------- src/publishers/AWS_IoT_Publisher.h | 60 +++++++++++++++++++--------- 2 files changed, 65 insertions(+), 38 deletions(-) diff --git a/src/publishers/AWS_IoT_Publisher.cpp b/src/publishers/AWS_IoT_Publisher.cpp index 361e28f8f..210b572d6 100644 --- a/src/publishers/AWS_IoT_Publisher.cpp +++ b/src/publishers/AWS_IoT_Publisher.cpp @@ -27,10 +27,10 @@ const char* AWS_IoT_Publisher::timestampTag = "\"timestamp\":\""; // Constructors // Primary constructor - handles full initialization with all parameters AWS_IoT_Publisher::AWS_IoT_Publisher( - Logger& baseLogger, const char* awsIoTEndpoint, const char* caCertName, - const char* clientCertName, const char* clientKeyName, - const char* samplingFeatureUUID, int sendEveryX) - : dataPublisher(baseLogger, sendEveryX) { + Logger& baseLogger, Client* inClient, const char* awsIoTEndpoint, + const char* caCertName, const char* clientCertName, + const char* clientKeyName, const char* samplingFeatureUUID, int sendEveryX) + : dataPublisher(baseLogger, inClient, sendEveryX) { if (awsIoTEndpoint) setEndpoint(awsIoTEndpoint); if (caCertName) setCACertName(caCertName); if (clientCertName) setClientCertName(clientCertName); @@ -43,32 +43,35 @@ AWS_IoT_Publisher::AWS_IoT_Publisher( // Delegating constructors -AWS_IoT_Publisher::AWS_IoT_Publisher() : dataPublisher() { - init(); -} -AWS_IoT_Publisher::AWS_IoT_Publisher(Logger& baseLogger, int sendEveryX) - : AWS_IoT_Publisher(baseLogger, nullptr, nullptr, nullptr, nullptr, nullptr, +AWS_IoT_Publisher::AWS_IoT_Publisher( + Logger& baseLogger, const char* awsIoTEndpoint, const char* caCertName, + const char* clientCertName, const char* clientKeyName, + const char* samplingFeatureUUID, int sendEveryX) + : AWS_IoT_Publisher(baseLogger, nullptr, awsIoTEndpoint, caCertName, + clientCertName, clientKeyName, samplingFeatureUUID, sendEveryX) {} -AWS_IoT_Publisher::AWS_IoT_Publisher(Logger& baseLogger, Client* inClient, - int sendEveryX) - : AWS_IoT_Publisher(baseLogger, nullptr, nullptr, nullptr, nullptr, nullptr, - sendEveryX) { - if (inClient) _inClient = inClient; -} AWS_IoT_Publisher::AWS_IoT_Publisher(Logger& baseLogger, const char* awsIoTEndpoint, const char* caCertName, const char* clientCertName, const char* clientKeyName, int sendEveryX) - : AWS_IoT_Publisher(baseLogger, awsIoTEndpoint, caCertName, clientCertName, - clientKeyName, nullptr, sendEveryX) {} + : AWS_IoT_Publisher(baseLogger, nullptr, awsIoTEndpoint, caCertName, + clientCertName, clientKeyName, nullptr, sendEveryX) {} AWS_IoT_Publisher::AWS_IoT_Publisher(Logger& baseLogger, Client* inClient, const char* awsIoTEndpoint, const char* samplingFeatureUUID, int sendEveryX) - : AWS_IoT_Publisher(baseLogger, awsIoTEndpoint, nullptr, nullptr, nullptr, - samplingFeatureUUID, sendEveryX) { - if (inClient) _inClient = inClient; + : AWS_IoT_Publisher(baseLogger, inClient, awsIoTEndpoint, nullptr, nullptr, + nullptr, samplingFeatureUUID, sendEveryX) {} +AWS_IoT_Publisher::AWS_IoT_Publisher(Logger& baseLogger, Client* inClient, + int sendEveryX) + : AWS_IoT_Publisher(baseLogger, inClient, nullptr, nullptr, nullptr, + nullptr, nullptr, sendEveryX) {} +AWS_IoT_Publisher::AWS_IoT_Publisher(Logger& baseLogger, int sendEveryX) + : AWS_IoT_Publisher(baseLogger, nullptr, nullptr, nullptr, nullptr, nullptr, + nullptr, sendEveryX) {} +AWS_IoT_Publisher::AWS_IoT_Publisher() : dataPublisher() { + init(); } diff --git a/src/publishers/AWS_IoT_Publisher.h b/src/publishers/AWS_IoT_Publisher.h index f022f3393..de0f37aac 100644 --- a/src/publishers/AWS_IoT_Publisher.h +++ b/src/publishers/AWS_IoT_Publisher.h @@ -87,23 +87,6 @@ class AWS_IoT_Publisher : public dataPublisher { public: // Constructors - /** - * @brief Construct a new AWS IoT Core Publisher object with no members - * initialized. - */ - AWS_IoT_Publisher(); - /** - * @brief Construct a new AWS IoT Core Publisher object - * - * @note If a client is never specified, the publisher will attempt to - * create and use a client on a LoggerModem instance tied to the attached - * logger. - * - * @param baseLogger The logger supplying the data to be published - * @param sendEveryX Interval (in units of the logging interval) between - * attempted data transmissions. NOTE: not implemented by this publisher! - */ - explicit AWS_IoT_Publisher(Logger& baseLogger, int sendEveryX = 1); /** * @brief Construct a new AWS IoT Core Publisher object * @@ -111,10 +94,23 @@ class AWS_IoT_Publisher : public dataPublisher { * @param inClient An Arduino client instance to use to print data to. * Allows the use of any type of client and multiple clients tied to a * single TinyGSM modem instance + * @param awsIoTEndpoint The endpoint for your AWS IoT instance + * @param caCertName The name of your certificate authority certificate + * file + * @param clientCertName The name of your client certificate file + * @param clientKeyName The name of your client private key file + * @param samplingFeatureUUID The sampling feature UUID * @param sendEveryX Interval (in units of the logging interval) between * attempted data transmissions. NOTE: not implemented by this publisher! + * + * @note The inputs to this are the **NAMES** of the certificate **files** + * as they are stored on you modem module, not the content of the + * certificates. */ - AWS_IoT_Publisher(Logger& baseLogger, Client* inClient, int sendEveryX = 1); + AWS_IoT_Publisher(Logger& baseLogger, Client* inClient, + const char* awsIoTEndpoint, const char* caCertName, + const char* clientCertName, const char* clientKeyName, + const char* samplingFeatureUUID, int sendEveryX = 1); /** * @brief Construct a new AWS IoT Core Publisher object * @@ -170,6 +166,34 @@ class AWS_IoT_Publisher : public dataPublisher { AWS_IoT_Publisher(Logger& baseLogger, Client* inClient, const char* awsIoTEndpoint, const char* samplingFeatureUUID, int sendEveryX = 1); + /** + * @brief Construct a new AWS IoT Core Publisher object + * + * @param baseLogger The logger supplying the data to be published + * @param inClient An Arduino client instance to use to print data to. + * Allows the use of any type of client and multiple clients tied to a + * single TinyGSM modem instance + * @param sendEveryX Interval (in units of the logging interval) between + * attempted data transmissions. NOTE: not implemented by this publisher! + */ + AWS_IoT_Publisher(Logger& baseLogger, Client* inClient, int sendEveryX = 1); + /** + * @brief Construct a new AWS IoT Core Publisher object + * + * @note If a client is never specified, the publisher will attempt to + * create and use a client on a LoggerModem instance tied to the attached + * logger. + * + * @param baseLogger The logger supplying the data to be published + * @param sendEveryX Interval (in units of the logging interval) between + * attempted data transmissions. NOTE: not implemented by this publisher! + */ + explicit AWS_IoT_Publisher(Logger& baseLogger, int sendEveryX = 1); + /** + * @brief Construct a new AWS IoT Core Publisher object with no members + * initialized. + */ + AWS_IoT_Publisher(); /** * @brief Destroy the AWS IoT Core Publisher object */ From 36ebd4ecb4df4725295e26a5b597f12a80db7609 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Wed, 4 Mar 2026 17:28:48 -0500 Subject: [PATCH 441/533] Extract method Signed-off-by: Sara Damiano --- src/modems/SodaqUBeeR410M.cpp | 40 ++++++++++++++++------------------- src/modems/SodaqUBeeR410M.h | 14 ++++++++++++ 2 files changed, 32 insertions(+), 22 deletions(-) diff --git a/src/modems/SodaqUBeeR410M.cpp b/src/modems/SodaqUBeeR410M.cpp index 3d9280cef..8fe1c9e0f 100644 --- a/src/modems/SodaqUBeeR410M.cpp +++ b/src/modems/SodaqUBeeR410M.cpp @@ -113,18 +113,7 @@ bool SodaqUBeeR410M::modemWakeFxn() { // The baud rate setting is NOT saved to non-volatile memory, so it must // be changed every time after loosing power. #if F_CPU == 8000000L - if (_powerPin >= 0) { - MS_DBG(F("Waiting for UART to become active and requesting a " - "slower baud rate.")); - delay(_max_at_response_time_ms + - 250); // Must wait for UART port to become active - _modemSerial->begin(115200); - gsmModem.setBaud(9600); - _modemSerial->end(); - _modemSerial->begin(9600); - gsmModem.sendAT(GF("E0")); - gsmModem.waitResponse(); - } + if (_powerPin >= 0) { configureLowBaudRate(); } #endif return true; } else { @@ -159,16 +148,7 @@ bool SodaqUBeeR410M::modemHardReset() { delay(_resetPulse_ms); digitalWrite(_modemResetPin, !_resetLevel); #if F_CPU == 8000000L - MS_DBG(F("Waiting for UART to become active and requesting a slower " - "baud rate.")); - delay(_max_at_response_time_ms + - 250); // Must wait for UART port to become active - _modemSerial->begin(115200); - gsmModem.setBaud(9600); - _modemSerial->end(); - _modemSerial->begin(9600); - gsmModem.sendAT(GF("E0")); - gsmModem.waitResponse(); + configureLowBaudRate(); #endif return gsmModem.init(); } else { @@ -187,4 +167,20 @@ bool SodaqUBeeR410M::extraModemSetup() { return success; } + +#if F_CPU == 8000000L +void SodaqUBeeR410M::configureLowBaudRate() { + MS_DBG(F("Waiting for UART to become active and requesting a slower " + "baud rate.")); + delay(_max_at_response_time_ms + + 250); // Must wait for UART port to become active + _modemSerial->begin(115200); + gsmModem.setBaud(9600); + _modemSerial->end(); + _modemSerial->begin(9600); + gsmModem.sendAT(GF("E0")); + gsmModem.waitResponse(); +} +#endif + // cSpell:ignore UGPIOC diff --git a/src/modems/SodaqUBeeR410M.h b/src/modems/SodaqUBeeR410M.h index 48a7cfbf3..16aff8677 100644 --- a/src/modems/SodaqUBeeR410M.h +++ b/src/modems/SodaqUBeeR410M.h @@ -355,7 +355,21 @@ class SodaqUBeeR410M : public loggerModem { private: const char* _apn; ///< Internal reference to the cellular APN + +#if F_CPU == 8000000L || defined(DOXYGEN) + /** + * @brief Configure modem to use a lower baud rate (9600) for slow + * processors. + * + * This helper method encapsulates the baud rate switching logic needed for + * F_CPU == 8000000L to slow down the R4/N4's default 115200 baud rate. The + * baud rate setting is NOT saved to non-volatile memory, so it must be + * changed every time after losing power. + */ + void configureLowBaudRate(); +#endif }; + /**@}*/ #endif // SRC_MODEMS_SODAQUBEER410M_H_ From 62591e64bf11e6d1348c8904ca5df69fc129f0ee Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Wed, 4 Mar 2026 17:37:53 -0500 Subject: [PATCH 442/533] Reorder delegating constructors Signed-off-by: Sara Damiano --- src/publishers/DreamHostPublisher.cpp | 25 ++++--- src/publishers/DreamHostPublisher.h | 30 ++++---- .../MonitorMyWatershedPublisher.cpp | 70 +++++++++---------- src/publishers/MonitorMyWatershedPublisher.h | 62 ++++++++-------- src/publishers/S3PresignedPublisher.cpp | 4 +- src/publishers/S3PresignedPublisher.h | 8 +-- src/publishers/ThingSpeakPublisher.cpp | 24 +++---- src/publishers/ThingSpeakPublisher.h | 56 +++++++-------- src/publishers/UbidotsPublisher.cpp | 24 +++---- src/publishers/UbidotsPublisher.h | 52 +++++++------- 10 files changed, 175 insertions(+), 180 deletions(-) diff --git a/src/publishers/DreamHostPublisher.cpp b/src/publishers/DreamHostPublisher.cpp index 0ccacded7..f8e6c6af8 100644 --- a/src/publishers/DreamHostPublisher.cpp +++ b/src/publishers/DreamHostPublisher.cpp @@ -22,28 +22,27 @@ const char* DreamHostPublisher::loggerTag = "?LoggerID="; const char* DreamHostPublisher::timestampTagDH = "&Loggertime="; // Constructors -// Primary constructor with Client parameter +// Primary constructor with all parameters DreamHostPublisher::DreamHostPublisher(Logger& baseLogger, Client* inClient, - int sendEveryX) - : dataPublisher(baseLogger, inClient, sendEveryX) {} + const char* dhUrl, int sendEveryX) + : DreamHostPublisher(baseLogger, inClient, sendEveryX) { + if (dhUrl) setDreamHostPortalRX(dhUrl); +} -// Default constructor (base class initialization) -DreamHostPublisher::DreamHostPublisher() : dataPublisher() {} // Delegating constructors -DreamHostPublisher::DreamHostPublisher(Logger& baseLogger, int sendEveryX) - : DreamHostPublisher(baseLogger, static_cast(nullptr), - sendEveryX) {} +DreamHostPublisher::DreamHostPublisher(Logger& baseLogger, Client* inClient, + int sendEveryX) + : dataPublisher(baseLogger, inClient, sendEveryX) {} DreamHostPublisher::DreamHostPublisher(Logger& baseLogger, const char* dhUrl, int sendEveryX) : DreamHostPublisher(baseLogger, static_cast(nullptr), sendEveryX) { if (dhUrl) setDreamHostPortalRX(dhUrl); } -DreamHostPublisher::DreamHostPublisher(Logger& baseLogger, Client* inClient, - const char* dhUrl, int sendEveryX) - : DreamHostPublisher(baseLogger, inClient, sendEveryX) { - if (dhUrl) setDreamHostPortalRX(dhUrl); -} +DreamHostPublisher::DreamHostPublisher(Logger& baseLogger, int sendEveryX) + : DreamHostPublisher(baseLogger, static_cast(nullptr), + sendEveryX) {} +DreamHostPublisher::DreamHostPublisher() : dataPublisher() {} // Functions for private SWRC server diff --git a/src/publishers/DreamHostPublisher.h b/src/publishers/DreamHostPublisher.h index f289ee521..fd40c427f 100644 --- a/src/publishers/DreamHostPublisher.h +++ b/src/publishers/DreamHostPublisher.h @@ -47,22 +47,19 @@ class DreamHostPublisher : public dataPublisher { public: // Constructors - /** - * @brief Construct a new DreamHost Publisher object with no members set. - */ - DreamHostPublisher(); /** * @brief Construct a new DreamHost Publisher object * - * @note If a client is never specified, the publisher will attempt to - * create and use a client on a LoggerModem instance tied to the attached - * logger. - * * @param baseLogger The logger supplying the data to be published + * @param inClient An Arduino client instance to use to print data to. + * Allows the use of any type of client and multiple clients tied to a + * single TinyGSM modem instance + * @param dhUrl The URL for sending data to DreamHost * @param sendEveryX Interval (in units of the logging interval) between * attempted data transmissions. NOTE: not implemented by this publisher! */ - explicit DreamHostPublisher(Logger& baseLogger, int sendEveryX = 1); + DreamHostPublisher(Logger& baseLogger, Client* inClient, const char* dhUrl, + int sendEveryX = 1); /** * @brief Construct a new DreamHost Publisher object * @@ -88,16 +85,19 @@ class DreamHostPublisher : public dataPublisher { /** * @brief Construct a new DreamHost Publisher object * + * @note If a client is never specified, the publisher will attempt to + * create and use a client on a LoggerModem instance tied to the attached + * logger. + * * @param baseLogger The logger supplying the data to be published - * @param inClient An Arduino client instance to use to print data to. - * Allows the use of any type of client and multiple clients tied to a - * single TinyGSM modem instance - * @param dhUrl The URL for sending data to DreamHost * @param sendEveryX Interval (in units of the logging interval) between * attempted data transmissions. NOTE: not implemented by this publisher! */ - DreamHostPublisher(Logger& baseLogger, Client* inClient, const char* dhUrl, - int sendEveryX = 1); + explicit DreamHostPublisher(Logger& baseLogger, int sendEveryX = 1); + /** + * @brief Construct a new DreamHost Publisher object with no members set. + */ + DreamHostPublisher(); /** * @brief Destroy the DreamHost Publisher object */ diff --git a/src/publishers/MonitorMyWatershedPublisher.cpp b/src/publishers/MonitorMyWatershedPublisher.cpp index ac5677de5..605e2a365 100644 --- a/src/publishers/MonitorMyWatershedPublisher.cpp +++ b/src/publishers/MonitorMyWatershedPublisher.cpp @@ -31,60 +31,56 @@ const char* MonitorMyWatershedPublisher::timestampTag = "\",\"timestamp\":"; // Constructors -// Primary constructor with client -MonitorMyWatershedPublisher::MonitorMyWatershedPublisher(Logger& baseLogger, - Client* inClient, - int sendEveryX) - : dataPublisher(baseLogger, inClient, sendEveryX) { - _logBuffer.setNumVariables(_baseLogger->getArrayVarCount()); - setHost("monitormywatershed.org"); - setPath("/api/data-stream/"); - setPort(80); -} - -// Delegating constructors -MonitorMyWatershedPublisher::MonitorMyWatershedPublisher() : dataPublisher() { - // NOTE: _logBuffer is not initialized here because _baseLogger is null - // Must call begin(Logger&, ...) before use to properly initialize - // _logBuffer - setHost("monitormywatershed.org"); - setPath("/api/data-stream/"); - setPort(80); -} -MonitorMyWatershedPublisher::MonitorMyWatershedPublisher(Logger& baseLogger, - int sendEveryX) - : MonitorMyWatershedPublisher(baseLogger, static_cast(nullptr), - sendEveryX) {} - +// Primary constructor with all parameters MonitorMyWatershedPublisher::MonitorMyWatershedPublisher( - Logger& baseLogger, const char* registrationToken, + Logger& baseLogger, Client* inClient, const char* registrationToken, const char* samplingFeatureUUID, int sendEveryX) - : MonitorMyWatershedPublisher(baseLogger, static_cast(nullptr), - sendEveryX) { + : MonitorMyWatershedPublisher(baseLogger, inClient, sendEveryX) { if (registrationToken) setToken(registrationToken); if (samplingFeatureUUID) _baseLogger->setSamplingFeatureUUID(samplingFeatureUUID); } -// Delegating constructor -MonitorMyWatershedPublisher::MonitorMyWatershedPublisher( - Logger& baseLogger, const char* registrationToken, int sendEveryX) - : MonitorMyWatershedPublisher(baseLogger, registrationToken, nullptr, - sendEveryX) {} -// Delegating constructor + +// Delegating constructors MonitorMyWatershedPublisher::MonitorMyWatershedPublisher( - Logger& baseLogger, Client* inClient, const char* registrationToken, + Logger& baseLogger, const char* registrationToken, const char* samplingFeatureUUID, int sendEveryX) - : MonitorMyWatershedPublisher(baseLogger, inClient, sendEveryX) { + : MonitorMyWatershedPublisher(baseLogger, static_cast(nullptr), + sendEveryX) { if (registrationToken) setToken(registrationToken); if (samplingFeatureUUID) _baseLogger->setSamplingFeatureUUID(samplingFeatureUUID); } -// Delegating constructor MonitorMyWatershedPublisher::MonitorMyWatershedPublisher( Logger& baseLogger, Client* inClient, const char* registrationToken, int sendEveryX) : MonitorMyWatershedPublisher(baseLogger, inClient, registrationToken, nullptr, sendEveryX) {} +MonitorMyWatershedPublisher::MonitorMyWatershedPublisher(Logger& baseLogger, + Client* inClient, + int sendEveryX) + : dataPublisher(baseLogger, inClient, sendEveryX) { + _logBuffer.setNumVariables(_baseLogger->getArrayVarCount()); + setHost("monitormywatershed.org"); + setPath("/api/data-stream/"); + setPort(80); +} +MonitorMyWatershedPublisher::MonitorMyWatershedPublisher( + Logger& baseLogger, const char* registrationToken, int sendEveryX) + : MonitorMyWatershedPublisher(baseLogger, registrationToken, nullptr, + sendEveryX) {} +MonitorMyWatershedPublisher::MonitorMyWatershedPublisher(Logger& baseLogger, + int sendEveryX) + : MonitorMyWatershedPublisher(baseLogger, static_cast(nullptr), + sendEveryX) {} +MonitorMyWatershedPublisher::MonitorMyWatershedPublisher() : dataPublisher() { + // NOTE: _logBuffer is not initialized here because _baseLogger is null + // Must call begin(Logger&, ...) before use to properly initialize + // _logBuffer + setHost("monitormywatershed.org"); + setPath("/api/data-stream/"); + setPort(80); +} // Returns the data destination String MonitorMyWatershedPublisher::getHost() { diff --git a/src/publishers/MonitorMyWatershedPublisher.h b/src/publishers/MonitorMyWatershedPublisher.h index 69714b711..aab08c863 100644 --- a/src/publishers/MonitorMyWatershedPublisher.h +++ b/src/publishers/MonitorMyWatershedPublisher.h @@ -48,24 +48,6 @@ class MonitorMyWatershedPublisher : public dataPublisher { public: // Constructors - /** - * @brief Construct a new Monitor My Watershed Publisher object with only - * default values for the host, path, and port set. - */ - MonitorMyWatershedPublisher(); - /** - * @brief Construct a new Monitor My Watershed Publisher object - * - * @note If a client is never specified, the publisher will attempt to - * create and use a client on a LoggerModem instance tied to the attached - * logger. - * - * @param baseLogger The logger supplying the data to be published - * @param sendEveryX Interval (in units of the logging interval) between - * attempted data transmissions. - */ - explicit MonitorMyWatershedPublisher(Logger& baseLogger, - int sendEveryX = 1); /** * @brief Construct a new Monitor My Watershed Publisher object * @@ -73,11 +55,17 @@ class MonitorMyWatershedPublisher : public dataPublisher { * @param inClient An Arduino client instance to use to print data to. * Allows the use of any type of client and multiple clients tied to a * single TinyGSM modem instance + * @param registrationToken The registration token for the site on Monitor + * My Watershed. + * @param samplingFeatureUUID The sampling feature UUID for the site on + * Monitor My Watershed. * @param sendEveryX Interval (in units of the logging interval) between * attempted data transmissions. */ MonitorMyWatershedPublisher(Logger& baseLogger, Client* inClient, - int sendEveryX = 1); + const char* registrationToken, + const char* samplingFeatureUUID, + int sendEveryX = 1); /** * @brief Construct a new Monitor My Watershed Publisher object * @@ -97,12 +85,15 @@ class MonitorMyWatershedPublisher : public dataPublisher { * @brief Construct a new Monitor My Watershed Publisher object * * @param baseLogger The logger supplying the data to be published + * @param inClient An Arduino client instance to use to print data to. + * Allows the use of any type of client and multiple clients tied to a + * single TinyGSM modem instance * @param registrationToken The registration token for the site on Monitor * My Watershed. * @param sendEveryX Interval (in units of the logging interval) between * attempted data transmissions. */ - MonitorMyWatershedPublisher(Logger& baseLogger, + MonitorMyWatershedPublisher(Logger& baseLogger, Client* inClient, const char* registrationToken, int sendEveryX = 1); /** @@ -112,32 +103,41 @@ class MonitorMyWatershedPublisher : public dataPublisher { * @param inClient An Arduino client instance to use to print data to. * Allows the use of any type of client and multiple clients tied to a * single TinyGSM modem instance - * @param registrationToken The registration token for the site on Monitor - * My Watershed. - * @param samplingFeatureUUID The sampling feature UUID for the site on - * Monitor My Watershed. * @param sendEveryX Interval (in units of the logging interval) between * attempted data transmissions. */ MonitorMyWatershedPublisher(Logger& baseLogger, Client* inClient, - const char* registrationToken, - const char* samplingFeatureUUID, - int sendEveryX = 1); + int sendEveryX = 1); /** * @brief Construct a new Monitor My Watershed Publisher object * * @param baseLogger The logger supplying the data to be published - * @param inClient An Arduino client instance to use to print data to. - * Allows the use of any type of client and multiple clients tied to a - * single TinyGSM modem instance * @param registrationToken The registration token for the site on Monitor * My Watershed. * @param sendEveryX Interval (in units of the logging interval) between * attempted data transmissions. */ - MonitorMyWatershedPublisher(Logger& baseLogger, Client* inClient, + MonitorMyWatershedPublisher(Logger& baseLogger, const char* registrationToken, int sendEveryX = 1); + /** + * @brief Construct a new Monitor My Watershed Publisher object + * + * @note If a client is never specified, the publisher will attempt to + * create and use a client on a LoggerModem instance tied to the attached + * logger. + * + * @param baseLogger The logger supplying the data to be published + * @param sendEveryX Interval (in units of the logging interval) between + * attempted data transmissions. + */ + explicit MonitorMyWatershedPublisher(Logger& baseLogger, + int sendEveryX = 1); + /** + * @brief Construct a new Monitor My Watershed Publisher object with only + * default values for the host, path, and port set. + */ + MonitorMyWatershedPublisher(); /** * @brief Destroy the Monitor My Watershed Publisher object */ diff --git a/src/publishers/S3PresignedPublisher.cpp b/src/publishers/S3PresignedPublisher.cpp index 88e41ed12..4cc79b190 100644 --- a/src/publishers/S3PresignedPublisher.cpp +++ b/src/publishers/S3PresignedPublisher.cpp @@ -18,7 +18,7 @@ const char* S3PresignedPublisher::contentLengthHeader = "\r\nContent-Length: "; const char* S3PresignedPublisher::contentTypeHeader = "\r\nContent-Type: "; // Constructors -// Primary constructor with all parameters +// Primary constructor with certificate S3PresignedPublisher::S3PresignedPublisher(Logger& baseLogger, const char* caCertName, String (*getUrlFxn)(String), @@ -31,7 +31,6 @@ S3PresignedPublisher::S3PresignedPublisher(Logger& baseLogger, } // Delegating constructors -S3PresignedPublisher::S3PresignedPublisher() : dataPublisher() {} S3PresignedPublisher::S3PresignedPublisher(Logger& baseLogger, Client* inClient, String (*getUrlFxn)(String), String (*getFileNameFxn)(), @@ -40,6 +39,7 @@ S3PresignedPublisher::S3PresignedPublisher(Logger& baseLogger, Client* inClient, getUrlFxn, getFileNameFxn, sendEveryX) { if (inClient) _inClient = inClient; } +S3PresignedPublisher::S3PresignedPublisher() : dataPublisher() {} void S3PresignedPublisher::setPort(int port) { diff --git a/src/publishers/S3PresignedPublisher.h b/src/publishers/S3PresignedPublisher.h index e14c412f9..d5fefcf13 100644 --- a/src/publishers/S3PresignedPublisher.h +++ b/src/publishers/S3PresignedPublisher.h @@ -134,10 +134,6 @@ class S3PresignedPublisher : public dataPublisher { public: // Constructors - /** - * @brief Construct a new S3 Publisher object with no members set. - */ - S3PresignedPublisher(); /** * @brief Construct a new S3 Publisher object * @@ -173,6 +169,10 @@ class S3PresignedPublisher : public dataPublisher { String (*getUrlFxn)(String) = nullptr, String (*getFileNameFxn)() = nullptr, int sendEveryX = 1); + /** + * @brief Construct a new S3 Publisher object with no members set. + */ + S3PresignedPublisher(); /** * @brief Destroy the S3 Publisher object */ diff --git a/src/publishers/ThingSpeakPublisher.cpp b/src/publishers/ThingSpeakPublisher.cpp index fb0110267..357bd38cb 100644 --- a/src/publishers/ThingSpeakPublisher.cpp +++ b/src/publishers/ThingSpeakPublisher.cpp @@ -42,18 +42,6 @@ ThingSpeakPublisher::ThingSpeakPublisher(Logger& baseLogger, Client* inClient, } // Delegating constructors -ThingSpeakPublisher::ThingSpeakPublisher() : dataPublisher() {} -ThingSpeakPublisher::ThingSpeakPublisher(Logger& baseLogger, int sendEveryX) - : ThingSpeakPublisher( - baseLogger, nullptr, static_cast(nullptr), - static_cast(nullptr), static_cast(nullptr), - static_cast(nullptr), sendEveryX) {} -ThingSpeakPublisher::ThingSpeakPublisher(Logger& baseLogger, Client* inClient, - int sendEveryX) - : ThingSpeakPublisher( - baseLogger, inClient, static_cast(nullptr), - static_cast(nullptr), static_cast(nullptr), - static_cast(nullptr), sendEveryX) {} ThingSpeakPublisher::ThingSpeakPublisher(Logger& baseLogger, const char* thingSpeakClientName, const char* thingSpeakMQTTUser, @@ -63,6 +51,18 @@ ThingSpeakPublisher::ThingSpeakPublisher(Logger& baseLogger, : ThingSpeakPublisher(baseLogger, nullptr, thingSpeakClientName, thingSpeakMQTTUser, thingSpeakMQTTPassword, thingSpeakChannelID, sendEveryX) {} +ThingSpeakPublisher::ThingSpeakPublisher(Logger& baseLogger, Client* inClient, + int sendEveryX) + : ThingSpeakPublisher( + baseLogger, inClient, static_cast(nullptr), + static_cast(nullptr), static_cast(nullptr), + static_cast(nullptr), sendEveryX) {} +ThingSpeakPublisher::ThingSpeakPublisher(Logger& baseLogger, int sendEveryX) + : ThingSpeakPublisher( + baseLogger, nullptr, static_cast(nullptr), + static_cast(nullptr), static_cast(nullptr), + static_cast(nullptr), sendEveryX) {} +ThingSpeakPublisher::ThingSpeakPublisher() : dataPublisher() {} void ThingSpeakPublisher::setMQTTClient(const char* thingSpeakClientName) { diff --git a/src/publishers/ThingSpeakPublisher.h b/src/publishers/ThingSpeakPublisher.h index 66e431dd9..ea11e2a57 100644 --- a/src/publishers/ThingSpeakPublisher.h +++ b/src/publishers/ThingSpeakPublisher.h @@ -57,23 +57,6 @@ class ThingSpeakPublisher : public dataPublisher { public: // Constructors - /** - * @brief Construct a new ThingSpeak Publisher object with no members - * initialized. - */ - ThingSpeakPublisher(); - /** - * @brief Construct a new ThingSpeak Publisher object - * - * @note If a client is never specified, the publisher will attempt to - * create and use a client on a LoggerModem instance tied to the attached - * logger. - * - * @param baseLogger The logger supplying the data to be published - * @param sendEveryX Interval (in units of the logging interval) between - * attempted data transmissions. NOTE: not implemented by this publisher! - */ - explicit ThingSpeakPublisher(Logger& baseLogger, int sendEveryX = 1); /** * @brief Construct a new ThingSpeak Publisher object * @@ -81,11 +64,20 @@ class ThingSpeakPublisher : public dataPublisher { * @param inClient An Arduino client instance to use to print data to. * Allows the use of any type of client and multiple clients tied to a * single TinyGSM modem instance + * @param thingSpeakClientName The client name for your MQTT device. This is + * probably the same as your MQTT device's user name. + * @param thingSpeakMQTTUser The user name for your MQTT device. This is + * probably the same as your MQTT device's client name. + * @param thingSpeakMQTTPassword The password for your MQTT device. + * @param thingSpeakChannelID The numeric channel id for your channel. * @param sendEveryX Interval (in units of the logging interval) between * attempted data transmissions. NOTE: not implemented by this publisher! */ ThingSpeakPublisher(Logger& baseLogger, Client* inClient, - int sendEveryX = 1); + const char* thingSpeakClientName, + const char* thingSpeakMQTTUser, + const char* thingSpeakMQTTPassword, + const char* thingSpeakChannelID, int sendEveryX = 1); /** * @brief Construct a new ThingSpeak Publisher object * @@ -110,20 +102,28 @@ class ThingSpeakPublisher : public dataPublisher { * @param inClient An Arduino client instance to use to print data to. * Allows the use of any type of client and multiple clients tied to a * single TinyGSM modem instance - * @param thingSpeakClientName The client name for your MQTT device. This is - * probably the same as your MQTT device's user name. - * @param thingSpeakMQTTUser The user name for your MQTT device. This is - * probably the same as your MQTT device's client name. - * @param thingSpeakMQTTPassword The password for your MQTT device. - * @param thingSpeakChannelID The numeric channel id for your channel. * @param sendEveryX Interval (in units of the logging interval) between * attempted data transmissions. NOTE: not implemented by this publisher! */ ThingSpeakPublisher(Logger& baseLogger, Client* inClient, - const char* thingSpeakClientName, - const char* thingSpeakMQTTUser, - const char* thingSpeakMQTTPassword, - const char* thingSpeakChannelID, int sendEveryX = 1); + int sendEveryX = 1); + /** + * @brief Construct a new ThingSpeak Publisher object + * + * @note If a client is never specified, the publisher will attempt to + * create and use a client on a LoggerModem instance tied to the attached + * logger. + * + * @param baseLogger The logger supplying the data to be published + * @param sendEveryX Interval (in units of the logging interval) between + * attempted data transmissions. NOTE: not implemented by this publisher! + */ + explicit ThingSpeakPublisher(Logger& baseLogger, int sendEveryX = 1); + /** + * @brief Construct a new ThingSpeak Publisher object with no members + * initialized. + */ + ThingSpeakPublisher(); /** * @brief Destroy the ThingSpeak Publisher object */ diff --git a/src/publishers/UbidotsPublisher.cpp b/src/publishers/UbidotsPublisher.cpp index 6fb66569e..65c91555d 100644 --- a/src/publishers/UbidotsPublisher.cpp +++ b/src/publishers/UbidotsPublisher.cpp @@ -32,7 +32,15 @@ const char* UbidotsPublisher::payload = "{"; // Constructors -// Primary constructor with authentication parameters +// Primary constructor with all authentication parameters and client +UbidotsPublisher::UbidotsPublisher(Logger& baseLogger, Client* inClient, + const char* authenticationToken, + const char* deviceID, int sendEveryX) + : UbidotsPublisher(baseLogger, authenticationToken, deviceID, sendEveryX) { + if (inClient) _inClient = inClient; +} + +// Delegating constructors UbidotsPublisher::UbidotsPublisher(Logger& baseLogger, const char* authenticationToken, const char* deviceID, int sendEveryX) @@ -41,22 +49,14 @@ UbidotsPublisher::UbidotsPublisher(Logger& baseLogger, if (deviceID) _baseLogger->setSamplingFeatureUUID(deviceID); MS_DBG(F("dataPublisher object created")); } - -// Delegating constructors -UbidotsPublisher::UbidotsPublisher() : dataPublisher() {} -UbidotsPublisher::UbidotsPublisher(Logger& baseLogger, int sendEveryX) - : UbidotsPublisher(baseLogger, nullptr, nullptr, sendEveryX) {} UbidotsPublisher::UbidotsPublisher(Logger& baseLogger, Client* inClient, int sendEveryX) : UbidotsPublisher(baseLogger, nullptr, nullptr, sendEveryX) { if (inClient) _inClient = inClient; } -UbidotsPublisher::UbidotsPublisher(Logger& baseLogger, Client* inClient, - const char* authenticationToken, - const char* deviceID, int sendEveryX) - : UbidotsPublisher(baseLogger, authenticationToken, deviceID, sendEveryX) { - if (inClient) _inClient = inClient; -} +UbidotsPublisher::UbidotsPublisher(Logger& baseLogger, int sendEveryX) + : UbidotsPublisher(baseLogger, nullptr, nullptr, sendEveryX) {} +UbidotsPublisher::UbidotsPublisher() : dataPublisher() {} void UbidotsPublisher::setToken(const char* authenticationToken) { diff --git a/src/publishers/UbidotsPublisher.h b/src/publishers/UbidotsPublisher.h index 2cee53aec..85ddc6b0b 100644 --- a/src/publishers/UbidotsPublisher.h +++ b/src/publishers/UbidotsPublisher.h @@ -46,22 +46,6 @@ class UbidotsPublisher : public dataPublisher { public: // Constructors - /** - * @brief Construct a new Ubidots Publisher object with no members set. - */ - UbidotsPublisher(); - /** - * @brief Construct a new Ubidots Publisher object - * - * @note If a client is never specified, the publisher will attempt to - * create and use a client on a LoggerModem instance tied to the attached - * logger. - * - * @param baseLogger The logger supplying the data to be published - * @param sendEveryX Interval (in units of the logging interval) between - * attempted data transmissions. NOTE: not implemented by this publisher! - */ - explicit UbidotsPublisher(Logger& baseLogger, int sendEveryX = 1); /** * @brief Construct a new Ubidots Publisher object * @@ -69,10 +53,18 @@ class UbidotsPublisher : public dataPublisher { * @param inClient An Arduino client instance to use to print data to. * Allows the use of any type of client and multiple clients tied to a * single TinyGSM modem instance + * @param authenticationToken The authentication token from Ubidots, either + * the Organization's Integration Token (under Users > Organization menu, + * visible by Admin only) OR the STEM User's Device Token (under the + * specific device's setup panel). + * @param deviceID The device API Label from Ubidots, derived from the + * user-specified device name. * @param sendEveryX Interval (in units of the logging interval) between * attempted data transmissions. NOTE: not implemented by this publisher! */ - UbidotsPublisher(Logger& baseLogger, Client* inClient, int sendEveryX = 1); + UbidotsPublisher(Logger& baseLogger, Client* inClient, + const char* authenticationToken, const char* deviceID, + int sendEveryX = 1); /** * @brief Construct a new Ubidots Publisher object * @@ -95,18 +87,26 @@ class UbidotsPublisher : public dataPublisher { * @param inClient An Arduino client instance to use to print data to. * Allows the use of any type of client and multiple clients tied to a * single TinyGSM modem instance - * @param authenticationToken The authentication token from Ubidots, either - * the Organization's Integration Token (under Users > Organization menu, - * visible by Admin only) OR the STEM User's Device Token (under the - * specific device's setup panel). - * @param deviceID The device API Label from Ubidots, derived from the - * user-specified device name. * @param sendEveryX Interval (in units of the logging interval) between * attempted data transmissions. NOTE: not implemented by this publisher! */ - UbidotsPublisher(Logger& baseLogger, Client* inClient, - const char* authenticationToken, const char* deviceID, - int sendEveryX = 1); + UbidotsPublisher(Logger& baseLogger, Client* inClient, int sendEveryX = 1); + /** + * @brief Construct a new Ubidots Publisher object + * + * @note If a client is never specified, the publisher will attempt to + * create and use a client on a LoggerModem instance tied to the attached + * logger. + * + * @param baseLogger The logger supplying the data to be published + * @param sendEveryX Interval (in units of the logging interval) between + * attempted data transmissions. NOTE: not implemented by this publisher! + */ + explicit UbidotsPublisher(Logger& baseLogger, int sendEveryX = 1); + /** + * @brief Construct a new Ubidots Publisher object with no members set. + */ + UbidotsPublisher(); /** * @brief Destroy the Ubidots Publisher object */ From 427fd29bb3033e26bb9d8a685485c81270e49a40 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Wed, 4 Mar 2026 17:42:33 -0500 Subject: [PATCH 443/533] More constructor rearrangements Signed-off-by: Sara Damiano --- src/VariableArray.cpp | 16 +++++++++------- src/VariableArray.h | 18 +++++++++--------- src/VariableBase.cpp | 12 ++++++------ src/publishers/UbidotsPublisher.cpp | 10 ++++++---- 4 files changed, 30 insertions(+), 26 deletions(-) diff --git a/src/VariableArray.cpp b/src/VariableArray.cpp index db4c2cfec..61fe576d0 100644 --- a/src/VariableArray.cpp +++ b/src/VariableArray.cpp @@ -12,19 +12,21 @@ // Constructors -VariableArray::VariableArray() {} -VariableArray::VariableArray(uint8_t variableCount, Variable* variableList[]) - : arrayOfVars(variableList), - _variableCount(variableCount) { - _sensorCount = getSensorCount(); -} -// Delegating constructor +// Primary constructor with all parameters VariableArray::VariableArray(uint8_t variableCount, Variable* variableList[], const char* uuids[]) : VariableArray(variableCount, variableList) { matchUUIDs(uuids); } +// Delegating constructors +VariableArray::VariableArray(uint8_t variableCount, Variable* variableList[]) + : arrayOfVars(variableList), + _variableCount(variableCount) { + _sensorCount = getSensorCount(); +} +VariableArray::VariableArray() {} + void VariableArray::begin(uint8_t variableCount, Variable* variableList[], const char* uuids[]) { diff --git a/src/VariableArray.h b/src/VariableArray.h index b0f4f77c4..190ae5024 100644 --- a/src/VariableArray.h +++ b/src/VariableArray.h @@ -77,29 +77,29 @@ class VariableArray { public: // Constructors - /** - * @brief Construct a new Variable Array object - */ - VariableArray(); /** * @brief Construct a new Variable Array object * * @param variableCount The number of variables in the array * @param variableList An array of pointers to variable objects. The * pointers may be to calculated or measured variable objects. + * @param uuids An array of UUIDs. These are linked 1-to-1 with the + * variables by array position. */ - VariableArray(uint8_t variableCount, Variable* variableList[]); + VariableArray(uint8_t variableCount, Variable* variableList[], + const char* uuids[]); /** * @brief Construct a new Variable Array object * * @param variableCount The number of variables in the array * @param variableList An array of pointers to variable objects. The * pointers may be to calculated or measured variable objects. - * @param uuids An array of UUIDs. These are linked 1-to-1 with the - * variables by array position. */ - VariableArray(uint8_t variableCount, Variable* variableList[], - const char* uuids[]); + VariableArray(uint8_t variableCount, Variable* variableList[]); + /** + * @brief Construct a new Variable Array object + */ + VariableArray(); /** * @brief Destroy the Variable Array object - no action taken. */ diff --git a/src/VariableBase.cpp b/src/VariableBase.cpp index 8d497c4c5..7747ec31a 100644 --- a/src/VariableBase.cpp +++ b/src/VariableBase.cpp @@ -15,9 +15,9 @@ // The class and functions for interfacing with a specific variable. // ============================================================================ -// Primary constructors with UUID parameter -// The constructor for a measured variable - that is, one whose values are -// updated by a sensor. +// Primary constructors +// The constructor for a measured variable with UUID - that is, one whose values +// are updated by a sensor. Variable::Variable(Sensor* parentSense, uint8_t sensorVarNum, uint8_t decimalResolution, const char* varName, const char* varUnit, const char* varCode, const char* uuid) @@ -34,8 +34,8 @@ Variable::Variable(Sensor* parentSense, uint8_t sensorVarNum, if (parentSense) attachSensor(parentSense); } -// The constructor for a calculated variable - that is, one whose value is -// calculated by the calcFxn which returns a float. +// The constructor for a calculated variable with UUID - that is, one whose +// value is calculated by the calcFxn which returns a float. Variable::Variable(float (*calcFxn)(), uint8_t decimalResolution, const char* varName, const char* varUnit, const char* varCode, const char* uuid) @@ -62,7 +62,7 @@ Variable::Variable(float (*calcFxn)(), uint8_t decimalResolution, const char* varCode) : Variable(calcFxn, decimalResolution, varName, varUnit, varCode, nullptr) { } -// constructor with no arguments +// Default constructor with no arguments Variable::Variable() : isCalculated(true) {} diff --git a/src/publishers/UbidotsPublisher.cpp b/src/publishers/UbidotsPublisher.cpp index 65c91555d..573b74fd7 100644 --- a/src/publishers/UbidotsPublisher.cpp +++ b/src/publishers/UbidotsPublisher.cpp @@ -45,9 +45,12 @@ UbidotsPublisher::UbidotsPublisher(Logger& baseLogger, const char* authenticationToken, const char* deviceID, int sendEveryX) : dataPublisher(baseLogger, sendEveryX) { - if (authenticationToken) setToken(authenticationToken); - if (deviceID) _baseLogger->setSamplingFeatureUUID(deviceID); - MS_DBG(F("dataPublisher object created")); + if (authenticationToken && authenticationToken[0] != '\0') { + setToken(authenticationToken); + } + if (deviceID && deviceID[0] != '\0') { + _baseLogger->setSamplingFeatureUUID(deviceID); + } } UbidotsPublisher::UbidotsPublisher(Logger& baseLogger, Client* inClient, int sendEveryX) @@ -61,7 +64,6 @@ UbidotsPublisher::UbidotsPublisher() : dataPublisher() {} void UbidotsPublisher::setToken(const char* authenticationToken) { _authenticationToken = authenticationToken; - MS_DBG(F("Registration token set!")); } From 901f901045cb796fcf3874f434a4c1a2b2f00c0d Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Thu, 5 Mar 2026 10:45:50 -0500 Subject: [PATCH 444/533] Add warnings about client deletion Signed-off-by: Sara Damiano --- src/modems/LoggerModemMacros.h | 43 +++++++++++++++++++++++++++++++--- 1 file changed, 40 insertions(+), 3 deletions(-) diff --git a/src/modems/LoggerModemMacros.h b/src/modems/LoggerModemMacros.h index f18b4b41b..3f0e946b1 100644 --- a/src/modems/LoggerModemMacros.h +++ b/src/modems/LoggerModemMacros.h @@ -536,6 +536,7 @@ MS_MODEM_CREATE_NULL_SECURE_CLIENTS(specificModem, TinyGSMType) #endif /** + * @def MS_MODEM_DELETE_CLIENT * @brief Creates a deleteClient function for a specific modem subclass. * * @param specificModem The modem subclass @@ -543,40 +544,76 @@ * * @return The text of deleteClient function specific to a single modem * subclass. + * + * @warning CRITICAL: This function MUST only be called with Client* pointers + * that were created by the corresponding createClient() function. Passing a + * Client* created by createSecureClient() will cause undefined behavior. + * Always match create/delete pairs: + * - createClient() -> deleteClient() + * - createSecureClient() -> deleteSecureClient() + * + * @note Since RTTI is not available, runtime type checking cannot be performed. + * The caller is responsible for ensuring the correct delete function is used. */ #define MS_MODEM_DELETE_CLIENT(specificModem, TinyGSMType) \ void specificModem::deleteClient(Client* client) { \ if (client != nullptr) { \ + MS_DBG(F("deleteClient: Deleting client of type "), \ + F("GsmClient" #TinyGSMType)); \ + /* WARNING: This static_cast is safe ONLY if the client was */ \ + /* created by createClient(). Mismatched create/delete calls */ \ + /* will cause undefined behavior. */ \ TinyGsm##TinyGSMType::GsmClient##TinyGSMType* cast_pointer = \ static_cast( \ client); \ delete cast_pointer; \ + } else { \ + MS_DBG(F("deleteClient: Attempted to delete nullptr client")); \ } \ } /** * @def MS_MODEM_DELETE_SECURE_CLIENT - * @brief Creates a deleteClient function for a specific modem subclass. + * @brief Creates a deleteSecureClient function for a specific modem subclass. * * @param specificModem The modem subclass * @param TinyGSMType The type used for the TinyGSM modem * * @return The text of deleteSecureClient function specific to a single modem * subclass. + * + * @warning CRITICAL: This function MUST only be called with Client* pointers + * that were created by the corresponding createSecureClient() function. Passing + * a Client* created by createClient() will cause undefined behavior. Always + * match create/delete pairs: + * - createClient() -> deleteClient() + * - createSecureClient() -> deleteSecureClient() + * + * @note Since RTTI is not available, runtime type checking cannot be performed. + * The caller is responsible for ensuring the correct delete function is used. */ #if defined(TINY_GSM_MODEM_HAS_SSL) #define MS_MODEM_DELETE_SECURE_CLIENT(specificModem, TinyGSMType) \ void specificModem::deleteSecureClient(Client* client) { \ if (client != nullptr) { \ + MS_DBG(F("deleteSecureClient: Deleting client of type "), \ + F("GsmClientSecure" #TinyGSMType)); \ + /* WARNING: This static_cast is safe ONLY if the client was */ \ + /* created by createSecureClient(). Mismatched create/delete */ \ + /* calls will cause undefined behavior. */ \ TinyGsm##TinyGSMType::GsmClientSecure##TinyGSMType* cast_pointer = \ static_cast< \ TinyGsm##TinyGSMType::GsmClientSecure##TinyGSMType*>( \ client); \ delete cast_pointer; \ + } else { \ + MS_DBG(F("deleteSecureClient: Attempted to delete nullptr")); \ } \ } #else -#define MS_MODEM_DELETE_SECURE_CLIENT(specificModem, TinyGSMType) \ - void specificModem::deleteSecureClient(Client*) {} +#define MS_MODEM_DELETE_SECURE_CLIENT(specificModem, TinyGSMType) \ + void specificModem::deleteSecureClient(Client*) { \ + MS_DBG(F("deleteSecureClient: SSL not supported, no-op")); \ + } #endif /** From 31964979b6a1be0119b3e4d9d1a0fd39121f2e95 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Thu, 5 Mar 2026 10:46:26 -0500 Subject: [PATCH 445/533] Fix issues with sleep pin - not that it works, anyway Signed-off-by: Sara Damiano --- src/modems/Espressif.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/modems/Espressif.cpp b/src/modems/Espressif.cpp index 94c079541..4426c0949 100644 --- a/src/modems/Espressif.cpp +++ b/src/modems/Espressif.cpp @@ -57,7 +57,6 @@ bool Espressif::modemWakeFxn() { MS_DEEP_DBG( F("Power pin"), _powerPin, F("takes priority over reset pin, modem wakes on power on")); - digitalWrite(_modemSleepRqPin, !_wakeLevel); if (_modemSleepRqPin >= 0) { digitalWrite(_modemSleepRqPin, !_wakeLevel); } @@ -72,7 +71,9 @@ bool Espressif::modemWakeFxn() { digitalWrite(_modemResetPin, LOW); delay(_resetPulse_ms); digitalWrite(_modemResetPin, HIGH); - digitalWrite(_modemSleepRqPin, !_wakeLevel); + if (_modemSleepRqPin >= 0) { + digitalWrite(_modemSleepRqPin, !_wakeLevel); + } success &= ESPwaitForBoot(); if (_modemSleepRqPin >= 0) { digitalWrite(_modemSleepRqPin, _wakeLevel); From 08022a77d7e3145a54a8ec1f4e5eea8a2c656794 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Thu, 5 Mar 2026 10:47:06 -0500 Subject: [PATCH 446/533] Add warning about dumping buffer Signed-off-by: Sara Damiano --- src/publishers/MonitorMyWatershedPublisher.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/publishers/MonitorMyWatershedPublisher.cpp b/src/publishers/MonitorMyWatershedPublisher.cpp index 605e2a365..71edf4406 100644 --- a/src/publishers/MonitorMyWatershedPublisher.cpp +++ b/src/publishers/MonitorMyWatershedPublisher.cpp @@ -251,8 +251,10 @@ int16_t MonitorMyWatershedPublisher::publishData(Client* outClient, "variables in logger:"), _logBuffer.getNumVariables(), F("vs"), _baseLogger->getArrayVarCount()); - MS_DBG(F("Setting number of variables in log buffer to match number of " - "variables in logger. This will erase the buffer.")); + PRINTOUT( + F("Setting number of variables in log buffer to match number of " + "variables in logger.")); + PRINTOUT(F("THIS WILL ERASE THE BUFFER AND DELETE ANY UNSENT DATA!")); _logBuffer.setNumVariables(_baseLogger->getArrayVarCount()); } @@ -276,7 +278,7 @@ int16_t MonitorMyWatershedPublisher::publishData(Client* outClient, } } - if (_initialTransmissionsRemaining > 0) { + if (record >= 0 && _initialTransmissionsRemaining > 0) { _initialTransmissionsRemaining -= 1; } From 670204a38f9a066a3f95b56139be55f9c3da46ec Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Thu, 5 Mar 2026 10:47:21 -0500 Subject: [PATCH 447/533] check for finite value Signed-off-by: Sara Damiano --- src/VariableBase.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/VariableBase.h b/src/VariableBase.h index e92810418..b27bfc68b 100644 --- a/src/VariableBase.h +++ b/src/VariableBase.h @@ -418,7 +418,7 @@ class Variable { * @return The number of decimal places needed to represent the resolution */ static inline uint8_t floatResolutionToDecimalPlaces(float resolution) { - if (resolution <= 0.0f || isnan(resolution)) { + if (resolution <= 0.0f || isnan(resolution) || isinf(resolution)) { return 4; // Default to 4 decimal places for invalid input } From 1c5bdc4e40635cbc81ac6ffb874257dbc26905a2 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Thu, 5 Mar 2026 11:02:11 -0500 Subject: [PATCH 448/533] Fix compiler order warning Signed-off-by: Sara Damiano --- src/VariableBase.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/VariableBase.cpp b/src/VariableBase.cpp index 7747ec31a..99bc5c06d 100644 --- a/src/VariableBase.cpp +++ b/src/VariableBase.cpp @@ -21,11 +21,11 @@ Variable::Variable(Sensor* parentSense, uint8_t sensorVarNum, uint8_t decimalResolution, const char* varName, const char* varUnit, const char* varCode, const char* uuid) - : isCalculated(false), - parentSensor(nullptr), + : parentSensor(nullptr), + isCalculated(false), _currentValue(MS_INVALID_VALUE), - _sensorVarNum(sensorVarNum), - _calcFxn(nullptr) { + _calcFxn(nullptr), + _sensorVarNum(sensorVarNum) { if (uuid) setVarUUID(uuid); if (varCode) setVarCode(varCode); if (varUnit) setVarUnit(varUnit); @@ -39,8 +39,8 @@ Variable::Variable(Sensor* parentSense, uint8_t sensorVarNum, Variable::Variable(float (*calcFxn)(), uint8_t decimalResolution, const char* varName, const char* varUnit, const char* varCode, const char* uuid) - : isCalculated(false), - parentSensor(nullptr), + : parentSensor(nullptr), + isCalculated(false), _currentValue(MS_INVALID_VALUE), _calcFxn(nullptr) { if (uuid) setVarUUID(uuid); From fa65dae17d3df9abee20f0adb2b39b8c544cd473 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Thu, 5 Mar 2026 11:03:17 -0500 Subject: [PATCH 449/533] Change type of did_respond Signed-off-by: Sara Damiano --- src/publishers/MonitorMyWatershedPublisher.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/publishers/MonitorMyWatershedPublisher.cpp b/src/publishers/MonitorMyWatershedPublisher.cpp index 71edf4406..d1f9706c8 100644 --- a/src/publishers/MonitorMyWatershedPublisher.cpp +++ b/src/publishers/MonitorMyWatershedPublisher.cpp @@ -295,9 +295,9 @@ int16_t MonitorMyWatershedPublisher::publishData(Client* outClient, int16_t MonitorMyWatershedPublisher::flushDataBuffer(Client* outClient) { // Create a buffer for the portions of the request and response - char tempBuffer[37] = ""; - uint16_t did_respond = 0; - int16_t responseCode = 0; + char tempBuffer[37] = ""; + int16_t did_respond = 0; + int16_t responseCode = 0; // Early return if no records to send if (_logBuffer.getNumRecords() == 0) { @@ -411,7 +411,7 @@ int16_t MonitorMyWatershedPublisher::flushDataBuffer(Client* outClient) { memcpy(responseCode_char, tempBuffer + 9, 3); // Null terminate the string responseCode_char[3] = '\0'; - responseCode = atoi(responseCode_char); + responseCode = atoi(responseCode_char); PRINTOUT(F("\n-- Response Code --")); PRINTOUT(responseCode); } else { From f9d2399d24cb8d990d84057d4cd787185a4a3797 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Thu, 5 Mar 2026 13:15:31 -0500 Subject: [PATCH 450/533] Handle timezone issues for mktime fxn Signed-off-by: Sara Damiano --- src/ClockSupport.cpp | 59 +++++++++++++++++++++++++++- src/ClockSupport.h | 37 ++++++++++++++++- src/modems/LoggerModemMacros.h | 72 ++++++++++++++++++---------------- 3 files changed, 132 insertions(+), 36 deletions(-) diff --git a/src/ClockSupport.cpp b/src/ClockSupport.cpp index 0ea290d39..fef5d36d8 100644 --- a/src/ClockSupport.cpp +++ b/src/ClockSupport.cpp @@ -181,6 +181,8 @@ const uint32_t epochTime::leapSeconds[NUMBER_LEAP_SECONDS] = LEAP_SECONDS; // Initialize the processor epoch epochStart loggerClock::_core_epoch = epochStart::y2k_epoch; +// Initialize the processor timezone offset +int16_t loggerClock::_core_tz = 0; // Initialize the static timezone int8_t loggerClock::_rtcUTCOffset = 0; @@ -565,8 +567,10 @@ void loggerClock::rtcISR() { } void loggerClock::begin() { - MS_DBG(F("Getting the epoch the processor uses for gmtime")); + MS_DBG(F("Getting the epoch the processor core uses for gmtime")); loggerClock::_core_epoch = getProcessorEpochStart(); + MS_DBG(F("Getting the timezone the processor core uses for mktime")); + loggerClock::_core_tz = getProcessorTimeZone(); PRINTOUT(F("An"), MS_CLOCK_NAME, F("will be used as the real time clock")); MS_DBG(F("Beginning"), MS_CLOCK_NAME, F("real time clock")); rtcBegin(); @@ -581,6 +585,8 @@ void loggerClock::begin() { static_cast(static_cast(_core_epoch) - static_cast(epochStart::unix_epoch)), F("seconds")); + MS_DBG(F("The processor considers local time to be"), _core_tz, + F("seconds ("), _core_tz / 3600, F("hours) offset from UTC")); MS_DBG(F("The attached"), MS_CLOCK_NAME, F("uses a"), epochTime::printEpochName(_rtcEpoch), F("epoch internally, which starts"), @@ -614,9 +620,60 @@ epochStart loggerClock::getProcessorEpochStart() { case 1980: ret_val = epochStart::gps_epoch; break; case 1900: ret_val = epochStart::nist_epoch; break; } + loggerClock::_core_epoch = ret_val; return ret_val; } +// This is yet another awkward function, but time support varies across device +// cores and I'm not sure if there is a better way to get the timezone offset +// that the processor/core considers "local time". We need to know this because +// the mktime function converts the input time to the number of seconds since +// the epoch in the processor's timezone. The UTC version of the function +// (timegm(&timeParts)) is not available on all platforms, and I have no idea +// how to consistently set or detect the timezone across platforms, so instead +// we will just use mktime and then compare the returned timestamp to the known +// epoch start to figure out the offset. +int16_t loggerClock::getProcessorTimeZone() { + // Create a time struct for Jan 1, 2000 at 00:00:00 in the processor's epoch + tm timeParts = {}; + timeParts.tm_sec = 0; + timeParts.tm_min = 0; + timeParts.tm_hour = 0; + timeParts.tm_mday = 1; + timeParts.tm_mon = 0; /* tm_mon is 0-11 */ + timeParts.tm_year = 100; /* tm_year is since 1900 */ + timeParts.tm_wday = 0; /* day of week, will be calculated */ + timeParts.tm_yday = 0; /* day of year, will be calculated */ + timeParts.tm_isdst = 0; /* daylight saving time flag */ + time_t timeTimeT = mktime(&timeParts); + // make a epoch time from the converted time + // NOTE: Re-run getProcessorEpochStart() instead of calling _core_epoch in + // case the functions are called out of order and _core_epoch hasn't been + // set yet. + epochTime timeEpoch(timeTimeT, getProcessorEpochStart()); + // convert to Y2K epoch + time_t timeY2K = epochTime::convert_epoch(timeEpoch, epochStart::y2k_epoch); + // Since we started with Jan 1, 2000, the offset from the input time and 0 + // in the Y2K epoch can only be caused by timezone shifts within the mktime + // function. + // Since time_t can be unsigned and is > 16 bit, we do checks before + // casting. If the timeY2K is less than 24 hours, it's a positive offset of + // that many seconds. If it's more than 24 hours, it's a negative offset of + // tz_offset (because the time would have rolled back to the previous day). + int16_t tz_offset; + if (timeY2K < 60 * 60 * 24) { + tz_offset = static_cast(timeY2K); + } else if (-1 * timeY2K < 60 * 60 * 24) { // force roll-over and check size + tz_offset = static_cast(-1 * (-1 * timeY2K)); + } else { // If the difference is more than 24 hours, something is wrong and + // we should just return 0 (UTC) + tz_offset = static_cast(0); + // NOTE: Do this silently in case Serial isn't initialzed yet. + } + loggerClock::_core_tz = tz_offset; + return tz_offset; +} + inline time_t loggerClock::tsToRawRTC(time_t ts, int8_t utcOffset, epochStart epoch) { time_t tz_change = diff --git a/src/ClockSupport.h b/src/ClockSupport.h index 7ca2e1956..3eca9cd6f 100644 --- a/src/ClockSupport.h +++ b/src/ClockSupport.h @@ -330,6 +330,15 @@ class epochTime { * deleted constructor. * * @todo Support half/quarter hour time zones + * + * Dealing with time is **hard**! This library only supports the bare minimum of + * what I think is necessary to get the logger's clock working and to convert + * between different epoch types. It does not support time zones (other than a + * static offset from UTC), daylight savings time, or any of the other + * complications of time. + * + * If you though handling time was simple, read this: + * https://gist.github.com/timvisee/fcda9bbdff88d45cc9061606b4b923ca */ class loggerClock { public: @@ -606,6 +615,16 @@ class loggerClock { static epochStart getCoreEpochStart() { return loggerClock::_core_epoch; }; + /** + * @brief Get the timezone offset for the processor/Arduino core in seconds + * from UTC + * + * @return The timezone offset for the processor/Arduino core in seconds + * from UTC + */ + static int16_t getCoreTimeZone() { + return loggerClock::_core_tz; + }; /** * @brief Get the epoch start for the RTC as an epochStart object * @@ -618,7 +637,8 @@ class loggerClock { protected: /** - * @brief Figure out where the epoch starts for the processor. + * @brief Figure out what epoch start is defined for the Arduino core used + * by the processor. * * The real time clock libraries mostly document this, but the cores for the * various Arduino processors don't. The time.h file is not much more than a @@ -629,11 +649,24 @@ class loggerClock { static epochStart getProcessorEpochStart(); /** - * @brief The start of the epoch for the processor's internal time.h + * @brief Figure out the timezone offset defined for the Arduino core used + * by the processor. + * + * @return The timezone offset in seconds from UTC + */ + static int16_t getProcessorTimeZone(); + + /** + * @brief The start of the epoch for the processor core's internal time.h * library. */ static epochStart _core_epoch; + /** + * @brief The timezone used by the processor core's internal time.h library. + */ + static int16_t _core_tz; + /** * @brief The static offset data of the real time clock from UTC in hours */ diff --git a/src/modems/LoggerModemMacros.h b/src/modems/LoggerModemMacros.h index 3f0e946b1..ade87b4f1 100644 --- a/src/modems/LoggerModemMacros.h +++ b/src/modems/LoggerModemMacros.h @@ -667,39 +667,45 @@ return gsmModem.getNetworkEpoch(TinyGSM_EpochStart::UNIX); \ } #elif defined(TINY_GSM_MODEM_HAS_NTP) && defined(TINY_GSM_MODEM_HAS_TIME) -#define MS_MODEM_GET_NIST_TIME(specificModem, TinyGSMType) \ - uint32_t specificModem::getNISTTime() { \ - /** Check for and bail if not connected to the internet. */ \ - if (!isInternetAvailable()) { \ - MS_DBG(F("No internet connection, cannot get network time.")); \ - return 0; \ - } \ - \ - MS_DBG("Asking modem to sync with NTP"); \ - gsmModem.NTPServerSync("pool.ntp.org", 0); /*UTC!*/ \ - gsmModem.waitForTimeSync(); \ - \ - /* Create ints to hold time parts */ \ - int seconds = 0; \ - int minutes = 0; \ - int hours = 0; \ - int day = 0; \ - int month = 0; \ - int year = 0; \ - /* Fetch the time as parts */ \ - bool success = gsmModem.getNetworkTime(&year, &month, &day, &hours, \ - &minutes, &seconds, 0); \ - if (!success) { return 0; } \ - tm timeParts = {}; \ - timeParts.tm_sec = seconds; \ - timeParts.tm_min = minutes; \ - timeParts.tm_hour = hours; \ - timeParts.tm_mday = day; \ - timeParts.tm_mon = month - 1; /* tm_mon is 0-11 */ \ - timeParts.tm_year = year - 1900; /* tm_year is since 1900 */ \ - timeParts.tm_wday = 0; /* day of week, will be calculated */ \ - time_t timeTimeT = mktime(&timeParts); \ - return static_cast(timeTimeT); \ +#define MS_MODEM_GET_NIST_TIME(specificModem, TinyGSMType) \ + uint32_t specificModem::getNISTTime() { \ + /** Check for and bail if not connected to the internet. */ \ + if (!isInternetAvailable()) { \ + MS_DBG(F("No internet connection, cannot get network time.")); \ + return 0; \ + } \ + \ + MS_DBG("Asking modem to sync with NTP"); \ + gsmModem.NTPServerSync("pool.ntp.org", 0); /*UTC!*/ \ + gsmModem.waitForTimeSync(); \ + \ + /* Create ints to hold time parts */ \ + int seconds = 0; \ + int minutes = 0; \ + int hours = 0; \ + int day = 0; \ + int month = 0; \ + int year = 0; \ + /* Fetch the time as parts */ \ + bool success = gsmModem.getNetworkTime(&year, &month, &day, &hours, \ + &minutes, &seconds, 0); \ + if (!success) { return 0; } \ + tm timeParts = {}; \ + timeParts.tm_sec = seconds; \ + timeParts.tm_min = minutes; \ + timeParts.tm_hour = hours; \ + timeParts.tm_mday = day; \ + timeParts.tm_mon = month - 1; /* tm_mon is 0-11 */ \ + timeParts.tm_year = year - 1900; /* tm_year is since 1900 */ \ + timeParts.tm_wday = 0; /* day of week, will be calculated */ \ + timeParts.tm_yday = 0; /* day of year, will be calculated */ \ + timeParts.tm_isdst = 0; /* daylight saving time flag */ \ + time_t timeTimeT = mktime(&timeParts); \ + /* The mktime fuction uses 'local' time in making the timestamp. */ \ + /* We subtrack whatever the processor thinks is 'local' */ \ + /* to get back to UTC.*/ \ + return static_cast(timeTimeT) - \ + loggerClock::getCoreTimeZone(); \ } #else #define MS_MODEM_GET_NIST_TIME(specificModem, TinyGSMType) \ From 9af36e565176b649f3f1b858bd7950ba6c2c6ba2 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Thu, 5 Mar 2026 14:26:19 -0500 Subject: [PATCH 451/533] Reorder delegating ctors, fix remaining virtual/override, nitpicks Signed-off-by: Sara Damiano --- src/LoggerModem.h | 2 -- src/VariableArray.cpp | 4 +++- src/VariableBase.cpp | 6 ++++-- src/WatchDogs/WatchDogAVR.cpp | 8 ++++++-- src/modems/DigiXBee.cpp | 3 --- src/modems/DigiXBee3GBypass.h | 2 +- src/modems/DigiXBeeLTEBypass.h | 2 +- src/modems/DigiXBeeWifi.h | 2 +- src/modems/EspressifESP32.cpp | 33 ++++++++++++++++++--------------- src/modems/QuectelBG96.h | 2 +- src/modems/SIMComSIM7080.h | 14 +++++++------- src/modems/SequansMonarch.cpp | 2 +- src/modems/Sodaq2GBeeR6.cpp | 2 +- src/modems/SodaqUBeeR410M.cpp | 13 ++++++------- src/modems/SodaqUBeeU201.h | 2 +- 15 files changed, 51 insertions(+), 46 deletions(-) diff --git a/src/LoggerModem.h b/src/LoggerModem.h index c49191d06..c8b028f3e 100644 --- a/src/LoggerModem.h +++ b/src/LoggerModem.h @@ -1225,8 +1225,6 @@ class loggerModem { uint8_t _pollModemMetaData = 0; }; -// typedef float (loggerModem::_*loggerGetValueFxn)(); - // Classes for the modem variables /** diff --git a/src/VariableArray.cpp b/src/VariableArray.cpp index 61fe576d0..834fd345a 100644 --- a/src/VariableArray.cpp +++ b/src/VariableArray.cpp @@ -25,7 +25,9 @@ VariableArray::VariableArray(uint8_t variableCount, Variable* variableList[]) _variableCount(variableCount) { _sensorCount = getSensorCount(); } -VariableArray::VariableArray() {} +// Default constructor with no arguments - delegates to ensure all members are +// initialized +VariableArray::VariableArray() : VariableArray(0, nullptr) {} void VariableArray::begin(uint8_t variableCount, Variable* variableList[], diff --git a/src/VariableBase.cpp b/src/VariableBase.cpp index 99bc5c06d..18c82cd76 100644 --- a/src/VariableBase.cpp +++ b/src/VariableBase.cpp @@ -62,8 +62,10 @@ Variable::Variable(float (*calcFxn)(), uint8_t decimalResolution, const char* varCode) : Variable(calcFxn, decimalResolution, varName, varUnit, varCode, nullptr) { } -// Default constructor with no arguments -Variable::Variable() : isCalculated(true) {} +// Default constructor with no arguments - delegates to ensure all members are +// initialized +Variable::Variable() + : Variable(nullptr, 0, 0, nullptr, nullptr, nullptr, nullptr) {} // This does all of the setup that can't happen in the constructors diff --git a/src/WatchDogs/WatchDogAVR.cpp b/src/WatchDogs/WatchDogAVR.cpp index 8b20cc481..9b949aeba 100644 --- a/src/WatchDogs/WatchDogAVR.cpp +++ b/src/WatchDogs/WatchDogAVR.cpp @@ -98,11 +98,15 @@ void extendedWatchDogAVR::clearWDTInterrupt() { /** * @brief ISR for watchdog early warning + * + * This makes multi cycle WDT possible. */ ISR(WDT_vect) { MS_DEEP_DBG(F("\nWatchdog interrupt!")); - extendedWatchDogAVR::_barksUntilReset--; // Increment down the counter, - // makes multi cycle WDT possible + // De-increment down the counter, but don't allow to roll-over + if (extendedWatchDogAVR::_barksUntilReset > 0) { + extendedWatchDogAVR::_barksUntilReset--; + } if (extendedWatchDogAVR::_barksUntilReset == 0) { MS_DEEP_DBG(F("The dog has barked enough; resetting the board.")); MCUSR = 0; // reset flags diff --git a/src/modems/DigiXBee.cpp b/src/modems/DigiXBee.cpp index f7bf420b1..79d7bf5f9 100644 --- a/src/modems/DigiXBee.cpp +++ b/src/modems/DigiXBee.cpp @@ -29,11 +29,9 @@ DigiXBee::DigiXBee(int8_t powerPin, int8_t statusPin, bool useCTSStatus, // connecting the XBee bool DigiXBee::modemWakeFxn() { if (_modemSleepRqPin >= 0) { - // Don't go to sleep if there's not a wake pin! MS_DBG(F("Setting pin"), _modemSleepRqPin, _wakeLevel ? F("HIGH") : F("LOW"), F("to wake"), _modemName); digitalWrite(_modemSleepRqPin, _wakeLevel); - return true; } return true; } @@ -45,7 +43,6 @@ bool DigiXBee::modemSleepFxn() { !_wakeLevel ? F("HIGH") : F("LOW"), F("to put"), _modemName, F("to sleep")); digitalWrite(_modemSleepRqPin, !_wakeLevel); - return true; } return true; } diff --git a/src/modems/DigiXBee3GBypass.h b/src/modems/DigiXBee3GBypass.h index 2a87232fc..f3fbdb2a3 100644 --- a/src/modems/DigiXBee3GBypass.h +++ b/src/modems/DigiXBee3GBypass.h @@ -144,7 +144,7 @@ class DigiXBee3GBypass : public DigiXBee { Client* createSecureClient(const char* pskIdent, const char* psKey, SSLVersion sslVersion = SSLVersion::TLS1_2) override; - virtual Client* + Client* createSecureClient(const char* pskTableName, SSLVersion sslVersion = SSLVersion::TLS1_2) override; diff --git a/src/modems/DigiXBeeLTEBypass.h b/src/modems/DigiXBeeLTEBypass.h index 558cf4a3a..f72930b23 100644 --- a/src/modems/DigiXBeeLTEBypass.h +++ b/src/modems/DigiXBeeLTEBypass.h @@ -159,7 +159,7 @@ class DigiXBeeLTEBypass : public DigiXBee { Client* createSecureClient(const char* pskIdent, const char* psKey, SSLVersion sslVersion = SSLVersion::TLS1_2) override; - virtual Client* + Client* createSecureClient(const char* pskTableName, SSLVersion sslVersion = SSLVersion::TLS1_2) override; diff --git a/src/modems/DigiXBeeWifi.h b/src/modems/DigiXBeeWifi.h index 25c2575d7..0017f0ab8 100644 --- a/src/modems/DigiXBeeWifi.h +++ b/src/modems/DigiXBeeWifi.h @@ -154,7 +154,7 @@ class DigiXBeeWifi : public DigiXBee { Client* createSecureClient(const char* pskIdent, const char* psKey, SSLVersion sslVersion = SSLVersion::TLS1_2) override; - virtual Client* + Client* createSecureClient(const char* pskTableName, SSLVersion sslVersion = SSLVersion::TLS1_2) override; diff --git a/src/modems/EspressifESP32.cpp b/src/modems/EspressifESP32.cpp index 9cfe03b8c..76aaa3e92 100644 --- a/src/modems/EspressifESP32.cpp +++ b/src/modems/EspressifESP32.cpp @@ -67,21 +67,24 @@ bool EspressifESP32::modemSleepFxn() { bool EspressifESP32::extraModemSetup() { if (_modemSleepRqPin >= 0) { digitalWrite(_modemSleepRqPin, !_wakeLevel); } bool success = gsmModem.init(); - _modemName = gsmModem.getModemName(); - // AT+CWCOUNTRY=,,, - // : - // 0: will change the county code to be the same as the AP that the - // ESP32 is connected to. - // 1: the country code will not change, always be the one set by - // command. - // : country code. Maximum length: 3 characters. Refer to ISO - // 3166-1 alpha-2 for country codes. - // : the channel number to start. Range: [1,14]. - // : total number of channels. - gsmModem.sendAT( - GF("+CWCOUNTRY=0,\"US\",1,13")); // Set country code to default to US, - // but allow to change if the AP is - success &= gsmModem.waitResponse() == 1; + _modemName = gsmModem.getModemName(); // Name is set by the ESP32 modem + // object independent of the init fxn + if (success) { + // AT+CWCOUNTRY=,,, + // : + // 0: will change the county code to be the same as the AP that the + // ESP32 is connected to. + // 1: the country code will not change, always be the one set by + // command. + // : country code. Maximum length: 3 characters. Refer to + // ISO 3166-1 alpha-2 for country codes. + // : the channel number to start. Range: [1,14]. + // : total number of channels. + gsmModem.sendAT(GF( + "+CWCOUNTRY=0,\"US\",1,13")); // Set country code to default to US, + // but allow to change if the AP is + success &= gsmModem.waitResponse() == 1; + } return success; } diff --git a/src/modems/QuectelBG96.h b/src/modems/QuectelBG96.h index 9b2eadecd..5949b9a61 100644 --- a/src/modems/QuectelBG96.h +++ b/src/modems/QuectelBG96.h @@ -219,7 +219,7 @@ class QuectelBG96 : public loggerModem { Client* createSecureClient(const char* pskIdent, const char* psKey, SSLVersion sslVersion = SSLVersion::TLS1_2) override; - virtual Client* + Client* createSecureClient(const char* pskTableName, SSLVersion sslVersion = SSLVersion::TLS1_2) override; diff --git a/src/modems/SIMComSIM7080.h b/src/modems/SIMComSIM7080.h index 6851ef090..e5a543174 100644 --- a/src/modems/SIMComSIM7080.h +++ b/src/modems/SIMComSIM7080.h @@ -190,18 +190,18 @@ class SIMComSIM7080 : public loggerModem { bool connectInternet(uint32_t maxConnectionTime = 50000L) override; void disconnectInternet() override; - virtual Client* createClient() override; - virtual void deleteClient(Client* client) override; - virtual Client* createSecureClient() override; - virtual void deleteSecureClient(Client* client) override; - virtual Client* createSecureClient( + Client* createClient() override; + void deleteClient(Client* client) override; + Client* createSecureClient() override; + void deleteSecureClient(Client* client) override; + Client* createSecureClient( SSLAuthMode sslAuthMode, SSLVersion sslVersion = SSLVersion::TLS1_2, const char* CAcertName = nullptr, const char* clientCertName = nullptr, const char* clientKeyName = nullptr) override; - virtual Client* + Client* createSecureClient(const char* pskIdent, const char* psKey, SSLVersion sslVersion = SSLVersion::TLS1_2) override; - virtual Client* + Client* createSecureClient(const char* pskTableName, SSLVersion sslVersion = SSLVersion::TLS1_2) override; diff --git a/src/modems/SequansMonarch.cpp b/src/modems/SequansMonarch.cpp index f5af2514d..0646059b9 100644 --- a/src/modems/SequansMonarch.cpp +++ b/src/modems/SequansMonarch.cpp @@ -124,7 +124,7 @@ bool SequansMonarch::extraModemSetup() { gsmModem.sendAT(GF("+SQNLED=1")); success &= static_cast(gsmModem.waitResponse()); // Enable power save mode if we're not going to cut power or use reset - if (!(_powerPin >= 0) && !(_modemResetPin >= 0) && _modemSleepRqPin >= 0) { + if (_powerPin < 0 && _modemResetPin < 0 && _modemSleepRqPin >= 0) { MS_DBG( "Enabling power save mode tracking area update [PSM TAU] timers"); // Requested Periodic TAU (Time in between Tracking Area Updates) = 101 diff --git a/src/modems/Sodaq2GBeeR6.cpp b/src/modems/Sodaq2GBeeR6.cpp index efb320abd..a09c6f0b9 100644 --- a/src/modems/Sodaq2GBeeR6.cpp +++ b/src/modems/Sodaq2GBeeR6.cpp @@ -46,6 +46,7 @@ bool Sodaq2GBeeR6::modemSleepFxn() { bool success = gsmModem.poweroff(); if (_vRefPin >= 0) { MS_DBG(F("Disabling voltage reference for GPRSBeeR6 on pin"), _vRefPin); + pinMode(_vRefPin, OUTPUT); digitalWrite(_vRefPin, LOW); } gsmModem.stream.flush(); @@ -55,7 +56,6 @@ bool Sodaq2GBeeR6::modemSleepFxn() { bool Sodaq2GBeeR6::extraModemSetup() { bool success = gsmModem.init(); _modemName = gsmModem.getModemName(); - if (_vRefPin >= 0) { pinMode(_vRefPin, OUTPUT); } return success; } diff --git a/src/modems/SodaqUBeeR410M.cpp b/src/modems/SodaqUBeeR410M.cpp index 8fe1c9e0f..5fd0952ff 100644 --- a/src/modems/SodaqUBeeR410M.cpp +++ b/src/modems/SodaqUBeeR410M.cpp @@ -123,18 +123,17 @@ bool SodaqUBeeR410M::modemWakeFxn() { bool SodaqUBeeR410M::modemSleepFxn() { + bool res = true; + // Only go to sleep if we can wake up! if (_modemSleepRqPin >= 0) { // R410 must have access to `PWR_ON` pin to sleep // Easiest to just go to sleep with the AT command rather than using // pins MS_DBG(F("Asking u-blox R410M to power down")); - bool res = gsmModem.poweroff(); - gsmModem.stream.flush(); - return res; - } else { // DON'T go to sleep if we can't wake up! - gsmModem.stream.flush(); - return true; + res = gsmModem.poweroff(); } + gsmModem.stream.flush(); + return res; } @@ -163,7 +162,7 @@ bool SodaqUBeeR410M::extraModemSetup() { // Turn on network indicator light // Pin 16 = GPIO1, function 2 = network status indication gsmModem.sendAT(GF("+UGPIOC=16,2")); - gsmModem.waitResponse(); + success &= gsmModem.waitResponse() == 1; return success; } diff --git a/src/modems/SodaqUBeeU201.h b/src/modems/SodaqUBeeU201.h index fe0c51150..1055699ca 100644 --- a/src/modems/SodaqUBeeU201.h +++ b/src/modems/SodaqUBeeU201.h @@ -214,7 +214,7 @@ class SodaqUBeeU201 : public loggerModem { virtual Client* createSecureClient(const char* pskIdent, const char* psKey, SSLVersion sslVersion = SSLVersion::TLS1_2) override; - virtual Client* + Client* createSecureClient(const char* pskTableName, SSLVersion sslVersion = SSLVersion::TLS1_2) override; From 347eb0bc72c4e4985872f49a1ffa4d254d1df091 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Thu, 5 Mar 2026 14:48:07 -0500 Subject: [PATCH 452/533] made initialTransmissions part of the dataPublisher Signed-off-by: Sara Damiano --- src/dataPublisherBase.cpp | 38 ++++++++-- src/dataPublisherBase.h | 50 ++++++++++++- src/publishers/AWS_IoT_Publisher.cpp | 32 +++++---- src/publishers/AWS_IoT_Publisher.h | 70 +++++++++++++++---- src/publishers/DreamHostPublisher.cpp | 26 ++++--- src/publishers/DreamHostPublisher.h | 49 ++++++++++--- src/publishers/EnviroDIYPublisher.h | 6 +- .../MonitorMyWatershedPublisher.cpp | 58 ++++++++------- src/publishers/MonitorMyWatershedPublisher.h | 57 ++++++++++----- src/publishers/S3PresignedPublisher.cpp | 23 +++--- src/publishers/S3PresignedPublisher.h | 48 +++++++++++-- src/publishers/ThingSpeakPublisher.cpp | 36 +++++----- src/publishers/ThingSpeakPublisher.h | 47 ++++++++++--- src/publishers/UbidotsPublisher.cpp | 50 +++++++------ src/publishers/UbidotsPublisher.h | 46 +++++++++--- 15 files changed, 463 insertions(+), 173 deletions(-) diff --git a/src/dataPublisherBase.cpp b/src/dataPublisherBase.cpp index 237540f13..1be400092 100644 --- a/src/dataPublisherBase.cpp +++ b/src/dataPublisherBase.cpp @@ -24,17 +24,25 @@ const char* dataPublisher::hostHeader = "\r\nHost: "; // Primary constructor dataPublisher::dataPublisher(Logger& baseLogger, Client* inClient, - int sendEveryX) + int sendEveryX, uint8_t initialTransmissions) : _baseLogger(&baseLogger), _inClient(inClient), - _sendEveryX(sendEveryX) { + _sendEveryX(sendEveryX), + _initialTransmissionsRemaining(initialTransmissions) { _baseModem = _baseLogger->registerDataPublisher(this); // register self with logger } // Constructors -dataPublisher::dataPublisher(Logger& baseLogger, int sendEveryX) - : dataPublisher(baseLogger, nullptr, sendEveryX) {} -dataPublisher::dataPublisher() {} +dataPublisher::dataPublisher(Logger& baseLogger, int sendEveryX, + uint8_t initialTransmissions) + : dataPublisher(baseLogger, nullptr, sendEveryX, initialTransmissions) {} +// Default constructor with explicit initialization to ensure all members are +// initialized +dataPublisher::dataPublisher() + : _baseLogger(nullptr), + _inClient(nullptr), + _sendEveryX(1), + _initialTransmissionsRemaining(5) {} // Sets the client @@ -63,6 +71,26 @@ void dataPublisher::setSendInterval(int sendEveryX) { } +// Get the number of initial transmissions remaining +uint8_t dataPublisher::getInitialTransmissions() const { + return _initialTransmissionsRemaining; +} + + +// Set the number of initial transmissions to send immediately after logging +void dataPublisher::setInitialTransmissions(uint8_t count) { + // Ensure minimum of 1 transmission + if (count < 1) { + MS_DBG(F("Initial transmissions count too low, setting to 1")); + _initialTransmissionsRemaining = 1; + } else { + _initialTransmissionsRemaining = count; + } + MS_DBG(F("Initial transmissions remaining set to:"), + _initialTransmissionsRemaining); +} + + // "Begins" the publisher - attaches client and logger void dataPublisher::begin(Logger& baseLogger, Client* inClient) { setClient(inClient); diff --git a/src/dataPublisherBase.h b/src/dataPublisherBase.h index bd2b3c53e..86a1dc428 100644 --- a/src/dataPublisherBase.h +++ b/src/dataPublisherBase.h @@ -80,8 +80,14 @@ class dataPublisher { * @param baseLogger The logger supplying the data to be published * @param sendEveryX Interval (in units of the logging interval) between * attempted data transmissions. Not respected by all publishers. + * @param initialTransmissions Number of transmissions to send immediately + * after each data point is logged, before beginning to cache data and only + * transmit every sendEveryX times the logger records data (default: 5). + * This allows faster in-field validation of initial data. Not respected by + * all publishers. */ - explicit dataPublisher(Logger& baseLogger, int sendEveryX = 1); + explicit dataPublisher(Logger& baseLogger, int sendEveryX = 1, + uint8_t initialTransmissions = 5); /** * @brief Construct a new data publisher object. * @@ -95,8 +101,14 @@ class dataPublisher { * single TinyGSM modem instance * @param sendEveryX Interval (in units of the logging interval) between * attempted data transmissions. Not respected by all publishers. + * @param initialTransmissions Number of transmissions to send immediately + * after each data point is logged, before beginning to cache data and only + * transmit every sendEveryX times the logger records data (default: 5). + * This allows faster in-field validation of initial data. Not respected by + * all publishers. */ - dataPublisher(Logger& baseLogger, Client* inClient, int sendEveryX = 1); + dataPublisher(Logger& baseLogger, Client* inClient, int sendEveryX = 1, + uint8_t initialTransmissions = 5); /** * @brief Destroy the data publisher object - no action is taken. */ @@ -123,6 +135,28 @@ class dataPublisher { */ void setSendInterval(int sendEveryX); + /** + * @brief Get the number of initial transmissions remaining + * + * @return The number of transmissions that will be sent at one minute + * intervals for faster in-field validation + */ + uint8_t getInitialTransmissions() const; + + /** + * @brief Set the number of initial transmissions to send immediately after + * logging + * + * This controls how many of the first data points are transmitted + * immediately after each is logged, before beginning to cache data and only + * transmit every sendEveryX times the logger records data. This allows + * faster in-field validation of initial data. + * + * @param count Number of initial transmissions (must be 1-255, will be + * clamped to this range) + */ + void setInitialTransmissions(uint8_t count); + /** * @brief Attach the publisher to a logger. * @@ -383,6 +417,18 @@ class dataPublisher { */ int _sendEveryX = 1; + /** + * @brief The number of transmissions remaining to send immediately after + * logging + * + * We send each of the first several data points immediately after they are + * logged, before beginning to cache data and only transmit every sendEveryX + * times the logger records data. This value is user-settable via + * constructor parameter or setInitialTransmissions() and allows faster + * in-field validation. + */ + uint8_t _initialTransmissionsRemaining = 5; + // Basic chunks of HTTP /** * @brief the text "GET " diff --git a/src/publishers/AWS_IoT_Publisher.cpp b/src/publishers/AWS_IoT_Publisher.cpp index 210b572d6..a203c2969 100644 --- a/src/publishers/AWS_IoT_Publisher.cpp +++ b/src/publishers/AWS_IoT_Publisher.cpp @@ -29,8 +29,9 @@ const char* AWS_IoT_Publisher::timestampTag = "\"timestamp\":\""; AWS_IoT_Publisher::AWS_IoT_Publisher( Logger& baseLogger, Client* inClient, const char* awsIoTEndpoint, const char* caCertName, const char* clientCertName, - const char* clientKeyName, const char* samplingFeatureUUID, int sendEveryX) - : dataPublisher(baseLogger, inClient, sendEveryX) { + const char* clientKeyName, const char* samplingFeatureUUID, int sendEveryX, + uint8_t initialTransmissions) + : dataPublisher(baseLogger, inClient, sendEveryX, initialTransmissions) { if (awsIoTEndpoint) setEndpoint(awsIoTEndpoint); if (caCertName) setCACertName(caCertName); if (clientCertName) setClientCertName(clientCertName); @@ -46,30 +47,37 @@ AWS_IoT_Publisher::AWS_IoT_Publisher( AWS_IoT_Publisher::AWS_IoT_Publisher( Logger& baseLogger, const char* awsIoTEndpoint, const char* caCertName, const char* clientCertName, const char* clientKeyName, - const char* samplingFeatureUUID, int sendEveryX) + const char* samplingFeatureUUID, int sendEveryX, + uint8_t initialTransmissions) : AWS_IoT_Publisher(baseLogger, nullptr, awsIoTEndpoint, caCertName, clientCertName, clientKeyName, samplingFeatureUUID, - sendEveryX) {} + sendEveryX, initialTransmissions) {} AWS_IoT_Publisher::AWS_IoT_Publisher(Logger& baseLogger, const char* awsIoTEndpoint, const char* caCertName, const char* clientCertName, - const char* clientKeyName, int sendEveryX) + const char* clientKeyName, int sendEveryX, + uint8_t initialTransmissions) : AWS_IoT_Publisher(baseLogger, nullptr, awsIoTEndpoint, caCertName, - clientCertName, clientKeyName, nullptr, sendEveryX) {} + clientCertName, clientKeyName, nullptr, sendEveryX, + initialTransmissions) {} AWS_IoT_Publisher::AWS_IoT_Publisher(Logger& baseLogger, Client* inClient, const char* awsIoTEndpoint, const char* samplingFeatureUUID, - int sendEveryX) + int sendEveryX, + uint8_t initialTransmissions) : AWS_IoT_Publisher(baseLogger, inClient, awsIoTEndpoint, nullptr, nullptr, - nullptr, samplingFeatureUUID, sendEveryX) {} + nullptr, samplingFeatureUUID, sendEveryX, + initialTransmissions) {} AWS_IoT_Publisher::AWS_IoT_Publisher(Logger& baseLogger, Client* inClient, - int sendEveryX) + int sendEveryX, + uint8_t initialTransmissions) : AWS_IoT_Publisher(baseLogger, inClient, nullptr, nullptr, nullptr, - nullptr, nullptr, sendEveryX) {} -AWS_IoT_Publisher::AWS_IoT_Publisher(Logger& baseLogger, int sendEveryX) + nullptr, nullptr, sendEveryX, initialTransmissions) {} +AWS_IoT_Publisher::AWS_IoT_Publisher(Logger& baseLogger, int sendEveryX, + uint8_t initialTransmissions) : AWS_IoT_Publisher(baseLogger, nullptr, nullptr, nullptr, nullptr, nullptr, - nullptr, sendEveryX) {} + nullptr, sendEveryX, initialTransmissions) {} AWS_IoT_Publisher::AWS_IoT_Publisher() : dataPublisher() { init(); } diff --git a/src/publishers/AWS_IoT_Publisher.h b/src/publishers/AWS_IoT_Publisher.h index de0f37aac..771551dd2 100644 --- a/src/publishers/AWS_IoT_Publisher.h +++ b/src/publishers/AWS_IoT_Publisher.h @@ -101,7 +101,13 @@ class AWS_IoT_Publisher : public dataPublisher { * @param clientKeyName The name of your client private key file * @param samplingFeatureUUID The sampling feature UUID * @param sendEveryX Interval (in units of the logging interval) between - * attempted data transmissions. NOTE: not implemented by this publisher! + * attempted data transmissions. + * @param initialTransmissions The number of initial transmissions + * (default: 5). This will be inverted from the argument! + * + * @remark The sendEveryX and initialTransmissions parameters are not + * implemented by this publisher. Data will be sent every time the logger + * records data. * * @note The inputs to this are the **NAMES** of the certificate **files** * as they are stored on you modem module, not the content of the @@ -110,7 +116,8 @@ class AWS_IoT_Publisher : public dataPublisher { AWS_IoT_Publisher(Logger& baseLogger, Client* inClient, const char* awsIoTEndpoint, const char* caCertName, const char* clientCertName, const char* clientKeyName, - const char* samplingFeatureUUID, int sendEveryX = 1); + const char* samplingFeatureUUID, int sendEveryX = 1, + uint8_t initialTransmissions = 5); /** * @brief Construct a new AWS IoT Core Publisher object * @@ -122,7 +129,13 @@ class AWS_IoT_Publisher : public dataPublisher { * @param clientKeyName The name of your client private key file * @param samplingFeatureUUID The sampling feature UUID * @param sendEveryX Interval (in units of the logging interval) between - * attempted data transmissions. NOTE: not implemented by this publisher! + * attempted data transmissions. + * @param initialTransmissions The number of initial transmissions + * (default: 5). This will be inverted from the argument! + * + * @remark The sendEveryX and initialTransmissions parameters are not + * implemented by this publisher. Data will be sent every time the logger + * records data. * * @note The inputs to this are the **NAMES** of the certificate **files** * as they are stored on you modem module, not the content of the @@ -131,7 +144,8 @@ class AWS_IoT_Publisher : public dataPublisher { AWS_IoT_Publisher(Logger& baseLogger, const char* awsIoTEndpoint, const char* caCertName, const char* clientCertName, const char* clientKeyName, - const char* samplingFeatureUUID, int sendEveryX = 1); + const char* samplingFeatureUUID, int sendEveryX = 1, + uint8_t initialTransmissions = 5); /** * @brief Construct a new AWS IoT Core Publisher object * @@ -142,7 +156,13 @@ class AWS_IoT_Publisher : public dataPublisher { * @param clientCertName The name of your client certificate file * @param clientKeyName The name of your client private key file * @param sendEveryX Interval (in units of the logging interval) between - * attempted data transmissions. NOTE: not implemented by this publisher! + * attempted data transmissions. + * @param initialTransmissions The number of initial transmissions + * (default: 5). This will be inverted from the argument! + * + * @remark The sendEveryX and initialTransmissions parameters are not + * implemented by this publisher. Data will be sent every time the logger + * records data. * * @note The inputs to this are the **NAMES** of the certificate **files** * as they are stored on you modem module, not the content of the @@ -150,7 +170,8 @@ class AWS_IoT_Publisher : public dataPublisher { */ AWS_IoT_Publisher(Logger& baseLogger, const char* awsIoTEndpoint, const char* caCertName, const char* clientCertName, - const char* clientKeyName, int sendEveryX = 1); + const char* clientKeyName, int sendEveryX = 1, + uint8_t initialTransmissions = 5); /** * @brief Construct a new AWS IoT Core Publisher object * @@ -161,11 +182,18 @@ class AWS_IoT_Publisher : public dataPublisher { * @param awsIoTEndpoint The endpoint for your AWS IoT instance * @param samplingFeatureUUID The sampling feature UUID * @param sendEveryX Interval (in units of the logging interval) between - * attempted data transmissions. NOTE: not implemented by this publisher! + * attempted data transmissions. + * @param initialTransmissions The number of initial transmissions + * (default: 5). This will be inverted from the argument! + * + * @remark The sendEveryX and initialTransmissions parameters are not + * implemented by this publisher. Data will be sent every time the logger + * records data. */ AWS_IoT_Publisher(Logger& baseLogger, Client* inClient, const char* awsIoTEndpoint, - const char* samplingFeatureUUID, int sendEveryX = 1); + const char* samplingFeatureUUID, int sendEveryX = 1, + uint8_t initialTransmissions = 5); /** * @brief Construct a new AWS IoT Core Publisher object * @@ -174,9 +202,16 @@ class AWS_IoT_Publisher : public dataPublisher { * Allows the use of any type of client and multiple clients tied to a * single TinyGSM modem instance * @param sendEveryX Interval (in units of the logging interval) between - * attempted data transmissions. NOTE: not implemented by this publisher! + * attempted data transmissions. + * @param initialTransmissions The number of initial transmissions + * (default: 5). This will be inverted from the argument! + * + * @remark The sendEveryX and initialTransmissions parameters are not + * implemented by this publisher. Data will be sent every time the logger + * records data. */ - AWS_IoT_Publisher(Logger& baseLogger, Client* inClient, int sendEveryX = 1); + AWS_IoT_Publisher(Logger& baseLogger, Client* inClient, int sendEveryX = 1, + uint8_t initialTransmissions = 5); /** * @brief Construct a new AWS IoT Core Publisher object * @@ -186,12 +221,19 @@ class AWS_IoT_Publisher : public dataPublisher { * * @param baseLogger The logger supplying the data to be published * @param sendEveryX Interval (in units of the logging interval) between - * attempted data transmissions. NOTE: not implemented by this publisher! + * attempted data transmissions. + * @param initialTransmissions The number of initial transmissions + * (default: 5). This will be inverted from the argument! + * + * @remark The sendEveryX and initialTransmissions parameters are not + * implemented by this publisher. Data will be sent every time the logger + * records data. */ - explicit AWS_IoT_Publisher(Logger& baseLogger, int sendEveryX = 1); + explicit AWS_IoT_Publisher(Logger& baseLogger, int sendEveryX = 1, + uint8_t initialTransmissions = 5); /** - * @brief Construct a new AWS IoT Core Publisher object with no members - * initialized. + * @brief Construct a new AWS IoT Core Publisher object with all members set + * to defaults or nulls */ AWS_IoT_Publisher(); /** diff --git a/src/publishers/DreamHostPublisher.cpp b/src/publishers/DreamHostPublisher.cpp index f8e6c6af8..2a470a0f1 100644 --- a/src/publishers/DreamHostPublisher.cpp +++ b/src/publishers/DreamHostPublisher.cpp @@ -24,24 +24,28 @@ const char* DreamHostPublisher::timestampTagDH = "&Loggertime="; // Constructors // Primary constructor with all parameters DreamHostPublisher::DreamHostPublisher(Logger& baseLogger, Client* inClient, - const char* dhUrl, int sendEveryX) - : DreamHostPublisher(baseLogger, inClient, sendEveryX) { + const char* dhUrl, int sendEveryX, + uint8_t initialTransmissions) + : dataPublisher(baseLogger, inClient, sendEveryX, initialTransmissions) { if (dhUrl) setDreamHostPortalRX(dhUrl); } // Delegating constructors DreamHostPublisher::DreamHostPublisher(Logger& baseLogger, Client* inClient, - int sendEveryX) - : dataPublisher(baseLogger, inClient, sendEveryX) {} + int sendEveryX, + uint8_t initialTransmissions) + : DreamHostPublisher(baseLogger, inClient, nullptr, sendEveryX, + initialTransmissions) {} DreamHostPublisher::DreamHostPublisher(Logger& baseLogger, const char* dhUrl, - int sendEveryX) + int sendEveryX, + uint8_t initialTransmissions) + : DreamHostPublisher(baseLogger, static_cast(nullptr), dhUrl, + sendEveryX, initialTransmissions) {} +DreamHostPublisher::DreamHostPublisher(Logger& baseLogger, int sendEveryX, + uint8_t initialTransmissions) : DreamHostPublisher(baseLogger, static_cast(nullptr), - sendEveryX) { - if (dhUrl) setDreamHostPortalRX(dhUrl); -} -DreamHostPublisher::DreamHostPublisher(Logger& baseLogger, int sendEveryX) - : DreamHostPublisher(baseLogger, static_cast(nullptr), - sendEveryX) {} + static_cast(nullptr), sendEveryX, + initialTransmissions) {} DreamHostPublisher::DreamHostPublisher() : dataPublisher() {} diff --git a/src/publishers/DreamHostPublisher.h b/src/publishers/DreamHostPublisher.h index fd40c427f..5dce6d67a 100644 --- a/src/publishers/DreamHostPublisher.h +++ b/src/publishers/DreamHostPublisher.h @@ -56,10 +56,16 @@ class DreamHostPublisher : public dataPublisher { * single TinyGSM modem instance * @param dhUrl The URL for sending data to DreamHost * @param sendEveryX Interval (in units of the logging interval) between - * attempted data transmissions. NOTE: not implemented by this publisher! + * attempted data transmissions. + * @param initialTransmissions Number of transmissions to send immediately + * after each data point is logged (default: 5). + * + * @remark The sendEveryX and initialTransmissions parameters are not + * implemented by this publisher. Data will be sent every time the logger + * records data. */ DreamHostPublisher(Logger& baseLogger, Client* inClient, const char* dhUrl, - int sendEveryX = 1); + int sendEveryX = 1, uint8_t initialTransmissions = 5); /** * @brief Construct a new DreamHost Publisher object * @@ -68,20 +74,32 @@ class DreamHostPublisher : public dataPublisher { * Allows the use of any type of client and multiple clients tied to a * single TinyGSM modem instance * @param sendEveryX Interval (in units of the logging interval) between - * attempted data transmissions. NOTE: not implemented by this publisher! + * attempted data transmissions. + * @param initialTransmissions Number of transmissions to send immediately + * after each data point is logged (default: 5). + * + * @remark The sendEveryX and initialTransmissions parameters are not + * implemented by this publisher. Data will be sent every time the logger + * records data. */ - DreamHostPublisher(Logger& baseLogger, Client* inClient, - int sendEveryX = 1); + DreamHostPublisher(Logger& baseLogger, Client* inClient, int sendEveryX = 1, + uint8_t initialTransmissions = 5); /** * @brief Construct a new DreamHost Publisher object * * @param baseLogger The logger supplying the data to be published * @param dhUrl The URL for sending data to DreamHost * @param sendEveryX Interval (in units of the logging interval) between - * attempted data transmissions. NOTE: not implemented by this publisher! + * attempted data transmissions. + * @param initialTransmissions Number of transmissions to send immediately + * after each data point is logged (default: 5). + * + * @remark The sendEveryX and initialTransmissions parameters are not + * implemented by this publisher. Data will be sent every time the logger + * records data. */ DreamHostPublisher(Logger& baseLogger, const char* dhUrl, - int sendEveryX = 1); + int sendEveryX = 1, uint8_t initialTransmissions = 5); /** * @brief Construct a new DreamHost Publisher object * @@ -91,11 +109,22 @@ class DreamHostPublisher : public dataPublisher { * * @param baseLogger The logger supplying the data to be published * @param sendEveryX Interval (in units of the logging interval) between - * attempted data transmissions. NOTE: not implemented by this publisher! + * attempted data transmissions. + * @param initialTransmissions Number of transmissions to send immediately + * after each data point is logged (default: 5). + * + * @remark The sendEveryX and initialTransmissions parameters are not + * implemented by this publisher. Data will be sent every time the logger + * records data. */ - explicit DreamHostPublisher(Logger& baseLogger, int sendEveryX = 1); + explicit DreamHostPublisher(Logger& baseLogger, int sendEveryX = 1, + uint8_t initialTransmissions = 5); /** - * @brief Construct a new DreamHost Publisher object with no members set. + * @brief Construct a new DreamHost Publisher object with all members set to + * default or null. + * + * @note You must call the begin() function to initialize the members before + * using the publisher. */ DreamHostPublisher(); /** diff --git a/src/publishers/EnviroDIYPublisher.h b/src/publishers/EnviroDIYPublisher.h index 5cd443ad6..729363c93 100644 --- a/src/publishers/EnviroDIYPublisher.h +++ b/src/publishers/EnviroDIYPublisher.h @@ -5,9 +5,9 @@ * This library is published under the BSD-3 license. * @author Sara Geleskie Damiano * - * @brief Contains the EnviroDIYPublisher subclass of dataPublisher which is a - * typedef reference to the MonitorMyWatershedPublisher for backward - * compatibility. + * @brief Contains the EnviroDIYPublisher typedef, which provides backward + * compatibility by aliasing to MonitorMyWatershedPublisher (a subclass of + * dataPublisher). */ // Header Guards diff --git a/src/publishers/MonitorMyWatershedPublisher.cpp b/src/publishers/MonitorMyWatershedPublisher.cpp index d1f9706c8..9ba7f0978 100644 --- a/src/publishers/MonitorMyWatershedPublisher.cpp +++ b/src/publishers/MonitorMyWatershedPublisher.cpp @@ -34,8 +34,14 @@ const char* MonitorMyWatershedPublisher::timestampTag = "\",\"timestamp\":"; // Primary constructor with all parameters MonitorMyWatershedPublisher::MonitorMyWatershedPublisher( Logger& baseLogger, Client* inClient, const char* registrationToken, - const char* samplingFeatureUUID, int sendEveryX) - : MonitorMyWatershedPublisher(baseLogger, inClient, sendEveryX) { + const char* samplingFeatureUUID, int sendEveryX, + uint8_t initialTransmissionsRemaining) + : dataPublisher(baseLogger, inClient, sendEveryX, + initialTransmissionsRemaining) { + _logBuffer.setNumVariables(_baseLogger->getArrayVarCount()); + setHost("monitormywatershed.org"); + setPath("/api/data-stream/"); + setPort(80); if (registrationToken) setToken(registrationToken); if (samplingFeatureUUID) _baseLogger->setSamplingFeatureUUID(samplingFeatureUUID); @@ -44,35 +50,33 @@ MonitorMyWatershedPublisher::MonitorMyWatershedPublisher( // Delegating constructors MonitorMyWatershedPublisher::MonitorMyWatershedPublisher( Logger& baseLogger, const char* registrationToken, - const char* samplingFeatureUUID, int sendEveryX) + const char* samplingFeatureUUID, int sendEveryX, + uint8_t initialTransmissionsRemaining) : MonitorMyWatershedPublisher(baseLogger, static_cast(nullptr), - sendEveryX) { - if (registrationToken) setToken(registrationToken); - if (samplingFeatureUUID) - _baseLogger->setSamplingFeatureUUID(samplingFeatureUUID); -} + registrationToken, samplingFeatureUUID, + sendEveryX, initialTransmissionsRemaining) {} MonitorMyWatershedPublisher::MonitorMyWatershedPublisher( Logger& baseLogger, Client* inClient, const char* registrationToken, - int sendEveryX) + int sendEveryX, uint8_t initialTransmissionsRemaining) : MonitorMyWatershedPublisher(baseLogger, inClient, registrationToken, - nullptr, sendEveryX) {} -MonitorMyWatershedPublisher::MonitorMyWatershedPublisher(Logger& baseLogger, - Client* inClient, - int sendEveryX) - : dataPublisher(baseLogger, inClient, sendEveryX) { - _logBuffer.setNumVariables(_baseLogger->getArrayVarCount()); - setHost("monitormywatershed.org"); - setPath("/api/data-stream/"); - setPort(80); -} + nullptr, sendEveryX, + initialTransmissionsRemaining) {} +MonitorMyWatershedPublisher::MonitorMyWatershedPublisher( + Logger& baseLogger, Client* inClient, int sendEveryX, + uint8_t initialTransmissionsRemaining) + : MonitorMyWatershedPublisher(baseLogger, inClient, nullptr, nullptr, + sendEveryX, initialTransmissionsRemaining) {} +MonitorMyWatershedPublisher::MonitorMyWatershedPublisher( + Logger& baseLogger, const char* registrationToken, int sendEveryX, + uint8_t initialTransmissionsRemaining) + : MonitorMyWatershedPublisher(baseLogger, static_cast(nullptr), + registrationToken, nullptr, sendEveryX, + initialTransmissionsRemaining) {} MonitorMyWatershedPublisher::MonitorMyWatershedPublisher( - Logger& baseLogger, const char* registrationToken, int sendEveryX) - : MonitorMyWatershedPublisher(baseLogger, registrationToken, nullptr, - sendEveryX) {} -MonitorMyWatershedPublisher::MonitorMyWatershedPublisher(Logger& baseLogger, - int sendEveryX) + Logger& baseLogger, int sendEveryX, uint8_t initialTransmissionsRemaining) : MonitorMyWatershedPublisher(baseLogger, static_cast(nullptr), - sendEveryX) {} + nullptr, nullptr, sendEveryX, + initialTransmissionsRemaining) {} MonitorMyWatershedPublisher::MonitorMyWatershedPublisher() : dataPublisher() { // NOTE: _logBuffer is not initialized here because _baseLogger is null // Must call begin(Logger&, ...) before use to properly initialize @@ -203,9 +207,9 @@ bool MonitorMyWatershedPublisher::connectionNeeded() { if (percent >= 90) { interval = 1; } else if (percent >= 75) { - interval /= 4; + interval = max(1, interval / 4); } else if (percent >= 50) { - interval /= 2; + interval = max(1, interval / 2); } // the programmed interval is about to be reached by the next record, or it diff --git a/src/publishers/MonitorMyWatershedPublisher.h b/src/publishers/MonitorMyWatershedPublisher.h index aab08c863..284bb0f1c 100644 --- a/src/publishers/MonitorMyWatershedPublisher.h +++ b/src/publishers/MonitorMyWatershedPublisher.h @@ -61,11 +61,16 @@ class MonitorMyWatershedPublisher : public dataPublisher { * Monitor My Watershed. * @param sendEveryX Interval (in units of the logging interval) between * attempted data transmissions. + * @param initialTransmissionsRemaining Number of transmissions to send + * immediately after each data point is logged, before beginning to cache + * data and only transmit every sendEveryX times the logger records data + * (default: 5). This allows faster in-field validation of initial data. */ MonitorMyWatershedPublisher(Logger& baseLogger, Client* inClient, const char* registrationToken, const char* samplingFeatureUUID, - int sendEveryX = 1); + int sendEveryX = 1, + uint8_t initialTransmissionsRemaining = 5); /** * @brief Construct a new Monitor My Watershed Publisher object * @@ -76,11 +81,16 @@ class MonitorMyWatershedPublisher : public dataPublisher { * Monitor My Watershed. * @param sendEveryX Interval (in units of the logging interval) between * attempted data transmissions. + * @param initialTransmissionsRemaining Number of transmissions to send + * immediately after each data point is logged, before beginning to cache + * data and only transmit every sendEveryX times the logger records data + * (default: 5). This allows faster in-field validation of initial data. */ MonitorMyWatershedPublisher(Logger& baseLogger, const char* registrationToken, const char* samplingFeatureUUID, - int sendEveryX = 1); + int sendEveryX = 1, + uint8_t initialTransmissionsRemaining = 5); /** * @brief Construct a new Monitor My Watershed Publisher object * @@ -92,10 +102,15 @@ class MonitorMyWatershedPublisher : public dataPublisher { * My Watershed. * @param sendEveryX Interval (in units of the logging interval) between * attempted data transmissions. + * @param initialTransmissionsRemaining Number of transmissions to send + * immediately after each data point is logged, before beginning to cache + * data and only transmit every sendEveryX times the logger records data + * (default: 5). This allows faster in-field validation of initial data. */ MonitorMyWatershedPublisher(Logger& baseLogger, Client* inClient, const char* registrationToken, - int sendEveryX = 1); + int sendEveryX = 1, + uint8_t initialTransmissionsRemaining = 5); /** * @brief Construct a new Monitor My Watershed Publisher object * @@ -105,9 +120,14 @@ class MonitorMyWatershedPublisher : public dataPublisher { * single TinyGSM modem instance * @param sendEveryX Interval (in units of the logging interval) between * attempted data transmissions. + * @param initialTransmissionsRemaining Number of transmissions to send + * immediately after each data point is logged, before beginning to cache + * data and only transmit every sendEveryX times the logger records data + * (default: 5). This allows faster in-field validation of initial data. */ MonitorMyWatershedPublisher(Logger& baseLogger, Client* inClient, - int sendEveryX = 1); + int sendEveryX = 1, + uint8_t initialTransmissionsRemaining = 5); /** * @brief Construct a new Monitor My Watershed Publisher object * @@ -116,10 +136,15 @@ class MonitorMyWatershedPublisher : public dataPublisher { * My Watershed. * @param sendEveryX Interval (in units of the logging interval) between * attempted data transmissions. + * @param initialTransmissionsRemaining Number of transmissions to send + * immediately after each data point is logged, before beginning to cache + * data and only transmit every sendEveryX times the logger records data + * (default: 5). This allows faster in-field validation of initial data. */ MonitorMyWatershedPublisher(Logger& baseLogger, const char* registrationToken, - int sendEveryX = 1); + int sendEveryX = 1, + uint8_t initialTransmissionsRemaining = 5); /** * @brief Construct a new Monitor My Watershed Publisher object * @@ -130,12 +155,17 @@ class MonitorMyWatershedPublisher : public dataPublisher { * @param baseLogger The logger supplying the data to be published * @param sendEveryX Interval (in units of the logging interval) between * attempted data transmissions. + * @param initialTransmissionsRemaining Number of transmissions to send + * immediately after each data point is logged, before beginning to cache + * data and only transmit every sendEveryX times the logger records data + * (default: 5). This allows faster in-field validation of initial data. */ - explicit MonitorMyWatershedPublisher(Logger& baseLogger, - int sendEveryX = 1); + explicit MonitorMyWatershedPublisher( + Logger& baseLogger, int sendEveryX = 1, + uint8_t initialTransmissionsRemaining = 5); /** * @brief Construct a new Monitor My Watershed Publisher object with only - * default values for the host, path, and port set. + * default values for all parameters. */ MonitorMyWatershedPublisher(); /** @@ -306,17 +336,6 @@ class MonitorMyWatershedPublisher : public dataPublisher { */ int16_t flushDataBuffer(Client* outClient); - /** - * @brief The number of transmissions remaining at the single minute - * intervals - * - * We send every one of the first five data points at only one minute - * intervals for faster in-field validation. - * - * @todo This should be a user-settable parameter. - */ - uint8_t _initialTransmissionsRemaining = 5; - private: /** * @brief Internal reference to the Monitor My Watershed registration token. diff --git a/src/publishers/S3PresignedPublisher.cpp b/src/publishers/S3PresignedPublisher.cpp index 4cc79b190..a657729fe 100644 --- a/src/publishers/S3PresignedPublisher.cpp +++ b/src/publishers/S3PresignedPublisher.cpp @@ -18,27 +18,32 @@ const char* S3PresignedPublisher::contentLengthHeader = "\r\nContent-Length: "; const char* S3PresignedPublisher::contentTypeHeader = "\r\nContent-Type: "; // Constructors -// Primary constructor with certificate -S3PresignedPublisher::S3PresignedPublisher(Logger& baseLogger, +// Primary constructor with all parameters +S3PresignedPublisher::S3PresignedPublisher(Logger& baseLogger, Client* inClient, const char* caCertName, String (*getUrlFxn)(String), String (*getFileNameFxn)(), - int sendEveryX) - : dataPublisher(baseLogger, sendEveryX) { + int sendEveryX, + uint8_t initialTransmissions) + : dataPublisher(baseLogger, inClient, sendEveryX, initialTransmissions) { if (caCertName) setCACertName(caCertName); if (getUrlFxn) setURLUpdateFunction(getUrlFxn); if (getFileNameFxn) setFileUpdateFunction(getFileNameFxn); } // Delegating constructors +S3PresignedPublisher::S3PresignedPublisher( + Logger& baseLogger, const char* caCertName, String (*getUrlFxn)(String), + String (*getFileNameFxn)(), int sendEveryX, uint8_t initialTransmissions) + : S3PresignedPublisher(baseLogger, nullptr, caCertName, getUrlFxn, + getFileNameFxn, sendEveryX, initialTransmissions) {} S3PresignedPublisher::S3PresignedPublisher(Logger& baseLogger, Client* inClient, String (*getUrlFxn)(String), String (*getFileNameFxn)(), - int sendEveryX) - : S3PresignedPublisher(baseLogger, static_cast(nullptr), - getUrlFxn, getFileNameFxn, sendEveryX) { - if (inClient) _inClient = inClient; -} + int sendEveryX, + uint8_t initialTransmissions) + : S3PresignedPublisher(baseLogger, inClient, nullptr, getUrlFxn, + getFileNameFxn, sendEveryX, initialTransmissions) {} S3PresignedPublisher::S3PresignedPublisher() : dataPublisher() {} diff --git a/src/publishers/S3PresignedPublisher.h b/src/publishers/S3PresignedPublisher.h index d5fefcf13..7d031cfc1 100644 --- a/src/publishers/S3PresignedPublisher.h +++ b/src/publishers/S3PresignedPublisher.h @@ -138,23 +138,55 @@ class S3PresignedPublisher : public dataPublisher { * @brief Construct a new S3 Publisher object * * @param baseLogger The logger supplying the data to be published + * @param inClient An Arduino client instance to use to print data to. + * Allows the use of any type of client and multiple clients tied to a + * single TinyGSM modem instance * @param caCertName The name of your certificate authority certificate * file - used to validate the server's certificate when connecting to S3 * with SSL. @see setCACertName() * @param getUrlFxn A function to call to get a new pre-signed URL * @param getFileNameFxn A function to call to get a new filename * @param sendEveryX Interval (in units of the logging interval) between - * attempted data transmissions. NOTE: not implemented by this publisher! + * attempted data transmissions. + * @param initialTransmissions Number of transmissions to send immediately + * after each data point is logged (default: 5). + * + * @remark The sendEveryX and initialTransmissions parameters are not + * implemented by this publisher. Data will be sent every time the logger + * records data. * * @note The inputs to this is the **NAME** of the certificate **file** as * it is stored on you modem module, not the actual certificate content. */ + S3PresignedPublisher(Logger& baseLogger, Client* inClient, + const char* caCertName, + String (*getUrlFxn)(String) = nullptr, + String (*getFileNameFxn)() = nullptr, + int sendEveryX = 1, uint8_t initialTransmissions = 5); + /** + * @brief Construct a new S3 Publisher object with certificate + * + * @param baseLogger The logger supplying the data to be published + * @param caCertName The name of the certificate to use for SSL + * verification. This is the name of the certificate file as it is stored on + * you modem module, not the actual certificate content. + * @param getUrlFxn A function to call to get a new pre-signed URL + * @param getFileNameFxn A function to call to get a new filename + * @param sendEveryX Interval (in units of the logging interval) between + * attempted data transmissions. + * @param initialTransmissions Number of transmissions to send immediately + * after each data point is logged (default: 5). + * + * @remark The sendEveryX and initialTransmissions parameters are not + * implemented by this publisher. Data will be sent every time the logger + * records data. + */ S3PresignedPublisher(Logger& baseLogger, const char* caCertName, String (*getUrlFxn)(String) = nullptr, String (*getFileNameFxn)() = nullptr, - int sendEveryX = 1); + int sendEveryX = 1, uint8_t initialTransmissions = 5); /** - * @brief Construct a new S3 Publisher object + * @brief Construct a new S3 Publisher object without certificate * * @param baseLogger The logger supplying the data to be published * @param inClient An Arduino client instance to use to print data to. @@ -163,12 +195,18 @@ class S3PresignedPublisher : public dataPublisher { * @param getUrlFxn A function to call to get a new pre-signed URL * @param getFileNameFxn A function to call to get a new filename * @param sendEveryX Interval (in units of the logging interval) between - * attempted data transmissions. NOTE: not implemented by this publisher! + * attempted data transmissions. + * @param initialTransmissions Number of transmissions to send immediately + * after each data point is logged (default: 5). + * + * @remark The sendEveryX and initialTransmissions parameters are not + * implemented by this publisher. Data will be sent every time the logger + * records data. */ S3PresignedPublisher(Logger& baseLogger, Client* inClient, String (*getUrlFxn)(String) = nullptr, String (*getFileNameFxn)() = nullptr, - int sendEveryX = 1); + int sendEveryX = 1, uint8_t initialTransmissions = 5); /** * @brief Construct a new S3 Publisher object with no members set. */ diff --git a/src/publishers/ThingSpeakPublisher.cpp b/src/publishers/ThingSpeakPublisher.cpp index 357bd38cb..53fe490cd 100644 --- a/src/publishers/ThingSpeakPublisher.cpp +++ b/src/publishers/ThingSpeakPublisher.cpp @@ -32,13 +32,13 @@ ThingSpeakPublisher::ThingSpeakPublisher(Logger& baseLogger, Client* inClient, const char* thingSpeakMQTTUser, const char* thingSpeakMQTTPassword, const char* thingSpeakChannelID, - int sendEveryX) - : dataPublisher(baseLogger, sendEveryX) { + int sendEveryX, + uint8_t initialTransmissions) + : dataPublisher(baseLogger, inClient, sendEveryX, initialTransmissions) { if (thingSpeakClientName) setMQTTClient(thingSpeakClientName); if (thingSpeakMQTTUser) setUserName(thingSpeakMQTTUser); if (thingSpeakMQTTPassword) setPassword(thingSpeakMQTTPassword); if (thingSpeakChannelID) setChannelID(thingSpeakChannelID); - if (inClient) _inClient = inClient; } // Delegating constructors @@ -47,21 +47,27 @@ ThingSpeakPublisher::ThingSpeakPublisher(Logger& baseLogger, const char* thingSpeakMQTTUser, const char* thingSpeakMQTTPassword, const char* thingSpeakChannelID, - int sendEveryX) + int sendEveryX, + uint8_t initialTransmissions) : ThingSpeakPublisher(baseLogger, nullptr, thingSpeakClientName, thingSpeakMQTTUser, thingSpeakMQTTPassword, - thingSpeakChannelID, sendEveryX) {} + thingSpeakChannelID, sendEveryX, + initialTransmissions) {} ThingSpeakPublisher::ThingSpeakPublisher(Logger& baseLogger, Client* inClient, - int sendEveryX) + int sendEveryX, + uint8_t initialTransmissions) : ThingSpeakPublisher( baseLogger, inClient, static_cast(nullptr), static_cast(nullptr), static_cast(nullptr), - static_cast(nullptr), sendEveryX) {} -ThingSpeakPublisher::ThingSpeakPublisher(Logger& baseLogger, int sendEveryX) + static_cast(nullptr), sendEveryX, initialTransmissions) { +} +ThingSpeakPublisher::ThingSpeakPublisher(Logger& baseLogger, int sendEveryX, + uint8_t initialTransmissions) : ThingSpeakPublisher( baseLogger, nullptr, static_cast(nullptr), static_cast(nullptr), static_cast(nullptr), - static_cast(nullptr), sendEveryX) {} + static_cast(nullptr), sendEveryX, initialTransmissions) { +} ThingSpeakPublisher::ThingSpeakPublisher() : dataPublisher() {} @@ -106,10 +112,8 @@ void ThingSpeakPublisher::begin(Logger& baseLogger, Client* inClient, const char* thingSpeakMQTTUser, const char* thingSpeakMQTTPassword, const char* thingSpeakChannelID) { - setMQTTClient(thingSpeakClientName); - setChannelID(thingSpeakChannelID); - setPassword(thingSpeakMQTTPassword); - setUserName(thingSpeakMQTTUser); + setThingSpeakParams(thingSpeakClientName, thingSpeakMQTTUser, + thingSpeakMQTTPassword, thingSpeakChannelID); dataPublisher::begin(baseLogger, inClient); } void ThingSpeakPublisher::begin(Logger& baseLogger, @@ -117,10 +121,8 @@ void ThingSpeakPublisher::begin(Logger& baseLogger, const char* thingSpeakMQTTUser, const char* thingSpeakMQTTPassword, const char* thingSpeakChannelID) { - setMQTTClient(thingSpeakClientName); - setChannelID(thingSpeakChannelID); - setPassword(thingSpeakMQTTPassword); - setUserName(thingSpeakMQTTUser); + setThingSpeakParams(thingSpeakClientName, thingSpeakMQTTUser, + thingSpeakMQTTPassword, thingSpeakChannelID); dataPublisher::begin(baseLogger); } diff --git a/src/publishers/ThingSpeakPublisher.h b/src/publishers/ThingSpeakPublisher.h index ea11e2a57..f6f175c29 100644 --- a/src/publishers/ThingSpeakPublisher.h +++ b/src/publishers/ThingSpeakPublisher.h @@ -71,13 +71,20 @@ class ThingSpeakPublisher : public dataPublisher { * @param thingSpeakMQTTPassword The password for your MQTT device. * @param thingSpeakChannelID The numeric channel id for your channel. * @param sendEveryX Interval (in units of the logging interval) between - * attempted data transmissions. NOTE: not implemented by this publisher! + * attempted data transmissions. + * @param initialTransmissions Number of transmissions to send immediately + * after each data point is logged (default: 5). + * + * @remark The sendEveryX and initialTransmissions parameters are not + * implemented by this publisher. Data will be sent every time the logger + * records data. */ ThingSpeakPublisher(Logger& baseLogger, Client* inClient, const char* thingSpeakClientName, const char* thingSpeakMQTTUser, const char* thingSpeakMQTTPassword, - const char* thingSpeakChannelID, int sendEveryX = 1); + const char* thingSpeakChannelID, int sendEveryX = 1, + uint8_t initialTransmissions = 5); /** * @brief Construct a new ThingSpeak Publisher object * @@ -89,12 +96,19 @@ class ThingSpeakPublisher : public dataPublisher { * @param thingSpeakMQTTPassword The password for your MQTT device. * @param thingSpeakChannelID The numeric channel id for your channel. * @param sendEveryX Interval (in units of the logging interval) between - * attempted data transmissions. NOTE: not implemented by this publisher! + * attempted data transmissions. + * @param initialTransmissions Number of transmissions to send immediately + * after each data point is logged (default: 5). + * + * @remark The sendEveryX and initialTransmissions parameters are not + * implemented by this publisher. Data will be sent every time the logger + * records data. */ ThingSpeakPublisher(Logger& baseLogger, const char* thingSpeakClientName, const char* thingSpeakMQTTUser, const char* thingSpeakMQTTPassword, - const char* thingSpeakChannelID, int sendEveryX = 1); + const char* thingSpeakChannelID, int sendEveryX = 1, + uint8_t initialTransmissions = 5); /** * @brief Construct a new ThingSpeak Publisher object * @@ -103,10 +117,16 @@ class ThingSpeakPublisher : public dataPublisher { * Allows the use of any type of client and multiple clients tied to a * single TinyGSM modem instance * @param sendEveryX Interval (in units of the logging interval) between - * attempted data transmissions. NOTE: not implemented by this publisher! + * attempted data transmissions. + * @param initialTransmissions Number of transmissions to send immediately + * after each data point is logged (default: 5). + * + * @remark The sendEveryX and initialTransmissions parameters are not + * implemented by this publisher. Data will be sent every time the logger + * records data. */ ThingSpeakPublisher(Logger& baseLogger, Client* inClient, - int sendEveryX = 1); + int sendEveryX = 1, uint8_t initialTransmissions = 5); /** * @brief Construct a new ThingSpeak Publisher object * @@ -116,12 +136,19 @@ class ThingSpeakPublisher : public dataPublisher { * * @param baseLogger The logger supplying the data to be published * @param sendEveryX Interval (in units of the logging interval) between - * attempted data transmissions. NOTE: not implemented by this publisher! + * attempted data transmissions. + * @param initialTransmissions Number of transmissions to send immediately + * after each data point is logged (default: 5). + * + * @remark The sendEveryX and initialTransmissions parameters are not + * implemented by this publisher. Data will be sent every time the logger + * records data. */ - explicit ThingSpeakPublisher(Logger& baseLogger, int sendEveryX = 1); + explicit ThingSpeakPublisher(Logger& baseLogger, int sendEveryX = 1, + uint8_t initialTransmissions = 5); /** - * @brief Construct a new ThingSpeak Publisher object with no members - * initialized. + * @brief Construct a new ThingSpeak Publisher object with all members set + * to defaults or null. */ ThingSpeakPublisher(); /** diff --git a/src/publishers/UbidotsPublisher.cpp b/src/publishers/UbidotsPublisher.cpp index 573b74fd7..479f80fe5 100644 --- a/src/publishers/UbidotsPublisher.cpp +++ b/src/publishers/UbidotsPublisher.cpp @@ -35,16 +35,9 @@ const char* UbidotsPublisher::payload = "{"; // Primary constructor with all authentication parameters and client UbidotsPublisher::UbidotsPublisher(Logger& baseLogger, Client* inClient, const char* authenticationToken, - const char* deviceID, int sendEveryX) - : UbidotsPublisher(baseLogger, authenticationToken, deviceID, sendEveryX) { - if (inClient) _inClient = inClient; -} - -// Delegating constructors -UbidotsPublisher::UbidotsPublisher(Logger& baseLogger, - const char* authenticationToken, - const char* deviceID, int sendEveryX) - : dataPublisher(baseLogger, sendEveryX) { + const char* deviceID, int sendEveryX, + uint8_t initialTransmissions) + : dataPublisher(baseLogger, inClient, sendEveryX, initialTransmissions) { if (authenticationToken && authenticationToken[0] != '\0') { setToken(authenticationToken); } @@ -52,13 +45,22 @@ UbidotsPublisher::UbidotsPublisher(Logger& baseLogger, _baseLogger->setSamplingFeatureUUID(deviceID); } } + +// Delegating constructors +UbidotsPublisher::UbidotsPublisher(Logger& baseLogger, + const char* authenticationToken, + const char* deviceID, int sendEveryX, + uint8_t initialTransmissions) + : UbidotsPublisher(baseLogger, nullptr, authenticationToken, deviceID, + sendEveryX, initialTransmissions) {} UbidotsPublisher::UbidotsPublisher(Logger& baseLogger, Client* inClient, - int sendEveryX) - : UbidotsPublisher(baseLogger, nullptr, nullptr, sendEveryX) { - if (inClient) _inClient = inClient; -} -UbidotsPublisher::UbidotsPublisher(Logger& baseLogger, int sendEveryX) - : UbidotsPublisher(baseLogger, nullptr, nullptr, sendEveryX) {} + int sendEveryX, uint8_t initialTransmissions) + : UbidotsPublisher(baseLogger, inClient, nullptr, nullptr, sendEveryX, + initialTransmissions) {} +UbidotsPublisher::UbidotsPublisher(Logger& baseLogger, int sendEveryX, + uint8_t initialTransmissions) + : UbidotsPublisher(baseLogger, nullptr, nullptr, nullptr, sendEveryX, + initialTransmissions) {} UbidotsPublisher::UbidotsPublisher() : dataPublisher() {} @@ -96,16 +98,24 @@ uint16_t UbidotsPublisher::calculateJsonSize() { void UbidotsPublisher::begin(Logger& baseLogger, Client* inClient, const char* authenticationToken, const char* deviceID) { - setToken(authenticationToken); + if (authenticationToken && authenticationToken[0] != '\0') { + setToken(authenticationToken); + } dataPublisher::begin(baseLogger, inClient); - _baseLogger->setSamplingFeatureUUID(deviceID); + if (deviceID && deviceID[0] != '\0') { + _baseLogger->setSamplingFeatureUUID(deviceID); + } } void UbidotsPublisher::begin(Logger& baseLogger, const char* authenticationToken, const char* deviceID) { - setToken(authenticationToken); + if (authenticationToken && authenticationToken[0] != '\0') { + setToken(authenticationToken); + } dataPublisher::begin(baseLogger); - _baseLogger->setSamplingFeatureUUID(deviceID); + if (deviceID && deviceID[0] != '\0') { + _baseLogger->setSamplingFeatureUUID(deviceID); + } } diff --git a/src/publishers/UbidotsPublisher.h b/src/publishers/UbidotsPublisher.h index 85ddc6b0b..d650af8d5 100644 --- a/src/publishers/UbidotsPublisher.h +++ b/src/publishers/UbidotsPublisher.h @@ -60,11 +60,17 @@ class UbidotsPublisher : public dataPublisher { * @param deviceID The device API Label from Ubidots, derived from the * user-specified device name. * @param sendEveryX Interval (in units of the logging interval) between - * attempted data transmissions. NOTE: not implemented by this publisher! + * attempted data transmissions. + * @param initialTransmissions Number of transmissions to send immediately + * after each data point is logged (default: 5). + * + * @remark The sendEveryX and initialTransmissions parameters are not + * implemented by this publisher. Data will be sent every time the logger + * records data. */ UbidotsPublisher(Logger& baseLogger, Client* inClient, const char* authenticationToken, const char* deviceID, - int sendEveryX = 1); + int sendEveryX = 1, uint8_t initialTransmissions = 5); /** * @brief Construct a new Ubidots Publisher object * @@ -76,10 +82,17 @@ class UbidotsPublisher : public dataPublisher { * @param deviceID The device API Label from Ubidots, derived from the * user-specified device name. * @param sendEveryX Interval (in units of the logging interval) between - * attempted data transmissions. NOTE: not implemented by this publisher! + * attempted data transmissions. + * @param initialTransmissions Number of transmissions to send immediately + * after each data point is logged (default: 5). + * + * @remark The sendEveryX and initialTransmissions parameters are not + * implemented by this publisher. Data will be sent every time the logger + * records data. */ UbidotsPublisher(Logger& baseLogger, const char* authenticationToken, - const char* deviceID, int sendEveryX = 1); + const char* deviceID, int sendEveryX = 1, + uint8_t initialTransmissions = 5); /** * @brief Construct a new Ubidots Publisher object * @@ -88,9 +101,16 @@ class UbidotsPublisher : public dataPublisher { * Allows the use of any type of client and multiple clients tied to a * single TinyGSM modem instance * @param sendEveryX Interval (in units of the logging interval) between - * attempted data transmissions. NOTE: not implemented by this publisher! + * attempted data transmissions. + * @param initialTransmissions Number of transmissions to send immediately + * after each data point is logged (default: 5). + * + * @remark The sendEveryX and initialTransmissions parameters are not + * implemented by this publisher. Data will be sent every time the logger + * records data. */ - UbidotsPublisher(Logger& baseLogger, Client* inClient, int sendEveryX = 1); + UbidotsPublisher(Logger& baseLogger, Client* inClient, int sendEveryX = 1, + uint8_t initialTransmissions = 5); /** * @brief Construct a new Ubidots Publisher object * @@ -100,11 +120,19 @@ class UbidotsPublisher : public dataPublisher { * * @param baseLogger The logger supplying the data to be published * @param sendEveryX Interval (in units of the logging interval) between - * attempted data transmissions. NOTE: not implemented by this publisher! + * attempted data transmissions. + * @param initialTransmissions Number of transmissions to send immediately + * after each data point is logged (default: 5). + * + * @remark The sendEveryX and initialTransmissions parameters are not + * implemented by this publisher. Data will be sent every time the logger + * records data. */ - explicit UbidotsPublisher(Logger& baseLogger, int sendEveryX = 1); + explicit UbidotsPublisher(Logger& baseLogger, int sendEveryX = 1, + uint8_t initialTransmissions = 5); /** - * @brief Construct a new Ubidots Publisher object with no members set. + * @brief Construct a new Ubidots Publisher object with all members set to + * defaults or null. */ UbidotsPublisher(); /** From 6c63c53b63ba2bff85763d959f37eafa2e2711d8 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Thu, 5 Mar 2026 14:56:08 -0500 Subject: [PATCH 453/533] Rename retry related fxns/vars Signed-off-by: Sara Damiano --- ChangeLog.md | 2 +- src/SensorBase.cpp | 37 ++++++++++++++------------- src/SensorBase.h | 38 ++++++++++++++-------------- src/VariableArray.cpp | 31 ++++++++--------------- src/sensors/ANBpH.cpp | 10 ++++---- src/sensors/AOSongDHT.cpp | 2 +- src/sensors/TEConnectivityMS5837.cpp | 2 +- 7 files changed, 57 insertions(+), 65 deletions(-) diff --git a/ChangeLog.md b/ChangeLog.md index 2a1194ca3..bb8074806 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -174,7 +174,7 @@ This is *not* breaking because only AVR and SAMD processors were supported anywa - **Added support for retrying measurements for all sensors**. - Each sensor now supports a number of possible retry attempts for when the sensor returns a bad or no value. -The number of retry attempts can be set using the `setAllowedMeasurementRetries(uint8_t)` function. +The number of retry attempts can be set using the `setMaxRetries(uint8_t)` function. - The number of retries is independent of the number of measurements to average. A retry is performed when a sensor doesn't report a value or reports an error value. If multiple retries are needed, only the result of the final (successful) retry is stored. diff --git a/src/SensorBase.cpp b/src/SensorBase.cpp index 3d843d2db..c29ff8be3 100644 --- a/src/SensorBase.cpp +++ b/src/SensorBase.cpp @@ -87,17 +87,17 @@ void Sensor::setNumberMeasurementsToAverage(uint8_t nReadings) { uint8_t Sensor::getNumberMeasurementsToAverage() { return _measurementsToAverage; } -uint8_t Sensor::getNumberCompleteMeasurementsAttempts() { - return _measurementAttemptsCompleted; +uint8_t Sensor::getCompletedMeasurements() { + return _completedMeasurements; } -uint8_t Sensor::getNumberRetryAttemptsMade() { - return _retryAttemptsMade; +uint8_t Sensor::getCurrentRetries() { + return _currentRetries; } -void Sensor::setAllowedMeasurementRetries(uint8_t allowedMeasurementRetries) { - _allowedMeasurementRetries = allowedMeasurementRetries; +void Sensor::setMaxRetries(uint8_t maxRetries) { + _maxRetries = maxRetries; } -uint8_t Sensor::getAllowedMeasurementRetries() { - return _allowedMeasurementRetries; +uint8_t Sensor::getMaxRetries() { + return _maxRetries; } @@ -371,8 +371,8 @@ void Sensor::clearValues() { numberGoodMeasurementsMade[i] = 0; } // Reset measurement attempt counters - _measurementAttemptsCompleted = 0; - _retryAttemptsMade = 0; + _completedMeasurements = 0; + _currentRetries = 0; } // This clears power-related status bits and resets power timing. void Sensor::clearPowerStatus() { @@ -522,7 +522,7 @@ bool Sensor::update() { // bumpMeasurementAttemptCount() only after success or the last retry // attempt, so it's safe to check this value to determine if we have the // requested number of successful measurements. - while (_measurementAttemptsCompleted < _measurementsToAverage) { + while (_completedMeasurements < _measurementsToAverage) { // start a measurement ret_val &= startSingleMeasurement(); if (!getStatusBit(MEASUREMENT_SUCCESSFUL)) { @@ -536,8 +536,9 @@ bool Sensor::update() { waitForMeasurementCompletion(); // get the measurement result - this should call - // bumpMeasurementAttemptCount() and update the measurement attempt - // and retry counts as needed + // bumpMeasurementAttemptCount() to update the measurement attempt + // and retry counts as needed so we don't call that function + // directly here ret_val &= addSingleMeasurementResult(); } } @@ -665,7 +666,7 @@ bool Sensor::isStable(bool debug) { // If we're taking a repeat measurement, we may have already waited for // stabilization after the initial wake, so we can skip this wait. - if (_retryAttemptsMade != 0) { + if (_currentRetries != 0) { if (debug) { MS_DBG(getSensorNameAndLocation(), F("is retrying and doesn't need to stabilize again.")); @@ -746,14 +747,14 @@ bool Sensor::bumpMeasurementAttemptCount(bool wasSuccessful) { // Unset the status bits for a measurement request (bits 5 & 6) clearStatusBits(MEASUREMENT_ATTEMPTED, MEASUREMENT_SUCCESSFUL); // Bump the number of attempted retries - _retryAttemptsMade++; + _currentRetries++; - if (wasSuccessful || _retryAttemptsMade > _allowedMeasurementRetries) { + if (wasSuccessful || _currentRetries > _maxRetries) { // Bump the number of completed measurement attempts - we've succeeded // or failed but exceeded retries - _measurementAttemptsCompleted++; + _completedMeasurements++; // Reset the number of retries made for the next measurement attempt - _retryAttemptsMade = 0; + _currentRetries = 0; } // Return the input parameter so it's easy to use this in a return statement // to pass forward a value diff --git a/src/SensorBase.h b/src/SensorBase.h index 1b5ce9928..fa9d2c27c 100644 --- a/src/SensorBase.h +++ b/src/SensorBase.h @@ -200,31 +200,31 @@ class Sensor { * * @return The number of complete measurement attempts. */ - uint8_t getNumberCompleteMeasurementsAttempts(); + uint8_t getCompletedMeasurements(); /** - * @brief Get the number of retry attempts that have been made for a - * measurement + * @brief Get the number of retry attempts that have been made for the + * current measurement cycle * * @return The number of retries that have been made for the current - * measurement attempt. + * measurement cycle. * * @note What is "successful" vs what qualifies for a retry varies by * sensor. For some it may be that if any values were returned, for others * that a specific value is in range, etc. */ - uint8_t getNumberRetryAttemptsMade(); + uint8_t getCurrentRetries(); /** - * @brief Get the number of allowed retries if a measurement fails. + * @brief Get the maximum number of retries allowed if a measurement fails. * - * @return The number of allowed retries. + * @return The maximum number of allowed retries. */ - uint8_t getAllowedMeasurementRetries(); + uint8_t getMaxRetries(); /** - * @brief Set the number of retries if a measurement fails. + * @brief Set the maximum number of retries if a measurement fails. * - * @param allowedMeasurementRetries The number of allowed retries. + * @param maxRetries The maximum number of allowed retries. */ - void setAllowedMeasurementRetries(uint8_t allowedMeasurementRetries); + void setMaxRetries(uint8_t maxRetries); // _warmUpTime_ms _stabilizationTime_ms _measurementTime_ms @@ -524,7 +524,7 @@ class Sensor { * * This clears the values array by setting all values to #MS_INVALID_VALUE, * sets all values in numberGoodMeasurementsMade to 0, and resets the - * attempt (#_measurementAttemptsCompleted) and retry (#_retryAttemptsMade) + * attempt (#_completedMeasurements) and retry (#_currentRetries) * counts. */ void clearValues(); @@ -735,19 +735,19 @@ class Sensor { */ uint8_t _measurementsToAverage; /** - * @brief The number of measurement attempts completed in the current update + * @brief The number of measurement cycles completed in the current update * cycle (reset by clearValues()). */ - uint8_t _measurementAttemptsCompleted = 0; + uint8_t _completedMeasurements = 0; /** - * @brief The number of retries that have been attempted so far for a single - * measurement. + * @brief The number of retries that have been attempted so far for the + * current measurement cycle. */ - uint8_t _retryAttemptsMade = 0; + uint8_t _currentRetries = 0; /** - * @brief The number of allowed retries if a measurement fails. + * @brief The maximum number of retries allowed if a measurement fails. */ - uint8_t _allowedMeasurementRetries = 1; + uint8_t _maxRetries = 1; /** * @brief Array with the number of valid measurement values per variable by * the sensor in the current update cycle. diff --git a/src/VariableArray.cpp b/src/VariableArray.cpp index 834fd345a..ac10c383d 100644 --- a/src/VariableArray.cpp +++ b/src/VariableArray.cpp @@ -384,15 +384,11 @@ bool VariableArray::completeUpdate(bool powerUp, bool wake, bool sleep, #if defined(MS_VARIABLEARRAY_DEBUG) || defined(MS_VARIABLEARRAY_DEBUG_DEEP) String sName = sensorList[i]->getSensorNameAndLocation(); String cycCount = String(i) + '.' + - String(sensorList[i]->getNumberCompleteMeasurementsAttempts() + - 1) + - '.' + String(sensorList[i]->getNumberRetryAttemptsMade()); + String(sensorList[i]->getCompletedMeasurements() + 1) + '.' + + String(sensorList[i]->getCurrentRetries()); #endif // Skip sensors that have already completed all their measurements - if (sensorList[i]->getNumberCompleteMeasurementsAttempts() >= - nReq) { - continue; - } + if (sensorList[i]->getCompletedMeasurements() >= nReq) { continue; } // If attempts were made to wake the sensor, but they failed OR if // we're not waking the sensor but it is not already awake or the @@ -412,7 +408,7 @@ bool VariableArray::completeUpdate(bool powerUp, bool wake, bool sleep, // skipped in further loops. NOTE: These are protected members // of the Sensor class; we can only access them because the // VariableArray class is a friend of the Sensor class. - sensorList[i]->_measurementAttemptsCompleted = + sensorList[i]->_completedMeasurements = sensorList[i]->_measurementsToAverage; } @@ -493,8 +489,7 @@ bool VariableArray::completeUpdate(bool powerUp, bool wake, bool sleep, } // If all the measurements are now complete - if (sensorList[i]->getNumberCompleteMeasurementsAttempts() >= - nReq) { + if (sensorList[i]->getCompletedMeasurements() >= nReq) { if (sleep) { MS_DBG(i, F("--->> Finished all measurements from"), sName, F(", putting it to sleep. ...")); @@ -537,8 +532,7 @@ bool VariableArray::completeUpdate(bool powerUp, bool wake, bool sleep, sensorList[k]->getSecondaryPowerPin()))) // Check if sensor k still needs measurements && - (sensorList[k] - ->getNumberCompleteMeasurementsAttempts() < + (sensorList[k]->getCompletedMeasurements() < sensorList[k]->getNumberMeasurementsToAverage())) { // If sensors i and k share a primary power pin or a // secondary power pin and sensor k still needs @@ -577,8 +571,7 @@ bool VariableArray::completeUpdate(bool powerUp, bool wake, bool sleep, sensorList[i]->getSecondaryPowerPin() == sensorList[k] ->getSecondaryPowerPin()))) && - (sensorList[k] - ->getNumberCompleteMeasurementsAttempts() < + (sensorList[k]->getCompletedMeasurements() < sensorList[k] ->getNumberMeasurementsToAverage())) { MS_DBG( @@ -588,7 +581,7 @@ bool VariableArray::completeUpdate(bool powerUp, bool wake, bool sleep, sensorList[k] ->getNumberMeasurementsToAverage() - sensorList[k] - ->getNumberCompleteMeasurementsAttempts(), + ->getCompletedMeasurements(), F("measurements.")); MS_DBG(sName, '(', i, ')', F("pins are"), sensorList[i]->getPowerPin(), F("and"), @@ -608,11 +601,9 @@ bool VariableArray::completeUpdate(bool powerUp, bool wake, bool sleep, MS_DBG(F("*****---"), nSensorsCompleted, F("sensors now complete ---*****")); } else { - MS_DEEP_DBG( - i, F("--->>"), sName, F("still needs to take"), - nReq - - sensorList[i]->getNumberCompleteMeasurementsAttempts(), - F("measurements.")); + MS_DEEP_DBG(i, F("--->>"), sName, F("still needs to take"), + nReq - sensorList[i]->getCompletedMeasurements(), + F("measurements.")); } } MS_DEEP_DBG(F("xxxxx---"), _sensorCount - nSensorsCompleted, diff --git a/src/sensors/ANBpH.cpp b/src/sensors/ANBpH.cpp index 0861b7edc..51c5cc9d0 100644 --- a/src/sensors/ANBpH.cpp +++ b/src/sensors/ANBpH.cpp @@ -26,7 +26,7 @@ ANBpH::ANBpH(byte modbusAddress, Stream* stream, int8_t powerPin, _anb_sensor.setDebugStream(&MS_SERIAL_OUTPUT); #endif setSecondaryPowerPin(powerPin2); - setAllowedMeasurementRetries(ANB_PH_DEFAULT_MEASUREMENT_RETRIES); + setMaxRetries(ANB_PH_DEFAULT_MEASUREMENT_RETRIES); } // Delegating constructor ANBpH::ANBpH(byte modbusAddress, Stream& stream, int8_t powerPin, @@ -396,7 +396,7 @@ bool ANBpH::addSingleMeasurementResult() { health == ANBHealthCode::NOT_IMMERSED); // Put values into the array - if it's a success or our last try - if (success || _retryAttemptsMade >= _allowedMeasurementRetries) { + if (success || _currentRetries >= _maxRetries) { verifyAndAddMeasurementResult(ANB_PH_PH_VAR_NUM, pH); verifyAndAddMeasurementResult(ANB_PH_TEMP_VAR_NUM, temp); verifyAndAddMeasurementResult(ANB_PH_SALINITY_VAR_NUM, sal); @@ -487,7 +487,7 @@ bool ANBpH::isWarmedUp(bool debug) { } uint32_t ANBpH::getStartMeasurementWindow() { - if (_powerPin >= 0 && _retryAttemptsMade == 0) { + if (_powerPin >= 0 && _currentRetries == 0) { if (_salinityMode == ANBSalinityMode::HIGH_SALINITY) { return ANB_PH_1ST_VALUE_HIGH_SALT; } else { @@ -503,7 +503,7 @@ uint32_t ANBpH::getStartMeasurementWindow() { // If a pin was provided for power, we assume it's on-demand powered and use // the maximum wait time for the first measurement as our maximum wait. uint32_t ANBpH::getEndMeasurementWindow() { - if (_powerPin >= 0 && _retryAttemptsMade == 0) { + if (_powerPin >= 0 && _currentRetries == 0) { if (_salinityMode == ANBSalinityMode::HIGH_SALINITY) { return ANB_PH_1ST_VALUE_HIGH_SALT_MAX; } else { @@ -539,7 +539,7 @@ bool ANBpH::isMeasurementComplete(bool debug) { // After the first measurement, the sensor will always report that a // measurement is ready, but a new value will not be available for at // least 10.5 (high salinity) or 14 (low salinity) seconds. - if (_retryAttemptsMade > 0) { + if (_currentRetries > 0) { if (elapsed_since_meas_start > _measurementTime_ms) { if (debug) { MS_DBG(F("It's been"), elapsed_since_meas_start, diff --git a/src/sensors/AOSongDHT.cpp b/src/sensors/AOSongDHT.cpp index ccda78537..4422b1fd9 100644 --- a/src/sensors/AOSongDHT.cpp +++ b/src/sensors/AOSongDHT.cpp @@ -19,7 +19,7 @@ AOSongDHT::AOSongDHT(int8_t powerPin, int8_t dataPin, const uint8_t type, dataPin, measurementsToAverage, DHT_INC_CALC_VARIABLES), dht_internal(dataPin, type), _dhtType(type) { - setAllowedMeasurementRetries(DHT_DEFAULT_MEASUREMENT_RETRIES); + setMaxRetries(DHT_DEFAULT_MEASUREMENT_RETRIES); } diff --git a/src/sensors/TEConnectivityMS5837.cpp b/src/sensors/TEConnectivityMS5837.cpp index 02e61ce25..921b8a831 100644 --- a/src/sensors/TEConnectivityMS5837.cpp +++ b/src/sensors/TEConnectivityMS5837.cpp @@ -28,7 +28,7 @@ TEConnectivityMS5837::TEConnectivityMS5837(TwoWire* theI2C, int8_t powerPin, _fluidDensity(fluidDensity), _airPressure(airPressure), _overSamplingRatio(overSamplingRatio) { - setAllowedMeasurementRetries(MS5837_DEFAULT_MEASUREMENT_RETRIES); + setMaxRetries(MS5837_DEFAULT_MEASUREMENT_RETRIES); } // Delegating constructors From 3e73f7efdc0761b6144f648ba3900f19f15527d2 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Thu, 5 Mar 2026 14:56:30 -0500 Subject: [PATCH 454/533] format Signed-off-by: Sara Damiano --- src/modems/SIMComSIM7080.h | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/modems/SIMComSIM7080.h b/src/modems/SIMComSIM7080.h index e5a543174..72e4c699e 100644 --- a/src/modems/SIMComSIM7080.h +++ b/src/modems/SIMComSIM7080.h @@ -194,10 +194,11 @@ class SIMComSIM7080 : public loggerModem { void deleteClient(Client* client) override; Client* createSecureClient() override; void deleteSecureClient(Client* client) override; - Client* createSecureClient( - SSLAuthMode sslAuthMode, SSLVersion sslVersion = SSLVersion::TLS1_2, - const char* CAcertName = nullptr, const char* clientCertName = nullptr, - const char* clientKeyName = nullptr) override; + Client* createSecureClient(SSLAuthMode sslAuthMode, + SSLVersion sslVersion = SSLVersion::TLS1_2, + const char* CAcertName = nullptr, + const char* clientCertName = nullptr, + const char* clientKeyName = nullptr) override; Client* createSecureClient(const char* pskIdent, const char* psKey, SSLVersion sslVersion = SSLVersion::TLS1_2) override; From 426ab655fd4aa39505a9a0c87516245ed80f3256 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Thu, 5 Mar 2026 14:59:45 -0500 Subject: [PATCH 455/533] Allow temp of 0, verified that TinyGSM should return -9999 for bad temp Signed-off-by: Sara Damiano --- src/modems/DigiXBeeWifi.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/modems/DigiXBeeWifi.cpp b/src/modems/DigiXBeeWifi.cpp index ae8a5d1b3..728157d3c 100644 --- a/src/modems/DigiXBeeWifi.cpp +++ b/src/modems/DigiXBeeWifi.cpp @@ -523,7 +523,9 @@ bool DigiXBeeWifi::updateModemMetadata() { MS_DBG(F("CURRENT Modem temperature(C):"), loggerModem::_priorModemTemp); - success &= ((chip_temp != MS_INVALID_VALUE) && (chip_temp != 0)); + // TinyGSM returns -9999 when it fails to get a temperature reading, so + // check for that as well as the invalid value + success &= ((chip_temp != MS_INVALID_VALUE) && (chip_temp != -9999)); } else { MS_DBG(F("Polling for modem chip temperature is disabled")); } From 8bf5d099759e2797736c44974946232090532209 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Thu, 5 Mar 2026 15:22:14 -0500 Subject: [PATCH 456/533] Fix overflow compiler warning Signed-off-by: Sara Damiano --- src/ClockSupport.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/ClockSupport.cpp b/src/ClockSupport.cpp index fef5d36d8..484a4403b 100644 --- a/src/ClockSupport.cpp +++ b/src/ClockSupport.cpp @@ -660,10 +660,12 @@ int16_t loggerClock::getProcessorTimeZone() { // casting. If the timeY2K is less than 24 hours, it's a positive offset of // that many seconds. If it's more than 24 hours, it's a negative offset of // tz_offset (because the time would have rolled back to the previous day). - int16_t tz_offset; - if (timeY2K < 60 * 60 * 24) { + int16_t tz_offset; + const time_t secondsInDay = 60L * 60L * 24L; // 86400 seconds in a day + if (timeY2K < secondsInDay) { tz_offset = static_cast(timeY2K); - } else if (-1 * timeY2K < 60 * 60 * 24) { // force roll-over and check size + } else if ((-1 * timeY2K) < + secondsInDay) { // force roll-over and check size tz_offset = static_cast(-1 * (-1 * timeY2K)); } else { // If the difference is more than 24 hours, something is wrong and // we should just return 0 (UTC) From 1dab51f9145b59a6accdb57d5f10fd0bae779b4c Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Thu, 5 Mar 2026 15:23:23 -0500 Subject: [PATCH 457/533] Added a config for MAX_NUMBER_SENSORS Signed-off-by: Sara Damiano --- src/ModSensorConfig.h | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/ModSensorConfig.h b/src/ModSensorConfig.h index 0dbb8e8a8..84d85bdf9 100644 --- a/src/ModSensorConfig.h +++ b/src/ModSensorConfig.h @@ -81,12 +81,16 @@ */ #define MS_INVALID_VALUE -9999 #endif + #ifndef MAX_NUMBER_VARS /** * @brief The largest number of variables from a single sensor. * * Every sensor will create a buffer of this length for holding variable values. * Decrease this value to save a memory. + * + * @note This is the maximum number of variables that can be tied to any one + * sensor, not the maximum number of variables in a variable array. */ #define MAX_NUMBER_VARS 21 // GroPoint Profile GPLP-8 has 8 Moisture and 13 Temperature values @@ -95,6 +99,28 @@ // number of variables from any sensor. Anything more is a waste of memory. static_assert(MAX_NUMBER_VARS > 0 && MAX_NUMBER_VARS <= 21, "MAX_NUMBER_VARS must be between 1 and 21"); + +#ifndef MAX_NUMBER_SENSORS +/** + * @brief The largest number of sensors in a single variable array. + * + * @note This iS **not** the same as the maximum number of variables in a + * variable array. One sensor may return many variables but only counts as one + * sensor. + * + * Decrease this value to save memory if you know you'll use fewer sensors. + * Increase if you need to support more sensors in a single array. + */ +#define MAX_NUMBER_SENSORS 20 +#endif +// Static assert to ensure the maximum number of sensors is reasonable +static_assert(MAX_NUMBER_SENSORS > 0 && MAX_NUMBER_SENSORS <= 50, + "MAX_NUMBER_SENSORS must be between 1 and 50"); +//============================================================== + + +//============================================================== +// User button functionality //============================================================== #ifndef MS_LOGGERBASE_BUTTON_BENCH_TEST /** @@ -266,6 +292,7 @@ static_assert(MS_DEFAULT_ADS1X15_ADDRESS == 0x48 || "for ADS1X15"); //============================================================== + //============================================================== // SDI-12 Configuration //============================================================== From dd6e5f94fcca75b0432fadecaa5b6e33c9d30bc9 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Thu, 5 Mar 2026 15:27:23 -0500 Subject: [PATCH 458/533] Made the sensor list a parameter of the variableArray Signed-off-by: Sara Damiano --- src/VariableArray.cpp | 190 +++++++++++++++++++++++------------------- src/VariableArray.h | 15 ++++ 2 files changed, 119 insertions(+), 86 deletions(-) diff --git a/src/VariableArray.cpp b/src/VariableArray.cpp index ac10c383d..b49aeeff5 100644 --- a/src/VariableArray.cpp +++ b/src/VariableArray.cpp @@ -24,6 +24,7 @@ VariableArray::VariableArray(uint8_t variableCount, Variable* variableList[]) : arrayOfVars(variableList), _variableCount(variableCount) { _sensorCount = getSensorCount(); + populateSensorList(); } // Default constructor with no arguments - delegates to ensure all members are // initialized @@ -36,6 +37,7 @@ void VariableArray::begin(uint8_t variableCount, Variable* variableList[], arrayOfVars = variableList; _sensorCount = getSensorCount(); + populateSensorList(); matchUUIDs(uuids); checkVariableUUIDs(); } @@ -44,10 +46,12 @@ void VariableArray::begin(uint8_t variableCount, Variable* variableList[]) { arrayOfVars = variableList; _sensorCount = getSensorCount(); + populateSensorList(); checkVariableUUIDs(); } void VariableArray::begin() { _sensorCount = getSensorCount(); + populateSensorList(); checkVariableUUIDs(); } @@ -80,6 +84,30 @@ void VariableArray::matchUUIDs(const char* uuids[]) { } } +// This populates the internal sensor list from the variable array +bool VariableArray::populateSensorList() { + uint8_t addedSensors = 0; + for (uint8_t i = 0; i < _variableCount; i++) { + if (isLastVarFromSensor(i)) { + if (addedSensors >= _sensorCount || + addedSensors >= MAX_NUMBER_SENSORS) { + // Unfortunately silent so this can be run in the constructor + // before the serial port is set up. + return false; + } + _sensorList[addedSensors++] = arrayOfVars[i]->parentSensor; + } + } + + if (addedSensors != _sensorCount) { + // Unfortunately silent so this can be run in the constructor + // before the serial port is set up. + return false; + } + + return true; +} + // Public functions for interfacing with a list of sensors // This sets up all of the sensors in the list // NOTE: Calculated variables will always be skipped in this process because @@ -297,28 +325,12 @@ bool VariableArray::completeUpdate(bool powerUp, bool wake, bool sleep, bool deepDebugTiming = false; #endif - MS_DBG(F("Creating an array of pointers to the sensors..")); - Sensor* sensorList[_sensorCount]; - uint8_t addedSensors = 0; - for (uint8_t i = 0; i < _variableCount; i++) { - if (isLastVarFromSensor(i)) { - if (addedSensors >= _sensorCount) { - MS_DBG(F("ERROR: More unique sensors found than expected!")); - return false; - } - sensorList[addedSensors++] = arrayOfVars[i]->parentSensor; - } - } - if (addedSensors != _sensorCount) { - MS_DBG(F("ERROR: Expected"), _sensorCount, F("sensors but found"), - addedSensors); - return false; - } + MS_DBG(F("Using internal sensor list for measurements...")); #if defined(MS_VARIABLEARRAY_DEBUG) || defined(MS_VARIABLEARRAY_DEBUG_DEEP) for (uint8_t i = 0; i < _sensorCount; i++) { MS_DBG(F(" Sensor"), i, F("is"), - sensorList[i]->getSensorNameAndLocation()); + _sensorList[i]->getSensorNameAndLocation()); } #endif @@ -330,7 +342,7 @@ bool VariableArray::completeUpdate(bool powerUp, bool wake, bool sleep, F("----->> Clearing all power status bits before taking new " "measurements. ...")); for (uint8_t i = 0; i < _sensorCount; i++) { - sensorList[i]->clearPowerStatus(); + _sensorList[i]->clearPowerStatus(); } MS_DEEP_DBG(F(" ... Complete. <<-----")); @@ -346,7 +358,7 @@ bool VariableArray::completeUpdate(bool powerUp, bool wake, bool sleep, // wake check or wake function will work correctly. MS_DBG(F("----->> Checking the power state of all sensor. ...")); for (uint8_t i = 0; i < _sensorCount; i++) { - sensorList[i]->checkPowerOn(); + _sensorList[i]->checkPowerOn(); } MS_DBG(F(" ... Complete. <<-----")); } @@ -367,7 +379,7 @@ bool VariableArray::completeUpdate(bool powerUp, bool wake, bool sleep, MS_DEEP_DBG(F("----->> Clearing all measurement status bits before taking " "new measurements. ...")); for (uint8_t i = 0; i < _sensorCount; i++) { - sensorList[i]->clearMeasurementStatus(); + _sensorList[i]->clearMeasurementStatus(); } MS_DEEP_DBG(F(" ... Complete. <<-----")); @@ -375,29 +387,34 @@ bool VariableArray::completeUpdate(bool powerUp, bool wake, bool sleep, // attempt and retry counts. MS_DBG(F("----->> Clearing all results arrays before taking new " "measurements. ...")); - for (uint8_t i = 0; i < _sensorCount; i++) { sensorList[i]->clearValues(); } + for (uint8_t i = 0; i < _sensorCount; i++) { + _sensorList[i]->clearValues(); + } MS_DBG(F(" ... Complete. <<-----")); while (nSensorsCompleted < _sensorCount) { for (uint8_t i = 0; i < _sensorCount; i++) { - uint8_t nReq = sensorList[i]->getNumberMeasurementsToAverage(); + uint8_t nReq = _sensorList[i]->getNumberMeasurementsToAverage(); #if defined(MS_VARIABLEARRAY_DEBUG) || defined(MS_VARIABLEARRAY_DEBUG_DEEP) - String sName = sensorList[i]->getSensorNameAndLocation(); + String sName = _sensorList[i]->getSensorNameAndLocation(); String cycCount = String(i) + '.' + - String(sensorList[i]->getCompletedMeasurements() + 1) + '.' + - String(sensorList[i]->getCurrentRetries()); + String(_sensorList[i]->getCompletedMeasurements() + 1) + '.' + + String(_sensorList[i]->getCurrentRetries()); #endif // Skip sensors that have already completed all their measurements - if (sensorList[i]->getCompletedMeasurements() >= nReq) { continue; } + if (_sensorList[i]->getCompletedMeasurements() >= nReq) { + continue; + } // If attempts were made to wake the sensor, but they failed OR if // we're not waking the sensor but it is not already awake or the // previous wake attempts failed... - if ((sensorList[i]->getStatusBit(Sensor::WAKE_ATTEMPTED) == 1 && - sensorList[i]->getStatusBit(Sensor::WAKE_SUCCESSFUL) == 0) || + if ((_sensorList[i]->getStatusBit(Sensor::WAKE_ATTEMPTED) == 1 && + _sensorList[i]->getStatusBit(Sensor::WAKE_SUCCESSFUL) == 0) || (!wake && - (sensorList[i]->getStatusBit(Sensor::WAKE_ATTEMPTED) == 0 || - sensorList[i]->getStatusBit(Sensor::WAKE_SUCCESSFUL) == 0))) { + (_sensorList[i]->getStatusBit(Sensor::WAKE_ATTEMPTED) == 0 || + _sensorList[i]->getStatusBit(Sensor::WAKE_SUCCESSFUL) == + 0))) { MS_DBG(i, F("--->>"), sName, F("failed to wake up! No measurements will be taken! " "<<---"), @@ -408,22 +425,22 @@ bool VariableArray::completeUpdate(bool powerUp, bool wake, bool sleep, // skipped in further loops. NOTE: These are protected members // of the Sensor class; we can only access them because the // VariableArray class is a friend of the Sensor class. - sensorList[i]->_completedMeasurements = - sensorList[i]->_measurementsToAverage; + _sensorList[i]->_completedMeasurements = + _sensorList[i]->_measurementsToAverage; } if (wake // ^^ if we're supposed to wake the sensors - && sensorList[i]->getStatusBit(Sensor::WAKE_ATTEMPTED) == 0 + && _sensorList[i]->getStatusBit(Sensor::WAKE_ATTEMPTED) == 0 // ^^ And no attempts yet made to wake the sensor up - && sensorList[i]->isWarmedUp(deepDebugTiming) + && _sensorList[i]->isWarmedUp(deepDebugTiming) // ^^ and if it is already warmed up ) { MS_DBG(i, F("--->> Waking"), sName, F("...")); // Make a single attempt to wake the sensor after it is // warmed up - bool sensorSuccess_wake = sensorList[i]->wake(); + bool sensorSuccess_wake = _sensorList[i]->wake(); success &= sensorSuccess_wake; if (sensorSuccess_wake) { @@ -435,18 +452,18 @@ bool VariableArray::completeUpdate(bool powerUp, bool wake, bool sleep, // If the sensor was successfully awoken/activated, but no // measurement was either started or finished ... - if (sensorList[i]->getStatusBit(Sensor::WAKE_SUCCESSFUL) == 1 && - sensorList[i]->getStatusBit(Sensor::MEASUREMENT_ATTEMPTED) == + if (_sensorList[i]->getStatusBit(Sensor::WAKE_SUCCESSFUL) == 1 && + _sensorList[i]->getStatusBit(Sensor::MEASUREMENT_ATTEMPTED) == 0 && - sensorList[i]->getStatusBit(Sensor::MEASUREMENT_SUCCESSFUL) == + _sensorList[i]->getStatusBit(Sensor::MEASUREMENT_SUCCESSFUL) == 0) { // .. check if it's stable - if (sensorList[i]->isStable(deepDebugTiming)) { + if (_sensorList[i]->isStable(deepDebugTiming)) { MS_DBG(cycCount, F("--->> Starting reading on"), sName, F("...")); bool sensorSuccess_start = - sensorList[i]->startSingleMeasurement(); + _sensorList[i]->startSingleMeasurement(); success &= sensorSuccess_start; if (sensorSuccess_start) { @@ -463,18 +480,18 @@ bool VariableArray::completeUpdate(bool powerUp, bool wake, bool sleep, // successfully... // We aren't checking if the measurement start was successful; // isMeasurementComplete(deepDebugTiming) will do that. - if (sensorList[i]->getStatusBit(Sensor::MEASUREMENT_ATTEMPTED) == + if (_sensorList[i]->getStatusBit(Sensor::MEASUREMENT_ATTEMPTED) == 1) { // If a measurement is finished, get the result and tick up // the number of finished measurements. - if (sensorList[i]->isMeasurementComplete(deepDebugTiming)) { + if (_sensorList[i]->isMeasurementComplete(deepDebugTiming)) { // Get the value MS_DBG(cycCount, F("--->> Collected result of reading from"), sName, F("...")); bool sensorSuccess_result = - sensorList[i]->addSingleMeasurementResult(); + _sensorList[i]->addSingleMeasurementResult(); success &= sensorSuccess_result; if (sensorSuccess_result) { @@ -489,19 +506,20 @@ bool VariableArray::completeUpdate(bool powerUp, bool wake, bool sleep, } // If all the measurements are now complete - if (sensorList[i]->getCompletedMeasurements() >= nReq) { + if (_sensorList[i]->getCompletedMeasurements() >= nReq) { if (sleep) { MS_DBG(i, F("--->> Finished all measurements from"), sName, F(", putting it to sleep. ...")); // Put the completed sensor to sleep - bool sensorSuccess_sleep = sensorList[i]->sleep(); + bool sensorSuccess_sleep = _sensorList[i]->sleep(); success &= sensorSuccess_sleep; if (sensorSuccess_sleep) { MS_DBG(F(" ... succeeded in putting sensor to sleep. " "Total wake time was"), - millis() - sensorList[i]->_millisSensorActivated, + millis() - + _sensorList[i]->_millisSensorActivated, F("ms <<---"), i); } else { MS_DBG(F(" ... sleep failed! <<---"), i); @@ -517,23 +535,23 @@ bool VariableArray::completeUpdate(bool powerUp, bool wake, bool sleep, if (( // Check if sensor i's primary pin matches // either of sensor k's pins - (sensorList[i]->getPowerPin() >= 0 && - (sensorList[i]->getPowerPin() == - sensorList[k]->getPowerPin() || - sensorList[i]->getPowerPin() == - sensorList[k]->getSecondaryPowerPin())) + (_sensorList[i]->getPowerPin() >= 0 && + (_sensorList[i]->getPowerPin() == + _sensorList[k]->getPowerPin() || + _sensorList[i]->getPowerPin() == + _sensorList[k]->getSecondaryPowerPin())) // Check if sensor i's secondary pin matches // either of sensor k's pins || - (sensorList[i]->getSecondaryPowerPin() >= 0 && - (sensorList[i]->getSecondaryPowerPin() == - sensorList[k]->getPowerPin() || - sensorList[i]->getSecondaryPowerPin() == - sensorList[k]->getSecondaryPowerPin()))) + (_sensorList[i]->getSecondaryPowerPin() >= 0 && + (_sensorList[i]->getSecondaryPowerPin() == + _sensorList[k]->getPowerPin() || + _sensorList[i]->getSecondaryPowerPin() == + _sensorList[k]->getSecondaryPowerPin()))) // Check if sensor k still needs measurements - && - (sensorList[k]->getCompletedMeasurements() < - sensorList[k]->getNumberMeasurementsToAverage())) { + && (_sensorList[k]->getCompletedMeasurements() < + _sensorList[k] + ->getNumberMeasurementsToAverage())) { // If sensors i and k share a primary power pin or a // secondary power pin and sensor k still needs // measurements, sensor i can't be powered down @@ -541,7 +559,7 @@ bool VariableArray::completeUpdate(bool powerUp, bool wake, bool sleep, break; // stop looping after finding a conflict } } - if (canPowerDown) { sensorList[i]->powerDown(); } + if (canPowerDown) { _sensorList[i]->powerDown(); } #if defined(MS_VARIABLEARRAY_DEBUG) if (canPowerDown) { MS_DBG( @@ -549,30 +567,30 @@ bool VariableArray::completeUpdate(bool powerUp, bool wake, bool sleep, F("are complete and no other sensors on the same " "power pin need to take measurements. " "Powered down all sensors on pin"), - sensorList[i]->getPowerPin(), F("or pin"), - sensorList[i]->getSecondaryPowerPin(), F("...")); + _sensorList[i]->getPowerPin(), F("or pin"), + _sensorList[i]->getSecondaryPowerPin(), F("...")); } else { MS_DBG(i, F("--->> All measurements from"), sName, F("are complete but other sensors on the same " "power pin still need to take measurements. " "Leaving power on pin"), - sensorList[i]->getPowerPin(), F("ON. <<---")); + _sensorList[i]->getPowerPin(), F("ON. <<---")); // Find and report which sensor still needs measurements for (uint8_t k = 0; k < _sensorCount; k++) { - if (((sensorList[i]->getPowerPin() >= 0 && - (sensorList[i]->getPowerPin() == - sensorList[k]->getPowerPin() || - sensorList[i]->getPowerPin() == - sensorList[k] + if (((_sensorList[i]->getPowerPin() >= 0 && + (_sensorList[i]->getPowerPin() == + _sensorList[k]->getPowerPin() || + _sensorList[i]->getPowerPin() == + _sensorList[k] ->getSecondaryPowerPin())) || - (sensorList[i]->getSecondaryPowerPin() >= 0 && - (sensorList[i]->getSecondaryPowerPin() == - sensorList[k]->getPowerPin() || - sensorList[i]->getSecondaryPowerPin() == - sensorList[k] + (_sensorList[i]->getSecondaryPowerPin() >= 0 && + (_sensorList[i]->getSecondaryPowerPin() == + _sensorList[k]->getPowerPin() || + _sensorList[i]->getSecondaryPowerPin() == + _sensorList[k] ->getSecondaryPowerPin()))) && - (sensorList[k]->getCompletedMeasurements() < - sensorList[k] + (_sensorList[k]->getCompletedMeasurements() < + _sensorList[k] ->getNumberMeasurementsToAverage())) { MS_DBG( sName, F("shares a power pin with"), @@ -584,13 +602,13 @@ bool VariableArray::completeUpdate(bool powerUp, bool wake, bool sleep, ->getCompletedMeasurements(), F("measurements.")); MS_DBG(sName, '(', i, ')', F("pins are"), - sensorList[i]->getPowerPin(), F("and"), - sensorList[i]->getSecondaryPowerPin()); + _sensorList[i]->getPowerPin(), F("and"), + _sensorList[i]->getSecondaryPowerPin()); MS_DBG( - sensorList[k]->getSensorNameAndLocation(), + _sensorList[k]->getSensorNameAndLocation(), '(', k, ')', F("pins are"), - sensorList[k]->getPowerPin(), F("and"), - sensorList[k]->getSecondaryPowerPin()); + _sensorList[k]->getPowerPin(), F("and"), + _sensorList[k]->getSecondaryPowerPin()); break; } } @@ -602,7 +620,7 @@ bool VariableArray::completeUpdate(bool powerUp, bool wake, bool sleep, F("sensors now complete ---*****")); } else { MS_DEEP_DBG(i, F("--->>"), sName, F("still needs to take"), - nReq - sensorList[i]->getCompletedMeasurements(), + nReq - _sensorList[i]->getCompletedMeasurements(), F("measurements.")); } } @@ -614,11 +632,11 @@ bool VariableArray::completeUpdate(bool powerUp, bool wake, bool sleep, MS_DBG(F("----->> Averaging results and notifying all variables. ...")); for (uint8_t i = 0; i < _sensorCount; i++) { MS_DBG(F("--- Averaging results from"), - sensorList[i]->getSensorNameAndLocation(), F("---")); - sensorList[i]->averageMeasurements(); + _sensorList[i]->getSensorNameAndLocation(), F("---")); + _sensorList[i]->averageMeasurements(); MS_DBG(F("--- Notifying variables from"), - sensorList[i]->getSensorNameAndLocation(), F("---")); - sensorList[i]->notifyVariables(); + _sensorList[i]->getSensorNameAndLocation(), F("---")); + _sensorList[i]->notifyVariables(); } MS_DBG(F("... Complete. <<-----")); diff --git a/src/VariableArray.h b/src/VariableArray.h index 190ae5024..8dbb00fbc 100644 --- a/src/VariableArray.h +++ b/src/VariableArray.h @@ -324,6 +324,21 @@ class VariableArray { bool getSensorStatusBit(int arrayIndex, Sensor::sensor_status_bits bitToGet); + /** + * @brief Populate the internal sensor list from the variable array + * + * This extracts unique sensors from the variable array and stores them + * in the internal sensor list for efficient access during operations. + * + * @return True if the sensor list was populated successfully + */ + bool populateSensorList(); + + /** + * @brief Array of pointers to unique sensors derived from variables + */ + Sensor* _sensorList[MAX_NUMBER_SENSORS]; + #ifdef MS_VARIABLEARRAY_DEBUG_DEEP /** * @brief Prints out the contents of an array with even spaces and commas From 2e471938657db39f39fa2c2edf11cd60ef13084a Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Thu, 5 Mar 2026 15:39:52 -0500 Subject: [PATCH 459/533] Modify sensorsPowerUp, sensorsWake, sensorsSleep, and sensorsPowerDown to use the _sensorList Signed-off-by: Sara Damiano --- src/VariableArray.cpp | 63 +++++++++++++++---------------------------- 1 file changed, 22 insertions(+), 41 deletions(-) diff --git a/src/VariableArray.cpp b/src/VariableArray.cpp index b49aeeff5..5d7b8c641 100644 --- a/src/VariableArray.cpp +++ b/src/VariableArray.cpp @@ -183,13 +183,9 @@ bool VariableArray::setupSensors() { // sensor. void VariableArray::sensorsPowerUp() { MS_DBG(F("Powering up sensors...")); - for (uint8_t i = 0; i < _variableCount; i++) { - if (isLastVarFromSensor(i)) { // Skip non-unique sensors - MS_DBG(F(" Powering up"), - arrayOfVars[i]->getParentSensorNameAndLocation()); - - arrayOfVars[i]->parentSensor->powerUp(); - } + for (uint8_t i = 0; i < _sensorCount; i++) { + MS_DBG(F(" Powering up"), _sensorList[i]->getSensorNameAndLocation()); + _sensorList[i]->powerUp(); } } @@ -212,13 +208,10 @@ bool VariableArray::sensorsWake() { // Check for any sensors that are awake outside of being sent a "wake" // command - for (uint8_t i = 0; i < _variableCount; i++) { - if (isLastVarFromSensor(i) // Skip non-unique sensors - && getSensorStatusBit(i, Sensor::WAKE_ATTEMPTED) == - 1 // already attempted to wake - ) { + for (uint8_t i = 0; i < _sensorCount; i++) { + if (_sensorList[i]->getStatusBit(Sensor::WAKE_ATTEMPTED) == 1) { MS_DBG(F(" Wake up of"), - arrayOfVars[i]->getParentSensorNameAndLocation(), + _sensorList[i]->getSensorNameAndLocation(), F("has already been attempted.")); nSensorsAwake++; } @@ -229,20 +222,15 @@ bool VariableArray::sensorsWake() { // up and increment the counter marking that's been done. // We keep looping until they've all been done. while (nSensorsAwake < _sensorCount) { - for (uint8_t i = 0; i < _variableCount; i++) { - if (isLastVarFromSensor(i) // Skip non-unique sensors - && getSensorStatusBit(i, Sensor::WAKE_ATTEMPTED) == - 0 // If no attempts yet made to wake the sensor up - && arrayOfVars[i]->parentSensor->isWarmedUp( - deepDebugTiming) // and if it is already warmed up - ) { - MS_DBG(F(" Wake up of"), - arrayOfVars[i]->getParentSensorNameAndLocation(), + for (uint8_t i = 0; i < _sensorCount; i++) { + if (_sensorList[i]->getStatusBit(Sensor::WAKE_ATTEMPTED) == 0 && + _sensorList[i]->isWarmedUp(deepDebugTiming)) { + MS_DBG(F(" Wake up of"), _sensorList[i]->getSensorNameAndLocation(), F("...")); // Make a single attempt to wake the sensor after it is // warmed up - bool sensorSuccess = arrayOfVars[i]->parentSensor->wake(); + bool sensorSuccess = _sensorList[i]->wake(); success &= sensorSuccess; // We increment up the number of sensors awake/active, // even if the wake up command failed! @@ -269,19 +257,16 @@ bool VariableArray::sensorsWake() { bool VariableArray::sensorsSleep() { MS_DBG(F("Putting sensors to sleep...")); bool success = true; - for (uint8_t i = 0; i < _variableCount; i++) { - if (isLastVarFromSensor(i)) { // Skip non-unique sensors - MS_DBG(F(" "), arrayOfVars[i]->getParentSensorNameAndLocation(), - F("...")); + for (uint8_t i = 0; i < _sensorCount; i++) { + MS_DBG(F(" "), _sensorList[i]->getSensorNameAndLocation(), F("...")); - bool sensorSuccess = arrayOfVars[i]->parentSensor->sleep(); - success &= sensorSuccess; + bool sensorSuccess = _sensorList[i]->sleep(); + success &= sensorSuccess; - if (sensorSuccess) { - MS_DBG(F(" ... successfully put to sleep.")); - } else { - MS_DBG(F(" ... failed to sleep!")); - } + if (sensorSuccess) { + MS_DBG(F(" ... successfully put to sleep.")); + } else { + MS_DBG(F(" ... failed to sleep!")); } } return success; @@ -295,13 +280,9 @@ bool VariableArray::sensorsSleep() { // sensor. void VariableArray::sensorsPowerDown() { MS_DBG(F("Powering down sensors...")); - for (uint8_t i = 0; i < _variableCount; i++) { - if (isLastVarFromSensor(i)) { // Skip non-unique sensors - MS_DBG(F(" Powering down"), - arrayOfVars[i]->getParentSensorNameAndLocation()); - - arrayOfVars[i]->parentSensor->powerDown(); - } + for (uint8_t i = 0; i < _sensorCount; i++) { + MS_DBG(F(" Powering down"), _sensorList[i]->getSensorNameAndLocation()); + _sensorList[i]->powerDown(); } } From b39631332b67c7fe16448c0177abc8d24a910614 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Thu, 5 Mar 2026 15:44:06 -0500 Subject: [PATCH 460/533] Check for matching pointers, instead of rechecking isLastVarFromSensor Signed-off-by: Sara Damiano --- src/VariableArray.cpp | 48 +++++++++++++++++++++++++------------------ src/VariableArray.h | 1 - 2 files changed, 28 insertions(+), 21 deletions(-) diff --git a/src/VariableArray.cpp b/src/VariableArray.cpp index 5d7b8c641..0e5f0a360 100644 --- a/src/VariableArray.cpp +++ b/src/VariableArray.cpp @@ -23,7 +23,6 @@ VariableArray::VariableArray(uint8_t variableCount, Variable* variableList[], VariableArray::VariableArray(uint8_t variableCount, Variable* variableList[]) : arrayOfVars(variableList), _variableCount(variableCount) { - _sensorCount = getSensorCount(); populateSensorList(); } // Default constructor with no arguments - delegates to ensure all members are @@ -36,7 +35,6 @@ void VariableArray::begin(uint8_t variableCount, Variable* variableList[], _variableCount = variableCount; arrayOfVars = variableList; - _sensorCount = getSensorCount(); populateSensorList(); matchUUIDs(uuids); checkVariableUUIDs(); @@ -45,12 +43,10 @@ void VariableArray::begin(uint8_t variableCount, Variable* variableList[]) { _variableCount = variableCount; arrayOfVars = variableList; - _sensorCount = getSensorCount(); populateSensorList(); checkVariableUUIDs(); } void VariableArray::begin() { - _sensorCount = getSensorCount(); populateSensorList(); checkVariableUUIDs(); } @@ -67,14 +63,9 @@ uint8_t VariableArray::getCalculatedVariableCount() { } -// This counts and returns the number of sensors +// This returns the number of sensors uint8_t VariableArray::getSensorCount() { - uint8_t numSensors = 0; - // Check for unique sensors - for (uint8_t i = 0; i < _variableCount; i++) { - if (isLastVarFromSensor(i)) numSensors++; - } - return numSensors; + return _sensorCount; } // This matches UUIDs from an array of pointers to the variable array @@ -87,23 +78,40 @@ void VariableArray::matchUUIDs(const char* uuids[]) { // This populates the internal sensor list from the variable array bool VariableArray::populateSensorList() { uint8_t addedSensors = 0; + + // Clear the sensor list first + for (uint8_t i = 0; i < MAX_NUMBER_SENSORS; i++) { + _sensorList[i] = nullptr; + } + for (uint8_t i = 0; i < _variableCount; i++) { - if (isLastVarFromSensor(i)) { - if (addedSensors >= _sensorCount || - addedSensors >= MAX_NUMBER_SENSORS) { + // Skip calculated variables since they don't have parent sensors + if (arrayOfVars[i]->isCalculated) { continue; } + + Sensor* currentSensor = arrayOfVars[i]->parentSensor; + + // Check if this sensor is already in the list + bool alreadyInList = false; + for (uint8_t j = 0; j < addedSensors; j++) { + if (_sensorList[j] == currentSensor) { + alreadyInList = true; + break; + } + } + + // If not already in list, add it + if (!alreadyInList) { + if (addedSensors >= MAX_NUMBER_SENSORS) { // Unfortunately silent so this can be run in the constructor // before the serial port is set up. return false; } - _sensorList[addedSensors++] = arrayOfVars[i]->parentSensor; + _sensorList[addedSensors++] = currentSensor; } } - if (addedSensors != _sensorCount) { - // Unfortunately silent so this can be run in the constructor - // before the serial port is set up. - return false; - } + // Update the sensor count to match what we actually found + _sensorCount = addedSensors; return true; } diff --git a/src/VariableArray.h b/src/VariableArray.h index 8dbb00fbc..5aebab191 100644 --- a/src/VariableArray.h +++ b/src/VariableArray.h @@ -167,7 +167,6 @@ class VariableArray { */ uint8_t getCalculatedVariableCount(); - // This counts and returns the number of sensors /** * @brief Get the number of sensors associated with the variables in the * array. From 34df43547e75f8cf08f785f07f108f259f1e2657 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Thu, 5 Mar 2026 15:52:45 -0500 Subject: [PATCH 461/533] Reduce repeats in begin, use _sensorList in setup Signed-off-by: Sara Damiano --- src/VariableArray.cpp | 46 ++++++++++++++++++------------------------- 1 file changed, 19 insertions(+), 27 deletions(-) diff --git a/src/VariableArray.cpp b/src/VariableArray.cpp index 0e5f0a360..e795a6b73 100644 --- a/src/VariableArray.cpp +++ b/src/VariableArray.cpp @@ -32,21 +32,20 @@ VariableArray::VariableArray() : VariableArray(0, nullptr) {} void VariableArray::begin(uint8_t variableCount, Variable* variableList[], const char* uuids[]) { - _variableCount = variableCount; - arrayOfVars = variableList; - - populateSensorList(); + begin(variableCount, variableList); matchUUIDs(uuids); checkVariableUUIDs(); } void VariableArray::begin(uint8_t variableCount, Variable* variableList[]) { _variableCount = variableCount; arrayOfVars = variableList; - - populateSensorList(); - checkVariableUUIDs(); + begin(); } void VariableArray::begin() { + if (_variableCount == 0 || arrayOfVars == nullptr) { + MS_DBG(F("No variable array in the VariableArray object!")); + return; + } populateSensorList(); checkVariableUUIDs(); } @@ -138,14 +137,10 @@ bool VariableArray::setupSensors() { // Check for any sensors that have been set up outside of this (ie, the // modem) uint8_t nSensorsSetup = 0; - for (uint8_t i = 0; i < _variableCount; i++) { - if (isLastVarFromSensor(i) // Skip non-unique sensors - && getSensorStatusBit(i, Sensor::SETUP_SUCCESSFUL) == - 1 // already set up - ) { - MS_DBG(F(" "), arrayOfVars[i]->getParentSensorNameAndLocation(), + for (uint8_t i = 0; i < _sensorCount; i++) { + if (_sensorList[i]->getStatusBit(Sensor::SETUP_SUCCESSFUL) == 1) { + MS_DBG(F(" "), _sensorList[i]->getSensorNameAndLocation(), F("was already set up!")); - nSensorsSetup++; } } @@ -155,17 +150,12 @@ bool VariableArray::setupSensors() { // up and increment the counter marking that's been done. // We keep looping until they've all been done. while (nSensorsSetup < _sensorCount) { - for (uint8_t i = 0; i < _variableCount; i++) { - if (isLastVarFromSensor(i) // Skip non-unique sensors - && getSensorStatusBit(i, Sensor::SETUP_SUCCESSFUL) == - 0 // only set up if it has not yet been set up - ) { + for (uint8_t i = 0; i < _sensorCount; i++) { + if (_sensorList[i]->getStatusBit(Sensor::SETUP_SUCCESSFUL) == 0) { MS_DBG(F(" Set up of"), - arrayOfVars[i]->getParentSensorNameAndLocation(), - F("...")); + _sensorList[i]->getSensorNameAndLocation(), F("...")); - bool sensorSuccess = - arrayOfVars[i]->parentSensor->setup(); // set it up + bool sensorSuccess = _sensorList[i]->setup(); // set it up success &= sensorSuccess; nSensorsSetup++; @@ -192,7 +182,8 @@ bool VariableArray::setupSensors() { void VariableArray::sensorsPowerUp() { MS_DBG(F("Powering up sensors...")); for (uint8_t i = 0; i < _sensorCount; i++) { - MS_DBG(F(" Powering up"), _sensorList[i]->getSensorNameAndLocation()); + MS_DBG(F(" Powering up"), + _sensorList[i]->getSensorNameAndLocation()); _sensorList[i]->powerUp(); } } @@ -233,8 +224,8 @@ bool VariableArray::sensorsWake() { for (uint8_t i = 0; i < _sensorCount; i++) { if (_sensorList[i]->getStatusBit(Sensor::WAKE_ATTEMPTED) == 0 && _sensorList[i]->isWarmedUp(deepDebugTiming)) { - MS_DBG(F(" Wake up of"), _sensorList[i]->getSensorNameAndLocation(), - F("...")); + MS_DBG(F(" Wake up of"), + _sensorList[i]->getSensorNameAndLocation(), F("...")); // Make a single attempt to wake the sensor after it is // warmed up @@ -289,7 +280,8 @@ bool VariableArray::sensorsSleep() { void VariableArray::sensorsPowerDown() { MS_DBG(F("Powering down sensors...")); for (uint8_t i = 0; i < _sensorCount; i++) { - MS_DBG(F(" Powering down"), _sensorList[i]->getSensorNameAndLocation()); + MS_DBG(F(" Powering down"), + _sensorList[i]->getSensorNameAndLocation()); _sensorList[i]->powerDown(); } } From 7db8a32cd491d2a5fb0f4d062ca2fbe81ed22386 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Thu, 5 Mar 2026 16:21:37 -0500 Subject: [PATCH 462/533] Extract code to check if a sensor can power down into a new function Signed-off-by: Sara Damiano --- src/VariableArray.cpp | 160 ++++++++++++++++++++---------------------- src/VariableArray.h | 14 ++++ 2 files changed, 89 insertions(+), 85 deletions(-) diff --git a/src/VariableArray.cpp b/src/VariableArray.cpp index e795a6b73..ed0ff60d7 100644 --- a/src/VariableArray.cpp +++ b/src/VariableArray.cpp @@ -115,6 +115,74 @@ bool VariableArray::populateSensorList() { return true; } +// Helper function to check if sensor can be powered down safely with debug +// output +bool VariableArray::canPowerDownSensor(uint8_t sensorIndex) { + // NOTE: We are NOT checking if the sleep command succeeded! + // Check if it's safe to cut power to this sensor and all that share the pin + bool canPowerDown = + true; // assume we can power down unless we find a conflict + + for (uint8_t k = 0; k < _sensorCount; k++) { + if (( + // Check if sensor i's primary pin matches either of sensor k's + // pins + (_sensorList[sensorIndex]->getPowerPin() >= 0 && + (_sensorList[sensorIndex]->getPowerPin() == + _sensorList[k]->getPowerPin() || + _sensorList[sensorIndex]->getPowerPin() == + _sensorList[k]->getSecondaryPowerPin())) + // Check if sensor i's secondary pin matches either of sensor + // k's pins + || (_sensorList[sensorIndex]->getSecondaryPowerPin() >= 0 && + (_sensorList[sensorIndex]->getSecondaryPowerPin() == + _sensorList[k]->getPowerPin() || + _sensorList[sensorIndex]->getSecondaryPowerPin() == + _sensorList[k]->getSecondaryPowerPin()))) + // Check if sensor k still needs measurements + && (_sensorList[k]->getCompletedMeasurements() < + _sensorList[k]->getNumberMeasurementsToAverage())) { + // If sensors share a power pin and sensor k still needs + // measurements, can't power down + canPowerDown = false; + + // Debug output for conflict detection + MS_DBG(sensorIndex, F("--->> All measurements from"), + _sensorList[sensorIndex]->getSensorNameAndLocation(), + F("are complete but other sensors on the same power pin " + "still need to take measurements. " + "Leaving power on pin"), + _sensorList[sensorIndex]->getPowerPin(), F("ON. <<---")); + MS_DBG(_sensorList[sensorIndex]->getSensorNameAndLocation(), + F("shares a power pin with"), + _sensorList[k]->getSensorNameAndLocation(), + F("which still needs to take"), + _sensorList[k]->getNumberMeasurementsToAverage() - + _sensorList[k]->getCompletedMeasurements(), + F("measurements.")); + MS_DEEP_DBG(_sensorList[sensorIndex]->getSensorNameAndLocation(), + '(', sensorIndex, ')', F("pins are"), + _sensorList[sensorIndex]->getPowerPin(), F("and"), + _sensorList[sensorIndex]->getSecondaryPowerPin()); + MS_DEEP_DBG(_sensorList[k]->getSensorNameAndLocation(), '(', k, ')', + F("pins are"), _sensorList[k]->getPowerPin(), F("and"), + _sensorList[k]->getSecondaryPowerPin()); + + break; // stop looping after finding a conflict + } + } + + if (canPowerDown) { + MS_DBG(sensorIndex, F("--->> All measurements from"), + _sensorList[sensorIndex]->getSensorNameAndLocation(), + F("are complete and no other sensors on the same power pin need " + "to take measurements. This sensor can be powered down."), + F("<<---")); + } + + return canPowerDown; +} + // Public functions for interfacing with a list of sensors // This sets up all of the sensors in the list // NOTE: Calculated variables will always be skipped in this process because @@ -506,95 +574,17 @@ bool VariableArray::completeUpdate(bool powerUp, bool wake, bool sleep, MS_DBG(F(" ... sleep failed! <<---"), i); } } + // NOTE: We are NOT checking if the sleep command succeeded! if (powerDown) { - // NOTE: We are NOT checking if the sleep command succeeded! // Cut the power, if ready, to this sensors and all that // share the pin - bool canPowerDown = true; // assume we can power down - // unless we find a conflict - for (uint8_t k = 0; k < _sensorCount; k++) { - if (( - // Check if sensor i's primary pin matches - // either of sensor k's pins - (_sensorList[i]->getPowerPin() >= 0 && - (_sensorList[i]->getPowerPin() == - _sensorList[k]->getPowerPin() || - _sensorList[i]->getPowerPin() == - _sensorList[k]->getSecondaryPowerPin())) - // Check if sensor i's secondary pin matches - // either of sensor k's pins - || - (_sensorList[i]->getSecondaryPowerPin() >= 0 && - (_sensorList[i]->getSecondaryPowerPin() == - _sensorList[k]->getPowerPin() || - _sensorList[i]->getSecondaryPowerPin() == - _sensorList[k]->getSecondaryPowerPin()))) - // Check if sensor k still needs measurements - && (_sensorList[k]->getCompletedMeasurements() < - _sensorList[k] - ->getNumberMeasurementsToAverage())) { - // If sensors i and k share a primary power pin or a - // secondary power pin and sensor k still needs - // measurements, sensor i can't be powered down - canPowerDown = false; - break; // stop looping after finding a conflict - } + if (canPowerDownSensor(i)) { + MS_DBG(F("Powering down all sensors on pin"), + _sensorList[i]->getPowerPin(), F("or pin"), + _sensorList[i]->getSecondaryPowerPin(), + F("...")); + _sensorList[i]->powerDown(); } - if (canPowerDown) { _sensorList[i]->powerDown(); } -#if defined(MS_VARIABLEARRAY_DEBUG) - if (canPowerDown) { - MS_DBG( - i, F("--->> All measurements from"), sName, - F("are complete and no other sensors on the same " - "power pin need to take measurements. " - "Powered down all sensors on pin"), - _sensorList[i]->getPowerPin(), F("or pin"), - _sensorList[i]->getSecondaryPowerPin(), F("...")); - } else { - MS_DBG(i, F("--->> All measurements from"), sName, - F("are complete but other sensors on the same " - "power pin still need to take measurements. " - "Leaving power on pin"), - _sensorList[i]->getPowerPin(), F("ON. <<---")); - // Find and report which sensor still needs measurements - for (uint8_t k = 0; k < _sensorCount; k++) { - if (((_sensorList[i]->getPowerPin() >= 0 && - (_sensorList[i]->getPowerPin() == - _sensorList[k]->getPowerPin() || - _sensorList[i]->getPowerPin() == - _sensorList[k] - ->getSecondaryPowerPin())) || - (_sensorList[i]->getSecondaryPowerPin() >= 0 && - (_sensorList[i]->getSecondaryPowerPin() == - _sensorList[k]->getPowerPin() || - _sensorList[i]->getSecondaryPowerPin() == - _sensorList[k] - ->getSecondaryPowerPin()))) && - (_sensorList[k]->getCompletedMeasurements() < - _sensorList[k] - ->getNumberMeasurementsToAverage())) { - MS_DBG( - sName, F("shares a power pin with"), - sensorList[k]->getSensorNameAndLocation(), - F("which still needs to take"), - sensorList[k] - ->getNumberMeasurementsToAverage() - - sensorList[k] - ->getCompletedMeasurements(), - F("measurements.")); - MS_DBG(sName, '(', i, ')', F("pins are"), - _sensorList[i]->getPowerPin(), F("and"), - _sensorList[i]->getSecondaryPowerPin()); - MS_DBG( - _sensorList[k]->getSensorNameAndLocation(), - '(', k, ')', F("pins are"), - _sensorList[k]->getPowerPin(), F("and"), - _sensorList[k]->getSecondaryPowerPin()); - break; - } - } - } -#endif } nSensorsCompleted++; // mark the whole sensor as done MS_DBG(F("*****---"), nSensorsCompleted, diff --git a/src/VariableArray.h b/src/VariableArray.h index 5aebab191..c9702bd2b 100644 --- a/src/VariableArray.h +++ b/src/VariableArray.h @@ -312,6 +312,20 @@ class VariableArray { */ bool checkVariableUUIDs(); + /** + * @brief Check if sensor can be powered down safely + * + * This helper function checks if a sensor can be powered down by verifying + * that no other sensors sharing the same power pins still need + * measurements. Provides comprehensive debug output about the power + * management decision. + * + * @param sensorIndex Index of the sensor in _sensorList to check + * @return True if sensor can be safely powered down, false if it must stay + * powered + */ + bool canPowerDownSensor(uint8_t sensorIndex); + /** * @brief Get a specific status bit from the sensor tied to a variable in * the array. From 828bc7e636da72ff34036377b09bd00ebcb667ff Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Thu, 5 Mar 2026 16:41:20 -0500 Subject: [PATCH 463/533] Extract logic into helpers Signed-off-by: Sara Damiano --- src/VariableArray.cpp | 69 ++++++++++++++++++++++++++++++------------- src/VariableArray.h | 43 +++++++++++++++++++++++++++ 2 files changed, 91 insertions(+), 21 deletions(-) diff --git a/src/VariableArray.cpp b/src/VariableArray.cpp index ed0ff60d7..45446df10 100644 --- a/src/VariableArray.cpp +++ b/src/VariableArray.cpp @@ -115,6 +115,49 @@ bool VariableArray::populateSensorList() { return true; } +// Helper function to check if sensor wake failed or is not ready +inline bool VariableArray::isSensorWakeFailure(uint8_t sensorIndex, bool wake) { + bool wakeAttempted = + _sensorList[sensorIndex]->getStatusBit(Sensor::WAKE_ATTEMPTED) == 1; + bool wakeSuccessful = + _sensorList[sensorIndex]->getStatusBit(Sensor::WAKE_SUCCESSFUL) == 1; + bool wakeFailedAfterAttempt = wakeAttempted && !wakeSuccessful; + bool notWakingButNotAwake = !wake && (!wakeAttempted || !wakeSuccessful); + return wakeFailedAfterAttempt || notWakingButNotAwake; +} + +// Helper function to check if sensor should be woken up +inline bool VariableArray::shouldWakeSensor(uint8_t sensorIndex, bool wake, + bool deepDebugTiming) { + bool wakeAttempted = + _sensorList[sensorIndex]->getStatusBit(Sensor::WAKE_ATTEMPTED) == 1; + return wake && !wakeAttempted && + _sensorList[sensorIndex]->isWarmedUp(deepDebugTiming); +} + +// Helper function to check if sensor is ready to start measurements +inline bool VariableArray::isSensorReadyToMeasure(uint8_t sensorIndex) { + bool wakeSuccessful = + _sensorList[sensorIndex]->getStatusBit(Sensor::WAKE_SUCCESSFUL) == 1; + bool measurementAttempted = _sensorList[sensorIndex]->getStatusBit( + Sensor::MEASUREMENT_ATTEMPTED) == 1; + bool measurementSuccessful = _sensorList[sensorIndex]->getStatusBit( + Sensor::MEASUREMENT_SUCCESSFUL) == 1; + return wakeSuccessful && !measurementAttempted && !measurementSuccessful; +} + +// Helper function to check if measurements have been attempted +inline bool VariableArray::isMeasurementAttempted(uint8_t sensorIndex) { + return _sensorList[sensorIndex]->getStatusBit( + Sensor::MEASUREMENT_ATTEMPTED) == 1; +} + +// Helper function to check if all measurements are complete +inline bool VariableArray::areMeasurementsComplete(uint8_t sensorIndex) { + return _sensorList[sensorIndex]->getCompletedMeasurements() >= + _sensorList[sensorIndex]->getNumberMeasurementsToAverage(); +} + // Helper function to check if sensor can be powered down safely with debug // output bool VariableArray::canPowerDownSensor(uint8_t sensorIndex) { @@ -458,12 +501,7 @@ bool VariableArray::completeUpdate(bool powerUp, bool wake, bool sleep, // If attempts were made to wake the sensor, but they failed OR if // we're not waking the sensor but it is not already awake or the // previous wake attempts failed... - if ((_sensorList[i]->getStatusBit(Sensor::WAKE_ATTEMPTED) == 1 && - _sensorList[i]->getStatusBit(Sensor::WAKE_SUCCESSFUL) == 0) || - (!wake && - (_sensorList[i]->getStatusBit(Sensor::WAKE_ATTEMPTED) == 0 || - _sensorList[i]->getStatusBit(Sensor::WAKE_SUCCESSFUL) == - 0))) { + if (isSensorWakeFailure(i, wake)) { MS_DBG(i, F("--->>"), sName, F("failed to wake up! No measurements will be taken! " "<<---"), @@ -478,13 +516,7 @@ bool VariableArray::completeUpdate(bool powerUp, bool wake, bool sleep, _sensorList[i]->_measurementsToAverage; } - if (wake - // ^^ if we're supposed to wake the sensors - && _sensorList[i]->getStatusBit(Sensor::WAKE_ATTEMPTED) == 0 - // ^^ And no attempts yet made to wake the sensor up - && _sensorList[i]->isWarmedUp(deepDebugTiming) - // ^^ and if it is already warmed up - ) { + if (shouldWakeSensor(i, wake, deepDebugTiming)) { MS_DBG(i, F("--->> Waking"), sName, F("...")); // Make a single attempt to wake the sensor after it is @@ -501,11 +533,7 @@ bool VariableArray::completeUpdate(bool powerUp, bool wake, bool sleep, // If the sensor was successfully awoken/activated, but no // measurement was either started or finished ... - if (_sensorList[i]->getStatusBit(Sensor::WAKE_SUCCESSFUL) == 1 && - _sensorList[i]->getStatusBit(Sensor::MEASUREMENT_ATTEMPTED) == - 0 && - _sensorList[i]->getStatusBit(Sensor::MEASUREMENT_SUCCESSFUL) == - 0) { + if (isSensorReadyToMeasure(i)) { // .. check if it's stable if (_sensorList[i]->isStable(deepDebugTiming)) { MS_DBG(cycCount, F("--->> Starting reading on"), sName, @@ -529,8 +557,7 @@ bool VariableArray::completeUpdate(bool powerUp, bool wake, bool sleep, // successfully... // We aren't checking if the measurement start was successful; // isMeasurementComplete(deepDebugTiming) will do that. - if (_sensorList[i]->getStatusBit(Sensor::MEASUREMENT_ATTEMPTED) == - 1) { + if (isMeasurementAttempted(i)) { // If a measurement is finished, get the result and tick up // the number of finished measurements. if (_sensorList[i]->isMeasurementComplete(deepDebugTiming)) { @@ -555,7 +582,7 @@ bool VariableArray::completeUpdate(bool powerUp, bool wake, bool sleep, } // If all the measurements are now complete - if (_sensorList[i]->getCompletedMeasurements() >= nReq) { + if (areMeasurementsComplete(i)) { if (sleep) { MS_DBG(i, F("--->> Finished all measurements from"), sName, F(", putting it to sleep. ...")); diff --git a/src/VariableArray.h b/src/VariableArray.h index c9702bd2b..85b72c7e9 100644 --- a/src/VariableArray.h +++ b/src/VariableArray.h @@ -312,6 +312,49 @@ class VariableArray { */ bool checkVariableUUIDs(); + /** + * @brief Check if a sensor has failed to wake up or is not ready for use. + * + * @param sensorIndex Index of the sensor in _sensorList to check + * @param wake Whether we are currently in wake mode + * @return True if sensor wake failed or is not ready + */ + bool isSensorWakeFailure(uint8_t sensorIndex, bool wake); + + /** + * @brief Check if a sensor should be woken up now. + * + * @param sensorIndex Index of the sensor in _sensorList to check + * @param wake Whether we are currently in wake mode + * @param deepDebugTiming Whether to use deep debug timing + * @return True if sensor should be woken up + */ + bool shouldWakeSensor(uint8_t sensorIndex, bool wake, bool deepDebugTiming); + + /** + * @brief Check if a sensor is ready to start measurements. + * + * @param sensorIndex Index of the sensor in _sensorList to check + * @return True if sensor is awake and ready for measurements + */ + bool isSensorReadyToMeasure(uint8_t sensorIndex); + + /** + * @brief Check if measurements have been attempted on a sensor. + * + * @param sensorIndex Index of the sensor in _sensorList to check + * @return True if measurement attempt has been made + */ + bool isMeasurementAttempted(uint8_t sensorIndex); + + /** + * @brief Check if all required measurements are complete for a sensor. + * + * @param sensorIndex Index of the sensor in _sensorList to check + * @return True if all measurements are complete + */ + bool areMeasurementsComplete(uint8_t sensorIndex); + /** * @brief Check if sensor can be powered down safely * From 8db978ea339d53c81389ca6d67d214ab5e625633 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Thu, 5 Mar 2026 16:48:36 -0500 Subject: [PATCH 464/533] rename printSensorData to printVariableData with compatibility stub Signed-off-by: Sara Damiano --- src/LoggerBase.cpp | 12 ++++++------ src/VariableArray.cpp | 7 ++++++- src/VariableArray.h | 19 +++++++++++++++---- 3 files changed, 27 insertions(+), 11 deletions(-) diff --git a/src/LoggerBase.cpp b/src/LoggerBase.cpp index 7fb339d7b..d43174ac7 100644 --- a/src/LoggerBase.cpp +++ b/src/LoggerBase.cpp @@ -1626,9 +1626,9 @@ void Logger::benchTestingMode(bool sleepBeforeReturning) { PRINTOUT(F("-----------------------")); // Print out the sensor data #if !defined(MS_SILENT) - _internalArray->printSensorData(&MS_OUTPUT); + _internalArray->printVariableData(&MS_OUTPUT); #if defined(MS_2ND_OUTPUT) - _internalArray->printSensorData(&MS_2ND_OUTPUT); + _internalArray->printVariableData(&MS_2ND_OUTPUT); #endif #endif PRINTOUT(F("-----------------------")); @@ -1851,9 +1851,9 @@ void Logger::logData(bool sleepBeforeReturning) { // Print out the sensor data #if !defined(MS_SILENT) PRINTOUT(" "); - _internalArray->printSensorData(&MS_OUTPUT); + _internalArray->printVariableData(&MS_OUTPUT); #if defined(MS_2ND_OUTPUT) - _internalArray->printSensorData(&MS_2ND_OUTPUT); + _internalArray->printVariableData(&MS_2ND_OUTPUT); #endif PRINTOUT(" "); #endif @@ -1923,9 +1923,9 @@ void Logger::logDataAndPublish(bool sleepBeforeReturning) { // Print out the sensor data #if !defined(MS_SILENT) PRINTOUT(" "); - _internalArray->printSensorData(&MS_OUTPUT); + _internalArray->printVariableData(&MS_OUTPUT); #if defined(MS_2ND_OUTPUT) - _internalArray->printSensorData(&MS_2ND_OUTPUT); + _internalArray->printVariableData(&MS_2ND_OUTPUT); #endif PRINTOUT(" "); #endif diff --git a/src/VariableArray.cpp b/src/VariableArray.cpp index 45446df10..25abea968 100644 --- a/src/VariableArray.cpp +++ b/src/VariableArray.cpp @@ -646,10 +646,15 @@ bool VariableArray::completeUpdate(bool powerUp, bool wake, bool sleep, return success; } +// Backward compatibility wrapper +void VariableArray::printSensorData(Stream* stream) { + printVariableData(stream); +} + // This function prints out the results for any connected sensors to a stream // Calculated Variable results will be included -void VariableArray::printSensorData(Stream* stream) { +void VariableArray::printVariableData(Stream* stream) { for (uint8_t i = 0; i < _variableCount; i++) { if (i > 0) { // Check if we need to add a line break between different sensors diff --git a/src/VariableArray.h b/src/VariableArray.h index 85b72c7e9..0c6a60604 100644 --- a/src/VariableArray.h +++ b/src/VariableArray.h @@ -268,16 +268,27 @@ class VariableArray { bool sleep = true, bool powerDown = true); /** - * @brief Print out the results for all connected sensors to a stream + * @brief Print out the results for all variables in the variable array to a + * stream * - * This prints current sensor values along with meta-data to a stream - * (either hardware or software serial). By default, it will print to the - * first Serial port. Note that the input is a pointer to a stream instance + * This prints current variable values - both those from sensors and + * calculated variables - along with meta-data to a stream (either hardware + * or software serial). By default, it will print to the first Serial port. + * Note that the input is a pointer to a stream instance * - to use a hardware serial instance you must use an ampersand before the * serial name (ie, &Serial1). * * @param stream An Arduino Stream instance */ + void printVariableData(Stream* stream = &Serial); + + /** + * @brief Print out the results for all variables in the variable array to a + * stream + * + * @deprecated{0,39,0} Use printVariableData() instead. + * @param stream An Arduino Stream instance + */ void printSensorData(Stream* stream = &Serial); protected: From 1cc4d88d44ae2c7d9c4070127ce38af14d93e351 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Thu, 5 Mar 2026 16:49:16 -0500 Subject: [PATCH 465/533] rename printSensorDataCSV to printVariableValuesCSV with compatibility stub Signed-off-by: Sara Damiano --- src/LoggerBase.cpp | 13 +++++++++---- src/LoggerBase.h | 14 ++++++++++++-- 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/src/LoggerBase.cpp b/src/LoggerBase.cpp index d43174ac7..9d464d4eb 100644 --- a/src/LoggerBase.cpp +++ b/src/LoggerBase.cpp @@ -1305,7 +1305,7 @@ void Logger::printFileHeader(Stream* stream) { // This prints a comma separated list of values of sensor data - including the // time - out over an Arduino stream -void Logger::printSensorDataCSV(Stream* stream) { +void Logger::printVariableValuesCSV(Stream* stream) { String csvString = ""; String iso8601 = formatDateTime_ISO8601(Logger::markedLocalUnixTime); iso8601.replace("T", " "); @@ -1319,6 +1319,11 @@ void Logger::printSensorDataCSV(Stream* stream) { stream->println(); } +// Backward compatibility wrapper +void Logger::printSensorDataCSV(Stream* stream) { + printVariableValuesCSV(stream); +} + // Protected helper function - This checks if the SD card is available and ready bool Logger::initializeSDCard() { // If we don't know the slave select of the sd card, we can't use it @@ -1538,13 +1543,13 @@ bool Logger::logToSD() { } // Write the data - printSensorDataCSV(&logFile); + printVariableValuesCSV(&logFile); // Echo the line to the serial port #if !defined(MS_SILENT) PRINTOUT(F("\n \\/---- Line Saved to SD Card ----\\/")); - printSensorDataCSV(&MS_OUTPUT); + printVariableValuesCSV(&MS_OUTPUT); #if defined(MS_2ND_OUTPUT) - printSensorDataCSV(&MS_2ND_OUTPUT); + printVariableValuesCSV(&MS_2ND_OUTPUT); #endif PRINTOUT('\n'); #endif diff --git a/src/LoggerBase.h b/src/LoggerBase.h index 2e1f81f6d..af57392bd 100644 --- a/src/LoggerBase.h +++ b/src/LoggerBase.h @@ -1243,12 +1243,22 @@ class Logger { virtual void printFileHeader(Stream* stream); /** - * @brief Print a comma separated list of values of sensor data - - * including the time in the logging timezone - out over an Arduino stream + * @brief Print a comma separated list of the values of the variables in the + * underling variable array - along with the logged time in the logger's + * timezone - out over an Arduino stream * * @param stream An Arduino stream instance - expected to be an SdFat file - * but could also be the "main" Serial port for debugging. */ + void printVariableValuesCSV(Stream* stream); + + /** + * @brief Print a comma separated list of values of variable data - + * including the time in the logging timezone - out over an Arduino stream + * + * @deprecated{0,39,0} Use printVariableValuesCSV() instead. + * @param stream An Arduino stream instance + */ void printSensorDataCSV(Stream* stream); /** From 9c861359b1a8184f4b5370d3e72064009984ad26 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Thu, 5 Mar 2026 17:35:13 -0500 Subject: [PATCH 466/533] Add function so sensor can print its own data Signed-off-by: Sara Damiano --- src/SensorBase.cpp | 33 +++++++++++++++++++++++++++++++++ src/SensorBase.h | 21 +++++++++++++++++++++ src/VariableArray.h | 10 ++++++---- 3 files changed, 60 insertions(+), 4 deletions(-) diff --git a/src/SensorBase.cpp b/src/SensorBase.cpp index c29ff8be3..245dedb54 100644 --- a/src/SensorBase.cpp +++ b/src/SensorBase.cpp @@ -471,6 +471,39 @@ void Sensor::averageMeasurements() { } +void Sensor::printData(Stream* stream) { + for (uint8_t i = 0; i < _numReturnedValues; i++) { + stream->print(getSensorNameAndLocation()); + // stream->print(F(" with status 0b")); + // stream->print(getStatusBit(7)); + // stream->print(getStatusBit(6)); + // stream->print(getStatusBit(5)); + // stream->print(getStatusBit(4)); + // stream->print(getStatusBit(3)); + // stream->print(getStatusBit(2)); + // stream->print(getStatusBit(1)); + // stream->print(getStatusBit(0)); + stream->print(F(" reports ")); + if (variables[i] != nullptr) { + stream->print(variables[i]->getVarName()); + stream->print(F(" (")); + stream->print(variables[i]->getVarCode()); + stream->print(F(")")); + stream->print(F(" is ")); + stream->print(variables[i]->getValueString()); + stream->print(F(" ")); + stream->print(variables[i]->getVarUnit()); + } else { + stream->print(F("variable #")); + stream->print(i); + stream->print(F(" is ")); + stream->print(sensorValues[i]); + } + stream->println(); + } +} + + // This updates a sensor value by checking it's power, waking it, taking as many // readings as requested, then putting the sensor to sleep and powering down. bool Sensor::update() { diff --git a/src/SensorBase.h b/src/SensorBase.h index fa9d2c27c..41825b133 100644 --- a/src/SensorBase.h +++ b/src/SensorBase.h @@ -598,6 +598,27 @@ class Sensor { */ void averageMeasurements(); + /** + * @brief Print out the results from a measurement - whether or not there is + * a variable attached to the sensor to receive the results. + * + * If there is a variable attached to the sensor, the printed info will + * include the variable name, units, and code and the value will be + * formatted with the correct number of decimal places. If there is no + * variable attached to the sensor, the printed info will only include the + * variable number position and the value will printed to two decimal + * places. + * + * @todo Figure out a way to have a sensor figure out the metadata about its + * own variables. Currently that is stored in the variable objects, but it + * is also a property of the sensor's results. + * See issue [498](https://github.com/EnviroDIY/ModularSensors/issues/498) + * for more discussion. + * + * @param stream An Arduino Stream instance + */ + virtual void printData(Stream* stream = &Serial); + /** * @brief Register a variable object to a sensor. * diff --git a/src/VariableArray.h b/src/VariableArray.h index 0c6a60604..ffa2a6c7c 100644 --- a/src/VariableArray.h +++ b/src/VariableArray.h @@ -273,10 +273,12 @@ class VariableArray { * * This prints current variable values - both those from sensors and * calculated variables - along with meta-data to a stream (either hardware - * or software serial). By default, it will print to the first Serial port. - * Note that the input is a pointer to a stream instance - * - to use a hardware serial instance you must use an ampersand before the - * serial name (ie, &Serial1). + * or software serial). This does not include all possible variables from + * each sensor, only those variables that are in the variable list. + * + * By default, it will print to the first Serial port. Note that the input + * is a pointer to a stream instance - to use a hardware serial instance you + * must use an ampersand before the serial name (ie, &Serial1). * * @param stream An Arduino Stream instance */ From 0cdc9c62bdd1531fcfdb644fdea3d39590b595d5 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Fri, 6 Mar 2026 09:54:31 -0500 Subject: [PATCH 467/533] Remove arguments that aren't honored Signed-off-by: Sara Damiano --- src/publishers/AWS_IoT_Publisher.cpp | 51 ++++++++---------- src/publishers/AWS_IoT_Publisher.h | 72 ++++--------------------- src/publishers/DreamHostPublisher.cpp | 25 +++------ src/publishers/DreamHostPublisher.h | 44 ++------------- src/publishers/S3PresignedPublisher.cpp | 21 ++++---- src/publishers/S3PresignedPublisher.h | 33 ++---------- src/publishers/ThingSpeakPublisher.cpp | 26 +++------ src/publishers/ThingSpeakPublisher.h | 44 ++------------- src/publishers/UbidotsPublisher.cpp | 27 ++++------ src/publishers/UbidotsPublisher.h | 44 ++------------- 10 files changed, 81 insertions(+), 306 deletions(-) diff --git a/src/publishers/AWS_IoT_Publisher.cpp b/src/publishers/AWS_IoT_Publisher.cpp index a203c2969..2c0f83f1c 100644 --- a/src/publishers/AWS_IoT_Publisher.cpp +++ b/src/publishers/AWS_IoT_Publisher.cpp @@ -26,12 +26,13 @@ const char* AWS_IoT_Publisher::timestampTag = "\"timestamp\":\""; // Constructors // Primary constructor - handles full initialization with all parameters -AWS_IoT_Publisher::AWS_IoT_Publisher( - Logger& baseLogger, Client* inClient, const char* awsIoTEndpoint, - const char* caCertName, const char* clientCertName, - const char* clientKeyName, const char* samplingFeatureUUID, int sendEveryX, - uint8_t initialTransmissions) - : dataPublisher(baseLogger, inClient, sendEveryX, initialTransmissions) { +AWS_IoT_Publisher::AWS_IoT_Publisher(Logger& baseLogger, Client* inClient, + const char* awsIoTEndpoint, + const char* caCertName, + const char* clientCertName, + const char* clientKeyName, + const char* samplingFeatureUUID) + : dataPublisher(baseLogger, inClient) { if (awsIoTEndpoint) setEndpoint(awsIoTEndpoint); if (caCertName) setCACertName(caCertName); if (clientCertName) setClientCertName(clientCertName); @@ -44,40 +45,32 @@ AWS_IoT_Publisher::AWS_IoT_Publisher( // Delegating constructors -AWS_IoT_Publisher::AWS_IoT_Publisher( - Logger& baseLogger, const char* awsIoTEndpoint, const char* caCertName, - const char* clientCertName, const char* clientKeyName, - const char* samplingFeatureUUID, int sendEveryX, - uint8_t initialTransmissions) +AWS_IoT_Publisher::AWS_IoT_Publisher(Logger& baseLogger, + const char* awsIoTEndpoint, + const char* caCertName, + const char* clientCertName, + const char* clientKeyName, + const char* samplingFeatureUUID) : AWS_IoT_Publisher(baseLogger, nullptr, awsIoTEndpoint, caCertName, - clientCertName, clientKeyName, samplingFeatureUUID, - sendEveryX, initialTransmissions) {} + clientCertName, clientKeyName, samplingFeatureUUID) {} AWS_IoT_Publisher::AWS_IoT_Publisher(Logger& baseLogger, const char* awsIoTEndpoint, const char* caCertName, const char* clientCertName, - const char* clientKeyName, int sendEveryX, - uint8_t initialTransmissions) + const char* clientKeyName) : AWS_IoT_Publisher(baseLogger, nullptr, awsIoTEndpoint, caCertName, - clientCertName, clientKeyName, nullptr, sendEveryX, - initialTransmissions) {} + clientCertName, clientKeyName, nullptr) {} AWS_IoT_Publisher::AWS_IoT_Publisher(Logger& baseLogger, Client* inClient, const char* awsIoTEndpoint, - const char* samplingFeatureUUID, - int sendEveryX, - uint8_t initialTransmissions) + const char* samplingFeatureUUID) : AWS_IoT_Publisher(baseLogger, inClient, awsIoTEndpoint, nullptr, nullptr, - nullptr, samplingFeatureUUID, sendEveryX, - initialTransmissions) {} -AWS_IoT_Publisher::AWS_IoT_Publisher(Logger& baseLogger, Client* inClient, - int sendEveryX, - uint8_t initialTransmissions) + nullptr, samplingFeatureUUID) {} +AWS_IoT_Publisher::AWS_IoT_Publisher(Logger& baseLogger, Client* inClient) : AWS_IoT_Publisher(baseLogger, inClient, nullptr, nullptr, nullptr, - nullptr, nullptr, sendEveryX, initialTransmissions) {} -AWS_IoT_Publisher::AWS_IoT_Publisher(Logger& baseLogger, int sendEveryX, - uint8_t initialTransmissions) + nullptr, nullptr) {} +AWS_IoT_Publisher::AWS_IoT_Publisher(Logger& baseLogger) : AWS_IoT_Publisher(baseLogger, nullptr, nullptr, nullptr, nullptr, nullptr, - nullptr, sendEveryX, initialTransmissions) {} + nullptr) {} AWS_IoT_Publisher::AWS_IoT_Publisher() : dataPublisher() { init(); } diff --git a/src/publishers/AWS_IoT_Publisher.h b/src/publishers/AWS_IoT_Publisher.h index 771551dd2..5c83435b2 100644 --- a/src/publishers/AWS_IoT_Publisher.h +++ b/src/publishers/AWS_IoT_Publisher.h @@ -100,14 +100,6 @@ class AWS_IoT_Publisher : public dataPublisher { * @param clientCertName The name of your client certificate file * @param clientKeyName The name of your client private key file * @param samplingFeatureUUID The sampling feature UUID - * @param sendEveryX Interval (in units of the logging interval) between - * attempted data transmissions. - * @param initialTransmissions The number of initial transmissions - * (default: 5). This will be inverted from the argument! - * - * @remark The sendEveryX and initialTransmissions parameters are not - * implemented by this publisher. Data will be sent every time the logger - * records data. * * @note The inputs to this are the **NAMES** of the certificate **files** * as they are stored on you modem module, not the content of the @@ -116,8 +108,7 @@ class AWS_IoT_Publisher : public dataPublisher { AWS_IoT_Publisher(Logger& baseLogger, Client* inClient, const char* awsIoTEndpoint, const char* caCertName, const char* clientCertName, const char* clientKeyName, - const char* samplingFeatureUUID, int sendEveryX = 1, - uint8_t initialTransmissions = 5); + const char* samplingFeatureUUID); /** * @brief Construct a new AWS IoT Core Publisher object * @@ -128,14 +119,6 @@ class AWS_IoT_Publisher : public dataPublisher { * @param clientCertName The name of your client certificate file * @param clientKeyName The name of your client private key file * @param samplingFeatureUUID The sampling feature UUID - * @param sendEveryX Interval (in units of the logging interval) between - * attempted data transmissions. - * @param initialTransmissions The number of initial transmissions - * (default: 5). This will be inverted from the argument! - * - * @remark The sendEveryX and initialTransmissions parameters are not - * implemented by this publisher. Data will be sent every time the logger - * records data. * * @note The inputs to this are the **NAMES** of the certificate **files** * as they are stored on you modem module, not the content of the @@ -144,8 +127,7 @@ class AWS_IoT_Publisher : public dataPublisher { AWS_IoT_Publisher(Logger& baseLogger, const char* awsIoTEndpoint, const char* caCertName, const char* clientCertName, const char* clientKeyName, - const char* samplingFeatureUUID, int sendEveryX = 1, - uint8_t initialTransmissions = 5); + const char* samplingFeatureUUID); /** * @brief Construct a new AWS IoT Core Publisher object * @@ -155,14 +137,6 @@ class AWS_IoT_Publisher : public dataPublisher { * file * @param clientCertName The name of your client certificate file * @param clientKeyName The name of your client private key file - * @param sendEveryX Interval (in units of the logging interval) between - * attempted data transmissions. - * @param initialTransmissions The number of initial transmissions - * (default: 5). This will be inverted from the argument! - * - * @remark The sendEveryX and initialTransmissions parameters are not - * implemented by this publisher. Data will be sent every time the logger - * records data. * * @note The inputs to this are the **NAMES** of the certificate **files** * as they are stored on you modem module, not the content of the @@ -170,8 +144,7 @@ class AWS_IoT_Publisher : public dataPublisher { */ AWS_IoT_Publisher(Logger& baseLogger, const char* awsIoTEndpoint, const char* caCertName, const char* clientCertName, - const char* clientKeyName, int sendEveryX = 1, - uint8_t initialTransmissions = 5); + const char* clientKeyName); /** * @brief Construct a new AWS IoT Core Publisher object * @@ -181,19 +154,10 @@ class AWS_IoT_Publisher : public dataPublisher { * single TinyGSM modem instance * @param awsIoTEndpoint The endpoint for your AWS IoT instance * @param samplingFeatureUUID The sampling feature UUID - * @param sendEveryX Interval (in units of the logging interval) between - * attempted data transmissions. - * @param initialTransmissions The number of initial transmissions - * (default: 5). This will be inverted from the argument! - * - * @remark The sendEveryX and initialTransmissions parameters are not - * implemented by this publisher. Data will be sent every time the logger - * records data. */ AWS_IoT_Publisher(Logger& baseLogger, Client* inClient, const char* awsIoTEndpoint, - const char* samplingFeatureUUID, int sendEveryX = 1, - uint8_t initialTransmissions = 5); + const char* samplingFeatureUUID); /** * @brief Construct a new AWS IoT Core Publisher object * @@ -201,17 +165,8 @@ class AWS_IoT_Publisher : public dataPublisher { * @param inClient An Arduino client instance to use to print data to. * Allows the use of any type of client and multiple clients tied to a * single TinyGSM modem instance - * @param sendEveryX Interval (in units of the logging interval) between - * attempted data transmissions. - * @param initialTransmissions The number of initial transmissions - * (default: 5). This will be inverted from the argument! - * - * @remark The sendEveryX and initialTransmissions parameters are not - * implemented by this publisher. Data will be sent every time the logger - * records data. */ - AWS_IoT_Publisher(Logger& baseLogger, Client* inClient, int sendEveryX = 1, - uint8_t initialTransmissions = 5); + AWS_IoT_Publisher(Logger& baseLogger, Client* inClient); /** * @brief Construct a new AWS IoT Core Publisher object * @@ -220,20 +175,12 @@ class AWS_IoT_Publisher : public dataPublisher { * logger. * * @param baseLogger The logger supplying the data to be published - * @param sendEveryX Interval (in units of the logging interval) between - * attempted data transmissions. - * @param initialTransmissions The number of initial transmissions - * (default: 5). This will be inverted from the argument! - * - * @remark The sendEveryX and initialTransmissions parameters are not - * implemented by this publisher. Data will be sent every time the logger - * records data. */ - explicit AWS_IoT_Publisher(Logger& baseLogger, int sendEveryX = 1, - uint8_t initialTransmissions = 5); + explicit AWS_IoT_Publisher(Logger& baseLogger); /** * @brief Construct a new AWS IoT Core Publisher object with all members set - * to defaults or nulls + * to defaults or nulls. This cannot be used without setting up the AWS IoT + * connection parameters and client before use. */ AWS_IoT_Publisher(); /** @@ -241,9 +188,8 @@ class AWS_IoT_Publisher : public dataPublisher { */ ~AWS_IoT_Publisher() override = default; - // Returns the data destination String getEndpoint() override { - return String(_awsIoTEndpoint); + return _awsIoTEndpoint ? String(_awsIoTEndpoint) : String(); } /** diff --git a/src/publishers/DreamHostPublisher.cpp b/src/publishers/DreamHostPublisher.cpp index 2a470a0f1..64851cb6c 100644 --- a/src/publishers/DreamHostPublisher.cpp +++ b/src/publishers/DreamHostPublisher.cpp @@ -24,28 +24,19 @@ const char* DreamHostPublisher::timestampTagDH = "&Loggertime="; // Constructors // Primary constructor with all parameters DreamHostPublisher::DreamHostPublisher(Logger& baseLogger, Client* inClient, - const char* dhUrl, int sendEveryX, - uint8_t initialTransmissions) - : dataPublisher(baseLogger, inClient, sendEveryX, initialTransmissions) { + const char* dhUrl) + : dataPublisher(baseLogger, inClient) { if (dhUrl) setDreamHostPortalRX(dhUrl); } // Delegating constructors -DreamHostPublisher::DreamHostPublisher(Logger& baseLogger, Client* inClient, - int sendEveryX, - uint8_t initialTransmissions) - : DreamHostPublisher(baseLogger, inClient, nullptr, sendEveryX, - initialTransmissions) {} -DreamHostPublisher::DreamHostPublisher(Logger& baseLogger, const char* dhUrl, - int sendEveryX, - uint8_t initialTransmissions) - : DreamHostPublisher(baseLogger, static_cast(nullptr), dhUrl, - sendEveryX, initialTransmissions) {} -DreamHostPublisher::DreamHostPublisher(Logger& baseLogger, int sendEveryX, - uint8_t initialTransmissions) +DreamHostPublisher::DreamHostPublisher(Logger& baseLogger, Client* inClient) + : DreamHostPublisher(baseLogger, inClient, nullptr) {} +DreamHostPublisher::DreamHostPublisher(Logger& baseLogger, const char* dhUrl) + : DreamHostPublisher(baseLogger, static_cast(nullptr), dhUrl) {} +DreamHostPublisher::DreamHostPublisher(Logger& baseLogger) : DreamHostPublisher(baseLogger, static_cast(nullptr), - static_cast(nullptr), sendEveryX, - initialTransmissions) {} + static_cast(nullptr)) {} DreamHostPublisher::DreamHostPublisher() : dataPublisher() {} diff --git a/src/publishers/DreamHostPublisher.h b/src/publishers/DreamHostPublisher.h index 5dce6d67a..decd58691 100644 --- a/src/publishers/DreamHostPublisher.h +++ b/src/publishers/DreamHostPublisher.h @@ -55,17 +55,8 @@ class DreamHostPublisher : public dataPublisher { * Allows the use of any type of client and multiple clients tied to a * single TinyGSM modem instance * @param dhUrl The URL for sending data to DreamHost - * @param sendEveryX Interval (in units of the logging interval) between - * attempted data transmissions. - * @param initialTransmissions Number of transmissions to send immediately - * after each data point is logged (default: 5). - * - * @remark The sendEveryX and initialTransmissions parameters are not - * implemented by this publisher. Data will be sent every time the logger - * records data. */ - DreamHostPublisher(Logger& baseLogger, Client* inClient, const char* dhUrl, - int sendEveryX = 1, uint8_t initialTransmissions = 5); + DreamHostPublisher(Logger& baseLogger, Client* inClient, const char* dhUrl); /** * @brief Construct a new DreamHost Publisher object * @@ -73,33 +64,15 @@ class DreamHostPublisher : public dataPublisher { * @param inClient An Arduino client instance to use to print data to. * Allows the use of any type of client and multiple clients tied to a * single TinyGSM modem instance - * @param sendEveryX Interval (in units of the logging interval) between - * attempted data transmissions. - * @param initialTransmissions Number of transmissions to send immediately - * after each data point is logged (default: 5). - * - * @remark The sendEveryX and initialTransmissions parameters are not - * implemented by this publisher. Data will be sent every time the logger - * records data. */ - DreamHostPublisher(Logger& baseLogger, Client* inClient, int sendEveryX = 1, - uint8_t initialTransmissions = 5); + DreamHostPublisher(Logger& baseLogger, Client* inClient); /** * @brief Construct a new DreamHost Publisher object * * @param baseLogger The logger supplying the data to be published * @param dhUrl The URL for sending data to DreamHost - * @param sendEveryX Interval (in units of the logging interval) between - * attempted data transmissions. - * @param initialTransmissions Number of transmissions to send immediately - * after each data point is logged (default: 5). - * - * @remark The sendEveryX and initialTransmissions parameters are not - * implemented by this publisher. Data will be sent every time the logger - * records data. */ - DreamHostPublisher(Logger& baseLogger, const char* dhUrl, - int sendEveryX = 1, uint8_t initialTransmissions = 5); + DreamHostPublisher(Logger& baseLogger, const char* dhUrl); /** * @brief Construct a new DreamHost Publisher object * @@ -108,17 +81,8 @@ class DreamHostPublisher : public dataPublisher { * logger. * * @param baseLogger The logger supplying the data to be published - * @param sendEveryX Interval (in units of the logging interval) between - * attempted data transmissions. - * @param initialTransmissions Number of transmissions to send immediately - * after each data point is logged (default: 5). - * - * @remark The sendEveryX and initialTransmissions parameters are not - * implemented by this publisher. Data will be sent every time the logger - * records data. */ - explicit DreamHostPublisher(Logger& baseLogger, int sendEveryX = 1, - uint8_t initialTransmissions = 5); + explicit DreamHostPublisher(Logger& baseLogger); /** * @brief Construct a new DreamHost Publisher object with all members set to * default or null. diff --git a/src/publishers/S3PresignedPublisher.cpp b/src/publishers/S3PresignedPublisher.cpp index a657729fe..b475022a8 100644 --- a/src/publishers/S3PresignedPublisher.cpp +++ b/src/publishers/S3PresignedPublisher.cpp @@ -22,28 +22,25 @@ const char* S3PresignedPublisher::contentTypeHeader = "\r\nContent-Type: "; S3PresignedPublisher::S3PresignedPublisher(Logger& baseLogger, Client* inClient, const char* caCertName, String (*getUrlFxn)(String), - String (*getFileNameFxn)(), - int sendEveryX, - uint8_t initialTransmissions) - : dataPublisher(baseLogger, inClient, sendEveryX, initialTransmissions) { + String (*getFileNameFxn)()) + : dataPublisher(baseLogger, inClient) { if (caCertName) setCACertName(caCertName); if (getUrlFxn) setURLUpdateFunction(getUrlFxn); if (getFileNameFxn) setFileUpdateFunction(getFileNameFxn); } // Delegating constructors -S3PresignedPublisher::S3PresignedPublisher( - Logger& baseLogger, const char* caCertName, String (*getUrlFxn)(String), - String (*getFileNameFxn)(), int sendEveryX, uint8_t initialTransmissions) +S3PresignedPublisher::S3PresignedPublisher(Logger& baseLogger, + const char* caCertName, + String (*getUrlFxn)(String), + String (*getFileNameFxn)()) : S3PresignedPublisher(baseLogger, nullptr, caCertName, getUrlFxn, - getFileNameFxn, sendEveryX, initialTransmissions) {} + getFileNameFxn) {} S3PresignedPublisher::S3PresignedPublisher(Logger& baseLogger, Client* inClient, String (*getUrlFxn)(String), - String (*getFileNameFxn)(), - int sendEveryX, - uint8_t initialTransmissions) + String (*getFileNameFxn)()) : S3PresignedPublisher(baseLogger, inClient, nullptr, getUrlFxn, - getFileNameFxn, sendEveryX, initialTransmissions) {} + getFileNameFxn) {} S3PresignedPublisher::S3PresignedPublisher() : dataPublisher() {} diff --git a/src/publishers/S3PresignedPublisher.h b/src/publishers/S3PresignedPublisher.h index 7d031cfc1..9755a164f 100644 --- a/src/publishers/S3PresignedPublisher.h +++ b/src/publishers/S3PresignedPublisher.h @@ -146,14 +146,6 @@ class S3PresignedPublisher : public dataPublisher { * with SSL. @see setCACertName() * @param getUrlFxn A function to call to get a new pre-signed URL * @param getFileNameFxn A function to call to get a new filename - * @param sendEveryX Interval (in units of the logging interval) between - * attempted data transmissions. - * @param initialTransmissions Number of transmissions to send immediately - * after each data point is logged (default: 5). - * - * @remark The sendEveryX and initialTransmissions parameters are not - * implemented by this publisher. Data will be sent every time the logger - * records data. * * @note The inputs to this is the **NAME** of the certificate **file** as * it is stored on you modem module, not the actual certificate content. @@ -161,8 +153,7 @@ class S3PresignedPublisher : public dataPublisher { S3PresignedPublisher(Logger& baseLogger, Client* inClient, const char* caCertName, String (*getUrlFxn)(String) = nullptr, - String (*getFileNameFxn)() = nullptr, - int sendEveryX = 1, uint8_t initialTransmissions = 5); + String (*getFileNameFxn)() = nullptr); /** * @brief Construct a new S3 Publisher object with certificate * @@ -172,19 +163,10 @@ class S3PresignedPublisher : public dataPublisher { * you modem module, not the actual certificate content. * @param getUrlFxn A function to call to get a new pre-signed URL * @param getFileNameFxn A function to call to get a new filename - * @param sendEveryX Interval (in units of the logging interval) between - * attempted data transmissions. - * @param initialTransmissions Number of transmissions to send immediately - * after each data point is logged (default: 5). - * - * @remark The sendEveryX and initialTransmissions parameters are not - * implemented by this publisher. Data will be sent every time the logger - * records data. */ S3PresignedPublisher(Logger& baseLogger, const char* caCertName, String (*getUrlFxn)(String) = nullptr, - String (*getFileNameFxn)() = nullptr, - int sendEveryX = 1, uint8_t initialTransmissions = 5); + String (*getFileNameFxn)() = nullptr); /** * @brief Construct a new S3 Publisher object without certificate * @@ -194,19 +176,10 @@ class S3PresignedPublisher : public dataPublisher { * single TinyGSM modem instance * @param getUrlFxn A function to call to get a new pre-signed URL * @param getFileNameFxn A function to call to get a new filename - * @param sendEveryX Interval (in units of the logging interval) between - * attempted data transmissions. - * @param initialTransmissions Number of transmissions to send immediately - * after each data point is logged (default: 5). - * - * @remark The sendEveryX and initialTransmissions parameters are not - * implemented by this publisher. Data will be sent every time the logger - * records data. */ S3PresignedPublisher(Logger& baseLogger, Client* inClient, String (*getUrlFxn)(String) = nullptr, - String (*getFileNameFxn)() = nullptr, - int sendEveryX = 1, uint8_t initialTransmissions = 5); + String (*getFileNameFxn)() = nullptr); /** * @brief Construct a new S3 Publisher object with no members set. */ diff --git a/src/publishers/ThingSpeakPublisher.cpp b/src/publishers/ThingSpeakPublisher.cpp index 53fe490cd..83da80889 100644 --- a/src/publishers/ThingSpeakPublisher.cpp +++ b/src/publishers/ThingSpeakPublisher.cpp @@ -31,10 +31,8 @@ ThingSpeakPublisher::ThingSpeakPublisher(Logger& baseLogger, Client* inClient, const char* thingSpeakClientName, const char* thingSpeakMQTTUser, const char* thingSpeakMQTTPassword, - const char* thingSpeakChannelID, - int sendEveryX, - uint8_t initialTransmissions) - : dataPublisher(baseLogger, inClient, sendEveryX, initialTransmissions) { + const char* thingSpeakChannelID) + : dataPublisher(baseLogger, inClient) { if (thingSpeakClientName) setMQTTClient(thingSpeakClientName); if (thingSpeakMQTTUser) setUserName(thingSpeakMQTTUser); if (thingSpeakMQTTPassword) setPassword(thingSpeakMQTTPassword); @@ -46,28 +44,20 @@ ThingSpeakPublisher::ThingSpeakPublisher(Logger& baseLogger, const char* thingSpeakClientName, const char* thingSpeakMQTTUser, const char* thingSpeakMQTTPassword, - const char* thingSpeakChannelID, - int sendEveryX, - uint8_t initialTransmissions) + const char* thingSpeakChannelID) : ThingSpeakPublisher(baseLogger, nullptr, thingSpeakClientName, thingSpeakMQTTUser, thingSpeakMQTTPassword, - thingSpeakChannelID, sendEveryX, - initialTransmissions) {} -ThingSpeakPublisher::ThingSpeakPublisher(Logger& baseLogger, Client* inClient, - int sendEveryX, - uint8_t initialTransmissions) + thingSpeakChannelID) {} +ThingSpeakPublisher::ThingSpeakPublisher(Logger& baseLogger, Client* inClient) : ThingSpeakPublisher( baseLogger, inClient, static_cast(nullptr), static_cast(nullptr), static_cast(nullptr), - static_cast(nullptr), sendEveryX, initialTransmissions) { -} -ThingSpeakPublisher::ThingSpeakPublisher(Logger& baseLogger, int sendEveryX, - uint8_t initialTransmissions) + static_cast(nullptr)) {} +ThingSpeakPublisher::ThingSpeakPublisher(Logger& baseLogger) : ThingSpeakPublisher( baseLogger, nullptr, static_cast(nullptr), static_cast(nullptr), static_cast(nullptr), - static_cast(nullptr), sendEveryX, initialTransmissions) { -} + static_cast(nullptr)) {} ThingSpeakPublisher::ThingSpeakPublisher() : dataPublisher() {} diff --git a/src/publishers/ThingSpeakPublisher.h b/src/publishers/ThingSpeakPublisher.h index f6f175c29..b7eae6a6d 100644 --- a/src/publishers/ThingSpeakPublisher.h +++ b/src/publishers/ThingSpeakPublisher.h @@ -70,21 +70,12 @@ class ThingSpeakPublisher : public dataPublisher { * probably the same as your MQTT device's client name. * @param thingSpeakMQTTPassword The password for your MQTT device. * @param thingSpeakChannelID The numeric channel id for your channel. - * @param sendEveryX Interval (in units of the logging interval) between - * attempted data transmissions. - * @param initialTransmissions Number of transmissions to send immediately - * after each data point is logged (default: 5). - * - * @remark The sendEveryX and initialTransmissions parameters are not - * implemented by this publisher. Data will be sent every time the logger - * records data. */ ThingSpeakPublisher(Logger& baseLogger, Client* inClient, const char* thingSpeakClientName, const char* thingSpeakMQTTUser, const char* thingSpeakMQTTPassword, - const char* thingSpeakChannelID, int sendEveryX = 1, - uint8_t initialTransmissions = 5); + const char* thingSpeakChannelID); /** * @brief Construct a new ThingSpeak Publisher object * @@ -95,20 +86,11 @@ class ThingSpeakPublisher : public dataPublisher { * probably the same as your MQTT device's client name. * @param thingSpeakMQTTPassword The password for your MQTT device. * @param thingSpeakChannelID The numeric channel id for your channel. - * @param sendEveryX Interval (in units of the logging interval) between - * attempted data transmissions. - * @param initialTransmissions Number of transmissions to send immediately - * after each data point is logged (default: 5). - * - * @remark The sendEveryX and initialTransmissions parameters are not - * implemented by this publisher. Data will be sent every time the logger - * records data. */ ThingSpeakPublisher(Logger& baseLogger, const char* thingSpeakClientName, const char* thingSpeakMQTTUser, const char* thingSpeakMQTTPassword, - const char* thingSpeakChannelID, int sendEveryX = 1, - uint8_t initialTransmissions = 5); + const char* thingSpeakChannelID); /** * @brief Construct a new ThingSpeak Publisher object * @@ -116,17 +98,8 @@ class ThingSpeakPublisher : public dataPublisher { * @param inClient An Arduino client instance to use to print data to. * Allows the use of any type of client and multiple clients tied to a * single TinyGSM modem instance - * @param sendEveryX Interval (in units of the logging interval) between - * attempted data transmissions. - * @param initialTransmissions Number of transmissions to send immediately - * after each data point is logged (default: 5). - * - * @remark The sendEveryX and initialTransmissions parameters are not - * implemented by this publisher. Data will be sent every time the logger - * records data. */ - ThingSpeakPublisher(Logger& baseLogger, Client* inClient, - int sendEveryX = 1, uint8_t initialTransmissions = 5); + ThingSpeakPublisher(Logger& baseLogger, Client* inClient); /** * @brief Construct a new ThingSpeak Publisher object * @@ -135,17 +108,8 @@ class ThingSpeakPublisher : public dataPublisher { * logger. * * @param baseLogger The logger supplying the data to be published - * @param sendEveryX Interval (in units of the logging interval) between - * attempted data transmissions. - * @param initialTransmissions Number of transmissions to send immediately - * after each data point is logged (default: 5). - * - * @remark The sendEveryX and initialTransmissions parameters are not - * implemented by this publisher. Data will be sent every time the logger - * records data. */ - explicit ThingSpeakPublisher(Logger& baseLogger, int sendEveryX = 1, - uint8_t initialTransmissions = 5); + explicit ThingSpeakPublisher(Logger& baseLogger); /** * @brief Construct a new ThingSpeak Publisher object with all members set * to defaults or null. diff --git a/src/publishers/UbidotsPublisher.cpp b/src/publishers/UbidotsPublisher.cpp index 479f80fe5..227ba6a4f 100644 --- a/src/publishers/UbidotsPublisher.cpp +++ b/src/publishers/UbidotsPublisher.cpp @@ -35,9 +35,8 @@ const char* UbidotsPublisher::payload = "{"; // Primary constructor with all authentication parameters and client UbidotsPublisher::UbidotsPublisher(Logger& baseLogger, Client* inClient, const char* authenticationToken, - const char* deviceID, int sendEveryX, - uint8_t initialTransmissions) - : dataPublisher(baseLogger, inClient, sendEveryX, initialTransmissions) { + const char* deviceID) + : dataPublisher(baseLogger, inClient) { if (authenticationToken && authenticationToken[0] != '\0') { setToken(authenticationToken); } @@ -49,18 +48,12 @@ UbidotsPublisher::UbidotsPublisher(Logger& baseLogger, Client* inClient, // Delegating constructors UbidotsPublisher::UbidotsPublisher(Logger& baseLogger, const char* authenticationToken, - const char* deviceID, int sendEveryX, - uint8_t initialTransmissions) - : UbidotsPublisher(baseLogger, nullptr, authenticationToken, deviceID, - sendEveryX, initialTransmissions) {} -UbidotsPublisher::UbidotsPublisher(Logger& baseLogger, Client* inClient, - int sendEveryX, uint8_t initialTransmissions) - : UbidotsPublisher(baseLogger, inClient, nullptr, nullptr, sendEveryX, - initialTransmissions) {} -UbidotsPublisher::UbidotsPublisher(Logger& baseLogger, int sendEveryX, - uint8_t initialTransmissions) - : UbidotsPublisher(baseLogger, nullptr, nullptr, nullptr, sendEveryX, - initialTransmissions) {} + const char* deviceID) + : UbidotsPublisher(baseLogger, nullptr, authenticationToken, deviceID) {} +UbidotsPublisher::UbidotsPublisher(Logger& baseLogger, Client* inClient) + : UbidotsPublisher(baseLogger, inClient, nullptr, nullptr) {} +UbidotsPublisher::UbidotsPublisher(Logger& baseLogger) + : UbidotsPublisher(baseLogger, nullptr, nullptr, nullptr) {} UbidotsPublisher::UbidotsPublisher() : dataPublisher() {} @@ -131,12 +124,12 @@ int16_t UbidotsPublisher::publishData(Client* outClient, bool) { strlen(_baseLogger->getSamplingFeatureUUID()) == 0) { PRINTOUT(F("A sampling feature UUID must be set before publishing data " "to Ubidots!")); - return 0; + return -1; // Configuration error } if (_authenticationToken == nullptr || _authenticationToken[0] == '\0') { PRINTOUT(F("An authentication token must be set before publishing data " "to Ubidots!")); - return 0; + return -1; // Configuration error } MS_DBG(F("Outgoing JSON size:"), calculateJsonSize()); diff --git a/src/publishers/UbidotsPublisher.h b/src/publishers/UbidotsPublisher.h index d650af8d5..cd04b99a0 100644 --- a/src/publishers/UbidotsPublisher.h +++ b/src/publishers/UbidotsPublisher.h @@ -59,18 +59,9 @@ class UbidotsPublisher : public dataPublisher { * specific device's setup panel). * @param deviceID The device API Label from Ubidots, derived from the * user-specified device name. - * @param sendEveryX Interval (in units of the logging interval) between - * attempted data transmissions. - * @param initialTransmissions Number of transmissions to send immediately - * after each data point is logged (default: 5). - * - * @remark The sendEveryX and initialTransmissions parameters are not - * implemented by this publisher. Data will be sent every time the logger - * records data. */ UbidotsPublisher(Logger& baseLogger, Client* inClient, - const char* authenticationToken, const char* deviceID, - int sendEveryX = 1, uint8_t initialTransmissions = 5); + const char* authenticationToken, const char* deviceID); /** * @brief Construct a new Ubidots Publisher object * @@ -81,18 +72,9 @@ class UbidotsPublisher : public dataPublisher { * specific device's setup panel). * @param deviceID The device API Label from Ubidots, derived from the * user-specified device name. - * @param sendEveryX Interval (in units of the logging interval) between - * attempted data transmissions. - * @param initialTransmissions Number of transmissions to send immediately - * after each data point is logged (default: 5). - * - * @remark The sendEveryX and initialTransmissions parameters are not - * implemented by this publisher. Data will be sent every time the logger - * records data. */ UbidotsPublisher(Logger& baseLogger, const char* authenticationToken, - const char* deviceID, int sendEveryX = 1, - uint8_t initialTransmissions = 5); + const char* deviceID); /** * @brief Construct a new Ubidots Publisher object * @@ -100,17 +82,8 @@ class UbidotsPublisher : public dataPublisher { * @param inClient An Arduino client instance to use to print data to. * Allows the use of any type of client and multiple clients tied to a * single TinyGSM modem instance - * @param sendEveryX Interval (in units of the logging interval) between - * attempted data transmissions. - * @param initialTransmissions Number of transmissions to send immediately - * after each data point is logged (default: 5). - * - * @remark The sendEveryX and initialTransmissions parameters are not - * implemented by this publisher. Data will be sent every time the logger - * records data. */ - UbidotsPublisher(Logger& baseLogger, Client* inClient, int sendEveryX = 1, - uint8_t initialTransmissions = 5); + UbidotsPublisher(Logger& baseLogger, Client* inClient); /** * @brief Construct a new Ubidots Publisher object * @@ -119,17 +92,8 @@ class UbidotsPublisher : public dataPublisher { * logger. * * @param baseLogger The logger supplying the data to be published - * @param sendEveryX Interval (in units of the logging interval) between - * attempted data transmissions. - * @param initialTransmissions Number of transmissions to send immediately - * after each data point is logged (default: 5). - * - * @remark The sendEveryX and initialTransmissions parameters are not - * implemented by this publisher. Data will be sent every time the logger - * records data. */ - explicit UbidotsPublisher(Logger& baseLogger, int sendEveryX = 1, - uint8_t initialTransmissions = 5); + explicit UbidotsPublisher(Logger& baseLogger); /** * @brief Construct a new Ubidots Publisher object with all members set to * defaults or null. From 9bcdaa2766c0feef0cfed92e9f238e0ba0af894e Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Fri, 6 Mar 2026 12:02:59 -0500 Subject: [PATCH 468/533] Change type of tz_offset Signed-off-by: Sara Damiano --- src/ClockSupport.cpp | 14 +++++++------- src/ClockSupport.h | 26 ++++++++++++++------------ 2 files changed, 21 insertions(+), 19 deletions(-) diff --git a/src/ClockSupport.cpp b/src/ClockSupport.cpp index 484a4403b..816423883 100644 --- a/src/ClockSupport.cpp +++ b/src/ClockSupport.cpp @@ -182,7 +182,7 @@ const uint32_t epochTime::leapSeconds[NUMBER_LEAP_SECONDS] = LEAP_SECONDS; // Initialize the processor epoch epochStart loggerClock::_core_epoch = epochStart::y2k_epoch; // Initialize the processor timezone offset -int16_t loggerClock::_core_tz = 0; +int32_t loggerClock::_core_tz = 0; // Initialize the static timezone int8_t loggerClock::_rtcUTCOffset = 0; @@ -633,7 +633,7 @@ epochStart loggerClock::getProcessorEpochStart() { // how to consistently set or detect the timezone across platforms, so instead // we will just use mktime and then compare the returned timestamp to the known // epoch start to figure out the offset. -int16_t loggerClock::getProcessorTimeZone() { +int32_t loggerClock::getProcessorTimeZone() { // Create a time struct for Jan 1, 2000 at 00:00:00 in the processor's epoch tm timeParts = {}; timeParts.tm_sec = 0; @@ -660,17 +660,17 @@ int16_t loggerClock::getProcessorTimeZone() { // casting. If the timeY2K is less than 24 hours, it's a positive offset of // that many seconds. If it's more than 24 hours, it's a negative offset of // tz_offset (because the time would have rolled back to the previous day). - int16_t tz_offset; + int32_t tz_offset; const time_t secondsInDay = 60L * 60L * 24L; // 86400 seconds in a day if (timeY2K < secondsInDay) { - tz_offset = static_cast(timeY2K); + tz_offset = static_cast(timeY2K); } else if ((-1 * timeY2K) < secondsInDay) { // force roll-over and check size - tz_offset = static_cast(-1 * (-1 * timeY2K)); + tz_offset = -1 * (static_cast(-1 * timeY2K)); } else { // If the difference is more than 24 hours, something is wrong and // we should just return 0 (UTC) - tz_offset = static_cast(0); - // NOTE: Do this silently in case Serial isn't initialzed yet. + tz_offset = static_cast(0); + // NOTE: Do this silently in case Serial isn't initialized yet. } loggerClock::_core_tz = tz_offset; return tz_offset; diff --git a/src/ClockSupport.h b/src/ClockSupport.h index 3eca9cd6f..08e9ec799 100644 --- a/src/ClockSupport.h +++ b/src/ClockSupport.h @@ -53,7 +53,8 @@ #undef MS_USE_RV8803 #undef MS_USE_RTC_ZERO #elif (defined(ARDUINO_ARCH_SAMD) && !defined(__SAMD51__)) && \ - !defined(MS_USE_DS3231) && !defined(MS_USE_RV8803) && \ + !defined(MS_USE_DS3231) && \ + !defined(MS_USE_RV8803) && \ !defined(MS_USE_RTC_ZERO) /** * @brief Select the SAMD21's internal clock (via RTC Zero) if no other RTC is @@ -64,7 +65,8 @@ #undef MS_USE_DS3231 #endif -#if !defined(MS_USE_RV8803) && !defined(MS_USE_DS3231) && \ +#if !defined(MS_USE_RV8803) && \ + !defined(MS_USE_DS3231) && \ !defined(MS_USE_RTC_ZERO) #error Define a clock to use for the RTC for Modular Sensors! #endif @@ -158,14 +160,14 @@ enum class epochStart : time_t { EPOCH_NIST_TO_UNIX, ///< Use a Unix epoch, starting Jan 1, 1970. ///< This is the default for this library y2k_epoch = EPOCH_NIST_TO_UNIX + - EPOCH_UNIX_TO_Y2K, ///< Use an epoch starting Jan 1, 2000, as some - ///< RTC's and Arduinos do (946684800s ahead of - ///< UNIX epoch) + EPOCH_UNIX_TO_Y2K, ///< Use an epoch starting Jan 1, 2000, as + ///< some RTC's and Arduinos do (946684800s + ///< ahead of UNIX epoch) gps_epoch = EPOCH_NIST_TO_UNIX + - EPOCH_UNIX_TO_GPS, ///< Use the GPS epoch starting Jan 5, 1980 - ///< (was 315964800s ahead of UNIX epoch at - ///< founding, has drifted farther apart due to - ///< leap seconds) + EPOCH_UNIX_TO_GPS, ///< Use the GPS epoch starting Jan 5, 1980 + ///< (was 315964800s ahead of UNIX epoch at + ///< founding, has drifted farther apart due + ///< to leap seconds) nist_epoch = 0 ///< Use the epoch starting Jan 1, 1900 as returned by ///< the NIST Network Time Protocol (RFC-1305 and later ///< versions) and Time Protocol (RFC-868) (2208988800 @@ -622,7 +624,7 @@ class loggerClock { * @return The timezone offset for the processor/Arduino core in seconds * from UTC */ - static int16_t getCoreTimeZone() { + static int32_t getCoreTimeZone() { return loggerClock::_core_tz; }; /** @@ -654,7 +656,7 @@ class loggerClock { * * @return The timezone offset in seconds from UTC */ - static int16_t getProcessorTimeZone(); + static int32_t getProcessorTimeZone(); /** * @brief The start of the epoch for the processor core's internal time.h @@ -665,7 +667,7 @@ class loggerClock { /** * @brief The timezone used by the processor core's internal time.h library. */ - static int16_t _core_tz; + static int32_t _core_tz; /** * @brief The static offset data of the real time clock from UTC in hours From be819ff2fbcb71f445e2e55512237173c16e4514 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Fri, 6 Mar 2026 12:16:14 -0500 Subject: [PATCH 469/533] Fix some typos, spelling, virtual/override redundancy Signed-off-by: Sara Damiano --- src/ModSensorConfig.h | 2 +- src/VariableArray.cpp | 8 ++- src/dataPublisherBase.cpp | 1 + src/modems/DigiXBee3GBypass.cpp | 2 +- src/modems/LoggerModemMacros.h | 78 +++++++++++++-------------- src/modems/SodaqUBeeU201.h | 19 +++---- src/publishers/AWS_IoT_Publisher.h | 4 +- src/publishers/S3PresignedPublisher.h | 4 +- 8 files changed, 63 insertions(+), 55 deletions(-) diff --git a/src/ModSensorConfig.h b/src/ModSensorConfig.h index 84d85bdf9..3db21094d 100644 --- a/src/ModSensorConfig.h +++ b/src/ModSensorConfig.h @@ -104,7 +104,7 @@ static_assert(MAX_NUMBER_VARS > 0 && MAX_NUMBER_VARS <= 21, /** * @brief The largest number of sensors in a single variable array. * - * @note This iS **not** the same as the maximum number of variables in a + * @note This is **not** the same as the maximum number of variables in a * variable array. One sensor may return many variables but only counts as one * sensor. * diff --git a/src/VariableArray.cpp b/src/VariableArray.cpp index 25abea968..a06b5ab1c 100644 --- a/src/VariableArray.cpp +++ b/src/VariableArray.cpp @@ -83,6 +83,12 @@ bool VariableArray::populateSensorList() { _sensorList[i] = nullptr; } + // Early exit if no valid variable array + if (arrayOfVars == nullptr) { + _sensorCount = 0; + return true; + } + for (uint8_t i = 0; i < _variableCount; i++) { // Skip calculated variables since they don't have parent sensors if (arrayOfVars[i]->isCalculated) { continue; } @@ -448,7 +454,7 @@ bool VariableArray::completeUpdate(bool powerUp, bool wake, bool sleep, // assuming they are awake. If the sensors are not powered, the // checkPowerOn function will reset the power *and wake* bits so the // wake check or wake function will work correctly. - MS_DBG(F("----->> Checking the power state of all sensor. ...")); + MS_DBG(F("----->> Checking the power state of all sensors. ...")); for (uint8_t i = 0; i < _sensorCount; i++) { _sensorList[i]->checkPowerOn(); } diff --git a/src/dataPublisherBase.cpp b/src/dataPublisherBase.cpp index 1be400092..8ca2ce7a6 100644 --- a/src/dataPublisherBase.cpp +++ b/src/dataPublisherBase.cpp @@ -40,6 +40,7 @@ dataPublisher::dataPublisher(Logger& baseLogger, int sendEveryX, // initialized dataPublisher::dataPublisher() : _baseLogger(nullptr), + _baseModem(nullptr), _inClient(nullptr), _sendEveryX(1), _initialTransmissionsRemaining(5) {} diff --git a/src/modems/DigiXBee3GBypass.cpp b/src/modems/DigiXBee3GBypass.cpp index f40a3eb06..e1ed67f1d 100644 --- a/src/modems/DigiXBee3GBypass.cpp +++ b/src/modems/DigiXBee3GBypass.cpp @@ -159,7 +159,7 @@ bool DigiXBee3GBypass::modemHardReset() { } if (success) { MS_DBG(F("... and forcing a reset of the cellular component.")); - // Force a reset of the undelying cellular component + // Force a reset of the underlying cellular component gsmModem.sendAT(GF("!R")); success &= gsmModem.waitResponse(30000L, GF("OK\r")) == 1; // Exit command mode diff --git a/src/modems/LoggerModemMacros.h b/src/modems/LoggerModemMacros.h index ade87b4f1..4cc773d18 100644 --- a/src/modems/LoggerModemMacros.h +++ b/src/modems/LoggerModemMacros.h @@ -667,45 +667,45 @@ return gsmModem.getNetworkEpoch(TinyGSM_EpochStart::UNIX); \ } #elif defined(TINY_GSM_MODEM_HAS_NTP) && defined(TINY_GSM_MODEM_HAS_TIME) -#define MS_MODEM_GET_NIST_TIME(specificModem, TinyGSMType) \ - uint32_t specificModem::getNISTTime() { \ - /** Check for and bail if not connected to the internet. */ \ - if (!isInternetAvailable()) { \ - MS_DBG(F("No internet connection, cannot get network time.")); \ - return 0; \ - } \ - \ - MS_DBG("Asking modem to sync with NTP"); \ - gsmModem.NTPServerSync("pool.ntp.org", 0); /*UTC!*/ \ - gsmModem.waitForTimeSync(); \ - \ - /* Create ints to hold time parts */ \ - int seconds = 0; \ - int minutes = 0; \ - int hours = 0; \ - int day = 0; \ - int month = 0; \ - int year = 0; \ - /* Fetch the time as parts */ \ - bool success = gsmModem.getNetworkTime(&year, &month, &day, &hours, \ - &minutes, &seconds, 0); \ - if (!success) { return 0; } \ - tm timeParts = {}; \ - timeParts.tm_sec = seconds; \ - timeParts.tm_min = minutes; \ - timeParts.tm_hour = hours; \ - timeParts.tm_mday = day; \ - timeParts.tm_mon = month - 1; /* tm_mon is 0-11 */ \ - timeParts.tm_year = year - 1900; /* tm_year is since 1900 */ \ - timeParts.tm_wday = 0; /* day of week, will be calculated */ \ - timeParts.tm_yday = 0; /* day of year, will be calculated */ \ - timeParts.tm_isdst = 0; /* daylight saving time flag */ \ - time_t timeTimeT = mktime(&timeParts); \ - /* The mktime fuction uses 'local' time in making the timestamp. */ \ - /* We subtrack whatever the processor thinks is 'local' */ \ - /* to get back to UTC.*/ \ - return static_cast(timeTimeT) - \ - loggerClock::getCoreTimeZone(); \ +#define MS_MODEM_GET_NIST_TIME(specificModem, TinyGSMType) \ + uint32_t specificModem::getNISTTime() { \ + /** Check for and bail if not connected to the internet. */ \ + if (!isInternetAvailable()) { \ + MS_DBG(F("No internet connection, cannot get network time.")); \ + return 0; \ + } \ + \ + MS_DBG("Asking modem to sync with NTP"); \ + gsmModem.NTPServerSync("pool.ntp.org", 0); /*UTC!*/ \ + gsmModem.waitForTimeSync(); \ + \ + /* Create ints to hold time parts */ \ + int seconds = 0; \ + int minutes = 0; \ + int hours = 0; \ + int day = 0; \ + int month = 0; \ + int year = 0; \ + /* Fetch the time as parts */ \ + bool success = gsmModem.getNetworkTime(&year, &month, &day, &hours, \ + &minutes, &seconds, 0); \ + if (!success) { return 0; } \ + tm timeParts = {}; \ + timeParts.tm_sec = seconds; \ + timeParts.tm_min = minutes; \ + timeParts.tm_hour = hours; \ + timeParts.tm_mday = day; \ + timeParts.tm_mon = month - 1; /* tm_mon is 0-11 */ \ + timeParts.tm_year = year - 1900; /* tm_year is since 1900 */ \ + timeParts.tm_wday = 0; /* day of week, will be calculated */ \ + timeParts.tm_yday = 0; /* day of year, will be calculated */ \ + timeParts.tm_isdst = 0; /* daylight saving time flag */ \ + time_t timeTimeT = mktime(&timeParts); \ + /* The mktime function uses 'local' time in making the timestamp. */ \ + /* We subtract whatever the processor thinks is 'local' */ \ + /* to get back to UTC.*/ \ + return static_cast(timeTimeT) - \ + loggerClock::getCoreTimeZone(); \ } #else #define MS_MODEM_GET_NIST_TIME(specificModem, TinyGSMType) \ diff --git a/src/modems/SodaqUBeeU201.h b/src/modems/SodaqUBeeU201.h index 1055699ca..f4bc3946b 100644 --- a/src/modems/SodaqUBeeU201.h +++ b/src/modems/SodaqUBeeU201.h @@ -203,15 +203,16 @@ class SodaqUBeeU201 : public loggerModem { bool connectInternet(uint32_t maxConnectionTime = 50000L) override; void disconnectInternet() override; - virtual Client* createClient() override; - virtual void deleteClient(Client* client); - virtual Client* createSecureClient() override; - virtual void deleteSecureClient(Client* client); - virtual Client* createSecureClient( - SSLAuthMode sslAuthMode, SSLVersion sslVersion = SSLVersion::TLS1_2, - const char* CAcertName = nullptr, const char* clientCertName = nullptr, - const char* clientKeyName = nullptr) override; - virtual Client* + Client* createClient() override; + void deleteClient(Client* client) override; + Client* createSecureClient() override; + void deleteSecureClient(Client* client) override; + Client* createSecureClient(SSLAuthMode sslAuthMode, + SSLVersion sslVersion = SSLVersion::TLS1_2, + const char* CAcertName = nullptr, + const char* clientCertName = nullptr, + const char* clientKeyName = nullptr) override; + Client* createSecureClient(const char* pskIdent, const char* psKey, SSLVersion sslVersion = SSLVersion::TLS1_2) override; Client* diff --git a/src/publishers/AWS_IoT_Publisher.h b/src/publishers/AWS_IoT_Publisher.h index 5c83435b2..247d99e6b 100644 --- a/src/publishers/AWS_IoT_Publisher.h +++ b/src/publishers/AWS_IoT_Publisher.h @@ -458,8 +458,8 @@ class AWS_IoT_Publisher : public dataPublisher { static const int mqttPort; static const char* samplingFeatureTag; ///< The JSON feature UUID tag static const char* timestampTag; ///< The JSON feature timestamp tag - virtual Client* createClient() override; - virtual void deleteClient(Client* client) override; + Client* createClient() override; + void deleteClient(Client* client) override; private: // Keys for AWS IoT Core diff --git a/src/publishers/S3PresignedPublisher.h b/src/publishers/S3PresignedPublisher.h index 9755a164f..46682ebd7 100644 --- a/src/publishers/S3PresignedPublisher.h +++ b/src/publishers/S3PresignedPublisher.h @@ -321,8 +321,8 @@ class S3PresignedPublisher : public dataPublisher { bool forceFlush = MS_ALWAYS_FLUSH_PUBLISHERS) override; protected: - virtual Client* createClient() override; - virtual void deleteClient(Client* client) override; + Client* createClient() override; + void deleteClient(Client* client) override; const char* s3_parent_host = "s3.amazonaws.com"; ///< The host name int s3Port = 443; ///< The host port From 02a629457118fd9ff99bcd6090dff9c6a2638db5 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Fri, 6 Mar 2026 12:27:27 -0500 Subject: [PATCH 470/533] Update clang format; increase PenaltyReturnTypeOnItsOwnLine Signed-off-by: Sara Damiano --- .clang-format | 74 +++++++++++++------ .../sdi12_address_change.ino | 4 +- src/ClockSupport.h | 20 +++-- src/LoggerModem.h | 12 +-- src/dataPublisherBase.h | 5 +- src/modems/DigiXBee3GBypass.h | 12 +-- src/modems/DigiXBeeCellularTransparent.h | 12 +-- src/modems/DigiXBeeLTEBypass.h | 12 +-- src/modems/DigiXBeeWifi.h | 12 +-- src/modems/EspressifESP32.h | 12 +-- src/modems/EspressifESP8266.h | 12 +-- src/modems/LoggerModemMacros.h | 2 +- src/modems/QuectelBG96.h | 12 +-- src/modems/SIMComSIM7000.h | 12 +-- src/modems/SIMComSIM7080.h | 12 +-- src/modems/SIMComSIM800.h | 12 +-- src/modems/SequansMonarch.h | 12 +-- src/modems/SodaqUBeeR410M.h | 12 +-- src/modems/SodaqUBeeU201.h | 12 +-- src/sensors/ProcessorAnalog.cpp | 5 +- 20 files changed, 152 insertions(+), 126 deletions(-) diff --git a/.clang-format b/.clang-format index 6e42a7597..f12b4c484 100644 --- a/.clang-format +++ b/.clang-format @@ -2,13 +2,28 @@ Language: Cpp # BasedOnStyle: Google AccessModifierOffset: -3 +ColumnLimit: 80 +DisableFormat: false +Standard: Cpp11 +TabWidth: 4 +UseTab: Never + AlignAfterOpenBracket: Align AlignConsecutiveMacros: false -AlignConsecutiveAssignments: true -AlignConsecutiveDeclarations: true +AlignArrayOfStructures: Right +AlignConsecutiveAssignments: + Enabled: true + AcrossEmptyLines: false + AcrossComments: false +AlignConsecutiveDeclarations: + Enabled: true + AcrossEmptyLines: false + AcrossComments: false AlignEscapedNewlines: Left +# AlignOperands: AlignAfterOperator AlignOperands: false AlignTrailingComments: true + AllowAllArgumentsOnNextLine: true AllowAllConstructorInitializersOnNextLine: true AllowAllParametersOfDeclarationOnNextLine: true @@ -19,33 +34,40 @@ AllowShortFunctionsOnASingleLine: Empty AllowShortIfStatementsOnASingleLine: WithoutElse AllowShortLambdasOnASingleLine: All AllowShortLoopsOnASingleLine: true -AlwaysBreakAfterDefinitionReturnType: None -AlwaysBreakAfterReturnType: None + AlwaysBreakBeforeMultilineStrings: false AlwaysBreakTemplateDeclarations: Yes + BinPackArguments: true -BinPackParameters: true +BinPackParameters: BinPack + BreakAfterJavaFieldAnnotations: false +BreakAfterReturnType: Automatic +BreakArrays: false BreakBeforeBinaryOperators: None BreakBeforeBraces: Attach BreakBeforeInheritanceComma: false BreakBeforeTernaryOperators: true -BreakConstructorInitializersBeforeComma: false +# BreakBinaryOperations: RespectPrecedence +BreakBinaryOperations: Never BreakConstructorInitializers: BeforeColon +BreakFunctionDefinitionParameters: false BreakInheritanceList: BeforeColon BreakStringLiterals: true -ColumnLimit: 80 + CommentPragmas: '^ IWYU pragma:' + CompactNamespaces: false -ConstructorInitializerAllOnOneLineOrOnePerLine: false + ConstructorInitializerIndentWidth: 4 + ContinuationIndentWidth: 4 Cpp11BracedListStyle: true DerivePointerAlignment: false -DisableFormat: false + EmptyLineAfterAccessModifier: Leave EmptyLineBeforeAccessModifier: Leave -ExperimentalAutoDetectBinPacking: false + FixNamespaceComments: true ForEachMacros: - foreach @@ -64,6 +86,7 @@ IncludeCategories: - Regex: '.*' Priority: 1 IncludeIsMainRegex: '([-_](test|unittest))?$' + IndentAccessModifiers: false IndentCaseBlocks: false IndentCaseLabels: true @@ -72,19 +95,24 @@ IndentGotoLabels: true IndentPPDirectives: None IndentWidth: 4 IndentWrappedFunctionNames: false + +InsertBraces: false +InsertNewlineAtEOF: true InsertTrailingCommas: None -JavaScriptQuotes: Leave -JavaScriptWrapImports: true -KeepEmptyLinesAtTheStartOfBlocks: false + +KeepEmptyLines: + AtEndOfFile: false + AtStartOfBlock: false + AtStartOfFile: false +MaxEmptyLinesToKeep: 2 + MacroBlockBegin: '' MacroBlockEnd: '' -MaxEmptyLinesToKeep: 2 + NamespaceIndentation: None -# ObjCBinPackProtocolList: Auto -ObjCBlockIndentWidth: 2 -ObjCSpaceAfterProperty: false -ObjCSpaceBeforeProtocolList: true + PackConstructorInitializers: CurrentLine + PenaltyBreakAssignment: 25 PenaltyBreakBeforeFirstCallParameter: 19 PenaltyBreakComment: 300 @@ -92,15 +120,20 @@ PenaltyBreakFirstLessLess: 120 PenaltyBreakString: 1000 PenaltyBreakTemplateDeclaration: 10 PenaltyExcessCharacter: 600 -PenaltyReturnTypeOnItsOwnLine: 50 +PenaltyReturnTypeOnItsOwnLine: 500 + PointerAlignment: Left PointerBindsToType: true QualifierAlignment: Left ReferenceAlignment: Left + ReflowComments: true + SeparateDefinitionBlocks: Leave + SortIncludes: false SortUsingDeclarations: true + SpaceAfterCStyleCast: false SpaceAfterLogicalNot: false SpaceAfterTemplateKeyword: true @@ -121,7 +154,4 @@ SpacesInLineCommentPrefix: Minimum: 1 SpacesInParentheses: false SpacesInSquareBrackets: false -Standard: Cpp11 -TabWidth: 4 -UseTab: Never --- diff --git a/extras/sdi12_address_change/sdi12_address_change.ino b/extras/sdi12_address_change/sdi12_address_change.ino index 88f3e2271..f14083e70 100644 --- a/extras/sdi12_address_change/sdi12_address_change.ino +++ b/extras/sdi12_address_change/sdi12_address_change.ino @@ -33,8 +33,8 @@ char oldAddress = '!'; // invalid address as placeholder // this checks for activity at a particular address // expects a char, '0'-'9', 'a'-'z', or 'A'-'Z' -boolean -checkActive(byte i) { // this checks for activity at a particular address +boolean checkActive( + byte i) { // this checks for activity at a particular address Serial.print("Checking address "); Serial.print(static_cast(i)); Serial.print("..."); diff --git a/src/ClockSupport.h b/src/ClockSupport.h index 08e9ec799..4eed8b4dd 100644 --- a/src/ClockSupport.h +++ b/src/ClockSupport.h @@ -53,8 +53,7 @@ #undef MS_USE_RV8803 #undef MS_USE_RTC_ZERO #elif (defined(ARDUINO_ARCH_SAMD) && !defined(__SAMD51__)) && \ - !defined(MS_USE_DS3231) && \ - !defined(MS_USE_RV8803) && \ + !defined(MS_USE_DS3231) && !defined(MS_USE_RV8803) && \ !defined(MS_USE_RTC_ZERO) /** * @brief Select the SAMD21's internal clock (via RTC Zero) if no other RTC is @@ -65,8 +64,7 @@ #undef MS_USE_DS3231 #endif -#if !defined(MS_USE_RV8803) && \ - !defined(MS_USE_DS3231) && \ +#if !defined(MS_USE_RV8803) && !defined(MS_USE_DS3231) && \ !defined(MS_USE_RTC_ZERO) #error Define a clock to use for the RTC for Modular Sensors! #endif @@ -160,14 +158,14 @@ enum class epochStart : time_t { EPOCH_NIST_TO_UNIX, ///< Use a Unix epoch, starting Jan 1, 1970. ///< This is the default for this library y2k_epoch = EPOCH_NIST_TO_UNIX + - EPOCH_UNIX_TO_Y2K, ///< Use an epoch starting Jan 1, 2000, as - ///< some RTC's and Arduinos do (946684800s - ///< ahead of UNIX epoch) + EPOCH_UNIX_TO_Y2K, ///< Use an epoch starting Jan 1, 2000, as + ///< some RTC's and Arduinos do (946684800s + ///< ahead of UNIX epoch) gps_epoch = EPOCH_NIST_TO_UNIX + - EPOCH_UNIX_TO_GPS, ///< Use the GPS epoch starting Jan 5, 1980 - ///< (was 315964800s ahead of UNIX epoch at - ///< founding, has drifted farther apart due - ///< to leap seconds) + EPOCH_UNIX_TO_GPS, ///< Use the GPS epoch starting Jan 5, 1980 + ///< (was 315964800s ahead of UNIX epoch at + ///< founding, has drifted farther apart due + ///< to leap seconds) nist_epoch = 0 ///< Use the epoch starting Jan 1, 1900 as returned by ///< the NIST Network Time Protocol (RFC-1305 and later ///< versions) and Time Protocol (RFC-868) (2208988800 diff --git a/src/LoggerModem.h b/src/LoggerModem.h index c8b028f3e..7c6c42561 100644 --- a/src/LoggerModem.h +++ b/src/LoggerModem.h @@ -606,9 +606,9 @@ class loggerModem { * * @return A new secure client object */ - virtual Client* - createSecureClient(const char* pskIdent, const char* psKey, - SSLVersion sslVersion = SSLVersion::TLS1_2) = 0; + virtual Client* createSecureClient( + const char* pskIdent, const char* psKey, + SSLVersion sslVersion = SSLVersion::TLS1_2) = 0; /** * @brief Create a new secure client object using the default socket number * @@ -618,9 +618,9 @@ class loggerModem { * * @return A new secure client object */ - virtual Client* - createSecureClient(const char* pskTableName, - SSLVersion sslVersion = SSLVersion::TLS1_2) = 0; + virtual Client* createSecureClient( + const char* pskTableName, + SSLVersion sslVersion = SSLVersion::TLS1_2) = 0; /** * @brief Attempts to delete a created TinyGsmClient object. We need to do * this to close memory leaks from the create client because we can't delete diff --git a/src/dataPublisherBase.h b/src/dataPublisherBase.h index 86a1dc428..2aa2c246a 100644 --- a/src/dataPublisherBase.h +++ b/src/dataPublisherBase.h @@ -235,9 +235,8 @@ class dataPublisher { * @return The result of publishing data. May be an http response code or a * result code from PubSubClient. */ - virtual int16_t - publishData(Client* outClient, - bool forceFlush = MS_ALWAYS_FLUSH_PUBLISHERS) = 0; + virtual int16_t publishData( + Client* outClient, bool forceFlush = MS_ALWAYS_FLUSH_PUBLISHERS) = 0; /** * @brief Open a socket to the correct receiver and send out the formatted * data. diff --git a/src/modems/DigiXBee3GBypass.h b/src/modems/DigiXBee3GBypass.h index f3fbdb2a3..a534e43a9 100644 --- a/src/modems/DigiXBee3GBypass.h +++ b/src/modems/DigiXBee3GBypass.h @@ -141,12 +141,12 @@ class DigiXBee3GBypass : public DigiXBee { const char* CAcertName = nullptr, const char* clientCertName = nullptr, const char* clientKeyName = nullptr) override; - Client* - createSecureClient(const char* pskIdent, const char* psKey, - SSLVersion sslVersion = SSLVersion::TLS1_2) override; - Client* - createSecureClient(const char* pskTableName, - SSLVersion sslVersion = SSLVersion::TLS1_2) override; + Client* createSecureClient( + const char* pskIdent, const char* psKey, + SSLVersion sslVersion = SSLVersion::TLS1_2) override; + Client* createSecureClient( + const char* pskTableName, + SSLVersion sslVersion = SSLVersion::TLS1_2) override; uint32_t getNISTTime() override; diff --git a/src/modems/DigiXBeeCellularTransparent.h b/src/modems/DigiXBeeCellularTransparent.h index 030673d6e..e48253e39 100644 --- a/src/modems/DigiXBeeCellularTransparent.h +++ b/src/modems/DigiXBeeCellularTransparent.h @@ -175,12 +175,12 @@ class DigiXBeeCellularTransparent : public DigiXBee { const char* CAcertName = nullptr, const char* clientCertName = nullptr, const char* clientKeyName = nullptr) override; - Client* - createSecureClient(const char* pskIdent, const char* psKey, - SSLVersion sslVersion = SSLVersion::TLS1_2) override; - Client* - createSecureClient(const char* pskTableName, - SSLVersion sslVersion = SSLVersion::TLS1_2) override; + Client* createSecureClient( + const char* pskIdent, const char* psKey, + SSLVersion sslVersion = SSLVersion::TLS1_2) override; + Client* createSecureClient( + const char* pskTableName, + SSLVersion sslVersion = SSLVersion::TLS1_2) override; uint32_t getNISTTime() override; diff --git a/src/modems/DigiXBeeLTEBypass.h b/src/modems/DigiXBeeLTEBypass.h index f72930b23..ea97d9a22 100644 --- a/src/modems/DigiXBeeLTEBypass.h +++ b/src/modems/DigiXBeeLTEBypass.h @@ -156,12 +156,12 @@ class DigiXBeeLTEBypass : public DigiXBee { const char* CAcertName = nullptr, const char* clientCertName = nullptr, const char* clientKeyName = nullptr) override; - Client* - createSecureClient(const char* pskIdent, const char* psKey, - SSLVersion sslVersion = SSLVersion::TLS1_2) override; - Client* - createSecureClient(const char* pskTableName, - SSLVersion sslVersion = SSLVersion::TLS1_2) override; + Client* createSecureClient( + const char* pskIdent, const char* psKey, + SSLVersion sslVersion = SSLVersion::TLS1_2) override; + Client* createSecureClient( + const char* pskTableName, + SSLVersion sslVersion = SSLVersion::TLS1_2) override; uint32_t getNISTTime() override; diff --git a/src/modems/DigiXBeeWifi.h b/src/modems/DigiXBeeWifi.h index 0017f0ab8..2f53056e5 100644 --- a/src/modems/DigiXBeeWifi.h +++ b/src/modems/DigiXBeeWifi.h @@ -151,12 +151,12 @@ class DigiXBeeWifi : public DigiXBee { const char* CAcertName = nullptr, const char* clientCertName = nullptr, const char* clientKeyName = nullptr) override; - Client* - createSecureClient(const char* pskIdent, const char* psKey, - SSLVersion sslVersion = SSLVersion::TLS1_2) override; - Client* - createSecureClient(const char* pskTableName, - SSLVersion sslVersion = SSLVersion::TLS1_2) override; + Client* createSecureClient( + const char* pskIdent, const char* psKey, + SSLVersion sslVersion = SSLVersion::TLS1_2) override; + Client* createSecureClient( + const char* pskTableName, + SSLVersion sslVersion = SSLVersion::TLS1_2) override; uint32_t getNISTTime() override; diff --git a/src/modems/EspressifESP32.h b/src/modems/EspressifESP32.h index 39b3f78be..12790dedb 100644 --- a/src/modems/EspressifESP32.h +++ b/src/modems/EspressifESP32.h @@ -139,12 +139,12 @@ class EspressifESP32 : public Espressif { const char* CAcertName = nullptr, const char* clientCertName = nullptr, const char* clientKeyName = nullptr) override; - Client* - createSecureClient(const char* pskIdent, const char* psKey, - SSLVersion sslVersion = SSLVersion::TLS1_2) override; - Client* - createSecureClient(const char* pskTableName, - SSLVersion sslVersion = SSLVersion::TLS1_2) override; + Client* createSecureClient( + const char* pskIdent, const char* psKey, + SSLVersion sslVersion = SSLVersion::TLS1_2) override; + Client* createSecureClient( + const char* pskTableName, + SSLVersion sslVersion = SSLVersion::TLS1_2) override; uint32_t getNISTTime() override; diff --git a/src/modems/EspressifESP8266.h b/src/modems/EspressifESP8266.h index a59890371..df12f6fc7 100644 --- a/src/modems/EspressifESP8266.h +++ b/src/modems/EspressifESP8266.h @@ -138,12 +138,12 @@ class EspressifESP8266 : public Espressif { const char* CAcertName = nullptr, const char* clientCertName = nullptr, const char* clientKeyName = nullptr) override; - Client* - createSecureClient(const char* pskIdent, const char* psKey, - SSLVersion sslVersion = SSLVersion::TLS1_2) override; - Client* - createSecureClient(const char* pskTableName, - SSLVersion sslVersion = SSLVersion::TLS1_2) override; + Client* createSecureClient( + const char* pskIdent, const char* psKey, + SSLVersion sslVersion = SSLVersion::TLS1_2) override; + Client* createSecureClient( + const char* pskTableName, + SSLVersion sslVersion = SSLVersion::TLS1_2) override; uint32_t getNISTTime() override; diff --git a/src/modems/LoggerModemMacros.h b/src/modems/LoggerModemMacros.h index 4cc773d18..9af90ed60 100644 --- a/src/modems/LoggerModemMacros.h +++ b/src/modems/LoggerModemMacros.h @@ -705,7 +705,7 @@ /* We subtract whatever the processor thinks is 'local' */ \ /* to get back to UTC.*/ \ return static_cast(timeTimeT) - \ - loggerClock::getCoreTimeZone(); \ + loggerClock::getCoreTimeZone(); \ } #else #define MS_MODEM_GET_NIST_TIME(specificModem, TinyGSMType) \ diff --git a/src/modems/QuectelBG96.h b/src/modems/QuectelBG96.h index 5949b9a61..f5c64f197 100644 --- a/src/modems/QuectelBG96.h +++ b/src/modems/QuectelBG96.h @@ -216,12 +216,12 @@ class QuectelBG96 : public loggerModem { const char* CAcertName = nullptr, const char* clientCertName = nullptr, const char* clientKeyName = nullptr) override; - Client* - createSecureClient(const char* pskIdent, const char* psKey, - SSLVersion sslVersion = SSLVersion::TLS1_2) override; - Client* - createSecureClient(const char* pskTableName, - SSLVersion sslVersion = SSLVersion::TLS1_2) override; + Client* createSecureClient( + const char* pskIdent, const char* psKey, + SSLVersion sslVersion = SSLVersion::TLS1_2) override; + Client* createSecureClient( + const char* pskTableName, + SSLVersion sslVersion = SSLVersion::TLS1_2) override; uint32_t getNISTTime() override; diff --git a/src/modems/SIMComSIM7000.h b/src/modems/SIMComSIM7000.h index 24176cedc..9a7aae1fa 100644 --- a/src/modems/SIMComSIM7000.h +++ b/src/modems/SIMComSIM7000.h @@ -204,12 +204,12 @@ class SIMComSIM7000 : public loggerModem { const char* CAcertName = nullptr, const char* clientCertName = nullptr, const char* clientKeyName = nullptr) override; - Client* - createSecureClient(const char* pskIdent, const char* psKey, - SSLVersion sslVersion = SSLVersion::TLS1_2) override; - Client* - createSecureClient(const char* pskTableName, - SSLVersion sslVersion = SSLVersion::TLS1_2) override; + Client* createSecureClient( + const char* pskIdent, const char* psKey, + SSLVersion sslVersion = SSLVersion::TLS1_2) override; + Client* createSecureClient( + const char* pskTableName, + SSLVersion sslVersion = SSLVersion::TLS1_2) override; uint32_t getNISTTime() override; diff --git a/src/modems/SIMComSIM7080.h b/src/modems/SIMComSIM7080.h index 72e4c699e..44b846872 100644 --- a/src/modems/SIMComSIM7080.h +++ b/src/modems/SIMComSIM7080.h @@ -199,12 +199,12 @@ class SIMComSIM7080 : public loggerModem { const char* CAcertName = nullptr, const char* clientCertName = nullptr, const char* clientKeyName = nullptr) override; - Client* - createSecureClient(const char* pskIdent, const char* psKey, - SSLVersion sslVersion = SSLVersion::TLS1_2) override; - Client* - createSecureClient(const char* pskTableName, - SSLVersion sslVersion = SSLVersion::TLS1_2) override; + Client* createSecureClient( + const char* pskIdent, const char* psKey, + SSLVersion sslVersion = SSLVersion::TLS1_2) override; + Client* createSecureClient( + const char* pskTableName, + SSLVersion sslVersion = SSLVersion::TLS1_2) override; uint32_t getNISTTime() override; diff --git a/src/modems/SIMComSIM800.h b/src/modems/SIMComSIM800.h index 587929bcb..f4491eb81 100644 --- a/src/modems/SIMComSIM800.h +++ b/src/modems/SIMComSIM800.h @@ -206,12 +206,12 @@ class SIMComSIM800 : public loggerModem { const char* CAcertName = nullptr, const char* clientCertName = nullptr, const char* clientKeyName = nullptr) override; - Client* - createSecureClient(const char* pskIdent, const char* psKey, - SSLVersion sslVersion = SSLVersion::TLS1_2) override; - Client* - createSecureClient(const char* pskTableName, - SSLVersion sslVersion = SSLVersion::TLS1_2) override; + Client* createSecureClient( + const char* pskIdent, const char* psKey, + SSLVersion sslVersion = SSLVersion::TLS1_2) override; + Client* createSecureClient( + const char* pskTableName, + SSLVersion sslVersion = SSLVersion::TLS1_2) override; uint32_t getNISTTime() override; diff --git a/src/modems/SequansMonarch.h b/src/modems/SequansMonarch.h index 172081661..326b907ce 100644 --- a/src/modems/SequansMonarch.h +++ b/src/modems/SequansMonarch.h @@ -237,12 +237,12 @@ class SequansMonarch : public loggerModem { const char* CAcertName = nullptr, const char* clientCertName = nullptr, const char* clientKeyName = nullptr) override; - Client* - createSecureClient(const char* pskIdent, const char* psKey, - SSLVersion sslVersion = SSLVersion::TLS1_2) override; - Client* - createSecureClient(const char* pskTableName, - SSLVersion sslVersion = SSLVersion::TLS1_2) override; + Client* createSecureClient( + const char* pskIdent, const char* psKey, + SSLVersion sslVersion = SSLVersion::TLS1_2) override; + Client* createSecureClient( + const char* pskTableName, + SSLVersion sslVersion = SSLVersion::TLS1_2) override; uint32_t getNISTTime() override; diff --git a/src/modems/SodaqUBeeR410M.h b/src/modems/SodaqUBeeR410M.h index 16aff8677..69d672c59 100644 --- a/src/modems/SodaqUBeeR410M.h +++ b/src/modems/SodaqUBeeR410M.h @@ -313,12 +313,12 @@ class SodaqUBeeR410M : public loggerModem { const char* CAcertName = nullptr, const char* clientCertName = nullptr, const char* clientKeyName = nullptr) override; - Client* - createSecureClient(const char* pskIdent, const char* psKey, - SSLVersion sslVersion = SSLVersion::TLS1_2) override; - Client* - createSecureClient(const char* pskTableName, - SSLVersion sslVersion = SSLVersion::TLS1_2) override; + Client* createSecureClient( + const char* pskIdent, const char* psKey, + SSLVersion sslVersion = SSLVersion::TLS1_2) override; + Client* createSecureClient( + const char* pskTableName, + SSLVersion sslVersion = SSLVersion::TLS1_2) override; uint32_t getNISTTime() override; diff --git a/src/modems/SodaqUBeeU201.h b/src/modems/SodaqUBeeU201.h index f4bc3946b..97ce6b434 100644 --- a/src/modems/SodaqUBeeU201.h +++ b/src/modems/SodaqUBeeU201.h @@ -212,12 +212,12 @@ class SodaqUBeeU201 : public loggerModem { const char* CAcertName = nullptr, const char* clientCertName = nullptr, const char* clientKeyName = nullptr) override; - Client* - createSecureClient(const char* pskIdent, const char* psKey, - SSLVersion sslVersion = SSLVersion::TLS1_2) override; - Client* - createSecureClient(const char* pskTableName, - SSLVersion sslVersion = SSLVersion::TLS1_2) override; + Client* createSecureClient( + const char* pskIdent, const char* psKey, + SSLVersion sslVersion = SSLVersion::TLS1_2) override; + Client* createSecureClient( + const char* pskTableName, + SSLVersion sslVersion = SSLVersion::TLS1_2) override; uint32_t getNISTTime() override; diff --git a/src/sensors/ProcessorAnalog.cpp b/src/sensors/ProcessorAnalog.cpp index 8978ac0b2..da98cf8db 100644 --- a/src/sensors/ProcessorAnalog.cpp +++ b/src/sensors/ProcessorAnalog.cpp @@ -69,9 +69,8 @@ bool ProcessorAnalogBase::readVoltageSingleEnded(int8_t analogChannel, return true; } -String -ProcessorAnalogBase::getAnalogLocation(int8_t analogChannel, - int8_t /*analogReferenceChannel*/) { +String ProcessorAnalogBase::getAnalogLocation( + int8_t analogChannel, int8_t /*analogReferenceChannel*/) { String sensorLocation; sensorLocation += F("ProcessorAnalog_Pin"); sensorLocation += String(analogChannel); From d6803eaf4a339d48bb04247e0d930e15543ffc62 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Fri, 6 Mar 2026 12:51:00 -0500 Subject: [PATCH 471/533] Add debug bit opt to printSensorData Signed-off-by: Sara Damiano --- src/LoggerBase.h | 6 +++--- src/SensorBase.cpp | 22 ++++++++++++---------- src/SensorBase.h | 3 ++- src/VariableArray.cpp | 11 ++--------- src/VariableArray.h | 2 +- src/VariableBase.cpp | 3 ++- src/modems/EspressifESP32.cpp | 2 +- src/modems/SIMComSIM800.cpp | 2 +- 8 files changed, 24 insertions(+), 27 deletions(-) diff --git a/src/LoggerBase.h b/src/LoggerBase.h index af57392bd..7f9f00bcc 100644 --- a/src/LoggerBase.h +++ b/src/LoggerBase.h @@ -245,12 +245,12 @@ class Logger { } // Backwards-compatibility shims /// @copydoc setInitialShortIntervals - /// @deprecated use setInitialShortIntervals + /// @m_deprecated_since{0,38,0} use setInitialShortIntervals void setinitialShortIntervals(int16_t initialShortIntervals) { setInitialShortIntervals(initialShortIntervals); } /// @copydoc getInitialShortIntervals - /// @deprecated use getInitialShortIntervals + /// @m_deprecated_since{0,38,0} use getInitialShortIntervals int16_t getinitialShortIntervals() { return getInitialShortIntervals(); } @@ -1256,7 +1256,7 @@ class Logger { * @brief Print a comma separated list of values of variable data - * including the time in the logging timezone - out over an Arduino stream * - * @deprecated{0,39,0} Use printVariableValuesCSV() instead. + * @m_deprecated_since{0,38,0} Use printVariableValuesCSV() instead. * @param stream An Arduino stream instance */ void printSensorDataCSV(Stream* stream); diff --git a/src/SensorBase.cpp b/src/SensorBase.cpp index 245dedb54..31da81f92 100644 --- a/src/SensorBase.cpp +++ b/src/SensorBase.cpp @@ -471,18 +471,20 @@ void Sensor::averageMeasurements() { } -void Sensor::printData(Stream* stream) { +void Sensor::printData(Stream* stream, bool printStatusBits) { for (uint8_t i = 0; i < _numReturnedValues; i++) { stream->print(getSensorNameAndLocation()); - // stream->print(F(" with status 0b")); - // stream->print(getStatusBit(7)); - // stream->print(getStatusBit(6)); - // stream->print(getStatusBit(5)); - // stream->print(getStatusBit(4)); - // stream->print(getStatusBit(3)); - // stream->print(getStatusBit(2)); - // stream->print(getStatusBit(1)); - // stream->print(getStatusBit(0)); + if (printStatusBits) { + stream->print(F(" with status 0b")); + stream->print(getStatusBit(ERROR_OCCURRED)); + stream->print(getStatusBit(MEASUREMENT_SUCCESSFUL)); + stream->print(getStatusBit(MEASUREMENT_ATTEMPTED)); + stream->print(getStatusBit(WAKE_SUCCESSFUL)); + stream->print(getStatusBit(WAKE_ATTEMPTED)); + stream->print(getStatusBit(POWER_SUCCESSFUL)); + stream->print(getStatusBit(POWER_ATTEMPTED)); + stream->print(getStatusBit(SETUP_SUCCESSFUL)); + } stream->print(F(" reports ")); if (variables[i] != nullptr) { stream->print(variables[i]->getVarName()); diff --git a/src/SensorBase.h b/src/SensorBase.h index 41825b133..21f3f6be3 100644 --- a/src/SensorBase.h +++ b/src/SensorBase.h @@ -617,7 +617,8 @@ class Sensor { * * @param stream An Arduino Stream instance */ - virtual void printData(Stream* stream = &Serial); + virtual void printData(Stream* stream = &Serial, + bool printStatusBits = false); /** * @brief Register a variable object to a sensor. diff --git a/src/VariableArray.cpp b/src/VariableArray.cpp index a06b5ab1c..167bd9c22 100644 --- a/src/VariableArray.cpp +++ b/src/VariableArray.cpp @@ -173,6 +173,8 @@ bool VariableArray::canPowerDownSensor(uint8_t sensorIndex) { true; // assume we can power down unless we find a conflict for (uint8_t k = 0; k < _sensorCount; k++) { + if (k == sensorIndex) continue; // Skip self-comparison + if (( // Check if sensor i's primary pin matches either of sensor k's // pins @@ -691,15 +693,6 @@ void VariableArray::printVariableData(Stream* stream) { stream->println(); } else { stream->print(arrayOfVars[i]->getParentSensorNameAndLocation()); - // stream->print(F(" with status 0b")); - // stream->print(getSensorStatusBit(i, 7)); - // stream->print(getSensorStatusBit(i, 6)); - // stream->print(getSensorStatusBit(i, 5)); - // stream->print(getSensorStatusBit(i, 4)); - // stream->print(getSensorStatusBit(i, 3)); - // stream->print(getSensorStatusBit(i, 2)); - // stream->print(getSensorStatusBit(i, 1)); - // stream->print(getSensorStatusBit(i, 0)); stream->print(F(" reports ")); stream->print(arrayOfVars[i]->getVarName()); stream->print(F(" (")); diff --git a/src/VariableArray.h b/src/VariableArray.h index ffa2a6c7c..5e799a789 100644 --- a/src/VariableArray.h +++ b/src/VariableArray.h @@ -288,7 +288,7 @@ class VariableArray { * @brief Print out the results for all variables in the variable array to a * stream * - * @deprecated{0,39,0} Use printVariableData() instead. + * @m_deprecated_since{0,38,0} Use printVariableData() instead. * @param stream An Arduino Stream instance */ void printSensorData(Stream* stream = &Serial); diff --git a/src/VariableBase.cpp b/src/VariableBase.cpp index 18c82cd76..4ba4b88ac 100644 --- a/src/VariableBase.cpp +++ b/src/VariableBase.cpp @@ -42,7 +42,8 @@ Variable::Variable(float (*calcFxn)(), uint8_t decimalResolution, : parentSensor(nullptr), isCalculated(false), _currentValue(MS_INVALID_VALUE), - _calcFxn(nullptr) { + _calcFxn(nullptr), + _sensorVarNum(0) { if (uuid) setVarUUID(uuid); if (varCode) setVarCode(varCode); if (varUnit) setVarUnit(varUnit); diff --git a/src/modems/EspressifESP32.cpp b/src/modems/EspressifESP32.cpp index 76aaa3e92..53e45ef24 100644 --- a/src/modems/EspressifESP32.cpp +++ b/src/modems/EspressifESP32.cpp @@ -83,7 +83,7 @@ bool EspressifESP32::extraModemSetup() { gsmModem.sendAT(GF( "+CWCOUNTRY=0,\"US\",1,13")); // Set country code to default to US, // but allow to change if the AP is - success &= gsmModem.waitResponse() == 1; + success &= (gsmModem.waitResponse() == 1); } return success; } diff --git a/src/modems/SIMComSIM800.cpp b/src/modems/SIMComSIM800.cpp index bc2300722..55b749e01 100644 --- a/src/modems/SIMComSIM800.cpp +++ b/src/modems/SIMComSIM800.cpp @@ -67,7 +67,7 @@ bool SIMComSIM800::modemWakeFxn() { bool SIMComSIM800::modemSleepFxn() { if (_modemSleepRqPin >= 0) { - // Must have access to `PWRKEY` pin to sleep + // Must have access to `PWRKEY` (_modemSleepRqPin) pin to sleep // Easiest to just go to sleep with the AT command rather than using // pins MS_DBG(F("Asking SIM800 to power down")); From d7fbafe7fefedf51aec59ea63d3bc115ecd9b1ed Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Fri, 6 Mar 2026 12:54:28 -0500 Subject: [PATCH 472/533] Fix RSSI PWM Signed-off-by: Sara Damiano --- src/modems/DigiXBeeWifi.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/modems/DigiXBeeWifi.cpp b/src/modems/DigiXBeeWifi.cpp index 728157d3c..b53e62546 100644 --- a/src/modems/DigiXBeeWifi.cpp +++ b/src/modems/DigiXBeeWifi.cpp @@ -215,7 +215,7 @@ bool DigiXBeeWifi::extraModemSetup() { * thus brighter LED) indicates better signal quality. NOTE: Only * the `DIO10/PWM0` pin (6 on the bee socket) can be used for this * function. */ - bool changedP0 = gsmModem.changeSettingIfNeeded(GF("D5"), 1); + bool changedP0 = gsmModem.changeSettingIfNeeded(GF("P0"), 1); changesMade |= changedP0; if (changedP0) { MS_DBG(F("DIO10/PWM0 changed to"), 1); @@ -503,7 +503,7 @@ bool DigiXBeeWifi::updateModemMetadata() { MS_DBG(F("CURRENT Modem battery (mV):"), volt_mV); if (volt_mV != 9999) { loggerModem::_priorBatteryVoltage = - static_cast(volt_mV / 1000); + static_cast(volt_mV / 1000.0f); } else { loggerModem::_priorBatteryVoltage = static_cast(MS_INVALID_VALUE); From 8c91fa669c350fdd6a4b2f0fe1cb8886875a4869 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Fri, 6 Mar 2026 12:55:50 -0500 Subject: [PATCH 473/533] Rename bumpMeasurementAttemptCount to finalizeMeasurementAttempt Signed-off-by: Sara Damiano --- src/SensorBase.cpp | 12 ++++++------ src/SensorBase.h | 22 ++++++++++++++++------ src/sensors/ANBpH.cpp | 4 ++-- src/sensors/AOSongAM2315.cpp | 4 ++-- src/sensors/AOSongDHT.cpp | 4 ++-- src/sensors/AlphasenseCO2.cpp | 6 +++--- src/sensors/AnalogElecConductivity.cpp | 12 ++++++------ src/sensors/ApogeeSQ212.cpp | 6 +++--- src/sensors/AtlasParent.cpp | 4 ++-- src/sensors/BoschBME280.cpp | 4 ++-- src/sensors/BoschBMP3xx.cpp | 4 ++-- src/sensors/CampbellOBS3.cpp | 6 +++--- src/sensors/EverlightALSPT19.cpp | 8 ++++---- src/sensors/FreescaleMPL115A2.cpp | 4 ++-- src/sensors/GeoluxHydroCam.cpp | 10 +++++----- src/sensors/GroPointParent.cpp | 4 ++-- src/sensors/KellerParent.cpp | 4 ++-- src/sensors/MaxBotixSonar.cpp | 4 ++-- src/sensors/MaximDS18.cpp | 4 ++-- src/sensors/MaximDS3231.cpp | 2 +- src/sensors/MeaSpecMS5803.cpp | 4 ++-- src/sensors/PaleoTerraRedox.cpp | 8 ++++---- src/sensors/ProcessorAnalog.cpp | 6 +++--- src/sensors/ProcessorStats.cpp | 2 +- src/sensors/RainCounterI2C.cpp | 6 +++--- src/sensors/SDI12Sensors.cpp | 8 ++++---- src/sensors/SensirionSHT4x.cpp | 4 ++-- src/sensors/TEConnectivityMS5837.cpp | 12 ++++++------ src/sensors/TIADS1x15.cpp | 6 +++--- src/sensors/TIINA219.cpp | 4 ++-- src/sensors/TallyCounterI2C.cpp | 4 ++-- src/sensors/TurnerCyclops.cpp | 8 ++++---- src/sensors/TurnerTurbidityPlus.cpp | 8 ++++---- src/sensors/YosemitechParent.cpp | 4 ++-- 34 files changed, 111 insertions(+), 101 deletions(-) diff --git a/src/SensorBase.cpp b/src/SensorBase.cpp index 31da81f92..2b399500b 100644 --- a/src/SensorBase.cpp +++ b/src/SensorBase.cpp @@ -554,7 +554,7 @@ bool Sensor::update() { // loop through until we have the requested number of successful // measurements // NOTE: The number of measurement attempts completed is bumped by - // bumpMeasurementAttemptCount() only after success or the last retry + // finalizeMeasurementAttempt() only after success or the last retry // attempt, so it's safe to check this value to determine if we have the // requested number of successful measurements. while (_completedMeasurements < _measurementsToAverage) { @@ -565,13 +565,13 @@ bool Sensor::update() { // count to trigger retry logic, but skip waiting for measurement // completion and adding a result since we didn't actually start a // measurement - bumpMeasurementAttemptCount(false); + finalizeMeasurementAttempt(false); } else { // wait for the measurement to finish waitForMeasurementCompletion(); // get the measurement result - this should call - // bumpMeasurementAttemptCount() to update the measurement attempt + // finalizeMeasurementAttempt() to update the measurement attempt // and retry counts as needed so we don't call that function // directly here ret_val &= addSingleMeasurementResult(); @@ -774,7 +774,7 @@ void Sensor::waitForMeasurementCompletion() { } -bool Sensor::bumpMeasurementAttemptCount(bool wasSuccessful) { +bool Sensor::finalizeMeasurementAttempt(bool wasSuccessful) { // Record the time that the measurement was completed _millisMeasurementCompleted = millis(); // Unset the time stamp for the beginning of this measurement @@ -784,9 +784,9 @@ bool Sensor::bumpMeasurementAttemptCount(bool wasSuccessful) { // Bump the number of attempted retries _currentRetries++; - if (wasSuccessful || _currentRetries > _maxRetries) { + if (wasSuccessful || _currentRetries >= _maxRetries) { // Bump the number of completed measurement attempts - we've succeeded - // or failed but exceeded retries + // or failed but reached the retry limit _completedMeasurements++; // Reset the number of retries made for the next measurement attempt _currentRetries = 0; diff --git a/src/SensorBase.h b/src/SensorBase.h index 21f3f6be3..afd6bd1b6 100644 --- a/src/SensorBase.h +++ b/src/SensorBase.h @@ -848,12 +848,22 @@ class Sensor { Variable* variables[MAX_NUMBER_VARS]; /** - * @brief A helper function to correctly bump the measurement counts and - * retries and set the appropriate timestamp and status bits. - * @param wasSuccessful True if the measurement attempt was successful. - * @return Returns the input parameter wasSuccessful. - */ - bool bumpMeasurementAttemptCount(bool wasSuccessful); + * @brief Finalizes a measurement attempt by updating timestamps, status + * bits, and retry counts. + * + * This method performs multiple cleanup actions after a measurement + * attempt: + * - Records measurement completion timestamp + * - Clears measurement request status bits + * - Updates retry counters with proper semantics + * - Conditionally increments completed measurements based on success or + * retry limit + * + * @param wasSuccessful True if the measurement was successful, false + * otherwise + * @return The input parameter for easy chaining in return statements + */ + bool finalizeMeasurementAttempt(bool wasSuccessful); }; #endif // SRC_SENSORBASE_H_ diff --git a/src/sensors/ANBpH.cpp b/src/sensors/ANBpH.cpp index 51c5cc9d0..0c9ce7d76 100644 --- a/src/sensors/ANBpH.cpp +++ b/src/sensors/ANBpH.cpp @@ -335,7 +335,7 @@ bool ANBpH::sleep() { bool ANBpH::addSingleMeasurementResult() { // Immediately quit if the measurement was not successfully started if (!getStatusBit(MEASUREMENT_SUCCESSFUL)) { - return bumpMeasurementAttemptCount(false); + return finalizeMeasurementAttempt(false); } bool success = false; @@ -411,7 +411,7 @@ bool ANBpH::addSingleMeasurementResult() { } // Return success value when finished - return bumpMeasurementAttemptCount(success); + return finalizeMeasurementAttempt(success); } // check if the sensor is ready diff --git a/src/sensors/AOSongAM2315.cpp b/src/sensors/AOSongAM2315.cpp index c1d378399..132e9f25f 100644 --- a/src/sensors/AOSongAM2315.cpp +++ b/src/sensors/AOSongAM2315.cpp @@ -53,7 +53,7 @@ bool AOSongAM2315::setup() { bool AOSongAM2315::addSingleMeasurementResult() { // Immediately quit if the measurement was not successfully started if (!getStatusBit(MEASUREMENT_SUCCESSFUL)) { - return bumpMeasurementAttemptCount(false); + return finalizeMeasurementAttempt(false); } bool success = false; @@ -77,5 +77,5 @@ bool AOSongAM2315::addSingleMeasurementResult() { } // Return success value when finished - return bumpMeasurementAttemptCount(success); + return finalizeMeasurementAttempt(success); } diff --git a/src/sensors/AOSongDHT.cpp b/src/sensors/AOSongDHT.cpp index 4422b1fd9..4fb395e21 100644 --- a/src/sensors/AOSongDHT.cpp +++ b/src/sensors/AOSongDHT.cpp @@ -43,7 +43,7 @@ String AOSongDHT::getSensorName() { bool AOSongDHT::addSingleMeasurementResult() { // Immediately quit if the measurement was not successfully started if (!getStatusBit(MEASUREMENT_SUCCESSFUL)) { - return bumpMeasurementAttemptCount(false); + return finalizeMeasurementAttempt(false); } bool success = false; @@ -74,5 +74,5 @@ bool AOSongDHT::addSingleMeasurementResult() { } // Return success value when finished - return bumpMeasurementAttemptCount(success); + return finalizeMeasurementAttempt(success); } diff --git a/src/sensors/AlphasenseCO2.cpp b/src/sensors/AlphasenseCO2.cpp index ca1428553..83a680c18 100644 --- a/src/sensors/AlphasenseCO2.cpp +++ b/src/sensors/AlphasenseCO2.cpp @@ -75,14 +75,14 @@ bool AlphasenseCO2::setup() { bool AlphasenseCO2::addSingleMeasurementResult() { // Immediately quit if the measurement was not successfully started if (!getStatusBit(MEASUREMENT_SUCCESSFUL)) { - return bumpMeasurementAttemptCount(false); + return finalizeMeasurementAttempt(false); } // Check if we have a valid analog voltage reader if (_analogVoltageReader == nullptr) { MS_DBG(getSensorNameAndLocation(), F("No analog voltage reader available")); - return bumpMeasurementAttemptCount(false); + return finalizeMeasurementAttempt(false); } float adcVoltage = MS_INVALID_VALUE; @@ -113,5 +113,5 @@ bool AlphasenseCO2::addSingleMeasurementResult() { } // Return success value when finished - return bumpMeasurementAttemptCount(success); + return finalizeMeasurementAttempt(success); } diff --git a/src/sensors/AnalogElecConductivity.cpp b/src/sensors/AnalogElecConductivity.cpp index 08ae85d1a..31f9b0ec1 100644 --- a/src/sensors/AnalogElecConductivity.cpp +++ b/src/sensors/AnalogElecConductivity.cpp @@ -74,21 +74,21 @@ bool AnalogElecConductivity::setup() { bool AnalogElecConductivity::addSingleMeasurementResult() { // Immediately quit if the measurement was not successfully started if (!getStatusBit(MEASUREMENT_SUCCESSFUL)) { - return bumpMeasurementAttemptCount(false); + return finalizeMeasurementAttempt(false); } // Check if we have a valid analog voltage reader if (_analogVoltageReader == nullptr) { MS_DBG(getSensorNameAndLocation(), F("No analog voltage reader available")); - return bumpMeasurementAttemptCount(false); + return finalizeMeasurementAttempt(false); } // Check if we have a resistance and cell constant if (_Rseries_ohms <= 0 || _sensorEC_Konst <= 0) { MS_DBG(getSensorNameAndLocation(), F(" has an invalid cell constant or resistor value!")); - return bumpMeasurementAttemptCount(false); + return finalizeMeasurementAttempt(false); } float adcVoltage = MS_INVALID_VALUE; @@ -106,7 +106,7 @@ bool AnalogElecConductivity::addSingleMeasurementResult() { float supplyVoltage = _analogVoltageReader->getSupplyVoltage(); if (supplyVoltage <= 0.0f) { MS_DBG(F(" Invalid supply voltage from analog reader")); - return bumpMeasurementAttemptCount(false); + return finalizeMeasurementAttempt(false); } float adcRatio = adcVoltage / supplyVoltage; @@ -118,7 +118,7 @@ bool AnalogElecConductivity::addSingleMeasurementResult() { } else if (adcRatio < 0.0f) { MS_DBG(F(" Negative ADC ratio ("), adcRatio, F("); negative supply or ADC voltage")); - return bumpMeasurementAttemptCount(false); + return finalizeMeasurementAttempt(false); } float Rwater_ohms = _Rseries_ohms * adcRatio / (1.0f - adcRatio); @@ -138,7 +138,7 @@ bool AnalogElecConductivity::addSingleMeasurementResult() { } else { MS_DBG(F(" Failed to get valid voltage from analog reader")); } - return bumpMeasurementAttemptCount(success); + return finalizeMeasurementAttempt(success); } // cSpell:ignore AnalogElecConductivity Rseries_ohms sensorEC_Konst Rwater_ohms diff --git a/src/sensors/ApogeeSQ212.cpp b/src/sensors/ApogeeSQ212.cpp index 79c4922e1..a5c79359f 100644 --- a/src/sensors/ApogeeSQ212.cpp +++ b/src/sensors/ApogeeSQ212.cpp @@ -69,14 +69,14 @@ bool ApogeeSQ212::setup() { bool ApogeeSQ212::addSingleMeasurementResult() { // Immediately quit if the measurement was not successfully started if (!getStatusBit(MEASUREMENT_SUCCESSFUL)) { - return bumpMeasurementAttemptCount(false); + return finalizeMeasurementAttempt(false); } // Check if we have a valid analog voltage reader if (_analogVoltageReader == nullptr) { MS_DBG(getSensorNameAndLocation(), F("No analog voltage reader available")); - return bumpMeasurementAttemptCount(false); + return finalizeMeasurementAttempt(false); } float adcVoltage = MS_INVALID_VALUE; @@ -107,5 +107,5 @@ bool ApogeeSQ212::addSingleMeasurementResult() { } // Return success value when finished - return bumpMeasurementAttemptCount(success); + return finalizeMeasurementAttempt(success); } diff --git a/src/sensors/AtlasParent.cpp b/src/sensors/AtlasParent.cpp index 52a767018..4adec383d 100644 --- a/src/sensors/AtlasParent.cpp +++ b/src/sensors/AtlasParent.cpp @@ -137,7 +137,7 @@ bool AtlasParent::startSingleMeasurement() { bool AtlasParent::addSingleMeasurementResult() { // Immediately quit if the measurement was not successfully started if (!getStatusBit(MEASUREMENT_SUCCESSFUL)) { - return bumpMeasurementAttemptCount(false); + return finalizeMeasurementAttempt(false); } bool success = false; @@ -190,7 +190,7 @@ bool AtlasParent::addSingleMeasurementResult() { } // Return success value when finished - return bumpMeasurementAttemptCount(success); + return finalizeMeasurementAttempt(success); } diff --git a/src/sensors/BoschBME280.cpp b/src/sensors/BoschBME280.cpp index aa4d0b3d3..67ebae87c 100644 --- a/src/sensors/BoschBME280.cpp +++ b/src/sensors/BoschBME280.cpp @@ -113,7 +113,7 @@ bool BoschBME280::wake() { bool BoschBME280::addSingleMeasurementResult() { // Immediately quit if the measurement was not successfully started if (!getStatusBit(MEASUREMENT_SUCCESSFUL)) { - return bumpMeasurementAttemptCount(false); + return finalizeMeasurementAttempt(false); } bool success = false; @@ -156,5 +156,5 @@ bool BoschBME280::addSingleMeasurementResult() { } // Return success value when finished - return bumpMeasurementAttemptCount(success); + return finalizeMeasurementAttempt(success); } diff --git a/src/sensors/BoschBMP3xx.cpp b/src/sensors/BoschBMP3xx.cpp index d680087b5..8bdcd9c0e 100644 --- a/src/sensors/BoschBMP3xx.cpp +++ b/src/sensors/BoschBMP3xx.cpp @@ -287,7 +287,7 @@ bool BoschBMP3xx::startSingleMeasurement() { bool BoschBMP3xx::addSingleMeasurementResult() { // Immediately quit if the measurement was not successfully started if (!getStatusBit(MEASUREMENT_SUCCESSFUL)) { - return bumpMeasurementAttemptCount(false); + return finalizeMeasurementAttempt(false); } bool success = false; @@ -312,7 +312,7 @@ bool BoschBMP3xx::addSingleMeasurementResult() { } // Return success value when finished - return bumpMeasurementAttemptCount(success); + return finalizeMeasurementAttempt(success); } // cSpell:words oversample diff --git a/src/sensors/CampbellOBS3.cpp b/src/sensors/CampbellOBS3.cpp index 5829ae3dd..d0f160187 100644 --- a/src/sensors/CampbellOBS3.cpp +++ b/src/sensors/CampbellOBS3.cpp @@ -70,14 +70,14 @@ bool CampbellOBS3::setup() { bool CampbellOBS3::addSingleMeasurementResult() { // Immediately quit if the measurement was not successfully started if (!getStatusBit(MEASUREMENT_SUCCESSFUL)) { - return bumpMeasurementAttemptCount(false); + return finalizeMeasurementAttempt(false); } // Check if we have a valid analog voltage reader if (_analogVoltageReader == nullptr) { MS_DBG(getSensorNameAndLocation(), F("No analog voltage reader available")); - return bumpMeasurementAttemptCount(false); + return finalizeMeasurementAttempt(false); } // Print out the calibration curve @@ -107,5 +107,5 @@ bool CampbellOBS3::addSingleMeasurementResult() { } // Return success value when finished - return bumpMeasurementAttemptCount(success); + return finalizeMeasurementAttempt(success); } diff --git a/src/sensors/EverlightALSPT19.cpp b/src/sensors/EverlightALSPT19.cpp index 5be87eaf3..628028ec6 100644 --- a/src/sensors/EverlightALSPT19.cpp +++ b/src/sensors/EverlightALSPT19.cpp @@ -81,19 +81,19 @@ bool EverlightALSPT19::setup() { bool EverlightALSPT19::addSingleMeasurementResult() { // Immediately quit if the measurement was not successfully started if (!getStatusBit(MEASUREMENT_SUCCESSFUL)) { - return bumpMeasurementAttemptCount(false); + return finalizeMeasurementAttempt(false); } // Check if we have a valid analog voltage reader if (_analogVoltageReader == nullptr) { MS_DBG(getSensorNameAndLocation(), F("No analog voltage reader available")); - return bumpMeasurementAttemptCount(false); + return finalizeMeasurementAttempt(false); } // Check if we have a valid load resistor if (_loadResistor <= 0) { MS_DBG(getSensorNameAndLocation(), F("Invalid load resistor value")); - return bumpMeasurementAttemptCount(false); + return finalizeMeasurementAttempt(false); } float adcVoltage = MS_INVALID_VALUE; @@ -137,5 +137,5 @@ bool EverlightALSPT19::addSingleMeasurementResult() { } else { MS_DBG(F(" Failed to get valid voltage from analog reader")); } - return bumpMeasurementAttemptCount(success); + return finalizeMeasurementAttempt(success); } diff --git a/src/sensors/FreescaleMPL115A2.cpp b/src/sensors/FreescaleMPL115A2.cpp index d340120af..1bb97693c 100644 --- a/src/sensors/FreescaleMPL115A2.cpp +++ b/src/sensors/FreescaleMPL115A2.cpp @@ -58,7 +58,7 @@ bool FreescaleMPL115A2::setup() { bool FreescaleMPL115A2::addSingleMeasurementResult() { // Immediately quit if the measurement was not successfully started if (!getStatusBit(MEASUREMENT_SUCCESSFUL)) { - return bumpMeasurementAttemptCount(false); + return finalizeMeasurementAttempt(false); } bool success = false; @@ -83,5 +83,5 @@ bool FreescaleMPL115A2::addSingleMeasurementResult() { } // Return success value when finished - return bumpMeasurementAttemptCount(success); + return finalizeMeasurementAttempt(success); } diff --git a/src/sensors/GeoluxHydroCam.cpp b/src/sensors/GeoluxHydroCam.cpp index 46d505476..9b12cc3b5 100644 --- a/src/sensors/GeoluxHydroCam.cpp +++ b/src/sensors/GeoluxHydroCam.cpp @@ -187,7 +187,7 @@ bool GeoluxHydroCam::startSingleMeasurement() { bool GeoluxHydroCam::addSingleMeasurementResult() { // Immediately quit if the measurement was not successfully started if (!getStatusBit(MEASUREMENT_SUCCESSFUL)) { - return bumpMeasurementAttemptCount(false); + return finalizeMeasurementAttempt(false); } bool success = false; @@ -199,7 +199,7 @@ bool GeoluxHydroCam::addSingleMeasurementResult() { if (image_size <= 0) { MS_DBG(F("Camera returned an image size <= 0, which means the snapshot " "failed!")); - return bumpMeasurementAttemptCount(false); + return finalizeMeasurementAttempt(false); } // set a new filename based on the current RTC time @@ -211,7 +211,7 @@ bool GeoluxHydroCam::addSingleMeasurementResult() { // skip everything else if there's no SD card, otherwise it might hang if (!_baseLogger->initializeSDCard()) { MS_DBG(F("Failed initialize SD card, aborting!")); - return bumpMeasurementAttemptCount(false); + return finalizeMeasurementAttempt(false); } // Open the file in write mode - creating a new file if it doesn't exist or @@ -220,7 +220,7 @@ bool GeoluxHydroCam::addSingleMeasurementResult() { MS_DBG(F("Created new file:"), filename); } else { MS_DBG(F("Failed to create the image file, aborting!")); - return bumpMeasurementAttemptCount(false); + return finalizeMeasurementAttempt(false); } // dump anything in the camera stream, just in case @@ -258,7 +258,7 @@ bool GeoluxHydroCam::addSingleMeasurementResult() { verifyAndAddMeasurementResult(HYDROCAM_ERROR_VAR_NUM, byte_error); // Return success value when finished - return bumpMeasurementAttemptCount(success); + return finalizeMeasurementAttempt(success); } // check if the camera is ready diff --git a/src/sensors/GroPointParent.cpp b/src/sensors/GroPointParent.cpp index 7aabf8e39..92358b08d 100644 --- a/src/sensors/GroPointParent.cpp +++ b/src/sensors/GroPointParent.cpp @@ -161,7 +161,7 @@ bool GroPointParent::sleep() { bool GroPointParent::addSingleMeasurementResult() { // Immediately quit if the measurement was not successfully started if (!getStatusBit(MEASUREMENT_SUCCESSFUL)) { - return bumpMeasurementAttemptCount(false); + return finalizeMeasurementAttempt(false); } bool success = false; @@ -235,7 +235,7 @@ bool GroPointParent::addSingleMeasurementResult() { // Return success value when finished. Success requires both the moisture // and temperature values to be successfully retrieved - return bumpMeasurementAttemptCount((success && successT)); + return finalizeMeasurementAttempt((success && successT)); } // cSpell:ignore gsensor diff --git a/src/sensors/KellerParent.cpp b/src/sensors/KellerParent.cpp index 2e4567a78..c163d0974 100644 --- a/src/sensors/KellerParent.cpp +++ b/src/sensors/KellerParent.cpp @@ -84,7 +84,7 @@ bool KellerParent::sleep() { bool KellerParent::addSingleMeasurementResult() { // Immediately quit if the measurement was not successfully started if (!getStatusBit(MEASUREMENT_SUCCESSFUL)) { - return bumpMeasurementAttemptCount(false); + return finalizeMeasurementAttempt(false); } bool success = false; @@ -130,7 +130,7 @@ bool KellerParent::addSingleMeasurementResult() { } // Return success value when finished - return bumpMeasurementAttemptCount(success); + return finalizeMeasurementAttempt(success); } // cSpell:ignore ksensor diff --git a/src/sensors/MaxBotixSonar.cpp b/src/sensors/MaxBotixSonar.cpp index f6f3510ca..b66615693 100644 --- a/src/sensors/MaxBotixSonar.cpp +++ b/src/sensors/MaxBotixSonar.cpp @@ -119,7 +119,7 @@ bool MaxBotixSonar::sleep() { bool MaxBotixSonar::addSingleMeasurementResult() { // Immediately quit if the measurement was not successfully started if (!getStatusBit(MEASUREMENT_SUCCESSFUL)) { - return bumpMeasurementAttemptCount(false); + return finalizeMeasurementAttempt(false); } // Initialize values @@ -187,5 +187,5 @@ bool MaxBotixSonar::addSingleMeasurementResult() { if (success) { verifyAndAddMeasurementResult(HRXL_VAR_NUM, result); } // Return success value when finished - return bumpMeasurementAttemptCount(success); + return finalizeMeasurementAttempt(success); } diff --git a/src/sensors/MaximDS18.cpp b/src/sensors/MaximDS18.cpp index 7f91b1736..ff9a86363 100644 --- a/src/sensors/MaximDS18.cpp +++ b/src/sensors/MaximDS18.cpp @@ -184,7 +184,7 @@ bool MaximDS18::startSingleMeasurement() { bool MaximDS18::addSingleMeasurementResult() { // Immediately quit if the measurement was not successfully started if (!getStatusBit(MEASUREMENT_SUCCESSFUL)) { - return bumpMeasurementAttemptCount(false); + return finalizeMeasurementAttempt(false); } bool success = false; @@ -206,5 +206,5 @@ bool MaximDS18::addSingleMeasurementResult() { } // Return success value when finished - return bumpMeasurementAttemptCount(success); + return finalizeMeasurementAttempt(success); } diff --git a/src/sensors/MaximDS3231.cpp b/src/sensors/MaximDS3231.cpp index 0aad4f4a1..134ec125e 100644 --- a/src/sensors/MaximDS3231.cpp +++ b/src/sensors/MaximDS3231.cpp @@ -67,5 +67,5 @@ bool MaximDS3231::addSingleMeasurementResult() { bool success = !isnan(tempVal); // Return success value when finished - return bumpMeasurementAttemptCount(success); + return finalizeMeasurementAttempt(success); } diff --git a/src/sensors/MeaSpecMS5803.cpp b/src/sensors/MeaSpecMS5803.cpp index e19638704..be10156f9 100644 --- a/src/sensors/MeaSpecMS5803.cpp +++ b/src/sensors/MeaSpecMS5803.cpp @@ -57,7 +57,7 @@ bool MeaSpecMS5803::setup() { bool MeaSpecMS5803::addSingleMeasurementResult() { // Immediately quit if the measurement was not successfully started if (!getStatusBit(MEASUREMENT_SUCCESSFUL)) { - return bumpMeasurementAttemptCount(false); + return finalizeMeasurementAttempt(false); } bool success = false; @@ -88,5 +88,5 @@ bool MeaSpecMS5803::addSingleMeasurementResult() { } // Return success value when finished - return bumpMeasurementAttemptCount(success); + return finalizeMeasurementAttempt(success); } diff --git a/src/sensors/PaleoTerraRedox.cpp b/src/sensors/PaleoTerraRedox.cpp index aa08aae00..06f50bf83 100644 --- a/src/sensors/PaleoTerraRedox.cpp +++ b/src/sensors/PaleoTerraRedox.cpp @@ -104,7 +104,7 @@ bool PaleoTerraRedox::setup() { bool PaleoTerraRedox::addSingleMeasurementResult() { // Immediately quit if the measurement was not successfully started if (!getStatusBit(MEASUREMENT_SUCCESSFUL)) { - return bumpMeasurementAttemptCount(false); + return finalizeMeasurementAttempt(false); } bool success = false; @@ -127,14 +127,14 @@ bool PaleoTerraRedox::addSingleMeasurementResult() { 0b10001100); // initiate conversion, One-Shot mode, 18 bits, PGA x1 i2c_status = _i2c->endTransmission(); // fail if transmission error - if (i2c_status != 0) { return bumpMeasurementAttemptCount(false); } + if (i2c_status != 0) { return finalizeMeasurementAttempt(false); } // wait for the conversion to complete delay(PTR_CONVERSION_WAIT_TIME_MS); // Get 4 bytes from device if (_i2c->requestFrom(int(_i2cAddressHex), 4) != 4) { - return bumpMeasurementAttemptCount(false); + return finalizeMeasurementAttempt(false); } // per the datasheet, in 18 bit mode: // byte 1: [MMMMMM D17 D16 (1st data byte] @@ -177,5 +177,5 @@ bool PaleoTerraRedox::addSingleMeasurementResult() { } // Return success value when finished - return bumpMeasurementAttemptCount(success); + return finalizeMeasurementAttempt(success); } diff --git a/src/sensors/ProcessorAnalog.cpp b/src/sensors/ProcessorAnalog.cpp index da98cf8db..460115757 100644 --- a/src/sensors/ProcessorAnalog.cpp +++ b/src/sensors/ProcessorAnalog.cpp @@ -158,14 +158,14 @@ String ProcessorAnalog::getSensorLocation() { bool ProcessorAnalog::addSingleMeasurementResult() { // Immediately quit if the measurement was not successfully started if (!getStatusBit(MEASUREMENT_SUCCESSFUL)) { - return bumpMeasurementAttemptCount(false); + return finalizeMeasurementAttempt(false); } // Check if we have a valid analog voltage reader if (_analogVoltageReader == nullptr) { MS_DBG(getSensorNameAndLocation(), F("No analog voltage reader available")); - return bumpMeasurementAttemptCount(false); + return finalizeMeasurementAttempt(false); } MS_DBG(getSensorNameAndLocation(), F("is reporting:")); @@ -181,5 +181,5 @@ bool ProcessorAnalog::addSingleMeasurementResult() { } // Return success value when finished - return bumpMeasurementAttemptCount(success); + return finalizeMeasurementAttempt(success); } diff --git a/src/sensors/ProcessorStats.cpp b/src/sensors/ProcessorStats.cpp index ebcdf9ffd..b6a49827b 100644 --- a/src/sensors/ProcessorStats.cpp +++ b/src/sensors/ProcessorStats.cpp @@ -272,7 +272,7 @@ bool ProcessorStats::addSingleMeasurementResult() { } // Return true value when finished - return bumpMeasurementAttemptCount(true); + return finalizeMeasurementAttempt(true); } // cSpell:ignore ADALOGGER RSTC RCAUSE BKUPEXIT BODCORE BODVDD BBPS brkval MCUSR diff --git a/src/sensors/RainCounterI2C.cpp b/src/sensors/RainCounterI2C.cpp index 7db5bc624..134e139b8 100644 --- a/src/sensors/RainCounterI2C.cpp +++ b/src/sensors/RainCounterI2C.cpp @@ -98,7 +98,7 @@ bool RainCounterI2C::setup() { bool RainCounterI2C::addSingleMeasurementResult() { // Immediately quit if the measurement was not successfully started if (!getStatusBit(MEASUREMENT_SUCCESSFUL)) { - return bumpMeasurementAttemptCount(false); + return finalizeMeasurementAttempt(false); } bool success = false; // assume the worst @@ -123,7 +123,7 @@ bool RainCounterI2C::addSingleMeasurementResult() { } if (byte_in < 1) { MS_DBG(F(" No data bytes received")); - return bumpMeasurementAttemptCount(false); + return finalizeMeasurementAttempt(false); } // Concatenate bytes into uint32_t by bit-shifting @@ -173,5 +173,5 @@ bool RainCounterI2C::addSingleMeasurementResult() { } // Return success value when finished - return bumpMeasurementAttemptCount(success); + return finalizeMeasurementAttempt(success); } diff --git a/src/sensors/SDI12Sensors.cpp b/src/sensors/SDI12Sensors.cpp index 3d51d9146..cda560b64 100644 --- a/src/sensors/SDI12Sensors.cpp +++ b/src/sensors/SDI12Sensors.cpp @@ -713,13 +713,13 @@ bool SDI12Sensors::getResults(bool verify_crc) { bool SDI12Sensors::addSingleMeasurementResult() { // Immediately quit if the measurement was not successfully started if (!getStatusBit(MEASUREMENT_SUCCESSFUL)) { - return bumpMeasurementAttemptCount(false); + return finalizeMeasurementAttempt(false); } bool success = getResults(MS_SDI12_USE_CRC); // Return success value when finished - return bumpMeasurementAttemptCount(success); + return finalizeMeasurementAttempt(success); } #else // concurrent measurement disabled // This is for non-concurrent measurements, so this function must both start the @@ -730,7 +730,7 @@ bool SDI12Sensors::addSingleMeasurementResult() { bool SDI12Sensors::addSingleMeasurementResult() { // Immediately quit if the measurement was not successfully started if (!getStatusBit(MEASUREMENT_SUCCESSFUL)) { - return bumpMeasurementAttemptCount(false); + return finalizeMeasurementAttempt(false); } bool success = false; @@ -801,6 +801,6 @@ bool SDI12Sensors::addSingleMeasurementResult() { deactivate(); // Return success value when finished - return bumpMeasurementAttemptCount(success); + return finalizeMeasurementAttempt(success); } #endif // #ifndef MS_SDI12_NON_CONCURRENT diff --git a/src/sensors/SensirionSHT4x.cpp b/src/sensors/SensirionSHT4x.cpp index 9d87ddcbd..149058c72 100644 --- a/src/sensors/SensirionSHT4x.cpp +++ b/src/sensors/SensirionSHT4x.cpp @@ -88,7 +88,7 @@ bool SensirionSHT4x::setup() { bool SensirionSHT4x::addSingleMeasurementResult() { // Immediately quit if the measurement was not successfully started if (!getStatusBit(MEASUREMENT_SUCCESSFUL)) { - return bumpMeasurementAttemptCount(false); + return finalizeMeasurementAttempt(false); } bool success = false; @@ -125,7 +125,7 @@ bool SensirionSHT4x::addSingleMeasurementResult() { MS_DBG(F(" Humidity:"), humid_val, '%'); // Return success value when finished - return bumpMeasurementAttemptCount(success); + return finalizeMeasurementAttempt(success); } diff --git a/src/sensors/TEConnectivityMS5837.cpp b/src/sensors/TEConnectivityMS5837.cpp index 921b8a831..8ff6e77b3 100644 --- a/src/sensors/TEConnectivityMS5837.cpp +++ b/src/sensors/TEConnectivityMS5837.cpp @@ -149,19 +149,19 @@ bool TEConnectivityMS5837::wake() { bool TEConnectivityMS5837::addSingleMeasurementResult() { // Immediately quit if the measurement was not successfully started if (!getStatusBit(MEASUREMENT_SUCCESSFUL)) { - return bumpMeasurementAttemptCount(false); + return finalizeMeasurementAttempt(false); } // Validate configuration parameters if (_fluidDensity <= 0.1 || _fluidDensity > 5.0) { MS_DBG(F("Invalid fluid density:"), _fluidDensity, F("g/cm³. Expected range: (0.1-5.0]")); - return bumpMeasurementAttemptCount(false); + return finalizeMeasurementAttempt(false); } if (_airPressure < 500.0 || _airPressure > 1200.0) { MS_DBG(F("Invalid air pressure:"), _airPressure, F("mBar. Expected range: 500-1200")); - return bumpMeasurementAttemptCount(false); + return finalizeMeasurementAttempt(false); } // Read values from the sensor - returns 0 on success @@ -177,7 +177,7 @@ bool TEConnectivityMS5837::addSingleMeasurementResult() { default: MS_DBG(F("Invalid oversampling ratio:"), _overSamplingRatio, F(". Valid values: 256, 512, 1024, 2048, 4096, 8192")); - return bumpMeasurementAttemptCount(false); + return finalizeMeasurementAttempt(false); } MS_DBG(F(" Requesting"), OSR, F("bit OSR (oversampling ratio:"), _overSamplingRatio, F(")")); @@ -199,7 +199,7 @@ bool TEConnectivityMS5837::addSingleMeasurementResult() { } else { MS_DBG(F(" Read failed, error:"), MS5837_internal.getLastError(), F("Return value from read():"), read_return); - return bumpMeasurementAttemptCount(false); + return finalizeMeasurementAttempt(false); } // Validate the readings @@ -271,7 +271,7 @@ bool TEConnectivityMS5837::addSingleMeasurementResult() { } // Return success value when finished - return bumpMeasurementAttemptCount(success); + return finalizeMeasurementAttempt(success); } diff --git a/src/sensors/TIADS1x15.cpp b/src/sensors/TIADS1x15.cpp index c9c8aa8c7..b7c9c8835 100644 --- a/src/sensors/TIADS1x15.cpp +++ b/src/sensors/TIADS1x15.cpp @@ -411,14 +411,14 @@ bool TIADS1x15::setup() { bool TIADS1x15::addSingleMeasurementResult() { // Immediately quit if the measurement was not successfully started if (!getStatusBit(MEASUREMENT_SUCCESSFUL)) { - return bumpMeasurementAttemptCount(false); + return finalizeMeasurementAttempt(false); } // Check if we have a valid analog voltage reader if (_analogVoltageReader == nullptr) { MS_DBG(getSensorNameAndLocation(), F("No analog voltage reader available")); - return bumpMeasurementAttemptCount(false); + return finalizeMeasurementAttempt(false); } float resultValue = MS_INVALID_VALUE; @@ -450,7 +450,7 @@ bool TIADS1x15::addSingleMeasurementResult() { } // Return success value when finished - return bumpMeasurementAttemptCount(success); + return finalizeMeasurementAttempt(success); } // cspell:words GAIN_TWOTHIRDS diff --git a/src/sensors/TIINA219.cpp b/src/sensors/TIINA219.cpp index fc078c059..ca48795e5 100644 --- a/src/sensors/TIINA219.cpp +++ b/src/sensors/TIINA219.cpp @@ -91,7 +91,7 @@ bool TIINA219::wake() { bool TIINA219::addSingleMeasurementResult() { // Immediately quit if the measurement was not successfully started if (!getStatusBit(MEASUREMENT_SUCCESSFUL)) { - return bumpMeasurementAttemptCount(false); + return finalizeMeasurementAttempt(false); } bool success = false; @@ -125,7 +125,7 @@ bool TIINA219::addSingleMeasurementResult() { // Return success value when finished - return bumpMeasurementAttemptCount(success); + return finalizeMeasurementAttempt(success); } // cSpell:ignore TIINA219 diff --git a/src/sensors/TallyCounterI2C.cpp b/src/sensors/TallyCounterI2C.cpp index 721bd32d5..a6da4ade9 100644 --- a/src/sensors/TallyCounterI2C.cpp +++ b/src/sensors/TallyCounterI2C.cpp @@ -70,7 +70,7 @@ bool TallyCounterI2C::setup() { bool TallyCounterI2C::addSingleMeasurementResult() { // Immediately quit if the measurement was not successfully started if (!getStatusBit(MEASUREMENT_SUCCESSFUL)) { - return bumpMeasurementAttemptCount(false); + return finalizeMeasurementAttempt(false); } bool success = false; @@ -99,5 +99,5 @@ bool TallyCounterI2C::addSingleMeasurementResult() { MS_DBG(F(" Events:"), events); // Return success value when finished - return bumpMeasurementAttemptCount(success); + return finalizeMeasurementAttempt(success); } diff --git a/src/sensors/TurnerCyclops.cpp b/src/sensors/TurnerCyclops.cpp index 6ef12dd48..be3f7c728 100644 --- a/src/sensors/TurnerCyclops.cpp +++ b/src/sensors/TurnerCyclops.cpp @@ -71,14 +71,14 @@ bool TurnerCyclops::setup() { bool TurnerCyclops::addSingleMeasurementResult() { // Immediately quit if the measurement was not successfully started if (!getStatusBit(MEASUREMENT_SUCCESSFUL)) { - return bumpMeasurementAttemptCount(false); + return finalizeMeasurementAttempt(false); } // Check if we have a valid analog voltage reader if (_analogVoltageReader == nullptr) { MS_DBG(getSensorNameAndLocation(), F("No analog voltage reader available")); - return bumpMeasurementAttemptCount(false); + return finalizeMeasurementAttempt(false); } // Print out the calibration curve @@ -86,7 +86,7 @@ bool TurnerCyclops::addSingleMeasurementResult() { F(". "), _volt_blank, F("V blank.")); if (fabsf(_volt_std - _volt_blank) < CYCLOPS_CALIBRATION_EPSILON) { MS_DBG(F("Invalid calibration: point voltage equals blank voltage")); - return bumpMeasurementAttemptCount(false); + return finalizeMeasurementAttempt(false); } float adcVoltage = MS_INVALID_VALUE; @@ -113,5 +113,5 @@ bool TurnerCyclops::addSingleMeasurementResult() { } // Return success value when finished - return bumpMeasurementAttemptCount(success); + return finalizeMeasurementAttempt(success); } diff --git a/src/sensors/TurnerTurbidityPlus.cpp b/src/sensors/TurnerTurbidityPlus.cpp index 017c0effa..29958e064 100644 --- a/src/sensors/TurnerTurbidityPlus.cpp +++ b/src/sensors/TurnerTurbidityPlus.cpp @@ -112,14 +112,14 @@ void TurnerTurbidityPlus::powerUp() { bool TurnerTurbidityPlus::addSingleMeasurementResult() { // Immediately quit if the measurement was not successfully started if (!getStatusBit(MEASUREMENT_SUCCESSFUL)) { - return bumpMeasurementAttemptCount(false); + return finalizeMeasurementAttempt(false); } // Check if we have a valid analog voltage reader if (_analogVoltageReader == nullptr) { MS_DBG(getSensorNameAndLocation(), F("No analog voltage reader available")); - return bumpMeasurementAttemptCount(false); + return finalizeMeasurementAttempt(false); } // Print out the calibration curve @@ -127,7 +127,7 @@ bool TurnerTurbidityPlus::addSingleMeasurementResult() { F(". "), _volt_blank, F("V blank.")); if (fabsf(_volt_std - _volt_blank) < TURBIDITY_PLUS_CALIBRATION_EPSILON) { MS_DBG(F("Invalid calibration: point voltage equals blank voltage")); - return bumpMeasurementAttemptCount(false); + return finalizeMeasurementAttempt(false); } float adcVoltage = MS_INVALID_VALUE; @@ -154,5 +154,5 @@ bool TurnerTurbidityPlus::addSingleMeasurementResult() { } // Return success value when finished - return bumpMeasurementAttemptCount(success); + return finalizeMeasurementAttempt(success); } diff --git a/src/sensors/YosemitechParent.cpp b/src/sensors/YosemitechParent.cpp index f61e073a8..0524c1a00 100644 --- a/src/sensors/YosemitechParent.cpp +++ b/src/sensors/YosemitechParent.cpp @@ -169,7 +169,7 @@ bool YosemitechParent::sleep() { bool YosemitechParent::addSingleMeasurementResult() { // Immediately quit if the measurement was not successfully started if (!getStatusBit(MEASUREMENT_SUCCESSFUL)) { - return bumpMeasurementAttemptCount(false); + return finalizeMeasurementAttempt(false); } bool success = false; @@ -250,7 +250,7 @@ bool YosemitechParent::addSingleMeasurementResult() { } // Return success value when finished - return bumpMeasurementAttemptCount(success); + return finalizeMeasurementAttempt(success); } // cSpell:ignore ysensor From ce9336fdfd877099fbbfb05e150bdc8fbe5e33f8 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Fri, 6 Mar 2026 13:14:13 -0500 Subject: [PATCH 474/533] Add define for HTTP_VERSION_PREFIX_LEN Signed-off-by: Sara Damiano --- src/dataPublisherBase.h | 6 ++++++ src/publishers/DreamHostPublisher.cpp | 2 +- src/publishers/MonitorMyWatershedPublisher.cpp | 5 +++-- src/publishers/S3PresignedPublisher.cpp | 2 +- src/publishers/ThingSpeakPublisher.cpp | 2 +- src/publishers/UbidotsPublisher.cpp | 2 +- 6 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/dataPublisherBase.h b/src/dataPublisherBase.h index 2aa2c246a..001948457 100644 --- a/src/dataPublisherBase.h +++ b/src/dataPublisherBase.h @@ -45,6 +45,12 @@ #include "LoggerBase.h" #include "Client.h" +// HTTP response parsing constants +/** + * @brief Length of the HTTP version prefix "HTTP/1.1 " used when parsing HTTP response codes + */ +#define HTTP_VERSION_PREFIX_LEN 9 + /** * @brief The dataPublisher class is a virtual class used by other publishers to * distribute data online. diff --git a/src/publishers/DreamHostPublisher.cpp b/src/publishers/DreamHostPublisher.cpp index 64851cb6c..1c930dadc 100644 --- a/src/publishers/DreamHostPublisher.cpp +++ b/src/publishers/DreamHostPublisher.cpp @@ -129,7 +129,7 @@ int16_t DreamHostPublisher::publishData(Client* outClient, bool) { // The first 9 characters should be "HTTP/1.1 " if (did_respond > 0) { char responseCode_char[4]; - memcpy(responseCode_char, tempBuffer + 9, 3); + memcpy(responseCode_char, tempBuffer + HTTP_VERSION_PREFIX_LEN, 3); // Null terminate the string memset(responseCode_char + 3, '\0', 1); responseCode = atoi(responseCode_char); diff --git a/src/publishers/MonitorMyWatershedPublisher.cpp b/src/publishers/MonitorMyWatershedPublisher.cpp index 9ba7f0978..4e05bddf0 100644 --- a/src/publishers/MonitorMyWatershedPublisher.cpp +++ b/src/publishers/MonitorMyWatershedPublisher.cpp @@ -258,7 +258,8 @@ int16_t MonitorMyWatershedPublisher::publishData(Client* outClient, PRINTOUT( F("Setting number of variables in log buffer to match number of " "variables in logger.")); - PRINTOUT(F("THIS WILL ERASE THE BUFFER AND DELETE ANY UNSENT DATA!")); + PRINTOUT(F("THIS WILL ERASE THE BUFFER AND DELETE"), + _logBuffer.getNumRecords(), F("UNSENT RECORDS!")); _logBuffer.setNumVariables(_baseLogger->getArrayVarCount()); } @@ -412,7 +413,7 @@ int16_t MonitorMyWatershedPublisher::flushDataBuffer(Client* outClient) { // The first 9 characters should be "HTTP/1.1 " if (did_respond > 0) { char responseCode_char[4]; - memcpy(responseCode_char, tempBuffer + 9, 3); + memcpy(responseCode_char, tempBuffer + HTTP_VERSION_PREFIX_LEN, 3); // Null terminate the string responseCode_char[3] = '\0'; responseCode = atoi(responseCode_char); diff --git a/src/publishers/S3PresignedPublisher.cpp b/src/publishers/S3PresignedPublisher.cpp index b475022a8..c0603efba 100644 --- a/src/publishers/S3PresignedPublisher.cpp +++ b/src/publishers/S3PresignedPublisher.cpp @@ -375,7 +375,7 @@ int16_t S3PresignedPublisher::publishData(Client* outClient, bool) { // The first 9 characters should be "HTTP/1.1 " if (did_respond > 0) { char responseCode_char[4]; - memcpy(responseCode_char, tempBuffer + 9, 3); + memcpy(responseCode_char, tempBuffer + HTTP_VERSION_PREFIX_LEN, 3); // Null terminate the string memset(responseCode_char + 3, '\0', 1); responseCode = atoi(responseCode_char); diff --git a/src/publishers/ThingSpeakPublisher.cpp b/src/publishers/ThingSpeakPublisher.cpp index 83da80889..d8301f004 100644 --- a/src/publishers/ThingSpeakPublisher.cpp +++ b/src/publishers/ThingSpeakPublisher.cpp @@ -289,7 +289,7 @@ int16_t ThingSpeakPublisher::publishMetadata(Client* outClient) { // The first 9 characters should be "HTTP/1.1 " if (did_respond > 0) { char responseCode_char[4]; - memcpy(responseCode_char, tempBuffer + 9, 3); + memcpy(responseCode_char, tempBuffer + HTTP_VERSION_PREFIX_LEN, 3); // Null terminate the string memset(responseCode_char + 3, '\0', 1); responseCode = atoi(responseCode_char); diff --git a/src/publishers/UbidotsPublisher.cpp b/src/publishers/UbidotsPublisher.cpp index 227ba6a4f..a70f76ca4 100644 --- a/src/publishers/UbidotsPublisher.cpp +++ b/src/publishers/UbidotsPublisher.cpp @@ -197,7 +197,7 @@ int16_t UbidotsPublisher::publishData(Client* outClient, bool) { // The first 9 characters should be "HTTP/1.1 " if (did_respond > 0) { char responseCode_char[4]; - memcpy(responseCode_char, tempBuffer + 9, 3); + memcpy(responseCode_char, tempBuffer + HTTP_VERSION_PREFIX_LEN, 3); // Null terminate the string memset(responseCode_char + 3, '\0', 1); responseCode = atoi(responseCode_char); From 432d6bfbf80f92df04f885384df6ffdfe1ee3a66 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Fri, 6 Mar 2026 13:58:58 -0500 Subject: [PATCH 475/533] Add some comments Signed-off-by: Sara Damiano --- src/ClockSupport.cpp | 4 ++-- src/ClockSupport.h | 16 +++++++++++++--- src/ModSensorConfig.h | 2 +- src/SensorBase.cpp | 4 ++-- src/modems/EspressifESP32.cpp | 6 +++--- src/modems/SIMComSIM800.cpp | 2 +- src/modems/SodaqUBeeR410M.cpp | 2 +- 7 files changed, 23 insertions(+), 13 deletions(-) diff --git a/src/ClockSupport.cpp b/src/ClockSupport.cpp index 816423883..13dba1022 100644 --- a/src/ClockSupport.cpp +++ b/src/ClockSupport.cpp @@ -568,9 +568,9 @@ void loggerClock::rtcISR() { void loggerClock::begin() { MS_DBG(F("Getting the epoch the processor core uses for gmtime")); - loggerClock::_core_epoch = getProcessorEpochStart(); + getProcessorEpochStart(); // Sets _core_epoch internally MS_DBG(F("Getting the timezone the processor core uses for mktime")); - loggerClock::_core_tz = getProcessorTimeZone(); + getProcessorTimeZone(); // Sets _core_tz internally PRINTOUT(F("An"), MS_CLOCK_NAME, F("will be used as the real time clock")); MS_DBG(F("Beginning"), MS_CLOCK_NAME, F("real time clock")); rtcBegin(); diff --git a/src/ClockSupport.h b/src/ClockSupport.h index 4eed8b4dd..3420907fc 100644 --- a/src/ClockSupport.h +++ b/src/ClockSupport.h @@ -337,7 +337,7 @@ class epochTime { * static offset from UTC), daylight savings time, or any of the other * complications of time. * - * If you though handling time was simple, read this: + * If you thought handling time was simple, read this: * https://gist.github.com/timvisee/fcda9bbdff88d45cc9061606b4b923ca */ class loggerClock { @@ -492,9 +492,14 @@ class loggerClock { * the epoch). * * @return True if the input timestamp passes sanity checks **and** - * the clock has been successfully set. + * the clock is now at or within tolerance (±5 seconds) of the target time. + * This includes both cases where the clock was successfully set and where + * the clock was already within tolerance and did not need adjustment. * * @note There is no timezone correction in this function + * @note Changed behavior: Previously returned true only when clock was + * actually written. Now returns true when clock is at/within tolerance, + * regardless of whether it was written. */ static bool setRTClock(time_t ts, int8_t utcOffset, epochStart epoch); /** @@ -505,9 +510,14 @@ class loggerClock { * @param utcOffset The offset of the epoch time from UTC. * * @return True if the input timestamp passes sanity checks **and** - * the clock has been successfully set. + * the clock is now at or within tolerance (±5 seconds) of the target time. + * This includes both cases where the clock was successfully set and where + * the clock was already within tolerance and did not need adjustment. * * @note There is no timezone correction in this function + * @note Changed behavior: Previously returned true only when clock was + * actually written. Now returns true when clock is at/within tolerance, + * regardless of whether it was written. */ static bool setRTClock(epochTime in_time, int8_t utcOffset); diff --git a/src/ModSensorConfig.h b/src/ModSensorConfig.h index 3db21094d..48ea2c564 100644 --- a/src/ModSensorConfig.h +++ b/src/ModSensorConfig.h @@ -288,7 +288,7 @@ static_assert(MS_DEFAULT_ADS1X15_ADDRESS == 0x48 || MS_DEFAULT_ADS1X15_ADDRESS == 0x49 || MS_DEFAULT_ADS1X15_ADDRESS == 0x4A || MS_DEFAULT_ADS1X15_ADDRESS == 0x4B, - "MS_DEFAULT_ADS1X15_ADDRESS should be 0x48, 0x49, 0x4A, or 0x4B " + "MS_DEFAULT_ADS1X15_ADDRESS must be 0x48, 0x49, 0x4A, or 0x4B " "for ADS1X15"); //============================================================== diff --git a/src/SensorBase.cpp b/src/SensorBase.cpp index 2b399500b..5387f6c55 100644 --- a/src/SensorBase.cpp +++ b/src/SensorBase.cpp @@ -177,8 +177,8 @@ void Sensor::powerUp() { // This turns off sensor power void Sensor::powerDown() { if (_powerPin >= 0 || _powerPin2 >= 0) { - // Reset power pin mode every power up because pins are set to tri-state - // on sleep on SAMD boards + // Reset power pin mode every pin access because pins are set to + // tri-state on sleep on SAMD boards if (_powerPin >= 0) { pinMode(_powerPin, OUTPUT); MS_DBG(F("Turning off"), getSensorNameAndLocation(), F("with pin"), diff --git a/src/modems/EspressifESP32.cpp b/src/modems/EspressifESP32.cpp index 53e45ef24..4b27fa592 100644 --- a/src/modems/EspressifESP32.cpp +++ b/src/modems/EspressifESP32.cpp @@ -80,9 +80,9 @@ bool EspressifESP32::extraModemSetup() { // ISO 3166-1 alpha-2 for country codes. // : the channel number to start. Range: [1,14]. // : total number of channels. - gsmModem.sendAT(GF( - "+CWCOUNTRY=0,\"US\",1,13")); // Set country code to default to US, - // but allow to change if the AP is + // We set the country code to default to US, but allow it to change if + // the AP is in a different country. + gsmModem.sendAT(GF("+CWCOUNTRY=0,\"US\",1,13")); success &= (gsmModem.waitResponse() == 1); } return success; diff --git a/src/modems/SIMComSIM800.cpp b/src/modems/SIMComSIM800.cpp index 55b749e01..c309422a8 100644 --- a/src/modems/SIMComSIM800.cpp +++ b/src/modems/SIMComSIM800.cpp @@ -76,6 +76,6 @@ bool SIMComSIM800::modemSleepFxn() { return res; } else { // DON'T go to sleep if we can't wake up! gsmModem.stream.flush(); - return true; + return true; // nothing's wrong with sleeping, we just won't do it! } } diff --git a/src/modems/SodaqUBeeR410M.cpp b/src/modems/SodaqUBeeR410M.cpp index 5fd0952ff..55bce5c61 100644 --- a/src/modems/SodaqUBeeR410M.cpp +++ b/src/modems/SodaqUBeeR410M.cpp @@ -178,7 +178,7 @@ void SodaqUBeeR410M::configureLowBaudRate() { _modemSerial->end(); _modemSerial->begin(9600); gsmModem.sendAT(GF("E0")); - gsmModem.waitResponse(); + gsmModem.waitResponse(); // allowed to fail } #endif From 2dbe12f6f725498f5a37fbed004e628159b850c8 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Fri, 6 Mar 2026 14:00:44 -0500 Subject: [PATCH 476/533] Initialization, null checks Signed-off-by: Sara Damiano --- src/VariableArray.cpp | 3 +++ src/VariableArray.h | 2 +- src/dataPublisherBase.cpp | 2 +- src/dataPublisherBase.h | 6 ++++++ src/modems/DigiXBeeCellularTransparent.cpp | 6 ++---- src/modems/DigiXBeeWifi.cpp | 3 +-- src/modems/LoggerModemMacros.h | 2 +- src/publishers/S3PresignedPublisher.h | 4 ++-- 8 files changed, 17 insertions(+), 11 deletions(-) diff --git a/src/VariableArray.cpp b/src/VariableArray.cpp index 167bd9c22..c224f7d2d 100644 --- a/src/VariableArray.cpp +++ b/src/VariableArray.cpp @@ -95,6 +95,9 @@ bool VariableArray::populateSensorList() { Sensor* currentSensor = arrayOfVars[i]->parentSensor; + // Skip variables with null parent sensors to avoid crashes + if (currentSensor == nullptr) { continue; } + // Check if this sensor is already in the list bool alreadyInList = false; for (uint8_t j = 0; j < addedSensors; j++) { diff --git a/src/VariableArray.h b/src/VariableArray.h index 5e799a789..c8da801c2 100644 --- a/src/VariableArray.h +++ b/src/VariableArray.h @@ -406,7 +406,7 @@ class VariableArray { /** * @brief Array of pointers to unique sensors derived from variables */ - Sensor* _sensorList[MAX_NUMBER_SENSORS]; + Sensor* _sensorList[MAX_NUMBER_SENSORS] = {}; #ifdef MS_VARIABLEARRAY_DEBUG_DEEP /** diff --git a/src/dataPublisherBase.cpp b/src/dataPublisherBase.cpp index 8ca2ce7a6..d67dd0805 100644 --- a/src/dataPublisherBase.cpp +++ b/src/dataPublisherBase.cpp @@ -43,7 +43,7 @@ dataPublisher::dataPublisher() _baseModem(nullptr), _inClient(nullptr), _sendEveryX(1), - _initialTransmissionsRemaining(5) {} + _initialTransmissionsRemaining(DEFAULT_INITIAL_TRANSMISSIONS) {} // Sets the client diff --git a/src/dataPublisherBase.h b/src/dataPublisherBase.h index 001948457..2f0eb0f3d 100644 --- a/src/dataPublisherBase.h +++ b/src/dataPublisherBase.h @@ -51,6 +51,12 @@ */ #define HTTP_VERSION_PREFIX_LEN 9 +// Data publisher defaults +/** + * @brief Default number of initial transmissions to send immediately after each data point + */ +#define DEFAULT_INITIAL_TRANSMISSIONS 5 + /** * @brief The dataPublisher class is a virtual class used by other publishers to * distribute data online. diff --git a/src/modems/DigiXBeeCellularTransparent.cpp b/src/modems/DigiXBeeCellularTransparent.cpp index 7c3c270c9..ffff5e7a5 100644 --- a/src/modems/DigiXBeeCellularTransparent.cpp +++ b/src/modems/DigiXBeeCellularTransparent.cpp @@ -256,8 +256,6 @@ uint32_t DigiXBeeCellularTransparent::getNISTTime() { bool DigiXBeeCellularTransparent::updateModemMetadata() { - bool success = true; - // Unset whatever we had previously loggerModem::_priorRSSI = MS_INVALID_VALUE; loggerModem::_priorSignalPercent = MS_INVALID_VALUE; @@ -298,7 +296,7 @@ bool DigiXBeeCellularTransparent::updateModemMetadata() { if (signalQual != 0 && signalQual != MS_INVALID_VALUE) break; delay(250); } while ((signalQual == 0 || signalQual == MS_INVALID_VALUE) && - millis() - startMillis < 15000L && success); + millis() - startMillis < 15000L); // Convert signal quality to RSSI loggerModem::_priorRSSI = signalQual; @@ -323,5 +321,5 @@ bool DigiXBeeCellularTransparent::updateModemMetadata() { MS_DBG(F("Leaving Command Mode after updating modem metadata:")); gsmModem.exitCommand(); - return success; + return true; } diff --git a/src/modems/DigiXBeeWifi.cpp b/src/modems/DigiXBeeWifi.cpp index b53e62546..6b8a9a835 100644 --- a/src/modems/DigiXBeeWifi.cpp +++ b/src/modems/DigiXBeeWifi.cpp @@ -517,8 +517,7 @@ bool DigiXBeeWifi::updateModemMetadata() { if ((_pollModemMetaData & MODEM_TEMPERATURE_ENABLE_BITMASK) == MODEM_TEMPERATURE_ENABLE_BITMASK) { MS_DBG(F("Getting chip temperature:")); - float chip_temp = MS_INVALID_VALUE; - chip_temp = getModemChipTemperature(); + float chip_temp = getModemChipTemperature(); loggerModem::_priorModemTemp = chip_temp; MS_DBG(F("CURRENT Modem temperature(C):"), loggerModem::_priorModemTemp); diff --git a/src/modems/LoggerModemMacros.h b/src/modems/LoggerModemMacros.h index 9af90ed60..99b430881 100644 --- a/src/modems/LoggerModemMacros.h +++ b/src/modems/LoggerModemMacros.h @@ -134,7 +134,7 @@ MS_DBG(F("Wait"), _wakeDelayTime_ms - (millis() - _millisPowerOn), \ F("ms longer for warm-up")); \ while (millis() - _millisPowerOn < _wakeDelayTime_ms) { \ - /* wait*/ \ + yield(); /* wait */ \ } \ } \ \ diff --git a/src/publishers/S3PresignedPublisher.h b/src/publishers/S3PresignedPublisher.h index 46682ebd7..727ff99cc 100644 --- a/src/publishers/S3PresignedPublisher.h +++ b/src/publishers/S3PresignedPublisher.h @@ -352,7 +352,7 @@ class S3PresignedPublisher : public dataPublisher { * @note This will be *ignored* if the filename is set. If neither the * filename nor the file prefix is set, the logger ID will be used. */ - const char* _filePrefix; + const char* _filePrefix = nullptr; /** * @brief The extension to add to files, if generating a filename based on * the date/time @@ -360,7 +360,7 @@ class S3PresignedPublisher : public dataPublisher { * @note This will be *ignored* if the filename is set. If neither the * filename nor the file extension is set, `#S3_DEFAULT_FILE_EXTENSION`. */ - const char* _fileExtension; + const char* _fileExtension = nullptr; /** * @brief Private reference to function used fetch a new file name. */ From 87cb61d859fa12107eaf2551a6c934ccf24966fc Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Fri, 6 Mar 2026 14:01:38 -0500 Subject: [PATCH 477/533] Replace log fxn with builtin bit math Signed-off-by: Sara Damiano --- src/SensorBase.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/SensorBase.cpp b/src/SensorBase.cpp index 5387f6c55..2e64a56c0 100644 --- a/src/SensorBase.cpp +++ b/src/SensorBase.cpp @@ -611,14 +611,12 @@ bool Sensor::checkPowerOn(bool debug) { bool pp1_off = false; bool pp2_off = false; if (_powerPin >= 0) { - auto powerBitNumber = - static_cast(log(digitalPinToBitMask(_powerPin)) / log(2)); + auto powerBitNumber = static_cast(__builtin_ctz(digitalPinToBitMask(_powerPin))); pp1_off = bitRead(*portInputRegister(digitalPinToPort(_powerPin)), powerBitNumber) == LOW; } if (_powerPin2 >= 0) { - auto powerBitNumber2 = - static_cast(log(digitalPinToBitMask(_powerPin2)) / log(2)); + auto powerBitNumber2 = static_cast(__builtin_ctz(digitalPinToBitMask(_powerPin2))); pp2_off = bitRead(*portInputRegister(digitalPinToPort(_powerPin2)), powerBitNumber2) == LOW; } From 0cdcec028bfbc004555c76238a79733c7c25572b Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Fri, 6 Mar 2026 14:02:01 -0500 Subject: [PATCH 478/533] Always add UUID row to header Signed-off-by: Sara Damiano --- src/LoggerBase.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/LoggerBase.cpp b/src/LoggerBase.cpp index 9d464d4eb..ea6ec203a 100644 --- a/src/LoggerBase.cpp +++ b/src/LoggerBase.cpp @@ -1287,10 +1287,13 @@ void Logger::printFileHeader(Stream* stream) { // Next comes the ODM2 unit name STREAM_CSV_ROW(F("Result Unit:"), getVarUnitAtI(i)) // Next comes the variable UUIDs - // We'll only add UUIDs if we see a UUID for the first variable - if (getVarUUIDAtI(0) != nullptr && strlen(getVarUUIDAtI(0)) > 1) { - STREAM_CSV_ROW(F("Result UUID:"), getVarUUIDAtI(i)) - } + /// @todo Currrently the file header will always have a UUID row, but it + /// will be blank if the user doesn't set any UUIDs. Versions 0.37.0 and + /// prior only printed the row if the **first** UUID existed. It might be + /// better to only print the UUID row if at least one variable has a UUID + /// even if that single variable with a UUID isn't the first one. + STREAM_CSV_ROW(F("Result UUID:"), + getVarUUIDAtI(i) != nullptr ? getVarUUIDAtI(i) : "") // We'll finish up with the custom variable codes String dtRowHeader = F("Date and Time in UTC"); From 2fecf3ac9e86ed6a744b9d92bf000b3a1069c431 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Fri, 6 Mar 2026 14:03:05 -0500 Subject: [PATCH 479/533] For real handle tz_offset with different types Signed-off-by: Sara Damiano --- src/ClockSupport.cpp | 46 +++++++++++++++++++++++++++++--------------- 1 file changed, 31 insertions(+), 15 deletions(-) diff --git a/src/ClockSupport.cpp b/src/ClockSupport.cpp index 13dba1022..51a542405 100644 --- a/src/ClockSupport.cpp +++ b/src/ClockSupport.cpp @@ -11,6 +11,9 @@ #include "ClockSupport.h" #include "LoggerBase.h" +// Constants +constexpr time_t SECONDS_IN_DAY = 86400L; // 86400 (60*60*24)seconds in a day + epochTime::epochTime(time_t timestamp, epochStart epoch) { _unixTimestamp = convert_epoch(timestamp, epoch, epochStart::unix_epoch); @@ -656,21 +659,34 @@ int32_t loggerClock::getProcessorTimeZone() { // Since we started with Jan 1, 2000, the offset from the input time and 0 // in the Y2K epoch can only be caused by timezone shifts within the mktime // function. - // Since time_t can be unsigned and is > 16 bit, we do checks before - // casting. If the timeY2K is less than 24 hours, it's a positive offset of - // that many seconds. If it's more than 24 hours, it's a negative offset of - // tz_offset (because the time would have rolled back to the previous day). - int32_t tz_offset; - const time_t secondsInDay = 60L * 60L * 24L; // 86400 seconds in a day - if (timeY2K < secondsInDay) { - tz_offset = static_cast(timeY2K); - } else if ((-1 * timeY2K) < - secondsInDay) { // force roll-over and check size - tz_offset = -1 * (static_cast(-1 * timeY2K)); - } else { // If the difference is more than 24 hours, something is wrong and - // we should just return 0 (UTC) - tz_offset = static_cast(0); - // NOTE: Do this silently in case Serial isn't initialized yet. + // Handle both signed and unsigned time_t properly + // Check if time_t is signed by testing if (time_t)-1 < (time_t)0 + int32_t tz_offset; + const bool is_time_t_signed = ((time_t)-1 < (time_t)0); + + if (is_time_t_signed) { + // For signed time_t, negative values are represented normally + if (timeY2K >= -SECONDS_IN_DAY && timeY2K <= SECONDS_IN_DAY) { + tz_offset = static_cast(timeY2K); + } else { + tz_offset = 0; // Outside reasonable timezone range (±24 hours) + } + } else { + // For unsigned time_t, check for wraparound indicating negative values + if (timeY2K <= SECONDS_IN_DAY) { + // Positive offset or zero + tz_offset = static_cast(timeY2K); + } else { + // Check if this looks like a wrapped negative value + const time_t max_unsigned = (time_t)-1; + if (timeY2K > (max_unsigned - SECONDS_IN_DAY)) { + // This is likely a wrapped negative offset + time_t offsetMagnitude = max_unsigned - timeY2K + 1; + tz_offset = -static_cast(offsetMagnitude); + } else { + tz_offset = 0; // Outside reasonable timezone range + } + } } loggerClock::_core_tz = tz_offset; return tz_offset; From 91212b930bd024df875e97fc1de1943c8cff12b7 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Fri, 6 Mar 2026 15:02:59 -0500 Subject: [PATCH 480/533] Lots of small changes Signed-off-by: Sara Damiano --- src/ClockSupport.cpp | 12 ++++++++++-- src/ClockSupport.h | 6 +++--- src/VariableBase.h | 2 +- src/dataPublisherBase.cpp | 3 ++- src/dataPublisherBase.h | 13 ++++++++----- src/sensors/ANBpH.h | 2 +- src/sensors/AnalogElecConductivity.cpp | 1 + src/sensors/AtlasParent.cpp | 8 ++++++-- src/sensors/BoschBMP3xx.cpp | 12 ++++++------ src/sensors/BoschBMP3xx.h | 10 ++++++++++ src/sensors/GeoluxHydroCam.cpp | 2 +- src/sensors/GroPointParent.cpp | 1 + src/sensors/InSituRDO.h | 1 - src/sensors/KnownProcessors.h | 24 ++++++++++++++++++++++++ src/sensors/MeterTeros11.cpp | 7 +++---- src/sensors/ProcessorAnalog.cpp | 7 +++---- src/sensors/ProcessorStats.cpp | 6 +++++- src/sensors/SensirionSHT4x.cpp | 3 +++ src/sensors/TEConnectivityMS5837.cpp | 2 +- src/sensors/YosemitechY560.h | 9 +++++---- 20 files changed, 94 insertions(+), 37 deletions(-) diff --git a/src/ClockSupport.cpp b/src/ClockSupport.cpp index 51a542405..338bf6569 100644 --- a/src/ClockSupport.cpp +++ b/src/ClockSupport.cpp @@ -649,6 +649,14 @@ int32_t loggerClock::getProcessorTimeZone() { timeParts.tm_yday = 0; /* day of year, will be calculated */ timeParts.tm_isdst = 0; /* daylight saving time flag */ time_t timeTimeT = mktime(&timeParts); + + // Check for mktime failure + if (timeTimeT == (time_t)-1) { + MS_DBG(F("mktime failed, defaulting timezone offset to 0")); + loggerClock::_core_tz = 0; + return 0; + } + // make a epoch time from the converted time // NOTE: Re-run getProcessorEpochStart() instead of calling _core_epoch in // case the functions are called out of order and _core_epoch hasn't been @@ -661,8 +669,8 @@ int32_t loggerClock::getProcessorTimeZone() { // function. // Handle both signed and unsigned time_t properly // Check if time_t is signed by testing if (time_t)-1 < (time_t)0 - int32_t tz_offset; - const bool is_time_t_signed = ((time_t)-1 < (time_t)0); + int32_t tz_offset; + constexpr bool is_time_t_signed = ((time_t)-1 < (time_t)0); if (is_time_t_signed) { // For signed time_t, negative values are represented normally diff --git a/src/ClockSupport.h b/src/ClockSupport.h index 3420907fc..36e75d607 100644 --- a/src/ClockSupport.h +++ b/src/ClockSupport.h @@ -624,7 +624,7 @@ class loggerClock { */ static epochStart getCoreEpochStart() { return loggerClock::_core_epoch; - }; + } /** * @brief Get the timezone offset for the processor/Arduino core in seconds * from UTC @@ -634,7 +634,7 @@ class loggerClock { */ static int32_t getCoreTimeZone() { return loggerClock::_core_tz; - }; + } /** * @brief Get the epoch start for the RTC as an epochStart object * @@ -642,7 +642,7 @@ class loggerClock { */ static epochStart getRTCEpochStart() { return _rtcEpoch; - }; + } protected: diff --git a/src/VariableBase.h b/src/VariableBase.h index b27bfc68b..af4f31387 100644 --- a/src/VariableBase.h +++ b/src/VariableBase.h @@ -426,7 +426,7 @@ class Variable { // resolution We want at least one significant digit beyond the // resolution float log10Resolution = log10f(resolution); - int decimalPlaces = static_cast(-log10Resolution) + 1; + int decimalPlaces = static_cast(ceilf(-log10Resolution)) + 1; // Clamp to reasonable bounds (0-6 decimal places) if (decimalPlaces < 0) decimalPlaces = 0; diff --git a/src/dataPublisherBase.cpp b/src/dataPublisherBase.cpp index d67dd0805..f99a487bb 100644 --- a/src/dataPublisherBase.cpp +++ b/src/dataPublisherBase.cpp @@ -28,7 +28,8 @@ dataPublisher::dataPublisher(Logger& baseLogger, Client* inClient, : _baseLogger(&baseLogger), _inClient(inClient), _sendEveryX(sendEveryX), - _initialTransmissionsRemaining(initialTransmissions) { + _initialTransmissionsRemaining( + initialTransmissions < 1 ? 1 : initialTransmissions) { _baseModem = _baseLogger->registerDataPublisher(this); // register self with logger } diff --git a/src/dataPublisherBase.h b/src/dataPublisherBase.h index 2f0eb0f3d..28d8e6fb2 100644 --- a/src/dataPublisherBase.h +++ b/src/dataPublisherBase.h @@ -47,13 +47,15 @@ // HTTP response parsing constants /** - * @brief Length of the HTTP version prefix "HTTP/1.1 " used when parsing HTTP response codes + * @brief Length of the HTTP version prefix "HTTP/1.1 " used when parsing HTTP + * response codes */ #define HTTP_VERSION_PREFIX_LEN 9 // Data publisher defaults /** - * @brief Default number of initial transmissions to send immediately after each data point + * @brief Default number of initial transmissions to send immediately after each + * data point */ #define DEFAULT_INITIAL_TRANSMISSIONS 5 @@ -98,8 +100,9 @@ class dataPublisher { * This allows faster in-field validation of initial data. Not respected by * all publishers. */ - explicit dataPublisher(Logger& baseLogger, int sendEveryX = 1, - uint8_t initialTransmissions = 5); + explicit dataPublisher( + Logger& baseLogger, int sendEveryX = 1, + uint8_t initialTransmissions = DEFAULT_INITIAL_TRANSMISSIONS); /** * @brief Construct a new data publisher object. * @@ -120,7 +123,7 @@ class dataPublisher { * all publishers. */ dataPublisher(Logger& baseLogger, Client* inClient, int sendEveryX = 1, - uint8_t initialTransmissions = 5); + uint8_t initialTransmissions = DEFAULT_INITIAL_TRANSMISSIONS); /** * @brief Destroy the data publisher object - no action is taken. */ diff --git a/src/sensors/ANBpH.h b/src/sensors/ANBpH.h index c2b9c556f..2d19c25d1 100644 --- a/src/sensors/ANBpH.h +++ b/src/sensors/ANBpH.h @@ -350,7 +350,7 @@ */ /**@{*/ /// @brief Decimal places in string representation; raw electrical conductivity -/// should have 2. +/// should have 3. #define ANB_PH_EC_RESOLUTION 3 /// @brief Sensor variable number; conductivity is stored in sensorValues[4]. #define ANB_PH_EC_VAR_NUM 4 diff --git a/src/sensors/AnalogElecConductivity.cpp b/src/sensors/AnalogElecConductivity.cpp index 31f9b0ec1..fc5cf5f0d 100644 --- a/src/sensors/AnalogElecConductivity.cpp +++ b/src/sensors/AnalogElecConductivity.cpp @@ -41,6 +41,7 @@ AnalogElecConductivity::~AnalogElecConductivity() { String AnalogElecConductivity::getSensorLocation() { String sensorLocation; + sensorLocation.reserve(48); // Approximate expected size if (_analogVoltageReader != nullptr) { sensorLocation = _analogVoltageReader->getAnalogLocation(_dataPin, -1); } else { diff --git a/src/sensors/AtlasParent.cpp b/src/sensors/AtlasParent.cpp index 4adec383d..5a09c1ae0 100644 --- a/src/sensors/AtlasParent.cpp +++ b/src/sensors/AtlasParent.cpp @@ -143,10 +143,14 @@ bool AtlasParent::addSingleMeasurementResult() { bool success = false; // call the circuit and request 40 bytes (this may be more than we need) - _i2c->requestFrom(static_cast(_i2cAddressHex), 40, 1); + int bytesReceived = _i2c->requestFrom(static_cast(_i2cAddressHex), 40, + 1); + if (bytesReceived == 0) { + MS_DBG(getSensorNameAndLocation(), F("I2C read failed - no response")); + return finalizeMeasurementAttempt(false); + } // the first byte is the response code, we read this separately. int code = _i2c->read(); - MS_DBG(getSensorNameAndLocation(), F("is reporting:")); // Parse the response code switch (code) { diff --git a/src/sensors/BoschBMP3xx.cpp b/src/sensors/BoschBMP3xx.cpp index 8bdcd9c0e..f184da3b9 100644 --- a/src/sensors/BoschBMP3xx.cpp +++ b/src/sensors/BoschBMP3xx.cpp @@ -110,11 +110,11 @@ bool BoschBMP3xx::setup() { // ADC NOTE: The ADC will return repeated values if the ADC's ODR (output // data rate) is set faster than the actual measurement time, given // oversampling. - float _timeStandby_ms = 5.0f * (1U << static_cast(_standbyEnum)); + float timeStandby_ms = 5.0f * (1U << static_cast(_standbyEnum)); // warn if an impossible sampling rate is selected - if ((_timeStandby_ms < max_measurementTime_us / 1000) && + if ((timeStandby_ms < max_measurementTime_us / 1000) && _mode == NORMAL_MODE) { - MS_DBG(F("The selected standby time of"), _timeStandby_ms, + MS_DBG(F("The selected standby time of"), timeStandby_ms, F("between ADC samples is less than the expected max of"), _measurementTime_ms, F("ms needed for temperature and pressure oversampling.")); @@ -126,10 +126,10 @@ bool BoschBMP3xx::setup() { #if defined(MS_DEBUGGING_STD) _timeStandby_ms = 5.0f * (1U << static_cast(_standbyEnum)); #endif - MS_DBG(_standbyEnum, _timeStandby_ms, + MS_DBG(_standbyEnum, timeStandby_ms, static_cast(max_measurementTime_us / 1000)); } - MS_DBG(F("A standby time of"), _timeStandby_ms, + MS_DBG(F("A standby time of"), timeStandby_ms, F("ms between reading will be used.")); } @@ -137,7 +137,7 @@ bool BoschBMP3xx::setup() { // the value of the enum is the power of the number of samples if (_filterCoeffEnum != IIR_FILTER_OFF && _mode == NORMAL_MODE) { MS_DBG(F("BMP388/390's IIR filter will only be fully initialized"), - (1U << static_cast(_filterCoeffEnum)) * _timeStandby_ms, + (1U << static_cast(_filterCoeffEnum)) * timeStandby_ms, F("ms after power on")); } if (_filterCoeffEnum != IIR_FILTER_OFF && _mode == FORCED_MODE) { diff --git a/src/sensors/BoschBMP3xx.h b/src/sensors/BoschBMP3xx.h index 7ba425c04..2f04d2c36 100644 --- a/src/sensors/BoschBMP3xx.h +++ b/src/sensors/BoschBMP3xx.h @@ -420,6 +420,16 @@ class BoschBMP3xx : public Sensor { * @param i2cAddressHex The I2C address of the BMP3xx; must be either 0x76 * or 0x77. The default value is 0x76. * + * @note **BEHAVIORAL CHANGE**: In previous versions of this library, the + * default oversampling settings were `OVERSAMPLING_X16` for pressure and + * `OVERSAMPLING_X2` for temperature, which provided higher resolution but + * consumed more power. The defaults have been changed to + * `OVERSAMPLING_SKIP` for both parameters to optimize for lowest power + * consumption as recommended in the datasheet. To retain the previous + * higher-resolution behavior, explicitly pass `OVERSAMPLING_X16` for + * pressure and `OVERSAMPLING_X2` for temperature when constructing the + * sensor object. + * * @note For the BoschBMP3xx we do _**NOT**_ provide a * `measurementsToAverage` option. The sensor already provides on-board * averaging by way of oversampling and the IIR filter, so there is no diff --git a/src/sensors/GeoluxHydroCam.cpp b/src/sensors/GeoluxHydroCam.cpp index 9b12cc3b5..1988dab54 100644 --- a/src/sensors/GeoluxHydroCam.cpp +++ b/src/sensors/GeoluxHydroCam.cpp @@ -140,7 +140,7 @@ bool GeoluxHydroCam::sleep() { while (_stream->available()) { _stream->read(); } _stream->flush(); return Sensor::sleep(); -}; +} bool GeoluxHydroCam::startSingleMeasurement() { // Sensor::startSingleMeasurement() checks that if it's awake/active and diff --git a/src/sensors/GroPointParent.cpp b/src/sensors/GroPointParent.cpp index 92358b08d..11062df91 100644 --- a/src/sensors/GroPointParent.cpp +++ b/src/sensors/GroPointParent.cpp @@ -203,6 +203,7 @@ bool GroPointParent::addSingleMeasurementResult() { default: { // Get Values MS_DBG(F("Other GroPoint models not yet implemented.")); + break; } } diff --git a/src/sensors/InSituRDO.h b/src/sensors/InSituRDO.h index bf5728fa2..e9649bcaa 100644 --- a/src/sensors/InSituRDO.h +++ b/src/sensors/InSituRDO.h @@ -297,7 +297,6 @@ * {{ @ref InSituRDO_Temp::InSituRDO_Temp }} */ /**@{*/ -/// @brief /** * @brief Decimal places in string representation; temperature should have 2 - * resolution is 0.01°C. diff --git a/src/sensors/KnownProcessors.h b/src/sensors/KnownProcessors.h index ca74d62fe..d4596b794 100644 --- a/src/sensors/KnownProcessors.h +++ b/src/sensors/KnownProcessors.h @@ -34,6 +34,30 @@ * board version. Where the battery multiplier is not available, it is set to * -1. Where it's variable, it must be fixed in the ProcessorStats module or * constructor. + * + * @def BUILT_IN_ALS_POWER_PIN + * @brief The digital pin controlling power to the built-in ambient light sensor + * (ALS) on EnviroDIY boards. + * @note Set to -1 when the ALS is always powered or when no built-in ALS is + * available on the board. + * + * @def BUILT_IN_ALS_DATA_PIN + * @brief The analog pin connected to the built-in ambient light sensor (ALS) + * on EnviroDIY boards. + * @note The data pin varies by board model and version. Set to -1 when no + * built-in ALS is available on the board. + * + * @def BUILT_IN_ALS_SUPPLY_VOLTAGE + * @brief The supply voltage for the built-in ambient light sensor (ALS) on + * EnviroDIY boards, in volts. + * @note Typically matches the board's operating voltage. Set to -1 when no + * built-in ALS is available on the board. + * + * @def BUILT_IN_ALS_LOADING_RESISTANCE + * @brief The loading resistance for the built-in ambient light sensor (ALS) + * on EnviroDIY boards, in kΩ. + * @note The loading resistance affects light measurement calculations. Set to + * -1 when no built-in ALS is available on the board. */ // EnviroDIY boards diff --git a/src/sensors/MeterTeros11.cpp b/src/sensors/MeterTeros11.cpp index 41b304ec0..6f25fcfb9 100644 --- a/src/sensors/MeterTeros11.cpp +++ b/src/sensors/MeterTeros11.cpp @@ -35,10 +35,9 @@ bool MeterTeros11::getResults(bool verify_crc) { raw = MS_INVALID_VALUE; } if (raw != MS_INVALID_VALUE) { - ea = ((2.887e-9 * (raw * raw * raw)) - (2.08e-5 * (raw * raw)) + - (5.276e-2 * raw) - 43.39) * - ((2.887e-9 * (raw * raw * raw)) - (2.08e-5 * (raw * raw)) + - (5.276e-2 * raw) - 43.39); + double cubic = (2.887e-9 * raw * raw * raw) - (2.08e-5 * raw * raw) + + (5.276e-2 * raw) - 43.39; + ea = cubic * cubic; MS_DBG(F("Calculated Ea:"), ea); } diff --git a/src/sensors/ProcessorAnalog.cpp b/src/sensors/ProcessorAnalog.cpp index 460115757..516806d3c 100644 --- a/src/sensors/ProcessorAnalog.cpp +++ b/src/sensors/ProcessorAnalog.cpp @@ -53,15 +53,14 @@ bool ProcessorAnalogBase::readVoltageSingleEnded(int8_t analogChannel, analogRead(analogChannel); // priming reading // The return value from analogRead() is IN BITS NOT IN VOLTS!! analogRead(analogChannel); // another priming reading - int rawAdc = analogRead(analogChannel); - float rawAnalog = static_cast(rawAdc); - MS_DBG(F("Raw analog pin reading in bits:"), rawAnalog); + int rawAdc = analogRead(analogChannel); + MS_DBG(F("Raw analog pin reading in bits:"), rawAdc); // convert bits to volts // Use (PROCESSOR_ADC_MAX + 1) as divisor for correct 2^n scaling resultValue = (_supplyVoltage / (static_cast(PROCESSOR_ADC_MAX) + 1.0f)) * - _voltageMultiplier * rawAnalog; + _voltageMultiplier * static_cast(rawAdc); MS_DBG(F("Voltage:"), resultValue); // NOTE: We don't actually have any criteria for if the reading was any diff --git a/src/sensors/ProcessorStats.cpp b/src/sensors/ProcessorStats.cpp index b6a49827b..c2c0f9176 100644 --- a/src/sensors/ProcessorStats.cpp +++ b/src/sensors/ProcessorStats.cpp @@ -79,7 +79,11 @@ ProcessorStats::ProcessorStats(const char* boardName, const char* version, String ProcessorStats::getSensorLocation() { String result; result.reserve(50); // Reserve for board name + " " + version - result = String(_boardName) + " " + String(_version); + result = String(_boardName); + if (_version != nullptr) { + result += " "; + result += _version; + } return result; } diff --git a/src/sensors/SensirionSHT4x.cpp b/src/sensors/SensirionSHT4x.cpp index 149058c72..f3661ff63 100644 --- a/src/sensors/SensirionSHT4x.cpp +++ b/src/sensors/SensirionSHT4x.cpp @@ -63,6 +63,9 @@ bool SensirionSHT4x::setup() { ntries++; } + // NOTE: The setPrecision and setHeater functions set internal variables in + // the Adafruit library; they don't require sensor communication. + // Set sensor for high precision sht4x_internal.setPrecision(SHT4X_HIGH_PRECISION); diff --git a/src/sensors/TEConnectivityMS5837.cpp b/src/sensors/TEConnectivityMS5837.cpp index 8ff6e77b3..7f63b48ea 100644 --- a/src/sensors/TEConnectivityMS5837.cpp +++ b/src/sensors/TEConnectivityMS5837.cpp @@ -66,7 +66,7 @@ String TEConnectivityMS5837::getSensorName() { switch (modelEnum) { case MS5837Model::MS5837_02BA: modelStr += F("02BA"); break; case MS5837Model::MS5837_30BA: modelStr += F("30BA"); break; - case MS5837Model::MS5803_01BA: modelStr += F("01BA"); break; + case MS5837Model::MS5803_01BA: return F("TEConnectivityMS5803_01BA"); default: modelStr += F("Unknown"); break; } return modelStr; diff --git a/src/sensors/YosemitechY560.h b/src/sensors/YosemitechY560.h index 4273d42c0..5b8687b33 100644 --- a/src/sensors/YosemitechY560.h +++ b/src/sensors/YosemitechY560.h @@ -250,8 +250,8 @@ class YosemitechY560_NH4_N : public Variable { const char* uuid = "", const char* varCode = Y560_NH4_N_DEFAULT_CODE) : Variable(parentSense, static_cast(Y560_NH4_N_VAR_NUM), - (const uint8_t)Y560_NH4_N_RESOLUTION, Y560_NH4_N_VAR_NAME, - Y560_NH4_N_UNIT_NAME, varCode, uuid) {} + static_cast(Y560_NH4_N_RESOLUTION), + Y560_NH4_N_VAR_NAME, Y560_NH4_N_UNIT_NAME, varCode, uuid) {} /** * @brief Construct a new YosemitechY560_NH4_N object. * @@ -260,8 +260,9 @@ class YosemitechY560_NH4_N : public Variable { */ YosemitechY560_NH4_N() : Variable(static_cast(Y560_NH4_N_VAR_NUM), - (const uint8_t)Y560_NH4_N_RESOLUTION, Y560_NH4_N_VAR_NAME, - Y560_NH4_N_UNIT_NAME, Y560_NH4_N_DEFAULT_CODE) {} + static_cast(Y560_NH4_N_RESOLUTION), + Y560_NH4_N_VAR_NAME, Y560_NH4_N_UNIT_NAME, + Y560_NH4_N_DEFAULT_CODE) {} /** * @brief Destroy the YosemitechY560_NH4_N object - no action needed. */ From db756c153d5d4c9d00f1c983f414389d752918a2 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Fri, 6 Mar 2026 15:03:29 -0500 Subject: [PATCH 481/533] Add helper for isPinLow Signed-off-by: Sara Damiano --- src/SensorBase.cpp | 26 ++++++++++++++------------ src/SensorBase.h | 13 +++++++++++++ 2 files changed, 27 insertions(+), 12 deletions(-) diff --git a/src/SensorBase.cpp b/src/SensorBase.cpp index 2e64a56c0..c267a5b5f 100644 --- a/src/SensorBase.cpp +++ b/src/SensorBase.cpp @@ -608,18 +608,8 @@ bool Sensor::checkPowerOn(bool debug) { setStatusBits(POWER_ATTEMPTED, POWER_SUCCESSFUL); return true; } - bool pp1_off = false; - bool pp2_off = false; - if (_powerPin >= 0) { - auto powerBitNumber = static_cast(__builtin_ctz(digitalPinToBitMask(_powerPin))); - pp1_off = bitRead(*portInputRegister(digitalPinToPort(_powerPin)), - powerBitNumber) == LOW; - } - if (_powerPin2 >= 0) { - auto powerBitNumber2 = static_cast(__builtin_ctz(digitalPinToBitMask(_powerPin2))); - pp2_off = bitRead(*portInputRegister(digitalPinToPort(_powerPin2)), - powerBitNumber2) == LOW; - } + bool pp1_off = isPinLow(_powerPin); + bool pp2_off = isPinLow(_powerPin2); if (pp1_off || pp2_off) { if (debug) { MS_DBG(F("was off.")); } @@ -793,3 +783,15 @@ bool Sensor::finalizeMeasurementAttempt(bool wasSuccessful) { // to pass forward a value return wasSuccessful; } + + +// Helper function to check if a pin is physically LOW +bool Sensor::isPinLow(int8_t pin) { + if (pin < 0) { + return false; // Unconfigured pins are treated as not LOW + } + auto powerBitNumber = + static_cast(__builtin_ctz(digitalPinToBitMask(pin))); + return bitRead(*portInputRegister(digitalPinToPort(pin)), powerBitNumber) == + LOW; +} diff --git a/src/SensorBase.h b/src/SensorBase.h index afd6bd1b6..8b9d7679b 100644 --- a/src/SensorBase.h +++ b/src/SensorBase.h @@ -864,6 +864,19 @@ class Sensor { * @return The input parameter for easy chaining in return statements */ bool finalizeMeasurementAttempt(bool wasSuccessful); + + private: + /** + * @brief Helper function to check if a pin is physically LOW + * + * Reads the current physical state of a pin using direct port access. + * Returns true if the pin is configured and physically LOW, false if + * the pin is unconfigured (< 0) or HIGH. + * + * @param pin The pin number to check + * @return True if pin is configured and physically LOW, false otherwise + */ + bool isPinLow(int8_t pin); }; #endif // SRC_SENSORBASE_H_ From 61ece2a17d4cbadd9e416ba82ef91f1d26940787 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Fri, 6 Mar 2026 15:05:09 -0500 Subject: [PATCH 482/533] Add helper for sharesPowerPin Signed-off-by: Sara Damiano --- ChangeLog.md | 1 + src/VariableArray.cpp | 38 ++++++++++++++++++++------------------ src/VariableArray.h | 13 +++++++++++++ 3 files changed, 34 insertions(+), 18 deletions(-) diff --git a/ChangeLog.md b/ChangeLog.md index bb8074806..60612c320 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -210,6 +210,7 @@ This affects the following classes: - Added KnownProcessors.h and moved define values for supported built-in sensors on known processors to that file. - This affects ProcessorStats and the Everlight ALS PT-19. - Added a new example specific to the [EnviroDIY Monitoring Station Kit](https://www.envirodiy.org/product/envirodiy-monitoring-station-kit/). +- Added a variety of private and protected helper functions to simplify code. ### Removed diff --git a/src/VariableArray.cpp b/src/VariableArray.cpp index c224f7d2d..3219b182f 100644 --- a/src/VariableArray.cpp +++ b/src/VariableArray.cpp @@ -167,6 +167,23 @@ inline bool VariableArray::areMeasurementsComplete(uint8_t sensorIndex) { _sensorList[sensorIndex]->getNumberMeasurementsToAverage(); } +// Helper function to check if two sensors share any power pins +inline bool VariableArray::sharesPowerPin(Sensor* a, Sensor* b) { + // Check if sensor a's primary pin matches either of sensor b's pins + if (a->getPowerPin() >= 0 && + (a->getPowerPin() == b->getPowerPin() || + a->getPowerPin() == b->getSecondaryPowerPin())) { + return true; + } + // Check if sensor a's secondary pin matches either of sensor b's pins + if (a->getSecondaryPowerPin() >= 0 && + (a->getSecondaryPowerPin() == b->getPowerPin() || + a->getSecondaryPowerPin() == b->getSecondaryPowerPin())) { + return true; + } + return false; +} + // Helper function to check if sensor can be powered down safely with debug // output bool VariableArray::canPowerDownSensor(uint8_t sensorIndex) { @@ -178,24 +195,9 @@ bool VariableArray::canPowerDownSensor(uint8_t sensorIndex) { for (uint8_t k = 0; k < _sensorCount; k++) { if (k == sensorIndex) continue; // Skip self-comparison - if (( - // Check if sensor i's primary pin matches either of sensor k's - // pins - (_sensorList[sensorIndex]->getPowerPin() >= 0 && - (_sensorList[sensorIndex]->getPowerPin() == - _sensorList[k]->getPowerPin() || - _sensorList[sensorIndex]->getPowerPin() == - _sensorList[k]->getSecondaryPowerPin())) - // Check if sensor i's secondary pin matches either of sensor - // k's pins - || (_sensorList[sensorIndex]->getSecondaryPowerPin() >= 0 && - (_sensorList[sensorIndex]->getSecondaryPowerPin() == - _sensorList[k]->getPowerPin() || - _sensorList[sensorIndex]->getSecondaryPowerPin() == - _sensorList[k]->getSecondaryPowerPin()))) - // Check if sensor k still needs measurements - && (_sensorList[k]->getCompletedMeasurements() < - _sensorList[k]->getNumberMeasurementsToAverage())) { + if (sharesPowerPin(_sensorList[sensorIndex], _sensorList[k]) && + (_sensorList[k]->getCompletedMeasurements() < + _sensorList[k]->getNumberMeasurementsToAverage())) { // If sensors share a power pin and sensor k still needs // measurements, can't power down canPowerDown = false; diff --git a/src/VariableArray.h b/src/VariableArray.h index c8da801c2..9921dc6f8 100644 --- a/src/VariableArray.h +++ b/src/VariableArray.h @@ -368,6 +368,19 @@ class VariableArray { */ bool areMeasurementsComplete(uint8_t sensorIndex); + /** + * @brief Check if two sensors share any power pins + * + * This helper function checks if two sensors share either primary or + * secondary power pins by comparing all combinations of power pin + * assignments between the sensors. + * + * @param a First sensor to compare + * @param b Second sensor to compare + * @return True if sensors share any power pins + */ + bool sharesPowerPin(Sensor* a, Sensor* b); + /** * @brief Check if sensor can be powered down safely * From 8f217840ed4aadb79f911e7bdfd5f2d3559272df Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Fri, 6 Mar 2026 15:05:58 -0500 Subject: [PATCH 483/533] Remove the pointer to a new object, create object only at use Signed-off-by: Sara Damiano --- src/sensors/AOSongAM2315.cpp | 12 +++--------- src/sensors/AOSongAM2315.h | 6 +----- 2 files changed, 4 insertions(+), 14 deletions(-) diff --git a/src/sensors/AOSongAM2315.cpp b/src/sensors/AOSongAM2315.cpp index 132e9f25f..a2232b04c 100644 --- a/src/sensors/AOSongAM2315.cpp +++ b/src/sensors/AOSongAM2315.cpp @@ -18,18 +18,11 @@ AOSongAM2315::AOSongAM2315(TwoWire* theI2C, int8_t powerPin, : Sensor("AOSongAM2315", AM2315_NUM_VARIABLES, AM2315_WARM_UP_TIME_MS, AM2315_STABILIZATION_TIME_MS, AM2315_MEASUREMENT_TIME_MS, powerPin, -1, measurementsToAverage), - _i2c(theI2C != nullptr ? theI2C : &Wire) { - am2315ptr = new Adafruit_AM2315(_i2c); -} + _i2c(theI2C != nullptr ? theI2C : &Wire) {} // Delegating constructor AOSongAM2315::AOSongAM2315(int8_t powerPin, uint8_t measurementsToAverage) : AOSongAM2315(&Wire, powerPin, measurementsToAverage) {} -// Destructor -AOSongAM2315::~AOSongAM2315() { - delete am2315ptr; -} - String AOSongAM2315::getSensorLocation() { return F("I2C_0xB8"); @@ -62,7 +55,8 @@ bool AOSongAM2315::addSingleMeasurementResult() { MS_DBG(getSensorNameAndLocation(), F("is reporting:")); - success = am2315ptr->readTemperatureAndHumidity(&temp_val, &humid_val); + Adafruit_AM2315 am2315(_i2c); + success = am2315.readTemperatureAndHumidity(&temp_val, &humid_val); success &= !isnan(temp_val) && temp_val != MS_INVALID_VALUE && diff --git a/src/sensors/AOSongAM2315.h b/src/sensors/AOSongAM2315.h index d11cd35d3..bbe5e6e41 100644 --- a/src/sensors/AOSongAM2315.h +++ b/src/sensors/AOSongAM2315.h @@ -215,7 +215,7 @@ class AOSongAM2315 : public Sensor { /** * @brief Destroy the AOSongAM2315 object */ - ~AOSongAM2315() override; + ~AOSongAM2315() override = default; // Delete copy constructor and copy assignment operator to prevent shallow // copies @@ -253,10 +253,6 @@ class AOSongAM2315 : public Sensor { * @brief An internal reference to the hardware Wire instance. */ TwoWire* _i2c; - /** - * @brief Internal reference to the Adafruit sensor class - */ - Adafruit_AM2315* am2315ptr; }; From e241027352988cdbb519e1cbdda296e4e69c1afe Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Fri, 6 Mar 2026 15:28:50 -0500 Subject: [PATCH 484/533] Unify MaxBotix retries with rest of library Signed-off-by: Sara Damiano --- src/sensors/MaxBotixSonar.cpp | 125 +++++++++++++++++----------------- src/sensors/MaxBotixSonar.h | 42 ++++++++++++ 2 files changed, 103 insertions(+), 64 deletions(-) diff --git a/src/sensors/MaxBotixSonar.cpp b/src/sensors/MaxBotixSonar.cpp index b66615693..e6592ab74 100644 --- a/src/sensors/MaxBotixSonar.cpp +++ b/src/sensors/MaxBotixSonar.cpp @@ -20,7 +20,9 @@ MaxBotixSonar::MaxBotixSonar(Stream* stream, int8_t powerPin, int8_t triggerPin, _maxRange(maxRange), _triggerPin(triggerPin), _convertCm(convertCm), - _stream(stream) {} + _stream(stream) { + setMaxRetries(MAXBOTIX_DEFAULT_MEASUREMENT_RETRIES); +} // Delegating constructor MaxBotixSonar::MaxBotixSonar(Stream& stream, int8_t powerPin, int8_t triggerPin, @@ -87,21 +89,7 @@ bool MaxBotixSonar::wake() { MS_DBG(i, '-', headerLine); } // Clear anything else out of the stream buffer - auto junkChars = static_cast(_stream->available()); - if (junkChars) { - MS_DBG(F("Dumping"), junkChars, - F("characters from MaxBotix stream buffer")); - for (uint8_t i = 0; i < junkChars; i++) { -#ifdef MS_MAXBOTIXSONAR_DEBUG - MS_SERIAL_OUTPUT.print(_stream->read()); -#else - _stream->read(); -#endif - } -#ifdef MS_MAXBOTIXSONAR_DEBUG - PRINTOUT(" "); -#endif - } + dumpBuffer(); return true; } @@ -113,7 +101,31 @@ bool MaxBotixSonar::sleep() { while (_stream->available()) { _stream->read(); } _stream->flush(); return Sensor::sleep(); -}; +} + + +bool MaxBotixSonar::startSingleMeasurement() { + // Sensor::startSingleMeasurement() checks that if it's awake/active and + // sets the timestamp and status bits. If it returns false, there's no + // reason to go on. + if (!Sensor::startSingleMeasurement()) return false; + + dumpBuffer(); // dump anything stuck in the stream buffer + + // If the sonar is running on a trigger, activate it + if (_triggerPin >= 0) { + MS_DBG(F(" Triggering Sonar with"), _triggerPin); + digitalWrite(_triggerPin, HIGH); + delayMicroseconds(30); // Trigger must be held high for >20 µs + digitalWrite(_triggerPin, LOW); + + // Update the time that a measurement was requested + // For MaxBotix, we're actively triggering so mark time as now + _millisMeasurementRequested = millis(); + } + + return true; +} bool MaxBotixSonar::addSingleMeasurementResult() { @@ -126,7 +138,38 @@ bool MaxBotixSonar::addSingleMeasurementResult() { bool success = false; int16_t result = MS_INVALID_VALUE; - // Clear anything out of the stream buffer + MS_DBG(getSensorNameAndLocation(), F("is reporting:")); + + // Ask for a result and let the stream timeout be our "wait" for the + // measurement + result = static_cast(_stream->parseInt()); + _stream->read(); // Throw away the carriage return + MS_DBG(F(" Sonar Range:"), result); + + // Check if result is valid + // If it cannot obtain a result, the sonar sends a value just above its max + // range. If the result becomes garbled or the sonar is disconnected, + // parseInt returns 0. These sensors cannot read 0, so we know 0 is bad. + if (result <= 0 || result >= _maxRange) { + MS_DBG(F(" Bad or Suspicious Result, Retry #"), _currentRetries + 1); + result = MS_INVALID_VALUE; + } else { + MS_DBG(F(" Good result found")); + // convert result from cm to mm if convertCm is set to true + if (_convertCm) { result *= 10; } + success = true; + verifyAndAddMeasurementResult(HRXL_VAR_NUM, result); + } + + // dump anything left in the stream buffer + dumpBuffer(); + + // Return success value when finished + return finalizeMeasurementAttempt(success); +} + + +void MaxBotixSonar::dumpBuffer() { auto junkChars = static_cast(_stream->available()); if (junkChars) { MS_DBG(F("Dumping"), junkChars, @@ -142,50 +185,4 @@ bool MaxBotixSonar::addSingleMeasurementResult() { PRINTOUT(" "); #endif } - - MS_DBG(getSensorNameAndLocation(), F("is reporting:")); - - uint8_t rangeAttempts = 0; - while (!success && rangeAttempts < 25) { - /// @todo unify retries with other sensors? - // If the sonar is running on a trigger, activating the trigger - // should in theory happen within the startSingleMeasurement - // function. Because we're really taking up to 25 measurements - // for each "single measurement" until a valid value is returned - // and the measurement time is <166ms, we'll actually activate - // the trigger here. - if (_triggerPin >= 0) { - MS_DBG(F(" Triggering Sonar with"), _triggerPin); - digitalWrite(_triggerPin, HIGH); - delayMicroseconds(30); // Trigger must be held high for >20 µs - digitalWrite(_triggerPin, LOW); - } - - // Immediately ask for a result and let the stream timeout be our - // "wait" for the measurement. - result = static_cast(_stream->parseInt()); - _stream->read(); // To throw away the carriage return - MS_DBG(F(" Sonar Range:"), result); - rangeAttempts++; - - // If it cannot obtain a result, the sonar is supposed to send a - // value just above its max range. If the result becomes garbled or - // the sonar is disconnected, the parseInt function returns 0. - // Luckily, these sensors are not capable of reading 0, so we also - // know the 0 value is bad. - if (result <= 0 || result >= _maxRange) { - MS_DBG(F(" Bad or Suspicious Result, Retry Attempt #"), - rangeAttempts); - result = MS_INVALID_VALUE; - } else { - MS_DBG(F(" Good result found")); - // convert result from cm to mm if convertCm is set to true - if (_convertCm == true) { result *= 10; } - success = true; - } - } - if (success) { verifyAndAddMeasurementResult(HRXL_VAR_NUM, result); } - - // Return success value when finished - return finalizeMeasurementAttempt(success); } diff --git a/src/sensors/MaxBotixSonar.h b/src/sensors/MaxBotixSonar.h index f158c00d2..15feaa074 100644 --- a/src/sensors/MaxBotixSonar.h +++ b/src/sensors/MaxBotixSonar.h @@ -85,6 +85,11 @@ * - [MaxTemp Datasheet](https://github.com/EnviroDIY/ModularSensors/wiki/Sensor-Datasheets/Maxbotix-HR-MaxTemp-Datasheet.pdf) * - [Wiring Guide](https://github.com/EnviroDIY/ModularSensors/wiki/Sensor-Datasheets/Maxbotix-MaxSonar-MB7954-Datasheet-ConnectWire.pdf) * + * @section sensor_maxbotix_flags Build flags + * - ```-D MAXBOTIX_DEFAULT_MEASUREMENT_RETRIES=25``` + * - Changes the default number of measurement retries when a measurement + * fails. The default value is 25. This sensor fails frequently. + * * @section sensor_maxbotix_ctor Sensor Constructor * {{ @ref MaxBotixSonar::MaxBotixSonar }} * @@ -123,6 +128,34 @@ /** @ingroup sensor_maxbotix */ /**@{*/ +/** + * @anchor sensor_maxbotix_config + * @name Sensor Configuration + * Build-time configuration for the MaxBotix HRXL MaxSonar + */ +/**@{*/ +#if !defined(MAXBOTIX_DEFAULT_MEASUREMENT_RETRIES) || defined(DOXYGEN) +/** + * @brief Default number of measurement retries for MaxBotix sensors + * + * The default number of times to retry a measurement when it fails. The + * MaxBotix sensors can sometimes return invalid readings (0 or values above + * the maximum range), especially in challenging environmental conditions. + * Higher values provide better reliability but may increase total measurement + * time on sensor failures. This can be set at runtime for individual sensors + * and the default can be overridden at compile time with `-D + * MAXBOTIX_DEFAULT_MEASUREMENT_RETRIES=value` + */ +#define MAXBOTIX_DEFAULT_MEASUREMENT_RETRIES 25 +#endif + +// Static assert to validate measurement retries is reasonable +static_assert(MAXBOTIX_DEFAULT_MEASUREMENT_RETRIES >= 0 && + MAXBOTIX_DEFAULT_MEASUREMENT_RETRIES <= 50, + "MAXBOTIX_DEFAULT_MEASUREMENT_RETRIES must be between 0 and 50 " + "(reasonable measurement retry range)"); +/**@}*/ + /** * @anchor sensor_maxbotix_var_counts * @name Sensor Variable Counts @@ -255,6 +288,7 @@ class MaxBotixSonar : public Sensor { // override to empty and flush the stream bool sleep() override; + bool startSingleMeasurement() override; bool addSingleMeasurementResult() override; private: @@ -270,6 +304,14 @@ class MaxBotixSonar : public Sensor { * Maxbotix sensor. */ Stream* _stream; + + /** + * @brief Helper function to dump any available characters from the stream buffer + * + * Reads and discards all available characters from the stream to clear the buffer. + * Optionally prints debugging output showing the discarded characters. + */ + void dumpBuffer(); }; From 9627e6aca15be77a73e103d6990b9372394ab5d3 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Fri, 6 Mar 2026 16:34:37 -0500 Subject: [PATCH 485/533] Clarify retries, simplify bit check for pin state Signed-off-by: Sara Damiano --- src/SensorBase.cpp | 13 +++++++------ src/SensorBase.h | 3 +++ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/SensorBase.cpp b/src/SensorBase.cpp index c267a5b5f..161048919 100644 --- a/src/SensorBase.cpp +++ b/src/SensorBase.cpp @@ -769,8 +769,6 @@ bool Sensor::finalizeMeasurementAttempt(bool wasSuccessful) { _millisMeasurementRequested = 0; // Unset the status bits for a measurement request (bits 5 & 6) clearStatusBits(MEASUREMENT_ATTEMPTED, MEASUREMENT_SUCCESSFUL); - // Bump the number of attempted retries - _currentRetries++; if (wasSuccessful || _currentRetries >= _maxRetries) { // Bump the number of completed measurement attempts - we've succeeded @@ -778,7 +776,11 @@ bool Sensor::finalizeMeasurementAttempt(bool wasSuccessful) { _completedMeasurements++; // Reset the number of retries made for the next measurement attempt _currentRetries = 0; + } else { + // Bump the number of attempted retries + _currentRetries++; } + // Return the input parameter so it's easy to use this in a return statement // to pass forward a value return wasSuccessful; @@ -790,8 +792,7 @@ bool Sensor::isPinLow(int8_t pin) { if (pin < 0) { return false; // Unconfigured pins are treated as not LOW } - auto powerBitNumber = - static_cast(__builtin_ctz(digitalPinToBitMask(pin))); - return bitRead(*portInputRegister(digitalPinToPort(pin)), powerBitNumber) == - LOW; + uint8_t bitMask = digitalPinToBitMask(pin); + uint8_t portValue = *portInputRegister(digitalPinToPort(pin)); + return (portValue & bitMask) == 0; } diff --git a/src/SensorBase.h b/src/SensorBase.h index 8b9d7679b..d52886da3 100644 --- a/src/SensorBase.h +++ b/src/SensorBase.h @@ -768,6 +768,9 @@ class Sensor { uint8_t _currentRetries = 0; /** * @brief The maximum number of retries allowed if a measurement fails. + * Setting max retries to 1 means that if a measurement fails, it will be + * retried once. Setting max retries to 0 means that if a measurement + * fails, it will not be retried at all. */ uint8_t _maxRetries = 1; /** From 0d9596f1967eeb8d75030954cdd4f80bc07267cd Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Fri, 6 Mar 2026 16:35:11 -0500 Subject: [PATCH 486/533] Made explicit Signed-off-by: Sara Damiano --- src/sensors/AnalogVoltageBase.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/sensors/AnalogVoltageBase.h b/src/sensors/AnalogVoltageBase.h index d992f81d1..fa247803f 100644 --- a/src/sensors/AnalogVoltageBase.h +++ b/src/sensors/AnalogVoltageBase.h @@ -57,8 +57,8 @@ class AnalogVoltageBase { * @param voltageMultiplier The voltage multiplier for any voltage dividers * @param supplyVoltage The supply/operating voltage for the analog system */ - AnalogVoltageBase(float voltageMultiplier = 1.0f, - float supplyVoltage = OPERATING_VOLTAGE) + explicit AnalogVoltageBase(float voltageMultiplier = 1.0f, + float supplyVoltage = OPERATING_VOLTAGE) : // NOTE: These clamps are intentionally silent — Serial/MS_DBG is NOT // safe to call during construction (the Serial object may not be // initialized yet on Arduino targets). Use setSupplyVoltage() at From 2d53ac0454297b20ccbf163a16d9b5e5c2728e07 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Fri, 6 Mar 2026 16:35:32 -0500 Subject: [PATCH 487/533] Shorten interval logic Signed-off-by: Sara Damiano --- src/sensors/ANBpH.cpp | 40 +++++++++++++++------------------------- 1 file changed, 15 insertions(+), 25 deletions(-) diff --git a/src/sensors/ANBpH.cpp b/src/sensors/ANBpH.cpp index 0c9ce7d76..993b38d0c 100644 --- a/src/sensors/ANBpH.cpp +++ b/src/sensors/ANBpH.cpp @@ -146,31 +146,21 @@ bool ANBpH::setup() { int16_t originalInterval = _loggingIntervalMinutes; // Store original for debug messages #endif - if (_powerPin >= 0) { // Cycled power - if (_loggingIntervalMinutes == 0) { - programmedInterval = 10; - _loggingIntervalMinutes = 10; // Update the stored value - MS_DBG(F("Requested interval of"), originalInterval, - F("minutes is invalid when power is cycled; using"), - programmedInterval, F("minutes.")); - } else if (_loggingIntervalMinutes < 10) { - programmedInterval = 10; - _loggingIntervalMinutes = 10; // Update the stored value - MS_DBG(F("Requested interval of"), originalInterval, - F("minutes is too short; using"), programmedInterval, - F("minutes.")); - } else if (_loggingIntervalMinutes > 240) { - programmedInterval = 240; - _loggingIntervalMinutes = 240; // Update the stored value - MS_DBG(F("Requested interval of"), originalInterval, - F("minutes is too long; using"), programmedInterval, - F("minutes.")); - } - } else { // Always-powered (powerPin == -1) - if (_loggingIntervalMinutes == 0) { - programmedInterval = 0; // Allow 0 for always-on mode - // No need to change _loggingIntervalMinutes - } else if (_loggingIntervalMinutes < 10) { + // Handle special case: interval == 0 when power is cycled + if (_powerPin >= 0 && _loggingIntervalMinutes == 0) { + programmedInterval = 10; + _loggingIntervalMinutes = 10; // Update the stored value + MS_DBG(F("Requested interval of"), originalInterval, + F("minutes is invalid when power is cycled; using"), + programmedInterval, F("minutes.")); + } else if (_powerPin < 0 && _loggingIntervalMinutes == 0) { + programmedInterval = 0; // Allow 0 for always-on mode + // No need to change _loggingIntervalMinutes + } else { + // Shared validation for <10 and >240 limits + programmedInterval = + _loggingIntervalMinutes; // Start with original value + if (_loggingIntervalMinutes < 10) { programmedInterval = 10; _loggingIntervalMinutes = 10; // Update the stored value MS_DBG(F("Requested interval of"), originalInterval, From 780f09b94143d058c891a56e7a56f8bd405a99b8 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Fri, 6 Mar 2026 16:35:58 -0500 Subject: [PATCH 488/533] Move include Signed-off-by: Sara Damiano --- src/sensors/AOSongAM2315.cpp | 1 + src/sensors/AOSongAM2315.h | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sensors/AOSongAM2315.cpp b/src/sensors/AOSongAM2315.cpp index a2232b04c..07141cac2 100644 --- a/src/sensors/AOSongAM2315.cpp +++ b/src/sensors/AOSongAM2315.cpp @@ -9,6 +9,7 @@ */ #include "AOSongAM2315.h" +#include // The constructor - because this is I2C, only need the power pin diff --git a/src/sensors/AOSongAM2315.h b/src/sensors/AOSongAM2315.h index bbe5e6e41..0db462251 100644 --- a/src/sensors/AOSongAM2315.h +++ b/src/sensors/AOSongAM2315.h @@ -75,7 +75,6 @@ // Include other in-library and external dependencies #include "VariableBase.h" #include "SensorBase.h" -#include /** @ingroup sensor_am2315 */ /**@{*/ From bc283027421cf3c22fc5241d425b3f081a8f89b7 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Fri, 6 Mar 2026 16:36:48 -0500 Subject: [PATCH 489/533] Fix debugging Signed-off-by: Sara Damiano --- src/sensors/BoschBME280.cpp | 1 + src/sensors/BoschBMP3xx.cpp | 2 +- src/sensors/EverlightALSPT19.cpp | 2 +- src/sensors/ProcessorStats.cpp | 3 +++ 4 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/sensors/BoschBME280.cpp b/src/sensors/BoschBME280.cpp index 67ebae87c..4d8d5ddbb 100644 --- a/src/sensors/BoschBME280.cpp +++ b/src/sensors/BoschBME280.cpp @@ -55,6 +55,7 @@ bool BoschBME280::setup() { ntries++; } if (!success) { + MS_DBG(getSensorNameAndLocation(), F("setup failed after 5 attempts")); // Set the status error bit (bit 7) setStatusBit(ERROR_OCCURRED); // UN-set the set-up bit (bit 0) since setup failed! diff --git a/src/sensors/BoschBMP3xx.cpp b/src/sensors/BoschBMP3xx.cpp index f184da3b9..e0bde272e 100644 --- a/src/sensors/BoschBMP3xx.cpp +++ b/src/sensors/BoschBMP3xx.cpp @@ -124,7 +124,7 @@ bool BoschBMP3xx::setup() { _standbyEnum = static_cast(static_cast(_standbyEnum) + 1); #if defined(MS_DEBUGGING_STD) - _timeStandby_ms = 5.0f * (1U << static_cast(_standbyEnum)); + timeStandby_ms = 5.0f * (1U << static_cast(_standbyEnum)); #endif MS_DBG(_standbyEnum, timeStandby_ms, static_cast(max_measurementTime_us / 1000)); diff --git a/src/sensors/EverlightALSPT19.cpp b/src/sensors/EverlightALSPT19.cpp index 628028ec6..ed55ea91d 100644 --- a/src/sensors/EverlightALSPT19.cpp +++ b/src/sensors/EverlightALSPT19.cpp @@ -71,7 +71,7 @@ bool EverlightALSPT19::setup() { } } else { MS_DBG(getSensorNameAndLocation(), - F("No analog voltage reader to initialize")); + F("Unexpected: analog voltage reader is null")); } return sensorSetupSuccess && analogVoltageReaderSuccess; diff --git a/src/sensors/ProcessorStats.cpp b/src/sensors/ProcessorStats.cpp index c2c0f9176..908537ff6 100644 --- a/src/sensors/ProcessorStats.cpp +++ b/src/sensors/ProcessorStats.cpp @@ -56,6 +56,9 @@ ProcessorStats::ProcessorStats(const char* version, } else { _batteryPin = 33; } + } else { + MS_DBG(F( + "No Sodaq Autonomo version specified - using default battery pin")); } #endif } From a55c5bb045e3f3340bdf179b25707594ac07c810 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Fri, 6 Mar 2026 16:38:34 -0500 Subject: [PATCH 490/533] Clarify some comments Signed-off-by: Sara Damiano --- src/sensors/KellerParent.cpp | 2 +- src/sensors/KnownProcessors.h | 24 ++++++++---------------- src/sensors/MeterTeros11.cpp | 2 +- src/sensors/SensirionSHT4x.h | 4 ++-- src/sensors/TEConnectivityMS5837.cpp | 11 ++++------- src/sensors/TEConnectivityMS5837.h | 2 +- 6 files changed, 17 insertions(+), 28 deletions(-) diff --git a/src/sensors/KellerParent.cpp b/src/sensors/KellerParent.cpp index c163d0974..2d3cfc210 100644 --- a/src/sensors/KellerParent.cpp +++ b/src/sensors/KellerParent.cpp @@ -78,7 +78,7 @@ bool KellerParent::sleep() { while (_stream->available()) { _stream->read(); } _stream->flush(); return Sensor::sleep(); -}; +} bool KellerParent::addSingleMeasurementResult() { diff --git a/src/sensors/KnownProcessors.h b/src/sensors/KnownProcessors.h index d4596b794..0496ff65b 100644 --- a/src/sensors/KnownProcessors.h +++ b/src/sensors/KnownProcessors.h @@ -38,26 +38,26 @@ * @def BUILT_IN_ALS_POWER_PIN * @brief The digital pin controlling power to the built-in ambient light sensor * (ALS) on EnviroDIY boards. - * @note Set to -1 when the ALS is always powered or when no built-in ALS is - * available on the board. + * @note Set to -1 when the ALS is always powered. *Leave undefined* when no + * built-in ALS is available on the board. * * @def BUILT_IN_ALS_DATA_PIN * @brief The analog pin connected to the built-in ambient light sensor (ALS) * on EnviroDIY boards. - * @note The data pin varies by board model and version. Set to -1 when no - * built-in ALS is available on the board. + * @note The data pin varies by board model and version. *Leave undefined* when + * no built-in ALS is available on the board. * * @def BUILT_IN_ALS_SUPPLY_VOLTAGE * @brief The supply voltage for the built-in ambient light sensor (ALS) on * EnviroDIY boards, in volts. - * @note Typically matches the board's operating voltage. Set to -1 when no - * built-in ALS is available on the board. + * @note Typically matches the board's operating voltage. *Leave undefined* when + * no built-in ALS is available on the board. * * @def BUILT_IN_ALS_LOADING_RESISTANCE * @brief The loading resistance for the built-in ambient light sensor (ALS) * on EnviroDIY boards, in kΩ. - * @note The loading resistance affects light measurement calculations. Set to - * -1 when no built-in ALS is available on the board. + * @note The loading resistance affects light measurement calculations. *Leave + * undefined* when no built-in ALS is available on the board. */ // EnviroDIY boards @@ -66,26 +66,18 @@ #define OPERATING_VOLTAGE 3.3 #define BATTERY_PIN A6 #define BATTERY_MULTIPLIER 4.7 // for v0.5 and later -/// @brief The power pin for the ALS on the EnviroDIY Mayfly v1.x #define BUILT_IN_ALS_POWER_PIN -1 -/// @brief The data pin for the ALS on the EnviroDIY Mayfly v1.x #define BUILT_IN_ALS_DATA_PIN A4 -/// @brief The supply voltage for the ALS on the EnviroDIY Mayfly v1.x #define BUILT_IN_ALS_SUPPLY_VOLTAGE 3.3 -/// @brief The loading resistance for the ALS on the EnviroDIY Mayfly v1.x #define BUILT_IN_ALS_LOADING_RESISTANCE 10 #elif defined(ENVIRODIY_STONEFLY_M4) #define LOGGER_BOARD "EnviroDIY Stonefly" #define OPERATING_VOLTAGE 3.3 #define BATTERY_PIN A9 #define BATTERY_MULTIPLIER 4.7 -/// @brief The power pin for the ALS on the EnviroDIY Stonefly v0.x #define BUILT_IN_ALS_POWER_PIN -1 -/// @brief The data pin for the ALS on the EnviroDIY Stonefly v0.x #define BUILT_IN_ALS_DATA_PIN A8 -/// @brief The supply voltage for the ALS on the EnviroDIY Stonefly v0.x #define BUILT_IN_ALS_SUPPLY_VOLTAGE 3.3 -/// @brief The loading resistance for the ALS on the EnviroDIY Stonefly v0.x #define BUILT_IN_ALS_LOADING_RESISTANCE 10 // Sodaq boards diff --git a/src/sensors/MeterTeros11.cpp b/src/sensors/MeterTeros11.cpp index 6f25fcfb9..c8690e3b2 100644 --- a/src/sensors/MeterTeros11.cpp +++ b/src/sensors/MeterTeros11.cpp @@ -43,7 +43,7 @@ bool MeterTeros11::getResults(bool verify_crc) { // Calculate the VWC from EA using the Topp equation // range check - if (ea < 0 || ea > 350) { + if (ea != MS_INVALID_VALUE && (ea < 0 || ea > 350)) { MS_DBG(F("WARNING: Ea results out of range (0-350)! Cannot calculate " "VWC")); ea = MS_INVALID_VALUE; diff --git a/src/sensors/SensirionSHT4x.h b/src/sensors/SensirionSHT4x.h index ee0498514..3ef511445 100644 --- a/src/sensors/SensirionSHT4x.h +++ b/src/sensors/SensirionSHT4x.h @@ -161,8 +161,8 @@ */ /**@{*/ /** - * @brief Decimal places in string representation; humidity should have 2 (0.01 - * °C). + * @brief Decimal places in string representation; temperature should have 2 + * (0.01 °C). * * @note This resolution is some-what silly in light of the ± 0.2°C accuracy. */ diff --git a/src/sensors/TEConnectivityMS5837.cpp b/src/sensors/TEConnectivityMS5837.cpp index 7f63b48ea..d3effe3f7 100644 --- a/src/sensors/TEConnectivityMS5837.cpp +++ b/src/sensors/TEConnectivityMS5837.cpp @@ -61,15 +61,13 @@ TEConnectivityMS5837::TEConnectivityMS5837(int8_t powerPin, MS5837Model model, String TEConnectivityMS5837::getSensorName() { - auto modelEnum = static_cast(_model); - String modelStr = F("TEConnectivityMS5837_"); + auto modelEnum = static_cast(_model); switch (modelEnum) { - case MS5837Model::MS5837_02BA: modelStr += F("02BA"); break; - case MS5837Model::MS5837_30BA: modelStr += F("30BA"); break; + case MS5837Model::MS5837_02BA: return F("TEConnectivityMS5837_02BA"); + case MS5837Model::MS5837_30BA: return F("TEConnectivityMS5837_30BA"); case MS5837Model::MS5803_01BA: return F("TEConnectivityMS5803_01BA"); - default: modelStr += F("Unknown"); break; + default: return F("TEConnectivityMS5837_Unknown"); } - return modelStr; } @@ -83,7 +81,6 @@ bool TEConnectivityMS5837::setup() { Sensor::setup(); // this will set pin modes and the setup status bit // This sensor needs power for setup! - delay(10); bool wasOn = checkPowerOn(); if (!wasOn) { powerUp(); } waitForWarmUp(); diff --git a/src/sensors/TEConnectivityMS5837.h b/src/sensors/TEConnectivityMS5837.h index 60659c585..152896c48 100644 --- a/src/sensors/TEConnectivityMS5837.h +++ b/src/sensors/TEConnectivityMS5837.h @@ -496,7 +496,7 @@ class TEConnectivityMS5837 : public Sensor { private: /** - * @brief Private internal reference to the MS5837 object. + * @brief Private internal MS5837 object instance. */ MS5837 MS5837_internal; /** From a38d2bbeeaea6ff1e08ac8d2fc213c190b4b3ec8 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Fri, 6 Mar 2026 16:53:12 -0500 Subject: [PATCH 491/533] Rename initial/remaining short intervals and transmissions to startup measurements / transmissions Signed-off-by: Sara Damiano --- ChangeLog.md | 7 ++- .../EnviroDIY_Monitoring_Kit.ino | 2 +- examples/menu_a_la_carte/menu_a_la_carte.ino | 2 +- src/LoggerBase.cpp | 34 +++++++------- src/LoggerBase.h | 45 +++++++++--------- src/dataPublisherBase.cpp | 31 ++++++------- src/dataPublisherBase.h | 32 ++++++------- .../MonitorMyWatershedPublisher.cpp | 30 ++++++------ src/publishers/MonitorMyWatershedPublisher.h | 46 +++++++++---------- 9 files changed, 115 insertions(+), 114 deletions(-) diff --git a/ChangeLog.md b/ChangeLog.md index 60612c320..4bc403ce5 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -130,8 +130,7 @@ There is a shell file and typedef to maintain backwards compatibility. #### All Publishers -- Changed capitalization of `setInitialShortIntervals(#)` function - - Previously the 'i' of initial was not capitalized. +- Renamed `setinitialShortIntervals(#)` to `setStartupMeasurements(#)`. - The old `setinitialShortIntervals` remains available via compatibility shim in LoggerBase.h, so existing code is unaffected. #### Loggers and Variable Arrays @@ -204,6 +203,10 @@ This affects the following classes: - TurnerCyclops - TurnerTurbidityPlus +#### Features for Publishers + +- Added setters/getters for the number of startup transmissions. + #### Library-Wide - Added a configuration define for MS_INVALID_VALUE and replaced all occurrences of the standard -9999 with this define. diff --git a/examples/EnviroDIY_Monitoring_Kit/EnviroDIY_Monitoring_Kit.ino b/examples/EnviroDIY_Monitoring_Kit/EnviroDIY_Monitoring_Kit.ino index 051fed5ec..8089dd5d8 100644 --- a/examples/EnviroDIY_Monitoring_Kit/EnviroDIY_Monitoring_Kit.ino +++ b/examples/EnviroDIY_Monitoring_Kit/EnviroDIY_Monitoring_Kit.ino @@ -429,7 +429,7 @@ void setup() { PRINTOUT(F("Setting logging interval to"), loggingInterval, F("minutes")); dataLogger.setLoggingInterval(loggingInterval); PRINTOUT(F("Setting number of initial 1 minute intervals to 10")); - dataLogger.setInitialShortIntervals(10); + dataLogger.setStartupMeasurements(10); // Attach the variable array to the logger PRINTOUT(F("Attaching the variable array")); dataLogger.setVariableArray(&varArray); diff --git a/examples/menu_a_la_carte/menu_a_la_carte.ino b/examples/menu_a_la_carte/menu_a_la_carte.ino index e89a5af1e..9bca04add 100644 --- a/examples/menu_a_la_carte/menu_a_la_carte.ino +++ b/examples/menu_a_la_carte/menu_a_la_carte.ino @@ -3879,7 +3879,7 @@ void setup() { PRINTOUT(F("Setting logging interval to"), loggingInterval, F("minutes")); dataLogger.setLoggingInterval(loggingInterval); PRINTOUT(F("Setting number of initial 1 minute intervals to 10")); - dataLogger.setInitialShortIntervals(10); + dataLogger.setStartupMeasurements(10); // Attach the variable array to the logger PRINTOUT(F("Attaching the variable array")); dataLogger.setVariableArray(&varArray); diff --git a/src/LoggerBase.cpp b/src/LoggerBase.cpp index ea6ec203a..1e4f1b9c8 100644 --- a/src/LoggerBase.cpp +++ b/src/LoggerBase.cpp @@ -195,9 +195,9 @@ void Logger::setLoggingInterval(int16_t loggingIntervalMinutes) { } -// Sets the number of initial short intervals -void Logger::setInitialShortIntervals(int16_t initialShortIntervals) { - _remainingShortIntervals = initialShortIntervals; +// Sets the number of startup measurements +void Logger::setStartupMeasurements(int16_t startupMeasurements) { + _startupMeasurements = startupMeasurements; } @@ -671,7 +671,7 @@ bool Logger::checkInterval() { bool retval; uint32_t checkTime = static_cast(getNowLocalEpoch()); int16_t interval = _loggingIntervalMinutes; - if (_remainingShortIntervals > 0) { + if (_startupMeasurements > 0) { // log the first few samples at an interval of 1 minute so that // operation can be quickly verified in the field interval = 1; @@ -703,15 +703,15 @@ bool Logger::checkInterval() { static_cast(Logger::markedLocalUnixTime)); MS_DBG(F("Time to log!")); #if MS_LOGGERBASE_BUTTON_BENCH_TEST == 0 - if ((_remainingShortIntervals > 0) && (!testing)) { + if ((_startupMeasurements > 0) && (!testing)) { #else - if ((_remainingShortIntervals > 0)) { + if ((_startupMeasurements > 0)) { #endif - MS_DBG(F("Within initial 1-minute intervals; "), - _remainingShortIntervals, F("left.")); + MS_DBG(F("Within initial 1-minute measurements; "), + _startupMeasurements, F("left.")); // once we've marked the time, we need to decrement the remaining - // short intervals by one. (IFF not in "log now" testing mode.) - _remainingShortIntervals -= 1; + // startup measurements by one. (IFF not in "log now" testing mode.) + _startupMeasurements -= 1; } retval = true; } else { @@ -725,9 +725,9 @@ bool Logger::checkInterval() { // This checks to see if the MARKED time is an even interval of the logging rate bool Logger::checkMarkedInterval() { int16_t interval = _loggingIntervalMinutes; - // If we're within the range of our initial short intervals, we're logging, + // If we're within the range of our startup measurements, we're logging, // then set the interval to 1. - if (_remainingShortIntervals > 0) { interval = 1; } + if (_startupMeasurements > 0) { interval = 1; } bool retval; MS_DBG( @@ -739,11 +739,11 @@ bool Logger::checkMarkedInterval() { if (Logger::markedLocalUnixTime != 0 && (Logger::markedLocalUnixTime % (interval * 60) == 0)) { MS_DBG(F("Time to log!")); - // De-increment the number of short intervals after marking - if (_remainingShortIntervals > 0) { - MS_DBG(F("Within initial 1-minute intervals. There are "), - _remainingShortIntervals, F("left.")); - _remainingShortIntervals -= 1; + // De-increment the number of startup measurements after marking + if (_startupMeasurements > 0) { + MS_DBG(F("Within startup measurements. There are "), + _startupMeasurements, F("left.")); + _startupMeasurements -= 1; } retval = true; } else { diff --git a/src/LoggerBase.h b/src/LoggerBase.h index 7f9f00bcc..0de3c678a 100644 --- a/src/LoggerBase.h +++ b/src/LoggerBase.h @@ -223,36 +223,35 @@ class Logger { } /** - * @brief Set the number of initial datapoints to log (and publish) at - * 1-minute intervals before beginning logging on the regular logging - * interval. + * @brief Set the number of startup measurements to take at 1-minute + * intervals before beginning logging on the regular logging interval. * - * @param initialShortIntervals The number of 1-minute intervals. This - * number of transmissions will be performed with an interval of 1 minute - * regardless of the programmed interval. Useful for fast field - * verification. + * Whether the data is published or not depends on the settings of the data + * publishers. + * + * @param startupMeasurements The number of measurements to take at + * 1-minute intervals regardless of the programmed interval. Useful for + * fast field verification. */ - void setInitialShortIntervals(int16_t initialShortIntervals); + void setStartupMeasurements(int16_t startupMeasurements); /** - * @brief Get the number of 1-minute intervals at the start before logging - * on the regular logging interval + * @brief Get the remaining number of startup measurements * - * @return The number of 1-minute intervals at the start before logging - * on the regular logging interval + * @return The remaining number of startup measurements */ - int16_t getInitialShortIntervals() { - return _remainingShortIntervals; + int16_t getStartupMeasurements() { + return _startupMeasurements; } // Backwards-compatibility shims - /// @copydoc setInitialShortIntervals - /// @m_deprecated_since{0,38,0} use setInitialShortIntervals - void setinitialShortIntervals(int16_t initialShortIntervals) { - setInitialShortIntervals(initialShortIntervals); + /// @copydoc setStartupMeasurements + /// @m_deprecated_since{0,38,0} use setStartupMeasurements + void setStartupMeasurements(int16_t initialShortIntervals) { + setStartupMeasurements(initialShortIntervals); } - /// @copydoc getInitialShortIntervals - /// @m_deprecated_since{0,38,0} use getInitialShortIntervals + /// @copydoc getStartupMeasurements + /// @m_deprecated_since{0,38,0} use getStartupMeasurements int16_t getinitialShortIntervals() { - return getInitialShortIntervals(); + return getStartupMeasurements(); } /** @@ -474,10 +473,10 @@ class Logger { */ int16_t _loggingIntervalMinutes = 5; /** - * @brief The initial number of samples to log at an interval of 1 minute + * @brief The number of startup measurements to log at 1-minute intervals * for fast field verification */ - int16_t _remainingShortIntervals = 5; + int16_t _startupMeasurements = 5; /** * @brief Digital pin number on the mcu controlling the SD card slave * select. diff --git a/src/dataPublisherBase.cpp b/src/dataPublisherBase.cpp index f99a487bb..ff1b4037c 100644 --- a/src/dataPublisherBase.cpp +++ b/src/dataPublisherBase.cpp @@ -24,19 +24,19 @@ const char* dataPublisher::hostHeader = "\r\nHost: "; // Primary constructor dataPublisher::dataPublisher(Logger& baseLogger, Client* inClient, - int sendEveryX, uint8_t initialTransmissions) + int sendEveryX, uint8_t startupTransmissions) : _baseLogger(&baseLogger), _inClient(inClient), _sendEveryX(sendEveryX), - _initialTransmissionsRemaining( - initialTransmissions < 1 ? 1 : initialTransmissions) { + _startupTransmissions(startupTransmissions < 1 ? 1 + : startupTransmissions) { _baseModem = _baseLogger->registerDataPublisher(this); // register self with logger } // Constructors dataPublisher::dataPublisher(Logger& baseLogger, int sendEveryX, - uint8_t initialTransmissions) - : dataPublisher(baseLogger, nullptr, sendEveryX, initialTransmissions) {} + uint8_t startupTransmissions) + : dataPublisher(baseLogger, nullptr, sendEveryX, startupTransmissions) {} // Default constructor with explicit initialization to ensure all members are // initialized dataPublisher::dataPublisher() @@ -44,7 +44,7 @@ dataPublisher::dataPublisher() _baseModem(nullptr), _inClient(nullptr), _sendEveryX(1), - _initialTransmissionsRemaining(DEFAULT_INITIAL_TRANSMISSIONS) {} + _startupTransmissions(DEFAULT_STARTUP_TRANSMISSIONS) {} // Sets the client @@ -73,23 +73,22 @@ void dataPublisher::setSendInterval(int sendEveryX) { } -// Get the number of initial transmissions remaining -uint8_t dataPublisher::getInitialTransmissions() const { - return _initialTransmissionsRemaining; +// Get the number of startup transmissions +uint8_t dataPublisher::getStartupTransmissions() const { + return _startupTransmissions; } -// Set the number of initial transmissions to send immediately after logging -void dataPublisher::setInitialTransmissions(uint8_t count) { +// Set the number of startup transmissions to send immediately after logging +void dataPublisher::setStartupTransmissions(uint8_t count) { // Ensure minimum of 1 transmission if (count < 1) { - MS_DBG(F("Initial transmissions count too low, setting to 1")); - _initialTransmissionsRemaining = 1; + MS_DBG(F("Startup transmissions count too low, setting to 1")); + _startupTransmissions = 1; } else { - _initialTransmissionsRemaining = count; + _startupTransmissions = count; } - MS_DBG(F("Initial transmissions remaining set to:"), - _initialTransmissionsRemaining); + MS_DBG(F("Startup transmissions set to:"), _startupTransmissions); } diff --git a/src/dataPublisherBase.h b/src/dataPublisherBase.h index 28d8e6fb2..4cf377389 100644 --- a/src/dataPublisherBase.h +++ b/src/dataPublisherBase.h @@ -54,10 +54,10 @@ // Data publisher defaults /** - * @brief Default number of initial transmissions to send immediately after each + * @brief Default number of startup transmissions to send immediately after each * data point */ -#define DEFAULT_INITIAL_TRANSMISSIONS 5 +#define DEFAULT_STARTUP_TRANSMISSIONS 5 /** * @brief The dataPublisher class is a virtual class used by other publishers to @@ -94,15 +94,15 @@ class dataPublisher { * @param baseLogger The logger supplying the data to be published * @param sendEveryX Interval (in units of the logging interval) between * attempted data transmissions. Not respected by all publishers. - * @param initialTransmissions Number of transmissions to send immediately + * @param startupTransmissions Number of transmissions to send immediately * after each data point is logged, before beginning to cache data and only * transmit every sendEveryX times the logger records data (default: 5). - * This allows faster in-field validation of initial data. Not respected by + * This allows faster in-field validation of startup data. Not respected by * all publishers. */ explicit dataPublisher( Logger& baseLogger, int sendEveryX = 1, - uint8_t initialTransmissions = DEFAULT_INITIAL_TRANSMISSIONS); + uint8_t startupTransmissions = DEFAULT_STARTUP_TRANSMISSIONS); /** * @brief Construct a new data publisher object. * @@ -116,14 +116,14 @@ class dataPublisher { * single TinyGSM modem instance * @param sendEveryX Interval (in units of the logging interval) between * attempted data transmissions. Not respected by all publishers. - * @param initialTransmissions Number of transmissions to send immediately + * @param startupTransmissions Number of transmissions to send immediately * after each data point is logged, before beginning to cache data and only * transmit every sendEveryX times the logger records data (default: 5). - * This allows faster in-field validation of initial data. Not respected by + * This allows faster in-field validation of startup data. Not respected by * all publishers. */ dataPublisher(Logger& baseLogger, Client* inClient, int sendEveryX = 1, - uint8_t initialTransmissions = DEFAULT_INITIAL_TRANSMISSIONS); + uint8_t startupTransmissions = DEFAULT_STARTUP_TRANSMISSIONS); /** * @brief Destroy the data publisher object - no action is taken. */ @@ -151,15 +151,15 @@ class dataPublisher { void setSendInterval(int sendEveryX); /** - * @brief Get the number of initial transmissions remaining + * @brief Get the number of startup transmissions * * @return The number of transmissions that will be sent at one minute * intervals for faster in-field validation */ - uint8_t getInitialTransmissions() const; + uint8_t getStartupTransmissions() const; /** - * @brief Set the number of initial transmissions to send immediately after + * @brief Set the number of startup transmissions to send immediately after * logging * * This controls how many of the first data points are transmitted @@ -167,10 +167,10 @@ class dataPublisher { * transmit every sendEveryX times the logger records data. This allows * faster in-field validation of initial data. * - * @param count Number of initial transmissions (must be 1-255, will be + * @param count Number of startup transmissions (must be 1-255, will be * clamped to this range) */ - void setInitialTransmissions(uint8_t count); + void setStartupTransmissions(uint8_t count); /** * @brief Attach the publisher to a logger. @@ -432,16 +432,16 @@ class dataPublisher { int _sendEveryX = 1; /** - * @brief The number of transmissions remaining to send immediately after + * @brief The number of startup transmissions to send immediately after * logging * * We send each of the first several data points immediately after they are * logged, before beginning to cache data and only transmit every sendEveryX * times the logger records data. This value is user-settable via - * constructor parameter or setInitialTransmissions() and allows faster + * constructor parameter or setStartupTransmissions() and allows faster * in-field validation. */ - uint8_t _initialTransmissionsRemaining = 5; + uint8_t _startupTransmissions = DEFAULT_STARTUP_TRANSMISSIONS; // Basic chunks of HTTP /** diff --git a/src/publishers/MonitorMyWatershedPublisher.cpp b/src/publishers/MonitorMyWatershedPublisher.cpp index 4e05bddf0..071c1be31 100644 --- a/src/publishers/MonitorMyWatershedPublisher.cpp +++ b/src/publishers/MonitorMyWatershedPublisher.cpp @@ -35,9 +35,9 @@ const char* MonitorMyWatershedPublisher::timestampTag = "\",\"timestamp\":"; MonitorMyWatershedPublisher::MonitorMyWatershedPublisher( Logger& baseLogger, Client* inClient, const char* registrationToken, const char* samplingFeatureUUID, int sendEveryX, - uint8_t initialTransmissionsRemaining) + uint8_t startupTransmissions) : dataPublisher(baseLogger, inClient, sendEveryX, - initialTransmissionsRemaining) { + startupTransmissions) { _logBuffer.setNumVariables(_baseLogger->getArrayVarCount()); setHost("monitormywatershed.org"); setPath("/api/data-stream/"); @@ -51,32 +51,32 @@ MonitorMyWatershedPublisher::MonitorMyWatershedPublisher( MonitorMyWatershedPublisher::MonitorMyWatershedPublisher( Logger& baseLogger, const char* registrationToken, const char* samplingFeatureUUID, int sendEveryX, - uint8_t initialTransmissionsRemaining) + uint8_t startupTransmissions) : MonitorMyWatershedPublisher(baseLogger, static_cast(nullptr), registrationToken, samplingFeatureUUID, - sendEveryX, initialTransmissionsRemaining) {} + sendEveryX, startupTransmissions) {} MonitorMyWatershedPublisher::MonitorMyWatershedPublisher( Logger& baseLogger, Client* inClient, const char* registrationToken, - int sendEveryX, uint8_t initialTransmissionsRemaining) + int sendEveryX, uint8_t startupTransmissions) : MonitorMyWatershedPublisher(baseLogger, inClient, registrationToken, nullptr, sendEveryX, - initialTransmissionsRemaining) {} + startupTransmissions) {} MonitorMyWatershedPublisher::MonitorMyWatershedPublisher( Logger& baseLogger, Client* inClient, int sendEveryX, - uint8_t initialTransmissionsRemaining) + uint8_t startupTransmissions) : MonitorMyWatershedPublisher(baseLogger, inClient, nullptr, nullptr, - sendEveryX, initialTransmissionsRemaining) {} + sendEveryX, startupTransmissions) {} MonitorMyWatershedPublisher::MonitorMyWatershedPublisher( Logger& baseLogger, const char* registrationToken, int sendEveryX, - uint8_t initialTransmissionsRemaining) + uint8_t startupTransmissions) : MonitorMyWatershedPublisher(baseLogger, static_cast(nullptr), registrationToken, nullptr, sendEveryX, - initialTransmissionsRemaining) {} + startupTransmissions) {} MonitorMyWatershedPublisher::MonitorMyWatershedPublisher( - Logger& baseLogger, int sendEveryX, uint8_t initialTransmissionsRemaining) + Logger& baseLogger, int sendEveryX, uint8_t startupTransmissions) : MonitorMyWatershedPublisher(baseLogger, static_cast(nullptr), nullptr, nullptr, sendEveryX, - initialTransmissionsRemaining) {} + startupTransmissions) {} MonitorMyWatershedPublisher::MonitorMyWatershedPublisher() : dataPublisher() { // NOTE: _logBuffer is not initialized here because _baseLogger is null // Must call begin(Logger&, ...) before use to properly initialize @@ -237,7 +237,7 @@ bool MonitorMyWatershedPublisher::connectionNeeded() { // the initial log transmissions have not completed (we send every one of // the first five data points immediately for field validation) - bool initialTransmission = _initialTransmissionsRemaining > 0; + bool initialTransmission = _startupTransmissions > 0; return atSendInterval || initialTransmission; } @@ -283,8 +283,8 @@ int16_t MonitorMyWatershedPublisher::publishData(Client* outClient, } } - if (record >= 0 && _initialTransmissionsRemaining > 0) { - _initialTransmissionsRemaining -= 1; + if (record >= 0 && _startupTransmissions > 0) { + _startupTransmissions -= 1; } // do the data buffer flushing if we previously planned to diff --git a/src/publishers/MonitorMyWatershedPublisher.h b/src/publishers/MonitorMyWatershedPublisher.h index 284bb0f1c..94a7f9858 100644 --- a/src/publishers/MonitorMyWatershedPublisher.h +++ b/src/publishers/MonitorMyWatershedPublisher.h @@ -61,16 +61,16 @@ class MonitorMyWatershedPublisher : public dataPublisher { * Monitor My Watershed. * @param sendEveryX Interval (in units of the logging interval) between * attempted data transmissions. - * @param initialTransmissionsRemaining Number of transmissions to send + * @param startupTransmissions Number of transmissions to send * immediately after each data point is logged, before beginning to cache * data and only transmit every sendEveryX times the logger records data - * (default: 5). This allows faster in-field validation of initial data. + * (default: 5). This allows faster in-field validation of startup data. */ MonitorMyWatershedPublisher(Logger& baseLogger, Client* inClient, const char* registrationToken, const char* samplingFeatureUUID, - int sendEveryX = 1, - uint8_t initialTransmissionsRemaining = 5); + int sendEveryX = 1, + uint8_t startupTransmissions = 5); /** * @brief Construct a new Monitor My Watershed Publisher object * @@ -81,16 +81,16 @@ class MonitorMyWatershedPublisher : public dataPublisher { * Monitor My Watershed. * @param sendEveryX Interval (in units of the logging interval) between * attempted data transmissions. - * @param initialTransmissionsRemaining Number of transmissions to send + * @param startupTransmissions Number of transmissions to send * immediately after each data point is logged, before beginning to cache * data and only transmit every sendEveryX times the logger records data - * (default: 5). This allows faster in-field validation of initial data. + * (default: 5). This allows faster in-field validation of startup data. */ MonitorMyWatershedPublisher(Logger& baseLogger, const char* registrationToken, const char* samplingFeatureUUID, - int sendEveryX = 1, - uint8_t initialTransmissionsRemaining = 5); + int sendEveryX = 1, + uint8_t startupTransmissions = 5); /** * @brief Construct a new Monitor My Watershed Publisher object * @@ -102,15 +102,15 @@ class MonitorMyWatershedPublisher : public dataPublisher { * My Watershed. * @param sendEveryX Interval (in units of the logging interval) between * attempted data transmissions. - * @param initialTransmissionsRemaining Number of transmissions to send + * @param startupTransmissions Number of transmissions to send * immediately after each data point is logged, before beginning to cache * data and only transmit every sendEveryX times the logger records data - * (default: 5). This allows faster in-field validation of initial data. + * (default: 5). This allows faster in-field validation of startup data. */ MonitorMyWatershedPublisher(Logger& baseLogger, Client* inClient, const char* registrationToken, - int sendEveryX = 1, - uint8_t initialTransmissionsRemaining = 5); + int sendEveryX = 1, + uint8_t startupTransmissions = 5); /** * @brief Construct a new Monitor My Watershed Publisher object * @@ -120,14 +120,14 @@ class MonitorMyWatershedPublisher : public dataPublisher { * single TinyGSM modem instance * @param sendEveryX Interval (in units of the logging interval) between * attempted data transmissions. - * @param initialTransmissionsRemaining Number of transmissions to send + * @param startupTransmissions Number of transmissions to send * immediately after each data point is logged, before beginning to cache * data and only transmit every sendEveryX times the logger records data - * (default: 5). This allows faster in-field validation of initial data. + * (default: 5). This allows faster in-field validation of startup data. */ MonitorMyWatershedPublisher(Logger& baseLogger, Client* inClient, - int sendEveryX = 1, - uint8_t initialTransmissionsRemaining = 5); + int sendEveryX = 1, + uint8_t startupTransmissions = 5); /** * @brief Construct a new Monitor My Watershed Publisher object * @@ -136,15 +136,15 @@ class MonitorMyWatershedPublisher : public dataPublisher { * My Watershed. * @param sendEveryX Interval (in units of the logging interval) between * attempted data transmissions. - * @param initialTransmissionsRemaining Number of transmissions to send + * @param startupTransmissions Number of transmissions to send * immediately after each data point is logged, before beginning to cache * data and only transmit every sendEveryX times the logger records data - * (default: 5). This allows faster in-field validation of initial data. + * (default: 5). This allows faster in-field validation of startup data. */ MonitorMyWatershedPublisher(Logger& baseLogger, const char* registrationToken, - int sendEveryX = 1, - uint8_t initialTransmissionsRemaining = 5); + int sendEveryX = 1, + uint8_t startupTransmissions = 5); /** * @brief Construct a new Monitor My Watershed Publisher object * @@ -155,14 +155,14 @@ class MonitorMyWatershedPublisher : public dataPublisher { * @param baseLogger The logger supplying the data to be published * @param sendEveryX Interval (in units of the logging interval) between * attempted data transmissions. - * @param initialTransmissionsRemaining Number of transmissions to send + * @param startupTransmissions Number of transmissions to send * immediately after each data point is logged, before beginning to cache * data and only transmit every sendEveryX times the logger records data - * (default: 5). This allows faster in-field validation of initial data. + * (default: 5). This allows faster in-field validation of startup data. */ explicit MonitorMyWatershedPublisher( Logger& baseLogger, int sendEveryX = 1, - uint8_t initialTransmissionsRemaining = 5); + uint8_t startupTransmissions = 5); /** * @brief Construct a new Monitor My Watershed Publisher object with only * default values for all parameters. From ae65f24a13558b5e9efbd194bfd934d0306d1ea2 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Fri, 6 Mar 2026 17:03:39 -0500 Subject: [PATCH 492/533] Fix useHeater logic Signed-off-by: Sara Damiano --- src/sensors/ProcessorStats.h | 4 ++-- src/sensors/SensirionSHT4x.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/sensors/ProcessorStats.h b/src/sensors/ProcessorStats.h index c15249036..558fab86e 100644 --- a/src/sensors/ProcessorStats.h +++ b/src/sensors/ProcessorStats.h @@ -220,10 +220,10 @@ * {{ @ref ProcessorStats_ResetCode::ProcessorStats_ResetCode }} */ /**@{*/ -/// @brief Decimal places in string representation; ram should have 0 - +/// @brief Decimal places in string representation; reset code should have 0 - /// it's just a code #define PROCESSOR_RESET_RESOLUTION 0 -/// @brief Free RAM is stored in sensorValues[1] +/// @brief Reset code is stored in sensorValues[3] #define PROCESSOR_RESET_VAR_NUM 3 /// @brief Variable name in /// [ODM2 controlled vocabulary](http://vocabulary.odm2.org/variablename/); diff --git a/src/sensors/SensirionSHT4x.cpp b/src/sensors/SensirionSHT4x.cpp index f3661ff63..b4458430f 100644 --- a/src/sensors/SensirionSHT4x.cpp +++ b/src/sensors/SensirionSHT4x.cpp @@ -134,7 +134,7 @@ bool SensirionSHT4x::addSingleMeasurementResult() { // The function to run the internal heater before going to sleep bool SensirionSHT4x::sleep() { - if (_useHeater) { return Sensor::sleep(); } + if (!_useHeater) { return Sensor::sleep(); } if (!checkPowerOn()) { return true; } if (_millisSensorActivated == 0) { From 2db8f0a2f09691f3f96c7d6f7a3974111c746b5a Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Fri, 6 Mar 2026 17:04:08 -0500 Subject: [PATCH 493/533] Fix deprecated shim Signed-off-by: Sara Damiano --- src/LoggerBase.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/LoggerBase.h b/src/LoggerBase.h index 0de3c678a..687f85731 100644 --- a/src/LoggerBase.h +++ b/src/LoggerBase.h @@ -245,7 +245,7 @@ class Logger { // Backwards-compatibility shims /// @copydoc setStartupMeasurements /// @m_deprecated_since{0,38,0} use setStartupMeasurements - void setStartupMeasurements(int16_t initialShortIntervals) { + void setinitialShortIntervals(int16_t initialShortIntervals) { setStartupMeasurements(initialShortIntervals); } /// @copydoc getStartupMeasurements @@ -400,7 +400,7 @@ class Logger { * * Once in testing mode, the logger will attempt to connect to the internet * and take 25 measurements spaced at 5 second intervals writing the results - * to the main output destination (ie, Serial). Testing mode cannot be + * to the main output destination (i.e., Serial). Testing mode cannot be * entered while the logger is taking a scheduled measurement. No data is * written to the SD card in testing mode. * @@ -1122,8 +1122,8 @@ class Logger { * * @warning During sleep, the I2C/Wire interface is disabled and the SCL and * SDA pins are forced low to save power. Any attempt to communicate with an - * I2C device during sleep (ie, thorough an interrupt) will cause the board - * to hang indefinitely. + * I2C device during sleep (i.e., thorough an interrupt) will cause the + * board to hang indefinitely. */ void systemSleep(); From 96773dc7ba6a4ea33d8ce120499cd094626402d4 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Fri, 6 Mar 2026 17:23:49 -0500 Subject: [PATCH 494/533] Fix the punctuation of i.e., in a *lot* of places Signed-off-by: Sara Damiano --- ChangeLog.md | 16 +++++------ docs/FAQ/Arduino-Streams.md | 2 +- docs/For-Developers/Developer-Setup.md | 5 ++-- docs/Further-Reading/Modem-Notes.md | 2 +- docs/Further-Reading/SAMD-Clocks.md | 2 +- docs/Further-Reading/Sleep-Configurations.md | 10 +++---- examples/AWS_IoT_Core/AWS_IoT_Core.ino | 2 +- .../EnviroDIY_Monitoring_Kit.ino | 2 +- .../DRWI_CitizenScience/DRWI_2G/DRWI_2G.ino | 2 +- .../DRWI_DigiLTE/DRWI_DigiLTE.ino | 2 +- .../DRWI_Mayfly1/DRWI_Mayfly1.ino | 2 +- .../DRWI_Mayfly1_WiFi/DRWI_Mayfly1_WiFi.ino | 2 +- .../DRWI_NoCellular/DRWI_NoCellular.ino | 2 +- .../DRWI_SIM7080LTE/DRWI_SIM7080LTE.ino | 2 +- .../simple_logging_LearnEnviroDIY.ino | 2 +- examples/ReadMe.md | 3 +- .../baro_rho_correction.ino | 2 +- examples/double_logger/double_logger.ino | 2 +- examples/logging_to_MMW/logging_to_MMW.ino | 2 +- .../logging_to_ThingSpeak.ino | 2 +- examples/menu_a_la_carte/ReadMe.md | 12 ++++---- examples/menu_a_la_carte/menu_a_la_carte.ino | 28 +++++++++---------- examples/simple_logging/simple_logging.ino | 2 +- src/ClockSupport.cpp | 12 ++++---- src/ClockSupport.h | 20 ++++++------- src/LoggerBase.cpp | 6 ++-- src/LoggerBase.h | 2 +- src/LoggerModem.cpp | 2 +- src/LoggerModem.h | 2 +- src/SensorBase.cpp | 2 +- src/SensorBase.h | 26 ++++++++--------- src/VariableArray.cpp | 4 +-- src/VariableArray.h | 6 ++-- src/VariableBase.cpp | 2 +- src/VariableBase.h | 10 +++---- src/WatchDogs/WatchDogSAMD.cpp | 2 +- src/dataPublisherBase.cpp | 2 +- src/modems/DigiXBee.h | 4 +-- src/modems/LoggerModemMacros.h | 2 +- src/modems/SIMComSIM800.h | 2 +- src/modems/SodaqUBeeR410M.cpp | 2 +- src/publishers/AWS_IoT_Publisher.h | 4 +-- .../MonitorMyWatershedPublisher.cpp | 6 ++-- src/publishers/MonitorMyWatershedPublisher.h | 15 +++++----- src/publishers/S3PresignedPublisher.h | 8 +++--- src/sensors/ANBpH.cpp | 2 +- src/sensors/AnalogElecConductivity.h | 2 +- src/sensors/EverlightALSPT19.h | 2 +- src/sensors/GroPointParent.h | 2 +- src/sensors/InSituRDO.h | 2 +- src/sensors/KellerParent.h | 2 +- src/sensors/MaxBotixSonar.h | 8 ++++-- src/sensors/MaximDS18.cpp | 2 +- src/sensors/ProcessorAnalog.h | 2 +- src/sensors/ProcessorStats.h | 4 +-- src/sensors/YosemitechParent.h | 2 +- 56 files changed, 139 insertions(+), 140 deletions(-) diff --git a/ChangeLog.md b/ChangeLog.md index 4bc403ce5..df65af5aa 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -124,7 +124,7 @@ This was probably a hold-over from incorrect implementation and calling of the c #### Individual Publishers -- *Renamed* The EnviroDIYPublisher has been renamed the MonitorMyWatershedPublisher. +- *Renamed* the EnviroDIYPublisher to MonitorMyWatershedPublisher. This reflects changes to the website from years ago. There is a shell file and typedef to maintain backwards compatibility. @@ -143,7 +143,7 @@ Also added optional arguments to the `completeUpdate()` function to allow users Use `completeUpdate(false, false, false, false)` instead. - Previously the `updateAllSensors()` function asked all sensors to update their values, skipping all power, wake, and sleep steps while the `completeUpdate()` function duplicated that functionality and added the power, wake, and sleep. The two functions have been consolidated into one function with four arguments, one each for power on, wake, sleep, and power off. -To achieve the same functionality as the old `updateAllSensors()` function (ie, only updating values), set all the arguments to false. +To achieve the same functionality as the old `updateAllSensors()` function (i.e., only updating values), set all the arguments to false. #### Library-Wide @@ -236,14 +236,14 @@ This affects the following classes: ## [0.37.0] > [!note] -> This release has changes to nearly every file in the entire library (ie, hundreds of files). +> This release has changes to nearly every file in the entire library (i.e., hundreds of files). > Many of the changes are spelling and typo fixes found by implementing CSpell code spell checking. > All header files were also modified to include the new library configuration headers. ### Changed - **BREAKING** Converted the watch-dog classes into static classes with all static function and a **deleted constructor**. - - Any code that attempted to interact with the watchdog (ie, with a "complex loop") must now call the extendedWatchDog class directly, ie: `extendedWatchDog::resetWatchDog();` rather than `dataLogger.watchDogTimer.resetWatchDog();` + - Any code that attempted to interact with the watchdog (i.e., with a "complex loop") must now call the extendedWatchDog class directly, i.e.: `extendedWatchDog::resetWatchDog();` rather than `dataLogger.watchDogTimer.resetWatchDog();` - **BREAKING** Renamed `markedLocalEpochTime` to `markedLocalUnixTime` to clarify the start of the epoch that we're marking down. - **BREAKING** Renamed `markedUTCEpochTime` to `markedUTCUnixTime` to clarify the start of the epoch that we're marking down. - **Potentially BREAKING:** Changed the requirements for a "sane" timestamp to between 2025 and 2035. @@ -252,7 +252,7 @@ These defines can be set in the ModSensorConfig.h file. - **Potentially BREAKING:** For calculated variables, the calculation function will only be called if `getValue(true)` or `getValueString(true)` is called - that is, the boolean for 'update value' must explicitly be set to true to rerun the calculation function. - Previously, the calculation function was re-run every time `getValue()` or `getValueString()` was called, regardless of the update value parameter. For calculations that were based on the results of other variables that didn't change, this was fine. -But, for calculations based on new raw readings (ie, calling `analogRead()`) a new value would be returned each time the function was called. +But, for calculations based on new raw readings (i.e., calling `analogRead()`) a new value would be returned each time the function was called. I realized this was a problem for analog values I tried to read that reported correctly in the first round, but were saved as junk in the csv and publishers because a new analog reading was being attempted when the thing I was attempting to read was now powered down. - The variable array update functions have been modified accordingly. - Verify you have the functionality you expect if you use calculated variables. @@ -869,7 +869,7 @@ Modem Restructuring ### Changed - Restructured modem so that it no longer operates as a sensor. - Variables tied to the modem are now effectively calculated variables and all values from the modem will be offset by 1 sending cycle (ie, the signal strength posted will always be the strength from the prior send, not the current one). + Variables tied to the modem are now effectively calculated variables and all values from the modem will be offset by 1 sending cycle (i.e., the signal strength posted will always be the strength from the prior send, not the current one). *** @@ -1037,7 +1037,7 @@ Support for all Atlas Scientific I2C sensors, compiler-safe begin functions - RTD (temperature - Created empty constructors for the logger, publisher, variable array, and variable classes and all of their subclasses. For all classes created a corresponding "begin" function to set internal class object values. - See note for more details: - - The order of input arguments for all variable objects has changed. For variable subclasses (ie, variables from sensors), there is no change to the user. ****For calculated variable objects, all code must be updated!**** Please check the structure in the examples! Older code will compile without error but the variable metadata fields will be incorrectly populated. + - The order of input arguments for all variable objects has changed. For variable subclasses (i.e., variables from sensors), there is no change to the user. ****For calculated variable objects, all code must be updated!**** Please check the structure in the examples! Older code will compile without error but the variable metadata fields will be incorrectly populated. - Very preliminary support for SD cards with switchable power ### Removed @@ -1051,7 +1051,7 @@ Support for all Atlas Scientific I2C sensors, compiler-safe begin functions ### Known Issues -- Running some I2C sensors on switched power will cause unrecoverable hangs at the first call to any other I2C peripheral (ie, the DS3231 RTC) after sensor power is turned off. This is a hardware problem and is un-fixable within this library. +- Running some I2C sensors on switched power will cause unrecoverable hangs at the first call to any other I2C peripheral (i.e., the DS3231 RTC) after sensor power is turned off. This is a hardware problem and is un-fixable within this library. - The sensor class and all of its subclasses still require input arguments in the constructor. *** diff --git a/docs/FAQ/Arduino-Streams.md b/docs/FAQ/Arduino-Streams.md index 8ba7f8436..ee5b72526 100644 --- a/docs/FAQ/Arduino-Streams.md +++ b/docs/FAQ/Arduino-Streams.md @@ -112,7 +112,7 @@ enableInterrupt(rx_pin, neoSSerial1ISR, CHANGE); ## Neutered SoftwareSerial [The EnviroDIY modified version of SoftwareSerial](https://github.com/EnviroDIY/SoftwaterSerial_ExternalInts) removes direct interrupt control from the SoftwareSerial library, making it dependent on another interrupt library, but able to be compiled with ModularSensors. -This is, _by far_, the _least_ stable serial port option and should only be used on sensors that are not very picky about the quality of the serial stream or that only require one-way communication (ie, only posting data rather than needing to receive commands). +This is, _by far_, the _least_ stable serial port option and should only be used on sensors that are not very picky about the quality of the serial stream or that only require one-way communication (i.e., only posting data rather than needing to receive commands). To use the EnviroDIY modified version of SoftwareSerial: diff --git a/docs/For-Developers/Developer-Setup.md b/docs/For-Developers/Developer-Setup.md index aefbe6f8a..a6e39dc71 100644 --- a/docs/For-Developers/Developer-Setup.md +++ b/docs/For-Developers/Developer-Setup.md @@ -35,7 +35,8 @@ setupGitFilters.bat ``` **Manual Setup:** -If you prefer to configure the filters manually, run these Git commands from the repository root: + +If you prefer to configure the filters manually, run these Git commands from the repository root (requires PowerShell): ```bash git config --local filter.smudgePasswords.clean "powershell -ExecutionPolicy Bypass -File filters/cleanPasswords.ps1" @@ -57,7 +58,7 @@ Use PlatformIO in VSCode instead. Open the folder you've cloned this repo into with VSCode. Have PlatformIO create a new project for you, but instead of allowing it to create a new folder, select the folder you've already cloned this repo into. -Create a new source program to work with in a new directory (ie, a tests directory). +Create a new source program to work with in a new directory (i.e., a tests directory). This is the directory you should reference in the `src_dir` line of your platformio.ini. _Also add this directory to your .gitignore file_ so you can test and play with your code without publishing personal passwords or other messiness to the web. I recommend you start with the menu a la carte example for development since it already contains all features and is tested for proper compilation with continuous integration tools. diff --git a/docs/Further-Reading/Modem-Notes.md b/docs/Further-Reading/Modem-Notes.md index ae0e6f949..a5ee1b478 100644 --- a/docs/Further-Reading/Modem-Notes.md +++ b/docs/Further-Reading/Modem-Notes.md @@ -165,7 +165,7 @@ You should set the argument `useCTSforStatus` to `false` in the bee constructor 7 I _strongly_ recommend running two new wires along the back of the Mayfly to connect pin 5 of the XBee socket to pin A4 and pin 18 of the XBee socket to A3. This will enable you to use A4 as the reset pin and A3 as the sleep request pin. -With those connections made, the Dragino BG96 becomes the _**only**_ LTE module that can be run using only the 500mA regulator on the Mayfly (ie, without a separate battery connection for the modem). +With those connections made, the Dragino BG96 becomes the _**only**_ LTE module that can be run using only the 500mA regulator on the Mayfly (i.e., without a separate battery connection for the modem). 8 This module is no longer produced or sold. diff --git a/docs/Further-Reading/SAMD-Clocks.md b/docs/Further-Reading/SAMD-Clocks.md index 5f993421e..c519a5e22 100644 --- a/docs/Further-Reading/SAMD-Clocks.md +++ b/docs/Further-Reading/SAMD-Clocks.md @@ -42,7 +42,7 @@ Essentially every microprocessor or computer needs a consistent way of their own speed of operation so they can communicate with internal components and external devices. -An *[oscillator](https://en.wikipedia.org/wiki/Electronic_oscillator)* is a circuit that makes an oscillating signal - ie, it switches back and forth between to states at a consistent rate. +An *[oscillator](https://en.wikipedia.org/wiki/Electronic_oscillator)* is a circuit that makes an oscillating signal - i.e., it switches back and forth between to states at a consistent rate. The oscillator works like a metronome. An oscillator alone does not keep track of time; it ticks, but it doesn't count how many ticks have passed. diff --git a/docs/Further-Reading/Sleep-Configurations.md b/docs/Further-Reading/Sleep-Configurations.md index 3be758d1f..a9f60d870 100644 --- a/docs/Further-Reading/Sleep-Configurations.md +++ b/docs/Further-Reading/Sleep-Configurations.md @@ -89,13 +89,13 @@ The 5 sleep modes are: After completing the [steps for putting all boards to sleep](#steps-for-putting-all-boards-to-sleep), AVR boards finish their bedtime routine with these steps: -- Disable the onboard USB if it exists (ie, for a Leonardo) +- Disable the onboard USB if it exists (i.e., for a Leonardo) - Freeze the USB clock, turn off the USB PLL, and then disable the USB. - Set the sleep mode to SLEEP_MODE_PWR_DOWN. - Temporarily disables interrupts, so no mistakes are made when writing to the processor registers. - Disable the processor ADC, (This must be disabled before the board will power down.) - Turn off the brown-out detector, if possible. -- Disable all power-reduction modules (ie, the processor module clocks). +- Disable all power-reduction modules (i.e., the processor module clocks). - NOTE: This only shuts down the various clocks on the processor via the power reduction register! It does NOT actually disable the modules themselves or set the pins to any particular state! This means that the I2C/Serial/Timer/etc pins will still be active and powered unless they are turned off prior to calling this function. @@ -109,7 +109,7 @@ This means that the I2C/Serial/Timer/etc pins will still be active and powered u *Before* completing the [steps on wake for all boards](#steps-on-wake-for-all-boards), AVR boards start their wake routine with these steps: - Temporarily disables interrupts, so no mistakes are made when writing to the processor registers. -- Re-enable all power modules (ie, the processor module clocks) +- Re-enable all power modules (i.e., the processor module clocks) - NOTE: This only re-enables the various clocks on the processor! The modules may need to be re-initialized after the clocks re-start. - Clear the SE (sleep enable) bit. @@ -236,7 +236,7 @@ See [The SAMD clock file](@ref samd51_clock_other_libraries) for a list of which After completing the [steps for putting all boards to sleep](#steps-for-putting-all-boards-to-sleep), SAMD51 boards finish their bedtime routine with these steps: -- Detach any USB devices (ie, the built-in USB drivers for communication with a PC) +- Detach any USB devices (i.e., the built-in USB drivers for communication with a PC) - This is skipped if the TinyUSB library is called for some reason. - Force all pins except the RTC wake and button pins to go to minimum power draw levels (tri-state) - Configure GCLK7 to be disconnected from an oscillator source. @@ -285,7 +285,7 @@ The pin configurations for the SAMD21 are identical to those described above for After completing the [steps for putting all boards to sleep](#steps-for-putting-all-boards-to-sleep), SAMD21 boards finish their bedtime routine with these steps: -- Detach any USB devices (ie, the built-in USB drivers for communication with a PC) +- Detach any USB devices (i.e., the built-in USB drivers for communication with a PC) - This is skipped if the TinyUSB library is called for some reason. - Force all pins except the RTC wake and button pins to go to minimum power draw levels (tri-state) - Wait for all serial ports to finish transmitting diff --git a/examples/AWS_IoT_Core/AWS_IoT_Core.ino b/examples/AWS_IoT_Core/AWS_IoT_Core.ino index de09d6f12..926c288ac 100644 --- a/examples/AWS_IoT_Core/AWS_IoT_Core.ino +++ b/examples/AWS_IoT_Core/AWS_IoT_Core.ino @@ -66,7 +66,7 @@ const int8_t timeZone = -5; // Eastern Standard Time const int32_t serialBaud = 115200; // Baud rate for debugging const int8_t greenLED = 8; // Pin for the green LED const int8_t redLED = 9; // Pin for the red LED -const int8_t buttonPin = 21; // Pin for debugging mode (ie, button pin) +const int8_t buttonPin = 21; // Pin for debugging mode (i.e., button pin) const int8_t wakePin = 31; // MCU interrupt/alarm pin to wake from sleep // Mayfly 0.x D31 = A7 // Set the wake pin to -1 if you do not want the main processor to sleep. diff --git a/examples/EnviroDIY_Monitoring_Kit/EnviroDIY_Monitoring_Kit.ino b/examples/EnviroDIY_Monitoring_Kit/EnviroDIY_Monitoring_Kit.ino index 8089dd5d8..cb5d2392b 100644 --- a/examples/EnviroDIY_Monitoring_Kit/EnviroDIY_Monitoring_Kit.ino +++ b/examples/EnviroDIY_Monitoring_Kit/EnviroDIY_Monitoring_Kit.ino @@ -135,7 +135,7 @@ const char* sketchName = "EnviroDIY_Monitoring_Kit.ino"; const int32_t serialBaud = 115200; // Baud rate for debugging const int8_t greenLED = 8; // Pin for the green LED const int8_t redLED = 9; // Pin for the red LED -const int8_t buttonPin = 21; // Pin for debugging mode (ie, button pin) +const int8_t buttonPin = 21; // Pin for debugging mode (i.e., button pin) uint8_t buttonPinMode = INPUT; // mode for debugging pin const int8_t wakePin = 31; // MCU interrupt/alarm pin to wake from sleep uint8_t wakePinMode = INPUT_PULLUP; // mode for wake pin diff --git a/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_2G/DRWI_2G.ino b/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_2G/DRWI_2G.ino index 63225a5bd..047c0aa06 100644 --- a/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_2G/DRWI_2G.ino +++ b/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_2G/DRWI_2G.ino @@ -42,7 +42,7 @@ const int8_t timeZone = -5; // Eastern Standard Time const int32_t serialBaud = 115200; // Baud rate for debugging const int8_t greenLED = 8; // Pin for the green LED const int8_t redLED = 9; // Pin for the red LED -const int8_t buttonPin = 21; // Pin for debugging mode (ie, button pin) +const int8_t buttonPin = 21; // Pin for debugging mode (i.e., button pin) const int8_t wakePin = 31; // MCU interrupt/alarm pin to wake from sleep // Mayfly 0.x D31 = A7 // Set the wake pin to -1 if you do not want the main processor to sleep. diff --git a/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_DigiLTE/DRWI_DigiLTE.ino b/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_DigiLTE/DRWI_DigiLTE.ino index 451414e02..034f48609 100644 --- a/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_DigiLTE/DRWI_DigiLTE.ino +++ b/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_DigiLTE/DRWI_DigiLTE.ino @@ -43,7 +43,7 @@ const int8_t timeZone = -5; // Eastern Standard Time const int32_t serialBaud = 57600; // Baud rate for debugging const int8_t greenLED = 8; // Pin for the green LED const int8_t redLED = 9; // Pin for the red LED -const int8_t buttonPin = 21; // Pin for debugging mode (ie, button pin) +const int8_t buttonPin = 21; // Pin for debugging mode (i.e., button pin) const int8_t wakePin = 31; // MCU interrupt/alarm pin to wake from sleep // Mayfly 0.x D31 = A7 // Set the wake pin to -1 if you do not want the main processor to sleep. diff --git a/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_Mayfly1/DRWI_Mayfly1.ino b/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_Mayfly1/DRWI_Mayfly1.ino index e276b6c0e..09bf5e7db 100644 --- a/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_Mayfly1/DRWI_Mayfly1.ino +++ b/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_Mayfly1/DRWI_Mayfly1.ino @@ -49,7 +49,7 @@ const int8_t timeZone = -5; // Eastern Standard Time const int32_t serialBaud = 57600; // Baud rate for debugging const int8_t greenLED = 8; // Pin for the green LED const int8_t redLED = 9; // Pin for the red LED -const int8_t buttonPin = 21; // Pin for debugging mode (ie, button pin) +const int8_t buttonPin = 21; // Pin for debugging mode (i.e., button pin) const int8_t wakePin = 31; // MCU interrupt/alarm pin to wake from sleep // Mayfly 0.x, 1.x D31 = A7 const int8_t sdCardPwrPin = -1; // MCU SD card power pin diff --git a/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_Mayfly1_WiFi/DRWI_Mayfly1_WiFi.ino b/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_Mayfly1_WiFi/DRWI_Mayfly1_WiFi.ino index 5947eddcb..19162aeb4 100644 --- a/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_Mayfly1_WiFi/DRWI_Mayfly1_WiFi.ino +++ b/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_Mayfly1_WiFi/DRWI_Mayfly1_WiFi.ino @@ -46,7 +46,7 @@ const int8_t timeZone = -5; // Eastern Standard Time const int32_t serialBaud = 57600; // Baud rate for debugging const int8_t greenLED = 8; // Pin for the green LED const int8_t redLED = 9; // Pin for the red LED -const int8_t buttonPin = 21; // Pin for debugging mode (ie, button pin) +const int8_t buttonPin = 21; // Pin for debugging mode (i.e., button pin) const int8_t wakePin = 31; // MCU interrupt/alarm pin to wake from sleep // Mayfly 0.x, 1.x D31 = A7 const int8_t sdCardPwrPin = -1; // MCU SD card power pin diff --git a/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_NoCellular/DRWI_NoCellular.ino b/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_NoCellular/DRWI_NoCellular.ino index 0dd6d87e0..bda662e3f 100644 --- a/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_NoCellular/DRWI_NoCellular.ino +++ b/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_NoCellular/DRWI_NoCellular.ino @@ -43,7 +43,7 @@ const int8_t timeZone = -5; // Eastern Standard Time const int32_t serialBaud = 115200; // Baud rate for debugging const int8_t greenLED = 8; // Pin for the green LED const int8_t redLED = 9; // Pin for the red LED -const int8_t buttonPin = 21; // Pin for debugging mode (ie, button pin) +const int8_t buttonPin = 21; // Pin for debugging mode (i.e., button pin) const int8_t wakePin = 31; // MCU interrupt/alarm pin to wake from sleep // Mayfly 0.x D31 = A7 const int8_t sdCardPwrPin = -1; // MCU SD card power pin diff --git a/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_SIM7080LTE/DRWI_SIM7080LTE.ino b/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_SIM7080LTE/DRWI_SIM7080LTE.ino index 6980561e0..e3e5018a1 100644 --- a/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_SIM7080LTE/DRWI_SIM7080LTE.ino +++ b/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_SIM7080LTE/DRWI_SIM7080LTE.ino @@ -50,7 +50,7 @@ const int8_t timeZone = -5; // Eastern Standard Time const int32_t serialBaud = 57600; // Baud rate for debugging const int8_t greenLED = 8; // Pin for the green LED const int8_t redLED = 9; // Pin for the red LED -const int8_t buttonPin = 21; // Pin for debugging mode (ie, button pin) +const int8_t buttonPin = 21; // Pin for debugging mode (i.e., button pin) const int8_t wakePin = 31; // MCU interrupt/alarm pin to wake from sleep // Mayfly 0.x D31 = A7 const int8_t sdCardPwrPin = -1; // MCU SD card power pin diff --git a/examples/OutdatedExamples/simple_logging_LearnEnviroDIY/simple_logging_LearnEnviroDIY.ino b/examples/OutdatedExamples/simple_logging_LearnEnviroDIY/simple_logging_LearnEnviroDIY.ino index 585203ea3..c4b4c649c 100644 --- a/examples/OutdatedExamples/simple_logging_LearnEnviroDIY/simple_logging_LearnEnviroDIY.ino +++ b/examples/OutdatedExamples/simple_logging_LearnEnviroDIY/simple_logging_LearnEnviroDIY.ino @@ -43,7 +43,7 @@ const int8_t timeZone = -5; // Eastern Standard Time const int32_t serialBaud = 115200; // Baud rate for debugging const int8_t greenLED = 8; // Pin for the green LED const int8_t redLED = 9; // Pin for the red LED -const int8_t buttonPin = 21; // Pin for debugging mode (ie, button pin) +const int8_t buttonPin = 21; // Pin for debugging mode (i.e., button pin) const int8_t wakePin = 31; // MCU interrupt/alarm pin to wake from sleep // Mayfly 0.x D31 = A7 // Set the wake pin to -1 if you do not want the main processor to sleep. diff --git a/examples/ReadMe.md b/examples/ReadMe.md index fbc132e82..a012796a5 100644 --- a/examples/ReadMe.md +++ b/examples/ReadMe.md @@ -60,8 +60,7 @@ ___ ### Publishing to Monitor My Watershed -The logging to Monitor My Watershed example uses a Digi XBee in transparent mode to publish data live from a BME280 and Maxim DS18 to Monitor My Watershed. - +The logging to Monitor My Watershed example uses a Digi XBee in transparent mode to publish data live from a BME280 and Maxim DS18. - [Instructions for the logging to Monitor My Watershed example](https://envirodiy.github.io/ModularSensors/example_mmw.html) - [The logging to Monitor My Watershed example on GitHub](https://github.com/EnviroDIY/ModularSensors/tree/master/examples/logging_to_MMW) diff --git a/examples/baro_rho_correction/baro_rho_correction.ino b/examples/baro_rho_correction/baro_rho_correction.ino index 4b1b51c05..ba512cec9 100644 --- a/examples/baro_rho_correction/baro_rho_correction.ino +++ b/examples/baro_rho_correction/baro_rho_correction.ino @@ -43,7 +43,7 @@ const int8_t timeZone = -5; // Eastern Standard Time const int32_t serialBaud = 115200; // Baud rate for debugging const int8_t greenLED = 8; // Pin for the green LED const int8_t redLED = 9; // Pin for the red LED -const int8_t buttonPin = 21; // Pin for debugging mode (ie, button pin) +const int8_t buttonPin = 21; // Pin for debugging mode (i.e., button pin) const int8_t wakePin = 31; // MCU interrupt/alarm pin to wake from sleep // Mayfly 0.x D31 = A7 // Set the wake pin to -1 if you do not want the main processor to sleep. diff --git a/examples/double_logger/double_logger.ino b/examples/double_logger/double_logger.ino index 93af6f5d2..2f645fc28 100644 --- a/examples/double_logger/double_logger.ino +++ b/examples/double_logger/double_logger.ino @@ -44,7 +44,7 @@ const int8_t timeZone = -5; // Eastern Standard Time const int32_t serialBaud = 115200; // Baud rate for debugging const int8_t greenLED = 8; // Pin for the green LED const int8_t redLED = 9; // Pin for the red LED -const int8_t buttonPin = 21; // Pin for debugging mode (ie, button pin) +const int8_t buttonPin = 21; // Pin for debugging mode (i.e., button pin) const int8_t wakePin = 31; // MCU interrupt/alarm pin to wake from sleep // Mayfly 0.x D31 = A7 // Set the wake pin to -1 if you do not want the main processor to sleep. diff --git a/examples/logging_to_MMW/logging_to_MMW.ino b/examples/logging_to_MMW/logging_to_MMW.ino index 40408f6d5..a1d9c74d3 100644 --- a/examples/logging_to_MMW/logging_to_MMW.ino +++ b/examples/logging_to_MMW/logging_to_MMW.ino @@ -42,7 +42,7 @@ const int8_t timeZone = -5; // Eastern Standard Time const int32_t serialBaud = 115200; // Baud rate for debugging const int8_t greenLED = 8; // Pin for the green LED const int8_t redLED = 9; // Pin for the red LED -const int8_t buttonPin = 21; // Pin for debugging mode (ie, button pin) +const int8_t buttonPin = 21; // Pin for debugging mode (i.e., button pin) const int8_t wakePin = 31; // MCU interrupt/alarm pin to wake from sleep // Mayfly 0.x D31 = A7 // Set the wake pin to -1 if you do not want the main processor to sleep. diff --git a/examples/logging_to_ThingSpeak/logging_to_ThingSpeak.ino b/examples/logging_to_ThingSpeak/logging_to_ThingSpeak.ino index fa93f9e35..4ba70855b 100644 --- a/examples/logging_to_ThingSpeak/logging_to_ThingSpeak.ino +++ b/examples/logging_to_ThingSpeak/logging_to_ThingSpeak.ino @@ -43,7 +43,7 @@ const int8_t timeZone = -5; // Eastern Standard Time const int32_t serialBaud = 115200; // Baud rate for debugging const int8_t greenLED = 8; // Pin for the green LED const int8_t redLED = 9; // Pin for the red LED -const int8_t buttonPin = 21; // Pin for debugging mode (ie, button pin) +const int8_t buttonPin = 21; // Pin for debugging mode (i.e., button pin) const int8_t wakePin = 31; // MCU interrupt/alarm pin to wake from sleep // Mayfly 0.x D31 = A7 // Set the wake pin to -1 if you do not want the main processor to sleep. diff --git a/examples/menu_a_la_carte/ReadMe.md b/examples/menu_a_la_carte/ReadMe.md index 62325d66d..d60488190 100644 --- a/examples/menu_a_la_carte/ReadMe.md +++ b/examples/menu_a_la_carte/ReadMe.md @@ -184,7 +184,7 @@ ___ #### AVR Boards -Most Arduino AVR style boards have very few (ie, one, or none) dedicated serial ports *available* after counting out the programming serial port. +Most Arduino AVR style boards have very few (i.e., one, or none) dedicated serial ports *available* after counting out the programming serial port. So to connect anything else, we need to try to emulate the processor serial functionality with a software library. This example shows three possible libraries that can be used to emulate a serial port on an AVR board. @@ -580,8 +580,8 @@ ___ Set options and create the objects for using the processor as a sensor to report battery level, processor free ram, and sample number. The processor can return the number of "samples" it has taken, the amount of RAM it has available and, for some boards, the battery voltage (EnviroDIY Mayfly, Sodaq Mbili, Ndogo, Autonomo, and One, Adafruit Feathers). -The version of the board is required as input (ie, for a EnviroDIY Mayfly: "v0.3" or "v0.4" or "v0.5"). -Use a blank value (ie, "") for un-versioned boards. +The version of the board is required as input (i.e., for a EnviroDIY Mayfly: "v0.3" or "v0.4" or "v0.5"). +Use a blank value (i.e., "") for un-versioned boards. Please note that while you can opt to average more than one sample, it really makes no sense to do so for the processor. The number of "samples" taken will increase by one for each time another processor "measurement" is taken so averaging multiple measurements from the processor will result in the number of samples increasing by more than one with each loop. @@ -889,7 +889,7 @@ ___ The next two sections are for Keller RS485/Modbus water level sensors. The sensor class constructors for each are nearly identical, except for the class name. -The sensor constructors require as input: the sensor modbus address, a stream instance for data (ie, `Serial`), and one or two power pins. +The sensor constructors require as input: the sensor modbus address, a stream instance for data (i.e., `Serial`), and one or two power pins. The Arduino pin controlling the receive and data enable on your RS485-to-TTL adapter and the number of readings to average are optional. (Use -1 for the second power pin and -1 for the enable pin if these don't apply and you want to average more than one reading.) Please see the section "[Notes on Arduino Streams and Software Serial](https://envirodiy.github.io/ModularSensors/page_arduino_streams.html)" for more information about what streams can be used along with this library. In tests on these sensors, SoftwareSerial_ExtInts *did not work* to communicate with these sensors, because it isn't stable enough. @@ -923,7 +923,7 @@ ___ ### Maxbotix HRXL Ultrasonic Range Finder -The Arduino pin controlling power on/off, a stream instance for received data (ie, `Serial`), and the Arduino pin controlling the trigger are required for the sensor constructor. +The Arduino pin controlling power on/off, a stream instance for received data (i.e., `Serial`), and the Arduino pin controlling the trigger are required for the sensor constructor. (Use -1 for the trigger pin if you do not have it connected.) Please see the section "[Notes on Arduino Streams and Software Serial](https://envirodiy.github.io/ModularSensors/page_arduino_streams.html)" for more information about what streams can be used along with this library. @@ -1132,7 +1132,7 @@ ___ The next several sections are for Yosemitech brand sensors. The sensor class constructors for each are nearly identical, except for the class name. -The sensor constructor requires as input: the sensor modbus address, a stream instance for data (ie, `Serial`), and one or two power pins. +The sensor constructor requires as input: the sensor modbus address, a stream instance for data (i.e., `Serial`), and one or two power pins. The Arduino pin controlling the receive and data enable on your RS485-to-TTL adapter and the number of readings to average are optional. (Use -1 for the second power pin and -1 for the enable pin if these don't apply and you want to average more than one reading.) For most of the sensors, Yosemitech strongly recommends averaging multiple (in most cases 10) readings for each measurement. diff --git a/examples/menu_a_la_carte/menu_a_la_carte.ino b/examples/menu_a_la_carte/menu_a_la_carte.ino index 9bca04add..d7ca02af8 100644 --- a/examples/menu_a_la_carte/menu_a_la_carte.ino +++ b/examples/menu_a_la_carte/menu_a_la_carte.ino @@ -36,7 +36,7 @@ // The modem and a number of sensors communicate over UART/TTL - often called // "serial". "Hardware" serial ports (automatically controlled by the MCU) are // generally the most accurate and should be configured and used for as many -// peripherals as possible. In some cases (ie, modbus communication) many +// peripherals as possible. In some cases (i.e., modbus communication) many // sensors can share the same serial port. // For AVR boards @@ -331,11 +331,11 @@ const int8_t timeZone = -5; // Eastern Standard Time const int32_t serialBaud = 115200; // Baud rate for debugging const int8_t greenLED = 8; // Pin for the green LED const int8_t redLED = 9; // Pin for the red LED -const int8_t buttonPin = 21; // Pin for debugging mode (ie, button pin) +const int8_t buttonPin = 21; // Pin for debugging mode (i.e., button pin) uint8_t buttonPinMode = INPUT; // mode for debugging pin // NOTE: On the Mayfly (and Stonefly), pin 21 is tied to a button that pulls the // pin HIGH when pressed and an external pull-down that keeps the pin LOW when -// the button is not pressed. We want the pin mode to be INPUT - ie, floating +// the button is not pressed. We want the pin mode to be INPUT - i.e., floating // internally and pulled down externally until the button is pressed. AVR // processors like the 1284P on the Mayfly do not have internal pull-down // resistors - they do not have an INPUT_PULLDOWN mode like SAMD processors. @@ -344,7 +344,7 @@ uint8_t wakePinMode = INPUT_PULLUP; // mode for wake pin // Mayfly 0.x, 1.x D31 = A7 // NOTE: On the Mayfly, pin D31=A7 is tied directly to the RTC INT/SQW pin // on the onboard DS3231 RTC. The interrupt from the DS3231 will pull the pin -// DOWN, so we want the pin mode to be INPUT_PULLUP - ie, pulled up until the +// DOWN, so we want the pin mode to be INPUT_PULLUP - i.e., pulled up until the // RTC pulls it down. // Set the wake pin to -1 if you do not want the main processor to sleep. // In a SAMD system where you are using the built-in RTC, set the wakePin to 1. @@ -358,17 +358,17 @@ const int8_t relayPowerPin = A3; // MCU pin controlling an optional power relay const int32_t serialBaud = 921600; // Baud rate for debugging const int8_t greenLED = 8; // Pin for the green LED const int8_t redLED = 9; // Pin for the red LED -const int8_t buttonPin = 21; // Pin for debugging mode (ie, button pin) +const int8_t buttonPin = 21; // Pin for debugging mode (i.e., button pin) uint8_t buttonPinMode = INPUT_PULLDOWN; // mode for debugging pin // NOTE: On the Stonefly (and Mayfly), 21 is tied to a button that pulls the pin // HIGH when pressed and an external pull-down that keeps the pin LOW when the -// button is not pressed. We want the pin mode to be INPUT_PULLDOWN - ie, pulled -// down both internally and externally until the button is pressed. +// button is not pressed. We want the pin mode to be INPUT_PULLDOWN - i.e., +// pulled down both internally and externally until the button is pressed. const int8_t wakePin = 38; // MCU interrupt/alarm pin to wake from sleep uint8_t wakePinMode = INPUT_PULLUP; // mode for wake pin // NOTE: On the Stonefly, pin D38 is tied directly to the RTC INT/SQW pin // on the onboard RV-8803 RTC. The interrupt from the RV-8803 will pull the pin -// DOWN, so we want the pin mode to be INPUT_PULLUP - ie, pulled up until the +// DOWN, so we want the pin mode to be INPUT_PULLUP - i.e., pulled up until the // RTC pulls it down. const int8_t sdCardPwrPin = -1; // MCU SD card power pin // const int8_t sdCardPwrPin = 32; // MCU SD card power pin @@ -385,7 +385,7 @@ const int8_t greenLED = PIN_LED2; // Pin for the green LED const int8_t greenLED = -1; // Pin for the green LED #endif const int8_t redLED = LED_BUILTIN; // Pin for the red LED -const int8_t buttonPin = -1; // Pin for debugging mode (ie, button pin) +const int8_t buttonPin = -1; // Pin for debugging mode (i.e., button pin) uint8_t buttonPinMode = INPUT_PULLUP; // mode for debugging pin const int8_t wakePin = -1; // MCU interrupt/alarm pin to wake from sleep uint8_t wakePinMode = INPUT_PULLUP; // mode for wake pin @@ -1324,7 +1324,7 @@ Variable* atlasGrav = new AtlasScientificEC_SpecificGravity( // (that is, the specific conductance). For this example, we will use the // temperature measured by the Atlas RTD above this. You could use the // temperature returned by any other water temperature sensor if desired. -// **DO NOT** use your logger board temperature (ie, from the DS3231) to +// **DO NOT** use your logger board temperature (i.e., from the DS3231) to // calculate specific conductance! float calculateAtlasSpCond() { float spCond = MS_INVALID_VALUE; // Always safest to start with a bad value @@ -1626,7 +1626,7 @@ const uint8_t alsNReadings = 10; EverlightALSPT19 alsPt19(alsPower, alsData, alsSupply, alsResistance, alsNReadings); -// For a board with ALS parameters set in KnownProcessors.h (ie, an EnviroDIY +// For a board with ALS parameters set in KnownProcessors.h (i.e., an EnviroDIY // Mayfly or Stonefly), you can simply do: // EverlightALSPT19 alsPt19_mf(alsNReadings); @@ -2481,8 +2481,8 @@ TurnerTurbidityPlus turbidityPlus_c(ttPlusPower, ttPlusWiper, ttPlusChannel1, #include #include -const int8_t analogECPower = A4; // Power pin (-1 if continuously powered) -const int8_t analogECData = A0; // Data pin (must be an analog pin, ie A#) +const int8_t analogECPower = A4; // Power pin (-1 if continuously powered) +const int8_t analogECData = A0; // Data pin (must be an analog pin, i.e., A#) const uint8_t analogECNReadings = 1; // The number of readings to average // Create an Analog Electrical Conductivity sensor object @@ -2497,7 +2497,7 @@ Variable* analogEc_cond = new AnalogElecConductivity_EC( // temperature measured by the Maxim DS18 saved as ds18Temp several sections // above this. You could use the temperature returned by any other water // temperature sensor if desired. **DO NOT** use your logger board temperature -// (ie, from the DS3231) to calculate specific conductance! +// (i.e., from the DS3231) to calculate specific conductance! float calculateAnalogSpCond() { float spCond = MS_INVALID_VALUE; // Always safest to start with a bad value float waterTemp = ds18Temp->getValue(); diff --git a/examples/simple_logging/simple_logging.ino b/examples/simple_logging/simple_logging.ino index 51d0d5350..0db8452b9 100644 --- a/examples/simple_logging/simple_logging.ino +++ b/examples/simple_logging/simple_logging.ino @@ -43,7 +43,7 @@ const int8_t timeZone = -5; // Eastern Standard Time const int32_t serialBaud = 115200; // Baud rate for debugging const int8_t greenLED = 8; // Pin for the green LED const int8_t redLED = 9; // Pin for the red LED -const int8_t buttonPin = 21; // Pin for debugging mode (ie, button pin) +const int8_t buttonPin = 21; // Pin for debugging mode (i.e., button pin) const int8_t wakePin = 31; // MCU interrupt/alarm pin to wake from sleep // Mayfly 0.x D31 = A7 // Set the wake pin to -1 if you do not want the main processor to sleep. diff --git a/src/ClockSupport.cpp b/src/ClockSupport.cpp index 338bf6569..49b74a183 100644 --- a/src/ClockSupport.cpp +++ b/src/ClockSupport.cpp @@ -215,7 +215,7 @@ RTCZero loggerClock::zero_sleep_rtc; // Sets the static offset from UTC that the RTC is programmed in -// I VERY VERY STRONGLY RECOMMEND SETTING THE RTC IN UTC (ie, offset = 0) +// I VERY VERY STRONGLY RECOMMEND SETTING THE RTC IN UTC (i.e., offset = 0) // You can either set the RTC offset directly or set the offset between the // RTC and the logger void loggerClock::setRTCOffset(int8_t offsetHours) { @@ -285,7 +285,7 @@ String loggerClock::formatDateTime_ISO8601(time_t epochSeconds, String loggerClock::formatDateTime_ISO8601(epochTime in_time, int8_t epochSecondsUTCOffset) { // Use the conversion function to get a temporary variable for the epoch - // time in the epoch used by the processor core (ie, used by gmtime). + // time in the epoch used by the processor core (i.e., used by gmtime). time_t t = epochTime::convert_epoch(in_time, loggerClock::_core_epoch); MS_DEEP_DBG(F("Input time converted to processor epoch:"), t, '(', epochTime::printEpochName(loggerClock::_core_epoch), ')'); @@ -335,7 +335,7 @@ void loggerClock::formatDateTime(char* buffer, const char* fmt, void loggerClock::formatDateTime(char* buffer, const char* fmt, epochTime in_time) { // Use the conversion function to get a temporary variable for the epoch - // time in the epoch used by the processor core (ie, used by gmtime). + // time in the epoch used by the processor core (i.e., used by gmtime). time_t t = epochTime::convert_epoch(in_time, loggerClock::_core_epoch); MS_DEEP_DBG(F("Input time converted to processor epoch:"), t, '(', epochTime::printEpochName(loggerClock::_core_epoch), ')'); @@ -444,7 +444,7 @@ void loggerClock::setNextRTCInterrupt(epochTime in_time, int8_t utcOffset) { resetClockInterruptStatus(); // Use the conversion function to get a temporary variable for the epoch - // time in the epoch used by the processor core (ie, used by gmtime). + // time in the epoch used by the processor core (i.e., used by gmtime). time_t t = epochTime::convert_epoch(in_time, _rtcEpoch) - static_cast(utcOffset * 3600); MS_DBG(F("Setting the next alarm on the"), MS_CLOCK_NAME, F("to"), @@ -458,7 +458,7 @@ void loggerClock::setNextRTCInterrupt(epochTime in_time, int8_t utcOffset) { #if defined(MS_USE_RV8803) // NOTE: The RV-8803 hardware does **NOT** support alarms at finer frequency - // than minutes! The alarm will fire when the minute turns (ie, at + // than minutes! The alarm will fire when the minute turns (i.e., at // hh:mm:00). To set an alarm at a specific second interval, you would have // to use a periodic countdown timer interrupt and start the interrupt timer // carefully on the second you want to match. @@ -478,7 +478,7 @@ void loggerClock::setNextRTCInterrupt(epochTime in_time, int8_t utcOffset) { rtc.enableHardwareInterrupt(ALARM_INTERRUPT); #elif defined(MS_USE_DS3231) - // MATCH_HOURS = match hours *and* minutes, seconds, ie 1x per day at set + // MATCH_HOURS = match hours *and* minutes, seconds, i.e., 1x per day at set // hh:mm:ss rtc.enableInterrupts(MATCH_HOURS, 0, tmp->tm_hour, tmp->tm_min, tmp->tm_sec); // interrupt at (h,m,s) diff --git a/src/ClockSupport.h b/src/ClockSupport.h index 36e75d607..a32f77a11 100644 --- a/src/ClockSupport.h +++ b/src/ClockSupport.h @@ -371,8 +371,8 @@ class loggerClock { * @brief Set the static offset in hours from UTC that the RTC is programmed * in. * - * @note I VERY, VERY STRONGLY RECOMMEND SETTING THE RTC IN UTC(ie, offset = - * 0) + * @note I VERY, VERY STRONGLY RECOMMEND SETTING THE RTC IN UTC(i.e., offset + * = 0) * * @param offsetHours The offset of the real-time clock (RTC) from UTC in * hours @@ -390,8 +390,8 @@ class loggerClock { * the RTC. * * @param utcOffset The offset from UTC to return the epoch time in. - * @param epoch The type of epoch to use (ie, the standard for the start of - * the epoch). + * @param epoch The type of epoch to use (i.e., the standard for the start + * of the epoch). * * @return The number of seconds from the start of the given epoch. */ @@ -488,8 +488,8 @@ class loggerClock { * * @param ts The number of seconds since the start of the given epoch. * @param utcOffset The offset of the epoch time from UTC. - * @param epoch The type of epoch to use (ie, the standard for the start of - * the epoch). + * @param epoch The type of epoch to use (i.e., the standard for the start + * of the epoch). * * @return True if the input timestamp passes sanity checks **and** * the clock is now at or within tolerance (±5 seconds) of the target time. @@ -541,8 +541,8 @@ class loggerClock { * @param ts The timestamp to check (in seconds since the start of the given * epoch). * @param utcOffset The offset of the epoch time from UTC in hours. - * @param epoch The type of epoch to use (ie, the standard for the start of - * the epoch). + * @param epoch The type of epoch to use (i.e., the standard for the start + * of the epoch). * @return True if the given time passes sanity range checking. */ static bool isEpochTimeSane(time_t ts, int8_t utcOffset, epochStart epoch); @@ -565,8 +565,8 @@ class loggerClock { * @param ts The timestamp for the next interrupt - in seconds from the * start of the input epoch. * @param utcOffset The offset of the epoch time from UTC in hours. - * @param epoch The type of epoch to use (ie, the standard for the start of - * the epoch). + * @param epoch The type of epoch to use (i.e., the standard for the start + * of the epoch). */ static void setNextRTCInterrupt(time_t ts, int8_t utcOffset, epochStart epoch); diff --git a/src/LoggerBase.cpp b/src/LoggerBase.cpp index 1e4f1b9c8..9d539b5f5 100644 --- a/src/LoggerBase.cpp +++ b/src/LoggerBase.cpp @@ -684,7 +684,7 @@ bool Logger::checkInterval() { #if MS_LOGGERBASE_BUTTON_BENCH_TEST == 0 // If the person has set the button pin **NOT** to be used for "bench - // testing" (ie, immediate rapid logging) then we instead read this button + // testing" (i.e., immediate rapid logging) then we instead read this button // testing flag to mean "log now." To make that happen, we mark the time // here and return true if the flag is set. bool testing = Logger::startTesting; @@ -1027,7 +1027,7 @@ void Logger::systemSleep() { sleep_bod_disable(); #endif - // disable all power-reduction modules (ie, the processor module clocks) + // disable all power-reduction modules (i.e., the processor module clocks) // NOTE: This only shuts down the various clocks on the processor via // the power reduction register! It does NOT actually disable the // modules themselves or set the pins to any particular state! This @@ -1128,7 +1128,7 @@ void Logger::systemSleep() { // to the processor registers noInterrupts(); - // Re-enable all power modules (ie, the processor module clocks) + // Re-enable all power modules (i.e., the processor module clocks) // NOTE: This only re-enables the various clocks on the processor! // The modules may need to be re-initialized after the clocks re-start. power_all_enable(); diff --git a/src/LoggerBase.h b/src/LoggerBase.h index 687f85731..0d69753d1 100644 --- a/src/LoggerBase.h +++ b/src/LoggerBase.h @@ -1443,7 +1443,7 @@ class Logger { * to the internet. It then powers up all sensors tied to variable in the * internal variable array. The logger then updates readings from all * sensors 25 times with a 5 second wait in between. All results are output - * to the "main" output - ie Serial - and NOT to the SD card. After 25 + * to the "main" output - i.e., Serial - and NOT to the SD card. After 25 * measurements, the sensors are put to sleep, the modem is disconnected * from the internet, and the logger goes back to sleep. * diff --git a/src/LoggerModem.cpp b/src/LoggerModem.cpp index 474391f7f..b2fc32a8b 100644 --- a/src/LoggerModem.cpp +++ b/src/LoggerModem.cpp @@ -186,7 +186,7 @@ bool loggerModem::modemSleep() { // process of turning on and thus status pin isn't valid yet. In that case, // we wouldn't yet know it's coming on and so we'd mistakenly assume it's // already off and not turn it back off. This only applies to modules with a - // pulse wake (ie, non-zero wake time). For all modules that do pulse on, + // pulse wake (i.e., non-zero wake time). For all modules that do pulse on, // where possible I've selected a pulse time that is sufficient to wake but // not quite long enough to put it to sleep and am using AT commands to // sleep. This *should* keep everything lined up. diff --git a/src/LoggerModem.h b/src/LoggerModem.h index 7c6c42561..d8cb8e4f9 100644 --- a/src/LoggerModem.h +++ b/src/LoggerModem.h @@ -933,7 +933,7 @@ class loggerModem { * * @note It's possible that the status pin is on, but the modem is actually * mid-shutdown. In that case, we'll mistakenly skip re-waking it. This - * only applies to modules with a pulse wake (ie, non-zero wake time). For + * only applies to modules with a pulse wake (i.e., non-zero wake time). For * all modules that do pulse on, where possible I've selected a pulse time * that is sufficient to wake but not quite long enough to put it to sleep * and am using AT commands to sleep. This *should* keep everything lined diff --git a/src/SensorBase.cpp b/src/SensorBase.cpp index 161048919..f1185a170 100644 --- a/src/SensorBase.cpp +++ b/src/SensorBase.cpp @@ -39,7 +39,7 @@ Sensor::Sensor(const char* sensorName, const uint8_t totalReturnedValues, } -// This gets the place the sensor is installed ON THE MAYFLY (ie, pin number) +// This gets the place the sensor is installed ON THE MAYFLY (i.e., pin number) String Sensor::getSensorLocation() { String senseLoc; senseLoc.reserve(10); // Reserve for "Pin" + pin number diff --git a/src/SensorBase.h b/src/SensorBase.h index d52886da3..0ae7ce4da 100644 --- a/src/SensorBase.h +++ b/src/SensorBase.h @@ -161,7 +161,7 @@ class Sensor { * @return The pin on the mcu controlling secondary power * * This is for a second power needed to communicate with a sensor. Generally - * to an adapter or converter needed to talk to the sensor - ie, an RS232 + * to an adapter or converter needed to talk to the sensor - i.e., an RS232 * adapter, an RS485 adapter, or an IO multiplexer. */ virtual int8_t getSecondaryPowerPin(); @@ -169,7 +169,7 @@ class Sensor { * @brief Set the pin number controlling secondary sensor power. * * This is for a second power needed to communicate with a sensor. Generally - * to an adapter or converter needed to talk to the sensor - ie, an RS232 + * to an adapter or converter needed to talk to the sensor - i.e., an RS232 * adapter, an RS485 adapter, or an IO multiplexer. * * @param pin The pin on the mcu controlling secondary power @@ -363,7 +363,7 @@ class Sensor { } /** - * @brief Clear a specific status bit (ie, set it to 0). + * @brief Clear a specific status bit (i.e., set it to 0). * * @param bitToClear The status bit to clear. */ @@ -567,16 +567,16 @@ class Sensor { */ void clearMeasurementStatus(); /** - * @brief Verify that a measurement is OK (ie, not #MS_INVALID_VALUE) before - * adding it to the result array + * @brief Verify that a measurement is OK (i.e., not #MS_INVALID_VALUE) + * before adding it to the result array * * @param resultNumber The position of the result within the result array. * @param resultValue The value of the result. */ void verifyAndAddMeasurementResult(uint8_t resultNumber, float resultValue); /** - * @brief Verify that a measurement is OK (ie, not #MS_INVALID_VALUE) before - * adding it to the result array + * @brief Verify that a measurement is OK (i.e., not #MS_INVALID_VALUE) + * before adding it to the result array * * @param resultNumber The position of the result within the result array. * @param resultValue The value of the result. @@ -718,7 +718,7 @@ class Sensor { * @brief Digital pin number on the mcu controlling secondary power * * This is for a second power needed to communicate with a sensor. Generally - * to an adapter or converter needed to talk to the sensor - ie, an RS232 + * to an adapter or converter needed to talk to the sensor - i.e., an RS232 * adapter, an RS485 adapter, or an IO multiplexer. * * @note SIGNED int, to allow negative numbers for unused pins @@ -778,7 +778,7 @@ class Sensor { * the sensor in the current update cycle. * * @note The number of good measurements may vary between variables if - * some values are more likely to be invalid than others - ie, a pH sensor + * some values are more likely to be invalid than others - i.e., a pH sensor * may also measure temperature and report a valid temperature when the pH * is junk. */ @@ -804,7 +804,7 @@ class Sensor { */ uint32_t _stabilizationTime_ms; /** - * @brief The processor elapsed time when the sensor was activated - ie, + * @brief The processor elapsed time when the sensor was activated - i.e., * when the wake() function was run. * * The #_millisSensorActivated value is *usually* set in the wake() @@ -819,7 +819,7 @@ class Sensor { */ uint32_t _measurementTime_ms; /** - * @brief The processor elapsed time when a measurement was started - ie, + * @brief The processor elapsed time when a measurement was started - i.e., * when the startSingleMeasurement() function was run. * * The #_millisMeasurementRequested value is set in the @@ -828,8 +828,8 @@ class Sensor { */ uint32_t _millisMeasurementRequested = 0; /** - * @brief The processor elapsed time when a measurement was completed - ie, - * when the addSingleMeasurementResult() function was run. + * @brief The processor elapsed time when a measurement was completed - + * i.e., when the addSingleMeasurementResult() function was run. * * The #_millisMeasurementCompleted value is set in the * addSingleMeasurementResult() function. diff --git a/src/VariableArray.cpp b/src/VariableArray.cpp index 3219b182f..a5b1de965 100644 --- a/src/VariableArray.cpp +++ b/src/VariableArray.cpp @@ -258,7 +258,7 @@ bool VariableArray::setupSensors() { // Now run all the set-up functions MS_DBG(F("Running sensor setup functions.")); - // Check for any sensors that have been set up outside of this (ie, the + // Check for any sensors that have been set up outside of this (i.e., the // modem) uint8_t nSensorsSetup = 0; for (uint8_t i = 0; i < _sensorCount; i++) { @@ -472,7 +472,7 @@ bool VariableArray::completeUpdate(bool powerUp, bool wake, bool sleep, // the sensor wasn't powered, it will have cleared the wake bits. If we // clear the wake bits here before checking them, then we won't be able to // tell if the sensor was already awake before this function was called. If - // this function is called with wake=false (ie, expecting the sensors to + // this function is called with wake=false (i.e., expecting the sensors to // have been awoken elsewhere), then we need to be able to check if the wake // was successful before attempting readings, so we need to keep the wake // bits intact. diff --git a/src/VariableArray.h b/src/VariableArray.h index 9921dc6f8..36182f678 100644 --- a/src/VariableArray.h +++ b/src/VariableArray.h @@ -162,7 +162,7 @@ class VariableArray { /** * @brief Get the number of calculated variables * - * @return The number of calculated (ie, not measured by a + * @return The number of calculated (i.e., not measured by a * sensor) variables */ uint8_t getCalculatedVariableCount(); @@ -278,7 +278,7 @@ class VariableArray { * * By default, it will print to the first Serial port. Note that the input * is a pointer to a stream instance - to use a hardware serial instance you - * must use an ampersand before the serial name (ie, &Serial1). + * must use an ampersand before the serial name (i.e., &Serial1). * * @param stream An Arduino Stream instance */ @@ -309,7 +309,7 @@ class VariableArray { * will return. * * This is used for formating output where the format is slightly different - * for the last value. (ie, no comma after the last value) + * for the last value. (i.e., no comma after the last value) * * @param arrayIndex The index of the variable in the sensor variable array * @return True if the variable is the last in the array. diff --git a/src/VariableBase.cpp b/src/VariableBase.cpp index 4ba4b88ac..650e79960 100644 --- a/src/VariableBase.cpp +++ b/src/VariableBase.cpp @@ -250,7 +250,7 @@ float Variable::getValue(bool updateValue) { // NOTE: Only run the calculation function if update value is called, // otherwise return the last value. If we run the calculation function // every time we call getValue() or getValueString(), we will get - // different values each time - ie, the data on the CSV and each + // different values each time - i.e., the data on the CSV and each // publisher will report a different value. That is **NOT** the desired // behavior. Thus, we stash the value. if (updateValue && _calcFxn != nullptr) { diff --git a/src/VariableBase.h b/src/VariableBase.h index af4f31387..646373166 100644 --- a/src/VariableBase.h +++ b/src/VariableBase.h @@ -123,7 +123,7 @@ class Variable { * @param uuid A universally unique identifier for the variable. * * @warning The `calcFxn` absolutely must return a float value. If it - * returns a value of any other type (ie, some type of integer), your + * returns a value of any other type (i.e., some type of integer), your * program will compile but immediately hang. */ Variable(float (*calcFxn)(), uint8_t decimalResolution, const char* varName, @@ -142,7 +142,7 @@ class Variable { * text helping to identify the variable in files. * * @warning The `calcFxn` absolutely must return a float value. If it - * returns a value of any other type (ie, some type of integer), your + * returns a value of any other type (i.e., some type of integer), your * program will compile but immediately hang. */ Variable(float (*calcFxn)(), uint8_t decimalResolution, const char* varName, @@ -207,7 +207,7 @@ class Variable { * @return A pointer to the variable object * * @warning The `calcFxn` absolutely must return a float value. If it - * returns a value of any other type (ie, some type of integer), your + * returns a value of any other type (i.e., some type of integer), your * program will compile but immediately hang. */ Variable* begin(float (*calcFxn)(), uint8_t decimalResolution, @@ -229,7 +229,7 @@ class Variable { * @return A pointer to the variable object * * @warning The `calcFxn` absolutely must return a float value. If it - * returns a value of any other type (ie, some type of integer), your + * returns a value of any other type (i.e., some type of integer), your * program will compile but immediately hang. */ Variable* begin(float (*calcFxn)(), uint8_t decimalResolution, @@ -440,7 +440,7 @@ class Variable { * @brief The current data value * * When we create the variable, we also want to initialize it with a current - * value of #MS_INVALID_VALUE (ie, a bad result). + * value of #MS_INVALID_VALUE (i.e., a bad result). */ float _currentValue = MS_INVALID_VALUE; diff --git a/src/WatchDogs/WatchDogSAMD.cpp b/src/WatchDogs/WatchDogSAMD.cpp index 4be9f2f71..338a41175 100644 --- a/src/WatchDogs/WatchDogSAMD.cpp +++ b/src/WatchDogs/WatchDogSAMD.cpp @@ -224,7 +224,7 @@ void extendedWatchDogSAMD::configureClockGenerator() { // better. // NOTE: The generic clock generator must be enabled by performing a single // 32-bit write to the Generic Clock Generator Control register (GENCTRL) - - // ie, do this all in one step. + // i.e., do this all in one step. // NOTE: Per the manual 15.8.4, the run in standby setting // (GCLK_GENCTRL_RUNSTDBY) for the generic clock generator control only // applies if the generic clock generator has been configured to be output diff --git a/src/dataPublisherBase.cpp b/src/dataPublisherBase.cpp index ff1b4037c..de0c50a5e 100644 --- a/src/dataPublisherBase.cpp +++ b/src/dataPublisherBase.cpp @@ -29,7 +29,7 @@ dataPublisher::dataPublisher(Logger& baseLogger, Client* inClient, _inClient(inClient), _sendEveryX(sendEveryX), _startupTransmissions(startupTransmissions < 1 ? 1 - : startupTransmissions) { + : startupTransmissions) { _baseModem = _baseLogger->registerDataPublisher(this); // register self with logger } diff --git a/src/modems/DigiXBee.h b/src/modems/DigiXBee.h index 717d7ef31..8b8b13d7a 100644 --- a/src/modems/DigiXBee.h +++ b/src/modems/DigiXBee.h @@ -127,9 +127,9 @@ * indirectly with `CTS_N/DIO7`. The status level will depend on which is * being used: * - the `ON/SLEEP_N/DIO9` will be `HIGH` when the XBee is awake - * (ie, yes, I am not sleeping) + * (i.e., yes, I am not sleeping) * - but the `CTS_N/DIO7` will be `LOW` when the - * board is awake (ie, no it's not not clear to send). + * board is awake (i.e., no it's not not clear to send). * * To use the `CTS_N/DIO7` as the status indicator, set useCTSStatus to true in * the constructor. diff --git a/src/modems/LoggerModemMacros.h b/src/modems/LoggerModemMacros.h index 99b430881..9daa25981 100644 --- a/src/modems/LoggerModemMacros.h +++ b/src/modems/LoggerModemMacros.h @@ -339,7 +339,7 @@ } #else -//^^ from #if defined(TINY_GSM_MODEM_HAS_GPRS) (ie, this is wifi) +//^^ from #if defined(TINY_GSM_MODEM_HAS_GPRS) (i.e., this is wifi) #define MS_MODEM_IS_INTERNET_AVAILABLE(specificModem) \ bool specificModem::isInternetAvailable() { \ diff --git a/src/modems/SIMComSIM800.h b/src/modems/SIMComSIM800.h index f4491eb81..4fa74e164 100644 --- a/src/modems/SIMComSIM800.h +++ b/src/modems/SIMComSIM800.h @@ -28,7 +28,7 @@ * SIM800. * The one exception is the Sodaq GPRSBee **R6 and higher**, which has its own * [constructor](@ref modem_gprsbee). - * The earlier Sodaq GPRSBee's (ie, R4) do use this version. + * The earlier Sodaq GPRSBee's (i.e., R4) do use this version. * * The SIM800 consumes up to 2A of power while connecting to the network. * That is 4x what a typical USB or Arduino board can supply, so expect to give diff --git a/src/modems/SodaqUBeeR410M.cpp b/src/modems/SodaqUBeeR410M.cpp index 55bce5c61..a409abb44 100644 --- a/src/modems/SodaqUBeeR410M.cpp +++ b/src/modems/SodaqUBeeR410M.cpp @@ -83,7 +83,7 @@ bool SodaqUBeeR410M::modemWakeFxn() { // before ending pulse if (_statusPin >= 0) { uint32_t startTimer = millis(); - // 0.15-3.2s pulse for wake on SARA R4/N4 (ie, max is 3.2s) + // 0.15-3.2s pulse for wake on SARA R4/N4 (i.e., max is 3.2s) // Wait no more than 3.2s while (digitalRead(_statusPin) != static_cast(_statusLevel) && millis() - startTimer < 3200L) {} diff --git a/src/publishers/AWS_IoT_Publisher.h b/src/publishers/AWS_IoT_Publisher.h index 247d99e6b..d776795bd 100644 --- a/src/publishers/AWS_IoT_Publisher.h +++ b/src/publishers/AWS_IoT_Publisher.h @@ -215,7 +215,7 @@ class AWS_IoT_Publisher : public dataPublisher { * Certificate Authority - G2). * * This is exactly the same CA certificate as you would use to upload to S3 - * (ie, the S3 Presigned Publisher). For supported modules you can use the + * (i.e., the S3 Presigned Publisher). For supported modules you can use the * AWS_IOT_SetCertificates sketch in the extras folder to upload your * certificate. * @@ -282,7 +282,7 @@ class AWS_IoT_Publisher : public dataPublisher { * * If not specified, the topic "{LoggerID}/metadata" will be used for the * main logger metadata. For each variable, the variable number will be - * appended to the topic (ie, "{LoggerID}/metadata/variable01"). + * appended to the topic (i.e., "{LoggerID}/metadata/variable01"). * * Make sure you have IAM policies set up to allow your device to publish to * the specified topics! diff --git a/src/publishers/MonitorMyWatershedPublisher.cpp b/src/publishers/MonitorMyWatershedPublisher.cpp index 071c1be31..bda580901 100644 --- a/src/publishers/MonitorMyWatershedPublisher.cpp +++ b/src/publishers/MonitorMyWatershedPublisher.cpp @@ -36,8 +36,7 @@ MonitorMyWatershedPublisher::MonitorMyWatershedPublisher( Logger& baseLogger, Client* inClient, const char* registrationToken, const char* samplingFeatureUUID, int sendEveryX, uint8_t startupTransmissions) - : dataPublisher(baseLogger, inClient, sendEveryX, - startupTransmissions) { + : dataPublisher(baseLogger, inClient, sendEveryX, startupTransmissions) { _logBuffer.setNumVariables(_baseLogger->getArrayVarCount()); setHost("monitormywatershed.org"); setPath("/api/data-stream/"); @@ -59,8 +58,7 @@ MonitorMyWatershedPublisher::MonitorMyWatershedPublisher( Logger& baseLogger, Client* inClient, const char* registrationToken, int sendEveryX, uint8_t startupTransmissions) : MonitorMyWatershedPublisher(baseLogger, inClient, registrationToken, - nullptr, sendEveryX, - startupTransmissions) {} + nullptr, sendEveryX, startupTransmissions) {} MonitorMyWatershedPublisher::MonitorMyWatershedPublisher( Logger& baseLogger, Client* inClient, int sendEveryX, uint8_t startupTransmissions) diff --git a/src/publishers/MonitorMyWatershedPublisher.h b/src/publishers/MonitorMyWatershedPublisher.h index 94a7f9858..d33030c44 100644 --- a/src/publishers/MonitorMyWatershedPublisher.h +++ b/src/publishers/MonitorMyWatershedPublisher.h @@ -69,7 +69,7 @@ class MonitorMyWatershedPublisher : public dataPublisher { MonitorMyWatershedPublisher(Logger& baseLogger, Client* inClient, const char* registrationToken, const char* samplingFeatureUUID, - int sendEveryX = 1, + int sendEveryX = 1, uint8_t startupTransmissions = 5); /** * @brief Construct a new Monitor My Watershed Publisher object @@ -89,7 +89,7 @@ class MonitorMyWatershedPublisher : public dataPublisher { MonitorMyWatershedPublisher(Logger& baseLogger, const char* registrationToken, const char* samplingFeatureUUID, - int sendEveryX = 1, + int sendEveryX = 1, uint8_t startupTransmissions = 5); /** * @brief Construct a new Monitor My Watershed Publisher object @@ -109,7 +109,7 @@ class MonitorMyWatershedPublisher : public dataPublisher { */ MonitorMyWatershedPublisher(Logger& baseLogger, Client* inClient, const char* registrationToken, - int sendEveryX = 1, + int sendEveryX = 1, uint8_t startupTransmissions = 5); /** * @brief Construct a new Monitor My Watershed Publisher object @@ -126,7 +126,7 @@ class MonitorMyWatershedPublisher : public dataPublisher { * (default: 5). This allows faster in-field validation of startup data. */ MonitorMyWatershedPublisher(Logger& baseLogger, Client* inClient, - int sendEveryX = 1, + int sendEveryX = 1, uint8_t startupTransmissions = 5); /** * @brief Construct a new Monitor My Watershed Publisher object @@ -143,7 +143,7 @@ class MonitorMyWatershedPublisher : public dataPublisher { */ MonitorMyWatershedPublisher(Logger& baseLogger, const char* registrationToken, - int sendEveryX = 1, + int sendEveryX = 1, uint8_t startupTransmissions = 5); /** * @brief Construct a new Monitor My Watershed Publisher object @@ -160,9 +160,8 @@ class MonitorMyWatershedPublisher : public dataPublisher { * data and only transmit every sendEveryX times the logger records data * (default: 5). This allows faster in-field validation of startup data. */ - explicit MonitorMyWatershedPublisher( - Logger& baseLogger, int sendEveryX = 1, - uint8_t startupTransmissions = 5); + explicit MonitorMyWatershedPublisher(Logger& baseLogger, int sendEveryX = 1, + uint8_t startupTransmissions = 5); /** * @brief Construct a new Monitor My Watershed Publisher object with only * default values for all parameters. diff --git a/src/publishers/S3PresignedPublisher.h b/src/publishers/S3PresignedPublisher.h index 727ff99cc..b87039254 100644 --- a/src/publishers/S3PresignedPublisher.h +++ b/src/publishers/S3PresignedPublisher.h @@ -193,7 +193,7 @@ class S3PresignedPublisher : public dataPublisher { * @brief Set the S3 host name * * This is "s3..amazonaws.com" by default. - * If you need to use a host in a specific region (ie, anything but + * If you need to use a host in a specific region (i.e., anything but * US-East-1) you should set your own host. The host in that case should be: * "s3..amazonaws.com" * @@ -277,9 +277,9 @@ class S3PresignedPublisher : public dataPublisher { * Certificate Authority - G2). * * This is exactly the same CA certificate as you would use for an MQTT - * connection to AWS IoT (ie, the AWS IoT Publisher). For supported modules - * you can use the AWS_IOT_SetCertificates sketch in the extras folder to - * upload your certificate. + * connection to AWS IoT (i.e., the AWS IoT Publisher). For supported + * modules you can use the AWS_IOT_SetCertificates sketch in the extras + * folder to upload your certificate. * * @param caCertName The name of your certificate authority certificate * file. diff --git a/src/sensors/ANBpH.cpp b/src/sensors/ANBpH.cpp index 993b38d0c..115d5695f 100644 --- a/src/sensors/ANBpH.cpp +++ b/src/sensors/ANBpH.cpp @@ -181,7 +181,7 @@ bool ANBpH::setup() { intervalSet = _anb_sensor.setIntervalTime(programmedInterval); } else { // Set sampling interval to continuous if the sensor will be - // continuously powered (ie, a power style of ALWAYS_POWERED). + // continuously powered (i.e., a power style of ALWAYS_POWERED). MS_DBG(F("Set sensor sampling interval to 0 (continuous)...")); intervalSet = _anb_sensor.setIntervalTime(0); } diff --git a/src/sensors/AnalogElecConductivity.h b/src/sensors/AnalogElecConductivity.h index 1bc04de13..3d934b21c 100644 --- a/src/sensors/AnalogElecConductivity.h +++ b/src/sensors/AnalogElecConductivity.h @@ -306,7 +306,7 @@ class AnalogElecConductivity : public Sensor { * @param dataPin The processor ADC port pin to read the voltage from the EC * probe. Not all processor pins can be used as analog pins. Those usable * as analog pins generally are numbered with an "A" in front of the number - * - ie, A1. + * - i.e., A1. * @param Rseries_ohms The resistance of the resistor series (R) in the * line; optional with default value of * #ANALOGELECCONDUCTIVITY_RSERIES_OHMS (499). diff --git a/src/sensors/EverlightALSPT19.h b/src/sensors/EverlightALSPT19.h index 96ef07359..82e0a7a45 100644 --- a/src/sensors/EverlightALSPT19.h +++ b/src/sensors/EverlightALSPT19.h @@ -252,7 +252,7 @@ class EverlightALSPT19 : public Sensor { * @param dataPin The processor ADC port pin to read the voltage from the EC * probe. Not all processor pins can be used as analog pins. Those usable * as analog pins generally are numbered with an "A" in front of the number - * - ie, A1. + * - i.e., A1. * @param alsSupplyVoltage The power supply voltage (in volts) of the * ALS-PT19. This does not have to be the same as the board operating * voltage or the supply voltage of the AnalogVoltageBase reader. diff --git a/src/sensors/GroPointParent.h b/src/sensors/GroPointParent.h index 154e113b4..d9e3b5af8 100644 --- a/src/sensors/GroPointParent.h +++ b/src/sensors/GroPointParent.h @@ -35,7 +35,7 @@ * They communicate via [Modbus RTU](https://en.wikipedia.org/wiki/Modbus) over [RS-485](https://en.wikipedia.org/wiki/RS-485). * To interface with them, you will need an RS485-to-TTL adapter. * - * The sensor constructor requires as input: the sensor modbus address, a stream instance for data (ie, ```Serial```), and one or two power pins. + * The sensor constructor requires as input: the sensor modbus address, a stream instance for data (i.e., ```Serial```), and one or two power pins. * The Arduino pin controlling the receive and data enable on your RS485-to-TTL adapter and the number of readings to average are optional. * (Use -1 for the second power pin and -1 for the enable pin if these don't apply and you want to average more than one reading.) * Please see the section "[Notes on Arduino Streams and Software Serial](@ref page_arduino_streams)" diff --git a/src/sensors/InSituRDO.h b/src/sensors/InSituRDO.h index e9649bcaa..bc3d273c9 100644 --- a/src/sensors/InSituRDO.h +++ b/src/sensors/InSituRDO.h @@ -70,7 +70,7 @@ * 1. Disable caching: * - By default, the RDO PRO-X "caches" readings for 5000ms (5s) and will * not take a new measurement until the 5s cache expires. If you want to take - * measurements at faster than 5s intervals (ie, to average multiple + * measurements at faster than 5s intervals (i.e., to average multiple * measurements), I strongly recommend setting the cache value to 0ms using the * Win-Situ software. The cache value can be changed in the "Diagnostics" menu * found on the "Device Setup" tab of Win-Situ. diff --git a/src/sensors/KellerParent.h b/src/sensors/KellerParent.h index 8a383b716..7daa6994f 100644 --- a/src/sensors/KellerParent.h +++ b/src/sensors/KellerParent.h @@ -51,7 +51,7 @@ * protocols are not supported by this library. * * The sensor constructors require as input: the sensor modbus address, a - * stream instance for data (ie, ```Serial```), and one or two power pins. The + * stream instance for data (i.e., ```Serial```), and one or two power pins. The * Arduino pin controlling the receive and data enable on your RS485-to-TTL * adapter and the number of readings to average are optional. (Use -1 for the * second power pin and -1 for the enable pin if these don't apply and you want diff --git a/src/sensors/MaxBotixSonar.h b/src/sensors/MaxBotixSonar.h index 15feaa074..46cf85725 100644 --- a/src/sensors/MaxBotixSonar.h +++ b/src/sensors/MaxBotixSonar.h @@ -306,10 +306,12 @@ class MaxBotixSonar : public Sensor { Stream* _stream; /** - * @brief Helper function to dump any available characters from the stream buffer + * @brief Helper function to dump any available characters from the stream + * buffer * - * Reads and discards all available characters from the stream to clear the buffer. - * Optionally prints debugging output showing the discarded characters. + * Reads and discards all available characters from the stream to clear the + * buffer. Optionally prints debugging output showing the discarded + * characters. */ void dumpBuffer(); }; diff --git a/src/sensors/MaximDS18.cpp b/src/sensors/MaximDS18.cpp index ff9a86363..cdfed926d 100644 --- a/src/sensors/MaximDS18.cpp +++ b/src/sensors/MaximDS18.cpp @@ -56,7 +56,7 @@ String MaximDS18::makeAddressString(DeviceAddress owAddr) { } -// This gets the place the sensor is installed ON THE MAYFLY (ie, pin number) +// This gets the place the sensor is installed ON THE MAYFLY (i.e., pin number) String MaximDS18::getSensorLocation() { return makeAddressString(_OneWireAddress); } diff --git a/src/sensors/ProcessorAnalog.h b/src/sensors/ProcessorAnalog.h index e12525227..636d36747 100644 --- a/src/sensors/ProcessorAnalog.h +++ b/src/sensors/ProcessorAnalog.h @@ -256,7 +256,7 @@ class ProcessorAnalog : public Sensor { * @param dataPin The processor ADC pin used to read the target voltage. Not * all processor pins can be used as analog pins. Those usable as analog * pins generally are numbered with an "A" in front of the number - * - ie, A1. + * - i.e., A1. * @param measurementsToAverage The number of measurements to take and * average before giving a "final" result from the sensor; optional with a * default value of 1. diff --git a/src/sensors/ProcessorStats.h b/src/sensors/ProcessorStats.h index 558fab86e..302ce8411 100644 --- a/src/sensors/ProcessorStats.h +++ b/src/sensors/ProcessorStats.h @@ -26,8 +26,8 @@ * The processor can return the number of "samples" it has taken, the amount of * RAM it has available and, for some boards, the battery voltage (EnviroDIY * Mayfly, Sodaq Mbili, Ndogo, Autonomo, and One, Adafruit Feathers). The - * version of the board is required as input (ie, for a EnviroDIY Mayfly: "v0.3" - * or "v0.4" or "v0.5"). Use a blank value (ie, "") for un-versioned boards. + * version of the board is required as input (i.e., for a EnviroDIY Mayfly: "v0.3" + * or "v0.4" or "v0.5"). Use a blank value (i.e., "") for un-versioned boards. * Please note that while you cannot opt to average more than one sample, it really * makes no sense to do so for the processor. These values are only intended to be * used as diagnostics. diff --git a/src/sensors/YosemitechParent.h b/src/sensors/YosemitechParent.h index 33795607c..5c6522381 100644 --- a/src/sensors/YosemitechParent.h +++ b/src/sensors/YosemitechParent.h @@ -87,7 +87,7 @@ * This will _fry_ any board like the Mayfly that uses 3.3V logic. * You would need a voltage shifter in between the Mayfly and the MAX485 to make it work. * - * The sensor constructor requires as input: the sensor modbus address, a stream instance for data (ie, ```Serial```), and one or two power pins. + * The sensor constructor requires as input: the sensor modbus address, a stream instance for data (i.e., ```Serial```), and one or two power pins. * The Arduino pin controlling the receive and data enable on your RS485-to-TTL adapter and the number of readings to average are optional. * (Use -1 for the second power pin and -1 for the enable pin if these don't apply and you want to average more than one reading.) * For all of these sensors except pH, Yosemitech strongly recommends averaging 10 readings for each measurement. From 1044ddf9078d9ea743fb046a1cceee5c7cb1b3f8 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Fri, 6 Mar 2026 17:27:08 -0500 Subject: [PATCH 495/533] Format, switch to define Signed-off-by: Sara Damiano --- extras/sdi12_address_change/sdi12_address_change.ino | 5 ++--- src/ClockSupport.cpp | 3 ++- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/extras/sdi12_address_change/sdi12_address_change.ino b/extras/sdi12_address_change/sdi12_address_change.ino index f14083e70..a1b08d879 100644 --- a/extras/sdi12_address_change/sdi12_address_change.ino +++ b/extras/sdi12_address_change/sdi12_address_change.ino @@ -21,7 +21,7 @@ #define SERIAL_BAUD 115200 // The pin of the SDI-12 data bus #define DATA_PIN 7 -// The // Sensor power pin (or -1 if not switching power) +// The Sensor power pin (or -1 if not switching power) #define POWER_PIN 22 // Define the SDI-12 bus @@ -33,8 +33,7 @@ char oldAddress = '!'; // invalid address as placeholder // this checks for activity at a particular address // expects a char, '0'-'9', 'a'-'z', or 'A'-'Z' -boolean checkActive( - byte i) { // this checks for activity at a particular address +boolean checkActive(byte i) { Serial.print("Checking address "); Serial.print(static_cast(i)); Serial.print("..."); diff --git a/src/ClockSupport.cpp b/src/ClockSupport.cpp index 49b74a183..fe9a16be1 100644 --- a/src/ClockSupport.cpp +++ b/src/ClockSupport.cpp @@ -12,7 +12,8 @@ #include "LoggerBase.h" // Constants -constexpr time_t SECONDS_IN_DAY = 86400L; // 86400 (60*60*24)seconds in a day +// 86400 (60*60*24) seconds in a day +#define SECONDS_IN_DAY 86400L epochTime::epochTime(time_t timestamp, epochStart epoch) { From af7ceccc599e3ea0f8b83d6041248a31394003f0 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Fri, 6 Mar 2026 17:36:57 -0500 Subject: [PATCH 496/533] Fix missing docs and missing wire include Signed-off-by: Sara Damiano --- src/LoggerBase.h | 3 ++- src/SensorBase.h | 2 ++ src/sensors/AOSongAM2315.h | 1 + 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/LoggerBase.h b/src/LoggerBase.h index 0d69753d1..6ca25132c 100644 --- a/src/LoggerBase.h +++ b/src/LoggerBase.h @@ -243,7 +243,8 @@ class Logger { return _startupMeasurements; } // Backwards-compatibility shims - /// @copydoc setStartupMeasurements + /// @brief Deprecated alias for setStartupMeasurements + /// @param initialShortIntervals The number of startup measurements /// @m_deprecated_since{0,38,0} use setStartupMeasurements void setinitialShortIntervals(int16_t initialShortIntervals) { setStartupMeasurements(initialShortIntervals); diff --git a/src/SensorBase.h b/src/SensorBase.h index 0ae7ce4da..1e4197997 100644 --- a/src/SensorBase.h +++ b/src/SensorBase.h @@ -616,6 +616,8 @@ class Sensor { * for more discussion. * * @param stream An Arduino Stream instance + * @param printStatusBits True to include the sensor status bits in the + * printout, false to only print values and metadata. */ virtual void printData(Stream* stream = &Serial, bool printStatusBits = false); diff --git a/src/sensors/AOSongAM2315.h b/src/sensors/AOSongAM2315.h index 0db462251..da3c89f40 100644 --- a/src/sensors/AOSongAM2315.h +++ b/src/sensors/AOSongAM2315.h @@ -75,6 +75,7 @@ // Include other in-library and external dependencies #include "VariableBase.h" #include "SensorBase.h" +#include /** @ingroup sensor_am2315 */ /**@{*/ From cf4a6c01eaa8895b19c0f5b4908ccb4a252dd87c Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Tue, 10 Mar 2026 17:09:49 -0400 Subject: [PATCH 497/533] Removed all constructors for sensor-associated variables without the sensor Signed-off-by: Sara Damiano --- ChangeLog.md | 2 + src/VariableBase.cpp | 5 - src/VariableBase.h | 22 +--- src/sensors/ANBpH.h | 88 ---------------- src/sensors/AOSongAM2315.h | 20 ---- src/sensors/AOSongDHT.h | 28 ----- src/sensors/AlphasenseCO2.h | 23 ----- src/sensors/AnalogElecConductivity.h | 13 +-- src/sensors/AnalogVoltageBase.h | 1 - src/sensors/ApogeeSQ212.h | 20 ---- src/sensors/AtlasScientificCO2.h | 22 ---- src/sensors/AtlasScientificDO.h | 22 ---- src/sensors/AtlasScientificEC.h | 43 -------- src/sensors/AtlasScientificORP.h | 11 -- src/sensors/AtlasScientificRTD.h | 11 -- src/sensors/AtlasScientificpH.h | 11 -- src/sensors/BoschBME280.h | 40 -------- src/sensors/BoschBMP3xx.h | 30 ------ src/sensors/CampbellClariVUE10.h | 36 ------- src/sensors/CampbellOBS3.h | 19 ---- src/sensors/CampbellRainVUE10.h | 48 --------- src/sensors/Decagon5TM.h | 27 ----- src/sensors/DecagonCTD.h | 29 ------ src/sensors/DecagonES2.h | 18 ---- src/sensors/EverlightALSPT19.h | 33 ------ src/sensors/FreescaleMPL115A2.h | 22 ---- src/sensors/GeoluxHydroCam.h | 22 ---- src/sensors/GroPointGPLP8.h | 30 ------ src/sensors/InSituRDO.h | 44 -------- src/sensors/InSituTrollSdi12a.h | 34 ------ src/sensors/KellerAcculevel.h | 33 ------ src/sensors/KellerNanolevel.h | 33 ------ src/sensors/MaxBotixSonar.h | 10 -- src/sensors/MaximDS18.h | 10 -- src/sensors/MaximDS3231.h | 10 -- src/sensors/MeaSpecMS5803.h | 22 ---- src/sensors/MeterHydros21.h | 34 ------ src/sensors/MeterTeros11.h | 40 -------- src/sensors/PaleoTerraRedox.h | 11 -- src/sensors/ProcessorAnalog.h | 11 -- src/sensors/ProcessorStats.h | 44 -------- src/sensors/RainCounterI2C.h | 22 ---- src/sensors/SensirionSHT4x.h | 22 ---- src/sensors/TEConnectivityMS5837.h | 44 -------- src/sensors/TIADS1x15.h | 11 -- src/sensors/TIINA219.h | 30 ------ src/sensors/TallyCounterI2C.h | 11 -- src/sensors/TurnerCyclops.h | 148 --------------------------- src/sensors/TurnerTurbidityPlus.h | 23 ----- src/sensors/VegaPuls21.h | 58 ----------- src/sensors/YosemitechY4000.h | 87 ---------------- src/sensors/YosemitechY504.h | 33 ------ src/sensors/YosemitechY510.h | 22 ---- src/sensors/YosemitechY511.h | 22 ---- src/sensors/YosemitechY513.h | 21 ---- src/sensors/YosemitechY514.h | 22 ---- src/sensors/YosemitechY520.h | 22 ---- src/sensors/YosemitechY532.h | 32 ------ src/sensors/YosemitechY533.h | 21 ---- src/sensors/YosemitechY551.h | 32 ------ src/sensors/YosemitechY560.h | 32 ------ src/sensors/YosemitechY700.h | 22 ---- src/sensors/ZebraTechDOpto.h | 33 ------ 63 files changed, 4 insertions(+), 1798 deletions(-) diff --git a/ChangeLog.md b/ChangeLog.md index df65af5aa..00cff40e2 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -217,6 +217,8 @@ This affects the following classes: ### Removed +- **BREAKING** Removed all constructors for sensor-associated variables that don't include a pointer to the sensor. +You now *must* create the sensor instance before creating the variable and tie the variable to the sensor when creating the variable. - Unused `_maxSamplesToAverage` parameter of the VariableArray and the `countMaxToAverage()` function. - Unnecessary copy doc calls for inherited functions and properties. - All overrides of the powerUp and powerDown functions that are no longer needed since all sensors have two power pins built in. diff --git a/src/VariableBase.cpp b/src/VariableBase.cpp index 650e79960..b269b74ed 100644 --- a/src/VariableBase.cpp +++ b/src/VariableBase.cpp @@ -53,11 +53,6 @@ Variable::Variable(float (*calcFxn)(), uint8_t decimalResolution, } // Delegating constructors -Variable::Variable(uint8_t sensorVarNum, uint8_t decimalResolution, - const char* varName, const char* varUnit, - const char* varCode) - : Variable(nullptr, sensorVarNum, decimalResolution, varName, varUnit, - varCode, nullptr) {} Variable::Variable(float (*calcFxn)(), uint8_t decimalResolution, const char* varName, const char* varUnit, const char* varCode) diff --git a/src/VariableBase.h b/src/VariableBase.h index 646373166..37a2380c7 100644 --- a/src/VariableBase.h +++ b/src/VariableBase.h @@ -86,27 +86,7 @@ class Variable { Variable(Sensor* parentSense, uint8_t sensorVarNum, uint8_t decimalResolution, const char* varName, const char* varUnit, const char* varCode, const char* uuid); - /** - * @brief Construct a new Variable object for a measured variable - that is, - * one whose values are updated by a sensor - but do not tie it to a - * specific sensor. - * - * @note This constructor is NOT intended to be used outside of this - * libraries. It is intended to be used internally with sensors defined in - * this library. - * - * @param sensorVarNum The position in the sensor's value array of this - * variable's value. - * @param decimalResolution The resolution (in decimal places) of the value. - * @param varName The name of the variable per the [ODM2 variable name - * controlled vocabulary](http://vocabulary.odm2.org/variablename/) - * @param varUnit The unit of the variable per the [ODM2 unit controlled - * vocabulary](http://vocabulary.odm2.org/units/) - * @param varCode A custom code for the variable. This can be any short - * text helping to identify the variable in files. - */ - Variable(uint8_t sensorVarNum, uint8_t decimalResolution, - const char* varName, const char* varUnit, const char* varCode); + /** * @brief Construct a new Variable object for a calculated variable - that diff --git a/src/sensors/ANBpH.h b/src/sensors/ANBpH.h index 2d19c25d1..ad6186c52 100644 --- a/src/sensors/ANBpH.h +++ b/src/sensors/ANBpH.h @@ -733,17 +733,6 @@ class ANBpH_pH : public Variable { : Variable(parentSense, static_cast(ANB_PH_PH_VAR_NUM), static_cast(ANB_PH_PH_RESOLUTION), ANB_PH_PH_VAR_NAME, ANB_PH_PH_UNIT_NAME, varCode, uuid) {} - /** - * @brief Construct a new ANBpH_pH object. - * - * @note This must be tied with a parent ANBpH before it can be - * used. - */ - ANBpH_pH() - : Variable(static_cast(ANB_PH_PH_VAR_NUM), - static_cast(ANB_PH_PH_RESOLUTION), - ANB_PH_PH_VAR_NAME, ANB_PH_PH_UNIT_NAME, - ANB_PH_PH_DEFAULT_CODE) {} /** * @brief Destroy the ANBpH_pH object - no action needed. */ @@ -774,17 +763,6 @@ class ANBpH_Temp : public Variable { static_cast(ANB_PH_TEMP_RESOLUTION), ANB_PH_TEMP_VAR_NAME, ANB_PH_TEMP_UNIT_NAME, varCode, uuid) { } - /** - * @brief Construct a new ANBpH_Temp object. - * - * @note This must be tied with a parent ANBpH before it can be - * used. - */ - ANBpH_Temp() - : Variable(static_cast(ANB_PH_TEMP_VAR_NUM), - static_cast(ANB_PH_TEMP_RESOLUTION), - ANB_PH_TEMP_VAR_NAME, ANB_PH_TEMP_UNIT_NAME, - ANB_PH_TEMP_DEFAULT_CODE) {} /** * @brief Destroy the ANBpH_Temp object - no action needed. */ @@ -815,17 +793,6 @@ class ANBpH_Salinity : public Variable { static_cast(ANB_PH_SALINITY_RESOLUTION), ANB_PH_SALINITY_VAR_NAME, ANB_PH_SALINITY_UNIT_NAME, varCode, uuid) {} - /** - * @brief Construct a new ANBpH_Salinity object. - * - * @note This must be tied with a parent ANBpH object before it can be - * used. - */ - ANBpH_Salinity() - : Variable(static_cast(ANB_PH_SALINITY_VAR_NUM), - static_cast(ANB_PH_SALINITY_RESOLUTION), - ANB_PH_SALINITY_VAR_NAME, ANB_PH_SALINITY_UNIT_NAME, - ANB_PH_SALINITY_DEFAULT_CODE) {} /** * @brief Destroy the ANBpH_Salinity() object - no action * needed. @@ -858,16 +825,6 @@ class ANBpH_SpCond : public Variable { static_cast(ANB_PH_SPCOND_RESOLUTION), ANB_PH_SPCOND_VAR_NAME, ANB_PH_SPCOND_UNIT_NAME, varCode, uuid) {} - /** - * @brief Construct a new ANBpH_SpCond object. - * - * @note This must be tied with a parent ANBpH object before it can be used. - */ - ANBpH_SpCond() - : Variable(static_cast(ANB_PH_SPCOND_VAR_NUM), - static_cast(ANB_PH_SPCOND_RESOLUTION), - ANB_PH_SPCOND_VAR_NAME, ANB_PH_SPCOND_UNIT_NAME, - ANB_PH_SPCOND_DEFAULT_CODE) {} /** * @brief Destroy the ANBpH_SpCond object - no action needed. */ @@ -897,17 +854,6 @@ class ANBpH_EC : public Variable { : Variable(parentSense, static_cast(ANB_PH_EC_VAR_NUM), static_cast(ANB_PH_EC_RESOLUTION), ANB_PH_EC_VAR_NAME, ANB_PH_EC_UNIT_NAME, varCode, uuid) {} - /** - * @brief Construct a new ANBpH_EC object. - * - * @note This must be tied with a parent ANBpH object before it can be - * used. - */ - ANBpH_EC() - : Variable(static_cast(ANB_PH_EC_VAR_NUM), - static_cast(ANB_PH_EC_RESOLUTION), - ANB_PH_EC_VAR_NAME, ANB_PH_EC_UNIT_NAME, - ANB_PH_EC_DEFAULT_CODE) {} /** * @brief Destroy the ANBpH_EC object - no action needed. */ @@ -942,17 +888,6 @@ class ANBpH_HealthCode : public Variable { static_cast(ANB_PH_HEALTH_CODE_RESOLUTION), ANB_PH_HEALTH_CODE_VAR_NAME, ANB_PH_HEALTH_CODE_UNIT_NAME, varCode, uuid) {} - /** - * @brief Construct a new ANBpH_HealthCode object. - * - * @note This must be tied with a parent ANBpH object before it can be - * used. - */ - ANBpH_HealthCode() - : Variable(static_cast(ANB_PH_HEALTH_CODE_VAR_NUM), - static_cast(ANB_PH_HEALTH_CODE_RESOLUTION), - ANB_PH_HEALTH_CODE_VAR_NAME, ANB_PH_HEALTH_CODE_UNIT_NAME, - ANB_PH_HEALTH_CODE_DEFAULT_CODE) {} /** * @brief Destroy the ANBpH_HealthCode object - no action * needed. @@ -988,18 +923,6 @@ class ANBpH_DiagnosticCode : public Variable { static_cast(ANB_PH_DIAGNOSTIC_CODE_RESOLUTION), ANB_PH_DIAGNOSTIC_CODE_VAR_NAME, ANB_PH_DIAGNOSTIC_CODE_UNIT_NAME, varCode, uuid) {} - /** - * @brief Construct a new ANBpH_DiagnosticCode object. - * - * @note This must be tied with a parent ANBpH object before it can be - * used. - */ - ANBpH_DiagnosticCode() - : Variable(static_cast(ANB_PH_DIAGNOSTIC_CODE_VAR_NUM), - static_cast(ANB_PH_DIAGNOSTIC_CODE_RESOLUTION), - ANB_PH_DIAGNOSTIC_CODE_VAR_NAME, - ANB_PH_DIAGNOSTIC_CODE_UNIT_NAME, - ANB_PH_DIAGNOSTIC_CODE_DEFAULT_CODE) {} /** * @brief Destroy the ANBpH_DiagnosticCode object - no action * needed. @@ -1035,17 +958,6 @@ class ANBpH_StatusCode : public Variable { static_cast(ANB_PH_STATUS_CODE_RESOLUTION), ANB_PH_STATUS_CODE_VAR_NAME, ANB_PH_STATUS_CODE_UNIT_NAME, varCode, uuid) {} - /** - * @brief Construct a new ANBpH_StatusCode object. - * - * @note This must be tied with a parent ANBpH object before it can be - * used. - */ - ANBpH_StatusCode() - : Variable(static_cast(ANB_PH_STATUS_CODE_VAR_NUM), - static_cast(ANB_PH_STATUS_CODE_RESOLUTION), - ANB_PH_STATUS_CODE_VAR_NAME, ANB_PH_STATUS_CODE_UNIT_NAME, - ANB_PH_STATUS_CODE_DEFAULT_CODE) {} /** * @brief Destroy the ANBpH_StatusCode object - no action * needed. diff --git a/src/sensors/AOSongAM2315.h b/src/sensors/AOSongAM2315.h index da3c89f40..26d1ddcba 100644 --- a/src/sensors/AOSongAM2315.h +++ b/src/sensors/AOSongAM2315.h @@ -282,16 +282,6 @@ class AOSongAM2315_Humidity : public Variable { static_cast(AM2315_HUMIDITY_RESOLUTION), AM2315_HUMIDITY_VAR_NAME, AM2315_HUMIDITY_UNIT_NAME, varCode, uuid) {} - /** - * @brief Construct a new AOSongAM2315_Humidity object. - * - * @note This must be tied with a parent AOSongAM2315 before it can be used. - */ - AOSongAM2315_Humidity() - : Variable(static_cast(AM2315_HUMIDITY_VAR_NUM), - static_cast(AM2315_HUMIDITY_RESOLUTION), - AM2315_HUMIDITY_VAR_NAME, AM2315_HUMIDITY_UNIT_NAME, - AM2315_HUMIDITY_DEFAULT_CODE) {} /** * @brief Destroy the AOSongAM2315_Humidity object - no action needed. */ @@ -324,16 +314,6 @@ class AOSongAM2315_Temp : public Variable { static_cast(AM2315_TEMP_RESOLUTION), AM2315_TEMP_VAR_NAME, AM2315_TEMP_UNIT_NAME, varCode, uuid) { } - /** - * @brief Construct a new AOSongAM2315_Temp object. - * - * @note This must be tied with a parent AOSongAM2315 before it can be used. - */ - AOSongAM2315_Temp() - : Variable(static_cast(AM2315_TEMP_VAR_NUM), - static_cast(AM2315_TEMP_RESOLUTION), - AM2315_TEMP_VAR_NAME, AM2315_TEMP_UNIT_NAME, - AM2315_TEMP_DEFAULT_CODE) {} /** * @brief Destroy the AOSongAM2315_Temp object - no action needed. */ diff --git a/src/sensors/AOSongDHT.h b/src/sensors/AOSongDHT.h index e31f7a4dc..bcd225a23 100644 --- a/src/sensors/AOSongDHT.h +++ b/src/sensors/AOSongDHT.h @@ -308,16 +308,6 @@ class AOSongDHT_Humidity : public Variable { static_cast(DHT_HUMIDITY_RESOLUTION), DHT_HUMIDITY_VAR_NAME, DHT_HUMIDITY_UNIT_NAME, varCode, uuid) {} - /** - * @brief Construct a new AOSongDHT_Humidity object. - * - * @note This must be tied with a parent AOSongDHT before it can be used. - */ - AOSongDHT_Humidity() - : Variable(static_cast(DHT_HUMIDITY_VAR_NUM), - static_cast(DHT_HUMIDITY_RESOLUTION), - DHT_HUMIDITY_VAR_NAME, DHT_HUMIDITY_UNIT_NAME, - DHT_HUMIDITY_DEFAULT_CODE) {} /** * @brief Destroy the AOSongDHT_Humidity object - no action needed. */ @@ -350,15 +340,6 @@ class AOSongDHT_Temp : public Variable { : Variable(parentSense, static_cast(DHT_TEMP_VAR_NUM), static_cast(DHT_TEMP_RESOLUTION), DHT_TEMP_VAR_NAME, DHT_TEMP_UNIT_NAME, varCode, uuid) {} - /** - * @brief Construct a new AOSongDHT_Temp object. - * - * @note This must be tied with a parent AOSongDHT before it can be used. - */ - AOSongDHT_Temp() - : Variable(static_cast(DHT_TEMP_VAR_NUM), - static_cast(DHT_TEMP_RESOLUTION), DHT_TEMP_VAR_NAME, - DHT_TEMP_UNIT_NAME, DHT_TEMP_DEFAULT_CODE) {} /** * @brief Destroy the AOSongDHT_Temp object - no action needed. */ @@ -391,15 +372,6 @@ class AOSongDHT_HI : public Variable { : Variable(parentSense, static_cast(DHT_HI_VAR_NUM), static_cast(DHT_HI_RESOLUTION), DHT_HI_VAR_NAME, DHT_HI_UNIT_NAME, varCode, uuid) {} - /** - * @brief Construct a new AOSongDHT_HI object. - * - * @note This must be tied with a parent AOSongDHT before it can be used. - */ - AOSongDHT_HI() - : Variable(static_cast(DHT_HI_VAR_NUM), - static_cast(DHT_HI_RESOLUTION), DHT_HI_VAR_NAME, - DHT_HI_UNIT_NAME, DHT_HI_DEFAULT_CODE) {} /** * @brief Destroy the AOSongDHT_HI object - no action needed. */ diff --git a/src/sensors/AlphasenseCO2.h b/src/sensors/AlphasenseCO2.h index 46125b169..043f1fc79 100644 --- a/src/sensors/AlphasenseCO2.h +++ b/src/sensors/AlphasenseCO2.h @@ -365,17 +365,6 @@ class AlphasenseCO2_CO2 : public Variable { static_cast(ALPHASENSE_CO2_RESOLUTION), ALPHASENSE_CO2_VAR_NAME, ALPHASENSE_CO2_UNIT_NAME, varCode, uuid) {} - /** - * @brief Construct a new AlphasenseCO2_CO2 object. - * - * @note This must be tied with a parent AlphasenseCO2 before it can be - * used. - */ - AlphasenseCO2_CO2() - : Variable(static_cast(ALPHASENSE_CO2_VAR_NUM), - static_cast(ALPHASENSE_CO2_RESOLUTION), - ALPHASENSE_CO2_VAR_NAME, ALPHASENSE_CO2_UNIT_NAME, - ALPHASENSE_CO2_DEFAULT_CODE) {} /** * @brief Destroy the AlphasenseCO2_CO2 object - no action needed. */ @@ -410,18 +399,6 @@ class AlphasenseCO2_Voltage : public Variable { static_cast(ALPHASENSE_CO2_VOLTAGE_RESOLUTION), ALPHASENSE_CO2_VOLTAGE_VAR_NAME, ALPHASENSE_CO2_VOLTAGE_UNIT_NAME, varCode, uuid) {} - /** - * @brief Construct a new AlphasenseCO2_Voltage object. - * - * @note This must be tied with a parent AlphasenseCO2 before it can be - * used. - */ - AlphasenseCO2_Voltage() - : Variable(static_cast(ALPHASENSE_CO2_VOLTAGE_VAR_NUM), - static_cast(ALPHASENSE_CO2_VOLTAGE_RESOLUTION), - ALPHASENSE_CO2_VOLTAGE_VAR_NAME, - ALPHASENSE_CO2_VOLTAGE_UNIT_NAME, - ALPHASENSE_CO2_VOLTAGE_DEFAULT_CODE) {} /** * @brief Destroy the AlphasenseCO2_Voltage object - no action needed. */ diff --git a/src/sensors/AnalogElecConductivity.h b/src/sensors/AnalogElecConductivity.h index 3d934b21c..d0324178e 100644 --- a/src/sensors/AnalogElecConductivity.h +++ b/src/sensors/AnalogElecConductivity.h @@ -411,18 +411,7 @@ class AnalogElecConductivity_EC : public Variable { ANALOGELECCONDUCTIVITY_EC_VAR_NAME, ANALOGELECCONDUCTIVITY_EC_UNIT_NAME, varCode, uuid) {} - /** - * @brief Construct a new AnalogElecConductivity_EC object. - * - * @note This must be tied with a parent AnalogElecConductivity before it - * can be used. - */ - AnalogElecConductivity_EC() - : Variable(static_cast(ANALOGELECCONDUCTIVITY_EC_VAR_NUM), - static_cast(ANALOGELECCONDUCTIVITY_EC_RESOLUTION), - ANALOGELECCONDUCTIVITY_EC_VAR_NAME, - ANALOGELECCONDUCTIVITY_EC_UNIT_NAME, - ANALOGELECCONDUCTIVITY_EC_DEFAULT_CODE) {} + /** * @brief Destroy the AnalogElecConductivity_EC object - no action needed. */ diff --git a/src/sensors/AnalogVoltageBase.h b/src/sensors/AnalogVoltageBase.h index fa247803f..499cd964a 100644 --- a/src/sensors/AnalogVoltageBase.h +++ b/src/sensors/AnalogVoltageBase.h @@ -67,7 +67,6 @@ class AnalogVoltageBase { : 1.0f), _supplyVoltage((supplyVoltage > 0.0f) ? supplyVoltage : OPERATING_VOLTAGE) {} - /** * @brief Destroy the AnalogVoltageBase object */ diff --git a/src/sensors/ApogeeSQ212.h b/src/sensors/ApogeeSQ212.h index ffe71868e..1649f6a24 100644 --- a/src/sensors/ApogeeSQ212.h +++ b/src/sensors/ApogeeSQ212.h @@ -332,16 +332,6 @@ class ApogeeSQ212_PAR : public Variable { : Variable(parentSense, static_cast(SQ212_PAR_VAR_NUM), static_cast(SQ212_PAR_RESOLUTION), SQ212_PAR_VAR_NAME, SQ212_PAR_UNIT_NAME, varCode, uuid) {} - /** - * @brief Construct a new ApogeeSQ212_PAR object. - * - * @note This must be tied with a parent ApogeeSQ212 before it can be used. - */ - ApogeeSQ212_PAR() - : Variable(static_cast(SQ212_PAR_VAR_NUM), - static_cast(SQ212_PAR_RESOLUTION), - SQ212_PAR_VAR_NAME, SQ212_PAR_UNIT_NAME, - SQ212_PAR_DEFAULT_CODE) {} /** * @brief Destroy the ApogeeSQ212_PAR object - no action needed. */ @@ -377,16 +367,6 @@ class ApogeeSQ212_Voltage : public Variable { static_cast(SQ212_VOLTAGE_RESOLUTION), SQ212_VOLTAGE_VAR_NAME, SQ212_VOLTAGE_UNIT_NAME, varCode, uuid) {} - /** - * @brief Construct a new ApogeeSQ212_Voltage object. - * - * @note This must be tied with a parent ApogeeSQ212 before it can be used. - */ - ApogeeSQ212_Voltage() - : Variable(static_cast(SQ212_VOLTAGE_VAR_NUM), - static_cast(SQ212_VOLTAGE_RESOLUTION), - SQ212_VOLTAGE_VAR_NAME, SQ212_VOLTAGE_UNIT_NAME, - SQ212_VOLTAGE_DEFAULT_CODE) {} /** * @brief Destroy the ApogeeSQ212_Voltage object - no action needed. */ diff --git a/src/sensors/AtlasScientificCO2.h b/src/sensors/AtlasScientificCO2.h index 6cc1be80e..b469366ef 100644 --- a/src/sensors/AtlasScientificCO2.h +++ b/src/sensors/AtlasScientificCO2.h @@ -274,17 +274,6 @@ class AtlasScientificCO2_CO2 : public Variable { : Variable(parentSense, static_cast(ATLAS_CO2_VAR_NUM), static_cast(ATLAS_CO2_RESOLUTION), ATLAS_CO2_VAR_NAME, ATLAS_CO2_UNIT_NAME, varCode, uuid) {} - /** - * @brief Construct a new AtlasScientificCO2_CO2 object. - * - * @note This must be tied with a parent AtlasScientificCO2 before it can be - * used. - */ - AtlasScientificCO2_CO2() - : Variable(static_cast(ATLAS_CO2_VAR_NUM), - static_cast(ATLAS_CO2_RESOLUTION), - ATLAS_CO2_VAR_NAME, ATLAS_CO2_UNIT_NAME, - ATLAS_CO2_DEFAULT_CODE) {} /** * @brief Destroy the AtlasScientificCO2_CO2 object - no action needed. */ @@ -319,17 +308,6 @@ class AtlasScientificCO2_Temp : public Variable { static_cast(ATLAS_CO2TEMP_RESOLUTION), ATLAS_CO2TEMP_VAR_NAME, ATLAS_CO2TEMP_UNIT_NAME, varCode, uuid) {} - /** - * @brief Construct a new AtlasScientificCO2_Temp object. - * - * @note This must be tied with a parent AtlasScientificCO2 before it can be - * used. - */ - AtlasScientificCO2_Temp() - : Variable(static_cast(ATLAS_CO2TEMP_VAR_NUM), - static_cast(ATLAS_CO2TEMP_RESOLUTION), - ATLAS_CO2TEMP_VAR_NAME, ATLAS_CO2TEMP_UNIT_NAME, - ATLAS_CO2TEMP_DEFAULT_CODE) {} /** * @brief Destroy the AtlasScientificCO2_Temp object - no action needed. */ diff --git a/src/sensors/AtlasScientificDO.h b/src/sensors/AtlasScientificDO.h index 2d04120c2..75adcc81c 100644 --- a/src/sensors/AtlasScientificDO.h +++ b/src/sensors/AtlasScientificDO.h @@ -284,17 +284,6 @@ class AtlasScientificDO_DOmgL : public Variable { static_cast(ATLAS_DOMGL_RESOLUTION), ATLAS_DOMGL_VAR_NAME, ATLAS_DOMGL_UNIT_NAME, varCode, uuid) { } - /** - * @brief Construct a new AtlasScientificDO_DOmgL object. - * - * @note This must be tied with a parent AtlasScientificDO before it can be - * used. - */ - AtlasScientificDO_DOmgL() - : Variable(static_cast(ATLAS_DOMGL_VAR_NUM), - static_cast(ATLAS_DOMGL_RESOLUTION), - ATLAS_DOMGL_VAR_NAME, ATLAS_DOMGL_UNIT_NAME, - ATLAS_DOMGL_DEFAULT_CODE) {} /** * @brief Destroy the AtlasScientificDO_DOmgL object - no action needed. */ @@ -329,17 +318,6 @@ class AtlasScientificDO_DOpct : public Variable { static_cast(ATLAS_DOPCT_RESOLUTION), ATLAS_DOPCT_VAR_NAME, ATLAS_DOPCT_UNIT_NAME, varCode, uuid) { } - /** - * @brief Construct a new AtlasScientificDO_DOpct object. - * - * @note This must be tied with a parent AtlasScientificDO before it can be - * used. - */ - AtlasScientificDO_DOpct() - : Variable(static_cast(ATLAS_DOPCT_VAR_NUM), - static_cast(ATLAS_DOPCT_RESOLUTION), - ATLAS_DOPCT_VAR_NAME, ATLAS_DOPCT_UNIT_NAME, - ATLAS_DOPCT_DEFAULT_CODE) {} /** * @brief Destroy the AtlasScientificDO_DOpct object - no action needed. */ diff --git a/src/sensors/AtlasScientificEC.h b/src/sensors/AtlasScientificEC.h index 645e92701..68ddb6fba 100644 --- a/src/sensors/AtlasScientificEC.h +++ b/src/sensors/AtlasScientificEC.h @@ -346,17 +346,6 @@ class AtlasScientificEC_Cond : public Variable { : Variable(parentSense, static_cast(ATLAS_COND_VAR_NUM), static_cast(ATLAS_COND_RESOLUTION), ATLAS_COND_VAR_NAME, ATLAS_COND_UNIT_NAME, varCode, uuid) {} - /** - * @brief Construct a new AtlasScientificEC_Cond object. - * - * @note This must be tied with a parent AtlasScientificEC before it can be - * used. - */ - AtlasScientificEC_Cond() - : Variable(static_cast(ATLAS_COND_VAR_NUM), - static_cast(ATLAS_COND_RESOLUTION), - ATLAS_COND_VAR_NAME, ATLAS_COND_UNIT_NAME, - ATLAS_COND_DEFAULT_CODE) {} /** * @brief Destroy the AtlasScientificEC_Cond object - no action needed. */ @@ -390,17 +379,6 @@ class AtlasScientificEC_TDS : public Variable { : Variable(parentSense, static_cast(ATLAS_TDS_VAR_NUM), static_cast(ATLAS_TDS_RESOLUTION), ATLAS_TDS_VAR_NAME, ATLAS_TDS_UNIT_NAME, varCode, uuid) {} - /** - * @brief Construct a new AtlasScientificEC_TDS object. - * - * @note This must be tied with a parent AtlasScientificEC before it can be - * used. - */ - AtlasScientificEC_TDS() - : Variable(static_cast(ATLAS_TDS_VAR_NUM), - static_cast(ATLAS_TDS_RESOLUTION), - ATLAS_TDS_VAR_NAME, ATLAS_TDS_UNIT_NAME, - ATLAS_TDS_DEFAULT_CODE) {} /** * @brief Destroy the AtlasScientificEC_TDS object - no action needed. */ @@ -435,17 +413,6 @@ class AtlasScientificEC_Salinity : public Variable { static_cast(ATLAS_SALINITY_RESOLUTION), ATLAS_SALINITY_VAR_NAME, ATLAS_SALINITY_UNIT_NAME, varCode, uuid) {} - /** - * @brief Construct a new AtlasScientificEC_Salinity object. - * - * @note This must be tied with a parent AtlasScientificEC before it can be - * used. - */ - AtlasScientificEC_Salinity() - : Variable(static_cast(ATLAS_SALINITY_VAR_NUM), - static_cast(ATLAS_SALINITY_RESOLUTION), - ATLAS_SALINITY_VAR_NAME, ATLAS_SALINITY_UNIT_NAME, - ATLAS_SALINITY_DEFAULT_CODE) {} /** * @brief Destroy the AtlasScientificEC_Salinity() object - no action * needed. @@ -480,16 +447,6 @@ class AtlasScientificEC_SpecificGravity : public Variable { : Variable(parentSense, static_cast(ATLAS_SG_VAR_NUM), static_cast(ATLAS_SG_RESOLUTION), ATLAS_SG_VAR_NAME, ATLAS_SG_UNIT_NAME, varCode, uuid) {} - /** - * @brief Construct a new AtlasScientificEC_SpecificGravity object. - * - * @note This must be tied with a parent AtlasScientificEC before it can be - * used. - */ - AtlasScientificEC_SpecificGravity() - : Variable(static_cast(ATLAS_SG_VAR_NUM), - static_cast(ATLAS_SG_RESOLUTION), ATLAS_SG_VAR_NAME, - ATLAS_SG_UNIT_NAME, ATLAS_SG_DEFAULT_CODE) {} /** * @brief Destroy the AtlasScientificEC_SpecificGravity() object - no action * needed. diff --git a/src/sensors/AtlasScientificORP.h b/src/sensors/AtlasScientificORP.h index cd925b0da..b1b5adb0c 100644 --- a/src/sensors/AtlasScientificORP.h +++ b/src/sensors/AtlasScientificORP.h @@ -230,17 +230,6 @@ class AtlasScientificORP_Potential : public Variable { : Variable(parentSense, static_cast(ATLAS_ORP_VAR_NUM), static_cast(ATLAS_ORP_RESOLUTION), ATLAS_ORP_VAR_NAME, ATLAS_ORP_UNIT_NAME, varCode, uuid) {} - /** - * @brief Construct a new AtlasScientificORP_Potential object. - * - * @note This must be tied with a parent AtlasScientificORP before it can be - * used. - */ - AtlasScientificORP_Potential() - : Variable(static_cast(ATLAS_ORP_VAR_NUM), - static_cast(ATLAS_ORP_RESOLUTION), - ATLAS_ORP_VAR_NAME, ATLAS_ORP_UNIT_NAME, - ATLAS_ORP_DEFAULT_CODE) {} /** * @brief Destroy the AtlasScientificORP_Potential() object - no action * needed. diff --git a/src/sensors/AtlasScientificRTD.h b/src/sensors/AtlasScientificRTD.h index 0e1d074f4..a5e0edee2 100644 --- a/src/sensors/AtlasScientificRTD.h +++ b/src/sensors/AtlasScientificRTD.h @@ -237,17 +237,6 @@ class AtlasScientificRTD_Temp : public Variable { : Variable(parentSense, static_cast(ATLAS_RTD_VAR_NUM), static_cast(ATLAS_RTD_RESOLUTION), ATLAS_RTD_VAR_NAME, ATLAS_RTD_UNIT_NAME, varCode, uuid) {} - /** - * @brief Construct a new AtlasScientificRTD_Temp object. - * - * @note This must be tied with a parent AtlasScientificRTD before it can be - * used. - */ - AtlasScientificRTD_Temp() - : Variable(static_cast(ATLAS_RTD_VAR_NUM), - static_cast(ATLAS_RTD_RESOLUTION), - ATLAS_RTD_VAR_NAME, ATLAS_RTD_UNIT_NAME, - ATLAS_RTD_DEFAULT_CODE) {} /** * @brief Destroy the AtlasScientificRTD_Temp object - no action needed. */ diff --git a/src/sensors/AtlasScientificpH.h b/src/sensors/AtlasScientificpH.h index 3e6daa7fd..75068e41d 100644 --- a/src/sensors/AtlasScientificpH.h +++ b/src/sensors/AtlasScientificpH.h @@ -201,7 +201,6 @@ class AtlasScientificpH : public AtlasParent { ATLAS_PH_WARM_UP_TIME_MS, ATLAS_PH_STABILIZATION_TIME_MS, ATLAS_PH_MEASUREMENT_TIME_MS, ATLAS_PH_INC_CALC_VARIABLES) {} - /** * @brief Destroy the Atlas Scientific pH object */ @@ -238,16 +237,6 @@ class AtlasScientificpH_pH : public Variable { : Variable(parentSense, static_cast(ATLAS_PH_VAR_NUM), static_cast(ATLAS_PH_RESOLUTION), ATLAS_PH_VAR_NAME, ATLAS_PH_UNIT_NAME, varCode, uuid) {} - /** - * @brief Construct a new AtlasScientificpH_pH object. - * - * @note This must be tied with a parent AtlasScientificpH before it can be - * used. - */ - AtlasScientificpH_pH() - : Variable(static_cast(ATLAS_PH_VAR_NUM), - static_cast(ATLAS_PH_RESOLUTION), ATLAS_PH_VAR_NAME, - ATLAS_PH_UNIT_NAME, ATLAS_PH_DEFAULT_CODE) {} /** * @brief Destroy the AtlasScientificpH_pH object - no action needed. */ diff --git a/src/sensors/BoschBME280.h b/src/sensors/BoschBME280.h index 66b0c918d..fb1984890 100644 --- a/src/sensors/BoschBME280.h +++ b/src/sensors/BoschBME280.h @@ -369,16 +369,6 @@ class BoschBME280_Temp : public Variable { static_cast(BME280_TEMP_RESOLUTION), BME280_TEMP_VAR_NAME, BME280_TEMP_UNIT_NAME, varCode, uuid) { } - /** - * @brief Construct a new BoschBME280_Temp object. - * - * @note This must be tied with a parent BoschBME280 before it can be used. - */ - BoschBME280_Temp() - : Variable(static_cast(BME280_TEMP_VAR_NUM), - static_cast(BME280_TEMP_RESOLUTION), - BME280_TEMP_VAR_NAME, BME280_TEMP_UNIT_NAME, - BME280_TEMP_DEFAULT_CODE) {} /** * @brief Destroy the BoschBME280_Temp object - no action needed. */ @@ -414,16 +404,6 @@ class BoschBME280_Humidity : public Variable { static_cast(BME280_HUMIDITY_RESOLUTION), BME280_HUMIDITY_VAR_NAME, BME280_HUMIDITY_UNIT_NAME, varCode, uuid) {} - /** - * @brief Construct a new BoschBME280_Humidity object. - * - * @note This must be tied with a parent BoschBME280 before it can be used. - */ - BoschBME280_Humidity() - : Variable(static_cast(BME280_HUMIDITY_VAR_NUM), - static_cast(BME280_HUMIDITY_RESOLUTION), - BME280_HUMIDITY_VAR_NAME, BME280_HUMIDITY_UNIT_NAME, - BME280_HUMIDITY_DEFAULT_CODE) {} /** * @brief Destroy the BoschBME280_Humidity object - no action needed. */ @@ -459,16 +439,6 @@ class BoschBME280_Pressure : public Variable { static_cast(BME280_PRESSURE_RESOLUTION), BME280_PRESSURE_VAR_NAME, BME280_PRESSURE_UNIT_NAME, varCode, uuid) {} - /** - * @brief Construct a new BoschBME280_Pressure object. - * - * @note This must be tied with a parent BoschBME280 before it can be used. - */ - BoschBME280_Pressure() - : Variable(static_cast(BME280_PRESSURE_VAR_NUM), - static_cast(BME280_PRESSURE_RESOLUTION), - BME280_PRESSURE_VAR_NAME, BME280_PRESSURE_UNIT_NAME, - BME280_PRESSURE_DEFAULT_CODE) {} /** * @brief Destroy the BoschBME280_Pressure object - no action needed. */ @@ -504,16 +474,6 @@ class BoschBME280_Altitude : public Variable { static_cast(BME280_ALTITUDE_RESOLUTION), BME280_ALTITUDE_VAR_NAME, BME280_ALTITUDE_UNIT_NAME, varCode, uuid) {} - /** - * @brief Construct a new BoschBME280_Altitude object. - * - * @note This must be tied with a parent BoschBME280 before it can be used. - */ - BoschBME280_Altitude() - : Variable(static_cast(BME280_ALTITUDE_VAR_NUM), - static_cast(BME280_ALTITUDE_RESOLUTION), - BME280_ALTITUDE_VAR_NAME, BME280_ALTITUDE_UNIT_NAME, - BME280_ALTITUDE_DEFAULT_CODE) {} /** * @brief Destroy the BoschBME280_Altitude object - no action needed. */ diff --git a/src/sensors/BoschBMP3xx.h b/src/sensors/BoschBMP3xx.h index 2f04d2c36..5988ea9ed 100644 --- a/src/sensors/BoschBMP3xx.h +++ b/src/sensors/BoschBMP3xx.h @@ -607,16 +607,6 @@ class BoschBMP3xx_Temp : public Variable { static_cast(BMP3XX_TEMP_RESOLUTION), BMP3XX_TEMP_VAR_NAME, BMP3XX_TEMP_UNIT_NAME, varCode, uuid) { } - /** - * @brief Construct a new BoschBMP3xx_Temp object. - * - * @note This must be tied with a parent BoschBMP3xx before it can be used. - */ - BoschBMP3xx_Temp() - : Variable(static_cast(BMP3XX_TEMP_VAR_NUM), - static_cast(BMP3XX_TEMP_RESOLUTION), - BMP3XX_TEMP_VAR_NAME, BMP3XX_TEMP_UNIT_NAME, - BMP3XX_TEMP_DEFAULT_CODE) {} /** * @brief Destroy the BoschBMP3xx_Temp object - no action needed. */ @@ -652,16 +642,6 @@ class BoschBMP3xx_Pressure : public Variable { static_cast(BMP3XX_PRESSURE_RESOLUTION), BMP3XX_PRESSURE_VAR_NAME, BMP3XX_PRESSURE_UNIT_NAME, varCode, uuid) {} - /** - * @brief Construct a new BoschBMP3xx_Pressure object. - * - * @note This must be tied with a parent BoschBMP3xx before it can be used. - */ - BoschBMP3xx_Pressure() - : Variable(static_cast(BMP3XX_PRESSURE_VAR_NUM), - static_cast(BMP3XX_PRESSURE_RESOLUTION), - BMP3XX_PRESSURE_VAR_NAME, BMP3XX_PRESSURE_UNIT_NAME, - BMP3XX_PRESSURE_DEFAULT_CODE) {} /** * @brief Destroy the BoschBMP3xx_Pressure object - no action needed. */ @@ -697,16 +677,6 @@ class BoschBMP3xx_Altitude : public Variable { static_cast(BMP3XX_ALTITUDE_RESOLUTION), BMP3XX_ALTITUDE_VAR_NAME, BMP3XX_ALTITUDE_UNIT_NAME, varCode, uuid) {} - /** - * @brief Construct a new BoschBMP3xx_Altitude object. - * - * @note This must be tied with a parent BoschBMP3xx before it can be used. - */ - BoschBMP3xx_Altitude() - : Variable(static_cast(BMP3XX_ALTITUDE_VAR_NUM), - static_cast(BMP3XX_ALTITUDE_RESOLUTION), - BMP3XX_ALTITUDE_VAR_NAME, BMP3XX_ALTITUDE_UNIT_NAME, - BMP3XX_ALTITUDE_DEFAULT_CODE) {} /** * @brief Destroy the BoschBMP3xx_Altitude object - no action needed. */ diff --git a/src/sensors/CampbellClariVUE10.h b/src/sensors/CampbellClariVUE10.h index 2c585b327..4d87218ca 100644 --- a/src/sensors/CampbellClariVUE10.h +++ b/src/sensors/CampbellClariVUE10.h @@ -251,7 +251,6 @@ class CampbellClariVUE10 : public SDI12Sensors { CLARIVUE10_WARM_UP_TIME_MS, CLARIVUE10_STABILIZATION_TIME_MS, CLARIVUE10_MEASUREMENT_TIME_MS, CLARIVUE10_EXTRA_WAKE_TIME_MS, CLARIVUE10_INC_CALC_VARIABLES) {} - /** * @brief Destroy the Campbell ClariVUE10 object */ @@ -288,18 +287,6 @@ class CampbellClariVUE10_Turbidity : public Variable { static_cast(CLARIVUE10_TURBIDITY_RESOLUTION), CLARIVUE10_TURBIDITY_VAR_NAME, CLARIVUE10_TURBIDITY_UNIT_NAME, varCode, uuid) {} - /** - * @brief Construct a new CampbellClariVUE10_Turbidity object. - * - * @note This must be tied with a parent CampbellClariVUE10 before it can be - * used. - */ - CampbellClariVUE10_Turbidity() - : Variable(static_cast(CLARIVUE10_TURBIDITY_VAR_NUM), - static_cast(CLARIVUE10_TURBIDITY_RESOLUTION), - CLARIVUE10_TURBIDITY_VAR_NAME, - CLARIVUE10_TURBIDITY_UNIT_NAME, - CLARIVUE10_TURBIDITY_DEFAULT_CODE) {} /** * @brief Destroy the CampbellClariVUE10_Turbidity object - no action * needed. @@ -336,17 +323,6 @@ class CampbellClariVUE10_Temp : public Variable { static_cast(CLARIVUE10_TEMP_RESOLUTION), CLARIVUE10_TEMP_VAR_NAME, CLARIVUE10_TEMP_UNIT_NAME, varCode, uuid) {} - /** - * @brief Construct a new CampbellClariVUE10_Temp object. - * - * @note This must be tied with a parent CampbellClariVUE10 before it can be - * used. - */ - CampbellClariVUE10_Temp() - : Variable(static_cast(CLARIVUE10_TEMP_VAR_NUM), - static_cast(CLARIVUE10_TEMP_RESOLUTION), - CLARIVUE10_TEMP_VAR_NAME, CLARIVUE10_TEMP_UNIT_NAME, - CLARIVUE10_TEMP_DEFAULT_CODE) {} /** * @brief Destroy the CampbellClariVUE10_Temp object - no action needed. */ @@ -383,18 +359,6 @@ class CampbellClariVUE10_ErrorCode : public Variable { static_cast(CLARIVUE10_ERRORCODE_RESOLUTION), CLARIVUE10_ERRORCODE_VAR_NAME, CLARIVUE10_ERRORCODE_UNIT_NAME, varCode, uuid) {} - /** - * @brief Construct a new CampbellClariVUE10_ErrorCode object. - * - * @note This must be tied with a parent CampbellClariVUE10 before it can be - * used. - */ - CampbellClariVUE10_ErrorCode() - : Variable(static_cast(CLARIVUE10_ERRORCODE_VAR_NUM), - static_cast(CLARIVUE10_ERRORCODE_RESOLUTION), - CLARIVUE10_ERRORCODE_VAR_NAME, - CLARIVUE10_ERRORCODE_UNIT_NAME, - CLARIVUE10_ERRORCODE_DEFAULT_CODE) {} /** * @brief Destroy the CampbellClariVUE10_ErrorCode object - no action * needed. diff --git a/src/sensors/CampbellOBS3.h b/src/sensors/CampbellOBS3.h index e4638fac2..e085174bf 100644 --- a/src/sensors/CampbellOBS3.h +++ b/src/sensors/CampbellOBS3.h @@ -339,15 +339,6 @@ class CampbellOBS3_Turbidity : public Variable { : Variable(parentSense, static_cast(OBS3_TURB_VAR_NUM), static_cast(OBS3_RESOLUTION), OBS3_TURB_VAR_NAME, OBS3_TURB_UNIT_NAME, varCode, uuid) {} - /** - * @brief Construct a new CampbellOBS3_Turbidity object. - * - * @note This must be tied with a parent CampbellOBS3 before it can be used. - */ - CampbellOBS3_Turbidity() - : Variable(static_cast(OBS3_TURB_VAR_NUM), - static_cast(OBS3_RESOLUTION), OBS3_TURB_VAR_NAME, - OBS3_TURB_UNIT_NAME, OBS3_TURB_DEFAULT_CODE) {} /** * @brief Destroy the Campbell OBS3 Turbidity object */ @@ -385,16 +376,6 @@ class CampbellOBS3_Voltage : public Variable { static_cast(OBS3_VOLTAGE_RESOLUTION), OBS3_VOLTAGE_VAR_NAME, OBS3_VOLTAGE_UNIT_NAME, varCode, uuid) {} - /** - * @brief Construct a new CampbellOBS3_Voltage object. - * - * @note This must be tied with a parent CampbellOBS3 before it can be used. - */ - CampbellOBS3_Voltage() - : Variable(static_cast(OBS3_VOLTAGE_VAR_NUM), - static_cast(OBS3_VOLTAGE_RESOLUTION), - OBS3_VOLTAGE_VAR_NAME, OBS3_VOLTAGE_UNIT_NAME, - OBS3_VOLTAGE_DEFAULT_CODE) {} /** * @brief Destroy the CampbellOBS3_Voltage object - no action needed. */ diff --git a/src/sensors/CampbellRainVUE10.h b/src/sensors/CampbellRainVUE10.h index 9ad672c8e..5efb72121 100644 --- a/src/sensors/CampbellRainVUE10.h +++ b/src/sensors/CampbellRainVUE10.h @@ -290,7 +290,6 @@ class CampbellRainVUE10 : public SDI12Sensors { RAINVUE10_WARM_UP_TIME_MS, RAINVUE10_STABILIZATION_TIME_MS, RAINVUE10_MEASUREMENT_TIME_MS, RAINVUE10_EXTRA_WAKE_TIME_MS, RAINVUE10_INC_CALC_VARIABLES) {} - /** * @brief Destroy the Campbell RainVUE10 object */ @@ -327,18 +326,6 @@ class CampbellRainVUE10_Precipitation : public Variable { static_cast(RAINVUE10_PRECIPITATION_RESOLUTION), RAINVUE10_PRECIPITATION_VAR_NAME, RAINVUE10_PRECIPITATION_UNIT_NAME, varCode, uuid) {} - /** - * @brief Construct a new CampbellRainVUE10_Precipitation object. - * - * @note This must be tied with a parent CampbellRainVUE10 before it can be - * used. - */ - CampbellRainVUE10_Precipitation() - : Variable(static_cast(RAINVUE10_PRECIPITATION_VAR_NUM), - static_cast(RAINVUE10_PRECIPITATION_RESOLUTION), - RAINVUE10_PRECIPITATION_VAR_NAME, - RAINVUE10_PRECIPITATION_UNIT_NAME, - RAINVUE10_PRECIPITATION_DEFAULT_CODE) {} /** * @brief Destroy the CampbellRainVUE10_Precipitation object - no action * needed. @@ -375,17 +362,6 @@ class CampbellRainVUE10_Tips : public Variable { static_cast(RAINVUE10_TIPS_RESOLUTION), RAINVUE10_TIPS_VAR_NAME, RAINVUE10_TIPS_UNIT_NAME, varCode, uuid) {} - /** - * @brief Construct a new CampbellRainVUE10_Tips object. - * - * @note This must be tied with a parent CampbellRainVUE10 before it can be - * used. - */ - CampbellRainVUE10_Tips() - : Variable(static_cast(RAINVUE10_TIPS_VAR_NUM), - static_cast(RAINVUE10_TIPS_RESOLUTION), - RAINVUE10_TIPS_VAR_NAME, RAINVUE10_TIPS_UNIT_NAME, - RAINVUE10_TIPS_DEFAULT_CODE) {} /** * @brief Destroy the CampbellRainVUE10_Tips object - no action needed. */ @@ -422,18 +398,6 @@ class CampbellRainVUE10_RainRateAve : public Variable { static_cast(RAINVUE10_RAINRATEAVE_RESOLUTION), RAINVUE10_RAINRATEAVE_VAR_NAME, RAINVUE10_RAINRATEAVE_UNIT_NAME, varCode, uuid) {} - /** - * @brief Construct a new CampbellRainVUE10_RainRateAve object. - * - * @note This must be tied with a parent CampbellRainVUE10 before it can be - * used. - */ - CampbellRainVUE10_RainRateAve() - : Variable(static_cast(RAINVUE10_RAINRATEAVE_VAR_NUM), - static_cast(RAINVUE10_RAINRATEAVE_RESOLUTION), - RAINVUE10_RAINRATEAVE_VAR_NAME, - RAINVUE10_RAINRATEAVE_UNIT_NAME, - RAINVUE10_RAINRATEAVE_DEFAULT_CODE) {} /** * @brief Destroy the CampbellRainVUE10_RainRateAve object - no action * needed. @@ -472,18 +436,6 @@ class CampbellRainVUE10_RainRateMax : public Variable { static_cast(RAINVUE10_RAINRATEMAX_RESOLUTION), RAINVUE10_RAINRATEMAX_VAR_NAME, RAINVUE10_RAINRATEMAX_UNIT_NAME, varCode, uuid) {} - /** - * @brief Construct a new CampbellRainVUE10_RainRateMax object. - * - * @note This must be tied with a parent CampbellRainVUE10 before it can be - * used. - */ - CampbellRainVUE10_RainRateMax() - : Variable(static_cast(RAINVUE10_RAINRATEMAX_VAR_NUM), - static_cast(RAINVUE10_RAINRATEMAX_RESOLUTION), - RAINVUE10_RAINRATEMAX_VAR_NAME, - RAINVUE10_RAINRATEMAX_UNIT_NAME, - RAINVUE10_RAINRATEMAX_DEFAULT_CODE) {} /** * @brief Destroy the CampbellRainVUE10_RainRateMax object - no action * needed. diff --git a/src/sensors/Decagon5TM.h b/src/sensors/Decagon5TM.h index 67ddc7443..2f6520ec6 100644 --- a/src/sensors/Decagon5TM.h +++ b/src/sensors/Decagon5TM.h @@ -318,15 +318,6 @@ class Decagon5TM_Ea : public Variable { : Variable(parentSense, static_cast(TM_EA_VAR_NUM), static_cast(TM_EA_RESOLUTION), TM_EA_VAR_NAME, TM_EA_UNIT_NAME, varCode, uuid) {} - /** - * @brief Construct a new Decagon5TM_Ea object. - * - * @note This must be tied with a parent Decagon5TM before it can be used. - */ - Decagon5TM_Ea() - : Variable(static_cast(TM_EA_VAR_NUM), - static_cast(TM_EA_RESOLUTION), TM_EA_VAR_NAME, - TM_EA_UNIT_NAME, TM_EA_DEFAULT_CODE) {} /** * @brief Destroy the Decagon5TM_Ea object - no action needed. */ @@ -359,15 +350,6 @@ class Decagon5TM_Temp : public Variable { : Variable(parentSense, static_cast(TM_TEMP_VAR_NUM), static_cast(TM_TEMP_RESOLUTION), TM_TEMP_VAR_NAME, TM_TEMP_UNIT_NAME, varCode, uuid) {} - /** - * @brief Construct a new Decagon5TM_Temp object. - * - * @note This must be tied with a parent Decagon5TM before it can be used. - */ - Decagon5TM_Temp() - : Variable(static_cast(TM_TEMP_VAR_NUM), - static_cast(TM_TEMP_RESOLUTION), TM_TEMP_VAR_NAME, - TM_TEMP_UNIT_NAME, TM_TEMP_DEFAULT_CODE) {} /** * @brief Destroy the Decagon5TM_Temp object - no action needed. */ @@ -400,15 +382,6 @@ class Decagon5TM_VWC : public Variable { : Variable(parentSense, static_cast(TM_VWC_VAR_NUM), static_cast(TM_VWC_RESOLUTION), TM_VWC_VAR_NAME, TM_VWC_UNIT_NAME, varCode, uuid) {} - /** - * @brief Construct a new Decagon5TM_VWC object. - * - * @note This must be tied with a parent Decagon5TM before it can be used. - */ - Decagon5TM_VWC() - : Variable(static_cast(TM_VWC_VAR_NUM), - static_cast(TM_VWC_RESOLUTION), TM_VWC_VAR_NAME, - TM_VWC_UNIT_NAME, TM_VWC_DEFAULT_CODE) {} /** * @brief Destroy the Decagon5TM_VWC object - no action needed. */ diff --git a/src/sensors/DecagonCTD.h b/src/sensors/DecagonCTD.h index ac62e860c..931184fe6 100644 --- a/src/sensors/DecagonCTD.h +++ b/src/sensors/DecagonCTD.h @@ -252,7 +252,6 @@ class DecagonCTD : public SDI12Sensors { "DecagonCTD", CTD_NUM_VARIABLES, CTD_WARM_UP_TIME_MS, CTD_STABILIZATION_TIME_MS, CTD_MEASUREMENT_TIME_MS, CTD_EXTRA_WAKE_TIME_MS, CTD_INC_CALC_VARIABLES) {} - /** * @brief Destroy the Decagon CTD object */ @@ -285,15 +284,6 @@ class DecagonCTD_Cond : public Variable { : Variable(parentSense, static_cast(CTD_COND_VAR_NUM), static_cast(CTD_COND_RESOLUTION), CTD_COND_VAR_NAME, CTD_COND_UNIT_NAME, varCode, uuid) {} - /** - * @brief Construct a new DecagonCTD_Cond object. - * - * @note This must be tied with a parent DecagonCTD before it can be used. - */ - DecagonCTD_Cond() - : Variable(static_cast(CTD_COND_VAR_NUM), - static_cast(CTD_COND_RESOLUTION), CTD_COND_VAR_NAME, - CTD_COND_UNIT_NAME, CTD_COND_DEFAULT_CODE) {} /** * @brief Destroy the DecagonCTD_Cond object - no action needed. */ @@ -326,15 +316,6 @@ class DecagonCTD_Temp : public Variable { : Variable(parentSense, static_cast(CTD_TEMP_VAR_NUM), static_cast(CTD_TEMP_RESOLUTION), CTD_TEMP_VAR_NAME, CTD_TEMP_UNIT_NAME, varCode, uuid) {} - /** - * @brief Construct a new DecagonCTD_Temp object. - * - * @note This must be tied with a parent DecagonCTD before it can be used. - */ - DecagonCTD_Temp() - : Variable(static_cast(CTD_TEMP_VAR_NUM), - static_cast(CTD_TEMP_RESOLUTION), CTD_TEMP_VAR_NAME, - CTD_TEMP_UNIT_NAME, CTD_TEMP_DEFAULT_CODE) {} /** * @brief Destroy the DecagonCTD_Temp object - no action needed. */ @@ -367,16 +348,6 @@ class DecagonCTD_Depth : public Variable { : Variable(parentSense, static_cast(CTD_DEPTH_VAR_NUM), static_cast(CTD_DEPTH_RESOLUTION), CTD_DEPTH_VAR_NAME, CTD_DEPTH_UNIT_NAME, varCode, uuid) {} - /** - * @brief Construct a new DecagonCTD_Depth object. - * - * @note This must be tied with a parent DecagonCTD before it can be used. - */ - DecagonCTD_Depth() - : Variable(static_cast(CTD_DEPTH_VAR_NUM), - static_cast(CTD_DEPTH_RESOLUTION), - CTD_DEPTH_VAR_NAME, CTD_DEPTH_UNIT_NAME, - CTD_DEPTH_DEFAULT_CODE) {} /** * @brief Destroy the DecagonCTD_Depth object - no action needed. */ diff --git a/src/sensors/DecagonES2.h b/src/sensors/DecagonES2.h index 6a9f4367d..3ae8b67ab 100644 --- a/src/sensors/DecagonES2.h +++ b/src/sensors/DecagonES2.h @@ -247,15 +247,6 @@ class DecagonES2_Cond : public Variable { : Variable(parentSense, static_cast(ES2_COND_VAR_NUM), static_cast(ES2_COND_RESOLUTION), ES2_COND_VAR_NAME, ES2_COND_UNIT_NAME, varCode, uuid) {} - /** - * @brief Construct a new DecagonES2_Cond object. - * - * @note This must be tied with a parent DecagonES2 before it can be used. - */ - DecagonES2_Cond() - : Variable(static_cast(ES2_COND_VAR_NUM), - static_cast(ES2_COND_RESOLUTION), ES2_COND_VAR_NAME, - ES2_COND_UNIT_NAME, ES2_COND_DEFAULT_CODE) {} /** * @brief Destroy the DecagonES2_Cond object - no action needed. */ @@ -287,15 +278,6 @@ class DecagonES2_Temp : public Variable { : Variable(parentSense, static_cast(ES2_TEMP_VAR_NUM), static_cast(ES2_TEMP_RESOLUTION), ES2_TEMP_VAR_NAME, ES2_TEMP_UNIT_NAME, varCode, uuid) {} - /** - * @brief Construct a new DecagonES2_Temp object. - * - * @note This must be tied with a parent DecagonES2 before it can be used. - */ - DecagonES2_Temp() - : Variable(static_cast(ES2_TEMP_VAR_NUM), - static_cast(ES2_TEMP_RESOLUTION), ES2_TEMP_VAR_NAME, - ES2_TEMP_UNIT_NAME, ES2_TEMP_DEFAULT_CODE) {} /** * @brief Destroy the DecagonES2_Temp object - no action needed. */ diff --git a/src/sensors/EverlightALSPT19.h b/src/sensors/EverlightALSPT19.h index 82e0a7a45..12cba2be1 100644 --- a/src/sensors/EverlightALSPT19.h +++ b/src/sensors/EverlightALSPT19.h @@ -359,17 +359,6 @@ class EverlightALSPT19_Voltage : public Variable { static_cast(ALSPT19_VOLTAGE_RESOLUTION), ALSPT19_VOLTAGE_VAR_NAME, ALSPT19_VOLTAGE_UNIT_NAME, varCode, uuid) {} - /** - * @brief Construct a new EverlightALSPT19_Voltage object. - * - * @note This must be tied with a parent EverlightALSPT19 before it can be - * used. - */ - EverlightALSPT19_Voltage() - : Variable(static_cast(ALSPT19_VOLTAGE_VAR_NUM), - static_cast(ALSPT19_VOLTAGE_RESOLUTION), - ALSPT19_VOLTAGE_VAR_NAME, ALSPT19_VOLTAGE_UNIT_NAME, - ALSPT19_VOLTAGE_DEFAULT_CODE) {} /** * @brief Destroy the EverlightALSPT19_Voltage object - no action needed. */ @@ -403,17 +392,6 @@ class EverlightALSPT19_Current : public Variable { static_cast(ALSPT19_CURRENT_RESOLUTION), ALSPT19_CURRENT_VAR_NAME, ALSPT19_CURRENT_UNIT_NAME, varCode, uuid) {} - /** - * @brief Construct a new EverlightALSPT19_Current object. - * - * @note This must be tied with a parent EverlightALSPT19 before it can be - * used. - */ - EverlightALSPT19_Current() - : Variable(static_cast(ALSPT19_CURRENT_VAR_NUM), - static_cast(ALSPT19_CURRENT_RESOLUTION), - ALSPT19_CURRENT_VAR_NAME, ALSPT19_CURRENT_UNIT_NAME, - ALSPT19_CURRENT_DEFAULT_CODE) {} /** * @brief Destroy the EverlightALSPT19_Current object - no action needed. */ @@ -448,17 +426,6 @@ class EverlightALSPT19_Illuminance : public Variable { static_cast(ALSPT19_ILLUMINANCE_RESOLUTION), ALSPT19_ILLUMINANCE_VAR_NAME, ALSPT19_ILLUMINANCE_UNIT_NAME, varCode, uuid) {} - /** - * @brief Construct a new EverlightALSPT19_Illuminance object. - * - * @note This must be tied with a parent EverlightALSPT19 before it can be - * used. - */ - EverlightALSPT19_Illuminance() - : Variable(static_cast(ALSPT19_ILLUMINANCE_VAR_NUM), - static_cast(ALSPT19_ILLUMINANCE_RESOLUTION), - ALSPT19_ILLUMINANCE_VAR_NAME, ALSPT19_ILLUMINANCE_UNIT_NAME, - ALSPT19_ILLUMINANCE_DEFAULT_CODE) {} /** * @brief Destroy the EverlightALSPT19_Illuminance object - no action * needed. diff --git a/src/sensors/FreescaleMPL115A2.h b/src/sensors/FreescaleMPL115A2.h index 39c20da40..692ade432 100644 --- a/src/sensors/FreescaleMPL115A2.h +++ b/src/sensors/FreescaleMPL115A2.h @@ -287,17 +287,6 @@ class FreescaleMPL115A2_Temp : public Variable { static_cast(MPL115A2_TEMP_RESOLUTION), MPL115A2_TEMP_VAR_NAME, MPL115A2_TEMP_UNIT_NAME, varCode, uuid) {} - /** - * @brief Construct a new FreescaleMPL115A2_Temp object. - * - * @note This must be tied with a parent FreescaleMPL115A2 before it can be - * used. - */ - FreescaleMPL115A2_Temp() - : Variable(static_cast(MPL115A2_TEMP_VAR_NUM), - static_cast(MPL115A2_TEMP_RESOLUTION), - MPL115A2_TEMP_VAR_NAME, MPL115A2_TEMP_UNIT_NAME, - MPL115A2_TEMP_DEFAULT_CODE) {} /** * @brief Destroy the FreescaleMPL115A2_Temp object - no action needed. */ @@ -341,17 +330,6 @@ class FreescaleMPL115A2_Pressure : public Variable { static_cast(MPL115A2_PRESSURE_RESOLUTION), MPL115A2_PRESSURE_VAR_NAME, MPL115A2_PRESSURE_UNIT_NAME, varCode, uuid) {} - /** - * @brief Construct a new FreescaleMPL115A2_Pressure object. - * - * @note This must be tied with a parent FreescaleMPL115A2 before it can be - * used. - */ - FreescaleMPL115A2_Pressure() - : Variable(static_cast(MPL115A2_PRESSURE_VAR_NUM), - static_cast(MPL115A2_PRESSURE_RESOLUTION), - MPL115A2_PRESSURE_VAR_NAME, MPL115A2_PRESSURE_UNIT_NAME, - MPL115A2_PRESSURE_DEFAULT_CODE) {} /** * @brief Destroy the FreescaleMPL115A2_Pressure object - no action needed. */ diff --git a/src/sensors/GeoluxHydroCam.h b/src/sensors/GeoluxHydroCam.h index 8a4331cad..98cedd4d7 100644 --- a/src/sensors/GeoluxHydroCam.h +++ b/src/sensors/GeoluxHydroCam.h @@ -447,17 +447,6 @@ class GeoluxHydroCam_ImageSize : public Variable { static_cast(HYDROCAM_SIZE_RESOLUTION), HYDROCAM_SIZE_VAR_NAME, HYDROCAM_SIZE_UNIT_NAME, varCode, uuid) {} - /** - * @brief Construct a new GeoluxHydroCam_ImageSize object. - * - * @note This must be tied with a parent GeoluxHydroCam before it can be - * used. - */ - GeoluxHydroCam_ImageSize() - : Variable(static_cast(HYDROCAM_SIZE_VAR_NUM), - static_cast(HYDROCAM_SIZE_RESOLUTION), - HYDROCAM_SIZE_VAR_NAME, HYDROCAM_SIZE_UNIT_NAME, - HYDROCAM_SIZE_DEFAULT_CODE) {} /** * @brief Destroy the GeoluxHydroCam_ImageSize object - no action needed. */ @@ -493,17 +482,6 @@ class GeoluxHydroCam_ByteError : public Variable { static_cast(HYDROCAM_ERROR_RESOLUTION), HYDROCAM_ERROR_VAR_NAME, HYDROCAM_ERROR_UNIT_NAME, varCode, uuid) {} - /** - * @brief Construct a new GeoluxHydroCam_ByteError object. - * - * @note This must be tied with a parent GeoluxHydroCam before it can be - * used. - */ - GeoluxHydroCam_ByteError() - : Variable(static_cast(HYDROCAM_ERROR_VAR_NUM), - static_cast(HYDROCAM_ERROR_RESOLUTION), - HYDROCAM_ERROR_VAR_NAME, HYDROCAM_ERROR_UNIT_NAME, - HYDROCAM_ERROR_DEFAULT_CODE) {} /** * @brief Destroy the GeoluxHydroCam_ByteError object - no action * needed. diff --git a/src/sensors/GroPointGPLP8.h b/src/sensors/GroPointGPLP8.h index 9206921e7..e5d132355 100644 --- a/src/sensors/GroPointGPLP8.h +++ b/src/sensors/GroPointGPLP8.h @@ -230,21 +230,6 @@ class GroPointGPLP8_Moist : public Variable { static_cast(GPLP8_MOIST_RESOLUTION), GPLP8_MOIST_VAR_NAME, GPLP8_MOIST_UNIT_NAME, varCode, uuid) { } - /** - * @brief Construct a new GroPointGPLP8_Moist object. - * - * @param sensorVarNum The position the variable result holds in the - * variable result array. The GroPoint GPLP8 can have up to 8 soil moisture - * results. When creating the variable for soil moisture, you must specify - * the output number from the sensor. - * - * @note This must be tied with a parent GroPointGPLP8 before it can be - * used. - */ - GroPointGPLP8_Moist(const uint8_t sensorVarNum) - : Variable(sensorVarNum, static_cast(GPLP8_MOIST_RESOLUTION), - GPLP8_MOIST_VAR_NAME, GPLP8_MOIST_UNIT_NAME, - GPLP8_MOIST_DEFAULT_CODE) {} /** * @brief Destroy the GroPointGPLP8_Moist object - no action needed. */ @@ -283,21 +268,6 @@ class GroPointGPLP8_Temp : public Variable { : Variable(parentSense, sensorVarNum, static_cast(GPLP8_TEMP_RESOLUTION), GPLP8_TEMP_VAR_NAME, GPLP8_TEMP_UNIT_NAME, varCode, uuid) {} - /** - * @brief Construct a new GroPointGPLP8_Temp object. - * - * @param sensorVarNum The position the variable result holds in the - * variable result array. The GroPoint GPLP8 can have up to 8 temperature - * results. When creating the variable for temperature, you must specify the - * output number from the sensor. - * - * @note This must be tied with a parent GroPointGPLP8 before it can be - * used. - */ - GroPointGPLP8_Temp(const uint8_t sensorVarNum) - : Variable(sensorVarNum, static_cast(GPLP8_TEMP_RESOLUTION), - GPLP8_TEMP_VAR_NAME, GPLP8_TEMP_UNIT_NAME, - GPLP8_TEMP_DEFAULT_CODE) {} /** * @brief Destroy the GroPointGPLP8_Temp object - no action needed. */ diff --git a/src/sensors/InSituRDO.h b/src/sensors/InSituRDO.h index bc3d273c9..375c906d2 100644 --- a/src/sensors/InSituRDO.h +++ b/src/sensors/InSituRDO.h @@ -444,17 +444,6 @@ class InSituRDO_DOmgL : public Variable { static_cast(INSITU_RDO_DOMGL_RESOLUTION), INSITU_RDO_DOMGL_VAR_NAME, INSITU_RDO_DOMGL_UNIT_NAME, varCode, uuid) {} - /** - * @brief Construct a new InSituRDO_DOmgL object. - * - * @note This must be tied with a parent InSituRDO before it can be - * used. - */ - InSituRDO_DOmgL() - : Variable(static_cast(INSITU_RDO_DOMGL_VAR_NUM), - static_cast(INSITU_RDO_DOMGL_RESOLUTION), - INSITU_RDO_DOMGL_VAR_NAME, INSITU_RDO_DOMGL_UNIT_NAME, - INSITU_RDO_DOMGL_DEFAULT_CODE) {} /** * @brief Destroy the InSituRDO_DOmgL object - no action needed. */ @@ -490,17 +479,6 @@ class InSituRDO_DOpct : public Variable { static_cast(INSITU_RDO_DOPCT_RESOLUTION), INSITU_RDO_DOPCT_VAR_NAME, INSITU_RDO_DOPCT_UNIT_NAME, varCode, uuid) {} - /** - * @brief Construct a new InSituRDO_DOpct object. - * - * @note This must be tied with a parent InSituRDO before it can be - * used. - */ - InSituRDO_DOpct() - : Variable(static_cast(INSITU_RDO_DOPCT_VAR_NUM), - static_cast(INSITU_RDO_DOPCT_RESOLUTION), - INSITU_RDO_DOPCT_VAR_NAME, INSITU_RDO_DOPCT_UNIT_NAME, - INSITU_RDO_DOPCT_DEFAULT_CODE) {} /** * @brief Destroy the InSituRDO_DOpct object - no action needed. */ @@ -535,17 +513,6 @@ class InSituRDO_Temp : public Variable { static_cast(INSITU_RDO_TEMP_RESOLUTION), INSITU_RDO_TEMP_VAR_NAME, INSITU_RDO_TEMP_UNIT_NAME, varCode, uuid) {} - /** - * @brief Construct a new InSituRDO_Temp object. - * - * @note This must be tied with a parent InSituRDO before it can be - * used. - */ - InSituRDO_Temp() - : Variable(static_cast(INSITU_RDO_TEMP_VAR_NUM), - static_cast(INSITU_RDO_TEMP_RESOLUTION), - INSITU_RDO_TEMP_VAR_NAME, INSITU_RDO_TEMP_UNIT_NAME, - INSITU_RDO_TEMP_DEFAULT_CODE) {} /** * @brief Destroy the InSituRDO_Temp object - no action needed. */ @@ -582,17 +549,6 @@ class InSituRDO_Pressure : public Variable { static_cast(INSITU_RDO_PRESSURE_RESOLUTION), INSITU_RDO_PRESSURE_VAR_NAME, INSITU_RDO_PRESSURE_UNIT_NAME, varCode, uuid) {} - /** - * @brief Construct a new InSituRDO_Pressure object. - * - * @note This must be tied with a parent InSituRDO before it can be - * used. - */ - InSituRDO_Pressure() - : Variable(static_cast(INSITU_RDO_PRESSURE_VAR_NUM), - static_cast(INSITU_RDO_PRESSURE_RESOLUTION), - INSITU_RDO_PRESSURE_VAR_NAME, INSITU_RDO_PRESSURE_UNIT_NAME, - INSITU_RDO_PRESSURE_DEFAULT_CODE) {} /** * @brief Destroy the InSituRDO_Pressure object - no action needed. */ diff --git a/src/sensors/InSituTrollSdi12a.h b/src/sensors/InSituTrollSdi12a.h index dc61fcdd4..8e07c44a4 100644 --- a/src/sensors/InSituTrollSdi12a.h +++ b/src/sensors/InSituTrollSdi12a.h @@ -301,17 +301,6 @@ class InSituTrollSdi12a_Pressure : public Variable { static_cast(ITROLLA_PRESSURE_RESOLUTION), ITROLLA_PRESSURE_VAR_NAME, ITROLLA_PRESSURE_UNIT_NAME, varCode, uuid) {} - /** - * @brief Construct a new InSituTrollSdi12a_Pressure object. - * - * @note This must be tied with a parent InSituTrollSdi12a before it can be - * used. - */ - InSituTrollSdi12a_Pressure() - : Variable(static_cast(ITROLLA_PRESSURE_VAR_NUM), - static_cast(ITROLLA_PRESSURE_RESOLUTION), - ITROLLA_PRESSURE_VAR_NAME, ITROLLA_PRESSURE_UNIT_NAME, - ITROLLA_PRESSURE_DEFAULT_CODE) {} /** * @brief Destroy the InSituTrollSdi12a_Pressure object - no action needed. */ @@ -345,18 +334,6 @@ class InSituTrollSdi12a_Temp : public Variable { static_cast(ITROLLA_TEMP_RESOLUTION), ITROLLA_TEMP_TEMP_VAR_NAME, ITROLLA_TEMP_TEMP_UNIT_NAME, varCode, uuid) {} - - /** - * @brief Construct a new InSituTrollSdi12a_Temp object. - * - * @note This must be tied with a parent InSituTrollSdi12a before it can be - * used. - */ - InSituTrollSdi12a_Temp() - : Variable(static_cast(ITROLLA_TEMP_VAR_NUM), - static_cast(ITROLLA_TEMP_RESOLUTION), - ITROLLA_TEMP_TEMP_VAR_NAME, ITROLLA_TEMP_TEMP_UNIT_NAME, - ITROLLA_TEMP_DEFAULT_CODE) {} /** * @brief Destroy the InSituTrollSdi12a_Temp object - no action needed. */ @@ -390,17 +367,6 @@ class InSituTrollSdi12a_Depth : public Variable { static_cast(ITROLLA_DEPTH_RESOLUTION), ITROLLA_DEPTH_VAR_NAME, ITROLLA_DEPTH_UNIT_NAME, varCode, uuid) {} - /** - * @brief Construct a new InSituTrollSdi12a_Depth object. - * - * @note This must be tied with a parent InSituTrollSdi12a before it can be - * used. - */ - InSituTrollSdi12a_Depth() - : Variable(static_cast(ITROLLA_DEPTH_VAR_NUM), - static_cast(ITROLLA_DEPTH_RESOLUTION), - ITROLLA_DEPTH_VAR_NAME, ITROLLA_DEPTH_UNIT_NAME, - ITROLLA_DEPTH_DEFAULT_CODE) {} /** * @brief Destroy the InSituTrollSdi12a_Depth object - no action needed. */ diff --git a/src/sensors/KellerAcculevel.h b/src/sensors/KellerAcculevel.h index 7033028a5..eaccaecf8 100644 --- a/src/sensors/KellerAcculevel.h +++ b/src/sensors/KellerAcculevel.h @@ -211,17 +211,6 @@ class KellerAcculevel_Pressure : public Variable { static_cast(ACCULEVEL_PRESSURE_RESOLUTION), KELLER_PRESSURE_VAR_NAME, KELLER_PRESSURE_UNIT_NAME, varCode, uuid) {} - /** - * @brief Construct a new KellerAcculevel_Pressure object. - * - * @note This must be tied with a parent KellerAcculevel before it can be - * used. - */ - KellerAcculevel_Pressure() - : Variable(static_cast(KELLER_PRESSURE_VAR_NUM), - static_cast(ACCULEVEL_PRESSURE_RESOLUTION), - KELLER_PRESSURE_VAR_NAME, KELLER_PRESSURE_UNIT_NAME, - ACCULEVEL_PRESSURE_DEFAULT_CODE) {} /** * @brief Destroy the KellerAcculevel_Pressure object - no action needed. */ @@ -257,17 +246,6 @@ class KellerAcculevel_Temp : public Variable { static_cast(ACCULEVEL_TEMP_RESOLUTION), KELLER_TEMP_VAR_NAME, KELLER_TEMP_UNIT_NAME, varCode, uuid) { } - /** - * @brief Construct a new KellerAcculevel_Temp object. - * - * @note This must be tied with a parent KellerAcculevel before it can be - * used. - */ - KellerAcculevel_Temp() - : Variable(static_cast(KELLER_TEMP_VAR_NUM), - static_cast(ACCULEVEL_TEMP_RESOLUTION), - KELLER_TEMP_VAR_NAME, KELLER_TEMP_UNIT_NAME, - ACCULEVEL_TEMP_DEFAULT_CODE) {} /** * @brief Destroy the KellerAcculevel_Temp object - no action needed. */ @@ -303,17 +281,6 @@ class KellerAcculevel_Height : public Variable { static_cast(ACCULEVEL_HEIGHT_RESOLUTION), KELLER_HEIGHT_VAR_NAME, KELLER_HEIGHT_UNIT_NAME, varCode, uuid) {} - /** - * @brief Construct a new KellerAcculevel_Height object. - * - * @note This must be tied with a parent KellerAcculevel before it can be - * used. - */ - KellerAcculevel_Height() - : Variable(static_cast(KELLER_HEIGHT_VAR_NUM), - static_cast(ACCULEVEL_HEIGHT_RESOLUTION), - KELLER_HEIGHT_VAR_NAME, KELLER_HEIGHT_UNIT_NAME, - ACCULEVEL_HEIGHT_DEFAULT_CODE) {} /** * @brief Destroy the KellerAcculevel_Height object - no action needed. */ diff --git a/src/sensors/KellerNanolevel.h b/src/sensors/KellerNanolevel.h index 34a53d19d..a6f85f213 100644 --- a/src/sensors/KellerNanolevel.h +++ b/src/sensors/KellerNanolevel.h @@ -203,17 +203,6 @@ class KellerNanolevel_Pressure : public Variable { static_cast(NANOLEVEL_PRESSURE_RESOLUTION), KELLER_PRESSURE_VAR_NAME, KELLER_PRESSURE_UNIT_NAME, varCode, uuid) {} - /** - * @brief Construct a new KellerNanolevel_Pressure object. - * - * @note This must be tied with a parent KellerNanolevel before it can be - * used. - */ - KellerNanolevel_Pressure() - : Variable(static_cast(KELLER_PRESSURE_VAR_NUM), - static_cast(NANOLEVEL_PRESSURE_RESOLUTION), - KELLER_PRESSURE_VAR_NAME, KELLER_PRESSURE_UNIT_NAME, - NANOLEVEL_PRESSURE_DEFAULT_CODE) {} /** * @brief Destroy the KellerNanolevel_Pressure object - no action needed. */ @@ -249,17 +238,6 @@ class KellerNanolevel_Temp : public Variable { static_cast(NANOLEVEL_TEMP_RESOLUTION), KELLER_TEMP_VAR_NAME, KELLER_TEMP_UNIT_NAME, varCode, uuid) { } - /** - * @brief Construct a new KellerNanolevel_Temp object. - * - * @note This must be tied with a parent KellerNanolevel before it can be - * used. - */ - KellerNanolevel_Temp() - : Variable(static_cast(KELLER_TEMP_VAR_NUM), - static_cast(NANOLEVEL_TEMP_RESOLUTION), - KELLER_TEMP_VAR_NAME, KELLER_TEMP_UNIT_NAME, - NANOLEVEL_TEMP_DEFAULT_CODE) {} /** * @brief Destroy the KellerNanolevel_Temp object - no action needed. */ @@ -295,17 +273,6 @@ class KellerNanolevel_Height : public Variable { static_cast(NANOLEVEL_HEIGHT_RESOLUTION), KELLER_HEIGHT_VAR_NAME, KELLER_HEIGHT_UNIT_NAME, varCode, uuid) {} - /** - * @brief Construct a new KellerNanolevel_Height object. - * - * @note This must be tied with a parent KellerNanolevel before it can be - * used. - */ - KellerNanolevel_Height() - : Variable(static_cast(KELLER_HEIGHT_VAR_NUM), - static_cast(NANOLEVEL_HEIGHT_RESOLUTION), - KELLER_HEIGHT_VAR_NAME, KELLER_HEIGHT_UNIT_NAME, - NANOLEVEL_HEIGHT_DEFAULT_CODE) {} /** * @brief Destroy the KellerNanolevel_Height object - no action needed. */ diff --git a/src/sensors/MaxBotixSonar.h b/src/sensors/MaxBotixSonar.h index 46cf85725..0933795be 100644 --- a/src/sensors/MaxBotixSonar.h +++ b/src/sensors/MaxBotixSonar.h @@ -344,16 +344,6 @@ class MaxBotixSonar_Range : public Variable { : Variable(parentSense, static_cast(HRXL_VAR_NUM), static_cast(HRXL_RESOLUTION), HRXL_VAR_NAME, HRXL_UNIT_NAME, varCode, uuid) {} - /** - * @brief Construct a new MaxBotixSonar_Range object. - * - * @note This must be tied with a parent MaxBotixSonar before it can be - * used. - */ - MaxBotixSonar_Range() - : Variable(static_cast(HRXL_VAR_NUM), - static_cast(HRXL_RESOLUTION), HRXL_VAR_NAME, - HRXL_UNIT_NAME, HRXL_DEFAULT_CODE) {} /** * @brief Destroy the MaxBotixSonar_Range object - no action needed. */ diff --git a/src/sensors/MaximDS18.h b/src/sensors/MaximDS18.h index 89f258aea..8d3a00b15 100644 --- a/src/sensors/MaximDS18.h +++ b/src/sensors/MaximDS18.h @@ -312,16 +312,6 @@ class MaximDS18_Temp : public Variable { : Variable(parentSense, static_cast(DS18_TEMP_VAR_NUM), static_cast(DS18_TEMP_RESOLUTION), DS18_TEMP_VAR_NAME, DS18_TEMP_UNIT_NAME, varCode, uuid) {} - /** - * @brief Construct a new MaximDS18_Temp object. - * - * @note This must be tied with a parent MaximDS18 before it can be used. - */ - MaximDS18_Temp() - : Variable(static_cast(DS18_TEMP_VAR_NUM), - static_cast(DS18_TEMP_RESOLUTION), - DS18_TEMP_VAR_NAME, DS18_TEMP_UNIT_NAME, - DS18_TEMP_DEFAULT_CODE) {} /** * @brief Destroy the MaximDS18_Temp object - no action needed. */ diff --git a/src/sensors/MaximDS3231.h b/src/sensors/MaximDS3231.h index 564499ce3..281975f02 100644 --- a/src/sensors/MaximDS3231.h +++ b/src/sensors/MaximDS3231.h @@ -225,16 +225,6 @@ class MaximDS3231_Temp : public Variable { static_cast(DS3231_TEMP_RESOLUTION), DS3231_TEMP_VAR_NAME, DS3231_TEMP_UNIT_NAME, varCode, uuid) { } - /** - * @brief Construct a new MaximDS3231_Temp object. - * - * @note This must be tied with a parent MaximDS3231 before it can be used. - */ - MaximDS3231_Temp() - : Variable(static_cast(DS3231_TEMP_VAR_NUM), - static_cast(DS3231_TEMP_RESOLUTION), - DS3231_TEMP_VAR_NAME, DS3231_TEMP_UNIT_NAME, - DS3231_TEMP_DEFAULT_CODE) {} /** * @brief Destroy the MaximDS3231_Temp object - no action needed. */ diff --git a/src/sensors/MeaSpecMS5803.h b/src/sensors/MeaSpecMS5803.h index 983e3932e..a683f0257 100644 --- a/src/sensors/MeaSpecMS5803.h +++ b/src/sensors/MeaSpecMS5803.h @@ -299,17 +299,6 @@ class MeaSpecMS5803_Temp : public Variable { static_cast(MS5803_TEMP_RESOLUTION), MS5803_TEMP_VAR_NAME, MS5803_TEMP_UNIT_NAME, varCode, uuid) { } - /** - * @brief Construct a new MeaSpecMS5803_Temp object. - * - * @note This must be tied with a parent MeaSpecMS5803 before it can be - * used. - */ - MeaSpecMS5803_Temp() - : Variable(static_cast(MS5803_TEMP_VAR_NUM), - static_cast(MS5803_TEMP_RESOLUTION), - MS5803_TEMP_VAR_NAME, MS5803_TEMP_UNIT_NAME, - MS5803_TEMP_DEFAULT_CODE) {} /** * @brief Destroy the MeaSpecMS5803_Temp object - no action needed. */ @@ -346,17 +335,6 @@ class MeaSpecMS5803_Pressure : public Variable { static_cast(MS5803_PRESSURE_RESOLUTION), MS5803_PRESSURE_VAR_NAME, MS5803_PRESSURE_UNIT_NAME, varCode, uuid) {} - /** - * @brief Construct a new MeaSpecMS5803_Pressure object. - * - * @note This must be tied with a parent MeaSpecMS5803 before it can be - * used. - */ - MeaSpecMS5803_Pressure() - : Variable(static_cast(MS5803_PRESSURE_VAR_NUM), - static_cast(MS5803_PRESSURE_RESOLUTION), - MS5803_PRESSURE_VAR_NAME, MS5803_PRESSURE_UNIT_NAME, - MS5803_PRESSURE_DEFAULT_CODE) {} /** * @brief Destroy the MeaSpecMS5803_Pressure object - no action needed. */ diff --git a/src/sensors/MeterHydros21.h b/src/sensors/MeterHydros21.h index 582b63d28..1f2288c39 100644 --- a/src/sensors/MeterHydros21.h +++ b/src/sensors/MeterHydros21.h @@ -273,7 +273,6 @@ class MeterHydros21 : public SDI12Sensors { "MeterHydros21", HYDROS21_NUM_VARIABLES, HYDROS21_WARM_UP_TIME_MS, HYDROS21_STABILIZATION_TIME_MS, HYDROS21_MEASUREMENT_TIME_MS, HYDROS21_EXTRA_WAKE_TIME_MS, HYDROS21_INC_CALC_VARIABLES) {} - /** * @brief Destroy the Meter Hydros 21 object */ @@ -308,17 +307,6 @@ class MeterHydros21_Cond : public Variable { static_cast(HYDROS21_COND_RESOLUTION), HYDROS21_COND_VAR_NAME, HYDROS21_COND_UNIT_NAME, varCode, uuid) {} - /** - * @brief Construct a new MeterHydros21_Cond object. - * - * @note This must be tied with a parent MeterHydros21 before it can be - * used. - */ - MeterHydros21_Cond() - : Variable(static_cast(HYDROS21_COND_VAR_NUM), - static_cast(HYDROS21_COND_RESOLUTION), - HYDROS21_COND_VAR_NAME, HYDROS21_COND_UNIT_NAME, - HYDROS21_COND_DEFAULT_CODE) {} /** * @brief Destroy the MeterHydros21_Cond object - no action needed. */ @@ -353,17 +341,6 @@ class MeterHydros21_Temp : public Variable { static_cast(HYDROS21_TEMP_RESOLUTION), HYDROS21_TEMP_VAR_NAME, HYDROS21_TEMP_UNIT_NAME, varCode, uuid) {} - /** - * @brief Construct a new MeterHydros21_Temp object. - * - * @note This must be tied with a parent MeterHydros21 before it can be - * used. - */ - MeterHydros21_Temp() - : Variable(static_cast(HYDROS21_TEMP_VAR_NUM), - static_cast(HYDROS21_TEMP_RESOLUTION), - HYDROS21_TEMP_VAR_NAME, HYDROS21_TEMP_UNIT_NAME, - HYDROS21_TEMP_DEFAULT_CODE) {} /** * @brief Destroy the MeterHydros21_Temp object - no action needed. */ @@ -398,17 +375,6 @@ class MeterHydros21_Depth : public Variable { static_cast(HYDROS21_DEPTH_RESOLUTION), HYDROS21_DEPTH_VAR_NAME, HYDROS21_DEPTH_UNIT_NAME, varCode, uuid) {} - /** - * @brief Construct a new MeterHydros21_Depth object. - * - * @note This must be tied with a parent MeterHydros21 before it can be - * used. - */ - MeterHydros21_Depth() - : Variable(static_cast(HYDROS21_DEPTH_VAR_NUM), - static_cast(HYDROS21_DEPTH_RESOLUTION), - HYDROS21_DEPTH_VAR_NAME, HYDROS21_DEPTH_UNIT_NAME, - HYDROS21_DEPTH_DEFAULT_CODE) {} /** * @brief Destroy the MeterHydros21_Depth object - no action needed. */ diff --git a/src/sensors/MeterTeros11.h b/src/sensors/MeterTeros11.h index b93e74e04..62b42dc0a 100644 --- a/src/sensors/MeterTeros11.h +++ b/src/sensors/MeterTeros11.h @@ -368,16 +368,6 @@ class MeterTeros11_Count : public Variable { static_cast(TEROS11_COUNT_RESOLUTION), TEROS11_COUNT_VAR_NAME, TEROS11_COUNT_UNIT_NAME, varCode, uuid) {} - /** - * @brief Construct a new MeterTeros11_Count object. - * - * @note This must be tied with a parent MeterTeros11 before it can be used. - */ - MeterTeros11_Count() - : Variable(static_cast(TEROS11_COUNT_VAR_NUM), - static_cast(TEROS11_COUNT_RESOLUTION), - TEROS11_COUNT_VAR_NAME, TEROS11_COUNT_UNIT_NAME, - TEROS11_COUNT_DEFAULT_CODE) {} /** * @brief Destroy the MeterTeros11_Count object - no action needed. */ @@ -412,16 +402,6 @@ class MeterTeros11_Temp : public Variable { static_cast(TEROS11_TEMP_RESOLUTION), TEROS11_TEMP_VAR_NAME, TEROS11_TEMP_UNIT_NAME, varCode, uuid) {} - /** - * @brief Construct a new MeterTeros11_Temp object. - * - * @note This must be tied with a parent MeterTeros11 before it can be used. - */ - MeterTeros11_Temp() - : Variable(static_cast(TEROS11_TEMP_VAR_NUM), - static_cast(TEROS11_TEMP_RESOLUTION), - TEROS11_TEMP_VAR_NAME, TEROS11_TEMP_UNIT_NAME, - TEROS11_TEMP_DEFAULT_CODE) {} /** * @brief Destroy the MeterTeros11_Temp object - no action needed. */ @@ -456,16 +436,6 @@ class MeterTeros11_Ea : public Variable { : Variable(parentSense, static_cast(TEROS11_EA_VAR_NUM), static_cast(TEROS11_EA_RESOLUTION), TEROS11_EA_VAR_NAME, TEROS11_EA_UNIT_NAME, varCode, uuid) {} - /** - * @brief Construct a new MeterTeros11_Ea object. - * - * @note This must be tied with a parent MeterTeros11 before it can be used. - */ - MeterTeros11_Ea() - : Variable(static_cast(TEROS11_EA_VAR_NUM), - static_cast(TEROS11_EA_RESOLUTION), - TEROS11_EA_VAR_NAME, TEROS11_EA_UNIT_NAME, - TEROS11_EA_DEFAULT_CODE) {} /** * @brief Destroy the MeterTeros11_Ea object - no action needed. */ @@ -500,16 +470,6 @@ class MeterTeros11_VWC : public Variable { static_cast(TEROS11_VWC_RESOLUTION), TEROS11_VWC_VAR_NAME, TEROS11_VWC_UNIT_NAME, varCode, uuid) { } - /** - * @brief Construct a new MeterTeros11_VWC object. - * - * @note This must be tied with a parent MeterTeros11 before it can be used. - */ - MeterTeros11_VWC() - : Variable(static_cast(TEROS11_VWC_VAR_NUM), - static_cast(TEROS11_VWC_RESOLUTION), - TEROS11_VWC_VAR_NAME, TEROS11_VWC_UNIT_NAME, - TEROS11_VWC_DEFAULT_CODE) {} /** * @brief Destroy the MeterTeros11_VWC object - no action needed. */ diff --git a/src/sensors/PaleoTerraRedox.h b/src/sensors/PaleoTerraRedox.h index a43e6e92a..7431d0659 100644 --- a/src/sensors/PaleoTerraRedox.h +++ b/src/sensors/PaleoTerraRedox.h @@ -325,17 +325,6 @@ class PaleoTerraRedox_Voltage : public Variable { static_cast(PTR_VOLTAGE_RESOLUTION), PTR_VOLTAGE_VAR_NAME, PTR_VOLTAGE_UNIT_NAME, varCode, uuid) { } - /** - * @brief Construct a new PaleoTerraRedox_Voltage object. - * - * @note This must be tied with a parent PaleoTerraRedox before it can be - * used. - */ - PaleoTerraRedox_Voltage() - : Variable(static_cast(PTR_VOLTAGE_VAR_NUM), - static_cast(PTR_VOLTAGE_RESOLUTION), - PTR_VOLTAGE_VAR_NAME, PTR_VOLTAGE_UNIT_NAME, - PTR_VOLTAGE_DEFAULT_CODE) {} /** * @brief Destroy the PaleoTerraRedox_Voltage object - no action needed. */ diff --git a/src/sensors/ProcessorAnalog.h b/src/sensors/ProcessorAnalog.h index 636d36747..5c0f8a620 100644 --- a/src/sensors/ProcessorAnalog.h +++ b/src/sensors/ProcessorAnalog.h @@ -329,17 +329,6 @@ class ProcessorAnalog_Voltage : public Variable { static_cast(PROCESSOR_ANALOG_RESOLUTION), PROCESSOR_ANALOG_VAR_NAME, PROCESSOR_ANALOG_UNIT_NAME, varCode, uuid) {} - /** - * @brief Construct a new ProcessorAnalog_Voltage object. - * - * @note This must be tied with a parent ProcessorAnalog before it can be - * used. - */ - ProcessorAnalog_Voltage() - : Variable(static_cast(PROCESSOR_ANALOG_VAR_NUM), - static_cast(PROCESSOR_ANALOG_RESOLUTION), - PROCESSOR_ANALOG_VAR_NAME, PROCESSOR_ANALOG_UNIT_NAME, - PROCESSOR_ANALOG_DEFAULT_CODE) {} /** * @brief Destroy the ProcessorAnalog_Voltage object - no action needed. */ diff --git a/src/sensors/ProcessorStats.h b/src/sensors/ProcessorStats.h index 302ce8411..cada0461f 100644 --- a/src/sensors/ProcessorStats.h +++ b/src/sensors/ProcessorStats.h @@ -393,17 +393,6 @@ class ProcessorStats_Battery : public Variable { static_cast(PROCESSOR_BATTERY_RESOLUTION), PROCESSOR_BATTERY_VAR_NAME, PROCESSOR_BATTERY_UNIT_NAME, varCode, uuid) {} - /** - * @brief Construct a new ProcessorStats_Battery object. - * - * @note This must be tied with a parent ProcessorStats before it can be - * used. - */ - ProcessorStats_Battery() - : Variable(static_cast(PROCESSOR_BATTERY_VAR_NUM), - static_cast(PROCESSOR_BATTERY_RESOLUTION), - PROCESSOR_BATTERY_VAR_NAME, PROCESSOR_BATTERY_UNIT_NAME, - PROCESSOR_BATTERY_DEFAULT_CODE) {} /** * @brief Destroy the ProcessorStats_Battery object - no action needed. */ @@ -446,17 +435,6 @@ class ProcessorStats_FreeRam : public Variable { static_cast(PROCESSOR_RAM_RESOLUTION), PROCESSOR_RAM_VAR_NAME, PROCESSOR_RAM_UNIT_NAME, varCode, uuid) {} - /** - * @brief Construct a new ProcessorStats_FreeRam object. - * - * @note This must be tied with a parent ProcessorStats before it can be - * used. - */ - ProcessorStats_FreeRam() - : Variable(static_cast(PROCESSOR_RAM_VAR_NUM), - static_cast(PROCESSOR_RAM_RESOLUTION), - PROCESSOR_RAM_VAR_NAME, PROCESSOR_RAM_UNIT_NAME, - PROCESSOR_RAM_DEFAULT_CODE) {} /** * @brief Destroy the ProcessorStats_FreeRam object - no action needed. */ @@ -495,17 +473,6 @@ class ProcessorStats_SampleNumber : public Variable { static_cast(PROCESSOR_SAMPNUM_RESOLUTION), PROCESSOR_SAMPNUM_VAR_NAME, PROCESSOR_SAMPNUM_UNIT_NAME, varCode, uuid) {} - /** - * @brief Construct a new ProcessorStats_SampleNumber object. - * - * @note This must be tied with a parent ProcessorStats before it can be - * used. - */ - ProcessorStats_SampleNumber() - : Variable(static_cast(PROCESSOR_SAMPNUM_VAR_NUM), - static_cast(PROCESSOR_SAMPNUM_RESOLUTION), - PROCESSOR_SAMPNUM_VAR_NAME, PROCESSOR_SAMPNUM_UNIT_NAME, - PROCESSOR_SAMPNUM_DEFAULT_CODE) {} /** * @brief Destroy the ProcessorStats_SampleNumber() object - no action * needed. @@ -546,17 +513,6 @@ class ProcessorStats_ResetCode : public Variable { static_cast(PROCESSOR_RESET_RESOLUTION), PROCESSOR_RESET_VAR_NAME, PROCESSOR_RESET_UNIT_NAME, varCode, uuid) {} - /** - * @brief Construct a new ProcessorStats_ResetCode object. - * - * @note This must be tied with a parent ProcessorStats before it can be - * used. - */ - ProcessorStats_ResetCode() - : Variable(static_cast(PROCESSOR_RESET_VAR_NUM), - static_cast(PROCESSOR_RESET_RESOLUTION), - PROCESSOR_RESET_VAR_NAME, PROCESSOR_RESET_UNIT_NAME, - PROCESSOR_RESET_DEFAULT_CODE) {} /** * @brief Destroy the ProcessorStats_ResetCode object - no action needed. */ diff --git a/src/sensors/RainCounterI2C.h b/src/sensors/RainCounterI2C.h index c0ae1d47f..6d4c4fa98 100644 --- a/src/sensors/RainCounterI2C.h +++ b/src/sensors/RainCounterI2C.h @@ -345,17 +345,6 @@ class RainCounterI2C_Tips : public Variable { static_cast(BUCKET_TIPS_RESOLUTION), BUCKET_TIPS_VAR_NAME, BUCKET_TIPS_UNIT_NAME, varCode, uuid) { } - /** - * @brief Construct a new RainCounterI2C_Tips object. - * - * @note This must be tied with a parent RainCounterI2C before it can be - * used. - */ - RainCounterI2C_Tips() - : Variable(static_cast(BUCKET_TIPS_VAR_NUM), - static_cast(BUCKET_TIPS_RESOLUTION), - BUCKET_TIPS_VAR_NAME, BUCKET_TIPS_UNIT_NAME, - BUCKET_TIPS_DEFAULT_CODE) {} /** * @brief Destroy the RainCounterI2C_Tips object - no action needed. */ @@ -389,17 +378,6 @@ class RainCounterI2C_Depth : public Variable { static_cast(BUCKET_RAIN_RESOLUTION), BUCKET_RAIN_VAR_NAME, BUCKET_RAIN_UNIT_NAME, varCode, uuid) { } - /** - * @brief Construct a new RainCounterI2C_Depth object. - * - * @note This must be tied with a parent RainCounterI2C before it can be - * used. - */ - RainCounterI2C_Depth() - : Variable(static_cast(BUCKET_RAIN_VAR_NUM), - static_cast(BUCKET_RAIN_RESOLUTION), - BUCKET_RAIN_VAR_NAME, BUCKET_RAIN_UNIT_NAME, - BUCKET_RAIN_DEFAULT_CODE) {} /** * @brief Destroy the RainCounterI2C_Depth object - no action needed. */ diff --git a/src/sensors/SensirionSHT4x.h b/src/sensors/SensirionSHT4x.h index 3ef511445..99764b0f9 100644 --- a/src/sensors/SensirionSHT4x.h +++ b/src/sensors/SensirionSHT4x.h @@ -326,17 +326,6 @@ class SensirionSHT4x_Humidity : public Variable { static_cast(SHT4X_HUMIDITY_RESOLUTION), SHT4X_HUMIDITY_VAR_NAME, SHT4X_HUMIDITY_UNIT_NAME, varCode, uuid) {} - /** - * @brief Construct a new SensirionSHT4x_Humidity object. - * - * @note This must be tied with a parent SensirionSHT4x before it can be - * used. - */ - SensirionSHT4x_Humidity() - : Variable(static_cast(SHT4X_HUMIDITY_VAR_NUM), - static_cast(SHT4X_HUMIDITY_RESOLUTION), - SHT4X_HUMIDITY_VAR_NAME, SHT4X_HUMIDITY_UNIT_NAME, - SHT4X_HUMIDITY_DEFAULT_CODE) {} /** * @brief Destroy the SensirionSHT4x_Humidity object - no action needed. */ @@ -369,17 +358,6 @@ class SensirionSHT4x_Temp : public Variable { : Variable(parentSense, static_cast(SHT4X_TEMP_VAR_NUM), static_cast(SHT4X_TEMP_RESOLUTION), SHT4X_TEMP_VAR_NAME, SHT4X_TEMP_UNIT_NAME, varCode, uuid) {} - /** - * @brief Construct a new SensirionSHT4x_Temp object. - * - * @note This must be tied with a parent SensirionSHT4x before it can be - * used. - */ - SensirionSHT4x_Temp() - : Variable(static_cast(SHT4X_TEMP_VAR_NUM), - static_cast(SHT4X_TEMP_RESOLUTION), - SHT4X_TEMP_VAR_NAME, SHT4X_TEMP_UNIT_NAME, - SHT4X_TEMP_DEFAULT_CODE) {} /** * @brief Destroy the SensirionSHT4x_Temp object - no action needed. */ diff --git a/src/sensors/TEConnectivityMS5837.h b/src/sensors/TEConnectivityMS5837.h index 152896c48..d0ca3eba6 100644 --- a/src/sensors/TEConnectivityMS5837.h +++ b/src/sensors/TEConnectivityMS5837.h @@ -580,17 +580,6 @@ class TEConnectivityMS5837_Temp : public Variable { static_cast(MS5837_TEMP_RESOLUTION), MS5837_TEMP_VAR_NAME, MS5837_TEMP_UNIT_NAME, varCode, uuid) { } - /** - * @brief Construct a new TEConnectivityMS5837_Temp object. - * - * @note This must be tied with a parent TEConnectivityMS5837 before it can - * be used. - */ - TEConnectivityMS5837_Temp() - : Variable(static_cast(MS5837_TEMP_VAR_NUM), - static_cast(MS5837_TEMP_RESOLUTION), - MS5837_TEMP_VAR_NAME, MS5837_TEMP_UNIT_NAME, - MS5837_TEMP_DEFAULT_CODE) {} /** * @brief Destroy the TEConnectivityMS5837_Temp object - no action needed. */ @@ -626,17 +615,6 @@ class TEConnectivityMS5837_Pressure : public Variable { static_cast(MS5837_PRESSURE_RESOLUTION), MS5837_PRESSURE_VAR_NAME, MS5837_PRESSURE_UNIT_NAME, varCode, uuid) {} - /** - * @brief Construct a new TEConnectivityMS5837_Pressure object. - * - * @note This must be tied with a parent TEConnectivityMS5837 before it can - * be used. - */ - TEConnectivityMS5837_Pressure() - : Variable(static_cast(MS5837_PRESSURE_VAR_NUM), - static_cast(MS5837_PRESSURE_RESOLUTION), - MS5837_PRESSURE_VAR_NAME, MS5837_PRESSURE_UNIT_NAME, - MS5837_PRESSURE_DEFAULT_CODE) {} /** * @brief Destroy the TEConnectivityMS5837_Pressure object - no action * needed. @@ -673,17 +651,6 @@ class TEConnectivityMS5837_Depth : public Variable { static_cast(MS5837_DEPTH_RESOLUTION), MS5837_DEPTH_VAR_NAME, MS5837_DEPTH_UNIT_NAME, varCode, uuid) {} - /** - * @brief Construct a new TEConnectivityMS5837_Depth object. - * - * @note This must be tied with a parent TEConnectivityMS5837 before it can - * be used. - */ - TEConnectivityMS5837_Depth() - : Variable(static_cast(MS5837_DEPTH_VAR_NUM), - static_cast(MS5837_DEPTH_RESOLUTION), - MS5837_DEPTH_VAR_NAME, MS5837_DEPTH_UNIT_NAME, - MS5837_DEPTH_DEFAULT_CODE) {} /** * @brief Destroy the TEConnectivityMS5837_Depth object - no action needed. */ @@ -719,17 +686,6 @@ class TEConnectivityMS5837_Altitude : public Variable { static_cast(MS5837_ALTITUDE_RESOLUTION), MS5837_ALTITUDE_VAR_NAME, MS5837_ALTITUDE_UNIT_NAME, varCode, uuid) {} - /** - * @brief Construct a new TEConnectivityMS5837_Altitude object. - * - * @note This must be tied with a parent TEConnectivityMS5837 before it can - * be used. - */ - TEConnectivityMS5837_Altitude() - : Variable(static_cast(MS5837_ALTITUDE_VAR_NUM), - static_cast(MS5837_ALTITUDE_RESOLUTION), - MS5837_ALTITUDE_VAR_NAME, MS5837_ALTITUDE_UNIT_NAME, - MS5837_ALTITUDE_DEFAULT_CODE) {} /** * @brief Destroy the TEConnectivityMS5837_Altitude object - no action * needed. diff --git a/src/sensors/TIADS1x15.h b/src/sensors/TIADS1x15.h index 974d191cd..9f1a7d193 100644 --- a/src/sensors/TIADS1x15.h +++ b/src/sensors/TIADS1x15.h @@ -582,17 +582,6 @@ class TIADS1x15_Voltage : public Variable { : Variable(parentSense, static_cast(TIADS1X15_VAR_NUM), static_cast(TIADS1X15_RESOLUTION), TIADS1X15_VAR_NAME, TIADS1X15_UNIT_NAME, varCode, uuid) {} - /** - * @brief Construct a new TIADS1x15_Voltage object. - * - * @note This must be tied with a parent TIADS1x15 before it can be - * used. - */ - TIADS1x15_Voltage() - : Variable(static_cast(TIADS1X15_VAR_NUM), - static_cast(TIADS1X15_RESOLUTION), - TIADS1X15_VAR_NAME, TIADS1X15_UNIT_NAME, - TIADS1X15_DEFAULT_CODE) {} /** * @brief Destroy the TIADS1x15_Voltage object - no action needed. */ diff --git a/src/sensors/TIINA219.h b/src/sensors/TIINA219.h index 9d9d6e41a..974bc8f82 100644 --- a/src/sensors/TIINA219.h +++ b/src/sensors/TIINA219.h @@ -338,16 +338,6 @@ class TIINA219_Current : public Variable { static_cast(INA219_CURRENT_MA_RESOLUTION), INA219_CURRENT_MA_VAR_NAME, INA219_CURRENT_MA_UNIT_NAME, varCode, uuid) {} - /** - * @brief Construct a new TIINA219_Current object. - * - * @note This must be tied with a parent TIINA219 before it can be used. - */ - TIINA219_Current() - : Variable(static_cast(INA219_CURRENT_MA_VAR_NUM), - static_cast(INA219_CURRENT_MA_RESOLUTION), - INA219_CURRENT_MA_VAR_NAME, INA219_CURRENT_MA_UNIT_NAME, - INA219_CURRENT_MA_DEFAULT_CODE) {} /** * @brief Destroy the TIINA219_Current object - no action needed. */ @@ -382,16 +372,6 @@ class TIINA219_Voltage : public Variable { static_cast(INA219_BUS_VOLTAGE_RESOLUTION), INA219_BUS_VOLTAGE_VAR_NAME, INA219_BUS_VOLTAGE_UNIT_NAME, varCode, uuid) {} - /** - * @brief Construct a new TIINA219_Voltage object. - * - * @note This must be tied with a parent TIINA219 before it can be used. - */ - TIINA219_Voltage() - : Variable(static_cast(INA219_BUS_VOLTAGE_VAR_NUM), - static_cast(INA219_BUS_VOLTAGE_RESOLUTION), - INA219_BUS_VOLTAGE_VAR_NAME, INA219_BUS_VOLTAGE_UNIT_NAME, - INA219_BUS_VOLTAGE_DEFAULT_CODE) {} /** * @brief Destroy the TIINA219_Voltage object - no action needed. */ @@ -433,16 +413,6 @@ class TIINA219_Power : public Variable { static_cast(INA219_POWER_MW_RESOLUTION), INA219_POWER_MW_VAR_NAME, INA219_POWER_MW_UNIT_NAME, varCode, uuid) {} - /** - * @brief Construct a new TIINA219_Power object. - * - * @note This must be tied with a parent TIINA219 before it can be used. - */ - TIINA219_Power() - : Variable(static_cast(INA219_POWER_MW_VAR_NUM), - static_cast(INA219_POWER_MW_RESOLUTION), - INA219_POWER_MW_VAR_NAME, INA219_POWER_MW_UNIT_NAME, - INA219_POWER_MW_DEFAULT_CODE) {} /** * @brief Destroy the TIINA219_Power object - no action needed. */ diff --git a/src/sensors/TallyCounterI2C.h b/src/sensors/TallyCounterI2C.h index cd383241b..cde5cfd9a 100644 --- a/src/sensors/TallyCounterI2C.h +++ b/src/sensors/TallyCounterI2C.h @@ -262,17 +262,6 @@ class TallyCounterI2C_Events : public Variable { static_cast(TALLY_EVENTS_RESOLUTION), TALLY_EVENTS_VAR_NAME, TALLY_EVENTS_UNIT_NAME, varCode, uuid) {} - /** - * @brief Construct a new TallyCounterI2C_Events object. - * - * @note This must be tied with a parent TallyCounterI2C before it can be - * used. - */ - TallyCounterI2C_Events() - : Variable(static_cast(TALLY_EVENTS_VAR_NUM), - static_cast(TALLY_EVENTS_RESOLUTION), - TALLY_EVENTS_VAR_NAME, TALLY_EVENTS_UNIT_NAME, - TALLY_EVENTS_DEFAULT_CODE) {} /** * @brief Destroy the TallyCounterI2C_Events object - no action needed. */ diff --git a/src/sensors/TurnerCyclops.h b/src/sensors/TurnerCyclops.h index 89d7db843..7502f90d3 100644 --- a/src/sensors/TurnerCyclops.h +++ b/src/sensors/TurnerCyclops.h @@ -442,17 +442,6 @@ class TurnerCyclops_Voltage : public Variable { static_cast(CYCLOPS_VOLTAGE_RESOLUTION), CYCLOPS_VOLTAGE_VAR_NAME, CYCLOPS_VOLTAGE_UNIT_NAME, varCode, uuid) {} - /** - * @brief Construct a new TurnerCyclops_Voltage object. - * - * @note This must be tied with a parent TurnerCyclops before it can be - * used. - */ - TurnerCyclops_Voltage() - : Variable(static_cast(CYCLOPS_VOLTAGE_VAR_NUM), - static_cast(CYCLOPS_VOLTAGE_RESOLUTION), - CYCLOPS_VOLTAGE_VAR_NAME, CYCLOPS_VOLTAGE_UNIT_NAME, - CYCLOPS_VOLTAGE_DEFAULT_CODE) {} /** * @brief Destroy the Turner Cyclops Voltage object - no action needed. */ @@ -501,17 +490,6 @@ class TurnerCyclops_Chlorophyll : public Variable { static_cast(CYCLOPS_RESOLUTION), "chlorophyllFluorescence", "microgramPerLiter", varCode, uuid) {} - /** - * @brief Construct a new TurnerCyclops_Chlorophyll object. - * - * @note This must be tied with a parent TurnerCyclops before it can be - * used. - */ - TurnerCyclops_Chlorophyll() - : Variable(static_cast(CYCLOPS_VAR_NUM), - static_cast(CYCLOPS_RESOLUTION), - "chlorophyllFluorescence", "microgramPerLiter", - "CyclopsChlorophyll") {} /** * @brief Destroy the Turner Cyclops Chlorophyll variable object - no action * needed. @@ -559,17 +537,6 @@ class TurnerCyclops_Rhodamine : public Variable { : Variable(parentSense, static_cast(CYCLOPS_VAR_NUM), static_cast(CYCLOPS_RESOLUTION), "RhodamineFluorescence", "partPerBillion", varCode, uuid) {} - /** - * @brief Construct a new TurnerCyclops_Rhodamine object. - * - * @note This must be tied with a parent TurnerCyclops before it can be - * used. - */ - TurnerCyclops_Rhodamine() - : Variable(static_cast(CYCLOPS_VAR_NUM), - static_cast(CYCLOPS_RESOLUTION), - "RhodamineFluorescence", "partPerBillion", - "CyclopsRhodamine") {} /** * @brief Destroy the Turner Cyclops Rhodamine variable object - no action * needed. @@ -617,16 +584,6 @@ class TurnerCyclops_Fluorescein : public Variable { : Variable(parentSense, static_cast(CYCLOPS_VAR_NUM), static_cast(CYCLOPS_RESOLUTION), "fluorescein", "partPerBillion", varCode, uuid) {} - /** - * @brief Construct a new TurnerCyclops_Fluorescein object. - * - * @note This must be tied with a parent TurnerCyclops before it can be - * used. - */ - TurnerCyclops_Fluorescein() - : Variable(static_cast(CYCLOPS_VAR_NUM), - static_cast(CYCLOPS_RESOLUTION), "fluorescein", - "partPerBillion", "CyclopsFluorescein") {} /** * @brief Destroy the Turner Cyclops Fluorescein variable object - no action * needed. @@ -676,17 +633,6 @@ class TurnerCyclops_Phycocyanin : public Variable { static_cast(CYCLOPS_RESOLUTION), "blue_GreenAlgae_Cyanobacteria_Phycocyanin", "partPerBillion", varCode, uuid) {} - /** - * @brief Construct a new TurnerCyclops_Phycocyanin object. - * - * @note This must be tied with a parent TurnerCyclops before it can be - * used. - */ - TurnerCyclops_Phycocyanin() - : Variable(static_cast(CYCLOPS_VAR_NUM), - static_cast(CYCLOPS_RESOLUTION), - "blue_GreenAlgae_Cyanobacteria_Phycocyanin", - "partPerBillion", "CyclopsPhycocyanin") {} /** * @brief Destroy the Turner Cyclops Phycocyanin variable object - no action * needed. @@ -735,16 +681,6 @@ class TurnerCyclops_Phycoerythrin : public Variable { : Variable(parentSense, static_cast(CYCLOPS_VAR_NUM), static_cast(CYCLOPS_RESOLUTION), "phycoerythrin", "partPerBillion", varCode, uuid) {} - /** - * @brief Construct a new TurnerCyclops_Phycoerythrin object. - * - * @note This must be tied with a parent TurnerCyclops before it can be - * used. - */ - TurnerCyclops_Phycoerythrin() - : Variable(static_cast(CYCLOPS_VAR_NUM), - static_cast(CYCLOPS_RESOLUTION), "phycoerythrin", - "partPerBillion", "CyclopsPhycoerythrin") {} /** * @brief Destroy the Turner Cyclops Phycoerythrin variable object - no * action needed. @@ -797,17 +733,6 @@ class TurnerCyclops_CDOM : public Variable { static_cast(CYCLOPS_RESOLUTION), "fluorescenceDissolvedOrganicMatter", "partPerBillion", varCode, uuid) {} - /** - * @brief Construct a new TurnerCyclops_CDOM object. - * - * @note This must be tied with a parent TurnerCyclops before it can be - * used. - */ - TurnerCyclops_CDOM() - : Variable(static_cast(CYCLOPS_VAR_NUM), - static_cast(CYCLOPS_RESOLUTION), - "fluorescenceDissolvedOrganicMatter", "partPerBillion", - "CyclopsCDOM") {} /** * @brief Destroy the Turner Cyclops CDOM variable object - no action * needed. @@ -858,17 +783,6 @@ class TurnerCyclops_CrudeOil : public Variable { static_cast(CYCLOPS_RESOLUTION), "petroleumHydrocarbonTotal", "partPerBillion", varCode, uuid) {} - /** - * @brief Construct a new TurnerCyclops_CrudeOil object. - * - * @note This must be tied with a parent TurnerCyclops before it can be - * used. - */ - TurnerCyclops_CrudeOil() - : Variable(static_cast(CYCLOPS_VAR_NUM), - static_cast(CYCLOPS_RESOLUTION), - "petroleumHydrocarbonTotal", "partPerBillion", - "CyclopsCrudeOil") {} /** * @brief Destroy the Turner Cyclops CrudeOil variable object - no action * needed. @@ -919,17 +833,6 @@ class TurnerCyclops_Brighteners : public Variable { : Variable(parentSense, static_cast(CYCLOPS_VAR_NUM), static_cast(CYCLOPS_RESOLUTION), "opticalBrighteners", "partPerBillion", varCode, uuid) {} - /** - * @brief Construct a new TurnerCyclops_Brighteners object. - * - * @note This must be tied with a parent TurnerCyclops before it can be - * used. - */ - TurnerCyclops_Brighteners() - : Variable(static_cast(CYCLOPS_VAR_NUM), - static_cast(CYCLOPS_RESOLUTION), - "opticalBrighteners", "partPerBillion", - "CyclopsOpticalBrighteners") {} /** * @brief Destroy the Turner Cyclops Brighteners object - no action needed. */ @@ -976,16 +879,6 @@ class TurnerCyclops_Turbidity : public Variable { : Variable(parentSense, static_cast(CYCLOPS_VAR_NUM), static_cast(CYCLOPS_RESOLUTION), "Turbidity", "nephelometricTurbidityUnit", varCode, uuid) {} - /** - * @brief Construct a new TurnerCyclops_Turbidity object. - * - * @note This must be tied with a parent TurnerCyclops before it can be - * used. - */ - TurnerCyclops_Turbidity() - : Variable(static_cast(CYCLOPS_VAR_NUM), - static_cast(CYCLOPS_RESOLUTION), "Turbidity", - "nephelometricTurbidityUnit", "CyclopsTurbidity") {} /** * @brief Destroy the Turner Cyclops Turbidity variable object - no action * needed. @@ -1034,16 +927,6 @@ class TurnerCyclops_PTSA : public Variable { : Variable(parentSense, static_cast(CYCLOPS_VAR_NUM), static_cast(CYCLOPS_RESOLUTION), "ptsa", "partPerBillion", varCode, uuid) {} - /** - * @brief Construct a new TurnerCyclops_PTSA object. - * - * @note This must be tied with a parent TurnerCyclops before it can be - * used. - */ - TurnerCyclops_PTSA() - : Variable(static_cast(CYCLOPS_VAR_NUM), - static_cast(CYCLOPS_RESOLUTION), "ptsa", - "partPerBillion", "CyclopsPTSA") {} /** * @brief Destroy the Turner Cyclops PTSA variable object - no action * needed. @@ -1092,16 +975,6 @@ class TurnerCyclops_BTEX : public Variable { : Variable(parentSense, static_cast(CYCLOPS_VAR_NUM), static_cast(CYCLOPS_RESOLUTION), "btex", "partPerMillion", varCode, uuid) {} - /** - * @brief Construct a new TurnerCyclops_BTEX object. - * - * @note This must be tied with a parent TurnerCyclops before it can be - * used. - */ - TurnerCyclops_BTEX() - : Variable(static_cast(CYCLOPS_VAR_NUM), - static_cast(CYCLOPS_RESOLUTION), "btex", - "partPerMillion", "CyclopsBTEX") {} /** * @brief Destroy the Turner Cyclops BTEX variable object - no action * needed. @@ -1149,16 +1022,6 @@ class TurnerCyclops_Tryptophan : public Variable { : Variable(parentSense, static_cast(CYCLOPS_VAR_NUM), static_cast(CYCLOPS_RESOLUTION), "tryptophan", "partPerBillion", varCode, uuid) {} - /** - * @brief Construct a new TurnerCyclops_Tryptophan object. - * - * @note This must be tied with a parent TurnerCyclops before it can be - * used. - */ - TurnerCyclops_Tryptophan() - : Variable(static_cast(CYCLOPS_VAR_NUM), - static_cast(CYCLOPS_RESOLUTION), "tryptophan", - "partPerBillion", "CyclopsTryptophan") {} /** * @brief Destroy the Turner Cyclops Tryptophan variable object - no action * needed. @@ -1208,17 +1071,6 @@ class TurnerCyclops_RedChlorophyll : public Variable { static_cast(CYCLOPS_RESOLUTION), "chlorophyllFluorescence", "microgramPerLiter", varCode, uuid) {} - /** - * @brief Construct a new TurnerCyclops_RedChlorophyll object. - * - * @note This must be tied with a parent TurnerCyclops before it can be - * used. - */ - TurnerCyclops_RedChlorophyll() - : Variable(static_cast(CYCLOPS_VAR_NUM), - static_cast(CYCLOPS_RESOLUTION), - "chlorophyllFluorescence", "microgramPerLiter", - "CyclopsRedChlorophyll") {} /** * @brief Destroy the Turner Cyclops Red Chlorophyll variable object - no * action needed. diff --git a/src/sensors/TurnerTurbidityPlus.h b/src/sensors/TurnerTurbidityPlus.h index 09595200a..bb6d24eab 100644 --- a/src/sensors/TurnerTurbidityPlus.h +++ b/src/sensors/TurnerTurbidityPlus.h @@ -383,18 +383,6 @@ class TurnerTurbidityPlus_Voltage : public Variable { static_cast(TURBIDITY_PLUS_VOLTAGE_RESOLUTION), TURBIDITY_PLUS_VOLTAGE_VAR_NAME, TURBIDITY_PLUS_VOLTAGE_UNIT_NAME, varCode, uuid) {} - /** - * @brief Construct a new TurnerTurbidityPlus_Voltage object. - * - * @note This must be tied with a parent TurnerTurbidityPlus before it can - * be used. - */ - TurnerTurbidityPlus_Voltage() - : Variable(static_cast(TURBIDITY_PLUS_VOLTAGE_VAR_NUM), - static_cast(TURBIDITY_PLUS_VOLTAGE_RESOLUTION), - TURBIDITY_PLUS_VOLTAGE_VAR_NAME, - TURBIDITY_PLUS_VOLTAGE_UNIT_NAME, - TURBIDITY_PLUS_VOLTAGE_DEFAULT_CODE) {} /** * @brief Destroy the TurnerTurbidityPlus_Voltage object - no action needed. */ @@ -432,17 +420,6 @@ class TurnerTurbidityPlus_Turbidity : public Variable { static_cast(TURBIDITY_PLUS_RESOLUTION), TURBIDITY_PLUS_VAR_NAME, TURBIDITY_PLUS_UNIT_NAME, varCode, uuid) {} - /** - * @brief Construct a new TurnerTurbidityPlus_Turbidity object. - * - * @note This must be tied with a parent TurnerTurbidityPlus before it can - * be used. - */ - TurnerTurbidityPlus_Turbidity() - : Variable(static_cast(TURBIDITY_PLUS_VAR_NUM), - static_cast(TURBIDITY_PLUS_RESOLUTION), - TURBIDITY_PLUS_VAR_NAME, TURBIDITY_PLUS_UNIT_NAME, - TURBIDITY_PLUS_DEFAULT_CODE) {} /** * @brief Destroy the TurnerTurbidityPlus_Turbidity object - no action * needed. diff --git a/src/sensors/VegaPuls21.h b/src/sensors/VegaPuls21.h index 8037c6845..645eacdbf 100644 --- a/src/sensors/VegaPuls21.h +++ b/src/sensors/VegaPuls21.h @@ -294,7 +294,6 @@ class VegaPuls21 : public SDI12Sensors { VEGAPULS21_WARM_UP_TIME_MS, VEGAPULS21_STABILIZATION_TIME_MS, VEGAPULS21_MEASUREMENT_TIME_MS, VEGAPULS21_EXTRA_WAKE_TIME_MS, VEGAPULS21_INC_CALC_VARIABLES) {} - /** * @brief Destroy the VEGAPULS C 21 object */ @@ -330,17 +329,6 @@ class VegaPuls21_Stage : public Variable { static_cast(VEGAPULS21_STAGE_RESOLUTION), VEGAPULS21_STAGE_VAR_NAME, VEGAPULS21_STAGE_UNIT_NAME, varCode, uuid) {} - /** - * @brief Construct a new VegaPuls21_Stage object. - * - * @note This must be tied with a parent VegaPuls21 before it can be - * used. - */ - VegaPuls21_Stage() - : Variable(static_cast(VEGAPULS21_STAGE_VAR_NUM), - static_cast(VEGAPULS21_STAGE_RESOLUTION), - VEGAPULS21_STAGE_VAR_NAME, VEGAPULS21_STAGE_UNIT_NAME, - VEGAPULS21_STAGE_DEFAULT_CODE) {} /** * @brief Destroy the VegaPuls21_Stage object - no action needed. */ @@ -377,17 +365,6 @@ class VegaPuls21_Distance : public Variable { static_cast(VEGAPULS21_DISTANCE_RESOLUTION), VEGAPULS21_DISTANCE_VAR_NAME, VEGAPULS21_DISTANCE_UNIT_NAME, varCode, uuid) {} - /** - * @brief Construct a new VegaPuls21_Distance object. - * - * @note This must be tied with a parent VegaPuls21 before it can be - * used. - */ - VegaPuls21_Distance() - : Variable(static_cast(VEGAPULS21_DISTANCE_VAR_NUM), - static_cast(VEGAPULS21_DISTANCE_RESOLUTION), - VEGAPULS21_DISTANCE_VAR_NAME, VEGAPULS21_DISTANCE_UNIT_NAME, - VEGAPULS21_DISTANCE_DEFAULT_CODE) {} /** * @brief Destroy the VegaPuls21_Distance object - no action needed. */ @@ -422,17 +399,6 @@ class VegaPuls21_Temp : public Variable { static_cast(VEGAPULS21_TEMP_RESOLUTION), VEGAPULS21_TEMP_VAR_NAME, VEGAPULS21_TEMP_UNIT_NAME, varCode, uuid) {} - /** - * @brief Construct a new VegaPuls21_Temp object. - * - * @note This must be tied with a parent VegaPuls21 before it can be - * used. - */ - VegaPuls21_Temp() - : Variable(static_cast(VEGAPULS21_TEMP_VAR_NUM), - static_cast(VEGAPULS21_TEMP_RESOLUTION), - VEGAPULS21_TEMP_VAR_NAME, VEGAPULS21_TEMP_UNIT_NAME, - VEGAPULS21_TEMP_DEFAULT_CODE) {} /** * @brief Destroy the VegaPuls21_Temp object - no action needed. */ @@ -469,18 +435,6 @@ class VegaPuls21_Reliability : public Variable { static_cast(VEGAPULS21_RELIABILITY_RESOLUTION), VEGAPULS21_RELIABILITY_VAR_NAME, VEGAPULS21_RELIABILITY_UNIT_NAME, varCode, uuid) {} - /** - * @brief Construct a new VegaPuls21_Reliability object. - * - * @note This must be tied with a parent VegaPuls21 before it can be - * used. - */ - VegaPuls21_Reliability() - : Variable(static_cast(VEGAPULS21_RELIABILITY_VAR_NUM), - static_cast(VEGAPULS21_RELIABILITY_RESOLUTION), - VEGAPULS21_RELIABILITY_VAR_NAME, - VEGAPULS21_RELIABILITY_UNIT_NAME, - VEGAPULS21_RELIABILITY_DEFAULT_CODE) {} /** * @brief Destroy the VegaPuls21_Reliability object - no action * needed. @@ -518,18 +472,6 @@ class VegaPuls21_ErrorCode : public Variable { static_cast(VEGAPULS21_ERRORCODE_RESOLUTION), VEGAPULS21_ERRORCODE_VAR_NAME, VEGAPULS21_ERRORCODE_UNIT_NAME, varCode, uuid) {} - /** - * @brief Construct a new VegaPuls21_ErrorCode object. - * - * @note This must be tied with a parent VegaPuls21 before it can be - * used. - */ - VegaPuls21_ErrorCode() - : Variable(static_cast(VEGAPULS21_ERRORCODE_VAR_NUM), - static_cast(VEGAPULS21_ERRORCODE_RESOLUTION), - VEGAPULS21_ERRORCODE_VAR_NAME, - VEGAPULS21_ERRORCODE_UNIT_NAME, - VEGAPULS21_ERRORCODE_DEFAULT_CODE) {} /** * @brief Destroy the VegaPuls21_ErrorCode object - no action * needed. diff --git a/src/sensors/YosemitechY4000.h b/src/sensors/YosemitechY4000.h index e9a6314cb..3cb4b1692 100644 --- a/src/sensors/YosemitechY4000.h +++ b/src/sensors/YosemitechY4000.h @@ -405,17 +405,6 @@ class YosemitechY4000_DOmgL : public Variable { static_cast(Y4000_DOMGL_RESOLUTION), Y4000_DOMGL_VAR_NAME, Y4000_DOMGL_UNIT_NAME, varCode, uuid) { } - /** - * @brief Construct a new YosemitechY4000_DOmgL object. - * - * @note This must be tied with a parent YosemitechY4000 before it can be - * used. - */ - YosemitechY4000_DOmgL() - : Variable(static_cast(Y4000_DOMGL_VAR_NUM), - static_cast(Y4000_DOMGL_RESOLUTION), - Y4000_DOMGL_VAR_NAME, Y4000_DOMGL_UNIT_NAME, - Y4000_DOMGL_DEFAULT_CODE) {} /** * @brief Destroy the YosemitechY4000_DOmgL object - no action needed. */ @@ -449,17 +438,6 @@ class YosemitechY4000_Turbidity : public Variable { : Variable(parentSense, static_cast(Y4000_TURB_VAR_NUM), static_cast(Y4000_TURB_RESOLUTION), Y4000_TURB_VAR_NAME, Y4000_TURB_UNIT_NAME, varCode, uuid) {} - /** - * @brief Construct a new YosemitechY4000_Turbidity object. - * - * @note This must be tied with a parent YosemitechY4000 before it can be - * used. - */ - YosemitechY4000_Turbidity() - : Variable(static_cast(Y4000_TURB_VAR_NUM), - static_cast(Y4000_TURB_RESOLUTION), - Y4000_TURB_VAR_NAME, Y4000_TURB_UNIT_NAME, - Y4000_TURB_DEFAULT_CODE) {} /** * @brief Destroy the YosemitechY4000_Turbidity object - no action needed. */ @@ -493,17 +471,6 @@ class YosemitechY4000_Cond : public Variable { : Variable(parentSense, static_cast(Y4000_COND_VAR_NUM), static_cast(Y4000_COND_RESOLUTION), Y4000_COND_VAR_NAME, Y4000_COND_UNIT_NAME, varCode, uuid) {} - /** - * @brief Construct a new YosemitechY4000_Cond object. - * - * @note This must be tied with a parent YosemitechY4000 before it can be - * used. - */ - YosemitechY4000_Cond() - : Variable(static_cast(Y4000_COND_VAR_NUM), - static_cast(Y4000_COND_RESOLUTION), - Y4000_COND_VAR_NAME, Y4000_COND_UNIT_NAME, - Y4000_COND_DEFAULT_CODE) {} /** * @brief Destroy the YosemitechY4000_Cond object - no action needed. */ @@ -537,16 +504,6 @@ class YosemitechY4000_pH : public Variable { : Variable(parentSense, static_cast(Y4000_PH_VAR_NUM), static_cast(Y4000_PH_RESOLUTION), Y4000_PH_VAR_NAME, Y4000_PH_UNIT_NAME, varCode, uuid) {} - /** - * @brief Construct a new YosemitechY4000_pH object. - * - * @note This must be tied with a parent YosemitechY4000 before it can be - * used. - */ - YosemitechY4000_pH() - : Variable(static_cast(Y4000_PH_VAR_NUM), - static_cast(Y4000_PH_RESOLUTION), Y4000_PH_VAR_NAME, - Y4000_PH_UNIT_NAME, Y4000_PH_DEFAULT_CODE) {} /** * @brief Destroy the YosemitechY4000_pH object - no action needed. */ @@ -580,17 +537,6 @@ class YosemitechY4000_Temp : public Variable { : Variable(parentSense, static_cast(Y4000_TEMP_VAR_NUM), static_cast(Y4000_TEMP_RESOLUTION), Y4000_TEMP_VAR_NAME, Y4000_TEMP_UNIT_NAME, varCode, uuid) {} - /** - * @brief Construct a new YosemitechY4000_Temp object. - * - * @note This must be tied with a parent YosemitechY4000 before it can be - * used. - */ - YosemitechY4000_Temp() - : Variable(static_cast(Y4000_TEMP_VAR_NUM), - static_cast(Y4000_TEMP_RESOLUTION), - Y4000_TEMP_VAR_NAME, Y4000_TEMP_UNIT_NAME, - Y4000_TEMP_DEFAULT_CODE) {} /** * @brief Destroy the YosemitechY4000_Temp object - no action needed. */ @@ -624,17 +570,6 @@ class YosemitechY4000_ORP : public Variable { : Variable(parentSense, static_cast(Y4000_ORP_VAR_NUM), static_cast(Y4000_ORP_RESOLUTION), Y4000_ORP_VAR_NAME, Y4000_ORP_UNIT_NAME, varCode, uuid) {} - /** - * @brief Construct a new YosemitechY4000_ORP object. - * - * @note This must be tied with a parent YosemitechY4000 before it can be - * used. - */ - YosemitechY4000_ORP() - : Variable(static_cast(Y4000_ORP_VAR_NUM), - static_cast(Y4000_ORP_RESOLUTION), - Y4000_ORP_VAR_NAME, Y4000_ORP_UNIT_NAME, - Y4000_ORP_DEFAULT_CODE) {} /** * @brief Destroy the YosemitechY4000_ORP object - no action needed. */ @@ -669,17 +604,6 @@ class YosemitechY4000_Chlorophyll : public Variable { static_cast(Y4000_CHLORO_RESOLUTION), Y4000_CHLORO_VAR_NAME, Y4000_CHLORO_UNIT_NAME, varCode, uuid) {} - /** - * @brief Construct a new YosemitechY4000_Chlorophyll object. - * - * @note This must be tied with a parent YosemitechY4000 before it can be - * used. - */ - YosemitechY4000_Chlorophyll() - : Variable(static_cast(Y4000_CHLORO_VAR_NUM), - static_cast(Y4000_CHLORO_RESOLUTION), - Y4000_CHLORO_VAR_NAME, Y4000_CHLORO_UNIT_NAME, - Y4000_CHLORO_DEFAULT_CODE) {} /** * @brief Destroy the YosemitechY4000_Chlorophyll() object - no action * needed. @@ -714,17 +638,6 @@ class YosemitechY4000_BGA : public Variable { : Variable(parentSense, static_cast(Y4000_BGA_VAR_NUM), static_cast(Y4000_BGA_RESOLUTION), Y4000_BGA_VAR_NAME, Y4000_BGA_UNIT_NAME, varCode, uuid) {} - /** - * @brief Construct a new YosemitechY4000_BGA object. - * - * @note This must be tied with a parent YosemitechY4000 before it can be - * used. - */ - YosemitechY4000_BGA() - : Variable(static_cast(Y4000_BGA_VAR_NUM), - static_cast(Y4000_BGA_RESOLUTION), - Y4000_BGA_VAR_NAME, Y4000_BGA_UNIT_NAME, - Y4000_BGA_DEFAULT_CODE) {} /** * @brief Destroy the YosemitechY4000_BGA object - no action needed. */ diff --git a/src/sensors/YosemitechY504.h b/src/sensors/YosemitechY504.h index 939ad61a8..a6c8a81ea 100644 --- a/src/sensors/YosemitechY504.h +++ b/src/sensors/YosemitechY504.h @@ -258,17 +258,6 @@ class YosemitechY504_DOpct : public Variable { : Variable(parentSense, static_cast(Y504_DOPCT_VAR_NUM), static_cast(Y504_DOPCT_RESOLUTION), Y504_DOPCT_VAR_NAME, Y504_DOPCT_UNIT_NAME, varCode, uuid) {} - /** - * @brief Construct a new YosemitechY504_DOpct object. - * - * @note This must be tied with a parent YosemitechY504 before it can be - * used. - */ - YosemitechY504_DOpct() - : Variable(static_cast(Y504_DOPCT_VAR_NUM), - static_cast(Y504_DOPCT_RESOLUTION), - Y504_DOPCT_VAR_NAME, Y504_DOPCT_UNIT_NAME, - Y504_DOPCT_DEFAULT_CODE) {} /** * @brief Destroy the YosemitechY504_DOpct object - no action needed. */ @@ -303,17 +292,6 @@ class YosemitechY504_Temp : public Variable { : Variable(parentSense, static_cast(Y504_TEMP_VAR_NUM), static_cast(Y504_TEMP_RESOLUTION), Y504_TEMP_VAR_NAME, Y504_TEMP_UNIT_NAME, varCode, uuid) {} - /** - * @brief Construct a new YosemitechY504_Temp object. - * - * @note This must be tied with a parent YosemitechY504 before it can be - * used. - */ - YosemitechY504_Temp() - : Variable(static_cast(Y504_TEMP_VAR_NUM), - static_cast(Y504_TEMP_RESOLUTION), - Y504_TEMP_VAR_NAME, Y504_TEMP_UNIT_NAME, - Y504_TEMP_DEFAULT_CODE) {} /** * @brief Destroy the YosemitechY504_Temp object - no action needed. */ @@ -348,17 +326,6 @@ class YosemitechY504_DOmgL : public Variable { : Variable(parentSense, static_cast(Y504_DOMGL_VAR_NUM), static_cast(Y504_DOMGL_RESOLUTION), Y504_DOMGL_VAR_NAME, Y504_DOMGL_UNIT_NAME, varCode, uuid) {} - /** - * @brief Construct a new YosemitechY504_DOmgL object. - * - * @note This must be tied with a parent YosemitechY504 before it can be - * used. - */ - YosemitechY504_DOmgL() - : Variable(static_cast(Y504_DOMGL_VAR_NUM), - static_cast(Y504_DOMGL_RESOLUTION), - Y504_DOMGL_VAR_NAME, Y504_DOMGL_UNIT_NAME, - Y504_DOMGL_DEFAULT_CODE) {} /** * @brief Destroy the YosemitechY504_DOmgL object - no action needed. */ diff --git a/src/sensors/YosemitechY510.h b/src/sensors/YosemitechY510.h index da319c60f..d4e08bd63 100644 --- a/src/sensors/YosemitechY510.h +++ b/src/sensors/YosemitechY510.h @@ -224,17 +224,6 @@ class YosemitechY510_Turbidity : public Variable { : Variable(parentSense, static_cast(Y510_TURB_VAR_NUM), static_cast(Y510_TURB_RESOLUTION), Y510_TURB_VAR_NAME, Y510_TURB_UNIT_NAME, varCode, uuid) {} - /** - * @brief Construct a new YosemitechY510_Turbidity object. - * - * @note This must be tied with a parent YosemitechY510 before it can be - * used. - */ - YosemitechY510_Turbidity() - : Variable(static_cast(Y510_TURB_VAR_NUM), - static_cast(Y510_TURB_RESOLUTION), - Y510_TURB_VAR_NAME, Y510_TURB_UNIT_NAME, - Y510_TURB_DEFAULT_CODE) {} /** * @brief Destroy the YosemitechY510_Turbidity object - no action needed. */ @@ -269,17 +258,6 @@ class YosemitechY510_Temp : public Variable { : Variable(parentSense, static_cast(Y510_TEMP_VAR_NUM), static_cast(Y510_TEMP_RESOLUTION), Y510_TEMP_VAR_NAME, Y510_TEMP_UNIT_NAME, varCode, uuid) {} - /** - * @brief Construct a new YosemitechY510_Temp object. - * - * @note This must be tied with a parent YosemitechY510 before it can be - * used. - */ - YosemitechY510_Temp() - : Variable(static_cast(Y510_TEMP_VAR_NUM), - static_cast(Y510_TEMP_RESOLUTION), - Y510_TEMP_VAR_NAME, Y510_TEMP_UNIT_NAME, - Y510_TEMP_DEFAULT_CODE) {} /** * @brief Destroy the YosemitechY510_Temp object - no action needed. */ diff --git a/src/sensors/YosemitechY511.h b/src/sensors/YosemitechY511.h index 32dce7011..5adf2dda8 100644 --- a/src/sensors/YosemitechY511.h +++ b/src/sensors/YosemitechY511.h @@ -238,17 +238,6 @@ class YosemitechY511_Turbidity : public Variable { : Variable(parentSense, static_cast(Y511_TURB_VAR_NUM), static_cast(Y511_TURB_RESOLUTION), Y511_TURB_VAR_NAME, Y511_TURB_UNIT_NAME, varCode, uuid) {} - /** - * @brief Construct a new YosemitechY511_Turbidity object. - * - * @note This must be tied with a parent YosemitechY511 before it can be - * used. - */ - YosemitechY511_Turbidity() - : Variable(static_cast(Y511_TURB_VAR_NUM), - static_cast(Y511_TURB_RESOLUTION), - Y511_TURB_VAR_NAME, Y511_TURB_UNIT_NAME, - Y511_TURB_DEFAULT_CODE) {} /** * @brief Destroy the YosemitechY511_Turbidity object - no action needed. */ @@ -283,17 +272,6 @@ class YosemitechY511_Temp : public Variable { : Variable(parentSense, static_cast(Y511_TEMP_VAR_NUM), static_cast(Y511_TEMP_RESOLUTION), Y511_TEMP_VAR_NAME, Y511_TEMP_UNIT_NAME, varCode, uuid) {} - /** - * @brief Construct a new YosemitechY511_Temp object. - * - * @note This must be tied with a parent YosemitechY511 before it can be - * used. - */ - YosemitechY511_Temp() - : Variable(static_cast(Y511_TEMP_VAR_NUM), - static_cast(Y511_TEMP_RESOLUTION), - Y511_TEMP_VAR_NAME, Y511_TEMP_UNIT_NAME, - Y511_TEMP_DEFAULT_CODE) {} /** * @brief Destroy the YosemitechY511_Temp object - no action needed. */ diff --git a/src/sensors/YosemitechY513.h b/src/sensors/YosemitechY513.h index 16f627d4c..890178ddb 100644 --- a/src/sensors/YosemitechY513.h +++ b/src/sensors/YosemitechY513.h @@ -225,16 +225,6 @@ class YosemitechY513_BGA : public Variable { : Variable(parentSense, static_cast(Y513_BGA_VAR_NUM), static_cast(Y513_BGA_RESOLUTION), Y513_BGA_VAR_NAME, Y513_BGA_UNIT_NAME, varCode, uuid) {} - /** - * @brief Construct a new YosemitechY513_BGA object. - * - * @note This must be tied with a parent YosemitechY513 before it can be - * used. - */ - YosemitechY513_BGA() - : Variable(static_cast(Y513_BGA_VAR_NUM), - static_cast(Y513_BGA_RESOLUTION), Y513_BGA_VAR_NAME, - Y513_BGA_UNIT_NAME, Y513_BGA_DEFAULT_CODE) {} /** * @brief Destroy the YosemitechY513_BGA() object - no action * needed. @@ -270,17 +260,6 @@ class YosemitechY513_Temp : public Variable { : Variable(parentSense, static_cast(Y513_TEMP_VAR_NUM), static_cast(Y513_TEMP_RESOLUTION), Y513_TEMP_VAR_NAME, Y513_TEMP_UNIT_NAME, varCode, uuid) {} - /** - * @brief Construct a new YosemitechY513_Temp object. - * - * @note This must be tied with a parent YosemitechY513 before it can be - * used. - */ - YosemitechY513_Temp() - : Variable(static_cast(Y513_TEMP_VAR_NUM), - static_cast(Y513_TEMP_RESOLUTION), - Y513_TEMP_VAR_NAME, Y513_TEMP_UNIT_NAME, - Y513_TEMP_DEFAULT_CODE) {} /** * @brief Destroy the YosemitechY513_Temp object - no action needed. */ diff --git a/src/sensors/YosemitechY514.h b/src/sensors/YosemitechY514.h index 2a4cf50cf..d926fc239 100644 --- a/src/sensors/YosemitechY514.h +++ b/src/sensors/YosemitechY514.h @@ -228,17 +228,6 @@ class YosemitechY514_Chlorophyll : public Variable { static_cast(Y514_CHLORO_RESOLUTION), Y514_CHLORO_VAR_NAME, Y514_CHLORO_UNIT_NAME, varCode, uuid) { } - /** - * @brief Construct a new YosemitechY514_Chlorophyll object. - * - * @note This must be tied with a parent YosemitechY514 before it can be - * used. - */ - YosemitechY514_Chlorophyll() - : Variable(static_cast(Y514_CHLORO_VAR_NUM), - static_cast(Y514_CHLORO_RESOLUTION), - Y514_CHLORO_VAR_NAME, Y514_CHLORO_UNIT_NAME, - Y514_CHLORO_DEFAULT_CODE) {} /** * @brief Destroy the YosemitechY514_Chlorophyll() object - no action * needed. @@ -274,17 +263,6 @@ class YosemitechY514_Temp : public Variable { : Variable(parentSense, static_cast(Y514_TEMP_VAR_NUM), static_cast(Y514_TEMP_RESOLUTION), Y514_TEMP_VAR_NAME, Y514_TEMP_UNIT_NAME, varCode, uuid) {} - /** - * @brief Construct a new YosemitechY514_Temp object. - * - * @note This must be tied with a parent YosemitechY514 before it can be - * used. - */ - YosemitechY514_Temp() - : Variable(static_cast(Y514_TEMP_VAR_NUM), - static_cast(Y514_TEMP_RESOLUTION), - Y514_TEMP_VAR_NAME, Y514_TEMP_UNIT_NAME, - Y514_TEMP_DEFAULT_CODE) {} /** * @brief Destroy the YosemitechY514_Temp object - no action needed. */ diff --git a/src/sensors/YosemitechY520.h b/src/sensors/YosemitechY520.h index 75641d489..7fbf90a85 100644 --- a/src/sensors/YosemitechY520.h +++ b/src/sensors/YosemitechY520.h @@ -225,17 +225,6 @@ class YosemitechY520_Cond : public Variable { : Variable(parentSense, static_cast(Y520_COND_VAR_NUM), static_cast(Y520_COND_RESOLUTION), Y520_COND_VAR_NAME, Y520_COND_UNIT_NAME, varCode, uuid) {} - /** - * @brief Construct a new YosemitechY520_Cond object. - * - * @note This must be tied with a parent YosemitechY520 before it can be - * used. - */ - YosemitechY520_Cond() - : Variable(static_cast(Y520_COND_VAR_NUM), - static_cast(Y520_COND_RESOLUTION), - Y520_COND_VAR_NAME, Y520_COND_UNIT_NAME, - Y520_COND_DEFAULT_CODE) {} /** * @brief Destroy the YosemitechY520_Cond object - no action needed. */ @@ -270,17 +259,6 @@ class YosemitechY520_Temp : public Variable { : Variable(parentSense, static_cast(Y520_TEMP_VAR_NUM), static_cast(Y520_TEMP_RESOLUTION), Y520_TEMP_VAR_NAME, Y520_TEMP_UNIT_NAME, varCode, uuid) {} - /** - * @brief Construct a new YosemitechY520_Temp object. - * - * @note This must be tied with a parent YosemitechY520 before it can be - * used. - */ - YosemitechY520_Temp() - : Variable(static_cast(Y520_TEMP_VAR_NUM), - static_cast(Y520_TEMP_RESOLUTION), - Y520_TEMP_VAR_NAME, Y520_TEMP_UNIT_NAME, - Y520_TEMP_DEFAULT_CODE) {} /** * @brief Destroy the YosemitechY520_Temp object - no action needed. */ diff --git a/src/sensors/YosemitechY532.h b/src/sensors/YosemitechY532.h index 8da572d11..a01e42c0b 100644 --- a/src/sensors/YosemitechY532.h +++ b/src/sensors/YosemitechY532.h @@ -251,16 +251,6 @@ class YosemitechY532_pH : public Variable { : Variable(parentSense, static_cast(Y532_PH_VAR_NUM), static_cast(Y532_PH_RESOLUTION), Y532_PH_VAR_NAME, Y532_PH_UNIT_NAME, varCode, uuid) {} - /** - * @brief Construct a new YosemitechY532_pH object. - * - * @note This must be tied with a parent YosemitechY532 before it can be - * used. - */ - YosemitechY532_pH() - : Variable(static_cast(Y532_PH_VAR_NUM), - static_cast(Y532_PH_RESOLUTION), Y532_PH_VAR_NAME, - Y532_PH_UNIT_NAME, Y532_PH_DEFAULT_CODE) {} /** * @brief Destroy the YosemitechY532_pH object - no action needed. */ @@ -295,17 +285,6 @@ class YosemitechY532_Temp : public Variable { : Variable(parentSense, static_cast(Y532_TEMP_VAR_NUM), static_cast(Y532_TEMP_RESOLUTION), Y532_TEMP_VAR_NAME, Y532_TEMP_UNIT_NAME, varCode, uuid) {} - /** - * @brief Construct a new YosemitechY532_Temp object. - * - * @note This must be tied with a parent YosemitechY532 before it can be - * used. - */ - YosemitechY532_Temp() - : Variable(static_cast(Y532_TEMP_VAR_NUM), - static_cast(Y532_TEMP_RESOLUTION), - Y532_TEMP_VAR_NAME, Y532_TEMP_UNIT_NAME, - Y532_TEMP_DEFAULT_CODE) {} /** * @brief Destroy the YosemitechY532_Temp object - no action needed. */ @@ -341,17 +320,6 @@ class YosemitechY532_Voltage : public Variable { static_cast(Y532_VOLTAGE_RESOLUTION), Y532_VOLTAGE_VAR_NAME, Y532_VOLTAGE_UNIT_NAME, varCode, uuid) {} - /** - * @brief Construct a new YosemitechY532_Voltage object. - * - * @note This must be tied with a parent YosemitechY532 before it can be - * used. - */ - YosemitechY532_Voltage() - : Variable(static_cast(Y532_VOLTAGE_VAR_NUM), - static_cast(Y532_VOLTAGE_RESOLUTION), - Y532_VOLTAGE_VAR_NAME, Y532_VOLTAGE_UNIT_NAME, - Y532_VOLTAGE_DEFAULT_CODE) {} /** * @brief Destroy the YosemitechY532_Voltage object - no action needed. */ diff --git a/src/sensors/YosemitechY533.h b/src/sensors/YosemitechY533.h index d875c4946..1f90c856a 100644 --- a/src/sensors/YosemitechY533.h +++ b/src/sensors/YosemitechY533.h @@ -227,16 +227,6 @@ class YosemitechY533_ORP : public Variable { : Variable(parentSense, static_cast(Y533_ORP_VAR_NUM), static_cast(Y533_ORP_RESOLUTION), Y533_ORP_VAR_NAME, Y533_ORP_UNIT_NAME, varCode, uuid) {} - /** - * @brief Construct a new YosemitechY533_ORP object. - * - * @note This must be tied with a parent YosemitechY533 before it can be - * used. - */ - YosemitechY533_ORP() - : Variable(static_cast(Y533_ORP_VAR_NUM), - static_cast(Y533_ORP_RESOLUTION), Y533_ORP_VAR_NAME, - Y533_ORP_UNIT_NAME, Y533_ORP_DEFAULT_CODE) {} /** * @brief Destroy the YosemitechY533_ORP object - no action needed. */ @@ -271,17 +261,6 @@ class YosemitechY533_Temp : public Variable { : Variable(parentSense, static_cast(Y533_TEMP_VAR_NUM), static_cast(Y533_TEMP_RESOLUTION), Y533_TEMP_VAR_NAME, Y533_TEMP_UNIT_NAME, varCode, uuid) {} - /** - * @brief Construct a new YosemitechY533_Temp object. - * - * @note This must be tied with a parent YosemitechY533 before it can be - * used. - */ - YosemitechY533_Temp() - : Variable(static_cast(Y533_TEMP_VAR_NUM), - static_cast(Y533_TEMP_RESOLUTION), - Y533_TEMP_VAR_NAME, Y533_TEMP_UNIT_NAME, - Y533_TEMP_DEFAULT_CODE) {} /** * @brief Destroy the YosemitechY533_Temp object - no action needed. */ diff --git a/src/sensors/YosemitechY551.h b/src/sensors/YosemitechY551.h index 392a74cbb..affceee40 100644 --- a/src/sensors/YosemitechY551.h +++ b/src/sensors/YosemitechY551.h @@ -255,16 +255,6 @@ class YosemitechY551_COD : public Variable { : Variable(parentSense, static_cast(Y551_COD_VAR_NUM), static_cast(Y551_COD_RESOLUTION), Y551_COD_VAR_NAME, Y551_COD_UNIT_NAME, varCode, uuid) {} - /** - * @brief Construct a new YosemitechY551_COD object. - * - * @note This must be tied with a parent YosemitechY551 before it can be - * used. - */ - YosemitechY551_COD() - : Variable(static_cast(Y551_COD_VAR_NUM), - static_cast(Y551_COD_RESOLUTION), Y551_COD_VAR_NAME, - Y551_COD_UNIT_NAME, Y551_COD_DEFAULT_CODE) {} /** * @brief Destroy the YosemitechY551_COD object - no action needed. */ @@ -299,17 +289,6 @@ class YosemitechY551_Temp : public Variable { : Variable(parentSense, static_cast(Y551_TEMP_VAR_NUM), static_cast(Y551_TEMP_RESOLUTION), Y551_TEMP_VAR_NAME, Y551_TEMP_UNIT_NAME, varCode, uuid) {} - /** - * @brief Construct a new YosemitechY551_Temp object. - * - * @note This must be tied with a parent YosemitechY551 before it can be - * used. - */ - YosemitechY551_Temp() - : Variable(static_cast(Y551_TEMP_VAR_NUM), - static_cast(Y551_TEMP_RESOLUTION), - Y551_TEMP_VAR_NAME, Y551_TEMP_UNIT_NAME, - Y551_TEMP_DEFAULT_CODE) {} /** * @brief Destroy the YosemitechY551_Temp object - no action needed. */ @@ -344,17 +323,6 @@ class YosemitechY551_Turbidity : public Variable { : Variable(parentSense, static_cast(Y551_TURB_VAR_NUM), static_cast(Y551_TURB_RESOLUTION), Y551_TURB_VAR_NAME, Y551_TURB_UNIT_NAME, varCode, uuid) {} - /** - * @brief Construct a new YosemitechY551_Turbidity object. - * - * @note This must be tied with a parent YosemitechY551 before it can be - * used. - */ - YosemitechY551_Turbidity() - : Variable(static_cast(Y551_TURB_VAR_NUM), - static_cast(Y551_TURB_RESOLUTION), - Y551_TURB_VAR_NAME, Y551_TURB_UNIT_NAME, - Y551_TURB_DEFAULT_CODE) {} /** * @brief Destroy the YosemitechY551_Turbidity object - no action needed. */ diff --git a/src/sensors/YosemitechY560.h b/src/sensors/YosemitechY560.h index 5b8687b33..af73deae8 100644 --- a/src/sensors/YosemitechY560.h +++ b/src/sensors/YosemitechY560.h @@ -252,17 +252,6 @@ class YosemitechY560_NH4_N : public Variable { : Variable(parentSense, static_cast(Y560_NH4_N_VAR_NUM), static_cast(Y560_NH4_N_RESOLUTION), Y560_NH4_N_VAR_NAME, Y560_NH4_N_UNIT_NAME, varCode, uuid) {} - /** - * @brief Construct a new YosemitechY560_NH4_N object. - * - * @note This must be tied with a parent YosemitechY560 before it can be - * used. - */ - YosemitechY560_NH4_N() - : Variable(static_cast(Y560_NH4_N_VAR_NUM), - static_cast(Y560_NH4_N_RESOLUTION), - Y560_NH4_N_VAR_NAME, Y560_NH4_N_UNIT_NAME, - Y560_NH4_N_DEFAULT_CODE) {} /** * @brief Destroy the YosemitechY560_NH4_N object - no action needed. */ @@ -297,17 +286,6 @@ class YosemitechY560_Temp : public Variable { : Variable(parentSense, static_cast(Y560_TEMP_VAR_NUM), static_cast(Y560_TEMP_RESOLUTION), Y560_TEMP_VAR_NAME, Y560_TEMP_UNIT_NAME, varCode, uuid) {} - /** - * @brief Construct a new YosemitechY560_Temp object. - * - * @note This must be tied with a parent YosemitechY560 before it can be - * used. - */ - YosemitechY560_Temp() - : Variable(static_cast(Y560_TEMP_VAR_NUM), - static_cast(Y560_TEMP_RESOLUTION), - Y560_TEMP_VAR_NAME, Y560_TEMP_UNIT_NAME, - Y560_TEMP_DEFAULT_CODE) {} /** * @brief Destroy the YosemitechY560_Temp object - no action needed. */ @@ -342,16 +320,6 @@ class YosemitechY560_pH : public Variable { : Variable(parentSense, static_cast(Y560_PH_VAR_NUM), static_cast(Y560_PH_RESOLUTION), Y560_PH_VAR_NAME, Y560_PH_UNIT_NAME, varCode, uuid) {} - /** - * @brief Construct a new YosemitechY560_pH object. - * - * @note This must be tied with a parent YosemitechY560 before it can be - * used. - */ - YosemitechY560_pH() - : Variable(static_cast(Y560_PH_VAR_NUM), - static_cast(Y560_PH_RESOLUTION), Y560_PH_VAR_NAME, - Y560_PH_UNIT_NAME, Y560_PH_DEFAULT_CODE) {} /** * @brief Destroy the YosemitechY560_pH object - no action needed. */ diff --git a/src/sensors/YosemitechY700.h b/src/sensors/YosemitechY700.h index 824255c18..d2110d873 100644 --- a/src/sensors/YosemitechY700.h +++ b/src/sensors/YosemitechY700.h @@ -224,17 +224,6 @@ class YosemitechY700_Pressure : public Variable { : Variable(parentSense, static_cast(Y700_PRES_VAR_NUM), static_cast(Y700_PRES_RESOLUTION), Y700_PRES_VAR_NAME, Y700_PRES_UNIT_NAME, varCode, uuid) {} - /** - * @brief Construct a new YosemitechY700_Pressure object. - * - * @note This must be tied with a parent YosemitechY700 before it can be - * used. - */ - YosemitechY700_Pressure() - : Variable(static_cast(Y700_PRES_VAR_NUM), - static_cast(Y700_PRES_RESOLUTION), - Y700_PRES_VAR_NAME, Y700_PRES_UNIT_NAME, - Y700_PRES_DEFAULT_CODE) {} /** * @brief Destroy the YosemitechY700_Pressure object - no action needed. */ @@ -269,17 +258,6 @@ class YosemitechY700_Temp : public Variable { : Variable(parentSense, static_cast(Y700_TEMP_VAR_NUM), static_cast(Y700_TEMP_RESOLUTION), Y700_TEMP_VAR_NAME, Y700_TEMP_UNIT_NAME, varCode, uuid) {} - /** - * @brief Construct a new YosemitechY700_Temp object. - * - * @note This must be tied with a parent YosemitechY700 before it can be - * used. - */ - YosemitechY700_Temp() - : Variable(static_cast(Y700_TEMP_VAR_NUM), - static_cast(Y700_TEMP_RESOLUTION), - Y700_TEMP_VAR_NAME, Y700_TEMP_UNIT_NAME, - Y700_TEMP_DEFAULT_CODE) {} /** * @brief Destroy the YosemitechY700_Temp object - no action needed. */ diff --git a/src/sensors/ZebraTechDOpto.h b/src/sensors/ZebraTechDOpto.h index c7a3ff524..e14bc4118 100644 --- a/src/sensors/ZebraTechDOpto.h +++ b/src/sensors/ZebraTechDOpto.h @@ -280,17 +280,6 @@ class ZebraTechDOpto_Temp : public Variable { : Variable(parentSense, static_cast(DOPTO_TEMP_VAR_NUM), static_cast(DOPTO_TEMP_RESOLUTION), DOPTO_TEMP_VAR_NAME, DOPTO_TEMP_UNIT_NAME, varCode, uuid) {} - /** - * @brief Construct a new ZebraTechDOpto_Temp object. - * - * @note This must be tied with a parent ZebraTechDOpto before it can be - * used. - */ - ZebraTechDOpto_Temp() - : Variable(static_cast(DOPTO_TEMP_VAR_NUM), - static_cast(DOPTO_TEMP_RESOLUTION), - DOPTO_TEMP_VAR_NAME, DOPTO_TEMP_UNIT_NAME, - DOPTO_TEMP_DEFAULT_CODE) {} /** * @brief Destroy the ZebraTechDOpto_Temp object - no action needed. */ @@ -326,17 +315,6 @@ class ZebraTechDOpto_DOpct : public Variable { static_cast(DOPTO_DOPCT_RESOLUTION), DOPTO_DOPCT_VAR_NAME, DOPTO_DOPCT_UNIT_NAME, varCode, uuid) { } - /** - * @brief Construct a new ZebraTechDOpto_DOpct object. - * - * @note This must be tied with a parent ZebraTechDOpto before it can be - * used. - */ - ZebraTechDOpto_DOpct() - : Variable(static_cast(DOPTO_DOPCT_VAR_NUM), - static_cast(DOPTO_DOPCT_RESOLUTION), - DOPTO_DOPCT_VAR_NAME, DOPTO_DOPCT_UNIT_NAME, - DOPTO_DOPCT_DEFAULT_CODE) {} /** * @brief Destroy the ZebraTechDOpto_DOpct object - no action needed. */ @@ -372,17 +350,6 @@ class ZebraTechDOpto_DOmgL : public Variable { static_cast(DOPTO_DOMGL_RESOLUTION), DOPTO_DOMGL_VAR_NAME, DOPTO_DOMGL_UNIT_NAME, varCode, uuid) { } - /** - * @brief Construct a new ZebraTechDOpto_DOmgL object. - * - * @note This must be tied with a parent ZebraTechDOpto before it can be - * used. - */ - ZebraTechDOpto_DOmgL() - : Variable(static_cast(DOPTO_DOMGL_VAR_NUM), - static_cast(DOPTO_DOMGL_RESOLUTION), - DOPTO_DOMGL_VAR_NAME, DOPTO_DOMGL_UNIT_NAME, - DOPTO_DOMGL_DEFAULT_CODE) {} /** * @brief Destroy the ZebraTechDOpto_DOmgL object - no action needed. */ From c0d303dda7a9202d389e4d4f736f27f9a55efc61 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Tue, 10 Mar 2026 17:34:30 -0400 Subject: [PATCH 498/533] Removed empty variable constructor and all un-necessary "begin" variable functions Signed-off-by: Sara Damiano --- ChangeLog.md | 7 ++- src/VariableBase.cpp | 48 -------------------- src/VariableBase.h | 105 +------------------------------------------ 3 files changed, 7 insertions(+), 153 deletions(-) diff --git a/ChangeLog.md b/ChangeLog.md index 00cff40e2..f53adbfd9 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -148,7 +148,7 @@ To achieve the same functionality as the old `updateAllSensors()` function (i.e. #### Library-Wide - Bumped several dependencies - including crucial bug fixes to SensorModbusMaster. -- Applied many suggestions from Code Rabbit AI. +- Applied many suggestions from CodeRabbit AI. - Moved outdated examples to a new "Outdated" folder, with a subfolder for the DRWI examples - When importing TinyGSM for the modem objects, the specific modem client headers are now imported directly rather than importing the TinyGsmClient.h header which defines typedefs for the sub-types. - Moved the define for the default address used for a TI ADS from multiple individual files to the ModSensorConfig and renamed to `MS_DEFAULT_ADS1X15_ADDRESS`. @@ -217,8 +217,11 @@ This affects the following classes: ### Removed -- **BREAKING** Removed all constructors for sensor-associated variables that don't include a pointer to the sensor. +- **BREAKING** Constructors for sensor-associated variables that don't include a pointer to the sensor. You now *must* create the sensor instance before creating the variable and tie the variable to the sensor when creating the variable. +- **BREAKING** All flavors of the variable.begin() functions. +These were not needed since all arguments should be set in the constructor or setters for individual parameters. +There was no functionality needed in a typical Arduino "begin" function - that is, nothing that needed to be performed after the hardware was active. - Unused `_maxSamplesToAverage` parameter of the VariableArray and the `countMaxToAverage()` function. - Unnecessary copy doc calls for inherited functions and properties. - All overrides of the powerUp and powerDown functions that are no longer needed since all sensors have two power pins built in. diff --git a/src/VariableBase.cpp b/src/VariableBase.cpp index b269b74ed..efbf0ff21 100644 --- a/src/VariableBase.cpp +++ b/src/VariableBase.cpp @@ -52,54 +52,6 @@ Variable::Variable(float (*calcFxn)(), uint8_t decimalResolution, if (calcFxn) setCalculation(calcFxn); } -// Delegating constructors -Variable::Variable(float (*calcFxn)(), uint8_t decimalResolution, - const char* varName, const char* varUnit, - const char* varCode) - : Variable(calcFxn, decimalResolution, varName, varUnit, varCode, nullptr) { -} -// Default constructor with no arguments - delegates to ensure all members are -// initialized -Variable::Variable() - : Variable(nullptr, 0, 0, nullptr, nullptr, nullptr, nullptr) {} - - -// This does all of the setup that can't happen in the constructors -// That is, anything that depends on another object having been created -// first or anything that requires the actual processor/MCU to do something. -Variable* Variable::begin(Sensor* parentSense, const char* uuid, - const char* customVarCode) { - setVarCode(customVarCode); - return begin(parentSense, uuid); -} -Variable* Variable::begin(Sensor* parentSense, const char* uuid) { - setVarUUID(uuid); - return begin(parentSense); -} -Variable* Variable::begin(Sensor* parentSense) { - attachSensor(parentSense); - return this; -} - - -// Begin functions for calculated variables -Variable* Variable::begin(float (*calcFxn)(), uint8_t decimalResolution, - const char* varName, const char* varUnit, - const char* varCode, const char* uuid) { - setVarUUID(uuid); - return begin(calcFxn, decimalResolution, varName, varUnit, varCode); -} -Variable* Variable::begin(float (*calcFxn)(), uint8_t decimalResolution, - const char* varName, const char* varUnit, - const char* varCode) { - setVarCode(varCode); - setVarUnit(varUnit); - setVarName(varName); - setResolution(decimalResolution); - setCalculation(calcFxn); - return this; -} - // This notifies the parent sensor that it has an observing variable // This function should never be called for a calculated variable diff --git a/src/VariableBase.h b/src/VariableBase.h index 37a2380c7..b86d4b416 100644 --- a/src/VariableBase.h +++ b/src/VariableBase.h @@ -107,115 +107,14 @@ class Variable { * program will compile but immediately hang. */ Variable(float (*calcFxn)(), uint8_t decimalResolution, const char* varName, - const char* varUnit, const char* varCode, const char* uuid); - /** - * @brief Construct a new Variable object for a calculated variable - that - * is, one whose value is calculated by the calcFxn which returns a float. - * - * @param calcFxn Any function returning a float value - * @param decimalResolution The resolution (in decimal places) of the value. - * @param varName The name of the variable per the [ODM2 variable name - * controlled vocabulary](http://vocabulary.odm2.org/variablename/) - * @param varUnit The unit of the variable per the [ODM2 unit controlled - * vocabulary](http://vocabulary.odm2.org/units/) - * @param varCode A custom code for the variable. This can be any short - * text helping to identify the variable in files. - * - * @warning The `calcFxn` absolutely must return a float value. If it - * returns a value of any other type (i.e., some type of integer), your - * program will compile but immediately hang. - */ - Variable(float (*calcFxn)(), uint8_t decimalResolution, const char* varName, - const char* varUnit, const char* varCode); - /** - * @brief Construct a new Variable object - */ - Variable(); + const char* varUnit, const char* varCode, + const char* uuid = nullptr); /** * @brief Destroy the Variable object - no action taken. */ virtual ~Variable() = default; - /** - * @brief Begin for the Variable object - * - * @param parentSense The Sensor object supplying values. Supersedes any - * Sensor supplied in the constructor. - * @param uuid A universally unique identifier for the variable. - * Supersedes any value supplied in the constructor. - * @param customVarCode A custom code for the variable. Supersedes - * any value supplied in the constructor. - * @return A pointer to the variable object - */ - Variable* begin(Sensor* parentSense, const char* uuid, - const char* customVarCode); - /** - * @brief Begin for the Variable object - * - * @param parentSense The Sensor object supplying values. Supersedes any - * Sensor supplied in the constructor. - * @param uuid A universally unique identifier for the variable. - * Supersedes any value supplied in the constructor. - * @return A pointer to the variable object - */ - Variable* begin(Sensor* parentSense, const char* uuid); - /** - * @brief Begin for the Variable object - * - * @param parentSense The Sensor object supplying values. Supersedes any - * Sensor supplied in the constructor. - * @return A pointer to the variable object - */ - Variable* begin(Sensor* parentSense); - - /** - * @brief Begin for the Variable object - * - * @param calcFxn Any function returning a float value. Supersedes any - * function supplied in the constructor. - * @param decimalResolution The resolution (in decimal places) of the value. - * Supersedes any value supplied in the constructor. - * @param varName The name of the variable per the ODM2 variable name - * controlled vocabulary. Supersedes any value supplied in the constructor. - * @param varUnit The unit of the variable per the ODM2 unit controlled - * vocabulary. Supersedes any value supplied in the constructor. - * @param varCode A custom code for the variable. Supersedes any value - * supplied in the constructor. - * @param uuid A universally unique identifier for the variable. - * Supersedes any value supplied in the constructor. - * @return A pointer to the variable object - * - * @warning The `calcFxn` absolutely must return a float value. If it - * returns a value of any other type (i.e., some type of integer), your - * program will compile but immediately hang. - */ - Variable* begin(float (*calcFxn)(), uint8_t decimalResolution, - const char* varName, const char* varUnit, - const char* varCode, const char* uuid); - /** - * @brief Begin for the Variable object - * - * @param calcFxn Any function returning a float value. Supersedes any - * function supplied in the constructor. - * @param decimalResolution The resolution (in decimal places) of the value. - * Supersedes any value supplied in the constructor. - * @param varName The name of the variable per the ODM2 variable name - * controlled vocabulary. Supersedes any value supplied in the constructor. - * @param varUnit The unit of the variable per the ODM2 unit controlled - * vocabulary. Supersedes any value supplied in the constructor. - * @param varCode A custom code for the variable. Supersedes any value - * supplied in the constructor. - * @return A pointer to the variable object - * - * @warning The `calcFxn` absolutely must return a float value. If it - * returns a value of any other type (i.e., some type of integer), your - * program will compile but immediately hang. - */ - Variable* begin(float (*calcFxn)(), uint8_t decimalResolution, - const char* varName, const char* varUnit, - const char* varCode); - /** * @brief Notify the parent sensor that it has an observing variable. From 779d9fddcfe4376876eaa5d602bd9bf991187afb Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Tue, 10 Mar 2026 17:35:37 -0400 Subject: [PATCH 499/533] Reordered delegating constructors Signed-off-by: Sara Damiano --- src/VariableArray.cpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/VariableArray.cpp b/src/VariableArray.cpp index a5b1de965..541165bf2 100644 --- a/src/VariableArray.cpp +++ b/src/VariableArray.cpp @@ -12,19 +12,20 @@ // Constructors -// Primary constructor with all parameters +// Primary constructor with all parameters - ensures proper initialization order VariableArray::VariableArray(uint8_t variableCount, Variable* variableList[], const char* uuids[]) - : VariableArray(variableCount, variableList) { - matchUUIDs(uuids); -} - -// Delegating constructors -VariableArray::VariableArray(uint8_t variableCount, Variable* variableList[]) : arrayOfVars(variableList), _variableCount(variableCount) { + // Match UUIDs first, before populating sensor list + if (uuids) matchUUIDs(uuids); populateSensorList(); } + +// Delegating constructor - delegates to primary constructor with null UUIDs +VariableArray::VariableArray(uint8_t variableCount, Variable* variableList[]) + : VariableArray(variableCount, variableList, nullptr) { +} // Default constructor with no arguments - delegates to ensure all members are // initialized VariableArray::VariableArray() : VariableArray(0, nullptr) {} From 224eab24038eda3f8d3ff1d23408057e128f1d4c Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Tue, 10 Mar 2026 17:37:36 -0400 Subject: [PATCH 500/533] Grammar and spacing changes Signed-off-by: Sara Damiano --- docs/For-Developers/Developer-Setup.md | 2 +- docs/Further-Reading/SAMD-Clocks.md | 2 +- .../EnviroDIY_Monitoring_Kit/EnviroDIY_Monitoring_Kit.ino | 2 -- examples/ReadMe.md | 2 +- examples/baro_rho_correction/baro_rho_correction.ino | 8 ++++++-- examples/menu_a_la_carte/ReadMe.md | 6 +++--- examples/simple_logging/ReadMe.md | 2 +- src/ClockSupport.h | 6 +++--- src/LoggerBase.h | 2 +- src/modems/Espressif.cpp | 2 +- src/modems/SIMComSIM7080.cpp | 4 ++-- src/sensors/InSituTrollSdi12a.h | 2 +- src/sensors/KellerParent.h | 2 +- 13 files changed, 22 insertions(+), 20 deletions(-) diff --git a/docs/For-Developers/Developer-Setup.md b/docs/For-Developers/Developer-Setup.md index a6e39dc71..df4fd0501 100644 --- a/docs/For-Developers/Developer-Setup.md +++ b/docs/For-Developers/Developer-Setup.md @@ -38,7 +38,7 @@ setupGitFilters.bat If you prefer to configure the filters manually, run these Git commands from the repository root (requires PowerShell): -```bash +```powershell git config --local filter.smudgePasswords.clean "powershell -ExecutionPolicy Bypass -File filters/cleanPasswords.ps1" git config --local filter.smudgePasswords.smudge "powershell -ExecutionPolicy Bypass -File filters/smudgePasswords.ps1" git config --local filter.disableDebug.clean "powershell -ExecutionPolicy Bypass -File filters/cleanDebugConfig.ps1" diff --git a/docs/Further-Reading/SAMD-Clocks.md b/docs/Further-Reading/SAMD-Clocks.md index c519a5e22..9041f053b 100644 --- a/docs/Further-Reading/SAMD-Clocks.md +++ b/docs/Further-Reading/SAMD-Clocks.md @@ -42,7 +42,7 @@ Essentially every microprocessor or computer needs a consistent way of their own speed of operation so they can communicate with internal components and external devices. -An *[oscillator](https://en.wikipedia.org/wiki/Electronic_oscillator)* is a circuit that makes an oscillating signal - i.e., it switches back and forth between to states at a consistent rate. +An *[oscillator](https://en.wikipedia.org/wiki/Electronic_oscillator)* is a circuit that makes an oscillating signal - i.e., it switches back and forth between two states at a consistent rate. The oscillator works like a metronome. An oscillator alone does not keep track of time; it ticks, but it doesn't count how many ticks have passed. diff --git a/examples/EnviroDIY_Monitoring_Kit/EnviroDIY_Monitoring_Kit.ino b/examples/EnviroDIY_Monitoring_Kit/EnviroDIY_Monitoring_Kit.ino index cb5d2392b..6aa31340b 100644 --- a/examples/EnviroDIY_Monitoring_Kit/EnviroDIY_Monitoring_Kit.ino +++ b/examples/EnviroDIY_Monitoring_Kit/EnviroDIY_Monitoring_Kit.ino @@ -166,8 +166,6 @@ Logger dataLogger(LoggerID, samplingFeature, loggingInterval); // Create a reference to the serial port for the modem HardwareSerial& modemSerial = Serial1; // Use hardware serial if possible int32_t modemBaud = 57600; // Communication speed of the modem -// NOTE: This baud rate too fast for the Mayfly. We'll slow it down in the -// setup. // Modem Pins - Describe the physical pin connection of your modem to your board // NOTE: Use -1 for pins that do not apply diff --git a/examples/ReadMe.md b/examples/ReadMe.md index a012796a5..38cd7e57b 100644 --- a/examples/ReadMe.md +++ b/examples/ReadMe.md @@ -121,7 +121,7 @@ ___ ### The EnviroDIY Sensor Station Kit -The EnviroDIY Sensor Station Kit is designed to be used with the [EnviroDIY Monitoring Station Kit](https://www.envirodiy.org/product/envirodiy-monitoring-station-kit/). +This example is designed to be used with the hardware in the [EnviroDIY Monitoring Station Kit](https://www.envirodiy.org/product/envirodiy-monitoring-station-kit/). - [Instructions for the EnviroDIY sensor station kit example](https://envirodiy.github.io/ModularSensors/example_envirodiy_monitoring_kit.html) - [The EnviroDIY sensor station kit example on GitHub](https://github.com/EnviroDIY/ModularSensors/tree/master/examples/EnviroDIY_Monitoring_Kit) diff --git a/examples/baro_rho_correction/baro_rho_correction.ino b/examples/baro_rho_correction/baro_rho_correction.ino index ba512cec9..278d0df81 100644 --- a/examples/baro_rho_correction/baro_rho_correction.ino +++ b/examples/baro_rho_correction/baro_rho_correction.ino @@ -240,9 +240,13 @@ Variable* calcWaterPress = new Variable( // For this, we're using the conversion between mbar and mm pure water at 4°C // This calculation gives a final result in mm of water float calculateWaterDepthRaw(void) { - float waterDepth = calculateWaterPressure() * 10.1972; - if (calculateWaterPressure() == MS_INVALID_VALUE) + float pressure = calculateWaterPressure(); + float waterDepth; + if (pressure == MS_INVALID_VALUE) { waterDepth = MS_INVALID_VALUE; + } else { + waterDepth = pressure * 10.1972; + } // Serial.print(F("'Raw' water depth is ")); // for debugging // Serial.println(waterDepth); // for debugging return waterDepth; diff --git a/examples/menu_a_la_carte/ReadMe.md b/examples/menu_a_la_carte/ReadMe.md index d60488190..802433313 100644 --- a/examples/menu_a_la_carte/ReadMe.md +++ b/examples/menu_a_la_carte/ReadMe.md @@ -580,7 +580,7 @@ ___ Set options and create the objects for using the processor as a sensor to report battery level, processor free ram, and sample number. The processor can return the number of "samples" it has taken, the amount of RAM it has available and, for some boards, the battery voltage (EnviroDIY Mayfly, Sodaq Mbili, Ndogo, Autonomo, and One, Adafruit Feathers). -The version of the board is required as input (i.e., for a EnviroDIY Mayfly: "v0.3" or "v0.4" or "v0.5"). +The version of the board is required as input (i.e., for an EnviroDIY Mayfly: "v0.3" or "v0.4" or "v0.5"). Use a blank value (i.e., "") for un-versioned boards. Please note that while you can opt to average more than one sample, it really makes no sense to do so for the processor. The number of "samples" taken will increase by one for each time another processor "measurement" is taken so averaging multiple measurements from the processor will result in the number of samples increasing by more than one with each loop. @@ -889,7 +889,7 @@ ___ The next two sections are for Keller RS485/Modbus water level sensors. The sensor class constructors for each are nearly identical, except for the class name. -The sensor constructors require as input: the sensor modbus address, a stream instance for data (i.e., `Serial`), and one or two power pins. +The sensor constructors require as input: the sensor modbus address, a stream instance for data (i.e., `Serial`), and one or two power pins. The Arduino pin controlling the receive and data enable on your RS485-to-TTL adapter and the number of readings to average are optional. (Use -1 for the second power pin and -1 for the enable pin if these don't apply and you want to average more than one reading.) Please see the section "[Notes on Arduino Streams and Software Serial](https://envirodiy.github.io/ModularSensors/page_arduino_streams.html)" for more information about what streams can be used along with this library. In tests on these sensors, SoftwareSerial_ExtInts *did not work* to communicate with these sensors, because it isn't stable enough. @@ -1132,7 +1132,7 @@ ___ The next several sections are for Yosemitech brand sensors. The sensor class constructors for each are nearly identical, except for the class name. -The sensor constructor requires as input: the sensor modbus address, a stream instance for data (i.e., `Serial`), and one or two power pins. +The sensor constructor requires as input: the sensor modbus address, a stream instance for data (i.e., `Serial`), and one or two power pins. The Arduino pin controlling the receive and data enable on your RS485-to-TTL adapter and the number of readings to average are optional. (Use -1 for the second power pin and -1 for the enable pin if these don't apply and you want to average more than one reading.) For most of the sensors, Yosemitech strongly recommends averaging multiple (in most cases 10) readings for each measurement. diff --git a/examples/simple_logging/ReadMe.md b/examples/simple_logging/ReadMe.md index bd481bb2a..6695bc7c4 100644 --- a/examples/simple_logging/ReadMe.md +++ b/examples/simple_logging/ReadMe.md @@ -4,7 +4,7 @@ This shows the simplest use of a "logger" object. That is, creating an array of variable objects and then creating a logger object that utilizes those variables to update all of the variable results together and save the data to a SD card. The processor then goes to sleep between readings. -This is the example you should use to deploy a logger somewhere where you don't want or have access to a way of streaming live data and you won't want to upload data to Monitor My Watershed. +This is the example you should use to deploy a logger somewhere where you don't want or have access to a way of streaming live data and you won't be uploading data to Monitor My Watershed. _______ diff --git a/src/ClockSupport.h b/src/ClockSupport.h index a32f77a11..9faff0c20 100644 --- a/src/ClockSupport.h +++ b/src/ClockSupport.h @@ -371,8 +371,8 @@ class loggerClock { * @brief Set the static offset in hours from UTC that the RTC is programmed * in. * - * @note I VERY, VERY STRONGLY RECOMMEND SETTING THE RTC IN UTC(i.e., offset - * = 0) + * @note I VERY, VERY STRONGLY RECOMMEND SETTING THE RTC IN UTC + * (i.e., offset = 0) * * @param offsetHours The offset of the real-time clock (RTC) from UTC in * hours @@ -641,7 +641,7 @@ class loggerClock { * @return The epoch start for the RTC */ static epochStart getRTCEpochStart() { - return _rtcEpoch; + return loggerClock::_rtcEpoch; } protected: diff --git a/src/LoggerBase.h b/src/LoggerBase.h index 6ca25132c..ad75ef06f 100644 --- a/src/LoggerBase.h +++ b/src/LoggerBase.h @@ -1123,7 +1123,7 @@ class Logger { * * @warning During sleep, the I2C/Wire interface is disabled and the SCL and * SDA pins are forced low to save power. Any attempt to communicate with an - * I2C device during sleep (i.e., thorough an interrupt) will cause the + * I2C device during sleep (i.e., through an interrupt) will cause the * board to hang indefinitely. */ void systemSleep(); diff --git a/src/modems/Espressif.cpp b/src/modems/Espressif.cpp index 4426c0949..ec9db5b02 100644 --- a/src/modems/Espressif.cpp +++ b/src/modems/Espressif.cpp @@ -56,7 +56,7 @@ bool Espressif::modemWakeFxn() { if (_powerPin >= 0) { // Turns on when power is applied MS_DEEP_DBG( F("Power pin"), _powerPin, - F("takes priority over reset pin, modem wakes on power on")); + F("takes priority over reset pin, modem wakes on power on")); if (_modemSleepRqPin >= 0) { digitalWrite(_modemSleepRqPin, !_wakeLevel); } diff --git a/src/modems/SIMComSIM7080.cpp b/src/modems/SIMComSIM7080.cpp index 1d073880d..617e08d00 100644 --- a/src/modems/SIMComSIM7080.cpp +++ b/src/modems/SIMComSIM7080.cpp @@ -50,8 +50,8 @@ bool SIMComSIM7080::extraModemSetup() { gsmModem.waitResponse(); // Enable netlight indication of GPRS status // Enable, the netlight will be forced to enter into 64ms on/300ms off - // blinking state in GPRS data transmission service.Otherwise, the netlight - // state is not restricted. + // blinking state in GPRS data transmission service. Otherwise, the + // netlight state is not restricted. gsmModem.sendAT(F("+CNETLIGHT=1")); gsmModem.waitResponse(); diff --git a/src/sensors/InSituTrollSdi12a.h b/src/sensors/InSituTrollSdi12a.h index 8e07c44a4..573a58b5e 100644 --- a/src/sensors/InSituTrollSdi12a.h +++ b/src/sensors/InSituTrollSdi12a.h @@ -47,7 +47,7 @@ * Parameters are very flexible and need to be aligned used WinSitu with this module. * * The depth sensor third parameter may need to be created. The expected - * parameters and order are Pressure (PSI), Temperature (C), Depth (ft). + * parameters and order are Pressure (PSI), Temperature (C), Depth (ft). * * Tested with Level TROLL 500. * diff --git a/src/sensors/KellerParent.h b/src/sensors/KellerParent.h index 7daa6994f..296a0cf40 100644 --- a/src/sensors/KellerParent.h +++ b/src/sensors/KellerParent.h @@ -50,7 +50,7 @@ * Digital communication with Keller sensors configured for SDI12 communication * protocols are not supported by this library. * - * The sensor constructors require as input: the sensor modbus address, a + * The sensor constructors require as input: the sensor modbus address, a * stream instance for data (i.e., ```Serial```), and one or two power pins. The * Arduino pin controlling the receive and data enable on your RS485-to-TTL * adapter and the number of readings to average are optional. (Use -1 for the From a7a5bf17a0346924f13ba4e324336b4fd62acf07 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Wed, 11 Mar 2026 12:41:30 -0400 Subject: [PATCH 501/533] Ensure response has 12 characters Signed-off-by: Sara Damiano --- src/publishers/DreamHostPublisher.cpp | 2 +- src/publishers/MonitorMyWatershedPublisher.cpp | 4 ++-- src/publishers/S3PresignedPublisher.cpp | 2 +- src/publishers/ThingSpeakPublisher.cpp | 2 +- src/publishers/UbidotsPublisher.cpp | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/publishers/DreamHostPublisher.cpp b/src/publishers/DreamHostPublisher.cpp index 1c930dadc..915d2aa6b 100644 --- a/src/publishers/DreamHostPublisher.cpp +++ b/src/publishers/DreamHostPublisher.cpp @@ -127,7 +127,7 @@ int16_t DreamHostPublisher::publishData(Client* outClient, bool) { did_respond = outClient->readBytes(tempBuffer, 12); // Process the HTTP response code // The first 9 characters should be "HTTP/1.1 " - if (did_respond > 0) { + if (did_respond >= 12) { char responseCode_char[4]; memcpy(responseCode_char, tempBuffer + HTTP_VERSION_PREFIX_LEN, 3); // Null terminate the string diff --git a/src/publishers/MonitorMyWatershedPublisher.cpp b/src/publishers/MonitorMyWatershedPublisher.cpp index bda580901..590664576 100644 --- a/src/publishers/MonitorMyWatershedPublisher.cpp +++ b/src/publishers/MonitorMyWatershedPublisher.cpp @@ -409,7 +409,7 @@ int16_t MonitorMyWatershedPublisher::flushDataBuffer(Client* outClient) { did_respond = outClient->readBytes(tempBuffer, 12); // Process the HTTP response code // The first 9 characters should be "HTTP/1.1 " - if (did_respond > 0) { + if (did_respond >= 12) { char responseCode_char[4]; memcpy(responseCode_char, tempBuffer + HTTP_VERSION_PREFIX_LEN, 3); // Null terminate the string @@ -441,8 +441,8 @@ int16_t MonitorMyWatershedPublisher::flushDataBuffer(Client* outClient) { } else { PRINTOUT(F( "\n -- Unable to Establish Connection to Monitor My Watershed --")); + responseCode = -5; // Connection failure } - if (responseCode == 201) { // data was successfully transmitted, we can discard it from the buffer _logBuffer.clear(); diff --git a/src/publishers/S3PresignedPublisher.cpp b/src/publishers/S3PresignedPublisher.cpp index c0603efba..13dd98b81 100644 --- a/src/publishers/S3PresignedPublisher.cpp +++ b/src/publishers/S3PresignedPublisher.cpp @@ -373,7 +373,7 @@ int16_t S3PresignedPublisher::publishData(Client* outClient, bool) { did_respond = outClient->readBytes(tempBuffer, 12); // Process the HTTP response code // The first 9 characters should be "HTTP/1.1 " - if (did_respond > 0) { + if (did_respond >= 12) { char responseCode_char[4]; memcpy(responseCode_char, tempBuffer + HTTP_VERSION_PREFIX_LEN, 3); // Null terminate the string diff --git a/src/publishers/ThingSpeakPublisher.cpp b/src/publishers/ThingSpeakPublisher.cpp index d8301f004..436dec2ec 100644 --- a/src/publishers/ThingSpeakPublisher.cpp +++ b/src/publishers/ThingSpeakPublisher.cpp @@ -287,7 +287,7 @@ int16_t ThingSpeakPublisher::publishMetadata(Client* outClient) { did_respond = outClient->readBytes(tempBuffer, 12); // Process the HTTP response code // The first 9 characters should be "HTTP/1.1 " - if (did_respond > 0) { + if (did_respond >= 12) { char responseCode_char[4]; memcpy(responseCode_char, tempBuffer + HTTP_VERSION_PREFIX_LEN, 3); // Null terminate the string diff --git a/src/publishers/UbidotsPublisher.cpp b/src/publishers/UbidotsPublisher.cpp index a70f76ca4..b6546847c 100644 --- a/src/publishers/UbidotsPublisher.cpp +++ b/src/publishers/UbidotsPublisher.cpp @@ -195,7 +195,7 @@ int16_t UbidotsPublisher::publishData(Client* outClient, bool) { did_respond = outClient->readBytes(tempBuffer, 12); // Process the HTTP response code // The first 9 characters should be "HTTP/1.1 " - if (did_respond > 0) { + if (did_respond >= 12) { char responseCode_char[4]; memcpy(responseCode_char, tempBuffer + HTTP_VERSION_PREFIX_LEN, 3); // Null terminate the string From 2f51824a047a26ae2bb4d6b554d0491e685c32e9 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Wed, 11 Mar 2026 17:07:04 -0400 Subject: [PATCH 502/533] Minor grammar, comments Signed-off-by: Sara Damiano --- .../DRWI_SIM7080LTE/DRWI_SIM7080LTE.ino | 2 +- examples/menu_a_la_carte/menu_a_la_carte.ino | 2 +- src/ClockSupport.cpp | 5 ----- src/ClockSupport.h | 3 +++ src/LoggerBase.cpp | 2 +- src/LoggerBase.h | 2 +- src/SensorBase.h | 8 +------- src/VariableArray.cpp | 19 +++++++++++++++---- src/VariableArray.h | 2 +- src/VariableBase.h | 2 +- src/WatchDogs/WatchDogAVR.cpp | 2 +- src/WatchDogs/WatchDogSAMD.cpp | 2 +- src/dataPublisherBase.cpp | 2 +- src/modems/EspressifESP32.cpp | 7 +++++-- src/modems/EspressifESP8266.cpp | 6 +++++- src/modems/LoggerModemMacros.h | 6 +++--- src/modems/SIMComSIM7000.cpp | 3 ++- src/modems/SIMComSIM800.cpp | 3 ++- src/modems/SIMComSIM800.h | 2 +- src/modems/SodaqUBeeU201.cpp | 5 ++++- src/publishers/EnviroDIYPublisher.h | 2 +- .../MonitorMyWatershedPublisher.cpp | 4 ++-- src/publishers/MonitorMyWatershedPublisher.h | 3 +++ src/sensors/AnalogElecConductivity.h | 8 ++++++++ src/sensors/ApogeeSQ212.h | 3 +++ src/sensors/AtlasParent.h | 19 ------------------- src/sensors/BoschBME280.h | 1 - src/sensors/CampbellRainVUE10.h | 4 ++-- src/sensors/GroPointParent.h | 10 ++++------ src/sensors/KellerParent.h | 6 +++++- src/sensors/MaxBotixSonar.cpp | 6 +++--- src/sensors/MaxBotixSonar.h | 7 ++++++- src/sensors/MaximDS18.cpp | 2 +- src/sensors/MaximDS18.h | 11 ----------- src/sensors/MaximDS3231.h | 11 ----------- src/sensors/SDI12Sensors.h | 11 ----------- src/sensors/TallyCounterI2C.cpp | 6 +++--- src/sensors/TallyCounterI2C.h | 1 - src/sensors/YosemitechParent.cpp | 2 +- src/sensors/YosemitechParent.h | 7 ++----- 40 files changed, 94 insertions(+), 115 deletions(-) diff --git a/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_SIM7080LTE/DRWI_SIM7080LTE.ino b/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_SIM7080LTE/DRWI_SIM7080LTE.ino index e3e5018a1..5ab254da4 100644 --- a/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_SIM7080LTE/DRWI_SIM7080LTE.ino +++ b/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_SIM7080LTE/DRWI_SIM7080LTE.ino @@ -209,7 +209,7 @@ const char* UUIDs[] = // UUID array for device sensors "12345678-abcd-1234-ef00-1234567890ab", // Turbidity (Campbell_OBS3_Turb) (Low) "12345678-abcd-1234-ef00-1234567890ab", // Turbidity (Campbell_OBS3_Turb) (High) "12345678-abcd-1234-ef00-1234567890ab", // Battery voltage (EnviroDIY_Mayfly_Batt) - "12345678-abcd-1234-ef00-1234567890ab", // Battery voltage (EnviroDIY_Mayfly_Batt) + "12345678-abcd-1234-ef00-1234567890ab", // Temperature (EnviroDIY_Mayfly_Temp) "12345678-abcd-1234-ef00-1234567890ab", // Percent full scale (EnviroDIY_LTEB_SignalPercent) }; const char* registrationToken = "12345678-abcd-1234-ef00-1234567890ab"; // Device registration token diff --git a/examples/menu_a_la_carte/menu_a_la_carte.ino b/examples/menu_a_la_carte/menu_a_la_carte.ino index d7ca02af8..c1e80c452 100644 --- a/examples/menu_a_la_carte/menu_a_la_carte.ino +++ b/examples/menu_a_la_carte/menu_a_la_carte.ino @@ -1636,7 +1636,7 @@ Variable* alsPt19Volt = new EverlightALSPT19_Voltage( Variable* alsPt19Current = new EverlightALSPT19_Current( &alsPt19, "12345678-abcd-1234-ef00-1234567890ab"); Variable* alsPt19Lux = new EverlightALSPT19_Illuminance( - &alsPt19, "b7cf9961-246a-4443-b57f-0526fecfea8f"); + &alsPt19, "12345678-abcd-1234-ef00-1234567890ab"); // create a custom analog reader based on the Processor ADC (optional) float alsMultiplier = 1.0f; // factor for a voltage divider diff --git a/src/ClockSupport.cpp b/src/ClockSupport.cpp index fe9a16be1..a51638c7d 100644 --- a/src/ClockSupport.cpp +++ b/src/ClockSupport.cpp @@ -11,11 +11,6 @@ #include "ClockSupport.h" #include "LoggerBase.h" -// Constants -// 86400 (60*60*24) seconds in a day -#define SECONDS_IN_DAY 86400L - - epochTime::epochTime(time_t timestamp, epochStart epoch) { _unixTimestamp = convert_epoch(timestamp, epoch, epochStart::unix_epoch); } diff --git a/src/ClockSupport.h b/src/ClockSupport.h index 9faff0c20..1b440dabc 100644 --- a/src/ClockSupport.h +++ b/src/ClockSupport.h @@ -141,6 +141,9 @@ 599184012, 820108813, 914803214, 1025136015, 1119744016, 1167264017} #endif +/// @brief The number of seconds in a day +#define SECONDS_IN_DAY 86400L + /** * @brief Set the epoch start value. diff --git a/src/LoggerBase.cpp b/src/LoggerBase.cpp index 9d539b5f5..906cada55 100644 --- a/src/LoggerBase.cpp +++ b/src/LoggerBase.cpp @@ -739,7 +739,7 @@ bool Logger::checkMarkedInterval() { if (Logger::markedLocalUnixTime != 0 && (Logger::markedLocalUnixTime % (interval * 60) == 0)) { MS_DBG(F("Time to log!")); - // De-increment the number of startup measurements after marking + // Decrement the number of startup measurements after marking if (_startupMeasurements > 0) { MS_DBG(F("Within startup measurements. There are "), _startupMeasurements, F("left.")); diff --git a/src/LoggerBase.h b/src/LoggerBase.h index ad75ef06f..a0e7ab97d 100644 --- a/src/LoggerBase.h +++ b/src/LoggerBase.h @@ -1244,7 +1244,7 @@ class Logger { /** * @brief Print a comma separated list of the values of the variables in the - * underling variable array - along with the logged time in the logger's + * underlying variable array - along with the logged time in the logger's * timezone - out over an Arduino stream * * @param stream An Arduino stream instance - expected to be an SdFat file - diff --git a/src/SensorBase.h b/src/SensorBase.h index 1e4197997..42b65dd12 100644 --- a/src/SensorBase.h +++ b/src/SensorBase.h @@ -574,13 +574,7 @@ class Sensor { * @param resultValue The value of the result. */ void verifyAndAddMeasurementResult(uint8_t resultNumber, float resultValue); - /** - * @brief Verify that a measurement is OK (i.e., not #MS_INVALID_VALUE) - * before adding it to the result array - * - * @param resultNumber The position of the result within the result array. - * @param resultValue The value of the result. - */ + /// @copydoc verifyAndAddMeasurementResult(uint8_t, float) void verifyAndAddMeasurementResult(uint8_t resultNumber, int16_t resultValue); /** diff --git a/src/VariableArray.cpp b/src/VariableArray.cpp index 541165bf2..8d3e23572 100644 --- a/src/VariableArray.cpp +++ b/src/VariableArray.cpp @@ -24,8 +24,7 @@ VariableArray::VariableArray(uint8_t variableCount, Variable* variableList[], // Delegating constructor - delegates to primary constructor with null UUIDs VariableArray::VariableArray(uint8_t variableCount, Variable* variableList[]) - : VariableArray(variableCount, variableList, nullptr) { -} + : VariableArray(variableCount, variableList, nullptr) {} // Default constructor with no arguments - delegates to ensure all members are // initialized VariableArray::VariableArray() : VariableArray(0, nullptr) {} @@ -33,7 +32,16 @@ VariableArray::VariableArray() : VariableArray(0, nullptr) {} void VariableArray::begin(uint8_t variableCount, Variable* variableList[], const char* uuids[]) { - begin(variableCount, variableList); + _variableCount = variableCount; + arrayOfVars = variableList; + if (_variableCount == 0 || arrayOfVars == nullptr) { + MS_DBG(F("No variable array in the VariableArray object!")); + return; + } + if (!populateSensorList()) { + MS_DBG(F("Warning: Sensor list may be truncated - exceeded " + "MAX_NUMBER_SENSORS limit.")); + } matchUUIDs(uuids); checkVariableUUIDs(); } @@ -47,7 +55,10 @@ void VariableArray::begin() { MS_DBG(F("No variable array in the VariableArray object!")); return; } - populateSensorList(); + if (!populateSensorList()) { + MS_DBG(F("Warning: Sensor list may be truncated - exceeded " + "MAX_NUMBER_SENSORS limit.")); + } checkVariableUUIDs(); } diff --git a/src/VariableArray.h b/src/VariableArray.h index 36182f678..b75e37ecf 100644 --- a/src/VariableArray.h +++ b/src/VariableArray.h @@ -308,7 +308,7 @@ class VariableArray { * @brief Check if the current variable is the last variable that the sensor * will return. * - * This is used for formating output where the format is slightly different + * This is used for formatting output where the format is slightly different * for the last value. (i.e., no comma after the last value) * * @param arrayIndex The index of the variable in the sensor variable array diff --git a/src/VariableBase.h b/src/VariableBase.h index b86d4b416..d22dc1106 100644 --- a/src/VariableBase.h +++ b/src/VariableBase.h @@ -302,7 +302,7 @@ class Variable { } // Calculate the number of decimal places needed to represent the - // resolution We want at least one significant digit beyond the + // resolution. We want at least one significant digit beyond the // resolution float log10Resolution = log10f(resolution); int decimalPlaces = static_cast(ceilf(-log10Resolution)) + 1; diff --git a/src/WatchDogs/WatchDogAVR.cpp b/src/WatchDogs/WatchDogAVR.cpp index 9b949aeba..6592734d2 100644 --- a/src/WatchDogs/WatchDogAVR.cpp +++ b/src/WatchDogs/WatchDogAVR.cpp @@ -103,7 +103,7 @@ void extendedWatchDogAVR::clearWDTInterrupt() { */ ISR(WDT_vect) { MS_DEEP_DBG(F("\nWatchdog interrupt!")); - // De-increment down the counter, but don't allow to roll-over + // Decrement the counter, but don't allow to roll-over if (extendedWatchDogAVR::_barksUntilReset > 0) { extendedWatchDogAVR::_barksUntilReset--; } diff --git a/src/WatchDogs/WatchDogSAMD.cpp b/src/WatchDogs/WatchDogSAMD.cpp index 338a41175..b435a9476 100644 --- a/src/WatchDogs/WatchDogSAMD.cpp +++ b/src/WatchDogs/WatchDogSAMD.cpp @@ -394,7 +394,7 @@ void extendedWatchDogSAMD::waitForGCLKBitSync() { // ISR for watchdog early warning -void WDT_Handler() { +void WDT_Handler(void) { extendedWatchDogSAMD::clearWDTInterrupt(); MS_DEEP_DBG(F("\nWatchdog early warning interrupt!")); #if defined(MS_WATCHDOGSAMD_DEBUG_DEEP) diff --git a/src/dataPublisherBase.cpp b/src/dataPublisherBase.cpp index de0c50a5e..bc6fd603b 100644 --- a/src/dataPublisherBase.cpp +++ b/src/dataPublisherBase.cpp @@ -87,8 +87,8 @@ void dataPublisher::setStartupTransmissions(uint8_t count) { _startupTransmissions = 1; } else { _startupTransmissions = count; + MS_DBG(F("Startup transmissions set to:"), _startupTransmissions); } - MS_DBG(F("Startup transmissions set to:"), _startupTransmissions); } diff --git a/src/modems/EspressifESP32.cpp b/src/modems/EspressifESP32.cpp index 4b27fa592..3a2471f44 100644 --- a/src/modems/EspressifESP32.cpp +++ b/src/modems/EspressifESP32.cpp @@ -67,8 +67,11 @@ bool EspressifESP32::modemSleepFxn() { bool EspressifESP32::extraModemSetup() { if (_modemSleepRqPin >= 0) { digitalWrite(_modemSleepRqPin, !_wakeLevel); } bool success = gsmModem.init(); - _modemName = gsmModem.getModemName(); // Name is set by the ESP32 modem - // object independent of the init fxn + // Attempt to get the modem name even without a successful init + // The full make and model won't be returned, but it will at least be + // something that identifies the modem as an ESP32, which is helpful for + // debugging. + _modemName = gsmModem.getModemName(); if (success) { // AT+CWCOUNTRY=,,, // : diff --git a/src/modems/EspressifESP8266.cpp b/src/modems/EspressifESP8266.cpp index 61ff4cd3e..d6bbcdf6f 100644 --- a/src/modems/EspressifESP8266.cpp +++ b/src/modems/EspressifESP8266.cpp @@ -67,6 +67,10 @@ bool EspressifESP8266::modemSleepFxn() { bool EspressifESP8266::extraModemSetup() { if (_modemSleepRqPin >= 0) { digitalWrite(_modemSleepRqPin, !_wakeLevel); } bool success = gsmModem.init(); - _modemName = gsmModem.getModemName(); + // Attempt to get the modem name even without a successful init + // The full make and model won't be returned, but it will at least be + // something that identifies the modem as an ESP8266, which is helpful for + // debugging. + _modemName = gsmModem.getModemName(); return success; } diff --git a/src/modems/LoggerModemMacros.h b/src/modems/LoggerModemMacros.h index 9daa25981..7e2d53d9c 100644 --- a/src/modems/LoggerModemMacros.h +++ b/src/modems/LoggerModemMacros.h @@ -661,7 +661,7 @@ return 0; \ } \ \ - MS_DBG("Asking modem to sync with NTP"); \ + MS_DBG(F("Asking modem to sync with NTP")); \ gsmModem.NTPServerSync("pool.ntp.org", 0); /*UTC!*/ \ gsmModem.waitForTimeSync(); \ return gsmModem.getNetworkEpoch(TinyGSM_EpochStart::UNIX); \ @@ -675,7 +675,7 @@ return 0; \ } \ \ - MS_DBG("Asking modem to sync with NTP"); \ + MS_DBG(F("Asking modem to sync with NTP")); \ gsmModem.NTPServerSync("pool.ntp.org", 0); /*UTC!*/ \ gsmModem.waitForTimeSync(); \ \ @@ -718,7 +718,7 @@ \ /** Try up to 12 times to get a timestamp from NIST. */ \ for (uint8_t i = 0; i < NIST_SERVER_RETRYS; i++) { \ - while (millis() < _lastNISTrequest + 4000) { yield(); } \ + while (millis() - _lastNISTrequest < 4000) { yield(); } \ \ /** Make TCP connection. */ \ TinyGsm##TinyGSMType::GsmClient##TinyGSMType gsmClient( \ diff --git a/src/modems/SIMComSIM7000.cpp b/src/modems/SIMComSIM7000.cpp index a4e043301..3539cc154 100644 --- a/src/modems/SIMComSIM7000.cpp +++ b/src/modems/SIMComSIM7000.cpp @@ -67,7 +67,8 @@ bool SIMComSIM7000::modemWakeFxn() { bool SIMComSIM7000::modemSleepFxn() { if (_modemSleepRqPin >= 0) { - // Must have access to `PWRKEY` pin to sleep + // Must have access to `PWRKEY` pin to wake up; don't go to sleep if we + // can't wake up! // Easiest to just go to sleep with the AT command rather than using // pins MS_DBG(F("Asking SIM7000 to power down")); diff --git a/src/modems/SIMComSIM800.cpp b/src/modems/SIMComSIM800.cpp index c309422a8..20a3fe4dc 100644 --- a/src/modems/SIMComSIM800.cpp +++ b/src/modems/SIMComSIM800.cpp @@ -67,7 +67,8 @@ bool SIMComSIM800::modemWakeFxn() { bool SIMComSIM800::modemSleepFxn() { if (_modemSleepRqPin >= 0) { - // Must have access to `PWRKEY` (_modemSleepRqPin) pin to sleep + // Must have access to `PWRKEY` (_modemSleepRqPin) pin to wake up; don't + // sleep without it. // Easiest to just go to sleep with the AT command rather than using // pins MS_DBG(F("Asking SIM800 to power down")); diff --git a/src/modems/SIMComSIM800.h b/src/modems/SIMComSIM800.h index 4fa74e164..c950e5d99 100644 --- a/src/modems/SIMComSIM800.h +++ b/src/modems/SIMComSIM800.h @@ -28,7 +28,7 @@ * SIM800. * The one exception is the Sodaq GPRSBee **R6 and higher**, which has its own * [constructor](@ref modem_gprsbee). - * The earlier Sodaq GPRSBee's (i.e., R4) do use this version. + * The earlier Sodaq GPRSBees (i.e., R4) do use this version. * * The SIM800 consumes up to 2A of power while connecting to the network. * That is 4x what a typical USB or Arduino board can supply, so expect to give diff --git a/src/modems/SodaqUBeeU201.cpp b/src/modems/SodaqUBeeU201.cpp index bb5701946..bf07a127f 100644 --- a/src/modems/SodaqUBeeU201.cpp +++ b/src/modems/SodaqUBeeU201.cpp @@ -90,7 +90,10 @@ bool SodaqUBeeU201::extraModemSetup() { // Turn on network indicator light // Pin 16 = GPIO1, function 2 = network status indication gsmModem.sendAT(GF("+UGPIOC=16,2")); - gsmModem.waitResponse(); + if (gsmModem.waitResponse() != 1) { + // NOTE: We don't consider setup a failure without the light + MS_DBG(F("Failed to configure network indicator LED")); + } return success; } diff --git a/src/publishers/EnviroDIYPublisher.h b/src/publishers/EnviroDIYPublisher.h index 729363c93..84d457418 100644 --- a/src/publishers/EnviroDIYPublisher.h +++ b/src/publishers/EnviroDIYPublisher.h @@ -20,7 +20,7 @@ // ============================================================================ -// Functions for the EnviroDIY data portal receivers. +// Typedef for backward compatibility with EnviroDIY data portal receivers. // ============================================================================ /** * @brief typedef for backwards compatibility; use the diff --git a/src/publishers/MonitorMyWatershedPublisher.cpp b/src/publishers/MonitorMyWatershedPublisher.cpp index 590664576..27770b7b4 100644 --- a/src/publishers/MonitorMyWatershedPublisher.cpp +++ b/src/publishers/MonitorMyWatershedPublisher.cpp @@ -398,8 +398,8 @@ int16_t MonitorMyWatershedPublisher::flushDataBuffer(Client* outClient) { // Wait 30 seconds for a response from the server uint32_t start = millis(); - while ((millis() - start) < 30000L && outClient->connected() && - outClient->available() < 12) { + while ((millis() - start) < MMW_RESPONSE_TIMEOUT_MS && + outClient->connected() && outClient->available() < 12) { delay(10); } diff --git a/src/publishers/MonitorMyWatershedPublisher.h b/src/publishers/MonitorMyWatershedPublisher.h index d33030c44..b761803d9 100644 --- a/src/publishers/MonitorMyWatershedPublisher.h +++ b/src/publishers/MonitorMyWatershedPublisher.h @@ -34,6 +34,9 @@ #include "dataPublisherBase.h" #include "LogBuffer.h" +/// Timeout for server response in milliseconds +#define MMW_RESPONSE_TIMEOUT_MS 30000L + // ============================================================================ // Functions for Monitor My Watershed diff --git a/src/sensors/AnalogElecConductivity.h b/src/sensors/AnalogElecConductivity.h index d0324178e..ce7582d90 100644 --- a/src/sensors/AnalogElecConductivity.h +++ b/src/sensors/AnalogElecConductivity.h @@ -352,6 +352,14 @@ class AnalogElecConductivity : public Sensor { */ String getSensorLocation() override; + /** + * @brief Do any one-time preparations needed before the sensor will be able + * to take readings. + * + * This also initializes the internal analog voltage reader. + * + * @return True if the setup was successful. + */ bool setup() override; bool addSingleMeasurementResult() override; diff --git a/src/sensors/ApogeeSQ212.h b/src/sensors/ApogeeSQ212.h index 1649f6a24..0bb339038 100644 --- a/src/sensors/ApogeeSQ212.h +++ b/src/sensors/ApogeeSQ212.h @@ -279,6 +279,9 @@ class ApogeeSQ212 : public Sensor { AnalogVoltageBase* analogVoltageReader = nullptr); /** * @brief Destroy the ApogeeSQ212 object + * + * If the object owns the analog voltage reader (i.e., it was internally + * created), the reader is deleted. */ ~ApogeeSQ212() override; diff --git a/src/sensors/AtlasParent.h b/src/sensors/AtlasParent.h index a5951a891..ea159c3b4 100644 --- a/src/sensors/AtlasParent.h +++ b/src/sensors/AtlasParent.h @@ -199,27 +199,8 @@ class AtlasParent : public Sensor { // wake it and ask for a reading. // bool wake() override; - /** - * @brief Puts the sensor to sleep, if necessary. - * - * This also un-sets the #_millisSensorActivated timestamp (sets it to 0). - * This does NOT power down the sensor! - * - * @return True if the sleep function completed successfully. - */ bool sleep() override; - /** - * @brief Tell the sensor to start a single measurement, if needed. - * - * This also sets the #_millisMeasurementRequested timestamp. - * - * @note This function does NOT include any waiting for the sensor to be - * warmed up or stable! - * - * @return True if the start measurement function completed - * successfully. - */ bool startSingleMeasurement() override; bool addSingleMeasurementResult() override; diff --git a/src/sensors/BoschBME280.h b/src/sensors/BoschBME280.h index fb1984890..74203f8cd 100644 --- a/src/sensors/BoschBME280.h +++ b/src/sensors/BoschBME280.h @@ -323,7 +323,6 @@ class BoschBME280 : public Sensor { String getSensorLocation() override; - // bool startSingleMeasurement() override; // for forced mode bool addSingleMeasurementResult() override; private: diff --git a/src/sensors/CampbellRainVUE10.h b/src/sensors/CampbellRainVUE10.h index 5efb72121..a5c094f05 100644 --- a/src/sensors/CampbellRainVUE10.h +++ b/src/sensors/CampbellRainVUE10.h @@ -388,7 +388,7 @@ class CampbellRainVUE10_RainRateAve : public Variable { * @param uuid A universally unique identifier (UUID or GUID) for the * variable; optional with the default value of an empty string. * @param varCode A short code to help identify the variable in files; - * optional with a default value of "RainVUEError". + * optional with a default value of "RainVUERateAve". */ explicit CampbellRainVUE10_RainRateAve( CampbellRainVUE10* parentSense, const char* uuid = "", @@ -426,7 +426,7 @@ class CampbellRainVUE10_RainRateMax : public Variable { * @param uuid A universally unique identifier (UUID or GUID) for the * variable; optional with the default value of an empty string. * @param varCode A short code to help identify the variable in files; - * optional with a default value of "RainVUERateAve". + * optional with a default value of "RainVUERateMax". */ explicit CampbellRainVUE10_RainRateMax( CampbellRainVUE10* parentSense, const char* uuid = "", diff --git a/src/sensors/GroPointParent.h b/src/sensors/GroPointParent.h index d9e3b5af8..c982297a6 100644 --- a/src/sensors/GroPointParent.h +++ b/src/sensors/GroPointParent.h @@ -168,15 +168,13 @@ class GroPointParent : public Sensor { */ bool setup() override; - bool wake() override; /** - * @brief Puts the sensor to sleep, if necessary. - * - * This also un-sets the #_millisSensorActivated timestamp (sets it to 0). - * This does NOT power down the sensor! + * @brief Wake up the sensor and manually activate the brushes. * - * @return True if the sleep function completed successfully. + * @return True if the sensor wake and brush activation succeeded, false + * if activation failed after retries. */ + bool wake() override; bool sleep() override; bool addSingleMeasurementResult() override; diff --git a/src/sensors/KellerParent.h b/src/sensors/KellerParent.h index 296a0cf40..376e38e94 100644 --- a/src/sensors/KellerParent.h +++ b/src/sensors/KellerParent.h @@ -248,7 +248,11 @@ class KellerParent : public Sensor { */ bool setup() override; - // override to empty and flush the stream + /** + * @brief Empty and flush the stream before sleeping. + * + * @return True if sleep was successful. + */ bool sleep() override; bool addSingleMeasurementResult() override; diff --git a/src/sensors/MaxBotixSonar.cpp b/src/sensors/MaxBotixSonar.cpp index e6592ab74..8b6dfbc92 100644 --- a/src/sensors/MaxBotixSonar.cpp +++ b/src/sensors/MaxBotixSonar.cpp @@ -170,11 +170,11 @@ bool MaxBotixSonar::addSingleMeasurementResult() { void MaxBotixSonar::dumpBuffer() { - auto junkChars = static_cast(_stream->available()); - if (junkChars) { + auto junkChars = _stream->available(); + if (junkChars > 0) { MS_DBG(F("Dumping"), junkChars, F("characters from MaxBotix stream buffer:")); - for (uint8_t i = 0; i < junkChars; i++) { + while (_stream->available()) { #ifdef MS_MAXBOTIXSONAR_DEBUG MS_SERIAL_OUTPUT.print(_stream->read()); #else diff --git a/src/sensors/MaxBotixSonar.h b/src/sensors/MaxBotixSonar.h index 0933795be..b318dc860 100644 --- a/src/sensors/MaxBotixSonar.h +++ b/src/sensors/MaxBotixSonar.h @@ -285,7 +285,12 @@ class MaxBotixSonar : public Sensor { * @return True if the wake function completed successfully. */ bool wake() override; - // override to empty and flush the stream + /** + * @brief Puts the MaxBotixSonar sensor to sleep after emptying and flushing + * the stream. + * + * @return True if the sleep function completed successfully. + */ bool sleep() override; bool startSingleMeasurement() override; diff --git a/src/sensors/MaximDS18.cpp b/src/sensors/MaximDS18.cpp index cdfed926d..0d0eb05dc 100644 --- a/src/sensors/MaximDS18.cpp +++ b/src/sensors/MaximDS18.cpp @@ -45,7 +45,7 @@ String MaximDS18::makeAddressString(DeviceAddress owAddr) { addrStr += (_dataPin); addrStr += '{'; for (uint8_t i = 0; i < 8; i++) { - addrStr += "0x"; + addrStr += F("0x"); if (owAddr[i] < 0x10) addrStr += "0"; addrStr += String(owAddr[i], HEX); if (i < 7) addrStr += ","; diff --git a/src/sensors/MaximDS18.h b/src/sensors/MaximDS18.h index 8d3a00b15..fa9e7b604 100644 --- a/src/sensors/MaximDS18.h +++ b/src/sensors/MaximDS18.h @@ -242,17 +242,6 @@ class MaximDS18 : public Sensor { String getSensorLocation() override; - /** - * @brief Tell the sensor to start a single measurement, if needed. - * - * This also sets the #_millisMeasurementRequested timestamp. - * - * @note This function does NOT include any waiting for the sensor to be - * warmed up or stable! - * - * @return True if the start measurement function completed - * successfully. successfully. - */ bool startSingleMeasurement() override; bool addSingleMeasurementResult() override; diff --git a/src/sensors/MaximDS3231.h b/src/sensors/MaximDS3231.h index 281975f02..441ef7081 100644 --- a/src/sensors/MaximDS3231.h +++ b/src/sensors/MaximDS3231.h @@ -183,17 +183,6 @@ class MaximDS3231 : public Sensor { */ bool setup() override; - /** - * @brief Tell the sensor to start a single measurement, if needed. - * - * This also sets the #_millisMeasurementRequested timestamp. - * - * @note This function does NOT include any waiting for the sensor to be - * warmed up or stable! - * - * @return True if the start measurement function completed - * successfully. successfully. - */ bool startSingleMeasurement() override; bool addSingleMeasurementResult() override; }; diff --git a/src/sensors/SDI12Sensors.h b/src/sensors/SDI12Sensors.h index 9a48ef1f2..e64ca816d 100644 --- a/src/sensors/SDI12Sensors.h +++ b/src/sensors/SDI12Sensors.h @@ -238,17 +238,6 @@ class SDI12Sensors : public Sensor { // Only need this for concurrent measurements. // NOTE: By default, concurrent measurements are used! #ifndef MS_SDI12_NON_CONCURRENT - /** - * @brief Tell the sensor to start a single measurement, if needed. - * - * This also sets the #_millisMeasurementRequested timestamp. - * - * @note This function does NOT include any waiting for the sensor to be - * warmed up or stable! - * - * @return True if the start measurement function completed - * successfully. - */ bool startSingleMeasurement() override; #endif bool addSingleMeasurementResult() override; diff --git a/src/sensors/TallyCounterI2C.cpp b/src/sensors/TallyCounterI2C.cpp index a6da4ade9..3cd0c4a11 100644 --- a/src/sensors/TallyCounterI2C.cpp +++ b/src/sensors/TallyCounterI2C.cpp @@ -43,13 +43,13 @@ bool TallyCounterI2C::setup() { // Make 5 attempts uint8_t ntries = 0; bool success = false; - uint8_t Stat = false; // Used to test for connectivity to Tally device + uint8_t status = 0; // Used to test for connectivity to Tally device while (!success && ntries < 5) { - Stat = counter_internal.begin(); + status = counter_internal.begin(); counter_internal.Sleep(); // Engage auto-sleep mode between event // counts counter_internal.Clear(); // Clear count to ensure valid first reading - if (Stat == 0) success = true; + if (status == 0) success = true; ntries++; } if (!success) { diff --git a/src/sensors/TallyCounterI2C.h b/src/sensors/TallyCounterI2C.h index cde5cfd9a..d1848f33a 100644 --- a/src/sensors/TallyCounterI2C.h +++ b/src/sensors/TallyCounterI2C.h @@ -219,7 +219,6 @@ class TallyCounterI2C : public Sensor { String getSensorLocation() override; - // bool startSingleMeasurement() override; // for forced mode bool addSingleMeasurementResult() override; private: diff --git a/src/sensors/YosemitechParent.cpp b/src/sensors/YosemitechParent.cpp index 0524c1a00..c7d414c00 100644 --- a/src/sensors/YosemitechParent.cpp +++ b/src/sensors/YosemitechParent.cpp @@ -228,7 +228,7 @@ bool YosemitechParent::addSingleMeasurementResult() { parmValue *= 1000; } - MS_DBG(F(" "), _ysensor.getParameter(), ':', parmValue); + MS_DBG(' ', _ysensor.getParameter(), ':', parmValue); MS_DBG(F(" Temp:"), tempValue); // Not all sensors return a third value diff --git a/src/sensors/YosemitechParent.h b/src/sensors/YosemitechParent.h index 5c6522381..5e4d2f293 100644 --- a/src/sensors/YosemitechParent.h +++ b/src/sensors/YosemitechParent.h @@ -236,12 +236,9 @@ class YosemitechParent : public Sensor { */ bool wake() override; /** - * @brief Puts the sensor to sleep, if necessary. + * @brief Stop measurements and empty and flush the stream before sleeping. * - * This also un-sets the #_millisSensorActivated timestamp (sets it to 0). - * This does NOT power down the sensor! - * - * @return True if the sleep function completed successfully. + * @return True if sleep was successful. */ bool sleep() override; From a55b5327b2328239134011d978b3c6ee119f37fc Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Thu, 12 Mar 2026 11:05:35 -0400 Subject: [PATCH 503/533] Lots of markdown formatting and grammar errors Signed-off-by: Sara Damiano --- .coderabbit.yaml | 6 + ChangeLog.md | 161 +++++++++--------- README.md | 8 +- docs/FAQ/Code-Debugging.md | 5 +- docs/FAQ/Power-Parasites.md | 12 +- docs/FAQ/Processor-Compatibility.md | 64 +++---- docs/For-Developers/Developer-Setup.md | 5 +- docs/Further-Reading/Modem-Notes.md | 5 +- docs/Further-Reading/SAMD-Clocks.md | 8 +- docs/Further-Reading/Sleep-Configurations.md | 43 ++--- docs/Getting-Started/Getting-Started.md | 34 ++-- docs/Getting-Started/Library-Dependencies.md | 21 ++- examples/AWS_IoT_Core/ReadMe.md | 2 +- examples/EnviroDIY_Monitoring_Kit/ReadMe.md | 22 ++- .../DRWI_CitizenScience/DRWI_2G/ReadMe.md | 9 +- .../DRWI_DigiLTE/ReadMe.md | 13 +- .../DRWI_Mayfly1/ReadMe.md | 19 ++- .../DRWI_Mayfly1_WiFi/ReadMe.md | 8 +- .../DRWI_NoCellular/ReadMe.md | 13 +- .../DRWI_SIM7080LTE/DRWI_SIM7080LTE.ino | 2 +- .../DRWI_SIM7080LTE/ReadMe.md | 18 +- .../simple_logging_LearnEnviroDIY/ReadMe.md | 3 +- examples/ReadMe.md | 26 +-- examples/logging_to_MMW/ReadMe.md | 7 +- examples/logging_to_MMW/logging_to_MMW.ino | 2 +- examples/logging_to_ThingSpeak/ReadMe.md | 10 +- examples/menu_a_la_carte/ReadMe.md | 19 +-- examples/simple_logging/ReadMe.md | 5 +- examples/single_sensor/ReadMe.md | 5 +- extras/AWS_IoT_SetCertificates/ReadMe.md | 6 +- src/SensorBase.cpp | 2 +- 31 files changed, 306 insertions(+), 257 deletions(-) diff --git a/.coderabbit.yaml b/.coderabbit.yaml index 05e153bf7..a47798b95 100644 --- a/.coderabbit.yaml +++ b/.coderabbit.yaml @@ -27,6 +27,12 @@ reviews: - '!**/cspell.json' - '!**/platformio.ini' path_instructions: + - path: '**/*.md' + instructions: >- + Review for grammar, spelling, and clarity. + Each sentence should be on a new line. + Markdown files should follow rules of markdownlint. + Check c++ code snippets as c++ code. - path: '**/*.h' instructions: >- Review the C++ code, point out issues relative to principles of clean diff --git a/ChangeLog.md b/ChangeLog.md index f53adbfd9..6bed72307 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -78,13 +78,13 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm - **ANBpH** - **BREAKING** The constructor has changed! -The logging interval has been added as a required parameter for the constructor! + The logging interval has been added as a required parameter for the constructor! - Changed timing slightly and simplified timing logic. - **AlphasenseCO2** and **TurnerTurbidityPlus** - **BREAKING** The constructors for both of these analog-based classes have changed! -Previously the constructor required an enum object for the supported differential channels. -The new constructor requires two different analog channel numbers as inputs for the differential voltage measurement. -If you are using code from a previous version of the library, make sure to update your code to use the new constructor and provide the correct analog channel inputs for the differential voltage measurement. + Previously the constructor required an enum object for the supported differential channels. + The new constructor requires two different analog channel numbers as inputs for the differential voltage measurement. + If you are using code from a previous version of the library, make sure to update your code to use the new constructor and provide the correct analog channel inputs for the differential voltage measurement. - Moved resistor settings and calibration values into the following preprocessor defines that can be modified to tweak the library if necessary: - `ALPHASENSE_CO2_SENSE_RESISTOR_OHM` (defaults to `250.0f`) - `ALPHASENSE_CO2_MFG_SCALE` (defaults to `312.5f`) @@ -95,15 +95,15 @@ If you are using code from a previous version of the library, make sure to updat - `TURBIDITY_PLUS_CALIBRATION_EPSILON` (defaults to `1e-4f`) - **ApogeeSQ212**, **TIADS1x15**, **CampbellOBS3**, and **TurnerCyclops** - *Potentially breaking* The constructors for all of these analog-based classes have changed! -Previously the I2C address of the ADS1x15 was an optional input parameter which came *before* the optional input parameter for the number of measurements to average. -The input parameter for the I2C address has been *removed* and the input for the number of measurements to average has been moved up in the order! -For users who used the default values, this will have no effect. -For users who provided both a custom I2C address and a custom number of measurements, this will cause a compiler error. -For users who provided a custom I2C address *but not a custom number of measurements* this will cause a *silent failure* because the custom I2C address will be used as the measurement count and the default I2C address will be used. -Users who need a custom I2C address for the ADS1x15 must construct a TIADS1x15Base object with the correct address and pass a pointer to that object to the constructor. + Previously the I2C address of the ADS1x15 was an optional input parameter which came *before* the optional input parameter for the number of measurements to average. + The input parameter for the I2C address has been *removed* and the input for the number of measurements to average has been moved up in the order! + For users who used the default values, this will have no effect. + For users who provided both a custom I2C address and a custom number of measurements, this will cause a compiler error. + For users who provided a custom I2C address *but not a custom number of measurements* this will cause a *silent failure* because the custom I2C address will be used as the measurement count and the default I2C address will be used. + Users who need a custom I2C address for the ADS1x15 must construct a TIADS1x15Base object with the correct address and pass a pointer to that object to the constructor. - **AnalogElecConductivity** - *Renamed* configuration defines to have the prefix `ANALOGELECCONDUCTIVITY` and moved other defaults to defines. -This affects the following defines: + This affects the following defines: - `ANALOGELECCONDUCTIVITY_RSERIES_OHMS` (formerly `RSERIES_OHMS_DEF`) - `ANALOGELECCONDUCTIVITY_KONST` (formerly `SENSOREC_KONST_DEF`) - `ANALOGELECCONDUCTIVITY_ADC_MAX_RATIO` (formerly a hardcoded value of `0.999f`) @@ -117,16 +117,16 @@ This affects the following defines: - Simplified the `addSingleMeasurementResult()` function of all sensors to use an internal function to help set the bits and timing values and to quit sooner if the measurement was not started successfully. - The `verifyAndAddMeasurementResult()` is now consistently used in all sensors and is only called when the sensor successfully returned a measurement response. - Also removed all places where sensor values were re-set to -9999 after a measurement failed and then that -9999 was sent to the `verifyAndAddMeasurementResult()` function. -These resets were an awkward attempt to deal with bad values before feeding any bad values to the `verifyAndAddMeasurementResult()` function which was previously always called even if the sensor returned junk. -This was probably a hold-over from incorrect implementation and calling of the clearValues function deep in the library history. + These resets were an awkward attempt to deal with bad values before feeding any bad values to the `verifyAndAddMeasurementResult()` function which was previously always called even if the sensor returned junk. + This was probably a hold-over from incorrect implementation and calling of the clearValues function deep in the library history. - Also made the return from the `addSingleMeasurementResult()` function consistently false for a bad sensor response and true for a good one - where it's possible to tell the difference. - The Sensor::clearValues() function now resets the attempt and retry counts in addition to setting all values in the value array to MS_INVALID_VALUE. #### Individual Publishers - *Renamed* the EnviroDIYPublisher to MonitorMyWatershedPublisher. -This reflects changes to the website from years ago. -There is a shell file and typedef to maintain backwards compatibility. + This reflects changes to the website from years ago. + There is a shell file and typedef to maintain backwards compatibility. #### All Publishers @@ -138,12 +138,12 @@ There is a shell file and typedef to maintain backwards compatibility. - Made the enabling and disabling of the watchdog the very first and very last steps of sleep to keep the watchdog enabled through the whole getting ready for bed and waking up process. - Re-wrote most of the logic for looping variables within the complete update function of the VariableArray. - Re-wrote some of the logic of the `completeUpdate()` function. -Also added optional arguments to the `completeUpdate()` function to allow users to specify if the sensors should be powered/woken. + Also added optional arguments to the `completeUpdate()` function to allow users to specify if the sensors should be powered/woken. - The `updateAllSensors()` function is now deprecated. -Use `completeUpdate(false, false, false, false)` instead. + Use `completeUpdate(false, false, false, false)` instead. - Previously the `updateAllSensors()` function asked all sensors to update their values, skipping all power, wake, and sleep steps while the `completeUpdate()` function duplicated that functionality and added the power, wake, and sleep. -The two functions have been consolidated into one function with four arguments, one each for power on, wake, sleep, and power off. -To achieve the same functionality as the old `updateAllSensors()` function (i.e., only updating values), set all the arguments to false. + The two functions have been consolidated into one function with four arguments, one each for power on, wake, sleep, and power off. + To achieve the same functionality as the old `updateAllSensors()` function (i.e., only updating values), set all the arguments to false. #### Library-Wide @@ -153,7 +153,7 @@ To achieve the same functionality as the old `updateAllSensors()` function (i.e. - When importing TinyGSM for the modem objects, the specific modem client headers are now imported directly rather than importing the TinyGsmClient.h header which defines typedefs for the sub-types. - Moved the define for the default address used for a TI ADS from multiple individual files to the ModSensorConfig and renamed to `MS_DEFAULT_ADS1X15_ADDRESS`. - Within ModSensorConfig removed the default `MS_PROCESSOR_ADC_RESOLUTION` for all processors and clarified that the 12-bit default only applies to SAMD processors. -This is *not* breaking because only AVR and SAMD processors were supported anyway. + This is *not* breaking because only AVR and SAMD processors were supported anyway. - Converted as many duplicated constructors as possible into delegating constructors. ### Added @@ -173,17 +173,17 @@ This is *not* breaking because only AVR and SAMD processors were supported anywa - **Added support for retrying measurements for all sensors**. - Each sensor now supports a number of possible retry attempts for when the sensor returns a bad or no value. -The number of retry attempts can be set using the `setMaxRetries(uint8_t)` function. + The number of retry attempts can be set using the `setMaxRetries(uint8_t)` function. - The number of retries is independent of the number of measurements to average. -A retry is performed when a sensor doesn't report a value or reports an error value. -If multiple retries are needed, only the result of the final (successful) retry is stored. -When multiple 'measurements to average' are requested, the values of each successful measurement is stored and averaged. -Measurements that return bad values even after retries are still not included in averaging. + A retry is performed when a sensor doesn't report a value or reports an error value. + If multiple retries are needed, only the result of the final (successful) retry is stored. + When multiple 'measurements to average' are requested, the values of each successful measurement is stored and averaged. + Measurements that return bad values even after retries are still not included in averaging. - The default number of retry attempts for most sensors is 1. - Made a secondary power pin a property of all sensors. - Added internal function to run the steps of setting the timing and bits after a measurement. - Added setter and getter functions for sensor timing variables. -These values should generally be set in the specific sensor constructors and only changed if you know what you're doing. + These values should generally be set in the specific sensor constructors and only changed if you know what you're doing. - `setWarmUpTime(uint32_t warmUpTime_ms)` - `getWarmUpTime()` - `setStabilizationTime(uint32_t stabilizationTime_ms)` @@ -192,9 +192,9 @@ These values should generally be set in the specific sensor constructors and onl - `getMeasurementTime()` - Added the functions `Sensor::clearStatus()`,`Sensor::clearPowerStatus()`,`Sensor::clearWakeStatus()`,and `Sensor::clearMeasurementStatus()` which reset some or all of the sensor status bits and related timing variables. - Added an abstract AnalogVoltageBase class with two concrete classes for analog voltage measurements: ProcessorAnalogBase and TIADS1x15Base. -All supported analog sensors can now accept a pointer to an object of any concrete subclass of the AnalogVoltageBase class to use for raw voltage measurements. -By default, existing analog sensors will create an internal concrete AnalogVoltageBase subclass instance for whichever ADC type (processor or ADS1x15) the sensor was originally coded to use. -This affects the following classes: + All supported analog sensors can now accept a pointer to an object of any concrete subclass of the AnalogVoltageBase class to use for raw voltage measurements. + By default, existing analog sensors will create an internal concrete AnalogVoltageBase subclass instance for whichever ADC type (processor or ADS1x15) the sensor was originally coded to use. + This affects the following classes: - AlphasenseCO2 - AnalogElecConductivity - ApogeeSQ212 @@ -218,10 +218,10 @@ This affects the following classes: ### Removed - **BREAKING** Constructors for sensor-associated variables that don't include a pointer to the sensor. -You now *must* create the sensor instance before creating the variable and tie the variable to the sensor when creating the variable. + You now *must* create the sensor instance before creating the variable and tie the variable to the sensor when creating the variable. - **BREAKING** All flavors of the variable.begin() functions. -These were not needed since all arguments should be set in the constructor or setters for individual parameters. -There was no functionality needed in a typical Arduino "begin" function - that is, nothing that needed to be performed after the hardware was active. + These were not needed since all arguments should be set in the constructor or setters for individual parameters. + There was no functionality needed in a typical Arduino "begin" function - that is, nothing that needed to be performed after the hardware was active. - Unused `_maxSamplesToAverage` parameter of the VariableArray and the `countMaxToAverage()` function. - Unnecessary copy doc calls for inherited functions and properties. - All overrides of the powerUp and powerDown functions that are no longer needed since all sensors have two power pins built in. @@ -253,12 +253,12 @@ There was no functionality needed in a typical Arduino "begin" function - that i - **BREAKING** Renamed `markedUTCEpochTime` to `markedUTCUnixTime` to clarify the start of the epoch that we're marking down. - **Potentially BREAKING:** Changed the requirements for a "sane" timestamp to between 2025 and 2035. - Moved the value for the sane range into two defines: `EARLIEST_SANE_UNIX_TIMESTAMP` and `LATEST_SANE_UNIX_TIMESTAMP` so they can be more easily modified and tracked. -These defines can be set in the ModSensorConfig.h file. + These defines can be set in the ModSensorConfig.h file. - **Potentially BREAKING:** For calculated variables, the calculation function will only be called if `getValue(true)` or `getValueString(true)` is called - that is, the boolean for 'update value' must explicitly be set to true to rerun the calculation function. - Previously, the calculation function was re-run every time `getValue()` or `getValueString()` was called, regardless of the update value parameter. -For calculations that were based on the results of other variables that didn't change, this was fine. -But, for calculations based on new raw readings (i.e., calling `analogRead()`) a new value would be returned each time the function was called. -I realized this was a problem for analog values I tried to read that reported correctly in the first round, but were saved as junk in the csv and publishers because a new analog reading was being attempted when the thing I was attempting to read was now powered down. + For calculations that were based on the results of other variables that didn't change, this was fine. + But, for calculations based on new raw readings (i.e., calling `analogRead()`) a new value would be returned each time the function was called. + I realized this was a problem for analog values I tried to read that reported correctly in the first round, but were saved as junk in the csv and publishers because a new analog reading was being attempted when the thing I was attempting to read was now powered down. - The variable array update functions have been modified accordingly. - Verify you have the functionality you expect if you use calculated variables. - Removed the enable/disable wake pin interrupt at every sleep interval in favor of a single attachment during the begin. @@ -273,7 +273,7 @@ I realized this was a problem for analog values I tried to read that reported co - The size of a uint32_t is always 32 bits, but the size of the time_t object varies by processor - for some it is 32 bits, for other 64. - Changed the watchdog from a fixed 15 minute reset timer to 2x the logging interval (or at least 5 minutes). - Modified all examples which define a sercom serial port for SAMD21 processors to require the defines for the supported processors. -This should only make a difference for my compilation tests, real users should pick out only the chunks of code they want rather than leave conditional code in place. + This should only make a difference for my compilation tests, real users should pick out only the chunks of code they want rather than leave conditional code in place. - Changed some fill-in-the-blank spots in the menu example to only set the value in a single spot in the code. - Unified all defines related to the resolution of the processor ADC and moved them to the new configuration file. - Applies only to sensors using the built-in processor ADC: @@ -296,21 +296,23 @@ This should only make a difference for my compilation tests, real users should p ### Added - **CONFIGURATION** Added two configuration files (ModSensorConfig.h and ModSensorDebugConfig.h) that all files read from to check for configuration-related defines. -This allows Arduino IDE users who are unable to use build flags to more easily configure the library or enable debugging. + This allows Arduino IDE users who are unable to use build flags to more easily configure the library or enable debugging. It also allows PlatformIO users to avoid the time-consuming re-compile of all their libraries required when changing build flags. - **ALL** library configuration build flags previously in any other header file for the library have been moved into the ModSensorConfig.h file, including ADC, SDI-12, and variable array options. - Added support for caching readings in RAM and sending in batches. -This currently only works on the EnviroDIY/Monitor My Watershed Publisher. -Thank you to [Thomas Watson](https://github.com/tpwrules) for this work. + This currently only works on the EnviroDIY/Monitor My Watershed Publisher. + Thank you to [Thomas Watson](https://github.com/tpwrules) for this work. - Created a new ClockSupport module with the loggerClock and epochStart static classes. - Added support for the Micro Crystal RV-8803-C7 high accuracy, ultra low power Real-Time-Clock Module. - Added support for multiple 'epoch' types starting at January 1, 1970 (UNIX), January 1, 2000 (Arduino and others), January 5, 1980 (GPST), and January 1, 1900 (NIST time and NTP protocols). - This allows you to input the epoch you're using in every single function that deals with a uint32_t or epoch type timestamp. -If no epoch start is given, it is assumed to be UNIX (January 1, 1970). + If no epoch start is given, it is assumed to be UNIX (January 1, 1970). - The supported epochs are given in the enum epochStart. - Storing _buttonPinMode internally. - Added a single define (`MS_OUTPUT`) to use for all outputs from ModularSensors. -- Added support for sending printouts and debugging to two different serial ports. This is useful for devices (like SAMD) that use a built-in USB serial port which is turned off when the device sleeps. If `MS_2ND_OUTPUT` is defined, output will go to *both* `MS_2ND_OUTPUT` and to `MS_OUTPUT`. +- Added support for sending printouts and debugging to two different serial ports. + This is useful for devices (like SAMD) that use a built-in USB serial port which is turned off when the device sleeps. + If `MS_2ND_OUTPUT` is defined, output will go to *both* `MS_2ND_OUTPUT` and to `MS_OUTPUT`. - Added example code for flashing boards with a neo-pixel in the menu example. - **NEW SENSOR** Added support for [Geolux HydroCam](https://www.geolux-radars.com/hydrocam) - **NEW SENSOR** Added support for [ANB Sensors pH Sensors](https://www.anbsensors.com/) @@ -341,9 +343,9 @@ If no epoch start is given, it is assumed to be UNIX (January 1, 1970). - **Potentially BREAKING:** Removed support for any functions using the Sodaq "DateTime" class. - **Potentially BREAKING:** Removed ability to have `PRINTOUT`, `MS_DBG`, and `MS_DEEP_DBG` output going to different serial ports - Defines for `STANDARD_SERIAL_OUTPUT`, `DEBUGGING_SERIAL_OUTPUT`, and `DEEP_DEBUGGING_SERIAL_OUTPUT` are all ignored. -Use the single define `MS_OUTPUT` for all outputs. -If `MS_OUTPUT` is not defined, a default will be used (generally Serial or USBSerial). -If you do not want any output, define `MS_SILENT`. + Use the single define `MS_OUTPUT` for all outputs. + If `MS_OUTPUT` is not defined, a default will be used (generally Serial or USBSerial). + If you do not want any output, define `MS_SILENT`. - Removed internal functions for setting file times; replaced with SdFat's dateTimeCallback. - Added python script to run clang-format on all source files. @@ -360,7 +362,7 @@ If you do not want any output, define `MS_SILENT`. - **SEVERE** Sensors that require two or more power pins are treated as only requiring the first one within the variableArray and if the second or further power pin is a primary power pin with any other sensor, then the secondary pin will be turned off with the other sensor completes even if the sensor where that pin is secondary is not finished. - This is a serious issue for sensors that are both slow and require powered secondary communication adapters or relays - like the Geolux HydroCam or the ANB Sensors pH sensors. - - *Possible work-arounds* + - *Possible workarounds* - Wire required adapters to the same pin as that providing primary power. - Wire required adapters such that they are continuously powered. - If you must switch the power to both the sensor and an adapter and either the sensor power or the adapter power are shared with a pin that provides power to any other sensor, call the shared power pin the "sensor" power and the other the "adapter." @@ -398,7 +400,7 @@ If you do not want any output, define `MS_SILENT`. ### Changed - **BREAKING** Switched default clock for SAMD21 from the built-in 32bit RTC to the DS3231. -*This is not be a permanent change.* + *This is not be a permanent change.* - Switched to reusable workflows for CI ### Fixed @@ -420,7 +422,7 @@ Fixed clock configuration for SAMD21 - Only polling modem for enabled parameters - INCREASED THE MAXIMUM NUMBER OF VARIABLES FROM A SINGLE SENSOR and implemented an option to set this by build flag. - This will increase memory use for the entire library. -If you are not using the GroPoint sensors which require many variables, I recommend you change this value via the build flag `-D MAX_NUMBER_VARS=8` + If you are not using the GroPoint sensors which require many variables, I recommend you change this value via the build flag `-D MAX_NUMBER_VARS=8` - Allow all WiFi modems to first attempt to connect using existing on-modem saved credentials rather than immediately sending new credentials. - Add further debug printouts to the processor stats @@ -436,7 +438,7 @@ If you are not using the GroPoint sensors which require many variables, I recomm ### Fixed -- Minor bug fixes for XBee Wifi +- Minor bug fixes for XBee WiFi - Handle no SIM card response from SIM7080G (EnviroDIY LTE Bee) - Fixed Keller debugging output. - Fixed file reference for SDFat 2.2.3 @@ -449,14 +451,14 @@ If you are not using the GroPoint sensors which require many variables, I recomm ### Changed -- Incorporated improvements to the XBee Wifi - from [neilh10](https://github.com/EnviroDIY/ModularSensors/commits?author=neilh10) +- Incorporated improvements to the XBee WiFi - from [neilh10](https://github.com/EnviroDIY/ModularSensors/commits?author=neilh10) - #347 -WiFi S6B stability - tears down TCP/IP before going to sleep, doesn't automatically poll for meta data ### Added - Added the ability to enable or disable polling of modem attached variables. -By default, all polling is off, but polling is enabled for a modem sensor when a sensor is created and attached to a modem. -This functionality is inspired from [neilh10](https://github.com/EnviroDIY/ModularSensors/commits?author=neilh10). + By default, all polling is off, but polling is enabled for a modem sensor when a sensor is created and attached to a modem. + This functionality is inspired from [neilh10](https://github.com/EnviroDIY/ModularSensors/commits?author=neilh10). ### Fixed @@ -467,7 +469,7 @@ This functionality is inspired from [neilh10](https://github.com/EnviroDIY/Modul ### Changed - **BREAKING** - Removed support for light sleep on Espressif modules. -**This changes the order of the constructor for the ESP32 and ESP8266!** + **This changes the order of the constructor for the ESP32 and ESP8266!** - The light sleep mode is non-functional anyway, and confusion over the sleep request pin was putting the board in a position not to sleep at all. - Minor tweak to clang-format - Moved all variable initialization to default header values and initializer lists @@ -539,23 +541,23 @@ This functionality is inspired from [neilh10](https://github.com/EnviroDIY/Modul - **Breaking:** Renamed the static `markedEpochTime` variable to `markedLocalEpochTime`. - This was sometimes used in "complex" loops. Code utilizing it will have to be changed. - This is part of the effort to clarify where localized and UTC time are being used. -We recommend a logger's real time clock always be set in UTC and then localized for printing and storing data. + We recommend a logger's real time clock always be set in UTC and then localized for printing and storing data. - **Breaking:** Renamed the function `setNowEpoch(uint32_t)` to `setNowUTCEpoch(uint32_t)`. - Although public, this was never intended to be used externally. - **Breaking:** Renamed the YosemiTech Y550 COD sensor as Y551. See below. - **Potentially Breaking:** Changed the default "button" interrupt pin mode from `INPUT_PULLUP` to `INPUT` and created optional arguments to the `setTestingModePin` and `setLoggerPins` functions to specify the pin mode and pull-up resistor state. - `INPUT` is the proper mode for the Mayfly. -The Mayfly has an external pull *down* on the button pin with the button being active high. -This means having the pull-up resistors on negates the button signal. -The pin mode had been set as `INPUT_PULLUP` for the button, backwards for the Mayfly, since [July of 2017](https://github.com/EnviroDIY/ModularSensors/commit/6bafb0fd149589f71ca6f46b761fe72b1f9523a6). -By some electrical luck, with the 0.x versions of the Mayfly, the external pull-down on the button pin was strong enough to out-weigh the incorrectly activated pull-up resistors and an interrupt was still registered when the button was pressed. -With a different pull-down resistor on the Mayfly 1.x, the button no longer registers with the pull-up resistors active. -So, for most of our users with Mayflies, this will be a ***fix***. -But for anyone using a different board/processor/button configuration that depended on the processor pull-up resistors, this will be a breaking change and they will need to specify the button mode in the `setTestingModePin` or `setLoggerPins` function to return to the previous behavior. + The Mayfly has an external pull *down* on the button pin with the button being active high. + This means having the pull-up resistors on negates the button signal. + The pin mode had been set as `INPUT_PULLUP` for the button, backwards for the Mayfly, since [July of 2017](https://github.com/EnviroDIY/ModularSensors/commit/6bafb0fd149589f71ca6f46b761fe72b1f9523a6). + By some electrical luck, with the 0.x versions of the Mayfly, the external pull-down on the button pin was strong enough to out-weigh the incorrectly activated pull-up resistors and an interrupt was still registered when the button was pressed. + With a different pull-down resistor on the Mayfly 1.x, the button no longer registers with the pull-up resistors active. + So, for most of our users with Mayflies, this will be a ***fix***. + But for anyone using a different board/processor/button configuration that depended on the processor pull-up resistors, this will be a breaking change and they will need to specify the button mode in the `setTestingModePin` or `setLoggerPins` function to return to the previous behavior. - Added a longer warm up time and removed some of the modem set-up to work with the ESP-IDF AT firmware versions >2.0 - Made sure that all example clock synchronization happens at noon instead of midnight. - **Renamed Classes:** Renamed several classes for internal consistency. -These are *not* breaking changes at this time; the old class names are still usable. + These are *not* breaking changes at this time; the old class names are still usable. - Rename class `MPL115A2` to `FreescaleMPL115A2` - Rename class `MPL115A2_Pressure` to `FreescaleMPL115A2_Pressure` - Rename class `MPL115A2_Temp` to `FreescaleMPL115A2_Temp` @@ -590,7 +592,7 @@ These are *not* breaking changes at this time; the old class names are still usa - Restructured SDI-12 slightly to break out the start measurement functionality into a new function. - Modified Decagon 5-TM and Meter Teros 11 to use the SDI-12 get results function rather than addSingleMeasurementResult. -This will allow both sensors to honor the 'non-concurrent' flag, if that is set. + This will allow both sensors to honor the 'non-concurrent' flag, if that is set. Previously, they would not have. - **Documentation:** Migrated to latest version of Doxygen (1.9.2). This required some changes with m.css to properly ignore the doxyfile.xml the current version generates. @@ -599,7 +601,7 @@ Previously, they would not have. - **Board:** Adds 1.0 and 1.1 as valid version numbers for the Mayfly. Does not yet support any new features of those boards. - Add a new parameter (internal variable) to the sensor base class for the number of internally calculated variables. -These are used for values that we would always calculate for a sensor and depend only on the raw results of that single sensor. + These are used for values that we would always calculate for a sensor and depend only on the raw results of that single sensor. This is separate from any calculated variables that are created on-the-fly and depend on multiple other sensors. In many cases, this is 0 and in most of the other cases the value is informational only. For the SDI-12 sensors, I'm actually using this to make sure I'm getting the number of values expected. @@ -665,8 +667,8 @@ Remove support for SoftwareWire for Atlas sensors - **Breaking:** Removed support for SoftwareWire for Atlas sensors. - The only supported version of a bit-banged (software) version of I2C removed inheritance from the core Wire library. -Without inheritance, the parseFloat functions used by the Atlas sensors will not work. -As I think this feature was completely unused for the Atlas sensors and I see no reason to use it with sensors that have completely flexible addressing, I removed it. + Without inheritance, the parseFloat functions used by the Atlas sensors will not work. + As I think this feature was completely unused for the Atlas sensors and I see no reason to use it with sensors that have completely flexible addressing, I removed it. ### Fixed @@ -695,7 +697,7 @@ Create a ModularSensors.h ### Added - Created a ModularSensors.h file to include. -This makes it much easier to install and use the library from the Arduino CLI. + This makes it much easier to install and use the library from the Arduino CLI. - Modified examples to include the ModularSensors.h file - Added continuous integration testing with the Arduino CLI @@ -708,11 +710,11 @@ Duplicate and Rename Hydros 21 ### Added - **Sensor:** Created a new module for the Meter Hydros 21. -This is exactly identical to the Decagon CTD in everything but the name. -The Decagon CTD module still exists and can be used. -No old code needs to be adjusted for this change. -Moving forward, the two can be used interchangeably. -The addition was only made to stop complaints about typing in an older name. + This is exactly identical to the Decagon CTD in everything but the name. + The Decagon CTD module still exists and can be used. + No old code needs to be adjusted for this change. + Moving forward, the two can be used interchangeably. + The addition was only made to stop complaints about typing in an older name. *** @@ -724,8 +726,8 @@ SDI-12 Timing Sensor Customization - Allow each SDI-12 sensor to set the necessary command delay for that sensor. - Per protocol, sensors are allowed to take up to 100ms after receiving a break before being ready to receive a command. -This allows each sensor to specify what delay it needs. -This was added to support conflicting delay needs; the RDO needed a short delay, the newest Meter sensors do not respond properly if the delay is added. + This allows each sensor to specify what delay it needs. + This was added to support conflicting delay needs; the RDO needed a short delay, the newest Meter sensors do not respond properly if the delay is added. - For SDI-12 sensors, add repeated attempts to start a measurement if the first attempt unexpectedly fails. *** @@ -951,7 +953,7 @@ Modem Simplification - Digi XBee and XBee3 cellular modems of all types running in transparent mode - Digi XBee3 cellular LTE-M modems in bypass mode (this is *in addition* to transparent mode) - Digi XBee cellular 3G global modems in bypass mode (this is *in addition* to transparent mode) - - Digi XBee Wifi S6B modules + - Digi XBee WiFi S6B modules - Sodaq UBee LTE-M (SARA R410M) - Sodaq UBee 3G (SARA U201) - Sodaq 2GBee R6/R7 @@ -1042,7 +1044,11 @@ Support for all Atlas Scientific I2C sensors, compiler-safe begin functions - RTD (temperature - Created empty constructors for the logger, publisher, variable array, and variable classes and all of their subclasses. For all classes created a corresponding "begin" function to set internal class object values. - See note for more details: - - The order of input arguments for all variable objects has changed. For variable subclasses (i.e., variables from sensors), there is no change to the user. ****For calculated variable objects, all code must be updated!**** Please check the structure in the examples! Older code will compile without error but the variable metadata fields will be incorrectly populated. + - The order of input arguments for all variable objects has changed. + For variable subclasses (i.e., variables from sensors), there is no change to the user. + **For calculated variable objects, all code must be updated!** + Please check the structure in the examples! + Older code will compile without error but the variable metadata fields will be incorrectly populated. - Very preliminary support for SD cards with switchable power ### Removed @@ -1056,7 +1062,8 @@ Support for all Atlas Scientific I2C sensors, compiler-safe begin functions ### Known Issues -- Running some I2C sensors on switched power will cause unrecoverable hangs at the first call to any other I2C peripheral (i.e., the DS3231 RTC) after sensor power is turned off. This is a hardware problem and is un-fixable within this library. +- Running some I2C sensors on switched power will cause unrecoverable hangs at the first call to any other I2C peripheral (i.e., the DS3231 RTC) after sensor power is turned off. + This is a hardware problem and is un-fixable within this library. - The sensor class and all of its subclasses still require input arguments in the constructor. *** diff --git a/README.md b/README.md index 687ebb318..1d0d73cb3 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,7 @@ There is extensive documentation available in the [ModularSensors github pages]( - [The EnviroDIY ModularSensors Library](#the-envirodiy-modularsensors-library) - [Supported Sensors](#supported-sensors) - [Data Endpoints](#data-endpoints) - - [Supported Cellular/Wifi Modules:](#supported-cellularwifi-modules) + - [Supported Cellular/WiFi Modules:](#supported-cellularwifi-modules) - [Contributing](#contributing) - [License](#license) - [Acknowledgments](#acknowledgments) @@ -120,11 +120,11 @@ The currently supported services are [Monitor My Watershed](https://monitormywat - [AWS S3](https://envirodiy.github.io/ModularSensors/class_s3_presigned_publisher.html) - The S3 publisher requires you to provide a function that will return an updated pre-signed URL to publish to. - The S3 publisher does **NOT** publish any sensor data by default. -It is intended for publishing images. + It is intended for publishing images. -## Supported Cellular/Wifi Modules: +## Supported Cellular/WiFi Modules: All cellular and wifi support is through the [TinyGSM](https://github.com/vshymanskyy/TinyGSM) library. For information common to all modems and for tables of the proper class, baud rate, and pins to uses, see the [Modem Notes page](https://envirodiy.github.io/ModularSensors/page_modem_notes.html). @@ -137,7 +137,7 @@ For information common to all modems and for tables of the proper class, baud ra - [Digi XBee® Cellular 3G](https://hub.digi.com/support/products/digi-xbee/digi-xbee-cellular-3g/) [*obsolete*] - [Digi XBee® Cellular LTE Cat 1 (Verizon)](https://hub.digi.com/support/products/digi-xbee/digi-xbee-cellular-lte-cat-1/) [*obsolete*] - [Digi XBee® Wi-Fi (S6B)](https://hub.digi.com/support/products/digi-xbee/digi-xbee-wi-fi/) [*obsolete*] -- [Espressif Wifi SoC Modules](https://envirodiy.github.io/ModularSensors/group__modem__espressif.html) +- [Espressif WiFi SoC Modules](https://envirodiy.github.io/ModularSensors/group__modem__espressif.html) - Includes the [ESP8266](https://envirodiy.github.io/ModularSensors/group__modem__esp8266.html), [ESP32, ESP32-C3, ESP32-C2, ESP32-C6, and ESP32-S2](https://envirodiy.github.io/ModularSensors/group__modem__esp32.html) - Requires Espressif modules to be programmed with the [latest AT firmware provided by Espressif](https://github.com/espressif/esp-at). - These Espressif modules are **not** supported as primary processors, only as external communication modules. diff --git a/docs/FAQ/Code-Debugging.md b/docs/FAQ/Code-Debugging.md index 49fc5fc77..d99e74cd1 100644 --- a/docs/FAQ/Code-Debugging.md +++ b/docs/FAQ/Code-Debugging.md @@ -8,7 +8,8 @@ When using PlatformIO or other build systems that allow you to define build flag - `-D MS_SERIAL_OUTPUT=SerialX` to define a serial or other stream to use for all printout, debugging or otherwise - `-D MS_2ND_OUTPUT=SerialX` to define a second serial to output identical debugging output to - - This is very helpful for boards that use a built-in USB adapter. Assigning a secondary output that can be attached to a secondary TTL-to-USB adapter can make debugging much easier. + - This is very helpful for boards that use a built-in USB adapter. + Assigning a secondary output that can be attached to a secondary TTL-to-USB adapter can make debugging much easier. - `-D MS_SILENT` to suppress *ALL* output. There is also a debugging - and sometimes deep debugging - define for each component. @@ -16,7 +17,7 @@ The debugging flags are generally named as MS_xxx_DEBUG`, where xxxxx is the nam ## Arduino IDE -For intense _code_ debugging for any individual component of the library (sensor communication, modem communication, variable array functions, etc), open the source file header (\*.h), for that component. +For intense **code** debugging for any individual component of the library (sensor communication, modem communication, variable array functions, etc), open the source file header (\*.h) for that component. Find the line `// #define MS_xxx_DEBUG`, where xxxxx is the name of the header file to debug - in all caps with spaces removed. Remove the two comment slashes from that line. Then recompile and upload your code. diff --git a/docs/FAQ/Power-Parasites.md b/docs/FAQ/Power-Parasites.md index 34ee0d4c1..1c2513b51 100644 --- a/docs/FAQ/Power-Parasites.md +++ b/docs/FAQ/Power-Parasites.md @@ -4,20 +4,20 @@ When deploying a logger out into the wild and depending on only battery or solar This library assumes that the main power/Vcc supply to each sensor can be turned on by setting its powerPin high and off by setting its powerPin low. For most well-designed sensors, this should stop all power draw from the sensor. Real sensors, unfortunately, aren't as well designed as one might hope and some sensors (and particularly RS485 adapters) can continue to suck power from by way of high or floating data pins. -For most sensors, this library attempts to set all data pins low when sending the sensors and then logger to sleep. +For most sensors, this library attempts to set all data pins low when putting the sensors and then the logger to sleep. -If you are still seeing "parasitic" power draw, here are some work-arounds you can try: +If you are still seeing "parasitic" power draw, here are some workarounds you can try: - For sensors (and adapters) drawing power over a serial line: - Write-out your entire loop function. -(Don't just use `logData()`.) + (Don't just use `logData()`.) - Add a `SerialPortName.begin(BAUD);` statement to the beginning of your loop, before `sensorsPowerUp()`. - After `sensorsPowerDown()` add `SerialPortName.end(BAUD);`. - After "ending" the serial communication, explicitly set your Rx and Tx pins low using `digitalWrite(#, LOW);`. - For sensors drawing power over I2C: - Many (most?) boards have external pull-up resistors on the hardware I2C/Wire pins which cannot be disconnected from the main power supply. -This means I2C parasitic power draw is best solved via hardware, not software. + This means I2C parasitic power draw is best solved via hardware, not software. - Use a specially designed I2C isolator - Use a generic opto-isolator or other type of isolator on both the SCL and SDA lines - - In this future, this library _may_ offer the option of using software I2C, which would allow you to use the same technique as is currently usable to stop serial parasitic draw. -Until such an update happens, however, hardware solutions are required. + - In the future, this library _may_ offer the option of using software I2C, which would allow you to use the same technique as is currently usable to stop serial parasitic draw. + Until such an update happens, however, hardware solutions are required. diff --git a/docs/FAQ/Processor-Compatibility.md b/docs/FAQ/Processor-Compatibility.md index 4c302ed2d..e3c03fdd4 100644 --- a/docs/FAQ/Processor-Compatibility.md +++ b/docs/FAQ/Processor-Compatibility.md @@ -27,19 +27,19 @@ _Everything_ is designed to work with this processor. [Datasheet](https://github.com/EnviroDIY/ModularSensors/wiki/Processor-Datasheets/Atmel-ATmega1284P-Datasheet.pdf) - If using a non-Mayfly 1284p board, an external DS3231 or DS3232 RTC is required and the interrupt pin from the clock must be connected to the MCU. -This RTC is already built into the Mayfly and the interrupt is connected at either pin A7 (default) or D10 (with solder jumper SJ1). + This RTC is already built into the Mayfly and the interrupt is connected at either pin A7 (default) or D10 (with solder jumper SJ1). - There is a single SPI port on pins 14 (MISO), 15 (SCK), and 13 (MOSI) on a Mayfly/Mbili or pins 6 (MISO), 7 (SCK), and 5 (MOSI) on a Mighty 1284 or other AtMega1284p. -Chip select/slave select is pin 12 on a Mayfly and card detect can be set to pin 18 with solder jumper 10. -CS/SS and CD pins may vary for other boards. + Chip select/slave select is pin 12 on a Mayfly and card detect can be set to pin 18 with solder jumper 10. + CS/SS and CD pins may vary for other boards. - There is a single I2C (Wire) interface on pins 17 (SDA) and 16 (SCL). - This processor has two built-in hardware TTL serial ports, Serial and Serial1 - On most boards, Serial is connected to the FDTI chip for USB communication with the computer. -On both the Mayfly and the Mbili Serial1 is wired to the "Bee" sockets for communication with the modem. + On both the Mayfly and the Mbili Serial1 is wired to the "Bee" sockets for communication with the modem. - AltSoftSerial can be used on pins 5 (Tx) and 6 (Rx) on the Mayfly or Mbili. -Pin 4 should not be used while using AltSoftSerial on the Mayfly or Mbili. + Pin 4 should not be used while using AltSoftSerial on the Mayfly or Mbili. - Unfortunately, the Rx and Tx pins are on different Grove plugs on both the Mayfly and the Mbili making AltSoftSerial somewhat inconvenient to use. - AltSoftSerial can be used on pins 13 (Tx) and 14 (Rx) on the Mighty 1284 and other 1284p boards. -Pin 12 should not be used while using AltSoftSerial on the Mighty 1284. + Pin 12 should not be used while using AltSoftSerial on the Mighty 1284. - Any digital pin can be used with NeoSWSerial, SoftwareSerial_ExtInts, or SDI-12. ___ @@ -53,31 +53,31 @@ Fully supported [Datasheet](https://github.com/EnviroDIY/ModularSensors/wiki/Processor-Datasheets/Atmel-SAMD21-Datasheet.pdf) - This processor has an internal real time clock (RTC) and does not require a DS3231 to be installed. -The built-in RTC is not as accurate as the DS3231, however, and should be synchronized more frequently to keep the time correct. -The processor clock will also reset if the system battery dies because unlike most external RTC's, there is no coin battery backing up the clock. -At this time, the AtSAMD21 is only supported using the internal clock, but support with a more accurate external RTC is planned. + The built-in RTC is not as accurate as the DS3231, however, and should be synchronized more frequently to keep the time correct. + The processor clock will also reset if the system battery dies because unlike most external RTCs, there is no coin battery backing up the clock. + At this time, the AtSAMD21 is only supported using the internal clock, but support with a more accurate external RTC is planned. - This processor has built-in USB drivers. -Most boards connect the USB pins to a mini or microUSB connector for the computer connection. -Depending on the software core of the board, you send data to the USB port as either "USBSerial" or simply "Serial". + Most boards connect the USB pins to a mini or microUSB connector for the computer connection. + Depending on the software core of the board, you send data to the USB port as either "USBSerial" or simply "Serial". - Most variants have 2 hardware TTL serial ports ("Serial" on pins 30 (TX) and 31 (RX) and "Serial1" on pins 0 (TX) and 1 (RX)) configured by default. - On an Arduino Zero "Serial" goes to the EDBG programming port. - On a Sodaq Autonomo "Serial1" goes to the "Bee" port. - On an Adafruit Feather M0 only "Serial1" is configured, "Serial" will go to the native USB port. - Most variants have one SPI port configured by default (likely pins 22 (MISO), 23 (MOSI), and 24 (SCK)). -Chip select/slave select and card detect pins vary by board. + Chip select/slave select and card detect pins vary by board. - Most variants have one I2C (Wire) interface configured by default (likely pins 20 (SDA) and 21 (SCL)). - There are up to _6_ total "sercom" ports hard which can be configured for either hardware serial, SPI, or I2C (wire) communication on this processor. -See for more instructions on how to configure these ports, if you need them. -There are also examples for an Adafruit feather found in the menu a la carte example: + See for more instructions on how to configure these ports, if you need them. + There are also examples for an Adafruit feather found in the menu a la carte example: - AltSoftSerial is not supported on the AtSAMD21. - SoftwareSerial_ExtInts is not supported on the AtSAMD21. - NeoSWSerial is not supported at all on the AtSAMD21. - Any digital pin can be used with SDI-12. - Because the USB controller is built into the processor, your USB serial connection will close as soon as the processor goes to sleep. -If you need to debug, I recommend using a serial port monitor like [Tera Term](https://ttssh2.osdn.jp/index.html.en) which will automatically renew its connection with the serial port when it connects and disconnects. -Otherwise, you will have to rely on lights on your alert pin or your modem to verify the processor is waking/sleeping properly. + If you need to debug, I recommend using a serial port monitor like [Tera Term](https://ttssh2.osdn.jp/index.html.en) which will automatically renew its connection with the serial port when it connects and disconnects. + Otherwise, you will have to rely on lights on your alert pin or your modem to verify the processor is waking/sleeping properly. - There are also some oddities with debugging on the SAMD21 where turning on some of the debugging code will cause the native USB to fail (and the board appear to be bricked). -Turn off the debugging and double-tap to reset and reprogram if this happens. + Turn off the debugging and double-tap to reset and reprogram if this happens. ___ @@ -87,11 +87,11 @@ Should be fully functional, but untested. - An external DS3231 or DS3232 RTC is required. - There is a single SPI port on pins 50 (MISO), 52 (SCK), and 51 (MOSI). -Chip select/slave select is on pin 53. + Chip select/slave select is on pin 53. - There is a single I2C (Wire) interface on pins 20 (SDA) and 21 (SCL). - This processor has 4 built-in hardware serial ports Serial, which is connected to the FTDI chip for USB communication with the computer, Serial1 on pins 19 (RX) and 18 (TX), Serial2 on pins 17 (RX) and 16 (TX), and Serial3 on pins 15 (RX) and 14 (TX). - If you still need more serial ports, AltSoftSerial can be used on pins 46 (Tx) and 48 (Rx). -Pins 44 and 45 cannot be used while using AltSoftSerial on the AtMega2560. + Pins 44 and 45 cannot be used while using AltSoftSerial on the AtMega2560. - Pins 10, 11, 12, 13, 14, 15, 50, 51, 52, 53, A8 (62), A9 (63), A10 (64), A11 (65), A12 (66), A13 (67), A14 (68), and A15 (69) can be used with NeoSWSerial, SoftwareSerial_ExtInts, or SDI-12. ___ @@ -102,12 +102,12 @@ Should be fully functional, but untested. - An external DS3231 or DS3232 RTC is required. - This processor has two built-in hardware serial ports, Serial and Serial1. -On most boards, Serial is connected to the FDTI chip for USB communication with the computer. + On most boards, Serial is connected to the FDTI chip for USB communication with the computer. - There is a single I2C (Wire) interface on pins 17 (SDA) and 16 (SCL). - There is a single SPI port on pins 6 (MISO), 7 (SCK), and 5 (MOSI). -Chip select/slave select and card detect pins vary by board. + Chip select/slave select and card detect pins vary by board. - AltSoftSerial can be used on pins 13 (Tx) and 14 (Rx). -Pin 12 cannot be used while using AltSoftSerial on the AtMega644p. + Pin 12 cannot be used while using AltSoftSerial on the AtMega644p. - Any digital pin can be used with NeoSWSerial, SoftwareSerial_ExtInts, or SDI-12. ___ @@ -119,12 +119,12 @@ You will only be able to use a small number of sensors at one time and may not b - An external DS3231 or DS3232 RTC is required. - There is a singe SPI ports on pins 12 (MISO), 13 (SCK), and 11 (MOSI). -Chip select/slave select is pin 10 on an Uno. -SS/CS and CD pins may vary for other boards. + Chip select/slave select is pin 10 on an Uno. + SS/CS and CD pins may vary for other boards. - There is a single I2C (Wire) interface on pins A4 (SDA) and A5 (SCL). - This processor only has a single hardware serial port, Serial, which is connected to the FTDI chip for USB communication with the computer. - AltSoftSerial can be used on pins 9 (Tx) and 8 (Rx). -Pin 10 cannot be used while using AltSoftSerial on the AtMega328p. + Pin 10 cannot be used while using AltSoftSerial on the AtMega328p. - Any digital pin can be used with NeoSWSerial, SoftwareSerial_ExtInts, or SDI-12. ___ @@ -140,16 +140,16 @@ You will only be able to use a small number of sensors at one time and may not b - An external DS3231 or DS3232 RTC is required. - There is a single SPI port on pins 14 (MISO), 15 (SCK), and 16 (MOSI). -Chip select/slave select and card detect pins vary by board. + Chip select/slave select and card detect pins vary by board. - There is a single I2C (Wire) interface on pins 2 (SDA) and 3 (SCL). - This processor has one hardware serial port, Serial, which can _only_ be used for USB communication with a computer - There is one additional hardware serial port, Serial1, which can communicate with any serial device. - AltSoftSerial can be used on pins 5 (Tx) and 13 (Rx). - Only pins 8, 9, 10, 11, 14, 15, and 16 can be used with NeoSWSerial, SoftwareSerial_ExtInts, or SDI-12. -(And pins 14, 15, and 16 will be eliminated if you are using any SPI devices (like an SD card).) + (And pins 14, 15, and 16 will be eliminated if you are using any SPI devices (like an SD card).) - Because the USB controller is built into the processor, your USB serial connection will close as soon as the processor goes to sleep. -If you need to debug, I recommend using a serial port monitor like Tera Term which will automatically renew its connection with the serial port when it connects and disconnects. -Otherwise, you will have to rely on lights on your alert pin or your modem to verify the processor is waking/sleeping properly. + If you need to debug, I recommend using a serial port monitor like [Tera Term](https://teratermproject.github.io/index-en.html) which will automatically renew its connection with the serial port when it connects and disconnects. + Otherwise, you will have to rely on lights on your alert pin or your modem to verify the processor is waking/sleeping properly. ___ @@ -158,18 +158,18 @@ ___ - **ESP8266/ESP32** - Supported _only_ as a communications module (modem) with the default AT command firmware, not supported as an independent controller - **AtSAM3X (Arduino Due)** - Unsupported at this time due to clock and sleep issues. - There is one SPI port on pins 74 (MISO), 76 (MOSI), and 75 (SCK). -Pins 4, 10 and pin 52 can be used for CS/SS. + Pins 4, 10 and pin 52 can be used for CS/SS. - There are I2C (Wire) interfaces on pins 20 (SDA) and 21 (SCL) and 70 (SDA1) and 71 (SCL1). - This processor has one hardware serial port, USBSerial, which can _only_ be used for USB communication with a computer - There are three additional 3.3V TTL serial ports: Serial1 on pins 19 (RX) and 18 (TX); Serial2 on pins 17 (RX) and 16 (TX), Serial3 on pins 15 (RX) and 14 (TX). -Pins 0 and 1 are also connected to the corresponding pins of the ATmega16U2 USB-to-TTL Serial chip, which is connected to the USB debug port. + Pins 0 and 1 are also connected to the corresponding pins of the ATmega16U2 USB-to-TTL Serial chip, which is connected to the USB debug port. - AltSoftSerial is not directly supported on the AtSAM3X. - SoftwareSerial_ExtInts is not supported on the AtSAM3X. - SDI-12 is not supported on the AtSAM3X - Any digital pin can be used with SDI-12. - [Datasheet](https://github.com/EnviroDIY/ModularSensors/wiki/Processor-Datasheets/Atmel-AM3X-SAM3A-Datasheet.pdf) - **ATtiny** - Unsupported. -This chip has too little processing power and far too few pins and communication ports to ever use this library. + This chip has too little processing power and far too few pins and communication ports to ever use this library. - [Datasheet](https://github.com/EnviroDIY/ModularSensors/wiki/Processor-Datasheets/Atmel-ATtiny25-45-85-Datasheet.pdf) - **Teensy 2.x/3.x** - Unsupported - **STM32** - Unsupported diff --git a/docs/For-Developers/Developer-Setup.md b/docs/For-Developers/Developer-Setup.md index df4fd0501..2f5bc84d8 100644 --- a/docs/For-Developers/Developer-Setup.md +++ b/docs/For-Developers/Developer-Setup.md @@ -20,7 +20,8 @@ Clone it to your local computer. ## Git Filter Setup -This repository uses Git filters to manage sensitive credentials and debug configurations. After cloning the repository, run one of the following setup scripts to configure the necessary Git filter drivers: +This repository uses Git filters to manage sensitive credentials and debug configurations. +After cloning the repository, run one of the following setup scripts to configure the necessary Git filter drivers: **Windows Command Prompt:** @@ -80,7 +81,7 @@ src_dir = your_directory/your_source_code ; Default baud for all examples monitor_speed = 115200 framework = arduino -; To run code checks; clangtidy must be installed +; To run code checks, clangtidy must be installed check_tool = clangtidy check_src_filters = src diff --git a/docs/Further-Reading/Modem-Notes.md b/docs/Further-Reading/Modem-Notes.md index a5ee1b478..ad6d0f4e1 100644 --- a/docs/Further-Reading/Modem-Notes.md +++ b/docs/Further-Reading/Modem-Notes.md @@ -29,7 +29,7 @@ If you are having trouble, please see the pages for the specific modems and the | Digi XBee3 LTE Cat 1 AT&T (Telit LE866A1-NA) | DigiXBeeCellularTransparent | | Digi XBee S6B WiFi | DigiXBeeWifi | | Espressif ESP8266 | EspressifESP8266 | -| Espressif ESP32 | EspressifESP32 | +| Espressif ESP32 | EspressifESP32 | | Quectel BG96 | QuectelBG96 | | Mikroe LTE IOT 2 Click (_BG96_)¹ | QuectelBG96 | | Dragino NB IOT Bee (_BG96_)¹ | QuectelBG96 | @@ -195,7 +195,8 @@ Here are the pin numbers to use for modules that can be attached directly to an | Sodaq UBee LTE-M (u-blox SARA R410M) | 23 | 19 | A53 | 20 | | Sodaq UBee 3G (u-blox SARA U201) | 23 | 19 | A53 | 20 | -¹ This assumes you have not changed solder jumper 18. If you have switched SJ18 to connect bee pin one directly to 3.3V, use -1. +¹ This assumes you have not changed solder jumper 18. +If you have switched SJ18 to connect bee pin one directly to 3.3V, use -1. ² The Digi XBee reports ON/SLEEP_N on pin 13, but this is not connected to a Mayfly pin by default. You can use the XBee's `CTS` pin (pin 12) which is connected to Mayfly pin 19 by default and set the argument `useCTSforStatus` to `true` in the bee constructor. diff --git a/docs/Further-Reading/SAMD-Clocks.md b/docs/Further-Reading/SAMD-Clocks.md index 9041f053b..1b702ef63 100644 --- a/docs/Further-Reading/SAMD-Clocks.md +++ b/docs/Further-Reading/SAMD-Clocks.md @@ -40,8 +40,7 @@ ## Terms -Essentially every microprocessor or computer needs a consistent way of their own speed of operation so they can communicate with internal components and external devices. - +Essentially every microprocessor or computer needs a consistent way to track its own speed of operation so it can communicate with internal components and external devices. An *[oscillator](https://en.wikipedia.org/wiki/Electronic_oscillator)* is a circuit that makes an oscillating signal - i.e., it switches back and forth between two states at a consistent rate. The oscillator works like a metronome. An oscillator alone does not keep track of time; it ticks, but it doesn't count how many ticks have passed. @@ -49,7 +48,7 @@ An oscillator alone does not keep track of time; it ticks, but it doesn't count SAMD processors use these types of oscillators: - [crystal oscillators](https://en.wikipedia.org/wiki/Crystal_oscillator) - which are tiny pieces of quartz that vibrate under current. -This is just like the crystals in a quartz watch. + This is just like the crystals in a quartz watch. - Digital frequency locked loops (DFLL) and fractional digital phase locked loops (FDPLL) - these [phase locked loops (PLL)](https://wirelesspi.com/how-a-frequency-locked-loop-fll-works/) use a reference clock (like the external crystal) to create a consistent (faster) output frequency. - Ultra-low-power oscillators - circuits which generate the same frequency vibrations as a crystal power but using lower power consumption to get a less consistent signal. @@ -430,6 +429,7 @@ void NVIC_DisableIRQ (IRQn_Type IRQn) Functions are implemented as inline code. From the SAMD51 datasheet, here are the interrupt line mapping numbers for interrupts in the NVIC + ### [Datasheet Table 10-1 Interrupt Line Mapping](https://onlinedocs.microchip.com/oxy/GUID-F5813793-E016-46F5-A9E2-718D8BCED496-en-US-14/GUID-DA8CB38A-18D7-4512-965B-BB439142B281.html?hl=icpr#GUID-DA8CB38A-18D7-4512-965B-BB439142B281__TABLE_CYS_KLX_S5) @@ -883,7 +883,6 @@ From the SAMD51 datasheet, here are the interrupt line mapping numbers for inter
SDHC1 - SD/MMC Host Controller 1All SDHC1 Interrupts136disabled
- ## Exception and Interrupt Handlers Default exception handler functions are defined in startup_samd21.c. @@ -930,7 +929,6 @@ They're defined as “weak” functions, so you can override the default impleme ## NVIC Interrupts Defined in Other Popular Libraries - diff --git a/docs/Further-Reading/Sleep-Configurations.md b/docs/Further-Reading/Sleep-Configurations.md index a9f60d870..e832c1576 100644 --- a/docs/Further-Reading/Sleep-Configurations.md +++ b/docs/Further-Reading/Sleep-Configurations.md @@ -35,19 +35,19 @@ All boards start their bedtime routine with these steps. - Enable the wake ISR on the RTC wake pin - Stop the I2C (Wire) library - **WARNING:** After stopping I2C, we can no longer communicate with and I2C based RTCs! -Any calls to get the current time, change the alarm settings, reset the alarm flags, or any other event that involves communication with the RTC will fail! + Any calls to get the current time, change the alarm settings, reset the alarm flags, or any other event that involves communication with the RTC will fail! - For an AVR board, this disables the two-wire pin functionality and turns off the internal pull-up resistors. - // For a SAMD board, this only disables the I2C sercom and does nothing with - // the pins. The Wire.end() function does **NOT** force the pins low. + - For a SAMD board, this only disables the I2C sercom and does nothing with the pins. + - The Wire.end() function does **NOT** force the pins low. - Force the I2C pins to `LOW` - This only works if the SDA and SCL pins are defined in a boards pins.h file. -Not all boards define the SDA and SCL pins and those that do only define it for their "main" I2C/TWI interface + Not all boards define the SDA and SCL pins and those that do only define it for their "main" I2C/TWI interface - I2C devices have a nasty habit of stealing power from the SCL and SDA pins; this prevents that. - **WARNING:** Any calls to the I2C/Wire library when pins are forced low will cause an endless board hang. - Disable the watch-dog timer - If it is enabled the watchdog timer will wake the board every ~8 seconds checking if the board has been inactive too long and needs to be reset. - We have to chose between allowing the watchdog to save us in a hand during sleep and saving power. -We've chosen to save power. + We've chosen to save power. After this, the different processor types have different steps to finish preparing and finally falling asleep. @@ -60,7 +60,7 @@ But all processors finish their wake routine with these steps - Restart the I2C (Wire) interface - Disable any unnecessary timeouts in the Wire library - These waits would be caused by a readBytes or parseX being called on wire after the Wire buffer has emptied. -The default stream functions - used by wire - wait a timeout period after reading the end of the buffer to see if an interrupt puts something into the buffer. + The default stream functions - used by wire - wait a timeout period after reading the end of the buffer to see if an interrupt puts something into the buffer. In the case of the Wire library, that will never happen and the timeout period is a useless delay. - Detach RTC interrupt the from the wake pin - Disable the RTC interrupt @@ -97,7 +97,7 @@ After completing the [steps for putting all boards to sleep](#steps-for-putting- - Turn off the brown-out detector, if possible. - Disable all power-reduction modules (i.e., the processor module clocks). - NOTE: This only shuts down the various clocks on the processor via the power reduction register! -It does NOT actually disable the modules themselves or set the pins to any particular state! + It does NOT actually disable the modules themselves or set the pins to any particular state! This means that the I2C/Serial/Timer/etc pins will still be active and powered unless they are turned off prior to calling this function. - Set the sleep enable bit. - Wait until the serial ports have finished transmitting. @@ -111,7 +111,7 @@ This means that the I2C/Serial/Timer/etc pins will still be active and powered u - Temporarily disables interrupts, so no mistakes are made when writing to the processor registers. - Re-enable all power modules (i.e., the processor module clocks) - NOTE: This only re-enables the various clocks on the processor! -The modules may need to be re-initialized after the clocks re-start. + The modules may need to be re-initialized after the clocks re-start. - Clear the SE (sleep enable) bit. - Re-enable the processor ADC - Re-enables interrupts @@ -126,32 +126,35 @@ SAMD51 boards have multiple sleep configurations. > Modular Sensors uses **STANDBY** sleep mode for the SAMD51. The STANDBY mode is the lowest power configuration while keeping the state of the logic and the content of the RAM. -The HIBERNATE, BACKUP, and OFF modes do not retain RAM and a full reset occurs on wake. The watchdog timer also does not run in any sleep setting deeper than STANDBY. +The HIBERNATE, BACKUP, and OFF modes do not retain RAM and a full reset occurs on wake. +The watchdog timer also does not run in any sleep setting deeper than STANDBY. - Idle - PM_SLEEPCFG_SLEEPMODE_IDLE_Val = 0x2 - - The CPU is stopped. Synchronous clocks are stopped except when requested. The logic is retained. + - The CPU is stopped. + Synchronous clocks are stopped except when requested. + The logic is retained. - Wake-Up Sources: - Synchronous: interrupt generated on synchronous (APB or AHB) clock. - Asynchronous: interrupt generated on generic clock, external clock, or external event. - Standby - PM_SLEEPCFG_SLEEPMODE_STANDBY_Val = 0x4 - The CPU is stopped as well as the peripherals. -The logic is retained, and power domain gating can be used to fully or partially turn off the PDSYSRAM power domain. + The logic is retained, and power domain gating can be used to fully or partially turn off the PDSYSRAM power domain. - Wake-Up Sources: - Synchronous interrupt only for peripherals configured to run in standby. - Asynchronous: interrupt generated on generic clock, external clock, or external event. - Hibernate - PM_SLEEPCFG_SLEEPMODE_HIBERNATE_Val = 0x5 - PDCORESW power domain is turned OFF. -The backup power domain is kept powered to allow few features to run (RTC, 32KHz clock sources, and wake-up from external pins). + The backup power domain is kept powered to allow few features to run (RTC, 32KHz clock sources, and wake-up from external pins). The PDSYSRAM power domain can be retained according to software configuration. - Wake-Up Sources: - Hibernate reset detected by the RSTC - Backup - PM_SLEEPCFG_SLEEPMODE_BACKUP_Val = 0x6 - Only the backup domain is kept powered to allow few features to run (RTC, 32KHz clock sources, and wake-up from external pins). -The PDBKUPRAM power domain can be retained according to software configuration. + The PDBKUPRAM power domain can be retained according to software configuration. - Wake-Up Sources: - Backup reset detected by the RSTC - Off @@ -220,7 +223,7 @@ Some notes on what can and cannot be disabled: - We CAN disable the EIC controller timer (4) because the controller clock source is set to OSCULP32K. - We cannot disable the SERCOM peripheral timers for sleep because they're only reset with a begin(speed, config), which we do not call within the Modular Sensors library. -We force users to call the begin in their sketch so they can choose both the exact type of stream and the baud rate. + We force users to call the begin in their sketch so they can choose both the exact type of stream and the baud rate. - We cannot disable the ADC peripheral timers because they're only set in the init for the ADC at startup. - We CAN disable all of the timer clocks because they're reset every time they're used by SDI-12 (and others) @@ -248,13 +251,13 @@ After completing the [steps for putting all boards to sleep](#steps-for-putting- - Set the sleep mode configuration to use STANDBY mode. - Wait for the sleep mode setting to take - From datasheet 18.6.3.3: A small latency happens between the store instruction and actual writing of the SLEEPCFG register due to bridges. -Software must ensure that the SLEEPCFG register reads the desired value before executing a WFI instruction. + Software must ensure that the SLEEPCFG register reads the desired value before executing a WFI instruction. - Configure standby mode to retain all system RAM and disable fast wake. - Wait for all the board to be ready to sleep. - - From datasheet 18.6.3.3: After power-up, the MAINVREG low power mode takes some time to stabilize. O -Once stabilized, the INTFLAG.SLEEPRDY bit is set. -Before entering Standby, Hibernate or Backup mode, software must ensure that the INTFLAG.SLEEPRDY bit is set. -SRGD Note: I believe this only applies at power-on, but it's probably not a bad idea to check that the flag has been set. + - From datasheet 18.6.3.3: After power-up, the MAINVREG low power mode takes some time to stabilize. + Once stabilized, the INTFLAG.SLEEPRDY bit is set. + Before entering Standby, Hibernate or Backup mode, software must ensure that the INTFLAG.SLEEPRDY bit is set. + SRGD Note: I believe this only applies at power-on, but it's probably not a bad idea to check that the flag has been set. - Call the data sync barrier (`__DSB();`) function to ensure outgoing memory accesses complete. - Call wait for interrupts (`__WFI();`) to begin sleeping. - [See this link for tips on failing to sleep.](https://www.eevblog.com/forum/microcontrollers/crashing-through-__wfi/) @@ -295,7 +298,7 @@ After completing the [steps for putting all boards to sleep](#steps-for-putting- - Disable the systick interrupt. - See . - Due to a hardware bug on the SAMD21, the SysTick interrupts become active before the flash has powered up from sleep, causing a hard fault. -To prevent this the SysTick interrupts are disabled before entering sleep mode. + To prevent this the SysTick interrupts are disabled before entering sleep mode. - Set the sleep mode configuration to use STANDBY mode. - Call the data sync barrier (`__DSB();`) function to ensure outgoing memory accesses complete. - Call wait for interrupts (`__WFI();`) to begin sleeping. diff --git a/docs/Getting-Started/Getting-Started.md b/docs/Getting-Started/Getting-Started.md index abed77bff..e33d33bb0 100644 --- a/docs/Getting-Started/Getting-Started.md +++ b/docs/Getting-Started/Getting-Started.md @@ -50,7 +50,7 @@ That home page can be accessed from the PlatformIO menu. Before you can use this library, you'll need to install it and all of its [dependencies](https://github.com/EnviroDIY/ModularSensors/wiki/Library-Dependencies) so your compiler in the IDE can find them. Because this library has a large number of dependencies, I, again, _very, **very** strongly_ suggest using [PlatformIO](https://platformio.org/). If you use PlatformIO, the library will automatically be installed when you list it in your dependencies in your project's platformio.ini file. -If you really must use the Arduino IDE, this library and all is dependencies can be downloaded in one large zip file [here](https://github.com/EnviroDIY/Libraries/blob/master/libraries.zip?raw=true). +If you really must use the Arduino IDE, this library and all its dependencies can be downloaded in one large zip file downloadable with each Modular Sensors release. ## Setting the Clock @@ -67,20 +67,20 @@ But, for safety, I suggest you set the clock separately. NOTE: These steps are only for AVR boards, for those of you using a SAMD board, the on-board processor RTC is used instead of the DS3231. - Attach the DS3231 to your main board - they'll talk over I2C. -If you're using a Mayfly, the DS3231 is built into the board and you don't need to do anything. + If you're using a Mayfly, the DS3231 is built into the board and you don't need to do anything. - Put a coin battery in the supplemental power slot for the DS3231 (or you'll lose the time as soon as you unplug). -The Mayfly has this battery shot right next to the clock chip. -Every other DS3231 breakout I've seen has a similar way to power the chip. -On the Mayfly, the (+) side of the battery (with the words on it) goes up. + The Mayfly has this battery shot right next to the clock chip. + Every other DS3231 breakout I've seen has a similar way to power the chip. + On the Mayfly, the (+) side of the battery (with the words on it) goes up. - Create a new PlatformIO project from the PlatformIO menu or home page. -Pick whatever board you'll be working with from the drop down. + Pick whatever board you'll be working with from the drop down. For a new project, it's easiest to let PlatformIO set everything up in a new folder. - Once PlatformIO sets up the new project, find and open the newly created platformio.ini file. -It should be a short file with one `[platformio]` section and one `[env]` section for the board you selected earlier. + It should be a short file with one `[platformio]` section and one `[env]` section for the board you selected earlier. - In the `[platformio]` section add this line: `src_dir = .pio/libdeps/mayfly/EnviroDIY_DS3231/examples/PCsync` - In the `[env]` section add this line: `lib_deps = EnviroDIY_DS3231` - Upload to your board. -You shouldn't have to open or modify the program at all. + You shouldn't have to open or modify the program at all. - Download and run this tiny clock-sync program: - Your clock should be set! @@ -89,12 +89,12 @@ You shouldn't have to open or modify the program at all. The set-up in for your logger program PlatformIO is pretty simple: - Create another new PlatformIO project from the PlatformIO menu or home page. -Pick whatever board you'll be working with. + Pick whatever board you'll be working with. Again, it's easiest to let PlatformIO set everything up in a new folder. - Find and open the newly created platformio.ini file in your directory. -In the `[env]` section add these lines: + In the `[env]` section add these lines: - It is important that your configuration has the lib_ldf_mode and build flags set as show below. -Without this, the library won't compile. + Without this, the library won't compile. ```ini lib_deps = EnviroDIY_ModularSensors @@ -105,11 +105,11 @@ build_flags = ``` - Download the "ino" file for whatever example you think will be most similar to what you'll be doing. -Put the ino into the src directory of your project. + Put the ino into the src directory of your project. - Delete main.cpp in that folder. - Do a test build before changing the example just to make sure it compiles. -Note: before compiling the first time, PlatformIO has to download the library and is dependencies so be patient. -The download only happens once. + Note: before compiling the first time, PlatformIO has to download the library and its dependencies so be patient. + The download only happens once. - If the build succeeds, you're ready to move on. ## Modifying the Examples @@ -125,16 +125,16 @@ The examples currently available are: - [menu_a_la_carte](https://github.com/EnviroDIY/ModularSensors/tree/master/examples/menu_a_la_carte) - This shows most of the functions of the library at once. -It has code in it for every possible sensor and modem and for both AVR and SAMD boards. + It has code in it for every possible sensor and modem and for both AVR and SAMD boards. It is also over 1500 lines long. - [single_sensor](https://github.com/EnviroDIY/ModularSensors/tree/master/examples/single_sensor) - This shows making use of the unified set of commands to print data from a MaxBotix ultrasonic range finder to the serial port. -It also shows creating a calculated variable which is the water depth. + It also shows creating a calculated variable which is the water depth. - [simple_logging](https://github.com/EnviroDIY/ModularSensors/tree/master/examples/simple_logging) - This shows how to log data a simple sample count and battery voltage to a SD card. - [logging_to_ThingSpeak](https://github.com/EnviroDIY/ModularSensors/tree/master/examples/logging_to_ThingSpeak) - This uses an ESP8266 to send data to ThingSpeak. -It also includes a Meter Hydros 21 (formerly know as a Decagon CTD) and a Campbell OBS3+. + It also includes a Meter Hydros 21 (formerly known as a Decagon CTD) and a Campbell OBS3+. - [baro_rho_correction](https://github.com/EnviroDIY/ModularSensors/tree/master/examples/baro_rho_correction) - This example demonstrates how to work with calculated variables and calculates water depth by correcting the total pressure measured by a Measurement Specialties MS5803 with the atmospheric pressure measured by a Bosch BME280 environmental sensor and the temperature measured by a Maxim DS18 temperature probe. - [double_logger](https://github.com/EnviroDIY/ModularSensors/tree/master/examples/double_logger) diff --git a/docs/Getting-Started/Library-Dependencies.md b/docs/Getting-Started/Library-Dependencies.md index b01b02680..04075a1fb 100644 --- a/docs/Getting-Started/Library-Dependencies.md +++ b/docs/Getting-Started/Library-Dependencies.md @@ -1,7 +1,8 @@ # Library Dependencies > [!WARNING] -> This page is frequently out of date. Please see the library.json or dependencies.json and example_dependencies.json for the most up-to-date library references! +> This page is frequently out of date. +> Please see the library.json or dependencies.json and example_dependencies.json for the most up-to-date library references! In order to support multiple functions and sensors, there are quite a lot of sub-libraries that this library depends on. _Even if you do not use the modules, you must have all of the dependencies installed for the library itself to properly compile._ @@ -10,21 +11,21 @@ If you are using [PlatformIO](https://platformio.org), you can list "EnviroDIY_M If using the "standard" Arduino IDE, you must install each of these libraries individually, or in a bundle from the [EnviroDIY Libraries](https://github.com/EnviroDIY/Libraries) meta-repository. - [EnableInterrupt](https://github.com/GreyGnome/EnableInterrupt) - Administrates and handles pin change interrupts, allowing the logger to sleep and save battery. -This also controls the interrupts for the versions of SoftwareSerial and SDI-12 linked below that have been stripped of interrupt control. + This also controls the interrupts for the versions of SoftwareSerial and SDI-12 linked below that have been stripped of interrupt control. Because we use this library, _you must always add the line `#include ` to the top of your sketch._ - AVR sleep library - This is for low power sleeping for AVR processors. -(This library is built in to the Arduino and PlatformIO IDEs.) + (This library is built into the Arduino and PlatformIO IDEs.) - [EnviroDIY DS-3231](https://github.com/EnviroDIY/Sodaq_DS3231) - For real time clock control - [RTCZero library](https://github.com/arduino-libraries/RTCZero) - This real time clock control and low power sleeping on SAMD processors. -(This library may be built in to the Arduino IDE.) + (This library may be built into the Arduino IDE.) NOTE: If using an AVR board, you must explicitly _ignore_ this library when compiling with PlatformIO or you will have compiler errors. - [SdFat library](https://github.com/greiman/SdFat) - This enables communication with the SD card. - [TinyGSM library](https://github.com/vshymanskyy/TinyGSM) - This provides internet (TCP/IP) connectivity. - [PubSubClient](https://github.com/knolleary/pubsubclient) - For MQTT connectivity - [Adafruit ADS1X15 library](https://github.com/adafruit/Adafruit_ADS1X15) - For high-resolution analog to digital conversion. - - NOTE: As of version 0.36.0 the standard Adafruit library should be used, *NOT* the Soligen2010 fork. + - NOTE: As of version 0.36.0 the standard Adafruit library should be used, _NOT_ the Soligen2010 fork. - [EnviroDIY Arduino SDI-12 library](https://github.com/EnviroDIY/Arduino-SDI-12/tree/ExtInts) - For control of SDI-12 based sensors. -This modified version is needed so there are no pin change interrupt conflicts with the SoftwareSerial library or the software pin change interrupt library used to wake the processor. + This modified version is needed so there are no pin change interrupt conflicts with the SoftwareSerial library or the software pin change interrupt library used to wake the processor. - [SensorModbusMaster](https://github.com/EnviroDIY/SensorModbusMaster) - for easy communication with Modbus devices. - [OneWire](https://github.com/PaulStoffregen/OneWire) - This enables communication with Maxim/Dallas OneWire devices. - [DallasTemperature](https://github.com/milesburton/Arduino-Temperature-Control-Library) - for communication with the DS18 line of Maxim/Dallas OneWire temperature probes. @@ -35,12 +36,14 @@ This modified version is needed so there are no pin change interrupt conflicts w - [Adafruit BME280 library](https://github.com/adafruit/Adafruit_BME280_Library) - for the Bosch BME280 environmental sensor. - [Adafruit INA219 library](https://github.com/adafruit/Adafruit_INA219) - for the INA219 current/voltage sensor. - [Adafruit MPL115A2 library](https://github.com/adafruit/Adafruit_MPL115A2) - for the Freescale Semiconductor MPL115A2 barometer. -- [Adafruit SHT4x library](https://github.com/adafruit/Adafruit_SHT4X) - for the Senserion SHT40 temperature and humidity sensor. This sensor is built into the EnviroDIY Mayfly and Stonefly. +- [Adafruit SHT4x library](https://github.com/adafruit/Adafruit_SHT4X) - for the Sensirion SHT40 temperature and humidity sensor. + This sensor is built into the EnviroDIY Mayfly and Stonefly. - [YosemitechModbus](https://github.com/EnviroDIY/YosemitechModbus) - for all Yosemitech modbus environmental sensors. - [Northern Widget MS5803 Library](https://github.com/NorthernWidget/MS5803) - for the TE Connectivity MEAS MS5803 pressure sensor - [EnviroDIY KellerModbus Library](https://github.com/EnviroDIY/KellerModbus) - for all Keller modbus pressure and water level sensors. - [EnviroDIY GroPointModbus Library](https://github.com/EnviroDIY/GroPointModbus.git) - For GroPoint soil moisture probes. - [BMP388_DEV](https://registry.platformio.org/libraries/martinl1/BMP388_DEV) - for communication with the Bosch BMP388 barometer - - WARNING: The repository for this library has been removed from GitHub. The library itself is still available in the PlatformIO and Arduino library registries. + - WARNING: The repository for this library has been removed from GitHub. + The library itself is still available in the PlatformIO and Arduino library registries. - [Tally Library](https://github.com/EnviroDIY/Tally_Library.git#Dev_I2C) - For the Project Tally Event sensor - - NOTE: Use the `Dev_I2C` feature branch + - NOTE: Use the `Dev_I2C` feature branch diff --git a/examples/AWS_IoT_Core/ReadMe.md b/examples/AWS_IoT_Core/ReadMe.md index b67d97abb..f7dafcab6 100644 --- a/examples/AWS_IoT_Core/ReadMe.md +++ b/examples/AWS_IoT_Core/ReadMe.md @@ -61,7 +61,7 @@ Make sure there are quotation marks around the name string, as there are in the ### Set your Variable UUIDs -In the section beginning with `Start [variable_arrays]`, find and replace the text `"12345678-abcd-1234-ef00-1234567890ab"` with the UUIDs for each of your variables, if they have UUIDs. +In the `Start [variable_arrays]` section, find and replace the text `"12345678-abcd-1234-ef00-1234567890ab"` with the UUIDs for each of your variables, if they have UUIDs. Make sure there are quotation marks around the name string, as there are in the example. If you do not have UUIDs for your variables, delete the string entirely, leaving empty quotes (`""`). diff --git a/examples/EnviroDIY_Monitoring_Kit/ReadMe.md b/examples/EnviroDIY_Monitoring_Kit/ReadMe.md index 14a56b092..ccd02fddb 100644 --- a/examples/EnviroDIY_Monitoring_Kit/ReadMe.md +++ b/examples/EnviroDIY_Monitoring_Kit/ReadMe.md @@ -3,7 +3,7 @@ Example sketch to be used with the [EnviroDIY Monitoring Station Kit](https://www.envirodiy.org/product/envirodiy-monitoring-station-kit/). This example uses the sensors and equipment included with (or recommended for) the [EnviroDIY Monitoring Station Kit](https://www.envirodiy.org/product/envirodiy-monitoring-station-kit/). -It includes code for a Mayfly 1.x, a [Meter Hydros 21](https://metergroup.com/products/hydros-21/) and either a [SIM7080G-based EnviroDIY LTEbee](https://www.envirodiy.org/product/envirodiy-lte-bee/) or an [EnviroDIY ESP32 Bee](https://www.envirodiy.org/product/envirodiy-esp32-bee-wifi-bluetooth/) for communication. +It includes code for a Mayfly 1.x, a [Meter Hydros 21](https://metergroup.com/products/hydros-21/) and either a [SIM7080G-based EnviroDIY LTE Bee](https://www.envirodiy.org/product/envirodiy-lte-bee/) or an [EnviroDIY ESP32 Bee](https://www.envirodiy.org/product/envirodiy-esp32-bee-wifi-bluetooth/) for communication. This example also makes use of the on-board light, temperature, and humidity sensors on the Mayfly 1.x. The results are saved to the SD card and posted to Monitor My Watershed. @@ -16,12 +16,16 @@ The exact hardware configuration used in this example: - [EnviroDIY SIM7080 LTE Bee](https://www.envirodiy.org/product/envirodiy-lte-bee/) (with Hologram SIM card) **OR** [EnviroDIY ESP32 Bee](https://www.envirodiy.org/product/envirodiy-esp32-bee-wifi-bluetooth/) - Hydros21 CTD sensor -The EnviroDIY LTE SIM7080 module includes 2 antennas in the package. The small thin one is the cellular antenna, and should be connected to the socket labeled "CELL". The thicker block is the GPS antenna, and should be connected to the "GPS" socket, but only if you intend to use the GPS functionality of the module. ModularSensors does not currently support GPS functionality, but other libraries such as TinyGPS can work with the SIM7080 module. +The SIM7080-based EnviroDIY LTE Bee module includes two antennas in the package. +The small, thin one is the cellular antenna, and should be connected to the socket labeled "CELL". +The thicker block is the GPS antenna, and should be connected to the "GPS" socket, but only if you intend to use the GPS functionality of the module. +ModularSensors does not currently support GPS functionality, but other libraries such as TinyGPS can work with the SIM7080 module. -The included cell antenna works best in high-signal-strength areas. For most remote areas and logger deployments, we suggest a larger LTE antenna, like the W3907B0100 -from PulseLarsen (Digikey 1837-1003-ND or Mouser 673-W3907B0100) +The included cell antenna works best in high-signal-strength areas. +For most remote areas and logger deployments, we suggest a larger LTE antenna, like the W3907B0100 from PulseLarsen (Digikey 1837-1003-ND or Mouser 673-W3907B0100). -Users purchasing a new Hydros21 CTD sensor will need to change the SDI-12 address of the sensor in order to use this sketch. Full instructions for using this sketch as part of a monitoring station can be found in the EnviroDIY Monitoring Station Manual. +Users purchasing a new Hydros21 CTD sensor will need to change the SDI-12 address of the sensor in order to use this sketch. +Full instructions for using this sketch as part of a monitoring station can be found in the EnviroDIY Monitoring Station Manual. _______ @@ -76,7 +80,7 @@ Customize the sketch for the version of the kit that you have: cellular, wifi, o In the configuration section, select no more than one of the "bee" types that you will be using. - Activate the modem you wish to use by _removing_ any slashes (`//`) before the bee module you will use. - - The line should start with `#define` + - The line should start with `#define`. - Add two slashes (`//`) in front of the modem you are NOT using. - If you are not using any internet connection, put two slashes (`//`) in front of both lines. @@ -90,7 +94,7 @@ In the configuration section, select no more than one of the "bee" types that yo Replace `YourAPN` or both `YourWiFiSSID` and `YourWiFiPassword` with the appropriate APN or SSID and password for your network. Your APN is assigned by your SIM card provider. -If you are using a Hologram SIM card (recommended with the kit) the APN is `hologram`. +If you are using a Hologram SIM card (recommended with the kit), the APN is `hologram`. The SSID is the name of the wifi network. @@ -111,7 +115,7 @@ You can leave the configuration for the connection type you're not using as is. ### Set Data Logging Options -Customize your data logging options in `Data Logging Options` section of the example. +Customize your data logging options in the `Data Logging Options` section of the example. #### Set the logger ID @@ -174,7 +178,7 @@ const char* samplingFeature = "12345678-abcd-1234-ef00-1234567890ab"; // Sampli ``` - VERY CAREFULLY check the order of the UUIDs that you have copied in. -The UUIDs _**MUST**_ be in the following order: + The UUIDs _**MUST**_ be in the following order: - Specific conductance (Meter_Hydros21_Cond) - Water depth (Meter_Hydros21_Depth) - Temperature (Meter_Hydros21_Temp) diff --git a/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_2G/ReadMe.md b/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_2G/ReadMe.md index 80f555223..dd477d0f8 100644 --- a/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_2G/ReadMe.md +++ b/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_2G/ReadMe.md @@ -1,6 +1,7 @@ # DRWI 2G Sites -This code was used for DRWI monitoring stations in 2016-2022. The 2G GPRSbee cellular boards no longer function in the USA, so this code should not be used and is only provided to archival and reference purposes. +This code was used for DRWI monitoring stations in 2016-2022. +The 2G GPRSbee cellular boards no longer function in the USA, so this code should not be used and is only provided for archival and reference purposes. The exact hardware configuration used in this example: @@ -52,7 +53,7 @@ _______ ### Set the logger ID - Change the text `YourLoggerID` in this section of code to your logger ID. -For most DRWI installations, the logger ID was assigned by the Stroud Water Research Center before the station was built. + For most DRWI installations, the logger ID was assigned by the Stroud Water Research Center before the station was built. ```cpp // Logger ID, also becomes the prefix for the name of the data file on SD card @@ -63,7 +64,7 @@ const char *LoggerID = "YourLoggerID"; - The OBS3+ ships with a calibration certificate; you need this sheet! - Change _**all**_ of the `0.000E+00` and `1.000E+00` values in this section of code to the values on that calibration sheet. -Use numbers from the side of the calibration sheet that shows the calibration in _**volts**_. + Use numbers from the side of the calibration sheet that shows the calibration in _**volts**_. - The sketch will not compile if these values are not entered properly. - Do not change any values except those that are `0.000E+00` and `1.000E+00`! @@ -102,7 +103,7 @@ Variable* variableList[] = { ``` - If any of the variables are in a different order on the web page than in your code **reorder the variables in your code to match the website**. -- After you are completely certain that you have the order right in the variable section of your code use the teal "Copy" button on the website to copy the section of code containing all the UUIDs. +- After you are completely certain that you have the order right in the variable section of your code, use the teal "Copy" button on the website to copy the section of code containing all the UUIDs. - Paste the code from the website into your program in this section below the variable array ```cpp diff --git a/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_DigiLTE/ReadMe.md b/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_DigiLTE/ReadMe.md index 6fdc178aa..e8a5c79d4 100644 --- a/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_DigiLTE/ReadMe.md +++ b/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_DigiLTE/ReadMe.md @@ -1,6 +1,9 @@ # DRWI Digi LTE Sites -This example uses the sensors and equipment common to older stations (2016-2020) deployed by groups participating in the DRWI Citizen Science project with the Stroud Water Research Center. It includes a Meter Hydros21 CTD (formerly know as a Decagon), a Campbell OBS3+ (Turbidity), and a Digi XBee3 LTE-M cellular board for communication. The Digi LTE module also required the use of a EnviroDIY LTEBee Adapter board (discontinued in 2021). The Digi LTE modules are no longer recommended for use and have been replace by the EnviroDIY LTEBee in all DRWI-SWRC-managed stations. +This example uses the sensors and equipment common to older stations (2016-2020) deployed by groups participating in the DRWI Citizen Science project with the Stroud Water Research Center. +It includes a Meter Hydros21 CTD (formerly known as a Decagon), a Campbell OBS3+ (Turbidity), and a Digi XBee3 LTE-M cellular board for communication. +The Digi LTE module also required the use of an EnviroDIY LTE Bee Adapter board (discontinued in 2021). +The Digi LTE modules are no longer recommended for use and have been replaced by the EnviroDIY LTE Bee in all DRWI-SWRC-managed stations. The exact hardware configuration used in this example: @@ -53,8 +56,8 @@ _______ ### Set the logger ID -- Change the text `YourLoggerID` in this section of code to your loggerID. -For most DRWI installations, the logger ID was assigned by the Stroud Water Research Center before the station was built. +- Change the text `YourLoggerID` in this section of code to your logger ID. + For most DRWI installations, the logger ID was assigned by the Stroud Water Research Center before the station was built. ```cpp // Logger ID, also becomes the prefix for the name of the data file on SD card @@ -66,7 +69,7 @@ const char *LoggerID = "YourLoggerID"; - The OBS3+ ships with a calibration certificate; you need this sheet! - Change _**all**_ of the `0.000E+00` and `1.000E+00` values in this section of code to the values on that calibration sheet. -Use numbers from the side of the calibration sheet that shows the calibration in _**volts**_. + Use numbers from the side of the calibration sheet that shows the calibration in _**volts**_. - The sketch will not compile if these values are not entered properly. - Do not change any values except those that are `0.000E+00` and `1.000E+00`! @@ -106,7 +109,7 @@ Variable* variableList[] = { ``` - If any of the variables are in a different order on the web page than in your code **reorder the variables in your code to match the website**. -- After you are completely certain that you have the order right in the variable section of your code use the teal "Copy" button on the website to copy the section of code containing all the UUIDs. +- After you are completely certain that you have the order right in the variable section of your code, use the teal "Copy" button on the website to copy the section of code containing all the UUIDs. - Paste the code from the website into your program in this section below the variable array ```cpp diff --git a/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_Mayfly1/ReadMe.md b/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_Mayfly1/ReadMe.md index 0ee05cd5e..45aa520bd 100644 --- a/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_Mayfly1/ReadMe.md +++ b/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_Mayfly1/ReadMe.md @@ -2,7 +2,11 @@ Example sketch for using the EnviroDIY SIM7080G LTE cellular module with an EnviroDIY Mayfly Data Logger. -This example uses the sensors and equipment used by most groups participating in the DRWI (Delaware River Watershed Initiative) Citizen Science project with the Stroud Water Research Center. It includes a Meter Hydros 21 (CTD) and a SIM7080G-based EnviroDIY LTEbee for communication. This example also makes use of the on-board light, temperature, and humidity sensors on the Mayfly 1.x. The results are saved to the SD card and posted to Monitor My Watershed. Only to be used with newer Mayfly v1.0 and v1.1 boards. +This example uses the sensors and equipment used by most groups participating in the DRWI (Delaware River Watershed Initiative) Citizen Science project with the Stroud Water Research Center. +It includes a Meter Hydros 21 (CTD) and a SIM7080G-based EnviroDIY LTE Bee for communication. +This example also makes use of the on-board light, temperature, and humidity sensors on the Mayfly 1.x. +The results are saved to the SD card and posted to Monitor My Watershed. +This example is only to be used with newer Mayfly v1.0 and v1.1 boards. The exact hardware configuration used in this example: @@ -10,16 +14,19 @@ The exact hardware configuration used in this example: - EnviroDIY SIM7080 LTE module (with Hologram SIM card) - Hydros21 CTD sensor -An EnviroDIY LTE SIM7080 module can be used with the older Mayfly v0.5b boards if you change the modemVccPin from 18 to -1. +The SIM7080-based EnviroDIY LTE Bee module can be used with the older Mayfly v0.5b boards if you change the modemVccPin from 18 to -1. This is because the Mayfly v1.x board has a separate 3.3v regulator to power the Bee socket and is controlled by turning pin 18 on or off. Mayfly v0.5b has the Bee socket constantly powered, therefore using "-1" is the proper setting for that line of code. -The EnviroDIY LTE SIM7080 module includes 2 antennas in the package. The small thin one is the cellular antenna, and should be connected to the socket labeled "CELL". The thicker block is the GPS antenna, and should be connected to the "GPS" socket, but only if you intend to use the GPS functionality of the module. ModularSensors does not currently support GPS functionality, but other libraries such as TinyGPS can work with the SIM7080 module. +The SIM7080-based EnviroDIY LTE Bee module includes two antennas in the package. +The small, thin one is the cellular antenna, and should be connected to the socket labeled "CELL". +The thicker block is the GPS antenna, and should be connected to the "GPS" socket, but only if you intend to use the GPS functionality of the module. +ModularSensors does not currently support GPS functionality, but other libraries such as TinyGPS can work with the SIM7080 module. -The included cell antenna works best in high-signal-strength areas. For most remote areas and logger deployments, we suggest a larger LTE antenna, like the W3907B0100 -from PulseLarsen (Digikey 1837-1003-ND or Mouser 673-W3907B0100) +For most remote areas and logger deployments, we suggest a larger LTE antenna, like the W3907B0100 from PulseLarsen (Digikey 1837-1003-ND or Mouser 673-W3907B0100). -Users purchasing a new Hydros21 CTD sensor will need to change the SDI-12 address of the sensor in order to use this sketch. Full instructions for using this sketch as part of a monitoring station can be found in the EnviroDIY Monitoring Station Manual. +Users purchasing a new Hydros21 CTD sensor will need to change the SDI-12 address of the sensor in order to use this sketch. +Full instructions for using this sketch as part of a monitoring station can be found in the EnviroDIY Monitoring Station Manual. _______ diff --git a/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_Mayfly1_WiFi/ReadMe.md b/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_Mayfly1_WiFi/ReadMe.md index 9c308bdae..638d62671 100644 --- a/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_Mayfly1_WiFi/ReadMe.md +++ b/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_Mayfly1_WiFi/ReadMe.md @@ -9,12 +9,14 @@ The exact hardware configuration used in this example: - Hydros21 CTD sensor An EnviroDIY ESP32 WiFi module can also be used with the older Mayfly v0.5b boards if you change the modemVccPin from 18 to -1. -This is because the Mayfly v1.x board has a separate 3.3v regulator to power the Bee socket and is controlled by turning pin 18 on or off. -Mayfly v0.5b has the Bee socket constantly powered, therefore using "-1" is the proper setting for that line of code. Leave the modemVccPin as 18 for Mayfly version 1.0 and 1.1. +This is because the Mayfly v1.x board has a separate 3.3V regulator to power the Bee socket, which is controlled by turning pin 18 on or off. +Mayfly v0.5b has the Bee socket constantly powered, therefore using "-1" is the proper setting for that line of code. +Leave the modemVccPin as 18 for Mayfly version 1.0 and 1.1. The WiFi antenna is built into the ESP32 Bee - no external antenna is needed -Find and replace `YourWiFiSSID` and `YourWiFiPassword` with your real SSID and password, and edit the UUID section between `Beginning of Token UUID List` and `End of Token UUID List` with the correct UUIDs from your specific site on MonitorMyWatershed. +Find and replace `YourWiFiSSID` and `YourWiFiPassword` with your real SSID and password. +Edit the UUID section between `Beginning of Token UUID List` and `End of Token UUID List` with the correct UUIDs from your specific site on MonitorMyWatershed. _______ diff --git a/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_NoCellular/ReadMe.md b/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_NoCellular/ReadMe.md index 39e790782..e2ed2e9ff 100644 --- a/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_NoCellular/ReadMe.md +++ b/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_NoCellular/ReadMe.md @@ -11,8 +11,9 @@ The exact hardware configuration used in this example: Before using this example, you must register a site and sensors on [Monitor My Watershed](https://monitormywatershed.org). After you have registered the site and sensors, the portal will generate a registration token and universally unique identifier (UUID) for each site and further UUIDs for each variable. -You will need to copy all of those UUID values into your sketch to replace the `12345678-abcd-1234-ef00-1234567890ab` place holders in this example. -__You should register even if your logger will not be sending live data.__ This ensures that the data file your logger writes will be ready to immediately upload to the portal. +You will need to copy all of those UUID values into your sketch to replace the `12345678-abcd-1234-ef00-1234567890ab` placeholders in this example. +__You should register even if your logger will not be sending live data.__ +This ensures that the data file your logger writes will be ready to immediately upload to the portal. _______ @@ -56,8 +57,8 @@ _______ ### Set the logger ID -- Change the text `YourLoggerID` in this section of code to your loggerID. -For most DRWI installations, the logger ID was assigned by the Stroud Water Research Center before the station was built. +- Change the text `YourLoggerID` in this section of code to your logger ID. + For most DRWI installations, the logger ID was assigned by the Stroud Water Research Center before the station was built. ```cpp // Logger ID, also becomes the prefix for the name of the data file on SD card @@ -68,7 +69,7 @@ const char *LoggerID = "YourLoggerID"; - The OBS3+ ships with a calibration certificate; you need this sheet! - Change *__all__* of the `0.000E+00` and `1.000E+00` values in this section of code to the values on that calibration sheet. -Use numbers from the side of the calibration sheet that shows the calibration in *__volts__*. + Use numbers from the side of the calibration sheet that shows the calibration in *__volts__*. - The sketch will not compile if these values are not entered properly. - Do not change any values except those that are `0.000E+00` and `1.000E+00`! @@ -107,7 +108,7 @@ Variable* variableList[] = { ``` - If any of the variables are in a different order on the web page than in your code __reorder the variables in your code to match the website__. -- After you are completely certain that you have the order right in the variable section of your code use the teal "Copy" button on the website to copy the section of code containing all the UUIDs. +- After you are completely certain that you have the order right in the variable section of your code, use the teal "Copy" button on the website to copy the section of code containing all the UUIDs. - Paste the code from the website into your program in this section below the variable array ```cpp diff --git a/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_SIM7080LTE/DRWI_SIM7080LTE.ino b/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_SIM7080LTE/DRWI_SIM7080LTE.ino index 5ab254da4..6e9c377cc 100644 --- a/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_SIM7080LTE/DRWI_SIM7080LTE.ino +++ b/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_SIM7080LTE/DRWI_SIM7080LTE.ino @@ -209,7 +209,7 @@ const char* UUIDs[] = // UUID array for device sensors "12345678-abcd-1234-ef00-1234567890ab", // Turbidity (Campbell_OBS3_Turb) (Low) "12345678-abcd-1234-ef00-1234567890ab", // Turbidity (Campbell_OBS3_Turb) (High) "12345678-abcd-1234-ef00-1234567890ab", // Battery voltage (EnviroDIY_Mayfly_Batt) - "12345678-abcd-1234-ef00-1234567890ab", // Temperature (EnviroDIY_Mayfly_Temp) + "12345678-abcd-1234-ef00-1234567890ab", // Temperature (Maxim_DS3231_Temp) "12345678-abcd-1234-ef00-1234567890ab", // Percent full scale (EnviroDIY_LTEB_SignalPercent) }; const char* registrationToken = "12345678-abcd-1234-ef00-1234567890ab"; // Device registration token diff --git a/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_SIM7080LTE/ReadMe.md b/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_SIM7080LTE/ReadMe.md index cf0bb3238..55f2487b2 100644 --- a/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_SIM7080LTE/ReadMe.md +++ b/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_SIM7080LTE/ReadMe.md @@ -1,6 +1,7 @@ # DRWI Sites with EnviroDIY LTE Bees -The DRWI EnviroDIY LTEbee example uses the sensors and equipment common to older stations (2016-2020) deployed by groups participating in the DRWI Citizen Science project with the Stroud Water Research Center. It includes a Meter Hydros 21 (CTD), a Campbell OBS3+, (Turbidity) and a SIM7080G-based EnviroDIY LTEbee for communication. +The DRWI EnviroDIY LTE Bee example uses the sensors and equipment common to older stations (2016-2020) deployed by groups participating in the DRWI Citizen Science project with the Stroud Water Research Center. +It includes a Meter Hydros 21 (CTD), a Campbell OBS3+ (Turbidity), and a SIM7080G-based EnviroDIY LTE Bee for communication. The exact hardware configuration used in this example: @@ -9,14 +10,17 @@ The exact hardware configuration used in this example: - Hydros21 CTD sensor - Campbell Scientific OBS3+ Turbidity sensor -An EnviroDIY LTE SIM7080 module can be used with the older Mayfly v0.5b boards if you change the modemVccPin from 18 to -1. -This is because the Mayfly v1.0 board has a separate 3.3v regulator to power the Bee socket and is controlled by turning pin 18 on or off. -Mayfly v0.5b has the Bee socket constantly powered, therefore using "-1" is the proper setting for that line of code. +A SIM7080-based EnviroDIY LTE Bee module can be used with the older Mayfly v0.5b boards if you change the modemVccPin from 18 to -1. +This is because the Mayfly v1.0 board contains a separate 3.3V regulator that powers the Bee socket; that regulator is enabled/disabled by toggling pin 18. +The Mayfly v0.5b has the Bee socket constantly powered, therefore using "-1" is the proper setting for that line of code. -The EnviroDIY LTE SIM7080 module includes 2 antennas in the package. The small thin one is the cellular antenna, and should be connected to the socket labeled "CELL". The thicker block is the GPS antenna, and should be connected to the "GPS" socket, but only if you intend to use the GPS functionality of the module. ModularSensors does not currently support GPS functionality, but other libraries such as TinyGPS can work with the SIM7080 module. +The SIM7080-based EnviroDIY LTE Bee module includes two antennas in the package. +The small, thin one is the cellular antenna, and should be connected to the socket labeled "CELL". +The thicker one is the GPS antenna, and should be connected to the "GPS" socket, but only if you intend to use the GPS functionality of the module. +ModularSensors does not currently support GPS functionality, but other libraries such as TinyGPS can work with the SIM7080 module. -The included cell antenna works best in high-signal-strength areas. For most remote areas and logger deployments, we suggest a larger LTE antenna, like the W3907B0100 -from PulseLarsen (Digikey 1837-1003-ND or Mouser 673-W3907B0100) +The included cell antenna works best in high-signal-strength areas. +For most remote areas and logger deployments, we suggest a larger LTE antenna, like the W3907B0100 from PulseLarsen (Digikey 1837-1003-ND or Mouser 673-W3907B0100). _______ diff --git a/examples/OutdatedExamples/simple_logging_LearnEnviroDIY/ReadMe.md b/examples/OutdatedExamples/simple_logging_LearnEnviroDIY/ReadMe.md index 87500d61c..7b6e4bc0b 100644 --- a/examples/OutdatedExamples/simple_logging_LearnEnviroDIY/ReadMe.md +++ b/examples/OutdatedExamples/simple_logging_LearnEnviroDIY/ReadMe.md @@ -40,7 +40,8 @@ _______ - Replace the contents of the platformio.ini for your new project with the [platformio.ini](https://raw.githubusercontent.com/EnviroDIY/ModularSensors/master/examples/simple_logging_LearnEnviroDIY/platformio.ini) file in the examples/simple_logging_LearnEnviroDIY folder on GitHub. - It is important that your PlatformIO configuration has the lib_ldf_mode and build flags set as they are in the example. - Without this, the program won't compile. -- Open [simple_logging_LearnEnviroDIY.ino](https://raw.githubusercontent.com/EnviroDIY/ModularSensors/master/examples/simple_logging_LearnEnviroDIY/simple_logging_LearnEnviroDIY.ino) and save it to your computer. Put it into the src directory of your project. +- Open [simple_logging_LearnEnviroDIY.ino](https://raw.githubusercontent.com/EnviroDIY/ModularSensors/master/examples/simple_logging_LearnEnviroDIY/simple_logging_LearnEnviroDIY.ino) and save it to your computer. + Put it into the src directory of your project. - Delete main.cpp in that folder. ### Set the logger ID diff --git a/examples/ReadMe.md b/examples/ReadMe.md index 38cd7e57b..a9e4c5164 100644 --- a/examples/ReadMe.md +++ b/examples/ReadMe.md @@ -29,7 +29,7 @@ ___ - [DRWI CitSci No Cellular](#drwi-citsci-no-cellular) - [DRWI CitSci (2G)](#drwi-citsci-2g) - [DRWI Digi LTE](#drwi-digi-lte) - - [DRWI EnviroDIY LTEbee](#drwi-envirodiy-ltebee) + - [DRWI EnviroDIY LTE Bee](#drwi-envirodiy-lte-bee) @@ -61,13 +61,14 @@ ___ ### Publishing to Monitor My Watershed The logging to Monitor My Watershed example uses a Digi XBee in transparent mode to publish data live from a BME280 and Maxim DS18. + - [Instructions for the logging to Monitor My Watershed example](https://envirodiy.github.io/ModularSensors/example_mmw.html) - [The logging to Monitor My Watershed example on GitHub](https://github.com/EnviroDIY/ModularSensors/tree/master/examples/logging_to_MMW) ### Publishing to ThingSpeak The logging to ThingSpeak example uses an ESP8266 to send data to ThingSpeak. -It also includes a Meter Hydros 21 (formerly know as a Decagon CTD) and a Campbell OBS3+. +It also includes a Meter Hydros 21 (formerly known as a Decagon CTD) and a Campbell OBS3+. - [Instructions for the logging to ThingSpeak example](https://envirodiy.github.io/ModularSensors/example_thingspeak.html) - [The logging to ThingSpeak example on GitHub](https://github.com/EnviroDIY/ModularSensors/tree/master/examples/logging_to_ThingSpeak) @@ -108,7 +109,7 @@ The "menu a la carte" example shows most of the functions of the library in one It has code in it for every possible sensor and modem and for both AVR and SAMD boards. It is also over 1500 lines long. This example is intended to serve as an a la carte menu of all available options, allowing you to select only the portions of code pertinent to you and delete everything else. -This example is *NOT* intended to be run in its entirety +This example is *NOT* intended to be run in its entirety. - [The menu a la carte walkthrough](https://envirodiy.github.io/ModularSensors/example_menu.html) - Unlike the instructions for the other examples which show how to modify the example for your own use, this is a chunk-by-chunk step through of the code with explanations of each portion of the code and links to further documentation on each sensor. @@ -145,9 +146,10 @@ ___ #### DRWI Mayfly 1.x LTE The DRWI Mayfly 1.x LTE example uses the sensors and equipment used by most groups participating in the DRWI (Delaware River Watershed Initiative) Citizen Science project with the Stroud Water Research Center. -It includes a Meter Hydros 21 (CTD) and a SIM7080G-based EnviroDIY LTEbee for communication. +It includes a Meter Hydros 21 (CTD) and a SIM7080G-based EnviroDIY LTE Bee for communication. This example also makes use of the on-board light, temperature, and humidity sensors on the Mayfly 1.x. -The results are saved to the SD card and posted to Monitor My Watershed. Only to be used with newer Mayfly v1.0 and v1.1 boards. +The results are saved to the SD card and posted to Monitor My Watershed. +Only to be used with newer Mayfly v1.0 and v1.1 boards. - [Instructions for the Mayfly 1.x LTE DRWI Citizen Science example](https://envirodiy.github.io/ModularSensors/example_drwi_mayfly1.html) - [The Mayfly 1.x LTE DRWI Citizen Science example on GitHub](https://github.com/EnviroDIY/ModularSensors/tree/master/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_Mayfly1) @@ -165,7 +167,7 @@ The exclusion of the modem and publisher simplifies the code from the other DRWI The 2G DRWI Citizen Science example uses the sensors and equipment found on older stations used in the DRWI Citizen Science project before 2020. The 2G GPRSbee boards no longer function in the USA, so this code should not be used and is only provided for archival and reference purposes. -It includes a Meter Hydros 21 (formerly know as a Decagon CTD), a Campbell OBS3+, and a Sodaq GPRSBee for communication. +It includes a Meter Hydros 21 (formerly known as a Decagon CTD), a Campbell OBS3+, and a Sodaq GPRSBee for communication. The results are saved to the SD card and posted to Monitor My Watershed. The only difference between this and the other cellular DRWI examples is the type of modem used. @@ -175,19 +177,19 @@ The only difference between this and the other cellular DRWI examples is the typ #### DRWI Digi LTE The DRWI Digi LTE example uses the sensors and equipment common to older stations (2016-2020) deployed by groups participating in the DRWI Citizen Science project with the Stroud Water Research Center. -It includes a Meter Hydros 21 (formerly know as a Decagon CTD), a Campbell OBS3+, and a Digi XBee3 LTE-M for communication. +It includes a Meter Hydros 21 (formerly known as a Decagon CTD), a Campbell OBS3+, and a Digi XBee3 LTE-M for communication. The results are saved to the SD card and posted to Monitor My Watershed. The only difference between this and the other cellular DRWI examples is the type of modem used. - [Instructions for the Digi LTE DRWI Citizen Science example](https://envirodiy.github.io/ModularSensors/example_drwi_digilte.html) - [The Digi LTE DRWI Citizen Science example on GitHub](https://github.com/EnviroDIY/ModularSensors/tree/master/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_DigiLTE) -#### DRWI EnviroDIY LTEbee +#### DRWI EnviroDIY LTE Bee -The DRWI EnviroDIY LTEbee example uses the sensors and equipment common to newer stations (2016-2020) deployed by groups participating in the DRWI Citizen Science project with the Stroud Water Research Center. -It includes a Meter Hydros 21 (CTD), a Campbell OBS3+, (Turbidity) and a SIM7080G-based EnviroDIY LTEbee for communication. +The DRWI EnviroDIY LTE Bee example uses the sensors and equipment common to newer stations (after 2020) deployed by groups participating in the DRWI Citizen Science project with the Stroud Water Research Center. +It includes a Meter Hydros 21 (CTD), a Campbell OBS3+ (Turbidity), and a SIM7080G-based EnviroDIY LTE Bee for communication. The results are saved to the SD card and posted to Monitor My Watershed. -The only difference between this and the other cellular DRWI examples below is the type of modem used. +The only difference between this and the other cellular DRWI examples above is the type of modem used. -- [Instructions for the EnviroDIY LTEbee DRWI Citizen Science example](https://envirodiy.github.io/ModularSensors/example_drwi_ediylte.html) +- [Instructions for the EnviroDIY LTE Bee DRWI Citizen Science example](https://envirodiy.github.io/ModularSensors/example_drwi_ediylte.html) - [The EnviroDIY LTE DRWI Citizen Science example on GitHub](https://github.com/EnviroDIY/ModularSensors/tree/master/examples/OutdatedExamples/DRWI_CitizenScience/DRWI_SIM7080LTE) diff --git a/examples/logging_to_MMW/ReadMe.md b/examples/logging_to_MMW/ReadMe.md index 95e4f7f73..b69232eda 100644 --- a/examples/logging_to_MMW/ReadMe.md +++ b/examples/logging_to_MMW/ReadMe.md @@ -1,11 +1,12 @@ # Sending Data to Monitor My Watershed -This sketch reduces menu_a_la_carte.ino to provide an example of how to log to from two sensors, the BME280 and DS18. To complete the set up for logging to the web portal, the UUIDs for the site and each variable would need to be added to the sketch. +This sketch reduces menu_a_la_carte.ino to provide an example of how to log to from two sensors, the BME280 and DS18. +To complete the setup for logging to the web portal, the UUIDs for the site and each variable would need to be added to the sketch. The settings for other data portals were removed from the example. -The modem settings were left unchanged because the sketch will test successfully without modem connection (wait patiently, it takes a few minutes). - +The modem settings were left unchanged because the sketch will test successfully without modem connection. +(Wait patiently, it takes a few minutes.) This is the example you should use to deploy a logger with a modem to stream live data to Monitor My Watershed. _______ diff --git a/examples/logging_to_MMW/logging_to_MMW.ino b/examples/logging_to_MMW/logging_to_MMW.ino index a1d9c74d3..dd1231149 100644 --- a/examples/logging_to_MMW/logging_to_MMW.ino +++ b/examples/logging_to_MMW/logging_to_MMW.ino @@ -28,7 +28,7 @@ // ========================================================================== /** Start [logging_options] */ // The name of this program file -const char* sketchName = "logging_to MMW.ino"; +const char* sketchName = "logging_to_MMW.ino"; // Logger ID, also becomes the prefix for the name of the data file on SD card const char* LoggerID = "YourLoggerID"; // How frequently (in minutes) to log data diff --git a/examples/logging_to_ThingSpeak/ReadMe.md b/examples/logging_to_ThingSpeak/ReadMe.md index 728a9b582..debb545f6 100644 --- a/examples/logging_to_ThingSpeak/ReadMe.md +++ b/examples/logging_to_ThingSpeak/ReadMe.md @@ -54,20 +54,20 @@ _______ - Modify logging_to_ThingSpeak.ino to have the modem, sensor, and variable objects that you are interested in. - This example is written for an _ESP8266 (wifi)_ modem. -Change this to whatever modem you are using. + Change this to whatever modem you are using. Paste-able chunks of code for each modem are available in the individual sensor documentation or in the menu a la carte example. - Don't forget to put in your wifi username/password or cellular APN! - This example is written for a Campbell OBS3+ and a Meter Hydros 21. -Remove those sensors if you are not using them and add code for all of your sensors. + Remove those sensors if you are not using them and add code for all of your sensors. See the pages for the individual sensors in the [documentation](https://envirodiy.github.io/ModularSensors/index.html) for code snippets/examples. - Remember, no more than **8** variables/fields can be sent to a single ThingSpeak channel. -If you want to send data to multiple channels, you must create individual logger objects with unique publishers attached for each channel you want to send to. + If you want to send data to multiple channels, you must create individual logger objects with unique publishers attached for each channel you want to send to. - **Make sure the pin numbers and serial ports selected in your code match with how things are physically attached to your board!** - Order the variables in your variable array in the same order as your fields are on ThingSpeak. - This order is **crucial**. -The results from the variables in the VariableArray will be sent to ThingSpeak in the order they are in the array; that is, the first variable in the array will be sent as Field1, the second as Field2, etc. + The results from the variables in the VariableArray will be sent to ThingSpeak in the order they are in the array; that is, the first variable in the array will be sent as Field1, the second as Field2, etc. - Any UUIDs or custom variable codes are ignored for ThingSpeak. -They will only appear in the header of your file on the SD card. + They will only appear in the header of your file on the SD card. - Find this information for your ThingSpeak account and channel and put it into logging_to_ThingSpeak.ino: ```cpp diff --git a/examples/menu_a_la_carte/ReadMe.md b/examples/menu_a_la_carte/ReadMe.md index 802433313..ef14b31a1 100644 --- a/examples/menu_a_la_carte/ReadMe.md +++ b/examples/menu_a_la_carte/ReadMe.md @@ -184,7 +184,7 @@ ___ #### AVR Boards -Most Arduino AVR style boards have very few (i.e., one, or none) dedicated serial ports *available* after counting out the programming serial port. +Most Arduino AVR style boards have very few (i.e., one or none) dedicated serial ports *available* after counting out the programming serial port. So to connect anything else, we need to try to emulate the processor serial functionality with a software library. This example shows three possible libraries that can be used to emulate a serial port on an AVR board. @@ -513,7 +513,7 @@ To create a Sodaq2GBeeR6 object we need to know - the serial object name, - the MCU pin controlling modem power, (**NOTE:** On the GPRSBee R6 and R7 the pin labeled as ON/OFF in Sodaq's diagrams is tied to *both* the SIM800 power supply and the (inverted) SIM800 `PWRKEY`. -You should enter this pin as the power pin.) + You should enter this pin as the power pin.) - and the SIM card's cellular access point name (APN). Pins that do not apply should be set as -1. @@ -675,6 +675,7 @@ The default I2C addresses for the circuits are: - ORP (redox): 0x62 (98) - pH: 0x63 (99) - RTD (temperature): 0x66 (102) + All of the circuits can be re-addressed to any other 8 bit number if desired. To use multiple circuits of the same type, re-address them. @@ -732,7 +733,7 @@ ___ Here is the code for the Bosch BME280 environmental sensor. The only input needed is the Arduino pin controlling power on/off; the i2cAddressHex is optional as is the number of readings to average. -Keep in mind that the I2C address (0x76) of the BME280 matches those of some configurations of the MS5803, MS5837, BMP388, and BMP390 sensors; when using those sensors together, make sure they are set to different addresses. +Keep in mind that the I2C address (0x76) of the BME280 matches that of some configurations of the MS5803, MS5837, BMP388, and BMP390 sensors; when using those sensors together, make sure they are set to different addresses. @see @ref sensor_bme280 @@ -742,7 +743,7 @@ ___ ### Bosch BMP388 and BMP398 Pressure Sensors -Keep in mind that the I2C address (0x76) of the BMP388/BMP390 sensors matches those of some configurations of the MS5803, MS5837, and BME280 sensors; when using those sensors together, make sure they are set to different addresses. +Keep in mind that the I2C address (0x76) of the BMP388/BMP390 sensors matches that of some configurations of the MS5803, MS5837, and BME280 sensors; when using those sensors together, make sure they are set to different addresses. @see @ref sensor_bmp3xx @@ -953,8 +954,6 @@ ___ The only input needed is the Arduino pin controlling power on/off; the i2cAddressHex and maximum pressure are optional as is the number of readings to average. Keep in mind that the I2C address (0x76) of the MS5803 matches those of some configurations of the MS5837, BME280, BMP388, and BMP390 sensors; when using those sensors together, make sure they are set to different addresses. -@see @ref sensor_ms5803 - ___ @@ -963,7 +962,7 @@ ___ The MS5837 is commonly used in Blue Robotics Bar02/Bar30 pressure sensors for underwater applications and depth measurement. The only required input is the Arduino pin controlling power on/off; the sensor model, fluid density, air pressure, and number of readings to average are optional. -Keep in mind that the I2C address (0x76) of the MS5837 matches those of some configurations of the MS5803, BME280, BMP388, and BMP390 sensors. +Keep in mind that the I2C address (0x76) of the MS5837 matches that of some configurations of the MS5803, BME280, BMP388, and BMP390 sensors; when using those sensors together, make sure they are set to different addresses. @see @ref sensor_ms5837 @@ -1565,7 +1564,7 @@ Every time the logger wakes we check the battery voltage and do 1 of three thing 1. If the battery is very low, go immediately back to sleep and hope the sun comes back out 2. If the battery is at a moderate level, attempt to collect data from sensors, but do not attempt to publish data. -The modem the biggest power user of the whole system. + The modem the biggest power user of the whole system. 3. At full power, do everything. @@ -1580,7 +1579,7 @@ Here are some guidelines for writing a loop function: - If you want to log on an even interval, use `if (checkInterval())` or `if (checkMarkedInterval())` to verify that the current or marked time is an even interval of the logging interval.. - Call the `markTime()` function if you want associate with a two iterations of sensor updates with the same timestamp. -This allows you to use `checkMarkedInterval()` to check if an action should be preformed based on the exact time when the logger woke rather than up to several seconds later when iterating through sensors. + This allows you to use `checkMarkedInterval()` to check if an action should be preformed based on the exact time when the logger woke rather than up to several seconds later when iterating through sensors. - Either: - Power up all of your sensors with `sensorsPowerUp()`. - Wake up all your sensors with `sensorsWake()`. @@ -1589,7 +1588,7 @@ This allows you to use `checkMarkedInterval()` to check if an action should be p - Power down all of your sensors with `sensorsPowerDown()`. - Or: - Do a full update loop of all sensors, including powering them with `completeUpdate()`. -(This combines the previous 5 functions.) + (This combines the previous 5 functions.) - After updating the sensors, then call any functions you want to send/print/save data. - Finish by putting the logger back to sleep, if desired, with `systemSleep()`. diff --git a/examples/simple_logging/ReadMe.md b/examples/simple_logging/ReadMe.md index 6695bc7c4..d5fbb4529 100644 --- a/examples/simple_logging/ReadMe.md +++ b/examples/simple_logging/ReadMe.md @@ -1,7 +1,7 @@ # Simple Logging This shows the simplest use of a "logger" object. -That is, creating an array of variable objects and then creating a logger object that utilizes those variables to update all of the variable results together and save the data to a SD card. +That is, creating an array of variable objects and then creating a logger object that utilizes those variables to update all of the variable results together and save the data to an SD card. The processor then goes to sleep between readings. This is the example you should use to deploy a logger somewhere where you don't want or have access to a way of streaming live data and you won't be uploading data to Monitor My Watershed. @@ -35,7 +35,8 @@ _______ - Replace the contents of the platformio.ini for your new project with the [platformio.ini](https://raw.githubusercontent.com/EnviroDIY/ModularSensors/master/examples/simple_logging/platformio.ini) file in the examples/simple_logging folder on GitHub. - It is important that your PlatformIO configuration has the lib_ldf_mode and build flags set as they are in the example. - Without this, the program won't compile. -- Open [simple_logging.ino](https://raw.githubusercontent.com/EnviroDIY/ModularSensors/master/examples/simple_logging/simple_logging.ino) and save it to your computer. Put it into the src directory of your project. +- Open [simple_logging.ino](https://raw.githubusercontent.com/EnviroDIY/ModularSensors/master/examples/simple_logging/simple_logging.ino) and save it to your computer. + Put it into the src directory of your project. - Delete main.cpp in that folder. ### Set the logger ID diff --git a/examples/single_sensor/ReadMe.md b/examples/single_sensor/ReadMe.md index dc7925ac0..58fca4874 100644 --- a/examples/single_sensor/ReadMe.md +++ b/examples/single_sensor/ReadMe.md @@ -34,8 +34,9 @@ _______ - Replace the contents of the platformio.ini for your new project with the [platformio.ini](https://raw.githubusercontent.com/EnviroDIY/ModularSensors/master/examples/single_sensor/platformio.ini) file in the examples/single_sensor folder on GitHub. - It is important that your PlatformIO configuration has the lib_ldf_mode and build flags set as they are in the example. - Without this, the program won't compile. -- Open [single_sensor.ino](https://raw.githubusercontent.com/EnviroDIY/ModularSensors/master/examples/single_sensor/single_sensor.ino) and save it to your computer. Put it into the src directory of your project. - - Delete main.cpp in that folder. +- Open [single_sensor.ino](https://raw.githubusercontent.com/EnviroDIY/ModularSensors/master/examples/single_sensor/single_sensor.ino) and save it to your computer. +- Put it into the src directory of your project. +- Delete main.cpp in that folder. ### Upload! diff --git a/extras/AWS_IoT_SetCertificates/ReadMe.md b/extras/AWS_IoT_SetCertificates/ReadMe.md index 15e399c06..bece8a053 100644 --- a/extras/AWS_IoT_SetCertificates/ReadMe.md +++ b/extras/AWS_IoT_SetCertificates/ReadMe.md @@ -143,12 +143,14 @@ These are the messages you should see on the serial monitor as your program runs - After warm up, the modem will initialize and you should see the message `Initializing modem` … … `success`. - Next you will see a print out of the modem info; `Modem Info:` followed by the serial number and other info about your modem. This is just for your information. - The Stonefly will then load the CA certificate, client certificate, and key onto the modem, convert them to the modem's internal file format, and print back the loaded text so you can confirm it matches later if there are problems. -- After the certificates are loaded, the modem waits for a network connection. If the connection succeeds, you'll see the message `Waiting for network` … … `success` +- After the certificates are loaded, the modem waits for a network connection. + If the connection succeeds, you'll see the message `Waiting for network` … … `success` > [!WARNING] > The first time you connect to the a new cellular tower with a new SIM card and new modem, the connection may take a **long** time - up to several minutes. -- Now the modem waits gets a LTE internet connection. If the connection succeeds, you'll see the message `Connecting to hologram` … `success` +- Now the modem gets an LTE internet connection. + If the connection succeeds, you'll see the message `Connecting to hologram` … `success` - Once fully connected, the modem will sync its timestamp with NTP. This is required for later secured connections. - You'll see a message `=== MQTT NOT CONNECTED ===` because you haven't connected yet. - The modem will connect to MQTT, giving the message `Connecting to YOUR_ENDPOINT with client ID YOUR_THING_NAME` … `success` diff --git a/src/SensorBase.cpp b/src/SensorBase.cpp index f1185a170..a1ec6e342 100644 --- a/src/SensorBase.cpp +++ b/src/SensorBase.cpp @@ -65,7 +65,7 @@ String Sensor::getSensorNameAndLocation() { int8_t Sensor::getPowerPin() { return _powerPin; } -// This sets the power pin +// This sets the power pin void Sensor::setPowerPin(int8_t pin) { _powerPin = pin; } From ced9e921e7b729f22f4346d43a07beb32df19991 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Thu, 12 Mar 2026 11:06:56 -0400 Subject: [PATCH 504/533] Add missing begin Signed-off-by: Sara Damiano --- src/sensors/AOSongAM2315.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/sensors/AOSongAM2315.cpp b/src/sensors/AOSongAM2315.cpp index 07141cac2..07cf5a79e 100644 --- a/src/sensors/AOSongAM2315.cpp +++ b/src/sensors/AOSongAM2315.cpp @@ -57,6 +57,10 @@ bool AOSongAM2315::addSingleMeasurementResult() { MS_DBG(getSensorNameAndLocation(), F("is reporting:")); Adafruit_AM2315 am2315(_i2c); + if (!am2315.begin()) { + MS_DBG(getSensorNameAndLocation(), F("AM2315 begin() failed")); + return finalizeMeasurementAttempt(false); + } success = am2315.readTemperatureAndHumidity(&temp_val, &humid_val); From fd65973f138b82eca19df8b54a691a0d9cedcb7f Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Thu, 12 Mar 2026 11:17:32 -0400 Subject: [PATCH 505/533] More catches in markdown Signed-off-by: Sara Damiano --- ChangeLog.md | 4 ++-- docs/Further-Reading/Sleep-Configurations.md | 12 ++++++------ docs/Getting-Started/Getting-Started.md | 2 +- examples/logging_to_ThingSpeak/ReadMe.md | 4 ++-- examples/menu_a_la_carte/ReadMe.md | 8 +++----- 5 files changed, 14 insertions(+), 16 deletions(-) diff --git a/ChangeLog.md b/ChangeLog.md index 6bed72307..77431a3e7 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -400,7 +400,7 @@ It also allows PlatformIO users to avoid the time-consuming re-compile of all th ### Changed - **BREAKING** Switched default clock for SAMD21 from the built-in 32bit RTC to the DS3231. - *This is not be a permanent change.* + *This is not a permanent change.* - Switched to reusable workflows for CI ### Fixed @@ -458,7 +458,7 @@ Fixed clock configuration for SAMD21 - Added the ability to enable or disable polling of modem attached variables. By default, all polling is off, but polling is enabled for a modem sensor when a sensor is created and attached to a modem. - This functionality is inspired from [neilh10](https://github.com/EnviroDIY/ModularSensors/commits?author=neilh10). + This functionality is inspired by [neilh10](https://github.com/EnviroDIY/ModularSensors/commits?author=neilh10). ### Fixed diff --git a/docs/Further-Reading/Sleep-Configurations.md b/docs/Further-Reading/Sleep-Configurations.md index e832c1576..b8811710c 100644 --- a/docs/Further-Reading/Sleep-Configurations.md +++ b/docs/Further-Reading/Sleep-Configurations.md @@ -46,7 +46,7 @@ All boards start their bedtime routine with these steps. - **WARNING:** Any calls to the I2C/Wire library when pins are forced low will cause an endless board hang. - Disable the watch-dog timer - If it is enabled the watchdog timer will wake the board every ~8 seconds checking if the board has been inactive too long and needs to be reset. - - We have to chose between allowing the watchdog to save us in a hand during sleep and saving power. + - We have to choose between allowing the watchdog to save us in a hand during sleep and saving power. We've chosen to save power. After this, the different processor types have different steps to finish preparing and finally falling asleep. @@ -59,9 +59,9 @@ But all processors finish their wake routine with these steps - Re-enable the watch-dog timer - Restart the I2C (Wire) interface - Disable any unnecessary timeouts in the Wire library - - These waits would be caused by a readBytes or parseX being called on wire after the Wire buffer has emptied. - The default stream functions - used by wire - wait a timeout period after reading the end of the buffer to see if an interrupt puts something into the buffer. -In the case of the Wire library, that will never happen and the timeout period is a useless delay. + - These waits would be caused by a readBytes or parseX being called on Wire after the Wire buffer has emptied. + The default stream functions - used by Wire - wait a timeout period after reading the end of the buffer to see if an interrupt puts something into the buffer. + In the case of the Wire library, that will never happen and the timeout period is a useless delay. - Detach RTC interrupt the from the wake pin - Disable the RTC interrupt @@ -98,7 +98,7 @@ After completing the [steps for putting all boards to sleep](#steps-for-putting- - Disable all power-reduction modules (i.e., the processor module clocks). - NOTE: This only shuts down the various clocks on the processor via the power reduction register! It does NOT actually disable the modules themselves or set the pins to any particular state! -This means that the I2C/Serial/Timer/etc pins will still be active and powered unless they are turned off prior to calling this function. + This means that the I2C/Serial/Timer/etc pins will still be active and powered unless they are turned off prior to calling this function. - Set the sleep enable bit. - Wait until the serial ports have finished transmitting. - This isn't very important on AVR boards, but it's good practice. @@ -148,7 +148,7 @@ The watchdog timer also does not run in any sleep setting deeper than STANDBY. - PM_SLEEPCFG_SLEEPMODE_HIBERNATE_Val = 0x5 - PDCORESW power domain is turned OFF. The backup power domain is kept powered to allow few features to run (RTC, 32KHz clock sources, and wake-up from external pins). -The PDSYSRAM power domain can be retained according to software configuration. + The PDSYSRAM power domain can be retained according to software configuration. - Wake-Up Sources: - Hibernate reset detected by the RSTC - Backup diff --git a/docs/Getting-Started/Getting-Started.md b/docs/Getting-Started/Getting-Started.md index e33d33bb0..295d9cd7f 100644 --- a/docs/Getting-Started/Getting-Started.md +++ b/docs/Getting-Started/Getting-Started.md @@ -69,7 +69,7 @@ NOTE: These steps are only for AVR boards, for those of you using a SAMD board, - Attach the DS3231 to your main board - they'll talk over I2C. If you're using a Mayfly, the DS3231 is built into the board and you don't need to do anything. - Put a coin battery in the supplemental power slot for the DS3231 (or you'll lose the time as soon as you unplug). - The Mayfly has this battery shot right next to the clock chip. + The Mayfly has this battery slot right next to the clock chip. Every other DS3231 breakout I've seen has a similar way to power the chip. On the Mayfly, the (+) side of the battery (with the words on it) goes up. - Create a new PlatformIO project from the PlatformIO menu or home page. diff --git a/examples/logging_to_ThingSpeak/ReadMe.md b/examples/logging_to_ThingSpeak/ReadMe.md index debb545f6..b11398a22 100644 --- a/examples/logging_to_ThingSpeak/ReadMe.md +++ b/examples/logging_to_ThingSpeak/ReadMe.md @@ -55,11 +55,11 @@ _______ - Modify logging_to_ThingSpeak.ino to have the modem, sensor, and variable objects that you are interested in. - This example is written for an _ESP8266 (wifi)_ modem. Change this to whatever modem you are using. -Paste-able chunks of code for each modem are available in the individual sensor documentation or in the menu a la carte example. + Paste-able chunks of code for each modem are available in the individual sensor documentation or in the menu a la carte example. - Don't forget to put in your wifi username/password or cellular APN! - This example is written for a Campbell OBS3+ and a Meter Hydros 21. Remove those sensors if you are not using them and add code for all of your sensors. -See the pages for the individual sensors in the [documentation](https://envirodiy.github.io/ModularSensors/index.html) for code snippets/examples. + See the pages for the individual sensors in the [documentation](https://envirodiy.github.io/ModularSensors/index.html) for code snippets/examples. - Remember, no more than **8** variables/fields can be sent to a single ThingSpeak channel. If you want to send data to multiple channels, you must create individual logger objects with unique publishers attached for each channel you want to send to. - **Make sure the pin numbers and serial ports selected in your code match with how things are physically attached to your board!** diff --git a/examples/menu_a_la_carte/ReadMe.md b/examples/menu_a_la_carte/ReadMe.md index ef14b31a1..e1131571c 100644 --- a/examples/menu_a_la_carte/ReadMe.md +++ b/examples/menu_a_la_carte/ReadMe.md @@ -1564,10 +1564,8 @@ Every time the logger wakes we check the battery voltage and do 1 of three thing 1. If the battery is very low, go immediately back to sleep and hope the sun comes back out 2. If the battery is at a moderate level, attempt to collect data from sensors, but do not attempt to publish data. - The modem the biggest power user of the whole system. -3. - -At full power, do everything. + The modem is the biggest power user of the whole system. +3. At full power, do everything. @@ -1579,7 +1577,7 @@ Here are some guidelines for writing a loop function: - If you want to log on an even interval, use `if (checkInterval())` or `if (checkMarkedInterval())` to verify that the current or marked time is an even interval of the logging interval.. - Call the `markTime()` function if you want associate with a two iterations of sensor updates with the same timestamp. - This allows you to use `checkMarkedInterval()` to check if an action should be preformed based on the exact time when the logger woke rather than up to several seconds later when iterating through sensors. + This allows you to use `checkMarkedInterval()` to check if an action should be performed based on the exact time when the logger woke rather than up to several seconds later when iterating through sensors. - Either: - Power up all of your sensors with `sensorsPowerUp()`. - Wake up all your sensors with `sensorsWake()`. From 2fdc98d71d10405435351da5835d836a38a1d15c Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Thu, 12 Mar 2026 11:25:08 -0400 Subject: [PATCH 506/533] Forward declare wire and move include to cpp where possible Signed-off-by: Sara Damiano --- src/sensors/AOSongAM2315.cpp | 1 + src/sensors/AOSongAM2315.h | 4 +++- src/sensors/AtlasParent.h | 4 +++- src/sensors/PaleoTerraRedox.cpp | 5 +++++ src/sensors/PaleoTerraRedox.h | 5 +++-- src/sensors/RainCounterI2C.cpp | 5 +++++ src/sensors/RainCounterI2C.h | 5 +++-- src/sensors/YosemitechY700.h | 2 +- 8 files changed, 24 insertions(+), 7 deletions(-) diff --git a/src/sensors/AOSongAM2315.cpp b/src/sensors/AOSongAM2315.cpp index 07cf5a79e..a9e4d2118 100644 --- a/src/sensors/AOSongAM2315.cpp +++ b/src/sensors/AOSongAM2315.cpp @@ -9,6 +9,7 @@ */ #include "AOSongAM2315.h" +#include #include diff --git a/src/sensors/AOSongAM2315.h b/src/sensors/AOSongAM2315.h index 26d1ddcba..d710fd2fe 100644 --- a/src/sensors/AOSongAM2315.h +++ b/src/sensors/AOSongAM2315.h @@ -75,7 +75,9 @@ // Include other in-library and external dependencies #include "VariableBase.h" #include "SensorBase.h" -#include + +// Forward declarations +class TwoWire; /** @ingroup sensor_am2315 */ /**@{*/ diff --git a/src/sensors/AtlasParent.h b/src/sensors/AtlasParent.h index ea159c3b4..8664fa627 100644 --- a/src/sensors/AtlasParent.h +++ b/src/sensors/AtlasParent.h @@ -91,7 +91,9 @@ // Include other in-library and external dependencies #include "VariableBase.h" #include "SensorBase.h" -#include + +// Forward declarations +class TwoWire; /** * @brief A parent class for Atlas EZO circuits and sensors diff --git a/src/sensors/PaleoTerraRedox.cpp b/src/sensors/PaleoTerraRedox.cpp index 06f50bf83..b74288bf2 100644 --- a/src/sensors/PaleoTerraRedox.cpp +++ b/src/sensors/PaleoTerraRedox.cpp @@ -13,6 +13,11 @@ */ #include "PaleoTerraRedox.h" +#include + +#if defined(MS_PALEOTERRA_SOFTWAREWIRE) +#include // Testato's SoftwareWire +#endif // Constructors diff --git a/src/sensors/PaleoTerraRedox.h b/src/sensors/PaleoTerraRedox.h index 7431d0659..f2d78f79e 100644 --- a/src/sensors/PaleoTerraRedox.h +++ b/src/sensors/PaleoTerraRedox.h @@ -83,10 +83,11 @@ // Include other in-library and external dependencies #include "VariableBase.h" #include "SensorBase.h" -#include +// Forward declarations +class TwoWire; #if defined(MS_PALEOTERRA_SOFTWAREWIRE) -#include // Testato's SoftwareWire +class SoftwareWire; // Testato's SoftwareWire #endif /** @ingroup sensor_pt_redox */ diff --git a/src/sensors/RainCounterI2C.cpp b/src/sensors/RainCounterI2C.cpp index 134e139b8..e162ddc2c 100644 --- a/src/sensors/RainCounterI2C.cpp +++ b/src/sensors/RainCounterI2C.cpp @@ -10,6 +10,11 @@ */ #include "RainCounterI2C.h" +#include + +#if defined(MS_RAIN_SOFTWAREWIRE) +#include // Testato's SoftwareWire +#endif // The constructors diff --git a/src/sensors/RainCounterI2C.h b/src/sensors/RainCounterI2C.h index 6d4c4fa98..b9cc205a7 100644 --- a/src/sensors/RainCounterI2C.h +++ b/src/sensors/RainCounterI2C.h @@ -90,10 +90,11 @@ // Include other in-library and external dependencies #include "VariableBase.h" #include "SensorBase.h" -#include +// Forward declarations +class TwoWire; #if defined(MS_RAIN_SOFTWAREWIRE) -#include // Testato's SoftwareWire +class SoftwareWire; // Testato's SoftwareWire #endif /** @ingroup sensor_i2c_rain */ diff --git a/src/sensors/YosemitechY700.h b/src/sensors/YosemitechY700.h index d2110d873..91a294e47 100644 --- a/src/sensors/YosemitechY700.h +++ b/src/sensors/YosemitechY700.h @@ -95,7 +95,7 @@ * {{ @ref YosemitechY700_Pressure::YosemitechY700_Pressure }} */ /**@{*/ -/// @brief Decimal places in string representation; Pressure should have 1 +/// @brief Decimal places in string representation; Pressure should have 2 /// - resolution is 0.01 mm. #define Y700_PRES_RESOLUTION 2 /// @brief Sensor variable number; pressure is stored in sensorValues[0]. From c867ffa17182d8453c84e312d0b27a98e66513bf Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Thu, 12 Mar 2026 11:37:31 -0400 Subject: [PATCH 507/533] Rename analog objects from "base" to "reader" Signed-off-by: Sara Damiano --- ChangeLog.md | 8 ++-- examples/menu_a_la_carte/menu_a_la_carte.ino | 44 +++++++++---------- src/VariableArray.cpp | 3 +- src/sensors/AlphasenseCO2.cpp | 6 +-- src/sensors/AlphasenseCO2.h | 12 ++--- src/sensors/AnalogElecConductivity.cpp | 6 +-- src/sensors/AnalogElecConductivity.h | 8 ++-- ...logVoltageBase.h => AnalogVoltageReader.h} | 28 ++++++------ src/sensors/ApogeeSQ212.cpp | 8 ++-- src/sensors/ApogeeSQ212.h | 14 +++--- src/sensors/CampbellOBS3.cpp | 8 ++-- src/sensors/CampbellOBS3.h | 14 +++--- src/sensors/EverlightALSPT19.cpp | 10 ++--- src/sensors/EverlightALSPT19.h | 18 ++++---- src/sensors/ProcessorAnalog.cpp | 22 +++++----- src/sensors/ProcessorAnalog.h | 28 ++++++------ src/sensors/TIADS1x15.cpp | 42 +++++++++--------- src/sensors/TIADS1x15.h | 34 +++++++------- src/sensors/TurnerCyclops.cpp | 8 ++-- src/sensors/TurnerCyclops.h | 14 +++--- src/sensors/TurnerTurbidityPlus.cpp | 8 ++-- src/sensors/TurnerTurbidityPlus.h | 16 +++---- 22 files changed, 180 insertions(+), 179 deletions(-) rename src/sensors/{AnalogVoltageBase.h => AnalogVoltageReader.h} (92%) diff --git a/ChangeLog.md b/ChangeLog.md index 77431a3e7..b7b0dfbdf 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -100,7 +100,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm For users who used the default values, this will have no effect. For users who provided both a custom I2C address and a custom number of measurements, this will cause a compiler error. For users who provided a custom I2C address *but not a custom number of measurements* this will cause a *silent failure* because the custom I2C address will be used as the measurement count and the default I2C address will be used. - Users who need a custom I2C address for the ADS1x15 must construct a TIADS1x15Base object with the correct address and pass a pointer to that object to the constructor. + Users who need a custom I2C address for the ADS1x15 must construct a TIADS1x15Reader object with the correct address and pass a pointer to that object to the constructor. - **AnalogElecConductivity** - *Renamed* configuration defines to have the prefix `ANALOGELECCONDUCTIVITY` and moved other defaults to defines. This affects the following defines: @@ -191,9 +191,9 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm - `setMeasurementTime(uint32_t measurementTime_ms)` - `getMeasurementTime()` - Added the functions `Sensor::clearStatus()`,`Sensor::clearPowerStatus()`,`Sensor::clearWakeStatus()`,and `Sensor::clearMeasurementStatus()` which reset some or all of the sensor status bits and related timing variables. -- Added an abstract AnalogVoltageBase class with two concrete classes for analog voltage measurements: ProcessorAnalogBase and TIADS1x15Base. - All supported analog sensors can now accept a pointer to an object of any concrete subclass of the AnalogVoltageBase class to use for raw voltage measurements. - By default, existing analog sensors will create an internal concrete AnalogVoltageBase subclass instance for whichever ADC type (processor or ADS1x15) the sensor was originally coded to use. +- Added an abstract AnalogVoltageReader class with two concrete classes for analog voltage measurements: ProcessorAnalogReader and TIADS1x15Reader. + All supported analog sensors can now accept a pointer to an object of any concrete subclass of the AnalogVoltageReader class to use for raw voltage measurements. + By default, existing analog sensors will create an internal concrete AnalogVoltageReader subclass instance for whichever ADC type (processor or ADS1x15) the sensor was originally coded to use. This affects the following classes: - AlphasenseCO2 - AnalogElecConductivity diff --git a/examples/menu_a_la_carte/menu_a_la_carte.ino b/examples/menu_a_la_carte/menu_a_la_carte.ino index c1e80c452..c58256f9a 100644 --- a/examples/menu_a_la_carte/menu_a_la_carte.ino +++ b/examples/menu_a_la_carte/menu_a_la_carte.ino @@ -1021,10 +1021,10 @@ float AsCO2Multiplier = 1.0f; // factor for a voltage divider adsGain_t AsCO2AdsGain = GAIN_ONE; // gain of the ADS1115 float AsCO2adsSupply = 3.3f; // supply voltage of the ADS1115 const uint8_t AsCO2i2c_addr = 0x48; // The I2C address of the ADS1115 ADC -TIADS1x15Base AsCO2ADS(AsCO2Multiplier, AsCO2AdsGain, AsCO2i2c_addr, +TIADS1x15Reader AsCO2ADS(AsCO2Multiplier, AsCO2AdsGain, AsCO2i2c_addr, AsCO2adsSupply); -// Create an Alphasense CO2 sensor object with the custom TIADS1x15Base +// Create an Alphasense CO2 sensor object with the custom TIADS1x15Reader AlphasenseCO2 alphasenseCO2_c(asCO2Power, asCO2Channel1, asCO2Channel2, asCO2Meas, &AsCO2ADS); /** End [alphasense_co2] */ @@ -1153,10 +1153,10 @@ float sq212Multiplier = 1.0f; // factor for a voltage divider adsGain_t sq212AdsGain = GAIN_ONE; // gain of the ADS1115 float sq212adsSupply = 3.3f; // supply voltage of the ADS1115 const uint8_t sq212i2c_addr = 0x48; // The I2C address of the ADS1115 ADC -TIADS1x15Base sq212ADS(sq212Multiplier, sq212AdsGain, sq212i2c_addr, +TIADS1x15Reader sq212ADS(sq212Multiplier, sq212AdsGain, sq212i2c_addr, sq212adsSupply); -// Create an Apogee SQ212 sensor object with the custom TIADS1x15Base +// Create an Apogee SQ212 sensor object with the custom TIADS1x15Reader ApogeeSQ212 sq212_c(sq212Power, sq212ADSChannel, sq212Readings, &sq212ADS); /** End [apogee_sq212] */ #endif @@ -1506,16 +1506,16 @@ float OBS3Multiplier = 1.0f; // factor for a voltage divider adsGain_t OBS3AdsGain = GAIN_ONE; // gain of the ADS1115 float OBS3AdsSupplyVoltage = 3.3f; // supply voltage of the ADS1115 const uint8_t OBS3AdsI2C_addr = 0x48; // The I2C address of the ADS1115 ADC -TIADS1x15Base OBSADS(OBS3Multiplier, OBS3AdsGain, OBS3AdsI2C_addr, +TIADS1x15Reader OBSADS(OBS3Multiplier, OBS3AdsGain, OBS3AdsI2C_addr, OBS3AdsSupplyVoltage); // Create a Campbell OBS3+ *low* range sensor object with the custom -// TIADS1x15Base +// TIADS1x15Reader CampbellOBS3 osb3low_c(OBS3Power, OBSLowADSChannel, OBSLow_A, OBSLow_B, OBSLow_C, OBS3NReadings, &OBSADS); // Create a Campbell OBS3+ *high* range sensor object with the custom -// TIADS1x15Base +// TIADS1x15Reader CampbellOBS3 osb3high_c(OBS3Power, OBSHighADSChannel, OBSHigh_A, OBSHigh_B, OBSHigh_C, OBS3NReadings, &OBSADS); /** End [campbell_obs3] */ @@ -1641,10 +1641,10 @@ Variable* alsPt19Lux = new EverlightALSPT19_Illuminance( // create a custom analog reader based on the Processor ADC (optional) float alsMultiplier = 1.0f; // factor for a voltage divider float alsAdsSupply = 3.3f; // supply voltage of the Processor ADC -ProcessorAnalogBase alsADS(alsMultiplier, alsAdsSupply); +ProcessorAnalogReader alsADS(alsMultiplier, alsAdsSupply); // Create an Everlight ALS-PT19 sensor object with the custom -// ProcessorAnalogBase +// ProcessorAnalogReader EverlightALSPT19 alsPt19_c(alsPower, alsData, alsSupply, alsResistance, alsNReadings, &alsADS); /** End [everlight_alspt19] */ @@ -1668,10 +1668,10 @@ const int8_t evADSChannel2 = const uint8_t evReadsToAvg = 1; // Only read one sample // Create a single-ended External Voltage sensor object with the default -// TIADS1x15Base +// TIADS1x15Reader TIADS1x15 ads1x15(evADSPower, evADSChannel1); // Create a differential External Voltage sensor object with the default -// TIADS1x15Base +// TIADS1x15Reader TIADS1x15 ads1x15_d(evADSPower, evADSChannel1, evADSChannel2); // create a custom ADS instance (optional) @@ -1679,11 +1679,11 @@ float evVoltageMultiplier = 1.0f; // factor for a voltage divider adsGain_t evAdsGain = GAIN_ONE; // gain of the ADS1115 float evAdsSupplyVoltage = 3.3f; // supply voltage of the ADS1115 const uint8_t evAdsI2C_addr = 0x48; // The I2C address of the ADS1115 ADC -TIADS1x15Base evADS(evVoltageMultiplier, evAdsGain, evAdsI2C_addr, +TIADS1x15Reader evADS(evVoltageMultiplier, evAdsGain, evAdsI2C_addr, evAdsSupplyVoltage); // Create a single ended External Voltage sensor object with the custom -// TIADS1x15Base +// TIADS1x15Reader TIADS1x15 ads1x15_c(evADSPower, evADSChannel1, -1, evReadsToAvg, &evADS); // Create a voltage variable pointer @@ -1705,21 +1705,21 @@ const int8_t processorAnalogPowerPin = sensorPowerPin; // Power pin const int8_t processorAnalogDataPin = A0; // Analog input pin (processor ADC) const uint8_t processorAnalogNReadings = 1; // Only read one sample -// Create a Processor Analog sensor object with the default ProcessorAnalogBase +// Create a Processor Analog sensor object with the default ProcessorAnalogReader ProcessorAnalog processorAnalog(processorAnalogPowerPin, processorAnalogDataPin, processorAnalogNReadings); // create a custom analog reader based on the Processor ADC (optional) float processorAnalogMultiplier = 1.0f; // factor for a voltage divider float processorAnalogSupply = 3.3f; // supply voltage of the Processor ADC -ProcessorAnalogBase processorAnalogBaseCustom(processorAnalogMultiplier, +ProcessorAnalogReader processorAnalogReaderCustom(processorAnalogMultiplier, processorAnalogSupply); -// Create a Processor Analog sensor object with the custom ProcessorAnalogBase +// Create a Processor Analog sensor object with the custom ProcessorAnalogReader ProcessorAnalog processorAnalog_c(processorAnalogPowerPin, processorAnalogDataPin, processorAnalogNReadings, - &processorAnalogBaseCustom); + &processorAnalogReaderCustom); // Create a voltage variable pointer Variable* processorAnalogVolts = new ProcessorAnalog_Voltage( @@ -2401,7 +2401,7 @@ float cyclopsMultiplier = 1.0f; // factor for a voltage divider adsGain_t cyclopsAdsGain = GAIN_ONE; // gain of the ADS1115 float cyclopsAdsSupplyVoltage = 3.3f; // supply voltage of the ADS1115 const uint8_t cyclopsAdsI2C_addr = 0x48; // The I2C address of the ADS1115 ADC -TIADS1x15Base cyclopsADS(cyclopsMultiplier, cyclopsAdsGain, cyclopsAdsI2C_addr, +TIADS1x15Reader cyclopsADS(cyclopsMultiplier, cyclopsAdsGain, cyclopsAdsI2C_addr, cyclopsAdsSupplyVoltage); // Create a Turner Cyclops sensor object with the custom ADS instance @@ -2412,7 +2412,7 @@ TurnerCyclops cyclops_c(cyclopsPower, cyclopsADSChannel, cyclopsStdConc, // create a custom analog reader based on the Processor ADC (optional) float cyclopsMultiplier2 = 1.0f; // factor for a voltage divider float cyclopsSupply2 = 3.3f; // supply voltage of the Processor ADC -ProcessorAnalogBase cyclopsADS2(cyclopsMultiplier2, cyclopsSupply2); +ProcessorAnalogReader cyclopsADS2(cyclopsMultiplier2, cyclopsSupply2); // Create a Turner Cyclops sensor object with the custom ADS instance TurnerCyclops cyclops_c2(cyclopsPower, cyclopsADSChannel, cyclopsStdConc, @@ -2461,10 +2461,10 @@ float ttPlusMultiplier = 1.0f; // factor for a voltage divider adsGain_t ttPlusAdsGain = GAIN_ONE; // gain of the ADS1115 float ttPlusAdsSupply = 3.3f; // supply voltage of the ADS1115 const uint8_t ttPlusI2C_addr = 0x48; // The I2C address of the ADS1115 ADC -TIADS1x15Base ttPlusADS(ttPlusMultiplier, ttPlusAdsGain, ttPlusI2C_addr, +TIADS1x15Reader ttPlusADS(ttPlusMultiplier, ttPlusAdsGain, ttPlusI2C_addr, ttPlusAdsSupply); -// Create a Turner Turbidity Plus sensor object with the custom TIADS1x15Base +// Create a Turner Turbidity Plus sensor object with the custom TIADS1x15Reader TurnerTurbidityPlus turbidityPlus_c(ttPlusPower, ttPlusWiper, ttPlusChannel1, ttPlusChannel2, ttPlusStdConc, ttPlusStdVolt, ttPlusBlankVolt, @@ -2537,7 +2537,7 @@ Variable* analogEc_spcond = new Variable( // create a custom analog reader based on the Processor ADC (optional) float analogECMultiplier = 1.0f; // factor for a voltage divider float analogECSupply = 3.3f; // supply voltage of the Processor ADC -ProcessorAnalogBase analogECADS(analogECMultiplier, analogECSupply); +ProcessorAnalogReader analogECADS(analogECMultiplier, analogECSupply); // Create an AnalogElecConductivity sensor object with the custom ADS instance AnalogElecConductivity analogEC_c(analogECPower, analogECData, diff --git a/src/VariableArray.cpp b/src/VariableArray.cpp index 8d3e23572..5b8001e44 100644 --- a/src/VariableArray.cpp +++ b/src/VariableArray.cpp @@ -18,7 +18,8 @@ VariableArray::VariableArray(uint8_t variableCount, Variable* variableList[], : arrayOfVars(variableList), _variableCount(variableCount) { // Match UUIDs first, before populating sensor list - if (uuids) matchUUIDs(uuids); + if (uuids && arrayOfVars != nullptr && _variableCount > 0) + matchUUIDs(uuids); populateSensorList(); } diff --git a/src/sensors/AlphasenseCO2.cpp b/src/sensors/AlphasenseCO2.cpp index 83a680c18..78c83e60d 100644 --- a/src/sensors/AlphasenseCO2.cpp +++ b/src/sensors/AlphasenseCO2.cpp @@ -19,7 +19,7 @@ AlphasenseCO2::AlphasenseCO2(int8_t powerPin, int8_t analogChannel, int8_t analogReferenceChannel, uint8_t measurementsToAverage, - AnalogVoltageBase* analogVoltageReader) + AnalogVoltageReader* analogVoltageReader) : Sensor("AlphasenseCO2", ALPHASENSE_CO2_NUM_VARIABLES, ALPHASENSE_CO2_WARM_UP_TIME_MS, ALPHASENSE_CO2_STABILIZATION_TIME_MS, @@ -30,7 +30,7 @@ AlphasenseCO2::AlphasenseCO2(int8_t powerPin, int8_t analogChannel, // If no analog voltage reader was provided, create a default one _analogVoltageReader( analogVoltageReader == nullptr - ? new TIADS1x15Base(ALPHASENSE_CO2_VOLTAGE_MULTIPLIER) + ? new TIADS1x15Reader(ALPHASENSE_CO2_VOLTAGE_MULTIPLIER) : analogVoltageReader), _ownsAnalogVoltageReader(analogVoltageReader == nullptr) {} @@ -89,7 +89,7 @@ bool AlphasenseCO2::addSingleMeasurementResult() { MS_DBG(getSensorNameAndLocation(), F("is reporting:")); - // Read differential voltage using the AnalogVoltageBase interface + // Read differential voltage using the AnalogVoltageReader interface bool success = _analogVoltageReader->readVoltageDifferential( _dataPin, _analogReferenceChannel, adcVoltage); diff --git a/src/sensors/AlphasenseCO2.h b/src/sensors/AlphasenseCO2.h index 043f1fc79..079e08c8b 100644 --- a/src/sensors/AlphasenseCO2.h +++ b/src/sensors/AlphasenseCO2.h @@ -96,7 +96,7 @@ #include "SensorBase.h" // Forward declaration -class AnalogVoltageBase; +class AnalogVoltageReader; /** @ingroup sensor_alphasense_co2 */ /**@{*/ @@ -266,8 +266,8 @@ class AlphasenseCO2 : public Sensor { * and the analog data and reference channels. * * By default, this constructor will internally create a default - * AnalogVoltageBase implementation for voltage readings, but a pointer to - * a custom AnalogVoltageBase object can be passed in if desired. + * AnalogVoltageReader implementation for voltage readings, but a pointer to + * a custom AnalogVoltageReader object can be passed in if desired. * * @param powerPin The pin on the mcu controlling power to the * Alphasense CO2 sensor. Use -1 if it is continuously powered. @@ -283,7 +283,7 @@ class AlphasenseCO2 : public Sensor { * @param measurementsToAverage The number of measurements to take and * average before giving a "final" result from the sensor; optional with a * default value of 7. - * @param analogVoltageReader Pointer to an AnalogVoltageBase object for + * @param analogVoltageReader Pointer to an AnalogVoltageReader object for * voltage measurements. Pass nullptr (the default) to have the constructor * internally create and own an analog voltage reader. For backward * compatibility, the default reader uses a TI ADS1115 or ADS1015. If a @@ -300,7 +300,7 @@ class AlphasenseCO2 : public Sensor { AlphasenseCO2(int8_t powerPin, int8_t analogChannel, int8_t analogReferenceChannel, uint8_t measurementsToAverage = 7, - AnalogVoltageBase* analogVoltageReader = nullptr); + AnalogVoltageReader* analogVoltageReader = nullptr); /** * @brief Destroy the AlphasenseCO2 object */ @@ -330,7 +330,7 @@ class AlphasenseCO2 : public Sensor { */ int8_t _analogReferenceChannel = -1; /// @brief Pointer to analog voltage reader - AnalogVoltageBase* _analogVoltageReader = nullptr; + AnalogVoltageReader* _analogVoltageReader = nullptr; /// @brief Flag to track if this object owns the analog voltage reader and /// should delete it in the destructor bool _ownsAnalogVoltageReader = false; diff --git a/src/sensors/AnalogElecConductivity.cpp b/src/sensors/AnalogElecConductivity.cpp index fc5cf5f0d..75ffa4b74 100644 --- a/src/sensors/AnalogElecConductivity.cpp +++ b/src/sensors/AnalogElecConductivity.cpp @@ -16,7 +16,7 @@ // For Mayfly version; the battery resistor depends on it AnalogElecConductivity::AnalogElecConductivity( int8_t powerPin, int8_t dataPin, float Rseries_ohms, float sensorEC_Konst, - uint8_t measurementsToAverage, AnalogVoltageBase* analogVoltageReader) + uint8_t measurementsToAverage, AnalogVoltageReader* analogVoltageReader) : Sensor("AnalogElecConductivity", ANALOGELECCONDUCTIVITY_NUM_VARIABLES, ANALOGELECCONDUCTIVITY_WARM_UP_TIME_MS, ANALOGELECCONDUCTIVITY_STABILIZATION_TIME_MS, @@ -26,7 +26,7 @@ AnalogElecConductivity::AnalogElecConductivity( _sensorEC_Konst(sensorEC_Konst), // If no analog voltage reader was provided, create a default one _analogVoltageReader(analogVoltageReader == nullptr - ? new ProcessorAnalogBase() + ? new ProcessorAnalogReader() : analogVoltageReader), _ownsAnalogVoltageReader(analogVoltageReader == nullptr) {} @@ -96,7 +96,7 @@ bool AnalogElecConductivity::addSingleMeasurementResult() { MS_DBG(getSensorNameAndLocation(), F("is reporting:")); - // Read the analog voltage using the AnalogVoltageBase interface + // Read the analog voltage using the AnalogVoltageReader interface bool success = _analogVoltageReader->readVoltageSingleEnded(_dataPin, adcVoltage); diff --git a/src/sensors/AnalogElecConductivity.h b/src/sensors/AnalogElecConductivity.h index ce7582d90..dd34be100 100644 --- a/src/sensors/AnalogElecConductivity.h +++ b/src/sensors/AnalogElecConductivity.h @@ -288,7 +288,7 @@ static_assert( /**@}*/ // Forward declaration -class AnalogVoltageBase; +class AnalogVoltageReader; /** * @brief Class for the analog [Electrical Conductivity monitor](@ref @@ -315,7 +315,7 @@ class AnalogElecConductivity : public Sensor { * be calibrated for each specific sensing setup. * @param measurementsToAverage The number of measurements to average; * optional with default value of 1. - * @param analogVoltageReader Pointer to an AnalogVoltageBase object for + * @param analogVoltageReader Pointer to an AnalogVoltageReader object for * voltage measurements. Pass nullptr (the default) to have the constructor * internally create and own an analog voltage reader. For backward * compatibility, the default reader uses the processor's internal ADC. If a @@ -327,7 +327,7 @@ class AnalogElecConductivity : public Sensor { float Rseries_ohms = ANALOGELECCONDUCTIVITY_RSERIES_OHMS, float sensorEC_Konst = ANALOGELECCONDUCTIVITY_KONST, uint8_t measurementsToAverage = 1, - AnalogVoltageBase* analogVoltageReader = nullptr); + AnalogVoltageReader* analogVoltageReader = nullptr); /** * @brief Destroy the AnalogElecConductivity object. @@ -386,7 +386,7 @@ class AnalogElecConductivity : public Sensor { /// @brief the cell constant for the circuit float _sensorEC_Konst = ANALOGELECCONDUCTIVITY_KONST; /// @brief Pointer to analog voltage reader - AnalogVoltageBase* _analogVoltageReader = nullptr; + AnalogVoltageReader* _analogVoltageReader = nullptr; /// @brief Flag to track if this object owns the analog voltage reader and /// should delete it in the destructor bool _ownsAnalogVoltageReader = false; diff --git a/src/sensors/AnalogVoltageBase.h b/src/sensors/AnalogVoltageReader.h similarity index 92% rename from src/sensors/AnalogVoltageBase.h rename to src/sensors/AnalogVoltageReader.h index 499cd964a..d6997ef8b 100644 --- a/src/sensors/AnalogVoltageBase.h +++ b/src/sensors/AnalogVoltageReader.h @@ -1,12 +1,12 @@ /** - * @file AnalogVoltageBase.h + * @file AnalogVoltageReader.h * @copyright Stroud Water Research Center * Part of the EnviroDIY ModularSensors library for Arduino. * This library is published under the BSD-3 license. * @author Sara Geleskie Damiano * - * @brief Contains the AnalogVoltageBase abstract class for providing a unified - * interface for analog voltage reading sensors. + * @brief Contains the AnalogVoltageReader abstract class for providing a + * unified interface for analog voltage reading sensors. * * This abstract base class provides a common interface for sensors that can * read single-ended analog voltages, either through external ADCs (like TI @@ -14,8 +14,8 @@ */ // Header Guards -#ifndef SRC_SENSORS_ANALOGVOLTAGEBASE_H_ -#define SRC_SENSORS_ANALOGVOLTAGEBASE_H_ +#ifndef SRC_SENSORS_ANALOGVOLTAGEREADER_H_ +#define SRC_SENSORS_ANALOGVOLTAGEREADER_H_ // Include the library config before anything else #include "ModSensorConfig.h" @@ -27,8 +27,8 @@ #include "KnownProcessors.h" // Define the print label[s] for the debugger -#ifdef MS_ANALOGVOLTAGEBASE_DEBUG -#define MS_DEBUGGING_STD "AnalogVoltageBase" +#ifdef MS_ANALOGVOLTAGEREADER_DEBUG +#define MS_DEBUGGING_STD "AnalogVoltageReader" #endif // Include the debugger @@ -49,16 +49,16 @@ * - getAnalogLocation() to provide sensor location identification, and * - calculateAnalogResolutionVolts() to compute voltage resolution. */ -class AnalogVoltageBase { +class AnalogVoltageReader { public: /** - * @brief Construct a new AnalogVoltageBase object + * @brief Construct a new AnalogVoltageReader object * * @param voltageMultiplier The voltage multiplier for any voltage dividers * @param supplyVoltage The supply/operating voltage for the analog system */ - explicit AnalogVoltageBase(float voltageMultiplier = 1.0f, - float supplyVoltage = OPERATING_VOLTAGE) + explicit AnalogVoltageReader(float voltageMultiplier = 1.0f, + float supplyVoltage = OPERATING_VOLTAGE) : // NOTE: These clamps are intentionally silent — Serial/MS_DBG is NOT // safe to call during construction (the Serial object may not be // initialized yet on Arduino targets). Use setSupplyVoltage() at @@ -68,9 +68,9 @@ class AnalogVoltageBase { _supplyVoltage((supplyVoltage > 0.0f) ? supplyVoltage : OPERATING_VOLTAGE) {} /** - * @brief Destroy the AnalogVoltageBase object + * @brief Destroy the AnalogVoltageReader object */ - virtual ~AnalogVoltageBase() = default; + virtual ~AnalogVoltageReader() = default; /** * @brief Initialize the analog voltage reading system @@ -227,4 +227,4 @@ class AnalogVoltageBase { float _supplyVoltage; }; -#endif // SRC_SENSORS_ANALOGVOLTAGEBASE_H_ +#endif // SRC_SENSORS_ANALOGVOLTAGEREADER_H_ diff --git a/src/sensors/ApogeeSQ212.cpp b/src/sensors/ApogeeSQ212.cpp index a5c79359f..f582839a1 100644 --- a/src/sensors/ApogeeSQ212.cpp +++ b/src/sensors/ApogeeSQ212.cpp @@ -19,13 +19,13 @@ // The constructor - need the power pin and the data pin ApogeeSQ212::ApogeeSQ212(int8_t powerPin, int8_t analogChannel, uint8_t measurementsToAverage, - AnalogVoltageBase* analogVoltageReader) + AnalogVoltageReader* analogVoltageReader) : Sensor("ApogeeSQ212", SQ212_NUM_VARIABLES, SQ212_WARM_UP_TIME_MS, SQ212_STABILIZATION_TIME_MS, SQ212_MEASUREMENT_TIME_MS, powerPin, analogChannel, measurementsToAverage, SQ212_INC_CALC_VARIABLES), // If no analog voltage reader was provided, create a default one _analogVoltageReader(analogVoltageReader == nullptr - ? new TIADS1x15Base() + ? new TIADS1x15Reader() : analogVoltageReader), _ownsAnalogVoltageReader(analogVoltageReader == nullptr) {} @@ -83,9 +83,9 @@ bool ApogeeSQ212::addSingleMeasurementResult() { MS_DBG(getSensorNameAndLocation(), F("is reporting:")); - // Read the single-ended analog voltage using the AnalogVoltageBase + // Read the single-ended analog voltage using the AnalogVoltageReader // interface. - // NOTE: All implementations of the AnalogVoltageBase class validate both + // NOTE: All implementations of the AnalogVoltageReader class validate both // the input channel and the resulting voltage, so we can trust that a // successful read will give us a valid voltage value to work with. bool success = _analogVoltageReader->readVoltageSingleEnded(_dataPin, diff --git a/src/sensors/ApogeeSQ212.h b/src/sensors/ApogeeSQ212.h index 0bb339038..74c955219 100644 --- a/src/sensors/ApogeeSQ212.h +++ b/src/sensors/ApogeeSQ212.h @@ -93,7 +93,7 @@ #include "SensorBase.h" // Forward declaration -class AnalogVoltageBase; +class AnalogVoltageReader; /** @ingroup sensor_sq212 */ /**@{*/ @@ -244,22 +244,22 @@ class ApogeeSQ212 : public Sensor { * analog data channel. * * By default, this constructor will internally create a default - * AnalogVoltageBase implementation for voltage readings, but a pointer to - * a custom AnalogVoltageBase object can be passed in if desired. + * AnalogVoltageReader implementation for voltage readings, but a pointer to + * a custom AnalogVoltageReader object can be passed in if desired. * * @param powerPin The pin on the mcu controlling power to the Apogee * SQ-212. Use -1 if it is continuously powered. * - The SQ-212 requires 3.3 to 24 V DC; current draw 10 µA * @param analogChannel The analog data channel or processor pin for voltage * measurements. The significance of the channel number depends on the - * specific AnalogVoltageBase implementation used for voltage readings. For + * specific AnalogVoltageReader implementation used for voltage readings. For * example, with the TI ADS1x15, this would be the ADC channel (0-3) that * the sensor is connected to. Negative or invalid channel numbers are not * clamped and will cause the reading to fail and emit a warning. * @param measurementsToAverage The number of measurements to take and * average before giving a "final" result from the sensor; optional with a * default value of 1. - * @param analogVoltageReader Pointer to an AnalogVoltageBase object for + * @param analogVoltageReader Pointer to an AnalogVoltageReader object for * voltage measurements. Pass nullptr (the default) to have the constructor * internally create and own an analog voltage reader. For backward * compatibility, the default reader uses a TI ADS1115 or ADS1015. If a @@ -276,7 +276,7 @@ class ApogeeSQ212 : public Sensor { */ ApogeeSQ212(int8_t powerPin, int8_t analogChannel, uint8_t measurementsToAverage = 1, - AnalogVoltageBase* analogVoltageReader = nullptr); + AnalogVoltageReader* analogVoltageReader = nullptr); /** * @brief Destroy the ApogeeSQ212 object * @@ -302,7 +302,7 @@ class ApogeeSQ212 : public Sensor { private: /// @brief Pointer to analog voltage reader - AnalogVoltageBase* _analogVoltageReader = nullptr; + AnalogVoltageReader* _analogVoltageReader = nullptr; /// @brief Flag to track if this object owns the analog voltage reader and /// should delete it in the destructor bool _ownsAnalogVoltageReader = false; diff --git a/src/sensors/CampbellOBS3.cpp b/src/sensors/CampbellOBS3.cpp index d0f160187..5a56f84db 100644 --- a/src/sensors/CampbellOBS3.cpp +++ b/src/sensors/CampbellOBS3.cpp @@ -17,7 +17,7 @@ CampbellOBS3::CampbellOBS3(int8_t powerPin, int8_t analogChannel, float x2_coeff_A, float x1_coeff_B, float x0_coeff_C, uint8_t measurementsToAverage, - AnalogVoltageBase* analogVoltageReader) + AnalogVoltageReader* analogVoltageReader) : Sensor("CampbellOBS3", OBS3_NUM_VARIABLES, OBS3_WARM_UP_TIME_MS, OBS3_STABILIZATION_TIME_MS, OBS3_MEASUREMENT_TIME_MS, powerPin, analogChannel, measurementsToAverage, OBS3_INC_CALC_VARIABLES), @@ -26,7 +26,7 @@ CampbellOBS3::CampbellOBS3(int8_t powerPin, int8_t analogChannel, _x0_coeff_C(x0_coeff_C), // If no analog voltage reader was provided, create a default one _analogVoltageReader(analogVoltageReader == nullptr - ? new TIADS1x15Base() + ? new TIADS1x15Reader() : analogVoltageReader), _ownsAnalogVoltageReader(analogVoltageReader == nullptr) {} @@ -88,9 +88,9 @@ bool CampbellOBS3::addSingleMeasurementResult() { MS_DBG(getSensorNameAndLocation(), F("is reporting:")); - // Read the single-ended analog voltage using the AnalogVoltageBase + // Read the single-ended analog voltage using the AnalogVoltageReader // interface. - // NOTE: All implementations of the AnalogVoltageBase class validate both + // NOTE: All implementations of the AnalogVoltageReader class validate both // the input channel and the resulting voltage, so we can trust that a // successful read will give us a valid voltage value to work with. bool success = _analogVoltageReader->readVoltageSingleEnded(_dataPin, diff --git a/src/sensors/CampbellOBS3.h b/src/sensors/CampbellOBS3.h index e085174bf..967350ad7 100644 --- a/src/sensors/CampbellOBS3.h +++ b/src/sensors/CampbellOBS3.h @@ -84,7 +84,7 @@ #include "SensorBase.h" // Forward declaration -class AnalogVoltageBase; +class AnalogVoltageReader; /** @ingroup sensor_obs3 */ /**@{*/ @@ -236,8 +236,8 @@ class CampbellOBS3 : public Sensor { * analog data channel, and the calibration info. * * By default, this constructor will internally create a default - * AnalogVoltageBase implementation for voltage readings, but a pointer to - * a custom AnalogVoltageBase object can be passed in if desired. + * AnalogVoltageReader implementation for voltage readings, but a pointer to + * a custom AnalogVoltageReader object can be passed in if desired. * * @param powerPin The pin on the mcu controlling power to the OBS3+ * Use -1 if it is continuously powered. @@ -245,7 +245,7 @@ class CampbellOBS3 : public Sensor { * between measurements. * @param analogChannel The analog data channel or processor pin for voltage * measurements. The significance of the channel number depends on the - * specific AnalogVoltageBase implementation used for voltage readings. For + * specific AnalogVoltageReader implementation used for voltage readings. For * example, with the default TI ADS1x15, this would be the ADC channel (0-3) * that the sensor is connected to. Negative or invalid channel numbers are * not clamped and will cause the reading to fail and emit a warning. @@ -255,7 +255,7 @@ class CampbellOBS3 : public Sensor { * @param measurementsToAverage The number of measurements to take and * average before giving a "final" result from the sensor; optional with a * default value of 1. - * @param analogVoltageReader Pointer to an AnalogVoltageBase object for + * @param analogVoltageReader Pointer to an AnalogVoltageReader object for * voltage measurements. Pass nullptr (the default) to have the constructor * internally create and own an analog voltage reader. For backward * compatibility, the default reader uses a TI ADS1115 or ADS1015. If a @@ -273,7 +273,7 @@ class CampbellOBS3 : public Sensor { CampbellOBS3(int8_t powerPin, int8_t analogChannel, float x2_coeff_A, float x1_coeff_B, float x0_coeff_C, uint8_t measurementsToAverage = 1, - AnalogVoltageBase* analogVoltageReader = nullptr); + AnalogVoltageReader* analogVoltageReader = nullptr); /** * @brief Destroy the Campbell OBS3 object */ @@ -302,7 +302,7 @@ class CampbellOBS3 : public Sensor { /// @brief The x^0 (C) calibration coefficient float _x0_coeff_C; /// @brief Pointer to analog voltage reader - AnalogVoltageBase* _analogVoltageReader = nullptr; + AnalogVoltageReader* _analogVoltageReader = nullptr; /// @brief Flag to track if this object owns the analog voltage reader and /// should delete it in the destructor bool _ownsAnalogVoltageReader = false; diff --git a/src/sensors/EverlightALSPT19.cpp b/src/sensors/EverlightALSPT19.cpp index ed55ea91d..f7b96fd8a 100644 --- a/src/sensors/EverlightALSPT19.cpp +++ b/src/sensors/EverlightALSPT19.cpp @@ -15,7 +15,7 @@ EverlightALSPT19::EverlightALSPT19(int8_t powerPin, int8_t dataPin, float alsSupplyVoltage, float loadResistor, uint8_t measurementsToAverage, - AnalogVoltageBase* analogVoltageReader) + AnalogVoltageReader* analogVoltageReader) : Sensor("Everlight ALS-PT19", ALSPT19_NUM_VARIABLES, ALSPT19_WARM_UP_TIME_MS, ALSPT19_STABILIZATION_TIME_MS, ALSPT19_MEASUREMENT_TIME_MS, powerPin, dataPin, @@ -25,7 +25,7 @@ EverlightALSPT19::EverlightALSPT19(int8_t powerPin, int8_t dataPin, // If no analog voltage reader was provided, create a default one _loadResistor(loadResistor), _analogVoltageReader(analogVoltageReader == nullptr - ? new ProcessorAnalogBase() + ? new ProcessorAnalogReader() : analogVoltageReader), _ownsAnalogVoltageReader(analogVoltageReader == nullptr) {} @@ -34,7 +34,7 @@ EverlightALSPT19::EverlightALSPT19(int8_t powerPin, int8_t dataPin, defined(BUILT_IN_ALS_LOADING_RESISTANCE)) || \ defined(DOXYGEN) EverlightALSPT19::EverlightALSPT19(uint8_t measurementsToAverage, - AnalogVoltageBase* analogVoltageReader) + AnalogVoltageReader* analogVoltageReader) : EverlightALSPT19(BUILT_IN_ALS_POWER_PIN, BUILT_IN_ALS_DATA_PIN, BUILT_IN_ALS_SUPPLY_VOLTAGE, BUILT_IN_ALS_LOADING_RESISTANCE, measurementsToAverage, @@ -100,9 +100,9 @@ bool EverlightALSPT19::addSingleMeasurementResult() { MS_DBG(getSensorNameAndLocation(), F("is reporting:")); - // Read the single-ended analog voltage using the AnalogVoltageBase + // Read the single-ended analog voltage using the AnalogVoltageReader // interface. - // NOTE: All implementations of the AnalogVoltageBase class validate both + // NOTE: All implementations of the AnalogVoltageReader class validate both // the input channel and the resulting voltage, so we can trust that a // successful read will give us a valid voltage value to work with. bool success = _analogVoltageReader->readVoltageSingleEnded(_dataPin, diff --git a/src/sensors/EverlightALSPT19.h b/src/sensors/EverlightALSPT19.h index 12cba2be1..19fe7278e 100644 --- a/src/sensors/EverlightALSPT19.h +++ b/src/sensors/EverlightALSPT19.h @@ -34,8 +34,8 @@ * lux from the sensor * * @section sensor_alspt19_ctor Sensor Constructors - * {{ @ref EverlightALSPT19::EverlightALSPT19(uint8_t, AnalogVoltageBase*) }} - * {{ @ref EverlightALSPT19::EverlightALSPT19(int8_t, int8_t, float, float, uint8_t, AnalogVoltageBase*) }} + * {{ @ref EverlightALSPT19::EverlightALSPT19(uint8_t, AnalogVoltageReader*) }} + * {{ @ref EverlightALSPT19::EverlightALSPT19(int8_t, int8_t, float, float, uint8_t, AnalogVoltageReader*) }} * * @section sensor_alspt19_examples Example Code * @@ -233,7 +233,7 @@ static_assert(ALSPT19_UA_PER_1000LUX > 0, /**@}*/ // Forward declaration -class AnalogVoltageBase; +class AnalogVoltageReader; /* clang-format off */ /** @@ -255,13 +255,13 @@ class EverlightALSPT19 : public Sensor { * - i.e., A1. * @param alsSupplyVoltage The power supply voltage (in volts) of the * ALS-PT19. This does not have to be the same as the board operating - * voltage or the supply voltage of the AnalogVoltageBase reader. + * voltage or the supply voltage of the AnalogVoltageReader reader. * This is used to clamp the light values when the sensor is over-saturated. * @param loadResistor The size of the loading resistor, in kiloohms (kΩ). * @param measurementsToAverage The number of measurements to take and * average before giving a "final" result from the sensor; optional with a * default value of 10. - * @param analogVoltageReader Pointer to an AnalogVoltageBase object for + * @param analogVoltageReader Pointer to an AnalogVoltageReader object for * voltage measurements. Pass nullptr (the default) to have the constructor * internally create and own an analog voltage reader. For backward * compatibility, the default reader uses the processor's internal ADC. If a @@ -270,7 +270,7 @@ class EverlightALSPT19 : public Sensor { */ EverlightALSPT19(int8_t powerPin, int8_t dataPin, float alsSupplyVoltage, float loadResistor, uint8_t measurementsToAverage = 10, - AnalogVoltageBase* analogVoltageReader = nullptr); + AnalogVoltageReader* analogVoltageReader = nullptr); #if (defined(BUILT_IN_ALS_POWER_PIN) && defined(BUILT_IN_ALS_DATA_PIN) && \ defined(BUILT_IN_ALS_SUPPLY_VOLTAGE) && \ @@ -287,7 +287,7 @@ class EverlightALSPT19 : public Sensor { * @param measurementsToAverage The number of measurements to take and * average before giving a "final" result from the sensor; optional with a * default value of 10. - * @param analogVoltageReader Pointer to an AnalogVoltageBase object for + * @param analogVoltageReader Pointer to an AnalogVoltageReader object for * voltage measurements. Pass nullptr (the default) to have the constructor * internally create and own an analog voltage reader. For backward * compatibility, the default reader uses the processor's internal ADC. If a @@ -295,7 +295,7 @@ class EverlightALSPT19 : public Sensor { * ensure its lifetime exceeds that of this object. */ explicit EverlightALSPT19(uint8_t measurementsToAverage = 10, - AnalogVoltageBase* analogVoltageReader = nullptr); + AnalogVoltageReader* analogVoltageReader = nullptr); #endif /** * @brief Destroy the EverlightALSPT19 object. @@ -326,7 +326,7 @@ class EverlightALSPT19 : public Sensor { /// @brief The loading resistance float _loadResistor = 0.0f; /// @brief Pointer to analog voltage reader - AnalogVoltageBase* _analogVoltageReader = nullptr; + AnalogVoltageReader* _analogVoltageReader = nullptr; /// @brief Flag to track if this object owns the analog voltage reader and /// should delete it in the destructor bool _ownsAnalogVoltageReader = false; diff --git a/src/sensors/ProcessorAnalog.cpp b/src/sensors/ProcessorAnalog.cpp index 516806d3c..dcf9b1022 100644 --- a/src/sensors/ProcessorAnalog.cpp +++ b/src/sensors/ProcessorAnalog.cpp @@ -13,25 +13,25 @@ // ============================================================================ -// ProcessorAnalogBase Constructor +// ProcessorAnalogReader Constructor // ============================================================================ -ProcessorAnalogBase::ProcessorAnalogBase(float voltageMultiplier, +ProcessorAnalogReader::ProcessorAnalogReader(float voltageMultiplier, float operatingVoltage) - : AnalogVoltageBase(voltageMultiplier, operatingVoltage) {} + : AnalogVoltageReader(voltageMultiplier, operatingVoltage) {} // ============================================================================ -// ProcessorAnalogBase Functions +// ProcessorAnalogReader Functions // ============================================================================ -bool ProcessorAnalogBase::begin() { +bool ProcessorAnalogReader::begin() { // For processor analog systems, no special initialization is required // beyond what is done in the constructor return true; } -bool ProcessorAnalogBase::readVoltageSingleEnded(int8_t analogChannel, +bool ProcessorAnalogReader::readVoltageSingleEnded(int8_t analogChannel, float& resultValue) { // Compile-time validation of ADC configuration static_assert(PROCESSOR_ADC_MAX > 0, @@ -68,7 +68,7 @@ bool ProcessorAnalogBase::readVoltageSingleEnded(int8_t analogChannel, return true; } -String ProcessorAnalogBase::getAnalogLocation( +String ProcessorAnalogReader::getAnalogLocation( int8_t analogChannel, int8_t /*analogReferenceChannel*/) { String sensorLocation; sensorLocation += F("ProcessorAnalog_Pin"); @@ -76,7 +76,7 @@ String ProcessorAnalogBase::getAnalogLocation( return sensorLocation; } -bool ProcessorAnalogBase::readVoltageDifferential( +bool ProcessorAnalogReader::readVoltageDifferential( int8_t /*analogChannel*/, int8_t /*analogReferenceChannel*/, float& resultValue) { // ProcessorAnalog does not support differential measurements @@ -85,7 +85,7 @@ bool ProcessorAnalogBase::readVoltageDifferential( return false; } -float ProcessorAnalogBase::calculateAnalogResolutionVolts() { +float ProcessorAnalogReader::calculateAnalogResolutionVolts() { // Use the configured processor ADC resolution uint8_t resolutionBits = MS_PROCESSOR_ADC_RESOLUTION; @@ -125,7 +125,7 @@ float ProcessorAnalogBase::calculateAnalogResolutionVolts() { // measurements to average, with an optional external analog reader ProcessorAnalog::ProcessorAnalog(int8_t powerPin, int8_t dataPin, uint8_t measurementsToAverage, - ProcessorAnalogBase* analogVoltageReader) + ProcessorAnalogReader* analogVoltageReader) : Sensor("ProcessorAnalog", PROCESSOR_ANALOG_NUM_VARIABLES, PROCESSOR_ANALOG_WARM_UP_TIME_MS, PROCESSOR_ANALOG_STABILIZATION_TIME_MS, @@ -133,7 +133,7 @@ ProcessorAnalog::ProcessorAnalog(int8_t powerPin, int8_t dataPin, measurementsToAverage, PROCESSOR_ANALOG_INC_CALC_VARIABLES), // If no analog base provided, create one with default settings _analogVoltageReader(analogVoltageReader == nullptr - ? new ProcessorAnalogBase() + ? new ProcessorAnalogReader() : analogVoltageReader), _ownsAnalogVoltageReader(analogVoltageReader == nullptr) {} diff --git a/src/sensors/ProcessorAnalog.h b/src/sensors/ProcessorAnalog.h index 5c0f8a620..bfa20cc0c 100644 --- a/src/sensors/ProcessorAnalog.h +++ b/src/sensors/ProcessorAnalog.h @@ -76,7 +76,7 @@ // Include other in-library and external dependencies #include "VariableBase.h" #include "SensorBase.h" -#include "AnalogVoltageBase.h" +#include "AnalogVoltageReader.h" /** @ingroup sensor_processor_analog */ /**@{*/ @@ -157,16 +157,16 @@ /**@}*/ /** - * @brief Processor analog base class that inherits from AnalogVoltageBase + * @brief Processor analog base class that inherits from AnalogVoltageReader * * This class provides processor-specific analog functionality on top of the - * generic AnalogVoltageBase class. It handles processor ADC configuration and + * generic AnalogVoltageReader class. It handles processor ADC configuration and * processor-based analog voltage reads for requested channels. */ -class ProcessorAnalogBase : public AnalogVoltageBase { +class ProcessorAnalogReader : public AnalogVoltageReader { public: /** - * @brief Construct a new ProcessorAnalogBase object + * @brief Construct a new ProcessorAnalogReader object * * @param voltageMultiplier Any multiplier needed to convert raw battery * readings from `analogRead()` into true battery values based on any @@ -174,13 +174,13 @@ class ProcessorAnalogBase : public AnalogVoltageBase { * @param operatingVoltage The processor's operating voltage; most * likely 3.3 or 5. */ - ProcessorAnalogBase(float voltageMultiplier = 1.0f, + ProcessorAnalogReader(float voltageMultiplier = 1.0f, float operatingVoltage = OPERATING_VOLTAGE); /** - * @brief Destroy the ProcessorAnalogBase object + * @brief Destroy the ProcessorAnalogReader object */ - ~ProcessorAnalogBase() override = default; + ~ProcessorAnalogReader() override = default; /** * @brief Initialize the processor analog system @@ -260,13 +260,13 @@ class ProcessorAnalog : public Sensor { * @param measurementsToAverage The number of measurements to take and * average before giving a "final" result from the sensor; optional with a * default value of 1. - * @param analogVoltageReader Pointer to ProcessorAnalogBase object for + * @param analogVoltageReader Pointer to ProcessorAnalogReader object for * analog functionality. If nullptr (default), creates a new - * ProcessorAnalogBase with default settings. + * ProcessorAnalogReader with default settings. */ ProcessorAnalog(int8_t powerPin, int8_t dataPin, - uint8_t measurementsToAverage = 1, - ProcessorAnalogBase* analogVoltageReader = nullptr); + uint8_t measurementsToAverage = 1, + ProcessorAnalogReader* analogVoltageReader = nullptr); /** * @brief Destroy the Processor Analog object */ @@ -287,10 +287,10 @@ class ProcessorAnalog : public Sensor { private: /** - * @brief Pointer to the ProcessorAnalogBase object providing analog + * @brief Pointer to the ProcessorAnalogReader object providing analog * functionality */ - ProcessorAnalogBase* _analogVoltageReader = nullptr; + ProcessorAnalogReader* _analogVoltageReader = nullptr; /** * @brief Whether this object owns the _analogVoltageReader pointer and diff --git a/src/sensors/TIADS1x15.cpp b/src/sensors/TIADS1x15.cpp index b7c9c8835..35cd3e4e9 100644 --- a/src/sensors/TIADS1x15.cpp +++ b/src/sensors/TIADS1x15.cpp @@ -17,14 +17,14 @@ // ============================================================================ -// TIADS1x15Base Constructors +// TIADS1x15Reader Constructors // ============================================================================ // Constructor with TwoWire instance -TIADS1x15Base::TIADS1x15Base(TwoWire* theI2C, float voltageMultiplier, +TIADS1x15Reader::TIADS1x15Reader(TwoWire* theI2C, float voltageMultiplier, adsGain_t adsGain, uint8_t i2cAddress, float adsSupplyVoltage, uint16_t adsDataRate) - : AnalogVoltageBase(voltageMultiplier, adsSupplyVoltage), + : AnalogVoltageReader(voltageMultiplier, adsSupplyVoltage), _wire(theI2C != nullptr ? theI2C : &Wire), _i2cAddress(i2cAddress), _adsGain(adsGain), @@ -43,18 +43,18 @@ TIADS1x15Base::TIADS1x15Base(TwoWire* theI2C, float voltageMultiplier, } // Constructor using default Wire instance -TIADS1x15Base::TIADS1x15Base(float voltageMultiplier, adsGain_t adsGain, +TIADS1x15Reader::TIADS1x15Reader(float voltageMultiplier, adsGain_t adsGain, uint8_t i2cAddress, float adsSupplyVoltage, uint16_t adsDataRate) - : TIADS1x15Base(&Wire, voltageMultiplier, adsGain, i2cAddress, + : TIADS1x15Reader(&Wire, voltageMultiplier, adsGain, i2cAddress, adsSupplyVoltage, adsDataRate) {} // ============================================================================ -// TIADS1x15Base Functions +// TIADS1x15Reader Functions // ============================================================================ -bool TIADS1x15Base::begin() { +bool TIADS1x15Reader::begin() { // Initialize the per-instance ADS driver with stored configuration // ADS Library default settings: // - TI ADS1115 (16 bit) @@ -84,7 +84,7 @@ bool TIADS1x15Base::begin() { return success; } -String TIADS1x15Base::getAnalogLocation(int8_t analogChannel, +String TIADS1x15Reader::getAnalogLocation(int8_t analogChannel, int8_t analogReferenceChannel) { String sensorLocation; #ifndef MS_USE_ADS1015 @@ -105,7 +105,7 @@ String TIADS1x15Base::getAnalogLocation(int8_t analogChannel, return sensorLocation; } -bool TIADS1x15Base::readVoltageSingleEnded(int8_t analogChannel, +bool TIADS1x15Reader::readVoltageSingleEnded(int8_t analogChannel, float& resultValue) { bool success = false; int16_t adcCounts = MS_INVALID_VALUE; @@ -168,7 +168,7 @@ bool TIADS1x15Base::readVoltageSingleEnded(int8_t analogChannel, return success; } -bool TIADS1x15Base::readVoltageDifferential(int8_t analogChannel, +bool TIADS1x15Reader::readVoltageDifferential(int8_t analogChannel, int8_t analogReferenceChannel, float& resultValue) { bool success = false; @@ -237,7 +237,7 @@ bool TIADS1x15Base::readVoltageDifferential(int8_t analogChannel, } // Validation function for differential channel pairs -bool TIADS1x15Base::isValidDifferentialPair(int8_t channel1, int8_t channel2) { +bool TIADS1x15Reader::isValidDifferentialPair(int8_t channel1, int8_t channel2) { // Only canonical ordered pairs are valid (lower channel number first) // This ensures consistent polarity: channel1 is positive, channel2 is // negative Valid combinations are: 0-1, 0-3, 1-3, or 2-3 (in that order @@ -249,31 +249,31 @@ bool TIADS1x15Base::isValidDifferentialPair(int8_t channel1, int8_t channel2) { } // Setter and getter methods for ADS gain -void TIADS1x15Base::setADSGain(adsGain_t adsGain) { +void TIADS1x15Reader::setADSGain(adsGain_t adsGain) { // Update the per-instance driver with new gain setting _ads.setGain(adsGain); // Keep cached value in sync _adsGain = adsGain; } -adsGain_t TIADS1x15Base::getADSGain() { +adsGain_t TIADS1x15Reader::getADSGain() { return _ads.getGain(); } // Setter and getter methods for ADS data rate -void TIADS1x15Base::setADSDataRate(uint16_t adsDataRate) { +void TIADS1x15Reader::setADSDataRate(uint16_t adsDataRate) { // Update the per-instance driver with new data rate setting _ads.setDataRate(adsDataRate); // Keep cached value in sync _adsDataRate = adsDataRate; } -uint16_t TIADS1x15Base::getADSDataRate() { +uint16_t TIADS1x15Reader::getADSDataRate() { return _ads.getDataRate(); } -// Override setSupplyVoltage in TIADS1x15Base to validate ADS range -void TIADS1x15Base::setSupplyVoltage(float supplyVoltage) { +// Override setSupplyVoltage in TIADS1x15Reader to validate ADS range +void TIADS1x15Reader::setSupplyVoltage(float supplyVoltage) { // Validate supply voltage range: 0.0V to 5.5V per datasheet if (supplyVoltage < 0.0f) { MS_DBG(F("ADS supply voltage "), supplyVoltage, @@ -288,7 +288,7 @@ void TIADS1x15Base::setSupplyVoltage(float supplyVoltage) { } } -float TIADS1x15Base::calculateAnalogResolutionVolts() { +float TIADS1x15Reader::calculateAnalogResolutionVolts() { // Determine ADC resolution based on model #ifndef MS_USE_ADS1015 uint8_t resolutionBits = 16; // ADS1115 is 16-bit @@ -334,7 +334,7 @@ float TIADS1x15Base::calculateAnalogResolutionVolts() { return resolutionVolts; } -bool TIADS1x15Base::probeI2C() { +bool TIADS1x15Reader::probeI2C() { _wire->beginTransmission(_i2cAddress); if (_wire->endTransmission() != 0) { MS_DBG(F(" I2C communication failed at 0x"), String(_i2cAddress, HEX)); @@ -352,7 +352,7 @@ bool TIADS1x15Base::probeI2C() { TIADS1x15::TIADS1x15(int8_t powerPin, int8_t adsChannel, int8_t analogReferenceChannel, uint8_t measurementsToAverage, - TIADS1x15Base* analogVoltageReader) + TIADS1x15Reader* analogVoltageReader) : Sensor("TIADS1x15", TIADS1X15_NUM_VARIABLES, TIADS1X15_WARM_UP_TIME_MS, TIADS1X15_STABILIZATION_TIME_MS, TIADS1X15_MEASUREMENT_TIME_MS, powerPin, adsChannel, measurementsToAverage, @@ -360,7 +360,7 @@ TIADS1x15::TIADS1x15(int8_t powerPin, int8_t adsChannel, _analogReferenceChannel(analogReferenceChannel), // If no analog voltage reader was provided, create a default one _analogVoltageReader(analogVoltageReader == nullptr - ? new TIADS1x15Base() + ? new TIADS1x15Reader() : analogVoltageReader), _ownsAnalogVoltageReader(analogVoltageReader == nullptr) { // NOTE: We DO NOT validate the channel numbers and pairings in this diff --git a/src/sensors/TIADS1x15.h b/src/sensors/TIADS1x15.h index 9f1a7d193..84d2976ea 100644 --- a/src/sensors/TIADS1x15.h +++ b/src/sensors/TIADS1x15.h @@ -170,7 +170,7 @@ // Include other in-library and external dependencies #include "VariableBase.h" #include "SensorBase.h" -#include "AnalogVoltageBase.h" +#include "AnalogVoltageReader.h" #include /** @ingroup sensor_ads1x15 */ @@ -256,17 +256,17 @@ /**@}*/ /** - * @brief TI ADS1x15 base class that inherits from AnalogVoltageBase + * @brief TI ADS1x15 base class that inherits from AnalogVoltageReader * * This class provides ADS1x15-specific analog functionality on top of - * the generic AnalogVoltageBase class. It handles ADS configuration, + * the generic AnalogVoltageReader class. It handles ADS configuration, * I2C communication, and differential/single-ended measurement modes. */ -class TIADS1x15Base : public AnalogVoltageBase { +class TIADS1x15Reader : public AnalogVoltageReader { public: /** - * @brief Construct a new TIADS1x15Base object + * @brief Construct a new TIADS1x15Reader object * * @param theI2C A TwoWire instance for I2C communication. Due to the * speed and sensitivity requirements of the ADS1x15, only hardware I2C is @@ -278,7 +278,7 @@ class TIADS1x15Base : public AnalogVoltageBase { * @param adsSupplyVoltage The power supply voltage for the ADS1x15 in volts * @param adsDataRate The data rate for the ADS1x15 (samples per second) */ - explicit TIADS1x15Base(TwoWire* theI2C, float voltageMultiplier = 1.0f, + explicit TIADS1x15Reader(TwoWire* theI2C, float voltageMultiplier = 1.0f, adsGain_t adsGain = GAIN_ONE, uint8_t i2cAddress = MS_DEFAULT_ADS1X15_ADDRESS, float adsSupplyVoltage = OPERATING_VOLTAGE, @@ -290,7 +290,7 @@ class TIADS1x15Base : public AnalogVoltageBase { ); /** - * @brief Construct a new TIADS1x15Base object using the default hardware + * @brief Construct a new TIADS1x15Reader object using the default hardware * Wire instance. * * @param voltageMultiplier The voltage multiplier for any voltage dividers @@ -299,7 +299,7 @@ class TIADS1x15Base : public AnalogVoltageBase { * @param adsSupplyVoltage The power supply voltage for the ADS1x15 in volts * @param adsDataRate The data rate for the ADS1x15 (samples per second) */ - explicit TIADS1x15Base(float voltageMultiplier = 1.0f, + explicit TIADS1x15Reader(float voltageMultiplier = 1.0f, adsGain_t adsGain = GAIN_ONE, uint8_t i2cAddress = MS_DEFAULT_ADS1X15_ADDRESS, float adsSupplyVoltage = OPERATING_VOLTAGE, @@ -311,9 +311,9 @@ class TIADS1x15Base : public AnalogVoltageBase { ); /** - * @brief Destroy the TIADS1x15Base object + * @brief Destroy the TIADS1x15Reader object */ - ~TIADS1x15Base() override = default; + ~TIADS1x15Reader() override = default; /** * @brief Initialize the ADS1x15 analog voltage reading system @@ -495,14 +495,14 @@ class TIADS1x15 : public Sensor { * @param measurementsToAverage The number of measurements to take and * average before giving a "final" result from the sensor; optional with a * default value of 1. - * @param analogVoltageReader Pointer to TIADS1x15Base object for ADS - * functionality. If nullptr (default), creates a new TIADS1x15Base with + * @param analogVoltageReader Pointer to TIADS1x15Reader object for ADS + * functionality. If nullptr (default), creates a new TIADS1x15Reader with * default settings. */ TIADS1x15(int8_t powerPin, int8_t adsChannel, - int8_t analogReferenceChannel = -1, - uint8_t measurementsToAverage = 1, - TIADS1x15Base* analogVoltageReader = nullptr); + int8_t analogReferenceChannel = -1, + uint8_t measurementsToAverage = 1, + TIADS1x15Reader* analogVoltageReader = nullptr); /** * @brief Destroy the TIADS1x15 object */ @@ -535,9 +535,9 @@ class TIADS1x15 : public Sensor { int8_t _analogReferenceChannel = -1; /** - * @brief Pointer to the TIADS1x15Base object providing ADS functionality + * @brief Pointer to the TIADS1x15Reader object providing ADS functionality */ - TIADS1x15Base* _analogVoltageReader = nullptr; + TIADS1x15Reader* _analogVoltageReader = nullptr; /** * @brief Whether this object owns the _analogVoltageReader pointer and diff --git a/src/sensors/TurnerCyclops.cpp b/src/sensors/TurnerCyclops.cpp index be3f7c728..005654b62 100644 --- a/src/sensors/TurnerCyclops.cpp +++ b/src/sensors/TurnerCyclops.cpp @@ -17,7 +17,7 @@ TurnerCyclops::TurnerCyclops(int8_t powerPin, int8_t analogChannel, float conc_std, float volt_std, float volt_blank, uint8_t measurementsToAverage, - AnalogVoltageBase* analogVoltageReader) + AnalogVoltageReader* analogVoltageReader) : Sensor("TurnerCyclops", CYCLOPS_NUM_VARIABLES, CYCLOPS_WARM_UP_TIME_MS, CYCLOPS_STABILIZATION_TIME_MS, CYCLOPS_MEASUREMENT_TIME_MS, powerPin, analogChannel, measurementsToAverage, @@ -27,7 +27,7 @@ TurnerCyclops::TurnerCyclops(int8_t powerPin, int8_t analogChannel, _volt_blank(volt_blank), // If no analog voltage reader was provided, create a default one _analogVoltageReader(analogVoltageReader == nullptr - ? new TIADS1x15Base() + ? new TIADS1x15Reader() : analogVoltageReader), _ownsAnalogVoltageReader(analogVoltageReader == nullptr) {} @@ -93,9 +93,9 @@ bool TurnerCyclops::addSingleMeasurementResult() { MS_DBG(getSensorNameAndLocation(), F("is reporting:")); - // Read the single-ended analog voltage using the AnalogVoltageBase + // Read the single-ended analog voltage using the AnalogVoltageReader // interface. - // NOTE: All implementations of the AnalogVoltageBase class validate both + // NOTE: All implementations of the AnalogVoltageReader class validate both // the input channel and the resulting voltage, so we can trust that a // successful read will give us a valid voltage value to work with. bool success = _analogVoltageReader->readVoltageSingleEnded(_dataPin, diff --git a/src/sensors/TurnerCyclops.h b/src/sensors/TurnerCyclops.h index 7502f90d3..b6f179708 100644 --- a/src/sensors/TurnerCyclops.h +++ b/src/sensors/TurnerCyclops.h @@ -167,7 +167,7 @@ #include "SensorBase.h" // Forward declaration -class AnalogVoltageBase; +class AnalogVoltageReader; // Sensor Specific Defines /** @ingroup sensor_cyclops */ @@ -319,8 +319,8 @@ class TurnerCyclops : public Sensor { * analog data channel, and the calibration info. * * By default, this constructor will internally create a default - * AnalogVoltageBase implementation for voltage readings, but a pointer to - * a custom AnalogVoltageBase object can be passed in if desired. + * AnalogVoltageReader implementation for voltage readings, but a pointer to + * a custom AnalogVoltageReader object can be passed in if desired. * * @param powerPin The pin on the mcu controlling power to the Cyclops-7F * Use -1 if it is continuously powered. @@ -328,7 +328,7 @@ class TurnerCyclops : public Sensor { * turned off between measurements. * @param analogChannel The analog data channel or processor pin for voltage * measurements. The significance of the channel number depends on the - * specific AnalogVoltageBase implementation used for voltage readings. For + * specific AnalogVoltageReader implementation used for voltage readings. For * example, with the TI ADS1x15, this would be the ADC channel (0-3) that * the sensor is connected to. Negative or invalid channel numbers are not * clamped and will cause the reading to fail and emit a warning. @@ -344,7 +344,7 @@ class TurnerCyclops : public Sensor { * @param measurementsToAverage The number of measurements to take and * average before giving a "final" result from the sensor; optional with a * default value of 1. - * @param analogVoltageReader Pointer to an AnalogVoltageBase object for + * @param analogVoltageReader Pointer to an AnalogVoltageReader object for * voltage measurements. Pass nullptr (the default) to have the constructor * internally create and own an analog voltage reader. For backward * compatibility, the default reader uses a TI ADS1115 or ADS1015. If a @@ -362,7 +362,7 @@ class TurnerCyclops : public Sensor { TurnerCyclops(int8_t powerPin, int8_t analogChannel, float conc_std, float volt_std, float volt_blank, uint8_t measurementsToAverage = 1, - AnalogVoltageBase* analogVoltageReader = nullptr); + AnalogVoltageReader* analogVoltageReader = nullptr); /** * @brief Destroy the Turner Cyclops object */ @@ -403,7 +403,7 @@ class TurnerCyclops : public Sensor { */ float _volt_blank; /// @brief Pointer to analog voltage reader - AnalogVoltageBase* _analogVoltageReader = nullptr; + AnalogVoltageReader* _analogVoltageReader = nullptr; /// @brief Flag to track if this object owns the analog voltage reader and /// should delete it in the destructor bool _ownsAnalogVoltageReader = false; diff --git a/src/sensors/TurnerTurbidityPlus.cpp b/src/sensors/TurnerTurbidityPlus.cpp index 29958e064..01ab3b62e 100644 --- a/src/sensors/TurnerTurbidityPlus.cpp +++ b/src/sensors/TurnerTurbidityPlus.cpp @@ -17,7 +17,7 @@ TurnerTurbidityPlus::TurnerTurbidityPlus( int8_t powerPin, int8_t wiperTriggerPin, int8_t analogChannel, int8_t analogReferenceChannel, float conc_std, float volt_std, float volt_blank, uint8_t measurementsToAverage, - AnalogVoltageBase* analogVoltageReader) + AnalogVoltageReader* analogVoltageReader) : Sensor("TurnerTurbidityPlus", TURBIDITY_PLUS_NUM_VARIABLES, TURBIDITY_PLUS_WARM_UP_TIME_MS, TURBIDITY_PLUS_STABILIZATION_TIME_MS, @@ -30,7 +30,7 @@ TurnerTurbidityPlus::TurnerTurbidityPlus( _analogReferenceChannel(analogReferenceChannel), // If no analog voltage reader was provided, create a default one _analogVoltageReader(analogVoltageReader == nullptr - ? new TIADS1x15Base() + ? new TIADS1x15Reader() : analogVoltageReader), _ownsAnalogVoltageReader(analogVoltageReader == nullptr) {} @@ -134,8 +134,8 @@ bool TurnerTurbidityPlus::addSingleMeasurementResult() { MS_DBG(getSensorNameAndLocation(), F("is reporting:")); - // Read the differential voltage using the AnalogVoltageBase interface. - // NOTE: All implementations of the AnalogVoltageBase class validate both + // Read the differential voltage using the AnalogVoltageReader interface. + // NOTE: All implementations of the AnalogVoltageReader class validate both // the input channel and the resulting voltage, so we can trust that a // successful read will give us a valid voltage value to work with. bool success = _analogVoltageReader->readVoltageDifferential( diff --git a/src/sensors/TurnerTurbidityPlus.h b/src/sensors/TurnerTurbidityPlus.h index bb6d24eab..d72081001 100644 --- a/src/sensors/TurnerTurbidityPlus.h +++ b/src/sensors/TurnerTurbidityPlus.h @@ -68,7 +68,7 @@ #include "SensorBase.h" // Forward declaration -class AnalogVoltageBase; +class AnalogVoltageReader; /** @ingroup sensor_turbidity_plus */ /**@{*/ @@ -214,8 +214,8 @@ class TurnerTurbidityPlus : public Sensor { * the analog data and reference channels, and the calibration info. * * By default, this constructor will internally create a default - * AnalogVoltageBase implementation for voltage readings, but a pointer to - * a custom AnalogVoltageBase object can be passed in if desired. + * AnalogVoltageReader implementation for voltage readings, but a pointer to + * a custom AnalogVoltageReader object can be passed in if desired. * * @param powerPin The pin on the mcu controlling power to the Turbidity * Plus Use -1 if it is continuously powered. @@ -243,7 +243,7 @@ class TurnerTurbidityPlus : public Sensor { * @param measurementsToAverage The number of measurements to take and * average before giving a "final" result from the sensor; optional with a * default value of 1. - * @param analogVoltageReader Pointer to an AnalogVoltageBase object for + * @param analogVoltageReader Pointer to an AnalogVoltageReader object for * voltage measurements. Pass nullptr (the default) to have the constructor * internally create and own an analog voltage reader. For backward * compatibility, the default reader uses a TI ADS1115 or ADS1015. If a @@ -256,10 +256,10 @@ class TurnerTurbidityPlus : public Sensor { * Turner's output signal via a voltage divider. By default, the * TurnerTurbidityPlus object does **NOT** include any level-shifting or * voltage dividers. To have a voltage divider applied correctly, you must - * supply a pointer to a custom AnalogVoltageBase object that applies the + * supply a pointer to a custom AnalogVoltageReader object that applies the * voltage divider to the raw voltage readings. For example, if you are * using a simple voltage divider with two equal resistors, you would need - * to use an AnalogVoltageBase object that multiplies the raw voltage + * to use an AnalogVoltageReader object that multiplies the raw voltage * readings by 2 to account for the halving of the signal by the voltage * divider. * @@ -274,7 +274,7 @@ class TurnerTurbidityPlus : public Sensor { int8_t analogChannel, int8_t analogReferenceChannel, float conc_std, float volt_std, float volt_blank, uint8_t measurementsToAverage = 1, - AnalogVoltageBase* analogVoltageReader = nullptr); + AnalogVoltageReader* analogVoltageReader = nullptr); /** * @brief Destroy the Turner Turbidity Plus object */ @@ -345,7 +345,7 @@ class TurnerTurbidityPlus : public Sensor { */ int8_t _analogReferenceChannel = -1; /// @brief Pointer to analog voltage reader - AnalogVoltageBase* _analogVoltageReader = nullptr; + AnalogVoltageReader* _analogVoltageReader = nullptr; /// @brief Flag to track if this object owns the analog voltage reader and /// should delete it in the destructor bool _ownsAnalogVoltageReader = false; From 3553a247e2499254e2875bb389e9dad26916387e Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Thu, 12 Mar 2026 11:45:53 -0400 Subject: [PATCH 508/533] Split the clearValues function Signed-off-by: Sara Damiano --- src/SensorBase.cpp | 20 +++++++++++++++++--- src/SensorBase.h | 16 ++++++++++++++++ 2 files changed, 33 insertions(+), 3 deletions(-) diff --git a/src/SensorBase.cpp b/src/SensorBase.cpp index a1ec6e342..668c4581b 100644 --- a/src/SensorBase.cpp +++ b/src/SensorBase.cpp @@ -363,17 +363,31 @@ void Sensor::notifyVariables() { } -// This function empties the value array and resets the measurement counts. -void Sensor::clearValues() { +// This function empties the value array by setting all values to invalid. +void Sensor::clearValueArray() { MS_DBG(F("Clearing value array for"), getSensorNameAndLocation()); for (uint8_t i = 0; i < _numReturnedValues; i++) { - sensorValues[i] = MS_INVALID_VALUE; + sensorValues[i] = MS_INVALID_VALUE; + } +} + +// This function resets all measurement counts. +void Sensor::resetMeasurementCounts() { + MS_DBG(F("Resetting measurement counts for"), getSensorNameAndLocation()); + for (uint8_t i = 0; i < _numReturnedValues; i++) { numberGoodMeasurementsMade[i] = 0; } // Reset measurement attempt counters _completedMeasurements = 0; _currentRetries = 0; } + +// This function empties the value array and resets the measurement counts. +void Sensor::clearValues() { + clearValueArray(); + resetMeasurementCounts(); +} + // This clears power-related status bits and resets power timing. void Sensor::clearPowerStatus() { // Reset power timing value diff --git a/src/SensorBase.h b/src/SensorBase.h index 42b65dd12..e41f4d4ef 100644 --- a/src/SensorBase.h +++ b/src/SensorBase.h @@ -519,6 +519,22 @@ class Sensor { */ float sensorValues[MAX_NUMBER_VARS]; + /** + * @brief Clear only the values array. + * + * This clears the values array by setting all values to #MS_INVALID_VALUE. + */ + void clearValueArray(); + + /** + * @brief Reset all measurement counts. + * + * Sets all values in numberGoodMeasurementsMade to 0, and resets the + * attempt (#_completedMeasurements) and retry (#_currentRetries) + * counts. + */ + void resetMeasurementCounts(); + /** * @brief Clear the values array and reset retry counts. * From 3add2a6d2d2a76b52ad34f29f9852916decac08b Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Thu, 12 Mar 2026 12:08:43 -0400 Subject: [PATCH 509/533] Fix Atlas wire includes Signed-off-by: Sara Damiano --- src/sensors/AtlasParent.cpp | 1 - src/sensors/AtlasParent.h | 4 +--- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/src/sensors/AtlasParent.cpp b/src/sensors/AtlasParent.cpp index 5a09c1ae0..1e04df089 100644 --- a/src/sensors/AtlasParent.cpp +++ b/src/sensors/AtlasParent.cpp @@ -10,7 +10,6 @@ */ #include "AtlasParent.h" -#include // The constructors diff --git a/src/sensors/AtlasParent.h b/src/sensors/AtlasParent.h index 8664fa627..ea159c3b4 100644 --- a/src/sensors/AtlasParent.h +++ b/src/sensors/AtlasParent.h @@ -91,9 +91,7 @@ // Include other in-library and external dependencies #include "VariableBase.h" #include "SensorBase.h" - -// Forward declarations -class TwoWire; +#include /** * @brief A parent class for Atlas EZO circuits and sensors From 5dd9074c887e60e1b38669cb9265b71f1ffe98a3 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Thu, 12 Mar 2026 12:26:44 -0400 Subject: [PATCH 510/533] Create helper function initializeMeasurementResult to start all addSingleMeasurementResult with checks and value resets Signed-off-by: Sara Damiano --- src/ClockSupport.cpp | 3 ++- src/SensorBase.cpp | 21 ++++++++++++++++++--- src/SensorBase.h | 19 ++++++++++++++++--- src/VariableArray.cpp | 4 ++-- src/publishers/AWS_IoT_Publisher.h | 2 +- src/sensors/ANBpH.cpp | 6 ++---- src/sensors/AOSongAM2315.cpp | 6 ++---- src/sensors/AOSongDHT.cpp | 6 ++---- src/sensors/AlphasenseCO2.cpp | 6 ++---- src/sensors/AnalogElecConductivity.cpp | 6 ++---- src/sensors/ApogeeSQ212.cpp | 6 ++---- src/sensors/AtlasParent.cpp | 6 ++---- src/sensors/BoschBME280.cpp | 6 ++---- src/sensors/BoschBMP3xx.cpp | 6 ++---- src/sensors/CampbellOBS3.cpp | 6 ++---- src/sensors/EverlightALSPT19.cpp | 6 ++---- src/sensors/FreescaleMPL115A2.cpp | 6 ++---- src/sensors/GeoluxHydroCam.cpp | 6 ++---- src/sensors/GroPointParent.cpp | 6 ++---- src/sensors/KellerParent.cpp | 6 ++---- src/sensors/MaxBotixSonar.cpp | 6 ++---- src/sensors/MaxBotixSonar.h | 4 ++-- src/sensors/MaximDS18.cpp | 6 ++---- src/sensors/MaximDS3231.cpp | 10 +++++++--- src/sensors/MeaSpecMS5803.cpp | 6 ++---- src/sensors/PaleoTerraRedox.cpp | 6 ++---- src/sensors/ProcessorAnalog.cpp | 6 ++---- src/sensors/ProcessorStats.cpp | 6 ++++-- src/sensors/RainCounterI2C.cpp | 6 ++---- src/sensors/SDI12Sensors.cpp | 12 ++++-------- src/sensors/SensirionSHT4x.cpp | 6 ++---- src/sensors/TEConnectivityMS5837.cpp | 6 ++---- src/sensors/TIADS1x15.cpp | 6 ++---- src/sensors/TIINA219.cpp | 6 ++---- src/sensors/TallyCounterI2C.cpp | 6 ++---- src/sensors/TurnerCyclops.cpp | 6 ++---- src/sensors/TurnerTurbidityPlus.cpp | 6 ++---- src/sensors/YosemitechParent.cpp | 6 ++---- 38 files changed, 114 insertions(+), 141 deletions(-) diff --git a/src/ClockSupport.cpp b/src/ClockSupport.cpp index a51638c7d..385834887 100644 --- a/src/ClockSupport.cpp +++ b/src/ClockSupport.cpp @@ -670,7 +670,8 @@ int32_t loggerClock::getProcessorTimeZone() { if (is_time_t_signed) { // For signed time_t, negative values are represented normally - if (timeY2K >= -SECONDS_IN_DAY && timeY2K <= SECONDS_IN_DAY) { + if (timeY2K >= -static_cast(SECONDS_IN_DAY) && + timeY2K <= static_cast(SECONDS_IN_DAY)) { tz_offset = static_cast(timeY2K); } else { tz_offset = 0; // Outside reasonable timezone range (±24 hours) diff --git a/src/SensorBase.cpp b/src/SensorBase.cpp index 668c4581b..745f9f2ae 100644 --- a/src/SensorBase.cpp +++ b/src/SensorBase.cpp @@ -558,9 +558,9 @@ bool Sensor::update() { // them before starting a measurement. clearMeasurementStatus(); - // Clear stale values and reset the measurement attempt and retry - // counts before starting new measurements. - clearValues(); + // Reset the measurement attempt and retry counts before starting new + // measurements. + resetMeasurementCounts(); // Wait for the sensor to stabilize waitForStability(); @@ -801,6 +801,21 @@ bool Sensor::finalizeMeasurementAttempt(bool wasSuccessful) { } +// Common initialization for addSingleMeasurementResult implementations +bool Sensor::initializeMeasurementResult() { + // If it's the first attempt, clear all stale values in the value array + if (getCompletedMeasurements() == 0 && getCurrentRetries() == 0) { + clearValues(); + } + // Immediately quit if the measurement was not successfully started + if (!getStatusBit(MEASUREMENT_SUCCESSFUL)) { + finalizeMeasurementAttempt(false); + return false; + } + return true; +} + + // Helper function to check if a pin is physically LOW bool Sensor::isPinLow(int8_t pin) { if (pin < 0) { diff --git a/src/SensorBase.h b/src/SensorBase.h index e41f4d4ef..a6fee3db9 100644 --- a/src/SensorBase.h +++ b/src/SensorBase.h @@ -312,7 +312,7 @@ class Sensor { * * Bit 5 * - 0 => No measurements have been requested - * - 1 => Start measurement requested attempt made + * - 1 => Measurement start requested * - check _millisMeasurementRequested or bit 6 to see if * startSingleMeasurement() attempt was successful * - a failed request attempt will give _millisMeasurementRequested = 0 @@ -489,6 +489,19 @@ class Sensor { */ virtual bool startSingleMeasurement(); + /** + * @brief Common initialization logic for addSingleMeasurementResult(). + * + * This function performs the standard checks and initialization required + * at the start of every addSingleMeasurementResult() implementation: + * - Clears values array on first measurement attempt + * - Checks if measurement was successfully started + * + * @return True if initialization succeeded and measurement processing should + * continue, false if the measurement attempt should be aborted. + */ + bool initializeMeasurementResult(); + /** * @brief Get the results from a single measurement. * @@ -525,7 +538,7 @@ class Sensor { * This clears the values array by setting all values to #MS_INVALID_VALUE. */ void clearValueArray(); - + /** * @brief Reset all measurement counts. * @@ -534,7 +547,7 @@ class Sensor { * counts. */ void resetMeasurementCounts(); - + /** * @brief Clear the values array and reset retry counts. * diff --git a/src/VariableArray.cpp b/src/VariableArray.cpp index 5b8001e44..9b877fa4e 100644 --- a/src/VariableArray.cpp +++ b/src/VariableArray.cpp @@ -503,10 +503,10 @@ bool VariableArray::completeUpdate(bool powerUp, bool wake, bool sleep, // Clear the initial variable values arrays and reset the measurement // attempt and retry counts. - MS_DBG(F("----->> Clearing all results arrays before taking new " + MS_DBG(F("----->> Resetting all measurement counts before taking new " "measurements. ...")); for (uint8_t i = 0; i < _sensorCount; i++) { - _sensorList[i]->clearValues(); + _sensorList[i]->resetMeasurementCounts(); } MS_DBG(F(" ... Complete. <<-----")); diff --git a/src/publishers/AWS_IoT_Publisher.h b/src/publishers/AWS_IoT_Publisher.h index d776795bd..8553663c6 100644 --- a/src/publishers/AWS_IoT_Publisher.h +++ b/src/publishers/AWS_IoT_Publisher.h @@ -102,7 +102,7 @@ class AWS_IoT_Publisher : public dataPublisher { * @param samplingFeatureUUID The sampling feature UUID * * @note The inputs to this are the **NAMES** of the certificate **files** - * as they are stored on you modem module, not the content of the + * as they are stored on your modem module, not the content of the * certificates. */ AWS_IoT_Publisher(Logger& baseLogger, Client* inClient, diff --git a/src/sensors/ANBpH.cpp b/src/sensors/ANBpH.cpp index 115d5695f..605100ad2 100644 --- a/src/sensors/ANBpH.cpp +++ b/src/sensors/ANBpH.cpp @@ -323,10 +323,8 @@ bool ANBpH::sleep() { } bool ANBpH::addSingleMeasurementResult() { - // Immediately quit if the measurement was not successfully started - if (!getStatusBit(MEASUREMENT_SUCCESSFUL)) { - return finalizeMeasurementAttempt(false); - } + // Perform common initialization checks + if (!initializeMeasurementResult()) { return false; } bool success = false; float pH = MS_INVALID_VALUE; diff --git a/src/sensors/AOSongAM2315.cpp b/src/sensors/AOSongAM2315.cpp index a9e4d2118..30bde630f 100644 --- a/src/sensors/AOSongAM2315.cpp +++ b/src/sensors/AOSongAM2315.cpp @@ -46,10 +46,8 @@ bool AOSongAM2315::setup() { bool AOSongAM2315::addSingleMeasurementResult() { - // Immediately quit if the measurement was not successfully started - if (!getStatusBit(MEASUREMENT_SUCCESSFUL)) { - return finalizeMeasurementAttempt(false); - } + // Perform common initialization checks + if (!initializeMeasurementResult()) { return false; } bool success = false; float temp_val = MS_INVALID_VALUE; diff --git a/src/sensors/AOSongDHT.cpp b/src/sensors/AOSongDHT.cpp index 4fb395e21..8c984a8b2 100644 --- a/src/sensors/AOSongDHT.cpp +++ b/src/sensors/AOSongDHT.cpp @@ -41,10 +41,8 @@ String AOSongDHT::getSensorName() { bool AOSongDHT::addSingleMeasurementResult() { - // Immediately quit if the measurement was not successfully started - if (!getStatusBit(MEASUREMENT_SUCCESSFUL)) { - return finalizeMeasurementAttempt(false); - } + // Perform common initialization checks + if (!initializeMeasurementResult()) { return false; } bool success = false; float humid_val = MS_INVALID_VALUE; diff --git a/src/sensors/AlphasenseCO2.cpp b/src/sensors/AlphasenseCO2.cpp index 78c83e60d..381b2ca63 100644 --- a/src/sensors/AlphasenseCO2.cpp +++ b/src/sensors/AlphasenseCO2.cpp @@ -73,10 +73,8 @@ bool AlphasenseCO2::setup() { bool AlphasenseCO2::addSingleMeasurementResult() { - // Immediately quit if the measurement was not successfully started - if (!getStatusBit(MEASUREMENT_SUCCESSFUL)) { - return finalizeMeasurementAttempt(false); - } + // Perform common initialization checks + if (!initializeMeasurementResult()) { return false; } // Check if we have a valid analog voltage reader if (_analogVoltageReader == nullptr) { diff --git a/src/sensors/AnalogElecConductivity.cpp b/src/sensors/AnalogElecConductivity.cpp index 75ffa4b74..4d0440278 100644 --- a/src/sensors/AnalogElecConductivity.cpp +++ b/src/sensors/AnalogElecConductivity.cpp @@ -73,10 +73,8 @@ bool AnalogElecConductivity::setup() { bool AnalogElecConductivity::addSingleMeasurementResult() { - // Immediately quit if the measurement was not successfully started - if (!getStatusBit(MEASUREMENT_SUCCESSFUL)) { - return finalizeMeasurementAttempt(false); - } + // Perform common initialization checks + if (!initializeMeasurementResult()) { return false; } // Check if we have a valid analog voltage reader if (_analogVoltageReader == nullptr) { diff --git a/src/sensors/ApogeeSQ212.cpp b/src/sensors/ApogeeSQ212.cpp index f582839a1..f19166b95 100644 --- a/src/sensors/ApogeeSQ212.cpp +++ b/src/sensors/ApogeeSQ212.cpp @@ -67,10 +67,8 @@ bool ApogeeSQ212::setup() { bool ApogeeSQ212::addSingleMeasurementResult() { - // Immediately quit if the measurement was not successfully started - if (!getStatusBit(MEASUREMENT_SUCCESSFUL)) { - return finalizeMeasurementAttempt(false); - } + // Perform common initialization checks + if (!initializeMeasurementResult()) { return false; } // Check if we have a valid analog voltage reader if (_analogVoltageReader == nullptr) { diff --git a/src/sensors/AtlasParent.cpp b/src/sensors/AtlasParent.cpp index 1e04df089..5877e30fa 100644 --- a/src/sensors/AtlasParent.cpp +++ b/src/sensors/AtlasParent.cpp @@ -134,10 +134,8 @@ bool AtlasParent::startSingleMeasurement() { bool AtlasParent::addSingleMeasurementResult() { - // Immediately quit if the measurement was not successfully started - if (!getStatusBit(MEASUREMENT_SUCCESSFUL)) { - return finalizeMeasurementAttempt(false); - } + // Perform common initialization checks + if (!initializeMeasurementResult()) { return false; } bool success = false; diff --git a/src/sensors/BoschBME280.cpp b/src/sensors/BoschBME280.cpp index 4d8d5ddbb..51fc03414 100644 --- a/src/sensors/BoschBME280.cpp +++ b/src/sensors/BoschBME280.cpp @@ -112,10 +112,8 @@ bool BoschBME280::wake() { bool BoschBME280::addSingleMeasurementResult() { - // Immediately quit if the measurement was not successfully started - if (!getStatusBit(MEASUREMENT_SUCCESSFUL)) { - return finalizeMeasurementAttempt(false); - } + // Perform common initialization checks + if (!initializeMeasurementResult()) { return false; } bool success = false; float temp = MS_INVALID_VALUE; diff --git a/src/sensors/BoschBMP3xx.cpp b/src/sensors/BoschBMP3xx.cpp index e0bde272e..b1ef18126 100644 --- a/src/sensors/BoschBMP3xx.cpp +++ b/src/sensors/BoschBMP3xx.cpp @@ -285,10 +285,8 @@ bool BoschBMP3xx::startSingleMeasurement() { bool BoschBMP3xx::addSingleMeasurementResult() { - // Immediately quit if the measurement was not successfully started - if (!getStatusBit(MEASUREMENT_SUCCESSFUL)) { - return finalizeMeasurementAttempt(false); - } + // Perform common initialization checks + if (!initializeMeasurementResult()) { return false; } bool success = false; float temp = MS_INVALID_VALUE; diff --git a/src/sensors/CampbellOBS3.cpp b/src/sensors/CampbellOBS3.cpp index 5a56f84db..5f0963a81 100644 --- a/src/sensors/CampbellOBS3.cpp +++ b/src/sensors/CampbellOBS3.cpp @@ -68,10 +68,8 @@ bool CampbellOBS3::setup() { bool CampbellOBS3::addSingleMeasurementResult() { - // Immediately quit if the measurement was not successfully started - if (!getStatusBit(MEASUREMENT_SUCCESSFUL)) { - return finalizeMeasurementAttempt(false); - } + // Perform common initialization checks + if (!initializeMeasurementResult()) { return false; } // Check if we have a valid analog voltage reader if (_analogVoltageReader == nullptr) { diff --git a/src/sensors/EverlightALSPT19.cpp b/src/sensors/EverlightALSPT19.cpp index f7b96fd8a..0f886881b 100644 --- a/src/sensors/EverlightALSPT19.cpp +++ b/src/sensors/EverlightALSPT19.cpp @@ -79,10 +79,8 @@ bool EverlightALSPT19::setup() { bool EverlightALSPT19::addSingleMeasurementResult() { - // Immediately quit if the measurement was not successfully started - if (!getStatusBit(MEASUREMENT_SUCCESSFUL)) { - return finalizeMeasurementAttempt(false); - } + // Perform common initialization checks + if (!initializeMeasurementResult()) { return false; } // Check if we have a valid analog voltage reader if (_analogVoltageReader == nullptr) { diff --git a/src/sensors/FreescaleMPL115A2.cpp b/src/sensors/FreescaleMPL115A2.cpp index 1bb97693c..6f1a127e2 100644 --- a/src/sensors/FreescaleMPL115A2.cpp +++ b/src/sensors/FreescaleMPL115A2.cpp @@ -56,10 +56,8 @@ bool FreescaleMPL115A2::setup() { bool FreescaleMPL115A2::addSingleMeasurementResult() { - // Immediately quit if the measurement was not successfully started - if (!getStatusBit(MEASUREMENT_SUCCESSFUL)) { - return finalizeMeasurementAttempt(false); - } + // Perform common initialization checks + if (!initializeMeasurementResult()) { return false; } bool success = false; float temp = MS_INVALID_VALUE; diff --git a/src/sensors/GeoluxHydroCam.cpp b/src/sensors/GeoluxHydroCam.cpp index 1988dab54..e7ffcbbed 100644 --- a/src/sensors/GeoluxHydroCam.cpp +++ b/src/sensors/GeoluxHydroCam.cpp @@ -185,10 +185,8 @@ bool GeoluxHydroCam::startSingleMeasurement() { bool GeoluxHydroCam::addSingleMeasurementResult() { - // Immediately quit if the measurement was not successfully started - if (!getStatusBit(MEASUREMENT_SUCCESSFUL)) { - return finalizeMeasurementAttempt(false); - } + // Perform common initialization checks + if (!initializeMeasurementResult()) { return false; } bool success = false; int32_t bytes_transferred = MS_INVALID_VALUE; diff --git a/src/sensors/GroPointParent.cpp b/src/sensors/GroPointParent.cpp index 11062df91..68e2e193a 100644 --- a/src/sensors/GroPointParent.cpp +++ b/src/sensors/GroPointParent.cpp @@ -159,10 +159,8 @@ bool GroPointParent::sleep() { bool GroPointParent::addSingleMeasurementResult() { - // Immediately quit if the measurement was not successfully started - if (!getStatusBit(MEASUREMENT_SUCCESSFUL)) { - return finalizeMeasurementAttempt(false); - } + // Perform common initialization checks + if (!initializeMeasurementResult()) { return false; } bool success = false; bool successT = false; diff --git a/src/sensors/KellerParent.cpp b/src/sensors/KellerParent.cpp index 2d3cfc210..73379a3d6 100644 --- a/src/sensors/KellerParent.cpp +++ b/src/sensors/KellerParent.cpp @@ -82,10 +82,8 @@ bool KellerParent::sleep() { bool KellerParent::addSingleMeasurementResult() { - // Immediately quit if the measurement was not successfully started - if (!getStatusBit(MEASUREMENT_SUCCESSFUL)) { - return finalizeMeasurementAttempt(false); - } + // Perform common initialization checks + if (!initializeMeasurementResult()) { return false; } bool success = false; float waterPressureBar = MS_INVALID_VALUE; diff --git a/src/sensors/MaxBotixSonar.cpp b/src/sensors/MaxBotixSonar.cpp index 8b6dfbc92..af45fa432 100644 --- a/src/sensors/MaxBotixSonar.cpp +++ b/src/sensors/MaxBotixSonar.cpp @@ -129,10 +129,8 @@ bool MaxBotixSonar::startSingleMeasurement() { bool MaxBotixSonar::addSingleMeasurementResult() { - // Immediately quit if the measurement was not successfully started - if (!getStatusBit(MEASUREMENT_SUCCESSFUL)) { - return finalizeMeasurementAttempt(false); - } + // Perform common initialization checks + if (!initializeMeasurementResult()) { return false; } // Initialize values bool success = false; diff --git a/src/sensors/MaxBotixSonar.h b/src/sensors/MaxBotixSonar.h index b318dc860..1fe8a950a 100644 --- a/src/sensors/MaxBotixSonar.h +++ b/src/sensors/MaxBotixSonar.h @@ -181,8 +181,8 @@ static_assert(MAXBOTIX_DEFAULT_MEASUREMENT_RETRIES >= 0 && #define HRXL_STABILIZATION_TIME_MS 0 /// @brief Sensor::_measurementTime_ms; the HRXL takes 166ms to complete a /// measurement. It outputs results at least every 166ms. -/// @note Because this sensor allows up to 25 retries if a measurement fails, -/// the actual time to get a measurement may be much longer than 166ms. +/// @note Because the default number of measurement retries is 25, the actual +/// time to get a measurement result may be much longer than 166ms. #define HRXL_MEASUREMENT_TIME_MS 250 /**@}*/ diff --git a/src/sensors/MaximDS18.cpp b/src/sensors/MaximDS18.cpp index 0d0eb05dc..3e9858706 100644 --- a/src/sensors/MaximDS18.cpp +++ b/src/sensors/MaximDS18.cpp @@ -182,10 +182,8 @@ bool MaximDS18::startSingleMeasurement() { bool MaximDS18::addSingleMeasurementResult() { - // Immediately quit if the measurement was not successfully started - if (!getStatusBit(MEASUREMENT_SUCCESSFUL)) { - return finalizeMeasurementAttempt(false); - } + // Perform common initialization checks + if (!initializeMeasurementResult()) { return false; } bool success = false; float result = MS_INVALID_VALUE; diff --git a/src/sensors/MaximDS3231.cpp b/src/sensors/MaximDS3231.cpp index 134ec125e..498ad7c37 100644 --- a/src/sensors/MaximDS3231.cpp +++ b/src/sensors/MaximDS3231.cpp @@ -54,9 +54,13 @@ bool MaximDS3231::startSingleMeasurement() { bool MaximDS3231::addSingleMeasurementResult() { - // NOTE: If this fails we have much bigger problems than just a lost - // temperature value. That is, if I2C communication with the clock fails, - // the system is too broken to even ask for this temperature. + // Perform common initialization checks + if (!initializeMeasurementResult()) { return false; } + + // NOTE: If this the start measurement or get temperature fails we have much + // bigger problems than just a lost temperature value. That is, if I2C + // communication with the clock fails, the system is too broken to even ask + // for this temperature. MS_DBG(getSensorNameAndLocation(), F("is reporting:")); float tempVal = rtc.getTemperature(); MS_DBG(F(" Temp:"), tempVal, F("°C")); diff --git a/src/sensors/MeaSpecMS5803.cpp b/src/sensors/MeaSpecMS5803.cpp index be10156f9..dd35e1bf4 100644 --- a/src/sensors/MeaSpecMS5803.cpp +++ b/src/sensors/MeaSpecMS5803.cpp @@ -55,10 +55,8 @@ bool MeaSpecMS5803::setup() { bool MeaSpecMS5803::addSingleMeasurementResult() { - // Immediately quit if the measurement was not successfully started - if (!getStatusBit(MEASUREMENT_SUCCESSFUL)) { - return finalizeMeasurementAttempt(false); - } + // Perform common initialization checks + if (!initializeMeasurementResult()) { return false; } bool success = false; float temp = MS_INVALID_VALUE; diff --git a/src/sensors/PaleoTerraRedox.cpp b/src/sensors/PaleoTerraRedox.cpp index b74288bf2..e5ccb1025 100644 --- a/src/sensors/PaleoTerraRedox.cpp +++ b/src/sensors/PaleoTerraRedox.cpp @@ -107,10 +107,8 @@ bool PaleoTerraRedox::setup() { bool PaleoTerraRedox::addSingleMeasurementResult() { - // Immediately quit if the measurement was not successfully started - if (!getStatusBit(MEASUREMENT_SUCCESSFUL)) { - return finalizeMeasurementAttempt(false); - } + // Perform common initialization checks + if (!initializeMeasurementResult()) { return false; } bool success = false; byte config = 0; // Returned config diff --git a/src/sensors/ProcessorAnalog.cpp b/src/sensors/ProcessorAnalog.cpp index dcf9b1022..91410294f 100644 --- a/src/sensors/ProcessorAnalog.cpp +++ b/src/sensors/ProcessorAnalog.cpp @@ -155,10 +155,8 @@ String ProcessorAnalog::getSensorLocation() { } bool ProcessorAnalog::addSingleMeasurementResult() { - // Immediately quit if the measurement was not successfully started - if (!getStatusBit(MEASUREMENT_SUCCESSFUL)) { - return finalizeMeasurementAttempt(false); - } + // Perform common initialization checks + if (!initializeMeasurementResult()) { return false; } // Check if we have a valid analog voltage reader if (_analogVoltageReader == nullptr) { diff --git a/src/sensors/ProcessorStats.cpp b/src/sensors/ProcessorStats.cpp index 908537ff6..28bd926f6 100644 --- a/src/sensors/ProcessorStats.cpp +++ b/src/sensors/ProcessorStats.cpp @@ -224,8 +224,10 @@ String ProcessorStats::getLastResetCause() { bool ProcessorStats::addSingleMeasurementResult() { - // NOTE: We don't need to check if a measurement was started successfully - // because there is no way for it to fail! + // Perform common initialization checks + if (!initializeMeasurementResult()) { return false; } + + // NOTE: There is no way for the measurement start to fail! float sensorValue_battery = getBatteryVoltage(); verifyAndAddMeasurementResult(PROCESSOR_BATTERY_VAR_NUM, diff --git a/src/sensors/RainCounterI2C.cpp b/src/sensors/RainCounterI2C.cpp index e162ddc2c..684a528e7 100644 --- a/src/sensors/RainCounterI2C.cpp +++ b/src/sensors/RainCounterI2C.cpp @@ -101,10 +101,8 @@ bool RainCounterI2C::setup() { bool RainCounterI2C::addSingleMeasurementResult() { - // Immediately quit if the measurement was not successfully started - if (!getStatusBit(MEASUREMENT_SUCCESSFUL)) { - return finalizeMeasurementAttempt(false); - } + // Perform common initialization checks + if (!initializeMeasurementResult()) { return false; } bool success = false; // assume the worst float rain = MS_INVALID_VALUE; // Number of mm of rain diff --git a/src/sensors/SDI12Sensors.cpp b/src/sensors/SDI12Sensors.cpp index cda560b64..65fba5a67 100644 --- a/src/sensors/SDI12Sensors.cpp +++ b/src/sensors/SDI12Sensors.cpp @@ -711,10 +711,8 @@ bool SDI12Sensors::getResults(bool verify_crc) { // bit was set in the specialized startSingleMeasurement function based on // whether the response to the SDI-12 start measurement command. bool SDI12Sensors::addSingleMeasurementResult() { - // Immediately quit if the measurement was not successfully started - if (!getStatusBit(MEASUREMENT_SUCCESSFUL)) { - return finalizeMeasurementAttempt(false); - } + // Perform common initialization checks + if (!initializeMeasurementResult()) { return false; } bool success = getResults(MS_SDI12_USE_CRC); @@ -728,10 +726,8 @@ bool SDI12Sensors::addSingleMeasurementResult() { // startSingleMeasurement function from sensor base, which only verifies that // the sensor is awake and capable of starting measurements. bool SDI12Sensors::addSingleMeasurementResult() { - // Immediately quit if the measurement was not successfully started - if (!getStatusBit(MEASUREMENT_SUCCESSFUL)) { - return finalizeMeasurementAttempt(false); - } + // Perform common initialization checks + if (!initializeMeasurementResult()) { return false; } bool success = false; diff --git a/src/sensors/SensirionSHT4x.cpp b/src/sensors/SensirionSHT4x.cpp index b4458430f..6fb30e057 100644 --- a/src/sensors/SensirionSHT4x.cpp +++ b/src/sensors/SensirionSHT4x.cpp @@ -89,10 +89,8 @@ bool SensirionSHT4x::setup() { bool SensirionSHT4x::addSingleMeasurementResult() { - // Immediately quit if the measurement was not successfully started - if (!getStatusBit(MEASUREMENT_SUCCESSFUL)) { - return finalizeMeasurementAttempt(false); - } + // Perform common initialization checks + if (!initializeMeasurementResult()) { return false; } bool success = false; float temp_val = MS_INVALID_VALUE; diff --git a/src/sensors/TEConnectivityMS5837.cpp b/src/sensors/TEConnectivityMS5837.cpp index d3effe3f7..c21735e8b 100644 --- a/src/sensors/TEConnectivityMS5837.cpp +++ b/src/sensors/TEConnectivityMS5837.cpp @@ -144,10 +144,8 @@ bool TEConnectivityMS5837::wake() { bool TEConnectivityMS5837::addSingleMeasurementResult() { - // Immediately quit if the measurement was not successfully started - if (!getStatusBit(MEASUREMENT_SUCCESSFUL)) { - return finalizeMeasurementAttempt(false); - } + // Perform common initialization checks + if (!initializeMeasurementResult()) { return false; } // Validate configuration parameters if (_fluidDensity <= 0.1 || _fluidDensity > 5.0) { diff --git a/src/sensors/TIADS1x15.cpp b/src/sensors/TIADS1x15.cpp index 35cd3e4e9..6f2920af7 100644 --- a/src/sensors/TIADS1x15.cpp +++ b/src/sensors/TIADS1x15.cpp @@ -409,10 +409,8 @@ bool TIADS1x15::setup() { } bool TIADS1x15::addSingleMeasurementResult() { - // Immediately quit if the measurement was not successfully started - if (!getStatusBit(MEASUREMENT_SUCCESSFUL)) { - return finalizeMeasurementAttempt(false); - } + // Perform common initialization checks + if (!initializeMeasurementResult()) { return false; } // Check if we have a valid analog voltage reader if (_analogVoltageReader == nullptr) { diff --git a/src/sensors/TIINA219.cpp b/src/sensors/TIINA219.cpp index ca48795e5..030d0b2d6 100644 --- a/src/sensors/TIINA219.cpp +++ b/src/sensors/TIINA219.cpp @@ -89,10 +89,8 @@ bool TIINA219::wake() { bool TIINA219::addSingleMeasurementResult() { - // Immediately quit if the measurement was not successfully started - if (!getStatusBit(MEASUREMENT_SUCCESSFUL)) { - return finalizeMeasurementAttempt(false); - } + // Perform common initialization checks + if (!initializeMeasurementResult()) { return false; } bool success = false; float current_mA = MS_INVALID_VALUE; diff --git a/src/sensors/TallyCounterI2C.cpp b/src/sensors/TallyCounterI2C.cpp index 3cd0c4a11..916b9f2c4 100644 --- a/src/sensors/TallyCounterI2C.cpp +++ b/src/sensors/TallyCounterI2C.cpp @@ -68,10 +68,8 @@ bool TallyCounterI2C::setup() { bool TallyCounterI2C::addSingleMeasurementResult() { - // Immediately quit if the measurement was not successfully started - if (!getStatusBit(MEASUREMENT_SUCCESSFUL)) { - return finalizeMeasurementAttempt(false); - } + // Perform common initialization checks + if (!initializeMeasurementResult()) { return false; } bool success = false; int16_t events = MS_INVALID_VALUE; // Number of events diff --git a/src/sensors/TurnerCyclops.cpp b/src/sensors/TurnerCyclops.cpp index 005654b62..7ed683db4 100644 --- a/src/sensors/TurnerCyclops.cpp +++ b/src/sensors/TurnerCyclops.cpp @@ -69,10 +69,8 @@ bool TurnerCyclops::setup() { bool TurnerCyclops::addSingleMeasurementResult() { - // Immediately quit if the measurement was not successfully started - if (!getStatusBit(MEASUREMENT_SUCCESSFUL)) { - return finalizeMeasurementAttempt(false); - } + // Perform common initialization checks + if (!initializeMeasurementResult()) { return false; } // Check if we have a valid analog voltage reader if (_analogVoltageReader == nullptr) { diff --git a/src/sensors/TurnerTurbidityPlus.cpp b/src/sensors/TurnerTurbidityPlus.cpp index 01ab3b62e..f710e7ef4 100644 --- a/src/sensors/TurnerTurbidityPlus.cpp +++ b/src/sensors/TurnerTurbidityPlus.cpp @@ -110,10 +110,8 @@ void TurnerTurbidityPlus::powerUp() { } bool TurnerTurbidityPlus::addSingleMeasurementResult() { - // Immediately quit if the measurement was not successfully started - if (!getStatusBit(MEASUREMENT_SUCCESSFUL)) { - return finalizeMeasurementAttempt(false); - } + // Perform common initialization checks + if (!initializeMeasurementResult()) { return false; } // Check if we have a valid analog voltage reader if (_analogVoltageReader == nullptr) { diff --git a/src/sensors/YosemitechParent.cpp b/src/sensors/YosemitechParent.cpp index c7d414c00..46294901b 100644 --- a/src/sensors/YosemitechParent.cpp +++ b/src/sensors/YosemitechParent.cpp @@ -167,10 +167,8 @@ bool YosemitechParent::sleep() { bool YosemitechParent::addSingleMeasurementResult() { - // Immediately quit if the measurement was not successfully started - if (!getStatusBit(MEASUREMENT_SUCCESSFUL)) { - return finalizeMeasurementAttempt(false); - } + // Perform common initialization checks + if (!initializeMeasurementResult()) { return false; } bool success = false; From c78dd39e84c0908daac69891bb3618c4f7633d29 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Thu, 12 Mar 2026 12:30:29 -0400 Subject: [PATCH 511/533] Update instructions Signed-off-by: Sara Damiano --- .coderabbit.yaml | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/.coderabbit.yaml b/.coderabbit.yaml index a47798b95..d6892a128 100644 --- a/.coderabbit.yaml +++ b/.coderabbit.yaml @@ -35,12 +35,22 @@ reviews: Check c++ code snippets as c++ code. - path: '**/*.h' instructions: >- - Review the C++ code, point out issues relative to principles of clean - code, expressiveness, and performance. + Review the C++ code, point out issues relative to principles of clean code, expressiveness, and performance. + Don't suggest making getter functions const. + Since this is an Arduino project, never suggest using the standard library (std::). + For memory savings, prefer defines to const variables, and prefer using the F() macro for string literals longer than a single character. + Defines should be in the headers. + Unique functions, defines, and parameters must be documented with Doxygen comments in the header files. + Override functions don't need Doxygen comments in the header files, unless they have unique parameters or behavior that needs to be documented. + Files should be formatted according to the .clang-format file in the repo. - path: '**/*.cpp' instructions: >- - Review the C++ code, point out issues relative to principles of clean - code, expressiveness, and performance. + Review the C++ code, point out issues relative to principles of clean code, expressiveness, and performance. + Since this is an Arduino project, never suggest using the standard library (std::). + For memory savings, prefer defines to const variables, and prefer using the F() macro for string literals longer than a single character. + Defines should be in the headers. + Doxygen documentation should be in the header files. + Files should be formatted according to the .clang-format file in the repo. tools: shellcheck: enabled: true From bb18d133768fe17bad19021371e8e0aefc0f7cff Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Thu, 12 Mar 2026 12:38:01 -0400 Subject: [PATCH 512/533] Remove the out-of-date library dependencies page Signed-off-by: Sara Damiano --- docs/DoxygenLayout.xml | 1 - docs/Getting-Started/Getting-Started.md | 2 - docs/Getting-Started/Library-Dependencies.md | 49 -------------------- docs/mcss-conf.py | 4 -- 4 files changed, 56 deletions(-) delete mode 100644 docs/Getting-Started/Library-Dependencies.md diff --git a/docs/DoxygenLayout.xml b/docs/DoxygenLayout.xml index f9a2e60e3..5829aea9c 100644 --- a/docs/DoxygenLayout.xml +++ b/docs/DoxygenLayout.xml @@ -15,7 +15,6 @@ - diff --git a/docs/Getting-Started/Getting-Started.md b/docs/Getting-Started/Getting-Started.md index 295d9cd7f..e60873173 100644 --- a/docs/Getting-Started/Getting-Started.md +++ b/docs/Getting-Started/Getting-Started.md @@ -147,8 +147,6 @@ There are [video instructions](https://www.envirodiy.org/videos/) on the EnviroD - - diff --git a/docs/Getting-Started/Library-Dependencies.md b/docs/Getting-Started/Library-Dependencies.md deleted file mode 100644 index 04075a1fb..000000000 --- a/docs/Getting-Started/Library-Dependencies.md +++ /dev/null @@ -1,49 +0,0 @@ -# Library Dependencies - -> [!WARNING] -> This page is frequently out of date. -> Please see the library.json or dependencies.json and example_dependencies.json for the most up-to-date library references! - -In order to support multiple functions and sensors, there are quite a lot of sub-libraries that this library depends on. -_Even if you do not use the modules, you must have all of the dependencies installed for the library itself to properly compile._ -Please check the [library.json](https://github.com/EnviroDIY/ModularSensors/blob/master/library.json) file for more details on the versions required of each library. -If you are using [PlatformIO](https://platformio.org), you can list "EnviroDIY_ModularSensors" in the `lib_deps` section of your platformio.ini file and all of these libraries will be installed automatically. -If using the "standard" Arduino IDE, you must install each of these libraries individually, or in a bundle from the [EnviroDIY Libraries](https://github.com/EnviroDIY/Libraries) meta-repository. - -- [EnableInterrupt](https://github.com/GreyGnome/EnableInterrupt) - Administrates and handles pin change interrupts, allowing the logger to sleep and save battery. - This also controls the interrupts for the versions of SoftwareSerial and SDI-12 linked below that have been stripped of interrupt control. -Because we use this library, _you must always add the line `#include ` to the top of your sketch._ -- AVR sleep library - This is for low power sleeping for AVR processors. - (This library is built into the Arduino and PlatformIO IDEs.) -- [EnviroDIY DS-3231](https://github.com/EnviroDIY/Sodaq_DS3231) - For real time clock control -- [RTCZero library](https://github.com/arduino-libraries/RTCZero) - This real time clock control and low power sleeping on SAMD processors. - (This library may be built into the Arduino IDE.) -NOTE: If using an AVR board, you must explicitly _ignore_ this library when compiling with PlatformIO or you will have compiler errors. -- [SdFat library](https://github.com/greiman/SdFat) - This enables communication with the SD card. -- [TinyGSM library](https://github.com/vshymanskyy/TinyGSM) - This provides internet (TCP/IP) connectivity. -- [PubSubClient](https://github.com/knolleary/pubsubclient) - For MQTT connectivity -- [Adafruit ADS1X15 library](https://github.com/adafruit/Adafruit_ADS1X15) - For high-resolution analog to digital conversion. - - NOTE: As of version 0.36.0 the standard Adafruit library should be used, _NOT_ the Soligen2010 fork. -- [EnviroDIY Arduino SDI-12 library](https://github.com/EnviroDIY/Arduino-SDI-12/tree/ExtInts) - For control of SDI-12 based sensors. - This modified version is needed so there are no pin change interrupt conflicts with the SoftwareSerial library or the software pin change interrupt library used to wake the processor. -- [SensorModbusMaster](https://github.com/EnviroDIY/SensorModbusMaster) - for easy communication with Modbus devices. -- [OneWire](https://github.com/PaulStoffregen/OneWire) - This enables communication with Maxim/Dallas OneWire devices. -- [DallasTemperature](https://github.com/milesburton/Arduino-Temperature-Control-Library) - for communication with the DS18 line of Maxim/Dallas OneWire temperature probes. -- [Adafruit BusIO](https://github.com/adafruit/Adafruit_BusIO) - a dependency of several other Adafruit libraries, used to unify commands for fetching data via SPI and I2C. -- [Adafruit Unified Sensor Driver](https://github.com/adafruit/Adafruit_Sensor) - a dependency of several other Adafruit libraries, used to unify sensor data return types. -- [Adafruit AM2315 library](https://github.com/adafruit/Adafruit_AM2315) - for the AOSong AM2315 temperature and humidity sensor. -- [Adafruit DHT library](https://github.com/adafruit/DHT-sensor-library) - for other AOSong temperature and humidity sensors. -- [Adafruit BME280 library](https://github.com/adafruit/Adafruit_BME280_Library) - for the Bosch BME280 environmental sensor. -- [Adafruit INA219 library](https://github.com/adafruit/Adafruit_INA219) - for the INA219 current/voltage sensor. -- [Adafruit MPL115A2 library](https://github.com/adafruit/Adafruit_MPL115A2) - for the Freescale Semiconductor MPL115A2 barometer. -- [Adafruit SHT4x library](https://github.com/adafruit/Adafruit_SHT4X) - for the Sensirion SHT40 temperature and humidity sensor. - This sensor is built into the EnviroDIY Mayfly and Stonefly. -- [YosemitechModbus](https://github.com/EnviroDIY/YosemitechModbus) - for all Yosemitech modbus environmental sensors. -- [Northern Widget MS5803 Library](https://github.com/NorthernWidget/MS5803) - for the TE Connectivity MEAS MS5803 pressure sensor -- [EnviroDIY KellerModbus Library](https://github.com/EnviroDIY/KellerModbus) - for all Keller modbus pressure and water level sensors. -- [EnviroDIY GroPointModbus Library](https://github.com/EnviroDIY/GroPointModbus.git) - For GroPoint soil moisture probes. -- [BMP388_DEV](https://registry.platformio.org/libraries/martinl1/BMP388_DEV) - for communication with the Bosch BMP388 barometer - - WARNING: The repository for this library has been removed from GitHub. - The library itself is still available in the PlatformIO and Arduino library registries. -- [Tally Library](https://github.com/EnviroDIY/Tally_Library.git#Dev_I2C) - For the Project Tally Event sensor - - NOTE: Use the `Dev_I2C` feature branch diff --git a/docs/mcss-conf.py b/docs/mcss-conf.py index 1242ec741..f469d571a 100644 --- a/docs/mcss-conf.py +++ b/docs/mcss-conf.py @@ -45,10 +45,6 @@ # ), # ], ), - ( - "Library Dependencies", - "page_library_dependencies", - ), ( "Physical Dependencies", "page_physical_dependencies", From 46213749e69eddbf754a4c30169a9bc94bce9787 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Thu, 12 Mar 2026 12:45:09 -0400 Subject: [PATCH 513/533] Revert "Forward declare wire and move include to cpp where possible" This reverts commit 2fdc98d71d10405435351da5835d836a38a1d15c. Signed-off-by: Sara Damiano --- src/sensors/AOSongAM2315.cpp | 1 - src/sensors/AOSongAM2315.h | 4 +--- src/sensors/PaleoTerraRedox.cpp | 5 ----- src/sensors/PaleoTerraRedox.h | 5 ++--- src/sensors/RainCounterI2C.cpp | 5 ----- src/sensors/RainCounterI2C.h | 5 ++--- 6 files changed, 5 insertions(+), 20 deletions(-) diff --git a/src/sensors/AOSongAM2315.cpp b/src/sensors/AOSongAM2315.cpp index 30bde630f..a963afbe7 100644 --- a/src/sensors/AOSongAM2315.cpp +++ b/src/sensors/AOSongAM2315.cpp @@ -9,7 +9,6 @@ */ #include "AOSongAM2315.h" -#include #include diff --git a/src/sensors/AOSongAM2315.h b/src/sensors/AOSongAM2315.h index d710fd2fe..26d1ddcba 100644 --- a/src/sensors/AOSongAM2315.h +++ b/src/sensors/AOSongAM2315.h @@ -75,9 +75,7 @@ // Include other in-library and external dependencies #include "VariableBase.h" #include "SensorBase.h" - -// Forward declarations -class TwoWire; +#include /** @ingroup sensor_am2315 */ /**@{*/ diff --git a/src/sensors/PaleoTerraRedox.cpp b/src/sensors/PaleoTerraRedox.cpp index e5ccb1025..d7b59a527 100644 --- a/src/sensors/PaleoTerraRedox.cpp +++ b/src/sensors/PaleoTerraRedox.cpp @@ -13,11 +13,6 @@ */ #include "PaleoTerraRedox.h" -#include - -#if defined(MS_PALEOTERRA_SOFTWAREWIRE) -#include // Testato's SoftwareWire -#endif // Constructors diff --git a/src/sensors/PaleoTerraRedox.h b/src/sensors/PaleoTerraRedox.h index f2d78f79e..7431d0659 100644 --- a/src/sensors/PaleoTerraRedox.h +++ b/src/sensors/PaleoTerraRedox.h @@ -83,11 +83,10 @@ // Include other in-library and external dependencies #include "VariableBase.h" #include "SensorBase.h" +#include -// Forward declarations -class TwoWire; #if defined(MS_PALEOTERRA_SOFTWAREWIRE) -class SoftwareWire; // Testato's SoftwareWire +#include // Testato's SoftwareWire #endif /** @ingroup sensor_pt_redox */ diff --git a/src/sensors/RainCounterI2C.cpp b/src/sensors/RainCounterI2C.cpp index 684a528e7..bbb91b0f7 100644 --- a/src/sensors/RainCounterI2C.cpp +++ b/src/sensors/RainCounterI2C.cpp @@ -10,11 +10,6 @@ */ #include "RainCounterI2C.h" -#include - -#if defined(MS_RAIN_SOFTWAREWIRE) -#include // Testato's SoftwareWire -#endif // The constructors diff --git a/src/sensors/RainCounterI2C.h b/src/sensors/RainCounterI2C.h index b9cc205a7..6d4c4fa98 100644 --- a/src/sensors/RainCounterI2C.h +++ b/src/sensors/RainCounterI2C.h @@ -90,11 +90,10 @@ // Include other in-library and external dependencies #include "VariableBase.h" #include "SensorBase.h" +#include -// Forward declarations -class TwoWire; #if defined(MS_RAIN_SOFTWAREWIRE) -class SoftwareWire; // Testato's SoftwareWire +#include // Testato's SoftwareWire #endif /** @ingroup sensor_i2c_rain */ From 8640b734d04d0db853596b5f8e867bcc743244e0 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Thu, 12 Mar 2026 15:36:58 -0400 Subject: [PATCH 514/533] Moved more processor specifics into KnownProcessors and use config as override Signed-off-by: Sara Damiano --- cspell.json | 6 + docs/FAQ/Processor-Compatibility.md | 212 ++++++++++++++++++- src/ClockSupport.h | 39 +--- src/{sensors => }/KnownProcessors.h | 314 ++++++++++++++++++++++++++-- src/LogBuffer.h | 25 +-- src/ModSensorConfig.h | 119 ++++++----- src/sensors/AnalogVoltageReader.h | 3 - src/sensors/EverlightALSPT19.h | 3 - src/sensors/ProcessorAnalog.h | 3 - src/sensors/ProcessorStats.h | 3 - src/sensors/TIADS1x15.h | 3 - 11 files changed, 585 insertions(+), 145 deletions(-) rename src/{sensors => }/KnownProcessors.h (54%) diff --git a/cspell.json b/cspell.json index caa57261c..07186ffe2 100644 --- a/cspell.json +++ b/cspell.json @@ -79,6 +79,7 @@ "_TURB_", "Acculevel", "Adafruit", + "Adalogger", "ADCSRA", "Alconox", "Alphasense", @@ -124,6 +125,7 @@ "Dragino", "DreamHost", "DRWI", + "Duemilanove", "eeprom", "ENABLEINTERRUPT", "enviro_diy", @@ -141,6 +143,7 @@ "formazin", "Freescale", "FREQM", + "FTDI", "GCKL", "GCKLGEN", "GCLK", @@ -181,6 +184,7 @@ "MODSENSORDEBUGGER", "MODSENSORINTERRUPTS", "MODULARSENSORS", + "MOSI", "MQTT", "Nanolevel", "NDIR", @@ -223,11 +227,13 @@ "RSSI", "RUNSTBY", "SAMD", + "Sanguino", "SARAR4", "sdamiano", "SDCARD", "SDHC", "Seeed", + "Seeeduino", "Sensirion", "Sequans", "SERCOM", diff --git a/docs/FAQ/Processor-Compatibility.md b/docs/FAQ/Processor-Compatibility.md index e3c03fdd4..70eb3a998 100644 --- a/docs/FAQ/Processor-Compatibility.md +++ b/docs/FAQ/Processor-Compatibility.md @@ -7,21 +7,143 @@ - [Processor Compatibility](#processor-compatibility) + - [Processor Configuration and Adding Support](#processor-configuration-and-adding-support) + - [KnownProcessors.h Documentation](#knownprocessorsh-documentation) + - [Adding New Processor Support](#adding-new-processor-support) + - [Board-Specific Parameters](#board-specific-parameters) + - [Configuration Override](#configuration-override) - [AtMega1284p (EnviroDIY Mayfly, Sodaq Mbili, Mighty 1284)](#atmega1284p-envirodiy-mayfly-sodaq-mbili-mighty-1284) + - [Specific Supported Boards](#specific-supported-boards) + - [Processor Information](#processor-information) - [AtSAMD21 (Arduino Zero, Adafruit Feather M0, Sodaq Autonomo)](#atsamd21-arduino-zero-adafruit-feather-m0-sodaq-autonomo) + - [Specific Supported Boards](#specific-supported-boards-1) + - [Processor Information](#processor-information-1) + - [AtSAMD51 (Adafruit Feather M4, EnviroDIY Stonefly)](#atsamd51-adafruit-feather-m4-envirodiy-stonefly) + - [Specific Supported Boards](#specific-supported-boards-2) + - [Processor Information](#processor-information-2) - [AtMega2560 (Arduino Mega)](#atmega2560-arduino-mega) + - [Specific Supported Boards](#specific-supported-boards-3) + - [Processor Information](#processor-information-3) - [AtMega644p (Sanguino)](#atmega644p-sanguino) + - [Specific Supported Boards](#specific-supported-boards-4) + - [Processor Information](#processor-information-4) - [AtMega328p (Arduino Uno, Duemilanove, LilyPad, Mini, Seeeduino Stalker, etc)](#atmega328p-arduino-uno-duemilanove-lilypad-mini-seeeduino-stalker-etc) + - [Specific Supported Boards](#specific-supported-boards-5) + - [Processor Information](#processor-information-5) - [AtMega32u4 (Arduino Leonardo/Micro, Adafruit Flora/Feather, etc)](#atmega32u4-arduino-leonardomicro-adafruit-florafeather-etc) + - [Specific Supported Boards](#specific-supported-boards-6) + - [Processor Information](#processor-information-6) - [Unsupported Processors](#unsupported-processors) +## Processor Configuration and Adding Support + +The specific processors supported by the ModularSensors library are defined in the [KnownProcessors.h](../src/sensors/KnownProcessors.h) file. This file contains compiler defines for board names, operating voltages, battery monitoring pins, and other board-specific parameters. + +### KnownProcessors.h Documentation + +The [KnownProcessors.h](../src/sensors/KnownProcessors.h) file defines board-specific parameters for optimal configuration: + +**Basic Board Information:** +- `LOGGER_BOARD`: Pretty text name for the board +- `OPERATING_VOLTAGE`: Board operating voltage in volts +- `BATTERY_PIN`: Analog pin for battery voltage monitoring +- `BATTERY_MULTIPLIER`: Voltage divider multiplier for battery measurements +- Built-in ambient light sensor parameters (for compatible boards) + +**ADC Configuration:** + +- `MS_PROCESSOR_ADC_RESOLUTION`: ADC resolution in bits (10 for AVR, 12 for SAMD) + - Only add if the default of 10 for a AVR board or 12 for a SAMD board does not apply +- `MS_PROCESSOR_ADC_REFERENCE_MODE`: Voltage reference (DEFAULT, AR_DEFAULT, AR_EXTERNAL, etc.) + - Only add if the reference mode will not be `DEFAULT` + +**Memory Management:** + +- `MS_LOG_DATA_BUFFER_SIZE`: Log buffer size in bytes (optimized per board's memory) + - Only add if something atypical for this processor is needed + +**Clock Configuration:** + +Only add one of these if the clock chip is integrated into the same circuit board the main processor! + +- `MS_USE_DS3231`: Use DS3231 external RTC +- `MS_USE_RV8803`: Use RV8803 external RTC +- `MS_USE_RTC_ZERO`: Use internal RTC (SAMD21 boards only) + +### Adding New Processor Support + +To add support for a new board of a supported processor type: + +1. **Identify the processor type**: Determine if your board uses an AtMega1284p, AtSAMD21, AtSAMD51, AtMega2560, AtMega644p, AtMega328p, or AtMega32u4 processor. + +2. **Find the Arduino board define**: Use your board's Arduino IDE board definition to identify the compiler define (e.g., `ARDUINO_AVR_UNO` for Arduino Uno). + +3. **Add to KnownProcessors.h**: Add a new `#elif defined()` section with your board's define and set the appropriate parameters: + + ```cpp + #elif defined(YOUR_BOARD_DEFINE) + #define LOGGER_BOARD "Your Board Name" + #define OPERATING_VOLTAGE 3.3 // or 5.0 + #define BATTERY_PIN A0 // or -1 if not available + #define BATTERY_MULTIPLIER 2.0 // or -1 if not available + + // ADC defaults; if and only if needed + #ifndef MS_PROCESSOR_ADC_RESOLUTION + #define MS_PROCESSOR_ADC_RESOLUTION 10 // 10 for AVR, 12 for SAMD + #endif + #ifndef MS_PROCESSOR_ADC_REFERENCE_MODE + #define MS_PROCESSOR_ADC_REFERENCE_MODE DEFAULT // or AR_DEFAULT for SAMD + #endif + + // Log buffer size - adjust for board's memory capacity; if and only if needed + #ifndef MS_LOG_DATA_BUFFER_SIZE + #define MS_LOG_DATA_BUFFER_SIZE 1024 // Adjust based on available RAM + #endif + + // Built in clock; if and only if integrated into the board + #ifndef MS_USE_DS3231 // Choose appropriate RTC for your board + #define MS_USE_DS3231 + #endif + ``` + +4. **Submit contribution**: Create a pull request with your additions to help other users with the same board. + +### Board-Specific Parameters + +Each board entry should specify: + +- **Operating voltage**: Typically 3.3V or 5V +- **Battery monitoring**: Pin and voltage divider information if available +- **Built-in sensors**: Light sensor configuration for boards that include them +- **Clock selection**: Appropriate RTC type for the board's capabilities + - External RTC (DS3231, RV8803) for most AVR boards + - Internal RTC (RTC_ZERO) for SAMD21/SAMD51 boards +- **ADC configuration**: Resolution and reference voltage optimized for the processor +- **Memory management**: Log buffer size appropriate for the board's available RAM + +### Configuration Override + +All board-specific defaults can be overridden in [ModSensorConfig.h](../src/ModSensorConfig.h) if needed: +- Users can uncomment and modify clock, ADC, or buffer size settings +- Build flags can also be used with PlatformIO for custom configurations +- Arduino IDE users should modify ModSensorConfig.h as build flags aren't available + +___ + ## AtMega1284p (EnviroDIY Mayfly, Sodaq Mbili, Mighty 1284) The [EnviroDIY Mayfly](https://envirodiy.org/mayfly/) _is_ the test board for this library. _Everything_ is designed to work with this processor. +### Specific Supported Boards + +- **EnviroDIY Mayfly** (`ARDUINO_AVR_ENVIRODIY_MAYFLY`) +- **SODAQ Mbili** (`ARDUINO_AVR_SODAQ_MBILI`) + +### Processor Information + [Datasheet Summary](https://github.com/EnviroDIY/ModularSensors/wiki/Processor-Datasheets/Atmel-ATmega1284P-Datasheet-Summary.pdf) [Datasheet](https://github.com/EnviroDIY/ModularSensors/wiki/Processor-Datasheets/Atmel-ATmega1284P-Datasheet.pdf) @@ -33,7 +155,7 @@ _Everything_ is designed to work with this processor. CS/SS and CD pins may vary for other boards. - There is a single I2C (Wire) interface on pins 17 (SDA) and 16 (SCL). - This processor has two built-in hardware TTL serial ports, Serial and Serial1 - - On most boards, Serial is connected to the FDTI chip for USB communication with the computer. + - On most boards, Serial is connected to the FTDI chip for USB communication with the computer. On both the Mayfly and the Mbili Serial1 is wired to the "Bee" sockets for communication with the modem. - AltSoftSerial can be used on pins 5 (Tx) and 6 (Rx) on the Mayfly or Mbili. Pin 4 should not be used while using AltSoftSerial on the Mayfly or Mbili. @@ -48,11 +170,23 @@ ___ Fully supported +### Specific Supported Boards + +- **SODAQ ExpLoRer** (`ARDUINO_SODAQ_EXPLORER`) +- **SODAQ Autonomo** (`ARDUINO_SODAQ_AUTONOMO`) +- **SODAQ ONE Beta** (`ARDUINO_SODAQ_ONE_BETA`) +- **SODAQ ONE** (`ARDUINO_SODAQ_ONE`) +- **Adafruit Feather M0 Express** (`ARDUINO_SAMD_FEATHER_M0_EXPRESS`) +- **Adafruit Feather M0** (`ARDUINO_SAMD_FEATHER_M0`) +- **Arduino Zero** (`ARDUINO_SAMD_ZERO`) + +### Processor Information + [Datasheet Summary](https://github.com/EnviroDIY/ModularSensors/wiki/Processor-Datasheets/Atmel-SAMD21-Datasheet-Summary.pdf) [Datasheet](https://github.com/EnviroDIY/ModularSensors/wiki/Processor-Datasheets/Atmel-SAMD21-Datasheet.pdf) -- This processor has an internal real time clock (RTC) and does not require a DS3231 to be installed. +- This processor has an internal real time clock (RTC) and does not **require** an external RTC, though it can be used with one. The built-in RTC is not as accurate as the DS3231, however, and should be synchronized more frequently to keep the time correct. The processor clock will also reset if the system battery dies because unlike most external RTCs, there is no coin battery backing up the clock. At this time, the AtSAMD21 is only supported using the internal clock, but support with a more accurate external RTC is planned. @@ -74,18 +208,44 @@ Fully supported - NeoSWSerial is not supported at all on the AtSAMD21. - Any digital pin can be used with SDI-12. - Because the USB controller is built into the processor, your USB serial connection will close as soon as the processor goes to sleep. - If you need to debug, I recommend using a serial port monitor like [Tera Term](https://ttssh2.osdn.jp/index.html.en) which will automatically renew its connection with the serial port when it connects and disconnects. + If you need to debug, I recommend using a serial port monitor like [Tera Term](https://teratermproject.github.io/index-en.html) which will automatically renew its connection with the serial port when it connects and disconnects. Otherwise, you will have to rely on lights on your alert pin or your modem to verify the processor is waking/sleeping properly. - There are also some oddities with debugging on the SAMD21 where turning on some of the debugging code will cause the native USB to fail (and the board appear to be bricked). Turn off the debugging and double-tap to reset and reprogram if this happens. ___ +## AtSAMD51 (Adafruit Feather M4, EnviroDIY Stonefly) + +Fully supported with similar characteristics to AtSAMD21 but with enhanced performance. + +### Specific Supported Boards + +- **EnviroDIY Stonefly** (`ENVIRODIY_STONEFLY_M4`) +- **Adafruit Feather M4** (`ARDUINO_FEATHER_M4`) +- **Feather M4 CAN** (`ARDUINO_FEATHER_M4_CAN`) +- **Adafruit Feather M4 Adalogger** (`ADAFRUIT_FEATHER_M4_ADALOGGER`) +- **Adafruit Grand Central** (`ADAFRUIT_GRAND_CENTRAL_M4`) + +### Processor Information + +These boards share similar capabilities with the AtSAMD21 processor boards including built-in USB, internal RTC, and multiple hardware serial ports, but with increased processing power and memory. + +___ + ## AtMega2560 (Arduino Mega) Should be fully functional, but untested. -- An external DS3231 or DS3232 RTC is required. +### Specific Supported Boards + +- **Arduino Mega ADK** (`ARDUINO_AVR_ADK`) +- **Arduino Mega** (`ARDUINO_AVR_MEGA`) +- **Arduino Mega 2560** (`ARDUINO_AVR_MEGA2560`) + +### Processor Information + +- An external RTC (DS3231, DS3232, or RV8803) is required. - There is a single SPI port on pins 50 (MISO), 52 (SCK), and 51 (MOSI). Chip select/slave select is on pin 53. - There is a single I2C (Wire) interface on pins 20 (SDA) and 21 (SCL). @@ -100,9 +260,17 @@ ___ Should be fully functional, but untested. -- An external DS3231 or DS3232 RTC is required. +### Specific Supported Boards + +- **SODAQ Ndogo** (`ARDUINO_AVR_SODAQ_NDOGO`) +- **SODAQ Tatu** (`ARDUINO_AVR_SODAQ_TATU`) +- **SODAQ Moja** (`ARDUINO_AVR_SODAQ_MOJA`) + +### Processor Information + +- An external RTC (DS3231, DS3232, or RV8803) is required. - This processor has two built-in hardware serial ports, Serial and Serial1. - On most boards, Serial is connected to the FDTI chip for USB communication with the computer. + On most boards, Serial is connected to the FTDI chip for USB communication with the computer. - There is a single I2C (Wire) interface on pins 17 (SDA) and 16 (SCL). - There is a single SPI port on pins 6 (MISO), 7 (SCK), and 5 (MOSI). Chip select/slave select and card detect pins vary by board. @@ -117,7 +285,23 @@ ___ All functions are supported, but processor doesn't have sufficient power to use all of the functionality of the library. You will only be able to use a small number of sensors at one time and may not be able to log data. -- An external DS3231 or DS3232 RTC is required. +### Specific Supported Boards + +- **Adafruit Feather 328p** (`ARDUINO_AVR_FEATHER328P`) +- **Arduino BT** (`ARDUINO_AVR_BT`) +- **Arduino Duemilanove** (`ARDUINO_AVR_DUEMILANOVE`) +- **Arduino Ethernet** (`ARDUINO_AVR_ETHERNET`) +- **Arduino Fio** (`ARDUINO_AVR_FIO`) +- **Arduino Lilypad** (`ARDUINO_AVR_LILYPAD`) +- **Arduino Mini 05** (`ARDUINO_AVR_MINI`) +- **Arduino Nano** (`ARDUINO_AVR_NANO`) +- **Arduino NG** (`ARDUINO_AVR_NG`) +- **Arduino Pro** (`ARDUINO_AVR_PRO`) +- **Arduino Uno** (`ARDUINO_AVR_UNO`) + +### Processor Information + +- An external RTC (DS3231, DS3232, or RV8803) is required. - There is a singe SPI ports on pins 12 (MISO), 13 (SCK), and 11 (MOSI). Chip select/slave select is pin 10 on an Uno. SS/CS and CD pins may vary for other boards. @@ -134,11 +318,23 @@ ___ All functions are supported, but processor doesn't have sufficient power to use all of the functionality of the library. You will only be able to use a small number of sensors at one time and may not be able to log data. +### Specific Supported Boards + +- **Adafruit Feather 32u4** (`ARDUINO_AVR_FEATHER32U4`) +- **Arduino Esplora** (`ARDUINO_AVR_ESPLORA`) +- **Arduino Gemma** (`ARDUINO_AVR_GEMMA`) +- **Arduino Leonardo** (`ARDUINO_AVR_LEONARDO`) +- **Arduino Lilypad USB** (`ARDUINO_AVR_LILYPAD_USB`) +- **Arduino Micro** (`ARDUINO_AVR_MICRO`) +- **Arduino Yun** (`ARDUINO_AVR_YUN`) + +### Processor Information + [Datasheet Summary](https://github.com/EnviroDIY/ModularSensors/wiki/Processor-Datasheets/Atmel-ATmega16U4-32U4-Datasheet-Summary.pdf) [Datasheet](https://github.com/EnviroDIY/ModularSensors/wiki/Processor-Datasheets/Atmel-ATmega16U4-32U4-Datasheet.pdf) -- An external DS3231 or DS3232 RTC is required. +- An external RTC (DS3231, DS3232, or RV8803) is required. - There is a single SPI port on pins 14 (MISO), 15 (SCK), and 16 (MOSI). Chip select/slave select and card detect pins vary by board. - There is a single I2C (Wire) interface on pins 2 (SDA) and 3 (SCL). diff --git a/src/ClockSupport.h b/src/ClockSupport.h index 1b440dabc..d106f439a 100644 --- a/src/ClockSupport.h +++ b/src/ClockSupport.h @@ -37,36 +37,17 @@ #include #include -// Where possible, use the board's built in clock -#if defined(ENVIRODIY_STONEFLY_M4) && not defined(MS_USE_RV8803) -/** - * @brief Select RV-8803 as the RTC for the EnviroDIY Stonefly. - */ -#define MS_USE_RV8803 -#undef MS_USE_DS3231 -#undef MS_USE_RTC_ZERO -#elif defined(ARDUINO_AVR_ENVIRODIY_MAYFLY) && not defined(MS_USE_DS3231) -/** - * @brief Select DS3231 as the RTC for the EnviroDIY Mayfly. - */ -#define MS_USE_DS3231 -#undef MS_USE_RV8803 -#undef MS_USE_RTC_ZERO -#elif (defined(ARDUINO_ARCH_SAMD) && !defined(__SAMD51__)) && \ - !defined(MS_USE_DS3231) && !defined(MS_USE_RV8803) && \ - !defined(MS_USE_RTC_ZERO) -/** - * @brief Select the SAMD21's internal clock (via RTC Zero) if no other RTC is - * specified. - */ -#define MS_USE_RTC_ZERO -#undef MS_USE_RV8803 -#undef MS_USE_DS3231 -#endif - -#if !defined(MS_USE_RV8803) && !defined(MS_USE_DS3231) && \ +// Validate that exactly one clock has been selected (should be set by +// KnownProcessors.h) +#if defined(MS_USE_RV8803) && defined(MS_USE_DS3231) +#error Multiple clocks defined! Only one of MS_USE_RV8803, MS_USE_DS3231, or MS_USE_RTC_ZERO can be selected at a time. +#elif defined(MS_USE_RV8803) && defined(MS_USE_RTC_ZERO) +#error Multiple clocks defined! Only one of MS_USE_RV8803, MS_USE_DS3231, or MS_USE_RTC_ZERO can be selected at a time. +#elif defined(MS_USE_DS3231) && defined(MS_USE_RTC_ZERO) +#error Multiple clocks defined! Only one of MS_USE_RV8803, MS_USE_DS3231, or MS_USE_RTC_ZERO can be selected at a time. +#elif !defined(MS_USE_RV8803) && !defined(MS_USE_DS3231) && \ !defined(MS_USE_RTC_ZERO) -#error Define a clock to use for the RTC for Modular Sensors! +#error No clock defined! Define exactly one of MS_USE_RV8803, MS_USE_DS3231, or MS_USE_RTC_ZERO for the RTC. Check that KnownProcessors.h is properly setting defaults for your board, or select a clock in ModSensorConfig.h for other processors. #endif /** diff --git a/src/sensors/KnownProcessors.h b/src/KnownProcessors.h similarity index 54% rename from src/sensors/KnownProcessors.h rename to src/KnownProcessors.h index 0496ff65b..adf528eba 100644 --- a/src/sensors/KnownProcessors.h +++ b/src/KnownProcessors.h @@ -60,7 +60,12 @@ * undefined* when no built-in ALS is available on the board. */ + +//============================================================== // EnviroDIY boards +//============================================================== + +// https://envirodiy.org/mayfly/ #if defined(ARDUINO_AVR_ENVIRODIY_MAYFLY) #define LOGGER_BOARD "EnviroDIY Mayfly" #define OPERATING_VOLTAGE 3.3 @@ -70,6 +75,14 @@ #define BUILT_IN_ALS_DATA_PIN A4 #define BUILT_IN_ALS_SUPPLY_VOLTAGE 3.3 #define BUILT_IN_ALS_LOADING_RESISTANCE 10 +// Use ADC defaults for an AVR processor +// Use log buffer size defaults +// Built in DS3231 RTC +#ifndef MS_USE_DS3231 +#define MS_USE_DS3231 +#endif + +// https://envirodiy.org/stonefly/ #elif defined(ENVIRODIY_STONEFLY_M4) #define LOGGER_BOARD "EnviroDIY Stonefly" #define OPERATING_VOLTAGE 3.3 @@ -79,197 +92,464 @@ #define BUILT_IN_ALS_DATA_PIN A8 #define BUILT_IN_ALS_SUPPLY_VOLTAGE 3.3 #define BUILT_IN_ALS_LOADING_RESISTANCE 10 +// Use ADC defaults for a SAMD processor +// Use log buffer size defaults +// Built in RV-8803 RTC +#ifndef MS_USE_RV8803 +#define MS_USE_RV8803 +#endif + +//============================================================== // Sodaq boards +//============================================================== + +// https://learn.sodaq.com/Boards/ExpLoRer/ (Discontinued) #elif defined(ARDUINO_SODAQ_EXPLORER) #define LOGGER_BOARD "SODAQ ExpLoRer" #define OPERATING_VOLTAGE 3.3 #define BATTERY_PIN -1 #define BATTERY_MULTIPLIER -1 +// Use ADC defaults for a SAMD processor +// Use log buffer size defaults +// Use the processor as an RTC +#ifndef MS_USE_RTC_ZERO +#define MS_USE_RTC_ZERO +#endif + +// https://learn.sodaq.com/Boards/Autonomo/ (Discontinued) #elif defined(ARDUINO_SODAQ_AUTONOMO) #define LOGGER_BOARD "SODAQ Autonomo" #define OPERATING_VOLTAGE 3.3 #define BATTERY_PIN 48 // for version v0.1 #define BATTERY_MULTIPLIER 1.47 +// Use ADC defaults for a SAMD processor +// Use log buffer size defaults +// Use the processor as an RTC +#ifndef MS_USE_RTC_ZERO +#define MS_USE_RTC_ZERO +#endif + +// https://learn.sodaq.com/Boards/One/base/ (Discontinued) #elif defined(ARDUINO_SODAQ_ONE_BETA) #define LOGGER_BOARD "SODAQ ONE Beta" #define OPERATING_VOLTAGE 3.3 #define BATTERY_PIN 10 #define BATTERY_MULTIPLIER 2 // for version v0.1 +// Use ADC defaults for a SAMD processor +// Use log buffer size defaults +// Use the processor as an RTC +#ifndef MS_USE_RTC_ZERO +#define MS_USE_RTC_ZERO +#endif + +// https://learn.sodaq.com/Boards/One/base/ (Discontinued) #elif defined(ARDUINO_SODAQ_ONE) #define LOGGER_BOARD "SODAQ ONE" #define OPERATING_VOLTAGE 3.3 #define BATTERY_PIN 10 #define BATTERY_MULTIPLIER 2 // for version v0.1 +// Use ADC defaults for a SAMD processor +// Use log buffer size defaults +// Use the processor as an RTC +#ifndef MS_USE_RTC_ZERO +#define MS_USE_RTC_ZERO +#endif + +// https://learn.sodaq.com/Boards/Mbili/ (Discontinued) #elif defined(ARDUINO_AVR_SODAQ_MBILI) #define LOGGER_BOARD "SODAQ Mbili" #define OPERATING_VOLTAGE 3.3 #define BATTERY_PIN A6 #define BATTERY_MULTIPLIER 1.47 +// Use ADC defaults for an AVR processor +// Use log buffer size defaults +// Built in DS3231 RTC +#ifndef MS_USE_DS3231 +#define MS_USE_DS3231 +#endif + +// https://support.sodaq.com/Boards/NDOGO (Discontinued) #elif defined(ARDUINO_AVR_SODAQ_NDOGO) #define LOGGER_BOARD "SODAQ Ndogo" #define OPERATING_VOLTAGE 3.3 #define BATTERY_PIN 10 #define BATTERY_MULTIPLIER 1.47 +// Use ADC defaults for an AVR processor +// Use log buffer size defaults +// An external RTC is required + +// https://support.sodaq.com/Boards/TATU (Discontinued) #elif defined(ARDUINO_AVR_SODAQ_TATU) #define LOGGER_BOARD "SODAQ Tatu" #define OPERATING_VOLTAGE 3.3 #define BATTERY_PIN -1 #define BATTERY_MULTIPLIER -1 +// Use ADC defaults for an AVR processor +// Use log buffer size defaults +// An external RTC is required + +// https://support.sodaq.com/Boards/MOJA (Discontinued) #elif defined(ARDUINO_AVR_SODAQ_MOJA) #define LOGGER_BOARD "SODAQ Moja" #define OPERATING_VOLTAGE 3.3 #define BATTERY_PIN -1 #define BATTERY_MULTIPLIER -1 +// Use ADC defaults for an AVR processor +// Use log buffer size defaults +// An external RTC is required + +//============================================================== // Adafruit boards +//============================================================== + +// https://www.adafruit.com/product/3458 #elif defined(ARDUINO_AVR_FEATHER328P) #define LOGGER_BOARD "Adafruit Feather 328p" #define OPERATING_VOLTAGE 3.3 #define BATTERY_PIN 9 #define BATTERY_MULTIPLIER 2 +// Use ADC defaults for an AVR processor +// Use log buffer size defaults +// An external RTC is required + +// https://www.adafruit.com/product/2771 #elif defined(ARDUINO_AVR_FEATHER32U4) #define LOGGER_BOARD "Adafruit Feather 32u4" #define OPERATING_VOLTAGE 3.3 #define BATTERY_PIN 9 #define BATTERY_MULTIPLIER 2 +// Use ADC defaults for an AVR processor +// Use log buffer size defaults +// An external RTC is required + +// https://www.adafruit.com/product/3403 #elif defined(ARDUINO_SAMD_FEATHER_M0_EXPRESS) || \ defined(ADAFRUIT_FEATHER_M0_EXPRESS) #define LOGGER_BOARD "Adafruit Feather M0 Express" #define OPERATING_VOLTAGE 3.3 #define BATTERY_PIN 9 #define BATTERY_MULTIPLIER 2 +// Use ADC defaults for a SAMD processor +// Use log buffer size defaults +// Use the processor as an RTC +#ifndef MS_USE_RTC_ZERO +#define MS_USE_RTC_ZERO +#endif + +// https://www.adafruit.com/product/2772 #elif defined(ARDUINO_SAMD_FEATHER_M0) || defined(ADAFRUIT_FEATHER_M0) #define LOGGER_BOARD "Adafruit Feather M0" #define OPERATING_VOLTAGE 3.3 #define BATTERY_PIN 9 #define BATTERY_MULTIPLIER 2 +// Use ADC defaults for a SAMD processor +// Use log buffer size defaults +// Use the processor as an RTC +#ifndef MS_USE_RTC_ZERO +#define MS_USE_RTC_ZERO +#endif + +// https://www.adafruit.com/product/2796 +#elif defined(ADAFRUIT_FEATHER_M0_ADALOGGER) +#define LOGGER_BOARD "Adafruit Feather M0 Adalogger" +#define OPERATING_VOLTAGE 3.3 +#define BATTERY_PIN 9 +#define BATTERY_MULTIPLIER 2 +// Use ADC defaults for a SAMD processor +// Use log buffer size defaults +// Use the processor as an RTC +#ifndef MS_USE_RTC_ZERO +#define MS_USE_RTC_ZERO +#endif + +// https://www.adafruit.com/product/3857 #elif defined(ARDUINO_FEATHER_M4) || defined(ADAFRUIT_FEATHER_M4_EXPRESS) #define LOGGER_BOARD "Adafruit Feather M4" #define OPERATING_VOLTAGE 3.3 #define BATTERY_PIN 9 #define BATTERY_MULTIPLIER 2 +// Use ADC defaults for a SAMD processor +// Use log buffer size defaults +// An external RTC is required + +// https://www.adafruit.com/product/4759 #elif defined(ARDUINO_FEATHER_M4_CAN) || defined(ADAFRUIT_FEATHER_M4_CAN) #define LOGGER_BOARD "Feather M4 CAN" #define OPERATING_VOLTAGE 3.3 #define BATTERY_PIN 9 #define BATTERY_MULTIPLIER 2 -#elif defined(ADAFRUIT_FEATHER_M4_ADALOGGER) -#define LOGGER_BOARD "Adafruit Feather M4 Adalogger" -#define OPERATING_VOLTAGE 3.3 -#define BATTERY_PIN 9 -#define BATTERY_MULTIPLIER 2 +// Use ADC defaults for a SAMD processor +// Use log buffer size defaults +// An external RTC is required + +// https://www.adafruit.com/product/4064 #elif defined(ADAFRUIT_GRAND_CENTRAL_M4) #define LOGGER_BOARD "Adafruit Grand Central" #define OPERATING_VOLTAGE 3.3 #define BATTERY_PIN -1 #define BATTERY_MULTIPLIER -1 +// Use ADC defaults for a SAMD processor +// Use log buffer size defaults +// An external RTC is required -// Arduino boards + +//============================================================== +// Official Arduino boards +//============================================================== + +// https://docs.arduino.cc/retired/boards/arduino-mega-adk-rev3/ (Retired) #elif defined(ARDUINO_AVR_ADK) #define LOGGER_BOARD "Arduino Mega ADK" #define OPERATING_VOLTAGE 5 #define BATTERY_PIN -1 #define BATTERY_MULTIPLIER -1 -// Bluetooth +// Use ADC defaults for an AVR processor +// Use log buffer size defaults +// An external RTC is required + +// https://docs.arduino.cc/retired/boards/arduino-mega/ (Retired) +#elif defined(ARDUINO_AVR_MEGA) +#define LOGGER_BOARD "Arduino Mega" +#define OPERATING_VOLTAGE 5 +#define BATTERY_PIN -1 +#define BATTERY_MULTIPLIER -1 +// Use ADC defaults for an AVR processor +// Use log buffer size defaults +// An external RTC is required + +// https://store-usa.arduino.cc/products/arduino-mega-2560-rev3 +#elif defined(ARDUINO_AVR_MEGA2560) +#define LOGGER_BOARD "Arduino Mega 2560" +#define OPERATING_VOLTAGE 5 +#define BATTERY_PIN -1 +#define BATTERY_MULTIPLIER -1 +// Use ADC defaults for an AVR processor +// Use log buffer size defaults +// An external RTC is required + +// https://docs.arduino.cc/retired/getting-started-guides/ArduinoBT/ (Retired) #elif defined(ARDUINO_AVR_BT) #define LOGGER_BOARD "Arduino BT" #define OPERATING_VOLTAGE 5 #define BATTERY_PIN -1 #define BATTERY_MULTIPLIER -1 +// Use ADC defaults for an AVR processor +// Use log buffer size defaults +// An external RTC is required + +// https://docs.arduino.cc/retired/boards/arduino-duemilanove/ (Retired) #elif defined(ARDUINO_AVR_DUEMILANOVE) #define LOGGER_BOARD "Arduino Duemilanove" #define OPERATING_VOLTAGE 5 #define BATTERY_PIN -1 #define BATTERY_MULTIPLIER -1 +// Use ADC defaults for an AVR processor +// Use log buffer size defaults +// An external RTC is required + +// https://docs.arduino.cc/retired/boards/arduino-esplora/ (Retired) #elif defined(ARDUINO_AVR_ESPLORA) #define LOGGER_BOARD "Arduino Esplora" #define OPERATING_VOLTAGE 5 #define BATTERY_PIN -1 #define BATTERY_MULTIPLIER -1 +// Use ADC defaults for an AVR processor +// Use log buffer size defaults +// An external RTC is required + +// https://docs.arduino.cc/retired/boards/arduino-ethernet-rev3-without-poe/ (Retired) #elif defined(ARDUINO_AVR_ETHERNET) #define LOGGER_BOARD "Arduino Ethernet" #define OPERATING_VOLTAGE 5 #define BATTERY_PIN -1 #define BATTERY_MULTIPLIER -1 +// Use ADC defaults for an AVR processor +// Use log buffer size defaults +// An external RTC is required + +// https://docs.arduino.cc/retired/boards/arduino-fio/ (Retired) #elif defined(ARDUINO_AVR_FIO) #define LOGGER_BOARD "Arduino Fio" #define OPERATING_VOLTAGE 3.3 #define BATTERY_PIN -1 #define BATTERY_MULTIPLIER -1 +// Use ADC defaults for an AVR processor +// Use log buffer size defaults +// An external RTC is required + +// Arduino version: https://docs.arduino.cc/retired/boards/arduino-gemma/ (Retired) +// Adafruit version: https://www.adafruit.com/product/1222 #elif defined(ARDUINO_AVR_GEMMA) #define LOGGER_BOARD "Arduino Gemma" #define OPERATING_VOLTAGE 3.3 #define BATTERY_PIN -1 #define BATTERY_MULTIPLIER -1 +// Use ADC defaults for an AVR processor +// Use log buffer size defaults +// An external RTC is required + +// https://docs.arduino.cc/hardware/leonardo/ (Retired) #elif defined(ARDUINO_AVR_LEONARDO) #define LOGGER_BOARD "Arduino Leonardo" #define OPERATING_VOLTAGE 5 #define BATTERY_PIN -1 #define BATTERY_MULTIPLIER -1 +// Use ADC defaults for an AVR processor +// Use log buffer size defaults +// An external RTC is required + +// https://docs.arduino.cc/retired/getting-started-guides/ArduinoLilyPad/ +// (Retired) #elif defined(ARDUINO_AVR_LILYPAD) #define LOGGER_BOARD "Arduino Lilypad" // NOTE: The operating voltage is 2.7-5.5V #define OPERATING_VOLTAGE 3.3 #define BATTERY_PIN -1 #define BATTERY_MULTIPLIER -1 +// Use ADC defaults for an AVR processor +// Use log buffer size defaults +// An external RTC is required + +// https://docs.arduino.cc/retired/getting-started-guides/ArduinoLilyPadUSB/ +// (Retired) #elif defined(ARDUINO_AVR_LILYPAD_USB) #define LOGGER_BOARD "Arduino Lilypad USB" #define OPERATING_VOLTAGE 3.3 #define BATTERY_PIN -1 #define BATTERY_MULTIPLIER -1 -#elif defined(ARDUINO_AVR_MEGA) -#define LOGGER_BOARD "Arduino Mega" -#define OPERATING_VOLTAGE 5 -#define BATTERY_PIN -1 -#define BATTERY_MULTIPLIER -1 -#elif defined(ARDUINO_AVR_MEGA2560) -#define LOGGER_BOARD "Arduino Mega 2560" -#define OPERATING_VOLTAGE 5 -#define BATTERY_PIN -1 -#define BATTERY_MULTIPLIER -1 +// Use ADC defaults for an AVR processor +// Use log buffer size defaults +// An external RTC is required + +// https://store-usa.arduino.cc/products/arduino-micro #elif defined(ARDUINO_AVR_MICRO) #define LOGGER_BOARD "Arduino Micro" #define OPERATING_VOLTAGE 5 #define BATTERY_PIN -1 #define BATTERY_MULTIPLIER -1 +// Use ADC defaults for an AVR processor +// Use log buffer size defaults +// An external RTC is required + +// https://docs.arduino.cc/retired/boards/arduino-mini-05/ (Retired) #elif defined(ARDUINO_AVR_MINI) #define LOGGER_BOARD "Arduino Mini 05" #define OPERATING_VOLTAGE 5 #define BATTERY_PIN -1 #define BATTERY_MULTIPLIER -1 +// Use ADC defaults for an AVR processor +// Use log buffer size defaults +// An external RTC is required + +// https://store-usa.arduino.cc/products/arduino-nano #elif defined(ARDUINO_AVR_NANO) #define LOGGER_BOARD "Arduino Nano" #define OPERATING_VOLTAGE 5 #define BATTERY_PIN -1 #define BATTERY_MULTIPLIER -1 +// Use ADC defaults for an AVR processor +// Use log buffer size defaults +// An external RTC is required + +// https://docs.arduino.cc/retired/boards/arduino-ng/ (Retired) #elif defined(ARDUINO_AVR_NG) #define LOGGER_BOARD "Arduino NG" // WARNING: I can't find confirmation of the operating voltage online! #define OPERATING_VOLTAGE 5 #define BATTERY_PIN -1 #define BATTERY_MULTIPLIER -1 +// Use ADC defaults for an AVR processor +// Use log buffer size defaults +// An external RTC is required + +// https://docs.arduino.cc/retired/boards/arduino-pro/ (Retired) #elif defined(ARDUINO_AVR_PRO) #define LOGGER_BOARD "Arduino Pro" // NOTE: The operating voltage is 3.3V or 5V depending on the model #define OPERATING_VOLTAGE 5 #define BATTERY_PIN -1 #define BATTERY_MULTIPLIER -1 +// Use ADC defaults for an AVR processor +// Use log buffer size defaults +// An external RTC is required + +// https://store-usa.arduino.cc/products/arduino-uno-rev3 #elif defined(ARDUINO_AVR_UNO) #define LOGGER_BOARD "Arduino Uno" #define OPERATING_VOLTAGE 5 #define BATTERY_PIN -1 #define BATTERY_MULTIPLIER -1 +// Use ADC defaults for an AVR processor +// Use log buffer size defaults +// An external RTC is required + +// https://docs.arduino.cc/retired/boards/arduino-yun/ (Retired) #elif defined(ARDUINO_AVR_YUN) #define LOGGER_BOARD "Arduino Yun" #define OPERATING_VOLTAGE 5 #define BATTERY_PIN -1 #define BATTERY_MULTIPLIER -1 +// Use ADC defaults for an AVR processor +// Use log buffer size defaults +// An external RTC is required + +// https://docs.arduino.cc/hardware/zero/ #elif defined(ARDUINO_SAMD_ZERO) #define LOGGER_BOARD "Arduino Zero" #define OPERATING_VOLTAGE 3.3 #define BATTERY_PIN -1 #define BATTERY_MULTIPLIER -1 +// Use ADC defaults for a SAMD processor +// Use log buffer size defaults +// Use the processor as an RTC +#ifndef MS_USE_RTC_ZERO +#define MS_USE_RTC_ZERO +#endif + + +#endif + +// Default ADC settings for unknown processors +// These provide fallbacks when board-specific settings aren't available +#ifndef MS_PROCESSOR_ADC_RESOLUTION +// Fallback ADC resolution based on processor architecture +#if defined(__AVR__) || defined(ARDUINO_ARCH_AVR) +#define MS_PROCESSOR_ADC_RESOLUTION 10 +#elif defined(ARDUINO_ARCH_SAMD) +#define MS_PROCESSOR_ADC_RESOLUTION 12 +#else +#define MS_PROCESSOR_ADC_RESOLUTION 10 // Conservative default +#endif +#endif + +#ifndef MS_PROCESSOR_ADC_REFERENCE_MODE +// Fallback ADC reference mode based on processor architecture +#if defined(ARDUINO_ARCH_AVR) +#define MS_PROCESSOR_ADC_REFERENCE_MODE DEFAULT +#elif defined(ARDUINO_ARCH_SAMD) +#define MS_PROCESSOR_ADC_REFERENCE_MODE AR_DEFAULT +#else +#define MS_PROCESSOR_ADC_REFERENCE_MODE DEFAULT // Conservative default +#endif +#endif + +#ifndef MS_LOG_DATA_BUFFER_SIZE +// Fallback log buffer size based on processor type +#if defined(__SAMD51__) +#define MS_LOG_DATA_BUFFER_SIZE 8192 +#elif defined(ARDUINO_ARCH_SAMD) +#define MS_LOG_DATA_BUFFER_SIZE 4096 +#elif defined(__AVR_ATmega1284P__) +#define MS_LOG_DATA_BUFFER_SIZE 1024 // 1284p has good memory +#elif defined(__AVR_ATmega2560__) +#define MS_LOG_DATA_BUFFER_SIZE 512 // Mega has moderate memory +#elif defined(__AVR_ATmega328P__) || defined(__AVR_ATmega328__) +#define MS_LOG_DATA_BUFFER_SIZE 256 // 328p has limited memory +#else +#define MS_LOG_DATA_BUFFER_SIZE 1024 // Conservative default +#endif #endif // Print warnings if expected processor defines are missing diff --git a/src/LogBuffer.h b/src/LogBuffer.h index c965c6046..79f94ee7d 100644 --- a/src/LogBuffer.h +++ b/src/LogBuffer.h @@ -13,28 +13,9 @@ #ifndef SRC_LOGBUFFER_H_ #define SRC_LOGBUFFER_H_ -#ifndef MS_LOG_DATA_BUFFER_SIZE -#ifdef ARDUINO_AVR_MEGA2560 -#define MS_LOG_DATA_BUFFER_SIZE 512 -#elif defined(ARDUINO_AVR_UNO) || defined(ARDUINO_AVR_NANO) -#define MS_LOG_DATA_BUFFER_SIZE 256 -#elif defined(__AVR_ATmega1284P__) -#define MS_LOG_DATA_BUFFER_SIZE 2048 -#else -/** - * @brief Log Data Buffer - * - * This determines how much RAM is reserved to buffer log records before - * transmission. Each record consumes 4 bytes for the timestamp plus 4 bytes - * for each logged variable. Increasing this value too far can crash the - * device! The number of log records buffered is controlled by sendEveryX. - * - * This can be changed by setting the build flag MS_LOG_DATA_BUFFER_SIZE when - * compiling. 8192 bytes is a safe value for the Mayfly 1.1 with six variables. - */ -#define MS_LOG_DATA_BUFFER_SIZE 8192 -#endif -#endif +// Include ModSensorConfig.h which defines MS_LOG_DATA_BUFFER_SIZE +// (set automatically in KnownProcessors.h for supported boards) +#include "ModSensorConfig.h" #include #include diff --git a/src/ModSensorConfig.h b/src/ModSensorConfig.h index 48ea2c564..4c98042b9 100644 --- a/src/ModSensorConfig.h +++ b/src/ModSensorConfig.h @@ -29,10 +29,15 @@ // Include Arduino.h to ensure variants file is pulled first #include +// Include the known processors for default values +#include "KnownProcessors.h" + //============================================================== // Select the Real Time Clock to use by uncommenting one of the options below. -// NOTE: This is optional for a EnviroDIY Mayfly or Stonefly but **REQUIRED** -// for all other boards! +// NOTE: For supported boards (EnviroDIY Mayfly, Stonefly, SAMD21 boards), +// appropriate RTC defaults are automatically selected in KnownProcessors.h. +// Only uncomment these options to OVERRIDE the automatic selection. +// For unsupported boards, you MUST uncomment one option. // #define MS_USE_RV8803 // #define MS_USE_DS3231 // #define MS_USE_RTC_ZERO @@ -161,20 +166,20 @@ static_assert(MAX_NUMBER_SENSORS > 0 && MAX_NUMBER_SENSORS <= 50, * higher than what your processor actually supports. This does **not** apply to * the TI ADS1115 or ADS1015 external ADS. * - * The default for AVR boards is 10 and for SAMD boards is 12. The library - * currently only supports AVR and SAMD platforms. + * For supported boards, appropriate defaults are set in KnownProcessors.h: + * - AVR boards: 10 bits + * - SAMD boards: 12 bits + * + * Uncomment the line below only to OVERRIDE the automatic selection. + * The library currently only supports AVR and SAMD platforms. * * Future note: The ESP32 has a 12 bit ADC and the ESP8266 has a 10 bit ADC. */ -#if defined(__AVR__) || defined(ARDUINO_ARCH_AVR) -#define MS_PROCESSOR_ADC_RESOLUTION 10 -#elif defined(ARDUINO_ARCH_SAMD) -#define MS_PROCESSOR_ADC_RESOLUTION 12 +// #define MS_PROCESSOR_ADC_RESOLUTION 12 #endif #if !defined(MS_PROCESSOR_ADC_RESOLUTION) #error The processor ADC resolution must be defined! #endif // MS_PROCESSOR_ADC_RESOLUTION -#endif // Static assert to validate ADC resolution is reasonable static_assert(MS_PROCESSOR_ADC_RESOLUTION >= 8 && MS_PROCESSOR_ADC_RESOLUTION <= 16, @@ -202,62 +207,40 @@ static_assert(MS_PROCESSOR_ANALOG_MAX_CHANNEL > 0 && "MS_PROCESSOR_ANALOG_MAX_CHANNEL must be between 1 and 255"); #if !defined(MS_PROCESSOR_ADC_REFERENCE_MODE) || defined(DOXYGEN) -#if defined(ARDUINO_ARCH_AVR) || defined(DOXYGEN) /** * @brief The voltage reference mode for the processor's ADC. * - * For an AVR board, this must be one of: - * - `DEFAULT`: the default built-in analog reference of 5 volts (on 5V Arduino - * boards) or 3.3 volts (on 3.3V Arduino boards) - * - `INTERNAL`: a built-in reference, equal to 1.1 volts on the ATmega168 or - * ATmega328P and 2.56 volts on the ATmega32U4 and ATmega8 (not available on the - * Arduino Mega) - * - `INTERNAL1V1`: a built-in 1.1V reference (Arduino Mega only) - * - `INTERNAL2V56`: a built-in 2.56V reference (Arduino Mega only) - * - `EXTERNAL`: the voltage applied to the AREF pin (0 to 5V only) is used as - * the reference. - * - * If not set on an AVR board `DEFAULT` is used. - * - * For the best accuracy, use an `EXTERNAL` reference with the AREF pin - * connected to the power supply for the EC sensor. - */ -#define MS_PROCESSOR_ADC_REFERENCE_MODE DEFAULT -#endif -#if defined(ARDUINO_ARCH_SAMD) || defined(DOXYGEN) -/** - * @brief The voltage reference mode for the processor's ADC. - * - * For a SAMD board, this must be one of: - * - `AR_DEFAULT`: the default built-in analog reference of 3.3V - * - `AR_INTERNAL`: a built-in 2.23V reference - * - `AR_INTERNAL1V0`: a built-in 1.0V reference - * - `AR_INTERNAL1V65`: a built-in 1.65V reference - * - `AR_INTERNAL2V23`: a built-in 2.23V reference - * - `AR_EXTERNAL`: the voltage applied to the AREF pin is used as the reference - * - * If not set on an SAMD board `AR_DEFAULT` is used. - * - * For the best accuracy, use an `AR_EXTERNAL` reference with the AREF pin - * connected to the power supply for the EC sensor. On most Adafruit SAMD51 - * boards, there is an optional solder jumper to connect the AREF pin to - * the 3.3V supply. I suggest you close the jumper! On an EnviroDIY Stonefly, - * there is also a solder jumper, but on the Stonefly the jumper is *closed by - * default.* + * For supported boards, appropriate defaults are set in KnownProcessors.h. + * Uncomment one of the options below only to OVERRIDE the automatic selection. + * + * For AVR boards, valid options are: + * - `DEFAULT`: default built-in analog reference (5V or 3.3V depending on + * board) + * - `INTERNAL`: built-in reference (1.1V on ATmega168/328P, 2.56V on + * ATmega32U4) + * - `INTERNAL1V1`: built-in 1.1V reference (Arduino Mega only) + * - `INTERNAL2V56`: built-in 2.56V reference (Arduino Mega only) + * - `EXTERNAL`: voltage applied to AREF pin (0 to 5V) + * + * For SAMD boards, valid options are: + * - `AR_DEFAULT`: default built-in analog reference (3.3V) + * - `AR_INTERNAL`: built-in 2.23V reference + * - `AR_INTERNAL1V0`: built-in 1.0V reference + * - `AR_INTERNAL1V65`: built-in 1.65V reference + * - `AR_INTERNAL2V23`: built-in 2.23V reference + * - `AR_EXTERNAL`: voltage applied to AREF pin + * + * For best accuracy, use EXTERNAL/AR_EXTERNAL with AREF connected to sensor + * supply. * * @see * https://www.arduino.cc/reference/en/language/functions/analog-io/analogreference/ */ -#if defined(ENVIRODIY_STONEFLY_M4) -#define MS_PROCESSOR_ADC_REFERENCE_MODE AR_EXTERNAL -#else -#define MS_PROCESSOR_ADC_REFERENCE_MODE AR_DEFAULT -#endif +// #define MS_PROCESSOR_ADC_REFERENCE_MODE AR_EXTERNAL #endif #if !defined(MS_PROCESSOR_ADC_REFERENCE_MODE) #error The processor ADC reference type must be defined! #endif // MS_PROCESSOR_ADC_REFERENCE_MODE -#endif //============================================================== @@ -357,6 +340,7 @@ static_assert(MS_SEA_LEVEL_PRESSURE_HPA >= 800.0f && // Upper limit of 16 is set to constrain memory usage and array sizing static_assert(MAX_NUMBER_SENDERS >= 0 && MAX_NUMBER_SENDERS <= 16, "MAX_NUMBER_SENDERS must be between 0 and 16"); + #ifndef MS_ALWAYS_FLUSH_PUBLISHERS /** * @brief Set this to true to always force publishers to attempt to transmit @@ -366,6 +350,33 @@ static_assert(MAX_NUMBER_SENDERS >= 0 && MAX_NUMBER_SENDERS <= 16, #define MS_ALWAYS_FLUSH_PUBLISHERS false #endif +#ifndef MS_LOG_DATA_BUFFER_SIZE +/** + * @brief Log Data Buffer + * + * This determines how much RAM is reserved to buffer log records before + * transmission. Each record consumes 4 bytes for the timestamp plus 4 bytes + * for each logged variable. Increasing this value too far can crash the + * device! The number of log records buffered is controlled by sendEveryX. + * + * For supported boards, appropriate defaults are set in KnownProcessors.h: + * - ATmega1284p (Mayfly): 8192 bytes + * - ATmega2560 (Mega): 512 bytes + * - ATmega328p (Uno/Nano): 256 bytes + * - SAMD21/SAMD51: 1024 bytes (default) + * + * Uncomment the line below only to OVERRIDE the automatic selection. + * This can also be changed by setting the build flag MS_LOG_DATA_BUFFER_SIZE + * when compiling. 8192 bytes is a safe value for the Mayfly 1.1 with six + * variables. + */ +// #define MS_LOG_DATA_BUFFER_SIZE 1024 +#endif +// Static assert to validate log buffer size is reasonable +static_assert(MS_LOG_DATA_BUFFER_SIZE >= 64 && MS_LOG_DATA_BUFFER_SIZE <= 16384, + "MS_LOG_DATA_BUFFER_SIZE must be between 64 and 16384 bytes"); + + #ifndef MS_SEND_BUFFER_SIZE /** * @brief Send Buffer diff --git a/src/sensors/AnalogVoltageReader.h b/src/sensors/AnalogVoltageReader.h index d6997ef8b..ce402f81d 100644 --- a/src/sensors/AnalogVoltageReader.h +++ b/src/sensors/AnalogVoltageReader.h @@ -23,9 +23,6 @@ // Include the debugging config #include "ModSensorDebugConfig.h" -// Include the known processors for default values -#include "KnownProcessors.h" - // Define the print label[s] for the debugger #ifdef MS_ANALOGVOLTAGEREADER_DEBUG #define MS_DEBUGGING_STD "AnalogVoltageReader" diff --git a/src/sensors/EverlightALSPT19.h b/src/sensors/EverlightALSPT19.h index 19fe7278e..de3478c1c 100644 --- a/src/sensors/EverlightALSPT19.h +++ b/src/sensors/EverlightALSPT19.h @@ -52,9 +52,6 @@ // Include the library config before anything else #include "ModSensorConfig.h" -// Include the known processors for default values -#include "KnownProcessors.h" - // Include the debugging config #include "ModSensorDebugConfig.h" diff --git a/src/sensors/ProcessorAnalog.h b/src/sensors/ProcessorAnalog.h index bfa20cc0c..4a771d609 100644 --- a/src/sensors/ProcessorAnalog.h +++ b/src/sensors/ProcessorAnalog.h @@ -60,9 +60,6 @@ // Include the debugging config #include "ModSensorDebugConfig.h" -// Include the known processors for default values -#include "KnownProcessors.h" - // Define the print label[s] for the debugger #ifdef MS_PROCESSOR_ANALOG_DEBUG #define MS_DEBUGGING_STD "ProcessorAnalog" diff --git a/src/sensors/ProcessorStats.h b/src/sensors/ProcessorStats.h index cada0461f..a38ebd833 100644 --- a/src/sensors/ProcessorStats.h +++ b/src/sensors/ProcessorStats.h @@ -62,9 +62,6 @@ // Include the debugging config #include "ModSensorDebugConfig.h" -// Include the known processors for default values -#include "KnownProcessors.h" - // Define the print label[s] for the debugger #ifdef MS_PROCESSORSTATS_DEBUG #define MS_DEBUGGING_STD "ProcessorStats" diff --git a/src/sensors/TIADS1x15.h b/src/sensors/TIADS1x15.h index 84d2976ea..11d4b345e 100644 --- a/src/sensors/TIADS1x15.h +++ b/src/sensors/TIADS1x15.h @@ -154,9 +154,6 @@ // Include the debugging config #include "ModSensorDebugConfig.h" -// Include known processor settings for default operating voltage -#include "KnownProcessors.h" - // Define the print label[s] for the debugger #ifdef MS_TIADS1X15_DEBUG #define MS_DEBUGGING_STD "TIADS1x15" From a20926628823a72197f2a07a47ed499d027b7d8a Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Thu, 12 Mar 2026 15:42:21 -0400 Subject: [PATCH 515/533] Reran clang format Signed-off-by: Sara Damiano --- examples/menu_a_la_carte/menu_a_la_carte.ino | 63 ++++++++++---------- src/SensorBase.h | 4 +- src/sensors/AlphasenseCO2.cpp | 4 +- src/sensors/AlphasenseCO2.h | 4 +- src/sensors/AnalogElecConductivity.h | 6 +- src/sensors/ApogeeSQ212.cpp | 2 +- src/sensors/ApogeeSQ212.h | 10 ++-- src/sensors/CampbellOBS3.cpp | 2 +- src/sensors/CampbellOBS3.h | 11 ++-- src/sensors/EverlightALSPT19.cpp | 4 +- src/sensors/EverlightALSPT19.h | 5 +- src/sensors/ProcessorAnalog.cpp | 6 +- src/sensors/ProcessorAnalog.h | 4 +- src/sensors/TIADS1x15.cpp | 25 ++++---- src/sensors/TIADS1x15.h | 24 ++++---- src/sensors/TurnerCyclops.cpp | 2 +- src/sensors/TurnerCyclops.h | 10 ++-- src/sensors/TurnerTurbidityPlus.h | 2 +- 18 files changed, 96 insertions(+), 92 deletions(-) diff --git a/examples/menu_a_la_carte/menu_a_la_carte.ino b/examples/menu_a_la_carte/menu_a_la_carte.ino index c58256f9a..98e1c825d 100644 --- a/examples/menu_a_la_carte/menu_a_la_carte.ino +++ b/examples/menu_a_la_carte/menu_a_la_carte.ino @@ -1017,12 +1017,12 @@ Variable* asco2voltage = new AlphasenseCO2_Voltage( &alphasenseCO2, "12345678-abcd-1234-ef00-1234567890ab"); // create a custom analog reader based on the TI ADS1115 (optional) -float AsCO2Multiplier = 1.0f; // factor for a voltage divider -adsGain_t AsCO2AdsGain = GAIN_ONE; // gain of the ADS1115 -float AsCO2adsSupply = 3.3f; // supply voltage of the ADS1115 -const uint8_t AsCO2i2c_addr = 0x48; // The I2C address of the ADS1115 ADC +float AsCO2Multiplier = 1.0f; // factor for a voltage divider +adsGain_t AsCO2AdsGain = GAIN_ONE; // gain of the ADS1115 +float AsCO2adsSupply = 3.3f; // supply voltage of the ADS1115 +const uint8_t AsCO2i2c_addr = 0x48; // The I2C address of the ADS1115 ADC TIADS1x15Reader AsCO2ADS(AsCO2Multiplier, AsCO2AdsGain, AsCO2i2c_addr, - AsCO2adsSupply); + AsCO2adsSupply); // Create an Alphasense CO2 sensor object with the custom TIADS1x15Reader AlphasenseCO2 alphasenseCO2_c(asCO2Power, asCO2Channel1, asCO2Channel2, @@ -1149,12 +1149,12 @@ Variable* sq212voltage = new ApogeeSQ212_Voltage(&sq212, "12345678-abcd-1234-ef00-1234567890ab"); // create a custom analog reader based on the TI ADS1115 (optional) -float sq212Multiplier = 1.0f; // factor for a voltage divider -adsGain_t sq212AdsGain = GAIN_ONE; // gain of the ADS1115 -float sq212adsSupply = 3.3f; // supply voltage of the ADS1115 -const uint8_t sq212i2c_addr = 0x48; // The I2C address of the ADS1115 ADC +float sq212Multiplier = 1.0f; // factor for a voltage divider +adsGain_t sq212AdsGain = GAIN_ONE; // gain of the ADS1115 +float sq212adsSupply = 3.3f; // supply voltage of the ADS1115 +const uint8_t sq212i2c_addr = 0x48; // The I2C address of the ADS1115 ADC TIADS1x15Reader sq212ADS(sq212Multiplier, sq212AdsGain, sq212i2c_addr, - sq212adsSupply); + sq212adsSupply); // Create an Apogee SQ212 sensor object with the custom TIADS1x15Reader ApogeeSQ212 sq212_c(sq212Power, sq212ADSChannel, sq212Readings, &sq212ADS); @@ -1502,12 +1502,12 @@ Variable* obs3VoltHigh = new CampbellOBS3_Voltage( &osb3high, "12345678-abcd-1234-ef00-1234567890ab", "TurbHighV"); // create a custom analog reader based on the TI ADS1115 (optional) -float OBS3Multiplier = 1.0f; // factor for a voltage divider -adsGain_t OBS3AdsGain = GAIN_ONE; // gain of the ADS1115 -float OBS3AdsSupplyVoltage = 3.3f; // supply voltage of the ADS1115 -const uint8_t OBS3AdsI2C_addr = 0x48; // The I2C address of the ADS1115 ADC +float OBS3Multiplier = 1.0f; // factor for a voltage divider +adsGain_t OBS3AdsGain = GAIN_ONE; // gain of the ADS1115 +float OBS3AdsSupplyVoltage = 3.3f; // supply voltage of the ADS1115 +const uint8_t OBS3AdsI2C_addr = 0x48; // The I2C address of the ADS1115 ADC TIADS1x15Reader OBSADS(OBS3Multiplier, OBS3AdsGain, OBS3AdsI2C_addr, - OBS3AdsSupplyVoltage); + OBS3AdsSupplyVoltage); // Create a Campbell OBS3+ *low* range sensor object with the custom // TIADS1x15Reader @@ -1639,8 +1639,8 @@ Variable* alsPt19Lux = new EverlightALSPT19_Illuminance( &alsPt19, "12345678-abcd-1234-ef00-1234567890ab"); // create a custom analog reader based on the Processor ADC (optional) -float alsMultiplier = 1.0f; // factor for a voltage divider -float alsAdsSupply = 3.3f; // supply voltage of the Processor ADC +float alsMultiplier = 1.0f; // factor for a voltage divider +float alsAdsSupply = 3.3f; // supply voltage of the Processor ADC ProcessorAnalogReader alsADS(alsMultiplier, alsAdsSupply); // Create an Everlight ALS-PT19 sensor object with the custom @@ -1675,12 +1675,12 @@ TIADS1x15 ads1x15(evADSPower, evADSChannel1); TIADS1x15 ads1x15_d(evADSPower, evADSChannel1, evADSChannel2); // create a custom ADS instance (optional) -float evVoltageMultiplier = 1.0f; // factor for a voltage divider -adsGain_t evAdsGain = GAIN_ONE; // gain of the ADS1115 -float evAdsSupplyVoltage = 3.3f; // supply voltage of the ADS1115 -const uint8_t evAdsI2C_addr = 0x48; // The I2C address of the ADS1115 ADC +float evVoltageMultiplier = 1.0f; // factor for a voltage divider +adsGain_t evAdsGain = GAIN_ONE; // gain of the ADS1115 +float evAdsSupplyVoltage = 3.3f; // supply voltage of the ADS1115 +const uint8_t evAdsI2C_addr = 0x48; // The I2C address of the ADS1115 ADC TIADS1x15Reader evADS(evVoltageMultiplier, evAdsGain, evAdsI2C_addr, - evAdsSupplyVoltage); + evAdsSupplyVoltage); // Create a single ended External Voltage sensor object with the custom // TIADS1x15Reader @@ -1705,7 +1705,8 @@ const int8_t processorAnalogPowerPin = sensorPowerPin; // Power pin const int8_t processorAnalogDataPin = A0; // Analog input pin (processor ADC) const uint8_t processorAnalogNReadings = 1; // Only read one sample -// Create a Processor Analog sensor object with the default ProcessorAnalogReader +// Create a Processor Analog sensor object with the default +// ProcessorAnalogReader ProcessorAnalog processorAnalog(processorAnalogPowerPin, processorAnalogDataPin, processorAnalogNReadings); @@ -1713,7 +1714,7 @@ ProcessorAnalog processorAnalog(processorAnalogPowerPin, processorAnalogDataPin, float processorAnalogMultiplier = 1.0f; // factor for a voltage divider float processorAnalogSupply = 3.3f; // supply voltage of the Processor ADC ProcessorAnalogReader processorAnalogReaderCustom(processorAnalogMultiplier, - processorAnalogSupply); + processorAnalogSupply); // Create a Processor Analog sensor object with the custom ProcessorAnalogReader ProcessorAnalog processorAnalog_c(processorAnalogPowerPin, @@ -2401,8 +2402,8 @@ float cyclopsMultiplier = 1.0f; // factor for a voltage divider adsGain_t cyclopsAdsGain = GAIN_ONE; // gain of the ADS1115 float cyclopsAdsSupplyVoltage = 3.3f; // supply voltage of the ADS1115 const uint8_t cyclopsAdsI2C_addr = 0x48; // The I2C address of the ADS1115 ADC -TIADS1x15Reader cyclopsADS(cyclopsMultiplier, cyclopsAdsGain, cyclopsAdsI2C_addr, - cyclopsAdsSupplyVoltage); +TIADS1x15Reader cyclopsADS(cyclopsMultiplier, cyclopsAdsGain, + cyclopsAdsI2C_addr, cyclopsAdsSupplyVoltage); // Create a Turner Cyclops sensor object with the custom ADS instance TurnerCyclops cyclops_c(cyclopsPower, cyclopsADSChannel, cyclopsStdConc, @@ -2457,12 +2458,12 @@ Variable* turbidityPlusTurbidity = new TurnerTurbidityPlus_Turbidity( &turbidityPlus, "12345678-abcd-1234-ef00-1234567890ab"); // create a custom analog reader based on the TI ADS1115 (optional) -float ttPlusMultiplier = 1.0f; // factor for a voltage divider -adsGain_t ttPlusAdsGain = GAIN_ONE; // gain of the ADS1115 -float ttPlusAdsSupply = 3.3f; // supply voltage of the ADS1115 -const uint8_t ttPlusI2C_addr = 0x48; // The I2C address of the ADS1115 ADC +float ttPlusMultiplier = 1.0f; // factor for a voltage divider +adsGain_t ttPlusAdsGain = GAIN_ONE; // gain of the ADS1115 +float ttPlusAdsSupply = 3.3f; // supply voltage of the ADS1115 +const uint8_t ttPlusI2C_addr = 0x48; // The I2C address of the ADS1115 ADC TIADS1x15Reader ttPlusADS(ttPlusMultiplier, ttPlusAdsGain, ttPlusI2C_addr, - ttPlusAdsSupply); + ttPlusAdsSupply); // Create a Turner Turbidity Plus sensor object with the custom TIADS1x15Reader TurnerTurbidityPlus turbidityPlus_c(ttPlusPower, ttPlusWiper, ttPlusChannel1, diff --git a/src/SensorBase.h b/src/SensorBase.h index a6fee3db9..643ed4885 100644 --- a/src/SensorBase.h +++ b/src/SensorBase.h @@ -497,8 +497,8 @@ class Sensor { * - Clears values array on first measurement attempt * - Checks if measurement was successfully started * - * @return True if initialization succeeded and measurement processing should - * continue, false if the measurement attempt should be aborted. + * @return True if initialization succeeded and measurement processing + * should continue, false if the measurement attempt should be aborted. */ bool initializeMeasurementResult(); diff --git a/src/sensors/AlphasenseCO2.cpp b/src/sensors/AlphasenseCO2.cpp index 381b2ca63..96aef959e 100644 --- a/src/sensors/AlphasenseCO2.cpp +++ b/src/sensors/AlphasenseCO2.cpp @@ -17,8 +17,8 @@ // The constructor - need the power pin and the data pin AlphasenseCO2::AlphasenseCO2(int8_t powerPin, int8_t analogChannel, - int8_t analogReferenceChannel, - uint8_t measurementsToAverage, + int8_t analogReferenceChannel, + uint8_t measurementsToAverage, AnalogVoltageReader* analogVoltageReader) : Sensor("AlphasenseCO2", ALPHASENSE_CO2_NUM_VARIABLES, ALPHASENSE_CO2_WARM_UP_TIME_MS, diff --git a/src/sensors/AlphasenseCO2.h b/src/sensors/AlphasenseCO2.h index 079e08c8b..3b6ff65e1 100644 --- a/src/sensors/AlphasenseCO2.h +++ b/src/sensors/AlphasenseCO2.h @@ -298,8 +298,8 @@ class AlphasenseCO2 : public Sensor { * inputs for the differential voltage measurement. */ AlphasenseCO2(int8_t powerPin, int8_t analogChannel, - int8_t analogReferenceChannel, - uint8_t measurementsToAverage = 7, + int8_t analogReferenceChannel, + uint8_t measurementsToAverage = 7, AnalogVoltageReader* analogVoltageReader = nullptr); /** * @brief Destroy the AlphasenseCO2 object diff --git a/src/sensors/AnalogElecConductivity.h b/src/sensors/AnalogElecConductivity.h index dd34be100..b1b3a8bd7 100644 --- a/src/sensors/AnalogElecConductivity.h +++ b/src/sensors/AnalogElecConductivity.h @@ -324,9 +324,9 @@ class AnalogElecConductivity : public Sensor { */ AnalogElecConductivity( int8_t powerPin, int8_t dataPin, - float Rseries_ohms = ANALOGELECCONDUCTIVITY_RSERIES_OHMS, - float sensorEC_Konst = ANALOGELECCONDUCTIVITY_KONST, - uint8_t measurementsToAverage = 1, + float Rseries_ohms = ANALOGELECCONDUCTIVITY_RSERIES_OHMS, + float sensorEC_Konst = ANALOGELECCONDUCTIVITY_KONST, + uint8_t measurementsToAverage = 1, AnalogVoltageReader* analogVoltageReader = nullptr); /** diff --git a/src/sensors/ApogeeSQ212.cpp b/src/sensors/ApogeeSQ212.cpp index f19166b95..19a99dda7 100644 --- a/src/sensors/ApogeeSQ212.cpp +++ b/src/sensors/ApogeeSQ212.cpp @@ -18,7 +18,7 @@ // The constructor - need the power pin and the data pin ApogeeSQ212::ApogeeSQ212(int8_t powerPin, int8_t analogChannel, - uint8_t measurementsToAverage, + uint8_t measurementsToAverage, AnalogVoltageReader* analogVoltageReader) : Sensor("ApogeeSQ212", SQ212_NUM_VARIABLES, SQ212_WARM_UP_TIME_MS, SQ212_STABILIZATION_TIME_MS, SQ212_MEASUREMENT_TIME_MS, powerPin, diff --git a/src/sensors/ApogeeSQ212.h b/src/sensors/ApogeeSQ212.h index 74c955219..6cc93e890 100644 --- a/src/sensors/ApogeeSQ212.h +++ b/src/sensors/ApogeeSQ212.h @@ -252,10 +252,10 @@ class ApogeeSQ212 : public Sensor { * - The SQ-212 requires 3.3 to 24 V DC; current draw 10 µA * @param analogChannel The analog data channel or processor pin for voltage * measurements. The significance of the channel number depends on the - * specific AnalogVoltageReader implementation used for voltage readings. For - * example, with the TI ADS1x15, this would be the ADC channel (0-3) that - * the sensor is connected to. Negative or invalid channel numbers are not - * clamped and will cause the reading to fail and emit a warning. + * specific AnalogVoltageReader implementation used for voltage readings. + * For example, with the TI ADS1x15, this would be the ADC channel (0-3) + * that the sensor is connected to. Negative or invalid channel numbers are + * not clamped and will cause the reading to fail and emit a warning. * @param measurementsToAverage The number of measurements to take and * average before giving a "final" result from the sensor; optional with a * default value of 1. @@ -275,7 +275,7 @@ class ApogeeSQ212 : public Sensor { * compiler error or a silent reading error. */ ApogeeSQ212(int8_t powerPin, int8_t analogChannel, - uint8_t measurementsToAverage = 1, + uint8_t measurementsToAverage = 1, AnalogVoltageReader* analogVoltageReader = nullptr); /** * @brief Destroy the ApogeeSQ212 object diff --git a/src/sensors/CampbellOBS3.cpp b/src/sensors/CampbellOBS3.cpp index 5f0963a81..4dcafbdb5 100644 --- a/src/sensors/CampbellOBS3.cpp +++ b/src/sensors/CampbellOBS3.cpp @@ -16,7 +16,7 @@ // The constructor - need the power pin, the data pin, and the calibration info CampbellOBS3::CampbellOBS3(int8_t powerPin, int8_t analogChannel, float x2_coeff_A, float x1_coeff_B, float x0_coeff_C, - uint8_t measurementsToAverage, + uint8_t measurementsToAverage, AnalogVoltageReader* analogVoltageReader) : Sensor("CampbellOBS3", OBS3_NUM_VARIABLES, OBS3_WARM_UP_TIME_MS, OBS3_STABILIZATION_TIME_MS, OBS3_MEASUREMENT_TIME_MS, powerPin, diff --git a/src/sensors/CampbellOBS3.h b/src/sensors/CampbellOBS3.h index 967350ad7..977df5480 100644 --- a/src/sensors/CampbellOBS3.h +++ b/src/sensors/CampbellOBS3.h @@ -245,10 +245,11 @@ class CampbellOBS3 : public Sensor { * between measurements. * @param analogChannel The analog data channel or processor pin for voltage * measurements. The significance of the channel number depends on the - * specific AnalogVoltageReader implementation used for voltage readings. For - * example, with the default TI ADS1x15, this would be the ADC channel (0-3) - * that the sensor is connected to. Negative or invalid channel numbers are - * not clamped and will cause the reading to fail and emit a warning. + * specific AnalogVoltageReader implementation used for voltage readings. + * For example, with the default TI ADS1x15, this would be the ADC channel + * (0-3) that the sensor is connected to. Negative or invalid channel + * numbers are not clamped and will cause the reading to fail and emit a + * warning. * @param x2_coeff_A The x2 (A) coefficient for the calibration _in volts_ * @param x1_coeff_B The x (B) coefficient for the calibration _in volts_ * @param x0_coeff_C The x0 (C) coefficient for the calibration _in volts_ @@ -272,7 +273,7 @@ class CampbellOBS3 : public Sensor { */ CampbellOBS3(int8_t powerPin, int8_t analogChannel, float x2_coeff_A, float x1_coeff_B, float x0_coeff_C, - uint8_t measurementsToAverage = 1, + uint8_t measurementsToAverage = 1, AnalogVoltageReader* analogVoltageReader = nullptr); /** * @brief Destroy the Campbell OBS3 object diff --git a/src/sensors/EverlightALSPT19.cpp b/src/sensors/EverlightALSPT19.cpp index 0f886881b..10be07708 100644 --- a/src/sensors/EverlightALSPT19.cpp +++ b/src/sensors/EverlightALSPT19.cpp @@ -14,7 +14,7 @@ EverlightALSPT19::EverlightALSPT19(int8_t powerPin, int8_t dataPin, float alsSupplyVoltage, float loadResistor, - uint8_t measurementsToAverage, + uint8_t measurementsToAverage, AnalogVoltageReader* analogVoltageReader) : Sensor("Everlight ALS-PT19", ALSPT19_NUM_VARIABLES, ALSPT19_WARM_UP_TIME_MS, ALSPT19_STABILIZATION_TIME_MS, @@ -33,7 +33,7 @@ EverlightALSPT19::EverlightALSPT19(int8_t powerPin, int8_t dataPin, defined(BUILT_IN_ALS_SUPPLY_VOLTAGE) && \ defined(BUILT_IN_ALS_LOADING_RESISTANCE)) || \ defined(DOXYGEN) -EverlightALSPT19::EverlightALSPT19(uint8_t measurementsToAverage, +EverlightALSPT19::EverlightALSPT19(uint8_t measurementsToAverage, AnalogVoltageReader* analogVoltageReader) : EverlightALSPT19(BUILT_IN_ALS_POWER_PIN, BUILT_IN_ALS_DATA_PIN, BUILT_IN_ALS_SUPPLY_VOLTAGE, diff --git a/src/sensors/EverlightALSPT19.h b/src/sensors/EverlightALSPT19.h index de3478c1c..449e64ac8 100644 --- a/src/sensors/EverlightALSPT19.h +++ b/src/sensors/EverlightALSPT19.h @@ -291,8 +291,9 @@ class EverlightALSPT19 : public Sensor { * non-null pointer is supplied, the caller retains ownership and must * ensure its lifetime exceeds that of this object. */ - explicit EverlightALSPT19(uint8_t measurementsToAverage = 10, - AnalogVoltageReader* analogVoltageReader = nullptr); + explicit EverlightALSPT19( + uint8_t measurementsToAverage = 10, + AnalogVoltageReader* analogVoltageReader = nullptr); #endif /** * @brief Destroy the EverlightALSPT19 object. diff --git a/src/sensors/ProcessorAnalog.cpp b/src/sensors/ProcessorAnalog.cpp index 91410294f..1641bdf8a 100644 --- a/src/sensors/ProcessorAnalog.cpp +++ b/src/sensors/ProcessorAnalog.cpp @@ -17,7 +17,7 @@ // ============================================================================ ProcessorAnalogReader::ProcessorAnalogReader(float voltageMultiplier, - float operatingVoltage) + float operatingVoltage) : AnalogVoltageReader(voltageMultiplier, operatingVoltage) {} @@ -32,7 +32,7 @@ bool ProcessorAnalogReader::begin() { } bool ProcessorAnalogReader::readVoltageSingleEnded(int8_t analogChannel, - float& resultValue) { + float& resultValue) { // Compile-time validation of ADC configuration static_assert(PROCESSOR_ADC_MAX > 0, "PROCESSOR_ADC_MAX must be greater than 0. Check " @@ -124,7 +124,7 @@ float ProcessorAnalogReader::calculateAnalogResolutionVolts() { // The constructor - need the power pin, the data pin, and the number of // measurements to average, with an optional external analog reader ProcessorAnalog::ProcessorAnalog(int8_t powerPin, int8_t dataPin, - uint8_t measurementsToAverage, + uint8_t measurementsToAverage, ProcessorAnalogReader* analogVoltageReader) : Sensor("ProcessorAnalog", PROCESSOR_ANALOG_NUM_VARIABLES, PROCESSOR_ANALOG_WARM_UP_TIME_MS, diff --git a/src/sensors/ProcessorAnalog.h b/src/sensors/ProcessorAnalog.h index 4a771d609..9ebb7adc1 100644 --- a/src/sensors/ProcessorAnalog.h +++ b/src/sensors/ProcessorAnalog.h @@ -172,7 +172,7 @@ class ProcessorAnalogReader : public AnalogVoltageReader { * likely 3.3 or 5. */ ProcessorAnalogReader(float voltageMultiplier = 1.0f, - float operatingVoltage = OPERATING_VOLTAGE); + float operatingVoltage = OPERATING_VOLTAGE); /** * @brief Destroy the ProcessorAnalogReader object @@ -262,7 +262,7 @@ class ProcessorAnalog : public Sensor { * ProcessorAnalogReader with default settings. */ ProcessorAnalog(int8_t powerPin, int8_t dataPin, - uint8_t measurementsToAverage = 1, + uint8_t measurementsToAverage = 1, ProcessorAnalogReader* analogVoltageReader = nullptr); /** * @brief Destroy the Processor Analog object diff --git a/src/sensors/TIADS1x15.cpp b/src/sensors/TIADS1x15.cpp index 6f2920af7..a3e12dae6 100644 --- a/src/sensors/TIADS1x15.cpp +++ b/src/sensors/TIADS1x15.cpp @@ -22,8 +22,8 @@ // Constructor with TwoWire instance TIADS1x15Reader::TIADS1x15Reader(TwoWire* theI2C, float voltageMultiplier, - adsGain_t adsGain, uint8_t i2cAddress, - float adsSupplyVoltage, uint16_t adsDataRate) + adsGain_t adsGain, uint8_t i2cAddress, + float adsSupplyVoltage, uint16_t adsDataRate) : AnalogVoltageReader(voltageMultiplier, adsSupplyVoltage), _wire(theI2C != nullptr ? theI2C : &Wire), _i2cAddress(i2cAddress), @@ -44,10 +44,10 @@ TIADS1x15Reader::TIADS1x15Reader(TwoWire* theI2C, float voltageMultiplier, // Constructor using default Wire instance TIADS1x15Reader::TIADS1x15Reader(float voltageMultiplier, adsGain_t adsGain, - uint8_t i2cAddress, float adsSupplyVoltage, - uint16_t adsDataRate) + uint8_t i2cAddress, float adsSupplyVoltage, + uint16_t adsDataRate) : TIADS1x15Reader(&Wire, voltageMultiplier, adsGain, i2cAddress, - adsSupplyVoltage, adsDataRate) {} + adsSupplyVoltage, adsDataRate) {} // ============================================================================ @@ -85,7 +85,7 @@ bool TIADS1x15Reader::begin() { } String TIADS1x15Reader::getAnalogLocation(int8_t analogChannel, - int8_t analogReferenceChannel) { + int8_t analogReferenceChannel) { String sensorLocation; #ifndef MS_USE_ADS1015 sensorLocation += F("ADS1115_0x"); @@ -106,7 +106,7 @@ String TIADS1x15Reader::getAnalogLocation(int8_t analogChannel, } bool TIADS1x15Reader::readVoltageSingleEnded(int8_t analogChannel, - float& resultValue) { + float& resultValue) { bool success = false; int16_t adcCounts = MS_INVALID_VALUE; float adcVoltage = MS_INVALID_VALUE; @@ -169,8 +169,8 @@ bool TIADS1x15Reader::readVoltageSingleEnded(int8_t analogChannel, } bool TIADS1x15Reader::readVoltageDifferential(int8_t analogChannel, - int8_t analogReferenceChannel, - float& resultValue) { + int8_t analogReferenceChannel, + float& resultValue) { bool success = false; int16_t adcCounts = MS_INVALID_VALUE; float adcVoltage = MS_INVALID_VALUE; @@ -237,7 +237,8 @@ bool TIADS1x15Reader::readVoltageDifferential(int8_t analogChannel, } // Validation function for differential channel pairs -bool TIADS1x15Reader::isValidDifferentialPair(int8_t channel1, int8_t channel2) { +bool TIADS1x15Reader::isValidDifferentialPair(int8_t channel1, + int8_t channel2) { // Only canonical ordered pairs are valid (lower channel number first) // This ensures consistent polarity: channel1 is positive, channel2 is // negative Valid combinations are: 0-1, 0-3, 1-3, or 2-3 (in that order @@ -350,8 +351,8 @@ bool TIADS1x15Reader::probeI2C() { // The constructor - need the power pin the data pin, and voltage multiplier if // non standard TIADS1x15::TIADS1x15(int8_t powerPin, int8_t adsChannel, - int8_t analogReferenceChannel, - uint8_t measurementsToAverage, + int8_t analogReferenceChannel, + uint8_t measurementsToAverage, TIADS1x15Reader* analogVoltageReader) : Sensor("TIADS1x15", TIADS1X15_NUM_VARIABLES, TIADS1X15_WARM_UP_TIME_MS, TIADS1X15_STABILIZATION_TIME_MS, TIADS1X15_MEASUREMENT_TIME_MS, diff --git a/src/sensors/TIADS1x15.h b/src/sensors/TIADS1x15.h index 11d4b345e..e896f6777 100644 --- a/src/sensors/TIADS1x15.h +++ b/src/sensors/TIADS1x15.h @@ -276,13 +276,13 @@ class TIADS1x15Reader : public AnalogVoltageReader { * @param adsDataRate The data rate for the ADS1x15 (samples per second) */ explicit TIADS1x15Reader(TwoWire* theI2C, float voltageMultiplier = 1.0f, - adsGain_t adsGain = GAIN_ONE, - uint8_t i2cAddress = MS_DEFAULT_ADS1X15_ADDRESS, - float adsSupplyVoltage = OPERATING_VOLTAGE, + adsGain_t adsGain = GAIN_ONE, + uint8_t i2cAddress = MS_DEFAULT_ADS1X15_ADDRESS, + float adsSupplyVoltage = OPERATING_VOLTAGE, #ifndef MS_USE_ADS1015 - uint16_t adsDataRate = RATE_ADS1115_128SPS + uint16_t adsDataRate = RATE_ADS1115_128SPS #else - uint16_t adsDataRate = RATE_ADS1015_1600SPS + uint16_t adsDataRate = RATE_ADS1015_1600SPS #endif ); @@ -297,13 +297,13 @@ class TIADS1x15Reader : public AnalogVoltageReader { * @param adsDataRate The data rate for the ADS1x15 (samples per second) */ explicit TIADS1x15Reader(float voltageMultiplier = 1.0f, - adsGain_t adsGain = GAIN_ONE, - uint8_t i2cAddress = MS_DEFAULT_ADS1X15_ADDRESS, - float adsSupplyVoltage = OPERATING_VOLTAGE, + adsGain_t adsGain = GAIN_ONE, + uint8_t i2cAddress = MS_DEFAULT_ADS1X15_ADDRESS, + float adsSupplyVoltage = OPERATING_VOLTAGE, #ifndef MS_USE_ADS1015 - uint16_t adsDataRate = RATE_ADS1115_128SPS + uint16_t adsDataRate = RATE_ADS1115_128SPS #else - uint16_t adsDataRate = RATE_ADS1015_1600SPS + uint16_t adsDataRate = RATE_ADS1015_1600SPS #endif ); @@ -497,8 +497,8 @@ class TIADS1x15 : public Sensor { * default settings. */ TIADS1x15(int8_t powerPin, int8_t adsChannel, - int8_t analogReferenceChannel = -1, - uint8_t measurementsToAverage = 1, + int8_t analogReferenceChannel = -1, + uint8_t measurementsToAverage = 1, TIADS1x15Reader* analogVoltageReader = nullptr); /** * @brief Destroy the TIADS1x15 object diff --git a/src/sensors/TurnerCyclops.cpp b/src/sensors/TurnerCyclops.cpp index 7ed683db4..baa15ba1d 100644 --- a/src/sensors/TurnerCyclops.cpp +++ b/src/sensors/TurnerCyclops.cpp @@ -16,7 +16,7 @@ // The constructor - need the power pin, the data pin, and the calibration info TurnerCyclops::TurnerCyclops(int8_t powerPin, int8_t analogChannel, float conc_std, float volt_std, float volt_blank, - uint8_t measurementsToAverage, + uint8_t measurementsToAverage, AnalogVoltageReader* analogVoltageReader) : Sensor("TurnerCyclops", CYCLOPS_NUM_VARIABLES, CYCLOPS_WARM_UP_TIME_MS, CYCLOPS_STABILIZATION_TIME_MS, CYCLOPS_MEASUREMENT_TIME_MS, diff --git a/src/sensors/TurnerCyclops.h b/src/sensors/TurnerCyclops.h index b6f179708..860fbbff7 100644 --- a/src/sensors/TurnerCyclops.h +++ b/src/sensors/TurnerCyclops.h @@ -328,10 +328,10 @@ class TurnerCyclops : public Sensor { * turned off between measurements. * @param analogChannel The analog data channel or processor pin for voltage * measurements. The significance of the channel number depends on the - * specific AnalogVoltageReader implementation used for voltage readings. For - * example, with the TI ADS1x15, this would be the ADC channel (0-3) that - * the sensor is connected to. Negative or invalid channel numbers are not - * clamped and will cause the reading to fail and emit a warning. + * specific AnalogVoltageReader implementation used for voltage readings. + * For example, with the TI ADS1x15, this would be the ADC channel (0-3) + * that the sensor is connected to. Negative or invalid channel numbers are + * not clamped and will cause the reading to fail and emit a warning. * @param conc_std The concentration of the standard used for a 1-point * sensor calibration. The concentration units should be the same as the * final measuring units. @@ -361,7 +361,7 @@ class TurnerCyclops : public Sensor { */ TurnerCyclops(int8_t powerPin, int8_t analogChannel, float conc_std, float volt_std, float volt_blank, - uint8_t measurementsToAverage = 1, + uint8_t measurementsToAverage = 1, AnalogVoltageReader* analogVoltageReader = nullptr); /** * @brief Destroy the Turner Cyclops object diff --git a/src/sensors/TurnerTurbidityPlus.h b/src/sensors/TurnerTurbidityPlus.h index d72081001..662e6e36d 100644 --- a/src/sensors/TurnerTurbidityPlus.h +++ b/src/sensors/TurnerTurbidityPlus.h @@ -273,7 +273,7 @@ class TurnerTurbidityPlus : public Sensor { TurnerTurbidityPlus(int8_t powerPin, int8_t wiperTriggerPin, int8_t analogChannel, int8_t analogReferenceChannel, float conc_std, float volt_std, float volt_blank, - uint8_t measurementsToAverage = 1, + uint8_t measurementsToAverage = 1, AnalogVoltageReader* analogVoltageReader = nullptr); /** * @brief Destroy the Turner Turbidity Plus object From 45b41782e3797019d4e3c0cbbb637c3cbd3ad309 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Thu, 12 Mar 2026 16:11:27 -0400 Subject: [PATCH 516/533] Fix doxygen errors Signed-off-by: Sara Damiano --- ChangeLog.md | 2 +- docs/FAQ/Processor-Compatibility.md | 106 ++++++++++++++-------------- docs/doxyfile | 5 +- src/ModSensorConfig.h | 64 +++++++++++------ 4 files changed, 101 insertions(+), 76 deletions(-) diff --git a/ChangeLog.md b/ChangeLog.md index b7b0dfbdf..f10bedd17 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -211,7 +211,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm - Added a configuration define for MS_INVALID_VALUE and replaced all occurrences of the standard -9999 with this define. - Added KnownProcessors.h and moved define values for supported built-in sensors on known processors to that file. - - This affects ProcessorStats and the Everlight ALS PT-19. + - This affects defines for the built in clocks, ADC defaults, logging buffer, and on-board ALS settings - Added a new example specific to the [EnviroDIY Monitoring Station Kit](https://www.envirodiy.org/product/envirodiy-monitoring-station-kit/). - Added a variety of private and protected helper functions to simplify code. diff --git a/docs/FAQ/Processor-Compatibility.md b/docs/FAQ/Processor-Compatibility.md index 70eb3a998..c39cd5a8e 100644 --- a/docs/FAQ/Processor-Compatibility.md +++ b/docs/FAQ/Processor-Compatibility.md @@ -13,26 +13,26 @@ - [Board-Specific Parameters](#board-specific-parameters) - [Configuration Override](#configuration-override) - [AtMega1284p (EnviroDIY Mayfly, Sodaq Mbili, Mighty 1284)](#atmega1284p-envirodiy-mayfly-sodaq-mbili-mighty-1284) - - [Specific Supported Boards](#specific-supported-boards) - - [Processor Information](#processor-information) + - [Specific Supported AtMega1284p Boards](#specific-supported-atmega1284p-boards) + - [AtMega1284p Processor Information](#atmega1284p-processor-information) - [AtSAMD21 (Arduino Zero, Adafruit Feather M0, Sodaq Autonomo)](#atsamd21-arduino-zero-adafruit-feather-m0-sodaq-autonomo) - - [Specific Supported Boards](#specific-supported-boards-1) - - [Processor Information](#processor-information-1) + - [Specific Supported AtSAMD21 Boards](#specific-supported-atsamd21-boards) + - [AtSAMD21 Processor Information](#atsamd21-processor-information) - [AtSAMD51 (Adafruit Feather M4, EnviroDIY Stonefly)](#atsamd51-adafruit-feather-m4-envirodiy-stonefly) - - [Specific Supported Boards](#specific-supported-boards-2) - - [Processor Information](#processor-information-2) + - [Specific Supported AtSAMD51 Boards](#specific-supported-atsamd51-boards) + - [AtSAMD51 Processor Information](#atsamd51-processor-information) - [AtMega2560 (Arduino Mega)](#atmega2560-arduino-mega) - - [Specific Supported Boards](#specific-supported-boards-3) - - [Processor Information](#processor-information-3) + - [Specific Supported AtMega2560 Boards](#specific-supported-atmega2560-boards) + - [AtMega2560 Processor Information](#atmega2560-processor-information) - [AtMega644p (Sanguino)](#atmega644p-sanguino) - - [Specific Supported Boards](#specific-supported-boards-4) - - [Processor Information](#processor-information-4) + - [Specific Supported AtMega644p Boards](#specific-supported-atmega644p-boards) + - [AtMega644p Processor Information](#atmega644p-processor-information) - [AtMega328p (Arduino Uno, Duemilanove, LilyPad, Mini, Seeeduino Stalker, etc)](#atmega328p-arduino-uno-duemilanove-lilypad-mini-seeeduino-stalker-etc) - - [Specific Supported Boards](#specific-supported-boards-5) - - [Processor Information](#processor-information-5) + - [Specific Supported AtMega328p Boards](#specific-supported-atmega328p-boards) + - [AtMega328p Processor Information](#atmega328p-processor-information) - [AtMega32u4 (Arduino Leonardo/Micro, Adafruit Flora/Feather, etc)](#atmega32u4-arduino-leonardomicro-adafruit-florafeather-etc) - - [Specific Supported Boards](#specific-supported-boards-6) - - [Processor Information](#processor-information-6) + - [Specific Supported AtMega32u4 Boards](#specific-supported-atmega32u4-boards) + - [AtMega32u4 Processor Information](#atmega32u4-processor-information) - [Unsupported Processors](#unsupported-processors) @@ -82,31 +82,31 @@ To add support for a new board of a supported processor type: 3. **Add to KnownProcessors.h**: Add a new `#elif defined()` section with your board's define and set the appropriate parameters: - ```cpp - #elif defined(YOUR_BOARD_DEFINE) - #define LOGGER_BOARD "Your Board Name" - #define OPERATING_VOLTAGE 3.3 // or 5.0 - #define BATTERY_PIN A0 // or -1 if not available - #define BATTERY_MULTIPLIER 2.0 // or -1 if not available - - // ADC defaults; if and only if needed - #ifndef MS_PROCESSOR_ADC_RESOLUTION - #define MS_PROCESSOR_ADC_RESOLUTION 10 // 10 for AVR, 12 for SAMD - #endif - #ifndef MS_PROCESSOR_ADC_REFERENCE_MODE - #define MS_PROCESSOR_ADC_REFERENCE_MODE DEFAULT // or AR_DEFAULT for SAMD - #endif - - // Log buffer size - adjust for board's memory capacity; if and only if needed - #ifndef MS_LOG_DATA_BUFFER_SIZE - #define MS_LOG_DATA_BUFFER_SIZE 1024 // Adjust based on available RAM - #endif - - // Built in clock; if and only if integrated into the board - #ifndef MS_USE_DS3231 // Choose appropriate RTC for your board - #define MS_USE_DS3231 - #endif - ``` +```cpp +#elif defined(YOUR_BOARD_DEFINE) +#define LOGGER_BOARD "Your Board Name" +#define OPERATING_VOLTAGE 3.3 // or 5.0 +#define BATTERY_PIN A0 // or -1 if not available +#define BATTERY_MULTIPLIER 2.0 // or -1 if not available + +// ADC defaults; if and only if needed +#ifndef MS_PROCESSOR_ADC_RESOLUTION +#define MS_PROCESSOR_ADC_RESOLUTION 10 // 10 for AVR, 12 for SAMD +#endif +#ifndef MS_PROCESSOR_ADC_REFERENCE_MODE +#define MS_PROCESSOR_ADC_REFERENCE_MODE DEFAULT // or AR_DEFAULT for SAMD +#endif + +// Log buffer size - adjust for board's memory capacity; if and only if needed +#ifndef MS_LOG_DATA_BUFFER_SIZE +#define MS_LOG_DATA_BUFFER_SIZE 1024 // Adjust based on available RAM +#endif + +// Built in clock; if and only if integrated into the board +#ifndef MS_USE_DS3231 // Choose appropriate RTC for your board +#define MS_USE_DS3231 +#endif +``` 4. **Submit contribution**: Create a pull request with your additions to help other users with the same board. @@ -137,12 +137,12 @@ ___ The [EnviroDIY Mayfly](https://envirodiy.org/mayfly/) _is_ the test board for this library. _Everything_ is designed to work with this processor. -### Specific Supported Boards +### Specific Supported AtMega1284p Boards - **EnviroDIY Mayfly** (`ARDUINO_AVR_ENVIRODIY_MAYFLY`) - **SODAQ Mbili** (`ARDUINO_AVR_SODAQ_MBILI`) -### Processor Information +### AtMega1284p Processor Information [Datasheet Summary](https://github.com/EnviroDIY/ModularSensors/wiki/Processor-Datasheets/Atmel-ATmega1284P-Datasheet-Summary.pdf) @@ -170,7 +170,7 @@ ___ Fully supported -### Specific Supported Boards +### Specific Supported AtSAMD21 Boards - **SODAQ ExpLoRer** (`ARDUINO_SODAQ_EXPLORER`) - **SODAQ Autonomo** (`ARDUINO_SODAQ_AUTONOMO`) @@ -180,7 +180,7 @@ Fully supported - **Adafruit Feather M0** (`ARDUINO_SAMD_FEATHER_M0`) - **Arduino Zero** (`ARDUINO_SAMD_ZERO`) -### Processor Information +### AtSAMD21 Processor Information [Datasheet Summary](https://github.com/EnviroDIY/ModularSensors/wiki/Processor-Datasheets/Atmel-SAMD21-Datasheet-Summary.pdf) @@ -219,7 +219,7 @@ ___ Fully supported with similar characteristics to AtSAMD21 but with enhanced performance. -### Specific Supported Boards +### Specific Supported AtSAMD51 Boards - **EnviroDIY Stonefly** (`ENVIRODIY_STONEFLY_M4`) - **Adafruit Feather M4** (`ARDUINO_FEATHER_M4`) @@ -227,7 +227,7 @@ Fully supported with similar characteristics to AtSAMD21 but with enhanced perfo - **Adafruit Feather M4 Adalogger** (`ADAFRUIT_FEATHER_M4_ADALOGGER`) - **Adafruit Grand Central** (`ADAFRUIT_GRAND_CENTRAL_M4`) -### Processor Information +### AtSAMD51 Processor Information These boards share similar capabilities with the AtSAMD21 processor boards including built-in USB, internal RTC, and multiple hardware serial ports, but with increased processing power and memory. @@ -237,13 +237,13 @@ ___ Should be fully functional, but untested. -### Specific Supported Boards +### Specific Supported AtMega2560 Boards - **Arduino Mega ADK** (`ARDUINO_AVR_ADK`) - **Arduino Mega** (`ARDUINO_AVR_MEGA`) - **Arduino Mega 2560** (`ARDUINO_AVR_MEGA2560`) -### Processor Information +### AtMega2560 Processor Information - An external RTC (DS3231, DS3232, or RV8803) is required. - There is a single SPI port on pins 50 (MISO), 52 (SCK), and 51 (MOSI). @@ -260,13 +260,13 @@ ___ Should be fully functional, but untested. -### Specific Supported Boards +### Specific Supported AtMega644p Boards - **SODAQ Ndogo** (`ARDUINO_AVR_SODAQ_NDOGO`) - **SODAQ Tatu** (`ARDUINO_AVR_SODAQ_TATU`) - **SODAQ Moja** (`ARDUINO_AVR_SODAQ_MOJA`) -### Processor Information +### AtMega644p Processor Information - An external RTC (DS3231, DS3232, or RV8803) is required. - This processor has two built-in hardware serial ports, Serial and Serial1. @@ -285,7 +285,7 @@ ___ All functions are supported, but processor doesn't have sufficient power to use all of the functionality of the library. You will only be able to use a small number of sensors at one time and may not be able to log data. -### Specific Supported Boards +### Specific Supported AtMega328p Boards - **Adafruit Feather 328p** (`ARDUINO_AVR_FEATHER328P`) - **Arduino BT** (`ARDUINO_AVR_BT`) @@ -299,7 +299,7 @@ You will only be able to use a small number of sensors at one time and may not b - **Arduino Pro** (`ARDUINO_AVR_PRO`) - **Arduino Uno** (`ARDUINO_AVR_UNO`) -### Processor Information +### AtMega328p Processor Information - An external RTC (DS3231, DS3232, or RV8803) is required. - There is a singe SPI ports on pins 12 (MISO), 13 (SCK), and 11 (MOSI). @@ -318,7 +318,7 @@ ___ All functions are supported, but processor doesn't have sufficient power to use all of the functionality of the library. You will only be able to use a small number of sensors at one time and may not be able to log data. -### Specific Supported Boards +### Specific Supported AtMega32u4 Boards - **Adafruit Feather 32u4** (`ARDUINO_AVR_FEATHER32U4`) - **Arduino Esplora** (`ARDUINO_AVR_ESPLORA`) @@ -328,7 +328,7 @@ You will only be able to use a small number of sensors at one time and may not b - **Arduino Micro** (`ARDUINO_AVR_MICRO`) - **Arduino Yun** (`ARDUINO_AVR_YUN`) -### Processor Information +### AtMega32u4 Processor Information [Datasheet Summary](https://github.com/EnviroDIY/ModularSensors/wiki/Processor-Datasheets/Atmel-ATmega16U4-32U4-Datasheet-Summary.pdf) diff --git a/docs/doxyfile b/docs/doxyfile index 5a6c44c80..fc78aa063 100644 --- a/docs/doxyfile +++ b/docs/doxyfile @@ -1116,7 +1116,10 @@ EXCLUDE_PATTERNS = */aws_iot_config*.h EXCLUDE_SYMBOLS = MS_*_DEBUG \ MS_DEBUGGING_STD \ - MS_DEBUGGING_DEEP + MS_DEBUGGING_DEEP \ + MS_USE_RV8803 \ + MS_USE_DS3231 \ + MS_USE_RTC_ZERO # The EXAMPLE_PATH tag can be used to specify one or more files or directories # that contain example code fragments that are included (see the \include diff --git a/src/ModSensorConfig.h b/src/ModSensorConfig.h index 4c98042b9..dd096359a 100644 --- a/src/ModSensorConfig.h +++ b/src/ModSensorConfig.h @@ -47,15 +47,17 @@ //============================================================== // Time-stamp configurations //============================================================== -#ifndef MS_LOGGER_EPOCH +#if !defined(MS_LOGGER_EPOCH) || defined(DOXYGEN) /** + * @def MS_LOGGER_EPOCH * @brief The epoch start to use for the logger */ #define MS_LOGGER_EPOCH epochStart::unix_epoch #endif -#ifndef EARLIEST_SANE_UNIX_TIMESTAMP +#if !defined(EARLIEST_SANE_UNIX_TIMESTAMP) || defined(DOXYGEN) /** + * @def EARLIEST_SANE_UNIX_TIMESTAMP * @brief The earliest unix timestamp that can be considered sane. * * January 1, 2025 @@ -63,8 +65,9 @@ #define EARLIEST_SANE_UNIX_TIMESTAMP 1735689600 #endif -#ifndef LATEST_SANE_UNIX_TIMESTAMP +#if !defined(LATEST_SANE_UNIX_TIMESTAMP) || defined(DOXYGEN) /** + * @def LATEST_SANE_UNIX_TIMESTAMP * @brief The latest unix timestamp that can be considered sane. * * January 1, 2035 @@ -77,8 +80,9 @@ //============================================================== // Variable configurations //============================================================== -#ifndef MS_INVALID_VALUE +#if !defined(MS_INVALID_VALUE) || defined(DOXYGEN) /** + * @def MS_INVALID_VALUE * @brief The value used to represent an invalid or missing measurement. * * Every sensor will use this value to indicate that a measurement is invalid @@ -87,8 +91,9 @@ #define MS_INVALID_VALUE -9999 #endif -#ifndef MAX_NUMBER_VARS +#if !defined(MAX_NUMBER_VARS) || defined(DOXYGEN) /** + * @def MAX_NUMBER_VARS * @brief The largest number of variables from a single sensor. * * Every sensor will create a buffer of this length for holding variable values. @@ -105,8 +110,9 @@ static_assert(MAX_NUMBER_VARS > 0 && MAX_NUMBER_VARS <= 21, "MAX_NUMBER_VARS must be between 1 and 21"); -#ifndef MAX_NUMBER_SENSORS +#if !defined(MAX_NUMBER_SENSORS) || defined(DOXYGEN) /** + * @def MAX_NUMBER_SENSORS * @brief The largest number of sensors in a single variable array. * * @note This is **not** the same as the maximum number of variables in a @@ -127,8 +133,9 @@ static_assert(MAX_NUMBER_SENSORS > 0 && MAX_NUMBER_SENSORS <= 50, //============================================================== // User button functionality //============================================================== -#ifndef MS_LOGGERBASE_BUTTON_BENCH_TEST +#if !defined(MS_LOGGERBASE_BUTTON_BENCH_TEST) || defined(DOXYGEN) /** + * @def MS_LOGGERBASE_BUTTON_BENCH_TEST * @brief Enable bench testing mode for the testing button. * * When enabled, the testing button uses the benchTestingMode() function to @@ -144,8 +151,9 @@ static_assert(MAX_NUMBER_SENSORS > 0 && MAX_NUMBER_SENSORS <= 50, //============================================================== // SPI Configuration, iff needed //============================================================== -#if !defined(SDCARD_SPI) +#if !defined(SDCARD_SPI) || defined(DOXYGEN) /** + * @def SDCARD_SPI * @brief The SPI port to use for the SD card. * * This is typically defined in the board variant file. @@ -158,8 +166,9 @@ static_assert(MAX_NUMBER_SENSORS > 0 && MAX_NUMBER_SENSORS <= 50, //============================================================== // Processor ADC configuration //============================================================== -#ifndef MS_PROCESSOR_ADC_RESOLUTION +#if !defined(MS_PROCESSOR_ADC_RESOLUTION) || defined(DOXYGEN) /** + * @def MS_PROCESSOR_ADC_RESOLUTION * @brief Select or adjust the processor analog resolution. * * This is the resolution of the **built-in** processor ADC and it cannot be set @@ -191,8 +200,9 @@ static_assert(MS_PROCESSOR_ADC_RESOLUTION >= 8 && /// @brief The maximum possible range of the ADC - the resolution shifted up one /// bit. #define PROCESSOR_ADC_RANGE (1 << MS_PROCESSOR_ADC_RESOLUTION) -#ifndef MS_PROCESSOR_ANALOG_MAX_CHANNEL +#if !defined(MS_PROCESSOR_ANALOG_MAX_CHANNEL) || defined(DOXYGEN) /** + * @def MS_PROCESSOR_ANALOG_MAX_CHANNEL * @brief Upper bound used to sanity-check analog channel numbers at runtime. * * This is not a hardware limit but a validation ceiling that exceeds the @@ -208,6 +218,7 @@ static_assert(MS_PROCESSOR_ANALOG_MAX_CHANNEL > 0 && #if !defined(MS_PROCESSOR_ADC_REFERENCE_MODE) || defined(DOXYGEN) /** + * @def MS_PROCESSOR_ADC_REFERENCE_MODE * @brief The voltage reference mode for the processor's ADC. * * For supported boards, appropriate defaults are set in KnownProcessors.h. @@ -330,8 +341,9 @@ static_assert(MS_SEA_LEVEL_PRESSURE_HPA >= 800.0f && //============================================================== // Publisher configuration //============================================================== -#ifndef MAX_NUMBER_SENDERS +#if !defined(MAX_NUMBER_SENDERS) || defined(DOXYGEN) /** + * @def MAX_NUMBER_SENDERS * @brief The largest number of publishers that can be attached to a logger */ #define MAX_NUMBER_SENDERS 4 @@ -341,8 +353,9 @@ static_assert(MS_SEA_LEVEL_PRESSURE_HPA >= 800.0f && static_assert(MAX_NUMBER_SENDERS >= 0 && MAX_NUMBER_SENDERS <= 16, "MAX_NUMBER_SENDERS must be between 0 and 16"); -#ifndef MS_ALWAYS_FLUSH_PUBLISHERS +#if !defined(MS_ALWAYS_FLUSH_PUBLISHERS) || defined(DOXYGEN) /** + * @def MS_ALWAYS_FLUSH_PUBLISHERS * @brief Set this to true to always force publishers to attempt to transmit * data. If false, publishers will only transmit data at the sendEveryX * interval or when the buffer fills. @@ -350,8 +363,9 @@ static_assert(MAX_NUMBER_SENDERS >= 0 && MAX_NUMBER_SENDERS <= 16, #define MS_ALWAYS_FLUSH_PUBLISHERS false #endif -#ifndef MS_LOG_DATA_BUFFER_SIZE +#if !defined(MS_LOG_DATA_BUFFER_SIZE) || defined(DOXYGEN) /** + * @def MS_LOG_DATA_BUFFER_SIZE * @brief Log Data Buffer * * This determines how much RAM is reserved to buffer log records before @@ -377,8 +391,9 @@ static_assert(MS_LOG_DATA_BUFFER_SIZE >= 64 && MS_LOG_DATA_BUFFER_SIZE <= 16384, "MS_LOG_DATA_BUFFER_SIZE must be between 64 and 16384 bytes"); -#ifndef MS_SEND_BUFFER_SIZE +#if !defined(MS_SEND_BUFFER_SIZE) || defined(DOXYGEN) /** + * @def MS_SEND_BUFFER_SIZE * @brief Send Buffer * * This determines how many characters to set out at once over the TCP @@ -398,8 +413,9 @@ static_assert(MS_LOG_DATA_BUFFER_SIZE >= 64 && MS_LOG_DATA_BUFFER_SIZE <= 16384, static_assert(MS_SEND_BUFFER_SIZE >= 32 && MS_SEND_BUFFER_SIZE <= 2048, "MS_SEND_BUFFER_SIZE must be between 32 and 2048 bytes"); -#ifndef TINY_GSM_RX_BUFFER +#if !defined(TINY_GSM_RX_BUFFER) || defined(DOXYGEN) /** + * @def TINY_GSM_RX_BUFFER * @brief The size of the buffer for incoming data. * * If using a module that buffers data internally, this can be 64 or lower. If @@ -413,8 +429,9 @@ static_assert(TINY_GSM_RX_BUFFER >= 16 && TINY_GSM_RX_BUFFER <= 2048, "TINY_GSM_RX_BUFFER must be between 16 and 2048 bytes"); -#ifndef TINY_GSM_YIELD_MS +#if !defined(TINY_GSM_YIELD_MS) || defined(DOXYGEN) /** + * @def TINY_GSM_YIELD_MS * @brief The number of milliseconds to yield to the GSM module when using * TinyGSM. * @@ -428,8 +445,9 @@ static_assert(TINY_GSM_RX_BUFFER >= 16 && TINY_GSM_RX_BUFFER <= 2048, static_assert(TINY_GSM_YIELD_MS >= 0 && TINY_GSM_YIELD_MS <= 1000, "TINY_GSM_YIELD_MS must be between 0 and 1000 milliseconds"); -#ifndef MS_MQTT_MAX_PACKET_SIZE +#if !defined(MS_MQTT_MAX_PACKET_SIZE) || defined(DOXYGEN) /** + * @def MS_MQTT_MAX_PACKET_SIZE * @brief Configure the size of the PubSubClient buffer for MQTT publishers. * * This is the maximum size of any single MQTT message - incoming or outgoing. @@ -452,8 +470,9 @@ static_assert(MS_MQTT_MAX_PACKET_SIZE >= 128 && MS_MQTT_MAX_PACKET_SIZE <= 4096, //============================================================== // Special configurations for the AWS IoT Core publisher //============================================================== -#ifndef MS_AWS_IOT_PUBLISHER_SUB_COUNT +#if !defined(MS_AWS_IOT_PUBLISHER_SUB_COUNT) || defined(DOXYGEN) /** + * @def MS_AWS_IOT_PUBLISHER_SUB_COUNT * @brief The maximum number of extra subscriptions that can be added to the AWS * IoT Core publisher. * @@ -461,8 +480,9 @@ static_assert(MS_MQTT_MAX_PACKET_SIZE >= 128 && MS_MQTT_MAX_PACKET_SIZE <= 4096, */ #define MS_AWS_IOT_PUBLISHER_SUB_COUNT 4 #endif -#ifndef MS_AWS_IOT_PUBLISHER_PUB_COUNT +#if !defined(MS_AWS_IOT_PUBLISHER_PUB_COUNT) || defined(DOXYGEN) /** + * @def MS_AWS_IOT_PUBLISHER_PUB_COUNT * @brief The maximum number of extra publish messages that can be added to the * AWS IoT Core publisher. */ @@ -476,8 +496,9 @@ static_assert(MS_AWS_IOT_PUBLISHER_PUB_COUNT >= 0 && MS_AWS_IOT_PUBLISHER_PUB_COUNT <= 16, "MS_AWS_IOT_PUBLISHER_PUB_COUNT must be between 0 and 16"); -#ifndef MS_AWS_IOT_MAX_CONNECTION_TIME +#if !defined(MS_AWS_IOT_MAX_CONNECTION_TIME) || defined(DOXYGEN) /** + * @def MS_AWS_IOT_MAX_CONNECTION_TIME * @brief The maximum time to wait for subscriptions after publishing data to * AWS IoT Core. * @@ -491,8 +512,9 @@ static_assert(MS_AWS_IOT_PUBLISHER_PUB_COUNT >= 0 && //============================================================== // Special configurations for the S3 publisher //============================================================== -#ifndef S3_DEFAULT_FILE_EXTENSION +#if !defined(S3_DEFAULT_FILE_EXTENSION) || defined(DOXYGEN) /** + * @def S3_DEFAULT_FILE_EXTENSION * @brief The default file extension to use to send to S3: ".jpg" * * This assumes you are using S3 to send images. If you want to put your basic From 44f7a24ad53053586a2bf5bd1bee3f3694b60d59 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Thu, 12 Mar 2026 16:59:53 -0400 Subject: [PATCH 517/533] Remove processors with multiple possible voltages or unverified values Signed-off-by: Sara Damiano --- docs/FAQ/Processor-Compatibility.md | 8 ++--- src/KnownProcessors.h | 53 +++-------------------------- src/sensors/ProcessorStats.h | 2 +- 3 files changed, 8 insertions(+), 55 deletions(-) diff --git a/docs/FAQ/Processor-Compatibility.md b/docs/FAQ/Processor-Compatibility.md index c39cd5a8e..99fc6a752 100644 --- a/docs/FAQ/Processor-Compatibility.md +++ b/docs/FAQ/Processor-Compatibility.md @@ -27,7 +27,7 @@ - [AtMega644p (Sanguino)](#atmega644p-sanguino) - [Specific Supported AtMega644p Boards](#specific-supported-atmega644p-boards) - [AtMega644p Processor Information](#atmega644p-processor-information) - - [AtMega328p (Arduino Uno, Duemilanove, LilyPad, Mini, Seeeduino Stalker, etc)](#atmega328p-arduino-uno-duemilanove-lilypad-mini-seeeduino-stalker-etc) + - [AtMega328p (Arduino Uno, Seeeduino Stalker, etc)](#atmega328p-arduino-uno-seeeduino-stalker-etc) - [Specific Supported AtMega328p Boards](#specific-supported-atmega328p-boards) - [AtMega328p Processor Information](#atmega328p-processor-information) - [AtMega32u4 (Arduino Leonardo/Micro, Adafruit Flora/Feather, etc)](#atmega32u4-arduino-leonardomicro-adafruit-florafeather-etc) @@ -280,7 +280,7 @@ Should be fully functional, but untested. ___ -## AtMega328p (Arduino Uno, Duemilanove, LilyPad, Mini, Seeeduino Stalker, etc) +## AtMega328p (Arduino Uno, Seeeduino Stalker, etc) All functions are supported, but processor doesn't have sufficient power to use all of the functionality of the library. You will only be able to use a small number of sensors at one time and may not be able to log data. @@ -292,11 +292,8 @@ You will only be able to use a small number of sensors at one time and may not b - **Arduino Duemilanove** (`ARDUINO_AVR_DUEMILANOVE`) - **Arduino Ethernet** (`ARDUINO_AVR_ETHERNET`) - **Arduino Fio** (`ARDUINO_AVR_FIO`) -- **Arduino Lilypad** (`ARDUINO_AVR_LILYPAD`) - **Arduino Mini 05** (`ARDUINO_AVR_MINI`) - **Arduino Nano** (`ARDUINO_AVR_NANO`) -- **Arduino NG** (`ARDUINO_AVR_NG`) -- **Arduino Pro** (`ARDUINO_AVR_PRO`) - **Arduino Uno** (`ARDUINO_AVR_UNO`) ### AtMega328p Processor Information @@ -324,7 +321,6 @@ You will only be able to use a small number of sensors at one time and may not b - **Arduino Esplora** (`ARDUINO_AVR_ESPLORA`) - **Arduino Gemma** (`ARDUINO_AVR_GEMMA`) - **Arduino Leonardo** (`ARDUINO_AVR_LEONARDO`) -- **Arduino Lilypad USB** (`ARDUINO_AVR_LILYPAD_USB`) - **Arduino Micro** (`ARDUINO_AVR_MICRO`) - **Arduino Yun** (`ARDUINO_AVR_YUN`) diff --git a/src/KnownProcessors.h b/src/KnownProcessors.h index adf528eba..c9ab7888a 100644 --- a/src/KnownProcessors.h +++ b/src/KnownProcessors.h @@ -359,7 +359,8 @@ // Use log buffer size defaults // An external RTC is required -// https://docs.arduino.cc/retired/boards/arduino-ethernet-rev3-without-poe/ (Retired) +// https://docs.arduino.cc/retired/boards/arduino-ethernet-rev3-without-poe/ +// (Retired) #elif defined(ARDUINO_AVR_ETHERNET) #define LOGGER_BOARD "Arduino Ethernet" #define OPERATING_VOLTAGE 5 @@ -379,7 +380,8 @@ // Use log buffer size defaults // An external RTC is required -// Arduino version: https://docs.arduino.cc/retired/boards/arduino-gemma/ (Retired) +// Arduino version: https://docs.arduino.cc/retired/boards/arduino-gemma/ +// (Retired) // Adafruit version: https://www.adafruit.com/product/1222 #elif defined(ARDUINO_AVR_GEMMA) #define LOGGER_BOARD "Arduino Gemma" @@ -400,29 +402,6 @@ // Use log buffer size defaults // An external RTC is required -// https://docs.arduino.cc/retired/getting-started-guides/ArduinoLilyPad/ -// (Retired) -#elif defined(ARDUINO_AVR_LILYPAD) -#define LOGGER_BOARD "Arduino Lilypad" -// NOTE: The operating voltage is 2.7-5.5V -#define OPERATING_VOLTAGE 3.3 -#define BATTERY_PIN -1 -#define BATTERY_MULTIPLIER -1 -// Use ADC defaults for an AVR processor -// Use log buffer size defaults -// An external RTC is required - -// https://docs.arduino.cc/retired/getting-started-guides/ArduinoLilyPadUSB/ -// (Retired) -#elif defined(ARDUINO_AVR_LILYPAD_USB) -#define LOGGER_BOARD "Arduino Lilypad USB" -#define OPERATING_VOLTAGE 3.3 -#define BATTERY_PIN -1 -#define BATTERY_MULTIPLIER -1 -// Use ADC defaults for an AVR processor -// Use log buffer size defaults -// An external RTC is required - // https://store-usa.arduino.cc/products/arduino-micro #elif defined(ARDUINO_AVR_MICRO) #define LOGGER_BOARD "Arduino Micro" @@ -453,28 +432,6 @@ // Use log buffer size defaults // An external RTC is required -// https://docs.arduino.cc/retired/boards/arduino-ng/ (Retired) -#elif defined(ARDUINO_AVR_NG) -#define LOGGER_BOARD "Arduino NG" -// WARNING: I can't find confirmation of the operating voltage online! -#define OPERATING_VOLTAGE 5 -#define BATTERY_PIN -1 -#define BATTERY_MULTIPLIER -1 -// Use ADC defaults for an AVR processor -// Use log buffer size defaults -// An external RTC is required - -// https://docs.arduino.cc/retired/boards/arduino-pro/ (Retired) -#elif defined(ARDUINO_AVR_PRO) -#define LOGGER_BOARD "Arduino Pro" -// NOTE: The operating voltage is 3.3V or 5V depending on the model -#define OPERATING_VOLTAGE 5 -#define BATTERY_PIN -1 -#define BATTERY_MULTIPLIER -1 -// Use ADC defaults for an AVR processor -// Use log buffer size defaults -// An external RTC is required - // https://store-usa.arduino.cc/products/arduino-uno-rev3 #elif defined(ARDUINO_AVR_UNO) #define LOGGER_BOARD "Arduino Uno" @@ -583,6 +540,6 @@ "The battery multiplier can be added by editing KnownProcessors.h." #endif -// cspell:words Tatu Moja Adalogger Duemilanove Esplora Lilypad +// cspell:words Tatu Moja Adalogger Duemilanove Esplora #endif diff --git a/src/sensors/ProcessorStats.h b/src/sensors/ProcessorStats.h index a38ebd833..53f9cd61e 100644 --- a/src/sensors/ProcessorStats.h +++ b/src/sensors/ProcessorStats.h @@ -518,4 +518,4 @@ class ProcessorStats_ResetCode : public Variable { /**@}*/ #endif // SRC_SENSORS_PROCESSORSTATS_H_ -// cSpell:ignore SAMPNUM sampno Tatu Moja Adalogger Duemilanove Esplora Lilypad +// cSpell:ignore SAMPNUM sampno Tatu Moja Adalogger Duemilanove Esplora From 1c2606c19699361ebf880bb47a19ea3b09c373fb Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Thu, 12 Mar 2026 17:00:02 -0400 Subject: [PATCH 518/533] F strings Signed-off-by: Sara Damiano --- src/sensors/MaxBotixSonar.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/sensors/MaxBotixSonar.cpp b/src/sensors/MaxBotixSonar.cpp index af45fa432..52401c1ea 100644 --- a/src/sensors/MaxBotixSonar.cpp +++ b/src/sensors/MaxBotixSonar.cpp @@ -37,7 +37,8 @@ String MaxBotixSonar::getSensorLocation() { // attach the trigger pin to the stream number String loc; loc.reserve(25); // Reserve for "sonarStream_trigger" + pin number - loc = "sonarStream_trigger" + String(_triggerPin); + loc = F("sonarStream_trigger"); + loc += _triggerPin; return loc; } From 4b1dc072c7a9d0411c36477aaaa9071a59a78105 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Thu, 12 Mar 2026 17:00:18 -0400 Subject: [PATCH 519/533] Remove redundant check Signed-off-by: Sara Damiano --- src/sensors/PaleoTerraRedox.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/sensors/PaleoTerraRedox.cpp b/src/sensors/PaleoTerraRedox.cpp index d7b59a527..549827727 100644 --- a/src/sensors/PaleoTerraRedox.cpp +++ b/src/sensors/PaleoTerraRedox.cpp @@ -167,8 +167,7 @@ bool PaleoTerraRedox::addSingleMeasurementResult() { MS_DBG(F("Config byte:"), config); MS_DBG(F("Calculated voltage in uV:"), res); - success = (!isnan(res)) && - !(adcValue == 0 && i2c_status == 0 && config == 0); + success = (!isnan(res)) && !(adcValue == 0 && config == 0); if (success) { // Store the results in the sensorValues array verifyAndAddMeasurementResult(PTR_VOLTAGE_VAR_NUM, res); From 5edb26ef7ee96295426f3ac8b173c57aa5cdce9b Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Thu, 12 Mar 2026 17:07:25 -0400 Subject: [PATCH 520/533] Fix guard path Signed-off-by: Sara Damiano --- src/KnownProcessors.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/KnownProcessors.h b/src/KnownProcessors.h index c9ab7888a..75ee2a20b 100644 --- a/src/KnownProcessors.h +++ b/src/KnownProcessors.h @@ -8,8 +8,8 @@ */ // Header Guards -#ifndef SRC_SENSORS_KNOWN_PROCESSORS_H_ -#define SRC_SENSORS_KNOWN_PROCESSORS_H_ +#ifndef SRC_KNOWN_PROCESSORS_H_ +#define SRC_KNOWN_PROCESSORS_H_ /** * @def LOGGER_BOARD From c1bda7fe4d0c93961e5fa5e3715ae9cb6abbce29 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Thu, 12 Mar 2026 17:10:40 -0400 Subject: [PATCH 521/533] Restore older functionality of clearValues Signed-off-by: Sara Damiano --- src/SensorBase.cpp | 27 ++++++++---------------- src/SensorBase.h | 52 +++++++++++++++++++++++++++------------------- 2 files changed, 40 insertions(+), 39 deletions(-) diff --git a/src/SensorBase.cpp b/src/SensorBase.cpp index 745f9f2ae..1c60ab936 100644 --- a/src/SensorBase.cpp +++ b/src/SensorBase.cpp @@ -32,9 +32,9 @@ Sensor::Sensor(const char* sensorName, const uint8_t totalReturnedValues, _measurementTime_ms(measurementTime_ms) { // Clear arrays for (uint8_t i = 0; i < MAX_NUMBER_VARS; i++) { - variables[i] = nullptr; - sensorValues[i] = MS_INVALID_VALUE; - numberGoodMeasurementsMade[i] = 0; + variables[i] = nullptr; + sensorValues[i] = MS_INVALID_VALUE; + validCount[i] = 0; } } @@ -363,31 +363,23 @@ void Sensor::notifyVariables() { } -// This function empties the value array by setting all values to invalid. -void Sensor::clearValueArray() { +// This function resets the value array by setting all values to invalid. +void Sensor::clearValues() { MS_DBG(F("Clearing value array for"), getSensorNameAndLocation()); for (uint8_t i = 0; i < _numReturnedValues; i++) { sensorValues[i] = MS_INVALID_VALUE; + validCount[i] = 0; } } // This function resets all measurement counts. void Sensor::resetMeasurementCounts() { MS_DBG(F("Resetting measurement counts for"), getSensorNameAndLocation()); - for (uint8_t i = 0; i < _numReturnedValues; i++) { - numberGoodMeasurementsMade[i] = 0; - } // Reset measurement attempt counters _completedMeasurements = 0; _currentRetries = 0; } -// This function empties the value array and resets the measurement counts. -void Sensor::clearValues() { - clearValueArray(); - resetMeasurementCounts(); -} - // This clears power-related status bits and resets power timing. void Sensor::clearPowerStatus() { // Reset power timing value @@ -437,7 +429,7 @@ void Sensor::verifyAndAddMeasurementResult(uint8_t resultNumber, MS_DBG(F("Putting"), resultValue, F("in result array for variable"), resultNumber, F("from"), getSensorNameAndLocation()); sensorValues[resultNumber] = resultValue; - numberGoodMeasurementsMade[resultNumber] += 1; + validCount[resultNumber] += 1; } else if (prevResultGood && newResultGood) { // If the new result is good and there were already good results in // place add the new results to the total and add 1 to the good result @@ -445,7 +437,7 @@ void Sensor::verifyAndAddMeasurementResult(uint8_t resultNumber, MS_DBG(F("Adding"), resultValue, F("to result array for variable"), resultNumber, F("from"), getSensorNameAndLocation()); sensorValues[resultNumber] += resultValue; - numberGoodMeasurementsMade[resultNumber] += 1; + validCount[resultNumber] += 1; } else if (!prevResultGood && !newResultGood) { // If the new result is bad and there were only bad results, only print // debugging @@ -478,8 +470,7 @@ void Sensor::averageMeasurements() { MS_DBG(F("Averaging results from"), getSensorNameAndLocation(), F("over"), _measurementsToAverage, F("reading[s]")); for (uint8_t i = 0; i < _numReturnedValues; i++) { - if (numberGoodMeasurementsMade[i] > 0) - sensorValues[i] /= numberGoodMeasurementsMade[i]; + if (validCount[i] > 0) sensorValues[i] /= validCount[i]; MS_DBG(F(" ->Result #"), i, ':', sensorValues[i]); } } diff --git a/src/SensorBase.h b/src/SensorBase.h index 643ed4885..bdfe8306e 100644 --- a/src/SensorBase.h +++ b/src/SensorBase.h @@ -521,42 +521,37 @@ class Sensor { /** * @brief The array of result values for each sensor. * + * New valid values are summed with the current values by + * verifyAndAddMeasurementResult(). Values are set to the default invalid + * value by clearValues(). + * * @todo Support int16_t and int32_t directly in the value array so no * casting is needed. This could be done using a template or a union similar - * to the modbus library's leFrame union. + * to the SensorModbusMaster library's leFrame union. * * @note The values in this array will not be usable until after the sensor * completes all requested measurements! Prior to that, the values in this - * array will be the sum of all good values measured so far (or + * array will be the **sum** of all good values measured so far (or * #MS_INVALID_VALUE if no good values have been measured yet). */ float sensorValues[MAX_NUMBER_VARS]; /** - * @brief Clear only the values array. + * @brief Clear the values array and the count of values to average. * - * This clears the values array by setting all values to #MS_INVALID_VALUE. + * This clears the values array by setting all values in sensorValues to + * #MS_INVALID_VALUE and the count of values to average in validCount to 0. */ - void clearValueArray(); + void clearValues(); /** * @brief Reset all measurement counts. * - * Sets all values in numberGoodMeasurementsMade to 0, and resets the - * attempt (#_completedMeasurements) and retry (#_currentRetries) + * Resets the attempt (#_completedMeasurements) and retry (#_currentRetries) * counts. */ void resetMeasurementCounts(); - /** - * @brief Clear the values array and reset retry counts. - * - * This clears the values array by setting all values to #MS_INVALID_VALUE, - * sets all values in numberGoodMeasurementsMade to 0, and resets the - * attempt (#_completedMeasurements) and retry (#_currentRetries) - * counts. - */ - void clearValues(); /** * @brief This clears all of the status bits and resets timing values. * @@ -783,12 +778,24 @@ class Sensor { uint8_t _measurementsToAverage; /** * @brief The number of measurement cycles completed in the current update - * cycle (reset by clearValues()). + * cycle (reset by resetMeasurementCounts()). + * + * A single completed measurement may include many attempts if some attempts + * fail and require retries. This count is incremented when a measurement + * attempt is completed, regardless of whether it was successful or not. + * Multiple completed measurement attempts may be needed to get the + * requested number of good measurements to average, depending on the sensor + * and the environment. */ uint8_t _completedMeasurements = 0; /** * @brief The number of retries that have been attempted so far for the - * current measurement cycle. + * current measurement cycle (reset by resetMeasurementCounts()). + * + * The number of retries is separate from the number of completed + * measurements. Many retries may be needed to complete a single + * measurement. Many measurements may need to be taken in order to get + * values to average. */ uint8_t _currentRetries = 0; /** @@ -799,15 +806,18 @@ class Sensor { */ uint8_t _maxRetries = 1; /** - * @brief Array with the number of valid measurement values per variable by - * the sensor in the current update cycle. + * @brief Array with the number of valid measurement values per variable + * that have been summed into the sensorValues array. + * + * This is bumped by verifyAndAddMeasurementResult and reset by + * clearValues(). * * @note The number of good measurements may vary between variables if * some values are more likely to be invalid than others - i.e., a pH sensor * may also measure temperature and report a valid temperature when the pH * is junk. */ - uint8_t numberGoodMeasurementsMade[MAX_NUMBER_VARS]; + uint8_t validCount[MAX_NUMBER_VARS]; /** * @brief The time needed from the when a sensor has power until it's ready From 747c649efed5d491873f2e16b6248bc5c64cb842 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Thu, 12 Mar 2026 17:11:53 -0400 Subject: [PATCH 522/533] Clear count value regardless of read success (original functionality) Signed-off-by: Sara Damiano --- src/sensors/TallyCounterI2C.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/sensors/TallyCounterI2C.cpp b/src/sensors/TallyCounterI2C.cpp index 916b9f2c4..7e3d0b634 100644 --- a/src/sensors/TallyCounterI2C.cpp +++ b/src/sensors/TallyCounterI2C.cpp @@ -89,11 +89,11 @@ bool TallyCounterI2C::addSingleMeasurementResult() { MS_DBG(getSensorNameAndLocation(), F("is reporting:")); verifyAndAddMeasurementResult(TALLY_EVENTS_VAR_NUM, events); success = true; - - // Clear count value - counter_internal.Clear(); } + // Clear count value regardless of read success + counter_internal.Clear(); + MS_DBG(F(" Events:"), events); // Return success value when finished From 9bc4bbf56ec127d43d0e5f59a0143625d7afd07b Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Thu, 12 Mar 2026 17:13:38 -0400 Subject: [PATCH 523/533] doc changes Signed-off-by: Sara Damiano --- src/LoggerBase.h | 14 +++++++++----- src/VariableArray.h | 2 +- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/LoggerBase.h b/src/LoggerBase.h index a0e7ab97d..09201c98c 100644 --- a/src/LoggerBase.h +++ b/src/LoggerBase.h @@ -243,14 +243,18 @@ class Logger { return _startupMeasurements; } // Backwards-compatibility shims - /// @brief Deprecated alias for setStartupMeasurements - /// @param initialShortIntervals The number of startup measurements - /// @m_deprecated_since{0,38,0} use setStartupMeasurements + /** + * @brief Deprecated alias for setStartupMeasurements + * @param initialShortIntervals The number of startup measurements + * @m_deprecated_since{0,38,0} use setStartupMeasurements + */ void setinitialShortIntervals(int16_t initialShortIntervals) { setStartupMeasurements(initialShortIntervals); } - /// @copydoc getStartupMeasurements - /// @m_deprecated_since{0,38,0} use getStartupMeasurements + /** + * @brief Deprecated alias for getStartupMeasurements + * @m_deprecated_since{0,38,0} use getStartupMeasurements + */ int16_t getinitialShortIntervals() { return getStartupMeasurements(); } diff --git a/src/VariableArray.h b/src/VariableArray.h index b75e37ecf..0e1127286 100644 --- a/src/VariableArray.h +++ b/src/VariableArray.h @@ -138,7 +138,7 @@ class VariableArray { void begin(uint8_t variableCount, Variable* variableList[], const char* uuids[]); /** - * @brief Begins the VariableArray. Checks the validity of all UUID and + * @brief Begins the VariableArray. Checks the validity of all UUIDs and * outputs the results. */ void begin(); From e82c71a1c6e5d4431ba62afa2a831562ca089927 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Thu, 12 Mar 2026 17:14:05 -0400 Subject: [PATCH 524/533] Missed renames Signed-off-by: Sara Damiano --- src/sensors/ProcessorStats.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/sensors/ProcessorStats.cpp b/src/sensors/ProcessorStats.cpp index 28bd926f6..d5c293731 100644 --- a/src/sensors/ProcessorStats.cpp +++ b/src/sensors/ProcessorStats.cpp @@ -28,7 +28,7 @@ ProcessorStats::ProcessorStats(const char* version, #if defined(ARDUINO_AVR_ENVIRODIY_MAYFLY) // fix battery multiplier for older Mayfly versions if (_version != nullptr && - (strcmp(_version, "v0.3") == 0 || strcmp(_version, "v0.4") == 0)) { + (strcmp_P(_version, PSTR("v0.3")) == 0 || strcmp_P(_version, PSTR("v0.4")) == 0)) { _batteryMultiplier = 1.47; } #elif defined(ARDUINO_SODAQ_ONE) || defined(ARDUINO_SODAQ_ONE_BETA) @@ -235,7 +235,7 @@ bool ProcessorStats::addSingleMeasurementResult() { // NOTE: Only running this section if there are no measurements already for // the RAM! - if (numberGoodMeasurementsMade[PROCESSOR_RAM_VAR_NUM] == 0) { + if (validCount[PROCESSOR_RAM_VAR_NUM] == 0) { // Used only for debugging - can be removed MS_DBG(F("Getting Free RAM")); @@ -256,7 +256,7 @@ bool ProcessorStats::addSingleMeasurementResult() { // average-able measurement, only for new measurements. This is a workaround // in case someone wants to average more than one measurement of the battery // voltage. - if (numberGoodMeasurementsMade[PROCESSOR_SAMPNUM_VAR_NUM] == 0) { + if (validCount[PROCESSOR_SAMPNUM_VAR_NUM] == 0) { // bump up the sample number sampNum += 1; @@ -267,7 +267,7 @@ bool ProcessorStats::addSingleMeasurementResult() { // NOTE: Only running this section if there are no measurements already for // the reset cause! - if (numberGoodMeasurementsMade[PROCESSOR_RESET_VAR_NUM] == 0) { + if (validCount[PROCESSOR_RESET_VAR_NUM] == 0) { // Used only for debugging - can be removed MS_DBG(F("Getting last reset cause")); From 6d81ae8af0bd59875532219d5311b5d31508bfab Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Thu, 12 Mar 2026 18:19:52 -0400 Subject: [PATCH 525/533] Some minor changes Signed-off-by: Sara Damiano --- ChangeLog.md | 10 +++--- docs/FAQ/Processor-Compatibility.md | 2 ++ src/ClockSupport.cpp | 4 +-- src/ClockSupport.h | 15 ++++----- src/KnownProcessors.h | 49 +++++++++-------------------- src/LogBuffer.cpp | 10 +++--- src/ModSensorConfig.h | 9 ++++-- src/VariableArray.cpp | 3 +- src/VariableArray.h | 8 +++-- src/VariableBase.h | 4 +-- src/sensors/AOSongAM2315.cpp | 3 +- src/sensors/InSituTrollSdi12a.h | 7 +---- src/sensors/MeaSpecMS5803.h | 3 +- src/sensors/ProcessorStats.cpp | 9 +++--- src/sensors/SensirionSHT4x.h | 2 +- 15 files changed, 64 insertions(+), 74 deletions(-) diff --git a/ChangeLog.md b/ChangeLog.md index f10bedd17..5453692ec 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -118,9 +118,8 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm - The `verifyAndAddMeasurementResult()` is now consistently used in all sensors and is only called when the sensor successfully returned a measurement response. - Also removed all places where sensor values were re-set to -9999 after a measurement failed and then that -9999 was sent to the `verifyAndAddMeasurementResult()` function. These resets were an awkward attempt to deal with bad values before feeding any bad values to the `verifyAndAddMeasurementResult()` function which was previously always called even if the sensor returned junk. - This was probably a hold-over from incorrect implementation and calling of the clearValues function deep in the library history. + This was probably a hold-over from incorrect implementation and calling of the `clearValues()` function deep in the library history. - Also made the return from the `addSingleMeasurementResult()` function consistently false for a bad sensor response and true for a good one - where it's possible to tell the difference. -- The Sensor::clearValues() function now resets the attempt and retry counts in addition to setting all values in the value array to MS_INVALID_VALUE. #### Individual Publishers @@ -180,6 +179,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm When multiple 'measurements to average' are requested, the values of each successful measurement is stored and averaged. Measurements that return bad values even after retries are still not included in averaging. - The default number of retry attempts for most sensors is 1. + - The number of retries and the number of attempted measurements can be reset with `resetMeasurementCounts().` - Made a secondary power pin a property of all sensors. - Added internal function to run the steps of setting the timing and bits after a measurement. - Added setter and getter functions for sensor timing variables. @@ -217,11 +217,13 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm ### Removed -- **BREAKING** Constructors for sensor-associated variables that don't include a pointer to the sensor. +- **Potentially Breaking** Constructors for sensor-associated variables that don't include a pointer to the sensor. You now *must* create the sensor instance before creating the variable and tie the variable to the sensor when creating the variable. -- **BREAKING** All flavors of the variable.begin() functions. + This functionality was never used in any examples and is unlikely to affect any users. +- **Potentially Breaking** All flavors of the variable.begin() functions. These were not needed since all arguments should be set in the constructor or setters for individual parameters. There was no functionality needed in a typical Arduino "begin" function - that is, nothing that needed to be performed after the hardware was active. + This functionality was never used in any examples and is unlikely to affect any users. - Unused `_maxSamplesToAverage` parameter of the VariableArray and the `countMaxToAverage()` function. - Unnecessary copy doc calls for inherited functions and properties. - All overrides of the powerUp and powerDown functions that are no longer needed since all sensors have two power pins built in. diff --git a/docs/FAQ/Processor-Compatibility.md b/docs/FAQ/Processor-Compatibility.md index 99fc6a752..f35a4a391 100644 --- a/docs/FAQ/Processor-Compatibility.md +++ b/docs/FAQ/Processor-Compatibility.md @@ -46,6 +46,7 @@ The specific processors supported by the ModularSensors library are defined in t The [KnownProcessors.h](../src/sensors/KnownProcessors.h) file defines board-specific parameters for optimal configuration: **Basic Board Information:** + - `LOGGER_BOARD`: Pretty text name for the board - `OPERATING_VOLTAGE`: Board operating voltage in volts - `BATTERY_PIN`: Analog pin for battery voltage monitoring @@ -126,6 +127,7 @@ Each board entry should specify: ### Configuration Override All board-specific defaults can be overridden in [ModSensorConfig.h](../src/ModSensorConfig.h) if needed: + - Users can uncomment and modify clock, ADC, or buffer size settings - Build flags can also be used with PlatformIO for custom configurations - Arduino IDE users should modify ModSensorConfig.h as build flags aren't available diff --git a/src/ClockSupport.cpp b/src/ClockSupport.cpp index 385834887..8b7f67534 100644 --- a/src/ClockSupport.cpp +++ b/src/ClockSupport.cpp @@ -670,8 +670,8 @@ int32_t loggerClock::getProcessorTimeZone() { if (is_time_t_signed) { // For signed time_t, negative values are represented normally - if (timeY2K >= -static_cast(SECONDS_IN_DAY) && - timeY2K <= static_cast(SECONDS_IN_DAY)) { + if (timeY2K >= -static_cast(SECONDS_IN_DAY) && + timeY2K <= static_cast(SECONDS_IN_DAY)) { tz_offset = static_cast(timeY2K); } else { tz_offset = 0; // Outside reasonable timezone range (±24 hours) diff --git a/src/ClockSupport.h b/src/ClockSupport.h index d106f439a..3723ba36d 100644 --- a/src/ClockSupport.h +++ b/src/ClockSupport.h @@ -39,14 +39,15 @@ // Validate that exactly one clock has been selected (should be set by // KnownProcessors.h) -#if defined(MS_USE_RV8803) && defined(MS_USE_DS3231) +#if (defined(MS_USE_RV8803) + defined(MS_USE_DS3231) + \ + defined(MS_USE_RTC_ZERO)) > 1 #error Multiple clocks defined! Only one of MS_USE_RV8803, MS_USE_DS3231, or MS_USE_RTC_ZERO can be selected at a time. -#elif defined(MS_USE_RV8803) && defined(MS_USE_RTC_ZERO) -#error Multiple clocks defined! Only one of MS_USE_RV8803, MS_USE_DS3231, or MS_USE_RTC_ZERO can be selected at a time. -#elif defined(MS_USE_DS3231) && defined(MS_USE_RTC_ZERO) -#error Multiple clocks defined! Only one of MS_USE_RV8803, MS_USE_DS3231, or MS_USE_RTC_ZERO can be selected at a time. -#elif !defined(MS_USE_RV8803) && !defined(MS_USE_DS3231) && \ - !defined(MS_USE_RTC_ZERO) +#elif (defined(MS_USE_RV8803) + defined(MS_USE_DS3231) + \ + defined(MS_USE_RTC_ZERO)) == 0 && \ + (defined(ARDUINO_ARCH_SAMD) && !defined(__SAMD51__)) +#pragma message "No clock defined! Using processor as RTC." +#elif (defined(MS_USE_RV8803) + defined(MS_USE_DS3231) + \ + defined(MS_USE_RTC_ZERO)) == 0 #error No clock defined! Define exactly one of MS_USE_RV8803, MS_USE_DS3231, or MS_USE_RTC_ZERO for the RTC. Check that KnownProcessors.h is properly setting defaults for your board, or select a clock in ModSensorConfig.h for other processors. #endif diff --git a/src/KnownProcessors.h b/src/KnownProcessors.h index 75ee2a20b..8cb91e420 100644 --- a/src/KnownProcessors.h +++ b/src/KnownProcessors.h @@ -78,7 +78,8 @@ // Use ADC defaults for an AVR processor // Use log buffer size defaults // Built in DS3231 RTC -#ifndef MS_USE_DS3231 +#if (defined(MS_USE_RV8803) + defined(MS_USE_DS3231) + \ + defined(MS_USE_RTC_ZERO)) == 0 #define MS_USE_DS3231 #endif @@ -95,7 +96,8 @@ // Use ADC defaults for a SAMD processor // Use log buffer size defaults // Built in RV-8803 RTC -#ifndef MS_USE_RV8803 +#if (defined(MS_USE_RV8803) + defined(MS_USE_DS3231) + \ + defined(MS_USE_RTC_ZERO)) == 0 #define MS_USE_RV8803 #endif @@ -112,10 +114,7 @@ #define BATTERY_MULTIPLIER -1 // Use ADC defaults for a SAMD processor // Use log buffer size defaults -// Use the processor as an RTC -#ifndef MS_USE_RTC_ZERO -#define MS_USE_RTC_ZERO -#endif +// The processor can be used as an RTC, but the user must manually select it // https://learn.sodaq.com/Boards/Autonomo/ (Discontinued) #elif defined(ARDUINO_SODAQ_AUTONOMO) @@ -125,10 +124,7 @@ #define BATTERY_MULTIPLIER 1.47 // Use ADC defaults for a SAMD processor // Use log buffer size defaults -// Use the processor as an RTC -#ifndef MS_USE_RTC_ZERO -#define MS_USE_RTC_ZERO -#endif +// The processor can be used as an RTC, but the user must manually select it // https://learn.sodaq.com/Boards/One/base/ (Discontinued) #elif defined(ARDUINO_SODAQ_ONE_BETA) @@ -138,10 +134,7 @@ #define BATTERY_MULTIPLIER 2 // for version v0.1 // Use ADC defaults for a SAMD processor // Use log buffer size defaults -// Use the processor as an RTC -#ifndef MS_USE_RTC_ZERO -#define MS_USE_RTC_ZERO -#endif +// The processor can be used as an RTC, but the user must manually select it // https://learn.sodaq.com/Boards/One/base/ (Discontinued) #elif defined(ARDUINO_SODAQ_ONE) @@ -151,10 +144,7 @@ #define BATTERY_MULTIPLIER 2 // for version v0.1 // Use ADC defaults for a SAMD processor // Use log buffer size defaults -// Use the processor as an RTC -#ifndef MS_USE_RTC_ZERO -#define MS_USE_RTC_ZERO -#endif +// The processor can be used as an RTC, but the user must manually select it // https://learn.sodaq.com/Boards/Mbili/ (Discontinued) #elif defined(ARDUINO_AVR_SODAQ_MBILI) @@ -165,7 +155,8 @@ // Use ADC defaults for an AVR processor // Use log buffer size defaults // Built in DS3231 RTC -#ifndef MS_USE_DS3231 +#if (defined(MS_USE_RV8803) + defined(MS_USE_DS3231) + \ + defined(MS_USE_RTC_ZERO)) == 0 #define MS_USE_DS3231 #endif @@ -233,10 +224,7 @@ #define BATTERY_MULTIPLIER 2 // Use ADC defaults for a SAMD processor // Use log buffer size defaults -// Use the processor as an RTC -#ifndef MS_USE_RTC_ZERO -#define MS_USE_RTC_ZERO -#endif +// The processor can be used as an RTC, but the user must manually select it // https://www.adafruit.com/product/2772 #elif defined(ARDUINO_SAMD_FEATHER_M0) || defined(ADAFRUIT_FEATHER_M0) @@ -246,10 +234,7 @@ #define BATTERY_MULTIPLIER 2 // Use ADC defaults for a SAMD processor // Use log buffer size defaults -// Use the processor as an RTC -#ifndef MS_USE_RTC_ZERO -#define MS_USE_RTC_ZERO -#endif +// The processor can be used as an RTC, but the user must manually select it // https://www.adafruit.com/product/2796 #elif defined(ADAFRUIT_FEATHER_M0_ADALOGGER) @@ -259,10 +244,7 @@ #define BATTERY_MULTIPLIER 2 // Use ADC defaults for a SAMD processor // Use log buffer size defaults -// Use the processor as an RTC -#ifndef MS_USE_RTC_ZERO -#define MS_USE_RTC_ZERO -#endif +// The processor can be used as an RTC, but the user must manually select it // https://www.adafruit.com/product/3857 #elif defined(ARDUINO_FEATHER_M4) || defined(ADAFRUIT_FEATHER_M4_EXPRESS) @@ -460,10 +442,7 @@ #define BATTERY_MULTIPLIER -1 // Use ADC defaults for a SAMD processor // Use log buffer size defaults -// Use the processor as an RTC -#ifndef MS_USE_RTC_ZERO -#define MS_USE_RTC_ZERO -#endif +// The processor can be used as an RTC, but the user must manually select it #endif diff --git a/src/LogBuffer.cpp b/src/LogBuffer.cpp index 366f392c0..3db071f81 100644 --- a/src/LogBuffer.cpp +++ b/src/LogBuffer.cpp @@ -42,10 +42,12 @@ int LogBuffer::getNumRecords() { } uint8_t LogBuffer::getPercentFull() { - uint32_t bytesFull = (uint32_t)numRecords * (uint32_t)recordSize; - uint32_t bytesTotal = MS_LOG_DATA_BUFFER_SIZE; - - return (uint8_t)((bytesFull * (uint32_t)100) / bytesTotal); + uint32_t bytesFull = static_cast(numRecords) * + static_cast(recordSize); + uint32_t percent = (bytesFull * static_cast(100)) / + MS_LOG_DATA_BUFFER_SIZE; + // Cap the result at 100% to handle potential buffer overflow scenarios + return static_cast(percent > 100 ? 100 : percent); } int LogBuffer::addRecord(uint32_t timestamp) { diff --git a/src/ModSensorConfig.h b/src/ModSensorConfig.h index dd096359a..5e5b74f4c 100644 --- a/src/ModSensorConfig.h +++ b/src/ModSensorConfig.h @@ -97,7 +97,7 @@ * @brief The largest number of variables from a single sensor. * * Every sensor will create a buffer of this length for holding variable values. - * Decrease this value to save a memory. + * Decrease this value to save memory. * * @note This is the maximum number of variables that can be tied to any one * sensor, not the maximum number of variables in a variable array. @@ -325,7 +325,7 @@ static_assert(MS_DEFAULT_ADS1X15_ADDRESS == 0x48 || * local atmospheric conditions for more accurate calculations. * * @note In library versions prior to 0.37.0, this variable was named - * SEALEVELPRESSURE_HPA. and was defined in the header files for the BME280 and + * SEALEVELPRESSURE_HPA and was defined in the header files for the BME280 and * BMP3xx sensors. */ #define MS_SEA_LEVEL_PRESSURE_HPA 1013.25f @@ -506,6 +506,11 @@ static_assert(MS_AWS_IOT_PUBLISHER_PUB_COUNT >= 0 && */ #define MS_AWS_IOT_MAX_CONNECTION_TIME 30000L #endif +// Static assert to validate AWS IoT connection timeout is reasonable +static_assert(MS_AWS_IOT_MAX_CONNECTION_TIME > 0 && + MS_AWS_IOT_MAX_CONNECTION_TIME <= 600000L, + "MS_AWS_IOT_MAX_CONNECTION_TIME must be between 1 and 600000 " + "milliseconds (10 minutes max)"); //============================================================== diff --git a/src/VariableArray.cpp b/src/VariableArray.cpp index 9b877fa4e..0d0baeb57 100644 --- a/src/VariableArray.cpp +++ b/src/VariableArray.cpp @@ -39,11 +39,11 @@ void VariableArray::begin(uint8_t variableCount, Variable* variableList[], MS_DBG(F("No variable array in the VariableArray object!")); return; } + matchUUIDs(uuids); if (!populateSensorList()) { MS_DBG(F("Warning: Sensor list may be truncated - exceeded " "MAX_NUMBER_SENSORS limit.")); } - matchUUIDs(uuids); checkVariableUUIDs(); } void VariableArray::begin(uint8_t variableCount, Variable* variableList[]) { @@ -82,6 +82,7 @@ uint8_t VariableArray::getSensorCount() { // This matches UUIDs from an array of pointers to the variable array void VariableArray::matchUUIDs(const char* uuids[]) { + if (uuids == nullptr) return; for (uint8_t i = 0; i < _variableCount; i++) { arrayOfVars[i]->setVarUUID(uuids[i]); } diff --git a/src/VariableArray.h b/src/VariableArray.h index 0e1127286..62ac17f8f 100644 --- a/src/VariableArray.h +++ b/src/VariableArray.h @@ -97,7 +97,10 @@ class VariableArray { */ VariableArray(uint8_t variableCount, Variable* variableList[]); /** - * @brief Construct a new Variable Array object + * @brief Construct a new Variable Array object without initialization. + * + * Use this constructor when the variable list is not yet available. + * Call begin() to initialize the array before use. */ VariableArray(); /** @@ -318,7 +321,8 @@ class VariableArray { /** * @brief Check that all variables have valid UUIDs, if they are assigned * - * @return True if all variables have valid UUIDs. + * @return True if all assigned UUIDs are valid; also returns true if no + * UUIDs are assigned. * * @warning This does not check that the UUIDs are the true UUIDs for the * variables, just that the text is a validly formed UUID. diff --git a/src/VariableBase.h b/src/VariableBase.h index d22dc1106..0cf3e77f2 100644 --- a/src/VariableBase.h +++ b/src/VariableBase.h @@ -308,8 +308,8 @@ class Variable { int decimalPlaces = static_cast(ceilf(-log10Resolution)) + 1; // Clamp to reasonable bounds (0-6 decimal places) - if (decimalPlaces < 0) decimalPlaces = 0; - if (decimalPlaces > 6) decimalPlaces = 6; + if (decimalPlaces < 0) { decimalPlaces = 0; } + if (decimalPlaces > 6) { decimalPlaces = 6; } return static_cast(decimalPlaces); } diff --git a/src/sensors/AOSongAM2315.cpp b/src/sensors/AOSongAM2315.cpp index a963afbe7..377b496ea 100644 --- a/src/sensors/AOSongAM2315.cpp +++ b/src/sensors/AOSongAM2315.cpp @@ -62,8 +62,7 @@ bool AOSongAM2315::addSingleMeasurementResult() { success = am2315.readTemperatureAndHumidity(&temp_val, &humid_val); - success &= !isnan(temp_val) && temp_val != MS_INVALID_VALUE && - !isnan(humid_val) && humid_val != MS_INVALID_VALUE; + success &= !isnan(temp_val) && !isnan(humid_val); MS_DBG(F(" Temp:"), temp_val, F("°C")); MS_DBG(F(" Humidity:"), humid_val, '%'); diff --git a/src/sensors/InSituTrollSdi12a.h b/src/sensors/InSituTrollSdi12a.h index 573a58b5e..3db93b717 100644 --- a/src/sensors/InSituTrollSdi12a.h +++ b/src/sensors/InSituTrollSdi12a.h @@ -123,12 +123,7 @@ * {{ @ref InSituTrollSdi12a_Pressure::InSituTrollSdi12a_Pressure }} */ /**@{*/ -/** - * @brief Decimal places in string representation; conductivity should have 1. - * - * 0 are reported, adding extra digit to resolution to allow the proper number - * of significant figures for averaging - resolution is 0.001 mS/cm = 1 µS/cm - */ +/// @brief Decimal places in string representation; pressure should have 5. #define ITROLLA_PRESSURE_RESOLUTION 5 /// @brief Sensor variable number; pressure is stored in sensorValues[0]. #define ITROLLA_PRESSURE_VAR_NUM 0 diff --git a/src/sensors/MeaSpecMS5803.h b/src/sensors/MeaSpecMS5803.h index a683f0257..f6de8b43c 100644 --- a/src/sensors/MeaSpecMS5803.h +++ b/src/sensors/MeaSpecMS5803.h @@ -325,8 +325,7 @@ class MeaSpecMS5803_Pressure : public Variable { * @param uuid A universally unique identifier (UUID or GUID) for the * variable; optional with the default value of an empty string. * @param varCode A short code to help identify the variable in files; - * optional with a default value of th a default value of - * MeaSpecMS5803Pressure + * optional with a default value of MeaSpecMS5803Pressure */ explicit MeaSpecMS5803_Pressure( MeaSpecMS5803* parentSense, const char* uuid = "", diff --git a/src/sensors/ProcessorStats.cpp b/src/sensors/ProcessorStats.cpp index d5c293731..0221b0a3b 100644 --- a/src/sensors/ProcessorStats.cpp +++ b/src/sensors/ProcessorStats.cpp @@ -28,16 +28,17 @@ ProcessorStats::ProcessorStats(const char* version, #if defined(ARDUINO_AVR_ENVIRODIY_MAYFLY) // fix battery multiplier for older Mayfly versions if (_version != nullptr && - (strcmp_P(_version, PSTR("v0.3")) == 0 || strcmp_P(_version, PSTR("v0.4")) == 0)) { + (strcmp_P(_version, PSTR("v0.3")) == 0 || + strcmp_P(_version, PSTR("v0.4")) == 0)) { _batteryMultiplier = 1.47; } #elif defined(ARDUINO_SODAQ_ONE) || defined(ARDUINO_SODAQ_ONE_BETA) // only versions v0.1 and v0.2 of the Sodaq One are supported, and they have // different battery multipliers (_batteryPin uses the default) if (_version != nullptr) { - if (strcmp(_version, "v0.1") == 0) { + if (strcmp_P(_version, PSTR("v0.1")) == 0) { _batteryMultiplier = 2; - } else if (strcmp(_version, "v0.2") == 0) { + } else if (strcmp_P(_version, PSTR("v0.2")) == 0) { _batteryMultiplier = 1.47; } else { MS_DBG(F("Unsupported Sodaq One version:"), _version, @@ -51,7 +52,7 @@ ProcessorStats::ProcessorStats(const char* version, } #elif defined(ARDUINO_SODAQ_AUTONOMO) if (_version != nullptr) { - if (strcmp(_version, "v0.1") == 0) { + if (strcmp_P(_version, PSTR("v0.1")) == 0) { _batteryPin = 48; } else { _batteryPin = 33; diff --git a/src/sensors/SensirionSHT4x.h b/src/sensors/SensirionSHT4x.h index 99764b0f9..b04840efa 100644 --- a/src/sensors/SensirionSHT4x.h +++ b/src/sensors/SensirionSHT4x.h @@ -290,7 +290,7 @@ class SensirionSHT4x : public Sensor { */ bool _useHeater; /** - * @brief Internal reference to the Adafruit SHT4x object + * @brief Internal instance of the Adafruit SHT4x object */ Adafruit_SHT4x sht4x_internal; /** From 6b9e424e70b6e99c24b6085683f829e003281e4a Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Fri, 13 Mar 2026 12:39:27 -0400 Subject: [PATCH 526/533] Reduce magic numbers, add some docs Signed-off-by: Sara Damiano --- src/KnownProcessors.h | 12 +++---- src/LoggerBase.h | 1 + src/ModSensorConfig.h | 4 +++ src/SensorBase.h | 9 ++++++ src/sensors/AnalogElecConductivity.cpp | 3 +- src/sensors/ApogeeSQ212.cpp | 1 + src/sensors/AtlasParent.cpp | 16 +++++----- src/sensors/AtlasParent.h | 23 ++++++++++++++ src/sensors/CampbellOBS3.cpp | 1 + src/sensors/CampbellRainVUE10.h | 2 +- src/sensors/EverlightALSPT19.cpp | 1 + src/sensors/MaximDS18.cpp | 2 +- src/sensors/MaximDS18.h | 4 +++ src/sensors/PaleoTerraRedox.cpp | 6 ++-- src/sensors/PaleoTerraRedox.h | 33 ++++++++++++++------ src/sensors/ProcessorAnalog.cpp | 1 + src/sensors/ProcessorAnalog.h | 4 +-- src/sensors/TIADS1x15.h | 43 ++++++++++++-------------- src/sensors/TurnerCyclops.cpp | 1 + src/sensors/YosemitechY533.h | 4 +-- 20 files changed, 113 insertions(+), 58 deletions(-) diff --git a/src/KnownProcessors.h b/src/KnownProcessors.h index 8cb91e420..8fc96fb8c 100644 --- a/src/KnownProcessors.h +++ b/src/KnownProcessors.h @@ -462,7 +462,7 @@ #ifndef MS_PROCESSOR_ADC_REFERENCE_MODE // Fallback ADC reference mode based on processor architecture -#if defined(ARDUINO_ARCH_AVR) +#if defined(__AVR__) || defined(ARDUINO_ARCH_AVR) #define MS_PROCESSOR_ADC_REFERENCE_MODE DEFAULT #elif defined(ARDUINO_ARCH_SAMD) #define MS_PROCESSOR_ADC_REFERENCE_MODE AR_DEFAULT @@ -505,17 +505,17 @@ #define BATTERY_PIN -1 #pragma message \ "Warning: BATTERY_PIN is not defined for this processor.\n" \ - "If your processor does not have a built-in pin for measuring the battery voltage," \ + "If your processor does not have a built-in pin for measuring the battery voltage, " \ "or you have specified a different pin in your code, you can ignore this message.\n" \ "The battery pin can be added by editing KnownProcessors.h." #endif #ifndef BATTERY_MULTIPLIER #define BATTERY_MULTIPLIER -1 -#pragma message \ - "Warning: BATTERY_MULTIPLIER is not defined for this processor.\n" \ - "If your processor does not have a built-in pin for measuring the battery voltage," \ - "or you have specified the multiplier in your code, you can ignore this message.\n" \ +#pragma message \ + "Warning: BATTERY_MULTIPLIER is not defined for this processor.\n" \ + "If your processor does not have a built-in pin for measuring the battery voltage, " \ + "or you have specified the multiplier in your code, you can ignore this message.\n" \ "The battery multiplier can be added by editing KnownProcessors.h." #endif diff --git a/src/LoggerBase.h b/src/LoggerBase.h index 09201c98c..4441fde99 100644 --- a/src/LoggerBase.h +++ b/src/LoggerBase.h @@ -253,6 +253,7 @@ class Logger { } /** * @brief Deprecated alias for getStartupMeasurements + * @return The remaining number of startup measurements * @m_deprecated_since{0,38,0} use getStartupMeasurements */ int16_t getinitialShortIntervals() { diff --git a/src/ModSensorConfig.h b/src/ModSensorConfig.h index 5e5b74f4c..a3817797a 100644 --- a/src/ModSensorConfig.h +++ b/src/ModSensorConfig.h @@ -74,6 +74,10 @@ */ #define LATEST_SANE_UNIX_TIMESTAMP 2051222400 #endif +// Static assert to validate timestamp bounds relationship +static_assert(EARLIEST_SANE_UNIX_TIMESTAMP < LATEST_SANE_UNIX_TIMESTAMP, + "EARLIEST_SANE_UNIX_TIMESTAMP must be less than " + "LATEST_SANE_UNIX_TIMESTAMP"); //============================================================== diff --git a/src/SensorBase.h b/src/SensorBase.h index bdfe8306e..d8a5fd3f0 100644 --- a/src/SensorBase.h +++ b/src/SensorBase.h @@ -152,6 +152,11 @@ class Sensor { virtual int8_t getPowerPin(); /** * @brief Set the pin number controlling sensor power. + * + * @warning Only change power pins when the sensor is powered off to avoid + * leaving old pins HIGH and potentially damaging circuits or causing + * power management conflicts. + * * @param pin The pin on the mcu controlling power to the sensor. */ virtual void setPowerPin(int8_t pin); @@ -172,6 +177,10 @@ class Sensor { * to an adapter or converter needed to talk to the sensor - i.e., an RS232 * adapter, an RS485 adapter, or an IO multiplexer. * + * @warning Only change power pins when the sensor is powered off to avoid + * leaving old pins HIGH and potentially damaging circuits or causing + * power management conflicts. + * * @param pin The pin on the mcu controlling secondary power */ virtual void setSecondaryPowerPin(int8_t pin); diff --git a/src/sensors/AnalogElecConductivity.cpp b/src/sensors/AnalogElecConductivity.cpp index 4d0440278..fef8ed810 100644 --- a/src/sensors/AnalogElecConductivity.cpp +++ b/src/sensors/AnalogElecConductivity.cpp @@ -43,6 +43,7 @@ String AnalogElecConductivity::getSensorLocation() { String sensorLocation; sensorLocation.reserve(48); // Approximate expected size if (_analogVoltageReader != nullptr) { + // Set the reference channel to -1 for a single-ended sensor sensorLocation = _analogVoltageReader->getAnalogLocation(_dataPin, -1); } else { sensorLocation = F("Unknown_AnalogVoltageReader"); @@ -127,7 +128,7 @@ bool AnalogElecConductivity::addSingleMeasurementResult() { float EC_uScm = MS_INVALID_VALUE; // units are uS per cm if (Rwater_ohms > 0.0f) { EC_uScm = 1000000.0f / (Rwater_ohms * _sensorEC_Konst); - MS_DBG(F("Water EC (uS/cm)"), EC_uScm); + MS_DBG(F("Water EC (uS/cm):"), EC_uScm); verifyAndAddMeasurementResult(ANALOGELECCONDUCTIVITY_EC_VAR_NUM, EC_uScm); } else { diff --git a/src/sensors/ApogeeSQ212.cpp b/src/sensors/ApogeeSQ212.cpp index 19a99dda7..eab6ae331 100644 --- a/src/sensors/ApogeeSQ212.cpp +++ b/src/sensors/ApogeeSQ212.cpp @@ -40,6 +40,7 @@ ApogeeSQ212::~ApogeeSQ212() { String ApogeeSQ212::getSensorLocation() { if (_analogVoltageReader != nullptr) { + // Set the reference channel to -1 for a single-ended sensor return _analogVoltageReader->getAnalogLocation(_dataPin, -1); } else { return String(F("Unknown_AnalogVoltageReader")); diff --git a/src/sensors/AtlasParent.cpp b/src/sensors/AtlasParent.cpp index 5877e30fa..54cdd8821 100644 --- a/src/sensors/AtlasParent.cpp +++ b/src/sensors/AtlasParent.cpp @@ -139,9 +139,9 @@ bool AtlasParent::addSingleMeasurementResult() { bool success = false; - // call the circuit and request 40 bytes (this may be more than we need) - int bytesReceived = _i2c->requestFrom(static_cast(_i2cAddressHex), 40, - 1); + // call the circuit and request up to the maximum buffer size (this may be more than we need) + int bytesReceived = _i2c->requestFrom(static_cast(_i2cAddressHex), + ATLAS_I2C_RESPONSE_BUFFER_SIZE, 1); if (bytesReceived == 0) { MS_DBG(getSensorNameAndLocation(), F("I2C read failed - no response")); return finalizeMeasurementAttempt(false); @@ -151,20 +151,20 @@ bool AtlasParent::addSingleMeasurementResult() { MS_DBG(getSensorNameAndLocation(), F("is reporting:")); // Parse the response code switch (code) { - case 1: // the command was successful. + case ATLAS_RESPONSE_SUCCESS: // the command was successful. MS_DBG(F(" Measurement successful")); success = true; break; - case 2: // the command has failed. + case ATLAS_RESPONSE_FAILED: // the command has failed. MS_DBG(F(" Measurement Failed")); break; - case 254: // the command has not yet been finished calculating. + case ATLAS_RESPONSE_PENDING: // the command has not yet been finished calculating. MS_DBG(F(" Measurement Pending")); break; - case 255: // there is no further data to send. + case ATLAS_RESPONSE_NO_DATA: // there is no further data to send. MS_DBG(F(" No Data")); break; @@ -179,7 +179,7 @@ bool AtlasParent::addSingleMeasurementResult() { break; } float result = _i2c->parseFloat(); - if (isnan(result) || result < -1020) { + if (isnan(result) || result < ATLAS_MIN_VALID_RESULT) { result = MS_INVALID_VALUE; success = false; MS_DBG(F(" Invalid response for result #"), i); diff --git a/src/sensors/AtlasParent.h b/src/sensors/AtlasParent.h index ea159c3b4..ed17a7d62 100644 --- a/src/sensors/AtlasParent.h +++ b/src/sensors/AtlasParent.h @@ -93,6 +93,29 @@ #include "SensorBase.h" #include +/** @ingroup atlas_group */ +/**@{*/ + +/** + * @anchor atlas_response_codes + * @name Atlas Response Codes + * Standard response codes returned by Atlas EZO circuits + */ +/**@{*/ +/// @brief The command was successful +#define ATLAS_RESPONSE_SUCCESS 1 +/// @brief The command has failed +#define ATLAS_RESPONSE_FAILED 2 +/// @brief The command has not yet been finished calculating +#define ATLAS_RESPONSE_PENDING 254 +/// @brief There is no further data to send +#define ATLAS_RESPONSE_NO_DATA 255 +/// @brief Maximum I2C response buffer size for Atlas circuits +#define ATLAS_I2C_RESPONSE_BUFFER_SIZE 40 +/// @brief Minimum valid result threshold for Atlas sensor readings +#define ATLAS_MIN_VALID_RESULT -1020.0f +/**@}*/ + /** * @brief A parent class for Atlas EZO circuits and sensors * diff --git a/src/sensors/CampbellOBS3.cpp b/src/sensors/CampbellOBS3.cpp index 4dcafbdb5..238265a41 100644 --- a/src/sensors/CampbellOBS3.cpp +++ b/src/sensors/CampbellOBS3.cpp @@ -41,6 +41,7 @@ CampbellOBS3::~CampbellOBS3() { String CampbellOBS3::getSensorLocation() { if (_analogVoltageReader != nullptr) { + // Set the reference channel to -1 for a single-ended sensor return _analogVoltageReader->getAnalogLocation(_dataPin, -1); } else { return String(F("Unknown_AnalogVoltageReader")); diff --git a/src/sensors/CampbellRainVUE10.h b/src/sensors/CampbellRainVUE10.h index a5c094f05..60441bd3a 100644 --- a/src/sensors/CampbellRainVUE10.h +++ b/src/sensors/CampbellRainVUE10.h @@ -224,7 +224,7 @@ /// [ODM2 controlled vocabulary](http://vocabulary.odm2.org/units/); /// "inchPerHour" #define RAINVUE10_RAINRATEMAX_UNIT_NAME "inchPerHour" -/// @brief Default variable short code; "RainVUERateAve" +/// @brief Default variable short code; "RainVUERateMax" #define RAINVUE10_RAINRATEMAX_DEFAULT_CODE "RainVUERateMax" /**@}*/ diff --git a/src/sensors/EverlightALSPT19.cpp b/src/sensors/EverlightALSPT19.cpp index 10be07708..9cc32bff3 100644 --- a/src/sensors/EverlightALSPT19.cpp +++ b/src/sensors/EverlightALSPT19.cpp @@ -52,6 +52,7 @@ EverlightALSPT19::~EverlightALSPT19() { String EverlightALSPT19::getSensorLocation() { if (_analogVoltageReader != nullptr) { + // Set the reference channel to -1 for a single-ended sensor return _analogVoltageReader->getAnalogLocation(_dataPin, -1); } else { return String(F("Unknown_AnalogVoltageReader")); diff --git a/src/sensors/MaximDS18.cpp b/src/sensors/MaximDS18.cpp index 3e9858706..062b99211 100644 --- a/src/sensors/MaximDS18.cpp +++ b/src/sensors/MaximDS18.cpp @@ -194,7 +194,7 @@ bool MaximDS18::addSingleMeasurementResult() { // If a DS18 cannot get a good measurement, it returns 85 // If the sensor is not properly connected, it returns -127 - if (result != 85 && result != -127) { + if (result != DS18_BAD_MEASUREMENT_VALUE && result != DS18_DISCONNECTED_VALUE) { // Put value into the array verifyAndAddMeasurementResult(DS18_TEMP_VAR_NUM, result); success = true; diff --git a/src/sensors/MaximDS18.h b/src/sensors/MaximDS18.h index fa9e7b604..5f85322ad 100644 --- a/src/sensors/MaximDS18.h +++ b/src/sensors/MaximDS18.h @@ -167,6 +167,10 @@ #define DS18_TEMP_UNIT_NAME "degreeCelsius" /// @brief Default variable short code; "DS18Temp" #define DS18_TEMP_DEFAULT_CODE "DS18Temp" +/// @brief Value returned when DS18 cannot get a good measurement +#define DS18_BAD_MEASUREMENT_VALUE 85.0f +/// @brief Value returned when DS18 sensor is not properly connected +#define DS18_DISCONNECTED_VALUE -127.0f /**@}*/ /* clang-format off */ diff --git a/src/sensors/PaleoTerraRedox.cpp b/src/sensors/PaleoTerraRedox.cpp index 549827727..1abbea088 100644 --- a/src/sensors/PaleoTerraRedox.cpp +++ b/src/sensors/PaleoTerraRedox.cpp @@ -160,12 +160,12 @@ bool PaleoTerraRedox::addSingleMeasurementResult() { adcValue |= 0xFFFC0000; // Sign extend from bit 17 (set all bits 18-31) } - // convert the raw ADC value to voltage in microvolts (uV) - res = adcValue * 0.015625; // 15.625 uV per LSB + // convert the raw ADC value to voltage in millivolts (mV) + res = adcValue * PTR_MV_PER_LSB; // 0.015625 mV per LSB MS_DBG(F("Raw ADC reading in bits:"), adcValue); MS_DBG(F("Config byte:"), config); - MS_DBG(F("Calculated voltage in uV:"), res); + MS_DBG(F("Calculated voltage in mV:"), res); success = (!isnan(res)) && !(adcValue == 0 && config == 0); if (success) { diff --git a/src/sensors/PaleoTerraRedox.h b/src/sensors/PaleoTerraRedox.h index 7431d0659..f5cdf5e21 100644 --- a/src/sensors/PaleoTerraRedox.h +++ b/src/sensors/PaleoTerraRedox.h @@ -43,6 +43,12 @@ * @section sensor_pt_redox_flags Build flags * - `-D MS_PALEOTERRA_SOFTWAREWIRE` * - switches from using hardware I2C to software I2C + * - `PTR_MV_PER_LSB` + * - ADC LSB to microvolts conversion factor (15.625 μV per LSB) + * - Used to convert raw ADC values to voltage measurements + * - `MCP3421_ADR` + * - Default I2C address of the PaleoTerra redox sensor (0x68) + * - Can be overridden in constructor if sensor address is different * @warning Either all or none of your attached redox probes may use software I2C. * Using some with software I2C and others with hardware I2C is not supported. * @@ -92,6 +98,23 @@ /** @ingroup sensor_pt_redox */ /**@{*/ +/** + * @anchor sensor_pt_redox_config + * @name Configuration Defines + * Defines to set the address of the PaleoTerra redox sensor. + */ +/**@{*/ +/// @brief The default I2C address of the PaleoTerra redox sensor +#ifndef MCP3421_ADR +#define MCP3421_ADR 0x68 +#endif +/// @brief ADC LSB to millivolts conversion factor (15.625 µV per LSB = 0.015625 +/// mV per LSB) +#ifndef PTR_MV_PER_LSB +#define PTR_MV_PER_LSB 0.015625f +#endif +/**@}*/ + /** * @anchor sensor_pt_redox_var_counts * @name Sensor Variable Counts @@ -105,16 +128,6 @@ #define PTR_INC_CALC_VARIABLES 0 /**@}*/ -/** - * @anchor sensor_pt_redox_config - * @name Configuration Defines - * Defines to set the address of the PaleoTerra redox sensor. - */ -/**@{*/ -/// @brief The default I2C address of the PaleoTerra redox sensor -#define MCP3421_ADR 0x68 -/**@}*/ - /** * @anchor sensor_pt_redox_timing * @name Sensor Timing diff --git a/src/sensors/ProcessorAnalog.cpp b/src/sensors/ProcessorAnalog.cpp index 1641bdf8a..c90c805cf 100644 --- a/src/sensors/ProcessorAnalog.cpp +++ b/src/sensors/ProcessorAnalog.cpp @@ -148,6 +148,7 @@ ProcessorAnalog::~ProcessorAnalog() { String ProcessorAnalog::getSensorLocation() { if (_analogVoltageReader != nullptr) { + // Set the reference channel to -1 for a single-ended sensor return _analogVoltageReader->getAnalogLocation(_dataPin, -1); } else { return String(F("Unknown_AnalogVoltageReader")); diff --git a/src/sensors/ProcessorAnalog.h b/src/sensors/ProcessorAnalog.h index 9ebb7adc1..bf60ae21a 100644 --- a/src/sensors/ProcessorAnalog.h +++ b/src/sensors/ProcessorAnalog.h @@ -166,8 +166,8 @@ class ProcessorAnalogReader : public AnalogVoltageReader { * @brief Construct a new ProcessorAnalogReader object * * @param voltageMultiplier Any multiplier needed to convert raw battery - * readings from `analogRead()` into true battery values based on any - * resistors or voltage dividers + * readings from `analogRead()` into true voltage values based on any + * voltage divider resistors * @param operatingVoltage The processor's operating voltage; most * likely 3.3 or 5. */ diff --git a/src/sensors/TIADS1x15.h b/src/sensors/TIADS1x15.h index e896f6777..84b6899d9 100644 --- a/src/sensors/TIADS1x15.h +++ b/src/sensors/TIADS1x15.h @@ -246,9 +246,13 @@ #ifdef MS_USE_ADS1015 /// @brief Decimal places in string representation; voltage should have 1. #define TIADS1X15_RESOLUTION 1 +/// @brief Default data rate for ADS1015 (1600 SPS) +#define TIADS1X15_DEFAULT_DATA_RATE RATE_ADS1015_1600SPS #else /// @brief Decimal places in string representation; voltage should have 4. #define TIADS1X15_RESOLUTION 4 +/// @brief Default data rate for ADS1115 (128 SPS) +#define TIADS1X15_DEFAULT_DATA_RATE RATE_ADS1115_128SPS #endif /**@}*/ @@ -275,16 +279,12 @@ class TIADS1x15Reader : public AnalogVoltageReader { * @param adsSupplyVoltage The power supply voltage for the ADS1x15 in volts * @param adsDataRate The data rate for the ADS1x15 (samples per second) */ - explicit TIADS1x15Reader(TwoWire* theI2C, float voltageMultiplier = 1.0f, - adsGain_t adsGain = GAIN_ONE, - uint8_t i2cAddress = MS_DEFAULT_ADS1X15_ADDRESS, - float adsSupplyVoltage = OPERATING_VOLTAGE, -#ifndef MS_USE_ADS1015 - uint16_t adsDataRate = RATE_ADS1115_128SPS -#else - uint16_t adsDataRate = RATE_ADS1015_1600SPS -#endif - ); + explicit TIADS1x15Reader( + TwoWire* theI2C, float voltageMultiplier = 1.0f, + adsGain_t adsGain = GAIN_ONE, + uint8_t i2cAddress = MS_DEFAULT_ADS1X15_ADDRESS, + float adsSupplyVoltage = OPERATING_VOLTAGE, + uint16_t adsDataRate = TIADS1X15_DEFAULT_DATA_RATE); /** * @brief Construct a new TIADS1x15Reader object using the default hardware @@ -296,16 +296,11 @@ class TIADS1x15Reader : public AnalogVoltageReader { * @param adsSupplyVoltage The power supply voltage for the ADS1x15 in volts * @param adsDataRate The data rate for the ADS1x15 (samples per second) */ - explicit TIADS1x15Reader(float voltageMultiplier = 1.0f, - adsGain_t adsGain = GAIN_ONE, - uint8_t i2cAddress = MS_DEFAULT_ADS1X15_ADDRESS, - float adsSupplyVoltage = OPERATING_VOLTAGE, -#ifndef MS_USE_ADS1015 - uint16_t adsDataRate = RATE_ADS1115_128SPS -#else - uint16_t adsDataRate = RATE_ADS1015_1600SPS -#endif - ); + explicit TIADS1x15Reader( + float voltageMultiplier = 1.0f, adsGain_t adsGain = GAIN_ONE, + uint8_t i2cAddress = MS_DEFAULT_ADS1X15_ADDRESS, + float adsSupplyVoltage = OPERATING_VOLTAGE, + uint16_t adsDataRate = TIADS1X15_DEFAULT_DATA_RATE); /** * @brief Destroy the TIADS1x15Reader object @@ -432,19 +427,19 @@ class TIADS1x15Reader : public AnalogVoltageReader { /** * @brief An internal reference to the hardware Wire instance. */ - TwoWire* _wire; + TwoWire* _wire = nullptr; /** * @brief Internal reference to the I2C address of the TI-ADS1x15 */ - uint8_t _i2cAddress; + uint8_t _i2cAddress = MS_DEFAULT_ADS1X15_ADDRESS; /** * @brief The internal gain setting for the ADS1x15 */ - adsGain_t _adsGain; + adsGain_t _adsGain = GAIN_ONE; /** * @brief The data rate setting for the ADS1x15 */ - uint16_t _adsDataRate; + uint16_t _adsDataRate = TIADS1X15_DEFAULT_DATA_RATE; /** * @brief Per-instance ADS1x15 driver to maintain separate I2C state */ diff --git a/src/sensors/TurnerCyclops.cpp b/src/sensors/TurnerCyclops.cpp index baa15ba1d..b704d4ce6 100644 --- a/src/sensors/TurnerCyclops.cpp +++ b/src/sensors/TurnerCyclops.cpp @@ -42,6 +42,7 @@ TurnerCyclops::~TurnerCyclops() { String TurnerCyclops::getSensorLocation() { if (_analogVoltageReader != nullptr) { + // Set the reference channel to -1 for a single-ended sensor return _analogVoltageReader->getAnalogLocation(_dataPin, -1); } else { return String(F("Unknown_AnalogVoltageReader")); diff --git a/src/sensors/YosemitechY533.h b/src/sensors/YosemitechY533.h index 1f90c856a..6b70ab67e 100644 --- a/src/sensors/YosemitechY533.h +++ b/src/sensors/YosemitechY533.h @@ -212,14 +212,14 @@ class YosemitechY533 : public YosemitechParent { class YosemitechY533_ORP : public Variable { public: /** - * @brief Construct a new YosemitechY533_pH object. + * @brief Construct a new YosemitechY533_ORP object. * * @param parentSense The parent YosemitechY533 providing the result * values. * @param uuid A universally unique identifier (UUID or GUID) for the * variable; optional with the default value of an empty string. * @param varCode A short code to help identify the variable in files; - * optional with a default value of "Y533pH". + * optional with a default value of "Y533ORP". */ explicit YosemitechY533_ORP(YosemitechY533* parentSense, const char* uuid = "", From e7153d3bdb8a4868c10cb55b47f053fbe7e65528 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Fri, 13 Mar 2026 16:44:28 -0400 Subject: [PATCH 527/533] Added min/max range values for variables where I knew it. Not yet used. Signed-off-by: Sara Damiano --- cspell.json | 3 + src/KnownProcessors.h | 4 +- src/SensorBase.h | 4 +- src/WatchDogs/WatchDogAVR.cpp | 4 +- src/WatchDogs/WatchDogSAMD.cpp | 4 +- src/WatchDogs/WatchDogSAMD.h | 4 +- src/sensors/ANBpH.h | 20 +- src/sensors/AOSongAM2315.h | 8 + src/sensors/AOSongDHT.h | 10 +- src/sensors/AlphasenseCO2.h | 11 +- src/sensors/AnalogElecConductivity.h | 7 +- src/sensors/ApogeeSQ212.h | 10 +- src/sensors/AtlasParent.cpp | 10 +- src/sensors/AtlasScientificCO2.h | 8 + src/sensors/AtlasScientificDO.h | 8 + src/sensors/AtlasScientificEC.h | 18 +- src/sensors/AtlasScientificORP.h | 8 +- src/sensors/AtlasScientificRTD.h | 4 + src/sensors/AtlasScientificpH.h | 6 +- src/sensors/BoschBME280.h | 16 +- src/sensors/BoschBMP3xx.h | 12 +- src/sensors/CampbellClariVUE10.h | 10 + src/sensors/CampbellOBS3.h | 12 +- src/sensors/CampbellRainVUE10.h | 25 +- src/sensors/Decagon5TM.h | 21 +- src/sensors/DecagonCTD.h | 12 + src/sensors/DecagonES2.h | 8 + src/sensors/EverlightALSPT19.h | 14 + src/sensors/FreescaleMPL115A2.cpp | 5 +- src/sensors/FreescaleMPL115A2.h | 8 + src/sensors/GeoluxHydroCam.h | 19 +- src/sensors/GroPointParent.h | 2 +- src/sensors/InSituRDO.h | 22 +- src/sensors/InSituTrollSdi12a.h | 18 +- src/sensors/KellerAcculevel.h | 16 +- src/sensors/KellerNanolevel.h | 14 +- src/sensors/KellerParent.h | 2 +- src/sensors/MaxBotixSonar.h | 8 +- src/sensors/MaximDS18.cpp | 3 +- src/sensors/MaximDS18.h | 4 + src/sensors/MaximDS3231.h | 6 +- src/sensors/MeaSpecMS5803.cpp | 9 +- src/sensors/MeaSpecMS5803.h | 12 +- src/sensors/MeterHydros21.h | 12 + src/sensors/MeterTeros11.h | 15 ++ src/sensors/PaleoTerraRedox.h | 3 + src/sensors/ProcessorAnalog.h | 5 +- src/sensors/ProcessorStats.h | 17 +- src/sensors/RainCounterI2C.h | 14 +- src/sensors/SensirionSHT4x.h | 10 +- src/sensors/TEConnectivityMS5837.h | 12 +- src/sensors/TIADS1x15.h | 8 +- src/sensors/TIINA219.h | 24 +- src/sensors/TallyCounterI2C.h | 4 + src/sensors/TurnerCyclops.h | 370 +++++++++++++++++++++++---- src/sensors/TurnerTurbidityPlus.h | 9 +- src/sensors/VegaPuls21.h | 18 ++ src/sensors/YosemitechParent.h | 2 +- src/sensors/YosemitechY4000.h | 34 ++- src/sensors/YosemitechY504.h | 12 + src/sensors/YosemitechY510.h | 8 + src/sensors/YosemitechY511.h | 10 +- src/sensors/YosemitechY513.h | 10 + src/sensors/YosemitechY514.h | 10 +- src/sensors/YosemitechY520.h | 8 + src/sensors/YosemitechY532.h | 12 + src/sensors/YosemitechY533.h | 8 + src/sensors/YosemitechY551.h | 12 + src/sensors/YosemitechY560.h | 12 + src/sensors/YosemitechY700.h | 8 + src/sensors/ZebraTechDOpto.h | 14 +- 71 files changed, 976 insertions(+), 134 deletions(-) diff --git a/cspell.json b/cspell.json index 07186ffe2..07552df7f 100644 --- a/cspell.json +++ b/cspell.json @@ -171,6 +171,7 @@ "Mbili", "MCLK", "menusnip", + "MGPL", "microeinstein", "microeinsteins", "micromoles", @@ -179,6 +180,7 @@ "microvolts", "milliamp", "milliwatt", + "milliwatts", "Modbus", "MODSENSORCONFIG", "MODSENSORDEBUGGER", @@ -276,6 +278,7 @@ "USBCON", "USBE", "USBVIRTUAL", + "USCM", "USGS", "UUID", "VEGAPULS", diff --git a/src/KnownProcessors.h b/src/KnownProcessors.h index 8fc96fb8c..c575de773 100644 --- a/src/KnownProcessors.h +++ b/src/KnownProcessors.h @@ -519,6 +519,6 @@ "The battery multiplier can be added by editing KnownProcessors.h." #endif -// cspell:words Tatu Moja Adalogger Duemilanove Esplora - #endif + +// cSpell:words Tatu Moja Adalogger Duemilanove Esplora diff --git a/src/SensorBase.h b/src/SensorBase.h index d8a5fd3f0..807559ef3 100644 --- a/src/SensorBase.h +++ b/src/SensorBase.h @@ -152,11 +152,11 @@ class Sensor { virtual int8_t getPowerPin(); /** * @brief Set the pin number controlling sensor power. - * + * * @warning Only change power pins when the sensor is powered off to avoid * leaving old pins HIGH and potentially damaging circuits or causing * power management conflicts. - * + * * @param pin The pin on the mcu controlling power to the sensor. */ virtual void setPowerPin(int8_t pin); diff --git a/src/WatchDogs/WatchDogAVR.cpp b/src/WatchDogs/WatchDogAVR.cpp index 6592734d2..10a725c8a 100644 --- a/src/WatchDogs/WatchDogAVR.cpp +++ b/src/WatchDogs/WatchDogAVR.cpp @@ -128,6 +128,6 @@ ISR(WDT_vect) { } } -// cspell:words MCUSR WDTCSR WDCE WDRF WDIF WDIE WDT_vect - #endif + +// cSpell:words MCUSR WDTCSR WDCE WDRF WDIF WDIE WDT_vect diff --git a/src/WatchDogs/WatchDogSAMD.cpp b/src/WatchDogs/WatchDogSAMD.cpp index b435a9476..53381a41e 100644 --- a/src/WatchDogs/WatchDogSAMD.cpp +++ b/src/WatchDogs/WatchDogSAMD.cpp @@ -428,6 +428,6 @@ void WDT_Handler(void) { } // cspell:words EWCTRL EWOFFSET INTENSET ULP32KOSC GCLK_GENCTRL_GENEN APBAMASK -// cspell:words GCLK_CLKCTRL_CLKEN irqn CKSEL - #endif + +// cSpell:words GCLK_CLKCTRL_CLKEN irqn CKSEL diff --git a/src/WatchDogs/WatchDogSAMD.h b/src/WatchDogs/WatchDogSAMD.h index 23afc0651..3480ebc16 100644 --- a/src/WatchDogs/WatchDogSAMD.h +++ b/src/WatchDogs/WatchDogSAMD.h @@ -167,6 +167,6 @@ class extendedWatchDogSAMD { static uint32_t _resetTime_s; }; -// cspell:words ULP32KOSC - #endif // SRC_WATCHDOGS_WATCHDOGSAMD_H_ + +// cSpell:words ULP32KOSC diff --git a/src/sensors/ANBpH.h b/src/sensors/ANBpH.h index ad6186c52..76ad45277 100644 --- a/src/sensors/ANBpH.h +++ b/src/sensors/ANBpH.h @@ -221,6 +221,12 @@ * {{ @ref ANBpH_pH::ANBpH_pH }} */ /**@{*/ +/// @brief Minimum pH value. +#define ANB_PH_PH_MIN 0 +/// @brief Maximum pH value. +/// @note The valid range is up to 14, but we allow up to 100 to keep the 99.99 +/// error code from being out of range.) +#define ANB_PH_PH_MAX 100 /// @brief Decimal places in string representation; pH should have 2 - /// resolution is 0.01. #define ANB_PH_PH_RESOLUTION 2 @@ -245,6 +251,10 @@ * {{ @ref ANBpH_Temp::ANBpH_Temp }} */ /**@{*/ +/// @brief Minimum temperature in degrees Celsius. +#define ANB_PH_TEMP_MIN_C -5.0 +/// @brief Maximum temperature in degrees Celsius. +#define ANB_PH_TEMP_MAX_C 40.0 /// @brief Decimal places in string representation; temperature should have 2 - /// resolution is 0.01°C. #define ANB_PH_TEMP_RESOLUTION 2 @@ -275,6 +285,8 @@ * @note If both the pH and salinity output is 99.99, check the * transducer health code for instruction. * + * @todo Find and define minimum and maximum salinity measurement range + * * {{ @ref ANBpH_Salinity::ANBpH_Salinity }} */ /**@{*/ @@ -309,6 +321,9 @@ * @note If both the pH and specific conductance output is 99.99, check the * transducer health code for instruction. * + * @todo Find and define minimum and maximum specific conductance measurement + * range + * * {{ @ref ANBpH_SpCond::ANBpH_SpCond }} */ /**@{*/ @@ -346,6 +361,9 @@ * @note If both the pH and raw conductivity output is 99.99, check the * transducer health code for instruction. * + * @todo Find and define minimum and maximum electrical conductivity measurement + * range + * * {{ @ref ANBpH_EC::ANBpH_EC }} */ /**@{*/ @@ -967,4 +985,4 @@ class ANBpH_StatusCode : public Variable { /**@}*/ #endif // SRC_SENSORS_ANB_SENSORS_PH_H_ -// cSpell:ignore millisiemenPerCentimeter ppth SPCOND +// cSpell:words millisiemenPerCentimeter ppth SPCOND diff --git a/src/sensors/AOSongAM2315.h b/src/sensors/AOSongAM2315.h index 26d1ddcba..a0d603993 100644 --- a/src/sensors/AOSongAM2315.h +++ b/src/sensors/AOSongAM2315.h @@ -118,6 +118,10 @@ * {{ @ref AOSongAM2315_Humidity::AOSongAM2315_Humidity }} */ /**@{*/ +/// @brief Minimum humidity in percent relative humidity. +#define AM2315_HUMIDITY_MIN_RH 0 +/// @brief Maximum humidity in percent relative humidity. +#define AM2315_HUMIDITY_MAX_RH 100 /// @brief Decimal places in string representation; humidity should have 1 (0.1 /// % RH for the 16 bit sensor). #define AM2315_HUMIDITY_RESOLUTION 1 @@ -145,6 +149,10 @@ * {{ @ref AOSongAM2315_Temp::AOSongAM2315_Temp }} */ /**@{*/ +/// @brief Minimum temperature in degrees Celsius. +#define AM2315_TEMP_MIN_C -40.0 +/// @brief Maximum temperature in degrees Celsius. +#define AM2315_TEMP_MAX_C 125.0 /// @brief Decimal places in string representation; temperature should have 1. /// (0.1°C for the 16 bit sensor) #define AM2315_TEMP_RESOLUTION 1 diff --git a/src/sensors/AOSongDHT.h b/src/sensors/AOSongDHT.h index bcd225a23..bfd38a559 100644 --- a/src/sensors/AOSongDHT.h +++ b/src/sensors/AOSongDHT.h @@ -167,6 +167,10 @@ static const uint8_t AM2301{21}; /**< AM2301 */ * {{ @ref AOSongDHT_Humidity::AOSongDHT_Humidity }} */ /**@{*/ +/// @brief Minimum humidity in percent relative humidity. +#define DHT_HUMIDITY_MIN_RH 0 +/// @brief Maximum humidity in percent relative humidity. +#define DHT_HUMIDITY_MAX_RH 100 /// @brief Decimal places in string representation; humidity should have 1 (0.1 /// % RH for DHT22 and 1 % RH for DHT11) #define DHT_HUMIDITY_RESOLUTION 1 @@ -194,6 +198,10 @@ static const uint8_t AM2301{21}; /**< AM2301 */ * {{ @ref AOSongDHT_Temp::AOSongDHT_Temp }} */ /**@{*/ +/// @brief Minimum temperature in degrees Celsius. +#define DHT_TEMP_MIN_C -40.0 +/// @brief Maximum temperature in degrees Celsius. +#define DHT_TEMP_MAX_C 80.0 /// @brief Decimal places in string representation; temperature should have 1 - /// resolution is 0.1°C. #define DHT_TEMP_RESOLUTION 1 @@ -380,4 +388,4 @@ class AOSongDHT_HI : public Variable { /**@}*/ #endif // SRC_SENSORS_AOSONGDHT_H_ -// cSpell:ignore DHTHI +// cSpell:words DHTHI diff --git a/src/sensors/AlphasenseCO2.h b/src/sensors/AlphasenseCO2.h index 3b6ff65e1..29afade6c 100644 --- a/src/sensors/AlphasenseCO2.h +++ b/src/sensors/AlphasenseCO2.h @@ -192,6 +192,10 @@ static_assert(ALPHASENSE_CO2_SENSE_RESISTOR_OHM > 0, * {{ @ref AlphasenseCO2_CO2 }} */ /**@{*/ +/// @brief Minimum CO2 concentration in parts per million. +#define ALPHASENSE_CO2_MIN_PPM 0 +/// @brief Maximum CO2 concentration in parts per million. +#define ALPHASENSE_CO2_MAX_PPM 5000 /// Variable number; CO2 is stored in sensorValues[0]. #define ALPHASENSE_CO2_VAR_NUM 0 /// @brief Variable name in [ODM2 controlled @@ -218,7 +222,8 @@ static_assert(ALPHASENSE_CO2_SENSE_RESISTOR_OHM > 0, * @anchor sensor_alphasense_co2_voltage * @name Voltage * The voltage variable from an Alphasense IRC-A1 CO2 - * - Range is 0 to 3.6V [when ADC is powered at 3.3V] + * - Range depends on the ADC and sense resistor, but should not be more than + * the maximum power supply voltage of 5V. * - Accuracy is ± 0.5% * - 16-bit ADC (ADS1115): < 0.25% (gain error), <0.25 LSB (offset error) * - 12-bit ADC (ADS1015, using build flag ```MS_USE_ADS1015```): < 0.15% @@ -232,6 +237,10 @@ static_assert(ALPHASENSE_CO2_SENSE_RESISTOR_OHM > 0, * {{ @ref AlphasenseCO2_Voltage }} */ /**@{*/ +/// @brief Minimum voltage in volts. +#define ALPHASENSE_CO2_VOLTAGE_MIN_V 0 +/// @brief Maximum voltage in volts. +#define ALPHASENSE_CO2_VOLTAGE_MAX_V 5 /// Variable number; voltage is stored in sensorValues[1]. #define ALPHASENSE_CO2_VOLTAGE_VAR_NUM 1 /// @brief Variable name in [ODM2 controlled diff --git a/src/sensors/AnalogElecConductivity.h b/src/sensors/AnalogElecConductivity.h index b1b3a8bd7..73a7b059f 100644 --- a/src/sensors/AnalogElecConductivity.h +++ b/src/sensors/AnalogElecConductivity.h @@ -264,6 +264,9 @@ static_assert( * @name Electrical Conductance * The electrical conductance variable from a home-made analog sensor. * + * @todo Find and define minimum and maximum electrical conductivity + * measurement range + * * {{ @ref AnalogElecConductivity_EC::AnalogElecConductivity_EC }} */ /**@{*/ @@ -428,5 +431,5 @@ class AnalogElecConductivity_EC : public Variable { /**@}*/ #endif // SRC_SENSORS_ANALOGELECCONDUCTIVITY_H_ -// cSpell:ignore AnalogElecConductivity Rseries_ohms sensorEC_Konst Rwater -// cSpell:ignore _elec_ _Konst anlgEc +// cSpell:words AnalogElecConductivity Rseries_ohms sensorEC_Konst Rwater +// cSpell:words _elec_ _Konst anlgEc diff --git a/src/sensors/ApogeeSQ212.h b/src/sensors/ApogeeSQ212.h index 6cc93e890..5cef06b43 100644 --- a/src/sensors/ApogeeSQ212.h +++ b/src/sensors/ApogeeSQ212.h @@ -179,6 +179,10 @@ class AnalogVoltageReader; /// using an ADS1115. #define SQ212_PAR_RESOLUTION 4 #endif +/// @brief Minimum PAR value in microeinsteins per square meter per second. +#define SQ212_PAR_MIN 0 +/// @brief Maximum PAR value in microeinsteins per square meter per second. +#define SQ212_PAR_MAX 2500 /// Variable number; PAR is stored in sensorValues[0]. #define SQ212_PAR_VAR_NUM 0 /// @brief Variable name in [ODM2 controlled @@ -197,7 +201,7 @@ class AnalogVoltageReader; * @anchor sensor_sq212_voltage * @name Voltage * The voltage variable from an Apogee SQ-212 - * - Range is 0 to 3.6V [when ADC is powered at 3.3V] + * - Range is 0 to 2.5V for SQ-212/SQ-222, 0 to 5V for SQ-215/SQ-225 * - Accuracy is ± 0.5% * - 16-bit ADC (ADS1115): < 0.25% (gain error), <0.25 LSB (offset error) * - 12-bit ADC (ADS1015, using build flag ```MS_USE_ADS1015```): < 0.15% @@ -213,6 +217,10 @@ class AnalogVoltageReader; /**@{*/ /// Variable number; voltage is stored in sensorValues[1]. #define SQ212_VOLTAGE_VAR_NUM 1 +/// @brief Minimum voltage in volts. +#define SQ212_VOLTAGE_MIN_V 0 +/// @brief Maximum voltage in volts. +#define SQ212_VOLTAGE_MAX_V 5.0 /// @brief Variable name in [ODM2 controlled /// vocabulary](http://vocabulary.odm2.org/variablename/); "voltage" #define SQ212_VOLTAGE_VAR_NAME "voltage" diff --git a/src/sensors/AtlasParent.cpp b/src/sensors/AtlasParent.cpp index 54cdd8821..47a4c9502 100644 --- a/src/sensors/AtlasParent.cpp +++ b/src/sensors/AtlasParent.cpp @@ -139,8 +139,9 @@ bool AtlasParent::addSingleMeasurementResult() { bool success = false; - // call the circuit and request up to the maximum buffer size (this may be more than we need) - int bytesReceived = _i2c->requestFrom(static_cast(_i2cAddressHex), + // call the circuit and request up to the maximum buffer size (this may be + // more than we need) + int bytesReceived = _i2c->requestFrom(static_cast(_i2cAddressHex), ATLAS_I2C_RESPONSE_BUFFER_SIZE, 1); if (bytesReceived == 0) { MS_DBG(getSensorNameAndLocation(), F("I2C read failed - no response")); @@ -160,7 +161,8 @@ bool AtlasParent::addSingleMeasurementResult() { MS_DBG(F(" Measurement Failed")); break; - case ATLAS_RESPONSE_PENDING: // the command has not yet been finished calculating. + case ATLAS_RESPONSE_PENDING: // the command has not yet been finished + // calculating. MS_DBG(F(" Measurement Pending")); break; @@ -206,7 +208,7 @@ bool AtlasParent::waitForProcessing(uint32_t timeout) { while (!processed && millis() - start < timeout) { _i2c->requestFrom(static_cast(_i2cAddressHex), 1, 1); auto code = static_cast(_i2c->read()); - if (code == 1) processed = true; + if (code == ATLAS_RESPONSE_SUCCESS) processed = true; } return processed; } diff --git a/src/sensors/AtlasScientificCO2.h b/src/sensors/AtlasScientificCO2.h index b469366ef..4d7709243 100644 --- a/src/sensors/AtlasScientificCO2.h +++ b/src/sensors/AtlasScientificCO2.h @@ -124,6 +124,10 @@ * {{ @ref AtlasScientificCO2_CO2::AtlasScientificCO2_CO2 }} */ /**@{*/ +/// @brief Minimum CO2 concentration in parts per million. +#define ATLAS_CO2_MIN_PPM 0 +/// @brief Maximum CO2 concentration in parts per million. +#define ATLAS_CO2_MAX_PPM 10000 /// @brief Decimal places in string representation; CO2 should have 1 - /// resolution is 1 ppm. #define ATLAS_CO2_RESOLUTION 1 @@ -151,6 +155,10 @@ * {{ @ref AtlasScientificCO2_Temp::AtlasScientificCO2_Temp }} */ /**@{*/ +/// @brief Minimum temperature in degrees Celsius. +#define ATLAS_CO2TEMP_MIN_C -20 +/// @brief Maximum temperature in degrees Celsius. +#define ATLAS_CO2TEMP_MAX_C 50 /// @brief Decimal places in string representation; CO2TEMP should have 0 - /// resolution is 1°C. #define ATLAS_CO2TEMP_RESOLUTION 0 diff --git a/src/sensors/AtlasScientificDO.h b/src/sensors/AtlasScientificDO.h index 75adcc81c..4bbebdfda 100644 --- a/src/sensors/AtlasScientificDO.h +++ b/src/sensors/AtlasScientificDO.h @@ -133,6 +133,10 @@ * {{ @ref AtlasScientificDO_DOmgL::AtlasScientificDO_DOmgL }} */ /**@{*/ +/// @brief Minimum dissolved oxygen concentration in milligrams per liter. +#define ATLAS_DOMGL_MIN_MGPL 0.01 +/// @brief Maximum dissolved oxygen concentration in milligrams per liter. +#define ATLAS_DOMGL_MAX_MGPL 100.0 /// @brief Decimal places in string representation; dissolved oxygen /// concentration should have 2 - resolution is 0.01 mg/L. #define ATLAS_DOMGL_RESOLUTION 2 @@ -161,6 +165,10 @@ * {{ @ref AtlasScientificDO_DOpct::AtlasScientificDO_DOpct }} */ /**@{*/ +/// @brief Minimum dissolved oxygen percent saturation. +#define ATLAS_DOPCT_MIN_PCT 0.1 +/// @brief Maximum dissolved oxygen percent saturation. +#define ATLAS_DOPCT_MAX_PCT 400.0 /// @brief Decimal places in string representation; dissolved oxygen percent /// should have 1 - resolution is 0.1 % saturation. #define ATLAS_DOPCT_RESOLUTION 1 diff --git a/src/sensors/AtlasScientificEC.h b/src/sensors/AtlasScientificEC.h index 68ddb6fba..5ba949fed 100644 --- a/src/sensors/AtlasScientificEC.h +++ b/src/sensors/AtlasScientificEC.h @@ -144,6 +144,10 @@ * {{ @ref AtlasScientificEC_Cond::AtlasScientificEC_Cond }} */ /**@{*/ +/// @brief Minimum electrical conductivity in microsiemens per centimeter. +#define ATLAS_COND_MIN_USCM 0.07 +/// @brief Maximum electrical conductivity in microsiemens per centimeter. +#define ATLAS_COND_MAX_USCM 500000.0 /// @brief Decimal places in string representation; conductivity should have 3. #define ATLAS_COND_RESOLUTION 3 /// @brief Sensor variable number; conductivity is stored in sensorValues[0]. @@ -170,6 +174,10 @@ * {{ @ref AtlasScientificEC_TDS::AtlasScientificEC_TDS }} */ /**@{*/ +/// @brief Minimum total dissolved solids in parts per million. +#define ATLAS_TDS_MIN_PPM 0.01 +/// @brief Maximum total dissolved solids in parts per million. +#define ATLAS_TDS_MAX_PPM 300000.0 /// @brief Decimal places in string representation; TDS should have 3. #define ATLAS_TDS_RESOLUTION 3 /// @brief Sensor variable number; TDS is stored in sensorValues[1]. @@ -191,11 +199,15 @@ * @name Salinity * The salinity variable from an Atlas EC (conductivity) sensor * - Accuracy is ± 2% - * - Range is 0.07 − 500,000+ μS/cm + * - Range is 0 - 42 PSU * * {{ @ref AtlasScientificEC_Salinity::AtlasScientificEC_Salinity }} */ /**@{*/ +/// @brief Minimum salinity in practical salinity units. +#define ATLAS_SALINITY_MIN_PSU 0.0 +/// @brief Maximum salinity in practical salinity units. +#define ATLAS_SALINITY_MAX_PSU 42.0 /// @brief Decimal places in string representation; salinity should have 3. #define ATLAS_SALINITY_RESOLUTION 3 /// @brief Sensor variable number; salinity is stored in sensorValues[2]. @@ -224,6 +236,10 @@ */ /* clang-format on */ /**@{*/ +/// @brief Minimum specific gravity (dimensionless). +#define ATLAS_SG_MIN 0.99 +/// @brief Maximum specific gravity (dimensionless). +#define ATLAS_SG_MAX 1.042 /// @brief Decimal places in string representation; specific gravity should /// have 3. #define ATLAS_SG_RESOLUTION 3 diff --git a/src/sensors/AtlasScientificORP.h b/src/sensors/AtlasScientificORP.h index b1b5adb0c..0d5ae1508 100644 --- a/src/sensors/AtlasScientificORP.h +++ b/src/sensors/AtlasScientificORP.h @@ -111,8 +111,12 @@ * {{ @ref AtlasScientificORP_Potential::AtlasScientificORP_Potential }} */ /**@{*/ -/// @brief Decimal places in string representation; ORP should have 1 - -/// resolution is 0.1 mV. +/// @brief Minimum oxidation reduction potential in millivolts. +#define ATLAS_ORP_MIN_MV -1019.9 +/// @brief Maximum oxidation reduction potential in millivolts. +#define ATLAS_ORP_MAX_MV 1019.9 +/// @brief Decimal places in string representation; ORP should have 1 +/// (resolution is 0.1 mV). #define ATLAS_ORP_RESOLUTION 1 /// @brief Sensor variable number; ORP is stored in sensorValues[0]. #define ATLAS_ORP_VAR_NUM 0 diff --git a/src/sensors/AtlasScientificRTD.h b/src/sensors/AtlasScientificRTD.h index a5e0edee2..bd7e65497 100644 --- a/src/sensors/AtlasScientificRTD.h +++ b/src/sensors/AtlasScientificRTD.h @@ -119,6 +119,10 @@ * {{ @ref AtlasScientificRTD_Temp::AtlasScientificRTD_Temp }} */ /**@{*/ +/// @brief Minimum temperature in degrees Celsius. +#define ATLAS_RTD_MIN_C -126.0 +/// @brief Maximum temperature in degrees Celsius. +#define ATLAS_RTD_MAX_C 125.0 /// @brief Decimal places in string representation; temperature should have 3 - /// resolution is 0.001°C. #define ATLAS_RTD_RESOLUTION 3 diff --git a/src/sensors/AtlasScientificpH.h b/src/sensors/AtlasScientificpH.h index 75068e41d..408d64752 100644 --- a/src/sensors/AtlasScientificpH.h +++ b/src/sensors/AtlasScientificpH.h @@ -115,6 +115,10 @@ * {{ @ref AtlasScientificpH_pH::AtlasScientificpH_pH }} */ /**@{*/ +/// @brief Minimum pH value. +#define ATLAS_PH_MIN 0.001 +/// @brief Maximum pH value. +#define ATLAS_PH_MAX 14.000 /// @brief Decimal places in string representation; pH should have 3 - /// resolution is 0.001. #define ATLAS_PH_RESOLUTION 3 @@ -245,4 +249,4 @@ class AtlasScientificpH_pH : public Variable { /**@}*/ #endif // SRC_SENSORS_ATLASSCIENTIFICPH_H_ -// cSpell:ignore AtlasScientificpH AtlaspH +// cSpell:words AtlasScientificpH AtlaspH diff --git a/src/sensors/BoschBME280.h b/src/sensors/BoschBME280.h index 74203f8cd..0e3897189 100644 --- a/src/sensors/BoschBME280.h +++ b/src/sensors/BoschBME280.h @@ -161,6 +161,10 @@ * {{ @ref BoschBME280_Temp::BoschBME280_Temp }} */ /**@{*/ +/// @brief Minimum temperature in degrees Celsius. +#define BME280_TEMP_MIN_C -40.0 +/// @brief Maximum temperature in degrees Celsius. +#define BME280_TEMP_MAX_C 85.0 /// @brief Decimal places in string representation; temperature should have 2 - /// resolution is 0.01°C. #define BME280_TEMP_RESOLUTION 2 @@ -186,6 +190,10 @@ * {{ @ref BoschBME280_Humidity::BoschBME280_Humidity }} */ /**@{*/ +/// @brief Minimum relative humidity in percent. +#define BME280_HUMIDITY_MIN_RH 0.0 +/// @brief Maximum relative humidity in percent. +#define BME280_HUMIDITY_MAX_RH 100.0 /// @brief Decimal places in string representation; humidity should have 3- /// resolution is 0.008 % RH (16 bit). #define BME280_HUMIDITY_RESOLUTION 3 @@ -207,13 +215,17 @@ * @anchor sensor_bme280_pressure * @name Barometric Pressure * The barometric pressure variable from a Bosch BME280 - * - Range is 300 to 1100 hPa + * - Range is 300 to 1100 hPa (30000 to 110000 Pa) * - Absolute accuracy is ±1 hPa * - Relative accuracy is ±0.12 hPa * * {{ @ref BoschBME280_Pressure::BoschBME280_Pressure }} */ /**@{*/ +/// @brief Minimum barometric pressure in pascal. +#define BME280_PRESSURE_MIN_PA 30000.0 +/// @brief Maximum barometric pressure in pascal. +#define BME280_PRESSURE_MAX_PA 110000.0 /// @brief Decimal places in string representation; barometric pressure should /// have 2. #define BME280_PRESSURE_RESOLUTION 2 @@ -480,3 +492,5 @@ class BoschBME280_Altitude : public Variable { }; /**@}*/ #endif // SRC_SENSORS_BOSCHBME280_H_ + +// cSpell:words hectopascals diff --git a/src/sensors/BoschBMP3xx.h b/src/sensors/BoschBMP3xx.h index 5988ea9ed..1559e23a8 100644 --- a/src/sensors/BoschBMP3xx.h +++ b/src/sensors/BoschBMP3xx.h @@ -238,6 +238,10 @@ * {{ @ref BoschBMP3xx_Temp::BoschBMP3xx_Temp }} */ /**@{*/ +/// @brief Minimum temperature in degrees Celsius. +#define BMP3XX_TEMP_MIN_C -40.0 +/// @brief Maximum temperature in degrees Celsius. +#define BMP3XX_TEMP_MAX_C 85.0 /// @brief Decimal places in string representation; temperature should have 5 - /// resolution is 0.00015°C at the highest oversampling. See table 7 in the /// [sensor @@ -262,13 +266,17 @@ * @anchor sensor_bmp3xx_pressure * @name Barometric Pressure * The barometric pressure variable from a Bosch BMP388 or BMP390 - * - Range for both the BMP388 and BMP390 is 300‒1250 hPa + * - Range for both the BMP388 and BMP390 is 300‒1250 hPa (30000‒125000 Pa) * - Absolute accuracy is typ. ± 50 Pa (±0.50 hPa) * - Relative accuracy is typ. ± 3 Pa (±0.03 hPa), equiv. to ± 0.25 m * * {{ @ref BoschBMP3xx_Pressure::BoschBMP3xx_Pressure }} */ /**@{*/ +/// @brief Minimum barometric pressure in pascals. +#define BMP3XX_PRESSURE_MIN_PA 30000.0 +/// @brief Maximum barometric pressure in pascals. +#define BMP3XX_PRESSURE_MAX_PA 125000.0 /// @brief Decimal places in string representation; barometric pressure should /// have 3. Resolution of output data in highest resolution mode at lowest /// bandwidth is 0.016 Pa. See table 6 in the [sensor @@ -685,4 +693,4 @@ class BoschBMP3xx_Altitude : public Variable { /**@}*/ #endif // SRC_SENSORS_BOSCHBMP3XX_H_ -// cSpell:words oversample osrs_p DDIO bmp3xxtimingTest +// cSpell:words oversample osrs_p DDIO bmp3xxtimingTest hectopascals diff --git a/src/sensors/CampbellClariVUE10.h b/src/sensors/CampbellClariVUE10.h index 4d87218ca..89b216c45 100644 --- a/src/sensors/CampbellClariVUE10.h +++ b/src/sensors/CampbellClariVUE10.h @@ -119,6 +119,10 @@ * {{ @ref CampbellClariVUE10_Turbidity::CampbellClariVUE10_Turbidity }} */ /**@{*/ +/// @brief Minimum turbidity in formazin nephelometric units. +#define CLARIVUE10_TURBIDITY_MIN_FNU 0.0 +/// @brief Maximum turbidity in formazin nephelometric units. +#define CLARIVUE10_TURBIDITY_MAX_FNU 4000.0 /// @brief Decimal places in string representation; turbidity should have 1 /// (resolution is 0.2 FNU). #define CLARIVUE10_TURBIDITY_RESOLUTION 1 @@ -146,6 +150,10 @@ * {{ @ref CampbellClariVUE10_Temp::CampbellClariVUE10_Temp }} */ /**@{*/ +/// @brief Minimum temperature in degrees Celsius. +#define CLARIVUE10_TEMP_MIN_C -2.0 +/// @brief Maximum temperature in degrees Celsius. +#define CLARIVUE10_TEMP_MAX_C 40.0 /// @brief Decimal places in string representation; temperature should have 2 - /// resolution is 0.01°C. #define CLARIVUE10_TEMP_RESOLUTION 2 @@ -169,6 +177,8 @@ * The error code variable from a Campbell ClariVUE10 * - Significance of error code values is unknown. * + * @todo Find and define minimum and maximum error code range + * * {{ @ref CampbellClariVUE10_ErrorCode::CampbellClariVUE10_ErrorCode }} */ /**@{*/ diff --git a/src/sensors/CampbellOBS3.h b/src/sensors/CampbellOBS3.h index 977df5480..f18ac0688 100644 --- a/src/sensors/CampbellOBS3.h +++ b/src/sensors/CampbellOBS3.h @@ -155,7 +155,11 @@ class AnalogVoltageReader; * {{ @ref CampbellOBS3_Turbidity::CampbellOBS3_Turbidity }} */ /**@{*/ -/// Variable number; turbidity is stored in sensorValues[0]. +/// @brief Minimum turbidity in nephelometric turbidity units. +#define OBS3_TURB_MIN_NTU 0.0 +/// @brief Maximum turbidity in nephelometric turbidity units. +#define OBS3_TURB_MAX_NTU 4000.0 +/// @brief Variable number; turbidity is stored in sensorValues[0]. #define OBS3_TURB_VAR_NUM 0 #ifdef MS_USE_ADS1015 /// @brief Decimal places in string representation; turbidity should have 1. @@ -191,7 +195,11 @@ class AnalogVoltageReader; * {{ @ref CampbellOBS3_Voltage::CampbellOBS3_Voltage }} */ /**@{*/ -/// Variable number; voltage is stored in sensorValues[1]. +/// @brief Minimum voltage in volts. +#define OBS3_VOLTAGE_MIN_V 0.0 +/// @brief Maximum voltage in volts. +#define OBS3_VOLTAGE_MAX_V 2.5 +/// @brief Variable number; voltage is stored in sensorValues[1]. #define OBS3_VOLTAGE_VAR_NUM 1 /// @brief Variable name in /// [ODM2 controlled vocabulary](http://vocabulary.odm2.org/variablename/); diff --git a/src/sensors/CampbellRainVUE10.h b/src/sensors/CampbellRainVUE10.h index 60441bd3a..de190dfb7 100644 --- a/src/sensors/CampbellRainVUE10.h +++ b/src/sensors/CampbellRainVUE10.h @@ -122,6 +122,12 @@ * {{ @ref CampbellRainVUE10_Precipitation::CampbellRainVUE10_Precipitation }} */ /**@{*/ +/// @brief Minimum precipitation depth in inches. +#define RAINVUE10_PRECIPITATION_MIN_IN 0.0 +/// @brief Maximum precipitation depth in inches. +/// @note There isn't a maximum accumulated depth; this is a very high number to +/// allow for almost a year of rain in PA. +#define RAINVUE10_PRECIPITATION_MAX_IN 50.0 /// @brief Decimal places in string representation; depth should have 2 /// (resolution is 0.01 inches). #define RAINVUE10_PRECIPITATION_RESOLUTION 2 @@ -145,6 +151,9 @@ * Defines for tip count variable from a tipping bucket counter * - Range and accuracy depend on the tipping bucket used. * + * @todo Find and define minimum and maximum tip count range for the Campbell + * RainVUE10. + * * {{ @ref CampbellRainVUE10_Tips::CampbellRainVUE10_Tips }} */ /**@{*/ @@ -183,6 +192,12 @@ * {{ @ref CampbellRainVUE10_RainRateAve::CampbellRainVUE10_RainRateAve }} */ /**@{*/ +/// @brief Minimum rainfall rate in inches per hour. +/// @note The minimum rate when it's raining is 0.01 in/h, but is 0 when not +/// raining. +#define RAINVUE10_RAINRATEAVE_MIN_INPH 0 +/// @brief Maximum rainfall rate in inches per hour. +#define RAINVUE10_RAINRATEAVE_MAX_INPH 39.4 /// @brief Decimal places in string representation; the rainfall intensity /// has 2. #define RAINVUE10_RAINRATEAVE_RESOLUTION 2 @@ -206,10 +221,16 @@ * @name Rainfall Rate Maximum * The maximum rainfall rate variable from a Campbell RainVUE10, * defined as maximum precipitation intensity since last measurement. - * - Range & Accuracy same as for sensor_rainvue_rainratemax + * - Range is 0.01 to 1000 mm/h (0.0004 to 39.4 in./h) + * - Range & Accuracy same as for sensor_rainvue_rainrateave + * * {{ @ref CampbellRainVUE10_RainRateMax::CampbellRainVUE10_RainRateMax }} */ /**@{*/ +/// @brief Minimum rainfall rate; 0.0004 in./h (0.01 mm/h) +#define RAINVUE10_RAINRATEMAX_MIN_INPH 0.0004 +/// @brief Maximum rainfall rate; 39.4 in./h (1000 mm/h) +#define RAINVUE10_RAINRATEMAX_MAX_INPH 39.4 /// @brief Decimal places in string representation; the rainfall intensity /// has 2. #define RAINVUE10_RAINRATEMAX_RESOLUTION 2 @@ -445,4 +466,4 @@ class CampbellRainVUE10_RainRateMax : public Variable { /**@}*/ #endif // SRC_SENSORS_CAMPBELLRAINVUE10_H_ -// cSpell:ignore RAINRATEAVE RAINRATEMAX +// cSpell:words RAINRATEAVE RAINRATEMAX INPH diff --git a/src/sensors/Decagon5TM.h b/src/sensors/Decagon5TM.h index 2f6520ec6..40d9425fe 100644 --- a/src/sensors/Decagon5TM.h +++ b/src/sensors/Decagon5TM.h @@ -124,14 +124,17 @@ /** * @anchor sensor_fivetm_ea * @name EA - * The EA variable from a Meter ECH2O - * - Range is 0 – 1 m3/m3 (0 – 100% VWC) - * - Accuracy for generic calibration equation: ± 0.03 m3/m3 (± 3% VWC) typical - * - Accuracy for medium-specific calibration: ± 0.02 m3/m3 (± 2% VWC) + * The Apparent Dielectric Permittivity (EA) variable from a Meter ECH2O + * Accuracy is ± 1 Ka from 1 – 40 (soil range); + * ± 15% from 40 – 80 Soil. * * {{ @ref Decagon5TM_Ea::Decagon5TM_Ea }} */ /**@{*/ +/// @brief Minimum electrical permittivity in farads per meter. +#define TM_EA_MIN_FPM 1.0 +/// @brief Maximum electrical permittivity in farads per meter. +#define TM_EA_MAX_FPM 80.0 /** * @brief Decimal places in string representation; EA should have 5 * @@ -164,6 +167,10 @@ * {{ @ref Decagon5TM_Temp::Decagon5TM_Temp }} */ /**@{*/ +/// @brief Minimum temperature in degrees Celsius. +#define TM_TEMP_MIN_C -40.0 +/// @brief Maximum temperature in degrees Celsius. +#define TM_TEMP_MAX_C 50.0 /** * @brief Decimal places in string representation; temperature should have 2 * @@ -196,6 +203,10 @@ * {{ @ref Decagon5TM_VWC::Decagon5TM_VWC }} */ /**@{*/ +/// @brief Minimum volumetric water content in percent. +#define TM_VWC_MIN_PCT 0.0 +/// @brief Maximum volumetric water content in percent. +#define TM_VWC_MAX_PCT 100.0 /** * @brief Decimal places in string representation; VWC should have 3 * @@ -390,4 +401,4 @@ class Decagon5TM_VWC : public Variable { /**@}*/ #endif // SRC_SENSORS_DECAGON5TM_H_ -// cSpell:ignore fivetm matric +// cSpell:words fivetm matric diff --git a/src/sensors/DecagonCTD.h b/src/sensors/DecagonCTD.h index 931184fe6..16690af64 100644 --- a/src/sensors/DecagonCTD.h +++ b/src/sensors/DecagonCTD.h @@ -109,6 +109,10 @@ * {{ @ref DecagonCTD_Cond::DecagonCTD_Cond }} */ /**@{*/ +/// @brief Minimum specific conductance in microsiemens per centimeter. +#define CTD_COND_MIN_USCM 0.0 +/// @brief Maximum specific conductance in microsiemens per centimeter. +#define CTD_COND_MAX_USCM 120000.0 /** * @brief Decimal places in string representation; conductivity should have 1. * @@ -140,6 +144,10 @@ * {{ @ref DecagonCTD_Temp::DecagonCTD_Temp }} */ /**@{*/ +/// @brief Minimum temperature in degrees Celsius. +#define CTD_TEMP_MIN_C -11.0 +/// @brief Maximum temperature in degrees Celsius. +#define CTD_TEMP_MAX_C 49.0 /** * @brief Decimal places in string representation; temperature should have 2. * @@ -171,6 +179,10 @@ * {{ @ref DecagonCTD_Depth::DecagonCTD_Depth }} */ /**@{*/ +/// @brief Minimum water depth in millimeters. +#define CTD_DEPTH_MIN_MM 0.0 +/// @brief Maximum water depth in millimeters. +#define CTD_DEPTH_MAX_MM 10000.0 /** * @brief Decimal places in string representation; depth should have 1. * diff --git a/src/sensors/DecagonES2.h b/src/sensors/DecagonES2.h index 3ae8b67ab..3f0ccc50b 100644 --- a/src/sensors/DecagonES2.h +++ b/src/sensors/DecagonES2.h @@ -104,6 +104,10 @@ * {{ @ref DecagonES2_Cond::DecagonES2_Cond }} */ /**@{*/ +/// @brief Minimum specific conductance in microsiemens per centimeter. +#define ES2_COND_MIN_USCM 0.0 +/// @brief Maximum specific conductance in microsiemens per centimeter. +#define ES2_COND_MAX_USCM 120000.0 /** * @brief Decimal places in string representation; conductivity should have 1. * @@ -135,6 +139,10 @@ * {{ @ref DecagonES2_Temp::DecagonES2_Temp }} */ /**@{*/ +/// @brief Minimum temperature in degrees Celsius. +#define ES2_TEMP_MIN_C -40.0 +/// @brief Maximum temperature in degrees Celsius. +#define ES2_TEMP_MAX_C 50.0 /** * @brief Decimal places in string representation; temperature should have 2. * diff --git a/src/sensors/EverlightALSPT19.h b/src/sensors/EverlightALSPT19.h index 449e64ac8..ddb9bd9b3 100644 --- a/src/sensors/EverlightALSPT19.h +++ b/src/sensors/EverlightALSPT19.h @@ -145,6 +145,10 @@ static_assert(ALSPT19_UA_PER_1000LUX > 0, * {{ @ref EverlightALSPT19_Voltage::EverlightALSPT19_Voltage }} */ /**@{*/ +/// @brief Minimum voltage in volts. +#define ALSPT19_VOLTAGE_MIN_V 0.0 +/// @brief Maximum voltage in volts. +#define ALSPT19_VOLTAGE_MAX_V 4.6 /** * @brief Decimal places in string representation; voltage should have 0 * @@ -176,6 +180,10 @@ static_assert(ALSPT19_UA_PER_1000LUX > 0, * {{ @ref EverlightALSPT19_Current::EverlightALSPT19_Current }} */ /**@{*/ +/// @brief Minimum electric current in microamperes. +#define ALSPT19_CURRENT_MIN_UA 5.0 +/// @brief Maximum electric current in microamperes. +#define ALSPT19_CURRENT_MAX_UA 520.0 /** * @brief Decimal places in string representation; voltage should have 0 * @@ -207,6 +215,10 @@ static_assert(ALSPT19_UA_PER_1000LUX > 0, * {{ @ref EverlightALSPT19_Illuminance::EverlightALSPT19_Illuminance }} */ /**@{*/ +/// @brief Minimum illuminance in lux. +#define ALSPT19_ILLUMINANCE_MIN_LUX 0.0 +/// @brief Maximum illuminance in lux. +#define ALSPT19_ILLUMINANCE_MAX_LUX 10000.0 /** * @brief Decimal places in string representation; illuminance should have 0 * @@ -432,3 +444,5 @@ class EverlightALSPT19_Illuminance : public Variable { }; /**@}*/ #endif // SRC_SENSORS_EVERLIGHTALSPT19_H_ + +// cSpell:words microamperes diff --git a/src/sensors/FreescaleMPL115A2.cpp b/src/sensors/FreescaleMPL115A2.cpp index 6f1a127e2..d231dbb39 100644 --- a/src/sensors/FreescaleMPL115A2.cpp +++ b/src/sensors/FreescaleMPL115A2.cpp @@ -71,8 +71,9 @@ bool FreescaleMPL115A2::addSingleMeasurementResult() { MS_DBG(F(" Temperature:"), temp); MS_DBG(F(" Pressure:"), press); - if (!isnan(temp) && !isnan(press) && press >= 50.0 && press <= 115.0 && - temp >= -20.0 && temp <= 85.0) { + if (!isnan(temp) && !isnan(press) && press >= MPL115A2_PRESSURE_MIN_KPA && + press <= MPL115A2_PRESSURE_MAX_KPA && temp >= MPL115A2_TEMP_MIN_C && + temp <= MPL115A2_TEMP_MAX_C) { verifyAndAddMeasurementResult(MPL115A2_TEMP_VAR_NUM, temp); verifyAndAddMeasurementResult(MPL115A2_PRESSURE_VAR_NUM, press); success = true; diff --git a/src/sensors/FreescaleMPL115A2.h b/src/sensors/FreescaleMPL115A2.h index 692ade432..43a7eb09f 100644 --- a/src/sensors/FreescaleMPL115A2.h +++ b/src/sensors/FreescaleMPL115A2.h @@ -125,6 +125,10 @@ * {{ @ref FreescaleMPL115A2_Temp::FreescaleMPL115A2_Temp }} */ /**@{*/ +/// @brief Minimum valid temperature in degrees Celsius. +#define MPL115A2_TEMP_MIN_C -20.0 +/// @brief Maximum valid temperature in degrees Celsius. +#define MPL115A2_TEMP_MAX_C 85.0 /// @brief Decimal places in string representation; temperature should have 2 - /// resolution is 0.01°C. #define MPL115A2_TEMP_RESOLUTION 2 @@ -152,6 +156,10 @@ * {{ @ref FreescaleMPL115A2_Pressure::FreescaleMPL115A2_Pressure }} */ /**@{*/ +/// @brief Minimum valid pressure in kilopascals. +#define MPL115A2_PRESSURE_MIN_KPA 50.0 +/// @brief Maximum valid pressure in kilopascals. +#define MPL115A2_PRESSURE_MAX_KPA 115.0 /// @brief Decimal places in string representation; pressure should have 2 - /// resolution is 1.5 hPa. #define MPL115A2_PRESSURE_RESOLUTION 2 diff --git a/src/sensors/GeoluxHydroCam.h b/src/sensors/GeoluxHydroCam.h index 98cedd4d7..00b53be2c 100644 --- a/src/sensors/GeoluxHydroCam.h +++ b/src/sensors/GeoluxHydroCam.h @@ -154,7 +154,7 @@ /// @brief Sensor::_measurementTime_ms; the HydroCam imaging time is variable /// depending on the image size, but the typical minimum I've seen for the /// smallest image (160x120) is ~3.8s on firmware >2.0.1. -/// The largest image takes over 16s on firmwares <2.0.1. +/// The largest image (2592x1944) takes over 16s on firmwares <2.0.1. #define HYDROCAM_MEASUREMENT_TIME_MS 3800L /// @brief The maximum time to wait for an image. #define HYDROCAM_MEASUREMENT_TIME_MAX 18000L @@ -169,9 +169,19 @@ * SD card, not necessarily (but hopefully) the size of the image * as reported by the camera * + * @todo Figure out the largest image size the camera can produce and set the + * max accordingly. The manual doesn't specify, but there is a setting to limit + * the file size which has a maximum of 3000KB (3MB), so it seems like the + * camera should be able to produce images at least that large. For now, we'll + * set the max to a conservative 10MB (10485760 bytes). + * * {{ @ref GeoluxHydroCam_ImageSize::GeoluxHydroCam_ImageSize }} */ /**@{*/ +/// @brief Minimum image size in bytes. +#define HYDROCAM_SIZE_MIN_BYTES 0 +/// @brief Maximum image size in bytes. +#define HYDROCAM_SIZE_MAX_BYTES 10485760 /// @brief Decimal places in string representation; image size should have 0 - /// resolution is 1 byte. #define HYDROCAM_SIZE_RESOLUTION 0 @@ -198,6 +208,11 @@ * {{ @ref GeoluxHydroCam_ByteError::GeoluxHydroCam_ByteError }} */ /**@{*/ +/// @brief Minimum flash memory error count. +#define HYDROCAM_ERROR_MIN_COUNT 0 +/// @brief Maximum flash memory error count - can be off by as much as the max +/// image size. +#define HYDROCAM_ERROR_MAX_COUNT HYDROCAM_SIZE_MAX_BYTES /// @brief Decimal places in string representation; byte error should have /// 0 - resolution is 1 byte. #define HYDROCAM_ERROR_RESOLUTION 0 @@ -491,4 +506,4 @@ class GeoluxHydroCam_ByteError : public Variable { /**@}*/ #endif // SRC_SENSORS_GEOLUXHYDROCAM_H_ -// cSpell:ignore dataloggers QQVGA QVGA QXGA UXGA autofocusing +// cSpell:words dataloggers QQVGA QVGA QXGA UXGA autofocusing diff --git a/src/sensors/GroPointParent.h b/src/sensors/GroPointParent.h index c982297a6..48ef9f5e0 100644 --- a/src/sensors/GroPointParent.h +++ b/src/sensors/GroPointParent.h @@ -207,4 +207,4 @@ class GroPointParent : public Sensor { #endif // SRC_SENSORS_GROPOINTPARENT_H_ -// cSpell:ignore GPLPX gsensor +// cSpell:words GPLPX gsensor diff --git a/src/sensors/InSituRDO.h b/src/sensors/InSituRDO.h index 375c906d2..e588b5cd9 100644 --- a/src/sensors/InSituRDO.h +++ b/src/sensors/InSituRDO.h @@ -212,11 +212,11 @@ * @anchor sensor_insitu_rdo_domgl * @name Dissolved Oxygen Concentration * The DO concentration variable from an In-Situ RDO PRO-X - * - Range is 0 to 50 mg/L concentration + * - Range is 0 to 60 mg/L concentration * - Accuracy: * - ± 0.1 mg/L from 0 to 8 mg/L * - ± 0.2 mg/L of reading from 8-20 mg/L - * - ± 10% of reading from 20-50 mg/L + * - ± 10% of reading from 20-60 mg/L * * @note To achieve maximum accuracy, the sensor must be calibrated using either * a one or two point calibration. @@ -224,6 +224,10 @@ * {{ @ref InSituRDO_DOmgL::InSituRDO_DOmgL }} */ /**@{*/ +/// @brief Minimum dissolved oxygen concentration in milligrams per liter. +#define INSITU_RDO_DOMGL_MIN_MGPL 0.0 +/// @brief Maximum dissolved oxygen concentration in milligrams per liter. +#define INSITU_RDO_DOMGL_MAX_MGPL 60.0 /** * @brief Decimal places in string representation; dissolved oxygen * concentration should have 2 - resolution is 0.01 mg/L. @@ -260,9 +264,16 @@ * @note To achieve maximum accuracy, the sensor must be calibrated using either * a one or two point calibration. * + * @todo Find the maximum value for percent saturation. The spec sheet only + * lists the maximum DO concentration. I've set it here to 500%. + * * {{ @ref InSituRDO_DOpct::InSituRDO_DOpct }} */ /**@{*/ +/// @brief Minimum dissolved oxygen percent saturation. +#define INSITU_RDO_DOPCT_MIN_PCT 0.0 +/// @brief Maximum dissolved oxygen percent saturation. +#define INSITU_RDO_DOPCT_MAX_PCT 500.0 /** * @brief Decimal places in string representation; dissolved oxygen percent * saturation should have 1. @@ -297,6 +308,10 @@ * {{ @ref InSituRDO_Temp::InSituRDO_Temp }} */ /**@{*/ +/// @brief Minimum temperature in degrees Celsius. +#define INSITU_RDO_TEMP_MIN_C 0.0 +/// @brief Maximum temperature in degrees Celsius. +#define INSITU_RDO_TEMP_MAX_C 50.0 /** * @brief Decimal places in string representation; temperature should have 2 - * resolution is 0.01°C. @@ -328,6 +343,9 @@ * @note The oxygen partial pressure output must be manually enabled in SDI-12 * mode using the Win-Situ software. * + * @todo Find and define minimum and maximum oxygen partial pressure measurement + * range + * * {{ @ref InSituRDO_Pressure::InSituRDO_Pressure }} */ /**@{*/ diff --git a/src/sensors/InSituTrollSdi12a.h b/src/sensors/InSituTrollSdi12a.h index 3db93b717..1cc9c3d49 100644 --- a/src/sensors/InSituTrollSdi12a.h +++ b/src/sensors/InSituTrollSdi12a.h @@ -117,12 +117,16 @@ * @anchor sensor_insitu_troll_pressure * @name Pressure * The pressure variable from a In-Situ TROLL - * - Range is 0 – x (depends on range eg 5psig) + * - Range depends on the model; the highest range models go up to 500 psig. * * {{ @ref InSituTrollSdi12a_Pressure::InSituTrollSdi12a_Pressure }} */ /**@{*/ +/// @brief Minimum pressure; 0 psi +#define ITROLLA_PRESSURE_MIN_PSI 0 +/// @brief Maximum pressure; 500 psi (depends on model range) +#define ITROLLA_PRESSURE_MAX_PSI 500 /// @brief Decimal places in string representation; pressure should have 5. #define ITROLLA_PRESSURE_RESOLUTION 5 /// @brief Sensor variable number; pressure is stored in sensorValues[0]. @@ -149,6 +153,10 @@ * {{ @ref InSituTrollSdi12a_Temp::InSituTrollSdi12a_Temp }} */ /**@{*/ +/// @brief Minimum temperature; -11°C +#define ITROLLA_TEMP_MIN_C -11 +/// @brief Maximum temperature; 49°C +#define ITROLLA_TEMP_MAX_C 49 /** * @brief Decimal places in string representation; temperature should have 2. * @@ -174,12 +182,16 @@ * @anchor sensor_insitu_troll_depth * @name Water Depth * The water depth variable from a In-Situ TROLL - * - Range is 0 to 3.5m to 350m depending on model + * - Range is 0 to 3.5m to 350m (up to 1150ft) depending on model * - Accuracy is ±0.05% of full scale * * {{ @ref InSituTrollSdi12a_Depth::InSituTrollSdi12a_Depth }} */ /**@{*/ +/// @brief Minimum depth; 0 feet +#define ITROLLA_DEPTH_MIN_FT 0 +/// @brief Maximum depth; 1150 feet (depending on model) +#define ITROLLA_DEPTH_MAX_FT 1150 /** * @brief Decimal places in string representation; depth should have 1. * @@ -377,4 +389,4 @@ typedef InSituTrollSdi12a_Depth InsituTrollSdi12a_Depth; #endif // SRC_SENSORS_INSITUTROLLSDI12_H_ -// cSpell:ignore ITROLL ITROLLA +// cSpell:words ITROLL ITROLLA diff --git a/src/sensors/KellerAcculevel.h b/src/sensors/KellerAcculevel.h index eaccaecf8..7d94730ae 100644 --- a/src/sensors/KellerAcculevel.h +++ b/src/sensors/KellerAcculevel.h @@ -83,6 +83,10 @@ * {{ @ref KellerAcculevel_Pressure::KellerAcculevel_Pressure }} */ /**@{*/ +/// @brief Minimum pressure; 0 bar +#define ACCULEVEL_PRESSURE_MIN_BAR 0 +/// @brief Maximum pressure; 11 bar +#define ACCULEVEL_PRESSURE_MAX_BAR 11 /// @brief Decimal places in string representation; pressure should have 5 - /// resolution is 0.002%. #define ACCULEVEL_PRESSURE_RESOLUTION 5 @@ -100,6 +104,10 @@ * {{ @ref KellerAcculevel_Temp::KellerAcculevel_Temp }} */ /**@{*/ +/// @brief Minimum temperature; -10°C +#define ACCULEVEL_TEMP_MIN_C -10 +/// @brief Maximum temperature; 60°C +#define ACCULEVEL_TEMP_MAX_C 60 /// @brief Decimal places in string representation; temperature should have 2 - /// resolution is 0.01°C. #define ACCULEVEL_TEMP_RESOLUTION 2 @@ -111,12 +119,16 @@ * @anchor sensor_acculevel_height * @name Height * The height variable from a Keller Acculevel - * - Range is 0 to 900 feet + * - Range is 0 to 900 feet (0 to 275 m) * - Accuracy is Standard ±0.1% FS, Optional ±0.05% FS * * {{ @ref KellerAcculevel_Height::KellerAcculevel_Height }} */ /**@{*/ +/// @brief Minimum height; 0 feet (0 m) +#define ACCULEVEL_HEIGHT_MIN_M 0 +/// @brief Maximum height; 900 feet (275 m) +#define ACCULEVEL_HEIGHT_MAX_M 275 /// @brief Decimal places in string representation; height should have 4 - /// resolution is 0.002%. #define ACCULEVEL_HEIGHT_RESOLUTION 4 @@ -289,4 +301,4 @@ class KellerAcculevel_Height : public Variable { /**@}*/ #endif // SRC_SENSORS_KELLERACCULEVEL_H_ -// cSpell:ignore kellerAccuPress kellerAccuTemp kellerAccuHeight +// cSpell:words kellerAccuPress kellerAccuTemp kellerAccuHeight diff --git a/src/sensors/KellerNanolevel.h b/src/sensors/KellerNanolevel.h index a6f85f213..96e6bd8ba 100644 --- a/src/sensors/KellerNanolevel.h +++ b/src/sensors/KellerNanolevel.h @@ -75,6 +75,10 @@ * {{ @ref KellerNanolevel_Pressure::KellerNanolevel_Pressure }} */ /**@{*/ +/// @brief Minimum pressure; 0 mbar +#define NANOLEVEL_PRESSURE_MIN_MBAR 0 +/// @brief Maximum pressure; 300 mbar +#define NANOLEVEL_PRESSURE_MAX_MBAR 300 /// @brief Decimal places in string representation; pressure should have 5 - /// resolution is 0.002%. #define NANOLEVEL_PRESSURE_RESOLUTION 5 @@ -92,6 +96,10 @@ * {{ @ref KellerNanolevel_Temp::KellerNanolevel_Temp }} */ /**@{*/ +/// @brief Minimum temperature; 10°C +#define NANOLEVEL_TEMP_MIN_C 10 +/// @brief Maximum temperature; 50°C +#define NANOLEVEL_TEMP_MAX_C 50 /// @brief Decimal places in string representation; temperature should have 2 - /// resolution is 0.01°C. #define NANOLEVEL_TEMP_RESOLUTION 2 @@ -103,12 +111,16 @@ * @anchor sensor_nanolevel_height * @name Height * The height variable from a Keller Nanolevel - * - Range is 0 to 120 inches + * - Range is 0 to 120 inches (0 to 3.048 m) * - Accuracy is Standard ±0.1% FS, Optional ±0.05% FS * * {{ @ref KellerNanolevel_Height::KellerNanolevel_Height }} */ /**@{*/ +/// @brief Minimum height; 0 inches (0 m) +#define NANOLEVEL_HEIGHT_MIN_M 0 +/// @brief Maximum height; 120 inches (3.048 m) +#define NANOLEVEL_HEIGHT_MAX_M 3.048 /// @brief Decimal places in string representation; height should have 4 - /// resolution is 0.002%. #define NANOLEVEL_HEIGHT_RESOLUTION 4 diff --git a/src/sensors/KellerParent.h b/src/sensors/KellerParent.h index 376e38e94..d3970ca29 100644 --- a/src/sensors/KellerParent.h +++ b/src/sensors/KellerParent.h @@ -285,4 +285,4 @@ class KellerParent : public Sensor { /**@}*/ #endif // SRC_SENSORS_KELLERPARENT_H_ -// cSpell:ignore ksensor +// cSpell:words ksensor diff --git a/src/sensors/MaxBotixSonar.h b/src/sensors/MaxBotixSonar.h index 1fe8a950a..b5608b53f 100644 --- a/src/sensors/MaxBotixSonar.h +++ b/src/sensors/MaxBotixSonar.h @@ -190,12 +190,16 @@ static_assert(MAXBOTIX_DEFAULT_MEASUREMENT_RETRIES >= 0 && * @anchor sensor_maxbotix_range * @name Range * The range variable from a Maxbotix HRXL ultrasonic range finder - * - Range depends on the exact model + * - Range depends on the exact model, up to 10m for the longest range model. * - Accuracy is ±1% * * {{ @ref MaxBotixSonar_Range::MaxBotixSonar_Range }} */ /**@{*/ +/// @brief Minimum range in millimeters. +#define HRXL_MIN_MM 0 +/// @brief Maximum range in millimeters. +#define HRXL_MAX_MM 10000 /// @brief Decimal places in string representation; range should have 0 - /// resolution is 1mm (except for models which have range 10mm). #define HRXL_RESOLUTION 0 @@ -357,4 +361,4 @@ class MaxBotixSonar_Range : public Variable { /**@}*/ #endif // SRC_SENSORS_MAXBOTIXSONAR_H_ -// cSpell:ignore max_botix +// cSpell:words max_botix diff --git a/src/sensors/MaximDS18.cpp b/src/sensors/MaximDS18.cpp index 062b99211..ca710e2a1 100644 --- a/src/sensors/MaximDS18.cpp +++ b/src/sensors/MaximDS18.cpp @@ -194,7 +194,8 @@ bool MaximDS18::addSingleMeasurementResult() { // If a DS18 cannot get a good measurement, it returns 85 // If the sensor is not properly connected, it returns -127 - if (result != DS18_BAD_MEASUREMENT_VALUE && result != DS18_DISCONNECTED_VALUE) { + if (result != DS18_BAD_MEASUREMENT_VALUE && + result != DS18_DISCONNECTED_VALUE) { // Put value into the array verifyAndAddMeasurementResult(DS18_TEMP_VAR_NUM, result); success = true; diff --git a/src/sensors/MaximDS18.h b/src/sensors/MaximDS18.h index 5f85322ad..2e0cad348 100644 --- a/src/sensors/MaximDS18.h +++ b/src/sensors/MaximDS18.h @@ -153,6 +153,10 @@ * {{ @ref MaximDS18_Temp::MaximDS18_Temp }} */ /**@{*/ +/// @brief Minimum temperature in degrees Celsius. +#define DS18_TEMP_MIN_C -55.0 +/// @brief Maximum temperature in degrees Celsius. +#define DS18_TEMP_MAX_C 125.0 /// @brief Decimal places in string representation; temperature should have 4. #define DS18_TEMP_RESOLUTION 4 /// @brief Sensor variable number; temperature is stored in sensorValues[0]. diff --git a/src/sensors/MaximDS3231.h b/src/sensors/MaximDS3231.h index 441ef7081..7fac28a18 100644 --- a/src/sensors/MaximDS3231.h +++ b/src/sensors/MaximDS3231.h @@ -127,6 +127,10 @@ * {{ @ref MaximDS3231_Temp::MaximDS3231_Temp }} */ /**@{*/ +/// @brief Minimum temperature in degrees Celsius. +#define DS3231_TEMP_MIN_C -55.0 +/// @brief Maximum temperature in degrees Celsius. +#define DS3231_TEMP_MAX_C 125.0 /// @brief Decimal places in string representation; temperature should have 2 - /// resolution is -0.25°C (10 bit). #define DS3231_TEMP_RESOLUTION 2 @@ -222,4 +226,4 @@ class MaximDS3231_Temp : public Variable { /**@}*/ #endif // SRC_SENSORS_MAXIMDS3231_H_ -// cSpell:ignore temperatureDatalogger +// cSpell:words temperatureDatalogger diff --git a/src/sensors/MeaSpecMS5803.cpp b/src/sensors/MeaSpecMS5803.cpp index dd35e1bf4..682d10920 100644 --- a/src/sensors/MeaSpecMS5803.cpp +++ b/src/sensors/MeaSpecMS5803.cpp @@ -73,13 +73,14 @@ bool MeaSpecMS5803::addSingleMeasurementResult() { MS_DBG(F(" Temperature:"), temp); MS_DBG(F(" Pressure:"), press); - if (!isnan(temp) && !isnan(press) && temp >= -40.0 && temp <= 85.0 && - press > 0.0 && press <= (_maxPressure * 1000.0)) { + if (!isnan(temp) && !isnan(press) && temp >= MS5803_TEMP_MIN_C && + temp <= MS5803_TEMP_MAX_C && press > 0.0 && + press <= (_maxPressure * 1000.0)) { // Temperature Range is -40°C to +85°C // Pressure returns 0 when disconnected, which is highly unlikely to be // a real value. - // Pressure range depends on the model; validation uses _maxPressure * - // 1000.0 + // Pressure range depends on the model; validation uses _maxPressure + // (bar) * 1000 (mbar/bar) verifyAndAddMeasurementResult(MS5803_TEMP_VAR_NUM, temp); verifyAndAddMeasurementResult(MS5803_PRESSURE_VAR_NUM, press); success = true; diff --git a/src/sensors/MeaSpecMS5803.h b/src/sensors/MeaSpecMS5803.h index f6de8b43c..8dad823e3 100644 --- a/src/sensors/MeaSpecMS5803.h +++ b/src/sensors/MeaSpecMS5803.h @@ -144,6 +144,10 @@ * {{ @ref MeaSpecMS5803_Temp::MeaSpecMS5803_Temp }} */ /**@{*/ +/// @brief Minimum temperature in degrees Celsius. +#define MS5803_TEMP_MIN_C -40.0 +/// @brief Maximum temperature in degrees Celsius. +#define MS5803_TEMP_MAX_C 85.0 /// @brief Decimal places in string representation; temperature should have 2 - /// resolution is <0.01°C. #define MS5803_TEMP_RESOLUTION 2 @@ -165,7 +169,7 @@ * @anchor sensor_ms5803_pressure * @name Pressure * The pressure variable from a Measurement Specialties MS5803 - * - Range is 0 to 14 bar + * - Range is 0 to 14 bar (0 to 14000 mbar) * - Accuracy between 0 and +40°C is: * - 14ba: ±20mbar * - 2ba: ±1.5mbar @@ -183,6 +187,10 @@ * {{ @ref MeaSpecMS5803_Pressure::MeaSpecMS5803_Pressure }} */ /**@{*/ +/// @brief Minimum pressure in millibar. +#define MS5803_PRESSURE_MIN_MBAR 0.0 +/// @brief Maximum pressure in millibar. +#define MS5803_PRESSURE_MAX_MBAR 14000.0 /// @brief Decimal places in string representation; pressure should have 3. #define MS5803_PRESSURE_RESOLUTION 3 /// @brief Sensor variable number; pressure is stored in sensorValues[1]. @@ -325,7 +333,7 @@ class MeaSpecMS5803_Pressure : public Variable { * @param uuid A universally unique identifier (UUID or GUID) for the * variable; optional with the default value of an empty string. * @param varCode A short code to help identify the variable in files; - * optional with a default value of MeaSpecMS5803Pressure + * optional with a default value of "MeaSpecMS5803Pressure" */ explicit MeaSpecMS5803_Pressure( MeaSpecMS5803* parentSense, const char* uuid = "", diff --git a/src/sensors/MeterHydros21.h b/src/sensors/MeterHydros21.h index 1f2288c39..26a34d010 100644 --- a/src/sensors/MeterHydros21.h +++ b/src/sensors/MeterHydros21.h @@ -127,6 +127,10 @@ * {{ @ref MeterHydros21_Cond::MeterHydros21_Cond }} */ /**@{*/ +/// @brief Minimum conductivity; 0 µS/cm +#define HYDROS21_COND_MIN_USCM 0 +/// @brief Maximum conductivity; 120000 µS/cm (120 mS/cm) +#define HYDROS21_COND_MAX_USCM 120000 /** * @brief Decimal places in string representation; conductivity should have 1. * @@ -158,6 +162,10 @@ * {{ @ref MeterHydros21_Temp::MeterHydros21_Temp }} */ /**@{*/ +/// @brief Minimum temperature; -11°C +#define HYDROS21_TEMP_MIN_C -11 +/// @brief Maximum temperature; 49°C +#define HYDROS21_TEMP_MAX_C 49 /** * @brief Decimal places in string representation; temperature should have 2. * @@ -189,6 +197,10 @@ * {{ @ref MeterHydros21_Depth::MeterHydros21_Depth }} */ /**@{*/ +/// @brief Minimum depth; 0 m (0 millimeter) +#define HYDROS21_DEPTH_MIN_MM 0 +/// @brief Maximum depth; 10 m (10000 millimeters) +#define HYDROS21_DEPTH_MAX_MM 10000 /** * @brief Decimal places in string representation; depth should have 1. * diff --git a/src/sensors/MeterTeros11.h b/src/sensors/MeterTeros11.h index 62b42dc0a..94fbef9a0 100644 --- a/src/sensors/MeterTeros11.h +++ b/src/sensors/MeterTeros11.h @@ -139,6 +139,9 @@ * The raw VWC counts variable from a Meter Teros 11 * - Range and accuracy of the raw count values are not specified * + * @todo Find and define minimum and maximum raw count measurement range from a + * Meter Teros 11. + * * {{ @ref MeterTeros11_Count::MeterTeros11_Count }} */ /**@{*/ @@ -172,6 +175,10 @@ * {{ @ref MeterTeros11_Temp::MeterTeros11_Temp }} */ /**@{*/ +/// @brief Minimum temperature; -40°C +#define TEROS11_TEMP_MIN_C -40 +/// @brief Maximum temperature; 60°C +#define TEROS11_TEMP_MAX_C 60 /** * @brief Decimal places in string representation; temperature should have 2. * @@ -205,6 +212,10 @@ * {{ @ref MeterTeros11_Ea::MeterTeros11_Ea }} */ /**@{*/ +/// @brief Minimum EA; 1 (air) +#define TEROS11_EA_MIN 1 +/// @brief Maximum EA; 80 (water) +#define TEROS11_EA_MAX 80 /** * @brief Decimal places in string representation; EA should have 5. * @@ -242,6 +253,10 @@ * {{ @ref MeterTeros11_VWC::MeterTeros11_VWC }} */ /**@{*/ +/// @brief Minimum VWC; 0% (0.0 m3/m3) +#define TEROS11_VWC_MIN_PCT 0 +/// @brief Maximum VWC; 100% (1.0 m3/m3, soilless media calibration) +#define TEROS11_VWC_MAX_PCT 100 /** * @brief Decimal places in string representation; VWC should have 3. * diff --git a/src/sensors/PaleoTerraRedox.h b/src/sensors/PaleoTerraRedox.h index f5cdf5e21..612e071d1 100644 --- a/src/sensors/PaleoTerraRedox.h +++ b/src/sensors/PaleoTerraRedox.h @@ -153,6 +153,9 @@ * The voltage variable from a PaleoTerra redox probe * - Accuracy is ±5mV * + * @todo Find and define minimum and maximum voltage measurement range from a + * PaleoTerra redox probe. + * * {{ @ref PaleoTerraRedox_Voltage::PaleoTerraRedox_Voltage }} */ /**@{*/ diff --git a/src/sensors/ProcessorAnalog.h b/src/sensors/ProcessorAnalog.h index bf60ae21a..e695d5d60 100644 --- a/src/sensors/ProcessorAnalog.h +++ b/src/sensors/ProcessorAnalog.h @@ -122,11 +122,14 @@ * @anchor sensor_processor_analog_volt * @name Voltage * The voltage variable for the processor analog voltage sensor - * - Range is dependent on the supply voltage and any voltage divider + * - Range is dependent on the supply voltage and any voltage divider. We do + * not set a specific maximum for this variable. * * {{ @ref ProcessorAnalog_Voltage::ProcessorAnalog_Voltage }} */ /**@{*/ +/// @brief Minimum analog voltage in volts. +#define PROCESSOR_ANALOG_MIN_V 0.0 /// Variable number; voltage is stored in sensorValues[0]. #define PROCESSOR_ANALOG_VAR_NUM 0 /// @brief Variable name in diff --git a/src/sensors/ProcessorStats.h b/src/sensors/ProcessorStats.h index 53f9cd61e..4aa7e3d8b 100644 --- a/src/sensors/ProcessorStats.h +++ b/src/sensors/ProcessorStats.h @@ -117,10 +117,13 @@ * The battery voltage variable from the processor/mcu * This is the voltage as measured on the battery attached to the MCU using the * inbuilt ADC, if applicable. - * - Range is assumed to be 0 to 5V - * - Accuracy is processor dependent + * - Range and accuracy are processor dependent. + * + * We do not set a specific maximum for this variable. */ /**@{*/ +/// @brief Minimum battery voltage in volts. +#define PROCESSOR_BATTERY_MIN_V 0.0 /** * @brief Decimal places in string representation; battery voltage should * have 3. @@ -187,6 +190,10 @@ * {{ @ref ProcessorStats_SampleNumber::ProcessorStats_SampleNumber }} */ /**@{*/ +/// @brief Minimum sample number. +#define PROCESSOR_SAMPNUM_MIN_NUM 0 +/// @brief Maximum sample number. +#define PROCESSOR_SAMPNUM_MAX_NUM 32767 /// @brief Decimal places in string representation; sample number should have /// 0 - resolution is 1. #define PROCESSOR_SAMPNUM_RESOLUTION 0 @@ -217,6 +224,10 @@ * {{ @ref ProcessorStats_ResetCode::ProcessorStats_ResetCode }} */ /**@{*/ +/// @brief Minimum reset code value. +#define PROCESSOR_RESET_MIN_CODE 0 +/// @brief Maximum reset code value. +#define PROCESSOR_RESET_MAX_CODE 255 /// @brief Decimal places in string representation; reset code should have 0 - /// it's just a code #define PROCESSOR_RESET_RESOLUTION 0 @@ -518,4 +529,4 @@ class ProcessorStats_ResetCode : public Variable { /**@}*/ #endif // SRC_SENSORS_PROCESSORSTATS_H_ -// cSpell:ignore SAMPNUM sampno Tatu Moja Adalogger Duemilanove Esplora +// cSpell:words SAMPNUM sampno Tatu Moja Adalogger Duemilanove Esplora diff --git a/src/sensors/RainCounterI2C.h b/src/sensors/RainCounterI2C.h index 6d4c4fa98..3ab25f86c 100644 --- a/src/sensors/RainCounterI2C.h +++ b/src/sensors/RainCounterI2C.h @@ -137,11 +137,16 @@ * @anchor sensor_i2c_rain_depth * @name Rain Depth * The rain depth variable from a Trinket-based tipping bucket counter - * - Range and accuracy depend on the tipping bucket used + * - Range and accuracy depend on the tipping bucket used. We set it to a big + * number here. * * {{ @ref RainCounterI2C_Depth::RainCounterI2C_Depth }} */ /**@{*/ +/// @brief Minimum precipitation in millimeters. +#define BUCKET_RAIN_MIN_MM 0.0 +/// @brief Maximum precipitation in millimeters. +#define BUCKET_RAIN_MAX_MM 500.0 /** * @brief Decimal places in string representation; rain depth should have 2. * @@ -167,11 +172,16 @@ * @anchor sensor_i2c_rain_tips * @name Tip Count * Defines for tip count variable from a Trinket-based tipping bucket counter - * - Range and accuracy depend on the tipping bucket used. + * - Range and accuracy depend on the tipping bucket used. We set the maximum + * tip count to the maximum value of an unsigned long. * * {{ @ref RainCounterI2C_Tips::RainCounterI2C_Tips }} */ /**@{*/ +/// @brief Minimum number of bucket tips. +#define BUCKET_TIPS_MIN_TIPS 0 +/// @brief Maximum number of bucket tips. +#define BUCKET_TIPS_MAX_TIPS 4294967295 /// @brief Decimal places in string representation; the number of tips should /// have 0 - resolution is 1 tip. #define BUCKET_TIPS_RESOLUTION 0 diff --git a/src/sensors/SensirionSHT4x.h b/src/sensors/SensirionSHT4x.h index b04840efa..0488f5518 100644 --- a/src/sensors/SensirionSHT4x.h +++ b/src/sensors/SensirionSHT4x.h @@ -129,6 +129,10 @@ * {{ @ref SensirionSHT4x_Humidity::SensirionSHT4x_Humidity }} */ /**@{*/ +/// @brief Minimum relative humidity in percent. +#define SHT4X_HUMIDITY_MIN_RH 0.0 +/// @brief Maximum relative humidity in percent. +#define SHT4X_HUMIDITY_MAX_RH 100.0 /** * @brief Decimal places in string representation; humidity should have 2 (0.01 * % RH). @@ -160,6 +164,10 @@ * {{ @ref SensirionSHT4x_Temp::SensirionSHT4x_Temp }} */ /**@{*/ +/// @brief Minimum temperature in degrees Celsius. +#define SHT4X_TEMP_MIN_C -40.0 +/// @brief Maximum temperature in degrees Celsius. +#define SHT4X_TEMP_MAX_C 125.0 /** * @brief Decimal places in string representation; temperature should have 2 * (0.01 °C). @@ -366,4 +374,4 @@ class SensirionSHT4x_Temp : public Variable { /**@}*/ #endif // SRC_SENSORS_SENSIRIONSHT4X_H_ -// cSpell:ignore preconfigured +// cSpell:words preconfigured diff --git a/src/sensors/TEConnectivityMS5837.h b/src/sensors/TEConnectivityMS5837.h index d0ca3eba6..82b123ab5 100644 --- a/src/sensors/TEConnectivityMS5837.h +++ b/src/sensors/TEConnectivityMS5837.h @@ -228,6 +228,10 @@ static_assert( * {{ @ref TEConnectivityMS5837_Temp::TEConnectivityMS5837_Temp }} */ /**@{*/ +/// @brief Minimum temperature in degrees Celsius. +#define MS5837_TEMP_MIN_C -40.0 +/// @brief Maximum temperature in degrees Celsius. +#define MS5837_TEMP_MAX_C 85.0 /// @brief Decimal places in string representation; temperature should have 2 - /// resolution is <0.01°C. #define MS5837_TEMP_RESOLUTION 2 @@ -250,8 +254,8 @@ static_assert( * @name Pressure * The pressure variable from a TE Connectivity MS5837 * - Range depends on sensor model: - * - Bar02: 0 to 2 bar - * - Bar30: 0 to 30 bar + * - Bar02: 0 to 2 bar (0 to 2000 mbar) + * - Bar30: 0 to 30 bar (0 to 30000 mbar) * - Accuracy: * - Bar02: ±1.5mbar * - Bar30: ±20mbar @@ -264,6 +268,10 @@ static_assert( * {{ @ref TEConnectivityMS5837_Pressure::TEConnectivityMS5837_Pressure }} */ /**@{*/ +/// @brief Minimum pressure in millibar. +#define MS5837_PRESSURE_MIN_MBAR 0.0 +/// @brief Maximum pressure in millibar. +#define MS5837_PRESSURE_MAX_MBAR 3000.0 /// @brief Decimal places in string representation; pressure should have 3. #define MS5837_PRESSURE_RESOLUTION 3 /// @brief Sensor variable number; pressure is stored in sensorValues[1]. diff --git a/src/sensors/TIADS1x15.h b/src/sensors/TIADS1x15.h index 84b6899d9..d7abd08a0 100644 --- a/src/sensors/TIADS1x15.h +++ b/src/sensors/TIADS1x15.h @@ -231,6 +231,10 @@ * {{ @ref TIADS1x15_Voltage::TIADS1x15_Voltage }} */ /**@{*/ +/// @brief Minimum voltage in volts. +#define TIADS1X15_MIN_V -6.144 +/// @brief Maximum voltage in volts. +#define TIADS1X15_MAX_V 6.144 /// Variable number; voltage is stored in sensorValues[0]. #define TIADS1X15_VAR_NUM 0 /// @brief Variable name in @@ -590,6 +594,6 @@ typedef TIADS1x15_Voltage ExternalVoltage_Volt; /**@}*/ -// cspell:words GAIN_TWOTHIRDS - #endif // SRC_SENSORS_TIADS1X15_H_ + +// cSpell:words GAIN_TWOTHIRDS diff --git a/src/sensors/TIINA219.h b/src/sensors/TIINA219.h index 974bc8f82..d97e923f9 100644 --- a/src/sensors/TIINA219.h +++ b/src/sensors/TIINA219.h @@ -141,16 +141,18 @@ * - Range is between +/-0.4 Amps and +/-3.2 Amps * - Absolute accuracy is range dependent, and approx 2LSB (R accuracy * unknown) + * - Resolution is 12-bit + * - 0.8mA using +/-3.2 Amp range + * - 0.1mA using +/-0.4 Amp range * * {{ @ref TIINA219_Current::TIINA219_Current }} */ /**@{*/ -/** - * @brief Decimal places in string representation; current should have 1. - * - resolution is 12-bit - * - 0.8mA using +/-3.2 Amp range - * - 0.1mA using +/-0.4 Amp range - */ +/// @brief Minimum current in amps (negative for reverse current). +#define INA219_CURRENT_MIN_A -3.2 +/// @brief Maximum current in amps. +#define INA219_CURRENT_MAX_A 3.2 +/// @brief Decimal places in string representation; current should have 1. #define INA219_CURRENT_MA_RESOLUTION 1 /// @brief Sensor variable number; current is stored in sensorValues[0]. #define INA219_CURRENT_MA_VAR_NUM 0 @@ -175,6 +177,10 @@ * {{ @ref TIINA219_Voltage::TIINA219_Voltage }} */ /**@{*/ +/// @brief Minimum bus voltage in volts. +#define INA219_BUS_VOLTAGE_MIN_V 0 +/// @brief Maximum bus voltage in volts. +#define INA219_BUS_VOLTAGE_MAX_V 26 /// @brief Decimal places in string representation; bus voltage should have 3 - /// resolution is 0.004V. #define INA219_BUS_VOLTAGE_RESOLUTION 3 @@ -199,6 +205,10 @@ * {{ @ref TIINA219_Power::TIINA219_Power }} */ /**@{*/ +/// @brief Minimum power in milliwatts. +#define INA219_POWER_MW_MIN_MW 0 +/// @brief Maximum power in milliwatts. +#define INA219_POWER_MW_MAX_MW 102400 /// @brief Decimal places in string representation; power draw should have 2 - /// resolution is 0.01mW. #define INA219_POWER_MW_RESOLUTION 2 @@ -421,4 +431,4 @@ class TIINA219_Power : public Variable { /**@}*/ #endif // SRC_SENSORS_TIINA219_H_ -// cSpell:ignore TIINA219 +// cSpell:words TIINA219 diff --git a/src/sensors/TallyCounterI2C.h b/src/sensors/TallyCounterI2C.h index d1848f33a..14cad4cc4 100644 --- a/src/sensors/TallyCounterI2C.h +++ b/src/sensors/TallyCounterI2C.h @@ -144,9 +144,13 @@ * - For wind, we often use [Inspeed WS2R Version II Reed Switch Anemometer] * (https://www.store.inspeed.com/Inspeed-Version-II-Reed-Switch-Anemometer-Sensor-Only-WS2R.htm) * + * We do not set a specific maximum for this variable. + * * {{ @ref TallyCounterI2C_Events::TallyCounterI2C_Events }} */ /**@{*/ +/// @brief Minimum number of events. +#define TALLY_EVENTS_MIN_COUNT 0 /// @brief Decimal places in string representation; events are an integer /// should be 0 - resolution is 1 event. #define TALLY_EVENTS_RESOLUTION 0 diff --git a/src/sensors/TurnerCyclops.h b/src/sensors/TurnerCyclops.h index 860fbbff7..53fd9cd62 100644 --- a/src/sensors/TurnerCyclops.h +++ b/src/sensors/TurnerCyclops.h @@ -279,6 +279,10 @@ class AnalogVoltageReader; * {{ @ref TurnerCyclops_Voltage::TurnerCyclops_Voltage }} */ /**@{*/ +/// @brief Minimum voltage; 0 V +#define CYCLOPS_VOLTAGE_MIN_V 0 +/// @brief Maximum voltage; 3.6 V (when using ADS1x15 powered at 3.3V) +#define CYCLOPS_VOLTAGE_MAX_V 3.6 /// Variable number; voltage is stored in sensorValues[1]. #define CYCLOPS_VOLTAGE_VAR_NUM 1 /// @brief Variable name in @@ -304,6 +308,264 @@ class AnalogVoltageReader; #endif /**@}*/ +/** + * @anchor sensor_cyclops_chlorophyll + * @name Chlorophyll (Blue Excitation) + * The chlorophyll variable from a Turner Cyclops-7F configured for blue + * excitation + * - Range is 0 to 500 μg/L + * - Detection limit is 0.03 μg/L + */ +/**@{*/ +/// @brief Minimum chlorophyll concentration; 0 μg/L +#define CYCLOPS_CHLOROPHYLL_MIN_UGPL 0 +/// @brief Maximum chlorophyll concentration; 500 μg/L +#define CYCLOPS_CHLOROPHYLL_MAX_UGPL 500 +/// @brief Variable name in ODM2 controlled vocabulary; +/// "chlorophyllFluorescence" +#define CYCLOPS_CHLOROPHYLL_VAR_NAME "chlorophyllFluorescence" +/// @brief Variable unit name in ODM2 controlled vocabulary; "microgramPerLiter" +#define CYCLOPS_CHLOROPHYLL_UNIT_NAME "microgramPerLiter" +/// @brief Default variable short code; "CyclopsChlorophyll" +#define CYCLOPS_CHLOROPHYLL_DEFAULT_CODE "CyclopsChlorophyll" +/**@}*/ + +/** + * @anchor sensor_cyclops_rhodamine + * @name Rhodamine WT + * The rhodamine variable from a Turner Cyclops-7F configured for Rhodamine WT + * - Range is 0 to 1,000 ppb + * - Detection limit is 0.01 ppb + */ +/**@{*/ +/// @brief Minimum rhodamine concentration; 0 ppb +#define CYCLOPS_RHODAMINE_MIN_PPB 0 +/// @brief Maximum rhodamine concentration; 1,000 ppb +#define CYCLOPS_RHODAMINE_MAX_PPB 1000 +/// @brief Variable name in ODM2 controlled vocabulary; "RhodamineFluorescence" +#define CYCLOPS_RHODAMINE_VAR_NAME "RhodamineFluorescence" +/// @brief Variable unit name in ODM2 controlled vocabulary; "partPerBillion" +#define CYCLOPS_RHODAMINE_UNIT_NAME "partPerBillion" +/// @brief Default variable short code; "CyclopsRhodamine" +#define CYCLOPS_RHODAMINE_DEFAULT_CODE "CyclopsRhodamine" +/**@}*/ + +/** + * @anchor sensor_cyclops_fluorescein + * @name Fluorescein + * The fluorescein variable from a Turner Cyclops-7F configured for fluorescein + * - Range is 0 to 500 ppb + * - Detection limit is 0.01 ppb + */ +/**@{*/ +/// @brief Minimum fluorescein concentration; 0 ppb +#define CYCLOPS_FLUORESCEIN_MIN_PPB 0 +/// @brief Maximum fluorescein concentration; 500 ppb +#define CYCLOPS_FLUORESCEIN_MAX_PPB 500 +/// @brief Variable name in ODM2 controlled vocabulary; "fluorescein" +#define CYCLOPS_FLUORESCEIN_VAR_NAME "fluorescein" +/// @brief Variable unit name in ODM2 controlled vocabulary; "partPerBillion" +#define CYCLOPS_FLUORESCEIN_UNIT_NAME "partPerBillion" +/// @brief Default variable short code; "CyclopsFluorescein" +#define CYCLOPS_FLUORESCEIN_DEFAULT_CODE "CyclopsFluorescein" +/**@}*/ + +/** + * @anchor sensor_cyclops_phycocyanin + * @name Phycocyanin + * The phycocyanin variable from a Turner Cyclops-7F configured for phycocyanin + * - Range is 0 to 4,500 ppbPC + * - Detection limit is 2 ppbPC + */ +/**@{*/ +/// @brief Minimum phycocyanin concentration; 0 ppb +#define CYCLOPS_PHYCOCYANIN_MIN_PPB 0 +/// @brief Maximum phycocyanin concentration; 4,500 ppb +#define CYCLOPS_PHYCOCYANIN_MAX_PPB 4500 +/// @brief Variable name in ODM2 controlled vocabulary; +/// "blue_GreenAlgae_Cyanobacteria_Phycocyanin" +#define CYCLOPS_PHYCOCYANIN_VAR_NAME "blue_GreenAlgae_Cyanobacteria_Phycocyanin" +/// @brief Variable unit name in ODM2 controlled vocabulary; "partPerBillion" +#define CYCLOPS_PHYCOCYANIN_UNIT_NAME "partPerBillion" +/// @brief Default variable short code; "CyclopsPhycocyanin" +#define CYCLOPS_PHYCOCYANIN_DEFAULT_CODE "CyclopsPhycocyanin" +/**@}*/ + +/** + * @anchor sensor_cyclops_phycoerythrin + * @name Phycoerythrin + * The phycoerythrin variable from a Turner Cyclops-7F configured for + * phycoerythrin + * - Range is 0 to 750 ppbPE + * - Detection limit is 0.1 ppbPE + */ +/**@{*/ +/// @brief Minimum phycoerythrin concentration; 0 ppb +#define CYCLOPS_PHYCOERYTHRIN_MIN_PPB 0 +/// @brief Maximum phycoerythrin concentration; 750 ppb +#define CYCLOPS_PHYCOERYTHRIN_MAX_PPB 750 +/// @brief Variable name in ODM2 controlled vocabulary; "phycoerythrin" +#define CYCLOPS_PHYCOERYTHRIN_VAR_NAME "phycoerythrin" +/// @brief Variable unit name in ODM2 controlled vocabulary; "partPerBillion" +#define CYCLOPS_PHYCOERYTHRIN_UNIT_NAME "partPerBillion" +/// @brief Default variable short code; "CyclopsPhycoerythrin" +#define CYCLOPS_PHYCOERYTHRIN_DEFAULT_CODE "CyclopsPhycoerythrin" +/**@}*/ + +/** + * @anchor sensor_cyclops_cdom + * @name CDOM/fDOM + * The CDOM/fDOM variable from a Turner Cyclops-7F configured for CDOM + * - Range is 0 to 1,500 ppb (or 0 to 3,000 ppb depending on configuration) + * - Detection limit is 0.1 ppb (or 0.5 ppb) + */ +/**@{*/ +/// @brief Minimum CDOM concentration; 0 ppb +#define CYCLOPS_CDOM_MIN_PPB 0 +/// @brief Maximum CDOM concentration; 3,000 ppb +#define CYCLOPS_CDOM_MAX_PPB 3000 +/// @brief Variable name in ODM2 controlled vocabulary; +/// "fluorescenceDissolvedOrganicMatter" +#define CYCLOPS_CDOM_VAR_NAME "fluorescenceDissolvedOrganicMatter" +/// @brief Variable unit name in ODM2 controlled vocabulary; "partPerBillion" +#define CYCLOPS_CDOM_UNIT_NAME "partPerBillion" +/// @brief Default variable short code; "CyclopsCDOM" +#define CYCLOPS_CDOM_DEFAULT_CODE "CyclopsCDOM" +/**@}*/ + +/** + * @anchor sensor_cyclops_crudeoil + * @name Crude Oil + * The crude oil variable from a Turner Cyclops-7F configured for crude oil + * - Range is 0 to 1,500 ppb + * - Detection limit is 0.2 ppb + */ +/**@{*/ +/// @brief Minimum crude oil concentration; 0 ppb +#define CYCLOPS_CRUDE_OIL_MIN_PPB 0 +/// @brief Maximum crude oil concentration; 1,500 ppb +#define CYCLOPS_CRUDE_OIL_MAX_PPB 1500 +/// @brief Variable name in ODM2 controlled vocabulary; +/// "petroleumHydrocarbonTotal" +#define CYCLOPS_CRUDE_OIL_VAR_NAME "petroleumHydrocarbonTotal" +/// @brief Variable unit name in ODM2 controlled vocabulary; "partPerBillion" +#define CYCLOPS_CRUDE_OIL_UNIT_NAME "partPerBillion" +/// @brief Default variable short code; "CyclopsCrudeOil" +#define CYCLOPS_CRUDE_OIL_DEFAULT_CODE "CyclopsCrudeOil" +/**@}*/ + +/** + * @anchor sensor_cyclops_brighteners + * @name Optical Brighteners + * The optical brighteners variable from a Turner Cyclops-7F configured for + * optical brighteners + * + * @todo Find and define minimum and maximum optical brightener measurement + * range on a Turner Cyclops-7F. + */ +/**@{*/ +/// @brief Variable name in ODM2 controlled vocabulary; "opticalBrighteners" +#define CYCLOPS_BRIGHTENERS_VAR_NAME "opticalBrighteners" +/// @brief Variable unit name in ODM2 controlled vocabulary; "partPerBillion" +#define CYCLOPS_BRIGHTENERS_UNIT_NAME "partPerBillion" +/// @brief Default variable short code; "CyclopsOpticalBrighteners" +#define CYCLOPS_BRIGHTENERS_DEFAULT_CODE "CyclopsOpticalBrighteners" +/**@}*/ + +/** + * @anchor sensor_cyclops_turbidity + * @name Turbidity + * The turbidity variable from a Turner Cyclops-7F configured for turbidity + * - Range is 0 to 1,500 NTU + * - Detection limit is 0.05 NTU + */ +/**@{*/ +/// @brief Minimum turbidity; 0 NTU +#define CYCLOPS_TURBIDITY_MIN_NTU 0 +/// @brief Maximum turbidity; 1,500 NTU +#define CYCLOPS_TURBIDITY_MAX_NTU 1500 +/// @brief Variable name in ODM2 controlled vocabulary; "Turbidity" +#define CYCLOPS_TURBIDITY_VAR_NAME "Turbidity" +/// @brief Variable unit name in ODM2 controlled vocabulary; +/// "nephelometricTurbidityUnit" +#define CYCLOPS_TURBIDITY_UNIT_NAME "nephelometricTurbidityUnit" +/// @brief Default variable short code; "CyclopsTurbidity" +#define CYCLOPS_TURBIDITY_DEFAULT_CODE "CyclopsTurbidity" +/**@}*/ + +/** + * @anchor sensor_cyclops_ptsa + * @name PTSA + * The PTSA variable from a Turner Cyclops-7F configured for PTSA + * + * @todo Find and define minimum and maximum PTSA measurement range on a Turner + * Cyclops-7F. + */ +/**@{*/ +/// @brief Variable name in ODM2 controlled vocabulary; "ptsa" +#define CYCLOPS_PTSA_VAR_NAME "ptsa" +/// @brief Variable unit name in ODM2 controlled vocabulary; "partPerBillion" +#define CYCLOPS_PTSA_UNIT_NAME "partPerBillion" +/// @brief Default variable short code; "CyclopsPTSA" +#define CYCLOPS_PTSA_DEFAULT_CODE "CyclopsPTSA" +/**@}*/ + +/** + * @anchor sensor_cyclops_btex + * @name BTEX + * The BTEX variable from a Turner Cyclops-7F configured for BTEX + * + * @todo Find and define minimum and maximum BTEX measurement range on a Turner + * Cyclops-7F. + */ +/**@{*/ +/// @brief Variable name in ODM2 controlled vocabulary; "btex" +#define CYCLOPS_BTEX_VAR_NAME "btex" +/// @brief Variable unit name in ODM2 controlled vocabulary; "partPerMillion" +#define CYCLOPS_BTEX_UNIT_NAME "partPerMillion" +/// @brief Default variable short code; "CyclopsBTEX" +#define CYCLOPS_BTEX_DEFAULT_CODE "CyclopsBTEX" +/**@}*/ + +/** + * @anchor sensor_cyclops_tryptophan + * @name Tryptophan + * The tryptophan variable from a Turner Cyclops-7F configured for tryptophan + * + * @todo Find and define minimum and maximum tryptophan measurement range on a + * Turner Cyclops-7F. + */ +/**@{*/ +/// @brief Variable name in ODM2 controlled vocabulary; "tryptophan" +#define CYCLOPS_TRYPTOPHAN_VAR_NAME "tryptophan" +/// @brief Variable unit name in ODM2 controlled vocabulary; "partPerBillion" +#define CYCLOPS_TRYPTOPHAN_UNIT_NAME "partPerBillion" +/// @brief Default variable short code; "CyclopsTryptophan" +#define CYCLOPS_TRYPTOPHAN_DEFAULT_CODE "CyclopsTryptophan" +/**@}*/ + +/** + * @anchor sensor_cyclops_redchlorophyll + * @name Chlorophyll (Red Excitation) + * The chlorophyll variable from a Turner Cyclops-7F configured for red + * excitation (high CDOM environments) + * - Range is 0 to 500 μg/L + * - Detection limit is 0.3 μg/L + */ +/**@{*/ +/// @brief Minimum red chlorophyll concentration; 0 μg/L +#define CYCLOPS_RED_CHLOROPHYLL_MIN_UGPL 0 +/// @brief Maximum red chlorophyll concentration; 500 μg/L +#define CYCLOPS_RED_CHLOROPHYLL_MAX_UGPL 500 +/// @brief Variable name in ODM2 controlled vocabulary; +/// "chlorophyllFluorescence" +#define CYCLOPS_RED_CHLOROPHYLL_VAR_NAME "chlorophyllFluorescence" +/// @brief Variable unit name in ODM2 controlled vocabulary; "microgramPerLiter" +#define CYCLOPS_RED_CHLOROPHYLL_UNIT_NAME "microgramPerLiter" +/// @brief Default variable short code; "CyclopsRedChlorophyll" +#define CYCLOPS_RED_CHLOROPHYLL_DEFAULT_CODE "CyclopsRedChlorophyll" +/**@}*/ + /* clang-format off */ /** * @brief The Sensor sub-class for the @@ -485,11 +747,11 @@ class TurnerCyclops_Chlorophyll : public Variable { */ explicit TurnerCyclops_Chlorophyll( TurnerCyclops* parentSense, const char* uuid = "", - const char* varCode = "CyclopsChlorophyll") + const char* varCode = CYCLOPS_CHLOROPHYLL_DEFAULT_CODE) : Variable(parentSense, static_cast(CYCLOPS_VAR_NUM), static_cast(CYCLOPS_RESOLUTION), - "chlorophyllFluorescence", "microgramPerLiter", varCode, - uuid) {} + CYCLOPS_CHLOROPHYLL_VAR_NAME, CYCLOPS_CHLOROPHYLL_UNIT_NAME, + varCode, uuid) {} /** * @brief Destroy the Turner Cyclops Chlorophyll variable object - no action * needed. @@ -531,12 +793,13 @@ class TurnerCyclops_Rhodamine : public Variable { * @param varCode A short code to help identify the variable in files; * optional with a default value of "CyclopsRhodamine". */ - explicit TurnerCyclops_Rhodamine(TurnerCyclops* parentSense, - const char* uuid = "", - const char* varCode = "CyclopsRhodamine") + explicit TurnerCyclops_Rhodamine( + TurnerCyclops* parentSense, const char* uuid = "", + const char* varCode = CYCLOPS_RHODAMINE_DEFAULT_CODE) : Variable(parentSense, static_cast(CYCLOPS_VAR_NUM), static_cast(CYCLOPS_RESOLUTION), - "RhodamineFluorescence", "partPerBillion", varCode, uuid) {} + CYCLOPS_RHODAMINE_VAR_NAME, CYCLOPS_RHODAMINE_UNIT_NAME, + varCode, uuid) {} /** * @brief Destroy the Turner Cyclops Rhodamine variable object - no action * needed. @@ -580,10 +843,11 @@ class TurnerCyclops_Fluorescein : public Variable { */ explicit TurnerCyclops_Fluorescein( TurnerCyclops* parentSense, const char* uuid = "", - const char* varCode = "CyclopsFluorescein") + const char* varCode = CYCLOPS_FLUORESCEIN_DEFAULT_CODE) : Variable(parentSense, static_cast(CYCLOPS_VAR_NUM), - static_cast(CYCLOPS_RESOLUTION), "fluorescein", - "partPerBillion", varCode, uuid) {} + static_cast(CYCLOPS_RESOLUTION), + CYCLOPS_FLUORESCEIN_VAR_NAME, CYCLOPS_FLUORESCEIN_UNIT_NAME, + varCode, uuid) {} /** * @brief Destroy the Turner Cyclops Fluorescein variable object - no action * needed. @@ -628,11 +892,11 @@ class TurnerCyclops_Phycocyanin : public Variable { */ explicit TurnerCyclops_Phycocyanin( TurnerCyclops* parentSense, const char* uuid = "", - const char* varCode = "CyclopsPhycocyanin") + const char* varCode = CYCLOPS_PHYCOCYANIN_DEFAULT_CODE) : Variable(parentSense, static_cast(CYCLOPS_VAR_NUM), static_cast(CYCLOPS_RESOLUTION), - "blue_GreenAlgae_Cyanobacteria_Phycocyanin", - "partPerBillion", varCode, uuid) {} + CYCLOPS_PHYCOCYANIN_VAR_NAME, CYCLOPS_PHYCOCYANIN_UNIT_NAME, + varCode, uuid) {} /** * @brief Destroy the Turner Cyclops Phycocyanin variable object - no action * needed. @@ -677,10 +941,11 @@ class TurnerCyclops_Phycoerythrin : public Variable { */ explicit TurnerCyclops_Phycoerythrin( TurnerCyclops* parentSense, const char* uuid = "", - const char* varCode = "CyclopsPhycoerythrin") + const char* varCode = CYCLOPS_PHYCOERYTHRIN_DEFAULT_CODE) : Variable(parentSense, static_cast(CYCLOPS_VAR_NUM), - static_cast(CYCLOPS_RESOLUTION), "phycoerythrin", - "partPerBillion", varCode, uuid) {} + static_cast(CYCLOPS_RESOLUTION), + CYCLOPS_PHYCOERYTHRIN_VAR_NAME, + CYCLOPS_PHYCOERYTHRIN_UNIT_NAME, varCode, uuid) {} /** * @brief Destroy the Turner Cyclops Phycoerythrin variable object - no * action needed. @@ -727,12 +992,12 @@ class TurnerCyclops_CDOM : public Variable { * optional with a default value of "CyclopsCDOM". */ explicit TurnerCyclops_CDOM(TurnerCyclops* parentSense, - const char* uuid = "", - const char* varCode = "CyclopsCDOM") + const char* uuid = "", + const char* varCode = CYCLOPS_CDOM_DEFAULT_CODE) : Variable(parentSense, static_cast(CYCLOPS_VAR_NUM), static_cast(CYCLOPS_RESOLUTION), - "fluorescenceDissolvedOrganicMatter", "partPerBillion", - varCode, uuid) {} + CYCLOPS_CDOM_VAR_NAME, CYCLOPS_CDOM_UNIT_NAME, varCode, + uuid) {} /** * @brief Destroy the Turner Cyclops CDOM variable object - no action * needed. @@ -776,13 +1041,13 @@ class TurnerCyclops_CrudeOil : public Variable { * @param varCode A short code to help identify the variable in files; * optional with a default value of "CyclopsCrudeOil". */ - explicit TurnerCyclops_CrudeOil(TurnerCyclops* parentSense, - const char* uuid = "", - const char* varCode = "CyclopsCrudeOil") + explicit TurnerCyclops_CrudeOil( + TurnerCyclops* parentSense, const char* uuid = "", + const char* varCode = CYCLOPS_CRUDE_OIL_DEFAULT_CODE) : Variable(parentSense, static_cast(CYCLOPS_VAR_NUM), static_cast(CYCLOPS_RESOLUTION), - "petroleumHydrocarbonTotal", "partPerBillion", varCode, - uuid) {} + CYCLOPS_CRUDE_OIL_VAR_NAME, CYCLOPS_CRUDE_OIL_UNIT_NAME, + varCode, uuid) {} /** * @brief Destroy the Turner Cyclops CrudeOil variable object - no action * needed. @@ -829,10 +1094,11 @@ class TurnerCyclops_Brighteners : public Variable { */ explicit TurnerCyclops_Brighteners( TurnerCyclops* parentSense, const char* uuid = "", - const char* varCode = "CyclopsOpticalBrighteners") + const char* varCode = CYCLOPS_BRIGHTENERS_DEFAULT_CODE) : Variable(parentSense, static_cast(CYCLOPS_VAR_NUM), static_cast(CYCLOPS_RESOLUTION), - "opticalBrighteners", "partPerBillion", varCode, uuid) {} + CYCLOPS_BRIGHTENERS_VAR_NAME, CYCLOPS_BRIGHTENERS_UNIT_NAME, + varCode, uuid) {} /** * @brief Destroy the Turner Cyclops Brighteners object - no action needed. */ @@ -873,12 +1139,13 @@ class TurnerCyclops_Turbidity : public Variable { * @param varCode A short code to help identify the variable in files; * optional with a default value of "CyclopsTurbidity". */ - explicit TurnerCyclops_Turbidity(TurnerCyclops* parentSense, - const char* uuid = "", - const char* varCode = "CyclopsTurbidity") + explicit TurnerCyclops_Turbidity( + TurnerCyclops* parentSense, const char* uuid = "", + const char* varCode = CYCLOPS_TURBIDITY_DEFAULT_CODE) : Variable(parentSense, static_cast(CYCLOPS_VAR_NUM), - static_cast(CYCLOPS_RESOLUTION), "Turbidity", - "nephelometricTurbidityUnit", varCode, uuid) {} + static_cast(CYCLOPS_RESOLUTION), + CYCLOPS_TURBIDITY_VAR_NAME, CYCLOPS_TURBIDITY_UNIT_NAME, + varCode, uuid) {} /** * @brief Destroy the Turner Cyclops Turbidity variable object - no action * needed. @@ -922,11 +1189,12 @@ class TurnerCyclops_PTSA : public Variable { * optional with a default value of "CyclopsPTSA". */ explicit TurnerCyclops_PTSA(TurnerCyclops* parentSense, - const char* uuid = "", - const char* varCode = "CyclopsPTSA") + const char* uuid = "", + const char* varCode = CYCLOPS_PTSA_DEFAULT_CODE) : Variable(parentSense, static_cast(CYCLOPS_VAR_NUM), - static_cast(CYCLOPS_RESOLUTION), "ptsa", - "partPerBillion", varCode, uuid) {} + static_cast(CYCLOPS_RESOLUTION), + CYCLOPS_PTSA_VAR_NAME, CYCLOPS_PTSA_UNIT_NAME, varCode, + uuid) {} /** * @brief Destroy the Turner Cyclops PTSA variable object - no action * needed. @@ -970,11 +1238,12 @@ class TurnerCyclops_BTEX : public Variable { * optional with a default value of "CyclopsBTEX". */ explicit TurnerCyclops_BTEX(TurnerCyclops* parentSense, - const char* uuid = "", - const char* varCode = "CyclopsBTEX") + const char* uuid = "", + const char* varCode = CYCLOPS_BTEX_DEFAULT_CODE) : Variable(parentSense, static_cast(CYCLOPS_VAR_NUM), - static_cast(CYCLOPS_RESOLUTION), "btex", - "partPerMillion", varCode, uuid) {} + static_cast(CYCLOPS_RESOLUTION), + CYCLOPS_BTEX_VAR_NAME, CYCLOPS_BTEX_UNIT_NAME, varCode, + uuid) {} /** * @brief Destroy the Turner Cyclops BTEX variable object - no action * needed. @@ -1016,12 +1285,13 @@ class TurnerCyclops_Tryptophan : public Variable { * @param varCode A short code to help identify the variable in files; * optional with a default value of "CyclopsTryptophan". */ - explicit TurnerCyclops_Tryptophan(TurnerCyclops* parentSense, - const char* uuid = "", - const char* varCode = "CyclopsTryptophan") + explicit TurnerCyclops_Tryptophan( + TurnerCyclops* parentSense, const char* uuid = "", + const char* varCode = CYCLOPS_TRYPTOPHAN_DEFAULT_CODE) : Variable(parentSense, static_cast(CYCLOPS_VAR_NUM), - static_cast(CYCLOPS_RESOLUTION), "tryptophan", - "partPerBillion", varCode, uuid) {} + static_cast(CYCLOPS_RESOLUTION), + CYCLOPS_TRYPTOPHAN_VAR_NAME, CYCLOPS_TRYPTOPHAN_UNIT_NAME, + varCode, uuid) {} /** * @brief Destroy the Turner Cyclops Tryptophan variable object - no action * needed. @@ -1066,11 +1336,11 @@ class TurnerCyclops_RedChlorophyll : public Variable { */ explicit TurnerCyclops_RedChlorophyll( TurnerCyclops* parentSense, const char* uuid = "", - const char* varCode = "CyclopsRedChlorophyll") + const char* varCode = CYCLOPS_RED_CHLOROPHYLL_DEFAULT_CODE) : Variable(parentSense, static_cast(CYCLOPS_VAR_NUM), static_cast(CYCLOPS_RESOLUTION), - "chlorophyllFluorescence", "microgramPerLiter", varCode, - uuid) {} + CYCLOPS_RED_CHLOROPHYLL_VAR_NAME, + CYCLOPS_RED_CHLOROPHYLL_UNIT_NAME, varCode, uuid) {} /** * @brief Destroy the Turner Cyclops Red Chlorophyll variable object - no * action needed. @@ -1080,5 +1350,5 @@ class TurnerCyclops_RedChlorophyll : public Variable { /**@}*/ #endif // SRC_SENSORS_TURNERCYCLOPS_H_ -// cSpell:ignore fluorophores BTEX PTSA Pyrenetetrasulfonic Tetrasodium -// cSpell:ignore Ethylbenzene Prozyme sensor_cyclops_calib +// cSpell:words fluorophores BTEX PTSA Pyrenetetrasulfonic Tetrasodium +// cSpell:words Ethylbenzene Prozyme sensor_cyclops_calib UGPL diff --git a/src/sensors/TurnerTurbidityPlus.h b/src/sensors/TurnerTurbidityPlus.h index 662e6e36d..cef7828de 100644 --- a/src/sensors/TurnerTurbidityPlus.h +++ b/src/sensors/TurnerTurbidityPlus.h @@ -142,6 +142,10 @@ class AnalogVoltageReader; * The primary turbidity output from an Turbidity Plus */ /**@{*/ +/// @brief Minimum turbidity; 0 NTU +#define TURBIDITY_PLUS_MIN_NTU 0 +/// @brief Maximum turbidity; 3000 NTU (detection limit 0.5 NTU) +#define TURBIDITY_PLUS_MAX_NTU 3000 /// Variable number; the primary variable is stored in sensorValues[0]. #define TURBIDITY_PLUS_VAR_NUM 0 /// @brief Variable name in [ODM2 controlled @@ -179,6 +183,10 @@ class AnalogVoltageReader; * {{ @ref TurnerTurbidityPlus_Voltage::TurnerTurbidityPlus_Voltage }} */ /**@{*/ +/// @brief Minimum voltage when using ADS1x15 at 3.3V; 0.0V +#define TURBIDITY_PLUS_VOLTAGE_MIN_V 0.0 +/// @brief Maximum voltage when using ADS1x15 at 3.3V; 3.6V +#define TURBIDITY_PLUS_VOLTAGE_MAX_V 3.6 /// Variable number; voltage is stored in sensorValues[1]. #define TURBIDITY_PLUS_VOLTAGE_VAR_NUM 1 /// @brief Variable name in [ODM2 controlled @@ -427,5 +435,4 @@ class TurnerTurbidityPlus_Turbidity : public Variable { ~TurnerTurbidityPlus_Turbidity() override = default; }; /**@}*/ - #endif // SRC_SENSORS_TURNERTURBIDITYPLUS_H_ diff --git a/src/sensors/VegaPuls21.h b/src/sensors/VegaPuls21.h index 645eacdbf..bcdef607f 100644 --- a/src/sensors/VegaPuls21.h +++ b/src/sensors/VegaPuls21.h @@ -113,6 +113,10 @@ * {{ @ref VegaPuls21_Stage::VegaPuls21_Stage }} */ /**@{*/ +/// @brief Minimum stage; 0 m +#define VEGAPULS21_STAGE_MIN_M 0 +/// @brief Maximum stage; 20 m (measuring range) +#define VEGAPULS21_STAGE_MAX_M 20 /// @brief Decimal places in string representation; stage in meters should have /// 3 - resolution is 1mm. #define VEGAPULS21_STAGE_RESOLUTION 3 @@ -139,6 +143,10 @@ * {{ @ref VegaPuls21_Distance::VegaPuls21_Distance }} */ /**@{*/ +/// @brief Minimum distance; 0.25 m (minimum measuring distance) +#define VEGAPULS21_DISTANCE_MIN_M 0.25 +/// @brief Maximum distance; 20 m (measuring range) +#define VEGAPULS21_DISTANCE_MAX_M 20 /// @brief Decimal places in string representation; distance in meters should /// have 3 - resolution is 1mm. #define VEGAPULS21_DISTANCE_RESOLUTION 3 @@ -164,6 +172,10 @@ * {{ @ref VegaPuls21_Temp::VegaPuls21_Temp }} */ /**@{*/ +/// @brief Minimum process temperature; -40°C +#define VEGAPULS21_TEMP_MIN_C -40 +/// @brief Maximum process temperature; 80°C +#define VEGAPULS21_TEMP_MAX_C 80 /// @brief Decimal places in string representation; temperature should have 1 - /// resolution is 0.1°C. #define VEGAPULS21_TEMP_RESOLUTION 1 @@ -186,6 +198,9 @@ * @name Reliability * The reliability variable from a VEGAPULS C 21 * + * @todo Find and define minimum and maximum reliability measurement range from + * the VegaPuls21. + * * {{ @ref VegaPuls21_Reliability::VegaPuls21_Reliability }} */ /**@{*/ @@ -212,6 +227,9 @@ * The error code variable from a VEGAPULS C 21 * - Significance of error code values is unknown. * + * @todo Find and define minimum and maximum error code range from the + * VegaPuls21. + * * {{ @ref VegaPuls21_ErrorCode::VegaPuls21_ErrorCode }} */ /**@{*/ diff --git a/src/sensors/YosemitechParent.h b/src/sensors/YosemitechParent.h index 5e4d2f293..53e1736ce 100644 --- a/src/sensors/YosemitechParent.h +++ b/src/sensors/YosemitechParent.h @@ -272,4 +272,4 @@ class YosemitechParent : public Sensor { #endif // SRC_SENSORS_YOSEMITECHPARENT_H_ -// cSpell:ignore ysensor +// cSpell:words ysensor diff --git a/src/sensors/YosemitechY4000.h b/src/sensors/YosemitechY4000.h index 3cb4b1692..8edf2e524 100644 --- a/src/sensors/YosemitechY4000.h +++ b/src/sensors/YosemitechY4000.h @@ -109,6 +109,10 @@ * {{ @ref YosemitechY4000_DOmgL::YosemitechY4000_DOmgL }} */ /**@{*/ +/// @brief Minimum dissolved oxygen concentration in milligrams per liter. +#define Y4000_DOMGL_MIN_MGPL 0.0 +/// @brief Maximum dissolved oxygen concentration in milligrams per liter. +#define Y4000_DOMGL_MAX_MGPL 20.0 /// @brief Decimal places in string representation; dissolved oxygen /// concentration should have 2 - resolution is 0.01 mg/L. #define Y4000_DOMGL_RESOLUTION 2 @@ -137,6 +141,10 @@ * {{ @ref YosemitechY4000_Turbidity::YosemitechY4000_Turbidity }} */ /**@{*/ +/// @brief Minimum turbidity in nephelometric turbidity units. +#define Y4000_TURB_MIN_NTU 0.1 +/// @brief Maximum turbidity in nephelometric turbidity units. +#define Y4000_TURB_MAX_NTU 1000.0 /// @brief Decimal places in string representation; turbidity should have 2 - /// resolution is 0.01 NTU. #define Y4000_TURB_RESOLUTION 2 @@ -164,6 +172,10 @@ * {{ @ref YosemitechY4000_Cond::YosemitechY4000_Cond }} */ /**@{*/ +/// @brief Minimum specific conductance in microsiemens per centimeter. +#define Y4000_COND_MIN_USCM 1.0 +/// @brief Maximum specific conductance in microsiemens per centimeter. +#define Y4000_COND_MAX_USCM 200000.0 /// @brief Decimal places in string representation; conductivity should have 1 /// - resolution is 0.1 µS/cm. #define Y4000_COND_RESOLUTION 1 @@ -191,6 +203,10 @@ * {{ @ref YosemitechY4000_pH::YosemitechY4000_pH }} */ /**@{*/ +/// @brief Minimum pH value. +#define Y4000_PH_MIN 2.0 +/// @brief Maximum pH value. +#define Y4000_PH_MAX 12.0 /// @brief Decimal places in string representation; ph should have 2 - /// resolution is 0.01 pH units. #define Y4000_PH_RESOLUTION 2 @@ -217,6 +233,10 @@ * {{ @ref YosemitechY4000_Temp::YosemitechY4000_Temp }} */ /**@{*/ +/// @brief Minimum temperature in degrees Celsius. +#define Y4000_TEMP_MIN_C 0.0 +/// @brief Maximum temperature in degrees Celsius. +#define Y4000_TEMP_MAX_C 50.0 /// @brief Decimal places in string representation; temperature should have 1 - /// resolution is 0.1°C. #define Y4000_TEMP_RESOLUTION 1 @@ -244,6 +264,10 @@ * {{ @ref YosemitechY4000_ORP::YosemitechY4000_ORP }} */ /**@{*/ +/// @brief Minimum oxidation reduction potential in millivolts. +#define Y4000_ORP_MIN_MV -999.0 +/// @brief Maximum oxidation reduction potential in millivolts. +#define Y4000_ORP_MAX_MV 999.0 /// @brief Decimal places in string representation; orp should have 0 - /// resolution is 1 mV. #define Y4000_ORP_RESOLUTION 0 @@ -272,6 +296,10 @@ * {{ @ref YosemitechY4000_Chlorophyll::YosemitechY4000_Chlorophyll }} */ /**@{*/ +/// @brief Minimum chlorophyll concentration in micrograms per liter. +#define Y4000_CHLORO_MIN_UGPL 0.0 +/// @brief Maximum chlorophyll concentration in micrograms per liter. +#define Y4000_CHLORO_MAX_UGPL 400.0 /// @brief Decimal places in string representation; chlorophyll concentration /// should have 1 - resolution is 0.1 µg/L / 0.1 RFU. #define Y4000_CHLORO_RESOLUTION 1 @@ -300,6 +328,10 @@ * {{ @ref YosemitechY4000_BGA::YosemitechY4000_BGA }} */ /**@{*/ +/// @brief Minimum blue green algae concentration in micrograms per liter. +#define Y4000_BGA_MIN_UGPL 0.0 +/// @brief Maximum blue green algae concentration in micrograms per liter. +#define Y4000_BGA_MAX_UGPL 100.0 /// @brief Decimal places in string representation; bga should have 2 - /// resolution is 0.01 µg/L / 0.01 RFU. #define Y4000_BGA_RESOLUTION 2 @@ -646,4 +678,4 @@ class YosemitechY4000_BGA : public Variable { /**@}*/ #endif // SRC_SENSORS_YOSEMITECHY4000_H_ -// cSpell:ignore Y4000Chloro +// cSpell:words Y4000Chloro MGPL USCM UGPL diff --git a/src/sensors/YosemitechY504.h b/src/sensors/YosemitechY504.h index a6c8a81ea..fc5a4b511 100644 --- a/src/sensors/YosemitechY504.h +++ b/src/sensors/YosemitechY504.h @@ -100,6 +100,10 @@ * {{ @ref YosemitechY504_DOpct::YosemitechY504_DOpct }} */ /**@{*/ +/// @brief Minimum dissolved oxygen percent saturation; 0% saturation +#define Y504_DOPCT_MIN_PCT 0 +/// @brief Maximum dissolved oxygen percent saturation; 200% saturation +#define Y504_DOPCT_MAX_PCT 200 /// @brief Decimal places in string representation; dissolved oxygen percent /// should have 1 - resolution is 0.1%. #define Y504_DOPCT_RESOLUTION 1 @@ -128,6 +132,10 @@ * {{ @ref YosemitechY504_Temp::YosemitechY504_Temp }} */ /**@{*/ +/// @brief Minimum temperature; 0°C +#define Y504_TEMP_MIN_C 0 +/// @brief Maximum temperature; 50°C +#define Y504_TEMP_MAX_C 50 /// @brief Decimal places in string representation; temperature should have 1 - /// resolution is 0.1°C. #define Y504_TEMP_RESOLUTION 1 @@ -155,6 +163,10 @@ * {{ @ref YosemitechY504_DOmgL::YosemitechY504_DOmgL }} */ /**@{*/ +/// @brief Minimum dissolved oxygen concentration; 0 mg/L +#define Y504_DOMGL_MIN_MGPL 0 +/// @brief Maximum dissolved oxygen concentration; 20 mg/L +#define Y504_DOMGL_MAX_MGPL 20 /// @brief Decimal places in string representation; dissolved oxygen /// concentration should have 2 - resolution is 0.01 mg/L. #define Y504_DOMGL_RESOLUTION 2 diff --git a/src/sensors/YosemitechY510.h b/src/sensors/YosemitechY510.h index d4e08bd63..3ffbef067 100644 --- a/src/sensors/YosemitechY510.h +++ b/src/sensors/YosemitechY510.h @@ -95,6 +95,10 @@ * {{ @ref YosemitechY510_Turbidity::YosemitechY510_Turbidity }} */ /**@{*/ +/// @brief Minimum turbidity in nephelometric turbidity units. +#define Y510_TURB_MIN_NTU 0.1 +/// @brief Maximum turbidity in nephelometric turbidity units. +#define Y510_TURB_MAX_NTU 1000.0 /// @brief Decimal places in string representation; turbidity should have 2 - /// resolution is 0.01 NTU. #define Y510_TURB_RESOLUTION 2 @@ -122,6 +126,10 @@ * {{ @ref YosemitechY510_Temp::YosemitechY510_Temp }} */ /**@{*/ +/// @brief Minimum temperature in degrees Celsius. +#define Y510_TEMP_MIN_C 0.0 +/// @brief Maximum temperature in degrees Celsius. +#define Y510_TEMP_MAX_C 50.0 /// @brief Decimal places in string representation; temperature should have 1 - /// resolution is 0.1°C. #define Y510_TEMP_RESOLUTION 1 diff --git a/src/sensors/YosemitechY511.h b/src/sensors/YosemitechY511.h index 5adf2dda8..3e1fc3bb0 100644 --- a/src/sensors/YosemitechY511.h +++ b/src/sensors/YosemitechY511.h @@ -109,6 +109,10 @@ * {{ @ref YosemitechY511_Turbidity::YosemitechY511_Turbidity }} */ /**@{*/ +/// @brief Minimum turbidity; 0.1 NTU +#define Y511_TURB_MIN_NTU 0.1 +/// @brief Maximum turbidity; 1000 NTU +#define Y511_TURB_MAX_NTU 1000 /// @brief Decimal places in string representation; turbidity should have 2 - /// resolution is 0.01 NTU. #define Y511_TURB_RESOLUTION 2 @@ -136,6 +140,10 @@ * {{ @ref YosemitechY511_Temp::YosemitechY511_Temp }} */ /**@{*/ +/// @brief Minimum temperature; 0°C +#define Y511_TEMP_MIN_C 0 +/// @brief Maximum temperature; 50°C +#define Y511_TEMP_MAX_C 50 /// @brief Decimal places in string representation; temperature should have 1 - /// resolution is 0.1°C. #define Y511_TEMP_RESOLUTION 1 @@ -280,4 +288,4 @@ class YosemitechY511_Temp : public Variable { /**@}*/ #endif // SRC_SENSORS_YOSEMITECHY511_H_ -// cSpell:ignore Wipered +// cSpell:words Wipered diff --git a/src/sensors/YosemitechY513.h b/src/sensors/YosemitechY513.h index 890178ddb..3c095ba33 100644 --- a/src/sensors/YosemitechY513.h +++ b/src/sensors/YosemitechY513.h @@ -95,6 +95,10 @@ * {{ @ref YosemitechY513_BGA::YosemitechY513_BGA }} */ /**@{*/ +/// @brief Minimum BGA concentration; 0 µg/L +#define Y513_BGA_MIN_UGPL 0 +/// @brief Maximum BGA concentration; 400 µg/L +#define Y513_BGA_MAX_UGPL 400 /// @brief Decimal places in string representation; blue green algae /// concentration should have 1 - resolution is 0.1 µg/L / 0.1 RFU. #define Y513_BGA_RESOLUTION 1 @@ -123,6 +127,10 @@ * {{ @ref YosemitechY513_Temp::YosemitechY513_Temp }} */ /**@{*/ +/// @brief Minimum temperature; 0°C +#define Y513_TEMP_MIN_C 0 +/// @brief Maximum temperature; 50°C +#define Y513_TEMP_MAX_C 50 /// @brief Decimal places in string representation; temperature should have 1 - /// resolution is 0.1°C. #define Y513_TEMP_RESOLUTION 1 @@ -267,3 +275,5 @@ class YosemitechY513_Temp : public Variable { }; /**@}*/ #endif // SRC_SENSORS_YOSEMITECHY513_H_ + +// cSpell:words UGPL diff --git a/src/sensors/YosemitechY514.h b/src/sensors/YosemitechY514.h index d926fc239..b9a4620f0 100644 --- a/src/sensors/YosemitechY514.h +++ b/src/sensors/YosemitechY514.h @@ -97,6 +97,10 @@ * {{ @ref YosemitechY514_Chlorophyll::YosemitechY514_Chlorophyll }} */ /**@{*/ +/// @brief Minimum chlorophyll concentration; 0 µg/L +#define Y514_CHLORO_MIN_UGPL 0 +/// @brief Maximum chlorophyll concentration; 400 µg/L +#define Y514_CHLORO_MAX_UGPL 400 /// @brief Decimal places in string representation; chlorophyll concentration /// should have 1 - resolution is 0.1 µg/L / 0.1 RFU. #define Y514_CHLORO_RESOLUTION 1 @@ -125,6 +129,10 @@ * {{ @ref YosemitechY514_Temp::YosemitechY514_Temp }} */ /**@{*/ +/// @brief Minimum temperature; 0°C +#define Y514_TEMP_MIN_C 0 +/// @brief Maximum temperature; 50°C +#define Y514_TEMP_MAX_C 50 /// @brief Decimal places in string representation; temperature should have 1 - /// resolution is 0.1°C. #define Y514_TEMP_RESOLUTION 1 @@ -271,4 +279,4 @@ class YosemitechY514_Temp : public Variable { /**@}*/ #endif // SRC_SENSORS_YOSEMITECHY514_H_ -// cSpell:ignore Wipered Y514Chloro +// cSpell:words Wipered Y514Chloro UGPL diff --git a/src/sensors/YosemitechY520.h b/src/sensors/YosemitechY520.h index 7fbf90a85..eeae96cef 100644 --- a/src/sensors/YosemitechY520.h +++ b/src/sensors/YosemitechY520.h @@ -96,6 +96,10 @@ * {{ @ref YosemitechY520_Cond::YosemitechY520_Cond }} */ /**@{*/ +/// @brief Minimum conductivity; 1 µS/cm +#define Y520_COND_MIN_USCM 1 +/// @brief Maximum conductivity; 200000 µS/cm (200 mS/cm) +#define Y520_COND_MAX_USCM 200000 /// @brief Decimal places in string representation; conductivity should have 1 /// - resolution is 0.1 µS/cm. #define Y520_COND_RESOLUTION 1 @@ -123,6 +127,10 @@ * {{ @ref YosemitechY520_Temp::YosemitechY520_Temp }} */ /**@{*/ +/// @brief Minimum temperature; 0°C +#define Y520_TEMP_MIN_C 0 +/// @brief Maximum temperature; 50°C +#define Y520_TEMP_MAX_C 50 /// @brief Decimal places in string representation; temperature should have 1 - /// resolution is 0.1°C. #define Y520_TEMP_RESOLUTION 1 diff --git a/src/sensors/YosemitechY532.h b/src/sensors/YosemitechY532.h index a01e42c0b..01f22e5b1 100644 --- a/src/sensors/YosemitechY532.h +++ b/src/sensors/YosemitechY532.h @@ -96,6 +96,10 @@ * {{ @ref YosemitechY532_pH::YosemitechY532_pH }} */ /**@{*/ +/// @brief Minimum pH; 2 pH units +#define Y532_PH_MIN_PH 2 +/// @brief Maximum pH; 12 pH units +#define Y532_PH_MAX_PH 12 /// @brief Decimal places in string representation; pH should have 2 - /// resolution is 0.01 pH units. #define Y532_PH_RESOLUTION 2 @@ -122,6 +126,10 @@ * {{ @ref YosemitechY532_Temp::YosemitechY532_Temp }} */ /**@{*/ +/// @brief Minimum temperature; 0°C +#define Y532_TEMP_MIN_C 0 +/// @brief Maximum temperature; 50°C +#define Y532_TEMP_MAX_C 50 /// @brief Decimal places in string representation; temperature should have 1 - /// resolution is 0.1°C. #define Y532_TEMP_RESOLUTION 1 @@ -149,6 +157,10 @@ * {{ @ref YosemitechY532_Voltage::YosemitechY532_Voltage }} */ /**@{*/ +/// @brief Minimum voltage; -999 mV +#define Y532_VOLTAGE_MIN_MV -999 +/// @brief Maximum voltage; 999 mV +#define Y532_VOLTAGE_MAX_MV 999 /// @brief Decimal places in string representation; voltage should have 0 - /// resolution is 1mV. #define Y532_VOLTAGE_RESOLUTION 0 diff --git a/src/sensors/YosemitechY533.h b/src/sensors/YosemitechY533.h index 6b70ab67e..85f974930 100644 --- a/src/sensors/YosemitechY533.h +++ b/src/sensors/YosemitechY533.h @@ -96,6 +96,10 @@ * {{ @ref YosemitechY533_ORP::YosemitechY533_ORP }} */ /**@{*/ +/// @brief Minimum ORP; -999 mV +#define Y533_ORP_MIN_MV -999 +/// @brief Maximum ORP; 999 mV +#define Y533_ORP_MAX_MV 999 /// @brief Decimal places in string representation; ORP should have 0 - /// resolution is 1 mV units. #define Y533_ORP_RESOLUTION 0 @@ -125,6 +129,10 @@ * {{ @ref YosemitechY533_Temp::YosemitechY533_Temp }} */ /**@{*/ +/// @brief Minimum temperature; 0°C +#define Y533_TEMP_MIN_C 0 +/// @brief Maximum temperature; 50°C +#define Y533_TEMP_MAX_C 50 /// @brief Decimal places in string representation; temperature should have 1 - /// resolution is 0.1°C. #define Y533_TEMP_RESOLUTION 1 diff --git a/src/sensors/YosemitechY551.h b/src/sensors/YosemitechY551.h index affceee40..7f583162a 100644 --- a/src/sensors/YosemitechY551.h +++ b/src/sensors/YosemitechY551.h @@ -99,6 +99,10 @@ * {{ @ref YosemitechY551_COD::YosemitechY551_COD }} */ /**@{*/ +/// @brief Minimum COD; 0.75 mg/L +#define Y551_COD_MIN_MGPL 0.75 +/// @brief Maximum COD; 370 mg/L +#define Y551_COD_MAX_MGPL 370 /// @brief Decimal places in string representation; cod should have 2 - /// resolution is 0.01 mg/L COD. #define Y551_COD_RESOLUTION 2 @@ -126,6 +130,10 @@ * {{ @ref YosemitechY551_Temp::YosemitechY551_Temp }} */ /**@{*/ +/// @brief Minimum temperature; 5°C +#define Y551_TEMP_MIN_C 5 +/// @brief Maximum temperature; 45°C +#define Y551_TEMP_MAX_C 45 /// @brief Decimal places in string representation; temperature should have 2 - /// resolution is 0.01°C. #define Y551_TEMP_RESOLUTION 2 @@ -153,6 +161,10 @@ * {{ @ref YosemitechY551_Turbidity::YosemitechY551_Turbidity }} */ /**@{*/ +/// @brief Minimum turbidity; 0.1 NTU +#define Y551_TURB_MIN_NTU 0.1 +/// @brief Maximum turbidity; 1000 NTU +#define Y551_TURB_MAX_NTU 1000 /// @brief Decimal places in string representation; turbidity should have 2 - /// resolution is 0.01 NTU. #define Y551_TURB_RESOLUTION 2 diff --git a/src/sensors/YosemitechY560.h b/src/sensors/YosemitechY560.h index af73deae8..9d2feb9dc 100644 --- a/src/sensors/YosemitechY560.h +++ b/src/sensors/YosemitechY560.h @@ -97,6 +97,10 @@ * {{ @ref YosemitechY560_NH4_N::YosemitechY560_NH4_N }} */ /**@{*/ +/// @brief Minimum NH4_N concentration; 0 mg/L +#define Y560_NH4_N_MIN_MGPL 0 +/// @brief Maximum NH4_N concentration; 100 mg/L +#define Y560_NH4_N_MAX_MGPL 100 /// @brief Decimal places in string representation; NH4_N should have 1 - /// resolution is 0.1 mg/L. #define Y560_NH4_N_RESOLUTION 1 @@ -124,6 +128,10 @@ * {{ @ref YosemitechY560_Temp::YosemitechY560_Temp }} */ /**@{*/ +/// @brief Minimum temperature; 0°C +#define Y560_TEMP_MIN_C 0 +/// @brief Maximum temperature; 50°C +#define Y560_TEMP_MAX_C 50 /// @brief Decimal places in string representation; temperature should have 1 - /// resolution is 0.1°C. #define Y560_TEMP_RESOLUTION 1 @@ -151,6 +159,10 @@ * {{ @ref YosemitechY560_pH::YosemitechY560_pH }} */ /**@{*/ +/// @brief Minimum pH; 2 pH units +#define Y560_PH_MIN_PH 2 +/// @brief Maximum pH; 12 pH units +#define Y560_PH_MAX_PH 12 /// @brief Decimal places in string representation; pH should have 2 - /// resolution is 0.01 pH units. #define Y560_PH_RESOLUTION 2 diff --git a/src/sensors/YosemitechY700.h b/src/sensors/YosemitechY700.h index 91a294e47..fe0048127 100644 --- a/src/sensors/YosemitechY700.h +++ b/src/sensors/YosemitechY700.h @@ -95,6 +95,10 @@ * {{ @ref YosemitechY700_Pressure::YosemitechY700_Pressure }} */ /**@{*/ +/// @brief Minimum pressure; 0 mmH2O +#define Y700_PRES_MIN_MMH2O 0 +/// @brief Maximum pressure; 100000 mmH2O (100 mH2O, depending on model) +#define Y700_PRES_MAX_MMH2O 100000 /// @brief Decimal places in string representation; Pressure should have 2 /// - resolution is 0.01 mm. #define Y700_PRES_RESOLUTION 2 @@ -122,6 +126,10 @@ * {{ @ref YosemitechY700_Temp::YosemitechY700_Temp }} */ /**@{*/ +/// @brief Minimum temperature; 0°C +#define Y700_TEMP_MIN_C 0 +/// @brief Maximum temperature; 50°C +#define Y700_TEMP_MAX_C 50 /// @brief Decimal places in string representation; temperature should have 1 - /// resolution is 0.1°C. #define Y700_TEMP_RESOLUTION 1 diff --git a/src/sensors/ZebraTechDOpto.h b/src/sensors/ZebraTechDOpto.h index e14bc4118..9dcceb6c8 100644 --- a/src/sensors/ZebraTechDOpto.h +++ b/src/sensors/ZebraTechDOpto.h @@ -109,6 +109,10 @@ * The temperature variable from a ZebraTech D-Opto * - Range is not specified in sensor datasheet * - Accuracy is ± 0.1°C + * - Resolution: 0.01°C + * + * @todo Find and define minimum and maximum temperature measurement range from + * a ZebraTech D-Opto. * * {{ @ref ZebraTechDOpto_Temp::ZebraTechDOpto_Temp }} */ @@ -136,6 +140,10 @@ * The percent saturation variable from a ZebraTech D-Opto * - Range is not specified in sensor datasheet * - Accuracy is 1 % of reading or 0.02PPM, whichever is greater + * - Resolution: 0.01% + * + * @todo Find and define minimum and maximum dissolved oxygen percent saturation + * range from a ZebraTech D-Opto. * * {{ @ref ZebraTechDOpto_DOpct::ZebraTechDOpto_DOpct }} */ @@ -164,6 +172,10 @@ * The DO concentration variable from a ZebraTech D-Opto * - Range is not specified in sensor datasheet * - Accuracy is 1 % of reading or 0.02PPM, whichever is greater + * - Resolution: 0.001 PPM + * + * @todo Find and define minimum and maximum dissolved oxygen concentration + * range from a ZebraTech D-Opto. * * {{ @ref ZebraTechDOpto_DOmgL::ZebraTechDOpto_DOmgL }} */ @@ -358,4 +370,4 @@ class ZebraTechDOpto_DOmgL : public Variable { /**@}*/ #endif // SRC_SENSORS_ZEBRATECHDOPTO_H_ -// cSpell:ignore Pololu +// cSpell:words Pololu From 0356f5e0c7f57fe11c6b54f43097d856b5d9454e Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Fri, 13 Mar 2026 16:44:49 -0400 Subject: [PATCH 528/533] Overwrite instead of append file Signed-off-by: Sara Damiano --- src/sensors/GeoluxHydroCam.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/sensors/GeoluxHydroCam.cpp b/src/sensors/GeoluxHydroCam.cpp index e7ffcbbed..37eea7049 100644 --- a/src/sensors/GeoluxHydroCam.cpp +++ b/src/sensors/GeoluxHydroCam.cpp @@ -213,8 +213,8 @@ bool GeoluxHydroCam::addSingleMeasurementResult() { } // Open the file in write mode - creating a new file if it doesn't exist or - // appending to the end an existing one - if (imgFile.open(filename.c_str(), O_CREAT | O_WRITE | O_AT_END)) { + // overwriting an existing one + if (imgFile.open(filename.c_str(), O_CREAT | O_WRITE | O_TRUNC)) { MS_DBG(F("Created new file:"), filename); } else { MS_DBG(F("Failed to create the image file, aborting!")); From ba2a27a10c6329b0dde5ec9ad5679d91bf899ba7 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Fri, 13 Mar 2026 16:49:25 -0400 Subject: [PATCH 529/533] Comment and static assertion Signed-off-by: Sara Damiano --- .coderabbit.yaml | 3 ++- src/ClockSupport.h | 3 ++- src/ModSensorConfig.h | 3 +++ src/sensors/AlphasenseCO2.h | 2 ++ src/sensors/AtlasParent.h | 4 +--- 5 files changed, 10 insertions(+), 5 deletions(-) diff --git a/.coderabbit.yaml b/.coderabbit.yaml index d6892a128..e6350f5e6 100644 --- a/.coderabbit.yaml +++ b/.coderabbit.yaml @@ -36,13 +36,13 @@ reviews: - path: '**/*.h' instructions: >- Review the C++ code, point out issues relative to principles of clean code, expressiveness, and performance. - Don't suggest making getter functions const. Since this is an Arduino project, never suggest using the standard library (std::). For memory savings, prefer defines to const variables, and prefer using the F() macro for string literals longer than a single character. Defines should be in the headers. Unique functions, defines, and parameters must be documented with Doxygen comments in the header files. Override functions don't need Doxygen comments in the header files, unless they have unique parameters or behavior that needs to be documented. Files should be formatted according to the .clang-format file in the repo. + Don't suggest making getter functions const. - path: '**/*.cpp' instructions: >- Review the C++ code, point out issues relative to principles of clean code, expressiveness, and performance. @@ -51,6 +51,7 @@ reviews: Defines should be in the headers. Doxygen documentation should be in the header files. Files should be formatted according to the .clang-format file in the repo. + Don't suggest making getter functions const. tools: shellcheck: enabled: true diff --git a/src/ClockSupport.h b/src/ClockSupport.h index 3723ba36d..a9e16d4fc 100644 --- a/src/ClockSupport.h +++ b/src/ClockSupport.h @@ -658,7 +658,8 @@ class loggerClock { static epochStart _core_epoch; /** - * @brief The timezone used by the processor core's internal time.h library. + * @brief The timezone used by the processor core's internal time.h library, + * in seconds from UTC. */ static int32_t _core_tz; diff --git a/src/ModSensorConfig.h b/src/ModSensorConfig.h index a3817797a..b1cc37b2c 100644 --- a/src/ModSensorConfig.h +++ b/src/ModSensorConfig.h @@ -390,6 +390,9 @@ static_assert(MAX_NUMBER_SENDERS >= 0 && MAX_NUMBER_SENDERS <= 16, */ // #define MS_LOG_DATA_BUFFER_SIZE 1024 #endif +#if !defined(MS_LOG_DATA_BUFFER_SIZE) +#error The log data buffer size must be defined! +#endif // MS_LOG_DATA_BUFFER_SIZE // Static assert to validate log buffer size is reasonable static_assert(MS_LOG_DATA_BUFFER_SIZE >= 64 && MS_LOG_DATA_BUFFER_SIZE <= 16384, "MS_LOG_DATA_BUFFER_SIZE must be between 64 and 16384 bytes"); diff --git a/src/sensors/AlphasenseCO2.h b/src/sensors/AlphasenseCO2.h index 29afade6c..2153c18e4 100644 --- a/src/sensors/AlphasenseCO2.h +++ b/src/sensors/AlphasenseCO2.h @@ -122,6 +122,8 @@ static_assert(ALPHASENSE_CO2_SENSE_RESISTOR_OHM > 0, */ #define ALPHASENSE_CO2_MFG_SCALE 312.5f #endif +static_assert(ALPHASENSE_CO2_MFG_SCALE > 0, + "Manufacturer scale factor must be positive"); #if !defined(ALPHASENSE_CO2_MFG_OFFSET) || defined(DOXYGEN) /** * @brief Manufacturer offset for CO2 conversion (ppm) diff --git a/src/sensors/AtlasParent.h b/src/sensors/AtlasParent.h index ed17a7d62..4349c1b4e 100644 --- a/src/sensors/AtlasParent.h +++ b/src/sensors/AtlasParent.h @@ -120,8 +120,6 @@ * @brief A parent class for Atlas EZO circuits and sensors * * This contains the main I2C functionality for all Atlas EZO circuits. - * - * @ingroup atlas_group */ class AtlasParent : public Sensor { public: @@ -255,5 +253,5 @@ class AtlasParent : public Sensor { */ bool waitForProcessing(uint32_t timeout = 1000L); }; - +/**@}*/ #endif // SRC_SENSORS_ATLASPARENT_H_ From 83f5972effe39b991cfe7893075360d4bd2ac836 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Fri, 13 Mar 2026 17:04:59 -0400 Subject: [PATCH 530/533] Remove static casts Signed-off-by: Sara Damiano --- src/LoggerModem.h | 16 +++++----- src/sensors/ANBpH.h | 40 +++++++++--------------- src/sensors/AOSongAM2315.h | 10 +++--- src/sensors/AOSongDHT.h | 13 +++----- src/sensors/AlphasenseCO2.h | 12 +++----- src/sensors/AnalogElecConductivity.h | 5 ++- src/sensors/ApogeeSQ212.h | 6 ++-- src/sensors/AtlasScientificCO2.h | 6 ++-- src/sensors/AtlasScientificDO.h | 6 ++-- src/sensors/AtlasScientificEC.h | 18 +++++------ src/sensors/AtlasScientificORP.h | 3 +- src/sensors/AtlasScientificRTD.h | 3 +- src/sensors/AtlasScientificpH.h | 5 ++- src/sensors/BoschBME280.h | 24 ++++++--------- src/sensors/BoschBMP3xx.h | 17 +++++----- src/sensors/CampbellClariVUE10.h | 17 +++++----- src/sensors/CampbellOBS3.h | 8 ++--- src/sensors/CampbellRainVUE10.h | 22 ++++++------- src/sensors/Decagon5TM.h | 13 +++----- src/sensors/DecagonCTD.h | 13 +++----- src/sensors/DecagonES2.h | 10 +++--- src/sensors/EverlightALSPT19.h | 22 ++++++------- src/sensors/FreescaleMPL115A2.h | 10 +++--- src/sensors/GeoluxHydroCam.h | 10 +++--- src/sensors/GroPointGPLP8.h | 6 ++-- src/sensors/InSituRDO.h | 29 ++++++++---------- src/sensors/InSituTrollSdi12a.h | 13 +++----- src/sensors/KellerAcculevel.h | 17 +++++----- src/sensors/KellerNanolevel.h | 17 +++++----- src/sensors/MaxBotixSonar.h | 3 +- src/sensors/MaximDS18.h | 3 +- src/sensors/MaximDS3231.h | 3 +- src/sensors/MeaSpecMS5803.h | 10 +++--- src/sensors/MeterHydros21.h | 13 +++----- src/sensors/MeterTeros11.h | 12 +++----- src/sensors/PaleoTerraRedox.h | 3 +- src/sensors/ProcessorAnalog.h | 7 ++--- src/sensors/ProcessorStats.h | 24 ++++++--------- src/sensors/RainCounterI2C.h | 6 ++-- src/sensors/SensirionSHT4x.h | 10 +++--- src/sensors/TEConnectivityMS5837.h | 20 +++++------- src/sensors/TIADS1x15.h | 3 +- src/sensors/TIINA219.h | 22 ++++++------- src/sensors/TallyCounterI2C.h | 3 +- src/sensors/TurnerCyclops.h | 46 ++++++++++------------------ src/sensors/TurnerTurbidityPlus.h | 12 +++----- src/sensors/VegaPuls21.h | 32 ++++++++----------- src/sensors/YosemitechY4000.h | 26 ++++++---------- src/sensors/YosemitechY504.h | 9 ++---- src/sensors/YosemitechY510.h | 6 ++-- src/sensors/YosemitechY511.h | 6 ++-- src/sensors/YosemitechY513.h | 8 ++--- src/sensors/YosemitechY514.h | 6 ++-- src/sensors/YosemitechY520.h | 6 ++-- src/sensors/YosemitechY532.h | 11 +++---- src/sensors/YosemitechY533.h | 8 ++--- src/sensors/YosemitechY551.h | 11 +++---- src/sensors/YosemitechY560.h | 11 +++---- src/sensors/YosemitechY700.h | 6 ++-- src/sensors/ZebraTechDOpto.h | 9 ++---- 60 files changed, 287 insertions(+), 459 deletions(-) diff --git a/src/LoggerModem.h b/src/LoggerModem.h index d8cb8e4f9..affeb0587 100644 --- a/src/LoggerModem.h +++ b/src/LoggerModem.h @@ -1247,8 +1247,7 @@ class Modem_RSSI : public Variable { */ explicit Modem_RSSI(loggerModem* parentModem, const char* uuid = "", const char* varCode = MODEM_RSSI_DEFAULT_CODE) - : Variable(&parentModem->getModemRSSI, - static_cast(MODEM_RSSI_RESOLUTION), + : Variable(&parentModem->getModemRSSI, MODEM_RSSI_RESOLUTION, &*MODEM_RSSI_VAR_NAME, &*MODEM_RSSI_UNIT_NAME, varCode, uuid) { parentModem->enableMetadataPolling(MODEM_RSSI_ENABLE_BITMASK); @@ -1283,7 +1282,7 @@ class Modem_SignalPercent : public Variable { loggerModem* parentModem, const char* uuid = "", const char* varCode = MODEM_PERCENT_SIGNAL_DEFAULT_CODE) : Variable(&parentModem->getModemSignalPercent, - static_cast(MODEM_PERCENT_SIGNAL_RESOLUTION), + MODEM_PERCENT_SIGNAL_RESOLUTION, &*MODEM_PERCENT_SIGNAL_VAR_NAME, &*MODEM_PERCENT_SIGNAL_UNIT_NAME, varCode, uuid) { parentModem->enableMetadataPolling(MODEM_PERCENT_SIGNAL_ENABLE_BITMASK); @@ -1321,7 +1320,7 @@ class Modem_BatteryState : public Variable { loggerModem* parentModem, const char* uuid = "", const char* varCode = MODEM_BATTERY_STATE_DEFAULT_CODE) : Variable(&parentModem->getModemBatteryChargeState, - static_cast(MODEM_BATTERY_STATE_RESOLUTION), + MODEM_BATTERY_STATE_RESOLUTION, &*MODEM_BATTERY_STATE_VAR_NAME, &*MODEM_BATTERY_STATE_UNIT_NAME, varCode, uuid) { parentModem->enableMetadataPolling(MODEM_BATTERY_STATE_ENABLE_BITMASK); @@ -1359,7 +1358,7 @@ class Modem_BatteryPercent : public Variable { loggerModem* parentModem, const char* uuid = "", const char* varCode = MODEM_BATTERY_PERCENT_DEFAULT_CODE) : Variable(&parentModem->getModemBatteryChargePercent, - static_cast(MODEM_BATTERY_PERCENT_RESOLUTION), + MODEM_BATTERY_PERCENT_RESOLUTION, &*MODEM_BATTERY_PERCENT_VAR_NAME, &*MODEM_BATTERY_PERCENT_UNIT_NAME, varCode, uuid) { parentModem->enableMetadataPolling( @@ -1398,7 +1397,7 @@ class Modem_BatteryVoltage : public Variable { loggerModem* parentModem, const char* uuid = "", const char* varCode = MODEM_BATTERY_VOLTAGE_DEFAULT_CODE) : Variable(&parentModem->getModemBatteryVoltage, - static_cast(MODEM_BATTERY_VOLTAGE_RESOLUTION), + MODEM_BATTERY_VOLTAGE_RESOLUTION, &*MODEM_BATTERY_VOLTAGE_VAR_NAME, &*MODEM_BATTERY_VOLTAGE_UNIT_NAME, varCode, uuid) { parentModem->enableMetadataPolling( @@ -1436,9 +1435,8 @@ class Modem_Temp : public Variable { explicit Modem_Temp(loggerModem* parentModem, const char* uuid = "", const char* varCode = MODEM_TEMPERATURE_DEFAULT_CODE) : Variable(&parentModem->getModemTemperature, - static_cast(MODEM_TEMPERATURE_RESOLUTION), - &*MODEM_TEMPERATURE_VAR_NAME, &*MODEM_TEMPERATURE_UNIT_NAME, - varCode, uuid) { + MODEM_TEMPERATURE_RESOLUTION, &*MODEM_TEMPERATURE_VAR_NAME, + &*MODEM_TEMPERATURE_UNIT_NAME, varCode, uuid) { parentModem->enableMetadataPolling(MODEM_TEMPERATURE_ENABLE_BITMASK); } /** diff --git a/src/sensors/ANBpH.h b/src/sensors/ANBpH.h index 76ad45277..941f0c067 100644 --- a/src/sensors/ANBpH.h +++ b/src/sensors/ANBpH.h @@ -748,8 +748,7 @@ class ANBpH_pH : public Variable { */ explicit ANBpH_pH(ANBpH* parentSense, const char* uuid = "", const char* varCode = ANB_PH_PH_DEFAULT_CODE) - : Variable(parentSense, static_cast(ANB_PH_PH_VAR_NUM), - static_cast(ANB_PH_PH_RESOLUTION), + : Variable(parentSense, ANB_PH_PH_VAR_NUM, ANB_PH_PH_RESOLUTION, ANB_PH_PH_VAR_NAME, ANB_PH_PH_UNIT_NAME, varCode, uuid) {} /** * @brief Destroy the ANBpH_pH object - no action needed. @@ -777,8 +776,7 @@ class ANBpH_Temp : public Variable { */ explicit ANBpH_Temp(ANBpH* parentSense, const char* uuid = "", const char* varCode = ANB_PH_TEMP_DEFAULT_CODE) - : Variable(parentSense, static_cast(ANB_PH_TEMP_VAR_NUM), - static_cast(ANB_PH_TEMP_RESOLUTION), + : Variable(parentSense, ANB_PH_TEMP_VAR_NUM, ANB_PH_TEMP_RESOLUTION, ANB_PH_TEMP_VAR_NAME, ANB_PH_TEMP_UNIT_NAME, varCode, uuid) { } /** @@ -807,10 +805,9 @@ class ANBpH_Salinity : public Variable { */ explicit ANBpH_Salinity(ANBpH* parentSense, const char* uuid = "", const char* varCode = ANB_PH_SALINITY_DEFAULT_CODE) - : Variable(parentSense, static_cast(ANB_PH_SALINITY_VAR_NUM), - static_cast(ANB_PH_SALINITY_RESOLUTION), - ANB_PH_SALINITY_VAR_NAME, ANB_PH_SALINITY_UNIT_NAME, varCode, - uuid) {} + : Variable(parentSense, ANB_PH_SALINITY_VAR_NUM, + ANB_PH_SALINITY_RESOLUTION, ANB_PH_SALINITY_VAR_NAME, + ANB_PH_SALINITY_UNIT_NAME, varCode, uuid) {} /** * @brief Destroy the ANBpH_Salinity() object - no action * needed. @@ -839,8 +836,7 @@ class ANBpH_SpCond : public Variable { */ explicit ANBpH_SpCond(ANBpH* parentSense, const char* uuid = "", const char* varCode = ANB_PH_SPCOND_DEFAULT_CODE) - : Variable(parentSense, static_cast(ANB_PH_SPCOND_VAR_NUM), - static_cast(ANB_PH_SPCOND_RESOLUTION), + : Variable(parentSense, ANB_PH_SPCOND_VAR_NUM, ANB_PH_SPCOND_RESOLUTION, ANB_PH_SPCOND_VAR_NAME, ANB_PH_SPCOND_UNIT_NAME, varCode, uuid) {} /** @@ -869,8 +865,7 @@ class ANBpH_EC : public Variable { */ explicit ANBpH_EC(ANBpH* parentSense, const char* uuid = "", const char* varCode = ANB_PH_EC_DEFAULT_CODE) - : Variable(parentSense, static_cast(ANB_PH_EC_VAR_NUM), - static_cast(ANB_PH_EC_RESOLUTION), + : Variable(parentSense, ANB_PH_EC_VAR_NUM, ANB_PH_EC_RESOLUTION, ANB_PH_EC_VAR_NAME, ANB_PH_EC_UNIT_NAME, varCode, uuid) {} /** * @brief Destroy the ANBpH_EC object - no action needed. @@ -901,11 +896,9 @@ class ANBpH_HealthCode : public Variable { explicit ANBpH_HealthCode( ANBpH* parentSense, const char* uuid = "", const char* varCode = ANB_PH_HEALTH_CODE_DEFAULT_CODE) - : Variable(parentSense, - static_cast(ANB_PH_HEALTH_CODE_VAR_NUM), - static_cast(ANB_PH_HEALTH_CODE_RESOLUTION), - ANB_PH_HEALTH_CODE_VAR_NAME, ANB_PH_HEALTH_CODE_UNIT_NAME, - varCode, uuid) {} + : Variable(parentSense, ANB_PH_HEALTH_CODE_VAR_NUM, + ANB_PH_HEALTH_CODE_RESOLUTION, ANB_PH_HEALTH_CODE_VAR_NAME, + ANB_PH_HEALTH_CODE_UNIT_NAME, varCode, uuid) {} /** * @brief Destroy the ANBpH_HealthCode object - no action * needed. @@ -936,9 +929,8 @@ class ANBpH_DiagnosticCode : public Variable { explicit ANBpH_DiagnosticCode( ANBpH* parentSense, const char* uuid = "", const char* varCode = ANB_PH_DIAGNOSTIC_CODE_DEFAULT_CODE) - : Variable(parentSense, - static_cast(ANB_PH_DIAGNOSTIC_CODE_VAR_NUM), - static_cast(ANB_PH_DIAGNOSTIC_CODE_RESOLUTION), + : Variable(parentSense, ANB_PH_DIAGNOSTIC_CODE_VAR_NUM, + ANB_PH_DIAGNOSTIC_CODE_RESOLUTION, ANB_PH_DIAGNOSTIC_CODE_VAR_NAME, ANB_PH_DIAGNOSTIC_CODE_UNIT_NAME, varCode, uuid) {} /** @@ -971,11 +963,9 @@ class ANBpH_StatusCode : public Variable { explicit ANBpH_StatusCode( ANBpH* parentSense, const char* uuid = "", const char* varCode = ANB_PH_STATUS_CODE_DEFAULT_CODE) - : Variable(parentSense, - static_cast(ANB_PH_STATUS_CODE_VAR_NUM), - static_cast(ANB_PH_STATUS_CODE_RESOLUTION), - ANB_PH_STATUS_CODE_VAR_NAME, ANB_PH_STATUS_CODE_UNIT_NAME, - varCode, uuid) {} + : Variable(parentSense, ANB_PH_STATUS_CODE_VAR_NUM, + ANB_PH_STATUS_CODE_RESOLUTION, ANB_PH_STATUS_CODE_VAR_NAME, + ANB_PH_STATUS_CODE_UNIT_NAME, varCode, uuid) {} /** * @brief Destroy the ANBpH_StatusCode object - no action * needed. diff --git a/src/sensors/AOSongAM2315.h b/src/sensors/AOSongAM2315.h index a0d603993..dbaed603d 100644 --- a/src/sensors/AOSongAM2315.h +++ b/src/sensors/AOSongAM2315.h @@ -286,10 +286,9 @@ class AOSongAM2315_Humidity : public Variable { explicit AOSongAM2315_Humidity( AOSongAM2315* parentSense, const char* uuid = "", const char* varCode = AM2315_HUMIDITY_DEFAULT_CODE) - : Variable(parentSense, static_cast(AM2315_HUMIDITY_VAR_NUM), - static_cast(AM2315_HUMIDITY_RESOLUTION), - AM2315_HUMIDITY_VAR_NAME, AM2315_HUMIDITY_UNIT_NAME, varCode, - uuid) {} + : Variable(parentSense, AM2315_HUMIDITY_VAR_NUM, + AM2315_HUMIDITY_RESOLUTION, AM2315_HUMIDITY_VAR_NAME, + AM2315_HUMIDITY_UNIT_NAME, varCode, uuid) {} /** * @brief Destroy the AOSongAM2315_Humidity object - no action needed. */ @@ -318,8 +317,7 @@ class AOSongAM2315_Temp : public Variable { */ explicit AOSongAM2315_Temp(AOSongAM2315* parentSense, const char* uuid = "", const char* varCode = AM2315_TEMP_DEFAULT_CODE) - : Variable(parentSense, static_cast(AM2315_TEMP_VAR_NUM), - static_cast(AM2315_TEMP_RESOLUTION), + : Variable(parentSense, AM2315_TEMP_VAR_NUM, AM2315_TEMP_RESOLUTION, AM2315_TEMP_VAR_NAME, AM2315_TEMP_UNIT_NAME, varCode, uuid) { } /** diff --git a/src/sensors/AOSongDHT.h b/src/sensors/AOSongDHT.h index bfd38a559..adb20080c 100644 --- a/src/sensors/AOSongDHT.h +++ b/src/sensors/AOSongDHT.h @@ -312,8 +312,7 @@ class AOSongDHT_Humidity : public Variable { */ explicit AOSongDHT_Humidity(AOSongDHT* parentSense, const char* uuid = "", const char* varCode = DHT_HUMIDITY_DEFAULT_CODE) - : Variable(parentSense, static_cast(DHT_HUMIDITY_VAR_NUM), - static_cast(DHT_HUMIDITY_RESOLUTION), + : Variable(parentSense, DHT_HUMIDITY_VAR_NUM, DHT_HUMIDITY_RESOLUTION, DHT_HUMIDITY_VAR_NAME, DHT_HUMIDITY_UNIT_NAME, varCode, uuid) {} /** @@ -345,9 +344,8 @@ class AOSongDHT_Temp : public Variable { */ explicit AOSongDHT_Temp(AOSongDHT* parentSense, const char* uuid = "", const char* varCode = DHT_TEMP_DEFAULT_CODE) - : Variable(parentSense, static_cast(DHT_TEMP_VAR_NUM), - static_cast(DHT_TEMP_RESOLUTION), DHT_TEMP_VAR_NAME, - DHT_TEMP_UNIT_NAME, varCode, uuid) {} + : Variable(parentSense, DHT_TEMP_VAR_NUM, DHT_TEMP_RESOLUTION, + DHT_TEMP_VAR_NAME, DHT_TEMP_UNIT_NAME, varCode, uuid) {} /** * @brief Destroy the AOSongDHT_Temp object - no action needed. */ @@ -377,9 +375,8 @@ class AOSongDHT_HI : public Variable { */ explicit AOSongDHT_HI(AOSongDHT* parentSense, const char* uuid = "", const char* varCode = DHT_HI_DEFAULT_CODE) - : Variable(parentSense, static_cast(DHT_HI_VAR_NUM), - static_cast(DHT_HI_RESOLUTION), DHT_HI_VAR_NAME, - DHT_HI_UNIT_NAME, varCode, uuid) {} + : Variable(parentSense, DHT_HI_VAR_NUM, DHT_HI_RESOLUTION, + DHT_HI_VAR_NAME, DHT_HI_UNIT_NAME, varCode, uuid) {} /** * @brief Destroy the AOSongDHT_HI object - no action needed. */ diff --git a/src/sensors/AlphasenseCO2.h b/src/sensors/AlphasenseCO2.h index 2153c18e4..93ee307f8 100644 --- a/src/sensors/AlphasenseCO2.h +++ b/src/sensors/AlphasenseCO2.h @@ -372,10 +372,9 @@ class AlphasenseCO2_CO2 : public Variable { explicit AlphasenseCO2_CO2( AlphasenseCO2* parentSense, const char* uuid = "", const char* varCode = ALPHASENSE_CO2_DEFAULT_CODE) - : Variable(parentSense, static_cast(ALPHASENSE_CO2_VAR_NUM), - static_cast(ALPHASENSE_CO2_RESOLUTION), - ALPHASENSE_CO2_VAR_NAME, ALPHASENSE_CO2_UNIT_NAME, varCode, - uuid) {} + : Variable(parentSense, ALPHASENSE_CO2_VAR_NUM, + ALPHASENSE_CO2_RESOLUTION, ALPHASENSE_CO2_VAR_NAME, + ALPHASENSE_CO2_UNIT_NAME, varCode, uuid) {} /** * @brief Destroy the AlphasenseCO2_CO2 object - no action needed. */ @@ -405,9 +404,8 @@ class AlphasenseCO2_Voltage : public Variable { explicit AlphasenseCO2_Voltage( AlphasenseCO2* parentSense, const char* uuid = "", const char* varCode = ALPHASENSE_CO2_VOLTAGE_DEFAULT_CODE) - : Variable(parentSense, - static_cast(ALPHASENSE_CO2_VOLTAGE_VAR_NUM), - static_cast(ALPHASENSE_CO2_VOLTAGE_RESOLUTION), + : Variable(parentSense, ALPHASENSE_CO2_VOLTAGE_VAR_NUM, + ALPHASENSE_CO2_VOLTAGE_RESOLUTION, ALPHASENSE_CO2_VOLTAGE_VAR_NAME, ALPHASENSE_CO2_VOLTAGE_UNIT_NAME, varCode, uuid) {} /** diff --git a/src/sensors/AnalogElecConductivity.h b/src/sensors/AnalogElecConductivity.h index 73a7b059f..62715ceb1 100644 --- a/src/sensors/AnalogElecConductivity.h +++ b/src/sensors/AnalogElecConductivity.h @@ -416,9 +416,8 @@ class AnalogElecConductivity_EC : public Variable { AnalogElecConductivity_EC( AnalogElecConductivity* parentSense, const char* uuid = "", const char* varCode = ANALOGELECCONDUCTIVITY_EC_DEFAULT_CODE) - : Variable(parentSense, - static_cast(ANALOGELECCONDUCTIVITY_EC_VAR_NUM), - static_cast(ANALOGELECCONDUCTIVITY_EC_RESOLUTION), + : Variable(parentSense, ANALOGELECCONDUCTIVITY_EC_VAR_NUM, + ANALOGELECCONDUCTIVITY_EC_RESOLUTION, ANALOGELECCONDUCTIVITY_EC_VAR_NAME, ANALOGELECCONDUCTIVITY_EC_UNIT_NAME, varCode, uuid) {} diff --git a/src/sensors/ApogeeSQ212.h b/src/sensors/ApogeeSQ212.h index 5cef06b43..f3bd9046b 100644 --- a/src/sensors/ApogeeSQ212.h +++ b/src/sensors/ApogeeSQ212.h @@ -340,8 +340,7 @@ class ApogeeSQ212_PAR : public Variable { */ explicit ApogeeSQ212_PAR(ApogeeSQ212* parentSense, const char* uuid = "", const char* varCode = SQ212_PAR_DEFAULT_CODE) - : Variable(parentSense, static_cast(SQ212_PAR_VAR_NUM), - static_cast(SQ212_PAR_RESOLUTION), + : Variable(parentSense, SQ212_PAR_VAR_NUM, SQ212_PAR_RESOLUTION, SQ212_PAR_VAR_NAME, SQ212_PAR_UNIT_NAME, varCode, uuid) {} /** * @brief Destroy the ApogeeSQ212_PAR object - no action needed. @@ -374,8 +373,7 @@ class ApogeeSQ212_Voltage : public Variable { explicit ApogeeSQ212_Voltage( ApogeeSQ212* parentSense, const char* uuid = "", const char* varCode = SQ212_VOLTAGE_DEFAULT_CODE) - : Variable(parentSense, static_cast(SQ212_VOLTAGE_VAR_NUM), - static_cast(SQ212_VOLTAGE_RESOLUTION), + : Variable(parentSense, SQ212_VOLTAGE_VAR_NUM, SQ212_VOLTAGE_RESOLUTION, SQ212_VOLTAGE_VAR_NAME, SQ212_VOLTAGE_UNIT_NAME, varCode, uuid) {} /** diff --git a/src/sensors/AtlasScientificCO2.h b/src/sensors/AtlasScientificCO2.h index 4d7709243..2b33bd5de 100644 --- a/src/sensors/AtlasScientificCO2.h +++ b/src/sensors/AtlasScientificCO2.h @@ -279,8 +279,7 @@ class AtlasScientificCO2_CO2 : public Variable { explicit AtlasScientificCO2_CO2( AtlasScientificCO2* parentSense, const char* uuid = "", const char* varCode = ATLAS_CO2_DEFAULT_CODE) - : Variable(parentSense, static_cast(ATLAS_CO2_VAR_NUM), - static_cast(ATLAS_CO2_RESOLUTION), + : Variable(parentSense, ATLAS_CO2_VAR_NUM, ATLAS_CO2_RESOLUTION, ATLAS_CO2_VAR_NAME, ATLAS_CO2_UNIT_NAME, varCode, uuid) {} /** * @brief Destroy the AtlasScientificCO2_CO2 object - no action needed. @@ -312,8 +311,7 @@ class AtlasScientificCO2_Temp : public Variable { explicit AtlasScientificCO2_Temp( AtlasScientificCO2* parentSense, const char* uuid = "", const char* varCode = ATLAS_CO2TEMP_DEFAULT_CODE) - : Variable(parentSense, static_cast(ATLAS_CO2TEMP_VAR_NUM), - static_cast(ATLAS_CO2TEMP_RESOLUTION), + : Variable(parentSense, ATLAS_CO2TEMP_VAR_NUM, ATLAS_CO2TEMP_RESOLUTION, ATLAS_CO2TEMP_VAR_NAME, ATLAS_CO2TEMP_UNIT_NAME, varCode, uuid) {} /** diff --git a/src/sensors/AtlasScientificDO.h b/src/sensors/AtlasScientificDO.h index 4bbebdfda..ca61d7fdb 100644 --- a/src/sensors/AtlasScientificDO.h +++ b/src/sensors/AtlasScientificDO.h @@ -288,8 +288,7 @@ class AtlasScientificDO_DOmgL : public Variable { explicit AtlasScientificDO_DOmgL( AtlasScientificDO* parentSense, const char* uuid = "", const char* varCode = ATLAS_DOMGL_DEFAULT_CODE) - : Variable(parentSense, static_cast(ATLAS_DOMGL_VAR_NUM), - static_cast(ATLAS_DOMGL_RESOLUTION), + : Variable(parentSense, ATLAS_DOMGL_VAR_NUM, ATLAS_DOMGL_RESOLUTION, ATLAS_DOMGL_VAR_NAME, ATLAS_DOMGL_UNIT_NAME, varCode, uuid) { } /** @@ -322,8 +321,7 @@ class AtlasScientificDO_DOpct : public Variable { explicit AtlasScientificDO_DOpct( AtlasScientificDO* parentSense, const char* uuid = "", const char* varCode = ATLAS_DOPCT_DEFAULT_CODE) - : Variable(parentSense, static_cast(ATLAS_DOPCT_VAR_NUM), - static_cast(ATLAS_DOPCT_RESOLUTION), + : Variable(parentSense, ATLAS_DOPCT_VAR_NUM, ATLAS_DOPCT_RESOLUTION, ATLAS_DOPCT_VAR_NAME, ATLAS_DOPCT_UNIT_NAME, varCode, uuid) { } /** diff --git a/src/sensors/AtlasScientificEC.h b/src/sensors/AtlasScientificEC.h index 5ba949fed..0bccd09cc 100644 --- a/src/sensors/AtlasScientificEC.h +++ b/src/sensors/AtlasScientificEC.h @@ -359,8 +359,7 @@ class AtlasScientificEC_Cond : public Variable { explicit AtlasScientificEC_Cond( AtlasScientificEC* parentSense, const char* uuid = "", const char* varCode = ATLAS_COND_DEFAULT_CODE) - : Variable(parentSense, static_cast(ATLAS_COND_VAR_NUM), - static_cast(ATLAS_COND_RESOLUTION), + : Variable(parentSense, ATLAS_COND_VAR_NUM, ATLAS_COND_RESOLUTION, ATLAS_COND_VAR_NAME, ATLAS_COND_UNIT_NAME, varCode, uuid) {} /** * @brief Destroy the AtlasScientificEC_Cond object - no action needed. @@ -392,8 +391,7 @@ class AtlasScientificEC_TDS : public Variable { explicit AtlasScientificEC_TDS(AtlasScientificEC* parentSense, const char* uuid = "", const char* varCode = ATLAS_TDS_DEFAULT_CODE) - : Variable(parentSense, static_cast(ATLAS_TDS_VAR_NUM), - static_cast(ATLAS_TDS_RESOLUTION), + : Variable(parentSense, ATLAS_TDS_VAR_NUM, ATLAS_TDS_RESOLUTION, ATLAS_TDS_VAR_NAME, ATLAS_TDS_UNIT_NAME, varCode, uuid) {} /** * @brief Destroy the AtlasScientificEC_TDS object - no action needed. @@ -425,10 +423,9 @@ class AtlasScientificEC_Salinity : public Variable { explicit AtlasScientificEC_Salinity( AtlasScientificEC* parentSense, const char* uuid = "", const char* varCode = ATLAS_SALINITY_DEFAULT_CODE) - : Variable(parentSense, static_cast(ATLAS_SALINITY_VAR_NUM), - static_cast(ATLAS_SALINITY_RESOLUTION), - ATLAS_SALINITY_VAR_NAME, ATLAS_SALINITY_UNIT_NAME, varCode, - uuid) {} + : Variable(parentSense, ATLAS_SALINITY_VAR_NUM, + ATLAS_SALINITY_RESOLUTION, ATLAS_SALINITY_VAR_NAME, + ATLAS_SALINITY_UNIT_NAME, varCode, uuid) {} /** * @brief Destroy the AtlasScientificEC_Salinity() object - no action * needed. @@ -460,9 +457,8 @@ class AtlasScientificEC_SpecificGravity : public Variable { explicit AtlasScientificEC_SpecificGravity( AtlasScientificEC* parentSense, const char* uuid = "", const char* varCode = ATLAS_SG_DEFAULT_CODE) - : Variable(parentSense, static_cast(ATLAS_SG_VAR_NUM), - static_cast(ATLAS_SG_RESOLUTION), ATLAS_SG_VAR_NAME, - ATLAS_SG_UNIT_NAME, varCode, uuid) {} + : Variable(parentSense, ATLAS_SG_VAR_NUM, ATLAS_SG_RESOLUTION, + ATLAS_SG_VAR_NAME, ATLAS_SG_UNIT_NAME, varCode, uuid) {} /** * @brief Destroy the AtlasScientificEC_SpecificGravity() object - no action * needed. diff --git a/src/sensors/AtlasScientificORP.h b/src/sensors/AtlasScientificORP.h index 0d5ae1508..c33933625 100644 --- a/src/sensors/AtlasScientificORP.h +++ b/src/sensors/AtlasScientificORP.h @@ -231,8 +231,7 @@ class AtlasScientificORP_Potential : public Variable { explicit AtlasScientificORP_Potential( AtlasScientificORP* parentSense, const char* uuid = "", const char* varCode = ATLAS_ORP_DEFAULT_CODE) - : Variable(parentSense, static_cast(ATLAS_ORP_VAR_NUM), - static_cast(ATLAS_ORP_RESOLUTION), + : Variable(parentSense, ATLAS_ORP_VAR_NUM, ATLAS_ORP_RESOLUTION, ATLAS_ORP_VAR_NAME, ATLAS_ORP_UNIT_NAME, varCode, uuid) {} /** * @brief Destroy the AtlasScientificORP_Potential() object - no action diff --git a/src/sensors/AtlasScientificRTD.h b/src/sensors/AtlasScientificRTD.h index bd7e65497..770cb421a 100644 --- a/src/sensors/AtlasScientificRTD.h +++ b/src/sensors/AtlasScientificRTD.h @@ -238,8 +238,7 @@ class AtlasScientificRTD_Temp : public Variable { explicit AtlasScientificRTD_Temp( AtlasScientificRTD* parentSense, const char* uuid = "", const char* varCode = ATLAS_RTD_DEFAULT_CODE) - : Variable(parentSense, static_cast(ATLAS_RTD_VAR_NUM), - static_cast(ATLAS_RTD_RESOLUTION), + : Variable(parentSense, ATLAS_RTD_VAR_NUM, ATLAS_RTD_RESOLUTION, ATLAS_RTD_VAR_NAME, ATLAS_RTD_UNIT_NAME, varCode, uuid) {} /** * @brief Destroy the AtlasScientificRTD_Temp object - no action needed. diff --git a/src/sensors/AtlasScientificpH.h b/src/sensors/AtlasScientificpH.h index 408d64752..737cd153d 100644 --- a/src/sensors/AtlasScientificpH.h +++ b/src/sensors/AtlasScientificpH.h @@ -238,9 +238,8 @@ class AtlasScientificpH_pH : public Variable { explicit AtlasScientificpH_pH(AtlasScientificpH* parentSense, const char* uuid = "", const char* varCode = ATLAS_PH_DEFAULT_CODE) - : Variable(parentSense, static_cast(ATLAS_PH_VAR_NUM), - static_cast(ATLAS_PH_RESOLUTION), ATLAS_PH_VAR_NAME, - ATLAS_PH_UNIT_NAME, varCode, uuid) {} + : Variable(parentSense, ATLAS_PH_VAR_NUM, ATLAS_PH_RESOLUTION, + ATLAS_PH_VAR_NAME, ATLAS_PH_UNIT_NAME, varCode, uuid) {} /** * @brief Destroy the AtlasScientificpH_pH object - no action needed. */ diff --git a/src/sensors/BoschBME280.h b/src/sensors/BoschBME280.h index 0e3897189..7142038fd 100644 --- a/src/sensors/BoschBME280.h +++ b/src/sensors/BoschBME280.h @@ -376,8 +376,7 @@ class BoschBME280_Temp : public Variable { */ explicit BoschBME280_Temp(BoschBME280* parentSense, const char* uuid = "", const char* varCode = BME280_TEMP_DEFAULT_CODE) - : Variable(parentSense, static_cast(BME280_TEMP_VAR_NUM), - static_cast(BME280_TEMP_RESOLUTION), + : Variable(parentSense, BME280_TEMP_VAR_NUM, BME280_TEMP_RESOLUTION, BME280_TEMP_VAR_NAME, BME280_TEMP_UNIT_NAME, varCode, uuid) { } /** @@ -411,10 +410,9 @@ class BoschBME280_Humidity : public Variable { explicit BoschBME280_Humidity( BoschBME280* parentSense, const char* uuid = "", const char* varCode = BME280_HUMIDITY_DEFAULT_CODE) - : Variable(parentSense, static_cast(BME280_HUMIDITY_VAR_NUM), - static_cast(BME280_HUMIDITY_RESOLUTION), - BME280_HUMIDITY_VAR_NAME, BME280_HUMIDITY_UNIT_NAME, varCode, - uuid) {} + : Variable(parentSense, BME280_HUMIDITY_VAR_NUM, + BME280_HUMIDITY_RESOLUTION, BME280_HUMIDITY_VAR_NAME, + BME280_HUMIDITY_UNIT_NAME, varCode, uuid) {} /** * @brief Destroy the BoschBME280_Humidity object - no action needed. */ @@ -446,10 +444,9 @@ class BoschBME280_Pressure : public Variable { explicit BoschBME280_Pressure( BoschBME280* parentSense, const char* uuid = "", const char* varCode = BME280_PRESSURE_DEFAULT_CODE) - : Variable(parentSense, static_cast(BME280_PRESSURE_VAR_NUM), - static_cast(BME280_PRESSURE_RESOLUTION), - BME280_PRESSURE_VAR_NAME, BME280_PRESSURE_UNIT_NAME, varCode, - uuid) {} + : Variable(parentSense, BME280_PRESSURE_VAR_NUM, + BME280_PRESSURE_RESOLUTION, BME280_PRESSURE_VAR_NAME, + BME280_PRESSURE_UNIT_NAME, varCode, uuid) {} /** * @brief Destroy the BoschBME280_Pressure object - no action needed. */ @@ -481,10 +478,9 @@ class BoschBME280_Altitude : public Variable { explicit BoschBME280_Altitude( BoschBME280* parentSense, const char* uuid = "", const char* varCode = BME280_ALTITUDE_DEFAULT_CODE) - : Variable(parentSense, static_cast(BME280_ALTITUDE_VAR_NUM), - static_cast(BME280_ALTITUDE_RESOLUTION), - BME280_ALTITUDE_VAR_NAME, BME280_ALTITUDE_UNIT_NAME, varCode, - uuid) {} + : Variable(parentSense, BME280_ALTITUDE_VAR_NUM, + BME280_ALTITUDE_RESOLUTION, BME280_ALTITUDE_VAR_NAME, + BME280_ALTITUDE_UNIT_NAME, varCode, uuid) {} /** * @brief Destroy the BoschBME280_Altitude object - no action needed. */ diff --git a/src/sensors/BoschBMP3xx.h b/src/sensors/BoschBMP3xx.h index 1559e23a8..1ac23fbab 100644 --- a/src/sensors/BoschBMP3xx.h +++ b/src/sensors/BoschBMP3xx.h @@ -611,8 +611,7 @@ class BoschBMP3xx_Temp : public Variable { */ explicit BoschBMP3xx_Temp(BoschBMP3xx* parentSense, const char* uuid = "", const char* varCode = BMP3XX_TEMP_DEFAULT_CODE) - : Variable(parentSense, static_cast(BMP3XX_TEMP_VAR_NUM), - static_cast(BMP3XX_TEMP_RESOLUTION), + : Variable(parentSense, BMP3XX_TEMP_VAR_NUM, BMP3XX_TEMP_RESOLUTION, BMP3XX_TEMP_VAR_NAME, BMP3XX_TEMP_UNIT_NAME, varCode, uuid) { } /** @@ -646,10 +645,9 @@ class BoschBMP3xx_Pressure : public Variable { explicit BoschBMP3xx_Pressure( BoschBMP3xx* parentSense, const char* uuid = "", const char* varCode = BMP3XX_PRESSURE_DEFAULT_CODE) - : Variable(parentSense, static_cast(BMP3XX_PRESSURE_VAR_NUM), - static_cast(BMP3XX_PRESSURE_RESOLUTION), - BMP3XX_PRESSURE_VAR_NAME, BMP3XX_PRESSURE_UNIT_NAME, varCode, - uuid) {} + : Variable(parentSense, BMP3XX_PRESSURE_VAR_NUM, + BMP3XX_PRESSURE_RESOLUTION, BMP3XX_PRESSURE_VAR_NAME, + BMP3XX_PRESSURE_UNIT_NAME, varCode, uuid) {} /** * @brief Destroy the BoschBMP3xx_Pressure object - no action needed. */ @@ -681,10 +679,9 @@ class BoschBMP3xx_Altitude : public Variable { explicit BoschBMP3xx_Altitude( BoschBMP3xx* parentSense, const char* uuid = "", const char* varCode = BMP3XX_ALTITUDE_DEFAULT_CODE) - : Variable(parentSense, static_cast(BMP3XX_ALTITUDE_VAR_NUM), - static_cast(BMP3XX_ALTITUDE_RESOLUTION), - BMP3XX_ALTITUDE_VAR_NAME, BMP3XX_ALTITUDE_UNIT_NAME, varCode, - uuid) {} + : Variable(parentSense, BMP3XX_ALTITUDE_VAR_NUM, + BMP3XX_ALTITUDE_RESOLUTION, BMP3XX_ALTITUDE_VAR_NAME, + BMP3XX_ALTITUDE_UNIT_NAME, varCode, uuid) {} /** * @brief Destroy the BoschBMP3xx_Altitude object - no action needed. */ diff --git a/src/sensors/CampbellClariVUE10.h b/src/sensors/CampbellClariVUE10.h index 89b216c45..d6483c0eb 100644 --- a/src/sensors/CampbellClariVUE10.h +++ b/src/sensors/CampbellClariVUE10.h @@ -292,9 +292,8 @@ class CampbellClariVUE10_Turbidity : public Variable { explicit CampbellClariVUE10_Turbidity( CampbellClariVUE10* parentSense, const char* uuid = "", const char* varCode = CLARIVUE10_TURBIDITY_DEFAULT_CODE) - : Variable(parentSense, - static_cast(CLARIVUE10_TURBIDITY_VAR_NUM), - static_cast(CLARIVUE10_TURBIDITY_RESOLUTION), + : Variable(parentSense, CLARIVUE10_TURBIDITY_VAR_NUM, + CLARIVUE10_TURBIDITY_RESOLUTION, CLARIVUE10_TURBIDITY_VAR_NAME, CLARIVUE10_TURBIDITY_UNIT_NAME, varCode, uuid) {} /** @@ -329,10 +328,9 @@ class CampbellClariVUE10_Temp : public Variable { explicit CampbellClariVUE10_Temp( CampbellClariVUE10* parentSense, const char* uuid = "", const char* varCode = CLARIVUE10_TEMP_DEFAULT_CODE) - : Variable(parentSense, static_cast(CLARIVUE10_TEMP_VAR_NUM), - static_cast(CLARIVUE10_TEMP_RESOLUTION), - CLARIVUE10_TEMP_VAR_NAME, CLARIVUE10_TEMP_UNIT_NAME, varCode, - uuid) {} + : Variable(parentSense, CLARIVUE10_TEMP_VAR_NUM, + CLARIVUE10_TEMP_RESOLUTION, CLARIVUE10_TEMP_VAR_NAME, + CLARIVUE10_TEMP_UNIT_NAME, varCode, uuid) {} /** * @brief Destroy the CampbellClariVUE10_Temp object - no action needed. */ @@ -364,9 +362,8 @@ class CampbellClariVUE10_ErrorCode : public Variable { explicit CampbellClariVUE10_ErrorCode( CampbellClariVUE10* parentSense, const char* uuid = "", const char* varCode = CLARIVUE10_ERRORCODE_DEFAULT_CODE) - : Variable(parentSense, - static_cast(CLARIVUE10_ERRORCODE_VAR_NUM), - static_cast(CLARIVUE10_ERRORCODE_RESOLUTION), + : Variable(parentSense, CLARIVUE10_ERRORCODE_VAR_NUM, + CLARIVUE10_ERRORCODE_RESOLUTION, CLARIVUE10_ERRORCODE_VAR_NAME, CLARIVUE10_ERRORCODE_UNIT_NAME, varCode, uuid) {} /** diff --git a/src/sensors/CampbellOBS3.h b/src/sensors/CampbellOBS3.h index f18ac0688..c2641f8b3 100644 --- a/src/sensors/CampbellOBS3.h +++ b/src/sensors/CampbellOBS3.h @@ -345,9 +345,8 @@ class CampbellOBS3_Turbidity : public Variable { explicit CampbellOBS3_Turbidity( CampbellOBS3* parentSense, const char* uuid = "", const char* varCode = OBS3_TURB_DEFAULT_CODE) - : Variable(parentSense, static_cast(OBS3_TURB_VAR_NUM), - static_cast(OBS3_RESOLUTION), OBS3_TURB_VAR_NAME, - OBS3_TURB_UNIT_NAME, varCode, uuid) {} + : Variable(parentSense, OBS3_TURB_VAR_NUM, OBS3_RESOLUTION, + OBS3_TURB_VAR_NAME, OBS3_TURB_UNIT_NAME, varCode, uuid) {} /** * @brief Destroy the Campbell OBS3 Turbidity object */ @@ -381,8 +380,7 @@ class CampbellOBS3_Voltage : public Variable { explicit CampbellOBS3_Voltage( CampbellOBS3* parentSense, const char* uuid = "", const char* varCode = OBS3_VOLTAGE_DEFAULT_CODE) - : Variable(parentSense, static_cast(OBS3_VOLTAGE_VAR_NUM), - static_cast(OBS3_VOLTAGE_RESOLUTION), + : Variable(parentSense, OBS3_VOLTAGE_VAR_NUM, OBS3_VOLTAGE_RESOLUTION, OBS3_VOLTAGE_VAR_NAME, OBS3_VOLTAGE_UNIT_NAME, varCode, uuid) {} /** diff --git a/src/sensors/CampbellRainVUE10.h b/src/sensors/CampbellRainVUE10.h index de190dfb7..571f19b4d 100644 --- a/src/sensors/CampbellRainVUE10.h +++ b/src/sensors/CampbellRainVUE10.h @@ -342,9 +342,8 @@ class CampbellRainVUE10_Precipitation : public Variable { explicit CampbellRainVUE10_Precipitation( CampbellRainVUE10* parentSense, const char* uuid = "", const char* varCode = RAINVUE10_PRECIPITATION_DEFAULT_CODE) - : Variable(parentSense, - static_cast(RAINVUE10_PRECIPITATION_VAR_NUM), - static_cast(RAINVUE10_PRECIPITATION_RESOLUTION), + : Variable(parentSense, RAINVUE10_PRECIPITATION_VAR_NUM, + RAINVUE10_PRECIPITATION_RESOLUTION, RAINVUE10_PRECIPITATION_VAR_NAME, RAINVUE10_PRECIPITATION_UNIT_NAME, varCode, uuid) {} /** @@ -379,10 +378,9 @@ class CampbellRainVUE10_Tips : public Variable { explicit CampbellRainVUE10_Tips( CampbellRainVUE10* parentSense, const char* uuid = "", const char* varCode = RAINVUE10_TIPS_DEFAULT_CODE) - : Variable(parentSense, static_cast(RAINVUE10_TIPS_VAR_NUM), - static_cast(RAINVUE10_TIPS_RESOLUTION), - RAINVUE10_TIPS_VAR_NAME, RAINVUE10_TIPS_UNIT_NAME, varCode, - uuid) {} + : Variable(parentSense, RAINVUE10_TIPS_VAR_NUM, + RAINVUE10_TIPS_RESOLUTION, RAINVUE10_TIPS_VAR_NAME, + RAINVUE10_TIPS_UNIT_NAME, varCode, uuid) {} /** * @brief Destroy the CampbellRainVUE10_Tips object - no action needed. */ @@ -414,9 +412,8 @@ class CampbellRainVUE10_RainRateAve : public Variable { explicit CampbellRainVUE10_RainRateAve( CampbellRainVUE10* parentSense, const char* uuid = "", const char* varCode = RAINVUE10_RAINRATEAVE_DEFAULT_CODE) - : Variable(parentSense, - static_cast(RAINVUE10_RAINRATEAVE_VAR_NUM), - static_cast(RAINVUE10_RAINRATEAVE_RESOLUTION), + : Variable(parentSense, RAINVUE10_RAINRATEAVE_VAR_NUM, + RAINVUE10_RAINRATEAVE_RESOLUTION, RAINVUE10_RAINRATEAVE_VAR_NAME, RAINVUE10_RAINRATEAVE_UNIT_NAME, varCode, uuid) {} /** @@ -452,9 +449,8 @@ class CampbellRainVUE10_RainRateMax : public Variable { explicit CampbellRainVUE10_RainRateMax( CampbellRainVUE10* parentSense, const char* uuid = "", const char* varCode = RAINVUE10_RAINRATEMAX_DEFAULT_CODE) - : Variable(parentSense, - static_cast(RAINVUE10_RAINRATEMAX_VAR_NUM), - static_cast(RAINVUE10_RAINRATEMAX_RESOLUTION), + : Variable(parentSense, RAINVUE10_RAINRATEMAX_VAR_NUM, + RAINVUE10_RAINRATEMAX_RESOLUTION, RAINVUE10_RAINRATEMAX_VAR_NAME, RAINVUE10_RAINRATEMAX_UNIT_NAME, varCode, uuid) {} /** diff --git a/src/sensors/Decagon5TM.h b/src/sensors/Decagon5TM.h index 40d9425fe..e90c4422e 100644 --- a/src/sensors/Decagon5TM.h +++ b/src/sensors/Decagon5TM.h @@ -326,8 +326,7 @@ class Decagon5TM_Ea : public Variable { */ explicit Decagon5TM_Ea(Decagon5TM* parentSense, const char* uuid = "", const char* varCode = TM_EA_DEFAULT_CODE) - : Variable(parentSense, static_cast(TM_EA_VAR_NUM), - static_cast(TM_EA_RESOLUTION), TM_EA_VAR_NAME, + : Variable(parentSense, TM_EA_VAR_NUM, TM_EA_RESOLUTION, TM_EA_VAR_NAME, TM_EA_UNIT_NAME, varCode, uuid) {} /** * @brief Destroy the Decagon5TM_Ea object - no action needed. @@ -358,9 +357,8 @@ class Decagon5TM_Temp : public Variable { */ explicit Decagon5TM_Temp(Decagon5TM* parentSense, const char* uuid = "", const char* varCode = TM_TEMP_DEFAULT_CODE) - : Variable(parentSense, static_cast(TM_TEMP_VAR_NUM), - static_cast(TM_TEMP_RESOLUTION), TM_TEMP_VAR_NAME, - TM_TEMP_UNIT_NAME, varCode, uuid) {} + : Variable(parentSense, TM_TEMP_VAR_NUM, TM_TEMP_RESOLUTION, + TM_TEMP_VAR_NAME, TM_TEMP_UNIT_NAME, varCode, uuid) {} /** * @brief Destroy the Decagon5TM_Temp object - no action needed. */ @@ -390,9 +388,8 @@ class Decagon5TM_VWC : public Variable { */ explicit Decagon5TM_VWC(Decagon5TM* parentSense, const char* uuid = "", const char* varCode = TM_VWC_DEFAULT_CODE) - : Variable(parentSense, static_cast(TM_VWC_VAR_NUM), - static_cast(TM_VWC_RESOLUTION), TM_VWC_VAR_NAME, - TM_VWC_UNIT_NAME, varCode, uuid) {} + : Variable(parentSense, TM_VWC_VAR_NUM, TM_VWC_RESOLUTION, + TM_VWC_VAR_NAME, TM_VWC_UNIT_NAME, varCode, uuid) {} /** * @brief Destroy the Decagon5TM_VWC object - no action needed. */ diff --git a/src/sensors/DecagonCTD.h b/src/sensors/DecagonCTD.h index 16690af64..e1a2bb223 100644 --- a/src/sensors/DecagonCTD.h +++ b/src/sensors/DecagonCTD.h @@ -293,9 +293,8 @@ class DecagonCTD_Cond : public Variable { */ explicit DecagonCTD_Cond(DecagonCTD* parentSense, const char* uuid = "", const char* varCode = CTD_COND_DEFAULT_CODE) - : Variable(parentSense, static_cast(CTD_COND_VAR_NUM), - static_cast(CTD_COND_RESOLUTION), CTD_COND_VAR_NAME, - CTD_COND_UNIT_NAME, varCode, uuid) {} + : Variable(parentSense, CTD_COND_VAR_NUM, CTD_COND_RESOLUTION, + CTD_COND_VAR_NAME, CTD_COND_UNIT_NAME, varCode, uuid) {} /** * @brief Destroy the DecagonCTD_Cond object - no action needed. */ @@ -325,9 +324,8 @@ class DecagonCTD_Temp : public Variable { */ explicit DecagonCTD_Temp(DecagonCTD* parentSense, const char* uuid = "", const char* varCode = CTD_TEMP_DEFAULT_CODE) - : Variable(parentSense, static_cast(CTD_TEMP_VAR_NUM), - static_cast(CTD_TEMP_RESOLUTION), CTD_TEMP_VAR_NAME, - CTD_TEMP_UNIT_NAME, varCode, uuid) {} + : Variable(parentSense, CTD_TEMP_VAR_NUM, CTD_TEMP_RESOLUTION, + CTD_TEMP_VAR_NAME, CTD_TEMP_UNIT_NAME, varCode, uuid) {} /** * @brief Destroy the DecagonCTD_Temp object - no action needed. */ @@ -357,8 +355,7 @@ class DecagonCTD_Depth : public Variable { */ explicit DecagonCTD_Depth(DecagonCTD* parentSense, const char* uuid = "", const char* varCode = CTD_DEPTH_DEFAULT_CODE) - : Variable(parentSense, static_cast(CTD_DEPTH_VAR_NUM), - static_cast(CTD_DEPTH_RESOLUTION), + : Variable(parentSense, CTD_DEPTH_VAR_NUM, CTD_DEPTH_RESOLUTION, CTD_DEPTH_VAR_NAME, CTD_DEPTH_UNIT_NAME, varCode, uuid) {} /** * @brief Destroy the DecagonCTD_Depth object - no action needed. diff --git a/src/sensors/DecagonES2.h b/src/sensors/DecagonES2.h index 3f0ccc50b..b6599a406 100644 --- a/src/sensors/DecagonES2.h +++ b/src/sensors/DecagonES2.h @@ -252,9 +252,8 @@ class DecagonES2_Cond : public Variable { */ explicit DecagonES2_Cond(DecagonES2* parentSense, const char* uuid = "", const char* varCode = ES2_COND_DEFAULT_CODE) - : Variable(parentSense, static_cast(ES2_COND_VAR_NUM), - static_cast(ES2_COND_RESOLUTION), ES2_COND_VAR_NAME, - ES2_COND_UNIT_NAME, varCode, uuid) {} + : Variable(parentSense, ES2_COND_VAR_NUM, ES2_COND_RESOLUTION, + ES2_COND_VAR_NAME, ES2_COND_UNIT_NAME, varCode, uuid) {} /** * @brief Destroy the DecagonES2_Cond object - no action needed. */ @@ -283,9 +282,8 @@ class DecagonES2_Temp : public Variable { */ explicit DecagonES2_Temp(DecagonES2* parentSense, const char* uuid = "", const char* varCode = ES2_TEMP_DEFAULT_CODE) - : Variable(parentSense, static_cast(ES2_TEMP_VAR_NUM), - static_cast(ES2_TEMP_RESOLUTION), ES2_TEMP_VAR_NAME, - ES2_TEMP_UNIT_NAME, varCode, uuid) {} + : Variable(parentSense, ES2_TEMP_VAR_NUM, ES2_TEMP_RESOLUTION, + ES2_TEMP_VAR_NAME, ES2_TEMP_UNIT_NAME, varCode, uuid) {} /** * @brief Destroy the DecagonES2_Temp object - no action needed. */ diff --git a/src/sensors/EverlightALSPT19.h b/src/sensors/EverlightALSPT19.h index ddb9bd9b3..e45d92cd7 100644 --- a/src/sensors/EverlightALSPT19.h +++ b/src/sensors/EverlightALSPT19.h @@ -365,10 +365,9 @@ class EverlightALSPT19_Voltage : public Variable { explicit EverlightALSPT19_Voltage( EverlightALSPT19* parentSense, const char* uuid = "", const char* varCode = ALSPT19_VOLTAGE_DEFAULT_CODE) - : Variable(parentSense, static_cast(ALSPT19_VOLTAGE_VAR_NUM), - static_cast(ALSPT19_VOLTAGE_RESOLUTION), - ALSPT19_VOLTAGE_VAR_NAME, ALSPT19_VOLTAGE_UNIT_NAME, varCode, - uuid) {} + : Variable(parentSense, ALSPT19_VOLTAGE_VAR_NUM, + ALSPT19_VOLTAGE_RESOLUTION, ALSPT19_VOLTAGE_VAR_NAME, + ALSPT19_VOLTAGE_UNIT_NAME, varCode, uuid) {} /** * @brief Destroy the EverlightALSPT19_Voltage object - no action needed. */ @@ -398,10 +397,9 @@ class EverlightALSPT19_Current : public Variable { explicit EverlightALSPT19_Current( EverlightALSPT19* parentSense, const char* uuid = "", const char* varCode = ALSPT19_CURRENT_DEFAULT_CODE) - : Variable(parentSense, static_cast(ALSPT19_CURRENT_VAR_NUM), - static_cast(ALSPT19_CURRENT_RESOLUTION), - ALSPT19_CURRENT_VAR_NAME, ALSPT19_CURRENT_UNIT_NAME, varCode, - uuid) {} + : Variable(parentSense, ALSPT19_CURRENT_VAR_NUM, + ALSPT19_CURRENT_RESOLUTION, ALSPT19_CURRENT_VAR_NAME, + ALSPT19_CURRENT_UNIT_NAME, varCode, uuid) {} /** * @brief Destroy the EverlightALSPT19_Current object - no action needed. */ @@ -431,11 +429,9 @@ class EverlightALSPT19_Illuminance : public Variable { explicit EverlightALSPT19_Illuminance( EverlightALSPT19* parentSense, const char* uuid = "", const char* varCode = ALSPT19_ILLUMINANCE_DEFAULT_CODE) - : Variable(parentSense, - static_cast(ALSPT19_ILLUMINANCE_VAR_NUM), - static_cast(ALSPT19_ILLUMINANCE_RESOLUTION), - ALSPT19_ILLUMINANCE_VAR_NAME, ALSPT19_ILLUMINANCE_UNIT_NAME, - varCode, uuid) {} + : Variable(parentSense, ALSPT19_ILLUMINANCE_VAR_NUM, + ALSPT19_ILLUMINANCE_RESOLUTION, ALSPT19_ILLUMINANCE_VAR_NAME, + ALSPT19_ILLUMINANCE_UNIT_NAME, varCode, uuid) {} /** * @brief Destroy the EverlightALSPT19_Illuminance object - no action * needed. diff --git a/src/sensors/FreescaleMPL115A2.h b/src/sensors/FreescaleMPL115A2.h index 43a7eb09f..bfea42fa9 100644 --- a/src/sensors/FreescaleMPL115A2.h +++ b/src/sensors/FreescaleMPL115A2.h @@ -291,8 +291,7 @@ class FreescaleMPL115A2_Temp : public Variable { explicit FreescaleMPL115A2_Temp( FreescaleMPL115A2* parentSense, const char* uuid = "", const char* varCode = MPL115A2_TEMP_DEFAULT_CODE) - : Variable(parentSense, static_cast(MPL115A2_TEMP_VAR_NUM), - static_cast(MPL115A2_TEMP_RESOLUTION), + : Variable(parentSense, MPL115A2_TEMP_VAR_NUM, MPL115A2_TEMP_RESOLUTION, MPL115A2_TEMP_VAR_NAME, MPL115A2_TEMP_UNIT_NAME, varCode, uuid) {} /** @@ -334,10 +333,9 @@ class FreescaleMPL115A2_Pressure : public Variable { explicit FreescaleMPL115A2_Pressure( FreescaleMPL115A2* parentSense, const char* uuid = "", const char* varCode = MPL115A2_PRESSURE_DEFAULT_CODE) - : Variable(parentSense, static_cast(MPL115A2_PRESSURE_VAR_NUM), - static_cast(MPL115A2_PRESSURE_RESOLUTION), - MPL115A2_PRESSURE_VAR_NAME, MPL115A2_PRESSURE_UNIT_NAME, - varCode, uuid) {} + : Variable(parentSense, MPL115A2_PRESSURE_VAR_NUM, + MPL115A2_PRESSURE_RESOLUTION, MPL115A2_PRESSURE_VAR_NAME, + MPL115A2_PRESSURE_UNIT_NAME, varCode, uuid) {} /** * @brief Destroy the FreescaleMPL115A2_Pressure object - no action needed. */ diff --git a/src/sensors/GeoluxHydroCam.h b/src/sensors/GeoluxHydroCam.h index 00b53be2c..d30d30f06 100644 --- a/src/sensors/GeoluxHydroCam.h +++ b/src/sensors/GeoluxHydroCam.h @@ -458,8 +458,7 @@ class GeoluxHydroCam_ImageSize : public Variable { explicit GeoluxHydroCam_ImageSize( GeoluxHydroCam* parentSense, const char* uuid = "", const char* varCode = HYDROCAM_SIZE_DEFAULT_CODE) - : Variable(parentSense, static_cast(HYDROCAM_SIZE_VAR_NUM), - static_cast(HYDROCAM_SIZE_RESOLUTION), + : Variable(parentSense, HYDROCAM_SIZE_VAR_NUM, HYDROCAM_SIZE_RESOLUTION, HYDROCAM_SIZE_VAR_NAME, HYDROCAM_SIZE_UNIT_NAME, varCode, uuid) {} /** @@ -493,10 +492,9 @@ class GeoluxHydroCam_ByteError : public Variable { explicit GeoluxHydroCam_ByteError( GeoluxHydroCam* parentSense, const char* uuid = "", const char* varCode = HYDROCAM_ERROR_DEFAULT_CODE) - : Variable(parentSense, static_cast(HYDROCAM_ERROR_VAR_NUM), - static_cast(HYDROCAM_ERROR_RESOLUTION), - HYDROCAM_ERROR_VAR_NAME, HYDROCAM_ERROR_UNIT_NAME, varCode, - uuid) {} + : Variable(parentSense, HYDROCAM_ERROR_VAR_NUM, + HYDROCAM_ERROR_RESOLUTION, HYDROCAM_ERROR_VAR_NAME, + HYDROCAM_ERROR_UNIT_NAME, varCode, uuid) {} /** * @brief Destroy the GeoluxHydroCam_ByteError object - no action * needed. diff --git a/src/sensors/GroPointGPLP8.h b/src/sensors/GroPointGPLP8.h index e5d132355..1538a66ed 100644 --- a/src/sensors/GroPointGPLP8.h +++ b/src/sensors/GroPointGPLP8.h @@ -226,8 +226,7 @@ class GroPointGPLP8_Moist : public Variable { const uint8_t sensorVarNum, const char* uuid = "", const char* varCode = GPLP8_MOIST_DEFAULT_CODE) - : Variable(parentSense, sensorVarNum, - static_cast(GPLP8_MOIST_RESOLUTION), + : Variable(parentSense, sensorVarNum, GPLP8_MOIST_RESOLUTION, GPLP8_MOIST_VAR_NAME, GPLP8_MOIST_UNIT_NAME, varCode, uuid) { } /** @@ -265,8 +264,7 @@ class GroPointGPLP8_Temp : public Variable { const uint8_t sensorVarNum, const char* uuid = "", const char* varCode = GPLP8_TEMP_DEFAULT_CODE) - : Variable(parentSense, sensorVarNum, - static_cast(GPLP8_TEMP_RESOLUTION), + : Variable(parentSense, sensorVarNum, GPLP8_TEMP_RESOLUTION, GPLP8_TEMP_VAR_NAME, GPLP8_TEMP_UNIT_NAME, varCode, uuid) {} /** * @brief Destroy the GroPointGPLP8_Temp object - no action needed. diff --git a/src/sensors/InSituRDO.h b/src/sensors/InSituRDO.h index e588b5cd9..c1aa81789 100644 --- a/src/sensors/InSituRDO.h +++ b/src/sensors/InSituRDO.h @@ -458,10 +458,9 @@ class InSituRDO_DOmgL : public Variable { explicit InSituRDO_DOmgL( InSituRDO* parentSense, const char* uuid = "", const char* varCode = INSITU_RDO_DOMGL_DEFAULT_CODE) - : Variable(parentSense, static_cast(INSITU_RDO_DOMGL_VAR_NUM), - static_cast(INSITU_RDO_DOMGL_RESOLUTION), - INSITU_RDO_DOMGL_VAR_NAME, INSITU_RDO_DOMGL_UNIT_NAME, - varCode, uuid) {} + : Variable(parentSense, INSITU_RDO_DOMGL_VAR_NUM, + INSITU_RDO_DOMGL_RESOLUTION, INSITU_RDO_DOMGL_VAR_NAME, + INSITU_RDO_DOMGL_UNIT_NAME, varCode, uuid) {} /** * @brief Destroy the InSituRDO_DOmgL object - no action needed. */ @@ -493,10 +492,9 @@ class InSituRDO_DOpct : public Variable { explicit InSituRDO_DOpct( InSituRDO* parentSense, const char* uuid = "", const char* varCode = INSITU_RDO_DOPCT_DEFAULT_CODE) - : Variable(parentSense, static_cast(INSITU_RDO_DOPCT_VAR_NUM), - static_cast(INSITU_RDO_DOPCT_RESOLUTION), - INSITU_RDO_DOPCT_VAR_NAME, INSITU_RDO_DOPCT_UNIT_NAME, - varCode, uuid) {} + : Variable(parentSense, INSITU_RDO_DOPCT_VAR_NUM, + INSITU_RDO_DOPCT_RESOLUTION, INSITU_RDO_DOPCT_VAR_NAME, + INSITU_RDO_DOPCT_UNIT_NAME, varCode, uuid) {} /** * @brief Destroy the InSituRDO_DOpct object - no action needed. */ @@ -527,10 +525,9 @@ class InSituRDO_Temp : public Variable { */ explicit InSituRDO_Temp(InSituRDO* parentSense, const char* uuid = "", const char* varCode = INSITU_RDO_TEMP_DEFAULT_CODE) - : Variable(parentSense, static_cast(INSITU_RDO_TEMP_VAR_NUM), - static_cast(INSITU_RDO_TEMP_RESOLUTION), - INSITU_RDO_TEMP_VAR_NAME, INSITU_RDO_TEMP_UNIT_NAME, varCode, - uuid) {} + : Variable(parentSense, INSITU_RDO_TEMP_VAR_NUM, + INSITU_RDO_TEMP_RESOLUTION, INSITU_RDO_TEMP_VAR_NAME, + INSITU_RDO_TEMP_UNIT_NAME, varCode, uuid) {} /** * @brief Destroy the InSituRDO_Temp object - no action needed. */ @@ -562,11 +559,9 @@ class InSituRDO_Pressure : public Variable { explicit InSituRDO_Pressure( InSituRDO* parentSense, const char* uuid = "", const char* varCode = INSITU_RDO_PRESSURE_DEFAULT_CODE) - : Variable(parentSense, - static_cast(INSITU_RDO_PRESSURE_VAR_NUM), - static_cast(INSITU_RDO_PRESSURE_RESOLUTION), - INSITU_RDO_PRESSURE_VAR_NAME, INSITU_RDO_PRESSURE_UNIT_NAME, - varCode, uuid) {} + : Variable(parentSense, INSITU_RDO_PRESSURE_VAR_NUM, + INSITU_RDO_PRESSURE_RESOLUTION, INSITU_RDO_PRESSURE_VAR_NAME, + INSITU_RDO_PRESSURE_UNIT_NAME, varCode, uuid) {} /** * @brief Destroy the InSituRDO_Pressure object - no action needed. */ diff --git a/src/sensors/InSituTrollSdi12a.h b/src/sensors/InSituTrollSdi12a.h index 1cc9c3d49..ad88b585f 100644 --- a/src/sensors/InSituTrollSdi12a.h +++ b/src/sensors/InSituTrollSdi12a.h @@ -304,10 +304,9 @@ class InSituTrollSdi12a_Pressure : public Variable { InSituTrollSdi12a_Pressure( Sensor* parentSense, const char* uuid = "", const char* varCode = ITROLLA_PRESSURE_DEFAULT_CODE) - : Variable(parentSense, static_cast(ITROLLA_PRESSURE_VAR_NUM), - static_cast(ITROLLA_PRESSURE_RESOLUTION), - ITROLLA_PRESSURE_VAR_NAME, ITROLLA_PRESSURE_UNIT_NAME, - varCode, uuid) {} + : Variable(parentSense, ITROLLA_PRESSURE_VAR_NUM, + ITROLLA_PRESSURE_RESOLUTION, ITROLLA_PRESSURE_VAR_NAME, + ITROLLA_PRESSURE_UNIT_NAME, varCode, uuid) {} /** * @brief Destroy the InSituTrollSdi12a_Pressure object - no action needed. */ @@ -337,8 +336,7 @@ class InSituTrollSdi12a_Temp : public Variable { */ InSituTrollSdi12a_Temp(Sensor* parentSense, const char* uuid = "", const char* varCode = ITROLLA_TEMP_DEFAULT_CODE) - : Variable(parentSense, static_cast(ITROLLA_TEMP_VAR_NUM), - static_cast(ITROLLA_TEMP_RESOLUTION), + : Variable(parentSense, ITROLLA_TEMP_VAR_NUM, ITROLLA_TEMP_RESOLUTION, ITROLLA_TEMP_TEMP_VAR_NAME, ITROLLA_TEMP_TEMP_UNIT_NAME, varCode, uuid) {} /** @@ -370,8 +368,7 @@ class InSituTrollSdi12a_Depth : public Variable { */ InSituTrollSdi12a_Depth(Sensor* parentSense, const char* uuid = "", const char* varCode = ITROLLA_DEPTH_DEFAULT_CODE) - : Variable(parentSense, static_cast(ITROLLA_DEPTH_VAR_NUM), - static_cast(ITROLLA_DEPTH_RESOLUTION), + : Variable(parentSense, ITROLLA_DEPTH_VAR_NUM, ITROLLA_DEPTH_RESOLUTION, ITROLLA_DEPTH_VAR_NAME, ITROLLA_DEPTH_UNIT_NAME, varCode, uuid) {} /** diff --git a/src/sensors/KellerAcculevel.h b/src/sensors/KellerAcculevel.h index 7d94730ae..f3e990702 100644 --- a/src/sensors/KellerAcculevel.h +++ b/src/sensors/KellerAcculevel.h @@ -219,10 +219,9 @@ class KellerAcculevel_Pressure : public Variable { explicit KellerAcculevel_Pressure( KellerAcculevel* parentSense, const char* uuid = "", const char* varCode = ACCULEVEL_PRESSURE_DEFAULT_CODE) - : Variable(parentSense, static_cast(KELLER_PRESSURE_VAR_NUM), - static_cast(ACCULEVEL_PRESSURE_RESOLUTION), - KELLER_PRESSURE_VAR_NAME, KELLER_PRESSURE_UNIT_NAME, varCode, - uuid) {} + : Variable(parentSense, KELLER_PRESSURE_VAR_NUM, + ACCULEVEL_PRESSURE_RESOLUTION, KELLER_PRESSURE_VAR_NAME, + KELLER_PRESSURE_UNIT_NAME, varCode, uuid) {} /** * @brief Destroy the KellerAcculevel_Pressure object - no action needed. */ @@ -254,8 +253,7 @@ class KellerAcculevel_Temp : public Variable { explicit KellerAcculevel_Temp( KellerAcculevel* parentSense, const char* uuid = "", const char* varCode = ACCULEVEL_TEMP_DEFAULT_CODE) - : Variable(parentSense, static_cast(KELLER_TEMP_VAR_NUM), - static_cast(ACCULEVEL_TEMP_RESOLUTION), + : Variable(parentSense, KELLER_TEMP_VAR_NUM, ACCULEVEL_TEMP_RESOLUTION, KELLER_TEMP_VAR_NAME, KELLER_TEMP_UNIT_NAME, varCode, uuid) { } /** @@ -289,10 +287,9 @@ class KellerAcculevel_Height : public Variable { explicit KellerAcculevel_Height( KellerAcculevel* parentSense, const char* uuid = "", const char* varCode = ACCULEVEL_HEIGHT_DEFAULT_CODE) - : Variable(parentSense, static_cast(KELLER_HEIGHT_VAR_NUM), - static_cast(ACCULEVEL_HEIGHT_RESOLUTION), - KELLER_HEIGHT_VAR_NAME, KELLER_HEIGHT_UNIT_NAME, varCode, - uuid) {} + : Variable(parentSense, KELLER_HEIGHT_VAR_NUM, + ACCULEVEL_HEIGHT_RESOLUTION, KELLER_HEIGHT_VAR_NAME, + KELLER_HEIGHT_UNIT_NAME, varCode, uuid) {} /** * @brief Destroy the KellerAcculevel_Height object - no action needed. */ diff --git a/src/sensors/KellerNanolevel.h b/src/sensors/KellerNanolevel.h index 96e6bd8ba..66667c443 100644 --- a/src/sensors/KellerNanolevel.h +++ b/src/sensors/KellerNanolevel.h @@ -211,10 +211,9 @@ class KellerNanolevel_Pressure : public Variable { explicit KellerNanolevel_Pressure( KellerNanolevel* parentSense, const char* uuid = "", const char* varCode = NANOLEVEL_PRESSURE_DEFAULT_CODE) - : Variable(parentSense, static_cast(KELLER_PRESSURE_VAR_NUM), - static_cast(NANOLEVEL_PRESSURE_RESOLUTION), - KELLER_PRESSURE_VAR_NAME, KELLER_PRESSURE_UNIT_NAME, varCode, - uuid) {} + : Variable(parentSense, KELLER_PRESSURE_VAR_NUM, + NANOLEVEL_PRESSURE_RESOLUTION, KELLER_PRESSURE_VAR_NAME, + KELLER_PRESSURE_UNIT_NAME, varCode, uuid) {} /** * @brief Destroy the KellerNanolevel_Pressure object - no action needed. */ @@ -246,8 +245,7 @@ class KellerNanolevel_Temp : public Variable { explicit KellerNanolevel_Temp( KellerNanolevel* parentSense, const char* uuid = "", const char* varCode = NANOLEVEL_TEMP_DEFAULT_CODE) - : Variable(parentSense, static_cast(KELLER_TEMP_VAR_NUM), - static_cast(NANOLEVEL_TEMP_RESOLUTION), + : Variable(parentSense, KELLER_TEMP_VAR_NUM, NANOLEVEL_TEMP_RESOLUTION, KELLER_TEMP_VAR_NAME, KELLER_TEMP_UNIT_NAME, varCode, uuid) { } /** @@ -281,10 +279,9 @@ class KellerNanolevel_Height : public Variable { explicit KellerNanolevel_Height( KellerNanolevel* parentSense, const char* uuid = "", const char* varCode = NANOLEVEL_HEIGHT_DEFAULT_CODE) - : Variable(parentSense, static_cast(KELLER_HEIGHT_VAR_NUM), - static_cast(NANOLEVEL_HEIGHT_RESOLUTION), - KELLER_HEIGHT_VAR_NAME, KELLER_HEIGHT_UNIT_NAME, varCode, - uuid) {} + : Variable(parentSense, KELLER_HEIGHT_VAR_NUM, + NANOLEVEL_HEIGHT_RESOLUTION, KELLER_HEIGHT_VAR_NAME, + KELLER_HEIGHT_UNIT_NAME, varCode, uuid) {} /** * @brief Destroy the KellerNanolevel_Height object - no action needed. */ diff --git a/src/sensors/MaxBotixSonar.h b/src/sensors/MaxBotixSonar.h index b5608b53f..1bae9d487 100644 --- a/src/sensors/MaxBotixSonar.h +++ b/src/sensors/MaxBotixSonar.h @@ -350,8 +350,7 @@ class MaxBotixSonar_Range : public Variable { explicit MaxBotixSonar_Range(MaxBotixSonar* parentSense, const char* uuid = "", const char* varCode = HRXL_DEFAULT_CODE) - : Variable(parentSense, static_cast(HRXL_VAR_NUM), - static_cast(HRXL_RESOLUTION), HRXL_VAR_NAME, + : Variable(parentSense, HRXL_VAR_NUM, HRXL_RESOLUTION, HRXL_VAR_NAME, HRXL_UNIT_NAME, varCode, uuid) {} /** * @brief Destroy the MaxBotixSonar_Range object - no action needed. diff --git a/src/sensors/MaximDS18.h b/src/sensors/MaximDS18.h index 2e0cad348..0fc4beeed 100644 --- a/src/sensors/MaximDS18.h +++ b/src/sensors/MaximDS18.h @@ -306,8 +306,7 @@ class MaximDS18_Temp : public Variable { */ explicit MaximDS18_Temp(MaximDS18* parentSense, const char* uuid = "", const char* varCode = DS18_TEMP_DEFAULT_CODE) - : Variable(parentSense, static_cast(DS18_TEMP_VAR_NUM), - static_cast(DS18_TEMP_RESOLUTION), + : Variable(parentSense, DS18_TEMP_VAR_NUM, DS18_TEMP_RESOLUTION, DS18_TEMP_VAR_NAME, DS18_TEMP_UNIT_NAME, varCode, uuid) {} /** * @brief Destroy the MaximDS18_Temp object - no action needed. diff --git a/src/sensors/MaximDS3231.h b/src/sensors/MaximDS3231.h index 7fac28a18..6fce591ef 100644 --- a/src/sensors/MaximDS3231.h +++ b/src/sensors/MaximDS3231.h @@ -214,8 +214,7 @@ class MaximDS3231_Temp : public Variable { */ explicit MaximDS3231_Temp(MaximDS3231* parentSense, const char* uuid = "", const char* varCode = DS3231_TEMP_DEFAULT_CODE) - : Variable(parentSense, static_cast(DS3231_TEMP_VAR_NUM), - static_cast(DS3231_TEMP_RESOLUTION), + : Variable(parentSense, DS3231_TEMP_VAR_NUM, DS3231_TEMP_RESOLUTION, DS3231_TEMP_VAR_NAME, DS3231_TEMP_UNIT_NAME, varCode, uuid) { } /** diff --git a/src/sensors/MeaSpecMS5803.h b/src/sensors/MeaSpecMS5803.h index 8dad823e3..cbda9b41d 100644 --- a/src/sensors/MeaSpecMS5803.h +++ b/src/sensors/MeaSpecMS5803.h @@ -303,8 +303,7 @@ class MeaSpecMS5803_Temp : public Variable { explicit MeaSpecMS5803_Temp(MeaSpecMS5803* parentSense, const char* uuid = "", const char* varCode = MS5803_TEMP_DEFAULT_CODE) - : Variable(parentSense, static_cast(MS5803_TEMP_VAR_NUM), - static_cast(MS5803_TEMP_RESOLUTION), + : Variable(parentSense, MS5803_TEMP_VAR_NUM, MS5803_TEMP_RESOLUTION, MS5803_TEMP_VAR_NAME, MS5803_TEMP_UNIT_NAME, varCode, uuid) { } /** @@ -338,10 +337,9 @@ class MeaSpecMS5803_Pressure : public Variable { explicit MeaSpecMS5803_Pressure( MeaSpecMS5803* parentSense, const char* uuid = "", const char* varCode = MS5803_PRESSURE_DEFAULT_CODE) - : Variable(parentSense, static_cast(MS5803_PRESSURE_VAR_NUM), - static_cast(MS5803_PRESSURE_RESOLUTION), - MS5803_PRESSURE_VAR_NAME, MS5803_PRESSURE_UNIT_NAME, varCode, - uuid) {} + : Variable(parentSense, MS5803_PRESSURE_VAR_NUM, + MS5803_PRESSURE_RESOLUTION, MS5803_PRESSURE_VAR_NAME, + MS5803_PRESSURE_UNIT_NAME, varCode, uuid) {} /** * @brief Destroy the MeaSpecMS5803_Pressure object - no action needed. */ diff --git a/src/sensors/MeterHydros21.h b/src/sensors/MeterHydros21.h index 26a34d010..f7e2a2d4f 100644 --- a/src/sensors/MeterHydros21.h +++ b/src/sensors/MeterHydros21.h @@ -315,8 +315,7 @@ class MeterHydros21_Cond : public Variable { explicit MeterHydros21_Cond( MeterHydros21* parentSense, const char* uuid = "", const char* varCode = HYDROS21_COND_DEFAULT_CODE) - : Variable(parentSense, static_cast(HYDROS21_COND_VAR_NUM), - static_cast(HYDROS21_COND_RESOLUTION), + : Variable(parentSense, HYDROS21_COND_VAR_NUM, HYDROS21_COND_RESOLUTION, HYDROS21_COND_VAR_NAME, HYDROS21_COND_UNIT_NAME, varCode, uuid) {} /** @@ -349,8 +348,7 @@ class MeterHydros21_Temp : public Variable { explicit MeterHydros21_Temp( MeterHydros21* parentSense, const char* uuid = "", const char* varCode = HYDROS21_TEMP_DEFAULT_CODE) - : Variable(parentSense, static_cast(HYDROS21_TEMP_VAR_NUM), - static_cast(HYDROS21_TEMP_RESOLUTION), + : Variable(parentSense, HYDROS21_TEMP_VAR_NUM, HYDROS21_TEMP_RESOLUTION, HYDROS21_TEMP_VAR_NAME, HYDROS21_TEMP_UNIT_NAME, varCode, uuid) {} /** @@ -383,10 +381,9 @@ class MeterHydros21_Depth : public Variable { explicit MeterHydros21_Depth( MeterHydros21* parentSense, const char* uuid = "", const char* varCode = HYDROS21_DEPTH_DEFAULT_CODE) - : Variable(parentSense, static_cast(HYDROS21_DEPTH_VAR_NUM), - static_cast(HYDROS21_DEPTH_RESOLUTION), - HYDROS21_DEPTH_VAR_NAME, HYDROS21_DEPTH_UNIT_NAME, varCode, - uuid) {} + : Variable(parentSense, HYDROS21_DEPTH_VAR_NUM, + HYDROS21_DEPTH_RESOLUTION, HYDROS21_DEPTH_VAR_NAME, + HYDROS21_DEPTH_UNIT_NAME, varCode, uuid) {} /** * @brief Destroy the MeterHydros21_Depth object - no action needed. */ diff --git a/src/sensors/MeterTeros11.h b/src/sensors/MeterTeros11.h index 94fbef9a0..7b3152d7c 100644 --- a/src/sensors/MeterTeros11.h +++ b/src/sensors/MeterTeros11.h @@ -379,8 +379,7 @@ class MeterTeros11_Count : public Variable { explicit MeterTeros11_Count( MeterTeros11* parentSense, const char* uuid = "", const char* varCode = TEROS11_COUNT_DEFAULT_CODE) - : Variable(parentSense, static_cast(TEROS11_COUNT_VAR_NUM), - static_cast(TEROS11_COUNT_RESOLUTION), + : Variable(parentSense, TEROS11_COUNT_VAR_NUM, TEROS11_COUNT_RESOLUTION, TEROS11_COUNT_VAR_NAME, TEROS11_COUNT_UNIT_NAME, varCode, uuid) {} /** @@ -413,8 +412,7 @@ class MeterTeros11_Temp : public Variable { */ explicit MeterTeros11_Temp(MeterTeros11* parentSense, const char* uuid = "", const char* varCode = TEROS11_TEMP_DEFAULT_CODE) - : Variable(parentSense, static_cast(TEROS11_TEMP_VAR_NUM), - static_cast(TEROS11_TEMP_RESOLUTION), + : Variable(parentSense, TEROS11_TEMP_VAR_NUM, TEROS11_TEMP_RESOLUTION, TEROS11_TEMP_VAR_NAME, TEROS11_TEMP_UNIT_NAME, varCode, uuid) {} /** @@ -448,8 +446,7 @@ class MeterTeros11_Ea : public Variable { */ explicit MeterTeros11_Ea(MeterTeros11* parentSense, const char* uuid = "", const char* varCode = TEROS11_EA_DEFAULT_CODE) - : Variable(parentSense, static_cast(TEROS11_EA_VAR_NUM), - static_cast(TEROS11_EA_RESOLUTION), + : Variable(parentSense, TEROS11_EA_VAR_NUM, TEROS11_EA_RESOLUTION, TEROS11_EA_VAR_NAME, TEROS11_EA_UNIT_NAME, varCode, uuid) {} /** * @brief Destroy the MeterTeros11_Ea object - no action needed. @@ -481,8 +478,7 @@ class MeterTeros11_VWC : public Variable { */ explicit MeterTeros11_VWC(MeterTeros11* parentSense, const char* uuid = "", const char* varCode = TEROS11_VWC_DEFAULT_CODE) - : Variable(parentSense, static_cast(TEROS11_VWC_VAR_NUM), - static_cast(TEROS11_VWC_RESOLUTION), + : Variable(parentSense, TEROS11_VWC_VAR_NUM, TEROS11_VWC_RESOLUTION, TEROS11_VWC_VAR_NAME, TEROS11_VWC_UNIT_NAME, varCode, uuid) { } /** diff --git a/src/sensors/PaleoTerraRedox.h b/src/sensors/PaleoTerraRedox.h index 612e071d1..098c7089d 100644 --- a/src/sensors/PaleoTerraRedox.h +++ b/src/sensors/PaleoTerraRedox.h @@ -337,8 +337,7 @@ class PaleoTerraRedox_Voltage : public Variable { explicit PaleoTerraRedox_Voltage( Sensor* parentSense, const char* uuid = "", const char* varCode = PTR_VOLTAGE_DEFAULT_CODE) - : Variable(parentSense, static_cast(PTR_VOLTAGE_VAR_NUM), - static_cast(PTR_VOLTAGE_RESOLUTION), + : Variable(parentSense, PTR_VOLTAGE_VAR_NUM, PTR_VOLTAGE_RESOLUTION, PTR_VOLTAGE_VAR_NAME, PTR_VOLTAGE_UNIT_NAME, varCode, uuid) { } /** diff --git a/src/sensors/ProcessorAnalog.h b/src/sensors/ProcessorAnalog.h index e695d5d60..2423e5434 100644 --- a/src/sensors/ProcessorAnalog.h +++ b/src/sensors/ProcessorAnalog.h @@ -325,10 +325,9 @@ class ProcessorAnalog_Voltage : public Variable { explicit ProcessorAnalog_Voltage( ProcessorAnalog* parentSense, const char* uuid = "", const char* varCode = PROCESSOR_ANALOG_DEFAULT_CODE) - : Variable(parentSense, static_cast(PROCESSOR_ANALOG_VAR_NUM), - static_cast(PROCESSOR_ANALOG_RESOLUTION), - PROCESSOR_ANALOG_VAR_NAME, PROCESSOR_ANALOG_UNIT_NAME, - varCode, uuid) {} + : Variable(parentSense, PROCESSOR_ANALOG_VAR_NUM, + PROCESSOR_ANALOG_RESOLUTION, PROCESSOR_ANALOG_VAR_NAME, + PROCESSOR_ANALOG_UNIT_NAME, varCode, uuid) {} /** * @brief Destroy the ProcessorAnalog_Voltage object - no action needed. */ diff --git a/src/sensors/ProcessorStats.h b/src/sensors/ProcessorStats.h index 4aa7e3d8b..57f124f0f 100644 --- a/src/sensors/ProcessorStats.h +++ b/src/sensors/ProcessorStats.h @@ -397,10 +397,9 @@ class ProcessorStats_Battery : public Variable { explicit ProcessorStats_Battery( ProcessorStats* parentSense, const char* uuid = "", const char* varCode = PROCESSOR_BATTERY_DEFAULT_CODE) - : Variable(parentSense, static_cast(PROCESSOR_BATTERY_VAR_NUM), - static_cast(PROCESSOR_BATTERY_RESOLUTION), - PROCESSOR_BATTERY_VAR_NAME, PROCESSOR_BATTERY_UNIT_NAME, - varCode, uuid) {} + : Variable(parentSense, PROCESSOR_BATTERY_VAR_NUM, + PROCESSOR_BATTERY_RESOLUTION, PROCESSOR_BATTERY_VAR_NAME, + PROCESSOR_BATTERY_UNIT_NAME, varCode, uuid) {} /** * @brief Destroy the ProcessorStats_Battery object - no action needed. */ @@ -439,8 +438,7 @@ class ProcessorStats_FreeRam : public Variable { explicit ProcessorStats_FreeRam( ProcessorStats* parentSense, const char* uuid = "", const char* varCode = PROCESSOR_RAM_DEFAULT_CODE) - : Variable(parentSense, static_cast(PROCESSOR_RAM_VAR_NUM), - static_cast(PROCESSOR_RAM_RESOLUTION), + : Variable(parentSense, PROCESSOR_RAM_VAR_NUM, PROCESSOR_RAM_RESOLUTION, PROCESSOR_RAM_VAR_NAME, PROCESSOR_RAM_UNIT_NAME, varCode, uuid) {} /** @@ -477,10 +475,9 @@ class ProcessorStats_SampleNumber : public Variable { explicit ProcessorStats_SampleNumber( ProcessorStats* parentSense, const char* uuid = "", const char* varCode = PROCESSOR_SAMPNUM_DEFAULT_CODE) - : Variable(parentSense, static_cast(PROCESSOR_SAMPNUM_VAR_NUM), - static_cast(PROCESSOR_SAMPNUM_RESOLUTION), - PROCESSOR_SAMPNUM_VAR_NAME, PROCESSOR_SAMPNUM_UNIT_NAME, - varCode, uuid) {} + : Variable(parentSense, PROCESSOR_SAMPNUM_VAR_NUM, + PROCESSOR_SAMPNUM_RESOLUTION, PROCESSOR_SAMPNUM_VAR_NAME, + PROCESSOR_SAMPNUM_UNIT_NAME, varCode, uuid) {} /** * @brief Destroy the ProcessorStats_SampleNumber() object - no action * needed. @@ -517,10 +514,9 @@ class ProcessorStats_ResetCode : public Variable { explicit ProcessorStats_ResetCode( ProcessorStats* parentSense, const char* uuid = "", const char* varCode = PROCESSOR_RESET_DEFAULT_CODE) - : Variable(parentSense, static_cast(PROCESSOR_RESET_VAR_NUM), - static_cast(PROCESSOR_RESET_RESOLUTION), - PROCESSOR_RESET_VAR_NAME, PROCESSOR_RESET_UNIT_NAME, varCode, - uuid) {} + : Variable(parentSense, PROCESSOR_RESET_VAR_NUM, + PROCESSOR_RESET_RESOLUTION, PROCESSOR_RESET_VAR_NAME, + PROCESSOR_RESET_UNIT_NAME, varCode, uuid) {} /** * @brief Destroy the ProcessorStats_ResetCode object - no action needed. */ diff --git a/src/sensors/RainCounterI2C.h b/src/sensors/RainCounterI2C.h index 3ab25f86c..b8907a430 100644 --- a/src/sensors/RainCounterI2C.h +++ b/src/sensors/RainCounterI2C.h @@ -351,8 +351,7 @@ class RainCounterI2C_Tips : public Variable { explicit RainCounterI2C_Tips(RainCounterI2C* parentSense, const char* uuid = "", const char* varCode = BUCKET_TIPS_DEFAULT_CODE) - : Variable(parentSense, static_cast(BUCKET_TIPS_VAR_NUM), - static_cast(BUCKET_TIPS_RESOLUTION), + : Variable(parentSense, BUCKET_TIPS_VAR_NUM, BUCKET_TIPS_RESOLUTION, BUCKET_TIPS_VAR_NAME, BUCKET_TIPS_UNIT_NAME, varCode, uuid) { } /** @@ -384,8 +383,7 @@ class RainCounterI2C_Depth : public Variable { explicit RainCounterI2C_Depth( RainCounterI2C* parentSense, const char* uuid = "", const char* varCode = BUCKET_RAIN_DEFAULT_CODE) - : Variable(parentSense, static_cast(BUCKET_RAIN_VAR_NUM), - static_cast(BUCKET_RAIN_RESOLUTION), + : Variable(parentSense, BUCKET_RAIN_VAR_NUM, BUCKET_RAIN_RESOLUTION, BUCKET_RAIN_VAR_NAME, BUCKET_RAIN_UNIT_NAME, varCode, uuid) { } /** diff --git a/src/sensors/SensirionSHT4x.h b/src/sensors/SensirionSHT4x.h index 0488f5518..96bbe95f0 100644 --- a/src/sensors/SensirionSHT4x.h +++ b/src/sensors/SensirionSHT4x.h @@ -330,10 +330,9 @@ class SensirionSHT4x_Humidity : public Variable { explicit SensirionSHT4x_Humidity( SensirionSHT4x* parentSense, const char* uuid = "", const char* varCode = SHT4X_HUMIDITY_DEFAULT_CODE) - : Variable(parentSense, static_cast(SHT4X_HUMIDITY_VAR_NUM), - static_cast(SHT4X_HUMIDITY_RESOLUTION), - SHT4X_HUMIDITY_VAR_NAME, SHT4X_HUMIDITY_UNIT_NAME, varCode, - uuid) {} + : Variable(parentSense, SHT4X_HUMIDITY_VAR_NUM, + SHT4X_HUMIDITY_RESOLUTION, SHT4X_HUMIDITY_VAR_NAME, + SHT4X_HUMIDITY_UNIT_NAME, varCode, uuid) {} /** * @brief Destroy the SensirionSHT4x_Humidity object - no action needed. */ @@ -363,8 +362,7 @@ class SensirionSHT4x_Temp : public Variable { explicit SensirionSHT4x_Temp(SensirionSHT4x* parentSense, const char* uuid = "", const char* varCode = SHT4X_TEMP_DEFAULT_CODE) - : Variable(parentSense, static_cast(SHT4X_TEMP_VAR_NUM), - static_cast(SHT4X_TEMP_RESOLUTION), + : Variable(parentSense, SHT4X_TEMP_VAR_NUM, SHT4X_TEMP_RESOLUTION, SHT4X_TEMP_VAR_NAME, SHT4X_TEMP_UNIT_NAME, varCode, uuid) {} /** * @brief Destroy the SensirionSHT4x_Temp object - no action needed. diff --git a/src/sensors/TEConnectivityMS5837.h b/src/sensors/TEConnectivityMS5837.h index 82b123ab5..7cec6301d 100644 --- a/src/sensors/TEConnectivityMS5837.h +++ b/src/sensors/TEConnectivityMS5837.h @@ -584,8 +584,7 @@ class TEConnectivityMS5837_Temp : public Variable { explicit TEConnectivityMS5837_Temp( TEConnectivityMS5837* parentSense, const char* uuid = "", const char* varCode = MS5837_TEMP_DEFAULT_CODE) - : Variable(parentSense, static_cast(MS5837_TEMP_VAR_NUM), - static_cast(MS5837_TEMP_RESOLUTION), + : Variable(parentSense, MS5837_TEMP_VAR_NUM, MS5837_TEMP_RESOLUTION, MS5837_TEMP_VAR_NAME, MS5837_TEMP_UNIT_NAME, varCode, uuid) { } /** @@ -619,10 +618,9 @@ class TEConnectivityMS5837_Pressure : public Variable { explicit TEConnectivityMS5837_Pressure( TEConnectivityMS5837* parentSense, const char* uuid = "", const char* varCode = MS5837_PRESSURE_DEFAULT_CODE) - : Variable(parentSense, static_cast(MS5837_PRESSURE_VAR_NUM), - static_cast(MS5837_PRESSURE_RESOLUTION), - MS5837_PRESSURE_VAR_NAME, MS5837_PRESSURE_UNIT_NAME, varCode, - uuid) {} + : Variable(parentSense, MS5837_PRESSURE_VAR_NUM, + MS5837_PRESSURE_RESOLUTION, MS5837_PRESSURE_VAR_NAME, + MS5837_PRESSURE_UNIT_NAME, varCode, uuid) {} /** * @brief Destroy the TEConnectivityMS5837_Pressure object - no action * needed. @@ -655,8 +653,7 @@ class TEConnectivityMS5837_Depth : public Variable { explicit TEConnectivityMS5837_Depth( TEConnectivityMS5837* parentSense, const char* uuid = "", const char* varCode = MS5837_DEPTH_DEFAULT_CODE) - : Variable(parentSense, static_cast(MS5837_DEPTH_VAR_NUM), - static_cast(MS5837_DEPTH_RESOLUTION), + : Variable(parentSense, MS5837_DEPTH_VAR_NUM, MS5837_DEPTH_RESOLUTION, MS5837_DEPTH_VAR_NAME, MS5837_DEPTH_UNIT_NAME, varCode, uuid) {} /** @@ -690,10 +687,9 @@ class TEConnectivityMS5837_Altitude : public Variable { explicit TEConnectivityMS5837_Altitude( TEConnectivityMS5837* parentSense, const char* uuid = "", const char* varCode = MS5837_ALTITUDE_DEFAULT_CODE) - : Variable(parentSense, static_cast(MS5837_ALTITUDE_VAR_NUM), - static_cast(MS5837_ALTITUDE_RESOLUTION), - MS5837_ALTITUDE_VAR_NAME, MS5837_ALTITUDE_UNIT_NAME, varCode, - uuid) {} + : Variable(parentSense, MS5837_ALTITUDE_VAR_NUM, + MS5837_ALTITUDE_RESOLUTION, MS5837_ALTITUDE_VAR_NAME, + MS5837_ALTITUDE_UNIT_NAME, varCode, uuid) {} /** * @brief Destroy the TEConnectivityMS5837_Altitude object - no action * needed. diff --git a/src/sensors/TIADS1x15.h b/src/sensors/TIADS1x15.h index d7abd08a0..e40740759 100644 --- a/src/sensors/TIADS1x15.h +++ b/src/sensors/TIADS1x15.h @@ -575,8 +575,7 @@ class TIADS1x15_Voltage : public Variable { */ explicit TIADS1x15_Voltage(TIADS1x15* parentSense, const char* uuid = "", const char* varCode = TIADS1X15_DEFAULT_CODE) - : Variable(parentSense, static_cast(TIADS1X15_VAR_NUM), - static_cast(TIADS1X15_RESOLUTION), + : Variable(parentSense, TIADS1X15_VAR_NUM, TIADS1X15_RESOLUTION, TIADS1X15_VAR_NAME, TIADS1X15_UNIT_NAME, varCode, uuid) {} /** * @brief Destroy the TIADS1x15_Voltage object - no action needed. diff --git a/src/sensors/TIINA219.h b/src/sensors/TIINA219.h index d97e923f9..5b38e2331 100644 --- a/src/sensors/TIINA219.h +++ b/src/sensors/TIINA219.h @@ -344,10 +344,9 @@ class TIINA219_Current : public Variable { explicit TIINA219_Current( TIINA219* parentSense, const char* uuid = "", const char* varCode = INA219_CURRENT_MA_DEFAULT_CODE) - : Variable(parentSense, static_cast(INA219_CURRENT_MA_VAR_NUM), - static_cast(INA219_CURRENT_MA_RESOLUTION), - INA219_CURRENT_MA_VAR_NAME, INA219_CURRENT_MA_UNIT_NAME, - varCode, uuid) {} + : Variable(parentSense, INA219_CURRENT_MA_VAR_NUM, + INA219_CURRENT_MA_RESOLUTION, INA219_CURRENT_MA_VAR_NAME, + INA219_CURRENT_MA_UNIT_NAME, varCode, uuid) {} /** * @brief Destroy the TIINA219_Current object - no action needed. */ @@ -377,11 +376,9 @@ class TIINA219_Voltage : public Variable { explicit TIINA219_Voltage( TIINA219* parentSense, const char* uuid = "", const char* varCode = INA219_BUS_VOLTAGE_DEFAULT_CODE) - : Variable(parentSense, - static_cast(INA219_BUS_VOLTAGE_VAR_NUM), - static_cast(INA219_BUS_VOLTAGE_RESOLUTION), - INA219_BUS_VOLTAGE_VAR_NAME, INA219_BUS_VOLTAGE_UNIT_NAME, - varCode, uuid) {} + : Variable(parentSense, INA219_BUS_VOLTAGE_VAR_NUM, + INA219_BUS_VOLTAGE_RESOLUTION, INA219_BUS_VOLTAGE_VAR_NAME, + INA219_BUS_VOLTAGE_UNIT_NAME, varCode, uuid) {} /** * @brief Destroy the TIINA219_Voltage object - no action needed. */ @@ -419,10 +416,9 @@ class TIINA219_Power : public Variable { */ explicit TIINA219_Power(TIINA219* parentSense, const char* uuid = "", const char* varCode = INA219_POWER_MW_DEFAULT_CODE) - : Variable(parentSense, static_cast(INA219_POWER_MW_VAR_NUM), - static_cast(INA219_POWER_MW_RESOLUTION), - INA219_POWER_MW_VAR_NAME, INA219_POWER_MW_UNIT_NAME, varCode, - uuid) {} + : Variable(parentSense, INA219_POWER_MW_VAR_NUM, + INA219_POWER_MW_RESOLUTION, INA219_POWER_MW_VAR_NAME, + INA219_POWER_MW_UNIT_NAME, varCode, uuid) {} /** * @brief Destroy the TIINA219_Power object - no action needed. */ diff --git a/src/sensors/TallyCounterI2C.h b/src/sensors/TallyCounterI2C.h index 14cad4cc4..d8c3b0669 100644 --- a/src/sensors/TallyCounterI2C.h +++ b/src/sensors/TallyCounterI2C.h @@ -261,8 +261,7 @@ class TallyCounterI2C_Events : public Variable { explicit TallyCounterI2C_Events( TallyCounterI2C* parentSense, const char* uuid = "", const char* varCode = TALLY_EVENTS_DEFAULT_CODE) - : Variable(parentSense, static_cast(TALLY_EVENTS_VAR_NUM), - static_cast(TALLY_EVENTS_RESOLUTION), + : Variable(parentSense, TALLY_EVENTS_VAR_NUM, TALLY_EVENTS_RESOLUTION, TALLY_EVENTS_VAR_NAME, TALLY_EVENTS_UNIT_NAME, varCode, uuid) {} /** diff --git a/src/sensors/TurnerCyclops.h b/src/sensors/TurnerCyclops.h index 53fd9cd62..abf384551 100644 --- a/src/sensors/TurnerCyclops.h +++ b/src/sensors/TurnerCyclops.h @@ -700,10 +700,9 @@ class TurnerCyclops_Voltage : public Variable { explicit TurnerCyclops_Voltage( TurnerCyclops* parentSense, const char* uuid = "", const char* varCode = CYCLOPS_VOLTAGE_DEFAULT_CODE) - : Variable(parentSense, static_cast(CYCLOPS_VOLTAGE_VAR_NUM), - static_cast(CYCLOPS_VOLTAGE_RESOLUTION), - CYCLOPS_VOLTAGE_VAR_NAME, CYCLOPS_VOLTAGE_UNIT_NAME, varCode, - uuid) {} + : Variable(parentSense, CYCLOPS_VOLTAGE_VAR_NUM, + CYCLOPS_VOLTAGE_RESOLUTION, CYCLOPS_VOLTAGE_VAR_NAME, + CYCLOPS_VOLTAGE_UNIT_NAME, varCode, uuid) {} /** * @brief Destroy the Turner Cyclops Voltage object - no action needed. */ @@ -748,8 +747,7 @@ class TurnerCyclops_Chlorophyll : public Variable { explicit TurnerCyclops_Chlorophyll( TurnerCyclops* parentSense, const char* uuid = "", const char* varCode = CYCLOPS_CHLOROPHYLL_DEFAULT_CODE) - : Variable(parentSense, static_cast(CYCLOPS_VAR_NUM), - static_cast(CYCLOPS_RESOLUTION), + : Variable(parentSense, CYCLOPS_VAR_NUM, CYCLOPS_RESOLUTION, CYCLOPS_CHLOROPHYLL_VAR_NAME, CYCLOPS_CHLOROPHYLL_UNIT_NAME, varCode, uuid) {} /** @@ -796,8 +794,7 @@ class TurnerCyclops_Rhodamine : public Variable { explicit TurnerCyclops_Rhodamine( TurnerCyclops* parentSense, const char* uuid = "", const char* varCode = CYCLOPS_RHODAMINE_DEFAULT_CODE) - : Variable(parentSense, static_cast(CYCLOPS_VAR_NUM), - static_cast(CYCLOPS_RESOLUTION), + : Variable(parentSense, CYCLOPS_VAR_NUM, CYCLOPS_RESOLUTION, CYCLOPS_RHODAMINE_VAR_NAME, CYCLOPS_RHODAMINE_UNIT_NAME, varCode, uuid) {} /** @@ -844,8 +841,7 @@ class TurnerCyclops_Fluorescein : public Variable { explicit TurnerCyclops_Fluorescein( TurnerCyclops* parentSense, const char* uuid = "", const char* varCode = CYCLOPS_FLUORESCEIN_DEFAULT_CODE) - : Variable(parentSense, static_cast(CYCLOPS_VAR_NUM), - static_cast(CYCLOPS_RESOLUTION), + : Variable(parentSense, CYCLOPS_VAR_NUM, CYCLOPS_RESOLUTION, CYCLOPS_FLUORESCEIN_VAR_NAME, CYCLOPS_FLUORESCEIN_UNIT_NAME, varCode, uuid) {} /** @@ -893,8 +889,7 @@ class TurnerCyclops_Phycocyanin : public Variable { explicit TurnerCyclops_Phycocyanin( TurnerCyclops* parentSense, const char* uuid = "", const char* varCode = CYCLOPS_PHYCOCYANIN_DEFAULT_CODE) - : Variable(parentSense, static_cast(CYCLOPS_VAR_NUM), - static_cast(CYCLOPS_RESOLUTION), + : Variable(parentSense, CYCLOPS_VAR_NUM, CYCLOPS_RESOLUTION, CYCLOPS_PHYCOCYANIN_VAR_NAME, CYCLOPS_PHYCOCYANIN_UNIT_NAME, varCode, uuid) {} /** @@ -942,8 +937,7 @@ class TurnerCyclops_Phycoerythrin : public Variable { explicit TurnerCyclops_Phycoerythrin( TurnerCyclops* parentSense, const char* uuid = "", const char* varCode = CYCLOPS_PHYCOERYTHRIN_DEFAULT_CODE) - : Variable(parentSense, static_cast(CYCLOPS_VAR_NUM), - static_cast(CYCLOPS_RESOLUTION), + : Variable(parentSense, CYCLOPS_VAR_NUM, CYCLOPS_RESOLUTION, CYCLOPS_PHYCOERYTHRIN_VAR_NAME, CYCLOPS_PHYCOERYTHRIN_UNIT_NAME, varCode, uuid) {} /** @@ -994,8 +988,7 @@ class TurnerCyclops_CDOM : public Variable { explicit TurnerCyclops_CDOM(TurnerCyclops* parentSense, const char* uuid = "", const char* varCode = CYCLOPS_CDOM_DEFAULT_CODE) - : Variable(parentSense, static_cast(CYCLOPS_VAR_NUM), - static_cast(CYCLOPS_RESOLUTION), + : Variable(parentSense, CYCLOPS_VAR_NUM, CYCLOPS_RESOLUTION, CYCLOPS_CDOM_VAR_NAME, CYCLOPS_CDOM_UNIT_NAME, varCode, uuid) {} /** @@ -1044,8 +1037,7 @@ class TurnerCyclops_CrudeOil : public Variable { explicit TurnerCyclops_CrudeOil( TurnerCyclops* parentSense, const char* uuid = "", const char* varCode = CYCLOPS_CRUDE_OIL_DEFAULT_CODE) - : Variable(parentSense, static_cast(CYCLOPS_VAR_NUM), - static_cast(CYCLOPS_RESOLUTION), + : Variable(parentSense, CYCLOPS_VAR_NUM, CYCLOPS_RESOLUTION, CYCLOPS_CRUDE_OIL_VAR_NAME, CYCLOPS_CRUDE_OIL_UNIT_NAME, varCode, uuid) {} /** @@ -1095,8 +1087,7 @@ class TurnerCyclops_Brighteners : public Variable { explicit TurnerCyclops_Brighteners( TurnerCyclops* parentSense, const char* uuid = "", const char* varCode = CYCLOPS_BRIGHTENERS_DEFAULT_CODE) - : Variable(parentSense, static_cast(CYCLOPS_VAR_NUM), - static_cast(CYCLOPS_RESOLUTION), + : Variable(parentSense, CYCLOPS_VAR_NUM, CYCLOPS_RESOLUTION, CYCLOPS_BRIGHTENERS_VAR_NAME, CYCLOPS_BRIGHTENERS_UNIT_NAME, varCode, uuid) {} /** @@ -1142,8 +1133,7 @@ class TurnerCyclops_Turbidity : public Variable { explicit TurnerCyclops_Turbidity( TurnerCyclops* parentSense, const char* uuid = "", const char* varCode = CYCLOPS_TURBIDITY_DEFAULT_CODE) - : Variable(parentSense, static_cast(CYCLOPS_VAR_NUM), - static_cast(CYCLOPS_RESOLUTION), + : Variable(parentSense, CYCLOPS_VAR_NUM, CYCLOPS_RESOLUTION, CYCLOPS_TURBIDITY_VAR_NAME, CYCLOPS_TURBIDITY_UNIT_NAME, varCode, uuid) {} /** @@ -1191,8 +1181,7 @@ class TurnerCyclops_PTSA : public Variable { explicit TurnerCyclops_PTSA(TurnerCyclops* parentSense, const char* uuid = "", const char* varCode = CYCLOPS_PTSA_DEFAULT_CODE) - : Variable(parentSense, static_cast(CYCLOPS_VAR_NUM), - static_cast(CYCLOPS_RESOLUTION), + : Variable(parentSense, CYCLOPS_VAR_NUM, CYCLOPS_RESOLUTION, CYCLOPS_PTSA_VAR_NAME, CYCLOPS_PTSA_UNIT_NAME, varCode, uuid) {} /** @@ -1240,8 +1229,7 @@ class TurnerCyclops_BTEX : public Variable { explicit TurnerCyclops_BTEX(TurnerCyclops* parentSense, const char* uuid = "", const char* varCode = CYCLOPS_BTEX_DEFAULT_CODE) - : Variable(parentSense, static_cast(CYCLOPS_VAR_NUM), - static_cast(CYCLOPS_RESOLUTION), + : Variable(parentSense, CYCLOPS_VAR_NUM, CYCLOPS_RESOLUTION, CYCLOPS_BTEX_VAR_NAME, CYCLOPS_BTEX_UNIT_NAME, varCode, uuid) {} /** @@ -1288,8 +1276,7 @@ class TurnerCyclops_Tryptophan : public Variable { explicit TurnerCyclops_Tryptophan( TurnerCyclops* parentSense, const char* uuid = "", const char* varCode = CYCLOPS_TRYPTOPHAN_DEFAULT_CODE) - : Variable(parentSense, static_cast(CYCLOPS_VAR_NUM), - static_cast(CYCLOPS_RESOLUTION), + : Variable(parentSense, CYCLOPS_VAR_NUM, CYCLOPS_RESOLUTION, CYCLOPS_TRYPTOPHAN_VAR_NAME, CYCLOPS_TRYPTOPHAN_UNIT_NAME, varCode, uuid) {} /** @@ -1337,8 +1324,7 @@ class TurnerCyclops_RedChlorophyll : public Variable { explicit TurnerCyclops_RedChlorophyll( TurnerCyclops* parentSense, const char* uuid = "", const char* varCode = CYCLOPS_RED_CHLOROPHYLL_DEFAULT_CODE) - : Variable(parentSense, static_cast(CYCLOPS_VAR_NUM), - static_cast(CYCLOPS_RESOLUTION), + : Variable(parentSense, CYCLOPS_VAR_NUM, CYCLOPS_RESOLUTION, CYCLOPS_RED_CHLOROPHYLL_VAR_NAME, CYCLOPS_RED_CHLOROPHYLL_UNIT_NAME, varCode, uuid) {} /** diff --git a/src/sensors/TurnerTurbidityPlus.h b/src/sensors/TurnerTurbidityPlus.h index cef7828de..c754441f6 100644 --- a/src/sensors/TurnerTurbidityPlus.h +++ b/src/sensors/TurnerTurbidityPlus.h @@ -386,9 +386,8 @@ class TurnerTurbidityPlus_Voltage : public Variable { explicit TurnerTurbidityPlus_Voltage( TurnerTurbidityPlus* parentSense, const char* uuid = "", const char* varCode = TURBIDITY_PLUS_VOLTAGE_DEFAULT_CODE) - : Variable(parentSense, - static_cast(TURBIDITY_PLUS_VOLTAGE_VAR_NUM), - static_cast(TURBIDITY_PLUS_VOLTAGE_RESOLUTION), + : Variable(parentSense, TURBIDITY_PLUS_VOLTAGE_VAR_NUM, + TURBIDITY_PLUS_VOLTAGE_RESOLUTION, TURBIDITY_PLUS_VOLTAGE_VAR_NAME, TURBIDITY_PLUS_VOLTAGE_UNIT_NAME, varCode, uuid) {} /** @@ -424,10 +423,9 @@ class TurnerTurbidityPlus_Turbidity : public Variable { explicit TurnerTurbidityPlus_Turbidity( TurnerTurbidityPlus* parentSense, const char* uuid = "", const char* varCode = TURBIDITY_PLUS_DEFAULT_CODE) - : Variable(parentSense, static_cast(TURBIDITY_PLUS_VAR_NUM), - static_cast(TURBIDITY_PLUS_RESOLUTION), - TURBIDITY_PLUS_VAR_NAME, TURBIDITY_PLUS_UNIT_NAME, varCode, - uuid) {} + : Variable(parentSense, TURBIDITY_PLUS_VAR_NUM, + TURBIDITY_PLUS_RESOLUTION, TURBIDITY_PLUS_VAR_NAME, + TURBIDITY_PLUS_UNIT_NAME, varCode, uuid) {} /** * @brief Destroy the TurnerTurbidityPlus_Turbidity object - no action * needed. diff --git a/src/sensors/VegaPuls21.h b/src/sensors/VegaPuls21.h index bcdef607f..fb712965d 100644 --- a/src/sensors/VegaPuls21.h +++ b/src/sensors/VegaPuls21.h @@ -343,10 +343,9 @@ class VegaPuls21_Stage : public Variable { explicit VegaPuls21_Stage( VegaPuls21* parentSense, const char* uuid = "", const char* varCode = VEGAPULS21_STAGE_DEFAULT_CODE) - : Variable(parentSense, static_cast(VEGAPULS21_STAGE_VAR_NUM), - static_cast(VEGAPULS21_STAGE_RESOLUTION), - VEGAPULS21_STAGE_VAR_NAME, VEGAPULS21_STAGE_UNIT_NAME, - varCode, uuid) {} + : Variable(parentSense, VEGAPULS21_STAGE_VAR_NUM, + VEGAPULS21_STAGE_RESOLUTION, VEGAPULS21_STAGE_VAR_NAME, + VEGAPULS21_STAGE_UNIT_NAME, varCode, uuid) {} /** * @brief Destroy the VegaPuls21_Stage object - no action needed. */ @@ -378,11 +377,9 @@ class VegaPuls21_Distance : public Variable { explicit VegaPuls21_Distance( VegaPuls21* parentSense, const char* uuid = "", const char* varCode = VEGAPULS21_DISTANCE_DEFAULT_CODE) - : Variable(parentSense, - static_cast(VEGAPULS21_DISTANCE_VAR_NUM), - static_cast(VEGAPULS21_DISTANCE_RESOLUTION), - VEGAPULS21_DISTANCE_VAR_NAME, VEGAPULS21_DISTANCE_UNIT_NAME, - varCode, uuid) {} + : Variable(parentSense, VEGAPULS21_DISTANCE_VAR_NUM, + VEGAPULS21_DISTANCE_RESOLUTION, VEGAPULS21_DISTANCE_VAR_NAME, + VEGAPULS21_DISTANCE_UNIT_NAME, varCode, uuid) {} /** * @brief Destroy the VegaPuls21_Distance object - no action needed. */ @@ -413,10 +410,9 @@ class VegaPuls21_Temp : public Variable { */ explicit VegaPuls21_Temp(VegaPuls21* parentSense, const char* uuid = "", const char* varCode = VEGAPULS21_TEMP_DEFAULT_CODE) - : Variable(parentSense, static_cast(VEGAPULS21_TEMP_VAR_NUM), - static_cast(VEGAPULS21_TEMP_RESOLUTION), - VEGAPULS21_TEMP_VAR_NAME, VEGAPULS21_TEMP_UNIT_NAME, varCode, - uuid) {} + : Variable(parentSense, VEGAPULS21_TEMP_VAR_NUM, + VEGAPULS21_TEMP_RESOLUTION, VEGAPULS21_TEMP_VAR_NAME, + VEGAPULS21_TEMP_UNIT_NAME, varCode, uuid) {} /** * @brief Destroy the VegaPuls21_Temp object - no action needed. */ @@ -448,9 +444,8 @@ class VegaPuls21_Reliability : public Variable { explicit VegaPuls21_Reliability( VegaPuls21* parentSense, const char* uuid = "", const char* varCode = VEGAPULS21_RELIABILITY_DEFAULT_CODE) - : Variable(parentSense, - static_cast(VEGAPULS21_RELIABILITY_VAR_NUM), - static_cast(VEGAPULS21_RELIABILITY_RESOLUTION), + : Variable(parentSense, VEGAPULS21_RELIABILITY_VAR_NUM, + VEGAPULS21_RELIABILITY_RESOLUTION, VEGAPULS21_RELIABILITY_VAR_NAME, VEGAPULS21_RELIABILITY_UNIT_NAME, varCode, uuid) {} /** @@ -485,9 +480,8 @@ class VegaPuls21_ErrorCode : public Variable { explicit VegaPuls21_ErrorCode( VegaPuls21* parentSense, const char* uuid = "", const char* varCode = VEGAPULS21_ERRORCODE_DEFAULT_CODE) - : Variable(parentSense, - static_cast(VEGAPULS21_ERRORCODE_VAR_NUM), - static_cast(VEGAPULS21_ERRORCODE_RESOLUTION), + : Variable(parentSense, VEGAPULS21_ERRORCODE_VAR_NUM, + VEGAPULS21_ERRORCODE_RESOLUTION, VEGAPULS21_ERRORCODE_VAR_NAME, VEGAPULS21_ERRORCODE_UNIT_NAME, varCode, uuid) {} /** diff --git a/src/sensors/YosemitechY4000.h b/src/sensors/YosemitechY4000.h index 8edf2e524..62943729f 100644 --- a/src/sensors/YosemitechY4000.h +++ b/src/sensors/YosemitechY4000.h @@ -433,8 +433,7 @@ class YosemitechY4000_DOmgL : public Variable { explicit YosemitechY4000_DOmgL( YosemitechY4000* parentSense, const char* uuid = "", const char* varCode = Y4000_DOMGL_DEFAULT_CODE) - : Variable(parentSense, static_cast(Y4000_DOMGL_VAR_NUM), - static_cast(Y4000_DOMGL_RESOLUTION), + : Variable(parentSense, Y4000_DOMGL_VAR_NUM, Y4000_DOMGL_RESOLUTION, Y4000_DOMGL_VAR_NAME, Y4000_DOMGL_UNIT_NAME, varCode, uuid) { } /** @@ -467,8 +466,7 @@ class YosemitechY4000_Turbidity : public Variable { explicit YosemitechY4000_Turbidity( YosemitechY4000* parentSense, const char* uuid = "", const char* varCode = Y4000_TURB_DEFAULT_CODE) - : Variable(parentSense, static_cast(Y4000_TURB_VAR_NUM), - static_cast(Y4000_TURB_RESOLUTION), + : Variable(parentSense, Y4000_TURB_VAR_NUM, Y4000_TURB_RESOLUTION, Y4000_TURB_VAR_NAME, Y4000_TURB_UNIT_NAME, varCode, uuid) {} /** * @brief Destroy the YosemitechY4000_Turbidity object - no action needed. @@ -500,8 +498,7 @@ class YosemitechY4000_Cond : public Variable { explicit YosemitechY4000_Cond(YosemitechY4000* parentSense, const char* uuid = "", const char* varCode = Y4000_COND_DEFAULT_CODE) - : Variable(parentSense, static_cast(Y4000_COND_VAR_NUM), - static_cast(Y4000_COND_RESOLUTION), + : Variable(parentSense, Y4000_COND_VAR_NUM, Y4000_COND_RESOLUTION, Y4000_COND_VAR_NAME, Y4000_COND_UNIT_NAME, varCode, uuid) {} /** * @brief Destroy the YosemitechY4000_Cond object - no action needed. @@ -533,9 +530,8 @@ class YosemitechY4000_pH : public Variable { explicit YosemitechY4000_pH(YosemitechY4000* parentSense, const char* uuid = "", const char* varCode = Y4000_PH_DEFAULT_CODE) - : Variable(parentSense, static_cast(Y4000_PH_VAR_NUM), - static_cast(Y4000_PH_RESOLUTION), Y4000_PH_VAR_NAME, - Y4000_PH_UNIT_NAME, varCode, uuid) {} + : Variable(parentSense, Y4000_PH_VAR_NUM, Y4000_PH_RESOLUTION, + Y4000_PH_VAR_NAME, Y4000_PH_UNIT_NAME, varCode, uuid) {} /** * @brief Destroy the YosemitechY4000_pH object - no action needed. */ @@ -566,8 +562,7 @@ class YosemitechY4000_Temp : public Variable { explicit YosemitechY4000_Temp(YosemitechY4000* parentSense, const char* uuid = "", const char* varCode = Y4000_TEMP_DEFAULT_CODE) - : Variable(parentSense, static_cast(Y4000_TEMP_VAR_NUM), - static_cast(Y4000_TEMP_RESOLUTION), + : Variable(parentSense, Y4000_TEMP_VAR_NUM, Y4000_TEMP_RESOLUTION, Y4000_TEMP_VAR_NAME, Y4000_TEMP_UNIT_NAME, varCode, uuid) {} /** * @brief Destroy the YosemitechY4000_Temp object - no action needed. @@ -599,8 +594,7 @@ class YosemitechY4000_ORP : public Variable { explicit YosemitechY4000_ORP(YosemitechY4000* parentSense, const char* uuid = "", const char* varCode = Y4000_ORP_DEFAULT_CODE) - : Variable(parentSense, static_cast(Y4000_ORP_VAR_NUM), - static_cast(Y4000_ORP_RESOLUTION), + : Variable(parentSense, Y4000_ORP_VAR_NUM, Y4000_ORP_RESOLUTION, Y4000_ORP_VAR_NAME, Y4000_ORP_UNIT_NAME, varCode, uuid) {} /** * @brief Destroy the YosemitechY4000_ORP object - no action needed. @@ -632,8 +626,7 @@ class YosemitechY4000_Chlorophyll : public Variable { explicit YosemitechY4000_Chlorophyll( YosemitechY4000* parentSense, const char* uuid = "", const char* varCode = Y4000_CHLORO_DEFAULT_CODE) - : Variable(parentSense, static_cast(Y4000_CHLORO_VAR_NUM), - static_cast(Y4000_CHLORO_RESOLUTION), + : Variable(parentSense, Y4000_CHLORO_VAR_NUM, Y4000_CHLORO_RESOLUTION, Y4000_CHLORO_VAR_NAME, Y4000_CHLORO_UNIT_NAME, varCode, uuid) {} /** @@ -667,8 +660,7 @@ class YosemitechY4000_BGA : public Variable { explicit YosemitechY4000_BGA(YosemitechY4000* parentSense, const char* uuid = "", const char* varCode = Y4000_BGA_DEFAULT_CODE) - : Variable(parentSense, static_cast(Y4000_BGA_VAR_NUM), - static_cast(Y4000_BGA_RESOLUTION), + : Variable(parentSense, Y4000_BGA_VAR_NUM, Y4000_BGA_RESOLUTION, Y4000_BGA_VAR_NAME, Y4000_BGA_UNIT_NAME, varCode, uuid) {} /** * @brief Destroy the YosemitechY4000_BGA object - no action needed. diff --git a/src/sensors/YosemitechY504.h b/src/sensors/YosemitechY504.h index fc5a4b511..f1d061b09 100644 --- a/src/sensors/YosemitechY504.h +++ b/src/sensors/YosemitechY504.h @@ -267,8 +267,7 @@ class YosemitechY504_DOpct : public Variable { explicit YosemitechY504_DOpct(YosemitechY504* parentSense, const char* uuid = "", const char* varCode = Y504_DOPCT_DEFAULT_CODE) - : Variable(parentSense, static_cast(Y504_DOPCT_VAR_NUM), - static_cast(Y504_DOPCT_RESOLUTION), + : Variable(parentSense, Y504_DOPCT_VAR_NUM, Y504_DOPCT_RESOLUTION, Y504_DOPCT_VAR_NAME, Y504_DOPCT_UNIT_NAME, varCode, uuid) {} /** * @brief Destroy the YosemitechY504_DOpct object - no action needed. @@ -301,8 +300,7 @@ class YosemitechY504_Temp : public Variable { explicit YosemitechY504_Temp(YosemitechY504* parentSense, const char* uuid = "", const char* varCode = Y504_TEMP_DEFAULT_CODE) - : Variable(parentSense, static_cast(Y504_TEMP_VAR_NUM), - static_cast(Y504_TEMP_RESOLUTION), + : Variable(parentSense, Y504_TEMP_VAR_NUM, Y504_TEMP_RESOLUTION, Y504_TEMP_VAR_NAME, Y504_TEMP_UNIT_NAME, varCode, uuid) {} /** * @brief Destroy the YosemitechY504_Temp object - no action needed. @@ -335,8 +333,7 @@ class YosemitechY504_DOmgL : public Variable { explicit YosemitechY504_DOmgL(YosemitechY504* parentSense, const char* uuid = "", const char* varCode = Y504_DOMGL_DEFAULT_CODE) - : Variable(parentSense, static_cast(Y504_DOMGL_VAR_NUM), - static_cast(Y504_DOMGL_RESOLUTION), + : Variable(parentSense, Y504_DOMGL_VAR_NUM, Y504_DOMGL_RESOLUTION, Y504_DOMGL_VAR_NAME, Y504_DOMGL_UNIT_NAME, varCode, uuid) {} /** * @brief Destroy the YosemitechY504_DOmgL object - no action needed. diff --git a/src/sensors/YosemitechY510.h b/src/sensors/YosemitechY510.h index 3ffbef067..82b5286b7 100644 --- a/src/sensors/YosemitechY510.h +++ b/src/sensors/YosemitechY510.h @@ -229,8 +229,7 @@ class YosemitechY510_Turbidity : public Variable { explicit YosemitechY510_Turbidity( YosemitechY510* parentSense, const char* uuid = "", const char* varCode = Y510_TURB_DEFAULT_CODE) - : Variable(parentSense, static_cast(Y510_TURB_VAR_NUM), - static_cast(Y510_TURB_RESOLUTION), + : Variable(parentSense, Y510_TURB_VAR_NUM, Y510_TURB_RESOLUTION, Y510_TURB_VAR_NAME, Y510_TURB_UNIT_NAME, varCode, uuid) {} /** * @brief Destroy the YosemitechY510_Turbidity object - no action needed. @@ -263,8 +262,7 @@ class YosemitechY510_Temp : public Variable { explicit YosemitechY510_Temp(YosemitechY510* parentSense, const char* uuid = "", const char* varCode = Y510_TEMP_DEFAULT_CODE) - : Variable(parentSense, static_cast(Y510_TEMP_VAR_NUM), - static_cast(Y510_TEMP_RESOLUTION), + : Variable(parentSense, Y510_TEMP_VAR_NUM, Y510_TEMP_RESOLUTION, Y510_TEMP_VAR_NAME, Y510_TEMP_UNIT_NAME, varCode, uuid) {} /** * @brief Destroy the YosemitechY510_Temp object - no action needed. diff --git a/src/sensors/YosemitechY511.h b/src/sensors/YosemitechY511.h index 3e1fc3bb0..1831b9000 100644 --- a/src/sensors/YosemitechY511.h +++ b/src/sensors/YosemitechY511.h @@ -243,8 +243,7 @@ class YosemitechY511_Turbidity : public Variable { explicit YosemitechY511_Turbidity( YosemitechY511* parentSense, const char* uuid = "", const char* varCode = Y511_TURB_DEFAULT_CODE) - : Variable(parentSense, static_cast(Y511_TURB_VAR_NUM), - static_cast(Y511_TURB_RESOLUTION), + : Variable(parentSense, Y511_TURB_VAR_NUM, Y511_TURB_RESOLUTION, Y511_TURB_VAR_NAME, Y511_TURB_UNIT_NAME, varCode, uuid) {} /** * @brief Destroy the YosemitechY511_Turbidity object - no action needed. @@ -277,8 +276,7 @@ class YosemitechY511_Temp : public Variable { explicit YosemitechY511_Temp(YosemitechY511* parentSense, const char* uuid = "", const char* varCode = Y511_TEMP_DEFAULT_CODE) - : Variable(parentSense, static_cast(Y511_TEMP_VAR_NUM), - static_cast(Y511_TEMP_RESOLUTION), + : Variable(parentSense, Y511_TEMP_VAR_NUM, Y511_TEMP_RESOLUTION, Y511_TEMP_VAR_NAME, Y511_TEMP_UNIT_NAME, varCode, uuid) {} /** * @brief Destroy the YosemitechY511_Temp object - no action needed. diff --git a/src/sensors/YosemitechY513.h b/src/sensors/YosemitechY513.h index 3c095ba33..808e6010d 100644 --- a/src/sensors/YosemitechY513.h +++ b/src/sensors/YosemitechY513.h @@ -230,9 +230,8 @@ class YosemitechY513_BGA : public Variable { explicit YosemitechY513_BGA(YosemitechY513* parentSense, const char* uuid = "", const char* varCode = Y513_BGA_DEFAULT_CODE) - : Variable(parentSense, static_cast(Y513_BGA_VAR_NUM), - static_cast(Y513_BGA_RESOLUTION), Y513_BGA_VAR_NAME, - Y513_BGA_UNIT_NAME, varCode, uuid) {} + : Variable(parentSense, Y513_BGA_VAR_NUM, Y513_BGA_RESOLUTION, + Y513_BGA_VAR_NAME, Y513_BGA_UNIT_NAME, varCode, uuid) {} /** * @brief Destroy the YosemitechY513_BGA() object - no action * needed. @@ -265,8 +264,7 @@ class YosemitechY513_Temp : public Variable { explicit YosemitechY513_Temp(YosemitechY513* parentSense, const char* uuid = "", const char* varCode = Y513_TEMP_DEFAULT_CODE) - : Variable(parentSense, static_cast(Y513_TEMP_VAR_NUM), - static_cast(Y513_TEMP_RESOLUTION), + : Variable(parentSense, Y513_TEMP_VAR_NUM, Y513_TEMP_RESOLUTION, Y513_TEMP_VAR_NAME, Y513_TEMP_UNIT_NAME, varCode, uuid) {} /** * @brief Destroy the YosemitechY513_Temp object - no action needed. diff --git a/src/sensors/YosemitechY514.h b/src/sensors/YosemitechY514.h index b9a4620f0..5d561f65e 100644 --- a/src/sensors/YosemitechY514.h +++ b/src/sensors/YosemitechY514.h @@ -232,8 +232,7 @@ class YosemitechY514_Chlorophyll : public Variable { explicit YosemitechY514_Chlorophyll( YosemitechY514* parentSense, const char* uuid = "", const char* varCode = Y514_CHLORO_DEFAULT_CODE) - : Variable(parentSense, static_cast(Y514_CHLORO_VAR_NUM), - static_cast(Y514_CHLORO_RESOLUTION), + : Variable(parentSense, Y514_CHLORO_VAR_NUM, Y514_CHLORO_RESOLUTION, Y514_CHLORO_VAR_NAME, Y514_CHLORO_UNIT_NAME, varCode, uuid) { } /** @@ -268,8 +267,7 @@ class YosemitechY514_Temp : public Variable { explicit YosemitechY514_Temp(YosemitechY514* parentSense, const char* uuid = "", const char* varCode = Y514_TEMP_DEFAULT_CODE) - : Variable(parentSense, static_cast(Y514_TEMP_VAR_NUM), - static_cast(Y514_TEMP_RESOLUTION), + : Variable(parentSense, Y514_TEMP_VAR_NUM, Y514_TEMP_RESOLUTION, Y514_TEMP_VAR_NAME, Y514_TEMP_UNIT_NAME, varCode, uuid) {} /** * @brief Destroy the YosemitechY514_Temp object - no action needed. diff --git a/src/sensors/YosemitechY520.h b/src/sensors/YosemitechY520.h index eeae96cef..f16269181 100644 --- a/src/sensors/YosemitechY520.h +++ b/src/sensors/YosemitechY520.h @@ -230,8 +230,7 @@ class YosemitechY520_Cond : public Variable { explicit YosemitechY520_Cond(YosemitechY520* parentSense, const char* uuid = "", const char* varCode = Y520_COND_DEFAULT_CODE) - : Variable(parentSense, static_cast(Y520_COND_VAR_NUM), - static_cast(Y520_COND_RESOLUTION), + : Variable(parentSense, Y520_COND_VAR_NUM, Y520_COND_RESOLUTION, Y520_COND_VAR_NAME, Y520_COND_UNIT_NAME, varCode, uuid) {} /** * @brief Destroy the YosemitechY520_Cond object - no action needed. @@ -264,8 +263,7 @@ class YosemitechY520_Temp : public Variable { explicit YosemitechY520_Temp(YosemitechY520* parentSense, const char* uuid = "", const char* varCode = Y520_TEMP_DEFAULT_CODE) - : Variable(parentSense, static_cast(Y520_TEMP_VAR_NUM), - static_cast(Y520_TEMP_RESOLUTION), + : Variable(parentSense, Y520_TEMP_VAR_NUM, Y520_TEMP_RESOLUTION, Y520_TEMP_VAR_NAME, Y520_TEMP_UNIT_NAME, varCode, uuid) {} /** * @brief Destroy the YosemitechY520_Temp object - no action needed. diff --git a/src/sensors/YosemitechY532.h b/src/sensors/YosemitechY532.h index 01f22e5b1..2242680e6 100644 --- a/src/sensors/YosemitechY532.h +++ b/src/sensors/YosemitechY532.h @@ -260,9 +260,8 @@ class YosemitechY532_pH : public Variable { explicit YosemitechY532_pH(YosemitechY532* parentSense, const char* uuid = "", const char* varCode = Y532_PH_DEFAULT_CODE) - : Variable(parentSense, static_cast(Y532_PH_VAR_NUM), - static_cast(Y532_PH_RESOLUTION), Y532_PH_VAR_NAME, - Y532_PH_UNIT_NAME, varCode, uuid) {} + : Variable(parentSense, Y532_PH_VAR_NUM, Y532_PH_RESOLUTION, + Y532_PH_VAR_NAME, Y532_PH_UNIT_NAME, varCode, uuid) {} /** * @brief Destroy the YosemitechY532_pH object - no action needed. */ @@ -294,8 +293,7 @@ class YosemitechY532_Temp : public Variable { explicit YosemitechY532_Temp(YosemitechY532* parentSense, const char* uuid = "", const char* varCode = Y532_TEMP_DEFAULT_CODE) - : Variable(parentSense, static_cast(Y532_TEMP_VAR_NUM), - static_cast(Y532_TEMP_RESOLUTION), + : Variable(parentSense, Y532_TEMP_VAR_NUM, Y532_TEMP_RESOLUTION, Y532_TEMP_VAR_NAME, Y532_TEMP_UNIT_NAME, varCode, uuid) {} /** * @brief Destroy the YosemitechY532_Temp object - no action needed. @@ -328,8 +326,7 @@ class YosemitechY532_Voltage : public Variable { explicit YosemitechY532_Voltage( YosemitechY532* parentSense, const char* uuid = "", const char* varCode = Y532_VOLTAGE_DEFAULT_CODE) - : Variable(parentSense, static_cast(Y532_VOLTAGE_VAR_NUM), - static_cast(Y532_VOLTAGE_RESOLUTION), + : Variable(parentSense, Y532_VOLTAGE_VAR_NUM, Y532_VOLTAGE_RESOLUTION, Y532_VOLTAGE_VAR_NAME, Y532_VOLTAGE_UNIT_NAME, varCode, uuid) {} /** diff --git a/src/sensors/YosemitechY533.h b/src/sensors/YosemitechY533.h index 85f974930..eef6c29e2 100644 --- a/src/sensors/YosemitechY533.h +++ b/src/sensors/YosemitechY533.h @@ -232,9 +232,8 @@ class YosemitechY533_ORP : public Variable { explicit YosemitechY533_ORP(YosemitechY533* parentSense, const char* uuid = "", const char* varCode = Y533_ORP_DEFAULT_CODE) - : Variable(parentSense, static_cast(Y533_ORP_VAR_NUM), - static_cast(Y533_ORP_RESOLUTION), Y533_ORP_VAR_NAME, - Y533_ORP_UNIT_NAME, varCode, uuid) {} + : Variable(parentSense, Y533_ORP_VAR_NUM, Y533_ORP_RESOLUTION, + Y533_ORP_VAR_NAME, Y533_ORP_UNIT_NAME, varCode, uuid) {} /** * @brief Destroy the YosemitechY533_ORP object - no action needed. */ @@ -266,8 +265,7 @@ class YosemitechY533_Temp : public Variable { explicit YosemitechY533_Temp(YosemitechY533* parentSense, const char* uuid = "", const char* varCode = Y533_TEMP_DEFAULT_CODE) - : Variable(parentSense, static_cast(Y533_TEMP_VAR_NUM), - static_cast(Y533_TEMP_RESOLUTION), + : Variable(parentSense, Y533_TEMP_VAR_NUM, Y533_TEMP_RESOLUTION, Y533_TEMP_VAR_NAME, Y533_TEMP_UNIT_NAME, varCode, uuid) {} /** * @brief Destroy the YosemitechY533_Temp object - no action needed. diff --git a/src/sensors/YosemitechY551.h b/src/sensors/YosemitechY551.h index 7f583162a..b7a064dfa 100644 --- a/src/sensors/YosemitechY551.h +++ b/src/sensors/YosemitechY551.h @@ -264,9 +264,8 @@ class YosemitechY551_COD : public Variable { explicit YosemitechY551_COD(YosemitechY551* parentSense, const char* uuid = "", const char* varCode = Y551_COD_DEFAULT_CODE) - : Variable(parentSense, static_cast(Y551_COD_VAR_NUM), - static_cast(Y551_COD_RESOLUTION), Y551_COD_VAR_NAME, - Y551_COD_UNIT_NAME, varCode, uuid) {} + : Variable(parentSense, Y551_COD_VAR_NUM, Y551_COD_RESOLUTION, + Y551_COD_VAR_NAME, Y551_COD_UNIT_NAME, varCode, uuid) {} /** * @brief Destroy the YosemitechY551_COD object - no action needed. */ @@ -298,8 +297,7 @@ class YosemitechY551_Temp : public Variable { explicit YosemitechY551_Temp(YosemitechY551* parentSense, const char* uuid = "", const char* varCode = Y551_TEMP_DEFAULT_CODE) - : Variable(parentSense, static_cast(Y551_TEMP_VAR_NUM), - static_cast(Y551_TEMP_RESOLUTION), + : Variable(parentSense, Y551_TEMP_VAR_NUM, Y551_TEMP_RESOLUTION, Y551_TEMP_VAR_NAME, Y551_TEMP_UNIT_NAME, varCode, uuid) {} /** * @brief Destroy the YosemitechY551_Temp object - no action needed. @@ -332,8 +330,7 @@ class YosemitechY551_Turbidity : public Variable { explicit YosemitechY551_Turbidity( YosemitechY551* parentSense, const char* uuid = "", const char* varCode = Y551_TURB_DEFAULT_CODE) - : Variable(parentSense, static_cast(Y551_TURB_VAR_NUM), - static_cast(Y551_TURB_RESOLUTION), + : Variable(parentSense, Y551_TURB_VAR_NUM, Y551_TURB_RESOLUTION, Y551_TURB_VAR_NAME, Y551_TURB_UNIT_NAME, varCode, uuid) {} /** * @brief Destroy the YosemitechY551_Turbidity object - no action needed. diff --git a/src/sensors/YosemitechY560.h b/src/sensors/YosemitechY560.h index 9d2feb9dc..63d1fead5 100644 --- a/src/sensors/YosemitechY560.h +++ b/src/sensors/YosemitechY560.h @@ -261,8 +261,7 @@ class YosemitechY560_NH4_N : public Variable { explicit YosemitechY560_NH4_N(YosemitechY560* parentSense, const char* uuid = "", const char* varCode = Y560_NH4_N_DEFAULT_CODE) - : Variable(parentSense, static_cast(Y560_NH4_N_VAR_NUM), - static_cast(Y560_NH4_N_RESOLUTION), + : Variable(parentSense, Y560_NH4_N_VAR_NUM, Y560_NH4_N_RESOLUTION, Y560_NH4_N_VAR_NAME, Y560_NH4_N_UNIT_NAME, varCode, uuid) {} /** * @brief Destroy the YosemitechY560_NH4_N object - no action needed. @@ -295,8 +294,7 @@ class YosemitechY560_Temp : public Variable { explicit YosemitechY560_Temp(YosemitechY560* parentSense, const char* uuid = "", const char* varCode = Y560_TEMP_DEFAULT_CODE) - : Variable(parentSense, static_cast(Y560_TEMP_VAR_NUM), - static_cast(Y560_TEMP_RESOLUTION), + : Variable(parentSense, Y560_TEMP_VAR_NUM, Y560_TEMP_RESOLUTION, Y560_TEMP_VAR_NAME, Y560_TEMP_UNIT_NAME, varCode, uuid) {} /** * @brief Destroy the YosemitechY560_Temp object - no action needed. @@ -329,9 +327,8 @@ class YosemitechY560_pH : public Variable { explicit YosemitechY560_pH(YosemitechY560* parentSense, const char* uuid = "", const char* varCode = Y560_PH_DEFAULT_CODE) - : Variable(parentSense, static_cast(Y560_PH_VAR_NUM), - static_cast(Y560_PH_RESOLUTION), Y560_PH_VAR_NAME, - Y560_PH_UNIT_NAME, varCode, uuid) {} + : Variable(parentSense, Y560_PH_VAR_NUM, Y560_PH_RESOLUTION, + Y560_PH_VAR_NAME, Y560_PH_UNIT_NAME, varCode, uuid) {} /** * @brief Destroy the YosemitechY560_pH object - no action needed. */ diff --git a/src/sensors/YosemitechY700.h b/src/sensors/YosemitechY700.h index fe0048127..7a66fdc58 100644 --- a/src/sensors/YosemitechY700.h +++ b/src/sensors/YosemitechY700.h @@ -229,8 +229,7 @@ class YosemitechY700_Pressure : public Variable { explicit YosemitechY700_Pressure( YosemitechY700* parentSense, const char* uuid = "", const char* varCode = Y700_PRES_DEFAULT_CODE) - : Variable(parentSense, static_cast(Y700_PRES_VAR_NUM), - static_cast(Y700_PRES_RESOLUTION), + : Variable(parentSense, Y700_PRES_VAR_NUM, Y700_PRES_RESOLUTION, Y700_PRES_VAR_NAME, Y700_PRES_UNIT_NAME, varCode, uuid) {} /** * @brief Destroy the YosemitechY700_Pressure object - no action needed. @@ -263,8 +262,7 @@ class YosemitechY700_Temp : public Variable { explicit YosemitechY700_Temp(YosemitechY700* parentSense, const char* uuid = "", const char* varCode = Y700_TEMP_DEFAULT_CODE) - : Variable(parentSense, static_cast(Y700_TEMP_VAR_NUM), - static_cast(Y700_TEMP_RESOLUTION), + : Variable(parentSense, Y700_TEMP_VAR_NUM, Y700_TEMP_RESOLUTION, Y700_TEMP_VAR_NAME, Y700_TEMP_UNIT_NAME, varCode, uuid) {} /** * @brief Destroy the YosemitechY700_Temp object - no action needed. diff --git a/src/sensors/ZebraTechDOpto.h b/src/sensors/ZebraTechDOpto.h index 9dcceb6c8..13145c884 100644 --- a/src/sensors/ZebraTechDOpto.h +++ b/src/sensors/ZebraTechDOpto.h @@ -289,8 +289,7 @@ class ZebraTechDOpto_Temp : public Variable { explicit ZebraTechDOpto_Temp(ZebraTechDOpto* parentSense, const char* uuid = "", const char* varCode = DOPTO_TEMP_DEFAULT_CODE) - : Variable(parentSense, static_cast(DOPTO_TEMP_VAR_NUM), - static_cast(DOPTO_TEMP_RESOLUTION), + : Variable(parentSense, DOPTO_TEMP_VAR_NUM, DOPTO_TEMP_RESOLUTION, DOPTO_TEMP_VAR_NAME, DOPTO_TEMP_UNIT_NAME, varCode, uuid) {} /** * @brief Destroy the ZebraTechDOpto_Temp object - no action needed. @@ -323,8 +322,7 @@ class ZebraTechDOpto_DOpct : public Variable { explicit ZebraTechDOpto_DOpct( ZebraTechDOpto* parentSense, const char* uuid = "", const char* varCode = DOPTO_DOPCT_DEFAULT_CODE) - : Variable(parentSense, static_cast(DOPTO_DOPCT_VAR_NUM), - static_cast(DOPTO_DOPCT_RESOLUTION), + : Variable(parentSense, DOPTO_DOPCT_VAR_NUM, DOPTO_DOPCT_RESOLUTION, DOPTO_DOPCT_VAR_NAME, DOPTO_DOPCT_UNIT_NAME, varCode, uuid) { } /** @@ -358,8 +356,7 @@ class ZebraTechDOpto_DOmgL : public Variable { explicit ZebraTechDOpto_DOmgL( ZebraTechDOpto* parentSense, const char* uuid = "", const char* varCode = DOPTO_DOMGL_DEFAULT_CODE) - : Variable(parentSense, static_cast(DOPTO_DOMGL_VAR_NUM), - static_cast(DOPTO_DOMGL_RESOLUTION), + : Variable(parentSense, DOPTO_DOMGL_VAR_NUM, DOPTO_DOMGL_RESOLUTION, DOPTO_DOMGL_VAR_NAME, DOPTO_DOMGL_UNIT_NAME, varCode, uuid) { } /** From 1bb6fb6e9f6bb0d94f7f285684448a2c31d1901e Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Fri, 13 Mar 2026 17:15:14 -0400 Subject: [PATCH 531/533] Bump DHT library version Signed-off-by: Sara Damiano --- continuous_integration/dependencies.json | 4 ++-- docs/For-Developers/Developer-Setup.md | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/continuous_integration/dependencies.json b/continuous_integration/dependencies.json index d193955a1..93bff68d2 100644 --- a/continuous_integration/dependencies.json +++ b/continuous_integration/dependencies.json @@ -1,5 +1,5 @@ { - "action_cache_version": 47, + "action_cache_version": 48, "dependencies": [ { "name": "EnviroDIY_DS3231", @@ -387,4 +387,4 @@ "note": "Used for debugging modem streams and duplicating primary output stream" } ] -} +} \ No newline at end of file diff --git a/docs/For-Developers/Developer-Setup.md b/docs/For-Developers/Developer-Setup.md index 2f5bc84d8..50e3082df 100644 --- a/docs/For-Developers/Developer-Setup.md +++ b/docs/For-Developers/Developer-Setup.md @@ -135,7 +135,7 @@ lib_deps = adafruit/Adafruit AM2315@^2.2.3 adafruit/Adafruit BME280 Library@^2.3.0 MartinL1/BMP388_DEV@^1.0.11 - adafruit/DHT sensor library@^1.4.6 + adafruit/DHT sensor library@^1.4.7 adafruit/Adafruit INA219@^1.2.3 adafruit/Adafruit MPL115A2@^2.0.2 adafruit/Adafruit SHT4x Library@^1.0.5 From 1b8fdc4eb79662d183a34e157bee12ee147bb836 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Mon, 16 Mar 2026 17:15:47 -0400 Subject: [PATCH 532/533] Bump DHT sensor library Signed-off-by: Sara Damiano --- continuous_integration/dependencies.json | 4 ++-- library.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/continuous_integration/dependencies.json b/continuous_integration/dependencies.json index 93bff68d2..2968c8e12 100644 --- a/continuous_integration/dependencies.json +++ b/continuous_integration/dependencies.json @@ -1,5 +1,5 @@ { - "action_cache_version": 48, + "action_cache_version": 49, "dependencies": [ { "name": "EnviroDIY_DS3231", @@ -162,7 +162,7 @@ "owner": "adafruit", "library id": "19", "url": "https://github.com/adafruit/DHT-sensor-library", - "version": "~1.4.6", + "version": "~1.4.7", "note": "AOSong DHT Sensor Library by Adafruit", "authors": [ "Adafruit" diff --git a/library.json b/library.json index 1ecff04dd..a51ea34b7 100644 --- a/library.json +++ b/library.json @@ -192,7 +192,7 @@ "owner": "adafruit", "library id": "19", "url": "https://github.com/adafruit/DHT-sensor-library", - "version": "~1.4.6", + "version": "~1.4.7", "note": "AOSong DHT Sensor Library by Adafruit", "authors": ["Adafruit"], "frameworks": "arduino" From 79165f6295286d78911f841b1eaf3b5832097d3c Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Mon, 16 Mar 2026 17:28:54 -0400 Subject: [PATCH 533/533] Use deep instead of deep+ Signed-off-by: Sara Damiano --- continuous_integration/platformio.ini | 2 +- docs/For-Developers/Developer-Setup.md | 2 +- docs/Getting-Started/Getting-Started.md | 2 +- examples/AWS_IoT_Core/platformio.ini | 2 +- examples/EnviroDIY_Monitoring_Kit/platformio.ini | 2 +- examples/baro_rho_correction/platformio.ini | 2 +- examples/double_logger/platformio.ini | 2 +- examples/logging_to_MMW/platformio.ini | 2 +- examples/logging_to_ThingSpeak/platformio.ini | 2 +- examples/menu_a_la_carte/platformio.ini | 2 +- examples/simple_logging/platformio.ini | 2 +- examples/single_sensor/platformio.ini | 2 +- extras/sdi12_address_change/platformio.ini | 2 +- src/ClockSupport.h | 3 +++ 14 files changed, 16 insertions(+), 13 deletions(-) diff --git a/continuous_integration/platformio.ini b/continuous_integration/platformio.ini index ee2c745ed..38079a19a 100644 --- a/continuous_integration/platformio.ini +++ b/continuous_integration/platformio.ini @@ -14,7 +14,7 @@ boards_dir = ${platformio.core_dir}/boards [env] framework = arduino -lib_ldf_mode = deep+ +lib_ldf_mode = deep lib_compat_mode = soft build_flags = -Wall diff --git a/docs/For-Developers/Developer-Setup.md b/docs/For-Developers/Developer-Setup.md index 50e3082df..106f4c694 100644 --- a/docs/For-Developers/Developer-Setup.md +++ b/docs/For-Developers/Developer-Setup.md @@ -91,7 +91,7 @@ check_flags = clangtidy: --checks=-* check_skip_packages = yes ; deep search for dependencies, evaluating preprocessor conditionals -lib_ldf_mode = deep+ +lib_ldf_mode = deep lib_compat_mode = soft ; look for the library directory lib_extra_dirs = . diff --git a/docs/Getting-Started/Getting-Started.md b/docs/Getting-Started/Getting-Started.md index e60873173..be120fb6e 100644 --- a/docs/Getting-Started/Getting-Started.md +++ b/docs/Getting-Started/Getting-Started.md @@ -98,7 +98,7 @@ Again, it's easiest to let PlatformIO set everything up in a new folder. ```ini lib_deps = EnviroDIY_ModularSensors -lib_ldf_mode = deep+ +lib_ldf_mode = deep build_flags = -DSDI12_EXTERNAL_PCINT -DNEOSWSERIAL_EXTERNAL_PCINT diff --git a/examples/AWS_IoT_Core/platformio.ini b/examples/AWS_IoT_Core/platformio.ini index 9083a4eb6..bccba6959 100644 --- a/examples/AWS_IoT_Core/platformio.ini +++ b/examples/AWS_IoT_Core/platformio.ini @@ -16,7 +16,7 @@ monitor_speed = 115200 board = mayfly platform = atmelavr framework = arduino -lib_ldf_mode = deep+ +lib_ldf_mode = deep lib_ignore = RTCZero Adafruit NeoPixel diff --git a/examples/EnviroDIY_Monitoring_Kit/platformio.ini b/examples/EnviroDIY_Monitoring_Kit/platformio.ini index 8881915dc..cc6cc0662 100644 --- a/examples/EnviroDIY_Monitoring_Kit/platformio.ini +++ b/examples/EnviroDIY_Monitoring_Kit/platformio.ini @@ -16,7 +16,7 @@ monitor_speed = 57600 board = mayfly platform = atmelavr framework = arduino -lib_ldf_mode = deep+ +lib_ldf_mode = deep lib_ignore = RTCZero Adafruit NeoPixel diff --git a/examples/baro_rho_correction/platformio.ini b/examples/baro_rho_correction/platformio.ini index 06fed9f6b..3478bd920 100644 --- a/examples/baro_rho_correction/platformio.ini +++ b/examples/baro_rho_correction/platformio.ini @@ -17,7 +17,7 @@ monitor_speed = 115200 board = mayfly platform = atmelavr framework = arduino -lib_ldf_mode = deep+ +lib_ldf_mode = deep lib_ignore = RTCZero Adafruit NeoPixel diff --git a/examples/double_logger/platformio.ini b/examples/double_logger/platformio.ini index 970bdd3d5..88d796134 100644 --- a/examples/double_logger/platformio.ini +++ b/examples/double_logger/platformio.ini @@ -16,7 +16,7 @@ monitor_speed = 115200 board = mayfly platform = atmelavr framework = arduino -lib_ldf_mode = deep+ +lib_ldf_mode = deep lib_ignore = RTCZero Adafruit NeoPixel diff --git a/examples/logging_to_MMW/platformio.ini b/examples/logging_to_MMW/platformio.ini index 8c2996ae3..07f62b446 100644 --- a/examples/logging_to_MMW/platformio.ini +++ b/examples/logging_to_MMW/platformio.ini @@ -16,7 +16,7 @@ monitor_speed = 115200 board = mayfly platform = atmelavr framework = arduino -lib_ldf_mode = deep+ +lib_ldf_mode = deep lib_ignore = RTCZero Adafruit NeoPixel diff --git a/examples/logging_to_ThingSpeak/platformio.ini b/examples/logging_to_ThingSpeak/platformio.ini index 5c60bf4ee..1435c8543 100644 --- a/examples/logging_to_ThingSpeak/platformio.ini +++ b/examples/logging_to_ThingSpeak/platformio.ini @@ -16,7 +16,7 @@ monitor_speed = 115200 board = mayfly platform = atmelavr framework = arduino -lib_ldf_mode = deep+ +lib_ldf_mode = deep lib_ignore = RTCZero Adafruit NeoPixel diff --git a/examples/menu_a_la_carte/platformio.ini b/examples/menu_a_la_carte/platformio.ini index c55e718b3..4950952ed 100644 --- a/examples/menu_a_la_carte/platformio.ini +++ b/examples/menu_a_la_carte/platformio.ini @@ -16,7 +16,7 @@ monitor_speed = 115200 board = mayfly platform = atmelavr framework = arduino -lib_ldf_mode = deep+ +lib_ldf_mode = deep lib_ignore = RTCZero Adafruit NeoPixel diff --git a/examples/simple_logging/platformio.ini b/examples/simple_logging/platformio.ini index 9a51f192c..08f8b1067 100644 --- a/examples/simple_logging/platformio.ini +++ b/examples/simple_logging/platformio.ini @@ -16,7 +16,7 @@ monitor_speed = 115200 board = mayfly platform = atmelavr framework = arduino -lib_ldf_mode = deep+ +lib_ldf_mode = deep lib_ignore = RTCZero Adafruit NeoPixel diff --git a/examples/single_sensor/platformio.ini b/examples/single_sensor/platformio.ini index 13eee776b..2a9a7e46f 100644 --- a/examples/single_sensor/platformio.ini +++ b/examples/single_sensor/platformio.ini @@ -16,7 +16,7 @@ monitor_speed = 115200 board = mayfly platform = atmelavr framework = arduino -lib_ldf_mode = deep+ +lib_ldf_mode = deep lib_ignore = RTCZero Adafruit NeoPixel diff --git a/extras/sdi12_address_change/platformio.ini b/extras/sdi12_address_change/platformio.ini index bc5744755..71c3ef7e1 100644 --- a/extras/sdi12_address_change/platformio.ini +++ b/extras/sdi12_address_change/platformio.ini @@ -17,7 +17,7 @@ monitor_speed = 115200 board = mayfly platform = atmelavr framework = arduino -lib_ldf_mode = deep+ +lib_ldf_mode = deep lib_ignore = RTCZero Adafruit NeoPixel diff --git a/src/ClockSupport.h b/src/ClockSupport.h index a9e16d4fc..91ec46bf8 100644 --- a/src/ClockSupport.h +++ b/src/ClockSupport.h @@ -64,16 +64,19 @@ * @brief A text description of the clock */ #if defined(MS_USE_RV8803) +// #pragma message "Using RV-8803 RTC as the clock." #define MS_CLOCK_NAME "RV-8803" #include // Interrupt is active low on the RV8803 #define CLOCK_INTERRUPT_MODE FALLING #elif defined(MS_USE_DS3231) +// #pragma message "Using DS3231 RTC as the clock." #define MS_CLOCK_NAME "DS3231" #include // Interrupt is active low on the DS3231 #define CLOCK_INTERRUPT_MODE FALLING #elif defined(MS_USE_RTC_ZERO) +// #pragma message "Using SAMD 32-bit RTC as the clock." #define MS_CLOCK_NAME "SAMD 32-bit RTC" #include #endif