??? Comment utiliser 2 ADS1115 avec arduino ??? (Résolu)

Bonjour à tous

Je suis débutant donc merci d'avance pour votre patience et compréhension.

Je désire utiliser 2 ADS1115 affin de pouvoir mesurer 4 tensions différentielles donc 2 par ads.
La configuration basique pour une seule carte, ça va je comprends et réussis tout à fait
à écrire et configurer le sketch. Mais je suis coincé pour rajouter le 2éme, l'utilisation de I2C
simplifie les choses mais je butte sur l'adressage. Pas que je ne sache pas comment changer
l'adresse sur la carte mais pour intégrer tout ça au code...

Je joint une ébauche de mon code en espérant profiter de vos lumières.

#include <Wire.h>
#include <Adafruit_ADS1015.h>

Adafruit_ADS1115 ads; // ads 1
// Adafruit_ADS1115 ads; // ads 2




void setup(void){  

  ads.begin();
  ads.setGain(GAIN_EIGHT);      // 8x gain   +/- 0.512V  1 bit = 0.25mV   0.015625mV

 
  
}

void loop(void)
{
  int16_t data1;
  int16_t data2;
  // int16_t data3;
  // int16_t data4;
  // int16_t data5;
  // int16_t data6;
  
  float multiplier = 0.015625; 
  
  data1 = ads.readADC_Differential_0_1(); // Differential read from ads 1 pin A0/A1
  data2 = ads.readADC_Differential_2_3(); // Differential read from ads 1 pin A2/A3
  // data3 = ads.readADC_Differential_0_1(); // Differential read from ads 2 pin A0/A1
  // data4 = ads.readADC_Differential_2_3(); // Differential read from ads 2 pin A2/A3
    
 

  delay(10);
}

pepe:
Bonsoir

Comme tu sembles utiliser la bibliothèque ADS1X15 d'Adafruit, alors tu peux procéder comme suit :

#include <Wire.h>

#include <Adafruit_ADS1015.h>

Adafruit_ADS1115 adsA;        // premier ADS1115 à l'adresse par défaut (0x48)
Adafruit_ADS1115 adsB(0x49);  // second ADS1115 à l'adresse 0x49 (ADDR relié à VDD)

void setup(void){
  adsA.begin();  // initialise la liaison I2C

//  adsB.begin();  // inutile avec la version actuelle de la bibliothèque

adsA.setGain(GAIN_EIGHT);  // gain du premier ADS1115
  adsB.setGain(GAIN_EIGHT);  // gain du second ADS1115
}

void loop() {
  int16_t data1, data2, data3, data4;

data1 = adsA.readADC_Differential_0_1(); // tension differentielle A0/A1 du premier ADS1115
  data2 = adsA.readADC_Differential_2_3(); // tension differentielle A2/A3 du premier ADS1115
  data3 = adsB.readADC_Differential_0_1(); // tension differentielle A0/A1 du second ADS1115
  data4 = adsB.readADC_Differential_2_3(); // tension differentielle A2/A3 du second ADS1115

...

}

Je te remercie de t'être penché sur cas!!! juste avant lire le poste j'avais fini par trouver la solution quasi identique

Voila ce à quoi j'ai abouti reste plus qu'à finir, en espérant que cela pourrait aider...
Merci encore :wink:

#include <Wire.h>
#include <Adafruit_ADS1015.h>

Adafruit_ADS1115 ads1(0x48); // ads 1
Adafruit_ADS1115 ads2(0x49); // ads 2




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

  ads1.begin();
  ads2.begin();
  ads1.setGain(GAIN_EIGHT);      // 8x gain   +/- 0.512V  1 bit = 0.25mV   0.015625mV
  ads2.setGain(GAIN_EIGHT);      // 8x gain   +/- 0.512V  1 bit = 0.25mV   0.015625mV
  

 
  
}

void loop(void)
{
  int16_t data1, data2, data3, data4;
 
  
  float multiplier = 0.015625; 
  
  data1 = ads1.readADC_Differential_0_1(); // Differential read from ads 1 pin A0/A1
  data2 = ads1.readADC_Differential_2_3(); // Differential read from ads 1 pin A2/A3
  data3 = ads2.readADC_Differential_0_1(); // Differential read from ads 2 pin A0/A1
  data4 = ads2.readADC_Differential_2_3(); // Differential read from ads 2 pin A2/A3
    


  delay(10);


}