diff --git a/platformio.ini b/platformio.ini
index bc46f3f23..63308790d 100644
--- a/platformio.ini
+++ b/platformio.ini
@@ -90,4 +90,4 @@ lib_deps =
adafruit/Adafruit MCP9808 Library@^2.0.0
adafruit/Adafruit INA260 Library@^1.5.0
adafruit/Adafruit INA219@^1.2.0
-
+ https://github.com/adafruit/Adafruit_SHTC3@^1.0.0
diff --git a/src/configuration.h b/src/configuration.h
index 2aeb0f4a5..feb0da1cd 100644
--- a/src/configuration.h
+++ b/src/configuration.h
@@ -110,6 +110,7 @@ along with this program. If not, see .
#define INA_ADDR_ALTERNATE 0x41
#define QMC6310_ADDR 0x1C
#define QMI8658_ADDR 0x6B
+#define SHTC3_ADDR 0x70
// -----------------------------------------------------------------------------
// Security
diff --git a/src/detect/i2cScan.h b/src/detect/i2cScan.h
index 1148495ba..f1c0fbdd5 100644
--- a/src/detect/i2cScan.h
+++ b/src/detect/i2cScan.h
@@ -191,14 +191,18 @@ void scanI2Cdevice(void)
nodeTelemetrySensorsMap[TelemetrySensorType_MCP9808] = addr;
DEBUG_MSG("MCP9808 sensor found at address 0x%x\n", (uint8_t)addr);
}
- if(addr == QMC6310_ADDR){
+ if (addr == QMC6310_ADDR) {
DEBUG_MSG("QMC6310 3-Axis magnetic sensor found at address 0x%x\n", (uint8_t)addr);
nodeTelemetrySensorsMap[TelemetrySensorType_QMC6310] = addr;
}
- if(addr == QMI8658_ADDR){
+ if (addr == QMI8658_ADDR) {
DEBUG_MSG("QMI8658 6-Axis inertial measurement sensor found at address 0x%x\n", (uint8_t)addr);
nodeTelemetrySensorsMap[TelemetrySensorType_QMI8658] = addr;
}
+ if (addr == SHTC3_ADDR) {
+ DEBUG_MSG("SHTC3 sensor found at address 0x%x\n", (uint8_t)addr);
+ nodeTelemetrySensorsMap[TelemetrySensorType_SHTC3] = addr;
+ }
} else if (err == 4) {
DEBUG_MSG("Unknow error at address 0x%x\n", addr);
}
diff --git a/src/modules/Telemetry/EnvironmentTelemetry.cpp b/src/modules/Telemetry/EnvironmentTelemetry.cpp
index 36e6a8176..ce1301dfe 100644
--- a/src/modules/Telemetry/EnvironmentTelemetry.cpp
+++ b/src/modules/Telemetry/EnvironmentTelemetry.cpp
@@ -17,6 +17,7 @@
#include "Sensor/MCP9808Sensor.h"
#include "Sensor/INA260Sensor.h"
#include "Sensor/INA219Sensor.h"
+#include "Sensor/SHTC3Sensor.h"
BMP280Sensor bmp280Sensor;
BME280Sensor bme280Sensor;
@@ -24,6 +25,7 @@ BME680Sensor bme680Sensor;
MCP9808Sensor mcp9808Sensor;
INA260Sensor ina260Sensor;
INA219Sensor ina219Sensor;
+SHTC3Sensor shtc3Sensor;
#define FAILED_STATE_SENSOR_READ_MULTIPLIER 10
#define DISPLAY_RECEIVEID_MEASUREMENTS_ON_SCREEN true
@@ -83,6 +85,8 @@ int32_t EnvironmentTelemetryModule::runOnce()
result = ina260Sensor.runOnce();
if (ina219Sensor.hasSensor())
result = ina219Sensor.runOnce();
+ if (shtc3Sensor.hasSensor())
+ result = shtc3Sensor.runOnce();
}
return result;
} else {
@@ -212,6 +216,8 @@ bool EnvironmentTelemetryModule::sendOurTelemetry(NodeNum dest, bool wantReplies
ina219Sensor.getMetrics(&m);
if (ina260Sensor.hasSensor())
ina260Sensor.getMetrics(&m);
+ if (shtc3Sensor.hasSensor())
+ shtc3Sensor.getMetrics(&m);
DEBUG_MSG("Telemetry->time: %i\n", m.time);
DEBUG_MSG("Telemetry->barometric_pressure: %f\n", m.variant.environment_metrics.barometric_pressure);
diff --git a/src/modules/Telemetry/Sensor/SHTC3Sensor.cpp b/src/modules/Telemetry/Sensor/SHTC3Sensor.cpp
new file mode 100644
index 000000000..b3a76ba91
--- /dev/null
+++ b/src/modules/Telemetry/Sensor/SHTC3Sensor.cpp
@@ -0,0 +1,34 @@
+#include "../mesh/generated/telemetry.pb.h"
+#include "configuration.h"
+#include "TelemetrySensor.h"
+#include "SHTC3Sensor.h"
+#include
+
+SHTC3Sensor::SHTC3Sensor() :
+ TelemetrySensor(TelemetrySensorType_SHTC3, "SHTC3")
+{
+}
+
+int32_t SHTC3Sensor::runOnce() {
+ DEBUG_MSG("Init sensor: %s\n", sensorName);
+ if (!hasSensor()) {
+ return DEFAULT_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS;
+ }
+ status = shtc3.begin();
+ return initI2CSensor();
+}
+
+void SHTC3Sensor::setup()
+{
+ // Set up oversampling and filter initialization
+}
+
+bool SHTC3Sensor::getMetrics(Telemetry *measurement) {
+ sensors_event_t humidity, temp;
+ shtc3.getEvent(&humidity, &temp);
+
+ measurement->variant.environment_metrics.temperature = temp.temperature;
+ measurement->variant.environment_metrics.relative_humidity = humidity.relative_humidity;
+
+ return true;
+}
\ No newline at end of file
diff --git a/src/modules/Telemetry/Sensor/SHTC3Sensor.h b/src/modules/Telemetry/Sensor/SHTC3Sensor.h
new file mode 100644
index 000000000..28a1648bb
--- /dev/null
+++ b/src/modules/Telemetry/Sensor/SHTC3Sensor.h
@@ -0,0 +1,16 @@
+#include "../mesh/generated/telemetry.pb.h"
+#include "TelemetrySensor.h"
+#include
+
+class SHTC3Sensor : virtual public TelemetrySensor {
+private:
+ Adafruit_SHTC3 shtc3 = Adafruit_SHTC3();
+
+protected:
+ virtual void setup() override;
+
+public:
+ SHTC3Sensor();
+ virtual int32_t runOnce() override;
+ virtual bool getMetrics(Telemetry *measurement) override;
+};
\ No newline at end of file