• You can calculate the RMSSD using the differences in ms between heartbeats like this:

    function calculateRMSSD(RRIntervals) {
          var sumOfDifferencesSquared = 0;
          for (var i = 0; i < RRIntervals.length - 1; i++) {
              var difference = RRIntervals[i + 1] - RRIntervals[i];
              sumOfDifferencesSquared += difference * difference;
          var meanSquaredDifference = sumOfDifferencesSquared / (RRIntervals.length - 1);
          var rmssd = Math.sqrt(meanSquaredDifference);
          return rmssd;

    This is one of many ways to calculate the stress level. The event Bangle.HRM only gives the current heart beat calculated, however, the event doesn't get fired at exactly the time when a heartbeat was recognized.

    I know there is a .raw property that provides raw data by the sensor, which you could use to manually replicate the algorithm that measures when individual heart beats occurred, however I believe this procedure is kind of reinventing the wheel.

    I'm pretty sure the data about the individual time differences between heart beats already exists somewhere because otherwise the algorithm couldn't calculate the heart beat.

    So, how do I get the differences between individual heart beats? Thanks.

  • Hi - initially we had an 'open' HRM algorithm which did detect individual beats and sent an event for each beat, but it didn't deal very well with physical movement of the watch and eventually (early 2023) I caved in and used the binary-only algorithm provided by the sensor manufacturer which does a better job. That algorithm appears to use a frequency-based method which means you can't just ask it when a heart beat is.

    So I'm afraid now, you only have two choices:

    • Make a special build with the relevant lines changed to enable the open HRM monitor
    • Make your own HRM beat detection using the raw values you get
  • Understood, thanks. I'll try to use my own HRM beat detection using raw data then (as soon as I got the time) and will share it here for feedback then if you guys wanna.

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview

How to get exact timestamps of individual heart beats for RMSSD to calculate HRV for stress analysis?

Posted by Avatar for Ishidres @Ishidres