Skip to content

Heart_Rate_Sensor_SKU__SEN0203

Angelo edited this page Sep 22, 2016 · 6 revisions

Heart Rate Sensor SKU: SEN0203

Introduction

The DFRobot Heart Rate Sensor is used to measure the Heart Rate by testing the Oxygen saturation (medicine), read on Wikipedia. And we design it with two working mode: Digital/ Analog, hence that you could switch it for your project easily.

center 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

border

center 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.

File:SEN0203 belt holes.jpg|Thread the belt through the holes File:SEN0203 finger.jpg|Wrap on finger File:SEN0203 wrist.jpg|Wrap on wrist File:SEN0203 wrist back.jpg|Wrap on the back of wrist

Get Heart Rate

The sample code could be found in the download library, open the example "Heartrate", modify the line to adapt to the working mode: Digital/ Analog as shown below.

border

Analog Mode

  1. Wiring

    • Select the sensor's mode switch as "A" for analog
    • Connect it with UNO's A1 as the code indicates (you could change it as you wish)
  2. Code modify at line 15 as:

     Heartrate heartrate(ANALOG_MODE); ///< ANALOG_MODE or DIGITAL_MODE
  3. Upload the code

  4. Open the Serial monitor.

  5. 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:

right

File:SEN0203 serial reading a.png

Digital Mode

It is the same steps as above except the code should be written as Digital.

Heartrate heartrate(DIGITAL_MODE); ///< ANALOG_MODE or DIGITAL_MODE

center NOTE: In this section, we are still using Arduino-A1 as digital read pin, it is allowable. Should you want to use digital pins like D2-D13, except to define the digital pin, specify the pinMode as INPUT, you will have to modify the .cpp file as it was written by analogRead as so on.

Expected results:

border

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"

/*
  DigitalReadSerial
 Reads a digital input on pin 2, prints the result to the serial monitor

 This example code is in the public domain.
 */

// digital pin 2 has a pushbutton attached to it. Give it a name:
int pushButton = 2;

// the setup routine runs once when you press reset:
void setup() {
  // initialize serial communication at 9600 bits per second:
  Serial.begin(9600);
  // make the pushbutton's pin an input:
  pinMode(pushButton, INPUT);
}

// the loop routine runs over and over again forever:
void loop() {
  // read the input pin:
  int buttonState = digitalRead(pushButton);
  // print out the state of the button:
  Serial.println(buttonState);
  delay(10);        // delay in between reads for stability
}

border

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)
/*
  AnalogReadSerial
  Reads an analog input on pin 0, prints the result to the serial monitor.
  Graphical representation is available using serial plotter (Tools > Serial Plotter menu)
  Attach the center pin of a potentiometer to pin A0, and the outside pins to +5V and ground.

  This example code is in the public domain.
*/

// the setup routine runs once when you press reset:
void setup() {
  // initialize serial communication at 9600 bits per second:
  Serial.begin(9600);
}

// the loop routine runs over and over again forever:
void loop() {
  // read the input on analog pin 0:
  int sensorValue = analogRead(A1);
  // print out the value you read:
  Serial.println(sensorValue);
  delay(10);        // delay in between reads for stability
}

border

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.
/*!
* @file HeartrateDisplay
* @brief  Waves of blood oxygen saturation and heart rate value is displayed on the LCD
*
* @brief  Waves of blood oxygen saturation and heart rate value is displayed on the LCD
*
* @author linfeng(490289303@qq.com)
* @version  V1.1
* @date  2016-8-16
* @version  V1.0
* @date  2015-12-24
*/

#define heartratePin A1
#include "Heartrate.h"
#include "Lcd12864Shield.h"

uint16_t heartrateValue=0,heartrateValueLast=0;
uint8_t count;

Lcd12864Shield lcddisplay(10,9,8,13,11);
Heartrate heartrate(DIGITAL_MODE); ///< ANALOG_MODE or DIGITAL_MODE

