Saturday, 30 July 2016

HEART BEAT PROJECT USING ATMEGA328

HEART BEAT PROJECT USING ATMEGA328P


PROJECT DESCRIPTION:

Heart rate, body temperature and blood pressure monitoring are very important parameters of human body. Doctors use various kind of medical apparatus like thermometer for checking fever or body temperature, BP monitor for blood pressure measurement and heart rate monitor for heart rate measurement.  Here we have used a heartbeat sensor module which senses the heartbeat by the pulse in ear, Heart rate ear clip kit contain a ear clip and a receiver module. The heart rate measure kit can be used to monitor heart rate of patient and athlete. The result can be displayed on a screen via the serial port and can be saved for analysis. The entire system has a high sensitivity, low power consumption and is very portable.

This simple project will allow you to visualize your heart rate result  through a  Bluetooth connection with an  android moblie phone using hc-06  Bluetooth module

COMPONENT:


  1. Atmega328p
  2. Heart rate ear clip
  3. LCD 16X 2
  4. Bluetooth module


Fig 1...  Heart rate ear clip






Fig 2...  HC-06 Bluetooth module





Fig 3... PCB design 


Fig 4... First test


Fig 5... Testing 1



Fig 6... Testing 2


Fig 7... Testing 3 

Here is the code:

//ACE TECHNOLOGY '15
//HEART BEAT AND BLUETOOTH RECIEVER
//AKINSINMIDE IMOLEAYO
//ATMEGA328
//ACECCT.BLOGSPOT.COM

// include the library code:
#include <LiquidCrystal.h>

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(5,6,7,8,9,10);

#include <SoftwareSerial.h>// import the serial library

SoftwareSerial Genotronex(12, 11); // RX, TX
int ledpin=13; // led on D13 will show blink on / off
int BluetoothData; // the data given from Computer

#define LED 4 //indicator, Grove - LED is connected with D4 of Arduino
boolean led_state = LOW;//state of LED, each time an external interrupt
                //will change the state of LED
unsigned char counter;
unsigned long temp[21];
unsigned long sub;
bool data_effect=true;
unsigned int heart_rate;//the measurement result of heart rate

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()
{
    Genotronex.begin(9600);
  Genotronex.println(" HEART RATE MONITORING PROJECT ");
  delay (500);
  Genotronex.println(" BLUETOOTH DEVICE CONNECTED... "); 
  pinMode(ledpin,OUTPUT);
 delay (1000); // delay for lcd to boot up
    // initialize LCD and set up the number of columns and rows:
  lcd.begin(16, 2);
  delay (1000);
 
  lcd.clear();
  lcd.setCursor(0,0);
  lcd.print("   HEART RATE   ");
  lcd.setCursor(0,1);
  lcd.print("    MONITOR     ");
  delay (2500);
   Genotronex.println(" HEART RATE MONITORING PROJECT ");

  pinMode(LED, OUTPUT);
  Serial.begin(9600);
  arrayInit();
    lcd.clear();
  lcd.setCursor(0,0);
  lcd.print("   HEART RATE   ");
  lcd.setCursor(0,1);
  lcd.print(" TEST BEGIN.... ");
 
   Genotronex.println(" SCANNING PULSE BEGIN..... ");

  delay (2500);
  attachInterrupt(0, interrupt, RISING);//set interrupt 0,digital port 2



}
void loop()
{
  digitalWrite(LED, led_state);//Update the state of the indicator
}
/*Function: calculate the heart rate*/
void sum()
{
 if(data_effect)
    {
      heart_rate=1200000/(temp[20]-temp[0]);//60*20*1000/20_total_time
          lcd.clear();
    lcd.setCursor(0,1);
    lcd.print("Heartrate_is: ");
    lcd.print(heart_rate);
   Genotronex.println(" YOUR HEART_RATE IS: ");
   Genotronex.println(heart_rate);

   delay (1000);
    }
   data_effect=1;//sign bit
}
/*Function: Interrupt service routine.Get the sigal from the external interrupt*/
void interrupt()
{
    temp[counter]=millis();
  Serial.println(counter,DEC);    Serial.println(temp[counter]);
    digitalWrite(13, HIGH);
        lcd.clear();
  lcd.setCursor(0,0);
  lcd.print(" SCANNING ......");
      lcd.setCursor(0,1);
    lcd.print("Heartrate_is: ");
    lcd.print(heart_rate);
  delay (50);
 digitalWrite(13, LOW );
    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;
       Genotronex.println(" HEART BEAT SENSOR IS NOT WELL CONNECTED.. ");
    lcd.clear();
  lcd.setCursor(0,0);
  lcd.print("   HEART RATE   ");
  lcd.setCursor(0,1);
  lcd.print("  READS  ERROR  ");
  delay (2500);
arrayInit();
  }
    if (counter==20&&data_effect)
    {
    counter=0;
    sum();
    }
    else if(counter!=20&&data_effect)
    counter++;
    else
    {
    counter=0;
    data_effect=1;
    }
   
}
/*Function: Initialization for the array(temp)*/
void arrayInit()
{
  for(unsigned char i=0;i < 20;i ++)
  {
    temp[i]=0;
  }
  temp[20]=millis();
}
 


 If you have any question, feel free to comment on this post.... acecct.18f4550@gmail.com OR whatsapp me on :  +2348123206299
 
Heart rate project complete file can be downloaded  in the link below:
Link: Pcb design and code

2 comments:

  1. There is lot of articles on the web about this. But I like yours more, although i found one that’s more descriptive.

    biometrics access control

    ReplyDelete

Featured post

PURE SINE WAVE INVERTER WITH LED AND LCD

The inverter PCB is easy to assemble by following the label of the components to be inserted. The choice of the voltage to be used to power ...