The present invention provides an apparatus and method for a noninvasive
optical determination of the pH of a substance in a compartment in a
closed system comprising a compartment wherein a substance resides which
is permeable to at least one wavelength of light, a light source and
light detecting device configured to obtain spectral data for a substance
for at least one wavelength, a processor adapted to determine the pH of
the substance by correlating the spectral data with predetermined
spectral data for a known substance at a known pH at the at least one
wavelength, and wherein the processor is further configured to control
the release of the substance from the compartment to its end use.