This is a project I completed for a biomedical instrumentation class at Vanderbilt University. This spirometer uses a pressure transducer and an Arduino Uno to compute the volume of air blown through the plastic tube. The circuitry is very basic- the majority of this project relies on the coding and an understanding of fluid dynamics. I'll go through the set up of the physical circuitry and then delve in deeper to the code and mathematics.

Spirometers are typically used in a clinical setting to diagnose pulmonary disease. These tools measure the amount of air expired, and in some cases, can show the change in flow rate over time. This simple, low cost spirometer allows for a rough calculation of the volume of air expired from the lungs over a period of time. A button on the Arduino LCD screen is used to control the period of time over which this calculation takes place. The results are clearly displayed on the LCD screen, making this a fun, easy to use device.

Although this device is not intended to be used in a clinical setting, it was interesting to learn about pressure sensors and Arduino applications while working on this project. I hope you enjoy!

Materials:

-PVC pipe

-Plastic tubing

-Glue

-Pressure sensor (see Step 2)

-Arduino Uno

-Arduino compatible LCD screen

-Computer

-Micro USB cable

-Wires

## Step 1: Construct a Spirometer Tube

I was able to salvage my tube from a previous year's project, but I would recommend building your own spirometer tube in order to better customize the diameter size.

The tube should have two sections, one with a large diameter and one with a significantly smaller diameter. In my project I used D1 = 2.3 cm and D2 = 0.6 cm. PVC piping might be a good alternative to using a plastic tube. If I were to do this project again, I would definitely use tubes with a larger diameter difference. I ended up using duct tape in order to create a smaller diameter within the second half of the tube.

On each side of the diameter change, drill a small hole and connect plastic tubing. These two pieces of tubing will later be attached to the pressure sensor in order to calculate the pressure drop across this section of the tube. Make sure the seal is tight by using enough glue.

## Step 2: Select a Pressure Sensor

The only circuit component used for this project is a pressure sensor. I used a differential Honeywell ASDX Series Silicon Pressure Sensor. I liked using this sensor and I've attached the data sheet to this page.

Differential pressure sensors are able to convert a difference in two pressures to a voltage. A diaphragm is placed between two compartments of the sensor. Each compartment has a port where a pressure can be applied. When different pressures are applied to the two compartments, the diaphragm moves. The diaphragm is attached to a series of piezo-resistive strain gauges that are connected in a Wheatstone bridge configuration. As the resistances change, the output of the bridge circuit changes and can be used to calculate the pressure difference.

The sensor requires connections to a supply voltage (typically 5 V) and ground. There is also an output voltage pin, which is where the signal we are using will be produced. For this particular sensor, the output voltage when the pressure difference is zero is equal to 1/2 of the supply voltage. I used a 5 V supply, so my output was 2.5 V when there was no pressure differential applied. There is an equation included in the data sheet than can be used to calculate the pressure based on the output voltage.

## Step 3: Attach Arduino Microcontroller

Another major component of this device is an Arduino Uno microcontroller and a compatible LCD screen with buttons. They can be purchased here: http://www.arduino.cc/en/main/arduinoBoardUno. Connecting the Arduino to the pressure sensor is very simple. Since the Arduino is able to supply 5 V and ground, I was able to power the pressure sensor with the Arduino alone.

Before attaching wires from the pressure sensor to the Arduino, attach the LCD screen to the microcontroller. It should easily fit into pins of the Arduino. The pressure sensor can then be connected using the pins on the LCD screen.

My configuration was as follows:

Pressure Sensor --> Arduino

Pin 1 (supply) --> 5 V

Pin 2 (output) --> A1

Pin 3 (ground) --> GND

My pressure sensor was attached to a basic breadboard and the Arduino microcontroller was attached to a PC via a micro USB cable.

## Step 4: Creating the Code

This step was by far the most time intensive portion of this project. Luckily for you, I've done most of the work already! In this step, I will attempt to explain the fluid mechanics and the path I took to get from voltage to air volume using some relevant equations. I've also attached my Arduino code as a pdf document, so feel free to take a look at that and change parameters as necessary for your design.

1. Converting between digital and analog signals:

When an analog signal (like the voltage produced by our pressure sensor) is processed by the Arduino, it is converted to a digital value between 0 and 1023. Our first step in the code after reading in this value is to convert it back to an analog value. Here is the bit of code doing just that:

volt = inputVolt*(vs/1023.0);

2. Converting from a voltage to pressure:

