Seeed
/
Seeed_Barometer_Sensor_Example
Example using barometer
main.cpp@0:8381ff08ace1, 2014-08-16 (annotated)
- Committer:
- sam_grove
- Date:
- Sat Aug 16 01:03:36 2014 +0000
- Revision:
- 0:8381ff08ace1
Initial commit
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
sam_grove | 0:8381ff08ace1 | 1 | |
sam_grove | 0:8381ff08ace1 | 2 | #include "mbed.h" |
sam_grove | 0:8381ff08ace1 | 3 | #include "BMP085.h" |
sam_grove | 0:8381ff08ace1 | 4 | |
sam_grove | 0:8381ff08ace1 | 5 | BMP085 barometer(D14, D15); |
sam_grove | 0:8381ff08ace1 | 6 | |
sam_grove | 0:8381ff08ace1 | 7 | int main(void) |
sam_grove | 0:8381ff08ace1 | 8 | { |
sam_grove | 0:8381ff08ace1 | 9 | float p = 0.0f, t = 0.0f; |
sam_grove | 0:8381ff08ace1 | 10 | |
sam_grove | 0:8381ff08ace1 | 11 | while(1) { |
sam_grove | 0:8381ff08ace1 | 12 | barometer.update(); |
sam_grove | 0:8381ff08ace1 | 13 | p = barometer.get_pressure(); |
sam_grove | 0:8381ff08ace1 | 14 | t = barometer.get_temperature(); |
sam_grove | 0:8381ff08ace1 | 15 | printf("Pressure: %6.2f Temperature(c): %6.2f Temperature(F): %6.2f\n", p, t, 32 + t * 1.8f); |
sam_grove | 0:8381ff08ace1 | 16 | wait(1.0f); |
sam_grove | 0:8381ff08ace1 | 17 | } |
sam_grove | 0:8381ff08ace1 | 18 | } |