It seems this was planned for the Adafruit BMP280 library but not implemented. Looking at Adafruit_BMP280.h
we see commented code that has a method seaLevelForAltitude()
:
/*
class Adafruit_BMP280_Unified : public Adafruit_Sensor
{
public:
Adafruit_BMP280_Unified(int32_t sensorID = -1);
bool begin(uint8_t addr = BMP280_ADDRESS, uint8_t chipid = BMP280_CHIPID);
void getTemperature(float *temp);
void getPressure(float *pressure);
float pressureToAltitude(float seaLevel, float atmospheric, float temp);
float seaLevelForAltitude(float altitude, float atmospheric, float temp);
void getEvent(sensors_event_t*);
void getSensor(sensor_t*);
private:
uint8_t _i2c_addr;
int32_t _sensorID;
};
*/
In another library, BMP280-arduino-library, I found a function that seems to work:
double BMP280::sealevel(double P, double A)
// Given a pressure P (mb) taken at a specific altitude (meters),
// return the equivalent pressure (mb) at sea level.
// This produces pressure readings that can be used for weather measurements.
{
return(P/pow(1-(A/44330.0),5.255));
}
First, I just copied that function into my code (without the class name), due to the friendly pizza license. Later I switched to that library and it also worked fine.