When a gas expands against a constant external pressure, it pushes its surroundings out
of the way, and pushing something requires work. That work done by the gas is W = P × (V₂ − V₁), with pressure in pascals and volume in cubic
metres so the answer comes out in joules. If the gas expands, V₂ is larger than V₁ and W
is positive; if it’s compressed instead, W comes out negative — the surroundings did the
work on the gas, not the other way around.
Heat behaves differently at constant pressure than at constant volume, because some of
the heat you add goes into that expansion work rather than into raising the temperature.
The heat added is Q = n × Cp × (T₂ − T₁), where n is the amount of gas in moles, temperatures are in kelvin, and Cp is the molar heat capacity at constant pressure. This
calculator assumes a diatomic gas such as air or nitrogen, for which Cp = (7/2)R — an assumption that ties back to the ideal gas model, since Cp and its constant-volume counterpart Cv
are only fixed numbers like this because the gas is treated as ideal in the first place.
Put the two together and you get the first law of thermodynamics: ΔU = Q − W. Whatever heat goes in either does work pushing the
surroundings back, or stays behind as a change in internal energy — there's nowhere else
for it to go. If your readings came from a thermometer in Celsius or Fahrenheit rather
than kelvin, run them through the temperature converter first, or simply pick the
right unit from each temperature field's own dropdown above.