Core Motion: essence, motion sensors and data processing

Author: IT Sectr Published: 2026-03-25 Reading time: 8 min

The Core Motion framework is a system component of iOS that provides access to accelerometer, gyroscope, magnetometer and pedometer data on Apple devices. According to Apple Developer Documentation, 2025, the framework processes raw sensor data and converts it into understandable metrics — acceleration, angular velocity, orientation and step count. A single API for all motion sensors allows developers to create pedometers, fitness apps and games with device tilt control.

Key Takeaways

  • Core Motion — Apple framework for processing data from iPhone and iPad motion sensors.
  • CMMotionManager — central class for accessing accelerometer, gyroscope and magnetometer.
  • CMAltimeter — class for obtaining relative altitude and pressure change data.
  • CMPedometer — class for counting steps, distance traveled and movement speed.
  • CMDeviceMotion — combined data with gravity filtering (userAcceleration).

What is Core Motion?

Core Motion is a system framework by Apple, introduced in iOS 4 for working with device motion sensors. It provides a unified interface for accessing the accelerometer, gyroscope, magnetometer and pedometer, freeing the developer from working with hardware drivers at a low level.

The key advantage of Core Motion is hardware filtering of data. The framework automatically combines accelerometer and gyroscope readings to calculate pure userAcceleration without the gravitational component, and also provides device orientation in space in the form of quaternions and Euler angles.

According to Apple WWDC 2023, Core Motion is used in over 80% of fitness apps on the App Store. The framework is optimized for power consumption — the sensor polling frequency automatically decreases when there are no subscribers, extending the device’s battery life.

An important architectural feature is the use of the M-series coprocessor (Motion coprocessor), which processes motion sensor data independently of the main A-series processor. Starting with the M7 chip (iPhone 5S), the coprocessor continuously collects accelerometer and gyroscope data, allowing CMPedometer and CMAltimeter to work in the background with the screen locked while consuming less than 1 mW. This became possible thanks to hardware isolation: the coprocessor has its own non-volatile memory and data bus independent of the main system.

Core Motion Architecture

Core Motion architecture is built on a singleton model through CMMotionManager. The application obtains a single manager instance and through it configures the update frequency, starts or stops data collection for each sensor type. Data arrives through closure blocks at the specified interval.

The framework uses two modes of data retrieval: pull (active polling via startAccelerometerUpdates) and push (passive reception via startAccelerometerUpdatesToQueue). Push mode is preferable for UI applications since data is delivered to the specified queue without blocking the main thread.

swift
import CoreMotion

let motionManager = CMMotionManager()
motionManager.accelerometerUpdateInterval = 0.1

guard motionManager
    .isAccelerometerAvailable else { return }

motionManager.startAccelerometerUpdates(
    to: OperationQueue.current()!
) { data, _ in
    guard let accel = data?.acceleration else { return }
    print("X: \(accel.x), Y: \(accel.y), Z: \(accel.z)")
}

Core Motion Sensors

Core Motion provides access to four sensor categories: the accelerometer measures linear acceleration along three axes, the gyroscope measures angular rotation velocity, and the magnetometer measures magnetic field strength for the compass. The fourth category is combined CMDeviceMotion data, which includes filtered readings from all sensors.

CMDeviceMotion is the most valuable class for development. It provides userAcceleration (acceleration without gravity), rotationRate (rotation speed), magneticField (magnetic field vector) and attitude (device orientation as a quaternion or Euler angles). To calculate attitude, Core Motion uses sensor fusion of the gyroscope and accelerometer using an algorithm similar to a complementary filter.

The magnetometer is used for gyroscope drift correction. A pure gyroscope accumulates errors over time due to temperature drift and noise — the magnetometer and accelerometer correct this error, providing orientation accuracy of 1–2 degrees in a static position.

swift
guard motionManager
    .isDeviceMotionAvailable else { return }

motionManager.deviceMotionUpdateInterval = 1.0 // 1 Hz

motionManager.startDeviceMotionUpdates(
    using: .xArbitraryZVertical,
    to: OperationQueue.current()!
) { motion, _ in
    guard let attitude = motion?.attitude else { return }
    print("Roll: \(attitude.roll)")
    print("Pitch: \(attitude.pitch)")
    print("Yaw: \(attitude.yaw)")
}

Pedometer and Altimeter

CMPedometer is a class for counting steps, distance traveled and movement pace. It uses accelerometer data with hardware processing on the M-series motion coprocessor (M7/M8/M9/M10/M11). This allows it to work in the background with minimal power consumption — about 1% battery per 8 hours of continuous tracking.

CMAltimeter is a class for determining relative altitude based on the barometer installed in iPhone 6 and newer. It shows altitude change relative to the starting point with accuracy of about 1 meter. It is used in fitness apps for floor counting and in navigation apps for determining elevation changes.

CMPedometer data is available with a delay of no more than 5 seconds for current readings. For historical data, a 7-day lookback is available via queryPedometerData. The pedometer automatically recognizes walking, running and cycling — these activity types are available through queryPedometerData with filtering by type.

Accuracy and Limitations

