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 @@ -127,6 +127,7 @@ build_flags =
-D ENV_INCLUDE_BME280=1
-D ENV_INCLUDE_BMP280=1
-D ENV_INCLUDE_SHTC3=1
-D ENV_INCLUDE_SHT31=1
-D ENV_INCLUDE_SHT4X=1
-D ENV_INCLUDE_LPS22HB=1
-D ENV_INCLUDE_INA3221=1
Expand All @@ -146,6 +147,7 @@ lib_deps =
adafruit/Adafruit BME280 Library @ ^2.3.0
adafruit/Adafruit BMP280 Library @ ^2.6.8
adafruit/Adafruit SHTC3 Library @ ^1.0.1
adafruit/Adafruit SHT31 Library @ ^2.2.2
sensirion/Sensirion I2C SHT4x @ ^1.1.2
arduino-libraries/Arduino_LPS22HB @ ^1.0.2
adafruit/Adafruit MLX90614 Library @ ^2.1.5
Expand Down
27 changes: 27 additions & 0 deletions src/helpers/sensors/EnvironmentSensorManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,14 @@ static Adafruit_BMP280 BMP280(TELEM_WIRE);
static Adafruit_SHTC3 SHTC3;
#endif

#if ENV_INCLUDE_SHT31
#ifndef TELEM_SHT31_ADDRESS
#define TELEM_SHT31_ADDRESS 0x44 // SHT31 environmental sensor I2C address
#endif
#include <Adafruit_SHT31.h>
static Adafruit_SHT31 SHT31;
#endif

#if ENV_INCLUDE_SHT4X
#ifndef TELEM_SHT4X_ADDRESS
#define TELEM_SHT4X_ADDRESS 0x44
Expand Down Expand Up @@ -331,6 +339,21 @@ static void query_sht4x(uint8_t ch, uint8_t, CayenneLPP& lpp) {
}
#endif

#if ENV_INCLUDE_SHT31
static uint8_t init_sht3x(TwoWire* wire, uint8_t addr) {
return SHT31.begin(addr) ? 1 : 0;
}

static void query_sht3x(uint8_t ch, uint8_t, CayenneLPP& lpp) {
float temp, humidity;

if (SHT31.readBoth(&temp, &humidity)) {
lpp.addTemperature(ch, temp);
lpp.addRelativeHumidity(ch, humidity);
}
}
#endif

#if ENV_INCLUDE_LPS22HB
static uint8_t init_lps22hb(TwoWire*, uint8_t) {
// LPS22HBClass is constructed with the wire reference; begin() uses it.
Expand Down Expand Up @@ -570,9 +593,13 @@ static const SensorDef SENSOR_TABLE[] = {
#if ENV_INCLUDE_SHTC3
{ 0x70, "SHTC3", init_shtc3, query_shtc3 },
#endif

#if ENV_INCLUDE_SHT4X
{ TELEM_SHT4X_ADDRESS, "SHT4X", init_sht4x, query_sht4x },
#endif
#if ENV_INCLUDE_SHT31
{ TELEM_SHT31_ADDRESS, "SHT3X", init_sht3x, query_sht3x },
#endif
#if ENV_INCLUDE_LPS22HB
{ 0x5C, "LPS22HB", init_lps22hb, query_lps22hb },
#endif
Expand Down