upm  0.5.1
Sensor/Actuator repository for libmraa (v0.9.1)
 All Data Structures Files Functions Variables Enumerations Enumerator Macros Groups Pages
Public Member Functions
GroveEHR Class Reference

API for the Grove Ear-clip Heart Rate Sensor. More...

Detailed Description

UPM module for the Grove ear-clip heart rate sensor. It is used to measure your heart rate.

groveehr.jpg
// Instantiate a Grove Ear-clip Heart Rate sensor on digital pin D2
upm::GroveEHR* heart = new upm::GroveEHR(2);
// set the beat counter to 0, init the clock and start counting beats
heart->clearBeatCounter();
heart->initClock();
heart->startBeatCounter();
while (shouldRun)
{
// we grab these just for display purposes in this example
uint32_t millis = heart->getMillis();
uint32_t beats = heart->beatCounter();
// heartRate() requires that at least 5 seconds pass before
// returning anything other than 0
int hr = heart->heartRate();
// output milliseconds passed, beat count, and computed heart rate
cout << "Millis: " << millis << " Beats: " << beats;
cout << " Heart Rate: " << hr << endl;
sleep(1);
}
heart->stopBeatCounter();

Public Member Functions

 GroveEHR (int pin)
 
 ~GroveEHR ()
 
uint32_t getMillis ()
 
void initClock ()
 
void clearBeatCounter ()
 
void startBeatCounter ()
 
void stopBeatCounter ()
 
uint32_t beatCounter ()
 
int heartRate ()
 

Constructor & Destructor Documentation

GroveEHR ( int  pin)

GroveEHR constructor

Parameters
pinDigital pin to use
~GroveEHR ( )

GroveEHR destructor

Member Function Documentation

uint32_t getMillis ( )

Returns the time of milliseconds elapsed since initClock() was last called.

Returns
Elapsed milliseconds
void initClock ( )

Resets the clock

void clearBeatCounter ( )

Resets the beat counter to 0. The beat counter should be stopped via stopBeatCounter() prior to calling this function.

void startBeatCounter ( )

Starts the beat counter

void stopBeatCounter ( )

Stops the beat counter

uint32_t beatCounter ( )

Gets the beat Counter

Returns
Beat counter
int heartRate ( )

Computes the heart rate

Returns
Computed heart rate

The documentation for this class was generated from the following files: