This is my fucntion process data
/* Check if something should be processed by BSEC */
if (num_bsec_inputs > 0) {
/* Set number of outputs to the size of the allocated buffer */
/* BSEC_NUMBER_OUTPUTS to be defined */
num_bsec_outputs = BSEC_NUMBER_OUTPUTS;
/* Perform processing of the data by BSEC
Note:
* The number of outputs you get depends on what you asked for during bsec_update_subscription(). This is
handled under bme680_bsec_update_subscription() function in this example file.
* The number of actual outputs that are returned is written to num_bsec_outputs. */
bsec_status = bsec_do_steps(bsec_inputs, num_bsec_inputs, bsec_outputs, &num_bsec_outputs);
if (bsec_status != BME680_OK) return bsec_status;
KD_DEBUG(KD_BME680_BSEC, "num_bsec_outputs %d", num_bsec_outputs);
/* Iterate through the outputs and extract the relevant ones. */
for (index = 0; index < num_bsec_outputs; index++) {
switch (bsec_outputs[index].sensor_id) {
case BSEC_OUTPUT_IAQ:
KD_DEBUG(KD_BME680_BSEC, "BSEC_OUTPUT_IAQ");
iaq = bsec_outputs[index].signal;
iaq_accuracy = bsec_outputs[index].accuracy;
break;
case BSEC_OUTPUT_STATIC_IAQ:
KD_DEBUG(KD_BME680_BSEC, "BSEC_OUTPUT_STATIC_IAQ");
static_iaq = bsec_outputs[index].signal;
static_iaq_accuracy = bsec_outputs[index].accuracy;
break;
case BSEC_OUTPUT_CO2_EQUIVALENT:
KD_DEBUG(KD_BME680_BSEC, "BSEC_OUTPUT_CO2_EQUIVALENT");
co2_equivalent = bsec_outputs[index].signal;
co2_accuracy = bsec_outputs[index].accuracy;
break;
case BSEC_OUTPUT_BREATH_VOC_EQUIVALENT:
KD_DEBUG(KD_BME680_BSEC, "BSEC_OUTPUT_BREATH_VOC_EQUIVALENT");
breath_voc_equivalent = bsec_outputs[index].signal;
breath_voc_accuracy = bsec_outputs[index].accuracy;
break;
case BSEC_OUTPUT_SENSOR_HEAT_COMPENSATED_TEMPERATURE:
KD_DEBUG(KD_BME680_BSEC, "BSEC_OUTPUT_SENSOR_HEAT_COMPENSATED_TEMPERATURE");
temp = bsec_outputs[index].signal;
break;
case BSEC_OUTPUT_RAW_PRESSURE:
KD_DEBUG(KD_BME680_BSEC, "BSEC_OUTPUT_RAW_PRESSURE");
raw_pressure = bsec_outputs[index].signal;
break;
case BSEC_OUTPUT_SENSOR_HEAT_COMPENSATED_HUMIDITY:
KD_DEBUG(KD_BME680_BSEC, "BSEC_OUTPUT_SENSOR_HEAT_COMPENSATED_HUMIDITY");
humidity = bsec_outputs[index].signal;
break;
case BSEC_OUTPUT_RAW_GAS:
KD_DEBUG(KD_BME680_BSEC, "BSEC_OUTPUT_RAW_GAS");
raw_gas = bsec_outputs[index].signal;
break;
case BSEC_OUTPUT_RAW_TEMPERATURE:
KD_DEBUG(KD_BME680_BSEC, "BSEC_OUTPUT_RAW_TEMPERATURE");
raw_temp = bsec_outputs[index].signal;
break;
case BSEC_OUTPUT_RAW_HUMIDITY:
KD_DEBUG(KD_BME680_BSEC, "BSEC_OUTPUT_RAW_HUMIDITY");
raw_humidity = bsec_outputs[index].signal;
break;
case BSEC_OUTPUT_COMPENSATED_GAS:
KD_DEBUG(KD_BME680_BSEC, "BSEC_OUTPUT_COMPENSATED_GAS");
comp_gas_value = bsec_outputs[index].signal;
comp_gas_accuracy = bsec_outputs[index].accuracy;
break;
case BSEC_OUTPUT_GAS_PERCENTAGE:
KD_DEBUG(KD_BME680_BSEC, "BSEC_OUTPUT_GAS_PERCENTAGE");
gas_percentage = bsec_outputs[index].signal;
gas_percentage_acccuracy = bsec_outputs[index].accuracy;
break;
default:
continue;
}
/* Assume that all the returned timestamps are the same */
timestamp = bsec_outputs[index].time_stamp;
}
Hi @BSTRobin ,
This sentence is very interesting sentence : We found such as "case BSEC_OUTPUT_IAQ" .etc didn't run to assign iaq lead to IAQ output is 0 in the log.
Could you write to me something more regarding this issue? What was its cause and how it was solved?
Hi @BSTRobin
Could you answer my questions above?
Moreovere what are required compilation flags for bsec library?
I am strunggling with constant timestamp from bsec output (01015539:D:KD_BME680_BSEC :Timestamp: 16000000) and no IAQ.
Could you support? We want to release large product series with BME680, however it is a blocker for us now.
Hi @BSTRobin
I think I found root cause of showing IAQ 0, despite fact received timestamp is constant. I applied config `generic_33v_3s_4d` and I needed to commented out two `if` statements in file `bsec_integration.c` in function `bme680_bsec_read_data` (I don't think it's proper solution, does it?):
/*
* Following if statements have to be fixed, this is a root cause
*/
/* Gas to be processed by BSEC */
// if (bsec_process_data & BSEC_PROCESS_GAS) {
/* Check whether gas_valid flag is set */
// if (data.status & BME680_GASM_VALID_MSK) {
/* Place sample into input struct */
inputs[*num_bsec_inputs].sensor_id = BSEC_INPUT_GASRESISTOR;
inputs[*num_bsec_inputs].signal = (float)data.gas_resistance;
inputs[*num_bsec_inputs].time_stamp = time_stamp_trigger;
(*num_bsec_inputs)++;
//}
// }
IAQ was 0, because algorithm never receives gas resistance. Both flags are not set. When I commented behaviour is the same as in Arduino example (despite constant output timestamp in comparison to Arduino example).
Going up `bsec_process_data` comes from `bme680_bsec_trigger_measurement` and `bsec_sensor_control`.
I don't see where flag `BSEC_PROCESS_GAS` is set, could you point me where is it or how to use it? When is it set?
Flag `BME680_GASM_VALID_MSK`comes directly from sensor. Why it is not set? How to set it properly?
What I have to do to run whole framework successfuly?
Hi MJ_kio,
Please check our previous replies, because output order in function 'bme68x_bsec_process_data' is different from in log.
About the new feedback, i find the two flags ing bsec_iot_example.ino:
in ''bsec_datatypes.h"----- '#define BSEC_PROCESS_GAS (1 << (BSEC_INPUT_GASRESISTOR-1))' 'BSEC_INPUT_GASRESISTOR = 4, '
in "bme68x_defs.h"--------'#define BME68X_GASM_VALID_MSK UINT8_C(0x20)'
If you think the IAQ output is 0 due to these two 'if' statements are not executed, you can print some message in it by adding logs.
Or can you change a new 680 senser to test?