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
| Pattern | Description |
|---|---|
| ReadingChanged event | Subscribe to receive periodic sensor data. |
| GetDefault() | Obtain the default instance of a sensor class. |
| ReportInterval | Set the desired time interval between readings. |