12-09-2021 07:10 AM - edited 12-09-2021 12:28 PM
Hello,
I'm working with a STM32G070 MCU and the library 2.061 The heater_profil always stays the same, altough I have already change it and restart the whole system. The sensor get the old information from the function bsec_sensor_control.
I took the heater profile from the github parallel example, but in my case the measured temperature is to high. There is a 5 Celcius degree difference between the raw data from parallel mode to the raw data from the forced mode. The forced mode is much nearer to my comparison sensor. Even the compensated temperature has a difference about 2-3 degree to the forced mode.
Do you have any ideas?
Best regards
Solved! Go to Solution.
12-10-2021 03:25 AM
Hello doppio-R,
1. Do you use BME688 hardware designed by you?
2. Could we see you software you used?
02-08-2022 05:45 PM
Hello Robin,
sorry that I need this time to answer. I use the hardware from Adafruit.
In my initialization I configure the settings and the function bsec_sensor_control change this configuration. The most aspects of the code is from your exampels. I have tried each of the bsec_config_selectivity function but there is no big difference. How much time need the CO2 Value to get alternative to 500 or 400. This value is really important for me. The relevant code as follows.
bool BME688_Init(I2C_HandleTypeDef *hi2c, uint8_t Slave_Address)
{
BME688_MCU.phi2c = hi2c; //Data for the BME Driver & Communication
_bme68x.intf_ptr = (void*)(intptr_t) Slave_Address;
_bme68x.intf = BME68X_I2C_INTF;
_bme68x.amb_temp = 25;
_bme68x.delay_us = delay_us;
_bme68x.read = bme68x_i2c_read;
_bme68x.write = bme68x_i2c_write;
_timer_overflow_counter = 0;
_timer_last_value = 0;
_step = CONTROL_STEP;
_bme68x_status = BME68X_OK;
_bsec_status = BSEC_OK;
_temp_offset = 5.0;
_bme68x_status = bsec_init(); // Bsec Library initialization
memset(&_bsec_bme_settings, 0, sizeof(_bsec_bme_settings));
memset(&_output, 0, sizeof(_output));
_step = CONTROL_STEP;
last_meas_index = 0;
_bme68x_status |= setConfig(bsec_config_selectivity); // BME688 vordefinierte Config wird geladen
//_bme68x_status |= loadState();
_bme68x_status |= updateSubscription(BSEC_SAMPLE_RATE_HIGH_PERFORMANCE); // BME688 samplerate definition
_bme68x_status |= bme68x_init(&_bme68x); // BME688 initialization
if (_bsec_status < BSEC_OK)
return false;
//BME688 setting definition
_bsec_bme_settings.op_mode = BME68X_PARALLEL_MODE;
_bsec_bme_settings.humidity_oversampling = BME68X_OS_2X;
_bsec_bme_settings.pressure_oversampling = BME68X_OS_16X;
_bsec_bme_settings.temperature_oversampling = BME68X_OS_2X;
_bsec_bme_settings.run_gas = BME68X_ENABLE;
uint16_t temp_prof[10] = { 250, 100, 100, 100, 100, 100, 100, 250, 250, 250 }; // Heater temperature in degree Celsius
uint16_t mul_prof[10] = { 2, 0, 10, 15, 2, 2, 2, 2, 2, 2 }; // Multiplier to the shared heater duration
for(uint8_t i=0; i<(ARRAY_LEN(temp_prof));i++)
_bsec_bme_settings.heater_temperature_profile[i]= temp_prof[i];
for(uint8_t j=0; j<(ARRAY_LEN(mul_prof));j++)
_bsec_bme_settings.heater_duration_profile[j] = mul_prof[j];
_bsec_bme_settings.heater_profile_len = 10;
setBme68xConfigParallel();
return true;
}
bool run(void)
{
n_fields = 0;
tick = HAL_GetTick();
currTimeNs = 1000000 * (int64_t)tick;
_op_mode = _bsec_bme_settings.op_mode;
//del_period = bme68x_get_meas_dur(BME68X_PARALLEL_MODE, &conf, &_bme68x) + (heatr_conf.shared_heatr_dur * 1000);
//_bme68x.delay_us(del_period, _bme68x.intf_ptr);
//del = HAL_GetTick() - tick;
if (currTimeNs >= _bsec_bme_settings.next_call)
{
_bsec_status = bsec_sensor_control(currTimeNs, &_bsec_bme_settings);
if (_bsec_status < BSEC_OK)
return false;
switch(_bsec_bme_settings.op_mode) {
case BME68X_FORCED_MODE:
setBme68xConfigForced();
break;
case BME68X_PARALLEL_MODE:
if (_op_mode != _bsec_bme_settings.op_mode)
{
setBme68xConfigParallel();
}
break;
case BME68X_SLEEP_MODE:
if (_op_mode != _bsec_bme_settings.op_mode)
{
setBme68xConfigSleep();
}
break;
}
if (_bme68x_status < BME68X_OK)
return false;
{
//_bme68x_status = bme68x_get_data(BME68X_PARALLEL_MODE, _bme68x_data, &n_fields, &_bme68x);
_bme68x_status = bme68x_get_data(_op_mode, _bme68x_data, &n_fields, &_bme68x);
for(uint8_t i = 0; i < n_fields; i++)
{
if (_bme68x_data[i].status & BME68X_GASM_VALID_MSK)
{
/* Measurement index check to track the first valid sample after operation mode change */
if(check_meas_idx == true )
{
/* After changing the operation mode, Measurement index expected to be zero
* however with considering the data miss case as well, condition shall be checked less
* than last received measurement index */
if(last_meas_index == 0 || _bme68x_data[i].meas_index == 0 || _bme68x_data[i].meas_index < last_meas_index)
{
check_meas_idx = false;
}
else
{
continue; // Skip the invalid data samples or data from last duty cycle scan
}
}
last_meas_index = _bme68x_data[i].meas_index;
if(!processData(currTimeNs, &_bme68x_data[i]))
{
return false;
}
}
}
}
}
return true;
}
02-09-2022 07:46 AM
Hello doppio-R,
The heater temperature and duration cann't be easily changed, which is the best configuration of the sensor.
Please refer to the example code on GitHub.
https://github.com/BoschSensortec/BME68x-Sensor-API/blob/master/examples/parallel_mode/parallel_mode...
02-09-2022 08:25 AM
Thanks for your help! I have an other question.
I thought, that if the heater temperature is a bit lower the break of round about 300s after a few measurements could be reduce. The library by itself produce this large break and to get the CO2, IAQ values I need this BSEC library, right? Is it possible to get an continuous mode instead of the 300s break after a few measurements. In my opion it takes to much time to get the first values with an appropriable accurancy.