Stufin
Home Quick Cart Profile

M5StickC Digital to Analog Convertor Hat MCP4725

Buy Now on Stufin

DAC Chip

Microchip MCP4725

Resolution

12-bit

Number of Channels

1

Output Voltage Range

0V to VCC

Operating Voltage

3.3V to 5V

Power Consumption

Typically 1.5mA

Interface

I2C

Communication Speed

Up to 400 kHz

Operating Temperature

-40C to +85C

Dimensions

25mm x 25mm x 10mm (L x W x H)

Applications

The M5StickC Digital to Analog Convertor Hat MCP4725 is suitable for a wide range of applications, including

IoT devices

Robotics and automation

Industrial control systems

Home automation

Audio and video equipment

Medical devices

Aerospace and defense applications

By providing a compact and efficient digital-to-analog conversion solution, the M5StickC Digital to Analog Convertor Hat MCP4725 enables developers to create innovative and complex projects with ease.

Pin Configuration

  • M5StickC Digital to Analog Convertor Hat MCP4725 Pinout Explanation
  • The M5StickC Digital to Analog Convertor Hat MCP4725 is a compact module designed to provide a digital-to-analog conversion function for IoT projects. It is based on the MCP4725 DAC chip, which is a 12-bit, single-channel, voltage-output digital-to-analog converter. Here is a detailed explanation of the pins on the module:
  • Pinout Explanation:
  • 1. VCC (Power Supply)
  • Pin type: Power input
  • Voltage range: 3.3V to 5V
  • Description: This pin is used to power the module. Connect it to a suitable power source, such as the 3.3V or 5V output of your M5StickC or other microcontroller board.
  • 2. GND (Ground)
  • Pin type: Ground
  • Description: This pin is the ground connection for the module. Connect it to the ground pin of your M5StickC or other microcontroller board.
  • 3. SCL (Clock)
  • Pin type: I2C clock
  • Description: This pin is used for the I2C clock signal. Connect it to the SCL pin of your M5StickC or other microcontroller board.
  • 4. SDA (Data)
  • Pin type: I2C data
  • Description: This pin is used for the I2C data signal. Connect it to the SDA pin of your M5StickC or other microcontroller board.
  • 5. VOUT (Analog Output)
  • Pin type: Analog output
  • Voltage range: 0V to VCC
  • Description: This pin provides the analog output voltage, which is proportional to the digital input value. You can connect this pin to an external circuit, such as an amplifier or a sensor, that requires an analog input.
  • 6. ADDR (Address)
  • Pin type: Address selection
  • Description: This pin is used to set the I2C address of the MCP4725 chip. You can connect this pin to VCC, GND, or leave it floating to select one of the three available I2C addresses (0x60, 0x61, or 0x62).
  • How to Connect the Pins:
  • 1. Connect the VCC pin to a suitable power source (3.3V or 5V) on your M5StickC or other microcontroller board.
  • 2. Connect the GND pin to the ground pin of your M5StickC or other microcontroller board.
  • 3. Connect the SCL pin to the SCL pin of your M5StickC or other microcontroller board.
  • 4. Connect the SDA pin to the SDA pin of your M5StickC or other microcontroller board.
  • 5. Connect the VOUT pin to an external circuit that requires an analog input.
  • 6. Connect the ADDR pin to VCC, GND, or leave it floating to select the desired I2C address.
  • Important Note:
  • Make sure to use the correct voltage levels for the VCC and VOUT pins to avoid damaging the module or other connected components.
  • When using the I2C interface, ensure that the SCL and SDA pins are connected correctly and that the I2C address is set correctly using the ADDR pin.
  • By following these connections and guidelines, you can successfully integrate the M5StickC Digital to Analog Convertor Hat MCP4725 into your IoT project and take advantage of its digital-to-analog conversion capabilities.

Code Examples

