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

Sensor data collection

Hi. I am new to Fitbit app development and not sure how to start.

I'm trying to get raw sensor data(like accelerometer, gyroscope, etc) from Fitbit sense and store it as a CSV. there is one thing that I can not understand. what exactly is the companion app? so far I know that I need to use the device API to make an app to get the data and then send the data to my phone. so when I use the companion API do I need to make an android/ios app by myself? or does the companion API runs on the official Fitbit app.

 

Best Answer
0 Votes
6 REPLIES 6

There's a brief description of the structure here. Your second guess is closest to correct: the companion API is built into the Fitbit mobile app, so your companion code runs within the context of the Fitbit app.

Unfortunately, the companion API doesn't provide any means of storing data to the phone's file system, so you'll need to send the data from your companion code to a server app somewhere. That could be a native Android/iOS app that runs on the phone, or a remote web server.

Peter McLennan
Gondwana Software
Best Answer

Peter,

 

I looked into your fitbit-accel-fetcher, but could not get it built for a Fitbit Sense. Before I dig further, since you looked into this kind of thing before, do you think it would even be realistic to assume that I could continuously get accel data for at least 12 sps, heart beat data (preferably all "beats," or at least per-minute data (including min/median/max, if possible) and may be per-minute skin temperature, while still allowing for an at least 12 hour power budget until recharging? Basically, I want to create long-term FFT time series from the accel data, especially in the 5-6Hz range, hence the 12 sps.

 

Thanks,

Hans-Werner

Best Answer
0 Votes

Hi Hans-Werner. I've managed to transfer accel data (timestamp, x, y, z) at 60Hz (by accident!) to a heroku server, so I'd say it's possible. Obviously you'll need to intersperse the other data you want into or around the accel data, but if you don't need 60Hz, there's some headroom. That was using WebSockets in real time, whereas fitbit-accel-fetcher saves batches of data on the watch and sends them subsequently. If you use the latter approach, you might want to do some calculations to verify that the file sizes won't be too large.

 

The Fitbit API doesn't provide access to temperature.

 

I can't comment on battery impact. I also have reservations about how long the comms can remain open. In theory, it should be indefinite, but...

Peter McLennan
Gondwana Software
Best Answer

Thank you for your response. I don't need 60, but 15 samples per second would be nice. Interspersing is no issue, I assume I could pack them into per-second binary buckets, and batch them to the external (companion) storage via double buffers, lets say, every two minutes as a starting point (which could help with your connection duration concern), then from there to a disk array. Since for this I don't need real-time data, moving it to the array is not time critical. I don't know the resolution of the accelerometer, but best case let's say they are 4-byte floats per axis, which would make a 2-minute buffer 4*3*15*120 or about 22 kB. Let's say 30 kB to add once-per minute heart data or whatever. That does not sound like a big deal to me? Too bad the API is incomplete w.r.t. the sensor data, such as skin temp. Also unfortunate that while the watch contraption supports WiFi, that it can only send data to a phone, rather than some TCP port on a Linux system.

 

Hans-Werner

 

Best Answer
0 Votes

That sounds fine. I think you're allowed 10MB storage (maybe 15).

I squeezed accel values into 16 bits at some point, which is still very high precision for a physical measurement. I doubt that was necessary. Be warned that JS floats are normally 8 bytes I think, but you could use a Float32Array if you need to squeeze.

Peter McLennan
Gondwana Software
Best Answer
0 Votes

Interesting. Thanks!

Best Answer