# IMU Factory Calibration

PX4 OEM manufacturers can perform an IMU factory calibration in order to store persistent values for the accelerometer, gyroscope and magnetometer biases into persistent storage (usually EEPROM). This ensures that end users can always reset vehicle configurations and tuning to a safe state for flying.

This procedure will write the following parameters to `/fs/mtd_caldata`: [CAL\_ACC\*](https://px4.gitbook.io/px4-user-guide/parameter_reference#CAL_ACC0_ID), [CAL\_MAG\*](https://px4.gitbook.io/px4-user-guide/parameter_reference#CAL_MAG0_ID), [CAL\_GYRO\*](https://px4.gitbook.io/px4-user-guide/parameter_reference#CAL_GYRO0_ID). This data will then be used when the parameters are set (or reset) to their default values.

:::warning This feature relies on the FMU having a dedicated EEPROM chip or an accompanying IMU PCBA that has sufficient space for the data. PX4 will store the data to `/fs/mtd_caldata`, creating the file if necessary. :::

:::note These values cannot be stored in the [frame configuration](https://px4.gitbook.io/px4-user-guide/development/hardware/dev_airframes/adding_a_new_frame) because they vary from device to device (the frame configuration defines the set of parameters that are applicable across all vehicles of the same type, such as the enabled sensors, [autopilot rotation](https://px4.gitbook.io/px4-user-guide/config/flight_controller_orientation) and PID tuning). :::

## Performing the Factory Calibration

1. Set the parameter [SYS\_FAC\_CAL\_MODE](https://px4.gitbook.io/px4-user-guide/parameter_reference#SYS_FAC_CAL_MODE) to 1.
2. Perform all IMU calibrations: [accelerometer](https://px4.gitbook.io/px4-user-guide/config/accelerometer#performing-the-calibration), [gyroscope](https://px4.gitbook.io/px4-user-guide/config/gyroscope#performing-the-calibration) and [magnetometer](https://px4.gitbook.io/px4-user-guide/config/compass#performing-the-calibration).
3. Reboot the vehicle. This will write all `CAL_ACC*`, `CAL_GYRO*` and `CAL_MAG*` parameters into `/fs/mtd_caldata`.
4. Set the parameter `SYS_FAC_CAL_MODE` back to 0 (default).

Subsequent user calibrations will then take effect as usual (factory calibration data is only used for the parameter default values).

## Further Information

* [QGroundControl User Guide > Sensors](https://docs.qgroundcontrol.com/master/en/SetupView/sensors_px4.html)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://px4.gitbook.io/px4-user-guide/advanced_config/imu_factory_calibration.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
