How can I add 2 pressure sensors BMP180 to Arduino Uno?

If I want to connect 2 pressure sensors at the same time, to which Analog pins the second one should be connected?any single pressure sensors can be connected via 4 wires to GND, +3.3 v, A4 and A5 pins in Arduino.

which changed should be done in the program to read pressure from 2 sensors simultaneousely? this is the code:

#include <SFE_BMP180.h>
#include <Wire.h>
 
SFE_BMP180 pressure;
void setup()
{
  Serial.begin(9600);
  Serial.println("REBOOT");
  if (pressure.begin())
    Serial.println("BMP180 init success");
  else
  {
    Serial.println("BMP180 init fail\n\n");
    while(1); // Pause forever.
  }
}
 
void loop()
{
  char status;
  double T,P,p0,a;
  Serial.println();
  
  status = pressure.startTemperature();
  if (status != 0)
  {
      delay(status);
  status = pressure.getTemperature(T);
    if (status != 0)
    {
      Serial.print("temperature: ");
      Serial.print(T,2);
      Serial.print(" deg C, ");
      status = pressure.startPressure(3);
      if (status != 0)
      {
        delay(status);
 
        status = pressure.getPressure(P,T);
        if (status != 0)
        {
          Serial.print("absolute pressure: ");
          Serial.print(P,2);
          Serial.print(" mb, ");
          
        }
        else Serial.println("error retrieving pressure measurement\n");
      }
      else Serial.println("error starting pressure measurement\n");
    }
    else Serial.println("error retrieving temperature measurement\n");
  }
  else Serial.println("error starting temperature measurement\n");
 
  delay(1000);  // Pause for 1 seconds

Is there any one to answer me? or at least tell me what is this face sign beside the post!!

Hi there

The BMP180 connects to the Arduino over the I2C bus.

Typically, I2C devices have a way to configure different addresses, so you can connect them in parallel to the Arduino I2C pins and use software to select which one you want to talk to at any particular time.

However, the BMP180 has a fixed I2C address, so just connecting two in parallel would cause a clash.

There was an earlier thread about connecting similar Bosch pressure sensors: Connecting multiple I2C devices - Sensors - Arduino Forum

Regards

Ray

Thanks for answer.
I read the suggested discussion page. So, I need to have a multiplexer like : DssCircuits.com is for sale | HugeDomains
right?
I will buy and try to connect sensors and Arduino to that.

You will also need to add some code to your Arduino program to select the right mux channel before you write to or read from each pressure sensor. This is done by sending data over I2C to the mux itself.

On the web page that you posted, there is some information in the comments section. They are written for Raspberry Pi but you should be able to see the byte sequnces needed if you look at it in conjunction with the mux datasheet.

All the best

Ray

Hi,

Thanks for answer!

There is an issue here, I found this page Arduino Playground - SoftwareI2CLibrary
I wanna know if I understood correctly that I need to download that zip code, softI2C.zip, https://github.com/felias-fogg/SoftI2CMasterto define new I2C pins in Arduino. Then I can connect one BMP180 to the A4 and A5 pins, and connect the second one to the new defined pins. Bus I just need to put two SFE_BMP180 libraries in the main library.
the question is, how can I have two times SFE_BMP180 Library in one folder? I mean is it enough to change the name of folder and call it in the main program? or I need to change the address of I2C in the one for newly defined SDA and SCL as well?
What else I need to consider or change?

Regards,
Maryam

Bus I just need to put two SFE_BMP180 libraries in the main library.

Why do you think that?
You only need to have one instance of the software I2C bus for the second sensor and use the hardware bus for the first.

I downloaded zip code, softI2C.zip, https://github.com/felias-fogg/SoftI2CMasterto define new I2C pins in Arduino.
the problem is it just contains header file of I2Cmaster and not .cpp file. I need .cpp format to call it in mail program.
where can I find the .cpp format?

because I cannot call I2CMaster in program from library, I coppied the code in the main program, and defined the pins for SDA and SCL.

when I run the program , I have this message:
REBOOT
BMP180 init fail

please tell me what should I do?

please tell me what should I do?

Advice.mp3 (3.52 MB)

I asked for some tips and helps not musik for sure!

If you listen to the words it says
POST YOUR CODE

To be fair, Mike, the vocals are a bit swamped by the piano. ]:smiley:

