04-20-2018 00:00 - edited 04-20-2018 00:01
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

04-20-2018 00:00 - edited 04-20-2018 00:01
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
Hi,
I'm working on adding the heart rate sensor on my own clock face.
It seems working in the simulator (showing 65 BPM), but when deploying the app on my girlfriend's Ionic, the label is empty.
Here is basically what I'm doing :
- heartrate.js :
import document from "document"; import { HeartRateSensor } from "heart-rate"; import * as util from "../common/utils"; // Get a handle on the <text> element. const heartRateLabel = document.getElementById("heartRateLabel"); // Create a new instance of the HeartRateSensor object. const hrm = new HeartRateSensor(); hrm.onreading = function() { // Update the <text> element with the current heart rate sensor value. heartRateLabel.text = util.monoDigits(hrm.heartRate || 0); // Stop monitoring the sensor. hrm.stop(); } export function update() { // Begin monitoring the sensor. hrm.start(); }
- index.js :
import clock from "clock"; import * as activity from "activity"; import * as battery from "battery"; import * as date from "date"; import * as heartRate from "heartrate"; import * as time from "time"; import * as util from "../common/utils"; // Update the clock every second. clock.granularity = "seconds"; // Each second. clock.ontick = (evt) => { heartRate.update(); battery.update(); const todayDate = evt.date; date.update(todayDate); time.update(todayDate); activity.update(); }
Am I wrong somewhere?
Answered! Go to the Best Answer.

Accepted Solutions
04-22-2018 23:54
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

04-22-2018 23:54
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
I've found the problem.
When we update an app/clock face, the Fitbit App doesn't re-ask for permission, so the app doesn't have access to HR.
I've installed another clock and then mine back and it works properly now.

04-20-2018 05:55
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post


04-20-2018 05:55
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
- Who Voted for this post?
Did you enable the Heart Rate Sensor permission in the package.json?
04-20-2018 06:39
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

04-20-2018 06:39
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
Yes it is. 😕

04-21-2018 05:01
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post


04-21-2018 05:01
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
- Who Voted for this post?
My very simple clockface (still very experimental) has a miraculously working HR measurement in this way
// Reading heartrate const hrm = new HeartRateSensor(); hrm.onreading = function() { heartrateHandle.text = `${hrm.heartRate}`; } hrm.start();
it shall be noted that for some reason it is not under the clock.ontick block
04-22-2018 23:54
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

04-22-2018 23:54
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
I've found the problem.
When we update an app/clock face, the Fitbit App doesn't re-ask for permission, so the app doesn't have access to HR.
I've installed another clock and then mine back and it works properly now.

