This DIY sensor will take the form of a conductive knitted stretch sensor. It will wrap around your chest/stomach, and when your chest/stomach expands and contracts so will the sensor, and consequently the input data that is fed to the Arduino. So keep in mind this isn't a totally accurate way to track every breath, and sometimes the movements of the body can influence the sensor to since it is all about how it stretches. Also, in terms of stability, I've found the range of numbers can jump around quite a bit if the sensor doesn't remain a consistent tightness around the body, but if you are just standing and breathing it is pretty accurate/sensitive at picking up the slight expansion of the chest for each breath.
There are quite a few DIY breath sensors I've found while researching on the internet, but they do not have all the specific information needed to get one made and connected to the Arduino yourself. Here are some of those sources I've pieced together to give you the full story in this tutorial:
http://www.kobakant.at/DIY/?p=1762
http://cargocollective.com/nelramon/i-Breathe
https://hackingthebody.wordpress.com/2014/01/03/bluetooth-stretch-breath-sensor/
http://itp.nyu.edu/~ek1669/blog/?p=769
Please Note: I am only a novice of electricity/circuits/arduino/coding, so I welcome any suggestions or corrections if you find any!
Materials/Tools:
Begin by knitting a 2" wide band combining both the conductive yarn and elastic yarn.
Knit with the conductive and elastic yarn as if it was one piece of yarn!
You can use a standard stitch. My band was 10 stitches across and about 30 inches long.
If you don't know how to knit, Youtube is your friend. :) **Tip: Find videos that are specific to your dominant hand. This one helped me: https://www.youtube.com/watch?v=b21msW3cS34
Flip over your band and sew the other matching velcro (the soft half, if you used the hard half on the other side) onto the other end of your knitted band. You'll want the length of this velcro to be a bit longer, approx. 7 inches.
*** Before you sew make sure when you wrap the band around yourself the velcro halves match up!
Use the photos on this step to wire up your Arduino to the sensor.
Attach 2 alligator clips to the knitted band, one on each end. The amount of stretch will only be measured between these 2 points. ** Be sure to clip the band securely and choose a spot where a lot of the conductive yarn is exposed, it is essential for the conductive yarn and metal clip to make contact (I've tried to check this connection with the Volt Meter, but I've found even if it is working it doesn't necessarily show that it is on the Volt Meter, I recommend wiring up the whole circuit and then seeing what the numbers look like in your serial monitor to see if it is working) **
Use this Analog Input Tutorial provided by Arduino to help wire up your circuit. (Just substitute the photosensitive resistor with the knitted band + alligator clips, and it's the exact diagram/schematic you need).
If you've never used Arduino before please refer to this "getting started" page and download the Arduino Software (it's free!).
Once you have the software downloaded on your computer, open up the program and follow these steps:
TROUBLE SHOOTING TIPS IF YOU DON'T SEE A STREAM OF NUMBERS:
Wrap it around yourself and monitor the numbers while you breath! You may need to try different resistors to get the right range of numbers that work for your specific project.
Experiment putting the band round different areas of your chest/stomach. You'll probablly need longer wires than the alligator clips once it is around yourself. I think it works best under your clothes, or on top of unbaggy clothes.
Now you can take this code and sensor and modify it however you want, and apply it in a lot of different ways!
Example idea: Make an LED change brightness with each breath.