Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BME680 BSEC library #200

Open
wants to merge 10 commits into
base: devel
Choose a base branch
from
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
63 changes: 40 additions & 23 deletions src/Sensors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -975,21 +975,23 @@ void Sensors::bmp280Read() {
}

void Sensors::bme680Read() {
if (!isSensorRegistered(SENSORS::SBME680)) return;
if (!bme680.performReading()) return;
float temp1 = bme680.temperature;
temp = temp1 - toffset;
humi = bme680.humidity;
pres = bme680.pressure / 100.0;
gas = bme680.gas_resistance / 1000.0;
alt = bme680.readAltitude(sealevel);
dataReady = true;
DEBUG("-->[SLIB] BME680 read\t\t: done!");
tempRegister(false);
unitRegister(UNIT::HUM);
unitRegister(UNIT::PRESS);
unitRegister(UNIT::GAS);
unitRegister(UNIT::ALT);
if (!iaqSensor.run()) return;
float temp1 = iaqSensor.rawTemperature;
temp = temp1 - toffset;
humi = iaqSensor.humidity;
pres = iaqSensor.pressure/100;
gas = iaqSensor.gasResistance/1000;
//gas = iaqSensor.iaq;
//alt = (1.0 - pow((float) iaqSensor.pressure / sealevel, 0.190284));
//alt = 44330 * (1.0 - pow(pres / sealevel, 0.1903));
Comment on lines +985 to +986
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the alt unit is registered but it is not read there. Why?


dataReady = true;
DEBUG("-->[SLIB] BME680 read\t\t: done!");
tempRegister(false);
unitRegister(UNIT::HUM);
unitRegister(UNIT::PRESS);
unitRegister(UNIT::GAS);
unitRegister(UNIT::ALT);
}

void Sensors::aht10Read() {
Expand Down Expand Up @@ -1590,14 +1592,29 @@ void Sensors::bmp280Init() {

/// Bosch BME680 sensor init
void Sensors::bme680Init() {
sensorAnnounce(SENSORS::SBME680);
if (!bme680.begin()) return;
bme680.setTemperatureOversampling(BME680_OS_8X);
bme680.setHumidityOversampling(BME680_OS_2X);
bme680.setPressureOversampling(BME680_OS_4X);
bme680.setIIRFilterSize(BME680_FILTER_SIZE_3);
bme680.setGasHeater(320, 150); // 320*C for 150 ms
sensorRegister(SENSORS::SBME680);
sensorAnnounce(SENSORS::SBME680);
iaqSensor.begin(BME68X_I2C_ADDR_HIGH, Wire);
if (iaqSensor.bsecStatus != BSEC_OK) return;
if (iaqSensor.bme68xStatus != BME68X_OK) return;
bsec_virtual_sensor_t sensorList[13] = {
BSEC_OUTPUT_IAQ,
BSEC_OUTPUT_STATIC_IAQ,
BSEC_OUTPUT_CO2_EQUIVALENT,
BSEC_OUTPUT_BREATH_VOC_EQUIVALENT,
BSEC_OUTPUT_RAW_TEMPERATURE,
BSEC_OUTPUT_RAW_PRESSURE,
BSEC_OUTPUT_RAW_HUMIDITY,
BSEC_OUTPUT_RAW_GAS,
BSEC_OUTPUT_STABILIZATION_STATUS,
BSEC_OUTPUT_RUN_IN_STATUS,
BSEC_OUTPUT_SENSOR_HEAT_COMPENSATED_TEMPERATURE,
BSEC_OUTPUT_SENSOR_HEAT_COMPENSATED_HUMIDITY,
BSEC_OUTPUT_GAS_PERCENTAGE
};

iaqSensor.updateSubscription(sensorList, 13, BSEC_SAMPLE_RATE_LP);

sensorRegister(SENSORS::SBME680);
}

/// AHTXX sensors init
Expand Down
38 changes: 19 additions & 19 deletions src/Sensors.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include <AHTxx.h>
#include <AM232X.h>
#include <Adafruit_BME280.h>
#include <Adafruit_BME680.h>
#include "bsec.h"
#include <Adafruit_BMP280.h>
#include <Adafruit_SCD30.h>
#include <Adafruit_SHT31.h>
Expand Down Expand Up @@ -115,7 +115,7 @@
X(CO2HUM, "%", "CO2H") \
X(PRESS, "hPa", "P") \
X(ALT, "m", "Alt") \
X(GAS, "Ohm", "Gas") \
X(GAS, "kohm", "Gas") \
X(CPM, "CPM", "RAD") \
X(RAD, "uSv/h", "RAD") \
X(NH3, "ppm", "NH3") \
Expand Down Expand Up @@ -206,27 +206,27 @@ class Sensors {
/// only detect i2c sensors flag
bool i2conly;

/*****************************************
/*****************************************
* I2C sensors:
****************************************/

/// AM2320 object (Humidity and temperature)
AM232X am2320;
/// BME280 object (Humidity, Pressure, Altitude and Temperature)
Adafruit_BME280 bme280;
/// BMP280 object (Humidity, Pressure, Altitude and Temperature)
Adafruit_BMP280 bmp280;
/// BME680 object (Humidity, Gas, IAQ, Pressure, Altitude and Temperature)
Adafruit_BME680 bme680;
/// AHTXX sensors object
AHTxx aht10;
/// SHT31 object (Humidity and temperature)
Adafruit_SHT31 sht31;

#ifdef DHT11_ENABLED
/// AM2320 object (Humidity and temperature)
AM232X am2320;
/// BME280 object (Humidity, Pressure, Altitude and Temperature)
Adafruit_BME280 bme280;
/// BMP280 object (Humidity, Pressure, Altitude and Temperature)
Adafruit_BMP280 bmp280;
/// BME680 object (Humidity, Gas, IAQ, Pressure, Altitude and Temperature)
Bsec iaqSensor;
/// AHTXX sensors object
AHTxx aht10;
/// SHT31 object (Humidity and temperature)
Adafruit_SHT31 sht31;

#ifdef DHT11_ENABLED
/// @deprecated DHT sensor variable
float dhthumi, dhttemp;
#endif
#endif
/// Mhz19 object sensor
MHZ19 mhz19;
/// SCD30 object sensor
Expand Down
2 changes: 1 addition & 1 deletion unified-lib-deps.ini
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ lib_deps =
adafruit/Adafruit Unified [email protected]
adafruit/Adafruit BME280 [email protected]
adafruit/Adafruit BMP280 [email protected]
adafruit/Adafruit BME680 Library@2.0.4
boschsensortec/BSEC Software Library @ ^1.8.1492
adafruit/Adafruit SHT31 [email protected]
adafruit/Adafruit [email protected]
adafruit/Adafruit [email protected]
Expand Down