2025-06-24 15:18:08 -07:00

34 lines
850 B
C++

/// © MiroZ 2024
#include "Bmp280.h"
#include <esp_log.h>
static const char *TAG = "bme280";
Bmp280::Bmp280(TwoWire & bus) : m_bus(bus)
{
m_sensor = new BMP280_DEV(bus);
}
bool Bmp280::init()
{
uint8_t status = 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
m_operational = status == 1;
return m_operational;
}
bool Bmp280::read(float & temp, float & pressure)
{
if(m_sensor->getTempPres(temp, pressure))
return true;
return false;
}