Introduction: Low Cost Spirometer

Picture of Low Cost Spirometer

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!


-PVC pipe

-Plastic tubing


-Pressure sensor (see Step 2)

-Arduino Uno

-Arduino compatible LCD screen


-Micro USB cable



Step 1: Construct a Spirometer Tube

Picture of 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: 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

Picture of 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:

inputVolt = analogRead(analogInPin); // Voltage read in (0 to 1023)

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:


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;


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!


anim2016 made it! (author)2016-04-13


I made it :)

A few notes observations:

- need a potentiometer to increase LCD brightness

- 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
100psi sensor you'll only be using around 2% of its range. This means
you'll only get around 2% of the 5 volt output range (0.1 volts). This
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)

- 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.

@author thank you for this :)

nasyun24 (author)anim20162016-05-15

anim2016, can i ask you one more question hihi sorryy .. what did she meant by . "There is an equation included in the data sheet than can be used to calculate the pressure based on the output voltage." which equation in the datasheet that she manipulated to calculate the pressure?

anim2016 (author)nasyun242016-05-18

Please see picture for the pitot tube design.
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.

abuhafss (author)anim20162017-11-02

I think you have labelled the tubes wrong.
If the impact tube is to be perpendicular to the flow direction it should be (b) and the static tube should be (a).

anim2016 made it! (author)nasyun242016-05-19

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.

In the datasheet the author attached (honeywell-sensing-asdx-series-analog-pressure-sensors-product sheet-008090-12-EN.pdf) is the one highlighted in the attached picture.

Replacing the values in the ecuation you should get: pressure_psi = (15/2)*(volt-2.492669)

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)

nasyun24 (author)anim20162016-05-01

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!

anim2016 (author)nasyun242016-05-01

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

abuhafss (author)anim20162017-11-02

Can you provide some more details about the construction of the pitot tube? The diameters, the distances a, b, e; the heights c & d. Here is the diagram of the tube what I understand from the details provided herein. Please let me know if I understood it correctly?

Nazrin13 (author)anim20162016-11-19

So which tube to be insert on the shrunk diameter? Impact tube or static tube?

nasyun24 (author)nasyun242016-05-01

Thanks a lot for your explanations :) Really appreciate it!

Luis RodolfoP (author)anim20162017-05-29

Hi, do you have more photos of the Breadboard? because I think I'm connecting something wrong.

EmmanuelE21 (author)anim20162016-10-21

How sensor you finaly use¡? i bougth an mpx5700 but is a 100psi sensor :/

number251 (author)anim20162016-04-25

Hi, anim2016 nice to meet you

i am appreciation for your made it,

I am also learning to make these tools but my difficulty with the spirometer tube design.

if you allow allow me know how you make the spirometer tube.


anim2016 (author)number2512016-05-18


Please see above my explanation. It's not a spirometer tube it's a pitot tube. The device is called spirometer

number251 (author)anim20162016-10-12

may I Look Spirometer Code That your created.

abuhafss (author)2017-11-02

I was wondering if I can use two separate pressure sensors like MPS20N0040D could be used to get differential pressure?

mhasanpour made it! (author)2017-03-31

That was great. Thank you soooooo much

Luis RodolfoP (author)mhasanpour2017-06-04

Hi, How did you do the mask?

Niraimathy (author)2016-12-29

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?
Awaiting your response... we would love to communicate to you through email as well please ping us at

Mohammad RezaH1 (author)2016-12-08


ashrafsy16 (author)2016-12-05

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
i used pressure sensor with 2 input and max pressure 500 kpa
and by arduino i will calculate the volumes and air flow
please help me how i will choose a pipe ?

CadisEtramaDiRaizel (author)2016-09-22

Can you explain how you used the following formula in the code?

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

How did you get 15/2?

Pierpa_76 (author)2016-07-29

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.

LucaR18 (author)2016-04-08

Hello Maria! Very nice project!
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.
Which sensor p/n did you used? How is precise? Thanks! ;)

SurduM (author)2016-02-28

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 !

CameronH21 (author)2015-11-25

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.

GraceW3 (author)2015-05-30

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: Thank you :) Neat project by the way!

emason (author)2015-04-20

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.
I can't agree more that the 2nd / 3rd world needs cheap medical tech.

MariaL7 (author)emason2015-04-20

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.

ohoilett (author)2015-04-19

Awesome sauce!

MariaL7 (author)ohoilett2015-04-19

Thank you Orlando!

seamster (author)2015-04-19

Very impressive project, and expertly documented. I hope you'll share more of your projects here!

acheide (author)2015-04-18

I remember having my lung capacity tested. Thanks for showing how it is done.

About This Instructable




More by MariaL7:Low Cost Spirometer
Add instructable to: