# Calibrate sensors

Sensors that are sensitive to changes in the operating environment
produce inappropriate output values due to factors, such as temperature
variations, mechanical wear, or shift in the operating range. The sensor calibration process involves the following:

- Adjust or fine-tune the sensor hardware to ensure accuracy and minimize the errors.
- Compare the expected output based on the theoretical models or standards with the actual measured output from the sensor.
- Enhance performance, accuracy, and reliability, which ensures that the sensor provides reliable data.

After successful calibration and the associated registry update (as described
in the following sections), the value of `ver` registry item increments.
For example, if the bias offset in registry item has `ver` value of 0,
then on a successful calibration and registry update, the registry item
is updated with the new bias offset and the `ver` value increments to 1.

Note

The `<registry_path>` referred in the following sections should be considered as one of the existing paths on the device: `/etc/sensors/registry/registry/` or `/var/cache/sensors/registry/registry/`.

## Perform factory sensor calibration

The factory sensor calibration is a process to adjust or fine-tune the sensors during the manufacturing phase.

### Accelerometer factory calibration

To calibrate the accelerometer sensor:

- Run the command while keeping the device stationary on a flat surface.

**Command**

ssc_drva_test -sensor=accel -factory_test=2 -duration=10
    Copy to clipboard

Note

A test result (`PASS` or `FAIL`) indicates only the test execution status whether the test is completed or not.

**Bias value**

The following is the example of the QCS6490 device (ICM42688 sensor):

- The `<registry_path>/qcs6490_rbx_icm4x6xx_0.json.icm4x6xx_0_platform.accel.fac_cal.bias` file is created or updated automatically, and stores the bias offset after the calibration.

### Magnetometer factory calibration

To calibrate the magnetometer:

1. Obtain the correction matrix (`corr_matrix`) and bias scale values (if applicable) for your device from the sensor vendor.
2. Set these values in the `corr_matrix` section of the sensor’s platform-specific magnetometer JSON file.

**Command**

Magnetometer factory calibration doesn’t use a command-line tool. The correction matrix values are obtained from the sensor vendor and set manually in the registry.

**Bias value**

The following is an example of the QCS6490 device (AK09915 sensor):

- The `<registry_path>/qcs6490_rbx_navmez_ak991x_0.json.ak0991x_0_platform.mag.fac_cal.corr_mat` file is created or updated automatically, and stores the bias offset after the calibration.

### Proximity factory calibration

To calibrate the proximity sensor:

1. Keep an obstacle/object at a required distance (for example, 5 cm or as per the specification shared by the vendor) from the proximity sensor and run the command.
2. Ensure that the test returns a `PASS` result.
3. This procedure uses 5 cm as the threshold and the distance within the threshold is considered as near and the distance more than the threshold is considered as far.

**Command**

ssc_drva_test -sensor=prox -factory_test=2 -duration=10
    Copy to clipboard

**Bias value**

The following is an example of the TMD3702 sensor:

- The `<registry_path>/tmd3702_platform.prox.fac_cal` file is created or updated automatically, and stores the bias offset after the calibration.

### Ambient light factory calibration

To calibrate the ambient light sensor:

- Confirm the test procedure specified by the sensor vendor and run the command.

**Command**

ssc_drva_test -sensor=als -factory_test=2 -duration=10
    Copy to clipboard

**Bias value**

The following is an example of the TMD3702 sensor:

- The `<registry_path>/tmd3702_platform.als.fac_cal` file is created or updated automatically, and stores the bias offset after the calibration.

## Perform runtime sensor calibration

Runtime sensor calibration adjusts or fine-tunes the
sensors during their operational phase, rather than during the
manufacturing phase. It occurs dynamically while the sensor actively
collects the data in the real-world scenarios.

### Gyroscope runtime calibration

The gyroscope calibration sensor `gyro_cal` calibrates the gyroscope at runtime.

To calibrate the gyroscope sensor:

1. While keeping the device stationary, request the gyroscope calibration sensor `gyro_cal` data for more than 120 sec and then stop.
2. After executing the command, check the status field in the received event for the calibration accuracy status.

**Command**

Use `see_workhorse` to enable a gyroscope calibration sensor (`gyro_cal`).

see_workhorse -sensor=gyro_cal -on_change=1 -duration=120 -display_events=1
    Copy to clipboard

**Bias value**

The `<registry_path>/sns_gyro_cal_persist_sX.bias` file (where, X = sensor index) is created or updated automatically, and stores the bias offset after the calibration:

Note

Gyroscope calibration runs approximately for every 60 sec. The gyroscope bias is stored into the registry only after the existing streaming clients for the gyroscope are disabled.

The gyroscope sensor always produces uncalibrated values. Hence, for the client/algorithm that needs the calibrated gyroscope values run the `gyro_cal` sensor to generate and provide calibration offset/bias. The bias received from the `gyro_cal` sensor can then be subtracted as shown in the following pseudocode:

calibrated_gyro_x_val = (gyro_data.x_val - gyro_cal.x_bias);
    calibrated_gyro_y_val = (gyro_data.y_val - gyro_cal.y_bias);
    calibrated_gyro_z_val = (gyro_data.z_val - gyro_cal.z_bias);
    Copy to clipboard

### Magnetometer runtime calibration

The magnetometer calibration sensor `mag_cal` calibrates the magnetometer at runtime.

To calibrate the magnetometer sensor:

1. Bring the device to an open area where there is no magnetic field interference.
2. Stream the magnetometer data and move the device in a **figure-8** motion for more than 60 sec. Moving the device in a **figure-8** motion is mandatory.
3. Check the status field in the received event for the calibration accuracy status.

**Command**

Use `see_workhorse` to enable the magnetometer calibration sensor `mag_cal`.

see_workhorse -sensor=mag_cal -on_change=1 -duration=500 -display_events=1
    Copy to clipboard

**Bias value**

The `<registry_path>/sns_mag_cal_persist_sXmY.bias` file (where, X = sensor index and Y = device mode index) is created/updated automatically, and stores the bias offset after the calibration.

Last Published: May 07, 2026

[Previous Topic
Test and validate](https://docs.qualcomm.com/bundle/publicresource/80-80022-7/topics/test_validate.md) [Next Topic
Verify sensors](https://docs.qualcomm.com/bundle/publicresource/80-80022-7/topics/verify.md)