High accuracy barometer with temperature and altitude compensation based on BMP180


Senior Member
Based on the signed multiprecision routines I've posted in snippets, this code is for a high accuracy barometer with full temperature and altitude correction based on the bmp180.

The code does all the arithmetic in 40-bit mode which results in no loss of accuracy. The code includes commented out test routines that if run demonstrate that it can exactly match the sample calculations in the bmp180 datasheet. The calculation time is about 2 seconds per data point.

To show sea level pressure it is necessary to calculate the pressure ratio between the instrument and sea level which is based solely on the altitude above sea level. This is calculated externally using the formula: ratio = 1/(1 - (altitude_in_meters/44330)^5.225). This value is then scaled by 1,000,000 and stored in a table to be used by the code to correct the measured pressure for sea level.

The code makes extensive use of the scratchpad so will only run on an X2 part.

The code just uses sertxd to report the data but there is enough code space left to drive a serial or parallel LCD or 7 segment LEDs and to log data etc.