23 lines
517 B
C++
23 lines
517 B
C++
#include <Adafruit_BMP085.h>
|
|
#include <math.h>
|
|
#include "sensors.h"
|
|
|
|
static Adafruit_BMP085 bmp;
|
|
|
|
bool sensorsBegin() {
|
|
return bmp.begin(); // uses Wire (already started on D6/D1), addr 0x77
|
|
}
|
|
|
|
float readAbsPressureHpa() {
|
|
return bmp.readPressure() / 100.0f; // Pa -> hPa
|
|
}
|
|
|
|
float readTemperatureC() {
|
|
return bmp.readTemperature();
|
|
}
|
|
|
|
// Standard barometric reduction to sea level.
|
|
float toSeaLevelHpa(float absHpa, float altitudeM) {
|
|
return absHpa / powf(1.0f - (altitudeM / 44330.0f), 5.255f);
|
|
}
|