adc1_get_raw() function
Take an ADC1 reading from a single channel.
Arguments
channel
ADC1 channel to read
Return value
- -1: Parameter error - Other: ADC1 channel reading.
Notes
ESP32: 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. When enabling power for any of these peripherals, ignore input from GPIO36 and GPIO39. Please refer to section 3.11 of 'ECO_and_Workarounds_for_Bugs_in_ESP32' for the description of this issue. As a workaround, call sar_periph_ctrl_adc_oneshot_power_acquire() in the app. This will result in higher power consumption (by ~1mA), but will remove the glitches on GPIO36 and GPIO39. Call ``adc1_config_width()`` before the first time this function is called. For any given channel, adc1_config_channel_atten(channel) must be called before the first time this function is called. Configuring a new channel does not prevent a previously configured channel from being read.
![]()
adc_reading = adc1_get_raw(channel);
adc1_get_raw() is called by 2 functions and calls 11 functions:
![]()
adc1_get_raw()
adc1_get_raw() reads 9 variables:
![]()
adc1_get_raw()