Subversion Repositories FlightCtrl

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
1993 - 1
// BMP085_test2
2
// by Filipe Vieira
3
// Simple test of BMP085 output using default settings using dynamic update.
4
// In order to take full advantage of dynamic measurement, automatic temperature updates must be disabled.
5
// To disable automatic updates set AUTO_UPDATE_TEMPERATURE to false in bmp085.h.
6
// IMPORTANT!! To get correct values you MUST CHANGE init() parameters, in
7
// this example I've set 250m based on GPS data for my location.
8
 
9
#include <Wire.h>
10
#include <BMP085.h>
11
 
12
BMP085 dps = BMP085();      // Digital Pressure Sensor
13
 
14
long Pressure = 0, Altitude = 0;
15
unsigned long time1=0;
16
 
17
void setup(void) {
18
  Serial.begin(9600);
19
  Wire.begin();
20
  delay(1000);
21
 
22
  // uncomment for different initialization settings
23
  //dps.init();     // QFE (Field Elevation above ground level) is set to 0 meters.
24
                  // same as init(MODE_STANDARD, 0, true);
25
 
26
  //dps.init(MODE_STANDARD, 101850, false);  // 101850Pa = 1018.50hPa, false = using Pa units
27
                  // this initialization is useful for normalizing pressure to specific datum.
28
                  // OR setting current local hPa information from a weather station/local airport (QNH).
29
 
30
  dps.init(MODE_STANDARD, 25000, true);  // 250 meters, true = using meter units
31
                  // this initialization is useful if current altitude is known,
32
                  // pressure will be calculated based on TruePressure and known altitude.
33
 
34
  // note: use zeroCal only after initialization.
35
  // dps.zeroCal(101800, 0);    // set zero point
36
}
37
 
38
void loop(void) {
39
  // calculate temperature every 1 sec (dynamic measurement)
40
  // NOTE: in order to take full advantage of dynamic measurement set AUTO_UPDATE_TEMPERATURE to false in bmp085.h
41
  if (((millis() - time1)/1000.0) >= 1.0) {
42
     dps.calcTrueTemperature();
43
     time1 = millis();
44
  }
45
 
46
  dps.getPressure(&Pressure);
47
  dps.getAltitude(&Altitude);
48
 
49
  Serial.print("  Alt(cm):");
50
  Serial.print(Altitude);
51
  Serial.print("  Pressure(Pa):");
52
  Serial.println(Pressure);
53
}