arduino based heartbeat monitoring system

24
Micro Project ArDUiNo BASeD HeArtBeAt MoNitoriNG SYSteM An additional experiment to satisfy P.O. & P.E.O. of CSE dept. Communication Engg & Coding Theory RCC Institute of Information Technology

Upload: arkadeep-dey

Post on 22-Jan-2018

536 views

Category:

Technology


2 download

TRANSCRIPT

Page 1: Arduino based heartbeat monitoring system

v

Micro Project

ArDUiNo BASeD HeArtBeAt MoNitoriNG SYSteM

An additional experiment to satisfy P.O. & P.E.O. of CSE dept.

Communication Engg & Coding Theory

RCC Institute of Information Technology

Page 2: Arduino based heartbeat monitoring system

1 | P a g e

RCC Institute of Information Technology

A Micro Project

oN ArDUiNo BASeD HeArtBeAt MoNitoriNG

SYSteM.

An additional experiment to satisfy P.O. & P.E.O. of CSE dept. Communication Engineering & Coding Theory (CS401)

Submitted to

Parama Bagchi

Assistant Professor

Department of Computer Science and Technology

RCC Institute of Information Technology

Submitted By

Arkadeep Dey (CSE2015/030)

Kaustav Mondal (CSE2015/016)

Portret Mallick (CSE2015/012)

Department of Computer Science and Technology

RCC Institute of Information Technology

Page 3: Arduino based heartbeat monitoring system

2 | P a g e

TABLE OF CONTENTS

CONTENTS PAGE NO.

I. GROUP DETAILS 03

II. ACKNOWLEDGEMENT 04 III. ABSTRACT 05 IV. INTRODUCTION 06 V. THE BENEFITS OF THE PROJECT 07

VI. HARDWARES USED 07 VII. ARDUINO UNO 08

VIII. DIFFERENT PARTS OF ARDUINO UNO 09 IX. PULSE SENSOR 10 X. LCD DISPLAY 11

XI. SOFTWARES USED 12 XII. CIRCUIT SCHEMATIC 13

XIII. PROCIDURE 14 XIV. ARDINO CODE 15 XV. PHOTO OF THE PROJECT 21

XVI. CONCLUTION 22 XVII. RESOURSE 22

I. GROUP DETAILS

Page 4: Arduino based heartbeat monitoring system

3 | P a g e

LEADER ARKADEEP DEY

ROLL NO : CSE2015/030 UNIVERCITY ROLL NO. : 11700115017 YEAR:2ND YEAR (4TH SEMESTER)

MEMBERS Kaustav Moldal

ROLL NO : CSE2015/016 UNIVERCITY ROLL NO. : 11700115035 YEAR:2ND YEAR (4TH SEMESTER)

Portret Mallick ROLL NO : CSE2015/012 UNIVERCITY ROLL NO. : 11700115043 YEAR:2ND YEAR (4TH SEMESTER)

Paper: Communication Engineering & Coding Theory

Paper Code: CS401

Page 5: Arduino based heartbeat monitoring system

4 | P a g e

II. ACKNOWLEDGEMENT

In performing our assignment, we had to take the help and guideline of some respected persons, who deserve our greatest gratitude. The completion of this assignment gives us much Pleasure. We would like to show our gratitude Parama Bagchi, Assistant Professor, The Department of Computer Science and Technology, RCC Institute of Information Technology for giving us a good guideline for assignment throughout numerous consultations. We would also like to expand our deepest gratitude to all those who have directly and indirectly guided us in writing this assignment.

In addition, a thank you to Mr. Dipankar Khorat, who introduced us to the Methodology of work, and whose passion for the “underlying structures” had lasting effect . Many people, especially our classmates and team members itself, have made valuable comment suggestions on this proposal which gave us an inspiration to improve our assignment. We thank all the people for their help directly and indirectly to complete our assignment.

Page 6: Arduino based heartbeat monitoring system

5 | P a g e

III. ABSTRACT

Technological innovations in the field of disease prevention and