I want to use a software I2C library to create a second I2C bus on a free pair of pins. I could then put one BMP180 on the original hardware bus, and the second BMP180 on the new software bus. Here is one such library, there may be more: Arduino Playground - SoftwareI2CLibrary .

my I2CMaster library is placed in Documents\Arduino\libraries\i2cmaster
When I call it as header file in the program, the program does not consider it as a header.

#include <SFE_BMP180.h>
#include <Wire.h>
#define SCL_PIN 2 
#define SCL_PORT PORTD 
#define SDA_PIN 0 
#define SDA_PORT PORTC 
#include<i2cmaster.h>

SFE_BMP180 pressure;

#define ALTITUDE 1655.0 // Altitude of SparkFun's HQ in Boulder, CO. in meters

void setup()
{
  Serial.begin(9600);
  Serial.println("REBOOT");

  // Initialize the sensor (it is important to get calibration values stored on the device).

  if (pressure.begin())
    Serial.println("BMP180 init success");
  else
  {
    // Oops, something went wrong, this is usually a connection problem,
    // see the comments at the top of this sketch for the proper connections.

    Serial.println("BMP180 init fail\n\n");
    while(1); // Pause forever.
  }
}

void loop()
{
  char status;
  double T,P,p0,a;

  // Loop here getting pressure readings every 10 seconds.

  // If you want sea-level-compensated pressure, as used in weather reports,
  // you will need to know the altitude at which your measurements are taken.
  // We're using a constant called ALTITUDE in this sketch:
  
  Serial.println();
  Serial.print("provided altitude: ");
  Serial.print(ALTITUDE,0);
  Serial.print(" meters, ");
  Serial.print(ALTITUDE*3.28084,0);
  Serial.println(" feet");
  
  // If you want to measure altitude, and not pressure, you will instead need
  // to provide a known baseline pressure. This is shown at the end of the sketch.

  // You must first get a temperature measurement to perform a pressure reading.
  
  // Start a temperature measurement:
  // If request is successful, the number of ms to wait is returned.
  // If request is unsuccessful, 0 is returned.

  status = pressure.startTemperature();
  if (status != 0)
  {
    // Wait for the measurement to complete:
    delay(status);

    // Retrieve the completed temperature measurement:
    // Note that the measurement is stored in the variable T.
    // Function returns 1 if successful, 0 if failure.

    status = pressure.getTemperature(T);
    if (status != 0)
    {
      // Print out the measurement:
      Serial.print("temperature: ");
      Serial.print(T,2);
      Serial.print(" deg C, ");
      Serial.print((9.0/5.0)*T+32.0,2);
      Serial.println(" deg F");
      
      // Start a pressure measurement:
      // The parameter is the oversampling setting, from 0 to 3 (highest res, longest wait).
      // If request is successful, the number of ms to wait is returned.
      // If request is unsuccessful, 0 is returned.

      status = pressure.startPressure(3);
      if (status != 0)
      {
        // Wait for the measurement to complete:
        delay(status);

        // Retrieve the completed pressure measurement:
        // Note that the measurement is stored in the variable P.
        // Note also that the function requires the previous temperature measurement (T).
        // (If temperature is stable, you can do one temperature measurement for a number of pressure measurements.)
        // Function returns 1 if successful, 0 if failure.

        status = pressure.getPressure(P,T);
        if (status != 0)
        {
          // Print out the measurement:
          Serial.print("absolute pressure: ");
          Serial.print(P,2);
          Serial.print(" mb, ");
          Serial.print(P*0.0295333727,2);
          Serial.println(" inHg");

          // The pressure sensor returns abolute pressure, which varies with altitude.
          // To remove the effects of altitude, use the sealevel function and your current altitude.
          // This number is commonly used in weather reports.
          // Parameters: P = absolute pressure in mb, ALTITUDE = current altitude in m.
          // Result: p0 = sea-level compensated pressure in mb

          p0 = pressure.sealevel(P,ALTITUDE); // we're at 1655 meters (Boulder, CO)
          Serial.print("relative (sea-level) pressure: ");
          Serial.print(p0,2);
          Serial.print(" mb, ");
          Serial.print(p0*0.0295333727,2);
          Serial.println(" inHg");

          // On the other hand, if you want to determine your altitude from the pressure reading,
          // use the altitude function along with a baseline pressure (sea-level or other).
          // Parameters: P = absolute pressure in mb, p0 = baseline pressure in mb.
          // Result: a = altitude in m.

          a = pressure.altitude(P,p0);
          Serial.print("computed altitude: ");
          Serial.print(a,0);
          Serial.print(" meters, ");
          Serial.print(a*3.28084,0);
          Serial.println(" feet");
        }
        else Serial.println("error retrieving pressure measurement\n");
      }
      else Serial.println("error starting pressure measurement\n");
    }
    else Serial.println("error retrieving temperature measurement\n");
  }
  else Serial.println("error starting temperature measurement\n");

  delay(5000);  // Pause for 5 seconds.
}

