![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
demo program of BMP085 pressure sensor
main.cpp@3:ae2b8103e52b, 2012-11-09 (annotated)
- Committer:
- newk8600
- Date:
- Fri Nov 09 18:42:56 2012 +0000
- Revision:
- 3:ae2b8103e52b
- Parent:
- 2:8c00953d4755
little tweaks
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
tylerjw | 2:8c00953d4755 | 1 | /* |
newk8600 | 3:ae2b8103e52b | 2 | *@file main.cpp |
newk8600 | 3:ae2b8103e52b | 3 | * |
newk8600 | 3:ae2b8103e52b | 4 | * |
newk8600 | 3:ae2b8103e52b | 5 | * |
newk8600 | 3:ae2b8103e52b | 6 | * |
newk8600 | 3:ae2b8103e52b | 7 | * 1.8 - 3.6V (Vdd) |
newk8600 | 3:ae2b8103e52b | 8 | * 1.62 - 3.6 (Vddio) |
newk8600 | 3:ae2b8103e52b | 9 | * |
newk8600 | 3:ae2b8103e52b | 10 | * |
newk8600 | 3:ae2b8103e52b | 11 | *Altitude = 44330*(1-(p/p0)^(1/5.255)) |
newk8600 | 3:ae2b8103e52b | 12 | * set p0 to sealevel pressure |
newk8600 | 3:ae2b8103e52b | 13 | * delta p = 1hPa = 8.43m at sea level |
newk8600 | 3:ae2b8103e52b | 14 | * |
newk8600 | 3:ae2b8103e52b | 15 | */ |
tylerjw | 2:8c00953d4755 | 16 | |
tylerjw | 2:8c00953d4755 | 17 | /* |
newk8600 | 3:ae2b8103e52b | 18 | *Pinout: |
newk8600 | 3:ae2b8103e52b | 19 | *pin9 = SDA |
newk8600 | 3:ae2b8103e52b | 20 | *pin10 = SCL |
newk8600 | 3:ae2b8103e52b | 21 | *pin11 = XCLR (digital out; active low; Resets sensor) |
newk8600 | 3:ae2b8103e52b | 22 | *pin12 = EOC ("end of conversation"; signal when conversion finished) |
newk8600 | 3:ae2b8103e52b | 23 | * |
newk8600 | 3:ae2b8103e52b | 24 | */ |
tylerjw | 2:8c00953d4755 | 25 | |
tylerjw | 2:8c00953d4755 | 26 | #include "mbed.h" |
tylerjw | 2:8c00953d4755 | 27 | #include "BMP085.h" |
tylerjw | 2:8c00953d4755 | 28 | |
tylerjw | 2:8c00953d4755 | 29 | I2C i2c(p9, p10); // sda, scl |
tylerjw | 2:8c00953d4755 | 30 | BMP085 alt_sensor(i2c); |
tylerjw | 2:8c00953d4755 | 31 | Serial pc(USBTX, USBRX); // tx, rx |
tylerjw | 2:8c00953d4755 | 32 | |
tylerjw | 2:8c00953d4755 | 33 | |
tylerjw | 2:8c00953d4755 | 34 | int main() |
tylerjw | 2:8c00953d4755 | 35 | { |
tylerjw | 2:8c00953d4755 | 36 | pc.baud(9600); |
tylerjw | 2:8c00953d4755 | 37 | //alt_sensor.display_cal_param(&pc); |
newk8600 | 3:ae2b8103e52b | 38 | while(1) { |
tylerjw | 2:8c00953d4755 | 39 | pc.printf("Temperature: %d\r\n", alt_sensor.get_temperature()); |
tylerjw | 2:8c00953d4755 | 40 | pc.printf("Pressure: %d\r\n", alt_sensor.get_pressure()); |
tylerjw | 2:8c00953d4755 | 41 | pc.printf("Altitude: %f\r\n", alt_sensor.get_altitude_ft()); |
newk8600 | 3:ae2b8103e52b | 42 | |
tylerjw | 2:8c00953d4755 | 43 | wait(0.5); |
tylerjw | 2:8c00953d4755 | 44 | } |