A manometer is a device to measure pressures. In the normal condition during the CPAP therapy, there is a significant change in the air pressure inside the CPAP piping due to breathing as patient inhale and exhale the air. If there is a large air leak or the mask is off, the air pressure fluctuation in the piping will become much smaller. So essentially we can check the mask status by constantly monitoring the air pressure inside the CPAP piping with a manometer.
Digital Manometer
In this project MPXV7002DP Integrated Silicon Pressure Sensor is used as a transducer to convert the air pressure to digital signals. The MPXV7002DP breakout board is widely available as a pressure differential sensor to measure the airspeed of RC models and is relatively cheap. This is the same technology inside commercial CPAP machines.
MPXV7002DP is a monolithic silicon pressure sensor designed for a wide range of applications. It has a measuring range of air pressure from -2 kPa to 2 kPa (approximately +/- 20.4 cmH2O), which covers nicely the typical pressure levels for treating Obstructive Sleep Apnea range from 6 to 15 cmH2O.
MPXV7002DP is designed as a differential pressure sensor and have two ports (P1 & P2). In this project, MPXV7002DP is used as a gauge pressure sensor by leaving the backside port (P2) open to the ambient air. This way pressure is measured relative to the ambient atmospheric pressure.
MPXV7002DP will output an analog voltage from 0-5V. This voltage is read by the Arduino analog pin and covert to corresponding air pressure using the transfer function provided by the manufacturer. The pressure is measured in kPa, 1Pa = 0.10197162129779 mmH2O. The results then are displayed on the LCD screen in both Pa (Pascal) and cmH2O.

CPAP Machine Monitor
Study shows breathing movements are symmetrical and did not change significantly with increasing age. The average respiratory rate is 14 during quiet breathing for both sexes. The rhythm (inspiration/expiration ratio) is 1:1.21 for men and 1:1.14 for women during quiet breathing.
The raw data of air pressure measurements from the CPAP piping goes up and down as people breath and also has many 'spikes' since Arduino 5.0V supply is quite noisy. Therefore the data needs to be smoothed out and evaluated over time in order to reliably detect the pressure changes introduced by inhalation and exhalation.
Several measures are taken by the Arduino sketch to process the data and monitor the air pressure. In a nutshell, the Arduino sketch uses the running average library by Rob Tillaart to first calculate the moving average of the air pressure measurements in real-time to smooth out the data points, then calculate the minimum and maximum observed air pressure every a few seconds to determine whether the mask has been disconnected by checking the differences between the peak and trough levels of air pressure. So if the incoming data line becomes flat, then it is likely that there's a large air leak or the mask has been disconnected, an audible alarm will sound to wake up the patient to make necessary adjustments. See the data plots for the visualization of this algorithm.


I've put all the things together here, but am still debugging a few parts that are not working. Really looking forward to having this around! Thank you.