An oral-nasal cannula receives exhaled gases from the nose and mouth of a patient. The exhaled gases are transported to variable flow valves that can variably restrict the flow of the gases through the valves upon software generated signals. The exhaled gases pass through the variable flow valves and mix so that they can be measured by a single sensor such as a sensor of a capnometer. Based upon information gathered by the capnometer, the variable valves can be adjusted in real-time according to a software method in order to identify a variable valve flow configuration that maximizes the amount of CO2 received and measured by the capnometer. In this manner, the software can adapt a single capnometer to measure exhaled gases regardless of whether a patient breathes primarily through their nose or mouth or some proportion of the two.