adc1_config_channel_atten() function
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 | (dB) | (mV) | +==========+=============+=================+ | | 0 | 100 ~ 950 | | +-------------+-----------------+ | | 2.5 | 100 ~ 1250 | | ESP32 +-------------+-----------------+ | | 6 | 150 ~ 1750 | | +-------------+-----------------+ | | 11 | 150 ~ 2450 | +----------+-------------+-----------------+ | | 0 | 0 ~ 750 | | +-------------+-----------------+ | | 2.5 | 0 ~ 1050 | | ESP32-S2 +-------------+-----------------+ | | 6 | 0 ~ 1300 | | +-------------+-----------------+ | | 11 | 0 ~ 2500 | +----------+-------------+-----------------+ For maximum accuracy, use the ADC calibration APIs and measure voltages within these recommended ranges.
Arguments
channel
ADC1 channel to configure
Return value
- ESP_OK success - ESP_ERR_INVALID_ARG Parameter error
Notes
For any given channel, this function must be called before the first time ``adc1_get_raw()`` is called for that channel. This function can be called multiple times to configure multiple ADC channels simultaneously. You may call ``adc1_get_raw()`` only after configuring a channel.
adc1_config_channel_atten() calls 7 functions:
![]()
adc1_config_channel_atten()
adc1_config_channel_atten() reads 7 variables:
![]()
adc1_config_channel_atten()