ADS1115 with OLED Display - Only A0 operational

General project help for Adafruit customers

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
CPW
 
Posts: 24
Joined: Tue Aug 24, 2021 4:46 pm

ADS1115 with OLED Display - Only A0 operational

Post by CPW »

Working a project where I'd like to display several channels from the ads1115 on a small OLED display. All 4 channels of the ads1115 work as expected in isolation. However, when I add an OLED display to the I2C bus, only the A0 channel of the ads1115 is operational. Channels A1, shows a value of unknown origin...about 1.9 V, and A2, A2 show 0. The ads1115 is at 0x48; the OLED is at 0x3C, as detected by the device scanner. I've changed the OLED to 0x3D...same result. Any thoughts?

User avatar
adafruit_support_bill
 
Posts: 88088
Joined: Sat Feb 07, 2009 10:11 am

Re: ADS1115 with OLED Display - Only A0 operational

Post by adafruit_support_bill »

What is connected to those channels?

User avatar
CPW
 
Posts: 24
Joined: Tue Aug 24, 2021 4:46 pm

Re: ADS1115 with OLED Display - Only A0 operational

Post by CPW »

Testing with 4.5 volt DC source.

User avatar
adafruit_support_bill
 
Posts: 88088
Joined: Sat Feb 07, 2009 10:11 am

Re: ADS1115 with OLED Display - Only A0 operational

Post by adafruit_support_bill »

Please post your code and a photo of your setup. That might provide some clues.

User avatar
CPW
 
Posts: 24
Joined: Tue Aug 24, 2021 4:46 pm

Re: ADS1115 with OLED Display - Only A0 operational

Post by CPW »

[img]
A1.jpg
A1.jpg (117.21 KiB) Viewed 157 times
[/img]
A0.jpg
A0.jpg (117.57 KiB) Viewed 157 times
[attachment=0]A2D-OLEDSetup.jpg. Photo with 4.5 v DC source to each A2D input with OLED display of result, one of the whole setup using Arduino UNO and the code the UNO is running..

Code: Select all

#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include <Adafruit_ADS1X15.h>
Adafruit_ADS1115 ads;

#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 32 // OLED display height, in pixels
#define OLED_RESET     4 // Reset pin # (or -1 if sharing Arduino reset pin)
#define SCREEN_ADDRESS 0x3D
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);


void setup() {
  
  Serial.begin(9600);
  if (!ads.begin()) {
    Serial.println("Failed to initialize ADS.");
    while (1);
  }
    
  ads.setGain(GAIN_TWOTHIRDS);
 

  if(!display.begin(SSD1306_SWITCHCAPVCC, SCREEN_ADDRESS)) {
    Serial.println(F("SSD1306 allocation failed"));
    for(;;); // Don't proceed, loop forever
  }

  display.clearDisplay();
  display.setTextColor(SSD1306_WHITE); // Draw white text
  display.cp437(true);         // Use full 256 char 'Code Page 437' font
  display.setTextSize(1);
}

int16_t adc3, adc1, adc2, adc0;
float volts3, volts1, volts2, volts0;
float sum1, sum2, sum3, sum0;
const int n = 1;

void loop() {

  sum0 = sum1 = sum2 = sum3 = 0.0;
  for (int i = 1; i <= n; i++){
    adc0 = ads.readADC_SingleEnded(0);
      adc1 = ads.readADC_SingleEnded(1);
        adc2 = ads.readADC_SingleEnded(2);
          adc3 = ads.readADC_SingleEnded(3);
    sum0 = sum0 + float(adc0);    
      sum1 = sum1 + float(adc1); 
        sum1 = sum1 + float(adc1);    
          sum1 = sum1 + float(adc1);
  }

  sum0 = sum0/float(n);
    sum1 = sum1/float(n);
      sum2 = sum2/float(n);
        sum3 = sum3/float(n);
  volts0 = ads.computeVolts(sum0);
    volts1 = ads.computeVolts(sum1);
      volts2 = ads.computeVolts(sum2);
        volts3 = ads.computeVolts(sum3);

  Serial.println("V0 = " + String(volts0,4));  
    Serial.println("V1 = " + String(volts1,4));
      Serial.println("V2 = " + String(volts2,4));
        Serial.println("V3 = " + String(volts3,4));
        
  display.clearDisplay();
  display.setCursor(0,0);
  display.println("v0 = " + String(volts0,4));
    display.setCursor(0,8);
    display.println("v1 = " + String(volts1,4));
      display.setCursor(0,16);
      display.println("v2 = " + String(volts2,4));
            display.setCursor(0,24);
            display.println("v3 = " + String(volts3,4));
  display.display();
  delay(1000);
  }
Attachments
A2D-OLEDSetup.jpg
A2D-OLEDSetup.jpg (383.45 KiB) Viewed 157 times

User avatar
CPW
 
Posts: 24
Joined: Tue Aug 24, 2021 4:46 pm

Re: ADS1115 with OLED Display - Only A0 operational

Post by CPW »

I found the problem...opied code and didn't review it closely enough.

User avatar
adafruit_support_bill
 
Posts: 88088
Joined: Sat Feb 07, 2009 10:11 am

Re: ADS1115 with OLED Display - Only A0 operational

Post by adafruit_support_bill »

You only have a connection to A0. All the others are floating. Their values are 'undefined'.

Locked
Please be positive and constructive with your questions and comments.

Return to “General Project help”