From 5d9800b7c2c7754e91db228efd7fd73320883a14 Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Thu, 9 May 2024 21:25:36 -0500 Subject: [PATCH] Revert "Add Sensirion SHT4X sensors (#3792)" (#3845) This reverts commit 5371f134ba5ab84b1292d3b5bf8a560ea6b9187f. --- platformio.ini | 1 - src/configuration.h | 2 +- src/detect/ScanI2C.h | 1 - src/detect/ScanI2CTwoWire.cpp | 15 +---- src/main.cpp | 3 +- .../Telemetry/EnvironmentTelemetry.cpp | 6 -- src/modules/Telemetry/Sensor/SHT4XSensor.cpp | 63 ------------------- src/modules/Telemetry/Sensor/SHT4XSensor.h | 23 ------- 8 files changed, 4 insertions(+), 110 deletions(-) delete mode 100644 src/modules/Telemetry/Sensor/SHT4XSensor.cpp delete mode 100644 src/modules/Telemetry/Sensor/SHT4XSensor.h diff --git a/platformio.ini b/platformio.ini index 9d7c76fbf..a6db1c76e 100644 --- a/platformio.ini +++ b/platformio.ini @@ -133,4 +133,3 @@ lib_deps = https://github.com/lewisxhe/SensorLib#27fd0f721e20cd09e1f81383f0ba58a54fe84a17 adafruit/Adafruit LSM6DS@^4.7.2 mprograms/QMC5883LCompass@^1.2.0 - https://github.com/Sensirion/arduino-i2c-sht4x#1.1.0 diff --git a/src/configuration.h b/src/configuration.h index 0d9ee5451..493449764 100644 --- a/src/configuration.h +++ b/src/configuration.h @@ -126,7 +126,7 @@ along with this program. If not, see . #define SHTC3_ADDR 0x70 #define LPS22HB_ADDR 0x5C #define LPS22HB_ADDR_ALT 0x5D -#define SHT31_4x_ADDR 0x44 +#define SHT31_ADDR 0x44 #define PMSA0031_ADDR 0x12 #define RCWL9620_ADDR 0x57 diff --git a/src/detect/ScanI2C.h b/src/detect/ScanI2C.h index a53df11f3..20f22040c 100644 --- a/src/detect/ScanI2C.h +++ b/src/detect/ScanI2C.h @@ -29,7 +29,6 @@ class ScanI2C INA3221, MCP9808, SHT31, - SHT4X, SHTC3, LPS22HB, QMC6310, diff --git a/src/detect/ScanI2CTwoWire.cpp b/src/detect/ScanI2CTwoWire.cpp index 58d46a58d..562a94c1f 100644 --- a/src/detect/ScanI2CTwoWire.cpp +++ b/src/detect/ScanI2CTwoWire.cpp @@ -292,18 +292,7 @@ void ScanI2CTwoWire::scanPort(I2CPort port) break; - case SHT31_4x_ADDR: - registerValue = getRegisterValue(ScanI2CTwoWire::RegisterLocation(addr, 0x89), 2); - if (registerValue == 0x11a2) { - type = SHT4X; - LOG_INFO("SHT4X sensor found\n"); - } else { - type = SHT31; - LOG_INFO("SHT31 sensor found\n"); - } - - break; - + SCAN_SIMPLE_CASE(SHT31_ADDR, SHT31, "SHT31 sensor found\n") SCAN_SIMPLE_CASE(SHTC3_ADDR, SHTC3, "SHTC3 sensor found\n") SCAN_SIMPLE_CASE(RCWL9620_ADDR, RCWL9620, "RCWL9620 sensor found\n") @@ -368,4 +357,4 @@ TwoWire *ScanI2CTwoWire::fetchI2CBus(ScanI2C::DeviceAddress address) const size_t ScanI2CTwoWire::countDevices() const { return foundDevices.size(); -} +} \ No newline at end of file diff --git a/src/main.cpp b/src/main.cpp index 1465cd084..b7bc4892b 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -541,7 +541,6 @@ void setup() SCANNER_TO_SENSORS_MAP(ScanI2C::DeviceType::QMC5883L, meshtastic_TelemetrySensorType_QMC5883L) SCANNER_TO_SENSORS_MAP(ScanI2C::DeviceType::PMSA0031, meshtastic_TelemetrySensorType_PMSA003I) SCANNER_TO_SENSORS_MAP(ScanI2C::DeviceType::RCWL9620, meshtastic_TelemetrySensorType_RCWL9620) - SCANNER_TO_SENSORS_MAP(ScanI2C::DeviceType::SHT4X, meshtastic_TelemetrySensorType_SHT4X) i2cScanner.reset(); @@ -1033,4 +1032,4 @@ void loop() mainDelay.delay(delayMsec); } // if (didWake) LOG_DEBUG("wake!\n"); -} \ No newline at end of file +} diff --git a/src/modules/Telemetry/EnvironmentTelemetry.cpp b/src/modules/Telemetry/EnvironmentTelemetry.cpp index 62adc9a8c..93184069d 100644 --- a/src/modules/Telemetry/EnvironmentTelemetry.cpp +++ b/src/modules/Telemetry/EnvironmentTelemetry.cpp @@ -26,7 +26,6 @@ #include "Sensor/MCP9808Sensor.h" #include "Sensor/RCWL9620Sensor.h" #include "Sensor/SHT31Sensor.h" -#include "Sensor/SHT4XSensor.h" #include "Sensor/SHTC3Sensor.h" BMP085Sensor bmp085Sensor; @@ -37,7 +36,6 @@ MCP9808Sensor mcp9808Sensor; SHTC3Sensor shtc3Sensor; LPS22HBSensor lps22hbSensor; SHT31Sensor sht31Sensor; -SHT4XSensor sht4xSensor; RCWL9620Sensor rcwl9620Sensor; #define FAILED_STATE_SENSOR_READ_MULTIPLIER 10 @@ -93,8 +91,6 @@ int32_t EnvironmentTelemetryModule::runOnce() result = lps22hbSensor.runOnce(); if (sht31Sensor.hasSensor()) result = sht31Sensor.runOnce(); - if (sht4xSensor.hasSensor()) - result = sht4xSensor.runOnce(); if (ina219Sensor.hasSensor()) result = ina219Sensor.runOnce(); if (ina260Sensor.hasSensor()) @@ -250,8 +246,6 @@ bool EnvironmentTelemetryModule::sendTelemetry(NodeNum dest, bool phoneOnly) if (sht31Sensor.hasSensor()) valid = sht31Sensor.getMetrics(&m); - if (sht4xSensor.hasSensor()) - valid = sht4xSensor.getMetrics(&m); if (lps22hbSensor.hasSensor()) valid = lps22hbSensor.getMetrics(&m); if (shtc3Sensor.hasSensor()) diff --git a/src/modules/Telemetry/Sensor/SHT4XSensor.cpp b/src/modules/Telemetry/Sensor/SHT4XSensor.cpp deleted file mode 100644 index d324b7fd6..000000000 --- a/src/modules/Telemetry/Sensor/SHT4XSensor.cpp +++ /dev/null @@ -1,63 +0,0 @@ -#include "configuration.h" - -#if !MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR - -#include "../mesh/generated/meshtastic/telemetry.pb.h" -#include "SHT4XSensor.h" -#include "TelemetrySensor.h" -#include - -// macro definitions -// make sure that we use the proper definition of NO_ERROR -#ifdef NO_ERROR -#undef NO_ERROR -#endif -#define NO_ERROR 0 - -static char errorMessage[64]; -static int16_t error; - -SHT4XSensor::SHT4XSensor() : TelemetrySensor(meshtastic_TelemetrySensorType_SHT4X, "SHT4X") {} - -int32_t SHT4XSensor::runOnce() -{ - LOG_INFO("Init sensor: %s\n", sensorName); - if (!hasSensor()) { - return DEFAULT_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS; - } - - uint32_t serialNumber = 0; - - sht4x.begin(*nodeTelemetrySensorsMap[sensorType].second, 0x44); - - error = sht4x.serialNumber(serialNumber); - LOG_DEBUG("serialNumber : %x\n", serialNumber); - if (error != NO_ERROR) { - LOG_DEBUG("Error trying to execute serialNumber(): "); - errorToString(error, errorMessage, sizeof errorMessage); - LOG_DEBUG(errorMessage); - status = 0; - } else { - status = 1; - } - - return initI2CSensor(); -} - -void SHT4XSensor::setup() -{ - // Set up oversampling and filter initialization -} - -bool SHT4XSensor::getMetrics(meshtastic_Telemetry *measurement) -{ - float aTemperature = 0.0; - float aHumidity = 0.0; - sht4x.measureLowestPrecision(aTemperature, aHumidity); - measurement->variant.environment_metrics.temperature = aTemperature; - measurement->variant.environment_metrics.relative_humidity = aHumidity; - - return true; -} - -#endif \ No newline at end of file diff --git a/src/modules/Telemetry/Sensor/SHT4XSensor.h b/src/modules/Telemetry/Sensor/SHT4XSensor.h deleted file mode 100644 index 67045eb2a..000000000 --- a/src/modules/Telemetry/Sensor/SHT4XSensor.h +++ /dev/null @@ -1,23 +0,0 @@ -#include "configuration.h" - -#if !MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR - -#include "../mesh/generated/meshtastic/telemetry.pb.h" -#include "TelemetrySensor.h" -#include - -class SHT4XSensor : public TelemetrySensor -{ - private: - SensirionI2cSht4x sht4x; - - protected: - virtual void setup() override; - - public: - SHT4XSensor(); - virtual int32_t runOnce() override; - virtual bool getMetrics(meshtastic_Telemetry *measurement) override; -}; - -#endif \ No newline at end of file