adc2_config_channel_atten() function
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 | (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
ADC2 channel to configure
Return value
- ESP_OK success - ESP_ERR_INVALID_ARG Parameter error
Notes
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. For any given channel, this function must be called before the first time ``adc2_get_raw()`` is called for that channel.
adc2_config_channel_atten() calls 9 functions:
![]()
adc2_config_channel_atten()
adc2_config_channel_atten() reads 7 variables:
![]()
adc2_config_channel_atten()