06-21-2023 10:35 PM
Helllo,
I am trying to use BSEC v1.8.1492 driving a BME680 sensor using ESP32 chip, I am using Arduino framework and PlatfotmIO.
Previously I used BSEC Software Library v1.6.1480 and everything worked smoothly but I couldn't make it work after updating the BSEC to the latest version (1.8.xxxx).
I basically used the official example in github
So basically iaqSensor.run() is always false but it seems to work once I commented iaqSensor.setConfig(bsec_config_iaq);
and here is the actual code I am using
#include <bsec.h>
#include <Wire.h>
#include <Arduino.h>
const uint8_t bsec_config_iaq[] = {
#include "config/generic_33v_3s_4d/bsec_iaq.txt"
};
#define SERIAL_BAUDRATE 115200
#define EEPROM_SIZE 512
#define VERBOSE true
#define DEVICE_NAME "Connected Ambiente"
//* I2C Pins
#define I2C_SDA_PIN GPIO_NUM_13
#define I2C_SCL_PIN GPIO_NUM_15
#define OLED_Address 0x3c
#define I2C_Frequency 400000
void checkIaqSensorStatus();
Bsec iaqSensor;
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};
void setup()
{
Serial.begin(SERIAL_BAUDRATE);
Wire.begin(I2C_SDA_PIN, I2C_SCL_PIN, (uint32_t)I2C_Frequency);
iaqSensor.begin(BME68X_I2C_ADDR_LOW, Wire);
if (iaqSensor.bme68xStatus != 0)
{
iaqSensor.begin(BME68X_I2C_ADDR_HIGH, Wire);
if (iaqSensor.bme68xStatus != 0)
{
printf("No sensor found.\r\n");
return;
}
else
printf("BME680 sensor found with secondary address.\r\n");
}
else
printf("BME680 sensor found with primary address.\r\n");
checkIaqSensorStatus();
iaqSensor.updateSubscription(sensorList, 13, BSEC_SAMPLE_RATE_LP);
iaqSensor.setConfig(bsec_config_iaq);
checkIaqSensorStatus();
printf(">> Sensor : BSEC library version %d.%d.%d.%d\r\n",
iaqSensor.version.major,
iaqSensor.version.minor,
iaqSensor.version.major_bugfix,
iaqSensor.version.minor_bugfix);
}
void loop()
{
// put your main code here, to run repeatedly:
delay(100);
unsigned long time_trigger = millis();
if (iaqSensor.run())
{ // If new data is available
String output = String(time_trigger);
output += ", iaq: " + String(iaqSensor.iaq);
output += ", iaqAccuracy: " + String(iaqSensor.iaqAccuracy);
output += ", staticIaq: " + String(iaqSensor.staticIaq);
output += ", co2Equivalent: " + String(iaqSensor.co2Equivalent);
output += ", breathVocEquivalent: " + String(iaqSensor.breathVocEquivalent);
output += ", rawTemperature: " + String(iaqSensor.rawTemperature);
output += ", temperature: " + String(iaqSensor.temperature);
output += ", " + String(iaqSensor.pressure);
output += ", rawHumidity: " + String(iaqSensor.rawHumidity);
output += ", humidity: " + String(iaqSensor.humidity);
output += ", gasResistance: " + String(iaqSensor.gasResistance);
output += ", stabStatus: " + String(iaqSensor.stabStatus);
output += ", runInStatus: " + String(iaqSensor.runInStatus);
output += ", gasPercentage: " + String(iaqSensor.gasPercentage);
Serial.println(output);
}
else
{
checkIaqSensorStatus();
}
}
void checkIaqSensorStatus(void)
{
if (iaqSensor.bsecStatus != BSEC_OK)
{
if (iaqSensor.bsecStatus < BSEC_OK)
{
printf("BSEC error code : %d\r\n", iaqSensor.bsecStatus);
for (;;)
; /* Halt in case of failure */
}
else
{
printf("BSEC warning code : %d\r\n", iaqSensor.bsecStatus);
}
}
if (iaqSensor.bme68xStatus != BME68X_OK)
{
if (iaqSensor.bme68xStatus < BME68X_OK)
{
printf("BME68X error code : %d\r\n", iaqSensor.bme68xStatus);
for (;;)
; /* Halt in case of failure */
}
else
{
printf("BME68X warning code : %d\r\n", iaqSensor.bme68xStatus);
}
}
}
Solved! Go to Solution.
06-26-2023 11:30 AM
Hi rezza,
We recommend you to use latest library(BSEC2.4.0.0), you can dowload it from https://www.bosch-sensortec.com/software-tools/software/bme688-software
06-27-2023 09:45 AM
Hi rezza,
If you download BSEC2.4.0.0, you can also use latest API, example code, bsec.cpp in the software package.
06-28-2023 08:27 PM
Thank you for your reply.
I basically downloaded the latest library(BSEC2.4.0.0), I now I am running under v2.4.0.4. But I am experiencing the same issue.
As I mentioned above, in latest version iaqSensor.run() is always false but it seems to work once I comment iaqSensor.setConfig(bsec_config_iaq);
I attached the bsec.cpp file, I am using atm.
07-03-2023 08:15 AM
Hi rezza,
bsec.cpp was not contained in BSEC2.4.0.0. As you downloaed BSEC2.4.0.0, please use the example code under BSEC2.4.0.0 package.