• 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.

About

Avatar for Ishidres @Ishidres started