11-18-2020 07:52 PM - edited 11-18-2020 07:53 PM
I am running basic.ino example from the repo. I have BME680 soldered to D1 Mini (ESP8266) over I2C (D1 -> SCL, D2 -> SDA, 3V3 -> VCC, G -> GND. I have commented out infinite LED blinking loop and seeing that measurement succeeds after intermittant 'BME680 error code : -2' (BME680_E_COM_FAIL).
Here is the code:
#include "bsec.h"
// Helper functions declarations
void checkIaqSensorStatus(void);
void errLeds(void);
// Create an object of the class Bsec
Bsec iaqSensor;
String output;
// Entry point for the example
void setup(void)
{
Serial.begin(115200);
Wire.begin();
iaqSensor.begin(BME680_I2C_ADDR_PRIMARY, Wire);
output = "\nBSEC library version " + String(iaqSensor.version.major) + "." + String(iaqSensor.version.minor) + "." + String(iaqSensor.version.major_bugfix) + "." + String(iaqSensor.version.minor_bugfix);
Serial.println(output);
checkIaqSensorStatus();
bsec_virtual_sensor_t sensorList[10] = {
BSEC_OUTPUT_RAW_TEMPERATURE,
BSEC_OUTPUT_RAW_PRESSURE,
BSEC_OUTPUT_RAW_HUMIDITY,
BSEC_OUTPUT_RAW_GAS,
BSEC_OUTPUT_IAQ,
BSEC_OUTPUT_STATIC_IAQ,
BSEC_OUTPUT_CO2_EQUIVALENT,
BSEC_OUTPUT_BREATH_VOC_EQUIVALENT,
BSEC_OUTPUT_SENSOR_HEAT_COMPENSATED_TEMPERATURE,
BSEC_OUTPUT_SENSOR_HEAT_COMPENSATED_HUMIDITY,
};
iaqSensor.updateSubscription(sensorList, 10, BSEC_SAMPLE_RATE_LP);
checkIaqSensorStatus();
// Print the header
output = "Timestamp [ms], raw temperature [°C], pressure [hPa], raw relative humidity [%], gas [Ohm], IAQ, IAQ accuracy, temperature [°C], relative humidity [%], Static IAQ, CO2 equivalent, breath VOC equivalent";
Serial.println(output);
}
// Function that is looped forever
void loop(void)
{
unsigned long time_trigger = millis();
if (iaqSensor.run()) { // If new data is available
output = String(time_trigger);
output += ", " + String(iaqSensor.rawTemperature);
output += ", " + String(iaqSensor.pressure);
output += ", " + String(iaqSensor.rawHumidity);
output += ", " + String(iaqSensor.gasResistance);
output += ", " + String(iaqSensor.iaq);
output += ", " + String(iaqSensor.iaqAccuracy);
output += ", " + String(iaqSensor.temperature);
output += ", " + String(iaqSensor.humidity);
output += ", " + String(iaqSensor.staticIaq);
output += ", " + String(iaqSensor.co2Equivalent);
output += ", " + String(iaqSensor.breathVocEquivalent);
Serial.println(output);
} else {
checkIaqSensorStatus();
}
}
// Helper function definitions
void checkIaqSensorStatus(void)
{
if (iaqSensor.status != BSEC_OK) {
if (iaqSensor.status < BSEC_OK) {
output = "BSEC error code : " + String(iaqSensor.status);
Serial.println(output);
for (;;)
errLeds(); /* Halt in case of failure */
} else {
output = "BSEC warning code : " + String(iaqSensor.status);
Serial.println(output);
}
}
if (iaqSensor.bme680Status != BME680_OK) {
if (iaqSensor.bme680Status < BME680_OK) {
output = "BME680 error code : " + String(iaqSensor.bme680Status);
Serial.println(output);
// for (;;)
// errLeds(); /* Halt in case of failure */
} else {
output = "BME680 warning code : " + String(iaqSensor.bme680Status);
Serial.println(output);
}
}
}
void errLeds(void)
{
pinMode(LED_BUILTIN, OUTPUT);
digitalWrite(LED_BUILTIN, HIGH);
delay(100);
digitalWrite(LED_BUILTIN, LOW);
delay(100);
}
Here is the output:
10:41:07.066 -> BSEC library version 1.4.8.0
10:41:07.066 -> Timestamp [ms], raw temperature [°C], pressure [hPa], raw relative humidity [%], gas [Ohm], IAQ, IAQ accuracy, temperature [°C], relative humidity [%], Static IAQ, CO2 equivalent, breath VOC equivalent
10:41:07.305 -> 98, 23.60, 99947.00, 39.07, 14591.00, 25.00, 0, 23.60, 39.07, 25.00, 500.00, 0.50
10:41:10.324 -> 3098, 23.71, 99949.00, 38.87, 14080.00, 25.00, 0, 23.65, 38.82, 25.00, 500.00, 0.50
10:41:13.309 -> 6097, 24.16, 99949.00, 38.92, 14205.00, 25.00, 0, 24.10, 38.09, 25.00, 500.00, 0.50
10:41:16.056 -> BME680 error code : -2
....
10:41:19.086 -> BME680 error code : -2
10:41:19.329 -> 12098, 23.08, 99947.00, 38.90, 13766.00, 25.00, 0, 23.06, 40.19, 25.00, 500.00, 0.50
10:41:22.317 -> 15097, 23.14, 99947.00, 38.90, 13940.00, 25.00, 0, 23.08, 39.91, 25.00, 500.00, 0.50
10:41:25.300 -> 18098, 23.27, 99947.00, 38.90, 14024.00, 25.00, 0, 23.21, 39.48, 25.00, 500.00, 0.50
10:41:28.318 -> 21098, 23.40, 99949.00, 38.84, 14005.00, 25.00, 0, 23.34, 39.09, 25.00, 500.00, 0.50
10:41:31.310 -> 24098, 23.46, 99951.00, 38.74, 14043.00, 25.00, 0, 23.40, 38.86, 25.00, 500.00, 0.50
10:41:34.335 -> 27098, 23.55, 99951.00, 38.63, 14090.00, 25.00, 0, 23.49, 38.59, 25.00, 500.00, 0.50
10:41:37.305 -> 30097, 23.57, 99949.00, 38.52, 14043.00, 25.00, 0, 23.51, 38.48, 25.00, 500.00, 0.50
10:41:40.320 -> 33098, 23.63, 99951.00, 38.47, 14128.00, 25.00, 0, 23.57, 38.37, 25.00, 500.00, 0.50
10:41:43.328 -> 36098, 23.72, 99953.00, 38.42, 14118.00, 25.00, 0, 23.66, 38.21, 25.00, 500.00, 0.50
10:41:46.310 -> 39097, 23.90, 99947.00, 38.40, 14185.00, 25.00, 0, 23.84, 37.94, 25.00, 500.00, 0.50
10:41:49.335 -> 42098, 24.22, 99955.00, 38.40, 14253.00, 25.00, 0, 24.16, 37.50, 25.00, 500.00, 0.50
10:41:52.304 -> 45097, 24.72, 99953.00, 38.37, 14370.00, 25.00, 0, 24.66, 36.81, 25.00, 500.00, 0.50
10:41:55.330 -> 48098, 23.58, 99949.00, 38.15, 14157.00, 25.00, 0, 23.52, 39.00, 25.00, 500.00, 0.50
10:41:58.311 -> 51098, 23.56, 99949.00, 38.09, 14166.00, 25.00, 0, 23.50, 38.83, 25.00, 500.00, 0.50
10:42:01.314 -> 54098, 23.58, 99949.00, 38.07, 14224.00, 25.00, 0, 23.52, 38.64, 25.00, 500.00, 0.50
10:42:04.302 -> 57098, 23.59, 99945.00, 38.02, 14253.00, 25.00, 0, 23.53, 38.48, 25.00, 500.00, 0.50
10:42:07.302 -> 60098, 23.60, 99947.00, 38.01, 14272.00, 25.00, 0, 23.54, 38.39, 25.00, 500.00, 0.50
10:42:10.306 -> 63097, 23.61, 99947.00, 37.98, 14234.00, 25.00, 0, 23.55, 38.29, 25.00, 500.00, 0.50
10:42:13.337 -> 66098, 23.64, 99949.00, 37.97, 14272.00, 25.00, 0, 23.58, 38.20, 25.00, 500.00, 0.50
10:42:16.309 -> 69098, 23.66, 99949.00, 37.99, 14253.00, 25.00, 0, 23.60, 38.16, 25.00, 500.00, 0.50
10:42:19.326 -> 72098, 23.70, 99951.00, 38.00, 14272.00, 25.00, 0, 23.64, 38.09, 25.00, 500.00, 0.50
10:42:22.305 -> 75098, 23.80, 99953.00, 38.04, 14272.00, 25.00, 0, 23.74, 37.97, 25.00, 500.00, 0.50
10:42:25.326 -> 78098, 23.98, 99951.00, 38.12, 14331.00, 25.00, 0, 23.92, 37.77, 25.00, 500.00, 0.50
10:42:28.327 -> 81098, 24.33, 99953.00, 38.14, 14400.00, 25.00, 0, 24.27, 37.27, 25.00, 500.00, 0.50
10:42:31.338 -> 84097, 24.87, 99958.00, 38.19, 14470.00, 25.00, 0, 24.81, 36.59, 25.00, 500.00, 0.50
10:42:34.339 -> 87098, 23.54, 99951.00, 37.99, 14224.00, 25.00, 0, 23.48, 39.15, 25.00, 500.00, 0.50
10:42:37.327 -> 90098, 23.55, 99949.00, 37.99, 14311.00, 25.00, 0, 23.49, 38.91, 25.00, 500.00, 0.50
10:42:40.303 -> 93098, 23.57, 99949.00, 37.98, 14311.00, 25.00, 0, 23.51, 38.70, 25.00, 500.00, 0.50
10:42:43.313 -> 96098, 23.57, 99953.00, 37.96, 14311.00, 25.00, 0, 23.51, 38.56, 25.00, 500.00, 0.50
10:42:46.324 -> 99098, 23.59, 99949.00, 37.99, 14272.00, 25.00, 0, 23.53, 38.45, 25.00, 500.00, 0.50
10:42:49.308 -> 102098, 23.61, 99947.00, 37.96, 14292.00, 25.00, 0, 23.55, 38.32, 25.00, 500.00, 0.50
10:42:52.325 -> 105098, 23.67, 99955.00, 37.96, 14311.00, 25.00, 0, 23.61, 38.17, 25.00, 500.00, 0.50
10:42:55.320 -> 108097, 23.74, 99951.00, 37.98, 14272.00, 25.00, 0, 23.68, 38.05, 25.00, 500.00, 0.50
10:42:58.335 -> 111098, 23.83, 99957.00, 37.98, 14331.00, 25.00, 0, 23.77, 37.90, 25.00, 500.00, 0.50
10:43:01.310 -> 114098, 23.95, 99953.00, 37.96, 14351.00, 25.00, 0, 23.89, 37.72, 25.00, 500.00, 0.50
10:43:04.303 -> 117097, 24.17, 99955.00, 37.98, 14370.00, 25.00, 0, 24.11, 37.43, 25.00, 500.00, 0.50
10:43:07.331 -> 120098, 24.58, 99957.00, 37.98, 14460.00, 25.00, 0, 24.52, 36.85, 25.00, 500.00, 0.50
10:43:10.334 -> 123098, 25.06, 99951.00, 38.01, 14591.00, 25.00, 0, 25.00, 36.33, 25.00, 500.00, 0.50
10:43:13.346 -> 126098, 23.71, 99955.00, 37.79, 14234.00, 25.00, 0, 23.65, 38.90, 25.00, 500.00, 0.50
10:43:16.307 -> 129098, 23.75, 99955.00, 37.77, 14341.00, 25.00, 0, 23.69, 38.59, 25.00, 500.00, 0.50
10:43:19.302 -> 132097, 23.79, 99958.00, 37.74, 14370.00, 25.00, 0, 23.73, 38.35, 25.00, 500.00, 0.50
10:43:22.313 -> 135098, 23.83, 99958.00, 37.68, 14390.00, 25.00, 0, 23.77, 38.12, 25.00, 500.00, 0.50
10:43:25.329 -> 138098, 23.87, 99955.00, 37.62, 14430.00, 25.00, 0, 23.81, 37.92, 25.00, 500.00, 0.50
10:43:28.307 -> 141098, 23.92, 99955.00, 37.59, 14341.00, 25.00, 0, 23.86, 37.77, 25.00, 500.00, 0.50
10:43:31.334 -> 144098, 23.99, 99955.00, 37.55, 14351.00, 25.00, 0, 23.93, 37.60, 25.00, 500.00, 0.50
10:43:34.304 -> 147098, 24.07, 99958.00, 37.52, 14390.00, 25.00, 0, 24.01, 37.45, 25.00, 500.00, 0.50
10:43:37.315 -> 150098, 24.15, 99955.00, 37.50, 14390.00, 25.00, 0, 24.09, 37.33, 25.00, 500.00, 0.50
10:43:40.319 -> 153098, 24.27, 99957.00, 37.44, 14470.00, 25.00, 0, 24.21, 37.13, 25.00, 500.00, 0.50
10:43:43.303 -> 156098, 24.50, 99957.00, 37.45, 14510.00, 25.00, 0, 24.44, 36.83, 25.00, 500.00, 0.50
10:43:46.331 -> 159098, 24.94, 99960.00, 37.49, 14631.00, 25.00, 0, 24.88, 36.27, 25.00, 500.00, 0.50
10:43:49.340 -> 162097, 23.86, 99949.00, 37.30, 14292.00, 25.00, 0, 23.80, 38.28, 25.00, 500.00, 0.50
10:43:52.310 -> 165098, 23.88, 99951.00, 37.30, 14370.00, 25.00, 0, 23.82, 38.06, 25.00, 500.00, 0.50
10:43:55.333 -> 168098, 23.92, 99953.00, 37.29, 14470.00, 25.00, 0, 23.86, 37.85, 25.00, 500.00, 0.50
10:43:58.306 -> 171098, 23.96, 99951.00, 37.27, 14450.00, 25.00, 0, 23.90, 37.66, 25.00, 500.00, 0.50
10:44:01.321 -> 174098, 23.99, 99953.00, 37.23, 14410.00, 25.00, 0, 23.93, 37.52, 25.00, 500.00, 0.50
10:44:04.330 -> 177097, 24.03, 99951.00, 37.19, 14430.00, 25.00, 0, 23.97, 37.38, 25.00, 500.00, 0.50
10:44:07.306 -> 180098, 24.10, 99955.00, 37.15, 14440.00, 25.00, 0, 24.04, 37.21, 25.00, 500.00, 0.50
10:44:10.306 -> 183098, 24.15, 99955.00, 37.13, 14460.00, 25.00, 0, 24.09, 37.11, 25.00, 500.00, 0.50
10:44:13.333 -> 186098, 24.22, 99958.00, 37.11, 14520.00, 25.00, 0, 24.16, 37.00, 25.00, 500.00, 0.50
10:44:16.323 -> 189097, 24.33, 99957.00, 37.07, 14580.00, 25.00, 0, 24.27, 36.83, 25.00, 500.00, 0.50
10:44:19.326 -> 192097, 24.48, 99958.00, 37.05, 14470.00, 25.00, 0, 24.42, 36.63, 25.00, 500.00, 0.50
10:44:22.312 -> 195098, 24.79, 99958.00, 37.07, 14642.00, 25.00, 0, 24.73, 36.24, 25.00, 500.00, 0.50
10:44:25.320 -> 198098, 25.34, 99964.00, 37.10, 14683.00, 25.00, 0, 25.28, 35.54, 25.00, 500.00, 0.50
10:44:28.322 -> BME680 warning code : 2
...
10:44:31.073 -> BME680 warning code : 2
10:44:31.331 -> 204099, 24.08, 99955.00, 36.89, 14430.00, 25.00, 0, 24.06, 37.79, 25.00, 500.00, 0.50
10:44:34.305 -> 207099, 24.07, 99957.00, 36.88, 14470.00, 25.00, 0, 24.01, 37.70, 25.00, 500.00, 0.50
10:44:37.335 -> 210099, 24.07, 99957.00, 36.93, 14530.00, 25.00, 0, 24.01, 37.61, 25.00, 500.00, 0.50
10:44:40.313 -> 213099, 24.09, 99955.00, 37.00, 14480.00, 25.00, 0, 24.03, 37.53, 25.00, 500.00, 0.50
10:44:43.313 -> 216098, 24.13, 99955.00, 36.99, 14470.00, 25.00, 0, 24.07, 37.37, 25.00, 500.00, 0.50
10:44:46.308 -> 219099, 24.19, 99957.00, 37.01, 14500.00, 25.00, 0, 24.13, 37.23, 25.00, 500.00, 0.50
10:44:49.308 -> 222099, 24.24, 99958.00, 37.00, 14510.00, 25.00, 0, 24.18, 37.12, 25.00, 500.00, 0.50
10:44:52.341 -> 225099, 24.33, 99962.00, 36.96, 14530.00, 25.00, 0, 24.27, 36.93, 25.00, 500.00, 0.50
10:44:55.321 -> 228098, 24.43, 99964.00, 36.95, 14500.00, 25.00, 0, 24.37, 36.78, 25.00, 500.00, 0.50
10:44:58.333 -> 231098, 24.62, 99960.00, 36.97, 14611.00, 25.00, 0, 24.56, 36.54, 25.00, 500.00, 0.50
10:45:01.316 -> 234099, 24.99, 99964.00, 37.02, 14631.00, 25.00, 0, 24.93, 36.07, 25.00, 500.00, 0.50
10:45:04.305 -> 237099, 25.49, 99960.00, 37.08, 14703.00, 25.00, 0, 25.43, 35.52, 25.00, 500.00, 0.50
10:45:07.330 -> 240099, 24.12, 99957.00, 36.89, 14450.00, 25.00, 0, 24.06, 38.07, 25.00, 500.00, 0.50
10:45:10.332 -> 243099, 24.14, 99957.00, 36.89, 14510.00, 25.00, 0, 24.08, 37.81, 25.00, 500.00, 0.50
10:45:13.312 -> 246099, 24.17, 99958.00, 36.85, 14570.00, 25.00, 0, 24.11, 37.55, 25.00, 500.00, 0.50
10:45:16.306 -> 249099, 24.17, 99957.00, 36.83, 14470.00, 25.00, 0, 24.11, 37.41, 25.00, 500.00, 0.50
10:45:19.320 -> 252099, 24.20, 99958.00, 36.82, 14540.00, 25.00, 0, 24.14, 37.25, 25.00, 500.00, 0.50
10:45:22.313 -> 255099, 24.24, 99960.00, 36.77, 14490.00, 25.00, 0, 24.18, 37.07, 25.00, 500.00, 0.50
11-18-2020 08:06 PM
Hello,
error code -2 means there is some communication error. Therefore, I assume that your I2C is some in unstable state sometimes.
And, if you are using 3s interval, normally it takes 20 ~30 mins to get IAQ. You can get IAQ after IAQ accuracy is >= 1.
Warning 2 means htere is no value, so certainly some interface issue.
Could you please test with our latest version of BSEC library and wait for 20 ~ 30 mins?
https://www.bosch-sensortec.com/software-tools/software/bsec/
Thanks,
11-18-2020 09:51 PM
It took about 1 hour and 18 minutes to see some non-25 value for IAQ!
Here is the new output:
11:58:53.423 -> 4662134, 23.22, 99986.00, 35.22, 8167.00, 25.00, 1, 23.16, 36.36, 25.00, 500.00, 0.50
11:58:53.423 -> 4665133, 23.24, 99986.00, 35.24, 8205.00, 26.77, 1, 23.18, 36.13, 25.77, 503.09, 0.51
11:59:14.488 -> 4668134, 23.26, 99986.00, 35.22, 8205.00, 28.13, 1, 23.20, 35.92, 26.37, 505.46, 0.51
Any idea why it took such a long time? Also, does intermittent communication error (code -2) have any impact on IAQ value?
11-19-2020 01:59 AM
Hello,
-2 means communication error, so it should affect IAQ initialization.
Thanks,