Go Down

Topic: Pulse sensor and Temperature Sensor (Need Help!!!) (Read 2494 times) previous topic - next topic

cute-98

I am creating a sensor that are able to detect pulse rate (Pulse sensor amped : http://pulsesensor.myshopify.com/products/pulse-sensor-amped) and body temperature (LM35) and send the result wirelessly using XBee.

The component I used are:
1. Arduino Uno - R3
2. XBee Shield v1.1 - Enhanced XBee Breakout for Arduino
3. Xbee USB Adapter
4. XBee 1mW Wire Antenna - Series 1

So what I do is, Put the XBee Shield v1.1 on top of Arduino UNO-R3 with XBee 1mW Wire Antenna attached to it.
Then connect jumper wire from the Xbee Shield to breadboard, connect the LM35 ad pulse sensor both to the breadboard.

But I came across some problem.

1st the pulse sensor is not working correctly. It give wrong reading. Here are the code:
Code: [Select]

unsigned char pin = 13;
unsigned char counter=0;
unsigned int heart_rate=0;
unsigned long temp[21];
unsigned long sub=0;
volatile unsigned char state = LOW;
bool data_effect=true;
const int max_heartpluse_duty=2000;//you can change it follow your system's request.2000 meams 2 seconds.
//System return error if the duty overtrip 2 second.

void setup()
{
pinMode(pin, OUTPUT);
Serial.begin(9600);
Serial.println("Please ready your eat clip.");
delay(5000);
array_init();
Serial.println("Heart rate test begin.");
attachInterrupt(1, interrupt, RISING);//set interrupt 0,digital port 2
}

void loop()
{
digitalWrite(pin, state);
}

void sum()//calculate the heart rate
{
if(data_effect)
{
heart_rate=120000/(temp[20]-temp[0]);//6*20*1000/20_total_time
Serial.print("Heart_rate_is:\t");
Serial.println(heart_rate);
}
data_effect=1;//sign bit
}

void interrupt()
{
temp[counter]=millis();
state = !state;
Serial.println(counter,DEC);
Serial.println(temp[counter]);
switch(counter)
{
case(0):
sub=temp[counter]-temp[20];
Serial.println(sub);
break;
default:
sub=temp[counter]-temp[counter-1];
Serial.println(sub);
break;
}
if(sub>max_heartpluse_duty)//set 2 seconds as max heart pluse duty
{
data_effect=0;//sign bit
counter=0;
Serial.println("Heart rate measure error,test will restart!" );
array_init();
}
if (counter==20&&;data_effect)
{
counter=0;
sum();
}
else if(counter!=20&&;data_effect)
counter++;
else
{
counter=0;
data_effect=1;
}
}

void array_init()
{
for(unsigned char i=0;i!=20;++i)
{
temp[i]=0;
}
temp[20]=millis();
}



2nd, the temperature sensor (LM35) is working properly before I attached the XBEE, but after I attached the XBee, it give wrong temperature numbers. Do I need to do any voltage adjustment or stuff like that? Here is my code for the temperature sensor:

Code: [Select]

int potPin = 0;
float temperature = 0;
void setup()
{
Serial.begin(9600);
Serial.println("LM35 Thermometer ");
analogReference(INTERNAL);
}
void printTenths(int value) {
// prints a value of 123 as 12.3
Serial.print(value / 10);
Serial.print(".");
Serial.println(value % 10);
}
void loop() {
int span = 20;
int aRead = 0;
for (int i = 0; i < span; i++) {
aRead = aRead+analogRead(potPin);
}
aRead = aRead / 20;
temperature = ((100*1.1*aRead)/1024)*10;
// convert voltage to temperature
Serial.print("Analog in reading: ");
Serial.print(long(aRead));
// print temperature value on serial monitor
Serial.print(" - Calculated Temp: ");
printTenths(long(temperature));
delay(500);
}




ali_jamil

hi , i'm doing same project as you exactly
:smiley-eek:
i hope someone can help us about this project
:D

cute , i send you my email , i hope u can add me so we talk about project

:)
thanks

Erdin

#2
Mar 13, 2013, 09:46 am Last Edit: Mar 13, 2013, 09:49 am by Erdin Reason: 1
This was an older post of 2 month ago.
@cute-98, sorry no one replied to this.

You created two small test sketches to get the sensors working. Very good. That's how it should be done.

Did you know about the tutorial at Adafruit, http://www.adafruit.com/products/1093
There is also a great video.
For an older or inactive person or someone with a darker skin the detection is less. So you might try a few things.

The LM35 is very simple, it can't go wrong. But you power it with the USB. If the voltage drops a little the analog reading changes.
This was the same problem, http://arduino.cc/forum/index.php/topic,153556.msg1152036.html

sdcompeng

i am currently doing the same project as you. did you have any luck? also can you email me with any tips or problems that you ran into?

Go Up