GetCurrentReading | getCurrentReading method

Accelerometer.GetCurrentReading | getCurrentReading method

Gets the current accelerometer reading.


var accelerometerReading = accelerometer.getCurrentReading();


This method has no parameters.

Return value

Type: AccelerometerReading

This method has no parameters.


An application may use this method to poll the sensor for the current reading as an alternative to registering a ReadingChanged event handler. This would be the preferred alternative for an application that updates its user interface at a specific frame rate. Whether polling once or many times, the application must establish a desired ReportInterval. This informs the sensor driver that resources should be allocated to satisfy subsequent polling requests

If the sensor is configured to support batch delivery, this method flushes the current batch and starts a new latency period. For more information about sensor batching, see Sensors.

Before using the return value from this method, the application must first check that the value is not null. (If the value is null and you attempt to retrieve it, Windows will generate an exception.)

The following example demonstrates how a Windows Store app built with XAML and C# retrieves the current reading for the three axes of the default accelerometer.

private void DisplayCurrentReading(object sender, object args)
    AccelerometerReading reading = _accelerometer.GetCurrentReading();
    if (reading != null)
        ScenarioOutput_X.Text = String.Format("{0,5:0.00}", reading.AccelerationX);
        ScenarioOutput_Y.Text = String.Format("{0,5:0.00}", reading.AccelerationY);
        ScenarioOutput_Z.Text = String.Format("{0,5:0.00}", reading.AccelerationZ);

The following example demonstrates how a Windows Store app built for Windows using JavaScript retrieves the current reading for the three axes of the default accelerometer.

function getCurrentReading() {
    var reading = accelerometer.getCurrentReading();
    if (reading) {
        document.getElementById("readingOutputX").innerHTML = reading.accelerationX.toFixed(2);
        document.getElementById("readingOutputY").innerHTML = reading.accelerationY.toFixed(2);
        document.getElementById("readingOutputZ").innerHTML = reading.accelerationZ.toFixed(2);

Requirements (Windows 10 device family)

Device family

Universal, introduced version 10.0.10240.0

API contract

Windows.Foundation.UniversalApiContract, introduced version 1.0


Windows::Devices::Sensors [C++]



Requirements (Windows 8.x and Windows Phone 8.x)

Minimum supported client

Windows 8

Minimum supported server

None supported

Minimum supported phone

Windows Phone 8


Windows::Devices::Sensors [C++]



See also

Sensor data and display orientation
Accelerometer sample (Windows 10)



© 2017 Microsoft