Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5

How to get the sea level pressure with BMP280?
#1

Hello, I know that my question it isnt't related to the weatherduino pro 2, but thats why I'm writing this message on General Discussion.  I'm begginer with arduino, and I'm also trying to set up a weather station with him. 

So, firstly, I'm picking the sensors and programming them on the Arduino. One of the sensors that I had chose was the BMP280 (adafruit version) - (https://learn.adafruit.com/adafruit-bmp2...g-and-test)

"But there's a problem"...

I have the arduino's programation code for this sensor, but with this code I can only get a real(absolute) atmospheric pressure according my altitude, and not the sea level atmospheric pressure.

The actual sea level pressure in my location is 1022.57 hPa (according the closest weather station). I had put this value on my arduino code  "altimeter = bmp.readAltitude (1022.57)", and the pressure read by the sensor is 98766.37 Pa (987,66hPa). This pressure keeps being the absolute pressure and not the relative pressure (sea level pressure). 

What do I have to do in the programming code, to the sensor starts doing the compensation/conversion of the absolute pressure reading, to the sea level pressure? 

That is, what I have to do, to the sensor read sea level pressures values as the closest weather station? 

This is my arduino's code of BMP280:
CODE: SELECT ALL | TOGGLE FULL SIZE
Code:
#include <Wire.h>
#include "SPI.h" //Why? Because library supports SPI and I2C connection
#include <Adafruit_Sensor.h>
#include <Adafruit_BMP280.h>

//Setup connection of the sensor
Adafruit_BMP280 bmp; // I2C
/*//For SPI connection!
#define BMP_SCK 13
#define BMP_MISO 12
#define BMP_MOSI 11 
#define BMP_CS 10
//Adafruit_BMP280 bme(BMP_CS); // hardware SPI
//Adafruit_BMP280 bme(BMP_CS, BMP_MOSI, BMP_MISO,  BMP_SCK);
*/

//Variables
float pressure;   //To store the barometric pressure (Pa)
float temperature;  //To store the temperature (oC)
int altimeter;    //To store the altimeter (m) (you can also use it as a float variable)

void setup() {
  bmp.begin();    //Begin the sensor
    Serial.begin(9600); //Begin serial communication at 9600bps
    Serial.println("Adafruit BMP280 test:");
}

void loop() {
  //Read values from the sensor:
  pressure = bmp.readPressure();
  temperature = bmp.readTemperature();
  altimeter = bmp.readAltitude (1022.57); //Change the "1050.35" to your city current barrometric pressure
  
  //Print values to serial monitor:
  Serial.print(F("Pressure: "));
    Serial.print(pressure);
    Serial.print(" Pa");
    Serial.print("\t");
    Serial.print(("Temp: "));
    Serial.print(temperature);
    Serial.print(" oC");
  Serial.print("\t");
    Serial.print("Altimeter: ");
    Serial.print(altimeter); // this should be adjusted to your local forcase
    Serial.println(" m");
    
    delay(5000); //Update every 5 sec
}

These were some of the values I had got:
[Image: Nxm4WwN.png]
Thanks for your time, and I apologize my ignorance, and I also apologize for possible language errors.

L.V.
Ps: I also accept answers in Portuguese. 
Reply
#2

(01-05-2017, 20:00)Updraft Wrote:  I have the arduino's programation code for this sensor, but with this code I can only get a real(absolute) atmospheric pressure according my altitude, and not the sea level atmospheric pressure.
Hi,
You have to recalculate the pressure according to the formula:
Prel = Pabs + h/8.3

Prel is relative pressure (recalculating to the sea level) [hPa]
Pabs is absolute pressure at the messurement place/site [hPa]
h is altitude (height above sea level) [m]

This applies with sufficient accuracy to about 1000 m above sea level.

Best Regards
Zdenek

Brandys/L Weather
Reply
#3

(02-05-2017, 17:28)hornychz Wrote:  
(01-05-2017, 20:00)Updraft Wrote:  I have the arduino's programation code for this sensor, but with this code I can only get a real(absolute) atmospheric pressure according my altitude, and not the sea level atmospheric pressure.
Hi,
You have to recalculate the pressure according to the formula:
Prel = Pabs + h/8.3

