Android accelerometer: Sampling Rate?

27,194

Solution 1

From developer.android.com :

The data delay (or sampling rate) controls the interval at which sensor events are sent to your application via the onSensorChanged() callback method. The default data delay is suitable for monitoring typical screen orientation changes and uses a delay of 200,000 microseconds. You can specify other data delays, such as SENSOR_DELAY_GAME (20,000 microsecond delay), SENSOR_DELAY_UI (60,000 microsecond delay), or SENSOR_DELAY_FASTEST (0 microsecond delay). As of Android 3.0 (API Level 11) you can also specify the delay as an absolute value (in microseconds).

But you should know the absolute value you specify in microseconds is only a suggestion to Android.

Solution 2

From my experience, here's what you can do. Let's start with the easiest:

[2] [in short] You cannot have a perfect accuracy (interval between readings) on (this) Android.

[2] [in long] You need to define perfect; that is, you have to define your precision. Note, this will never be a perfect 0; it never is, not even in the most critical applications imaginable. From my experience, on android, this can be even a full blown 100 ms.

[1] If your application is not critical, i.e. you just want to analyze some historical data you can try the following: save each reading with its timestamp; then, interpolate at a fixed interval; you will have a perfect time distribution but also an estimation.

Good luck, and ask if something is unclear.

Solution 3

https://github.com/dantasse/AccelerometerTest - here you can download a source code for an app that testes your real sampling rate. I don't think you can achieve in practice 100Hz or more... I'm working right now on testing sampling rates. So the answer for now is not- you cant achieve a 1 millisecond delay (even in theory).

Share:
27,194
pxm
Author by

pxm

Software Engineer doing lots of work in Java, C# and some back-end technologies. Usually a freelance designer and love to use Photoshop.

Updated on January 16, 2020

Comments

  • pxm
    pxm over 4 years

    I want to

    [1] Increase Sampling Rate of my phone's accelerometer. (SENSOR_DELAY_FASTEST gives max. about 100Hz on Xperia/ 180Hz on Nexus4, I want delay to be about 1ms or less for my work.

    [2] If [1] not possible can i make Rate constant.

    mSensorManager.registerListener(this, mAccelerometer,10000);//10000 in microsec
    

    Above code doesn't give me 10ms delay. I know it's only a suggestion to Android.

    I know These accelerometers inside phones are capable of giving much smaller delay. It's mentioned in their datasheets. So is their any method or driver/ADC programming to do [1] or [2]. I'm using ADT tools. Any other tool to do this?

    P.S: I've read

    Android: How to increase Accelerometer Sampling Rate?

    Impossibility to change the rate of the accelerometer