ESP32 DAC

The ESP32 DAC platform allows you to output analog voltages using the 8-bit digital-to-analog converter of the ESP32. Unlike the ESP32 LEDC Output, which can simulate an analog signal by using a fast switching frequency, the hardware DAC can output a real analog signal with no need for additional filtering.

The DAC spans across two pins, each on its own channel: GPIO25 (Channel 1) and GPIO26 (Channel 2).

The output level is a percentage of the board supply voltage (VDD_A) - generally this will be 3.3 V.

# Example configuration entry
output:
  - platform: esp32_dac
    pin: GPIO25
    id: dac_output

# Example usage
on_...:
  then:
    - output.set_level:
        id: dac_output
        level: 50%

# Use the DAC output as a light
light:
  - platform: monochromatic
    output: dac_output
    gamma_correct: 1.4
    id: mono_light

Configuration variables:

  • pin (Required, Pin Schema): The pin to use DAC on. Only GPIO25 and GPIO26 are supported.

  • id (Required, ID): The id to use for this output component.

  • All other options from Output.

Use Cases

  • Generating a specific (and dynamic) reference voltage for an external sensor or ADC, such as the ADS1115 4-Channel 16-Bit A/D Converter

  • Controlling the bias of a transistor

  • Driving a bar graph or large amount of LEDs using an analog-controlled LED driver like the LM3914 (datasheet); this can allow you to make tank level indicators, temperature gauges, and so on from a single output pin

  • Generating 0-10 V for a dimmable light (operational amplifier required)

See Also