So this was a random thought I had that I thought would be fun to mess around with using an Arduino and some sensors, but after the difficulty I've had I'm just curious to see if it can be done at all.

So I thought it would be interesting to take some samples measuring the density of the atmosphere. While looking at different formulas for calculating air density at different temperatures, pressures, humidity, and even formulas for different concentration of gases, I decided it would be more interesting to do it while ignoring the actual makeup of the gas.

In other words, I can take measurements of the gas, but I can't calculate the density using any constants specific to one type of gas. So the primary measurements I'm taking are Temperature, Pressure, and Speed of Sound, however so far I cannot find any way to calculate, or even approximate the density from these values.

Currently I'm trying to see if I can approximate it based on molecular collisions, but can't really seem to get it to go anywhere. The only thing I can think of that would work in practice would be to isolate a section of the atmosphere in a closed container with a plunger, and measure its pressure and temperature at different volumes but 1) I really don't want to have to build this device with moving parts unless absolutely necessary and 2) It just seems to me that we should be able to do it using the formulas, and its bugging me that I can't find it.

I would appreciate any insight you guys can give. Thanks.


Ok so here is my train of thought I've been working on.

I've been trying to come up with a solution by treating the molecules of the gas acting as a spring.

So let's imagine two gas molecules in space. Each molecule has a kinetic theory, which by the kinetic theory of gases is each to

Ke = (3/2)BoltmannsConstantAbsoluteTemperature. [1]

This energy takes the form of Brownian Motion, which the molecules uses to clear out an empty space for itself. We can calculate the average space per molecules by inverting the Lochsmidt Formula, so

Space per Molecule = BoltzmannConstant * Temperature / Pressure [2]

Once we know the space, we can calculate the average distance from the center of one molecule to the center of a number, by treating the space as a cube, and finding the lenght of a side

SideLength = cbrt(Space per Molecule) [3]

So back to our model. While the molecule is moving, we can pretend that it is just sitting in the center of that empty space. So let's say another molecules (A) comes in whos average velocity of the speed of sound. A's total kinetic energy will be its Thermal Energy (see Formula 1) plus the kinetic energy of it moving at the speed of sound. Whether by collision or by electromagnetic interation, it will exert a force on another molecule (B), causing B to speed up, and A to slow down. B's original kinetic energy will simply be its Thermal Energy. Now however, Molecule B will be acting as a spring for A, absorbing the kinetic energy of it moving at the speed of sound.
Finally as A reaches the original point of B, B's kinetic energy will be its Thermal Energy, the energy of it moving at the speed of sound.

Now using the kinematic equations we can find several parts of the puzzle

First off, the speed of sound is the average velocity of the molecules

V_a = (V_0 + V_f) / 2 [4]

Now V_0 = 0 and V_a = speed of sound, so the final velocity is

V_f = 2 * V_a [5]

Now that we know the final velocity, we can calculate the acceleration of molecule

V_f^2 = V_0^2 + 2 * A * D [6]

Again, V_f comes from formula 5.
V_0 = 0 D = distance between the atoms.

Simplifying and solving for A we get

A = V_f^2 / (2 * D) [7]

Now here's where things get interesting.

A (acceleration) is in the same unit as a Spring Constant.

So by treating A as a Spring Constant, we can plug it into the formula for the potential energy of a spring.

PE = (1/2) * K * X^2 [8]

PE = potential energy K = Spring Constant X = Displacement

So in our case we get

PE = (1/2) * A * D^2 [9]

A = Acceleration from formula 7 D = Distance between atoms.

By setting Potential energy equal to the kinetic energy of a moving object,

we get

(1/2) * A * D^2 = (1/2) * M * V^2 A * D^2 = M * V^2 (A * D^2) / V^2 = M [10]

which should give us the average mass of a molecule in the gas.

But it doesn't work.

Let's plug in our values for Air. We'll compare it to the values found on http://www.engineeringtoolbox.com/speed-sound-d_82.html

So the speed of sound in air at 0 degrees Celeius (273 Kelvin) and 1 bar of pressure (100000 Pascals) is equal to 331.2 m/s

So from Formula 2 the average space per molecules is

1.38064852e-23 * 273 / 100000 = 3.769e-26

From Formula 3, the average distance between molecules is

(3.769e-26) ^ (1/3) = 3.353e-9

Our final velocity is (Formula 5) is

2 * 331.2 = 662.4

Acceleration (Formula 6) is

(662.4^2) / (2 * 3.353e-9) = 6.543e13

And our mass per molecule (Formula 10) is

