Yes the depth sensor is sorted and even comes with a library. It's a bit expensive at $70US but for simplicity I will go with it. You can get them from China for substantially less but then would have to write the library; one for the future.

Gas pressure is purely a function of fraction of gas in breathing mix multiplied by depth.

As an example on the surface at 1bar of pressure nitrogen is .79 bar in the air. Slightly less in the lung due to water vapour there (though I have the value for that too).

Every 10 meters of depth adds an extra bar of pressure and increases the density of the air accordingly (at 10meters deep the air we are breathing is twice as dense as on the surface, 30, 20 meters deep 3 x as dense etc ). So breathing air at 10 meters depth would be 1.78 bar (it's commonly called the partial pressure (PP) of that gas). Correspondingly the PP of the Oxygen proportion of the air you would be breathing would be .21 bar on the surface and .42 bar at 10meters.

You wouldn't need a gas pressure sensor as such. Gas pressure in the algorithm means the pressure as explained above.

A good explanation is below:

A diver descends from the surface to 30 meters on air and waits there ten minutes. The partial pressure of nitrogen in the breathing gas Pgas is 4 x 0.79 = 3.16 ATM. (In the example 4 = absolute bar pressure as explained above).

Let's pick a compartment, say number five. The nitrogen half-time for compartment five tht is 27 minutes. The nitrogen partial pressure in compartment five on the surface Pbegin is 0.79 ATM, assuming the diver hasn't already been diving or subject to any altitude changes. The length of the exposure te is ten minutes. Plugging these values into the equation, we get:

Pcomp = 0.79 + [ 3.16 - 0.79 ] x [ 1 - 2 ^ ( - 10 / 27 ) ]

= 1.33 ATM

So the partial pressure of nitrogen in compartment five of our diver would be 1.33 ATM. In reality, the diver couldn't have made an instantaneous descent to 100 feet and would have been taking on gas during the descent as well. We could average the pressure during the descent and repeat the above calculation to get an idea of the extra gas, or simply repeat the calculation many times at short intervals during the descent. A computer makes this easy.

You can repeat this calculation, of course, for all the other compartments, you just need to know the half-times, ( See Table 1 ) Again, a computer is the ideal tool for this job. The beauty of the equation is its versatility. Absolute pressure ( not depth ) is used everywhere, as is the actual partial pressure of the inert gas being breathed, so we can ascend or descend to/from any pressure, breathe any gas, change gases, go flying after diving, stay on the surface, do a repetitive dive or anything we can think of.

HTH

Jools