Chapter 2. API Reference
• ESP_ERR_INVALID_ARG Parameter error
Parameters
• adc_unit: ADC unit index
• width_bit: Bit capture width for ADC unit.
void adc1_ulp_enable(void)
Configure ADC1 to be usable by the ULP.
This function reconfigures ADC1 to be controlled by the ULP. Effect of this function can be reverted using
adc1_get_raw() function.
Note that adc1_config_channel_atten, adc1_config_width() functions need to be called to configure
ADC1 channels, before ADC1 is used by the ULP.
esp_err_t adc2_pad_get_io_num(adc2_channel_t
Get the GPIO number of a specific ADC2 channel.
Return
• ESP_OK if success
• ESP_ERR_INVALID_ARG if channel not valid
Parameters
• channel: Channel to get the GPIO number
• gpio_num: output buffer to hold the GPIO number
esp_err_t adc2_config_channel_atten(adc2_channel_t
Configure the ADC2 channel, including setting attenuation.
The default ADC voltage is for attenuation 0 dB and listed in the table below. By setting higher attenuation it
is possible to read higher voltages.
Due to ADC characteristics, most accurate results are obtained within the "suggested range"shown in the
following table.
+----------+-------------+-----------------+
|
| attenuation | suggested range |
|
SoC
|
+==========+=============+=================+
|
|
|
+-------------+-----------------+
|
|
|
ESP32
+-------------+-----------------+
|
|
|
+-------------+-----------------+
|
|
+----------+-------------+-----------------+
|
|
|
+-------------+-----------------+
|
|
| ESP32-S2 +-------------+-----------------+
|
|
|
+-------------+-----------------+
|
|
+----------+-------------+-----------------+
For maximum accuracy, use the ADC calibration APIs and measure voltages within these recommended
ranges.
Note This function also configures the input GPIO pin mux to connect it to the ADC2 channel. It must be
called before calling adc2_get_raw() for this channel.
Note For any given channel, this function must be called before the first time adc2_get_raw() is called
for that channel.
Return
• ESP_OK success
• ESP_ERR_INVALID_ARG Parameter error
Espressif Systems
(dB)
|
(mV)
0
|
100 ~
2.5
|
100 ~ 1250
6
|
150 ~ 1750
11
|
150 ~ 2450
0
|
0 ~
2.5
|
0 ~ 1050
6
|
0 ~ 1300
11
|
0 ~ 2500
220
Submit Document Feedback
channel,
gpio_num_t
*gpio_num)
channel,
adc_atten_t
|
950
|
|
|
|
750
|
|
|
|
atten)
Release v4.4
Need help?
Do you have a question about the ESP32-S2 and is the answer not in the manual?
Questions and answers