# Calibrate

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. Sensor
calibration is the process to adjust or fine-tune the sensor hardware to
ensure accuracy and minimize the errors. Calibration involves comparing
the expected output based on the theoretical models or standards with
the actual measured output from the sensor. By precise adjustments, the
sensor calibration enhances performance, accuracy, and reliability,
which ensures that the sensor provides reliable data.

On successful calibration and 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 &lt;registry\_path&gt; 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/.

## Factory sensor calibration

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

### Accelerometer

The following table lists the accelerometer calibration procedure:

Table : Accelerometer calibration

| Command | Procedure | Bias values |
| --- | --- | --- |
| ssc_drva_test -sensor=accel -factory_test=2 -duration=10<br>    Copy to clipboard<br><br><br>Note<br><br><br>A test result (PASS or FAIL) indicates only the test execution status whether the test is completed or not. | Run the command, while keeping the device stationary on a flat surface. | The following is the example of the QCS6490 device (ICM42688 sensor): The<br><br><br>`<registry_path>/qcs6490_rbx_icm4x6xx_0.json.icm4x6xx_0_platform.accel.fac_cal.bias`<br><br><br>file is created/updated automatically, and stores the bias offset after the calibration. |

### Magnetometer

The following table lists the magnetometer calibration procedure:

Table : Magnetometer calibration

| Command | Procedure | Bias values |
| --- | --- | --- |
| NA | 1 Get <cite>/calculate corr_matrix</cite> and <cite>bias scale</cite> values (if applicable) for your device with the help of the sensor vendor.<br><br><br>2 Set the values into the corr\_matrix section in the platform-specific magnetometer JSON file of the sensor. | The following is an example of the QCS6490 device (AK09915 sensor):<br><br><br>The `<registry_path>/qcs6490_rbx_navmez_ak991x_0.json.ak0991x_0_platform.mag.fac_cal.corr_mat` file is created/updated automatically, and stores the bias offset after the calibration. |

### Proximity

The following table lists the proximity calibration procedure:

Table : Proximity calibration

| Command | Procedure | Bias values |
| --- | --- | --- |
| ssc_drva_test -sensor=prox -factory_test=2 -duration=10<br>    Copy to clipboard | 1 Keep an obstacle/object at a required distance (for example, 5cm or as mentioned in the specification) from the proximity sensor and run the command.<br><br><br>2 Verify that the test returns a PASS result.<br><br><br>3 This procedure uses 5cm as the threshold and the distance within the threshold is considered as near and the distance more than the threshold is considered as far. | The following is an example of the TMD3702 sensor:<br><br><br>The `<registry_path>/tmd3702_platform.prox.fac_cal`<br>file is created/updated automatically, and stores the bias offset after the calibration. |

### Ambient light

The following table lists the ambient light calibration procedure:

Table : Ambient light calibration

| Command | Procedure | Bias values |
| --- | --- | --- |
| ssc_drva_test -sensor=als -factory_test=2 -duration=10<br>    Copy to clipboard | Confirm the test procedure specified by the sensor vendor and run the command. | The following is an example of the TMD3702 sensor: The<br><br><br>`<registry_path>/tmd3702_platform.als.fac_cal`<br>file is created/updated automatically, and stores the bias offset after the calibration. |

## Runtime sensor calibration

Runtime sensor calibration is a process to adjust or fine-tune 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

The gyroscope calibration sensor `gyro_cal` is used for gyroscope
runtime calibration. The following table lists the gyroscope calibration
procedure:

Table : Gyroscope calibration

| Command | Procedure | Bias values |
| --- | --- | --- |
| Use `see_workhorse` to enable a gyroscope calibration sensor (`gyro_cal`).<br><br><br>see_workhorse -sensor=gyro_cal -on_change=1 -duration=120 -display_events=1<br>    Copy to clipboard | <ul class="simple"><br><li><p>While keeping the device stationary, request the gyroscope calibration sensor <code class="docutils literal notranslate"><span class="pre">gyro_cal</span></code> data for more than 120sec and then stop.</p></li><br><li><p>After the command is executed, check the status field in the received event for the calibration accuracy status.</p></li><br></ul><br><br>Note<br><br><br>The gyroscope sensor always produces noncalibrated 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:<br><br><br>calibrated_gyro_x_val = (gyro_data.x_val - gyro_cal.x_bias);<br>    Copy to clipboard<br><br><br>calibrated_gyro_y_val = (gyro_data.y_val - gyro_cal.y_bias);<br>    Copy to clipboard<br><br><br>calibrated_gyro_z_val = (gyro_data.z_val - gyro_cal.z_bias);<br>    Copy to clipboard | The `<registry_path>/sns_gyro_cal_persist_sX.bias` file (where, X = sensor index) is created/updated automatically, and stores the bias offset after the calibration:<br><br><br>Note<br><br><br>Gyroscope calibration runs approximately for every 60sec. The gyroscope bias is stored into the registry only after the existing streaming clients for the gyroscope are disabled. |

### Magnetometer

The magnetometer calibration sensor `mag_cal` is used for the
magnetometer runtime calibration. The following table lists the
magnetometer calibration procedure:

Table : Magnetometer calibration

| Command | Procedure | Bias values |
| --- | --- | --- |
| Use `see_workhorse` to enable the magnetometer calibration sensor `mag_cal`.<br><br><br>see_workhorse -sensor=mag_cal -on_change=1 -duration=500 -display_events=1``<br>    Copy to clipboard | <ul class="simple"><br><li><p>Bring the device to an open area where there is no magnetic field interference.</p></li><br><li><p>Stream the magnetometer data and move the device in motion <strong>8</strong> for more than 60sec. Moving the device in motion <strong>8</strong> is mandatory.</p></li><br><li><p>After the command is executed, check the status field in the received event for the calibration accuracy status.</p></li><br></ul> | 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: Dec 24, 2024

[Previous Topic
Tools](https://docs.qualcomm.com/bundle/publicresource/80-70017-7/topics/test_tools.md) [Next Topic
Verify](https://docs.qualcomm.com/bundle/publicresource/80-70017-7/topics/verify.md)