2024-04-29 22:10:49 +12:00
|
|
|
#include "configuration.h"
|
|
|
|
|
|
2025-04-28 18:35:13 -05:00
|
|
|
#if !MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR && __has_include(<Adafruit_BMP085.h>)
|
2024-04-27 18:05:39 +12:00
|
|
|
|
2024-03-02 22:14:34 +01:00
|
|
|
#include "../mesh/generated/meshtastic/telemetry.pb.h"
|
2024-05-03 14:26:57 +02:00
|
|
|
#include "BMP085Sensor.h"
|
2024-03-02 22:14:34 +01:00
|
|
|
#include "TelemetrySensor.h"
|
|
|
|
|
#include <Adafruit_BMP085.h>
|
|
|
|
|
#include <typeinfo>
|
|
|
|
|
|
|
|
|
|
BMP085Sensor::BMP085Sensor() : TelemetrySensor(meshtastic_TelemetrySensorType_BMP085, "BMP085") {}
|
|
|
|
|
|
|
|
|
|
int32_t BMP085Sensor::runOnce()
|
|
|
|
|
{
|
2024-10-14 06:11:43 +02:00
|
|
|
LOG_INFO("Init sensor: %s", sensorName);
|
2024-03-02 22:14:34 +01:00
|
|
|
if (!hasSensor()) {
|
|
|
|
|
return DEFAULT_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS;
|
|
|
|
|
}
|
|
|
|
|
bmp085 = Adafruit_BMP085();
|
|
|
|
|
status = bmp085.begin(nodeTelemetrySensorsMap[sensorType].first, nodeTelemetrySensorsMap[sensorType].second);
|
|
|
|
|
|
|
|
|
|
return initI2CSensor();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void BMP085Sensor::setup() {}
|
|
|
|
|
|
|
|
|
|
bool BMP085Sensor::getMetrics(meshtastic_Telemetry *measurement)
|
|
|
|
|
{
|
2024-08-16 17:15:51 -05:00
|
|
|
measurement->variant.environment_metrics.has_temperature = true;
|
|
|
|
|
measurement->variant.environment_metrics.has_barometric_pressure = true;
|
|
|
|
|
|
2024-11-04 19:15:59 -06:00
|
|
|
LOG_DEBUG("BMP085 getMetrics");
|
2024-03-02 22:14:34 +01:00
|
|
|
measurement->variant.environment_metrics.temperature = bmp085.readTemperature();
|
|
|
|
|
measurement->variant.environment_metrics.barometric_pressure = bmp085.readPressure() / 100.0F;
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2024-04-27 18:05:39 +12:00
|
|
|
|
|
|
|
|
#endif
|