Heart Rate Sensor (Pulse Sensor Amped)
Heart Rate Sensor
Detecting Heart Rate
Pulse Sensor Amped
- Measure heart rate on finger
- Green light useful (like Apple Watch)
Pulse Sensor Amped Wiring
Sensor |
Photon 2 |
Function |
GND |
GND |
Ground |
VCC |
3V3 |
Power (requires 3.3v) |
Data |
Analog Pin |
Data |
Library
- From Workbench, install the library
PulseSensorAmped_P2
Configuration
#include <PulseSensorAmped.h> //sensor library
const int PIN_PULSE = A0; // any analog pin
PulseSensor PulseSensorAmped; //create pulse sensor object
Initialization
void setup() {
analogRead(PIN_PULSE); // this is a workaround for a problem in the PulseSensorAmped library
PulseSensorAmped.attach(PIN_PULSE);
PulseSensorAmped.start();
Note
analogRead
needs to be before the pulse sensor is initialized. This is a workaround to fix a problem in the library. For more information, see this post
Sensor Readings
- The beats per minute can be read by adding the following function
void PulseSensorAmped_data(int BPM, int IBI) {
// BPM will be the parameter that is the current Beats Per Minute
// IBI will be the parameter that is the current Interbeat Interval
}
Other Useful Methods
- The following function will be called when the signal is lost
void PulseSensorAmped_lost(void) {
}
Credits