Cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Heart Rate Sensor heartrate value not being returned

ANSWERED

When using the provided tutorial code for the HR meter it's failing to pull back heart rate values. Below is a snippet of the code. When I switch it to pull it directly with setinterval() I see the value is showing null. I've restarted my watch, turned the heart rate monitor on and off and still nothing. I'm also able to read values from the other sensors so this is just an issue with the HR monitor which is the main sensor I need. Your assistance is greatly appreciated.

 

/ Create a new instance of the HeartRateSensor object
var hrm = new HeartRateSensor();

// Declare a even handler that will be called every time a new HR value is received.
hrm.onreading = function() {
// Peek the current sensor values
console.log("Current heart rate: " + hrm.heartRate);
hrLabel.text = hrm.heartRate;
lastValueTimestamp = Date.now();
}

// Begin monitoring the sensor
hrm.start();

// And update the display every .5s
setInterval(updateDisplay, 500);

Best Answer
0 Votes
1 BEST ANSWER

Accepted Solutions

Check that you've granted permission to the heart rate sensor in the package.json

View best answer in original post

Best Answer
0 Votes
2 REPLIES 2

Check that you've granted permission to the heart rate sensor in the package.json

Best Answer
0 Votes

TY so much that was the key.

Best Answer
0 Votes