#include <Arduino.h>
#include <Wire.h>
#include "BME280.h"

void setup() {
    Serial.begin(9600);
    Wire.begin();

    Serial.println("Initializing BME280...");

    uint8_t id = BME280_GetID();
    Serial.print("Sensor ID: 0x");
    Serial.println(id, HEX);

    BME280_Reset();

    // Set oversampling for humidity = x1 (00000001)
    BME280_CtrlHum(0x01);

    // Set oversampling for temp and pressure = x1, mode = normal (00100111)
    BME280_CtrlMeas(0x27);

    Serial.println("BME280 Setup Done.");
}

void loop() {
    long temp_raw = BME280_ReadTemperature();
    int hum_raw = BME280_ReadHumidity();
    long press_raw = BME280_ReadPressure();

    Serial.print("Raw Temperature: ");
    Serial.print(temp_raw);
    Serial.print(" | Raw Humidity: ");
    Serial.print(hum_raw);
    Serial.print(" | Raw Pressure: ");
    Serial.println(press_raw);
}
