top of page
  • Writer's pictureSubir Biswas

How Does A Smart Watch Count Steps | Tech-Knowledge

Updated: Nov 14, 2021

Earlier a watch was used to check the time. Later the date and time included in this. In the digital watch you can even set an alarm, use it as a stopwatch etc. But smart watches are a big innovation in the wearable industry. It is still digital but performing too many other activities. The most common use case of a smartwatch or smart band is to count the steps. Originally it was termed as Pedometer. This became more popular as this devices used an everyday exercise progress monitor. This has a big impact on health.


Early days a weighted mechanical switch used to detect steps, plus a simple counter. When these devices are shaken, one can hear a metal ball sliding back and forth, or a pendulum striking stops as it swings. But today, it is based on MEMS (microelectromechanical systems) sensors and suitable software to detect steps efficiently. MEMS sensors permit more accurate detection of steps. Taking advantage of the low cost and minimal space- and power requirements of MEMS sensors, pedometers / step counters are being integrated into the fitness tracker or in the smart watches or even in smart phones - basically, all portable consumer electronic devices.


In simple words it uses a 3 Axis Accelerometer to count the steps. Some models of phones/watches use motion sensors (Gyroscope) as well in addition to an accelerometer for more accurate results.

How Does A Smart Watch Count Steps | Tech-Knowledge

Understand the Operation:

The acceleration value differs based on the relevant parameter either you are walking or running. The three components of motion for an individual are forward (roll), vertical (yaw), and side (pitch), as shown in above figure. The MEMS sensor senses acceleration along its three axes i.e. x, y, and z. The pedometer will be in an unknown orientation, so the measurement accuracy should not depend critically on the relationship between the motion axes and the accelerometer's measurement axes. Let's think about the nature of walking. Figure below depicts a single step, defined as a unit cycle of walking behavior, showing the relationship between each stage of the walking cycle and the change in vertical and forward acceleration.

At least one axis will have relatively large periodic acceleration changes, no matter how the pedometer is worn, so peak detection and a dynamic threshold-decision algorithm for acceleration on all three axes are essential for detecting a unit cycle of walking or running. A typical pattern of x, y and z measurements corresponding to vertical, forward, and side acceleration of a running person captured in figure below from the test.

Algorithm for Steps Counter:

A digital low pass filter is introduced to smooth the signals shown in the above graph. Few registers and a summing unit can be used. If more registers can be used then the acceleration data will be smoother, but on the other hand the response time would be slower.


The internal logic continuously updates the maximum and minimum values of the acceleration every specific number of samples (for example 100) in all 3 axis's. The average value is called the dynamic threshold level. For the following 100 samples, this threshold level is used to decide whether steps have been considered or not. As it is updated every 100 samples (specific number of samples as considered earlier), the threshold is termed as dynamic threshold. In addition to dynamic threshold, dynamic precision is also used for further filtering. A linear-shift-register and the dynamic threshold are used to decide whether an effective step has been taken.

A step is defined as happening if there is a negative slope of the acceleration plot (sample_new < sample_old) when the acceleration curve crosses below the dynamic threshold.

The step counter calculates the steps from the x-axis, y-axis, or z-axis, depending on which axis's acceleration change is the largest one. If the changes in acceleration are too small, the step counter will discard them.


The step counter can work well by using this algorithm, but sometimes it seems too sensitive. When the pedometer vibrates very rapidly or very slowly from a cause other than walking or running, the step counter will also take it as a step. Such invalid vibrations must be discarded in order to find the true rhythmic steps. Time window and count regulation are used to solve this problem. Time window is used to discard the invalid vibrations. We assume that people can run as rapidly as five steps per second and walk as slowly as one step every two seconds. Thus, the interval between two valid steps is defined as being in the time window [0.2 s to 2.0 s]; all steps with intervals outside the time window should be discarded.


This algorithm uses a 100-Hz data rate (10 ms). A register named interval records how many times the data have updated during the two steps. If the value of interval is between 20 and 200, it means that the time between two steps is in the valid window [0.2 s to 2.0 s]; otherwise, the interval is outside the time window and the step is invalid.

Software Logic or Steps:

Here are the steps required to follow while preparing the code.

  • Firstly the pedometer starts the calibration as soon as it gets powered.

  • Then in the void loop function, it continuously gets the data from X, Y, and Z-axis filter those values to trim.

  • Find Max and Min values fro all axis's.

  • Check the sample counter = 100?

  • Then it compares the Max and Min values with the threshold values to count the step number.

  • If the acceleration vector crosses the threshold value, then it increases the step count; otherwise, it discards the invalid vibrations.

//A sample calibration code for MEMS sensor as ADXL335
calibrate_accelerometer()
{
for (int i = 0; i < 100; i++) {
    xval[i] = float(analogRead(xpin) - 345);
    sumx = xval[i] + sumx; 
    yval[j] = float(analogRead(ypin) - 346);
    sumy = yval[i] + sumy;
    zval[j] = float(analogRead(zpin) - 416);
    sumz = zval[i] + sumz; }
    xavg = sumx / 100.0;
    yavg = sumy / 100.0;
    zavg = sumz / 100.0;
}

Different manufactures use different makes and they select different sensitivity to measure. You will get different accuracy among the makers.


Few popular manufacturers of accelerometers ICs.


11,886 views2 comments

Related Posts

See All
Post: Blog2 Post
bottom of page