Reading Bug on ADS1115/ UNO

I'm using 3 ADS1115 to read 10 LDR sensor on an UNO, but i'm having a problem. I currently tried using 2 module first to test my code. I've followed the wiring correctly, the ADDR pin each connected to GND & VDD.



*the 3rd ADS1115 module is on shipping as the writting of this post.

The first photo is the wiring, what gets weird is photo 2&3. The UNO only reads the first module but knows there's a second module. When pin A3 from 1st Modul ewas put to GND, the serial monitor shows ADC3 & ADC7 the same value even thoughs ADC7 was from pin A3 of 2nd module .

Below is my code.

#include <Wire.h>
#include <Adafruit_ADS1X15.h>

Adafruit_ADS1115 ads1;
Adafruit_ADS1115 ads2;
//LiquidCrystal_I2C lcd(0x27, 20, 4);

void setup()
{

ads1.begin(0x48);
ads2.begin(0x49);

Serial.begin(9600);
if (!ads1.begin()){
  Serial.println("Failde to initialize ADS1");
  //lcd.print("Failde to initialize ADS1");
  while(1);
}
if (!ads2.begin()){
  Serial.println("Failde to initialize ADS2");
  //lcd.print("Failde to initialize ADS2");
  while(1);
}

}

void loop()
{
  int16_t adc1_0, adc1_1, adc1_2, adc1_3;
  int16_t adc2_0, adc2_1, adc2_2, adc2_3;
  int a = 20000;
  adc1_0 = ads1.readADC_SingleEnded(0);
  adc1_1 = ads1.readADC_SingleEnded(1);
  adc1_2 = ads1.readADC_SingleEnded(2);
  adc1_3 = ads1.readADC_SingleEnded(3);

  adc2_0 = ads2.readADC_SingleEnded(0);
  adc2_1 = ads2.readADC_SingleEnded(1);
  adc2_2 = ads2.readADC_SingleEnded(2);
  adc2_3 = ads2.readADC_SingleEnded(3);


  Serial.println("-----------------------------------------------------------");
  Serial.print("ADC0:  "); Serial.println(adc1_0);
  Serial.print("ADC1:  "); Serial.println(adc1_1);
  Serial.print("ADC2:  "); Serial.println(adc1_2);
  Serial.print("ADC3:  "); Serial.println(adc1_3);
  Serial.print("ADC4:  "); Serial.println(adc2_0);
  Serial.print("ADC5:  "); Serial.println(adc2_1);
  Serial.print("ADC6:  "); Serial.println(adc2_2);
  Serial.print("ADC7:  "); Serial.println(adc2_3);

  if(adc1_0 > a && adc1_1 > a && adc1_2 > a && adc1_3 > a && adc2_0 > a){
    Serial.print("Hal 8");
  }
  else if(adc1_0 > a && adc1_1 > a && adc1_2 > a && adc1_3 > a && adc2_0 < a){
    Serial.print("Hal 7");
  }
  else if(adc1_0 > a && adc1_1 > a && adc1_2 > a && adc1_3 < a && adc2_0 < a){
    Serial.print("Hal 6");
  }

  delay(1000);
}

I've read a topic about the same problem from different forum, they said that it was the ADS1115 module since there are a lots of fake stuff, so idk if this is my code problem or the modules problem.

Did you try the I2C pins SDA and SCL on the other side of the Uno (by the usb connector) rather than A4 and A5?

same thing. Still read from the first module.

Why are you running begin() calls twice?
I show the begin functions are type void.
Remove the begin code after the Serial.begin().

Edit: My bad. The Adafruit begin() does return boolean.
However, you must pass the address to ads2.

if (!ads2.begin(0x49)){
  Serial.println("Failde to initialize ADS2");
  //lcd.print("Failde to initialize ADS2");
  while(1);
}
1 Like

.... and remove the first calls of the ads1 & adc2

What does that mean?
image
This is unclear; can you please show how the address pins on both ADC's are actually connected?

There are ADC pins on your picture, it has nothing to do with a I2c address selection.
The ADS1115 module has only one ADDR pin

@rsml: It is clear to me. Those are the analog inputs to the ADC.
The ADDR is LOW by default. Pulling it HIGH (Vdd) increments the address. 0x49 rather than 0x48.

@ridwananhar
Is this related to your other topic on the same subject?

Sorry, I wasn't paying attention; my bad. I was thinking about another thread/issue involving a chip with 4 address pins. Apologies.

Looks like its indeed solved my coding problem.

void setup()
{

//ads1.begin(0x48);
//ads2.begin(0x49);

Serial.begin(9600);
if (!ads1.begin()){
  Serial.println("Failde to initialize ADS1");
  //lcd.print("Failde to initialize ADS1");
  while(1);
}
if (!ads2.begin(0x49)){
  Serial.println("Failde to initialize ADS2");
  //lcd.print("Failde to initialize ADS2");
  while(1);
}

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.