UWP Sensors API

Overview

The Windows.Devices.Sensors namespace provides access to the device's various sensors, such as accelerometer, gyroscope, compass, and more. This reference lists the primary sensor classes, their properties, methods, and usage examples.

Sensor Types

Getting Started

Below is a simple example of accessing the accelerometer and receiving data updates.

using Windows.Devices.Sensors;

var accelerometer = Accelerometer.GetDefault();
if (accelerometer != null)
{
    accelerometer.ReadingChanged += (s, e) =>
    {
        var reading = e.Reading;
        // Use reading.AccelerationX, Y, Z
    };
}

Common Patterns

PatternDescription
ReadingChanged eventSubscribe to receive periodic sensor data.
GetDefault()Obtain the default instance of a sensor class.
ReportIntervalSet the desired time interval between readings.