CMPedometer accuracy is about 95% during normal walking and decreases to 90% during running. Accuracy is affected by: phone placement in a pocket or backpack, shoe type and surface. Apple recommends using CMPedometer in combination with Core Location for distance determination outdoors — GPS provides more accurate distance while Core Motion handles step counting.

swift
let pedometer = CMPedometer()

guard CMPedometer
    .isStepCountingAvailable() else { return }

pedometer.startUpdates(from: Date()) { data, _ in
    guard let pedData = pedometerData else { return }
    print("Steps: \(pedData.numberOfSteps)")
    print("Distance: \(pedData.distance)")
}

// Altimeter access
let altimeter = CMAltimeter()
altimeter.startRelativeAltitudeUpdates(
    to: OperationQueue.current()!
) { data, _ in
    print("Altitude: \(data?.relativeAltitude)")
}

Integrating Core Motion into an App

Integrating Core Motion does not require special permissions or entitlements — just add the framework import and create a CMMotionManager instance. However, for CMPedometer starting with iOS 11, authorization is required via CMStepCounter or by using CMPedometer with a system permission dialog.

The integration process includes: creating a CMMotionManager, checking sensor availability via isAccelerometerAvailable / isGyroAvailable / isDeviceMotionAvailable, setting the update interval and starting data collection. It is important to stop updates via stopAccelerometerUpdates when data is no longer needed — this is critical for power consumption.

For background operation, CMPedometer and CMAltimeter do not require additional configuration — they use the motion coprocessor. For CMMotionManager, background operation is not available — data is only collected when the app is active and in the foreground. The only condition for CMPedometer is that the app must have been launched at least once by the user after installation to initialize the subscription to background updates from iOS.

Power Consumption Optimization

Core Motion supports adaptive polling frequency: if the app does not need real-time data, setting the interval to 1–5 Hz is sufficient instead of 100 Hz. For fitness apps, the optimal frequency is 10 Hz for CMMotionManager and 1 Hz for CMPedometer. Apple recommends reducing the frequency to the minimum necessary for correct operation.

For tilt-controlled games, a frequency of 60–100 Hz is necessary to ensure smooth response. In this case, it is important to use startDeviceMotionUpdates with a separate queue and process data as quickly as possible. According to Apple, 60 Hz consumes approximately 2 times more power than 30 Hz.

When working with Core Motion, it is important to consider device compatibility: the gyroscope is absent on iPhone 3GS and iPad 1st generation, the magnetometer is absent on all iPads without a cellular module. Static methods isAccelerometerAvailable, isGyroAvailable and isDeviceMotionAvailable of the CMMotionManager class are used to check sensor availability. On the simulator, Core Motion returns test data — for debugging on a real sensor, a physical Apple device is always necessary.

swift
// Optimal settings for fitness app
motionManager.deviceMotionUpdateInterval = 0.1 // 10 Hz

motionManager.startDeviceMotionUpdates(
    to: .main
) { [weak self] motion, error in
    guard let self = self,
          let motion = motion else { return }

    if motion.userAcceleration.magnitude() > 2.0 {
        self.detectedSignificantMovement()
    }
}

Frequently Asked Questions

Does Core Motion work on iPad and iPod touch?

Yes, Core Motion works on all Apple devices with the necessary sensors. The accelerometer is available on all iPhone, iPad and iPod touch devices. The gyroscope is on all iPhone 4 and newer, iPad 2 and newer. The magnetometer is only available on iPhone, not on iPad. The barometer is on iPhone 6 and newer.

How does Core Motion affect battery life?

The impact on battery depends on the polling frequency. At 100 Hz, Core Motion consumes about 5–7% battery per hour. At 10 Hz — about 1–2% per hour. CMPedometer on the motion coprocessor consumes less than 1% over 8 hours of operation. Apple recommends always stopping updates when data is not needed.

Can Core Motion be used to create a pedometer?

Yes, CMPedometer provides a ready-made solution for a pedometer without needing to process raw accelerometer data. The class automatically recognizes steps with about 95% accuracy during walking and 90% during running. For a custom step detector, you can use CMMotionManager with your own algorithm.

How is Core Motion different from the motion framework on Android?

Core Motion is integrated into iOS at the system level and uses the M-series coprocessor for low-energy processing. Android uses SensorManager with direct access to hardware drivers but does not have a specialized coprocessor, which increases power consumption during background tracking.

Is special permission required for CMPedometer?

For CMPedometer on iOS 11 and newer, user permission is required. The request is made automatically when creating a CMPedometer and triggers a system dialog. In Info.plist, you need to add the NSMotionUsageDescription key with a description of why the app needs access to motion data.

Summary

  • Core Motion is a system iOS framework for working with the accelerometer, gyroscope and magnetometer.
  • CMMotionManager is the central class providing access to all device motion sensors.
  • CMDeviceMotion provides filtered data — userAcceleration, attitude and rotationRate.
  • CMPedometer uses the M-series coprocessor for step counting with minimal power consumption.
  • CMAltimeter measures altitude change with accuracy up to 1 meter using the barometer.
  • Integration does not require entitlements, but CMPedometer needs NSMotionUsageDescription.
  • M7–M11 coprocessor enables background data collection with power consumption less than 1 mW.

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.

Discuss the project

Read also