I'm using an "ADS1115" from aliexpress with a "Pro Micro" from aliexpress to measure the same signal at the same time. Pro Micro input is A0 ADS1115 is AIN1.
SPS = 860
Single input (Non diferential).
20k potentiometer from VDD (Regulated pro micro output) to GND.
I have also multiplied ProMicro output by 35 for comparisson purposses (5bit resolution difference = 32 so it's reasonable).
Code is simple enouth.
The problem is that "ADS1115" module output has "spikes" always in same outputs values.
All ADS inputs have same behavior, different gain settings gives same result, lower SPS reduces behavior... but it is an 860SPS capable chip...
So. Do all ADS1115 behave the same or it's a defective unit or it is a bad chinesse copy? PCB looks good, same distributon, same components, as adafruit one.
IC has "83 BOGI" naming.
#include<ADS1115_WE.h>
#include<Wire.h>
#define I2C_ADDRESS 0x48
int sensorPin = A0; // select the input pin for the potentiometer
int16_t sensorValue = 0; // variable to store the value coming from the sensor
ADS1115_WE adc(I2C_ADDRESS);
void setup() {
Wire.begin();
Serial.begin(9600);
if(!adc.init()){
Serial.println("ADS1115 not connected!");
}
adc.setVoltageRange_mV(ADS1115_RANGE_4096); //comment line/change parameter to change range
adc.setCompareChannels(ADS1115_COMP_1_GND); //comment line/change parameter to change channel
adc.setConvRate(ADS1115_860_SPS); //uncomment if you want to change the default
}
void loop() {
float voltage = 0.0;
int16_t canal1=0;
adc.startSingleMeasurement();
while(adc.isBusy()){}
canal1=adc.getRawResult();
sensorValue = analogRead(sensorPin);
//voltage = adc.getResult_V(); // alternative: getResult_mV for Millivolt
//Serial.print("Channel 1 vs GND [V]: ");
Serial.print(canal1);Serial.print(",");Serial.println(35.33*sensorValue);
//Serial.println("-------------------------------");
delay(10);
}
So when the input goes above GND, shouldn't the output jump from one state to the other(LOW to HIGH) like a spike? Have you monitored the state of the ALERT pin when the spike occurs?
mmm...
Pot is between VDD and GND.
ADS1115 is measuring pot. cursor against GND - Blue graph
Arduino is measuring pot. cursor against GND - Red graph
Same VDD and GND for both, Arduino is reading the ADS I2C data.
There is no signal lower than GND or higher than VDD.
Both are the same signal. I've represented both together to actually see their behavior.
Spikes are present at diferent thresholds (always the same thresholds), for example in the picture it is around 20000 (raw ADS1115 ADC output).
I just discarded my crappy ADS1115 for my project.
Have you tried this example with the Adafruit library? You can install the library from the IDE library manager.
#include <Wire.h>
#include <Adafruit_ADS1015.h>
Adafruit_ADS1115 ads; /* Use this for the 16-bit version */
//Adafruit_ADS1015 ads; /* Use thi for the 12-bit version */
void setup(void)
{
Serial.begin(9600);
Serial.println("Hello!");
Serial.println("Getting single-ended readings from AIN0..3");
Serial.println("ADC Range: +/- 6.144V (1 bit = 3mV/ADS1015, 0.1875mV/ADS1115)");
// The ADC input range (or gain) can be changed via the following
// functions, but be careful never to exceed VDD +0.3V max, or to
// exceed the upper and lower limits if you adjust the input range!
// Setting these values incorrectly may destroy your ADC!
// ADS1015 ADS1115
// ------- -------
ads.setGain(GAIN_TWOTHIRDS); // 2/3x gain +/- 6.144V 1 bit = 3mV 0.1875mV (default)
// ads.setGain(GAIN_ONE); // 1x gain +/- 4.096V 1 bit = 2mV 0.125mV
// ads.setGain(GAIN_TWO); // 2x gain +/- 2.048V 1 bit = 1mV 0.0625mV
// ads.setGain(GAIN_FOUR); // 4x gain +/- 1.024V 1 bit = 0.5mV 0.03125mV
// ads.setGain(GAIN_EIGHT); // 8x gain +/- 0.512V 1 bit = 0.25mV 0.015625mV
// ads.setGain(GAIN_SIXTEEN); // 16x gain +/- 0.256V 1 bit = 0.125mV 0.0078125mV
ads.begin();
}
void loop(void)
{
int16_t adc0, adc1, adc2, adc3;
adc0 = ads.readADC_SingleEnded(0);
adc1 = ads.readADC_SingleEnded(1);
adc2 = ads.readADC_SingleEnded(2);
adc3 = ads.readADC_SingleEnded(3);
Serial.print("AIN0: "); Serial.println(adc0);
Serial.print("AIN1: "); Serial.println(adc1);
Serial.print("AIN2: "); Serial.println(adc2);
Serial.print("AIN3: "); Serial.println(adc3);
Serial.println(" ");
delay(1000);
}