Using (reading) Multiple ADS1115 boards in a single project

My project has multiple (4 to be exact) ADS1115 from Adafruit.

I'm using the Adafruit library Adafruit_ADS1015 from the Adafruit website.

The example code does not indicate how to specify the address for the ADS1115 but the tutorial does.

Adafruit_ADS1115 ads1115(0x49);

I would prefer to have an array of ads1115 instead of four unique variable names.

How to I define ads1115[4] with indexes 0-3 at addresses 0x48, 0x49, 0x4B, and 0x4A?

How to I define ads1115[4] with indexes 0-3 at addresses 0x48, 0x49, 0x4B, and 0x4A?

const byte ads1115[4] = {0x48, 0x49, 0x4B, 0x4A} ;

6v6gt:

How to I define ads1115[4] with indexes 0-3 at addresses 0x48, 0x49, 0x4B, and 0x4A?

const byte ads1115[4] = {0x48, 0x49, 0x4B, 0x4A} ;

I’m confused. You have type byte, Adafruit has type Adafruit_ADS1115.

I tried it but got a bunch of errors.

Arduino: 1.8.5 (Windows 7), Board: "Arduino/Genuino Uno"

...

Using cached library dependencies for file: C:\Users\Anthony\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.21\libraries\Wire\src\Wire.cpp
Using cached library dependencies for file: C:\Users\Anthony\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.21\libraries\Wire\src\utility\twi.c
Using cached library dependencies for file: C:\Users\Anthony\Documents\Arduino\libraries\hd44780\hd44780.cpp
Using cached library dependencies for file: C:\Users\Anthony\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.21\libraries\SPI\src\SPI.cpp
Using cached library dependencies for file:
...
Using cached library dependencies for file: C:\Users\Anthony\Documents\Arduino\libraries\Adafruit_ADS1X15-master\Adafruit_ADS1015.cpp
Generating function prototypes...
"C:\Users\Anthony\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\4.9.2-atmel3.5.4-arduino2/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics  -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10805 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR   "-IC:\Users\Anthony\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.21\cores\arduino" "-IC:\Users\Anthony\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.21\variants\standard" "-IC:\Users\Anthony\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.21\libraries\Wire\src" "-IC:\Users\Anthony\Documents\Arduino\libraries\hd44780" "-IC:\Users\Anthony\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.21\libraries\SPI\src" "-IC:\Users\Anthony\Documents\Arduino\libraries\RTClib" "-IC:\Users\Anthony\Documents\Arduino\libraries\SdFat\src" "-IC:\Users\Anthony\Documents\Arduino\libraries\DallasTemperature" "-IC:\Users\Anthony\Documents\Arduino\libraries\OneWire" "-IC:\Users\Anthony\Documents\Arduino\libraries\JC_Button\src" "-IC:\Users\Anthony\Documents\Arduino\libraries\Adafruit_ADS1X15-master" "C:\Users\Anthony\AppData\Local\Temp\arduino_build_395853\sketch\Battery_Tester_v7.ino.cpp" -o "C:\Users\Anthony\AppData\Local\Temp\arduino_build_395853\preproc\ctags_target_for_gcc_minus_e.cpp"
"C:\Program Files (x86)\Arduino\tools-builder\ctags\5.8-arduino11/ctags" -u --language-force=c++ -f - --c++-kinds=svpf --fields=KSTtzns --line-directives "C:\Users\Anthony\AppData\Local\Temp\arduino_build_395853\preproc\ctags_target_for_gcc_minus_e.cpp"
Compiling sketch...
"C:\Users\Anthony\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\4.9.2-atmel3.5.4-arduino2/bin/avr-g++" -c -g -Os -Wall -Wextra -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -flto -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10805 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR   "-IC:\Users\Anthony\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.21\cores\arduino" "-IC:\Users\Anthony\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.21\variants\standard" "-IC:\Users\Anthony\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.21\libraries\Wire\src" "-IC:\Users\Anthony\Documents\Arduino\libraries\hd44780" "-IC:\Users\Anthony\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.21\libraries\SPI\src" "-IC:\Users\Anthony\Documents\Arduino\libraries\RTClib" "-IC:\Users\Anthony\Documents\Arduino\libraries\SdFat\src" "-IC:\Users\Anthony\Documents\Arduino\libraries\DallasTemperature" "-IC:\Users\Anthony\Documents\Arduino\libraries\OneWire" "-IC:\Users\Anthony\Documents\Arduino\libraries\JC_Button\src" "-IC:\Users\Anthony\Documents\Arduino\libraries\Adafruit_ADS1X15-master" "C:\Users\Anthony\AppData\Local\Temp\arduino_build_395853\sketch\Battery_Tester_v7.ino.cpp" -o "C:\Users\Anthony\AppData\Local\Temp\arduino_build_395853\sketch\Battery_Tester_v7.ino.cpp.o"
C:\Users\Anthony\Documents\Arduino\Battery_Tester_v7\Battery_Tester_v7.ino: In function 'void loop()':

C:\Users\Anthony\Documents\Arduino\Battery_Tester_v7\Battery_Tester_v7.ino:897:18: warning: unused variable 'skip_adc_read' [-Wunused-variable]

   static boolean skip_adc_read=true;

                  ^

C:\Users\Anthony\Documents\Arduino\Battery_Tester_v7\Battery_Test_Low_V.ino: In function 'void start_adc()':

Battery_Test_Low_V:32: error: request for member 'setGain' in 'ads1115[0]', which is of non-class type 'const byte {aka const unsigned char}'

 ads1115[0].setGain(GAIN_ONE);

            ^

Battery_Test_Low_V:33: error: request for member 'begin' in 'ads1115[0]', which is of non-class type 'const byte {aka const unsigned char}'

 ads1115[0].begin();

            ^


Using library Wire at version 1.0 in folder: C:\Users\Anthony\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.21\libraries\Wire 
Using library hd44780 at version 0.9.3 in folder: C:\Users\Anthony\Documents\Arduino\libraries\hd44780 
Using library SPI at version 1.0 in folder: C:\Users\Anthony\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.21\libraries\SPI 
Using library RTClib at version 1.2.0 in folder: C:\Users\Anthony\Documents\Arduino\libraries\RTClib 
Using library SdFat at version 1.0.5 in folder: C:\Users\Anthony\Documents\Arduino\libraries\SdFat 
Using library DallasTemperature at version 3.8.0 in folder: C:\Users\Anthony\Documents\Arduino\libraries\DallasTemperature 
Using library OneWire at version 2.3.4 in folder: C:\Users\Anthony\Documents\Arduino\libraries\OneWire 
Using library JC_Button at version 2.0.1 in folder: C:\Users\Anthony\Documents\Arduino\libraries\JC_Button 
Using library Adafruit_ADS1X15-master at version 1.0.0 in folder: C:\Users\Anthony\Documents\Arduino\libraries\Adafruit_ADS1X15-master 
exit status 1
request for member 'setGain' in 'ads1115[0]', which is of non-class type 'const byte {aka const unsigned char}'

Oops. I didn’t read the question properly. Try this:

Adafruit_ADS1115 **ads1115 ;
ads1115 = new Adafruit_ADS1115 *[ 4 ] ;
ads1115[0] = new Adafruit_ADS1115( 0x48 ) ;
ads1115[1] = new Adafruit_ADS1115( 0x49 ) ;
ads1115[2] = new Adafruit_ADS1115( 0x4B ) ;
ads1115[3] = new Adafruit_ADS1115( 0x4A ) ;

Or look at vectors.