HP03SA pressure sensor and altimeter

Atmospheric pressure sensor and altimeter

Hello World

Import programmbed_HP03SA_LM77

Test program for HP03SA pressure and altitude sensor and for LM77 temperature sensor. Both devices use and I2C interface.


Import libraryHP03SA

Lib for HP03SA atmospheric pressure sensor. Provides pressure, temperature and altitude data.





The HP03S pressure sensor from Hope Microelectronics contains a piezoresistive transducer and integrated 16-bit A/D converter (ADC), along with control logic and an I2C interface. The transducer outputs one voltage that depends on pressure and one that depends on temperature. These analogue values are alternately converted by the ADC and the results made available on the I2C interface. During the manufacturing process eleven sensor-specific calibration values with a length of two bytes are stored in the device’s EEPROM, and these can also be retrieved by the microcontroller. The correction-parameters are read out from the device and used in the calculation. A 32 kHz clock with an amplitude of 3 V is required to drive the ADC. This could be derived from the mbed PwmOut (see Hello World example code). The HP03SA has an absolute pressure range between 300-1100 hPa. Operating temp is -20 to +60 degrees Celsius. Note: 1 atm = 1013.25 hPa = 1013.25 mbar

Here is a blockdiagram of the device:


The Altitude calculation is based on the ICAO Standard Atmosphere model (ISA). The code has certainly not been thoroughly validated! Use at own risk.


The diagram from www.engineeringtoolbox.com shows the relationship between pressure and altitude according to the ISA model.

The HP03SA lib provides Altitude in meters or feet above Medium Sea Level (MSL).

QNH is the barometric altimeter setting that causes an altimeter to read airfield elevation above mean sea level when on the airfield. In ISA temperature conditions the altimeter will read altitude above mean sea level in the vicinity of the airfield. Note: Remember QNH as mnemonic for "nautical height" Average sea-level pressure is 101.325 kPa (1013.25 hPa or mbar) or 29.92 inches (inHg) or 760 millimetres of mercury (mmHg). In aviation weather reports (METAR), QNH is transmitted around the world in hectopascals or millibars (1 hectopascal = 1 millibar), except in the United States, Canada, and Colombia where it is reported in inches (to two decimal places) of mercury.

You need to log in to post a discussion