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

Export accelerometry data

Hello all,

I need to collect and export in a raw the data of the accelerometer sensors by minute for my bachelor tesis but I can't reach the way to do it, someone could say how do it? 

 

Thanks

Best Answer
0 Votes
5 REPLIES 5

You listen for the sensor data, send it via messaging to the companion, then from the companion to your backend using fetch().

 

Take a look at the Sensors guide, Companion guide, and the Communications>Messaging guide.

 

https://dev.fitbit.com/build/guides/

Best Answer
0 Votes

Could you please give me a sample code to export accelerometer data? I could print it on the console while the app is being used and how can i get accelerometer data in the background?

 

import { Accelerometer } from "accelerometer";
import { Barometer } from "barometer";
import document from "document";
import { HeartRateSensor } from "heart-rate";

let accelData = document.getElementById("accel-data");
let barData = document.getElementById("bar-data");
let hrmData = document.getElementById("hrm-data");

let accel = new Accelerometer();
let bar = new Barometer();
let hrm = new HeartRateSensor();

accel.start();
bar.start();
hrm.start();

function refreshData() {
let data = {
accel: {
x: accel.x ? accel.x.toFixed(1) : 0,
y: accel.y ? accel.y.toFixed(1) : 0,
z: accel.z ? accel.z.toFixed(1) : 0
},
bar: {
pressure: bar.pressure ? parseInt(bar.pressure) : 0
},
hrm: {
heartRate: hrm.heartRate ? hrm.heartRate : 0
}
};

accelData.text = JSON.stringify(data.accel);
barData.text = JSON.stringify(data.bar);
hrmData.text = JSON.stringify(data.hrm);
console.log(accelData.text);
}

refreshData();
setInterval(refreshData, 1000);

Best Answer
0 Votes

At the moment, user apps can't run in the background.

Peter McLennan
Gondwana Software
Best Answer
0 Votes

Hi Catplace, thanks for the reply... Whenever i close the app on my Ionic i see "[1:01:17 PM]App Closed" and couldn't collect the accelerometer data. Are you saying that i cannot get accelerometer data in the background? How can i raw accelerometer data and send it to Azure cloud even when the app is not in use? or could it also be stored and then uploaded via wifi at the end of the day? 

Best Answer
0 Votes

It can't be done. Your app would need to run continuously.

Peter McLennan
Gondwana Software
Best Answer
0 Votes