Hectopascal to psi (Python)

Hectopascal to PSI conversion

I was watching The Martian last night and realised that the displays of pressure for the space suites/ habitat in the film were all in psi (Pound force per Square Inch), which today has driven me today to see how see what the pressure force in my home is in psi rather than hectopascal.

The sensor I am using (a BMP280 from Pimoroni) currently outputs the pressure reading in hectopascals, for more information on pascals check out https://en.wikipedia.org/wiki/Pascal_(unit)

To convert a hectopascal to psi is:

 

Psi = hectopascal *0.0145038

So 1 hectopascal is 0.0145038 Psi. For more information on psi check out https://en.wikipedia.org/wiki/Pounds_per_square_inch

My Python for this conversion is (using the BMP280 sensor):

from bmp280 import BMP280
try:
from smbus2 import SMBus
except ImportError:
from smbus import SMBus

bus = SMBus(1)
bmp280 = BMP280(i2c_dev=bus)
def get_pressure():
# returns pressure in Hectopascals
pressure = bmp280.get_pressure()
pressure = round(pressure)
pressure = str(pressure)
return(pressure)

def hectopascal_to_psi():
# returns pressure in Pound force per Square Inch
pressure = get_pressure()
pressure = float(pressure)
psi = pressure * 0.0145038
psi = round(psi,2)
str_psi = str(psi)
return(str_psi)

print(get_pressure())
print(hectopascal_to_psi())

The output from my sensor reports back 14.61 psi, which matches Earth’s average psi of 14.6 (see https://en.wikipedia.org/wiki/Atmospheric_pressure)

Hectopascal to PSI conversion
Hectopascal to PSI conversion