Arduino心率传感器heart rate sensor
简介
- 心率传感器,根据人体中的血氧饱和度变化来反应心脏跳动变化,可以实时打印心率值。
- 本模块可在数字和模拟两种输出模式之间切换,当配有显示器时,更可以直观的显示实时血氧波形和心率值。
- 本产品尺寸小巧,接线简单,直接接在arduino模拟口上就可以使用,是你DIY的时候一个必不可少的小模块。
注:血氧饱和度是血液中被氧结合的氧合血红蛋白的容量占全部可结合的血红蛋白容量的百分比,即血液中血氧的浓度,它是呼吸循环的重要生理参数。
产品参数
- 工作电压 5V
- 接口类型 模拟/数字
- 尺寸 28mm x 24mm
引脚说明
心率传感器引脚图
心率传感器引脚表
使用教程
教程1
使用Arduino板测试血氧饱和度值,输出心率值。可以把传感器直接放在手指、手腕等地方。
注:此例程需要把传感器上的开关拨向“D”档
所需硬件
- UNO x1
- 心率传感器 x1
- 杜邦线 若干
所需软件
- Arduino IDE 版本 点击下载Arduino IDE
接线图
心率传感器连线图
样例代码
点击下载库文件Heartrate.h
/*!
* @file Heartrate.h
* @brief Heartrate.h detailed description for Heartrate.cpp
*
* This is written for the heart rate sensor the company library. Mainly used for real
* time measurement of blood oxygen saturation, based on measured values calculate heart rate values.
*
* @author linfeng(490289303@qq.com)
* @version V1.0
* @date 2015-12-24
*/
#define heartratePin A1
#include "Heartrate.h"
Heartrate heartrate(DIGITAL_MODE); ///< ANALOG_MODE or DIGITAL_MODE
void setup() {
Serial.begin(115200);
}
void loop() {
unsigned int rateValue;
static unsigned char count;
static unsigned int value[SAMPLE_NUMBER]; ///< Initializes the value of sampling points
value[count]=heartrate.getValue(heartratePin,count); ///< A1 foot sampled values
count++;
if(count>=SAMPLE_NUMBER)count=0;
rateValue = heartrate.getRate(); ///< Get heart rate value
if(rateValue)
{
Serial.println(rateValue);
}
delay(20);
}
结果
通过串口打印心率值。
教程2
使用Arduino板测试血氧饱和度值,输出心率值并显示出来。可以把传感器直接放在手指、手腕等地方。
注:此例程需要把传感器上的开关拨向“A”档
所需硬件
- UNO x1
- 心率传感器 x1
- LCD12864 Sheild x1 (LCD说明)购买链接
- 杜邦线 若干
所需软件
效果视频
在LCD上显示血氧波形以及心率值
样例代码
点击下载库文件Heartrate.h和Lcd12864Shield.h
/*!
* @file Lcd12864Shield.h
* @brief Lcd12864Shield.h detailed description for Lcd12864Shield.cpp
*
* This library file is prepared for the company's LCD12864.
* Link below:http://www.dfrobot.com.cn/goods-849.html .
* You can display Chinese characters, letters, and lines
*
* @author linfeng(490289303@qq.com)
* @version V1.0
* @date 2015-12-24
*/
#define heartratePin A1
#include "Heartrate.h"
#include "Lcd12864Shield.h"
Lcd12864Shield lcddisplay(10,9,8,13,11);
Heartrate heartrate(ANALOG_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;
static unsigned char count;
static unsigned int value[SAMPLE_NUMBER]; ///< Initializes the value of sampling points
value[count]=heartrate.getValue(heartratePin,count); ///< A1 foot sampled values
if(count)
{
lcddisplay.drawYLine(count+8,value[count]/24,value[count-1]/24); ///< Draw a vertical line,Step 24
}
else
{
lcddisplay.drawYLine(count+8,value[count]/24,value[SAMPLE_NUMBER-1]/24);
}
count++;
if(count>=SAMPLE_NUMBER)count=0;
rateValue = heartrate.getRate(); ///< Get heart rate value
if(rateValue)
{
lcddisplay.drawLetter(7,50,3,rateValue,letterDisplay); ///< Display values
Serial.println(rateValue);
}
delay(20);
}
结果
显示血氧波形,以及心率值。
本文整理于DFRobot wiki
获取最新文章: 扫一扫右上角的二维码加入“创客智造”公众号