i2c ADS1X15 false output?

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)

ADS1114 arduino code

You can try this code from the above link and note that it works for single power supply that too in the range of 2.2 to 5 Volts. Make sure that input is in that very range for ADS1114. You can also refer to datasheet for the pins and connections , CHANNELS A1N1 and A1N0 to be positive and negative respectively, from which the output needs to be measured. The above parameters are for DC signal and probably this sensor does not work for the AC signal.

batman_d408:
ADS1114/ADS1114.ino at master · ControlEverythingCommunity/ADS1114 · GitHub

You can try this code from the above link and note that it works for single power supply that too in the range of 2.2 to 5 Volts. Make sure that input is in that very range for ADS1114. You can also refer to datasheet for the pins and connections , CHANNELS A1N1 and A1N0 to be positive and negative respectively, from which the output needs to be measured. The above parameters are for DC signal and probably this sensor does not work for the AC signal.

Awesome thanks I'll try this out later. If I give it an AC signal between that range of Vpp 2.2 to 5.5 would I get a proper reading or would that also not work?? My overall goal from this device would just be to see a sine wave inputted.

if your input voltage range is within the ADS1114 input then you can see the sine wave.
are you using any divider circuit with your AC signal.

Thank you so much for that code. I'm going to review the ADS1X15 library and see if I can find the difference between the two. Also if I wanted to set the SPS250 I would simply send

  Wire.write(0x85)
  // Continuous conversion mode, 250 SPS

instead of

  Wire.write(0xA3);
  // Continuous conversion mode, 128 SPS

would that be correct since according to the data table bit 5-7 are the config for sampling rate and the setting for 250sps is 101 instead of the 100 for the 128 default. This seems to work correctly.

What is the conversion back to voltage? Is it still the output value * .0000625? I tried this, but the voltages don't seem to full represent the inputs.

My function generator inputs are:

100hz
1Vpp
1V offset

It would be Wire.write(0xA3) instead of (0x83) for continuous conversion mode, 250 SPS, when you use 101 instead for 100 for 128 default.

So, initially according to default values data for default register was 8583h and now it would be 85A3h. Now, you can check if it works properly for that.

Why are you doing output value * .0000625.

Gotcha thanks.

I did output*.0000625 in order to get the voltage is that not correct? I went off of the data sheet that said output code for each bit = +FS/2^15 where the gain is 2.048 which gave me the .0000625. Is that not the correct conversion?

My vdd is 3.3V.

Yes, you are doing that right! Output * .0000625 will give the correct voltage output.

Awesome thanks. I’m still having an issue reading. I’m trying to read ground and I currently have 3 separate ads1114 for testing.

I currently have AIN0 and A1IN to ground however I’m reading 3 separate values upon the outputs. My Vin is 3.3V.

My outputs are listed as follows, all have the same inputs and setups

65519/4.0V (1) This is max value for some reason
0.00/0V (2) This is the correct one im assuming
12613636/788V (3) I have no idea why this is happening.

Here is the code I currently have running to test.

#include <Wire.h>

// ADS1114 I2C address is 0x48(72)
#define Addr 0x48
#define LED RED_LED
uint16_t temp;
byte outputData[4];
void setup() 
{
  pinMode(LED, OUTPUT);  
  // Initialise I2C communication as MASTER
  Wire.begin();
  // Initialise Serial Communication, set baud rate = 9600
  Serial.begin(9600);
  Serial.println("Starting ADC analysis");
  // Start I2C Transmission
  Wire.beginTransmission(Addr);
  // Select configuration register
  Wire.write(0x01);
  // AINP = AIN0 and AINN = AIN1, +/- 2.048V
  Wire.write(0x84);
    // Continuous conversion mode, 250 SPS
  Wire.write(0xC3);
  // Stop I2C Transmission
  Serial.println("Locking on end transmission");
  Wire.endTransmission();
  Serial.println("Starting ADC analysis");
  delay(300);
}

void loop() 
{
  unsigned int data[2];

  // Start I2C Transmission
  Wire.beginTransmission(Addr);
  // Select data register
  Wire.write(0x00);
  // Stop I2C Transmission
  Wire.endTransmission();

  // Request 2 bytes of data
  Wire.requestFrom(Addr, 2);

  // Read 2 bytes of data
  // raw_adc msb, raw_adc lsb
  if(Wire.available() == 2)
  {
     data[0] = Wire.read();
     data[1] = Wire.read();
  }

  // Convert the data
  float raw_adc = (data[0] * 256.0) + data[1];
//  raw_adc=raw_adc/16;
  // Output data to serial monitor
  float voltage = raw_adc * 0.0000625;

  Serial.print("Digital value of analog input : ");
  Serial.println(raw_adc);
  Serial.print("Digital value of voltage input : ");
  Serial.println(voltage);
  digitalWrite(LED, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(50);
  digitalWrite(LED, LOW);    
}