For a Biomedical Instrumentation class at my university, we decided to build a simple spirometer. Below are step-by-step instructions on how to construct your own low-cost spirometer. The spirometer was designed to calculate vital capacity of the person blowing into the tube and display the results on an Arduino LCD display. This device could be used to detect any abnormalities in lung volume.
Step 1: Materials
- 1 ft 1.5'' PVC pipe
- 0.5 ft 5/16'' flexible tubing
- Foam Circle
- Flexible Tubing to connect tube to sensor
- ASDX Series Silicon Pressure Sensor (photo above, see data sheet for more info)
- Arduino Uno
- Arduino LiquidCrystal LCD screen
Step 2: Building the Tube
Step 1: Two holes were drilled into the side of the 1.5” PVC pipe each a about 1-2” inches from each end. These served as the connecting points from the device to the sensor itself.
Step 2: A doughnut-shaped plug was made from foam using a wire foam cutter. The 5/16” diameter flexible tubing was inserted through the foam plug at one end so that about a half inch of tubing protruded from one side of the plug. The other end of the tubing was connected to one of the arms of a t-joint.
Step 3: The plug with the 5/16” tubing was inserted into the 1.5” PVC pipe and pushed through until the plug was resting at about half-way through the pipe. The perpendicular arm of the T-joint was pushed through one of the holes from the inside and connected to one sensor input with flexible tubing while the other arm remained open.
Step 4: The plug was then sealed from the side containing the T-joint using rubber cement. Hot glue was used to attach a length of flexible tubing to the remaining hole in the PVC pipe in order to connect it to the other sensor input. This was all left to dry for several hours, but the time depends on how long it takes for the rubber cement to set.
Step 3: Code
Step 1: Convert the digital output of the Arduino into a voltage.
volt = inputVolt*(source/1023)
Step 2: Convert the voltage into psi using the equation provided by the pressure sensor data sheet.
psi = -3.75*(0.49-volt); // Note that 0.49 was used instead of 0.5V because our sensor output 0.49V when there was no difference in pressures.
Step 3: Convert Psi to Pa
pa = abs(psi*6894.75729);
Step 4: Calculate volumetric flow by rearranging the Bernoulli equation. The areas were calculated based on our specific tube measurements.
volumeFlow = pow(10,3)*sqrt((2*pa/(rho*abs(1/pow(area1,2)-1/pow(area2,2)))));
Step 5: Integrate the volumetric flow by multiplying the flow by a small time step (dt)
volume = volumeFlow*dt + volume;
Two buttons on the LCD screen were also coded.
The first was an "run" button that while pressed would allow measurements to be taken, and the second was a reset button that when pushed would reset all measurements to zero. Example code was used to determine the digital threshold values associated with each button through trial and error (link below). Then, if statements were used to designate parts of the code to different buttons. Which buttons you choose for these function does not matter. We chose the left button for the "run" function and the left for the reset button.
Button code source: https://create.arduino.cc/projecthub/niftyjoeman/osepp-lcd-and-keypad-shield-d5b46e
The pdf attached should display exactly how we went about writing our code.
Step 4: Circuit
The circuit was very simply wired. The first pin on the sensor was connected to the 5V input on the Arduino, the second pin was connected to A1 input, and the third pin was connected to ground on the Arduino as well. Once you have connected the sensor to the Arduino, attach the tube to the two inputs of the sensor and you are done!
To use the spirometer, upload the code and blow into the tube while simultaneously holding down the left button. Keep holding the left button until you run out air before letting go. The LCD screen should display the volume of air you blew into the tube. Press the "right" button to reset the device.
And now you're done! Hope this instructables will help you build your own spirometer!
4 years ago
can i use two separate MPS20N0040D sensor to measure differential pressure ?
5 years ago
Thanks for sharing :)