I have an Arduino UNO R3 board. I am trying to connect "stretch sensor" which is DIY with conductive fiber and I am getting its resistance reading from it. Reading are fine, linear when I breath and so on. But when I connect LilyPad temperature sensor from SparkFun, it is all messy. Resistance jumping up and down for more then 10k Ohm even when I don't move or breath ( holding my breath ). This only happen's when I connect my temperature sensor as I said.
Let me tell ya I am no any kind of expert of electronic. Working with Arduino board for a very first time.
My Arduino is connect to my laptop. So that is also way he get power supply.
Simple electric scheme how I connect elements :
And my code looks like :
// Tempererature analog pin
const int tempPin = A0;
int num_samples = 10; // Number of samples before measure temperature!
// Stretch pin's
const int stretchPin = A5;
const long int R1_resistor = 593000; // Resistor 600k ohm (593k ohm measured with Ohm-meter)
void setup() {
Serial.begin(9600);
}
void loop() {
temperature();
delay(200);
stretch();
delay(500);
}
/*
LEGENDs :
S = stretch
T = temperature
*/
void sendData(char symbol, float number) {
Serial.print(symbol);
Serial.println(number);
}
//Stretch sensor
void stretch () {
int raw = 0;
int V_in = 5;
float V_out = 0;
float R2_resistor = 0;
float buffer = 0;
raw = analogRead(stretchPin);
if(raw) {
buffer = raw * V_in;
V_out = (buffer) / 1023.0;
buffer = (V_in / V_out) -1;
R2_resistor = R1_resistor * buffer;
sendData('S', R2_resistor);
}
}
// Temperature measure!
void temperature () {
int total = 0;
float temp;
for(int i = 0; i < num_samples; i++) {
total += analogRead(tempPin);
delay(5);
}
float v = total * 4.9 / 1024.0; // 4.93 volt measure
temp = ((v - 0-5) * 100) / num_samples
sendData('T', temp);
} // End of.emperature
}
Could you help me out with my project ? I been stuck at this for a while now. Thank you.
I gona provide some graphs so you could see better.
This is how "graph" looks like without temperature sensor connected to Arduino. It shows right on breath taking.
And this picture shows "graph" with temperature sensor connected. It's messy and at some points could say I take breath even I did not. When I did is marked with red.
EDIT: pictures don't wanna show. Added links to them.
Greetings, Marko!
