Example program to use BMP085

Dependencies:   BMP085 mbed

Fork of Barometer-Example by silabs-abakurs

Committer:
asmellby
Date:
Sun Nov 15 18:05:54 2015 +0000
Revision:
0:bcb1988de877
Child:
1:9194c7303ad5
Barometer example.;

Who changed what in which revision?

UserRevisionLine numberNew 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() {
asmellby 0:bcb1988de877 11 BMP085 sensor(PD6, PD7, 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 }