Digital To Analog Converter¶
ESP32 has two 8-bit DAC (digital to analog converter) channels, connected to GPIO25 (Channel 1) and GPIO26 (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, via the I2S driver when using the “built-in DAC mode”.
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.
Setting DAC channel 1 (GPIO 25) 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_out_voltage(DAC_CHANNEL_1, 200);
dac_out_voltage(dac_channel_t channel, uint8_t dac_value)¶
Set DAC output voltage.
DAC output is 8-bit. Maximum (255) corresponds to VDD.
- When this function is called, function for the DAC channel’s GPIO pin is reconfigured for RTC DAC function.
- ESP_OK success
- ESP_ERR_INVALID_ARG Parameter error
channel: DAC channel
dac_value: DAC output value