Ah, the atmosphere. It's the lovely air that's all around us. We are all generally familiar with several properties of this atmosphere, like temperature, humidity, etc. You can just walk outside and feel those right away.
There is also pressure. You don't quite sense that the same way, but it's there. If you've ever had your ears pop while going up in an elevator, that's due to the change in pressure.
In the above image, note how thin the atmosphere appears in relation to the scale of the Earth. It's often compared to the outer skin of an onion. But that's where we all hang out :)
As we will see, pressure and temperature change with altitude. In reality, they also change with time (ex: midnight vs. high noon) and location (ex: equator vs. poles). To provide atmospheric values an engineer can use in design calculations, the idea of a "standard atmosphere" is used. Just think of this as the atmospheric values averaged over all locations and times. The results are then made available via publications, like this:
That example is the 1962 version of the U.S. Standard Atmosphere. It was updated several times, with the most recent being the 1976 version:
There is also an International Standard Atmosphere.
These publications are nothing more than page after page of tables that provide atmospheric values for any given altitude. The tables comes from various equations which the publications also discuss. In 1976, computers were expensive, so these books of tables were a cheaper solution than putting those equations into a computer. Luckily that is no longer the case and nowadays one would simply use any number of available computer based options, like this Python library:
OK, so let's look at how pressure and temperature change with altitude in this standard atmosphere model. Here are some plots that show this. These were created using the Python module ambiance linked above.
The vertical axis is height, with the bottom being sea level and the top being 80km (that's very high). Pressure decreases with altitude in a bendy curve sort of way. Temperature is wacky, it sometimes decreases, sometimes stays the same, sometimes increases.
Even though the Earth's atmosphere is thin relative to the overall size of the Earth (see image at top of this page), it is pretty tall when compared with the highest point on Earth - Mt. Everest. In this guide, we are mainly interested in altitudes on the Earth's surface, like places where we could actually stand. So we don't need to worry about anything above the summit of Everest. Let's zoom in.
There! These two plots show the variation in pressure and temperature for the altitudes we are interested in - anywhere your feet are touching the ground. Now things look much simpler, just two happy little lines.
Note how pressure changes with altitude. Specifically - pressure decreases as altitude increases. We will use that fact to create our pressure based altimeter. First, we need a way to measure pressure, so let's look at how pressure sensors work.