Example Code for Arduino-Heart Rate BPM Output

Output heart rate value in BPM using the HeartSpeed library

Hardware Preparation

Software Preparation

Wiring Diagram

SEN0213 Heart Rate Monitor Sensor Connection Diagram

Sample Code

click to download the head file HeartSpeed


/*!
 * @file heart_test.ino
 * @copyright   [DFRobot](https://www.dfrobot.com), 2016
 * @copyright   GNU Lesser General Public License
 * @author [jianghao]([email protected])
 * @version  V1.0
 * @date  20160-07-8
 */

/*!
 * @brief Library for DFRobot's IR Position RAW_DATA
 * @author [jianghao]([email protected])
 */
#include "HeartSpeed.h"

HeartSpeed heartspeed(A1);                  ///<The serial port for at observe pulse.
//HeartSpeed heartspeed(A1,RAW_DATA);       ///<The serial port mapper, observation of ECG diagram.

/* Print the position result */
void mycb(uint8_t rawData, int value)
{
  if(rawData){
    Serial.println(value);
  }else{
    Serial.print("HeartRate Value = "); Serial.println(value);
  }
}
void setup() {
  Serial.begin(115200);
  heartspeed.setCB(mycb);    ///Callback function.
  heartspeed.begin();///The pulse test.
}

void loop() {

}

/******************************************************************************
  Copyright (C) <2016>  <jianghao>
  This program is free software: you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation, either version 3 of the License, or
  (at your option) any later version.
  This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.
  You should have received a copy of the GNU General Public License
  along with this program.  If not, see <http://www.gnu.org/licenses/>.
  Contact: [email protected]
 ******************************************************************************/

Result

  1. Open the Arduino IDE 1.6.6 (or above) "Serial Port";

  2. Then you could see the output signal in BPM.

SEN0213 Heart Rate Monitor Sensor Expected Result

Was this article helpful?

TOP