Skip to content
This repository was archived by the owner on Sep 30, 2019. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions Adafruit_BMP085/Adafruit_BMP085.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/python

import time
from decimal import Decimal
from Adafruit_I2C import Adafruit_I2C

# ===========================================================================
Expand Down Expand Up @@ -257,3 +258,11 @@ def readAltitude(self, seaLevelPressure=101325):
return altitude

return 0

# With the measured pressure and the absolute altitude the pressure at sea level can be calculated
# see BMP085 datasheet: 3.7 Calculating pressure at sea level
def getRealPressure(self, altitude):
pressure = self.readPressure()
denominator = pow(Decimal(1) - (Decimal(altitude) / Decimal(44330)), Decimal(5.255))

return pressure / denominator
5 changes: 5 additions & 0 deletions Adafruit_BMP085/Adafruit_BMP085_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@
# Read the current barometric pressure level
pressure = bmp.readPressure()

# get the real barometric pressure on sea level
# pass the absolute altitude of the sensors position as parameter
realPressure = bmp.getRealPressure(720)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Forgot to make the altitude parameter variable.
Best would be to use a global variable where the user could set the altitude.


# To calculate altitude based on an estimated mean sea level pressure
# (1013.25 hPa) call the function as follows, but this won't be very accurate
altitude = bmp.readAltitude()
Expand All @@ -32,4 +36,5 @@

print "Temperature: %.2f C" % temp
print "Pressure: %.2f hPa" % (pressure / 100.0)
print "Real pressure: %.2f hPa" % (realPressure / 100)
print "Altitude: %.2f" % altitude