ADC

API Reference

Functions

esp_err_t adc_read(uint16_t *data)

Single measurement of TOUT(ADC) pin, unit : 1/1023 V or VDD pin, uint: 1 mV.

Note
When measuring VDD pin voltage, the TOUT(ADC) pin must be left floating.
Return
  • ESP_OK Success
  • ESP_ERR_INVALID_ARG Parameter error
  • ESP_FAIL adc has not been initialized yet
Parameters
  • data: Pointer to accept adc value.

esp_err_t adc_read_fast(uint16_t *data, uint16_t len)

Measure the input voltage of TOUT(ADC) pin, unit : 1/1023 V.

Note
Wi-Fi and interrupts need to be turned off.
Return
  • ESP_OK Success
  • ESP_ERR_INVALID_ARG Parameter error
  • ESP_FAIL adc has not been initialized yet
Parameters
  • data: Pointer to accept adc value. Input voltage of TOUT(ADC) pin, unit : 1/1023 V
  • len: Receiving length of ADC value, range [1, 65535]

esp_err_t adc_deinit()

Deinit the adc.

Return
  • ESP_OK Success
  • ESP_FAIL adc has not been initialized yet

esp_err_t adc_init(adc_config_t *config)

Initialize the adc.

Note
First modify menuconfig->Component config->PHY->vdd33_const value, vdd33_const provides ADC mode settings, i.e. selecting system voltage or external voltage measurements. When measuring system voltage, it must be set to 255. To read the external voltage on TOUT(ADC) pin, vdd33_const need less than 255 When the ADC reference voltage is set to the actual VDD33 power supply voltage, the value range of vdd33_const is [18,36], the unit is 0.1V. When the ADC reference voltage is set to the default value of 3.3V as the supply voltage, the range of vdd33_const is [0, 18] or (36, 255).
Return
  • ESP_OK Success
  • ESP_ERR_NO_MEM malloc fail
  • ESP_ERR_INVALID_ARG Parameter error
  • ESP_FAIL adc has been initialized
Parameters
  • config: Pointer to deliver initialize configuration parameter

Structures

struct adc_config_t

ADC initialization parameter structure type definition.

Public Members

adc_mode_t mode

ADC mode

uint8_t clk_div

ADC sample collection clock=80M/clk_div, range[8, 32]

Enumerations

enum adc_mode_t

ADC working mode enumeration.

Values:

ADC_READ_TOUT_MODE = 0
ADC_READ_VDD_MODE
ADC_READ_MAX_MODE