Skip to content

setOversampling()

Arnd edited this page Dec 11, 2020 · 3 revisions

[success = ] setOversampling(sensor,oversampling);


This sets the oversampling rate for one of the 3 different sensors on the BME280. 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 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.


Example:

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