Hello everyone,
I am currently working a MCP4725 tutorial project.
Link of the tutorial:
https://electronoobs.com/eng_arduino_tut173.php
The goal is to output analog voltage values through the MCP4725 and read it through one of the analog ports of the same arduino board.
I read threads about this topic, being stuck with 1023 readings.
Here's what I've tried so far to solve this issue.
I read about bad connections, so I poured more solder on some spots of the module which seemed to not have a very good connection.
I changed the spot the module was placed on the breadboard.
Changed the resolution from 9 to 12 in the code, did not work.
Tried uploading a different code with different analog signal.
Tried swapping the I2C connection spots on the arduino board.
I read the values with the multimeter and it's working perfectly with regards to the analog voltage. But for some reason the serial monitor keeps throwing 1023.
This is the code I used:
#include <Wire.h>
#include <Adafruit_MCP4725.h>
Adafruit_MCP4725 dac;
// Set this value to 9, 8, 7, 6 or 5 to adjust the resolution
#define DAC_RESOLUTION (9)
const int pinoAnalogo = A1;
void setup(void) {
Serial.begin(9600);
// MCP4725A1 address is 0x62 (default)
// MCP4725A1 address is 0x63 (ADDR pin tied to VCC)
// MCP4725A1 address is 0x60 (ADDR pin tied to GND)
dac.begin(0x60); //I have my ADDR pin connected to GND so address is 0x60
}
void loop(void) {
int valorAnalogico = analogRead(pinoAnalogo);
dac.setVoltage((1*4095)/5, false); //Set voltage to 1V
Serial.println(valorAnalogico);
delay(2000);
dac.setVoltage((2*4095)/5, false); //Set voltage to 2V
Serial.println(valorAnalogico);
delay(2000);
dac.setVoltage((3*4095)/5, false); //Set voltage to 3V
Serial.println(valorAnalogico);
delay(2000);
dac.setVoltage((4*4095)/5, false); //Set voltage to 4V
Serial.println(valorAnalogico);
delay(2000);
dac.setVoltage(4095, false); //Set voltage to 5V or (Vcc)
Serial.println(valorAnalogico);
delay(2000);
}
Thank you if you've read this far.