Today we’re building a simple voltage divider where the output is read using an analog input on an Arduino Nano. I’m following a similar project that uses a thermistor instead of conductive cord.
We use the equation Vo = R / (R + 10K) * Vcc to measure the expected voltage output at various resistances. The conductive, resistive rubber cord has a resistance of 350-400 Ohms per inch (not very exact but fine for our prototyping needs). My fixed Resistor is a 10k (already in the equation above) and Vcc is 5v from my laptop to the Arduino.
Here is the simplified math:
ADC value = Vi * 1023 / Vcc
ADC value = R / (R + 10K) * Vcc * 1023 / Vcc
ADC value = R / (R + 10K) * 1023
R = 10K / (1023/ADC – 1)
We will test using the following code from the tutorial linked above.
We now want to measure two things:
breath volume
We can measure this by measuring the amount of time it takes to reach a peak (maximum value) from the baseline resistance.
breath rate
We can measure this by measuring the peak-to-peak time.
So far I’ve slightly modified the code so that it will tell me when the cord is measuring breath in and breath out or holding breath.