Skip to content

Commit

Permalink
Fix #7 by adding readSealevelPressure function.
Browse files Browse the repository at this point in the history
  • Loading branch information
tdicola committed Jun 12, 2014
1 parent 4466c26 commit af52d4b
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Adafruit_BMP085.cpp
Expand Up @@ -195,6 +195,10 @@ int32_t Adafruit_BMP085::readPressure(void) {
return p;
}

int32_t Adafruit_BMP085::readSealevelPressure(float altitude_meters) {
float pressure = readPressure();
return (int32_t)(pressure / pow(1.0-altitude_meters/44330, 5.255));
}

float Adafruit_BMP085::readTemperature(void) {
int32_t UT, B5; // following ds convention
Expand Down
1 change: 1 addition & 0 deletions Adafruit_BMP085.h
Expand Up @@ -58,6 +58,7 @@ class Adafruit_BMP085 {
boolean begin(uint8_t mode = BMP085_ULTRAHIGHRES); // by default go highres
float readTemperature(void);
int32_t readPressure(void);
int32_t readSealevelPressure(float altitude_meters = 0);
float readAltitude(float sealevelPressure = 101325); // std atmosphere
uint16_t readRawTemperature(void);
uint32_t readRawPressure(void);
Expand Down
4 changes: 4 additions & 0 deletions examples/BMP085test/BMP085test.ino
Expand Up @@ -49,6 +49,10 @@ void loop() {
Serial.print(bmp.readAltitude());
Serial.println(" meters");

Serial.print("Pressure at sealevel (calculated) = ");
Serial.print(bmp.readSealevelPressure());
Serial.println(" Pa");

// you can get a more precise measurement of altitude
// if you know the current sea level pressure which will
// vary with weather and such. If it is 1015 millibars
Expand Down

0 comments on commit af52d4b

Please sign in to comment.