Addressing multiple ADS1115 breakout boards

Breakout boards, sensors, other Adafruit kits, etc.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
jacobmcd
 
Posts: 1
Joined: Thu Jan 16, 2014 6:35 pm

Addressing multiple ADS1115 breakout boards

Post by jacobmcd »

I am trying to connect 4 ADS1115 boards together with addressing to read 16 single end thermistors. I am having trouble thought figuring out how to write the code for it to call one each of the boards separate. I have seen in the tutorial there is an address that is assigned based on how it is wired but I do not see anything about how to call on that address in the code.

Thanks

User avatar
figgyb
 
Posts: 41
Joined: Wed Mar 17, 2010 5:19 pm

Re: Addressing multiple ADS1115 breakout boards

Post by figgyb »

When you create the object for each of your chips, call out the address for each of them:

Code: Select all

Adafruit_ADS1115 ads1115(0x49);	// construct an ads1115 at address 0x49

User avatar
jtomerli
 
Posts: 11
Joined: Mon Oct 20, 2014 12:21 pm

Re: Addressing multiple ADS1115 breakout boards

Post by jtomerli »

figgyb wrote:When you create the object for each of your chips, call out the address for each of them:

Code: Select all

Adafruit_ADS1115 ads1115(0x49);	// construct an ads1115 at address 0x49

This is an old post so I don't know if it will get answered, but thought it best to keep this subject within the original post.

The code didn't answer the problem I am having. It showed how to address one ADS1115, but what is the syntax for the second board? The tutorial doesn't show an example of a second address either. Here is what I have tried and get an error, thanks for any help:

Code: Select all

#include <Wire.h>
#include <Adafruit_ADS1015.h>
#include <Adafruit_MCP23017.h>
#include <Adafruit_RGBLCDShield.h>
Adafruit_ADS1015 ads1115(0x48);	// Construct an ads1015 at the default address: 0x48
Adafruit_ADS1015 ads1115(0x49);
I get the error:

Code: Select all

heated_blanket_controller:6: error: redefinition of 'Adafruit_ADS1015 ads1115'
heated_blanket_controller:5: error: 'Adafruit_ADS1015 ads1115' previously declared here
heated_blanket_controller.ino: In function 'void setup()':
heated_blanket_controller:51: error: 'ads' was not declared in this scope
heated_blanket_controller.ino: In function 'void loop()':
heated_blanket_controller:57: error: expected unqualified-id before ';' token

Last question, when using multiple cards; I am using two, how do I set the second card for a different gain? I would like first card to be set 16X gain, and the second card at 1X gain.

Thank you.

User avatar
adafruit_support_mike
 
Posts: 67446
Joined: Thu Feb 11, 2010 2:51 pm

Re: Addressing multiple ADS1115 breakout boards

Post by adafruit_support_mike »

These lines are trying to create two different objects with the same name - 'ads1115':

Code: Select all

Adafruit_ADS1015 ads1115(0x48);
Adafruit_ADS1015 ads1115(0x49);
You need to give them different names:

Code: Select all

Adafruit_ADS1015 adcOne(0x48);
Adafruit_ADS1015 adcTwo(0x49);
then use those names ('adcOne' and 'adcTwo') when you want to communicate with either sensor. That includes things like setting the gain and the collection mode.

User avatar
jtomerli
 
Posts: 11
Joined: Mon Oct 20, 2014 12:21 pm

Re: Addressing multiple ADS1115 breakout boards

Post by jtomerli »

adafruit_support_mike wrote:These lines are trying to create two different objects with the same name - 'ads1115':

Code: Select all

Adafruit_ADS1015 ads1115(0x48);
Adafruit_ADS1015 ads1115(0x49);
You need to give them different names:

Code: Select all

CODE: SELECT ALL | TOGGLE FULL SIZE
Adafruit_ADS1015 adcOne(0x48);
Adafruit_ADS1015 adcTwo(0x49);


Hi Mike thanks for the great information.

Just to clarify, if I want to set the gain on adcOne, it would look something like this:

Code: Select all

adcOne(ox48).setGain(GAIN_SIXTEEN); 
Thank you.
I think I figured it out, this seems to work:

Code: Select all

Adafruit_ADS1115 adcOne(0x48);
Adafruit_ADS1115 adcTwo(0x49);


adcOne.setGain(GAIN_SIXTEEN);
adcTwo.setGain(GAIN_ONE);  

      
adc0 = adcOne.readADC_SingleEnded(0);
adc1 = adcTwo.readADC_SingleEnded(1);

User avatar
adafruit_support_mike
 
Posts: 67446
Joined: Thu Feb 11, 2010 2:51 pm

Re: Addressing multiple ADS1115 breakout boards

Post by adafruit_support_mike »

Yep, that's what you want.

User avatar
josephchrzempiec
 
Posts: 77
Joined: Tue May 12, 2015 4:34 am

Re: Addressing multiple ADS1115 breakout boards

Post by josephchrzempiec »

Hello i know this is a old post but i was wondering. If i string a bunch of these together like say 7 to 14 of them to measure batteries would it be possible? What i mean is I'm trying to have each battery on it's only i2c board and there are 7 of them. But planing on having 14 in total?

User avatar
adafruit_support_mike
 
Posts: 67446
Joined: Thu Feb 11, 2010 2:51 pm

Re: Addressing multiple ADS1115 breakout boards

Post by adafruit_support_mike »

The ADS1115 only has two possible I2C addresses, so you'd need something like a TCA9548 multiplexer:

https://www.adafruit.com/product/2717

There would also be issues with voltage levels if you wanted to measure individual batteries in series.

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

Return to “Other Products from Adafruit”