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.
- 6 pins
- 1 setting
- In 1 project
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)
6 pins
Named as the editor names them, so a wire lands where you expect it.
VOUT is a fraction of it.VCC for the second address.VCC x code / 4096.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.
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.
#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 DAC, MCP4725 errors and fixes
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.
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.
See the DAC, MCP4725 in a project
One built-in project uses it. It opens in the editor, already wired.
The boards it is shown on
This board has a built-in project with the DAC, MCP4725 in it.
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.
The rest of the bench
Every one of these is drawn and simulated the same way.
Wire up the DAC, MCP4725
Open the editor and push it into the breadboard. It is free, and it runs on your own machine.