ADS1115 sends the same values in each of its inputs

Hello, I am using an ads1115 of the adafruit brand, I have it connected to pins a0 and a1 of my photon using sda / scl, connect it to 3.3v and ground, the addr is default on the gnd pin, I have connected to the inputs of the ads an ozone sensor spec where a0-vgas, a1-vref, a2-vtemp, but when it gives me the data it always gives me the same data in each of the inputs, I was investigating and according to this modifying the ADS1115_CONVERSIONDELAY to 9 it could work but Still not doing it for this I am using the Adafruit_ADS1x15 library, does anyone know why this happens or could you give me ideas for modifications? Thanks in advance
I add the code that I am using

#include "Adafruit_ADS1115"
#include <Wire.h>
float TotVgas = 0;
float TotVref = 0;
float TotVtemp = 0;
int NumOfSamples = 0;
Adafruit_ADS1115 ads;
void setup() {
Serial.begin(9600);
  Wire.begin();
  //iniciar el adc
ads.begin();
ads.setGain(GAIN_SIXTEEN);
}

void loop() {
float Vgas = ads.readADC_SingleEnded(0);
float Vref = ads.readADC_SingleEnded(1);
float Vtemp = ads.readADC_SingleEnded(2);
    TotVgas += Vgas;
    TotVref += Vref;
    TotVtemp += Vtemp;
    NumOfSamples ++;
    // print out the value you read:
    Serial.println("Average Vgas: " + String(TotVgas / NumOfSamples));
    delay(100);
    Serial.println("Average Vref: " + String(TotVref / NumOfSamples));
     delay(100);
    Serial.println("Average Vtemp: " + String(TotVtemp / NumOfSamples));
     delay(100);
    Serial.println("Number of Samples: " + String(NumOfSamples));
    delay(100);        // delay in between reads for stability
}

That doesn't sound right.
The I2C interface is tied to D0/1 not A0/1

There would be a source that would tell that fact - it's there to be read not for decoration :wink:
https://docs.particle.io/reference/device-os/firmware/photon/#pins-i2c-

1 Like

Thanks :slight_smile: I had already connected it to pins d0 and d1 but the same thing happens, it keeps sending me the same value :frowning:

If you get the same value irrespective whether you use the right or the wrong pins chances are that you are not getting any values at all :wink:

Maybe it’s time to track back and first find out whether your can talk to the board at all.
Usually that’s best done via an I2C scanner sketch like this

1 Like

when I run that code it sends me this to the serial and my particle stays with the cyan led without blinking as if it were a bug

What ADS1115 board are you using?
Does it feature pull-up resistors?
What device OS version are you targeting?

But the command would be particle serial monitor --follow rather than particle monitor serial :wink:

You are trying to monitor the cloud variables a device called serial would expose, but I suppose you don’t have a so called device and hence the No matching device is telling the truth, I’d guess.

ADS1115 16-Bit ADC - 4 Channel with Programmable Gain Amplifier, these modules use the I2C interface and include the power conditioning and pull-up/pull-down resistors needed to basically make it plug-and-play to get up and running doing basic A-D conversions very easily, and the version is 2.0.0,
and can’t find the device

553a5e52d8655ae3d1425633ed3d24df

Have you got a hi-res photo of your setup?

Can’t see anything wrong with that.
You could try adding another set of 10k pull-up resistors in parallel or supply from Vin (5V) to see whether the I2C scanner can then see the board.

It could also be that either one of your I2C pins on the Photon is damaged or the ADS board is dead - it could even be that the breadboard has no good contact.
To test that I’d pull out a logic analyzer or oscilloscope to see whether there is any communication going on between the two at all.

If you had another Photon and/or ADS115 board (or other I2C device) swapping them out may also provide some more insight.

1 Like

Aside from a problem with the I2C on either the ADS1115 module or the Photon - the I2C scanner should return address 0x48 - once you have that working then the rest should follow.

A couple of observations on the code that you posted at the top of this topic:

  1. #include <Wire.h> is not required because this is included by default.
  2. In setup() Wire.begin(); isn’t required before ads.begin(); because that’s all that ads.begin() does.
  3. To read a single channel you use Vtemp = ads.readADC_SingleEnded(2); as you have done but the function does not return a float but rather an unsigned 16 bit number. This then needs to be scaled - it is reading an analog voltage and converting into a binary number (1 bit = 0.0078125mV with the gain you have set).

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