ADS 1115 (16bit I2C ADC) gives output on wrong channel

Hello folks,

I have a Problem with the ADS1115 I2C 16bit ADC from Adafruit (Overview | Adafruit 4-Channel ADC Breakouts | Adafruit Learning System) which gives me the output on the wrong channel.

My wiring:
VDD to 3.3 V
GND to GND
SCL to SCL
SDA to SDA
ADDR to GND (resulting in an I2C address of 0x48)
A0 to GND
A1 to GND
A2 to GND
A3 to 3.3 V

I’m not doing differential measuring the connecting of the A-pins to GND and 3.3V is just for testing purpose. Different voltages from any power source result in the same error.

When I connect A3 to a voltage I get a reading for A0. When I connect A0 to a voltage I get a reading for A1. When I connect A1 I get a reading for A2 and so on.

I tried a different ADS1115 which resulted in the same error.

Do you see any flaws in my code? I basically just copied the code from Adafruit (Arduino Code | Adafruit 4-Channel ADC Breakouts | Adafruit Learning System)

I appreciate any help!
Many thanks in advance.

#include "Wire.h"
#include "Adafruit_ADS1015.h"      //library for ADS1015 and ADS1115

Adafruit_ADS1115 ads1115(0x48);

void setup() 
{
  while (!Serial);
  delay(1000);
  Wire.begin();
  Serial.begin(115200);
  
  ads1115.begin();  // Initialize ads1115
  }

void loop() {

   int16_t adc0, adc1, adc2, adc3;
 
  adc0 = ads1115.readADC_SingleEnded(0);
  adc1 = ads1115.readADC_SingleEnded(1);
  adc2 = ads1115.readADC_SingleEnded(2);
  adc3 = ads1115.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.print("\n \n ");
  
  delay(1000);
}

Maybe your breakout board is connected wrongly / has the wrong markings at the connections? Cheap Chinese board maybe?

Thanks for the reply!

It's a original Adafruit breaktout board so the connection should be good. Changing the board (I have 5 of them) creates the same problem.

I just tried the same wiring with my Arduino Nano instead of my STM32 blue pill.

Now the outputs are correct.

That’s really strange because the sensor library is the same and the protocol is I2C therefore it can’t be a wiring error on the STM32 board.

Wrong speed on the I2C interface?

MarkT:
Wrong speed on the I2C interface?

That would normally mean it doesn't work at all...
Besides, I2C speed is defined by the master through its SCL signal, so unless it's too fast for the slave it should be OK.
A very strange issue indeed!

The stm32duino board helped me solve this issue.

A guy named haisan gave me the hint


In your Libraries folder, find 'Adafruit_ADS1X15/Adafruit_ADS1015.h' and edit:

#define ADS1115_CONVERSIONDELAY ( 8 )

to be:

#define ADS1115_CONVERSIONDELAY ( 9 )


Now it works fine. SOLVED

ZeroX_141:
The stm32duino board helped me solve this issue.

A guy named haisan gave me the hint


In your Libraries folder, find 'Adafruit_ADS1X15/Adafruit_ADS1015.h' and edit:

#define ADS1115_CONVERSIONDELAY ( 8 )

to be:

#define ADS1115_CONVERSIONDELAY ( 9 )


Now it works fine. SOLVED

Question is why?

Indeed, strange. Also an odd looking #define.
Would have to start digging through the library & the data sheet to maybe find an answer to why this happens. It's anyway just weird.

Its essential to add parantheses around #defines if there is any chance of the expansion interacting
with its context, given its basically textual substitution (well, almost). Single tokens don't need it,
but there's no harm in always doing it.

consider

#define ONE 1
#define TWO ONE+ONE

Serial.print (5 * TWO) ;  // prints 6

should be

#define TWO (ONE+ONE)

Note that there must be a space before the '(' unless you are defining a macro when there must be
no space.

#define SQUARE(n) (n*n)

Note that this is a bad way to define squaring, as n is textually substituted and any side-effects are
duplicated!