BMP180 absolute pressure reading twice as low as it should.

I spent a good part of the day trying to figure out why it wouldn't show a change in altitude despite the temperature and pressure seemingly working fine. It turns out, my absolute pressure was reading so low that it was calculating the sea-level pressure to be 615mb, it should be between 900 and 1050mb. So even a change of about 20 meters was not enough to register any change in the calculated altitude.

My absolute pressure reads about 570mb. I looked it up and for my elevation of about 1,742 ft, or 531m, my absolute pressure should be 1015mb. Everything else works fine, using other conversions, it reads that I should be at about 18,000 feet, which is correct for 570mb.

Is my module just bad? Could I have damaged it trying to solder it? (I am a noob and it was kind of hard). Or there a reason for this?

//Altimeter stuff
#include <SFE_BMP180.h>
#include <Wire.h>
SFE_BMP180 pressure;
#define ALTITUDE 531

//SD card stuff
#include <SD.h>
#include <SPI.h>
File myFile;
int pinCS = 10; 

void setup() 
{
  Serial.begin(9600);  
  if (pressure.begin())
    Serial.println("BMP180 init success");
    else
    {
    Serial.println("BMP180 init fail\n\n");
    while(1); // Pause forever.
    }

    //SD CARD 
  pinMode(pinCS, OUTPUT);
  // SD Card Initialization
  if (SD.begin()){
    Serial.println("SD card is ready to use.");
  } else{
    Serial.println("SD card initialization failed");
    return;
  }

  if(SD.exists("Altitude.txt")){
   SD.remove("Altitude.txt");
}
}

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

status = pressure.startTemperature();
status = pressure.getTemperature(T);
status = pressure.startPressure(3); 
status = pressure.getPressure(P,T);





p0 = pressure.sealevel(P,a); 
a = pressure.altitude(P,1013.25);

Serial.println(P);

//SD CARD
myFile = SD.open("Altitude.txt", FILE_WRITE);

    // if the file opened okay, write to it:
  if (myFile) {

    //another formula for alitude
    float aa = P/1013.25;
    float b = pow(aa,0.190284);
    float c = 1-b;
    float Altitude = 145366.45*c;

    
    myFile.println(a);
    Serial.println(a);
    myFile.close();
    delay(500);
  }
  else 
  {
    Serial.println("error opening test.txt");
  }
}

I've not used the BMP180 but have been testing the BME280 alot and I assume the pressure portion of the device is similar.
I've had not issues with pressure. Actually I have two running side by side and they are scary consistent and nearly identical for pressure.

I'll assume the library is correct (unless you tweaked it). Perhaps the vent hole is blocked?

Is the sensor getting the correct voltage? This is a 3.3v device. Most breakout boards have a 5V to 3.3v conversion capability but I don't know what you have.

I looked it up and for my elevation of about 1,742 ft, or 531m, my absolute pressure should be 1015mb.

Your "absolute pressure" is whatever a calibrated barometer indicates.

Are you confusing that with the "sea level pressure" or P0, which is used as the reference pressure for altitude calculations?

If the sea level pressure P0 is 1015 mB, then at altitude 531 m, you would expect a correctly calibrated barometer to read 952.7 mB. However, most people correct the barometer reading to the sea level equivalent, as reported by airports and used by airplane pilots.

What is this line of code supposed to do?

a = pressure.altitude(P,1013.25);

JohnRob:
Is the sensor getting the correct voltage? This is a 3.3v device. Most breakout boards have a 5V to 3.3v conversion capability but I don't know what you have.

I already took it apart to return it, I think I might have been using 5V, though I did watch a tutorial of it so I would have followed everything he did. I looked at other reviews on Amazon and they notoriously read completely inaccuratly. I think you are lucky that yours work correctly. One review, a man bout ten of them, only 3 worked correctly, though most were only off by a bit, 10-20%. I ordered another one from a different brand so I will try and remember to tell you how it turns out and I will use the 3.3V pin this time :slight_smile: thanks

jremington:
Your "absolute pressure" is whatever a calibrated barometer indicates.

Are you confusing that with the "sea level pressure" or P0, which is used as the reference pressure for altitude calculations?

If the sea level pressure P0 is 1015 mB, then at altitude 531 m, you would expect a correctly calibrated barometer to read 952.7 mB. However, most people correct the barometer reading to the sea level equivalent, as reported by airports and used by airplane pilots.

What is this line of code supposed to do?

a = pressure.altitude(P,1013.25);

No, the absolute pressure is the direct pressure reading from the surroundings. Which is "P" in the code. It reads about 560mb, should have been around 1000, like you said. Instead of using the calculated sea-level I am using the direct average sea level pressure in millibars, which is 1013.25. I did this in a troubleshooting effort and haven't changed it.

That line of code was what was originally taking the pressure reading and converting it to altitude in the library. At first I thought this was what was wrong, so i looked up the formula and did it myself in the code, I got the same result, which was no altitude change even after like 20 meters. What i eventually found out was that my altitude wasn't changing because my pressure was reading so low, that it was calculating sea level to be 600mb, which was throwing off the equation. Then when using the direct average sea level pressure, it read that I was at 18,000 feet, which would be correct for 560mb. I finally just looked up what my pressure should be at the altitude I live at lol

No, the absolute pressure is the direct pressure reading from the surroundings.

Correct, when using a calibrated barometer (calibrated absolute pressure sensor). Yours is not calibrated, but the datasheet will tell you the expected maximum error.

The following line of code is extremely likely to be wrong, because it is extremely unlikely that the current sea level pressure is 1013.25 mB. To use this function correctly, replace 1013.25 with the best estimate of the current sea level pressure P0, (which can change dramatically over one hour), or use the known altitude to calculate P0.

a = pressure.altitude(P,1013.25);

It is possible that your sensor is defective, but it also is clear that you misunderstand how to use the library.

Try the example given with the library . If that reads correct you know the problem is not with the sensor

jremington:
Correct, when using a calibrated barometer (calibrated absolute pressure sensor). Yours is not calibrated, but the datasheet will tell you the expected maximum error.

The following line of code is extremely likely to be wrong, because it is extremely unlikely that the current sea level pressure is 1013.25 mB. To use this function correctly, replace 1013.25 with the best estimate of the current sea level pressure P0, (which can change dramatically over one hour), or use the known altitude to calculate P0.

a = pressure.altitude(P,1013.25);

It is possible that your sensor is defective, but it also is clear that you misunderstand how to use the library.

Yes, 1013.25 is only an average, but it still gave me an approximate, not literally multitudes off from the actual pressure. I got a new BMP180 but the problem was in the code, which I got from a tutorial. The baseline reading was updating with the absolute pressure, which explains why it read no altitude change. Obviously, you need to establish the baseline in the setup, it is useless in the loop. This may have been the entire problem and the sensor I returned might have been fine but who knows, who cares. It works now, that's all that matters. Thanks.