char wordDisplay[]=  ///< word
{
0x00,0x00,0x01,0x03,0x07,0x0F,0x1F,0x3F,
0x1F,0x0F,0x07,0x03,0x01,0x00,0x00,0x00,
0x00,0x00,0xC0,0xE0,0xE0,0xE0,0xC0,0x80,
0xC0,0xE0,0xE0,0xE0,0xC0,0x00,0x00,0x00,///< ♥
};
char letterDisplay[]= ///< character
{

0x00,0xE0,0x10,0x08,0x08,0x10,0xE0,0x00,
0x00,0x0F,0x10,0x20,0x20,0x10,0x0F,0x00,///< 0
0x00,0x10,0x10,0xF8,0x00,0x00,0x00,0x00,
0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00,///< 1
0x00,0x70,0x08,0x08,0x08,0x88,0x70,0x00,
0x00,0x30,0x28,0x24,0x22,0x21,0x30,0x00,///< 2
0x00,0x30,0x08,0x88,0x88,0x48,0x30,0x00,
0x00,0x18,0x20,0x20,0x20,0x11,0x0E,0x00,///< 3
0x00,0x00,0xC0,0x20,0x10,0xF8,0x00,0x00,
0x00,0x07,0x04,0x24,0x24,0x3F,0x24,0x00,///< 4
0x00,0xF8,0x08,0x88,0x88,0x08,0x08,0x00,
0x00,0x19,0x21,0x20,0x20,0x11,0x0E,0x00,///< 5
0x00,0xE0,0x10,0x88,0x88,0x18,0x00,0x00,
0x00,0x0F,0x11,0x20,0x20,0x11,0x0E,0x00,///< 6
0x00,0x38,0x08,0x08,0xC8,0x38,0x08,0x00,
0x00,0x00,0x00,0x3F,0x00,0x00,0x00,0x00,///< 7
0x00,0x70,0x88,0x08,0x08,0x88,0x70,0x00,
0x00,0x1C,0x22,0x21,0x21,0x22,0x1C,0x00,///< 8
0x00,0xE0,0x10,0x08,0x08,0x10,0xE0,0x00,
0x00,0x00,0x31,0x22,0x22,0x11,0x0F,0x00,///< 9
0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x00,
0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x00,///< =
};



void lcdBegin(void)
{
  lcddisplay.initialLcd(); ///< Enable LCD
  lcddisplay.clearScreen(); ///< Clear LCD
  lcddisplay.drawXLine(48); ///< Draw a horizontal line
  lcddisplay.drawYLine(7); ///< Draw a vertical line
  lcddisplay.drawWord(7,10,0,wordDisplay); ///< Displays a word
  lcddisplay.drawLetter(7,30,10,letterDisplay); ///< Displays a character
}

void setup() {
  Serial.begin(115200);
  lcdBegin();
}

void loop() {
  unsigned char rateValue;
  heartrateValueLast = heartrateValue;
  heartrateValue = heartrate.getValue(heartratePin);  ///< A1 foot sampled values
  count = heartrate.getCnt();
  if(count)
  {
    lcddisplay.drawYLine(count+8,heartrateValue/24,heartrateValueLast/24); ///< Draw a vertical line,Step 24
  }
  else
  {
    lcddisplay.drawYLine(count+8,heartrateValue/24,heartrateValueLast/24);
  }

  rateValue = heartrate.getRate(); ///< Get heart rate value
  if(rateValue)
  {
    lcddisplay.drawLetter(7,50,3,rateValue,letterDisplay);  ///< Display values
    Serial.println(rateValue);
  }
  delay(20);
}

FAQ

'''Q1. '''Some general Arduino Problems/FAQ/Tips

'''A. '''Click the topic link on DFRobot Forum.

center For any questions, advice or cool ideas to share, please visit the DFRobot Forum.

More

link=http://www.dfrobot.com/ shopping from [link dfrobot store] or dfrobot distributor.

Clone this wiki locally