(6.543e13 * (3.353e-9)^2) / 662.4^2 = 1.676e-9

which is nowhere even close to the average mass of a molecule in the air.

I feel like I'm on the right track, but now sure what else to do. Any help would be appreciated.

  • $\begingroup$ You can easily measure temperature, pressure and sound velocity. If I understand it correctly, the rest is just the application of formulas in en.wikipedia.org/wiki/… $\endgroup$
    – dominecf
    Commented Apr 20, 2016 at 10:20
  • $\begingroup$ Note that for many applications, air can be modeled as an ideal gas. When dealing with an ideal gas, the empty space between particles is so large that interactions between gas molecules (ie collisions) can be neglected. Read en.wikipedia.org/wiki/Ideal_gas $\endgroup$ Commented Apr 20, 2016 at 13:43

3 Answers 3


Okay - probably you know, that weather physics is serious business and having even lot of measurements in many points you still can't calculate long enough evolution of a system to get results for e.g. the weather in the next month.

But you are asking for something else -- just equation of gas density in an open system depending on local temperature and pressure. Let's suppose that percentage amounts of elements in the air are constant: we get 78% of nitrogen (molar mass $M_{N_2} = 28 g/mol$), 21% of oxygen (molar mass $M_{O_2} = 32 g/mol$), 1% of everything else, like carbon dioxide (molar mass $M_{CO_2} = 44 g/mol$). The mean molar mass of air is then approximately $M = 29 g/mol$.

Great. Having Clapeyron equation for ideal gas (which can be our zero-order approximation):


we want to describe it in terms of mass, molar mass and density (pressure and temperature is known). We get:

$$P=\frac m{VM}RT,$$ $$P=\frac\rho MRT,$$ $$\rho=\frac{PM}{RT}.$$

Of course, you don't include here many other weather conditions like wind or humidity, but well, it is enough to begin with.

  • $\begingroup$ An 'A' for effort, but as I mentioned in my original post, I'm trying to do it independent of knowing the makeup of the gas. That's the trouble I'm having, since every equation I've seen so far requires some constant specific to that gas. $\endgroup$ Commented Apr 20, 2016 at 22:42
  • $\begingroup$ Having speed of sound gives another information, so maybe we could calculate mean molar mass from it. Okay, I'll maybe write addition tomorrow, for now we wait for another answer :) $\endgroup$ Commented Apr 20, 2016 at 22:49

Neither of the other answers discussed the speed of sound (“c”), which is not quite the same as the average speed of the molecules. The correct relationship is ${{c}^{2}}={{(dP/d\rho )}_{S}}=\gamma P/\rho $ where $P\sim {{\rho }^{\gamma }}$ for adiabatic (constant entropy) compression or expansion of an ideal gas. The exponent is the ratio of specific heats, $\gamma \equiv {{C}_{P}}/{{C}_{V}}$, ideally 7/5 for diatomic gases (except at cryogenic temperatures) and for rigid linear gases $(C{{O}_{2}})$ but only 5/3 for monatomic argon and 8/6 for water and methane. If you feel comfortable assuming 7/5 for an arbitrary mix of nitrogen and oxygen, you can get the density via $\rho =\gamma P/{{c}^{2}}$, and the mean molecular mass via $m=\rho RT/P$.


You can probably take advantage of measuring pressure at two different heights.

Air pressure is caused by its weight, similar to liquid pressure. Therefore, it can be shown that pressure difference of two points can be related to air density:

$$\Delta p=\rho g \Delta h$$

This equation gives $\rho$ (average mass density) as a function of $g$ (gravity acceleration), $\Delta h$ (height difference of sensors), and $\Delta p$ (pressure difference measured by sensors).

So two pressure sensors installed at different heights measure the pressure difference. Of course it's a good idea to estimate $\Delta p$ before building the project so you will know how much sensitive your pressure sensors need to be or how much $\Delta h$ you should take.

Also, here you can find more information about the equation (including proof, general form, etc.): https://en.wikipedia.org/wiki/Vertical_pressure_variation

  • $\begingroup$ The idea would work in theory, but practically: <br> 1. The pressure varies very little with small changes in height because of the low density of air <br> 2. The pressure measurements could be affected by wind $\endgroup$ Commented Jun 1, 2018 at 14:17
  • $\begingroup$ I haven't actually tested this in practice so maybe you're right. 1 meter height difference corresponds to about 0.01% pressure change, which may be hard to measure in practice. $\endgroup$ Commented Jun 1, 2018 at 15:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.