{"id":7485,"date":"2013-06-09T14:29:44","date_gmt":"2013-06-09T18:29:44","guid":{"rendered":"http:\/\/embedded-lab.com\/blog\/?p=7485"},"modified":"2023-04-05T23:21:45","modified_gmt":"2023-04-06T03:21:45","slug":"pc-based-heart-rate-monitor-using-arduino-and-easy-pulse-sensor","status":"publish","type":"post","link":"https:\/\/embedded-lab.com\/blog\/pc-based-heart-rate-monitor-using-arduino-and-easy-pulse-sensor\/","title":{"rendered":"PC-based heart rate monitor using Arduino and Easy Pulse sensor"},"content":{"rendered":"<p>The heart rate, also referred to as pulse rate, has been recognized as a vital sign since the beginning of medicine, and it is directly related to a person&#8217;s cadiovascular health. Today, we are going to make a PC-based heart rate monitor system using an Arduino board and Easy Pulse V1.1 sensor. Easy Pulse is a pulse detecting sensor that uses the principle of transmission photo-plethysmography (PPG) to sense the pulse signal from a finger tip. The sensor output is read by the Arduino board, which then transfers the data to the PC through a serial interface. A PC application is developed using Processing programming language to display the received PPG signal and instantaneous heart rate.<\/p>\n<div id=\"attachment_7508\" style=\"width: 575px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2013\/05\/EasyPulseMeterTitle.jpg\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-7508\" class=\"size-full wp-image-7508\" title=\"EasyPulseMeterTitle\" src=\"http:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2013\/05\/EasyPulseMeterTitle.jpg\" alt=\"\" width=\"565\" height=\"371\" srcset=\"https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2013\/05\/EasyPulseMeterTitle.jpg 565w, https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2013\/05\/EasyPulseMeterTitle-550x361.jpg 550w\" sizes=\"auto, (max-width: 565px) 100vw, 565px\" \/><\/a><p id=\"caption-attachment-7508\" class=\"wp-caption-text\">Arduino pulse meter<\/p><\/div>\n<h3><!--more--><strong>Brief introduction of Easy Pulse V1.1<\/strong><\/h3>\n<p>The Easy Pulse sensor is designed for hobby and educational applications to illustrate the principle of photoplethysmography (PPG) as a non-invasive optical technique for\u00a0detecting cardio-vascular pulse wave from a fingertip. It uses an infrared light source to illuminate the finger on one side, and a photodetector placed on the other side measures the small variations in the transmitted light intensity. The variations in the photodetector signal are related to changes in blood volume inside the tissue. The signal is filtered and amplified to obtain a nice and clean PPG waveform, which is synchronous with the heart beat. For more details, read <strong><a href=\"http:\/\/embedded-lab.com\/blog\/?p=7336\" target=\"_blank\" rel=\"noopener noreferrer\">Easy Pulse V1.1<\/a><\/strong>.<\/p>\n<div id=\"attachment_7524\" style=\"width: 575px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2013\/06\/EasyPulseV1.1Board3.jpg\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-7524\" class=\"size-full wp-image-7524\" title=\"EasyPulseV1.1Board3\" src=\"http:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2013\/06\/EasyPulseV1.1Board3.jpg\" alt=\"\" width=\"565\" height=\"439\" srcset=\"https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2013\/06\/EasyPulseV1.1Board3.jpg 565w, https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2013\/06\/EasyPulseV1.1Board3-550x427.jpg 550w\" sizes=\"auto, (max-width: 565px) 100vw, 565px\" \/><\/a><p id=\"caption-attachment-7524\" class=\"wp-caption-text\">Easy Pulse V1.1<\/p><\/div>\n<h3><strong>Hardware setup<\/strong><\/h3>\n<p>The hardware setup for this project is very simple. All you need is an Easy Pulse V1.1 sensor, an Arduino board, a PC, and few wires. The analog PPG output from Easy Pulse board is fed to an ADC channel of Arduino to convert it into digital counts for further processing. In this project, I am using a <strong><a href=\"http:\/\/www.elecrow.com\/arduino-compatiable-c-109\/micro-controller-c-109_117\/crowduino-with-atmega-328-p-338.html\" target=\"_blank\" rel=\"noopener noreferrer\">Crowduino<\/a><\/strong> board, a clone of Arduino Duemilanove, which is manufactured by <strong><a href=\"http:\/\/www.elecrow.com\" target=\"_blank\" rel=\"noopener noreferrer\">Elecrow<\/a><\/strong>.<\/p>\n<div style=\"width: 575px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"\" src=\"http:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2013\/06\/Crowduino.jpg\" alt=\"\" width=\"565\" height=\"443\" \/><p class=\"wp-caption-text\">The Crowduino is 100% compatible with Arduino Duemilanuve and comes with additional features. The major difference between Crowduino and other arduino compatible boards is the Crowduino contains a XBee socket. Thus Crowduino not only can adapt all the shields that are compatible with arduino Uno, but also adapts to the Xbee modules from Digi, and any module with the same footprint.<\/p><\/div>\n<p>The following picture shows the connections between the Easy Pulse, Crowduino and Power supply. The Easy Pulse sensor operates at +5V. The Enable pin (EN) of Easy Pulse is tied to VCC pin so that the sensor is activated. There is a 2-pin jumper on the Easy Pulse board to do this. The jumper is placed between VCC and EN pin by default, so you don&#8217;t need an external wire to do this. The analog output pin (AO) goes to analog input channel A0 of Crowduino. A mini USB cable connects the Crowduino board to the PC.\u00a0The power supply for Easy Pulse is derived from the Crowduino board.<\/p>\n<div id=\"attachment_7510\" style=\"width: 550px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2013\/06\/EasyPulseMeterSetup1.png\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-7510\" class=\"size-full wp-image-7510\" title=\"EasyPulseMeterSetup1\" src=\"http:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2013\/06\/EasyPulseMeterSetup1.png\" alt=\"\" width=\"540\" height=\"348\" \/><\/a><p id=\"caption-attachment-7510\" class=\"wp-caption-text\">Arduino and Easy Pulse connections<\/p><\/div>\n<div id=\"attachment_7507\" style=\"width: 575px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2013\/05\/EasyPulseMeterSetup.jpg\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-7507\" class=\"size-full wp-image-7507\" title=\"EasyPulseMeterSetup\" src=\"http:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2013\/05\/EasyPulseMeterSetup.jpg\" alt=\"\" width=\"565\" height=\"422\" srcset=\"https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2013\/05\/EasyPulseMeterSetup.jpg 565w, https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2013\/05\/EasyPulseMeterSetup-550x410.jpg 550w\" sizes=\"auto, (max-width: 565px) 100vw, 565px\" \/><\/a><p id=\"caption-attachment-7507\" class=\"wp-caption-text\">Easy Pulse meter setup<\/p><\/div>\n<h3><strong>Arduino Sketch<\/strong><\/h3>\n<p>The programming part of Arduino is very simple. The Arduino takes the ADC samples of the analog PPG signal at 5ms interval and continuously transmits the data to the PC through the USB-UART interface.<\/p>\n\n<div class=\"wp_syntax\"><table><tr><td class=\"code\"><pre class=\"c\" style=\"font-family:monospace;\"><span style=\"color: #808080; font-style: italic;\">\/*\n  AnalogReadSerial\n Reads an analog input on pin 0, prints the result to the serial monitor \n&nbsp;\n This example code is in the public domain.\n *\/<\/span>\n<span style=\"color: #993333;\">void<\/span> setup<span style=\"color: #009900;\">&#40;<\/span><span style=\"color: #009900;\">&#41;<\/span> <span style=\"color: #009900;\">&#123;<\/span>\n  Serial.<span style=\"color: #202020;\">begin<\/span><span style=\"color: #009900;\">&#40;<\/span><span style=\"color: #0000dd;\">115200<\/span><span style=\"color: #009900;\">&#41;<\/span><span style=\"color: #339933;\">;<\/span>\n<span style=\"color: #009900;\">&#125;<\/span>\n&nbsp;\n<span style=\"color: #993333;\">void<\/span> loop<span style=\"color: #009900;\">&#40;<\/span><span style=\"color: #009900;\">&#41;<\/span> <span style=\"color: #009900;\">&#123;<\/span>\n  <span style=\"color: #993333;\">int<\/span> sensorValue <span style=\"color: #339933;\">=<\/span> analogRead<span style=\"color: #009900;\">&#40;<\/span>A0<span style=\"color: #009900;\">&#41;<\/span><span style=\"color: #339933;\">;<\/span>\n  Serial.<span style=\"color: #202020;\">println<\/span><span style=\"color: #009900;\">&#40;<\/span>sensorValue<span style=\"color: #009900;\">&#41;<\/span><span style=\"color: #339933;\">;<\/span>\n  delay_x<span style=\"color: #009900;\">&#40;<\/span><span style=\"color: #0000dd;\">5<\/span><span style=\"color: #009900;\">&#41;<\/span><span style=\"color: #339933;\">;<\/span>\n<span style=\"color: #009900;\">&#125;<\/span>\n&nbsp;\n<span style=\"color: #993333;\">void<\/span> delay_x<span style=\"color: #009900;\">&#40;<\/span><span style=\"color: #993333;\">uint32_t<\/span> millis_delay<span style=\"color: #009900;\">&#41;<\/span>\n<span style=\"color: #009900;\">&#123;<\/span>\n  <span style=\"color: #993333;\">uint16_t<\/span> micros_now <span style=\"color: #339933;\">=<\/span> <span style=\"color: #009900;\">&#40;<\/span><span style=\"color: #993333;\">uint16_t<\/span><span style=\"color: #009900;\">&#41;<\/span>micros<span style=\"color: #009900;\">&#40;<\/span><span style=\"color: #009900;\">&#41;<\/span><span style=\"color: #339933;\">;<\/span>\n&nbsp;\n  <span style=\"color: #b1b100;\">while<\/span> <span style=\"color: #009900;\">&#40;<\/span>millis_delay <span style=\"color: #339933;\">&amp;<\/span>gt<span style=\"color: #339933;\">;<\/span> <span style=\"color: #0000dd;\">0<\/span><span style=\"color: #009900;\">&#41;<\/span> <span style=\"color: #009900;\">&#123;<\/span>\n    <span style=\"color: #b1b100;\">if<\/span> <span style=\"color: #009900;\">&#40;<\/span><span style=\"color: #009900;\">&#40;<\/span><span style=\"color: #009900;\">&#40;<\/span><span style=\"color: #993333;\">uint16_t<\/span><span style=\"color: #009900;\">&#41;<\/span>micros<span style=\"color: #009900;\">&#40;<\/span><span style=\"color: #009900;\">&#41;<\/span> <span style=\"color: #339933;\">-<\/span> micros_now<span style=\"color: #009900;\">&#41;<\/span> <span style=\"color: #339933;\">&amp;<\/span>gt<span style=\"color: #339933;\">;=<\/span> <span style=\"color: #0000dd;\">1000<\/span><span style=\"color: #009900;\">&#41;<\/span> <span style=\"color: #009900;\">&#123;<\/span>\n      millis_delay<span style=\"color: #339933;\">--;<\/span>\n      micros_now <span style=\"color: #339933;\">+=<\/span> <span style=\"color: #0000dd;\">1000<\/span><span style=\"color: #339933;\">;<\/span>\n    <span style=\"color: #009900;\">&#125;<\/span>\n  <span style=\"color: #009900;\">&#125;<\/span>  \n<span style=\"color: #009900;\">&#125;<\/span><\/pre><\/td><\/tr><\/table><\/div>\n\n<p><a href=\"https:\/\/www.embedded-lab.com\/uploads\/Misc\/SendPPGSignal.zip\"><strong>Download the Arduino Sketch (SendPPGSignal.zip)<\/strong><\/a><\/p>\n<h3><strong>PC application<\/strong><\/h3>\n<p>On PC side, we develop an application that reads the incoming ADC samples from the Arduino, and process them to extract the PPG signal and heart rate. The Processing software is used to develop this application. The following flow-chart explains the overall logic of computing the heart rate from the received ADC samples.<\/p>\n<div id=\"attachment_7514\" style=\"width: 575px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2013\/06\/ProcessingFlow.png\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-7514\" class=\"size-full wp-image-7514\" title=\"ProcessingFlow\" src=\"http:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2013\/06\/ProcessingFlow.png\" alt=\"\" width=\"565\" height=\"616\" srcset=\"https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2013\/06\/ProcessingFlow.png 565w, https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2013\/06\/ProcessingFlow-550x599.png 550w\" sizes=\"auto, (max-width: 565px) 100vw, 565px\" \/><\/a><p id=\"caption-attachment-7514\" class=\"wp-caption-text\">Algorithm flowchart for computing heart rate<\/p><\/div>\n<p>The PC application first reads 600 consecutive samples sent by Arduino. Since the sampling rate was 5ms, it takes 3 sec to read the 6000 samples. The DC component (minima of 600 samples) is subtracted out from the samples. Next, the range of the samples is computed. If the range is less than 50 counts, the received PPG waveform is very weak, and is considered to be a noise. This could happen when no PPG signal is detected through fingertip (sensor is faulty or disconnected) or the gain of the amplifier on Easy Pulse board is set very low. The gain can be increased through potentiometer P1 on the Easy Pulse board.<\/p>\n<p>If the range of ADC samples is greater than 50, it is considered as a valid PPG signal and is displayed on the PC screen. The samples are scaled to 1-1023 for full swing of display. Next, a 21-point moving average filter is applied to remove the unnecessary high frequency components (usually noise) in the PPG signal. The resulting samples are plotted against time to obtain a clean and smooth PPG waveform. Note that we lose 10 samples at the beginning and 10 samples at the end while applying the moving average filter.<\/p>\n<h3><strong>Computing heart rate<\/strong><\/h3>\n<p>The heart beat rate can be computed by knowing the time period of the PPG waveform. For this, we identify three consecutive peaks in the waveform based on where the slope of the curve changes from positive to negative, and the magnitude of the signal is greater than 80% of the maxima of all the samples. Since two consecutive samples are 5ms apart, time difference between any two peaks can be easily computed from their indices (or sequence numbers). Two heart rates are computed from the three consecutive PPG peaks and their average value is displayed as an instantaneous heart rate. The identified peaks are also marked on the display with a cross (X) symbol (see the PPG waveform plotted by the PC application on the computer screen).<\/p>\n<div id=\"attachment_7537\" style=\"width: 560px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2013\/06\/PPG_Waveform2.png\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-7537\" class=\"size-medium wp-image-7537\" title=\"PPG_Waveform2\" src=\"http:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2013\/06\/PPG_Waveform2-550x364.png\" alt=\"\" width=\"550\" height=\"364\" srcset=\"https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2013\/06\/PPG_Waveform2-550x364.png 550w, https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2013\/06\/PPG_Waveform2.png 734w\" sizes=\"auto, (max-width: 550px) 100vw, 550px\" \/><\/a><p id=\"caption-attachment-7537\" class=\"wp-caption-text\">PPG Waveform and heart rate displayed on computer screen (click to enlarge)<\/p><\/div>\n<p><iframe loading=\"lazy\" src=\"http:\/\/www.youtube.com\/embed\/gXVG7baqFn8\" width=\"480\" height=\"360\" frameborder=\"0\" allowfullscreen=\"allowfullscreen\"><\/iframe><\/p>\n<p style=\"font-size: 14px;\"><a href=\"http:\/\/embedded-lab.com\/uploads\/Processing\/Easy_Pulse_PPG_Analyzer_V1_0.zip\"><strong>Download Processing code and exported applications<\/strong><\/a><\/p>\n<p><strong>Note:<\/strong> This software is licensed under a Creative Commons Attribution-ShareAlike 3.0.<\/p>\n<h3><strong>Future work<\/strong><\/h3>\n<p>The current version of the Processing application displays the near-real-time PPG waveform and heart rate but does not record anything. There is a lot of room for improvements. Here&#8217;s a short list of features that I am seeing for its future release:<\/p>\n<ul>\n<li>Logging heart rate measurements and PPG samples along with the time-stamp information available from the PC<\/li>\n<li>Beping sound alarm for heart rates below or above threshold<\/li>\n<li>Heart rate trend over time, etc.<\/li>\n<\/ul>\n<p style=\"padding: 0.5em; font-family: verdana, arial, helvetica, sans-serif; font-size: 14px;\">You can buy both <strong><a href=\"https:\/\/www.elecrow.com\/cde10301e.html\" target=\"_blank\" rel=\"noopener noreferrer\">Easy Pulse sensor<\/a><\/strong> and <strong><a href=\"http:\/\/www.elecrow.com\/arduino-compatiable-c-109\/micro-controller-c-109_117\/crowduino-with-atmega-328-p-338.html\" target=\"_blank\" rel=\"noopener noreferrer\">Crowduino<\/a><\/strong> at Elecrow. US customers can also get <a href=\"https:\/\/www.tindie.com\/products\/rajbex\/easy-pulse-a-diy-pulse-sensor-based-on-photoplethysmography\/\"><strong>Easy Pulse sensor<\/strong><\/a> directly from our <a href=\"https:\/\/www.tindie.com\/products\/rajbex\/easy-pulse-a-diy-pulse-sensor-based-on-photoplethysmography\/\"><strong>Tindie<\/strong><\/a> store.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The heart rate, also referred to as pulse rate, has been recognized as a vital sign since the beginning of medicine, and it is directly related to a person&#8217;s cadiovascular health. Today, we are going to make a PC-based heart rate monitor system using an Arduino board and Easy Pulse V1.1 sensor. Easy Pulse is a pulse detecting sensor that uses the principle of transmission photo-plethysmography (PPG) to sense the pulse signal from a finger tip. The sensor output is read by the Arduino board, which then transfers the data to the PC through a serial interface. A PC application<\/p>\n","protected":false},"author":1,"featured_media":7506,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[150,245,349],"tags":[148,176,177,469],"class_list":["post-7485","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-arduino-2","category-embedded-lab-projects","category-processing","tag-arduino","tag-heart-rate-monitor","tag-pulse-meter","tag-pulse-sensor"],"_links":{"self":[{"href":"https:\/\/embedded-lab.com\/blog\/wp-json\/wp\/v2\/posts\/7485","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/embedded-lab.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/embedded-lab.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/embedded-lab.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/embedded-lab.com\/blog\/wp-json\/wp\/v2\/comments?post=7485"}],"version-history":[{"count":47,"href":"https:\/\/embedded-lab.com\/blog\/wp-json\/wp\/v2\/posts\/7485\/revisions"}],"predecessor-version":[{"id":15128,"href":"https:\/\/embedded-lab.com\/blog\/wp-json\/wp\/v2\/posts\/7485\/revisions\/15128"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/embedded-lab.com\/blog\/wp-json\/wp\/v2\/media\/7506"}],"wp:attachment":[{"href":"https:\/\/embedded-lab.com\/blog\/wp-json\/wp\/v2\/media?parent=7485"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/embedded-lab.com\/blog\/wp-json\/wp\/v2\/categories?post=7485"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/embedded-lab.com\/blog\/wp-json\/wp\/v2\/tags?post=7485"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}