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.
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
You can calculate the RMSSD using the differences in ms between heartbeats like this:
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.