Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ build_flags =
-D ENV_INCLUDE_BME280=1
-D ENV_INCLUDE_BMP280=1
-D ENV_INCLUDE_SHTC3=1
-D ENV_INCLUDE_SHT3X=1
-D ENV_INCLUDE_SHT4X=1
-D ENV_INCLUDE_LPS22HB=1
-D ENV_INCLUDE_INA3221=1
Expand All @@ -143,6 +144,7 @@ lib_deps =
adafruit/Adafruit BME280 Library @ ^2.3.0
adafruit/Adafruit BMP280 Library @ ^2.6.8
adafruit/Adafruit SHTC3 Library @ ^1.0.1
sensirion/Sensirion I2C SHT3x @ ^1.0.1
sensirion/Sensirion I2C SHT4x @ ^1.1.2
arduino-libraries/Arduino_LPS22HB @ ^1.0.2
adafruit/Adafruit MLX90614 Library @ ^2.1.5
Expand Down
31 changes: 31 additions & 0 deletions src/helpers/sensors/EnvironmentSensorManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@ static Adafruit_BMP280 BMP280(TELEM_WIRE);
static Adafruit_SHTC3 SHTC3;
#endif

#if ENV_INCLUDE_SHT3X
#define TELEM_SHT3X_ADDRESS 0x44 //Addresses with 0x44 (default) and 0x45 are possible
#include <SensirionI2cSht3x.h>
static SensirionI2cSht3x SHT3X;
#endif

#if ENV_INCLUDE_SHT4X
#define TELEM_SHT4X_ADDRESS 0x44 //0x44 - 0x46
#include <SensirionI2cSht4x.h>
Expand Down Expand Up @@ -228,6 +234,19 @@ bool EnvironmentSensorManager::begin() {
}
#endif

#if ENV_INCLUDE_SHT3X
SHT3X.begin(*TELEM_WIRE, TELEM_SHT3X_ADDRESS);
uint16_t SHT3XStatusRegister = 0u;
int16_t sht3x_error;
sht3x_error = SHT3X.readStatusRegister(SHT3XStatusRegister);
if (sht3x_error == 0) {
MESH_DEBUG_PRINTLN("Found SHT3X at address: %02X", TELEM_SHT3X_ADDRESS);
SHT3X_initialized = true;
} else {
SHT3X_initialized = false;
MESH_DEBUG_PRINTLN("SHT3X was not found at I2C address %02X", TELEM_SHT3X_ADDRESS);
}
#endif

#if ENV_INCLUDE_SHT4X
SHT4X.begin(*TELEM_WIRE, TELEM_SHT4X_ADDRESS);
Expand Down Expand Up @@ -394,6 +413,18 @@ bool EnvironmentSensorManager::querySensors(uint8_t requester_permissions, Cayen
}
#endif

#if ENV_INCLUDE_SHT3X
if (SHT3X_initialized) {
float sht3x_humidity, sht3x_temperature;
int16_t sht3x_error;
sht3x_error = SHT3X.measureSingleShot(REPEATABILITY_MEDIUM, false, sht3x_temperature, sht3x_humidity);
if (sht3x_error == 0) {
telemetry.addTemperature(TELEM_CHANNEL_SELF, sht3x_temperature);
telemetry.addRelativeHumidity(TELEM_CHANNEL_SELF, sht3x_humidity);
}
}
#endif

#if ENV_INCLUDE_SHT4X
if (SHT4X_initialized) {
float sht4x_humidity, sht4x_temperature;
Expand Down
1 change: 1 addition & 0 deletions src/helpers/sensors/EnvironmentSensorManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class EnvironmentSensorManager : public SensorManager {
bool LPS22HB_initialized = false;
bool MLX90614_initialized = false;
bool VL53L0X_initialized = false;
bool SHT3X_initialized = false;
bool SHT4X_initialized = false;
bool BME680_initialized = false;
bool BMP085_initialized = false;
Expand Down