ADC Two-Point Calibration Scheme
Important
The current two-point ADC calibration scheme is only applicable to ESP32 and ESP32-S2 chips
By default, the ESP32 is calibrated at the factory using a reference voltage. To further improve the consistency of ADC measurement results, users can modify the calibration scheme stored in eFuse to use the two-point calibration method.
Similarly, for the ESP32-S2 chip, the factory default is the two-point calibration method (Method 1). However, this method does not take into account calibration data across different ADC attenuation levels. If users wish to perform calibration using data from different attenuation settings, they can modify the calibration scheme in eFuse to use the two-point calibration method (Method 2).
It is important to note that both of the above methods require users to use the espefuse tool to modify the calibration scheme in eFuse and input the corresponding calibration data. This process must be carried out with extreme caution, as writing incorrect calibration data is irreversible and cannot be modified afterward. This is because data stored in eFuse is permanent and cannot be changed once written. Therefore, ensure the accuracy of the data before proceeding to avoid any unnecessary loss.
To avoid the risks associated with modifying eFuse, the adc_tp_calibration
component provides a method that allows users to perform calibration at the application level. This approach offers the following features:
Supports inputting calibration parameters at the application level, allowing users to store the calibration data in storage media such as NVS or SD cards.
Supports the two-point calibration scheme for ESP32 and the Method 2 two-point calibration scheme for ESP32-S2, without interfering with the existing calibration scheme provided by ESP-IDF.
Principle of Two-Point Calibration for ESP32
The two-point calibration for ESP32 requires applying stable voltages of 150 mV and 850 mV to both ADC1 and ADC2 channels. At each voltage level, raw ADC data should be collected using the ADC raw data acquisition interface to obtain stable readings corresponding to the applied voltages.
Input Voltage |
ADC1 (ATTEN0) |
ADC2 (ATTEN0) |
---|---|---|
150 mV |
A1 |
A2 |
850 mV |
B1 |
B2 |
Note
When collecting raw ADC data at 150 mV and 850 mV, the ADC driver attenuation must be configured to ADC_ATTEN_DB_0
.
Two-Point Calibration Formula for ESP32 ADC:
: : :65536 :
ADC1 |
ATTEN0 |
ATTEN_2_5 |
ATTEN_6 |
ATTEN_12 |
---|---|---|---|---|
65504 |
86975 |
120389 |
224310 |
|
0 |
1 |
27 |
54 |
ADC2 |
ATTEN0 |
ATTEN_2_5 |
ATTEN_6 |
ATTEN_12 |
---|---|---|---|---|
65467 |
86861 |
120416 |
224708 |
|
0 |
9 |
26 |
66 |
Principle of Two-Point Calibration (Method 2) for ESP32-S2
The two-point calibration (Method 2) for ESP32-S2 requires applying stable voltages of 600 mV, 800 mV, 1000 mV, and 2000 mV to both ADC1 and ADC2 channels. At each voltage level, raw ADC data should be collected using the ADC raw data acquisition interface to obtain stable readings. Taking ADC1 as an example:
Input Voltage |
ATTEN |
ADC1 Raw Value |
---|---|---|
600 mV |
ATTEN_0 |
High[ATTEN_0] |
800 mV |
ATTEN_2_5 |
High[ATTEN_2_5] |
1000 mV |
ATTEN_6 |
High[ATTEN_6] |
2000 mV |
ATTEN_12 |
High[ATTEN_12] |
Note
In two-point calibration (Method 2) for ESP32-S2, calibration points must be selected by collecting stable raw ADC data under the corresponding attenuation settings and calibration voltages to ensure accuracy. The High value is used to store the raw ADC data obtained under each specific combination of attenuation and calibration voltage.
The calculation formula for two-point ADC calibration (Method 2) on ESP32-S2 is as follows:
: :0 :65536 :1024
ATTEN0 |
ATTEN_2_5 |
ATTEN_6 |
ATTEN_12 |
|
---|---|---|---|---|
600 |
800 |
1000 |
2000 |
API Reference
Header File
Functions
-
adc_tp_cali_handle_t adc_tp_cali_create(adc_tp_cali_config_t *config, adc_atten_t atten)
Create ADC calibration handle.
- Parameters
config – Pointer to ADC calibration configuration
atten – ADC attenuation level
- Returns
adc_tp_cali_handle_t Handle of ADC calibration, NULL if failed
-
esp_err_t adc_tp_cali_delete(adc_tp_cali_handle_t *adc_tp_cali_handle)
Delete ADC calibration handle.
- Parameters
adc_tp_cali_handle – Pointer to ADC calibration handle
- Returns
esp_err_t
ESP_OK: Always returns ESP_OK
-
esp_err_t adc_tp_cali_raw_to_voltage(adc_tp_cali_handle_t adc_tp_cali_handle, int raw_value, int *voltage)
Convert ADC raw value to voltage in millivolts.
- Parameters
adc_tp_cali_handle – ADC calibration handle
raw_value – ADC raw value to convert
voltage – Pointer to store the converted voltage in millivolts
- Returns
esp_err_t
ESP_OK: Success
ESP_ERR_INVALID_ARG: Invalid argument
Structures
Type Definitions
-
typedef void *adc_tp_cali_handle_t
ADC calibration handle