Noteįor any given channel, adc1_config_channel_atten(channel) must be called before the first time this function is called. NoteĬall adc1_config_width() before the first time this function is called. This will result in higher power consumption (by ~1mA), but will remove the glitches on GPIO36 and GPIO39. As a workaround, call adc_power_acquire() in the app. Please refer to section 3.11 of ‘ECO_and_Workarounds_for_Bugs_in_ESP32’ for the description of this issue.
When enabling power for any of these peripherals, ignore input from GPIO36 and GPIO39. Take an ADC1 reading from a single channel.ĮSP32: When the power switch of SARADC1, SARADC2, HALL sensor and AMP sensor is turned on, the input of GPIO36 and GPIO39 will be pulled down for about 80ns. Int adc1_get_raw ( adc1_channel_t channel ) ¶ The configuration is for all channels of ADC1. ReturnĮsp_err_t adc1_config_width ( adc_bits_width_t width_bit ) ¶Ĭonfigure ADC1 capture width, meanwhile enable output invert for ADC1. You may call adc1_get_raw() only after configuring a channel. This function can be called multiple times to configure multiple ADC channels simultaneously. | ESP32-S2 +-+-+įor maximum accuracy, use the ADC calibration APIs and measure voltages within these recommended ranges.įor any given channel, this function must be called before the first time adc1_get_raw() is called for that channel. By setting higher attenuation it is possible to read higher voltages.ĭue to ADC characteristics, most accurate results are obtained within the “suggested range” shown in the following table. The default ADC voltage is for attenuation 0 dB and listed in the table below.
Set the attenuation of a particular channel on ADC1, and configure its associated GPIO pin mux. Gpio_num: output buffer to hold the GPIO numberĮsp_err_t adc1_config_channel_atten ( adc1_channel_t channel, adc_atten_t atten ) ¶ Get the GPIO number of a specific ADC1 channel. esp_err_t adc1_pad_get_io_num ( adc1_channel_t channel, gpio_num_t * gpio_num ) ¶ Call this function when done using the ADC. ADC will stay powered on while the counter is greater than 0. void adc_power_release (void ) ¶ĭecrement the usage counter for ADC module. Call adc_power_release when done using the ADC. Increment the usage counter for ADC module. It comes handy to calibrate ADC reading and this is discussed in section ADC Calibration. There is another specific function adc_vref_to_gpio() used to route internal reference voltage to a GPIO pin. To do so, call function adc1_ulp_enable() and then set precision and attenuation as discussed above. This API provides convenient way to configure ADC1 for reading from ULP. Otherwise it may affect the measurement of low value signal from the sensor. Do not connect anything else to these pins and do not change their configuration. Note that even the hall sensor is internal to ESP32, reading from it uses channels 0 and 3 of ADC1 (GPIO 36 and 39). It is also possible to read the internal hall effect sensor via ADC1 by calling dedicated function hall_sensor_read(). Single Read mode ADC example can be found in peripherals/adc/single_read directory of ESP-IDF examples. Reading width of ADC2 should be set as a parameter of adc2_get_raw() instead of in the configuration functions. Then it is possible to read ADC conversion result with adc1_get_raw() and adc2_get_raw(). The reading width of ADC2 is configured every time you take the reading.Īttenuation configuration is done per channel, see adc1_channel_t and adc2_channel_t, set as a parameter of above functions. For ADC1, configure desired precision and attenuation by calling functions adc1_config_width() and adc1_config_channel_atten().įor ADC2, configure the attenuation by adc2_config_channel_atten().