Add bmp-280 support (#1581)

This commit is contained in:
Ben Meadors
2022-07-31 08:52:47 -05:00
committed by GitHub
parent ade32b1827
commit 97684c6c73
9 changed files with 66 additions and 8 deletions

View File

@@ -0,0 +1,30 @@
#include "../mesh/generated/telemetry.pb.h"
#include "configuration.h"
#include "TelemetrySensor.h"
#include "BMP280Sensor.h"
#include <Adafruit_BMP280.h>
#include <typeinfo>
BMP280Sensor::BMP280Sensor() :
TelemetrySensor(TelemetrySensorType_BME280, "BMP280")
{
}
int32_t BMP280Sensor::runOnce() {
DEBUG_MSG("Init sensor: %s\n", sensorName);
if (!hasSensor()) {
return DEFAULT_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS;
}
status = bmp280.begin(nodeTelemetrySensorsMap[sensorType]);
return initI2CSensor();
}
void BMP280Sensor::setup() { }
bool BMP280Sensor::getMetrics(Telemetry *measurement) {
DEBUG_MSG("BMP280Sensor::getMetrics\n");
measurement->variant.environment_metrics.temperature = bmp280.readTemperature();
measurement->variant.environment_metrics.barometric_pressure = bmp280.readPressure() / 100.0F;
return true;
}