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

How to get the sea level pressure with BMP280?
#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


Messages In This Thread



Users browsing this thread: 1 Guest(s)