Friday, April 18, 2025

Understanding and Converting Galaxy Watch Accelerometer Data

Share

The Galaxy Watch has a built-in accelerometer sensor that measures movement or acceleration forces in three dimensions (X,Y, and Z axes). This data is commonly used for tracking movement, detecting gestures, and enabling fitness-related features like sleep tracking, fall detection, step counting, running, and workout tracking.

The accelerometer measures acceleration along three axes:

X-axis: Side-to-side movement.
Y-axis: Forward-and-backward movement.
Z-axis: Up-and-down movement.


Figure 1: Axis directions for the accelerometer sensor

Acceleration is typically measured in meters per second squared (m/s²) or gravity units (g), where 1g = 9.81 m/s².

This article describes how to read accelerometer sensor data from a Galaxy Watch running Wear OS powered by Samsung and also shows the conversion procedure for the raw data.

Environment Setup

Android Studio IDE is used for developing Wear OS applications. The examples in this article use Java, but Kotlin can also be used. Going forward, this article assumes you have already installed the latest Android Studio version on your PC.

Read Accelerometer Data from Galaxy Watch

To get accelerometer data, we need to use Android Sensor APIs from the SensorManager library.

To retrieve accelerometer data from your Galaxy Watch:

  1. Create a new Wear OS project in Android Studio by selecting File > New Project > Wear OS > Empty Activity > Finish. Set the minimum SDK version to API 30 or higher.

  2. Add permission to access the sensor into the manifest file (AndroidManifest.xml):


You do not need to manually set the runtime permission to access the accelerometer. This permission is granted by default.

  1. Design your preferred layout (.xml file) to show accelerometer data on the Galaxy Watch screen. This example uses three TextViews in a Constraint Layout to show the output of the three axes of the sensor. You can also check the result in the Logcat window in Android Studio.

For more detailed code, check the sample application.

  1. Use the SensorManager library and SensorEventListener to read accelerometer data. To implement them:
    • Initialize the SensorManager library globally:
private SensorManager sensorManager;
  • To retrieve android.hardware.SensorManager for accessing sensors, you have to use getSystemService().
sensorManager = SensorManager.getSystemService(Context.SENSOR_SERVICE);
  • As our target is the accelerometer sensor specifically, it is set as the default sensor here. It is recommended to always check the sensor availability before using it in the code. The procedure to do so is explained in this guide.

  • To make the accelerometer the default sensor:

Sensor sensor = sensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER);
  • To get continuous data from your Galaxy Watch, you need to register a listener to notify you if there is new data. This is done using a SensorEeventListener in Android’s Sensor API.
sensorManager.registerListener(listener, sensor, SensorManager.SENSOR_DELAY_NORMAL);
  • The listener method onSensorChanged() is called whenever new data is available. The new data is processed in the listener.
private SensorEventListener listener = new SensorEventListener() {
    @Override
    public void onSensorChanged(SensorEvent sensorEvent) {
        // for absolute values
        X = Math.abs(sensorEvent.values[0]); //0 -> X Axis 1-> Y Axis 2 -> Z Axis
        Y = Math.abs(sensorEvent.values[1]);
        Z = Math.abs(sensorEvent.values[2]);

        Log.e("--MainActivityTag--", "X: " + X + "\n" + "Y: " + Y + "\n" + "Z:  " + Z);
        // do whatever you want to do with the data
    }

    @Override
    public void onAccuracyChanged(Sensor sensor, int i) {

    }
};

Here, onAccuracyChanged(Sensor sensor, int i) is a part of the SensorEventListener interface. It is triggered when the accuracy of a sensor changes. However, for the accelerometer, it is called rarely, as the accelerometer data accuracy usually remains constant.

  • Unregister the listener when the data collection is over. Otherwise, it can cause unusual battery consumption.

Test the Code Sample

You can check out the sample app (download it using the link below) and try it out on your Galaxy Watch 4 and later.

AccelerometerDataExample.zip

(332.2 KB)

Run the sample project on your Galaxy Watch. You will see the following screen.


Figure 2: Output of the sample project (accelerometer data on Galaxy Watch)

Accelerometer Data Units and Conversion for Galaxy Watch

In the application end, raw accelerometer data from Galaxy Watch is converted into meters per second squared (m/s²).

Equation

raw data * 9.80665 (gravity force) / 4096 (8g rescale)

Example

Assume,
raw_x = raw data received from the sensor
acc_x = accelerometer data in application end

if raw_x = 100
acc_x = 100 * 9.80665 / 4096

After this, acc_x is received by the application, containing the Acceleration value in m/s².

Convert the Data into G-Force Units

The conversion from m/s² to g is: 1 / 9.80665
So 1 m/s² =0.10197g

Information about the Accelerometer Sensor

  • The accelerometer provides the 3 axis values separately.
  • The sampling rate of the accelerometer is usually a multiple of 50 Hz, but 100 Hz is also supported.
  • The range of the accelerometer is +- 8G.
  • Sampling rate:
    #Maximum Delay: https://developer.android.com/reference/android/hardware/Sensor#getMaxDelay() // 160 msec
    #Minimum Delay: https://developer.android.com/reference/android/hardware/Sensor#getMinDelay() // 10 msec
  • It is always recommended to read calibrated data to avoid unnecessary noise.
  • To get the result in g-force units, you need to divide the accelerometer values by 4096 (along every axis).
  • It is recommended to use a filter while reading any sensor data.
  • Make sure to always unregister the listener and stop all the services after using. Failure to do so can cause excessive battery drain.
  • There are some restrictions of using background services for Galaxy Watch.

Conclusion

For a Galaxy Watch running Wear OS powered by Samsung, accelerometer data is widely used in fitness tracking, fall detection, gesture recognition and motion analysis. Moreover, data conversion enables precise tracking for applications.

In this article, we’ve seen one of the ways of reading accelerometer sensor data on a Galaxy Watch running Wear OS powered by Samsung. You can also read sensor data using the Samsung Health Sensor SDK. For more details on Samsung Health, check here.

If you have any questions about or need help with the information in this article, you can reach out to us on the Samsung Developers Forum or contact us through Developer Support.

Read more

Trending News