06-01-2018 03:29
06-01-2018 03:29
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
06-01-2018 10:36
06-01-2018 10:36
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.
06-16-2018 14:08
06-16-2018 14:08
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);
06-16-2018 14:47
06-16-2018 14:47
At the moment, user apps can't run in the background.
06-17-2018 12:11
06-17-2018 12:11
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?
06-17-2018 13:38
06-17-2018 13:38
It can't be done. Your app would need to run continuously.