title: How to get HRV (Heart Rate Variability) from HR (Heart Rate)
body: <p>I am working on application in which I have to read heart beat till one minute and calculate heart rate variability from it.</p>
  
  <p>for reading heart beat I am using strap(Polar)</p>
  
  <p><a href="http://www.raywenderlich.com/52080/introduction-core-bluetooth-building-heart-rate-monitor" rel="noreferrer">Heart beat reading code I have used from link</a></p>
  
  <p>for calculating HRV I gone through following links but nothing helps:</p>
  
  <ol>
  <li><p><a href="https://www.google.co.in/url?sa=t&amp;rct=j&amp;q=&amp;esrc=s&amp;source=web&amp;cd=3&amp;cad=rja&amp;uact=8&amp;ved=0CCkQFjAC&amp;url=http%3A%2F%2Fdownloads.hindawi.com%2Fjournals%2Fmse%2F2012%2F931943.pdf&amp;ei=CKC6U6_kH86XuAStoYD4CQ&amp;usg=AFQjCNGImCuz1kBCW7JSLJ2h4Vy2yPiSkQ&amp;bvm=bv.70138588,d.c2E" rel="noreferrer">Research article on SDNN/RMSSD</a></p></li>
  <li><p><a href="http://www.biopac.com/researchApplications.asp?Aid=32&amp;AF=450&amp;Level=3" rel="noreferrer">RMSSD for HRV Analysis</a></p></li>
  <li><p><a href="http://www.ncbi.nlm.nih.gov/pmc/articles/PMC3834240/#!po=46.4286" rel="noreferrer">Comparison between HR and HRV</a></p></li>
  </ol>
  
  <p>Please provide formula from which i can get HRV(RMSSD) from HR and duration to get HR is one minute.</p>
  
  <p>Any help would be appreciated..</p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>I have got RR value with following code:</p>
  
  <pre><code>- (void) updateWithHRMData:(NSData *)datas {
  
  const uint8_t *reportData = [datas bytes];
  
  uint16_t bpm = 0;
  uint16_t bpm2 = 0;
  
  if ((reportData[0] &amp; 0x04) == 0)
  {
      NSLog(@"%@", @"Data are not present");
  }
  else
  {
  
      bpm = CFSwapInt16LittleToHost(*(uint16_t *)(&amp;reportData[2]));
  
      bpm2 = CFSwapInt16LittleToHost(*(uint16_t *)(&amp;reportData[4]));
  
      if (bpm != 0 || bpm2 != 0) {
  
              NSLog(@"%u", bpm);
  
              if (bpm2 != 0) {
                  NSLog(@"%u", bpm2);
              }
      }
  
  }
  
  }
  </code></pre>
  
  <p>My Question is I am getting RR values like:666,636,645 .... etc
  but when I use <code>HRV +</code> application and export RR values via email it shows values like 0.785,0.734,0.724 etc.. and if I do calculation with RR values of mine with following formula:</p>
  
  <p>RMSSD = <img src="https://i.stack.imgur.com/OQ2TB.jpg" alt="enter image description here"></p>
  
  <p>It gives me completely wrong result.</p>
  
  <p>Please help.</p>
  
  <p><strong>EDIT:</strong></p>
  
  <pre><code> //==================RR
  if ((reportData[0] &amp; 0x04) == 0)
  {
      NSLog(@"%@", @"Data are not present");
  }
  else
  {
      uint16_t rr2 = CFSwapInt16LittleToHost(*(uint16_t *)(&amp;reportData[2]));
      RR = CFSwapInt16LittleToHost(*(uint16_t *)(&amp;reportData[4]));
  
      //sometimes two values of RR may found so there are two RR: RR and rr2 which added in array and all calculation goes after one minute
  
      if (rr2 &gt; 0 || RR &gt; 0) {
  
          NSLog(@"RR2 %u", rr2);
          if (rr2&gt;0) {
              [RRArray addObject:[NSNumber numberWithInt:rr2]];
          }
          if (RR != 0) {
              NSLog(@"RR %u", RR);
              [RRArray addObject:[NSNumber numberWithInt:RR]];
  
              }
  
          }
  
      }
  
  }
  </code></pre>