<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>MCP4725 Breakout Archives - CyberBlogSpot</title>
	<atom:link href="https://cyberblogspot.com/tag/mcp4725-breakout/feed/" rel="self" type="application/rss+xml" />
	<link>https://cyberblogspot.com/tag/mcp4725-breakout/</link>
	<description>Not just another blogspot site</description>
	<lastBuildDate>Wed, 18 Jan 2023 03:10:49 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.8.3</generator>

<image>
	<url>https://cyberblogspot.com/wp-content/uploads/2018/08/cropped-iphone-iphone3gs-32x32.jpg</url>
	<title>MCP4725 Breakout Archives - CyberBlogSpot</title>
	<link>https://cyberblogspot.com/tag/mcp4725-breakout/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>How to Use MCP4725 Module with Arduino</title>
		<link>https://cyberblogspot.com/how-to-use-mcp4725-module-with-arduino/</link>
					<comments>https://cyberblogspot.com/how-to-use-mcp4725-module-with-arduino/#respond</comments>
		
		<dc:creator><![CDATA[admin]]></dc:creator>
		<pubDate>Fri, 19 Mar 2021 09:30:06 +0000</pubDate>
				<category><![CDATA[Arduino]]></category>
		<category><![CDATA[Arduino MCP4725]]></category>
		<category><![CDATA[Arduino MCP4725 Breakout]]></category>
		<category><![CDATA[Arduino MCP4725 Breakout Board]]></category>
		<category><![CDATA[Arduino MCP4725 Module]]></category>
		<category><![CDATA[Arduino MCP4725 Wiring Diagram]]></category>
		<category><![CDATA[MCP4725]]></category>
		<category><![CDATA[MCP4725 Arduino]]></category>
		<category><![CDATA[MCP4725 Breakout]]></category>
		<category><![CDATA[MCP4725 Breakout Board]]></category>
		<category><![CDATA[MCP4725 Library]]></category>
		<category><![CDATA[MCP4725 Module]]></category>
		<category><![CDATA[MCP4725 Schematic]]></category>
		<guid isPermaLink="false">https://cyberblogspot.com/?p=4307</guid>

					<description><![CDATA[<p>Arduino does not have a built-in Digital to Analog Converter (DAC). However, in some situations, like controlling motors and LEDs, we can use Arduino&#8217;s PWM outputs. That is, by varying the duty cycle of a PWM output on a digital pin, we can obtain a variable analog voltage from 0 volt to 5 volts. But&#8230;&#160;<a href="https://cyberblogspot.com/how-to-use-mcp4725-module-with-arduino/" rel="bookmark">Read More &#187;<span class="screen-reader-text">How to Use MCP4725 Module with Arduino</span></a></p>
<p>The post <a href="https://cyberblogspot.com/how-to-use-mcp4725-module-with-arduino/">How to Use MCP4725 Module with Arduino</a> appeared first on <a href="https://cyberblogspot.com">CyberBlogSpot</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p class="has-drop-cap">Arduino does not have a built-in Digital to Analog Converter (DAC).  However, in some situations, like controlling motors and LEDs, we can use Arduino&#8217;s PWM outputs.  That is, by varying the duty cycle of a PWM output on a digital pin, we can obtain a variable analog voltage from 0 volt to 5 volts.  But if we need a more precise analog output voltage, we can instead use an MCP4725 DAC module or breakout board for Arduino. </p>


<div class="wp-block-image">
<figure class="aligncenter size-large"><img fetchpriority="high" decoding="async" width="352" height="302" src="https://cyberblogspot.com/wp-content/uploads/2021/03/mcp4725-dac-chip.jpg" alt="The microchip MCP4725 chip or integrated circuit is the heart of an MCP4725 module or breakout board that can be used with Arduino" class="wp-image-4385" srcset="https://cyberblogspot.com/wp-content/uploads/2021/03/mcp4725-dac-chip.jpg 352w, https://cyberblogspot.com/wp-content/uploads/2021/03/mcp4725-dac-chip-300x257.jpg 300w" sizes="(max-width: 352px) 100vw, 352px" /><figcaption class="wp-element-caption">MCP4725 IC used on MCP4725 Module or Breakout Board</figcaption></figure></div>


<h2 class="wp-block-heading">Microchip MCP4725 Integrated Circuit</h2>



<p>The MCP4725 is a 12-bit Digital to Analog Converter with EEPROM memory.  It uses the I<sup>2</sup>C protocol to communicate with an MCU.  List of notable features:</p>



<ul class="wp-block-list">
<li>12-bit resolution</li>



<li>I<sup>2</sup>C protocol interface</li>



<li>On board EEPROM memory</li>



<li>0.2 LSB Differential Nonlinearity (DNL)</li>



<li>External address pin</li>



<li>Power down mode</li>



<li>Fast settling time</li>



<li>Low power consumption</li>



<li>Rail-to-rail output</li>



<li>Single supply operation</li>



<li>External voltage reference</li>



<li>Eight available addresses</li>



<li>Standard, fast, and high-speed modes</li>



<li>Small SOT-23 package</li>



<li>Extended temperature range</li>
</ul>



<p>The MCP4725 chip uses a small 6-pin SOT-23-6 package.  That is to say, it is an SMD (Surface Mount Device) device.  Also, the chip is really very small, with its plastic body measuring around 2 x 3 mm.   </p>


<div class="wp-block-image">
<figure class="aligncenter size-large"><a href="https://cyberblogspot.com/wp-content/uploads/2021/03/mcp4725-chip-pinout.png"><img decoding="async" width="428" height="216" src="https://cyberblogspot.com/wp-content/uploads/2021/03/mcp4725-chip-pinout.png" alt="The MCP4725 pinout or pin configuration.  The MCP4725 integrated circuit is used on MCP4725 modules or breakout board that can be used for Arduino projects" class="wp-image-4393" srcset="https://cyberblogspot.com/wp-content/uploads/2021/03/mcp4725-chip-pinout.png 428w, https://cyberblogspot.com/wp-content/uploads/2021/03/mcp4725-chip-pinout-300x151.png 300w" sizes="(max-width: 428px) 100vw, 428px" /></a><figcaption class="wp-element-caption">MCP4725 IC Pin Configuration</figcaption></figure></div>

<div class="wp-block-image">
<figure class="aligncenter size-large"><a href="https://cyberblogspot.com/wp-content/uploads/2021/03/mcp4725-chip-block-diagram.png"><img decoding="async" width="426" height="430" src="https://cyberblogspot.com/wp-content/uploads/2021/03/mcp4725-chip-block-diagram.png" alt="The picture shows the functional block diagram of an MCP4725 IC chip that is used on MCP4725 modules or breakout boards" class="wp-image-4392" srcset="https://cyberblogspot.com/wp-content/uploads/2021/03/mcp4725-chip-block-diagram.png 426w, https://cyberblogspot.com/wp-content/uploads/2021/03/mcp4725-chip-block-diagram-297x300.png 297w, https://cyberblogspot.com/wp-content/uploads/2021/03/mcp4725-chip-block-diagram-150x150.png 150w" sizes="(max-width: 426px) 100vw, 426px" /></a><figcaption class="wp-element-caption">MCP4725 IC Block Diagrarm</figcaption></figure></div>


<h2 class="wp-block-heading">The MCP4725 Modules or Breakout Boards for Arduino</h2>



<p>Since the MCP4725 chip comes in a very small package, it is hard to solder it on a PCB.  Luckily, both SparkFun and Adafruit have a breakout board or an MCP4725 module.  Moreover, MCP4725 modules from Chinese cloners are everywhere.  As a matter of fact, almost every popular online shopping stores have them on their inventory.  As a result, I have seen modules selling at very cheap prices.  Some are selling at almost a dollar a piece (Adafruit: $4.95, SparkFun: $5.25). </p>


<div class="wp-block-image">
<figure class="aligncenter size-large"><img loading="lazy" decoding="async" width="620" height="494" src="https://cyberblogspot.com/wp-content/uploads/2021/02/mcp4725-adafruit-1.jpg" alt="A picture of an Adafruit MCP4725 module or breakout board that can be used with Arduino projects" class="wp-image-4308" srcset="https://cyberblogspot.com/wp-content/uploads/2021/02/mcp4725-adafruit-1.jpg 620w, https://cyberblogspot.com/wp-content/uploads/2021/02/mcp4725-adafruit-1-300x239.jpg 300w" sizes="auto, (max-width: 620px) 100vw, 620px" /><figcaption class="wp-element-caption">Adafruit MCP4725 Module</figcaption></figure></div>

<div class="wp-block-image">
<figure class="aligncenter size-large"><img loading="lazy" decoding="async" width="602" height="452" src="https://cyberblogspot.com/wp-content/uploads/2021/02/mcp4725-sparkfun-1-1.jpg" alt="A screenshot of another model of MCP4725 breakout board " class="wp-image-4310" srcset="https://cyberblogspot.com/wp-content/uploads/2021/02/mcp4725-sparkfun-1-1.jpg 602w, https://cyberblogspot.com/wp-content/uploads/2021/02/mcp4725-sparkfun-1-1-300x225.jpg 300w" sizes="auto, (max-width: 602px) 100vw, 602px" /><figcaption class="wp-element-caption">SparkFun MCP4725 Module</figcaption></figure></div>


<h2 class="wp-block-heading">MCP4725 DAC Module Schematic Diagram</h2>


<div class="wp-block-image">
<figure class="aligncenter size-large"><img loading="lazy" decoding="async" width="669" height="322" src="https://cyberblogspot.com/wp-content/uploads/2021/02/mcp4725-adafruit-schematic.png" alt="Schematic diagram of an MCP4725 DAC module or breakout board" class="wp-image-4312" srcset="https://cyberblogspot.com/wp-content/uploads/2021/02/mcp4725-adafruit-schematic.png 669w, https://cyberblogspot.com/wp-content/uploads/2021/02/mcp4725-adafruit-schematic-300x144.png 300w" sizes="auto, (max-width: 669px) 100vw, 669px" /><figcaption class="wp-element-caption">MCP4725 Module Schematic Diagram (Adafruit)</figcaption></figure></div>


<p>Shown above is the MCP4725 DAC Module for Arduino.  The schematic diagram is a screenshot taken from the Adafruit documentation.  It is representative of most of the MCP4725 breakout modules.  </p>



<p>Let us take a look at the different parts of the schematic.  First, two 10K resistors are connected on pins 4 and 5, the SDA and SCL pins respectively.  The resistors pull the pins to the VDD potential (they are called pull-up resistors).  The I<sup>2</sup>C interface needs them for proper operation.  Second, another 10K resistor connects to the A0 pin.  This resistor selects the I<sup>2</sup>C address to be used by the module.  Third, a 1.0 microfarad capacitor connects the VDD and GND pins.  This is a power supply de-coupling capacitor.  It is there for reducing the noise coming from the power supply.  And lastly, the terminal JP1 breaks out all the MCP4725 pins for external connections.</p>



<blockquote class="wp-block-quote has-text-align-center is-style-default is-layout-flow wp-block-quote-is-layout-flow">
<p><strong>Supply Voltage (VDD or VSS)</strong></p>



<p>This pin requires an appropriate bypass capacitor of<br>about 0.1 μF (ceramic) to ground. An additional 10 μF<br>capacitor (tantalum) in parallel is also recommended to<br>further attenuate high frequency noise present in<br>application boards. The supply voltage (VDD) must be<br>maintained in the 2.7V to 5.5V range for specified<br>operation.</p>
<cite>Page 13, Datasheet Entitled: 12-Bit Digital-to-Analog Converter with EEPROM Memory<br>in SOT-23-6</cite></blockquote>



<h2 class="wp-block-heading">MCP4725 Module and Arduino Wiring Diagram</h2>



<figure class="wp-block-image size-large"><a href="https://cyberblogspot.com/wp-content/uploads/2021/03/mcp4725-arduino-wiring-connection.jpg"><img loading="lazy" decoding="async" width="1002" height="607" src="https://cyberblogspot.com/wp-content/uploads/2021/03/mcp4725-arduino-wiring-connection.jpg" alt="Wiring diagram showing how to connect MCP4725 module or breakout board to Arduino R3" class="wp-image-4395" srcset="https://cyberblogspot.com/wp-content/uploads/2021/03/mcp4725-arduino-wiring-connection.jpg 1002w, https://cyberblogspot.com/wp-content/uploads/2021/03/mcp4725-arduino-wiring-connection-300x182.jpg 300w, https://cyberblogspot.com/wp-content/uploads/2021/03/mcp4725-arduino-wiring-connection-768x465.jpg 768w" sizes="auto, (max-width: 1002px) 100vw, 1002px" /></a><figcaption class="wp-element-caption">Wiring Diagram for Connecting MCP4725 to Arduino</figcaption></figure>



<p>The wiring diagram above shows how easy it is to connect the MCP4725 module to Arduino.  First, connect the VCC of the module to the 5V pin of the Arduino board.  If you want, you may also power the module using the 3V3 (3.3V) pin.  In this case, the module will use the 3.3V as the voltage reference for its measurement instead of 5 volts.  Then, connect the GND terminal of MCP4725 to the corresponding GND terminal of the Arduino board. </p>



<p>Second, connect the SDA and the SCL pins of the MCP4725 module to Arduino&#8217;s D4 and D5 respectively.  This is because, D4 is Arduino&#8217;s SDA pin and D5 is its SCL pin.  </p>



<p>Finally, if you want to monitor the DAC output voltage using a voltmeter, connect the OUT terminal to the positive terminal of a voltmeter and the GND terminal to the negative terminal of the voltmeter.  But if you want to simply use the Arduino to measure the output voltage from the DAC, then connect the OUT terminal to the A0 terminal on the Arduino board.  Or, you may use any of the other free analog inputs (A1, A2, or A3).</p>



<h2 class="wp-block-heading">Arduino Library for MCP4725 DAC Module</h2>



<h3 class="wp-block-heading">How to Install the MCP4725 Library</h3>



<p>Before we can use the MCP4725 module, we need to install the library files for Arduino.  To install the library files, use the Library Manager that is available on the Tools -&gt; Manage Libraries.  You can find this on the main menu of the Arduino IDE.</p>



<h3 class="wp-block-heading">Adafruit Library Versus Rob Tillaart Library</h3>



<p>Arduino IDE comes with two libraries for the MCP4725 module.  One is from Adafruit and the other one is from Rob Tillaart.  The Adafruit library version has a very small set off procedures.  As a matter of fact, the Adafruit library has only a class constructor, an initialization, and a write procedure.  No more, no less.  Below is an excerpt from the Adafruit MCP4725 library header file.  It shows the three (3) procedures.  First is the Adafruit_MCP4725().  Second, the begin() procedure. And lastly, the setVoltage() procedure. </p>



<pre class="EnlighterJSRAW">class Adafruit_MCP4725 {
public:
  Adafruit_MCP4725();
  bool begin(uint8_t i2c_address = MCP4725_I2CADDR_DEFAULT,
             TwoWire *wire = &amp;Wire);
  bool setVoltage(uint16_t output, bool writeEEPROM,
                  uint32_t dac_frequency = 400000);
}</pre>



<p>The other MCP4725 library, the one from Rob Tillaart has many additional useful procedures.  Shown below is the excerpt from the header file showing the different methods available.</p>



<pre class="EnlighterJSRAW">class MCP4725
{
public:
  explicit MCP4725(const uint8_t deviceAddress, TwoWire *wire = &amp;Wire);

#if defined(ESP8266) || defined(ESP32)
  bool     begin(const uint8_t dataPin, const uint8_t clockPin);
#endif
  bool     begin();
  bool     isConnected();

  // uses writeFastMode
  int      setValue(const uint16_t value = 0);
  // returns last value set - cached - much faster than readDAC();
  uint16_t getValue();

  // 0..100.0% - no input check.
  int      setPercentage(float perc = 0) { return setValue(round(perc * (0.01 *       
MCP4725_MAXVALUE))); };
  float    getPercentage() { return getValue() * (100.0 / MCP4725_MAXVALUE); };

  int      writeDAC(const uint16_t value, const bool EEPROM = false);
  // RDY isdepreciated in the future, use ready() instead.
  // inline bool RDY()  { return ready(); };
  bool     ready();
  uint32_t getLastWriteEEPROM()  { return _lastWriteEEPROM; };
  uint16_t readDAC();
  uint16_t readEEPROM();

  // experimental
  int      writePowerDownMode(const uint8_t PDM, const bool EEPROM = false);
  uint8_t  readPowerDownModeEEPROM();
  uint8_t  readPowerDownModeDAC();
  int      powerOnReset();
  int      powerOnWakeUp();
}</pre>



<h2 class="wp-block-heading">Sample Sketch for Using MCP4725 Module</h2>



<p>For simplicity, we will use the Adafruit library for the MCP4725.  To use the library, first, we need to reference the library files in our sketch.</p>



<pre class="EnlighterJSRAW">#include &lt;Adafruit_MCP4725.h&gt;</pre>



<p>Then create an object or an instance of the Adafruit_MCP4725 class.  You may use any name you want for the object name.  In this case, I am using &#8220;myDAC&#8221;.</p>



<pre class="EnlighterJSRAW">Adafruit_MCP4725 myDAC;</pre>



<p>Afterwards, in the loop() procedure, we initialize the DAC object.  Here, the begin() method needs the address of the MCP4725 module in hex format.  The address is hardwired on the module.  But, depending the module you have, it&#8217;s either 0x60, 0x61, or 0x62. </p>



<pre class="EnlighterJSRAW">void setup(){
myDAC.begin(0x60);
}</pre>



<p>Finally, in the loop() procedure, we use the method setVoltage() to make the MCP4725 output a certain voltage. </p>



<pre class="EnlighterJSRAW">void loop(){
myDAC.setVoltage(2048, false);
}</pre>



<h3 class="wp-block-heading">How the setVoltage() Method Works</h3>



<p>As shown in the header file excerpt above, the setVoltage() method is defined as follows:</p>



<pre class="EnlighterJSRAW">bool setVoltage(uint16_t output, bool writeEEPROM,
                  uint32_t dac_frequency = 400000);</pre>



<p>The setVoltage() method has three (3) parameters, the first two (2) of which are required.  The three (3) parameters are <strong>output</strong>, <strong>writeEEPROM</strong>, and <strong>dac_frequency</strong>.</p>



<p>The first parameter, <strong>output</strong>, accepts a value ranging from 0 to 4095.  This is a 12-bit value that represents the digital <strong>input</strong> code to the DAC.  The maximum value of 4095 is the result of the DAC having a 12-bit resolution.  That is, <strong>2<sup>12</sup>-1 = 4095.</strong>  In other words, the DAC can generate 4095 different output voltages.  </p>



<p>The second parameter, <strong>writeEEPROM</strong>, is either &#8220;true&#8221; or &#8220;false&#8221;.  Because the MCP4725 allows us to store the DAC input value into its built-in memory, the second parameter allows us to enable or disable this feature.  The main use of this feature is for restoring the previous state of the DAC after a reset or power-down mode.</p>



<h4 class="wp-block-heading">MCP4725 DAC Frequency</h4>



<p>The third parameter is the <strong>dac_frequency</strong>.  The DAC frequency refers to the I<sup>2</sup>C data transfer rate.  In this case, it is the data transfer rate between the Arduino board and the MCP4725 module.  This is an optional parameter. Unlike the first two (2) parameters, output and writeEEPROM, you are not required to provide any value for the dac_frequency.  In that case, it will use the default value of 400,000.  The MCP4725 DAC has three speed modes, the standard mode (100khz), the fast mode (400khz), and the high speed mode (3.4Mhz).  Therefore, the valid arguments for the dac_frequency are 100,000, 400,000 (default), and 3,400,000.  </p>



<blockquote class="wp-block-quote has-text-align-center is-style-large is-layout-flow wp-block-quote-is-layout-flow">
<p>FYI: The default Arduino I<sup>2</sup>C protocol speed is 100khz.</p>
</blockquote>



<p>To sum up on the setVoltage() method, the procedure accepts three arguments which are the output (0 to 4095), the writeEEPROM (true or false), and the optional dac_frequency (1khz, 4khz, or 3.4Mhz). </p>



<pre class="EnlighterJSRAW">//Examples
myDAC.setVoltage(2048, false); //output a voltage about 1/2 of Vref
myDAC.setVoltage(4095, true);  //output the maximum voltage and store on EEPROM
myDAC.setVoltage(0, false, 4300000)  //set to minimum voltage, don&#039;t store, use //high speed mode</pre>



<h4 class="wp-block-heading">How to Output a Specific Voltage using setVoltage()</h4>



<p>As discussed above, setVoltage() accepts a value in the range of 0 to 4095.  We know that 0 means we should get a 0 volts output voltage.  Also, 4095 means that we should get a 5 volts output voltage.  This is of course assuming that we are using a 5V power supply.  Again, our voltage reference here is 5V (equal to the supply voltage).</p>



<p>What value should we use for the setVoltage() if we want an output voltage of 1V? 2V? 2.75V? etc.?</p>



<p>As it turns out, we need to compute the value of the input code.  The way the DAC works, it divides the Vref voltage into 4095 discrete values.  That is, Vref / 4095 or in this case 5V / 4095.  This gives us 0.00122 or about 1.2mV.  So, the digital code 1 is 1.2mv, digital code 2 is 2.4mV, digital code 3 is 3.6mV, and so on.  </p>



<h4 class="wp-block-heading">The MCP4725 Datasheet Formula</h4>



<p>The MCP4725 datasheet, on page 19, gives us the formula for computing the output voltage.</p>


<div class="wp-block-image">
<figure class="aligncenter size-large"><a href="https://cyberblogspot.com/wp-content/uploads/2021/03/mcp4725-Vout-computation.png"><img loading="lazy" decoding="async" width="444" height="191" src="https://cyberblogspot.com/wp-content/uploads/2021/03/mcp4725-Vout-computation.png" alt="Formula for computing the output voltage of MCP4725 module in Arduino" class="wp-image-4413" srcset="https://cyberblogspot.com/wp-content/uploads/2021/03/mcp4725-Vout-computation.png 444w, https://cyberblogspot.com/wp-content/uploads/2021/03/mcp4725-Vout-computation-300x129.png 300w" sizes="auto, (max-width: 444px) 100vw, 444px" /></a></figure></div>


<p>Based on the formula above, let&#8217;s compute <strong>Dn</strong> or the digital input code for a specific output voltage <strong>Vout</strong>.</p>



<p><img decoding="async" class="aligncenter" src="https://latex.codecogs.com/gif.latex?\fn_phv&amp;space;Vout=\frac{(Vref*Dn)}{4096}" alt="\fn_phv Vout=\frac{(Vref*Dn)}{4096}" align="absmiddle"></p>
<p>Cross multiplying, we get</p>
<p><img decoding="async" class="aligncenter" src="https://latex.codecogs.com/gif.latex?\fn_phv&amp;space;Vout*4096=(Vref*Dn)" alt="\fn_phv Vout*4096=(Vref*Dn)" align="absmiddle"></p>
<p>and after transposition, we get</p>
<p><img decoding="async" class="aligncenter" src="https://latex.codecogs.com/gif.latex?\fn_phv&amp;space;Dn=\frac{(Vout*4096)}{Vref}" alt="\fn_phv Dn=\frac{(Vout*4096)}{Vref}" align="absmiddle"></p>



<p>We seem to have a problem here.  The datasheet used 4096 for the resolution and not 4095.  As a result, we will surely get a wrong value.  Let&#8217;s say we want an output voltage of 5V.  Using the values Vout=5V and Vref=5V, we get</p>



<p><img decoding="async" class="aligncenter" src="https://latex.codecogs.com/gif.latex?\fn_phv&amp;space;Dn=\frac{5V*4096}{5V}=4096" alt="\fn_phv Dn=\frac{5V*4096}{5V}=4096" align="absmiddle"></p>



<p>But setVoltage() only accepts a value from 0-4095.  Using a value of 4096 will surely fold over to 0.</p>



<h4 class="wp-block-heading">The Dividend Debate</h4>



<blockquote class="wp-block-quote is-style-large is-layout-flow wp-block-quote-is-layout-flow">
<p>In Arduino, several schools of thought exist on how to compute the voltage from the value given by analogRead().  Some say the formula is Vout = (Vref * Dn) / 1024.  Others say it is Vout = (Vref * Dn) / 1023.  And still, there are those who go in-between, Vout = (Vref * (Dn + 0.5)) / 1024.   </p>
<cite>A good treatment of this issue can be found on https://www.gammon.com.au/forum/?id=12779</cite></blockquote>



<p>In order to match the setVoltage() parameter, I will stick with the following formula:</p>



<p><img decoding="async" class="aligncenter" src="https://latex.codecogs.com/gif.latex?\fn_phv&amp;space;Dn=\frac{Vout*4095}{Vref}" alt="\fn_phv Dn=\frac{Vout*4095}{Vref}" align="absmiddle" /></p>



<p>Let&#8217;s test the formula,</p>



<p>Vout = 0V, Vref = 5V, we get Dn = 0<br>Vout = 5V, Vref = 5V, we get Dn = 4095</p>



<p>Now, if we want an output voltage of 1V, we have Dn = (1V * 4095) / 5V = 819.  Therefore, to set the output voltage of the MCP4725 module to 1V, we should use setVoltage(819, false);</p>



<h2 class="wp-block-heading">Issues with Using MCP4725 DAC Module</h2>



<ol class="wp-block-list">
<li>MCP4725 does not have a separate pin for external voltage reference.  MCP4725 uses the applied VCC as its voltage reference.  Hence, it needs a clean and well regulated power supply.  <br></li>



<li>Although an external voltage reference can be used thru the VCC pin, VCC is limited to 2.7V minimum.  As a result, it is not possible to use the standard 1.028V, 2.048V and 2.500V voltage references.<br></li>



<li>Problem with the offset voltage error.  At 0 digital input code where 0 volts is expected, I get a 6.8 millivolts output.  That is, an almost 7mV of offset error.  Also, I have seen a post on a forum site where someone was asking how to remove a 32mV offset error.  The offset error specification for MCP4725 is 0.75% of FSR.  In other words, if you are using a 5-volt VCC, the offset error can be up to 37.5mV( 5V multiplied by .0075).  Although the offset error is easy to calibrate in software by simply subtracting the offset, the lower range up to the offset error voltage becomes unusable.  A hardware solution is possible (summing amplifier) to remove the offset but may need a precision op amp, or additional error may be introduced.</li>
</ol>



<h2 class="wp-block-heading">References on How to Use MCP4725 Module with Arduino</h2>



<p><a href="http://ww1.microchip.com/downloads/en/devicedoc/22039d.pdf" target="_blank" rel="noreferrer noopener">MCP4725 Datasheet</a><br><a href="https://www.gammon.com.au/forum/?id=12779" target="_blank" rel="noreferrer noopener">ADC conversion on the Arduino (analogRead)</a></p>



<h2 class="wp-block-heading">Related Articles on How to Use MCP4725 Module with Arduino</h2>



<p>1 &#8211; <a href="https://cyberblogspot.com/how-to-use-ads1220-adc-module-with-arduino/" target="_blank" rel="noreferrer noopener">How to Use ADS1220 ADC Module with Arduino</a><br>2 &#8211; <a href="https://cyberblogspot.com/how-to-program-esp-01-with-arduino-ide/" target="_blank" rel="noreferrer noopener">How to Program ESP-01 with Arduino IDE</a><br>3 &#8211; <a href="https://cyberblogspot.com/how-to-install-esptool-on-windows-10/" target="_blank" rel="noreferrer noopener">How to Install Esptool on Windows 10</a><br>4 &#8211; <a href="https://cyberblogspot.com/how-to-save-and-restore-esp8266-and-esp32-firmware/" target="_blank" rel="noreferrer noopener">How to Save and Restore ESP8266 and ESP32 Firmware</a><br>5 &#8211; <a href="https://cyberblogspot.com/how-to-test-a-nodemcu-v3-esp8266-dev-board/" target="_blank" rel="noreferrer noopener">How to Test a NodeMCU V3 ESP8266 Dev Board</a><br>6 &#8211; <a href="https://cyberblogspot.com/how-to-test-nodemcu-v3-using-esptool/" target="_blank" rel="noreferrer noopener">How to Test NodeMCU V3 Using Esptool</a><br>7 &#8211; <a href="https://cyberblogspot.com/nodemcu-v3-esp8266-pinout-and-configuration/" target="_blank" rel="noreferrer noopener">NodeMCU V3 ESP8266 Pinout and Configuration</a><br>8 &#8211; <a href="https://cyberblogspot.com/nodemcu-esp-32s-pin-configuration/" target="_blank" rel="noreferrer noopener">NodeMCU ESP-32S Pin Configuration</a><br>9 &#8211; <a href="https://cyberblogspot.com/esp-01-esp8266-ntp-clock-with-lcd-display/" target="_blank" rel="noreferrer noopener">ESP-01 ESP8266 NTP Clock with LCD Display</a><br>10 &#8211; <a href="https://cyberblogspot.com/esp-01-with-rtc-and-lcd-display/" target="_blank" rel="noreferrer noopener">ESP-01 with RTC and LCD Display</a><br>11 &#8211; <a href="https://cyberblogspot.com/how-to-control-esp-01-thru-a-router/" target="_blank" rel="noreferrer noopener">How to Control ESP-01 thru a Router</a><br>12 &#8211; <a href="https://cyberblogspot.com/how-to-control-esp-01-without-a-router/" target="_blank" rel="noreferrer noopener">How to Control ESP-01 Without a Router</a><br><br></p>
<p>The post <a href="https://cyberblogspot.com/how-to-use-mcp4725-module-with-arduino/">How to Use MCP4725 Module with Arduino</a> appeared first on <a href="https://cyberblogspot.com">CyberBlogSpot</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://cyberblogspot.com/how-to-use-mcp4725-module-with-arduino/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
