DFROBOT PULSE SENSOR

850.00

Categories: ,

Description

Introduction

The DFRobot heart rate sensor is a thumb-sized heart rate monitor designed for Arduino microcontrollers. It includes a Gravity interface, for easy plug-and-play connectivity.
This sensor is a pulse sensor which is developed based on PPG (PhotoPlethysmoGraphy) techniques. This is a simple and low-cost optical technique that can be used to detect blood volume changing in the microvascular bed of tissues. It is relatively easy to detect the pulsatile component of the cardiac cycle according to this theory.
The sensor has two holes that you can use to attach to your belt. You can wrap on your finger, wrist, earlobe or other areas where it has contact with skin.
The heart sensor has two kinds of signal output mode: analog pulse mode and digital square wave mode. You can change its output mode using the dial switch. There are many user scenarios, including education, sport or maker/interactive projects!

Warning yellow.png
Please Note: This product is NOT a medical device and is not intended to be used as such or as an accessory to such nor diagnose or treat any conditions.

Specification

  • Input Voltage (Vin): 3.3 – 6V (5V recommended)
  • Output Voltage: 0 – Vin (Analog), 0/ Vin (Digital)
  • Operating current: <10mA
  • Dimension: 28 x 24(mm), 1.102″ x 0.945″(in)
  • Interface Type: PH2.0-3P

Board Overview

SEN0203 overall.png
NOTE: The switch is to set the working mode, it will change the signal type to be Digital or Analog. If it was NOT set as consistent as the code or wiring, i.e. the switch was set as “A”, but you write your code as digitalRead and(or) you wire the module onto Arduino digital pin, in this case, you will fail to get any readings, vice versa.

Tutorial

Through this tutorial, you will learn how to use this Heart Rate sensor in digital mode as well as analog mode, more than this, at the end of this tutorial, we will show you how to use this sensor to draw the ECG to a LCD module.

Requirements

Before start

Once you opened the box, you could find the black belt inside of the package. Thread it through the holes of the sensor as indicted out in the photo. And then you could attach it on your finger (suggested), wrist or any other places where exposes blood vessels. Do not attach the belt too tight or too loose to your finger, or the reading might be not stable. Besides that, during the test, you should steady your finger, do not move too much, or the readings would be bad.

Connection Diagram

SEN0203 Connection Diagram.png

Sample Code

The sample code could be found in the Github Page, open the example “DFRobot_Heartrate_Digital_Mode“.

 1 /*!
 2 * @file DFRobot_Heartrate.h
 3 * @brief DFRobot_Heartrate.h detailed description for Heartrate.cpp 
 4 *
 5 *  This is written for the heart rate sensor the company library. Mainly used for real 
 6 *  time measurement of blood oxygen saturation, based on measured values calculate heart rate values.
 7 * 
 8 * @author linfeng(Musk.lin@dfrobot.com)
 9 * @version  V1.1
10 * @date  2016-8-16
11 * @version  V1.0
12 * @date  2015-12-24
13 */
14 #define heartratePin A1
15 #include "DFRobot_Heartrate.h"
16 
17 DFRobot_Heartrate heartrate(DIGITAL_MODE); ///< ANALOG_MODE or DIGITAL_MODE
18 
19 void setup() {
20   Serial.begin(115200);
21 }
22 
23 void loop() {
24   uint8_t rateValue;
25   heartrate.getValue(heartratePin); ///< A1 foot sampled values
26   rateValue = heartrate.getRate(); ///< Get heart rate value 
27   if(rateValue)  {
28     Serial.println(rateValue);
29   }
30   delay(20);
31 }
32 
33 /******************************************************************************
34   Copyright (C) <2015>  <linfeng>
35   This program is free software: you can redistribute it and/or modify
36   it under the terms of the GNU General Public License as published by
37   the Free Software Foundation, either version 3 of the License, or
38   (at your option) any later version.
39   This program is distributed in the hope that it will be useful,
40   but WITHOUT ANY WARRANTY; without even the implied warranty of
41   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
42   GNU General Public License for more details.
43   You should have received a copy of the GNU General Public License
44   along with this program.  If not, see <http://www.gnu.org/licenses/>.
45   Contact: Musk.lin@dfrobot.com
46  ******************************************************************************/

 

