Heart Rate Variability tracking with Sleep As Android

Working hard? Sporting actively? Being dragged into destructive habits? Not getting enough rest? Get a new level of insight into your bodily processes and the quality of your sleep. We proudly announce a new feature in Sleep as Android, monitoring heart rate variability via a wide range of wearable devices. Read on to learn more.

What is Heart Rate Variability?

It is no surprise that heart rate keeps changing all the time. It may rise to 180 bpm during intense exercise and fall as low as 40 bpm during deep sleep. 

A less known fact is that heart rate keeps fluctuating on a short time scale. Even if one is lying still, relaxed, the oxygen need of the body is stable, and there is no apparent reason for such variations.

The following picture demonstrates such fluctuation during 5 minutes, recorded on my own heart. The line represents gaps between individual heartbeats (so-called R-R intervals) in milliseconds. The average heart rate was 55 bpm, but the values were jumping between 45 and 65 on a short time scale – quite a wide range.

This phenomenon, called heart rate variability, or HRV, was discovered decades ago and has been intensely studied ever since. The current need for oxygen is not the only factor that controls the function of the heart. Today, we know of dozens of other factors, such as blood pressure, breath frequency, digestion, stress level, or medication, that contribute to the control of heartbeat. 

Even if the body is seemingly still, relaxed, and doing nothing, all these factors keep fluctuating, and the heart responds accordingly by random fluctuations of its beat. A healthy heart is not a metronome, and a certain level of variability is a normal function. Medical research has shown that too low variability may indicate various diseases, chronic stress, sleep deprivation, and much more.

There are countless resources on the Internet where you can learn more about this phenomenon and its health implications. Start with a popular introductory article, dive into an extensive scientific treatise, or simply try your luck with Google.

New: HRV tracking in Sleep As Android

Our app, Sleep as Android, integrates with a range of wearable devices that record individual R-R intervals. With these devices, you can now monitor HRV during your sleep and get a new level of insight into your physiological processes and the miraculous power of sleep. Here is how it works.

1. Get a supported device

  • Polar H7, H10, OH1, or Verity Sense. Recommended, tested.
  • A pulse oximeter from Happy Electronics. Recommended, tested.
  • Any device that implements the BLE Heart Rate Profile. It’s an open standard supported by various fitness trackers or health monitors. If you happen to have such a device at home, you can try to connect it with our app, and hopefully, it will work.

2. Connect it to the app, according to the documentation

3. Sleep with the device

Track your sleep, wearing the device. New information, showing your HRV analyses, appears in the sleep details chart, as well as long term statistics charts, as described in the following sections.

Short-term HRV chart

Apart from the heart rate (red line), the sleep record detail chart is now showing a violet line, depicting HRV development throughout the night. Each point on the violet line represents HRV (SDNN, in particular) for a 5-minute interval. 

The screenshot displays a typical night of mine. The first thing to notice is that the HRV curve closely corresponds to the amount of physical activity. It gets much higher in the light sleep phase, partly due to the simple fact of the body turning and tossing more intensely, partly due to internal processes related to the REM phase.

The parts that we should focus on instead are the lower values during the deep sleep phases when the body is completely still. The values then represent the natural variability of a free-running heart. These valleys are typically lower when one goes to bed very tired (a tough day at work, heavy exercise), and they get higher during the night as the body and the mind get refreshed. In the picture above, it grew gradually from 17 at the beginning of the night to more than 40 in the valleys at the end.

The actual values vary heavily among different people. We cannot generally pinpoint a “good” or “bad” number. However, they make sense in a longer-term individual context. You will surely notice these developments, having followed your HRV measurements for some time.

A Drunken Marathoner’s Chart

Compare the previous screenshot with this one.

Solely for the sake of education and enlightenment of myself and the readers, I underwent a dangerous experiment of drinking more than just a couple of beers.

The effects are obvious. The heart is boosted by the alcohol, it beats much faster than normal, and the variability gets close to zero. The values get better throughout the night, but they never return to my normal resting values.

Even though the drinker may seem to be sleeping happily, the actual nature of the underlying physiological processes is very different from normal healthy sleep.

I also get very similar readings after an unusually heavy exercise, such as running a marathon. The body is completely exhausted by the unaccustomed performance, and even a whole night of good sleep is not enough to fully recover.

Some professional coaches are using this kind of HRV analysis to monitor the training progress of athletes and to adjust their training load.

Resting HRV Before Awake

From the short-term HRV charts demonstrated above, we extract a single number that should correspond to the overall quality of your rest. We take one of the lower readings at the end of the night (technically, the 10th percentile from the last two hours) and call it HRV Before Awake. Analogously, we compute the same statistic for the first 2 hours (HRV after onset). Sleep record detail displays the two values at the bottom:

When you go to bed after a hard day and have a night of good quality sleep, the “After” value tends to be way higher than the “Before”. However, if you are not that tired in the evening, the value may remain roughly the same.

There are new items on the Charts/Trend screen. “HRV before awake” shows, well, the long term development of the HRV before awake.

“(+) HRV before awake” combines both values (after onset, before awake) in a single chart. Each night is represented by a bar, showing the two data points. If HRV increased during the night, the bar is violet, otherwise red.

This is a proprietary method that we invented to accommodate the fact that we measure the heart activity only during sleep and we need to find the representative values in a bunch of noise.

There is another approach, used by some health/fitness apps: The measurement is taken every morning just after wake-up, recording the heart for several minutes, before getting off the bed and starting usual daily activities.

Most people find this procedure too demanding. Some simply do not have the extra few minutes in the morning, others fall asleep again during the measurement.

If you are among those who are willing to adopt this regular routine, you may want to try an app specialized in this task, StressLocator by Happy Electronics. It may provide more detailed insights, as the measurements are taken under controlled conditions and permit different methods of analysis.

Total HRV for a night

Another statistic shown in the app is SDANN, which is a single number that nicely summarizes the total amount of heart rate variability throughout the entire night, including all the local minima and maxima.

Again, the values tend to vary heavily across the population, and it is difficult to pinpoint concrete “good” or “bad” readings. Some papers suggested normative values based on large-scale clinical studies. However, it makes more sense to watch the statistic in the individual context, and a decreasing trend may indicate an unfavorable condition like chronic stress and lack of proper sleep.

SDANN for a particular night is displayed in the sleep record detail,

and the long term trend can be monitored in Charts/Trend/HRV.

Try it out

All these features will be available in the next release of Sleep As Android. We are rolling them out in beta as of now, and a stable release will follow, hopefully in a few weeks.


31 thoughts on “Heart Rate Variability tracking with Sleep As Android

  1. Great, I am glad that it works for you. As for your first attempt, the recording needs to go for some time (it’s 15 minute, I think), as we need to calibrate the data and do some cleanup. Also, if we detect that there are too many suspicious values, which can happen if the sensor is not properly fixed to the arm, we do not generate the SDNN entries.

    Best Regards


  2. Hi again,

    Some more thoughts:
    Regarding the event timestamp: How do I relate this time stamp to the start of measurement, i.e. to the actual time?
    Missing data: Sometimes I have seen missing data for HR but not SDNN? Making a HR gap. Is that due to the integration of data for SDNN which makes it more robust?
    Any hint on how to import the CSV file into excel without having the latest measurement determine the maximum number of colomns? I have used import with comma as seperator but older and longer duration measurements are shopped up (but they are all there in the export csv file).



  3. Hello Henrik,

    * The timestamp is the actual time on your phone. It’s in millis since Jan 1 1970. It’s a standard convention. It is the midpoint of the 5 minute window.

    * Missing data: That’s a complex topic. Generally, data may be missing due to sensor outages, but they occur rarely. We may also drop the data if the values look nonsensical – for example, if you lie on the arm where the sensor is located, it often returns obviously wrong data (such as HR 200). However, when HRV is present, HR should be present too. I think I might know what your issue is. We generate SDNN every 5 minutes. However, HR, on the other hand, are generated at irregular intervals. It goes something like this: we compute median HR for a 5 minute window, and we generate a new HR entry only if it differs from the previous value. It often happens that the median HR is the same for several consecutive windows, so there is just one entry for 10 or 15 minute interval.

    * Yes, the import to excel may be problematic, I have no specific hints on this. Some people process the data with a simple script. Or you can sort/filter the data in a text editor manually first.

    Best Regards


  4. Can we get a Resting Heart Rate figure as well? I’d love to see a nightly RHR reading. I don’t know the optimal way to do that —lowest five percent of the night, lowest beats in a full minute— but it would be really cool to be able to track that and I don’t see a way to do that.

  5. Hello Ryan,

    The “HRV Before Awake” is supposed to be a good proxy for the resting HRV in the awake state. There have been some research showing that the two tend to be similar. You can try it yourself – after you wake up, stay still in the bed for 15 minutes, keep the sleep tracking going, and see the HRV readings in the chart.

    At the moment, we store HRV per five minute intervals. Please check the conversation just above your post. It describes how to export the HRV data, and then you can compute your own statistics from them.

    Thank you for your suggestions. We are not planning any changes to HRV functrionality at this moment, but we may implement your ideas at some point.

    Best Regards


Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.