M5StickC Digital to Analog Convertor Hat MCP4725 Documentation
The M5StickC Digital to Analog Convertor Hat MCP4725 is a small, compact module that allows users to convert digital signals from their microcontrollers to analog signals, making it compatible with devices that only accept analog inputs. This module is based on the MCP4725 12-bit Digital-to-Analog Converter (DAC) chip.
Technical Specifications
Resolution: 12-bit
 Output Voltage Range: 0 V to VCC ( Typically 3.3 V or 5 V)
 I2C Interface
 Operating Voltage: 3.3 V to 5 V
 Communication Protocol: I2C
Programming Interface
The M5StickC Digital to Analog Convertor Hat MCP4725 uses the I2C protocol to communicate with the microcontroller. The module has a default I2C address of 0x60, but this can be changed by connecting the ADDR pin to VCC, GND, or leaving it open.
Code Examples
Example 1: Basic Analog Output using Arduino
In this example, we'll demonstrate how to use the M5StickC Digital to Analog Convertor Hat MCP4725 to generate an analog output voltage using an Arduino board.
```c++
#include <Wire.h>
#define DAC_I2C_ADDRESS 0x60
void setup() {
  Wire.begin(); // Initialize I2C
}
void loop() {
  // Set the output voltage to 1.5V (approximately)
  uint16_t outputValue = 2048; // 12-bit value, 0 to 4095
  Wire.beginTransmission(DAC_I2C_ADDRESS);
  Wire.write(0x40); // Write to register 0x40 to set output voltage
  Wire.write(highByte(outputValue));
  Wire.write(lowByte(outputValue));
  Wire.endTransmission();
delay(1000);
}
```
Example 2: Generating a Sine Wave using MicroPython
In this example, we'll demonstrate how to use the M5StickC Digital to Analog Convertor Hat MCP4725 to generate a sine wave using a MicroPython-enabled board, such as the M5StickC.
```python
import machine
import math
dac_i2c = machine.I2C(sda=machine.Pin(21), scl=machine.Pin(22))  # Initialize I2C
while True:
    for i in range(0, 360):
        # Calculate the sine value (0 to 1) and scale it to 12-bit DAC value (0 to 4095)
        output_value = int((math.sin(math.radians(i)) + 1)  2048)
        dac_i2c.writeto(0x60, bytearray([0x40, output_value >> 8, output_value & 0xFF]))
        machine.sleep(0.01)  # 10ms delay
```
Example 3: Controlling a Servo Motor using ESP32
In this example, we'll demonstrate how to use the M5StickC Digital to Analog Convertor Hat MCP4725 to control a servo motor using an ESP32 board.
```c++
#include <WiFi.h>
#include < Wire.h>
#define DAC_I2C_ADDRESS 0x60
#define SERVO_PIN 18  // Servo motor connected to GPIO 18
WiFiClient espClient;
Servo servo;
void setup() {
  Serial.begin(115200);
  Wire.begin(); // Initialize I2C
  servo.attach(SERVO_PIN);
}
void loop() {
  // Set the servo motor to 0 degrees (approximately)
  uint16_t outputValue = 128; // 12-bit value, 0 to 4095, corresponding to 0 degrees
  Wire.beginTransmission(DAC_I2C_ADDRESS);
  Wire.write(0x40); // Write to register 0x40 to set output voltage
  Wire.write(highByte(outputValue));
  Wire.write(lowByte(outputValue));
  Wire.endTransmission();
  servo.write(0);
delay(1000);
// Set the servo motor to 90 degrees (approximately)
  outputValue = 256; // 12-bit value, 0 to 4095, corresponding to 90 degrees
  Wire.beginTransmission(DAC_I2C_ADDRESS);
  Wire.write(0x40); // Write to register 0x40 to set output voltage
  Wire.write(highByte(outputValue));
  Wire.write(lowByte(outputValue));
  Wire.endTransmission();
  servo.write(90);
delay(1000);
}
```
These examples demonstrate how to use the M5StickC Digital to Analog Convertor Hat MCP4725 to generate analog output voltages, creating a sine wave, and controlling a servo motor. The module's I2C interface makes it easy to integrate with popular microcontrollers and single-board computers.