Hi all, I'm using the Arduino GitHub repository for use a BME680 sensor with the BSEC software. I'm making the code with VSCode and Platformio with a Zero Arduino board which have a Cortex M0+. Platformio compile the "libalgobsec.a" library without errors. The application request a new data every 5 minutes with the "run()" method of the BSEC object. So the configuration have been made with the "generic_18V_300s_4d" file and "BSEC_SAMPLE_RATE_ULP". When the program starts, the IAQ accuracy change from 0 to 1 in about 20 minutes but this value (1) remains for more than 15 hours with no change to 2 but sometimes changes to 0. The IAQ value changes between 25 and 250. I tried made the application with 3 seconds sample option and the result is that it does change but the 3 IAQ accuracy value is continusly changes with accuracy 2. I share my code in case there is something wrong. Attach the IAQ and IAQ accuracy data too. The time that you will see it's the time of the sent to a server but the "tick2()" function of the code is executed every 300 seconds with +-5 ms of error. Appreciate any help. Thanks. Bsec iaqSensor;
String output;
uint8_t bsecState[BSEC_MAX_STATE_BLOB_SIZE] = {0};
uint16_t stateUpdateCounter = 0;
const uint8_t bsec_config_iaq[] = {
#include "config/generic_18v_300s_4d/bsec_iaq.txt"
};
void checkIaqSensorStatus(void) {
if (iaqSensor.status != BSEC_OK) {
if (iaqSensor.status < BSEC_OK) {
output = "BSEC error code : " + String(iaqSensor.status);
RH_UART_DEBUG.println(output);
_delay::s(1);
// for (;;) errLeds(); /* Halt in case of failure */
} else {
output = "BSEC warning code : " + String(iaqSensor.status);
RH_UART_DEBUG.println(output);
}
}
if (iaqSensor.bme680Status != BME680_OK) {
if (iaqSensor.bme680Status < BME680_OK) {
output = "BME680 error code : " + String(iaqSensor.bme680Status);
RH_UART_DEBUG.println(output);
_delay::s(1);
// for (;;) errLeds(); // Halt in case of failure
} else {
output = "BME680 warning code : " + String(iaqSensor.bme680Status);
RH_UART_DEBUG.println(output);
_delay::s(1);
}
}
}
void loadState(void) {
if (EEPROM.read(0) == BSEC_MAX_STATE_BLOB_SIZE) {
// Existing state in EEPROM
Serial.println("Reading state from EEPROM");
for (uint8_t i = 0; i < BSEC_MAX_STATE_BLOB_SIZE; i++) {
bsecState[i] = EEPROM.read(i + 1);
Serial.println(bsecState[i], HEX);
}
iaqSensor.setState(bsecState);
checkIaqSensorStatus();
} else {
// Erase the EEPROM with zeroes
Serial.println("Erasing EEPROM");
for (uint8_t i = 0; i < BSEC_MAX_STATE_BLOB_SIZE + 1; i++)
EEPROM.write(i, 0);
EEPROM.commit();
}
}
void updateState(void) {
bool update = false;
/* Set a trigger to save the state. Here, the state is saved every
* STATE_SAVE_PERIOD with the first state being saved once the algorithm
* achieves full calibration, i.e. iaqAccuracy = 3 */
if (stateUpdateCounter == 0) {
if (iaqSensor.iaqAccuracy >= 3) {
update = true;
stateUpdateCounter++;
}
} else {
/* Update every STATE_SAVE_PERIOD milliseconds */
if ((stateUpdateCounter * STATE_SAVE_PERIOD) < millis()) {
update = true;
stateUpdateCounter++;
}
}
if (update) {
iaqSensor.getState(bsecState);
checkIaqSensorStatus();
Serial.println("Writing state to EEPROM");
for (uint8_t i = 0; i < BSEC_MAX_STATE_BLOB_SIZE; i++) {
EEPROM.write(i + 1, bsecState[i]);
Serial.println(bsecState[i], HEX);
}
EEPROM.write(0, BSEC_MAX_STATE_BLOB_SIZE);
EEPROM.commit();
}
}
uint8_t tick2(uint8_t param) {
echo::info(F("ESTAMOS EN TICK2"));
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);
RH_UART_DEBUG.println(output);
} else {
checkIaqSensorStatus();
}
uint8_t err = puf::emit(EV_TICK1, 0);
if (err > 0) {
echo::error("Transmit error");
echo::info("Triying transmit again");
}
return 0;
}
void errLeds(void) {
pinMode(LED_BUILTIN, OUTPUT);
digitalWrite(LED_BUILTIN, HIGH);
delay(100);
digitalWrite(LED_BUILTIN, LOW);
delay(100);
}
uint8_t init(uint8_t param) {
char version[50];
// EEPROM.init(); // 1st address for the length
Wire.begin();
// Intialition BSEC object with I2C address. To select the other address:
// BME680_I2C_ADDR_SECONDARY
iaqSensor.begin(SENS_BME680_ADDRESS, Wire);
sprintf(version, "BSEC library version %u.%u.%u.%u", iaqSensor.version.major,
iaqSensor.version.minor, iaqSensor.version.major_bugfix,
iaqSensor.version.minor_bugfix);
Serial.println(version);
checkIaqSensorStatus();
iaqSensor.setConfig(bsec_config_iaq);
checkIaqSensorStatus();
loadState();
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,
};
// Sets desired sensors and sample rate (more sample rates:
// bsec_datatypes.h)
iaqSensor.updateSubscription(sensorList, 10, BSEC_SAMPLE_RATE_ULP);
checkIaqSensorStatus();
return 0;
} OUTPUT DATE IAQ IAQ Accuracy 26-05-21 08:44:09 132.98 1
26-05-21 08:39:14 122.24 1
26-05-21 08:34:09 117.59 1
26-05-21 08:29:09 143.09 1
26-05-21 08:24:09 140.65 1
26-05-21 08:19:09 125.13 1
26-05-21 08:14:09 132.42 1
26-05-21 08:09:09 117.78 1
26-05-21 08:04:11 109.59 1
26-05-21 07:59:09 134.84 1
26-05-21 07:54:09 139.30 1
26-05-21 07:49:09 140.31 1
26-05-21 07:44:10 135.23 1
26-05-21 07:39:11 146.98 1
26-05-21 07:34:09 143.59 1
26-05-21 07:29:10 153.56 1
26-05-21 07:24:22 161.00 1
26-05-21 07:14:20 194.04 1
26-05-21 07:09:10 157.41 1
26-05-21 07:04:15 123.45 1
26-05-21 06:59:10 130.16 1
26-05-21 06:54:10 112.98 1
26-05-21 06:49:13 104.60 1
26-05-21 06:44:10 123.72 1
26-05-21 06:39:10 198.72 1
26-05-21 06:34:10 250.00 1
26-05-21 06:29:10 116.85 1
26-05-21 06:24:12 58.17 1
26-05-21 06:19:10 25.00 1
26-05-21 06:14:10 27.24 1
26-05-21 06:09:10 25.00 1
26-05-21 06:04:11 41.72 1
26-05-21 05:59:11 31.74 1
26-05-21 05:54:11 36.14 1
26-05-21 05:49:11 25.00 1
26-05-21 05:44:11 25.00 1
26-05-21 05:39:12 31.13 1
26-05-21 05:29:12 26.79 1
26-05-21 05:24:11 35.00 1
26-05-21 05:19:11 31.57 1
26-05-21 05:14:11 40.31 1
26-05-21 05:09:11 34.98 1
26-05-21 05:04:12 42.42 1
26-05-21 04:59:11 32.36 1
26-05-21 04:54:12 28.37 1
26-05-21 04:49:12 32.42 1
26-05-21 04:44:12 36.08 1
26-05-21 04:39:12 43.79 1
26-05-21 04:34:16 44.10 1
26-05-21 04:29:12 47.42 1
26-05-21 04:24:12 44.60 0
26-05-21 04:19:16 44.30 0
26-05-21 04:14:12 40.25 0
26-05-21 04:09:12 35.63 0
26-05-21 04:04:11 35.63 1
26-05-21 03:59:17 35.63 1
26-05-21 03:54:12 32.11 1
26-05-21 03:49:12 35.29 1
26-05-21 03:44:13 33.24 1
26-05-21 03:39:13 31.95 1
26-05-21 03:34:13 32.72 1
26-05-21 03:29:13 36.49 1
26-05-21 03:24:13 28.15 1
26-05-21 03:19:13 25.00 1
26-05-21 03:14:13 31.66 1
26-05-21 03:09:13 34.12 1
26-05-21 03:04:18 32.28 1
26-05-21 02:59:13 25.00 1
26-05-21 02:54:13 32.15 1
26-05-21 02:49:14 30.64 1
26-05-21 02:44:14 28.42 1
26-05-21 02:39:14 31.26 1
26-05-21 02:34:14 34.94 1
26-05-21 02:29:14 34.26 1
26-05-21 02:24:14 26.35 1
26-05-21 02:19:14 34.41 1
26-05-21 02:14:14 25.00 1
26-05-21 02:09:14 25.00 1
26-05-21 02:04:15 25.00 1
26-05-21 01:59:14 25.00 1
26-05-21 01:54:14 35.23 1
26-05-21 01:39:14 37.73 0
26-05-21 01:29:14 31.31 0
26-05-21 01:24:14 26.30 0
26-05-21 01:19:12 26.30 1
26-05-21 01:14:18 26.30 1
26-05-21 01:09:14 27.23 1
26-05-21 01:04:14 27.49 1
26-05-21 00:59:14 35.74 1
26-05-21 00:54:14 39.14 1
26-05-21 00:49:15 39.07 0
26-05-21 00:44:14 37.07 0
26-05-21 00:39:14 33.94 0
26-05-21 00:34:14 28.27 0
26-05-21 00:29:12 28.27 1
26-05-21 00:24:14 28.27 1
26-05-21 00:19:14 29.39 1
26-05-21 00:14:14 28.47 1
26-05-21 00:09:14 41.25 1
26-05-21 00:04:15 36.47 1
25-05-21 23:59:14 38.69 1
25-05-21 23:54:15 45.62 1
25-05-21 23:49:15 42.16 1
25-05-21 23:39:15 25.00 1
25-05-21 23:34:15 32.23 1
25-05-21 23:29:15 30.52 1
25-05-21 23:24:15 34.94 1
25-05-21 23:19:15 25.33 1
25-05-21 23:14:15 32.41 1
25-05-21 23:09:15 33.12 1
25-05-21 23:04:15 29.70 1
25-05-21 22:59:15 42.86 1
25-05-21 22:54:15 37.36 1
25-05-21 22:49:16 30.35 1
25-05-21 22:44:15 32.19 1
25-05-21 22:39:15 36.44 1
25-05-21 22:34:15 36.63 1
25-05-21 22:29:15 33.75 1
25-05-21 22:24:15 25.00 1
25-05-21 22:19:15 28.77 1
25-05-21 22:14:15 29.84 1
25-05-21 22:09:15 25.00 1
25-05-21 22:04:16 27.60 1
25-05-21 21:59:16 27.63 1
25-05-21 21:54:16 38.21 1
25-05-21 21:49:16 25.27 1
25-05-21 21:44:16 28.15 1
25-05-21 21:39:16 27.38 1
25-05-21 21:34:16 34.76 1
25-05-21 21:29:16 25.00 1
25-05-21 21:24:16 30.44 1
25-05-21 21:19:16 25.00 1
25-05-21 21:14:16 29.70 1
25-05-21 21:09:16 25.00 1
25-05-21 21:04:16 25.00 1
25-05-21 20:59:16 25.86 1
25-05-21 20:54:16 31.16 1
25-05-21 20:49:16 31.88 1
25-05-21 20:44:16 28.02 1
25-05-21 20:39:16 33.85 1
25-05-21 20:34:16 33.81 1
25-05-21 20:29:16 30.25 1
25-05-21 20:24:16 39.24 1
25-05-21 20:19:16 36.08 1
25-05-21 20:14:16 37.51 1
25-05-21 20:09:16 35.12 1
25-05-21 20:04:16 35.00 1
25-05-21 19:59:16 38.24 1
25-05-21 19:54:17 25.00 1
25-05-21 19:49:17 30.88 1
25-05-21 19:44:17 25.00 1
25-05-21 19:39:17 31.32 1
25-05-21 19:34:17 30.47 1
25-05-21 19:29:17 28.03 1
25-05-21 19:24:17 42.23 1
25-05-21 19:19:17 43.23 1
25-05-21 19:14:17 34.38 1
25-05-21 19:09:17 25.00 1
25-05-21 19:04:17 25.58 1
25-05-21 18:59:17 33.94 1
25-05-21 18:54:17 39.03 1
25-05-21 18:49:17 48.12 1
25-05-21 18:44:17 46.22 1
25-05-21 18:39:17 41.82 1
25-05-21 18:34:17 45.60 1
25-05-21 18:29:17 59.27 1
25-05-21 18:24:17 48.42 1
25-05-21 18:19:17 48.02 1
25-05-21 18:14:17 52.64 1
25-05-21 18:09:17 57.17 1
25-05-21 18:04:17 66.58 1
25-05-21 17:59:17 58.61 1
25-05-21 17:54:17 54.61 1
25-05-21 17:49:17 60.27 1
25-05-21 17:44:18 62.77 1
25-05-21 17:39:18 61.92 1
25-05-21 17:34:18 61.45 1
25-05-21 17:29:18 62.07 1
25-05-21 17:24:18 57.92 1
25-05-21 17:19:18 70.62 1
25-05-21 17:14:18 74.72 1
25-05-21 17:09:18 63.66 1
25-05-21 17:04:18 62.11 1
25-05-21 16:59:18 59.77 1
25-05-21 16:54:18 46.66 1
25-05-21 16:49:18 61.05 1
25-05-21 16:44:18 75.51 1
25-05-21 16:39:18 55.58 1
25-05-21 16:34:18 81.29 1
25-05-21 16:29:18 83.64 1
25-05-21 16:24:18 81.89 1
25-05-21 16:19:18 79.78 1
25-05-21 16:14:19 79.15 1
25-05-21 16:09:19 115.93 1
25-05-21 16:04:19 86.37 1
25-05-21 15:59:19 64.15 1
25-05-21 15:54:19 87.72 1
25-05-21 15:49:19 63.15 1
25-05-21 15:44:19 39.39 1
25-05-21 15:39:19 36.35 1
25-05-21 15:34:19 43.48 1
25-05-21 15:29:19 25.00 1
25-05-21 15:24:19 38.36 1
25-05-21 15:19:19 25.00 1
25-05-21 15:14:19 25.00 1
25-05-21 15:09:19 25.00 0
25-05-21 15:04:19 25.00 0
25-05-21 14:59:19 25.00 0
25-05-21 14:54:20 25.00 0
25-05-21 14:49:18 25.00 0
25-05-21 14:44:20 25.00 0
... View more