maintenance of patient health have enabled the evolution of fields such as monitoring systems. Heart rate is a very vital health parameter that is directly related to the soundness of the human cardiovascular system. Heart rate is the number of times the heart beats per minute, reflects different physiological conditions such as biological workload, stress at work and concentration on tasks, drowsiness and the active state of the autonomic nervous system. It can be measured either by the ECG waveform or by sensing the pulse - the rhythmic expansion and contraction of an artery as blood is forced through it by the regular contractions of the heart. The pulse can be felt from those areas where the artery is close to the skin. This paper describes a technique of measuring the heart rate through a fingertip and Arduino. It is based on the principal of photophelthysmography (PPG) which is non-invasive method of measuring the variation in blood volume in tissue using a light source and detector. While the heart is beating, it is actually pumping blood throughout the body, and that makes the blood volume inside the finger artery to change too. This fluctuation of blood can be detected through an optical sensing mechanism placed around the fingertip. The signal can be amplified and is sent to Arduino with the help of serial port communication. With the help of processing software heart rate monitoring and counting is performed. The sensor unit consists of an infrared light-emitting-diode (IR LED) and a photo diode. The IR LED transmits an infrared light into the fingertip, a part of which is reflected back from the blood inside the finger arteries. The photo diode senses the portion of the light that is reflected back. The intensity of reflected light depends upon the blood volume inside the fingertip. So, every time the heart beats the amount of reflected infrared light changes, which can be detected by the photo diode. With a high gain amplifier, this little alteration in the amplitude of the reflected light can be converted into a pulse.

Page 7: Arduino based heartbeat monitoring system

6 | P a g e

IV. INTRODUCTION A heart rate monitor is a personal monitoring device that allows a subject to

measure their heart rate in real time or record their heart rate for later study. Early models consisted of a monitoring box with a set of electrode leads that attached to the chest. The heart rate of a healthy adult at rest is around 72 beats per minute (bpm) & Babies at around 120 bpm, while older children have heart rates at around 90 bpm. The heart rate rises gradually during exercises and returns slowly to the rest value after exercise. The rate when the pulse returns to normal is an indication of the fitness of the person. Lower than normal heart rates are usually an indication of a condition known as bradycardia, while higher is known as tachycardia. Heart rate is simply measured by placing the thumb over the subject’s arterial pulsation, and feeling, timing and counting the pulses usually in a 30 second period. Heart rate (bpm) of the subject is then found by multiplying the obtained number by 2. This method although simple, is not accurate and can give errors when the rate is high. More sophisticated methods to measure the heart rate utilize electronic techniques. Electro-cardiogram (ECG) is one of frequently used method for measuring the heart rate. But it is an expensive device. Low-cost devices in the form of wrist watches are also available for the instantaneous measurement of the heart rate. Such devices can give accurate measurements but their cost is usually in excess of several hundred dollars, making them uneconomical. So this heart rate monitor with a temperature sensor is definitely a useful instrument in knowing the pulse and the temperature of the subject or the patient.

Significance of Heart :

The heart acts as a pump that circulates oxygen and nutrient carrying blood around the body in order to keep it functioning. When the body is exerted the rate at which the heart beats will vary proportional to the amount of effort being exerted. By detecting the voltage created by the beating of the heart, its rate can be easily observed and used for a number of health purposes. Heart pounds to pump oxygen-rich blood to your muscles and to carry cell waste products away from your muscles. The heart rate gives a good indication during exercise routines of how effective that routine is improving your health.

Page 8: Arduino based heartbeat monitoring system

7 | P a g e

V. THE BENEFITS OF THE PROJECT

Why Monitoring……?

More than 2 million people are at high risk of having heart attack.

It would be helpful if there was a way for these people to monitor their heart.

So we have a problem. That is the way our project focuses on how we can utilize this problem and find a solution.

VI. HARDWARES USED

Arduino Uno Pulse sensor LCD display(16x2) Bread Board 10k potentiometer 1k resistors 220 ohm resistors Wi-Fi module ESP8266 LED Connecting wires Power adopter

Page 9: Arduino based heartbeat monitoring system

8 | P a g e

VII. ARDUINO UNO Arduino Uno is a microcontroller board based on the ATmega328P . It has 14 digital

input/output pins (of which 6 can be used as PWM outputs), 6 analog inputs, a 16

MHz quartz crystal, a USB connection, a power jack, an ICSP(In Circuit Serial

Programmer) header and a reset button.

Features:

• ATmega328 microcontroller

• Input voltage - 7-12V

• 14 Digital I/O Pins (6 PWM outputs)

• 6 Analog Inputs

• 32k Flash Memory

• 16Mhz Clock Speed

• SRAM 2 KB

• EEPROM 1KB

Operating Voltage 5V

Page 10: Arduino based heartbeat monitoring system

