Hello everyone,
I am currently attempting to use the ADS1114 with the Adafruit AD1X15 library. I based my overall design using the basic example from TI and have the following
2x10k pullup resistors to SDA and SCL respectively
A1 to ground
A0 as the input
So after reading this other post I found that I should only get positive values since A1 is grounded. However not only am I getting negative values, but the inputs are also incorrect after converting the voltage and plotting them. I receive the correct values from a DC input however whenever I attempt to view a sine or square wave the values are incorrect. I am using a function generator to view the values and the oscilloscope is showing the correct values. Here is my code:
#include <SoftwareSerial.h>
#include <Wire.h>
#include <Adafruit_ADS1015.h>
#define LED RED_LED
float voltage;
Adafruit_ADS1115 ads;
void setup()
{
Serial.begin(9600);
delay(100);
Serial.println("Hello world");
Serial.println("Getting single-ended readings from AIN0..3");
Serial.println("ADC Range: +/- 6.144V (1 bit = 3mV/ADS1015, 0.1875mV/ADS1115)");
// set the data rate for the SoftwareSerial port
//mySerial.begin(9600);
ads.setGain(GAIN_TWOTHIRDS);
pinMode(LED, OUTPUT);
digitalWrite(LED, HIGH); // turn the LED on (HIGH is the voltage level)
ads.begin();
//ads.startComparator_SingleEnded(0, 1000);
}
void loop() // run over and over
{
int16_t adc0;
//adc0 = ads.getLastConversionResults();
adc0 = ads.readADC_SingleEnded(0);
Serial.print("AIN0: "); Serial.println(adc0);
Serial.println(" ");
voltage = (adc0 * 0.1875)/1000;
Serial.print("\tVoltage: ");
Serial.println(voltage, 7);
Serial.println(" ");
delay(1000);
}
[!code]
I have attached my output values also in case anyone else is getting similar values with my input being a 500mv Vpp at 100hz.
Thanks
capture.txt (9.42 KB)