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

Heart rate on clock face

ANSWERED

I have been working on my first clock face, and one of the items I want on the face is my heart rate.  I am following the examples, but it doesn't seem to work.  I am sure its something i am missing because the heart rate shows up on the stock face.  

Any insight will be greatly appreciated!

Here's the code (I only get the "-" on the clock face, nothing logged to console):

// start code segment

let myHRM = document.getElementById("myHRM");
myHRM.text = "-";
var hrm = new HeartRateSensor();
hrm.onreading = function() {
// Peek the current sensor values
myHRM.text = hrm.heartRate;
console.log("Current heart rate: " + hrm.heartRate);
// Stop monitoring the sensor
hrm.stop();
}

// clock displays hours mins and secs fine
clock.ontick = function(evt) {
myClock.text = (" " + (parseInt(evt.date.getHours(),10) % 12)).slice(-2) + ":" +
("0" + evt.date.getMinutes()).slice(-2);
mySecs.text = ("0" + evt.date.getSeconds()).slice(-2);

// Peek HR sensor
hrm.start();

}

Best Answer
0 Votes
1 BEST ANSWER

Accepted Solutions

Newbie error.  I figured out shortly after posting that Heart Rate needed to be enabled in Package.json.  

Problem solved.

View best answer in original post

Best Answer
1 REPLY 1

Newbie error.  I figured out shortly after posting that Heart Rate needed to be enabled in Package.json.  

Problem solved.

Best Answer