Two BMP180 sensors with same I2C addresses on Wire and Wire1 (Teensy 4.1)

I want to utilize two BMP180 sensors and compare their data. Here is my current code:
Code:
#include <Wire.h>
#include <WireIMXRT.h>
#include <WireKinetis.h>

#include <Adafruit_BMP085.h>

unsigned long pre_cas = 0;
unsigned long pre_cas1 = 0;

double tempL, tempD, pritL, pritD, visL, visD, vis_let, vis_let_prava, vis_tla1, vis_tla, vis_od_tal;


long int prit_morje; //zračni pritisk v Kopru - podatki https://meteo.arso.gov.si/uploads/probase/www/observ/surface/text/sl/observationAms_KOPER_KAPET-IJA_history.html, python script - ker se zracni tlak ob morju spreminja visina nenatancna po dolocenem casu

int i;

String pritisk_vnesen;

Adafruit_BMP085 bmp;
Adafruit_BMP085 bmp1;

void setup() {
  Serial.begin(9600);
  Wire.begin();
  Wire1.begin();
  bmp.begin(BMP085_ULTRAHIGHRES);
  bmp1.begin(BMP085_ULTRAHIGHRES);

  delay(10000);

  Serial.println("Pritisk v koprski kapitaniji: ");

  delay(10000);

  if(Serial.available()>=5){
        pritisk_vnesen = Serial.readStringUntil('\n');
        prit_morje = pritisk_vnesen.toInt();
        Serial.println(prit_morje);
    }

  vis_tla1 = 0;

  for(i=0; i<200; i++){ //naredi povprečje levega in desnega krila, da ugotovi višino letala
      vis_tla1 = ((bmp.readAltitude(prit_morje) + bmp1.readAltitude(prit_morje))/2.0) + vis_tla1;
      delay(20);
    }
  
  vis_tla = vis_tla1/200.0;
  
  Serial.println("Zacetna nadmorska visina: ");
  Serial.println(vis_tla, 1);
  Serial.println("Let se lahko pricne");

}

void loop() {

  unsigned long cas = millis();

  if (cas - pre_cas >= 2000){//zakasnitev za 5 sekund
    pre_cas = cas;

    tempL = bmp.readTemperature();
    pritL = bmp.readPressure();

    tempD = bmp1.readTemperature();
    pritD = bmp1.readPressure();

    /*
    Serial.println(" ");
    Serial.println("Levi senzor: ");
    Serial.print(tempL);
    Serial.println(" C");
    Serial.print(pritL);
    Serial.println(" Pa");
    Serial.print(visL);
    Serial.println(" m");

    Serial.println("Desni senzor: ");
    Serial.print(tempD);
    Serial.println(" C");
    Serial.print(pritD);
    Serial.println(" Pa");
    Serial.print(visD);
    Serial.println(" m");
    */

    vis_let=0.0;
    
    for(i=0; i<30; i++){ //naredi povprečje levega in desnega krila, da ugotovi višino letala
      visL = bmp.readAltitude(prit_morje);
      visD = bmp1.readAltitude(prit_morje);
      vis_let = ((visD + visL)/2.0) + vis_let;
    }

    if(abs(visD - visL) > 6.0){
      Serial.println("Napaka zaradi prevelikega razpona senzorjev");
    }

    vis_let_prava = vis_let/30.0;

    Serial.println(" ");
    Serial.println("visina letala: ");
    Serial.println(vis_let_prava, 1);

    vis_od_tal = vis_let_prava - vis_tla;
    Serial.println(" ");
    Serial.println("oddaljenost od tal: ");
    Serial.println(vis_od_tal);

    if(Serial.available()>=5){
        pritisk_vnesen = Serial.readStringUntil('\n');
        prit_morje = pritisk_vnesen.toInt();
        Serial.println(prit_morje);
    }

  }
}
I input the current sea level pressure and then the programme calculates current elevation from the ground, etc. It works fine with this code but the sensor on SCL1 and SDA1 doesn't send data. When I tried:
Code:
bmp.begin(BMP085_ULTRAHIGHRES,&Wire);
bmp1.begin(BMP085_ULTRAHIGHRES,&Wire1);
The numbers were jumping around. The address for both is 0x77.
Thanks in advance for all help.
 
I don't know whether these modifications will make any difference...but
Code:
//#include <Wire.h>
//#include <WireIMXRT.h>
//#include <WireKinetis.h>
...the above are not necessary...and
Code:
void setup() {
    Serial.begin(9600);
    [COLOR="#FF0000"]while (!Serial && (millis() < 5000)) {};[/COLOR][B]    //(1)[/B]
    Wire.begin();
    Wire1.begin();
    [COLOR="#FF0000"]bmp.begin();[/COLOR][B]    //(2)[/B]
    [COLOR="#FF0000"]bmp1.begin(BMP085_ULTRAHIGHRES, &Wire1);[/COLOR][B]    //(3)[/B]
...the Teensy might be starting up too quickly for the BMP085 so adding the line commented as (1) will wait until the usb is up and give the BMP time to settle.
The line commented as (2)---No need for any parameters after the begin, they will default to what you had put (BMP085_ULTRAHIGHRES, Wire1).
The line commented as (3) is required to access the BMP on the second I2C port.

Can you show a picture of your wiring?
 
I tried the code above and it doesn't help. Here is the schematic
shemaBMP180.png
Here is also the schematic of the whole system
shema_senzorjev_schem.jpg
 
I was searching and thinking, is it possible that the library is not written for Wire1, but only Wire?
If you examine the .h file you will see that the code is written to take &WireX as an optional parameter.
 
Back
Top