9 | P a g e

VIII. DIFFERENT PARTS OF ARDUINO

UNO

Power (USB / Barrel Jack)

Pins (5V, 3.3V, GND, Analog, Digital, PWM, AREF)

Reset Button

Power LED Indicator

TX RX LEDs

Main IC

Voltage Regulator

Page 11: Arduino based heartbeat monitoring system

10 | P a g e

IX. Pulse Sensor

The Pulse Sensor Amped is a plug-and-play heart-rate sensor for Arduino. It can be used by students, artists, athletes, makers, and game & mobile developers who want to easily incorporate live heart-rate data into their projects. It essentially combines a simple optical heart rate sensor with amplification and noise cancellation circuitry making it fast and easy to get reliable pulse readings. Also, it sips power with just 4mA current draw at 5V so it’s great for mobile applications.

Simply clip the Pulse Sensor to your earlobe or fingertip and plug it into your 3 or 5 Volt Arduino and you’re ready to read heart rate! The 24" cable on the Pulse Sensor is terminated with standard male headers so there’s no soldering required. Of course Arduino example code is available as well as a Processing sketch for visualizing heart rate data.

Dimensions: 0.625" Diameter and 0.125" Thick

Page 12: Arduino based heartbeat monitoring system

11 | P a g e

X. LCD DISPLAY LCD (Liquid Crystal Display) screen is an electronic display module and find a wide range of applications. A 16x2 LCD display is very basic module and is very commonly used in various devices and circuits. These modules are preferred over seven segments and other multi segment LEDs. The reasons being: LCDs are economical; easily programmable; have no limitation of displaying special & even custom characters (unlike in seven segments), animations and so on. A 16x2 LCD means it can display 16 characters per line and there are 2 such lines. In this LCD each character is displayed in 5x7 pixel matrix. This LCD has two registers, namely, Command and Data. The command register stores the command instructions given to the LCD. A command is an instruction given to LCD to do a predefined task like initializing it, clearing its screen, setting the cursor position, controlling display etc. The data register stores the data to be displayed on the LCD. The data is the ASCII value of the character to be displayed on the LCD.

Page 13: Arduino based heartbeat monitoring system

12 | P a g e

XI. SOFTWARES USED 1. Arduino IDE

Page 14: Arduino based heartbeat monitoring system

13 | P a g e

XII. CIRCUIT SCHEMATIC

Page 15: Arduino based heartbeat monitoring system

14 | P a g e

XIII. CONNECTION PROCEDURE

Connect the Pulse Sensor with the Arduino. The connections of the pulse sensor are very easy. Pulse sensor has three pins. Connect 5V and the ground pin of the pulse sensor to the 5V and the ground of the Arduino and the signal pin to the A0 of Arduino.

Then connect the LED to pin 13 of Arduino. You do not have to connect a resistor with because the Arduino has built in resistor at pin 13.

In last, we will connect LCD with the Arduino. The connections of the LCD are as follows

Connect pin 1 (VEE) to the ground. Connect pin 2 (VDD or VCC) to the 5V.

Connect pin 3 (V0) to the middle pin of the 10K potentiometer and connect the other two ends of the potentiometer to the VCC and the GND. The potentiometer is used to control the screen contrast of the LCD. Potentiometer of values other than 10K will work too.

Connect pin 4 (RS) to the pin 12 of the Arduino. Connect pin 5 (Read/Write) to the ground of Arduino. This pin is not often used so we will

connect it to the ground. Connect pin 6 (E) to the pin 11 of the Arduino. The RS and E pin are the control pins which

are used to send data and characters. The following four pins are data pins which are used to communicate with the Arduino.

Connect pin 11 (D4) to pin 5 of Arduino.

Connect pin 12 (D5) to pin 4 of Arduino.

Connect pin 13 (D6) to pin 3 of Arduino.

Connect pin 14 (D7) to pin 2 of Arduino.

Connect pin 15 to the VCC through the 220 ohm resistor. The resistor will be used to set the back light brightness. Larger values will make the back light much more darker.

Connect pin 16 to the Ground.

Page 16: Arduino based heartbeat monitoring system

15 | P a g e

