12-24-2023 09:35 AM - edited 12-24-2023 09:41 AM
here is my output: {"IAQ Accuracy": "0", "IAQ":"50.00", "Static IAQ": "50.00", "CO2 equivalent": "500.00", "Breath VOC equivalent": "0.50", "Raw Temperature": "15.61", "Temperature": "15.58", "Raw Humidity": "51.92", "Humidity": "51.88","Pressure": "102629.20", "Raw Gas": "130553", "Gas Percentage":"0.00", "Stabilization status": 1,"Run in status": 0,"Status": "0", "timestamp": "115"}
cost 10028 ms
time stamp: 125251869000 ns next call: 118221856000 ns
I am using esp32s3 with lib version 2.4.0.0. my code is similar with stm32f411.
I viewed bst bme integration guide found this: but I do not know how to fix this:
Solved! Go to Solution.
12-25-2023 03:06 AM
Hi Mark-Walen,
Where did you get warning code 100 when you run your software code?
Previous reference code run on STM32 for C language, you need to migrate it your ESP32S3 platform.
12-25-2023 07:58 AM - edited 12-25-2023 08:03 AM
Yes, I already migrate to esp32s3 use libalgobsec.a of esp32s3 and esp32s3 hal api. I use c language.
I get warning code after call `bsec_sensor_control(time_stamp, &sensor_settings);` in bsec_iot_loop();there is no delay function in my code.
12-25-2023 12:35 PM
Hi BSTRobin,
I get warning code when i call `bsec_sensor_control(time_stamp, &sensor_settings);` in bsec_iot_loop();
My program language is c. I already migrate my platform: using esp32 hal api and BSEC API for esp32s3. There is no delay function in bsec_iot_loop:
void bsec_iot_loop(sleep_fct sleep_n, get_timestamp_us_fct get_timestamp_us, output_ready_fct_t output_ready,
state_save_fct state_save, uint32_t save_intvl)
{
/* Timestamp variables */
int64_t time_stamp = 0;
uint32_t tick_before, tick_after;
/* BSEC sensor settings struct */
bsec_bme_settings_t sensor_settings;
memset(&sensor_settings, 0, sizeof(sensor_settings));
/* BSEC sensor data */
struct bme68x_data data;
uint8_t nFieldsLeft = 0;
uint32_t bsec_state_len = 0;
uint32_t n_samples = 0;
int8_t ret_val;
opMode = sensor_settings.op_mode;
bsec_library_return_t bsec_status = BSEC_OK;
sensor_settings.next_call = 0;
while (1)
{
tick_before = get_timestamp();
/* get the timestamp in nanoseconds before calling bsec_sensor_control() */
// time_stamp = get_timestamp_us() * 1000;
time_stamp = get_timestamp_us() * 1000;
if (time_stamp >= sensor_settings.next_call)
{
printf("time stamp: %" PRId64 " next call: %" PRId64 "\r\n", time_stamp, sensor_settings.next_call);
/* Retrieve sensor settings to be used in this time instant by calling bsec_sensor_control */
bsec_status = bsec_sensor_control(time_stamp, &sensor_settings);
if (bsec_status != BSEC_OK)
{
if (bsec_status < BSEC_OK)
{
printf("ERROR: bsec_sensor_control: %d\n", bsec_status);
break;
}
else
{
printf("WARNING: bsec_sensor_control: %d\n", bsec_status);
}
}
switch (sensor_settings.op_mode)
{
case BME68X_FORCED_MODE:
setBme68xConfigForced(&sensor_settings);
break;
case BME68X_PARALLEL_MODE:
if (opMode != sensor_settings.op_mode)
{
setBme68xConfigParallel(&sensor_settings);
}
break;
case BME68X_SLEEP_MODE:
if (opMode != sensor_settings.op_mode)
{
ret_val = bme68x_set_op_mode(BME68X_SLEEP_MODE, &bme68x_g);
if ((ret_val == BME68X_OK) && (opMode != BME68X_SLEEP_MODE))
{
opMode = BME68X_SLEEP_MODE;
}
}
break;
}
if (sensor_settings.trigger_measurement && sensor_settings.op_mode != BME68X_SLEEP_MODE)
{
nFields = 0;
bme68x_get_data(lastOpMode, &sensor_data[0], &nFields, &bme68x_g);
iFields = 0;
if(nFields)
{
do
{
nFieldsLeft = getData(&data);
/* check for valid gas data */
if (data.status & BME68X_GASM_VALID_MSK)
{
if (!processData(time_stamp, data, sensor_settings.process_data, output_ready))
{
return;
}
}
}while(nFieldsLeft);
}
}
/* Increment sample counter */
n_samples++;
/* Retrieve and store state if the passed save_intvl */
if (n_samples >= save_intvl)
{
bsec_status = bsec_get_state(0, bsec_state, sizeof(bsec_state), work_buffer, sizeof(work_buffer), &bsec_state_len);
if (bsec_status == BSEC_OK)
{
state_save(bsec_state, bsec_state_len);
}
n_samples = 0;
}
}
tick_after = get_timestamp();
printf("cost %u ms\r\n", (tick_after - tick_before)/1000);
}
}
12-26-2023 09:10 AM
Hi Mark-Walen,
Return value 100(BSEC_W_SC_CALL_TIMING_VIOLATION) means "Difference between actual and defined sampling intervals of bsec_sensor_control() greater than allowed", you need to strictly refer to previous example code.