Hi, You can certainly avoid using bsec_iot_loop() in your code. I think that is just an example provided by Bosch. In my code I implemented a function to perform the equivalent functionality but without the loop. The key is to pass the current timestamp to bsec_sensor_control(), which in turn tells you if measurements should be run, and also when to run the next measurement. Then in your code use a timer or another method to delay the next call until the appropriate time. So basically (simplified): int64_t time_stamp = get_timestamp_us() * 1000ULL;
bsec_sensor_control(time_stamp, &sensor_settings);
bme680_bsec_trigger_measurement(&sensor_settings, sleep);
bme680_bsec_read_data(time_stamp, bsec_inputs, &num_bsec_inputs, sensor_settings.process_data);
bme680_bsec_process_data(bsec_inputs, num_bsec_inputs, output_ready);
int64_t time_stamp_interval_ms = (sensor_settings.next_call - get_timestamp_us() * 1000ULL) / 1000000ULL;
return (time_stamp_interval_ms > 0) ? time_stamp_interval_ms : 0; I hope this helps.
... View more