What is the variable that stores heart rate measurements in this Arduino code?

This code is used for interfacing the POLAR T31 heart rate sensor to the Arduino using a HRMI board.

I need to take multiple actions when a specific heart rate value is exceeded, so I need to know which variable stores the heart rate BPMs…

The code displays the serial monitor but I want to interact with the findings, so what is the variable that stores heart rate values in this code?

#include "Wire.h"
#include "hrmi_funcs.h"

* Configuration Information
* Change these constants to match your specific configuration.  These
* values are the factory default (no OP1-OP7 jumpers installed).  Jumper
* OP1 should be installed and jumper SJ1 removed.
* HRMI_HOST_BAUDRATE should be set to the baudrate the host will use
*   to communicate with the Arduino over the serial interface.
* HRMI_I2C_ADDR should be set to the I2C address the HRMI is configured
*   with.
#define HRMI_I2C_ADDR      127

* Program constants
#define MAX_IN_BUFFSIZE 16

* Global variables
char serInStr[MAX_IN_BUFFSIZE];   // Serial input string array
int numEntries = 0;               // Number of HR values to request
int numRspBytes;                  // Number of Response bytes to read
byte i2cRspArray[34];                // I2C response array, sized to read 32 HR values
byte hrmi_addr = HRMI_I2C_ADDR;   // I2C address to use

* Arduino initialization code segment
void setup()
// Initialize the I2C communication

// Initialize the serial interface

* Arduino main code loop
void loop()
// Request a set of heart rate values
hrmiCmdArg(hrmi_addr, 'G', (byte) numEntries);
// Get the response from the HRMI
numRspBytes = numEntries + 2;
if (hrmiGetData(hrmi_addr, numRspBytes, i2cRspArray) != -1) {
  // send the results back on the serial interface in ASCII form
  Serial.print("Request "); Serial.print(numEntries); Serial.print(" => ");
  for (int i=0; i<numRspBytes; i++) {
    Serial.print(i2cRspArray[i], DEC);
    Serial.print(" ");
// Setup to do it again
if (++numEntries > 30)
    numEntries = 0;
delay(1000);                  // Delay 1 second between commands

what is the variable that stores heart rate values in this code?

It looks like they are in the i2cRspArray array

After :
Serial.print(i2cRspArray[ i ], DEC) ;

You could add :
if ( i2cRspArray[ i ] < 5 ) Serial.print( “heart rate too low” ) ;

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.