I use the sketch "ReadSingleValue.ino", which is contained in the "ADS1115-Driver" library. Unfortunately, I only get fixed values when I read out the ADC channels. The ADC is supplied with 3.3V and a potentiometer is connected to both AD0 and AD1. Does anyone have an idea where the error could be?
#include "Arduino.h"
#include "ADS1115-Driver.h"
ADS1115 ads1115 = ADS1115(ADS1115_I2C_ADDR_GND);
uint16_t readValue(uint8_t input) {
ads1115.setMultiplexer(input);
ads1115.startSingleConvertion();
delayMicroseconds(25); // The ADS1115 needs to wake up from sleep mode and usually it takes 25 uS to do that
while (ads1115.getOperationalStatus() == 0);
return ads1115.readConvertedValue();
}
void setup() {
Serial.begin(9600);
ads1115.reset();
ads1115.setDeviceMode(ADS1115_MODE_SINGLE);
ads1115.setDataRate(ADS1115_DR_250_SPS);
ads1115.setPga(ADS1115_PGA_4_096);
}
void loop() {
uint16_t value0 = readValue(ADS1115_MUX_AIN0_GND);
uint16_t value1 = readValue(ADS1115_MUX_AIN1_GND);
uint16_t value2 = readValue(ADS1115_MUX_AIN2_GND);
uint16_t value3 = readValue(ADS1115_MUX_AIN3_GND);
//Serial.println("Values: ");
Serial.println("");
Serial.print("IN 0: ");
Serial.print(value0);
Serial.print(" IN 1: ");
Serial.print(value1);
Serial.print(" IN 2: ");
Serial.print(value2);
Serial.print(" IN 3: ");
Serial.print(value3);
Serial.print("");
delay(1000);
}
Let's have a look at a schematic and a photo of your setup showing how everything is connected.
I also assume you mean two separate pot meters for AD0 and AD1, correct?
Note that the value you're reading is effectively the full scale range of a nominal 14 bit measurement resolution (13 bit on either side of zero, so positive and negative), which suggests you're "maxing out" the channels you're reading. This suggests a connection error, hence the question about the schematic & photo.
Thank you guys, it works now.
The supply voltage was wrong connectet. I don't know why I overlooked that. The pull-up resistors are connected to Vcc, that´s ok.