Chapter 2. API Reference
ADC2_GPIO19_CHANNEL
ADC2_CHANNEL_8_GPIO_NUM
ADC2_GPIO20_CHANNEL
ADC2_CHANNEL_9_GPIO_NUM
2.2.2 Digital To Analog Converter (DAC)
Overview
ESP32-S2 has two 8-bit DAC (digital to analog converter) channels, connected to GPIO17 (Channel 1) and GPIO18
(Channel 2).
The DAC driver allows these channels to be set to arbitrary voltages.
The DAC channels can also be driven with DMA-style written sample data by the digital controller, however the
driver does not supported this yet.
For other analog output options, see the Sigma-delta Modulation module and the LED Control module. Both these
modules produce high frequency PWM output, which can be hardware low-pass filtered in order to generate a lower
frequency analog output.
Application Example
Setting DAC channel 1 (GPIO17) voltage to approx 0.78 of VDD_A voltage (VDD * 200 / 255). For VDD_A 3.3V,
this is 2.59V:
#include <driver/dac.h>
...
dac_output_enable(DAC_CHANNEL_1);
dac_output_voltage(DAC_CHANNEL_1, 200);
API Reference
Header File
• components/driver/esp32s2/include/driver/dac.h
Functions
esp_err_t dac_digi_init(void)
DAC digital controller initialization.
Return
• ESP_OK success
esp_err_t dac_digi_deinit(void)
DAC digital controller deinitialization.
Return
• ESP_OK success
esp_err_t dac_digi_controller_config(const dac_digi_config_t *cfg)
Setting the DAC digital controller.
Return
• ESP_OK success
• ESP_ERR_INVALID_ARG Parameter error
Espressif Systems 235
Submit Document Feedback
Release v4.4