when I connect BMP180 to the new defined I2C pins, I dont get any pressure reading by that.

Grumpy_Mike:
Advice.mp3

Effing brilliant! (Someone please remix it so the vocals are more distinct!)

when I connect BMP180 to the new defined I2C pins, I dont get any pressure reading by that.

Have you put pull up resistors on your new I2C pins?

my I2CMaster library is placed in Documents\Arduino\libraries\i2cmaster
When I call it as header file in the program, the program does not consider it as a header.

What do you mean by this? If it is not considered a file then it won't compile and therefore how do you know you don't get any readings?

You know that library uses the hardware I2C pins, so you are going to have to access the one on the soft I2C bus with your own code.

OK done a remix and replaced the file above with the new one.

about the pull up resistors, I tried with and witout. the point is there is not any new defined I2C. So does not matter if I put that resistors or not. Or it does matter and I do not know!

That I2CMaster is not read in the program, because when I wite # include <wire.h> this Wire s in orange color. but when I write #include <i2cMaster.h>, it is still black. because it does not considered as a header.

Question: If this command of #include <i2cMaster.h> really defined a new couple of I2C pins, and I did not use resistors, what may happened?
Question: is 4.7 kohm is enough for pull up resistors? how should I put it?

Thanks for time to answer!

the point is there is not any new defined I2C. So does not matter if I put that resistors or not. Or it does matter and I do not know!

Not sure I understand those words. You always need one set of pull up resistors on each I2C bus.

it is still black. because it does not considered as a header.

No it is still black because someone did not put in the line in the keywords.txt file that makes it change colour, that is all.

Question: If this command of #include <i2cMaster.h> really defined a new couple of I2C pins, and I did not use resistors, what may happened?

Then it would not work.

Question: is 4.7 kohm is enough for pull up resistors? how should I put it?

Yes, wire them from signal to +5V.

You always need one set of pull up resistors on each I2C bus.

I dont think always! at lease for pins A4 and A5, as you can see here:
https://learn.sparkfun.com/tutorials/bmp180-barometric-pressure-sensor-hookup-/all

what does

put in the line in the keywords.txt file

mean?

I dont think always!

I do.
If you look at the schematic for the breakout board, you'll see that it has pullups fitted.
If you put more than one device on this I2C bus, and it has pullups fitted, you'll need to disable one set.