Connect two Bmp180 to one elegoo uno r3

I have an elegoo uno r3 and i want to connect two no name bmp180 sensors wich do not have an Adress selector pin to it without using a multiplexer. I'm new to Arduino so i dont know how to use the library softwire or even wire can someone help me write the code for the second sensor wich will be connected to digital pins 6 and 7.


#include <Adafruit_BMP085.h>
#include <Wire.h>
#include <LiquidCrystal.h>

LiquidCrystal lcd(13, 12, 11, 10, 9, 8);//RS,EN,D4,D5,D6,D7
 
char PRESSURESHOW[4];// initializing a character of size 4 for showing the result
char TEMPARATURESHOW[4];// initializing a character of size 4 for showing the temparature result
Adafruit_BMP085 bmp;
 
void setup() {
lcd.begin(16, 2);
// Print a logo message to the LCD.
lcd.print(" BMP180 Sensor");
lcd.setCursor(0, 1);
lcd.print("Temp. & Pressure");
lcd.setCursor(0, 2);
delay (3000);
 
lcd.clear();//clear display
Serial.begin(9600);
if (!bmp.begin())
{
Serial.println("ERROR");///if there is an error in communication
while (1) {}
}
}
void loop()
{
Serial.print("Temperature:");
Serial.print(bmp.readTemperature());
Serial.print(",");  
Serial.print("Pressure:");
Serial.print(bmp.readPressure());
Serial.print(",");
lcd.print("Pressure= "); // print name
String PRESSUREVALUE = String(bmp.readPressure());
// convert the reading to a char array
PRESSUREVALUE.toCharArray(PRESSURESHOW, 4);
lcd.print(PRESSURESHOW);
lcd.print("hPa ");
lcd.setCursor(0, 1);
lcd.print("Temparature=");// print name
 
String TEMPARATUREVALUE = String(bmp.readTemperature());
// convert the reading to a char array
TEMPARATUREVALUE.toCharArray(TEMPARATURESHOW, 4);
lcd.print(TEMPARATURESHOW);
lcd.print("C ");
lcd.setCursor(0, 0);//set the cursor to column 0, line1
delay(500);
}

Maybe try a software I2C solution for the second sensor?

I want to use this but my problem is that i don't know how to use it

I don't either. But if I had to figure it out I would look at the example code that comes with the libraries and read whatever documentation that I could find. Then run the examples with my sensors to see if I could make them work.

If I could not get them to work, then maybe post the code that I tried, a schematic of the circuit and the details of the results of my attempts.

There may be members that have used the libraries that can help.

i now tried solving the problem with bit bang wich seems to be easier to use than softwire and connected the first bmp scl to digital pin 4 and sda to digital pin 4 for the second bmp scl to digital pin 7 and sda to digital pin 6

#include <BitBang_I2C.h>

//#include <Wire.h>

#include <Adafruit_BMP085.h>
Adafruit_BMP085 bmp;
BBI2C bbi2c;
#define BITBANG true
//uint32_t start;
//uint32_t stop;


float tempN1;
float presN1;


float tempN2;
float presN2;


int flip = 0;
void setup(){
  Serial.begin(9600);
}
void bmp180read(){
    if (flip == 0)
  {
  memset(&bbi2c, 0, sizeof(bbi2c));
  bbi2c.bWire = !BITBANG; // use bit bang, not wire library
  bbi2c.iSDA = 5;
  bbi2c.iSCL = 4;
  I2CInit(&bbi2c, 100000L);
    delay(100);
    bmp.begin();
    delay(250);
    tempN1 = bmp.readTemperature();
    presN1 = bmp.readPressure();
    delay(250);
    flip = 1;
  }
  else if (flip == 1)
  {

    memset(&bbi2c, 0, sizeof(bbi2c));
  bbi2c.bWire = !BITBANG; // use bit bang, not wire library
  bbi2c.iSDA = 6;
  bbi2c.iSCL = 7;
  I2CInit(&bbi2c, 100000L);
  delay(100); // allow devices to power up
    delay(250);
    bmp.begin();
    tempN2 = bmp.readTemperature();
    presN2 = bmp.readPressure();
    // dwn2 = SHT2x.GetDewPoint();
    delay(250);
    flip = 2;
  }
  else if (flip == 2)
  {
    flip = 0;
    Serial.print("TEMPERATURA N1= ");
    Serial.print(tempN1);
    Serial.print("");
    Serial.print("Press N1= ");
    Serial.print(presN1);
    Serial.print("");
    Serial.print("||||");

    Serial.print("TEMPERATURA N2= ");
    Serial.print(tempN2);
    Serial.print("");
    Serial.print("pressure N2= ");
    Serial.print(presN2);
    Serial.print("");
    Serial.print("||||");


    delay(5000);
  }
}

void loop() {
 bmp180read();
}

this code does compile but it doesn't show the right values can someone tell me what i did wrong

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.