# Accessing Heart Rate Data for Your ResearchKit Study

**URL:** <https://forums.kodeco.com/t/accessing-heart-rate-data-for-your-researchkit-study/7160>\
**Category:** 🎓 Courses & Articles\
**Created:** [March 4, 2016, 2:55pm UTC](https://forums.kodeco.com/t/accessing-heart-rate-data-for-your-researchkit-study/7160 "2016-03-04T14:55:55Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![mluedke](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/mluedke/32/33114_2.png) [@mluedke](https://forums.kodeco.com/u/mluedke)\
**Post date:** [March 4, 2016, 2:55pm UTC](https://forums.kodeco.com/t/accessing-heart-rate-data-for-your-researchkit-study/7160/1 "2016-03-04T14:55:55Z")

</div>

In this tutorial, you'll learn how to easily access heart rate data from HealthKit and use it in a ResearchKit study.

* * *
 This is a companion discussion topic for the original entry at [https://www.raywenderlich.com/1446-accessing-heart-rate-data-for-your-researchkit-study](https://www.raywenderlich.com/1446-accessing-heart-rate-data-for-your-researchkit-study)

---

<div class="post-metadata">

**Author:** ![dimitrit](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/dimitrit/32/37369_2.png) [@dimitrit](https://forums.kodeco.com/u/dimitrit)\
**Post date:** [July 21, 2016, 7:14am UTC](https://forums.kodeco.com/t/accessing-heart-rate-data-for-your-researchkit-study/7160/2 "2016-07-21T07:14:03Z")

</div>

Thank you Matt for this really helpful tutorial.

To use real data instead of mockdata, do I remove this line:  
let heartRateQuantity = HKQuantity(unit: HKUnit(fromString: “count/min”),  
doubleValue: Double(arc4random\_uniform(80) + 100))  
Or do I just remove ‘doubleValue: Double(arc4random\_uniform(80) + 100))’  
I’m having trouble understanding which part of the code is the mock rate and which part is real?

Also If I want to stop the measure on a ‘stop’ button tapped (eg ‘stopped walking’, like you had a button for started walking), instead of the set duration timer, how can I do that?

eg You noted that ORKActiveStep is the set duration lines “class MusicStep: ORKActiveStep {  
var clip: MusicClip!  
}”  
Do I remove that code as well as all of the code in ‘Music Step’? And then just as you have the UI Button for ‘walktapped’ which leads to HealthKitManager.startMockHeartData(), I can add another UI button for HealthKitManager.startMockHeartData()

---

<div class="post-metadata">

**Author:** ![beaunixie](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/beaunixie/32/50524_2.png) [@beaunixie](https://forums.kodeco.com/u/beaunixie)\
**Post date:** [December 20, 2016, 5:47pm UTC](https://forums.kodeco.com/t/accessing-heart-rate-data-for-your-researchkit-study/7160/3 "2016-12-20T17:47:52Z")

</div>

Hi, I am also wondering how to use the real data, have you found a solution?

---

<div class="post-metadata">

**Author:** ![shogunkaramazov](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/shogunkaramazov/32/108826_2.png) [@shogunkaramazov](https://forums.kodeco.com/u/shogunkaramazov)\
**Post date:** [November 16, 2017, 10:39pm UTC](https://forums.kodeco.com/t/accessing-heart-rate-data-for-your-researchkit-study/7160/4 "2017-11-16T22:39:33Z")

</div>

This tutorial is more than six months old so questions are no longer supported at the moment for it. We will update it as soon as possible. Thank you! :]

---

<div class="post-metadata">

**Author:** ![shogunkaramazov](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/shogunkaramazov/32/108826_2.png) [@shogunkaramazov](https://forums.kodeco.com/u/shogunkaramazov)\
**Post date:** [November 16, 2017, 10:39pm UTC](https://forums.kodeco.com/t/accessing-heart-rate-data-for-your-researchkit-study/7160/5 "2017-11-16T22:39:36Z")

</div>

Closed on November 16, 2017, 10:39pm UTC