Digital Mode

  1. Wiring
    • Select the sensor’s mode switch as “D” for Digital
    • Connect it with UNO’s A1 as the code indicates (you could change it as you wish)
  2. Upload the code
  3. Open the Serial monitor.
  4. Adjust the finger’s position until you notice the LED is flashing regularly as your heartbeat, after several seconds, the Serial Monitor will print your heart rate.

Expected results:

SEN0203 flashing as heart beats.gif
SEN0203 serial reading d.png

Draw the ECG (Electrocardiography)

Digital Mode

  1. Attach this sensor to Arduino D2
  2. Set the sensor mode switch as D (digital)
  3. Upload the code below
  4. Open the Arduino Serial Plotter (Baud: 9600)
Open "Serial Plotter"
 1 /*
 2   DigitalReadSerial
 3  Reads a digital input on pin 2, prints the result to the serial monitor
 4 
 5  This example code is in the public domain.
 6  */
 7 
 8 // digital pin 2 has a pushbutton attached to it. Give it a name:
 9 int pushButton = 2;
10 
11 // the setup routine runs once when you press reset:
12 void setup() {
13   // initialize serial communication at 9600 bits per second:
14   Serial.begin(9600);
15   // make the pushbutton's pin an input:
16   pinMode(pushButton, INPUT);
17 }
18 
19 // the loop routine runs over and over again forever:
20 void loop() {
21   // read the input pin:
22   int buttonState = digitalRead(pushButton);
23   // print out the state of the button:
24   Serial.println(buttonState);
25   delay(10);        // delay in between reads for stability
26 }
SEN0203 plotter digital.png

Analog Mode

  1. Attach this sensor to Arduino A1
  2. Set the sensor mode switch as A (analog)
  3. Upload the code below
  4. Open the Arduino Serial Plotter (Baud: 9600)
 1 /*
 2   AnalogReadSerial
 3   Reads an analog input on pin 0, prints the result to the serial monitor.
 4   Graphical representation is available using serial plotter (Tools > Serial Plotter menu)
 5   Attach the center pin of a potentiometer to pin A0, and the outside pins to +5V and ground.
 6 
 7   This example code is in the public domain.
 8 */
 9 
10 // the setup routine runs once when you press reset:
11 void setup() {
12   // initialize serial communication at 9600 bits per second:
13   Serial.begin(9600);
14 }
15 
16 // the loop routine runs over and over again forever:
17 void loop() {
18   // read the input on analog pin 0:
19   int sensorValue = analogRead(A1);
20   // print out the value you read:
21   Serial.println(sensorValue);
22   delay(10);        // delay in between reads for stability
23 }
SEN0203 plotter Analog.png

