Skip to content

Commit

Permalink
ESP32: Adding support for HDC1080
Browse files Browse the repository at this point in the history
  • Loading branch information
rezaneam committed Apr 8, 2021
1 parent 4aef67f commit d58116d
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
22 changes: 21 additions & 1 deletion ESP32/lib/Sensor/EnvironmentSensor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@
bool EnvironmentSensor::Initialize(TwoWire &i2c, bool verboseMode)
{
isVerbose = verboseMode;
isHDC1080Exist = hdc1080.Initialize(&i2c);
if (isHDC1080Exist)
{
if (isVerbose)
printf(">> Sensor : HDC1080 sensor found.\r\n");
initializeHDC1080();
}

bme680.begin(BME680_I2C_ADDR_SECONDARY, i2c);
;
if (bme680.bme680Status == 0)
Expand Down Expand Up @@ -159,6 +167,12 @@ bool EnvironmentSensor::initializeBMx280()
return true;
}

void EnvironmentSensor::initializeHDC1080()
{
hdc1080.Setup(
HDC1080::HDC1080_MeasurementResolution::HDC1080_RESOLUTION_11BIT,
HDC1080::HDC1080_MeasurementResolution::HDC1080_RESOLUTION_11BIT);
}
// Helper function definitions
bool EnvironmentSensor::checkIaqSensorStatus(void)
{
Expand Down Expand Up @@ -205,7 +219,13 @@ bool EnvironmentSensor::UpdateMeasurments()
return false;

SensorCalibrationStatus status;
Measurments.cur_temperature = readTemperature();
if (isHDC1080Exist)
{
Measurments.cur_temperature = (float)hdc1080.ReadTemperature();
printf(">> Sensor. TI: HDC1080 %2.3f Bosch %2.3f\r\n", Measurments.cur_temperature, readTemperature());
}
else
Measurments.cur_temperature = readTemperature();
Measurments.cur_humidity = readHumidity();
Measurments.cur_pressure = readPressure();
Measurments.cur_airQuality = readAirQuality(&status);
Expand Down
4 changes: 4 additions & 0 deletions ESP32/lib/Sensor/EnvironmentSensor.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include <BME280.h>
#include <enums.h>
#include <StoreHub.h>
#include <HDC1080.h>

#define SENSRO_MAX_AVERAGE_SAMPLES 60 * 24 // Maximum samples included in the calculating the average
const uint8_t bsec_config[] = {
Expand Down Expand Up @@ -49,6 +50,8 @@ class EnvironmentSensor

private:
bool isVerbose;
bool isHDC1080Exist;
HDC1080 hdc1080;
BME280 bmx280;
Bsec bme680;

Expand All @@ -67,6 +70,7 @@ class EnvironmentSensor

bool initializeBMx280();
bool initializeBME680();
void initializeHDC1080();
bool checkIaqSensorStatus(void);
bool TakeSample();
float readTemperature();
Expand Down

0 comments on commit d58116d

Please sign in to comment.