Part

DAC, MCP4725

A 12-bit analog voltage out over I2C at 0x60, VCC x code / 4096, with an EEPROM that keeps it, for Adafruit_MCP4725.h.

See every part
  • 6 pins
  • 1 setting
  • In 1 project
Drawn live by the editor's own code, at the size you see it.
At a glance

The DAC, MCP4725 in brief

What it is, and every setting the properties panel gives it.

The MCP4725 is a single-channel, 12-bit digital-to-analog converter on a small I2C breakout. An Uno can only fake an in-between voltage with PWM, a fast square wave whose average happens to land where you want it; the MCP4725 instead holds VOUT at a steady level, VCC multiplied by the code and divided by 4096. That makes it the usual way to feed a real voltage to an op-amp, a meter, a VCO or another board’s analog input. On the Mokxi bench the output is a voltage source behind 1 ohm, so a load on it divides the way it would on a breadboard. The chip’s EEPROM is modeled too: a new part wakes at mid-scale, a stored code comes back at the next power-up within the run, and an EEPROM write keeps the chip busy for 25 ms. The model property picks the A0 or A1 variant, which decides whether it answers at 0x60 or 0x62.

Family
Sensors
Pins
6
model
MCP4725A0 (or MCP4725A1, MCP4725A2, MCP4725A3)
Pins

6 pins

Named as the editor names them, so a wire lands where you expect it.

Pin
What it does
VCC
Supply, 2.7 to 5.5 V. It is also the reference: VOUT is a fraction of it.
GND
Ground.
SDA
I2C, with 10k pull-ups on the board.
SCL
I2C, with 10k pull-ups on the board.
A0
Address bit, pulled down on the board. Wire it to VCC for the second address.
VOUT
The output: VCC x code / 4096.
How to use it

How to use the MCP4725 DAC with an Arduino

Four wires do it: VCC to 5 V, GND to GND, SDA to A4 and SCL to A5. Leave the board’s A0 pad alone and a generic purple module answers at 0x60. The output, VOUT, is where the voltage appears. In the DAC sine project it goes to the Uno’s A0, so the sketch can read back what it set, and to channel 1 of the oscilloscope.

Call dac.begin(0x60), then dac.setVoltage(code, false) with a code from 0 to 4095. With the board on 5 V, code 2048 is 2.5 V and each step is about 1.2 mV. The project steps through a 32-point sine every 20 ms and plays the same curve on pin 9 with analogWrite(), so the scope shows a smooth staircase on one channel and a PWM square wave on the other.

The second argument of setVoltage() decides whether the code is also written to the EEPROM. Leave it false for anything that changes often; pass true once when you want the chip to wake up at that voltage next time.

Part pin
Board pin
VCC
5 V
GND
GND
SDA
A4
SCL
A5
VOUT
A0, and the scope’s channel 1
A0 (address)
Not wired: address 0x60

VCC is also the reference, so on a 3.3 V board such as an ESP32 or a Pico the same codes span 0 to 3.3 V instead of 0 to 5 V.

Arduino Uno: MCP4725 sine on a scopelive0.000 s 0.00x
Click to open it in the editor
This is the simulator itself, running here. Click anything to open it in the editor.
Setting the output, from the DAC sine sketch
#include <Wire.h>
#include <Adafruit_MCP4725.h>

Adafruit_MCP4725 dac;

void setup() {
  if (!dac.begin(0x60)) {
    while (1) {}   // nothing answered at 0x60
  }
}

void loop() {
  dac.setVoltage(2048, false);   // half of VCC, 2.5 V on 5 V
}
Common errors

Common DAC, MCP4725 errors and fixes

What goes wrong
The fix
begin() returns false, or an I2C scan finds the chip somewhere you did not ask for.
Adafruit’s library assumes 0x62, the address of Adafruit’s own board. A generic module is 0x60, or 0x61 with its A0 pad tied to VCC. Pass the address to begin().
VOUT sits at about 2.5 V before the sketch has written anything.
That is the factory EEPROM value, mid-scale. Write the code you want in setup(), or store a different power-up value once with setVoltage(code, true).
A write straight after storing to the EEPROM changes nothing.
An EEPROM write keeps the chip busy for 25 ms and it ignores writes until it is done. Store rarely, and wait before the next write.
The output only reaches a fraction of the voltage you expected.
The code is 12 bits, 0 to 4095, not the 0 to 255 of analogWrite(). Scale your value up, or shift it left by four as the sine sketch does the other way.
Questions

Questions and answers

Is the MCP4725 output real analog or PWM?

Real analog. VOUT holds a steady voltage, VCC times the code over 4096, with no switching. The DAC sine project draws both on one scope so you can see the difference.

What is the I2C address of an MCP4725 module?

It depends on the variant. The common MCP4725A0 boards answer at 0x60, or 0x61 with A0 high. Adafruit’s board carries the A1 variant at 0x62 or 0x63. Set the part’s model property to match the board you are copying.

Does the MCP4725 remember its voltage after power off?

Only if you store it. setVoltage(code, true) writes the code to the EEPROM as well, and the chip loads it at the next power-up. Plain writes with false are lost.

Can the MCP4725 drive a motor or an LED strip directly?

No. The real output stage is good for a few milliamps, about 25 mA at most, so a heavier load needs a transistor or an op-amp buffer after it. The simulation does not apply that limit, so check your load against it before building.

How it is modeled

What is true about the DAC, MCP4725, here

In its help article’s own words: what the simulation gets right, and where it stops.

Modeled

Every write command. The fast write (two bytes, repeatable in one transfer), the three-byte write of the DAC register, and the same with the EEPROM. The output moves at the acknowledge, as the datasheet says.

The EEPROM. A new chip starts at mid-scale, 0x800, the factory value. A write to the EEPROM keeps the chip busy for 25 ms: the RDY/BSY bit reads 0 and any write in that time is ignored. At power-on, and at a general call reset, the chip loads the EEPROM into its output, so a value stored before a power cycle comes back after it. The EEPROM lasts for the run; a new run starts from the factory value.

Reads. Five bytes: status with RDY/BSY and the power-down bits, the DAC register, and the EEPROM.

Power-down. Modes 1, 2 and 3 turn the output off and leave 1k, 100k or 500k to ground on VOUT. A write in normal mode, or a general call wake-up, ends it.

A real output. VOUT is a voltage source behind 1 ohm (the datasheet's output impedance), so a load on it divides as it would on the bench.

Not modeled

The output amplifier's 25 mA limit and its swing short of the rails under load, offset and gain error, the 6 us settling time and glitches, high-speed I2C mode, EEPROM wear, and the slow power-up that can make a real chip miss loading its EEPROM. An EEPROM write cut short by the supply leaves the old value.

From MCP4725 DAC, in full.

Projects

See the DAC, MCP4725 in a project

One built-in project uses it. It opens in the editor, already wired.

Boards

The boards it is shown on

This board has a built-in project with the DAC, MCP4725 in it.

Libraries

Arduino libraries for the DAC, MCP4725

Built in, so the sketch compiles with nothing to install. Each page has the calls, the wiring and an example to run.

Wire up the DAC, MCP4725

Open the editor and push it into the breadboard. It is free, and it runs on your own machine.