Simple Fitbit Heartrate
The goal of this project is to simplify access to the heart rate measures inside Fitbit OS applications.
It was built to do all this work easier and reduce the need to update the UI and calculations. Less you have to calculate something or update the UI and more you will reduce the impact of your application on the battery consumption.
This module includes many features to help developers :
- Get heart rate values each second.
- Get values as a single object
HeartReatMeasureis deined only when the module have new values to share to the fitbit application.
Data returned by the module respect the
1. Install the module
You could use a any package manager to install this module. it was tested with npm and pnpm.
npm install simple-fitbit-heartrate --save-dev
2. Request user's permissions
Your application should have access to :
access_heart_rate: requested to obtain heart rate of the user.
access_user_profile: requested for user custom zones.
package.json should be like this (you could request more permissions, it is not a problem) :
If permissions are not well set, you will not have exceptions :
- The callback method will return
3. Initialize the device app
app folder the
index.ts file have to :
- Import the module.
- Initialize the module with the method to call when UI should be updated with new values.
4. Use and get activities
updateHeartrate could be like this:
// Update heart rate informations
5. Refresh / update
This module has logic to periodic refresh (each second). It try to get measures only when display is on.
This modul expose :
lastexpose the last measure (it use the
stop()to use with AOD.
Contribute or report issues
You can report any issue via GitHub, if you found one, please report it! This code was open to be shared and improved. If you have an idea, tell it or send a pull request. Keep in mind that this module is built for small devices. It does not have the goal to be a Swiss knife with hundreds of functions. It is why it is simple as possible.
- clean (remove generated files from the
- lint (code quality).