ADC Range Extension Solution
Important
The current ADC extended range solution is only applicable to ESP32-S2 and ESP32-S3 chips.
The ESP32-S2/S3 ADC, within its default range, can handle most ADC functionalities such as key input and battery voltage detection through an external voltage divider circuit. However, for applications like NTC measurements, full-scale measurement (0 ~ 3300 mV) may be required. By configuring the registers to adjust the ADC’s offset voltage and applying a nonlinear compensation method for the high-voltage region, we can extend the range of the ESP32-S2/S3 ADC.
The process is as follows:
Measure the first voltage value using the default offset
If the measured voltage is less than the
set voltage, directly output the measured voltage as the resultIf the measured voltage is greater than the
set voltage, increase the offset voltage, perform a second measurement, apply nonlinear correction, and output the corrected value as the resultRestore the offset value once measurement is completed
Overall, during each ADC measurement, there will be 1-2 times ADC reading. For most application scenarios, the measurement delay introduced by this scheme is negligible.
Note
For the ESP32-S2, the set voltage is 2600 mV; for the ESP32-S3, the set voltage is 2900 mV.
Patch Use Guide
Important
This patch is developed based on ESP-IDF v4.4.8 and v5.3.1. If you need to use this solution with other versions of ESP-IDF, please refer to the patch content and modify ESP-IDF accordingly.
How to Apply a Patch Based on ESP-IDF v4.4.8
ESP32-S2 ADC Extension Patch Download:
esp32s2_adc_range_to_3300.patchESP32-S3 ADC Extension Patch Download:
esp32s3_adc_range_to_3300.patch
Using the ESP32-S3 as an example, please load the patch as follows:
Please make sure ESP-IDF has been
checked outto thev4.4.8Using command
git am --signoff < esp32s3_adc_range_to_3300.patchto apply the patch to ESP-IDFPlease note that this solution is only effective for the
esp_adc_cal_get_voltageinterface. Users can directly call this interface to obtain the extended readings.
How to Apply a Patch Based on ESP-IDF v5.3.1
ESP32-S2 ADC Extension Patch Download:
esp32s2_adc_range_to_3300_v531.patchESP32-S3 ADC Extension Patch Download:
esp32s3_adc_range_to_3300_v531.patch
Using the ESP32-S3 as an example, please load the patch as follows:
Please make sure ESP-IDF has been
checked outto thev5.3.1Using command
git am --signoff < esp32s3_adc_range_to_3300_v531.patchto apply the patch to ESP-IDFPlease note that this solution is only effective for the
adc_oneshot_get_calibrated_resultinterface. Users can directly call this interface to obtain the extended readings.
API Guide
The method to obtain the voltage value after ADC range extension varies for different versions of ESP-IDF:
ESP-IDF
v4.4.8To get the range expansion result, users must directly use
esp_adc_cal_get_voltageto get the voltage ofADC1orADC2.Other APIs of ESP-IDF
v4.4.8ADC are not affected, and the read results are consistent with the default results
ESP-IDF
v5.3.1To get the range expansion result, users must directly use
adc_oneshot_get_calibrated_resultto get the voltage ofADC1orADC2.Other APIs of ESP-IDF
v5.3.1ADC are not affected, and the read results are consistent with the default results
The patch enables ADC range extension by default and uses the float data type for correction. If you need to disable ADC extension or change the data type used during the correction process, please refer to the following procedure:
For ESP-IDF
v4.4.8: Please usemenuconfigto modify the settings underComponent config → Driver configurations → ADC configuration → ADC User Code OffsetFor ESP-IDF
v5.3.1: Please usemenuconfigto modify the settings underComponent config → ADC and ADC Calibration → ADC User Code Offset
Comparison of ADC Range Extension Effects
ESP32-S2 ADC Range Extension Effects Comparison:
ESP32-S3 ADC Range Extension Effects Comparison: