Skip to content

setOversampling()

Arnd edited this page Dec 12, 2020 · 5 revisions

[oversampling = ] setOversampling(sensor,[oversampling]);


This sets the oversampling rate for one of the 3 different sensors on the BME680. The "sensor" parameter can be specified using an integer value as below or using the enumerated type:

  • Use 0 or the enumerated variable TemperatureSensor
  • Use 1 or the enumerated variable HumiditySensor
  • Use 2 or the enumerated variable PressureSensor

Each sensor can be set to one of the following enumerated type values or the corresponding numeric values:

  • Use 0 or the enumerated variable SensorOff to disable the sensor
  • Use 1 or the enumerated variable Oversample1 to not use oversampling
  • Use 2 or the enumerated variable Oversample2 to use 2x oversampling
  • Use 3 or the enumerated variable Oversample4 to use 4x oversampling
  • Use 4 or the enumerated variable Oversample8 to use 8x oversampling
  • Use 5 or the enumerated variable Oversample16 to use the maximum 16x oversampling

Any value other value is ignored.

The value for the BME680 oversampling for the specified sensor is returned; this will be the second parameter value. If the second parameter for the sampling rate is not specified, then no changes are made and the current setting is returned.


Example:

BME680_Class BME680;  // Instantiate class    
...    
while (!BME680.begin()) {                          // Find on I2C bus
  Serial.println("Error, unable to find BME680."); // Show error message
  delay(5000);                                     // Wait 5 seconds 
} // of if-then we can't initialize or find the device
BME680.setOversample(TemperatureSensor,Oversample16); // 16x sampling to temperature
BME680.setOversample(HumiditySensor,SensorOff); // Don't measure humdity
BME680.setOversample(PressurSensor,Oversample8); // 8x oversampling for pressure
uint8 deviceMode = BME680.mode(NormalMode); // Set normal mode