XIV. ARDUINO CODE #include <SoftwareSerial.h> #define DEBUG true SoftwareSerial esp8266(9,10); #include <LiquidCrystal.h> #include <stdlib.h> LiquidCrystal lcd(12,11,5,4,3,2); #define SSID "AI-THINKER_F92AB1" // "SSID-WiFiname" #define PASS "1234" // "password" #define IP "184.106.153.149"// thingspeak.com ip String msg = "GET /update?key=M0JALXHJER8GKEKV"; //change it with your api key like "GET /update?key=Your Api Key" //Variables float temp; int hum; String tempC; int error; int pulsePin = 0; // Pulse Sensor purple wire connected to analog pin 0 int blinkPin = 13; // pin to blink led at each beat int fadePin = 5; int fadeRate = 0; // Volatile Variables, used in the interrupt service routine! volatile int BPM; // int that holds raw Analog in 0. updated every 2mS volatile int Signal; // holds the incoming raw data volatile int IBI = 600; // int that holds the time interval between beats! Must be seeded! volatile boolean Pulse = false; // "True" when heartbeat is detected. "False" when not a "live beat". volatile boolean QS = false; // becomes true when Arduino finds a beat. // Regards Serial OutPut -- Set This Up to your needs static boolean serialVisual = true; // Set to 'false' by Default. Re-set to 'true' to see Arduino Serial Monitor ASCII Visual Pulse volatile int rate[10]; // array to hold last ten IBI values volatile unsigned long sampleCounter = 0; // used to determine pulse timing volatile unsigned long lastBeatTime = 0; // used to find IBI volatile int P =512; // used to find peak in pulse wave, seeded volatile int T = 512; // used to find trough in pulse wave, seeded volatile int thresh = 525; // used to find instant moment of heart beat, seeded

Page 17: Arduino based heartbeat monitoring system

16 | P a g e

volatile int amp = 100; // used to hold amplitude of pulse waveform, seeded volatile boolean firstBeat = true; // used to seed rate array so we startup with reasonable BPM volatile boolean secondBeat = false; // used to seed rate array so we startup with reasonable BPM void setup() { lcd.begin(16, 2); lcd.print("Comm. Engg. Lab"); lcd.setCursor(0,1); lcd.print("Microproject"); delay(1000); lcd.setCursor(0,0); lcd.print("Group Members. . ."); delay(6000); lcd.setCursor(0,1); lcd.print("Arkadeep Dey "); delay(6000); lcd.setCursor(0,1); lcd.print("Kaustav Mondal "); delay(6000); lcd.setCursor(0,1); lcd.print("Portrait Mollick "); delay(600); Serial.begin(9600); //or use default 115200. esp8266.begin(9600); Serial.println("AT"); esp8266.println("AT"); delay(5000); if(esp8266.find("Ok")){ connectWiFi(); } interruptSetup(); } void loop(){ lcd.clear(); start: //label error=0; lcd.setCursor(0, 0); lcd.print("BPM = ");

Page 18: Arduino based heartbeat monitoring system

17 | P a g e

delay(1000); delay (60000); lcd.setCursor(0,0); loop(); lcd.setCursor(0, 1); // set the cursor to column 0, line 2 delay(1000); updatebeat(); //Resend if transmission is not completed if (error==1){ goto start; //go to label "start" } delay(1000); } void updatebeat(){ String cmd = "AT+CIPSTART=\"TCP\",\""; cmd += IP; cmd += "\",80"; Serial.println(cmd); esp8266.println(cmd); delay(2000); if(esp8266.find("Error")){ return; } cmd = msg ; cmd += "&field1="; cmd += BPM; cmd += "\r\n"; Serial.print("AT+CIPSEND="); esp8266.print("AT+CIPSEND="); Serial.println(cmd.length()); esp8266.println(cmd.length()); if(esp8266.find(">")){ Serial.print(cmd); esp8266.print(cmd); } else{ Serial.println("AT+CIPCLOSE");

Page 19: Arduino based heartbeat monitoring system

18 | P a g e

