Chapter 2. API Reference
ADC driver
Header File
•
components/driver/include/driver/adc.h
Functions
void adc_power_on(void)
Enable ADC power.
void adc_power_off(void)
Power off SAR ADC.
void adc_power_acquire(void)
Increment the usage counter for ADC module. ADC will stay powered on while the counter is greater than 0.
Call adc_power_release when done using the ADC.
void adc_power_release(void)
Decrement the usage counter for ADC module. ADC will stay powered on while the counter is greater than 0.
Call this function when done using the ADC.
esp_err_t adc1_pad_get_io_num(adc1_channel_t
Get the GPIO number of a specific ADC1 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 adc1_config_channel_atten(adc1_channel_t
Set the attenuation of a particular channel on ADC1, and configure its associated GPIO pin mux.
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.
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
218
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?