#include <Wire.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BME280.h>

#define I2C_SDA 33
#define I2C_SCL 32

#define SEALEVELPRESSURE_HPA (1013.25)

const float No_Val = -999.99;


struct {
  char temperature[15] = {0};
  char pressure[15] = {0};
  char approx_altitud[15] = {0};
  char humity[15] = {0};
  float Temp = No_Val;
  float Feuchte = No_Val;
  float L_Druck = No_Val;
  bool Status = true;
} BME280Data;


//TwoWire I2CBME = TwoWire(1);
Adafruit_BME280 bme;

unsigned long delayTime;

void Init_BME280() {
  Serial.begin(115200);
  Serial.println(F("BME280 test"));
  //I2CBME.begin(I2C_SDA, I2C_SCL, 100000);

  bool status;

  // default settings
  // (you can also pass in a Wire library object like &Wire2)
  status = bme.begin(0x76);  
  if (!status) {
    Serial.println("Could not find a valid BME280 sensor, check wiring!");
    BME280Data.Status = false;
  } else {Serial.println("BME280 Ok");
  }
}
void Read_BME280(){
  BME280Data.Temp = bme.readTemperature();
  BME280Data.Temp = BME280Data.Temp + BME_Korrectur;
  BME280Data.L_Druck = bme.readPressure();
  BME280Data.L_Druck = BME280Data.L_Druck + KorrekturLuftdruck;
  BME280Data.Feuchte = bme.readHumidity();
  BME280Data.Feuchte = BME280Data.Feuchte + BME_KorrekturFeuchte;
  Serial.printf("BME 280: Temperarur Innen %3.2f °C und\n         Luftfeuchtigkeit %3.2f %%\n\n", BME280Data.Temp, BME280Data.Feuchte );


}