Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6762399
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T14:19:16+00:00 2026-05-26T14:19:16+00:00

I am a bit puzzled by the sensor reading rates in Android. The code

  • 0

I am a bit puzzled by the sensor reading rates in Android. The code below reports delays of ~53 ms (ZTE Blade, rate sensor events is set to SENSOR_DELAY_FASTEST).

public void onSensorChanged(SensorEvent event) {
 synchronized (this) {
  switch (event.sensor.getType()) { 
   case Sensor.TYPE_MAGNETIC_FIELD:
     TimeNew = event.timestamp;
     delay = (long)((TimeNew - TimeOld)/1000000);
     TimeOld = TimeNew;
     Log.d("Test", delay + " ms");
    break;
    }
   }
  }

The log:

DEBUG/Test(23024): 52 ms
DEBUG/Test(23024): 53 ms
DEBUG/Test(23024): 54 ms
DEBUG/Test(23024): 56 ms
DEBUG/Test(23024): 52 ms
DEBUG/Test(23024): 52 ms
DEBUG/Test(23024): 55 ms
DEBUG/Test(23024): 52 ms

If we want to average say 100 samples, and then save the data, the time between each 100th sample will vary significantly. That is presumably because the sensor value is not changing in regular time periods.

But am I missing something ? Is there a way to get (more) regular measurements (e.g. 100 ms) ? Or perhaps I should go for averaging over a specific period of time instead of no.of samples ?

Also 50ms seems to be a bit long time. Could that be hardware limitation of the device ? Will this number vary on different platforms ?

Any advice is appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T14:19:17+00:00Added an answer on May 26, 2026 at 2:19 pm

    I would average over a period of time rather than a number of samples. I would expect different devices with different device capabilities would generate substantially different results if you were to go with the number-based approach. If you want more regular management of the sampling I would probably disconnect the test from the event and just poll the device at whatever frequency you wish.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm going through a Fortran code, and one bit has me a little puzzled.
I am a bit puzzled reading this: Gcc 4.5 online manual --- Standards section
I found some confusing code during code review and am a bit puzzled. Doing
While trying to optimize a code, I'm a bit puzzled by differences in profiles
I am a little bit puzzled as to how I can optimize my program
I'm a bit puzzled: From Cocoa Programming For Mac OS X (page 63, 3rd
I am a bit puzzled with my Regex results (and still trying to get
I am a bit puzzled by this strange behavior on CentOs 5.4 when starting
I'm a bit puzzled about the conditional operator. Consider the following two lines: Float
I'm doing simple divisions in c#, and I am a bit puzzled by its

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.