Zaphyr is a startup project aiming to develop a low-cost (frugal) spirometer for low-resource environments. It combines a differential pressure sensor (MXP5010DP), a microcontroller (ESP32), and an advanced Python script to acquire, process, and analyze patients' respiratory data to assist in the diagnosis of pulmonary diseases.
- High-Frequency Acquisition: Precise sampling at 1000 Hz for 10 seconds via the ESP32.
- Advanced Signal Processing: * Dynamic cut-off frequency calculation using Fast Fourier Transform (FFT).
- 4th-order low-pass Butterworth filtering with zero-phase distortion.
- Fluid Mechanics: Conversion of pressure to volumetric flow rate (Bernoulli's Principle) with dynamic compensation for friction-induced pressure drops (Solving the Colebrook-White equation).
- Automated Clinical Analysis: * Extraction of standard parameters: FVC (Forced Vital Capacity), FEV1 (Forced Expiratory Volume in 1 second), PEF (Peak Expiratory Flow).
- Calculation of the Tiffeneau-Pinelli index (FEV1/FVC ratio).
- Generation of a pre-diagnosis (normal, obstructive, or restrictive profile) by comparing results to theoretical values based on the patient's age, gender, and height.
- Medical Visualization: Automatic generation of standard spirometry curves (Volume-Time and Flow-Volume graphs).
- Simulation Mode: Built-in data generator simulating different clinical profiles to test the software without physical hardware.
- Microcontroller: ESP32 board (or compatible Arduino).
- Sensor: MXP5010DP differential pressure sensor.
- Mechanics: 3D-printed spirometry tube (Venturi effect with R1 = 13.9mm and R2 = 4.9mm).
codeArduino/codeArduino.ino: Embedded script for the ESP32. Handles the 12-bit ADC, strict timing (1 ms), and serial communication at 115200 bauds.zaphire.py: Main Python script running on the computer. Manages serial communication, mathematical processing (Numpy/Scipy), console user interface, and graph plotting (Matplotlib).A_frugal_arduino-based_spirometer_for_low-resource.pdf: Documentation and research associated with the project.
- Open
codeArduino.inoin the Arduino IDE. - Connect the
Voutpin of your sensor to pin34of the ESP32 (can be modified in the code). - Upload the code to the board.
Ensure Python 3 is installed. Install the required dependencies:
pip install pyserial numpy scipy matplotlib- Connect the ESP32 to your computer via USB.
- Identify your board's port:
- Windows:
COM3,COM4, etc. (Check Device Manager). - Mac/OSX:
/dev/tty.usbserial-...or/dev/cu.usbserial-...
- Windows:
- If necessary, modify the
portparameter in theacquerir_donnees_serie()function at the bottom of thezaphire.pyfile. - Run the script:
python zaphire.py- Follow the on-screen instructions (enter the patient's data, then blow into the tube when prompted!).
💡 Tip: To test the code without the ESP32, comment out the serial acquisition line in the main block (
__main__) and uncomment thegenerer_donnees_simulees(profil="obstructif")function.
- Echchorfi Charaf - Computer Science and Information Systems Engineering student - UIASS