180 Journal of Engineering, Mechanics and Architecture www. grnjournal.us AMERICAN Journal of Engineering, Mechanics and Architecture Volume 3, Issue 2, 2025 ISSN (E): 2993-2637 Design and Implementation of Digital Spirometer Using Arduino Hasanain Aziz Abed Department of Medical Instruments Techniques Engineering, Al Hussein University, hasanainaziz4@gmail.com Abstract: Spirometer is a medical diagnostic device used to evaluate the performance of the lungs through exhalation produced during the human breathing process. Through the MPX5010dp pressure sensor, the device can be practically applied. Using a tube of different diameters, it was connected to the sensor in each diameter. The sensor measures the pressure difference for both diameters when the pressure is applied inside the tube. This means when a person exhales inside the tube of different diameters, the sensor calculates the pressure difference applied inside the tube. Using the electronic controller Arduino UNO is received by the signal from the sensor blades software in the form of "volt" and it shows on the display LCD16 * 2. 1. INTRODUCTION 1. Spirometry? Basically, «spirometry is a physiological test that assesses the strength of your lungs by using a sensor to measure the maximum amount of air that you can inhale and exhale. In order to be truly medically acceptable, spirometry testing needs to be conducted three times by a reproducible method for determining forced vital capacity (FVC).» Fig 1.1 the lung in the body 181 Journal of Engineering, Mechanics and Architecture www. grnjournal.us 2. Why is Spirometry Important? Your doctor may advise spirometry if you have shortness of breath, a cough, or you snore. It can help diagnose problems like cystic fibrosis, asthma or can check lung function before surgery . The doctor or nurse will use it to know the patient's response to treatment and to know the condition of the patient's lungs, whether they are healthy or not, and what is the volume of air entering and exiting the lungs, in order to evaluate the condition and treat it as quickly as possible. Therefore, the device is considered one of the most important devices that help in evaluating the performance of the aforementioned organ and treating it. Fig 1. 2 patient doing the test 3. Performing a Spirometry Test To help ensure accurate test results, wear loose clothing and don’t eat a meal immediately before. Also, avoid the following activities: 1. Smoking within 24 hours of testing 2. Strenuous exercise 3. Consuming alcohol The test follows these steps: 1. Close the patient's nose with plugs to prevent the entry of air 2. The operator makes the patient breathe in as much air as possible to fill his lungs. 3. Seal your lips tightly around the mouth of the tube. 4. Breathe directly into the tube as quickly and forcefully as possible for a few seconds. Our project will have you breathe into the tube for five seconds 4. Collect the Hardware 1. Arduino uno 2. MPX5010DP pressure sensor 3. Character LCD 16X2 I2c 4. Breadboard 5. Jumper Cables 182 Journal of Engineering, Mechanics and Architecture www. grnjournal.us 6. PVC Pipe 7. Flexible pipe tube for sensor 8. Foam Circle (For pipe) 9. Hot Glue Gun 5. Aim of the project Measure inspired and expired air by our lungs 6. Project outline 1) chapter two Present the theoretical basis of project and define all the components that are used in project and description on microcontroller. 2) Chapter three Explain the mechanism of the proposed system and the details of its implementation and design 3) Chapter four Extract the required results and discuss them CHAPTER SECOND THEORETICAL PART 1. Arduino Uno «is a microcontroller board based on the ATmega328P (datasheet). It has 14 digital input/output pins (of which 6 can be used as PWM outputs), 6 analog inputs, a16MHz ceramic resonator (CSTCE16M0V53-R0), aUSB connection, a power jack, and a reset button. It contains everything needed to support the microcontroller; simply connect it to a computer with a USB cable or power it with a AC-to-DC adapter or battery to get started. You can tinker with your Uno without worrying too much about doing something wrong, worst-case scenario you can replace the chip for a few dollars and start over again.» «"Uno" means one in Italian and was chosen to mark the release of Arduino Software The Uno board and version of Arduino Software were the reference versions of Arduino, now evolved to newer releases. The Uno board is the first in a series of USB Arduino boards, and the reference model for the Arduino platform; for an extensive list of current, past or outdated boards see the Arduino index of boards. In figure (2.1) show the shape of board and pins description.» Fig 2.1 Arduino uno 183 Journal of Engineering, Mechanics and Architecture www. grnjournal.us 2. MPX5010DP sensor «the MPX5010DP is a dual port, integrated silicon pressure sensor in 6 pin SIP package. This piezoresistive transducer is state of the art monolithic silicon pressure sensor designed for wide range of applications. It is ideally suited for microprocessor or microcontroller-based system. This transducer combines advanced micromachining techniques, thin-film metallization and bipolar processing to provide an accurate, high level analogue output signal that is proportional to applied pressure. The axial port has been modified to accommodate industrial grade tubing.» 1. On-chip signal conditioned, temperature compensated and calibrated 2. Differential configuration 3. 5.0% maximum error over 0°C to 85°C 4. Durable epoxy unibody 5. Temperature compensated over -40°C to 125°C 6. Patented silicon shear stress strain gauge 7. Pressure ranges from 0KPa to 10KPa 8. Supply voltage range from 4.75VDC to 5.25VDC 9. Sensitivity of 450mV/mm 10. Response time of 1ms Fig 2.2 MPX5010DP sensor 1. Applications Sensing & Instrumentation, Consumer Electronics, Portable Devices, Automation & Process Control, Medical 3. LCD 16×2 Fig 2.3 LCD 16×2 Pin 184 Journal of Engineering, Mechanics and Architecture www. grnjournal.us 1. Features of LCD16x2 The main features of the LCD screen are: 1. This LCD screen's need is 4.7V-5.3V 2. It consists of two rows, each row can produce 16 letters and numbers 3. The current is 1mA without backlight 4. Each character can be built with a 5x8 pixel square 5. The monitor can work in two modes such as 4-bit and 8-bit 6. Available in blue and green backlight 7. Shows some custom characters created 4. Tube One of the necessary parts of the device, where a tube of different diameters was used, produced by a 3D printer, is connected to the sensor, whereby the patient exhales inside the tube to form a pressure that is sensed by the sensor. As shown in Figure 2.4 1. Tube worker When you shed pressure inside the tube, it moves in two different sized fields where the sensor reading depends on the pressure speed inside the tube as in Figure 2.4. Fig 2.4 Details of the tube used CHAPTER THIRD APPLICATION 1. Parts used and connection 1. MPX5010DP pressure sensor The pressure sensor used has 6 pins, each with its own function, which is connected to the Arduino via jumper wires. The principle of the sensor's work is to sense the pressure on it and give an analog signal to the arduino in the form of volts, where it gives a signal resulting from 185 Journal of Engineering, Mechanics and Architecture www. grnjournal.us the pressure difference that is mounted on it, which calculates it and converts it into a badge to the Arduino. , (converting the pressure signal to Volt). Fig 3. 1: Sensor ports MPX5010DP Pin number Pin Name Description 1 OUTPUT Analog output proportinol to differential pressure 2 GND IC ground reference 3 Vcc IC supply pin P1,P2 Sensrors Connect to the tube Table 3.1 sensor pins As shown in the previous figure 3.1 There are 3 pins N/C that were not used in the connection because the sensor manufacturers manufacture them for grounding purposes or for the purposes of the sensor primitive experiment. 2. Connect the sensor Fig 3.2 Connect the sensor to the Arduino 186 Journal of Engineering, Mechanics and Architecture www. grnjournal.us Pin number Connecting Reason Pin 1 To Ao in arduino Send the signal in the form of analog Pin 2 To GND in arduino ground reference Pin 3 To 5v in Arduino Power sensor Table 3.2 Pin connect with Arduino 3. LCD 16×2 Pin The results display screen contains many ports, each port has its own function mentioned earlier in the second chapter, but for ease of dealing with the screen connection, a special protocol called I2C was used to eliminate the complexity and reduce the number of wires inside the circuit . The integrated Circuit (I2C) is a high-speed, bi-directional serial communication system for linking with peripherals, connecting with an LCD, that uses fewer lines to communicate, where it is possible to choose between one of the following four speeds: 1. Standard - 100 kbps 2. Fast - 400 kbps 3. Double Speed - 1 Mbps 4. High Speed - 3.33Mbps Fig 3.3 : I2C with LCD After connecting the i2c with the lcd, the ports switch from 16 to four. They are connected to the arduino to display the required results . 4. LCD ; I2C with Arduino After converting the ports for the LCD by i2c and getting four ports as shown in Figure 3.3 , connect the four ports to the Arduino after knowing the function of each of them Pin number Pin name To arduino Reason Pin 1 GND 7 digital To ground Pin 2 Vcc ICSP Power Pin 3 SDA SDA Data transfer PIN 4 SCL SCL Data change Table 3.3 Pin connections with Arduino 187 Journal of Engineering, Mechanics and Architecture www. grnjournal.us Fig 3.4 I2C pin in Arduino 2. Programming code «The basics of programming start from the code - or code as some call it - a set of instructions written using a particular programming language. These codes are instructions that the computer performs in succession, these instructions may be reading file content, for example, a drawing, or a calculation.» Detail the code used in the program in sequence. 1. #include 2. #include 3. LiquidCrystal_I2C lcd (0x27,16,2); The expression #include is used to include external libraries in your code. This helps the programmer access a larger range of standard C libraries (which are a collection of pre-created functions) and libraries that are written specifically for Arduino. 1. float vol= 0; 2. float M=0; 3. float sen_read = 0; 4. float mm=0; 5. int i=0; 6. int m_time = 0; 7. int start_time = 0; 8. int end_time = 0; 188 Journal of Engineering, Mechanics and Architecture www. grnjournal.us 9. float mean_vol = 0; 10. float Max_vol = 0; The float type is used with decimal numbers, which are fractional numbers that use decimal comma in their representation. The int code is to store variables within the arduino. In this code, dentified the variables need and stored them on the Arduino . 1. void setup() { 2. Serial.begin(9600); 3. pinMode(8,INPUT_PULLUP); 4. lcd.init(); // initialize the lcd 5. // Print a message to the LCD. 6. lcd.backlight(); 7. lcd.setCursor(1,0); 8. lcd.print("W E L C O M E"); 9. delay(3000); 10. lcd.clear(); 11.} The first part is used "void setup" to identify the types of inputs and outputs of the Arduino, i.e. to determine the nature of the work of each pin in the arduino in terms of being an entrance/exit, digital or linear. Serial begin uses this command to make the erdwino start communicating with the existing sensor. through the used pins. PinMode is a fixed software sentence and is one of the basic and important sentences that are used in the programming of the electronic piece Arduino, and is always used as the first software sentence when programming the arduino piece, its function is to dentify electronic pieces connected to the ardino piece on the program, i.e. it tells the program that we have piece 1 and is considered input, and piece 2 is considered a output and so on, This sentence also specifies the pin number on the erdino and attached to the electronic pieces. pinMode(8, inPUT ) It means that the piece connected to Pin 8 is input.Lcd.int econnected the screen used after it was defined through its library. Then enter what is required of them to display it at first. after defining the changes, have defined the arduino on the modus operandy of the existing sensor where the arduino receives a volt-shaped sensor signal after selecting the changes and how to receive the signal and display it on the screen. Through a delay order where it performs the program according to the period given. Also select voltage read where you eat from 0 to 1023. the amount of volt resulting where it is greater than 0.27. And that's to get rid of showing results in the natural atmosphere without using the device . Also to get rid of the results caused by simple external vibrations affecting the sensor . After determining the changes required of the Arduino to take into account these variables. Final results on the screen 1. The highest volt value obtained during the highlight and called Max 2. The value of the average calculation of the total results obtained from Volt and called mean 3. The time it takes to get the highest volt value results measured by unit, m Sec and called time on the screen. 189 Journal of Engineering, Mechanics and Architecture www. grnjournal.us Time = m sec Fig 3.5 Signal wave 3. principle of the project When exhaling by the person used inside the tube through the hole in it, the speed of different pressures between the small and large area is formed p1&p2, through which the sensor sensing the pressure inside the tube at different speeds and converts it to the arduino in the form of a volt signal to be processed by the programming codes of The Ardino and then converted to the screen to display the results. The signal that the arduino gets from the sensor is the result of the pressure difference inside the tube, where it extracts one volt-shaped result, which is the pressure difference inside the tube. As in Figure 3.6 Figure 3.6.principle of the project CHAPTER FOURTH RESULTS 190 Journal of Engineering, Mechanics and Architecture www. grnjournal.us 1. Final design Image 4.1 Final design Image 4.1 Final design 2. Results Using a device ventilator carescape r860 located at Al Hussein Educational Hospital in Muthanna has been conducting tests on the project to get accurate results 191 Journal of Engineering, Mechanics and Architecture www. grnjournal.us Picture 4.1 Hospital visit 1. First test Put the project on the vantilator device by connecting the pipes of the device to the project pipe tightly, taking into account the following: 1. The respiratory rate is 6 times per minute 2. Change the volume of incoming air from the vantilator each time from 500ml to 2000ml At the start of the test, the following results appeared : First test TIME Mean V MAX volume 1568 M S 0.31 0.37 500 ml 1782 M S 0.35 0.43 750 ml 1945 M S 0.38 0.49 1000 ml 2126 M S 0.41 0.54 1250 ml 2387 M S 0.45 0.59 1500 ml 2601 M S 0.49 0.64 1750 ml 2843 M S 0.53 0.68 2000 ml Second Test TIME Mean V MAX volume 1633 M S 0.34 0.41 500 ml 1869 M S 0.38 0.47 750 ml 2014 M S 0.42 0.53 1000 ml 2257 M S 0.46 0.56 1250 ml 2499 M S 0.5 0.62 1500 ml 2706 M S 0.55 0.68 1750 ml 2921 M S 0.59 0.74 2000 ml Third Test TIME Mean V MAX volume 1428 M S 0.3 0.33 500 ml 1654 M S 0.35 0.38 750 ml 192 Journal of Engineering, Mechanics and Architecture www. grnjournal.us 1845 M S 0.39 0.52 1000 ml 2038 M S 0.44 0.57 1250 ml 2241 M S 0.48 0.61 1500 ml 2417 M S 0.53 0.66 1750 ml 2612 M S 0.57 0.7 2000 ml M S : IS MILLI SECOND UNIT Fig 4.1 line of one test (a) first test (b) Second test ( C ) Third test Fig 4.1 line of one test 193 Journal of Engineering, Mechanics and Architecture www. grnjournal.us 2. Second Test R.R VOLT MAX 750 ML MEAN 750 ML TIME 750 ML VOLT 1000 ML MEAN 1000 ML TIME 1000 ML 8 0.51 0.34 2471 m s 0.61 0.40 2785 m s 10 0.62 0.41 2102 m s 0.74 0.47 2423 m s 12 0.76 0.49 1869 m s 0.87 0.54 2099 m s 14 0.87 0.57 1423 m s 1.01 0.61 1799 m s 16 0.99 0.65 1122 m s 1.13 0.69 1354 m s 18 1.10 0.73 847 m s 1.26 0.78 1017 m s 20 1.22 0.81 493 m s 1.39 0.86 847 m s Table 4.2 Results for Second Test In this test apply the same previous steps but the different is a change of respiratory rate each time towards the increase from 8 to 20. With the choice of two fixed volumes of air coming out of the device. After the first test, the following results emerged When the volume of air flowing increases, volt increases in size, thus increasing the time spent breathing After the preliminary results are extracted, the straight line equation is applied, which states for each straight line there is a relationship between x&y of the points on which it is located and this relationship is called the straight line equation. Fig 4.2 Apply the straight line equation to one of the results of the first test 3. Conclusion At the time of the first test, the voltage increased when the amount of volume on the sensor was increased when the breathing rate was stabilized by 6 times per minute. Also in the second test when the amount of breathing rate is increased and the amount of air is stabilized on the sensor. As for the time when the air volume changes, we notice an increase in time when the respiratory rate is stabilized. In the second case, the time is lower when the breathing rate changes by the size. Thus, the linear shape of the results represents a straight line when the volume of air increases and the amount of volts increases and it is possible to find the line's inclination for results by the straight line equation applied above. 4. Applying the Bernoli equation to the flow of gases «Bernoli's theory is the relationship between pressure, speed and height in moving fluid, whether liquid or gas, compression and viscosity, i.e. internal friction that cannot be remembered and flowed constantly or plying. The first theory by Swiss mathematician Daniel Bernoli actually stated that the total mechanical energy of flowing liquids, including energy associated with fluid pressure, potential gravitational energy of height and kinetic energy of motion fluids, is therefore 194 Journal of Engineering, Mechanics and Architecture www. grnjournal.us the principle of energy conservation for ideal liquids in fixed flow and is the basis for many engineering applications.» 5. Discussion The purpose of the projector is to measure the amount of exhalation force through the speed of the air projected into the pipe. The MPX5010DP sensor was used to calculate the amount of pressure difference placed inside the tube and the time spent during the test. Thus, the results are compared by applying the Bernoli equation for gas flow and that to find the speed of pressure. This research can be developed on equipped with a delete button. Using a sensor other than MPX5010DP in order that there will be a better innovation and measurement. 6. Sources 1. Schmidt, M. ["Arduino: A Quick Start Guide"], Pragmatic Bookshelf, January 22, 2011, Pg. 201 2. Fowler, Charles B. (1967( ،"The Museum of Music: A History of Mechanical Instruments" ،Music Educators Journal54 ، (2(: 45–49 3. P. S. Wardana dan R. Adil , " Spirometer Non - Invasive dengan Sensor Piezoelektrik untuk Deteksi Kesehatan , " vol . 5 , no . 2 , hal . 188-206 , 2017 . 4. W. Mubarok , E. Kumaidah , dan Y. Supatmo , " PERBEDAAN NILAI VITAL CAPACITY , FORCED VITAL CAPACITY DAN FORCED EXPIRATORY VOLUME IN ONE SECOND ANTAR CABANG OLAHRAGA PADA ATLET USIA 6-12 TAHUN , " vol . 4 , no . 4 , hal . 1619-1625 , 2015 . 5. Alice Mela: "A visit to the Arduino factories". domus, 2013-5-15. (2015eko otsailaren 21ean ikusia) 6. Fowler, Charles B. (1967( ،"The Museum of Music: A History of Mechanical Instruments" ،Music Educators Journal54 ، (2(: 45–49 7. A. Zainudin , E. Rahmawati , dan Dzulkiflih , " Pengukuran Volume Paru Paru Dengan Memanfaatkan Sensor Tekanan , " J. Inov . Fis . Indones . Vol . , vol . 04 , hal . 127-132 , 2015 8. W. T. Kusuma , E. S. Pramukantoro , S. Djajalaksana , P. Studi , I. Fakultas , dan I. Komputer , " Rancang bangun aplikasi pengukur kesehatan fungsi paru manusia memanfaatkan microphone pada smartphone , " vol . 3 , no . 2 , hal . 115-125 , 2016 .