Prel is relative pressure (recalculating to the sea level) [hPa]
Pabs is absolute pressure at the messurement place/site [hPa]
h is altitude (height above sea level) [m]

This applies with sufficient accuracy to about 1000 m above sea level.

Thank you so much for the help and the for the tip Big Grin . I'm going to try to implement this formula in the arduino's programming code of the BMP280.

As soon as I get results, I'll give you feedback.

Best regards, 
Lourenço V.
Reply
#4

(01-05-2017, 20:00)Updraft Wrote:  That is, what I have to do, to the sensor read sea level pressures values as the closest weather station?

Based on the code published by you, try the code bellow. Don't forget to introduce the elevation of you location.
I haven't tested it, its only intended to reply to your question "what I have to do..."

Code:
#include <Wire.h>
#include "SPI.h" //Why? Because library supports SPI and I2C connection
#include <Adafruit_Sensor.h>
#include <Adafruit_BMP280.h>

//Setup connection of the sensor
Adafruit_BMP280 bmp; // I2C
/*//For SPI connection!
#define BMP_SCK 13
#define BMP_MISO 12
#define BMP_MOSI 11
#define BMP_CS 10
//Adafruit_BMP280 bme(BMP_CS); // hardware SPI
//Adafruit_BMP280 bme(BMP_CS, BMP_MOSI, BMP_MISO,  BMP_SCK);
*/

//Variables
float pressure;       //To store the barometric pressure (Pa)
float temperature;    //To store the temperature (oC)
float SLpressure_mB;
int ELEVATION = 290;  //PUT HERE THE ELEVATION OF YOUR LOCATION IN METERS

void setup() {
  bmp.begin();    //Begin the sensor
    Serial.begin(9600); //Begin serial communication at 9600bps
    Serial.println("Equivalent Sea Level Pressure Test:");
}

void loop() {
  //Read values from the sensor:
  pressure = bmp.readPressure();
  temperature = bmp.readTemperature();
  SLpressure_mB = (((pressure * 100.0)/pow((1-((float)(ELEVATION))/44330), 5.255))/100.0)  
  //Print values to serial monitor:
  Serial.print(F("Pressure: "));
    Serial.print(pressure, 2);
    Serial.print(" Pa");
    Serial.print("\t");
    Serial.print(("Temp: "));
    Serial.print(temperature);
    Serial.print(" oC");
  Serial.print("\t");
    Serial.print("Equivalent Sea Level Pressure: ");
    Serial.print(SLpressure_mB, 2);
    Serial.println(" mB");
   
    delay(5000); //Update every 5 sec
}

Reply
#5

Thank you so much  for your help again, Werk_AG.

The code is working, but the pressure at sea level is being recorded with somewhat high values.

I leave an example, 101491.61mB should be approximately 1014.92mb.

I have been trying since Wednesday to change the mathematical formula to modify the decimal places, but I have not yet succeeded.

Could you give me a hint about the part of the code where the problem is?


Does it have to do with the conversion from Pa to mB?

I apologize my extreme ignorance. And thanks for your time and atention.

kind regards, L. V.

[Image: h9EXfXs.png]
Reply
#6

Hi,
Try to change your formula to:
Code:
SLpressure_mB = (((pressure)/pow((1-((float)(ELEVATION))/44330), 5.255))/100.0)
Good luck

Best Regards
Zdenek

Brandys/L Weather
Reply
#7

Thank you very much, hornichz! Big Grin  The problem is finally solved!
Reply
#8

(06-05-2017, 00:39)Updraft Wrote:  Thank you very much, hornichz! Big Grin  The problem is finally solved!

Cool

Best Regards
Zdenek

Brandys/L Weather
Reply
#9

(06-05-2017, 00:15)hornychz Wrote:  Hi,
Try to change your formula to:
Code:
SLpressure_mB = (((pressure)/pow((1-((float)(ELEVATION))/44330), 5.255))/100.0)
Good luck
Hi, can you please write this formula in plain mathematical form? I do not understand the C version. Thank you!
Reply
#10

Hi,

Welcome to the forum. The formula is on page 17 of the BMP 180 data sheet. 

It needs a power of 5.255 so you need a reasonable maths package, or a lookup table method if only a basic software language is available.

   

Cheers,  Alan.
Reply




Users browsing this thread: 1 Guest(s)