Pedometer in mobile applications is a software-hardware mechanism for counting user steps based on data from the accelerometer and gyroscope. Modern smartphones use machine learning algorithms combined with sensors to accurately detect walking, running, and other types of physical activity. According to Apple HealthKit Documentation, 2025, step counting accuracy on modern devices reaches 95–97% during normal walking.
Key Takeaways
Pedometer in mobile applications is a feature that determines the number of user steps based on data from the smartphone's built-in motion sensors. Unlike mechanical pedometers of the past, the mobile pedometer uses microelectromechanical sensors (MEMS) and digital signal processing algorithms for accurate locomotion counting. Modern implementations not only count steps but also classify activity: walking, running, stair climbing.
Pedometer integration into mobile devices became possible with the introduction of the M7 motion coprocessor in the iPhone 5s in 2013, which continuously collected data from sensors with minimal power consumption. Today, all modern smartphones have hardware support for step counting at the sensor hub level — a dedicated chip that processes inertial sensor data without waking the main processor.
Step counting on a smartphone is based on analyzing accelerometer signals that measure device acceleration along three perpendicular axes (X, Y, Z). When walking, each step creates a characteristic acceleration pattern: first an upward peak when lifting the leg, then a downward peak upon landing. Step cadence is 100–130 steps/min for walking and 150–180 steps/min for running, while acceleration amplitude ranges from 2–6 m/s².
The raw accelerometer signal contains noise and high-frequency interference, so the first processing stage is low-pass filtering with a cutoff frequency of 3–5 Hz. After filtering, the acceleration vector is computed: a = sqrt(x² + y² + z²), isolating motion-related acceleration regardless of device orientation. The algorithm then detects local maxima in the signal — each maximum corresponds to one step.
To reduce false positives (e.g., from shaking in a vehicle), additional criteria are applied: minimum step amplitude (typically >1.2 m/s²), minimum interval between steps (300–400 ms for walking), and signal periodicity verification through autocorrelation. If the time intervals between peaks are irregular, the sequence is marked as random movement and not counted as steps.
The basic step detection algorithm uses threshold detection: the system looks for moments when the accelerometer signal exceeds a set threshold and then returns to a resting level. Each such event is considered a potential step. There are two approaches: peak detection and zero-crossing. Peak detection captures signal maxima, while zero-crossing detects moments when the signal crosses the mean value, which is less dependent on step amplitude.
Modern step counting algorithms use an adaptive threshold that automatically adjusts to the user's walking style. The system analyzes signal variance over the last 2–3 seconds and computes a dynamic threshold as the root mean square (RMS) multiplied by a coefficient. This allows correct step counting both during slow strolling and vigorous running without cross-calibration between activity types.
Modern pedometer implementations use not only peak detection but also machine learning for classifying movement patterns. Neural network models are trained on thousands of hours of real motion recordings from various scenarios: walking on flat surfaces, stair climbing, running, riding in vehicles. Input features include accelerometer and gyroscope time series, and the output is the probability that the current signal segment corresponds to human locomotion.
According to Google Activity Recognition research, convolutional neural network (CNN) models achieve 98% walking recognition accuracy on benchmark datasets. On Apple devices, Core ML is used with an Activity Classification model trained on data from over 100,000 volunteers. Optimized models run directly on the device (on-device inference), ensuring instant processing and preserving user privacy.
import CoreMotion
class PedometerObserver {
private let pedometer = CMPedometer()
func startTracking() {
guard CMPedometer.isStepCountingAvailable() else { return }
pedometer.startUpdates(from: Date()) { data, error in
guard let data = data else { return }
let steps = data.numberOfSteps.intValue
let distance = data.distance?.doubleValue
let floorsAscended = data.floorsAscended?.intValue
// Updating UI with step count
DispatchQueue.main.async {
// self.stepsLabel.text = "\(steps) steps"
}
}
}
func stopTracking() {
pedometer.stopUpdates()
}
}
On iOS, the CMPedometer class from the Core Motion framework is used to access the pedometer. CMPedometer provides not only step count but also distance walked, floor count (flights climbed), walking pace, and activity duration. Data is available both in real time (startUpdates) and for any arbitrary past period (queryPedometerData). The motion coprocessor (M-series) processes sensor data in hardware, reducing power consumption by 80% compared to software processing.
On Android, pedometer functionality is implemented through two hardware sensors: TYPE_STEP_COUNTER (cumulative step counter since boot) and TYPE_STEP_DETECTOR (event generation on each step). TYPE_STEP_COUNTER requires no calibration and consumes no processor power — data is updated in hardware at the sensor hub level. For accessing accumulated daily step statistics, Google Fit API is used with the DataType.TYPE_STEP_COUNT_DELTA record.
import android.hardware.Sensor
import android.hardware.SensorEvent
import android.hardware.SensorEventListener
import android.hardware.SensorManager
class StepCounter(
private val sensorManager: SensorManager
) : SensorEventListener {
private var totalSteps = 0
private var previousSteps = -1
fun startListening() {
val sensor = sensorManager.getDefaultSensor(Sensor.TYPE_STEP_COUNTER)
sensor?.let {
sensorManager.registerListener(this, it, SensorManager.SENSOR_DELAY_NORMAL)
}
}
override fun onSensorChanged(event: SensorEvent) {
if (previousSteps < 0) {
previousSteps = event.values[0].toInt()
}
val currentSteps = event.values[0].toInt()
totalSteps = currentSteps - previousSteps
}
fun getStepCount(): Int = totalSteps
override fun onAccuracyChanged(sensor: Sensor?, accuracy: Int) {}
}
Pedometer accuracy depends on several factors: smartphone placement (in hand, pocket, or bag), activity type (walking, running, stair climbing), and sensor quality. When the smartphone is carried in a pants pocket, accuracy reaches 93–97%; in a bag or backpack, it drops to 70–85%. Accuracy is also affected by the user's walking style: a shuffling gait with low acceleration amplitude produces more errors than a steady stride.
Key limitations of mobile pedometers include: inability to count steps during very slow movement (<1.5 km/h), false positives from vehicle travel, reduced accuracy during low-speed running (jogging), and the influence of gesticulation while talking. To minimize errors, modern applications use a combination of sensors (accelerometer + gyroscope + barometer) and machine learning to filter out artifacts. The barometer, for example, helps detect stair climbing and altitude changes, excluding false steps on an elevator.
Frequently Asked Questions
A pedometer in a phone uses the accelerometer, which registers acceleration with each step. The algorithm analyzes acceleration peaks along three axes, filters out noise, and determines the number of steps. Modern models also use the gyroscope and machine learning to improve accuracy and classify activity.
When carrying a smartphone in pants pockets, accuracy reaches 95–97% during normal walking. In a bag or backpack, accuracy drops to 70–85%. Walking style and surface type also affect accuracy — uneven terrain can introduce errors of up to 10–15%.
Yes, the pedometer works completely offline without an internet connection. All computations are performed on the device using built-in sensors. Internet may only be needed for synchronizing data with cloud services of fitness apps or for displaying a route map.
Different apps use different algorithms for processing sensor data, detection thresholds, and filtering methods. Some apps count steps based on raw accelerometer data, while others use system APIs (TYPE_STEP_COUNTER), and the difference in counts can reach 10–15%.
On Android, to access the pedometer, use the TYPE_STEP_COUNTER sensor through the Sensor API — it provides the cumulative step count since the last device reboot. For accessing steps for a specific day, integrate Google Fit API with the TYPE_STEP_COUNT_DELTA data type.
Summary
We will develop a mobile application turnkey
IT Sectr creates iOS and Android applications for startups and businesses since 2017. We will advise you and propose the best solution.
Read also