Use it with LCD12864 shield

  1. Please download and install the library for LCD12846.
  2. Upload the code below
  3. It will display the heart rate and ECG on the LCD(12846) screen.
 1 /*!
 2 * @file HeartrateDisplay
 3 * @brief  Waves of blood oxygen saturation and heart rate value is displayed on the LCD
 4 *
 5 * @brief  Waves of blood oxygen saturation and heart rate value is displayed on the LCD
 6 * 
 7 * @author linfeng(490289303@qq.com)
 8 * @version  V1.1
 9 * @date  2016-8-16
10 * @version  V1.0
11 * @date  2015-12-24
12 */
13 
14 #define heartratePin A1
15 #include "Heartrate.h"
16 #include "Lcd12864Shield.h"
17 
18 uint16_t heartrateValue=0,heartrateValueLast=0;
19 uint8_t count;
20 
21 Lcd12864Shield lcddisplay(10,9,8,13,11);
22 Heartrate heartrate(DIGITAL_MODE); ///< ANALOG_MODE or DIGITAL_MODE
23 
24 char wordDisplay[]=  ///< word
25 {
26 0x00,0x00,0x01,0x03,0x07,0x0F,0x1F,0x3F,
27 0x1F,0x0F,0x07,0x03,0x01,0x00,0x00,0x00,
28 0x00,0x00,0xC0,0xE0,0xE0,0xE0,0xC0,0x80,
29 0xC0,0xE0,0xE0,0xE0,0xC0,0x00,0x00,0x00,///< ♥
30 };
31 char letterDisplay[]= ///< character
32 {
33 	
34 0x00,0xE0,0x10,0x08,0x08,0x10,0xE0,0x00,
35 0x00,0x0F,0x10,0x20,0x20,0x10,0x0F,0x00,///< 0
36 0x00,0x10,0x10,0xF8,0x00,0x00,0x00,0x00,
37 0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00,///< 1
38 0x00,0x70,0x08,0x08,0x08,0x88,0x70,0x00,
39 0x00,0x30,0x28,0x24,0x22,0x21,0x30,0x00,///< 2
40 0x00,0x30,0x08,0x88,0x88,0x48,0x30,0x00,
41 0x00,0x18,0x20,0x20,0x20,0x11,0x0E,0x00,///< 3
42 0x00,0x00,0xC0,0x20,0x10,0xF8,0x00,0x00,
43 0x00,0x07,0x04,0x24,0x24,0x3F,0x24,0x00,///< 4
44 0x00,0xF8,0x08,0x88,0x88,0x08,0x08,0x00,
45 0x00,0x19,0x21,0x20,0x20,0x11,0x0E,0x00,///< 5
46 0x00,0xE0,0x10,0x88,0x88,0x18,0x00,0x00,
47 0x00,0x0F,0x11,0x20,0x20,0x11,0x0E,0x00,///< 6
48 0x00,0x38,0x08,0x08,0xC8,0x38,0x08,0x00,
49 0x00,0x00,0x00,0x3F,0x00,0x00,0x00,0x00,///< 7
50 0x00,0x70,0x88,0x08,0x08,0x88,0x70,0x00,
51 0x00,0x1C,0x22,0x21,0x21,0x22,0x1C,0x00,///< 8
52 0x00,0xE0,0x10,0x08,0x08,0x10,0xE0,0x00,
53 0x00,0x00,0x31,0x22,0x22,0x11,0x0F,0x00,///< 9
54 0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x00,
55 0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x00,///< =
56 };
57 
58 
59 
60 void lcdBegin(void)
61 {
62   lcddisplay.initialLcd(); ///< Enable LCD
63   lcddisplay.clearScreen(); ///< Clear LCD
64   lcddisplay.drawXLine(48); ///< Draw a horizontal line
65   lcddisplay.drawYLine(7); ///< Draw a vertical line
66   lcddisplay.drawWord(7,10,0,wordDisplay); ///< Displays a word
67   lcddisplay.drawLetter(7,30,10,letterDisplay); ///< Displays a character
68 }
69 
70 void setup() {
71   Serial.begin(115200);
72   lcdBegin();
73 }
74 
75 void loop() {
76   unsigned char rateValue;  
77   heartrateValueLast = heartrateValue;
78   heartrateValue = heartrate.getValue(heartratePin);  ///< A1 foot sampled values
79   count = heartrate.getCnt();
80   if(count)
81   {
82     lcddisplay.drawYLine(count+8,heartrateValue/24,heartrateValueLast/24); ///< Draw a vertical line,Step 24
83   }
84   else
85   {
86     lcddisplay.drawYLine(count+8,heartrateValue/24,heartrateValueLast/24);
87   }
88  
89   rateValue = heartrate.getRate(); ///< Get heart rate value   
90   if(rateValue)
91   {
92     lcddisplay.drawLetter(7,50,3,rateValue,letterDisplay);  ///< Display values
93     Serial.println(rateValue);
94   }  
95   delay(20);  
96 }

FAQ

Q1. Some general Arduino Problems/FAQ/Tips
A. Click the topic link on DFRobot Forum.
For any questions, advice or cool ideas to share, please visit the DFRobot Forum.

More

Schematic
Layout
SON1303 Datasheet
SON3130 Datasheet