mirror of
https://github.com/adafruit/Adafruit-BMP085-Library.git
synced 2026-09-22 18:36:51 +00:00
Example code
This commit is contained in:
1 parent
001d98a518
commit
299265e16d
1 file changed
+36
@@ -0,0 +1,36 @@
|
||||
#include <Wire.h>
|
||||
#include <BMP085.h>
|
||||
|
||||
BMP085 bmp;
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
bmp.begin();
|
||||
}
|
||||
|
||||
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");
|
||||
|
||||
// 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);
|
||||
}
|
||||
Reference in new issue
Block a user