[−][src]Function esp_idf_bindgen::adc1_config_channel_atten
pub unsafe extern "C" fn adc1_config_channel_atten(
channel: adc1_channel_t,
atten: adc_atten_t
) -> esp_err_t
@brief Set the attenuation of a particular channel on ADC1, and configure its associated GPIO pin mux.
The default ADC full-scale voltage is 1.1 V. To read higher voltages (up to the pin maximum voltage, usually 3.3 V) requires setting >0 dB signal attenuation for that ADC channel. When VDD_A is 3.3 V: - 0 dB attenuation (ADC_ATTEN_DB_0) gives full-scale voltage 1.1 V - 2.5 dB attenuation (ADC_ATTEN_DB_2_5) gives full-scale voltage 1.5 V - 6 dB attenuation (ADC_ATTEN_DB_6) gives full-scale voltage 2.2 V - 11 dB attenuation (ADC_ATTEN_DB_11) gives full-scale voltage 3.9 V (see note below)
@note The full-scale voltage is the voltage corresponding to a maximum reading (depending on ADC1 configured bit width, this value in ESP32 is: 4095 for 12-bits, 2047 for 11-bits, 1023 for 10-bits, 511 for 9 bits. this value in ESP32S2 is: 8191 for 13-bits.)
@note At 11 dB attenuation the maximum voltage is limited by VDD_A, not the full scale voltage.
@note For ESP32: Due to ADC characteristics, most accurate results are obtained within the following approximate voltage ranges:
- 0 dB attenuation (ADC_ATTEN_DB_0) between 100 and 950 mV - 2.5 dB attenuation (ADC_ATTEN_DB_2_5) between 100 and 1250 mV - 6 dB attenuation (ADC_ATTEN_DB_6) between 150 to 1750 mV - 11 dB attenuation (ADC_ATTEN_DB_11) between 150 to 2450 mV For maximum accuracy, use the ADC calibration APIs and measure voltages within these recommended ranges.
@note For any given channel, this function must be called before the first time adc1_get_raw()
is called for that channel.
@note This function can be called multiple times to configure multiple
ADC channels simultaneously. adc1_get_raw()
can then be called for any configured channel.
@param channel ADC1 channel to configure @param atten Attenuation level
@return - ESP_OK success - ESP_ERR_INVALID_ARG Parameter error