In the biosensing world, there are many ways to measure respiration. One can use a thermistor to measure the temperature around the nostril, but then again maybe you don't want a weird implement strapped to your nose. One can also attach an accelerometer to a belt that moves up and down, but the subject probably should be lying down or not otherwise moving. While this basic, flexible band belt respiration sensor has its drawbacks (the signal response isn't as accurate as other methods), it's good for if your subject just wants to strap in and down whatever it is that they do while their breath is being measured.
Here’s an example of a basic respiration sensor, which is intended to live inside of a flexible belt that you strap around a chest. When the chest in question expands and contracts through breathing air into the lungs, the resistance of an incorporated piece of stretchable rubber cord changes. Using just a few more components, we can translate this into an analog signal read live by your Arduino. This is done through the magic of the very essential and easy to learn voltage divider circuit.
WARNING: Before we begin, you should know that untested and unstable biosensing equipment always contains a risk of danger! Please test and create this circuit with a source of battery power- I will do everything to show you how to make this circuit to make sure you won’t be harmed, but I assume no responsibility for accidents that may occur. Use common sense and always test your circuit with a multimeter before strapping anything onto your chest.
Step 1: Step 1: WHAT YOU WILL NEED
1) Any microcontroller with an analog input will work, but in this example I will use an Arduino Uno. If you need one, you can get it from Adafruit or Sparkfun.
2) Conductive Rubber Cord. This amazing cord will act as a variable resistor, and will change in resistance as it is stretched or released. Available from Adafruit, or Robotshop has a nice variety of lengths with pre-attached metal endings
3) A multimeter
4) An LED
5) A 1K resistor
6) A pull-down resistor (we will figure out what the value of this is later!)
7) Duct tape
8) A hole punch or pair of scissors
9) Jumper wires
10) A breadboard
11) 2 Alligator clips
Please note that as with all biosensing equipment, this project is safest if your Arduino is powered from batteries.
To complete this project you may also need:
· Soldering iron and solder
· Hot glue gun
· Wire snips
· Wire stripper
· Helping Hands
· Vice, crimp tool, or a large pair of pliers
· 2 or more Ringed Crimp Terminals
Step 2: STEP 2 – Cut the Cord, and Attach Conductive Terminals
While you can use any length of rubber cord from 2”-8” for this experiment, shorter lengths of rubber are cheaper and you don’t actually need a super large amount to get the job done. If you purchased a long length of rubber then I would recommend cutting a 4” length. Cut this length and get ready to attach a conductive ending to both ends.
Take a terminal connector, such as one of them pictured above, and stick one end of the conductive rubber cord inside the end of one of your terminal connectors, and crimp the end together. You can use either a vice or the ends of your wire strippers to do this, but be careful not to squish the terminal too tightly lest you snap or cut your rubber! If you do manage to do this, and the cord cuts off, just try again with another terminal connector. You still should have plenty of length to accomplish this feat. If it gets shorter than 2” you should probably just try again with a new 4” length. Don’t worry, you’ll get it! Once you have accomplished this on one side, brilliant! Repeat on the other side. Now you are done!
Now you have a conductive rubber cord with a suitable terminal on each end. Let’s measure what the ranges of this cord are with a multimeter.
Step 3: Step 3: Measure Your Resistance!
Turn the dial of your multimeter to the ohm symbol (Ω) and stick both the red and the black ends of your multimeter into either side of your conductive cord.
If you are not sure how to use your multimeter yet, you can freshen up with this tutorial from Lady Ada.
Even though the number might jump around a little while you are measuring it, these numbers give you an idea of how much the resistance of the cord is when it is at rest. Taking your best guess, write down the at-rest resistance of your cord, then round it to the nearest multiple of 10. (ie: 239 = 240, 183 = 180)
Now, being careful to fix the multimeter probes in place with one hand, use your other hand to gently pull up on the cord. You can only stretch this stuff until it is about 50%-70% of its original length, so don’t pull too hard! Observe how the resistance values on your multimeter have changed. Let go, and repeat this process a few times to watch the resistance go from its minimum to its maximum. As you stretch it out, the resistance increases because the particles in the rubber are moved farther apart. Once the force is released, the rubber will shrink back, although it takes a minute or two to revert to its original length. Because of these physical limitations this stretchy cord is not a true linear sensor, so it isn’t amazingly precise but there are ways to work with this in the construction of your sensor. Stretch the cord once more to its maximum, and with each end of the multimeter probes in place on either side of your rubber cord, write down the resistance value, rounded once more to nearest multiple of 10.
Step 4: Step 4: Axel Benz Formula
We are going to use a simple voltage dividing circuit in order to use the variable resistance of the stretch cord as a respiration sensor. If you would like to know more about voltage dividing circuits, it’s basically a few resistors in series that turn a large voltage into a smaller one. Depending on the values of the resistors you use, you can chop your 5V out from your Arduino into larger or smaller portions of itself with a pull-down resistor, which is useful for Analog Read. If you would like to learn more about the math behind voltage dividing circuits, take a look at the excellent tutorial at Sparkfun.
While we know that the value of the first resistor in the circuit (the stretch sensor) will be in constant flux, we need to use a proper resistance value for the pull-down resistor in order to get as nice and varied a signal as possible.
To start, use the Axel Benz formula:
Pull-Down-Resistor = squareroot(Rmin * Rmax)
So if the minimum value of your stretch cord is 130ohms, and the maximum is 240ohms
Pull-Down Resistor = squareroot(130*240)
Pull-Down Resistor = squareroot(31200)
Pull-Down Resistor = 176.635217327
So now you should be looking at your resistor collection and figuring out what your best-case resistor “for now” is. If you just have a collection of random bits and bobs, this resistor colour band calculator might be helpful for you. Ballparking this resistor can be ok, you probably don’t have the perfect resistor on-hand. While you are using the circuit you might find that you have to swap it out for another one anyways, but this will give you a great start to start playing.
Finally, I round the number to the nearest multiple of 10.
Pull Down Resistor = 180ohms.
Step 5: Step 5: Prepare Your Breadboard!
Using jumper wires, connect the 5v pin of the Arduino to your power rail on your breadboard, and then connect a GND pin to the ground rail of your breadboard.
I like to draw 5V from the Arduino because this ensures that you don’t have to worry about sending too much of a voltage to the analog pins. You can also use the 3v3 voltage pin, but I find that I get a better signal from using 5v.
Connect your pull-down resistor to ground.
Take both of your alligator clips and clip them to the terminals on both sides of your variable resistance stretchy cord. Attach one end of these alligator clips to the 5v rail. Connect the other alligator clip to a wire in the configuration demonstrated in the diagrams.
Making sure that the “other” ends of your pull-down resistor and your conductive stretch cord are connected, now connect a jumper wire from an analog pin (let’s use A0) to the center of these two connecting points.
Finally, attached an LED with a 1k resistor to pin 9 of your Arduino.
Step 6: Step 6: Program Your Arduino
Now run the attached "RespSensorTest.ino" sketch on your Arduino.
Being careful not to touch the exposed metal, pick up your two alligator clips and stretch the rubber band. Watch the LED fade in and out as you stretch. Open up your Serial Monitor, and watch your analog voltage change. If you are not happy with the fading values or your numbers, you can try a few things:
1) Try swapping out another pull-down resistor value that is similar to the last one you used. Does it make a positive difference? (This is the best way to do it)
2) If all you really want to do is light the LED, try fiddling with the scaleValue variable to see if you can produce better ranges that way. (This might be the easiest way to do it)
Once you are happy enough with your numbers and LED glow, it’s time to prototype a model for wearing around your chest! Turn off your Arduino and disable power to the breadboard for the next step.
Step 7: Step 7: Make a Prototype Respiration Band!
The quickest way to make a prototype band is to just jig something together with duct tape. Take a long strip of duct tape (About 30”-36” should cover most, but ultimately this is just the circumference of your chest) and fold it so the sticky sides stick to itself. Punch holes into either side of your duct tape strip, so it resembles a belt.
Use screws to secure the terminals into the punched holes that you made for your sensor, and snugly connect your long piece of duct tape into a loop that you wear across your chest. You want to make sure that your “belt” fits pretty snug across you or your subject’s solar plexus, but make sure that there is enough room for incoming breaths to stretch the cord.
Finally, reattach your alligator clips and plug each of the jumpers from the end of the conductive stretch cord back into place in the breadboard. We are now ready to test the prototype!
Step 8: Step 8: Test Out the Prototype!
Turn on the Arduino and run the previous sketch
again. How are those analog values doing? Are you getting a nice resolution of data with your breaths? Does the LED have a nice variance of light as you breathe in and out? If not, try swapping out your pull-down resistor for a nearby value to see if the values that you read get any better.
When you have settled on the ideal pull-down resistor, rejoice! Your circuit is complete, your respiration is being recorded, and the LED will happily follow your breath.
Ideally either you or someone else will eventually sew a band for you out of non-conductive synthetic fabric with a little bit of stretch in it itself, and a D-Ring belt to tighten. (Velcro is ok as a fastener but it's a total mess with clothing and sweaters sometimes.) You can safely sew the conductive cord into this band, in fact the circular terminals are great to fasten to a fabric. For something a bit more permanent than alligator clips, you might want to simply solder a few very long multi-stranded wires to the ends of the terminal connectors and attach these to your circuit.