The purpose of the pressure transducer is to turn a pressure difference into a voltage, but now we want to determine the pressure difference based on a given voltage. The datasheet provides an equation to do just that, and with some rearranging, the pressure can be calculated as follows:

pressure_psi = (15/2)*(volt-2.492669); // Pressure in psi

You may notice that a value of 2.492669 is used instead of the 2.5 that I expected the sensor to produce at equilibrium. I determined this more precise value after a number of calibrations showed that my equilibrium value was not at exactly 2.5 V. You may need to adjust this number based on your own sensor's tendencies.

3. Psi to Pa

The equation given in the data sheet gives us the pressure in psi. In order to make further calculations easier, we will convert this to Pascals, which is the SI unit for pressure.

pressure_pa = pressure_psi*6894.75729; // Pressure in Pa

4. Calculating mass flow from pressure

This next step involves some fluid mechanics knowledge and creative algebra, but ultimately allows you to convert your pressure difference into a mass flow rate. The follow equation can be rearranged to solve for W, the mass flow rate in kg/s:

dP=((W^2)/2rho)*(1/A2^2−1/A1^2)

Where dP is the change in pressure across the tube in Pa, W is the mass flow rate in kg/s, rho is the density of air in kg/m^3, and A1 and A2 are the cross section areas of the two different sections of your tube in m^2. After rearranging and including values for rho, and the A1 and A2 for my specific tube design, I was able to compute W with the following code:

massFlow = 1000*sqrt((abs(pressure_pa)*2*rho)/((1/(pow(area_2,2)))-(1/(pow(area_1,2))))); // Mass flow of air

The syntax in Arduino makes this a bit messy, so be sure to check your parentheses. I also included a factor of 1000 so that in step 5, we end up with L/s instead of m^3/s, which allows the volume to be in a standard unit.

5. Mass flow to volumetric flow

This step is relatively easy- we can convert mass flow into volumetric flow by dividing by the density.

volFlow = massFlow/rho; // Volumetric flow of air

6. Computing volume

Finally, we have reached a point where volume can be computed. Since Arduino does not have the capability to perform integrals, we have to manually add up our volumetric flow rate over time. Since volumetric flow rate is simply volume over time, we can sum up the volumetric flow rate over small bits of time to compute total volume. This can be done using a delay in Arduino and multiplying each volumetric flow rate value by a small dt value.

volume = volFlow*dt + volume; // Total volume (essentially integrated over time)

dt = 0.001;

delay(1);

That's all the math! The rest of the code is just setting up the LCD screen, defining variables, and setting up the button controls.

The if statement in the code causes the volume to be calculated only when the button is being pushed. This feature prevents the calculation from being affected by noise, and also allows the user to indicate when air is actually flowing through the tube.

## Step 5: Try Out Your Spirometer!

Finally, you can try out your spirometer! In order to use the device, attach the tube created in Step 1 to the pressure sensor using the two pieces of tubing. Bring the tube up to your mouth and blow through it, while simultaneously pressing the up button on the LCD screen. Once you have finished expiring, release the button. The volume you expired will be neatly displayed on the LCD screen in liters.

I hope you enjoyed this instructable! Thanks for reading!

