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

Accelerometer sampling

I am building a high rate of sampling application using the accelerometer. This thread seemed some what relevant. Has anyone achieved higher sampling results? Are my sensor readings valid? Here is a bit of code.

 

 

import { Accelerometer } from "accelerometer";
let accel = new Accelerometer(); var collect_data_interval = 60; // milliseconds accel.start(); var refreshData = function() {     // code using accel.x, accel.y, and accel.z } var refresh_data = setInterval(refreshData, collect_data_interval);

 

This can sample at around 14hz. If I try to decrease to a smaller interval (than 60 milliseconds as above) some of the sensor readings begin to have the same value. There seems to be some limitation past that. In fact, at 14hz, some samples can get duplicated. I can try and compensate for the inaccuracies of the timer to get a more consist time between reading the sensors to get into the tune of how long of a cycle is needed for a refreshed value from the sensor. 

 

The second thing I noticed is that the memory is highly limited on the device. So samplings at that high of a rate required efficient objects like the Float64Arrays which were perfect for sending over the message api to the companion app where you can do things but any extra process slows down the ability to sample. So achieving a 14 hertz sample rate quickly get lowered by any other operations that might be interesting. Does anyone have good techniques for dealing with these individual challenges? 

 

Best Answer
0 Votes
2 REPLIES 2

Have you tried adjusting the frequency?

var accel = new Accelerometer({ frequency: 1 });

We originally had batched readings, but they were removed temporarily. Hopefully they will return soon.

The device definitely is memory constrained.

 

Best Answer
0 Votes

The batched readings would be important. I am dealing with an app calculating the antigravitary effort but I don't see any way to get peaks of acceleration if they occurr between two samples (obtained at relatively low frequency). Is there any way to detect such acceleration peaks?

Best Answer
0 Votes