Cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Real time heart rate into PC (for Research use)

ANSWERED

Hello! 
Is there any way to transmit heart rate data into a pc? I am looking for a way to stream the data, or a very quick, close to real-time update to a standalone PC - without the added lag/difficulty of creating several layers of applications and transmit the data over the internet (WebAPI?). Ideally, an C# or python example would be greatly appreciated.  


This is part of a university research project. I just need the live heart rate data and not other information from the user (not even UserId or any other personal identifier).

 

Thanks in advance!

 

Best Answer
1 BEST ANSWER

Accepted Solutions

1. The watch can only communicate directly with the companion, so the short answer is 'yes'. You may be able to run the companion component within Fitbit's Win10 app, but I don't think that's as current as the Android and iOS versions so attempting to do so could create additional complications.

2. I don't think so. You're limited to what the API provides.

Peter McLennan
Gondwana Software

View best answer in original post

Best Answer
0 Votes
9 REPLIES 9

It's possible but very difficult. Multiple layers of code are unavoidable, although you can avoid streaming over the internet.

Recommended architecture:

  • Watch clockface/app sends data to its companion component via messaging. (File transfer is more reliable, but slightly slower.)
  • Companion sends data via WebSocket to a server program running on the same device as the Fitbit app. This avoid having to use https. You can write the server in any suitable language that runs on your phone/tablet.
  • PC connects with abovementioned server using WebSocket.
  • Server sends data to PC via WebSocket.
Peter McLennan
Gondwana Software
Best Answer

Hello Peter! Thanks for the quick answer. 

 

I was fearing that I would need some architecture like the one described, from reading other posts on the forum. Thank you for the clarification. 
I have a couple of follow-up questions, if I may:

 

1. Is it mandatory to have the Companion App running on a phone or tablet? For my use case, it is a relay node that serves no purpose. Furthermore, it means that the data will travel wirelessly 2 times (from the watch to the companion, and then from the companion to the pc). If the answer is "Yes, you need the Companion App", then could the Companion app be made so as to run on a PC instead of a portable device?  

2. I think I have enough expertise to manually set the communication protocol, to communicate directly with the PC - with some specification details. Would that be an option from the fitbit side? I repeat this is for a specific experiment setup at the University.

Best Answer
0 Votes

1. The watch can only communicate directly with the companion, so the short answer is 'yes'. You may be able to run the companion component within Fitbit's Win10 app, but I don't think that's as current as the Android and iOS versions so attempting to do so could create additional complications.

2. I don't think so. You're limited to what the API provides.

Peter McLennan
Gondwana Software
Best Answer
0 Votes

I understand. Thanks again for the quick answer, Peter.

Best,

Best Answer

👍I hope you have a go at it!

Peter McLennan
Gondwana Software
Best Answer
0 Votes

Amendment to suggested architecture...

It's possible that iOS has slacker security than Android, with the result that the companion component may be able to communicate directly with any machine on the same LAN without requiring https. If so, the server component could be hosted on the PC. The .net app itself could possibly perform the server role, which would eliminate one link in the chain.

In addition, rather than using a WebSocket to communicate between server and client .net app (assuming they must be distinct), it might be possible to handle that communication by developing your own API (or applying a prefabricated one). The .net client would need to register a callback function with the server; the server would call that function whenever it receives new data. It may be easier just to use WebSockets which already allow this across different operating systems.

Peter McLennan
Gondwana Software
Best Answer
0 Votes

Hello again Peter, apologies for the late reply, and thanks for the addendum!
I will give it a try. 
I was wondering, could I hook up a client .net app to read directly from the WebSocket that the Companion app will be publishing? (Related to the architecture on your first reply). I am not sure why I would need an "internal" data relay inside the mobile device, i.e. from the Companion app to a 'server' app, and then to an external client app. Is there any limitation on the Companion app that I am not understanding? Thanks ahead!

Best Answer
0 Votes

The short answer to the question about a direct companion-to-.net connection is 'yes'.

The complication I see is security, and the situation depends on the companion's operating system:

  • If the companion is on iOS, I think it can communicate directly with any device on your LAN without requiring https (or wss).
  • If the companion is on Android, it can only communicate with applications on the same device (equivalent to localhost) without requiring https/wss. A .net app would presumably be running on a different machine, so that machine would need a non-self-signed SSL certificate. Those are hard to install (well, too hard for me).

Because my companion is on Android, and my desktop machine doesn't have the required certificate, I had to use a server app on Android to get the data off the device. Your circumstances may not be so constrained.

Peter McLennan
Gondwana Software
Best Answer

I dont know if you still need this but, There is a github repository that walks you trough a live view of the heartrate with pretty decent latency. I dont know if I can include links i will try https://github.com/bfroggio/heart-of-frogg 

Best Answer
0 Votes