Skip to content
Apr 10 / kkrizka

Counting Steps With the iPod Accelerometer

During my daily run, I’ve decided that I’ll have some fun with the accelerometer in my iPod Touch. Using the RC Physics App (free from the App Store), I recorded the force felt by the iPod, hoping that I will be able to see a pattern as I run and be able to extract the number of steps taken during my run. And to no surprise, there is a pattern, as seen in the accelerometer data from a quick test run (~20 steps), shown below.

20 Step Run DataThe physics, I think, behind the above graph is quite simple. As the iPod is stationary, then it only feels the force of gravity, thus the graph is centered at 1G. But as soon as I make a step, my body rises slightly. Since the body goes from stationary to moving, it must accelerate and thus the attached iPod must accelerate. If the acceleration is upward (start of the step), then the accelerometer feels a pseudo-force that is opposite to that and thus detects an increase in gravity. But what comes up, must come down, and so my body falls back to the ground at the end of my step. Since I am now acccelerating downwards, the force felt by the iPod is upwards and a decrease in gravity (remember, gravity acts down) is detected. This is then repeated for the next step.

So to extract the number of steps, all I have to do is count how many times the gravity went from greater than 1G to less than 1G. Or similary, I can count how many times gravity turned from increasing (reaching the top) to decreasing (falling back down). The latter is much simpler and allows me to filter our random shaking of the iPod during preparation. In my case, I only count a step if the detected gravity was greater than 2G. This filters out noise and, as I found experimentally, walking. The following is the cummulative number of steps as time progressed, for the data shown above:

run-20090410-testMy run consisted of around 20 steps, which is what the method detected. Also it is sensitive to me turning around, as seen in the jump at 5 seconds.

And finally, here is the step count for my actual run:

run-20090410As you can see, I kept a pretty constant pace during the whole time. The only exception is the two points at which I reached a hill. I walked up those…

The next step is to see if I can get the iPod to this processing automatically via an application. I’m sure something like that already exists, but what is the fun in that?

One Comment

Leave a comment
  1. johannes / Dec 15 2009

    thanks a lot for this blogentry; was just searching for a simple idea to do some stepcounting and thinks this might be the best answer…

Leave a comment