BME680 driver interface changes
- function bme680_force_measurement returns now a boolean - function bme680_is_measuring returns now boolean - function bme680_get_measurement_duration added - heating profiles implemented - example for heating profiles added
This commit is contained in:
parent
1bd9364ebb
commit
5b90f0ef58
9 changed files with 831 additions and 422 deletions
|
|
@ -56,28 +56,30 @@ static bme680_sensor_t* sensor;
|
|||
void user_task(void *pvParameters)
|
||||
{
|
||||
bme680_values_float_t values;
|
||||
int32_t duration;
|
||||
|
||||
TickType_t last_wakeup = xTaskGetTickCount();
|
||||
|
||||
// as long as sensor configuration isn't changed, duration is constant
|
||||
uint32_t duration = bme680_get_measurement_duration(sensor);
|
||||
|
||||
while (1)
|
||||
{
|
||||
{
|
||||
// trigger the sensor to start one TPHG measurement cycle
|
||||
duration = bme680_force_measurement (sensor);
|
||||
if (bme680_force_measurement (sensor))
|
||||
{
|
||||
// passive waiting until measurement results are available
|
||||
vTaskDelay (duration);
|
||||
|
||||
// passive waiting until measurement results are available
|
||||
if (duration > 0) vTaskDelay (duration);
|
||||
|
||||
// busy waiting until measurement results are available
|
||||
// while (bme680_is_measuring (sensor) > 0) ;
|
||||
|
||||
// get the results and do something with them
|
||||
if (bme680_get_results_float (sensor, &values))
|
||||
printf("%.3f BME680 Sensor: %.2f °C, %.2f %%, %.2f hPa, %.2f Ohm\n",
|
||||
(double)sdk_system_get_time()*1e-3,
|
||||
values.temperature, values.humidity,
|
||||
values.pressure, values.gas_resistance);
|
||||
// alternatively: busy waiting until measurement results are available
|
||||
// while (bme680_is_measuring (sensor)) ;
|
||||
|
||||
// get the results and do something with them
|
||||
if (bme680_get_results_float (sensor, &values))
|
||||
printf("%.3f BME680 Sensor: %.2f °C, %.2f %%, %.2f hPa, %.2f Ohm\n",
|
||||
(double)sdk_system_get_time()*1e-3,
|
||||
values.temperature, values.humidity,
|
||||
values.pressure, values.gas_resistance);
|
||||
}
|
||||
// passive waiting until 1 second is over
|
||||
vTaskDelayUntil(&last_wakeup, 1000 / portTICK_PERIOD_MS);
|
||||
}
|
||||
|
|
@ -93,7 +95,6 @@ void user_init(void)
|
|||
|
||||
/** -- MANDATORY PART -- */
|
||||
|
||||
|
||||
#ifdef SPI_USED
|
||||
// Init the sensor connected either to SPI.
|
||||
sensor = bme680_init_sensor (SPI_BUS, 0, SPI_CS_GPIO);
|
||||
|
|
@ -112,18 +113,19 @@ void user_init(void)
|
|||
|
||||
/** -- OPTIONAL PART -- */
|
||||
|
||||
// Changes the oversampling rates (default os_1x) to 4x oversampling
|
||||
// for temperature and 2x oversampling for humidity. Pressure
|
||||
// measurement is skipped in this example.
|
||||
// Changes the oversampling rates to 4x oversampling for temperature
|
||||
// and 2x oversampling for humidity. Pressure measurement is skipped.
|
||||
bme680_set_oversampling_rates(sensor, osr_4x, osr_none, osr_2x);
|
||||
|
||||
// Change the IIR filter size (default iir_size_3) for temperature and
|
||||
// and pressure to 7.
|
||||
// Change the IIR filter size for temperature and pressure to 7.
|
||||
bme680_set_filter_size(sensor, iir_size_7);
|
||||
|
||||
// Change the heaeter profile (default 320 degree Celcius for 150 ms)
|
||||
// to 200 degree Celcius for 100 ms.
|
||||
bme680_set_heater_profile (sensor, 320, 150);
|
||||
// Change the heater profile 0 to 200 degree Celcius for 100 ms.
|
||||
bme680_set_heater_profile (sensor, 0, 200, 100);
|
||||
bme680_use_heater_profile (sensor, 0);
|
||||
|
||||
// Set ambient temperature to 10 degree Celsius
|
||||
bme680_set_ambient_temperature (sensor, 10);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue