This paper presents a novel technique for extracting the alveolar part of human breath. Gas exchange occurs between blood and inhaled air in the alveoli, which is helpful in medical diagnostics based on breath analysis. Consequently, the alveolar portion of the exhaled air contains specific concentrations of endogenous EVOC (exogenous volatile organic compound), which, among other factors, depend on the person's health condition. As this part of the breath enables the screening for diseases, accurate sample collection for testing is crucial. Inaccurate sampling can significantly alter the composition of the specimen, alter the concentration of EVOC (biomarkers) and adversely affect the diagnosis. Furthermore, the volume of alveolar air is minimal (usually <350 mL), especially in the case of people affected by respiratory system problems. For these reasons, precise sampling is a key factor in the effectiveness of medical diagnostic systems. A new technique ensuring high accuracy and repeatability is presented in the article. It is based on analyzing the changes in carbon dioxide concentration in human breath using a fast and compensated non-dispersive infrared (NDIR) sensor and the simple moving adjacent average (SMAA) algorithm. Research has shown that this method accurately identifies exhalation phases with an uncertainty as low as 20 ms. This provides around 350 ms of breath duration for carrying out additional stages of the diagnostic process using various types of analyzers.