04-16-2018 04:57
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

04-16-2018 04:57
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
Hi guys,
I'd like to read the barometer and the heart rate at the same time in real time. Is this possible or do I have to stop one of the sensors to read the other and how do I do this?
Because I tried to start both after each other, but it doesn't work, and also starting the first, using data, closing the first and then starting the second,using data, closing the second doesn't work either.
Thanks
Answered! Go to the Best Answer.

Accepted Solutions
04-16-2018 16:17
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post


04-16-2018 16:17
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
You should be able to use them both at the same time.
import { Barometer } from "barometer";
import { HeartRateSensor } from "heart-rate";
var bar = new Barometer({ frequency: 1 }); var hrm = new HeartRateSensor();
bar.onreading = function() { console.log("ts:", bar.timestamp, "pressure:", parseInt(bar.pressure) + " Pa"); }
hrm.onreading = function() {
console.log("Current heart rate: " + hrm.heartRate);
}
bar.start();
hrm.start();
Depending what your app is doing, you could do the reading combined in a single setInterval(), or the clock tick event.
Make sure you've enabled the permissions in package.json too.

04-16-2018 16:17
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post


04-16-2018 16:17
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
You should be able to use them both at the same time.
import { Barometer } from "barometer";
import { HeartRateSensor } from "heart-rate";
var bar = new Barometer({ frequency: 1 }); var hrm = new HeartRateSensor();
bar.onreading = function() { console.log("ts:", bar.timestamp, "pressure:", parseInt(bar.pressure) + " Pa"); }
hrm.onreading = function() {
console.log("Current heart rate: " + hrm.heartRate);
}
bar.start();
hrm.start();
Depending what your app is doing, you could do the reading combined in a single setInterval(), or the clock tick event.
Make sure you've enabled the permissions in package.json too.

