Because of the Thanksgiving holiday in the U.S., TI E2E™ design support forum responses may be delayed from November 25 through December 2. Thank you for your patience.

This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

ADS1115: Unable to get a simple SingleEnd data from ADS1115.

Part Number: ADS1115
Other Parts Discussed in Thread: ADS1015

Hello,

I have two ADS1115 and attempting to use with Arduino UNO board.
I'm following instructions presented on https://learn.adafruit.com/adafruit-4-channel-adc-breakouts.
Arduino Library from Adafruit is used and can be download on https://github.com/adafruit/Adafruit_ADS1X15


I'm tryed to read voltage from Arduini +3.3V but all I get from the code is "-1" as value.

AIN0: -1
 
AIN0: -1
 
AIN0: -1
 
AIN0: -1
 
AIN0: -1

I've searched on several sources and what I could see is that if I get a "-1" value is probably an i2c problem.
What is wrong?
I've testes with 2 different ADS1115 and both gives me the same result.

The .ino code is presented as follows.
Files .ccp and .h from my library is attached to this post.

#include <Wire.h>
#include <Adafruit_ADS1015.h>
 
Adafruit_ADS1115 ads(0x48);
 
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)");
  ads.begin();
}
 
void loop(void)
{
  int16_t adc0;
 
  adc0 = ads.readADC_SingleEnded(0);
  Serial.print("AIN0: "); Serial.println(adc0);
  Serial.println(" ");
  
  delay(1000);
}

Adafruit_ADS1015.cppAdafruit_ADS1015.h

  • Eduardo,


    I'm not sure if you have this already, but Adafruit has a step-by-step guide to connectiong the ADS1115 to an Arduino:

    cdn-learn.adafruit.com/.../adafruit-4-channel-adc-breakouts.pdf

    To debug this problem, I'd start with a few things:

    1. Make sure that power is going to the device.
    2. Verify that the ADDR is connected to ground.
    3. Check the I2C command going to the device with an oscilloscope or logic analyzer.

    At this point, a read of -1 from the device translates to FFFFh. The SDA never goes low. This makes me think that the device isn't pulling the I2C pin down because it's just not getting the command. You'll need the oscilloscope just to make sure the ADS1115 has ACK'ed the Arduino's command. Another test you can run is just to read the configuration register back from the ADS1115.

    There may be other communication issues depending on how you program and read the device, but it should all be cleared up if you can see the SDA and SCL on a scope.


    Joseph Wu
  • Yes, I've already seen that. It's the guide I've cited on the post, but in a web version.

    1. The device is being powered by +5V from arduino and i confirmed with multimeter directly on the device pins.

    2. It is connected to ground.

    3. I do not have tools for that, I need to provide one for me.

    So, i tryed to send a simple code to the configuration register and read it back to see what happnes.

    The code i used is presented above.
    Accordingly to datasheet I have to send the code to access the configuration register (00000001 - 0x01) followed by the configuration I want (1100111010000011 - 0xCE83). Then to read I send the code to access the configuration register and close, request 1 byte, get it and print. (https://www.arduino.cc/en/Reference/WireRead)

    #include <Wire.h>
    
    void setup()
    {
      Serial.begin(9600);
      Wire.begin();
    }
    
    void loop()
    {
      Serial.println("Start writing");
      Wire.beginTransmission(0x48);
      Wire.write(1);
      Wire.write(0xCE83);
      Wire.endTransmission();
      Serial.println("End writing");
    
      Serial.println("Start reading");
      Wire.beginTransmission(0x48);
      Wire.write(1);
      Wire.endTransmission();
      Wire.requestFrom(0x48, 1);
      byte valor;
      if (Wire.available()){
        valor=Wire.read();
      }
      Wire.endTransmission();
      Serial.println("End reading");
      Serial.println(valor);
      
      delay(1000);
    }

    The result I get is 0

    Start writing
    End writing
    Start reading
    End reading
    0
    Start writing
    End writing
    Start reading
    End reading
    0
    Start writing
    End writing
    Start reading
    End reading
    0
    

  • Eduardo,


    Let me first say that I don't do much coding, so I may not be able to help much in debugging Arduino code. However, can you try this instead:

    Wire.beginTransmission(0x48);
     
    Wire.write(0x01);
     
    Wire.write(0xCE);
    Wire.write(0x83);
    Wire.endTransmission();

    I think Arduino code breaks the transmission up into byte transactions, so split up the write into bytes.

    Reading back from the device, just remember the configuration register is two bytes. You'll want to read back 2 bytes, not 1.

    However, if you continue to get back 0, I think you'll still need to get some sort of oscilloscope or logic analyzer. At this point, there's no way to know if the signals are coming out of the Arduino to talk to the ADS1115.


    Joseph Wu