ESP32 DAC Example

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.

ESP32 DevKit Pinout

ESP32 Arduino IDE code for DAC

/*
 * Copyright (c) 2018, circuits4you.com
 * All rights reserved.
 * 
 * ESP32 DAC - Digital To Analog Conversion Example
 */

#define DAC1 25

void setup() {
  Serial.begin(115200);
  
}

void loop() { // Generate a Sine wave
  int Value = 255; //255= 3.3V 128=1.65V
  
  dacWrite(DAC1, Value);
  delay(1000);
}

Results

To check the output voltage simply connect Voltmeter at pin 25 and GND of ESP32.

Leave a Reply