11-04-2017 18:22 - edited 02-04-2018 20:16
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

11-04-2017 18:22 - edited 02-04-2018 20:16
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
I have an app built which listens for heart rate using the Heart Rate Sensor. When I take the watch off it does not pick up that there is no data being sensed by the sensor. Is there a listener to listen for when readings have stopped? I have checked to see if the heart rate monitor is activated or if it has produced an error, but neither of these are triggered if the watch is taken off. I cannot see anything else in the API that would listen for this or for why the last value is being held by the heart rate sensor.
// Declare a even handler that will be called every time a new HR value is received.
heartRateMonitor.onreading = function() {
// Peek the current sensor values
//console.log("Current heart rate: " + heartRateMonitor.heartRate);
if (!heartRateMonitor.activated || heartRateMonitor.onerror) {
heartRateLabel.innerText = "--";
}
heartRateLabel.innerText = heartRateMonitor.heartRate;
//lastValueTimestamp = Date.now();
}
Any suggestions?
Answered! Go to the Best Answer.
Accepted Solutions
11-11-2017 18:20
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post


11-11-2017 18:20
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
- Who Voted for this post?
You seem to have stumbled upon a limitation with the current API implementation.
The onreading event only fires when there is a reading, so it just stops when the device is off wrist.
The onerror event doesn't fire, because offwrist isn't an error state.
We're evaluating how best to deal with this, but in the meantime you can periodically peek the reading and check its timestamp. When the device is offwrist, the reading timestamp does not get updated.
11-04-2017 22:09
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

11-04-2017 22:09
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
I read sensor data every 1/2 second. Heartrate:
// Create new HR Sensor handle let hrm = new HeartRateSensor(); hrm.onreading = function() { // Peek the current sensor values hrText.innerText = hrm.heartRate || 0; // Stop monitoring the sensor hrm.stop(); }
// Update heartrate and steps function updateOther() { // Update Heart Rate hrm.start(); }
Set timer:
setInterval(updateOther, 500);
This will update even if off the wrist.

11-04-2017 22:48
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

11-04-2017 22:48
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
Thank you but this did not help. I have checked another clock that the watch is running and it's heart rate did not change when the watch was taken off either. I am guessing this is a bug?

11-08-2017 16:55
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

11-08-2017 16:55
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
- Who Voted for this post?
Seems to be the same on the latest firmware version just out.
11-08-2017 17:03
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post


11-08-2017 17:03
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
@WauloK wrote:
Seems to be the same on the latest firmware version just out.
Did you enable the HRM permissions in package.json?

11-08-2017 21:32
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

11-08-2017 21:32
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
Yes I have. I am having heaps of issues with the Heart Rate Sensor working at all. I am in the process of doing a factory reset

11-10-2017 12:46
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

11-10-2017 12:46
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
HRM works fine. Yes, I have the permissions on. He's concern is when you take the watch off you don't get a 0 heart rate. It stays at 86 or whatever it was last on.

11-11-2017 18:20
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post


11-11-2017 18:20
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
- Who Voted for this post?
You seem to have stumbled upon a limitation with the current API implementation.
The onreading event only fires when there is a reading, so it just stops when the device is off wrist.
The onerror event doesn't fire, because offwrist isn't an error state.
We're evaluating how best to deal with this, but in the meantime you can periodically peek the reading and check its timestamp. When the device is offwrist, the reading timestamp does not get updated.
11-12-2017 17:03
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

11-12-2017 17:03
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
We're evaluating how best to deal with this, but in the meantime you can periodically peek the reading and check its timestamp. When the device is offwrist, the reading timestamp does not get updated.
--
Thanks for this. I will use this as a work around for now.

11-13-2017 04:04
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

11-13-2017 04:04
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
I did this and used:
ts = heartRate.timestamp;
now = Date.now();
As you can see I got wildly different times. I would have thought the the heart rate timestamp would have been synced to the watch time???
[22:35:15]ts: Sun Jan 04 1970 21:16:05 GMT+11:00 now: Mon Nov 13 2017 22:35:10 GMT+11:00
I have worked around it by collecting the timestamp in the on reading function:
heartRateMonitor.onreading = function() {
// Update timestamp;
lastValueTimestamp = Date.now();
// Retrieve heart rate from sensor
heartRate = heartRateMonitor.heartRate;
// Add heart rate to document element
heartRateLabel.text = heartRate;
}
and then checking it later
// time now
var now = Date.now();
// difference between now and the last time a heart reading was taken.
var difference = (now - lastValueTimestamp) / 1000;
//console.log("ts: " + lastValueTimestamp + " now: " + now);
//console.log("ts diff: " + difference);
if (difference > 5) {
heartRateLabel.text = "---";
heartRateZoneLabel.text = "---";
}

11-22-2017 18:14
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

11-22-2017 18:14
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
Yup! My Clockface was rejected from the App Gallery because it didn't zero out when off wrist 😕