<p>That was great. Thank you soooooo much</p>
<p>Hi, How did you do the mask?</p>
<p>Hi, </p><p>I made it :)</p><p>A few notes observations:</p><p>- need a potentiometer to increase LCD brightness</p><p>- the differential pressure sensor needs to be of maximum 5psi as the human lung can only produce about 1 to 2 psi so if you use a<br>100psi sensor you'll only be using around 2% of its range. This means<br>you'll only get around 2% of the 5 volt output range (0.1 volts). This<br>will severely limit the resolution of the application (took me a while to understand why was my sensor not showing an observable increase when blowing in the tube)</p><p>- also two 10ohm rezistors are required (one for the potentiometer and one for the analogue button) you can find online information on hot to setup these two components.</p><p>@author thank you for this :)</p>
<p>Hi, do you have more photos of the Breadboard? because I think I'm connecting something wrong.</p>
<p>hi anim2016, I also working on making spirometer for my group project but we get confused on the spirometer tube design. can you show how you do it? thank you very much!</p>
it's a pitot tube. bassically you need a tube open at both ends. you then shrink the diameter of the half of the tube ( i did it by inserting another tube inside); you make two holes, one where the diameter is not shrunk and one where the diameter is shrunk. it's a bit diffcult to explain. it's a simplifice version, just search pitot tube and you will understand
<p>So which tube to be insert on the shrunk diameter? Impact tube or static tube? </p>
Thanks a lot for your explanations :) Really appreciate it!
<p>How sensor you finaly use&iexcl;? i bougth an mpx5700 but is a 100psi sensor :/ </p>
<p>Hi, anim2016 nice to meet you</p><p>i am appreciation for your made it,</p><p>I am also learning to make these tools but my difficulty with the spirometer tube design.</p><p>if you allow allow me know how you make the spirometer tube.</p><p>Thanks</p>
<p>Hi, </p><p>Please see above my explanation. It's not a spirometer tube it's a pitot tube. The device is called spirometer</p>
<p>may I Look Spirometer Code That your created.</p>
<p>anim2016, can i ask you one more question hihi sorryy .. what did she meant by . &quot;There is an equation included in the data sheet than can be used to calculate the pressure based on the output voltage.&quot; which equation in the datasheet that she manipulated to calculate the pressure?</p>
<p>you need to check the datasheet of the differential pressure sensor you are using. It depends on the manufacturer but it should be there for all of them. </p><p>In the datasheet the author attached (<a href="https://www.instructables.com/files/orig/FVI/NGSA/I8LGQQMG/FVINGSAI8LGQQMG.pdf" rel="nofollow">honeywell-sensing-asdx-series-analog-pressure-sensors-product sheet-008090-12-EN.pdf</a>) is the one highlighted in the attached picture.</p><p>Replacing the values in the ecuation you should get: pressure_psi = (15/2)*(volt-2.492669)</p><p>It's a simplified mathematical version. (e.g.: in the graph you see Pmax and Pmin 5% and 95% etc etc.. and you replace the values accordingly in the ecuation)</p>
Hi, <br>Please see picture for the pitot tube design.<br>The pitot tube is a device to measure the local velocity along a streamline. The pitot tube has two tubes: one is static tube(b), and another is impact tube(a). The opening of the impact tube is perpendicular to the flow direction. The opening of the static tube is parallel to the direction of flow. The two legs are connected to the legs of differential presure senzor for measuring small pressure differences. The static tube measures the static pressure, since there is no velocity component perpendicular to its opening. The impact tube measures both the static pressure and impact pressure (due to kinetic energy). In terms of heads the impact tube measures the static pressure head plus the velocity head.
Thankyou soo much.. your project was very informative and we have used your project as our base for our finalyear project and we've some doubts as well...Is there any specific model that should be used for the honeywell pressure sensor asdx series?<br>Awaiting your response... we would love to communicate to you through email as well please ping us at sakthigyanavel@gmail.com
excellent
hello <br>now i preparing for my project in my university and by search by google i found your work about spirometer but i have some of confuse about this project <br>i used pressure sensor with 2 input and max pressure 500 kpa <br>and by arduino i will calculate the volumes and air flow <br>please help me how i will choose a pipe ?
<p>Can you explain how you used the following formula in the code?</p><p>pressure_psi = (15/2)*(volt-2.492669); // Pressure in psi</p><p>How did you get 15/2?</p>
<p>The pins are identical ARDUINO based on version 3 as well ? I bought the complete form and thanks to this project I want to try for the first time Arduino . Hello and thanks.</p>
Hello Maria! Very nice project!<br>I am very interested to your project because I am a free diver an I would like to measure the pulmonary capacity variation with different kind of breath techniques.<br>Which sensor p/n did you used? How is precise? Thanks! ;)
<p>Hi MariaL7! Congrats for your project!I have a question and i will thank you very much if you can let me an answer.Can you show me a model of that tube? I push the air in that tube and i see the air is going to sensor on .The sensor have an out for the air? Thanks for your time !</p>
Do you use push button? Because I saw lcd.setCursor(0,1); button=analogRead(analogButton); in the code. FYI, im using normal yellow backlight LCD.
<p>Hi:) I'm doing a class project and my group and I were really interested in your design. We are slightly confused about the interior of the pipe, can you possibly post more photos or email them to me? (email: gwhang@ucsd.edu) Thank you :) Neat project by the way!</p>
Yes, very impressive. Although I love the clear way you have led us through the calculations, for the production version you might get speed gains and fewer rounding errors by combining the calculations more.<br>I can't agree more that the 2nd / 3rd world needs cheap medical tech.
<p>Thank you so much for your input- combining the calculations is an idea I'd definitely use if I were to improve this prototype in the future. </p>
<p>Awesome sauce!</p>
<p>Thank you Orlando!</p>
<p>Very impressive project, and expertly documented. I hope you'll share more of your projects here!</p>
<p>I remember having my lung capacity tested. Thanks for showing how it is done.</p>