Skip to content

waitForReadings()

Arnd edited this page Dec 12, 2020 · 3 revisions

waitForReadings();


This call doesn't return until the currently active conversion process is complete. The getSensorData() function will also wait until the active conversion is complete; this call allows the waiting to be done in the user program rather than in the library.


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 humidity
BME680.setOversample(PressurSensor,Oversample8); // 8x oversampling for pressure
uint8 deviceMode = BME680.mode(NormalMode); // Set normal mode
int32_t temperature,humidity,pressure,gas;
BME680.getSensorData(temperature,humidity,pressure,gas);
BME680.waitForReadings(); // Wait for any conversions to complete before continuing