wellhub_reloaded/main/Bmp280.cpp

27 lines
840 B
C++

/// © MiroZ 2024
#include "Bmp280.h"
#include <esp_log.h>
static const char *TAG = "bme280";
Bmp280::Bmp280(TwoWire & wire) : m_wire(wire)
{
m_sensor = new BMP280_DEV(wire);
m_sensor->begin(0x76);
m_sensor->setPresOversampling(OVERSAMPLING_X4); // Set the pressure oversampling to X4
m_sensor->setTempOversampling(OVERSAMPLING_X1); // Set the temperature oversampling to X1
m_sensor->setIIRFilter(IIR_FILTER_4); // Set the IIR filter to setting 4
m_sensor->setTimeStandby(TIME_STANDBY_62MS);
m_sensor->startNormalConversion(); // Start BMP280 continuous conversion in NORMAL_MODE
}
bool Bmp280::test()
{
float temp, pressure, alt;
m_sensor->getCurrentMeasurements(temp, pressure, alt);
ESP_LOGI(TAG, "temp: %0.3f, pressure: %0.3f, alt: %0.3f", temp*1.8+32, pressure, alt);
return true;
}