![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Example program to use BMP085
Fork of Barometer-Example by
main.cpp@1:9194c7303ad5, 2017-01-24 (annotated)
- Committer:
- abouillot
- Date:
- Tue Jan 24 10:37:19 2017 +0000
- Revision:
- 1:9194c7303ad5
- Parent:
- 0:bcb1988de877
BMP085 example program for Nucleo mbed - tested on L152RE
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
asmellby | 0:bcb1988de877 | 1 | #include "BMP085.h" |
asmellby | 0:bcb1988de877 | 2 | |
asmellby | 0:bcb1988de877 | 3 | LowPowerTicker ticker; |
asmellby | 0:bcb1988de877 | 4 | |
asmellby | 0:bcb1988de877 | 5 | bool do_measurement = false; |
asmellby | 0:bcb1988de877 | 6 | void measurement() { |
asmellby | 0:bcb1988de877 | 7 | do_measurement = true; |
asmellby | 0:bcb1988de877 | 8 | } |
asmellby | 0:bcb1988de877 | 9 | |
asmellby | 0:bcb1988de877 | 10 | int main() { |
abouillot | 1:9194c7303ad5 | 11 | BMP085 sensor(D14, D15, BMP085_MODE_HIGH_RESOLUTION); |
asmellby | 0:bcb1988de877 | 12 | ticker.attach(&measurement, 0.4); |
asmellby | 0:bcb1988de877 | 13 | |
asmellby | 0:bcb1988de877 | 14 | while(1) { |
asmellby | 0:bcb1988de877 | 15 | sleep(); |
asmellby | 0:bcb1988de877 | 16 | if(do_measurement) { |
asmellby | 0:bcb1988de877 | 17 | do_measurement = false; |
asmellby | 0:bcb1988de877 | 18 | sensor.measure(); |
asmellby | 0:bcb1988de877 | 19 | printf("T: %6.2f, P: %6.4f\r\n ", sensor.get_temperature(), sensor.get_pressure()); |
asmellby | 0:bcb1988de877 | 20 | } |
asmellby | 0:bcb1988de877 | 21 | } |
asmellby | 0:bcb1988de877 | 22 | } |