# Calibrate
Source: [https://docs.qualcomm.com/doc/80-70014-7/topic/calibrate.html](https://docs.qualcomm.com/doc/80-70014-7/topic/calibrate.html)
Sensor calibration is the process to adjust or fine-tune the sensor hardware to ensure
accuracy and minimize the errors. 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. 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.
Note: 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.
## Factory sensor calibration
Source: [https://docs.qualcomm.com/doc/80-70014-7/topic/calibrate.html](https://docs.qualcomm.com/doc/80-70014-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
Note: 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
`/var/cache/sensors/registry/registry/qcs6490_rbx_icm4x6xx_0.json.icm4x6xx_0_platform.accel.fac_cal.bias`
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 |
- Get/calculate corr_matrix and bias,
scale values (if applicable) for your device
with the help of the sensor vendor.
- 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):
The
`/var/cache/sensors/registry/registry/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=10Copy to clipboard |
- Keep an obstacle/object at a required distance (for example,
5 cm or as mentioned in the specification) from the
proximity sensor and run the command.
- Verify that the test returns a PASS result.
- 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.
| The following is an example of the TMD3702 sensor:
The
`/var/cache/sensors/registry/registry/tmd3702_platform.prox.fac_cal`
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=10Copy 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
`/var/cache/sensors/registry/registry/tmd3702_platform.als.fac_cal`
file is created/updated automatically, and stores the bias
offset after the calibration. |
Note: The registry file mentioned here is only an example.
Look for the correct sensor registry file according to
the platform.
## Run-time sensor calibration
Source: [https://docs.qualcomm.com/doc/80-70014-7/topic/calibrate.html](https://docs.qualcomm.com/doc/80-70014-7/topic/calibrate.html)
Run-time 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
run-time 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`).
see_workhorse -sensor=gyro_cal -on_change=1 -duration=120 -display_events=1Copy to clipboard |
- While keeping the device stationary, request the gyroscope
calibration sensor gyro_cal data for more
than 120 seconds and then stop.
After the command is executed, check the status
field in the received event for the calibration accuracy
status.
Note: The
gyroscope sensor always produces non-calibrated 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 pseudo code:
calibrated_gyro_x_val = (gyro_data.x_val - gyro_cal.x_bias);Copy to clipboard
calibrated_gyro_y_val = (gyro_data.y_val - gyro_cal.y_bias);Copy to clipboard
calibrated_gyro_z_val = (gyro_data.z_val - gyro_cal.z_bias);Copy to clipboard | The
`/var/cache/sensors/registry/registry/sns_gyro_cal_persist_sX.bias`
file (where, X = sensor index) is created/updated automatically,
and stores the bias offset after the calibration:
Note: Gyroscope calibration runs approximately for every
60 seconds. The gyroscope bias is stored into the registry
only after all the existing streaming clients for the
gyroscope are disabled. |
### Magnetometer
Magnetometer calibration sensor `mag_cal`, is used for the
magnetometer run-time 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`.
see_workhorse -sensor=mag_cal -on_change=1 -duration=500 -display_events=1Copy to clipboard |
- Bring the device to an open area where there is no
magnetic field interference.
- Stream the magnetometer data and move the device in
motion 8 for more than 60 seconds. Moving the
device in motion 8 is mandatory.
- After the command is executed, check the status
field in the received event for the calibration accuracy
status.
| The
`/var/cache/sensors/registry/registry/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: Jul 12, 2024
[Previous Topic
Tools](https://docs.qualcomm.com/bundle/publicresource/80-70014-7/topics/test_tools.md) [Next Topic
Verify](https://docs.qualcomm.com/bundle/publicresource/80-70014-7/topics/verify.md)