Hi iam sending data from BMP180 to app Blynk. But data are not correct. Temp yes but another data no:Pressure = 96579 Pa
Altitude = 402.94 meters
in my city are : Pressure = : 1032.4 hPa
Altitude = 520 meters
I useing library Adafruit_BMP085… Thank you
Code:
#define BLYNK_PRINT Serial // Comment this out to disable prints and save space
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <SimpleTimer.h>
#include <DHT.h>
#include <Wire.h>
#include <Adafruit_BMP085.h>
#define DHTPIN 12 //pin gpio 12 in sensor
#define DHTTYPE DHT22 // DHT 22 Change this if you have a DHT11
DHT dht(DHTPIN, DHTTYPE);
// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "75a3e91cbdf18b35eea63e9c1"; // Put your Auth Token here. (see Step 3 above)
SimpleTimer timer;
#define I2C_SCL 12 // Barometric Pressure Sensor (BMP085)
#define I2C_SDA 13
Adafruit_BMP085 bmp;
float dst,bt,bp,ba;
char dstmp[20],btmp[20],bprs[20],balt[20];
bool bmp085_present=true;
void setup()
{
Serial.begin(9600); // See the connection status in Serial Monitor
Blynk.begin(auth, "ASUS", "Jersi2"); //insert here your SSID and password
Wire.begin(I2C_SDA, I2C_SCL);
delay(10);
if (!bmp.begin()) {
Serial.println("Could not find a valid BMP085 sensor, check wiring!");
while (1) {}
}
// Setup a function to be called every second
timer.setInterval(10000L, sendUptime);
}
void sendUptime()
{
// You can send any value at any time.
// Please don't send more that 10 values per second.
//Read the Temp and Humidity from DHT
float bp = bmp.readPressure();
Blynk.virtualWrite(10, bp); // virtual pin
float ba = bmp.readAltitude();
Blynk.virtualWrite(11, ba); // virtual pin
float bt = bmp.readTemperature();
Blynk.virtualWrite(12, bt); // virtual pin
float dst = bmp.readSealevelPressure();
Blynk.virtualWrite(13, dst); // virtual pin
}
void loop()
{
Serial.print("Temperature = ");
Serial.print(bmp.readTemperature());
Serial.println(" *C");
Serial.print("Pressure = ");
Serial.print(bmp.readPressure());
Serial.println(" Pa");
// Calculate altitude assuming 'standard' barometric
// pressure of 1013.25 millibar = 101325 Pascal
Serial.print("Altitude = ");
Serial.print(bmp.readAltitude());
Serial.println(" meters");
Serial.print("Pressure at sealevel (calculated) = ");
Serial.print(bmp.readSealevelPressure());
Serial.println(" Pa");
// you can get a more precise measurement of altitude
// if you know the current sea level pressure which will
// vary with weather and such. If it is 1015 millibars
// that is equal to 101500 Pascals.
Serial.print("Real altitude = ");
Serial.print(bmp.readAltitude(101500));
Serial.println(" meters");
Serial.println();
delay(500);
Blynk.run();
timer.run();
}
also please note, that because sea level pressure (which is given in meteo forecasts) is a two-unknown equation,you should pass your sealevel altitude as a known variable.
You can get either correct altitude (passing known sealevel pressure) OR correct sealevel pressure, NOT BOTH at the same time!
Alternatively you can read real pressure, which is not used in weather forecasting.
AND the best is (now I’ve noticed): You have it all in your quoted example! Just read on!
@Jiri_Bam you need to learn how your sensors work and how the required results are created. Google will have all the information you require but be sure to use a longtail keyphrase.
@Costas: no need to even Google this time: It’s all in quoted example - as a comments. The rest is an entry level school knowledge (I mean pressure - altitude dependency)
@Jiri_Bam: > I tryed : float ba = bmp.readAltitude()+117; or it is no good? thanks
Nope, it is NO good, because altitude=f(pressure) is a non linear function!
@Jiri_Bam if you study the regular Arduino example for a BMP180 you will see that an accurate altitude is arrived at by feeding the Pascal sea level pressure into the readAltitude function.
So you need to shuffle a couple of your functions in sendUptime and use result from one function in the next:
@Costas: it will NOT work correctly, because you are tryin’ to read Sealevel Pressure at unknown altitude! (function readSealevelPressure() without argument assumes altitude 0m), so You will be chasing Your own tail!.
As I’ve written before: You can’t get both unknowns from pressure sensor: You either need to pass altitude (to read Sealevel pressure), OR sea level reduced barometric pressure (to read REAL altitude) - and that is the way it is done in planes to read altitude - You HAVE to specify actual pressure.
So You have to read it as follows: float dst = bmp.readSealevelPressure(520)/100; float ba = bmp.readAltitude(dst*100);
Then it should give You correct altitude (which You had to specify earlier, btw)
@marvin7 I believe the formula for altitude is derived from the following equation with p0 as the average sealevel pressure (101325 Pa) and p is the pressure reading from the BMP180.
Presumably the libraries in the following Adafruit sketch take account of this formula and it indicates real altitude can be obtained simply with:
@Costas: No, no doubt about validity of Adafruit Lib&sketch. They are perfectly valid. Actually I had adapted their example for my needs during initial sensor testing and sorting (they are not perfect). The point is, as You can clearly see, that altitude calculation needs sea level pressure as a reference. And IF (but only IF) actual sea level pressure exactly equals ONE bar (i.e 1013hPa) THEN You will receive EXACTLY correct real altitude (taking into account sensor tolerance). In EVERY other case you should pass one of those (above) parameters to solve equation You posted. The three variables linked together are: altitude, p, and p0 (all other being constants). As only one equation we do have in this case, we HAVE to fill in missing value (or assume one as default)
To clarify my explanations: p0 is NOT constant, it is the reference pressure (the actual pressure reduced to sea level pressure). As only then we can compare pressure in different parts of the world (at different heights above sea level), it is the one used in weather forecast. And “build” weather maps
@marvin7 can we agree that p0 isn’t a constant but in the absence of knowing your altitude then it is taken as a constant to derive a very good approximation of your altitude based on the pressure sensor reading? Think this sounds better than your interpretation of needing to know your altitude so you can obtain a pressure reading to use in the calculation of altitude.
@Jiri_Bam it depends what purpose you have for the altitude data but if you are using it to fly a drone over mountains then using p0 as a constant is not recommended (without building in a large margin of error).
However if you just want to know how high you walked up a mountain today then it is fine.
https://www.sparkfun.com/tutorials/253 shows an approximate 1% deviation between Google Earth altitude for a known location (1580m) and the calculated altitude of 1600m using p0 as a constant.
Sure! Then library assumes 1013 as a default reference value, which might in some circumstances show your exact altitude.
I do hope, we explained very clearlyall aspects related to barometric pressure measurements ;)[quote=“Costas, post:14, topic:9843”]
it depends what purpose you have for the altitude data but if you are using it to fly a drone over mountains then using p0 as a constant is not recommended (without building in a large margin of error).
However if you just want to know how high you walked up a mountain today then it is fine
[/quote]
100% agree. For delta h (altitude difference) it should be very fine unless the difference is not too large (due to non linear curve). The last are my thoughts, as I have not checked it (but it seems logical)
Hi. Thank you for big answer. I try: float dst = bmp.readSealevelPressure(520)/100; bmp.readAltitude(101325); and:float ba = bmp.readAltitude(dst*100);
And presure now is good: 1033. But altitude still no good : 370.
Actually altitude is “good” too, but as you are passing a reference pressure as 1013 and the real pressure is 1033 (as you posted), then sensor ‘thinks’ it is on lower altitude than it IS. Observe your meteo office (or reading from sensor) and ‘catch’ the moment, when they show you 1013. THEN you should see that sensor ‘shows’ you the one, correct altitude. That is how it works.
Greets!
const float currentAltitude = 1580.08; // current altitude in METERS
const float ePressure = p0 * pow((1-currentAltitude/44330), 5.255); // expected pressure (in Pa) at altitude
float weatherDiff;
// Add this into loop(), after you've calculated the pressure
weatherDiff = pressure - ePressure;
if(weatherDiff > 250)
Serial.println("Sunny!");
else if ((weatherDiff <= 250) || (weatherDiff >= -250))
Serial.println("Partly Cloudy");
else if (weatherDiff > -250)
Serial.println("Rain :-(");
Serial.println();
because i need see it in LCD in blynk
#define BLYNK_PRINT Serial // Comment this out to disable prints and save space
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <SimpleTimer.h>
#include <DHT.h>
#include <SPI.h>
#include <Wire.h>
#include <Adafruit_BMP085.h>
#define DHTPIN 12 //pin gpio 12 in sensor
#define DHTTYPE DHT22 // DHT 22 Change this if you have a DHT11
DHT dht(DHTPIN, DHTTYPE);
// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "75a3e91cb498b35eea63e9c1"; // Put your Auth Token here. (see Step 3 above)
SimpleTimer timer;
#define I2C_SCL 12 // Barometric Pressure Sensor (BMP085)
#define I2C_SDA 13
Adafruit_BMP085 bmp;
float dst,bt,bp,ba;
char dstmp[20],btmp[20],bprs[20],balt[20];
const float currentAltitude = 1580.08; // current altitude in METERS
const float ePressure = p0 * pow((1-currentAltitude/44330), 5.255); // expected pressure (in Pa) at altitude
float weatherDiff;
void setup()
{
Serial.begin(9600); // See the connection status in Serial Monitor
Blynk.begin(auth, "ASUS", "Jersin72"); //insert here your SSID and password
Wire.begin(I2C_SDA, I2C_SCL);
delay(10);
if (!bmp.begin()) {
Serial.println("Could not find a valid BMP085 sensor, check wiring!");
while (1) {}
}
// Setup a function to be called every second
timer.setInterval(10000L, sendUptime);
}
void sendUptime()
{
// You can send any value at any time.
// Please don't send more that 10 values per second.
//Read the Temp and Humidity from DHT
float bp = bmp.readPressure()/100; // děleni 100
Blynk.virtualWrite(10, bp); // virtual pin
float ba = bmp.readAltitude(10132);
Blynk.virtualWrite(11, ba); // virtual pin
float bt = bmp.readTemperature();
Blynk.virtualWrite(12, bt); // virtual pin
float dst = bmp.readSealevelPressure(520)/100;
Blynk.virtualWrite(13, dst); // virtual pin
weatherDiff = pressure - ePressure;
if(weatherDiff > 250)
Serial.println("Sunny!");
else if ((weatherDiff <= 250) || (weatherDiff >= -250))
Serial.println("Partly Cloudy");
else if (weatherDiff > -250)
Serial.println("Rain :-(");
Serial.println();
}
void loop()
{
Blynk.run();
timer.run();
}