#include <Arduino.h>
#include <Wire.h>
#include <BME280I2C.h>

BME280I2C bme;   

void printBME280Data
(
   Stream* client
)
{
   float Temperature(NAN), Humidity(NAN), Pressure(NAN);

   BME280::TempUnit UnitT(BME280::TempUnit_Celsius);
   BME280::PresUnit UnitP(BME280::PresUnit_mbar);
   bme.read(Pressure, Temperature, Humidity, UnitT, UnitP);
   client->print("Temperature[]");
   client->print(Temperature);
   client->print("]C   Humidity[");
   client->print(Humidity);
   client->print("]%   Pressure[");
   client->print(Pressure);
   client->println("]mbar");
   delay(1000);
}

void setup()
{
  Serial.begin(115200);
  while(!Serial) {} // Wait
  //
  Wire.begin();
  delay(1000);
  while(!bme.begin())
  {
    Serial.println("Could not find BME280 sensor!");
    delay(1000);
  }
  //
  switch(bme.chipModel())
  {
     case BME280::ChipModel_BME280:
       Serial.println("Found BME280 sensor! Success.");
       break;
     case BME280::ChipModel_BMP280:
       Serial.println("Found BMP280 sensor! No Humidity available.");
       break;
     default:
       Serial.println("Found UNKNOWN sensor! Error!");
  }
}

void loop()
{
   printBME280Data(&Serial);
   delay(1000);
}