esp8266.println("AT+CIPCLOSE"); //Resend... error=1; } } boolean connectWiFi(){ Serial.println("AT+CWMODE=1"); esp8266.println("AT+CWMODE=1"); delay(2000); String cmd="AT+CWJAP=\""; cmd+=SSID; cmd+="\",\""; cmd+=PASS; cmd+="\""; Serial.println(cmd); esp8266.println(cmd); delay(5000); if(esp8266.find("OK")){ Serial.println("OK"); return true; }else{ return false; } } void interruptSetup(){ TCCR2A = 0x02; // DISABLE PWM ON DIGITAL PINS 3 AND 11, AND GO INTO CTC MODE TCCR2B = 0x06; // DON'T FORCE COMPARE, 256 PRESCALER OCR2A = 0X7C; // SET THE TOP OF THE COUNT TO 124 FOR 500Hz SAMPLE RATE TIMSK2 = 0x02; // ENABLE INTERRUPT ON MATCH BETWEEN TIMER2 AND OCR2A sei(); // MAKE SURE GLOBAL INTERRUPTS ARE ENABLED } ISR(TIMER2_COMPA_vect){ // triggered when Timer2 counts to 124 cli(); // disable interrupts while we do this Signal = analogRead(pulsePin); // read the Pulse Sensor sampleCounter += 2; // keep track of the time in mS int N = sampleCounter - lastBeatTime; // monitor the time since the last beat to avoid noise // find the peak and trough of the pulse wave

Page 20: Arduino based heartbeat monitoring system

19 | P a g e

if(Signal < thresh && N > (IBI/5)*3){ // avoid dichrotic noise by waiting 3/5 of last IBI if (Signal < T){ // T is the trough T = Signal; // keep track of lowest point in pulse wave } } if(Signal > thresh && Signal > P){ // thresh condition helps avoid noise P = Signal; // P is the peak } // keep track of highest point in pulse wave // NOW IT'S TIME TO LOOK FOR THE HEART BEAT // signal surges up in value every time there is a pulse if (N > 250){ // avoid high frequency noise if ( (Signal > thresh) && (Pulse == false) && (N > (IBI/5)*3) ){ Pulse = true; // set the Pulse flag when there is a pulse digitalWrite(blinkPin,HIGH); // turn on pin 13 LED IBI = sampleCounter - lastBeatTime; // time between beats in mS lastBeatTime = sampleCounter; // keep track of time for next pulse if(secondBeat){ // if this is the second beat secondBeat = false; // clear secondBeat flag for(int i=0; i<=9; i++){ // seed the running total to get a realistic BPM at startup rate[i] = IBI; } } if(firstBeat){ // if it's the first time beat is found firstBeat = false; // clear firstBeat flag secondBeat = true; // set the second beat flag sei(); // enable interrupts again return; // IBI value is unreliable so discard it } word runningTotal = 0; // clear the runningTotal variable for(int i=0; i<=8; i++){ // shift data in the rate array rate[i] = rate[i+1]; // and drop the oldest IBI value runningTotal += rate[i]; // add up the 9 oldest IBI values } rate[9] = IBI; // add the latest IBI to the rate array runningTotal += rate[9]; // add the latest IBI to runningTotal

Page 21: Arduino based heartbeat monitoring system

20 | P a g e

runningTotal /= 10; // average the last 10 IBI values BPM = 60000/runningTotal; // how many beats can fit into a minute? that's BPM! QS = true; // set Quantified Self flag // QS FLAG IS NOT CLEARED INSIDE THIS ISR } } if (Signal < thresh && Pulse == true){ // when the values are going down, the beat is over digitalWrite(blinkPin,LOW); // turn off pin 13 LED Pulse = false; // reset the Pulse flag so we can do it again amp = P - T; // get amplitude of the pulse wave thresh = amp/2 + T; // set thresh at 50% of the amplitude P = thresh; // reset these for next time T = thresh; } if (N > 2500){ // if 2.5 seconds go by without a beat thresh = 512; // set thresh default P = 512; // set P default T = 512; // set T default lastBeatTime = sampleCounter; // bring the lastBeatTime up to date firstBeat = true; // set these to avoid noise secondBeat = false; // when we get the heartbeat back } sei(); // enable interrupts when youre done! }// end isr

Page 22: Arduino based heartbeat monitoring system

21 | P a g e

XV. PHOTO OF THE PROJECT

Page 23: Arduino based heartbeat monitoring system

22 | P a g e

XVI. Conclusion

In the above mentioned system we have proposed a health monitoring system which is Arduino based.

User friendly and bridges gap between doctor and patients.

The system is simple, Power efficient.

Practical application of the system is superfine in rural areas as there would be no need for the patients to get their continuous follow-ups.

XVII. RESOURCES

I. www.arduino.cc

II. https://circuitdigest.com

III. www.wikipedia.org

IV. www.instructables.com

V. www.electronicshub.org

VI. www.hackster.io

Page 24: Arduino based heartbeat monitoring system

23 | P a g e

Thank You

)