Skip to content

getSensorData()

Arnd edited this page Aug 4, 2017 · 3 revisions

getSensorData(temperature,humidity,pressure);


This returns the most recent readings from the BME280. The function will wait for an measurement in progress to complete before returning with the new results. In order to avoid floating point, which is both slow and memory-intensive on the Arduino, the results are returned as follows:

  • Temperature - in degrees Celsius times 100, e.g. a value of "2526" means 25.26° Celsius
  • Humidity - percentage time 100, e.g. a value of "3407" means 34.07% humidity
  • Pressure - in pascals, thus "99979" denotes 999.79hPa

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 humidity
BME280.setOversample(PressurSensor,Oversample8); // 8x oversampling for pressure
uint8 deviceMode = BME280.mode(NormalMode); // Set normal mode
int32_t temperature,humidity,pressure;
BME280.getSensorData(temperature,humidity,pressure);
Clone this wiki locally