0

Trouble addressing two ADS1115 ADC's in Arduino Code
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Trouble addressing two ADS1115 ADC's in Arduino Code

by qpowell on Wed Jul 14, 2021 6:35 pm

I am working with two ADS1115's ADC's connected to one Arduino Mega 2560. I am having trouble addressing them in the code. I have posted the error and my code below.

I am given this error:

FG_SD:7:29: error: no matching function for call to 'Adafruit_ADS1115::Adafruit_ADS1115(int)'
Adafruit_ADS1115 adcOne(0x48); // ADDR to GND
^
In file included from F:\FG_SD\FG_SD.ino:3:0:
D:\Users\qpowell\Documents\Arduino\libraries\Adafruit_ADS1X15/Adafruit_ADS1X15.h:186:3: note: candidate: Adafruit_ADS1115::Adafruit_ADS1115()
Adafruit_ADS1115();
^~~~~~~~~~~~~~~~
D:\Users\qpowell\Documents\Arduino\libraries\Adafruit_ADS1X15/Adafruit_ADS1X15.h:186:3: note: candidate expects 0 arguments, 1 provided
D:\Users\qpowell\Documents\Arduino\libraries\Adafruit_ADS1X15/Adafruit_ADS1X15.h:184:7: note: candidate: constexpr Adafruit_ADS1115::Adafruit_ADS1115(const Adafruit_ADS1115&)
class Adafruit_ADS1115 : public Adafruit_ADS1X15 {
^~~~~~~~~~~~~~~~
D:\Users\qpowell\Documents\Arduino\libraries\Adafruit_ADS1X15/Adafruit_ADS1X15.h:184:7: note: no known conversion for argument 1 from 'int' to 'const Adafruit_ADS1115&'
D:\Users\qpowell\Documents\Arduino\libraries\Adafruit_ADS1X15/Adafruit_ADS1X15.h:184:7: note: candidate: constexpr Adafruit_ADS1115::Adafruit_ADS1115(Adafruit_ADS1115&&)
D:\Users\qpowell\Documents\Arduino\libraries\Adafruit_ADS1X15/Adafruit_ADS1X15.h:184:7: note: no known conversion for argument 1 from 'int' to 'Adafruit_ADS1115&&'
FG_SD:8:29: error: no matching function for call to 'Adafruit_ADS1115::Adafruit_ADS1115(int)'
Adafruit_ADS1115 adcTwo(0x49); // ADDR to VDD
^
In file included from F:\FG_SD\FG_SD.ino:3:0:
D:\Users\qpowell\Documents\Arduino\libraries\Adafruit_ADS1X15/Adafruit_ADS1X15.h:186:3: note: candidate: Adafruit_ADS1115::Adafruit_ADS1115()
Adafruit_ADS1115();
^~~~~~~~~~~~~~~~
D:\Users\qpowell\Documents\Arduino\libraries\Adafruit_ADS1X15/Adafruit_ADS1X15.h:186:3: note: candidate expects 0 arguments, 1 provided
D:\Users\qpowell\Documents\Arduino\libraries\Adafruit_ADS1X15/Adafruit_ADS1X15.h:184:7: note: candidate: constexpr Adafruit_ADS1115::Adafruit_ADS1115(const Adafruit_ADS1115&)
class Adafruit_ADS1115 : public Adafruit_ADS1X15 {
^~~~~~~~~~~~~~~~
D:\Users\qpowell\Documents\Arduino\libraries\Adafruit_ADS1X15/Adafruit_ADS1X15.h:184:7: note: no known conversion for argument 1 from 'int' to 'const Adafruit_ADS1115&'
D:\Users\qpowell\Documents\Arduino\libraries\Adafruit_ADS1X15/Adafruit_ADS1X15.h:184:7: note: candidate: constexpr Adafruit_ADS1115::Adafruit_ADS1115(Adafruit_ADS1115&&)
D:\Users\qpowell\Documents\Arduino\libraries\Adafruit_ADS1X15/Adafruit_ADS1X15.h:184:7: note: no known conversion for argument 1 from 'int' to 'Adafruit_ADS1115&&'
F:\FG_SD\FG_SD.ino: In function 'void setup()':
FG_SD:18:14: error: no match for call to '(Adafruit_ADS1115) (int)'
adcOne(0x48).begin();
^
FG_SD:19:14: error: no match for call to '(Adafruit_ADS1115) (int)'
adcTwo(0x49).begin();
^
FG_SD:21:14: error: no match for call to '(Adafruit_ADS1115) (int)'
adcOne(0x48).setGain(GAIN_ONE);
^
FG_SD:22:14: error: no match for call to '(Adafruit_ADS1115) (int)'
adcTwo(0x49).setGain(GAIN_ONE);
^
exit status 1
no matching function for call to 'Adafruit_ADS1115::Adafruit_ADS1115(int)'

Here is my code:

Code: Select all | TOGGLE FULL SIZE
#include<Wire.h>
#include <SD.h> //Load SD card library
#include <Adafruit_ADS1X15.h>
#include <SPI.h> //Load SPI Library
#include <SoftwareSerial.h> //Load the Software Serial library

Adafruit_ADS1115 adcOne(0x48); // ADDR to GND
Adafruit_ADS1115 adcTwo(0x49); // ADDR to VDD

void setup() {
  Serial.begin(115200);

  adcOne(0x48).begin();
  adcTwo(0x49).begin();

  //adcOne(0x48).setGain(GAIN_ONE);
  //adcTwo(0x49).setGain(GAIN_ONE);
 
}

void loop() {

  uint16_t FGM1, FGM2, FGM3, FGM4, FGM5, FGM6;
 
  FGM1 = adcOne.readADC_SingleEnded(0);
  FGM2 = adcOne.readADC_SingleEnded(1);
  FGM3 = adcOne.readADC_SingleEnded(2);
  FGM4 = adcTwo.readADC_SingleEnded(0);
  FGM5 = adcTwo.readADC_SingleEnded(1);
  FGM6 = adcTwo.readADC_SingleEnded(2);

  Serial.print(FGM1);
  Serial.print(",");
  Serial.print(FGM2);
  Serial.print(",");
  Serial.print(FGM3);
  Serial.print(",");
  Serial.print(FGM4);
  Serial.print(",");
  Serial.print(FGM5);
  Serial.print(",");
  Serial.println(FGM6);

}
Last edited by adafruit_support_bill on Wed Jul 14, 2021 7:20 pm, edited 2 times in total.
Reason: Pleas use [code] tags when posting code to the forums

qpowell
 
Posts: 1
Joined: Wed Jul 14, 2021 6:18 pm

Re: Trouble addressing two ADS1115 ADC's in Arduino Code

by adafruit_support_bill on Wed Jul 14, 2021 7:24 pm

FG_SD:7:29: error: no matching function for call to 'Adafruit_ADS1115::Adafruit_ADS1115(int)'

As the error messages say, there is no constructor that takes an integer parameter. You need to pass in the address in the begin function:
https://learn.adafruit.com/adafruit-4-c ... -2974130-2

adafruit_support_bill
 
Posts: 82190
Joined: Sat Feb 07, 2009 10:11 am

Please be positive and constructive with your questions and comments.