Go to most recent revision | Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1993 | - | 1 | // BMP085_test1 |
2 | // by Filipe Vieira |
||
3 | // Simple test of BMP085 output using default settings. |
||
4 | // This example requires AUTO_UPDATE_TEMPERATURE to be true in bmp085.h otherwise temperature will not update. |
||
5 | // IMPORTANT!! To get correct values you MUST CHANGE init() parameters, in |
||
6 | // this example I've set 250m based on GPS data for my location. |
||
7 | |||
8 | #include <Wire.h> |
||
9 | #include <BMP085.h> |
||
10 | |||
11 | BMP085 dps = BMP085(); // Digital Pressure Sensor |
||
12 | |||
13 | long Temperature = 0, Pressure = 0, Altitude = 0; |
||
14 | |||
15 | void setup(void) { |
||
16 | Serial.begin(9600); |
||
17 | Wire.begin(); |
||
18 | delay(1000); |
||
19 | |||
20 | // uncomment for different initialization settings |
||
21 | //dps.init(); // QFE (Field Elevation above ground level) is set to 0 meters. |
||
22 | // same as init(MODE_STANDARD, 0, true); |
||
23 | |||
24 | //dps.init(MODE_STANDARD, 101850, false); // 101850Pa = 1018.50hPa, false = using Pa units |
||
25 | // this initialization is useful for normalizing pressure to specific datum. |
||
26 | // OR setting current local hPa information from a weather station/local airport (QNH). |
||
27 | |||
28 | dps.init(MODE_ULTRA_HIGHRES, 25000, true); // 250 meters, true = using meter units |
||
29 | // this initialization is useful if current altitude is known, |
||
30 | // pressure will be calculated based on TruePressure and known altitude. |
||
31 | |||
32 | // note: use zeroCal only after initialization. |
||
33 | // dps.zeroCal(101800, 0); // set zero point |
||
34 | } |
||
35 | |||
36 | void loop(void) { |
||
37 | dps.getPressure(&Pressure); |
||
38 | dps.getAltitude(&Altitude); |
||
39 | |||
40 | Serial.print(" Alt(cm):"); |
||
41 | Serial.print(Altitude); |
||
42 | Serial.print(" Pressure(Pa):"); |
||
43 | Serial.println(Pressure); |
||
44 | } |