# Calibrate

Source: [https://docs.qualcomm.com/doc/80-70015-7/topic/calibrate.html](https://docs.qualcomm.com/doc/80-70015-7/topic/calibrate.html)

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

Source: [https://docs.qualcomm.com/doc/80-70015-7/topic/calibrate.html](https://docs.qualcomm.com/doc/80-70015-7/topic/calibrate.html)

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

###  Magnetometer

The following table lists the magnetometer calibration procedure:

Table : Magnetometer calibration

| Command | Procedure | Bias values |
| --- | --- | --- |
| NA | <ol class="ol"><br>                                        <li class="li">Get/calculate <em class="ph i">corr_matrix</em> and<em class="ph i"> bias</em><br>                                            <em class="ph i">scale</em> values (if applicable) for your device with<br>                                            the help of the sensor vendor.</li><br><br>                                        <li class="li">Set the values into the <em class="ph i">corr_matrix</em> section in<br>                                            the platform-specific magnetometer JSON file of the<br>                                            sensor. </li><br><br>                                    </ol> | The following is an example of the QCS6490 device (AK09915<br>                                        sensor):<br><br><br>                                    <br>The<br>                                            <br>                                        `<registry_path>/qcs6490_rbx_navmez_ak991x_0.json.ak0991x_0_platform.mag.fac_cal.corr_mat`<br>                                        file is created/updated automatically, and stores the bias<br>                                        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=10Copy to clipboard | <ol class="ol"><br>                                    <li class="li">Keep an obstacle/object at a required distance (for example,<br>                                        5 cm or as mentioned in the specification) from the<br>                                        proximity sensor and run the command. </li><br><br>                                    <li class="li">Verify that the test returns a <em class="ph i">PASS</em> result. </li><br><br>                                    <li class="li">This procedure uses 5 cm as the threshold and the distance<br>                                        within the threshold is considered as near and the distance<br>                                        more than the threshold is considered as far.</li><br><br>                                </ol> | The following is an example of the TMD3702 sensor:<br><br><br>                                <br>The<br>                                        <br>                                    `<registry_path>/tmd3702_platform.prox.fac_cal`<br>                                    file is created/updated automatically, and stores the bias<br>                                    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=10Copy to clipboard | Confirm the test procedure specified by the sensor vendor and<br>                                        run the command. | The following is an example of the TMD3702 sensor:<br><br><br>                                    <br>The<br>                                            <br>                                        `<registry_path>/tmd3702_platform.als.fac_cal`<br>                                        file is created/updated automatically, and stores the bias<br>                                        offset after the calibration. |

## Runtime sensor calibration

Source: [https://docs.qualcomm.com/doc/80-70015-7/topic/calibrate.html](https://docs.qualcomm.com/doc/80-70015-7/topic/calibrate.html)

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<br>                                calibration sensor (`gyro_cal`).<br>                                <br><br>    see_workhorse -sensor=gyro_cal -on_change=1 -duration=120 -display_events=1Copy to clipboard | <ol class="ol" id="calibrate_runtime_calibration__ol_vcg_l5f_v1c_monicapa_03-22-24-1538-24-313"><br>                                    <li class="li">While keeping the device stationary, request the gyroscope<br>                                        calibration sensor <code class="ph codeph">gyro_cal</code> data for more<br>                                        than 120 sec and then stop. </li><br><br>                                    <li class="li"><br>                                        <p class="p">After the command is executed, check the <em class="ph i">status</em><br>                                            field in the received event for the calibration accuracy<br>                                            status.</p><br><br>                                    </li><br><br>                                </ol><br><br>                                <br>Note: The<br>                                    gyroscope sensor always produces noncalibrated values. Hence,<br>                                    for the client/algorithm that needs the calibrated gyroscope<br>                                    values run the `gyro_cal` sensor to generate and<br>                                    provide calibration offset/bias. The bias received from the<br>                                        `gyro_cal` sensor can then be subtracted as<br>                                    shown in the following pseudocode:<br><br><br>                                <br>calibrated_gyro_x_val = (gyro_data.x_val - gyro_cal.x_bias);Copy to clipboard<br><br><br>                                <br>calibrated_gyro_y_val = (gyro_data.y_val - gyro_cal.y_bias);Copy to clipboard<br><br><br>                                <br>calibrated_gyro_z_val = (gyro_data.z_val - gyro_cal.z_bias);Copy to clipboard | The<br>                                        <br>                                    `<registry_path>/sns_gyro_cal_persist_sX.bias`<br>                                    file (where, X = sensor index) is created/updated automatically,<br>                                    and stores the bias offset after the calibration:<br><br><br>                                <br>Note: Gyroscope calibration runs approximately for every 60 sec.<br>                                        The gyroscope bias is stored into the registry only after<br>                                        the existing streaming clients for the gyroscope are<br>                                        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<br>                                    calibration sensor `mag_cal`.<br>                                    <br><br>    see_workhorse -sensor=mag_cal -on_change=1 -duration=500 -display_events=1Copy to clipboard | <ol class="ol" id="calibrate_runtime_calibration__ol_xhv_nbp_41c_monicapa_02-27-24-2134-30-521"><br>                                        <li class="li">Bring the device to an open area where there is no<br>                                            magnetic field interference.</li><br><br>                                        <li class="li">Stream the magnetometer data and move the device in<br>                                        motion <strong class="ph b">8</strong> for more than 60 sec. Moving the device in<br>                                        motion <strong class="ph b">8</strong> is mandatory.</li><br><br>                                        <li class="li">After the command is executed, check the <em class="ph i">status</em><br>                                            field in the received event for the calibration accuracy<br>                                            status.</li><br><br>                                    </ol> | The<br>                                    <br>                                    `<registry_path>/sns_mag_cal_persist_sXmY.bias`<br>                                file (where, X = sensor index and Y = device mode index) is<br>                                created/updated automatically, and stores the bias offset after the<br>                                calibration. |

Last Published: Oct 14, 2024

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