Physics Stack Exchange is a question and answer site for active researchers, academics and students of physics. It's 100% free.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I would like to detect if a user is moving by using an android smartphone - walking or jumping doesn't matter - want to know if the user wearing the smartphone is moving.

I have found this code example

private final SensorEventListener sensorEventListener = new SensorEventListener() {
        double calibration = SensorManager.STANDARD_GRAVITY;

        public void onAccuracyChanged(Sensor sensor, int accuracy) {

        public void onSensorChanged(SensorEvent event) {
            double x = event.values[0];
            double y = event.values[1];
            double z = event.values[2];

            double a = Math.round(Math.sqrt(Math.pow(x, 2) + Math.pow(y, 2)
                    + Math.pow(z, 2)));
            currentAcceleration = Math.abs((float) (a - calibration));

basically the squarerootof the three axis, which are raised to power 2 = sqrt(x-axis^2 + y-axis^2 + z-axis^2) = G force

And it gives readings between 0.01 and 0.2 G's - does anyone know how to translate these readings into "movement" - is it even possible this way - by use of G force

share|cite|improve this question
Do you understand the basics of the types of motion that you want to detect? How long do you expect them to last (timescale)? How abrupt do you expect them to be (scale of the acceleration itself)? I mean, at this point it looks like you are able to measure the RMS why don't you just collect some data on the kinds of motion that you are interested in. – dmckee Sep 10 '12 at 23:00
up vote 0 down vote accepted

It's possible to calculate velocity from acceleration, and indeed this is done in inertial guidance systems. However even small errors in the acceleration will give large errors in the calculated velocity and even larger errors in the calculated position.

Acceleration is related to velocity by:

$$ a = \frac{dv}{dt} $$

so to get the velocity you just integrate the acceleration with respect to time. To get the position you do a second integration of the calculated velocity with respect to time. Your problem is that a small error in the acceleration leads to an error in the velocity that grows linearly with time and an error in position that grows quadratically with time.

share|cite|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.