Software for DIY altimeter.
Supplied sketch will continuously output three different altitude readings in a pleonastic verbose format through the comport. The first kind of reading is the altitude calculated using the standard day conditions of 15° and 101325 Pa at sea level. Second altitude is calculated using sea level pressure from an external source, as weather service, Metar or AWOS, likely in DIY application you can get this information from a ground station at the airfield; this altitude can be referred as compensated for local sea level pressure deviations; in the source code the sea level pressure is stored in “base_pascal” variable. The last altitude type relies on the fact that the airfield elevation and air temperature are known, an initial calibration routine calculates the value of sea level pressure for best altitude fit; in the source code the current airfield altitude is stored in “FIELD_ALTITUDE” constant.
After the wiring is done just upload the code and monitor the serial port at 9600 baud 8N1.
You should get an output similar to those here reported:
<< Initialization sea level Temperature C 16.2 Initialization sea level pressure Pa 99802 Sea level pressure from weather service Pa 99700 ... Raw pressure Pa 99182 Filtered pressure Pa 99180 Temperature C 15 Barometric altitude according, ISA m 185.5505676269 Barometric altitude corrected for pressure at sea level, m 44.2671127319 Barometric altitude corrected, current altitude and temperature known m 53.4413719177 ... Raw pressure Pa 99185 Filtered pressure Pa 99181 Temperature C 15 Barometric altitude according, ISA m 185.4594726562 Barometric altitude corrected for pressure at sea level, m 44.1800498962 Barometric altitude corrected, current altitude and temperature known m 53.354980468 ... >>
The Sketch is ready to be incorporated in your projects, it is advisable that you carry out some test on the accuracy of your unit.
A simple way to have and approximate indication about altimeter accuracy is to go to a known altitude location, like an airport, and compare the altitude readings with the known value. A most accurate way is to use a geodetic network referral point as true altitude value.